From 183b3310c233b2f00c580dc2f2fdb6771bc5dfd8 Mon Sep 17 00:00:00 2001 From: David Golding Date: Tue, 12 May 2026 17:22:46 -0600 Subject: [PATCH] fix: Improving official plugin review recommendations The new community.obsidian.md portal for publishing plugins includes a review mechanism that presents recommendations and warnings to end-users about the plugin's implementation. This commit attempts to pass review warnings. --- .github/workflows/release.yml | 48 + .gitignore | 2 +- README.md | 2 +- main.js | 217 +++-- manifest.json | 2 +- package.json | 42 +- pnpm-lock.yaml | 1656 +++++++++++++++++++++++++++++++++ src/minimal-docx.js | 29 +- styles.css | 91 +- 9 files changed, 1884 insertions(+), 205 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 pnpm-lock.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2af58fa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release +on: + push: + tags: + - '*' + +permissions: + contents: write + id-token: write + attestations: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v3 + with: + version: 10 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Attest build provenance + uses: actions/attest-build-provenance@v1 + with: + subject-path: | + main.js + styles.css + manifest.json + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: | + main.js + manifest.json + styles.css diff --git a/.gitignore b/.gitignore index ab337ba..5f272a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .hotreload node_modules/ -pnpm-lock.yaml pnpm-workspace.yaml .DS_Store .vscode @@ -9,3 +8,4 @@ pnpm-workspace.yaml /docs skills-lock.json /.agent +/.agents diff --git a/README.md b/README.md index cebd2d8..e310efb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

Colophon 2.0

+

Colophon

Long-form writing canvas for Obsidian

Colophon provides a dedicated, typographically refined environment for writing manuscripts and screenplays. Unlike standard Markdown editors, Colophon uses a custom editor engine (Tiptap/ProseMirror) and a dedicated file format to ensure your formatting, footnotes, and script standards are preserved exactly as you intended. diff --git a/main.js b/main.js index 569857c..08cdcd6 100644 --- a/main.js +++ b/main.js @@ -1,31 +1,30 @@ -var Ow=Object.create;var Ls=Object.defineProperty;var Iw=Object.getOwnPropertyDescriptor;var Dw=Object.getOwnPropertyNames;var Rw=Object.getPrototypeOf,Pw=Object.prototype.hasOwnProperty;var M=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lw=(t,e)=>{for(var n in e)Ls(t,n,{get:e[n],enumerable:!0})},Bf=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Dw(e))!Pw.call(t,i)&&i!==n&&Ls(t,i,{get:()=>e[i],enumerable:!(r=Iw(e,i))||r.enumerable});return t};var si=(t,e,n)=>(n=t!=null?Ow(Rw(t)):{},Bf(e||!t||!t.__esModule?Ls(n,"default",{value:t,enumerable:!0}):n,t)),Bw=t=>Bf(Ls({},"__esModule",{value:!0}),t);var Bi=M((dR,du)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?du.exports={nextTick:VC}:du.exports=process;function VC(t,e,n,r){if(typeof t!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,s,o;switch(i){case 0:case 1:return process.nextTick(t);case 2:return process.nextTick(function(){t.call(null,e)});case 3:return process.nextTick(function(){t.call(null,e,n)});case 4:return process.nextTick(function(){t.call(null,e,n,r)});default:for(s=new Array(i-1),o=0;o{var UC={}.toString;Ag.exports=Array.isArray||function(t){return UC.call(t)=="[object Array]"}});var fu=M((hR,_g)=>{_g.exports=require("stream")});var zi=M((hu,Og)=>{var Do=require("buffer"),Ht=Do.Buffer;function Ng(t,e){for(var n in t)e[n]=t[n]}Ht.from&&Ht.alloc&&Ht.allocUnsafe&&Ht.allocUnsafeSlow?Og.exports=Do:(Ng(Do,hu),hu.Buffer=Cr);function Cr(t,e,n){return Ht(t,e,n)}Ng(Ht,Cr);Cr.from=function(t,e,n){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Ht(t,e,n)};Cr.alloc=function(t,e,n){if(typeof t!="number")throw new TypeError("Argument must be a number");var r=Ht(t);return e!==void 0?typeof n=="string"?r.fill(e,n):r.fill(e):r.fill(0),r};Cr.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ht(t)};Cr.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Do.SlowBuffer(t)}});var Er=M(Ne=>{function WC(t){return Array.isArray?Array.isArray(t):Ro(t)==="[object Array]"}Ne.isArray=WC;function jC(t){return typeof t=="boolean"}Ne.isBoolean=jC;function qC(t){return t===null}Ne.isNull=qC;function KC(t){return t==null}Ne.isNullOrUndefined=KC;function JC(t){return typeof t=="number"}Ne.isNumber=JC;function ZC(t){return typeof t=="string"}Ne.isString=ZC;function XC(t){return typeof t=="symbol"}Ne.isSymbol=XC;function GC(t){return t===void 0}Ne.isUndefined=GC;function YC(t){return Ro(t)==="[object RegExp]"}Ne.isRegExp=YC;function QC(t){return typeof t=="object"&&t!==null}Ne.isObject=QC;function eE(t){return Ro(t)==="[object Date]"}Ne.isDate=eE;function tE(t){return Ro(t)==="[object Error]"||t instanceof Error}Ne.isError=tE;function nE(t){return typeof t=="function"}Ne.isFunction=nE;function rE(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||typeof t>"u"}Ne.isPrimitive=rE;Ne.isBuffer=require("buffer").Buffer.isBuffer;function Ro(t){return Object.prototype.toString.call(t)}});var Ig=M((mR,pu)=>{typeof Object.create=="function"?pu.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:pu.exports=function(e,n){if(n){e.super_=n;var r=function(){};r.prototype=n.prototype,e.prototype=new r,e.prototype.constructor=e}}});var Tr=M((gR,gu)=>{try{if(mu=require("util"),typeof mu.inherits!="function")throw"";gu.exports=mu.inherits}catch{gu.exports=Ig()}var mu});var Rg=M((yR,yu)=>{"use strict";function iE(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var Dg=zi().Buffer,Fi=require("util");function sE(t,e,n){t.copy(e,n)}yu.exports=(function(){function t(){iE(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(n){var r={data:n,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length},t.prototype.unshift=function(n){var r={data:n,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length},t.prototype.shift=function(){if(this.length!==0){var n=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,n}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(n){if(this.length===0)return"";for(var r=this.head,i=""+r.data;r=r.next;)i+=n+r.data;return i},t.prototype.concat=function(n){if(this.length===0)return Dg.alloc(0);for(var r=Dg.allocUnsafe(n>>>0),i=this.head,s=0;i;)sE(i.data,r,s),s+=i.data.length,i=i.next;return r},t})();Fi&&Fi.inspect&&Fi.inspect.custom&&(yu.exports.prototype[Fi.inspect.custom]=function(){var t=Fi.inspect({length:this.length});return this.constructor.name+" "+t})});var bu=M((bR,Pg)=>{"use strict";var Po=Bi();function oE(t,e){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Po.nextTick(Lo,this,t)):Po.nextTick(Lo,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(s){!e&&s?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,Po.nextTick(Lo,n,s)):Po.nextTick(Lo,n,s):e&&e(s)}),this)}function aE(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Lo(t,e){t.emit("error",e)}Pg.exports={destroy:oE,undestroy:aE}});var Bg=M((vR,Lg)=>{Lg.exports=require("util").deprecate});var wu=M((wR,jg)=>{"use strict";var Hn=Bi();jg.exports=de;function Fg(t){var e=this;this.next=null,this.entry=null,this.finish=function(){EE(e,t)}}var lE=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:Hn.nextTick,Ar;de.WritableState=Hi;var $g=Object.create(Er());$g.inherits=Tr();var cE={deprecate:Bg()},Hg=fu(),zo=zi().Buffer,uE=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function dE(t){return zo.from(t)}function fE(t){return zo.isBuffer(t)||t instanceof uE}var Vg=bu();$g.inherits(de,Hg);function hE(){}function Hi(t,e){Ar=Ar||Vn(),t=t||{};var n=e instanceof Ar;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var r=t.highWaterMark,i=t.writableHighWaterMark,s=this.objectMode?16:16*1024;r||r===0?this.highWaterMark=r:n&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=s,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=t.decodeStrings===!1;this.decodeStrings=!o,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){wE(e,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Fg(this)}Hi.prototype.getBuffer=function(){for(var e=this.bufferedRequest,n=[];e;)n.push(e),e=e.next;return n};(function(){try{Object.defineProperty(Hi.prototype,"buffer",{get:cE.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Bo;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Bo=Function.prototype[Symbol.hasInstance],Object.defineProperty(de,Symbol.hasInstance,{value:function(t){return Bo.call(this,t)?!0:this!==de?!1:t&&t._writableState instanceof Hi}})):Bo=function(t){return t instanceof this};function de(t){if(Ar=Ar||Vn(),!Bo.call(de,this)&&!(this instanceof Ar))return new de(t);this._writableState=new Hi(t,this),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),Hg.call(this)}de.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function pE(t,e){var n=new Error("write after end");t.emit("error",n),Hn.nextTick(e,n)}function mE(t,e,n,r){var i=!0,s=!1;return n===null?s=new TypeError("May not write null values to stream"):typeof n!="string"&&n!==void 0&&!e.objectMode&&(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),Hn.nextTick(r,s),i=!1),i}de.prototype.write=function(t,e,n){var r=this._writableState,i=!1,s=!r.objectMode&&fE(t);return s&&!zo.isBuffer(t)&&(t=dE(t)),typeof e=="function"&&(n=e,e=null),s?e="buffer":e||(e=r.defaultEncoding),typeof n!="function"&&(n=hE),r.ended?pE(this,n):(s||mE(this,r,t,n))&&(r.pendingcb++,i=yE(this,r,s,t,e,n)),i};de.prototype.cork=function(){var t=this._writableState;t.corked++};de.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&Ug(this,t))};de.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this};function gE(t,e,n){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=zo.from(e,n)),e}Object.defineProperty(de.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function yE(t,e,n,r,i,s){if(!n){var o=gE(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var a=e.objectMode?1:r.length;e.length+=a;var l=e.length{"use strict";var qg=Bi(),TE=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};Zg.exports=Vt;var Kg=Object.create(Er());Kg.inherits=Tr();var Jg=Su(),ku=wu();Kg.inherits(Vt,Jg);for(xu=TE(ku.prototype),Fo=0;Fo{"use strict";var Eu=zi().Buffer,Xg=Eu.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _E(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function NE(t){var e=_E(t);if(typeof e!="string"&&(Eu.isEncoding===Xg||!Xg(t)))throw new Error("Unknown encoding: "+t);return e||t}Gg.StringDecoder=Vi;function Vi(t){this.encoding=NE(t);var e;switch(this.encoding){case"utf16le":this.text=LE,this.end=BE,e=4;break;case"utf8":this.fillLast=DE,e=4;break;case"base64":this.text=zE,this.end=FE,e=3;break;default:this.write=$E,this.end=HE;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Eu.allocUnsafe(e)}Vi.prototype.write=function(t){if(t.length===0)return"";var e,n;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function OE(t,e,n){var r=e.length-1;if(r=0?(i>0&&(t.lastNeed=i-1),i):--r=0?(i>0&&(t.lastNeed=i-2),i):--r=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function IE(t,e,n){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function DE(t){var e=this.lastTotal-this.lastNeed,n=IE(this,t,e);if(n!==void 0)return n;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function RE(t,e){var n=OE(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)}function PE(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function LE(t,e){if((t.length-e)%2===0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function BE(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function zE(t,e){var n=(t.length-e)%3;return n===0?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function FE(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function $E(t){return t.toString(this.encoding)}function HE(t){return t&&t.length?this.write(t):""}});var Su=M((CR,cy)=>{"use strict";var _r=Bi();cy.exports=G;var VE=Mg(),Ui;G.ReadableState=iy;var SR=require("events").EventEmitter,ty=function(t,e){return t.listeners(e).length},Ou=fu(),Wi=zi().Buffer,UE=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function WE(t){return Wi.from(t)}function jE(t){return Wi.isBuffer(t)||t instanceof UE}var ny=Object.create(Er());ny.inherits=Tr();var Au=require("util"),K=void 0;Au&&Au.debuglog?K=Au.debuglog("stream"):K=function(){};var qE=Rg(),ry=bu(),Mr;ny.inherits(G,Ou);var Mu=["error","close","destroy","pause","resume"];function KE(t,e,n){if(typeof t.prependListener=="function")return t.prependListener(e,n);!t._events||!t._events[e]?t.on(e,n):VE(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]}function iy(t,e){Ui=Ui||Vn(),t=t||{};var n=e instanceof Ui;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,i=t.readableHighWaterMark,s=this.objectMode?16:16*1024;r||r===0?this.highWaterMark=r:n&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new qE,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(Mr||(Mr=Tu().StringDecoder),this.decoder=new Mr(t.encoding),this.encoding=t.encoding)}function G(t){if(Ui=Ui||Vn(),!(this instanceof G))return new G(t);this._readableState=new iy(t,this),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),Ou.call(this)}Object.defineProperty(G.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});G.prototype.destroy=ry.destroy;G.prototype._undestroy=ry.undestroy;G.prototype._destroy=function(t,e){this.push(null),e(t)};G.prototype.push=function(t,e){var n=this._readableState,r;return n.objectMode?r=!0:typeof t=="string"&&(e=e||n.defaultEncoding,e!==n.encoding&&(t=Wi.from(t,e),e=""),r=!0),sy(this,t,e,!1,r)};G.prototype.unshift=function(t){return sy(this,t,null,!0,!1)};function sy(t,e,n,r,i){var s=t._readableState;if(e===null)s.reading=!1,GE(t,s);else{var o;i||(o=JE(s,e)),o?t.emit("error",o):s.objectMode||e&&e.length>0?(typeof e!="string"&&!s.objectMode&&Object.getPrototypeOf(e)!==Wi.prototype&&(e=WE(e)),r?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_u(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!n?(e=s.decoder.write(e),s.objectMode||e.length!==0?_u(t,s,e,!1):oy(t,s)):_u(t,s,e,!1))):r||(s.reading=!1)}return ZE(s)}function _u(t,e,n,r){e.flowing&&e.length===0&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&Ho(t)),oy(t,e)}function JE(t,e){var n;return!jE(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(n=new TypeError("Invalid non-string/buffer chunk")),n}function ZE(t){return!t.ended&&(t.needReadable||t.length=Yg?t=Yg:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function Qg(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=XE(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}G.prototype.read=function(t){K("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return K("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Nu(this):Ho(this),null;if(t=Qg(t,e),t===0&&e.ended)return e.length===0&&Nu(this),null;var r=e.needReadable;K("need readable",r),(e.length===0||e.length-t0?i=ay(t,e):i=null,i===null?(e.needReadable=!0,t=0):e.length-=t,e.length===0&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&Nu(this)),i!==null&&this.emit("data",i),i};function GE(t,e){if(!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,Ho(t)}}function Ho(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(K("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?_r.nextTick(ey,t):ey(t))}function ey(t){K("emit readable"),t.emit("readable"),Iu(t)}function oy(t,e){e.readingMore||(e.readingMore=!0,_r.nextTick(YE,t,e))}function YE(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length1&&ly(r.pipes,t)!==-1)&&!c&&(K("false write response, pause",r.awaitDrain),r.awaitDrain++,d=!0),n.pause())}function h(y){K("onerror",y),g(),t.removeListener("error",h),ty(t,"error")===0&&t.emit("error",y)}KE(t,"error",h);function p(){t.removeListener("finish",m),g()}t.once("close",p);function m(){K("onfinish"),t.removeListener("close",p),g()}t.once("finish",m);function g(){K("unpipe"),n.unpipe(t)}return t.emit("pipe",n),r.flowing||(K("pipe resume"),n.resume()),t};function QE(t){return function(){var e=t._readableState;K("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,e.awaitDrain===0&&ty(t,"data")&&(e.flowing=!0,Iu(t))}}G.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s=e.length?(e.decoder?n=e.buffer.join(""):e.buffer.length===1?n=e.buffer.head.data:n=e.buffer.concat(e.length),e.buffer.clear()):n=rT(t,e.buffer,e.decoder),n}function rT(t,e,n){var r;return ts.length?s.length:t;if(o===s.length?i+=s:i+=s.slice(0,t),t-=o,t===0){o===s.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++r}return e.length-=r,i}function sT(t,e){var n=Wi.allocUnsafe(t),r=e.head,i=1;for(r.data.copy(n),t-=r.data.length;r=r.next;){var s=r.data,o=t>s.length?s.length:t;if(s.copy(n,n.length-t,0,o),t-=o,t===0){o===s.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++i}return e.length-=i,n}function Nu(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,_r.nextTick(oT,e,t))}function oT(t,e){!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function ly(t,e){for(var n=0,r=t.length;n{"use strict";fy.exports=Ut;var Vo=Vn(),dy=Object.create(Er());dy.inherits=Tr();dy.inherits(Ut,Vo);function aT(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,e!=null&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";my.exports=ji;var hy=Du(),py=Object.create(Er());py.inherits=Tr();py.inherits(ji,hy);function ji(t){if(!(this instanceof ji))return new ji(t);hy.call(this,t)}ji.prototype._transform=function(t,e,n){n(null,t)}});var Ru=M((Se,Uo)=>{var bt=require("stream");process.env.READABLE_STREAM==="disable"&&bt?(Uo.exports=bt,Se=Uo.exports=bt.Readable,Se.Readable=bt.Readable,Se.Writable=bt.Writable,Se.Duplex=bt.Duplex,Se.Transform=bt.Transform,Se.PassThrough=bt.PassThrough,Se.Stream=bt):(Se=Uo.exports=Su(),Se.Stream=bt||Se,Se.Readable=Se,Se.Writable=wu(),Se.Duplex=Vn(),Se.Transform=Du(),Se.PassThrough=gy())});var Wt=M(Ve=>{"use strict";Ve.base64=!0;Ve.array=!0;Ve.string=!0;Ve.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";Ve.nodebuffer=typeof Buffer<"u";Ve.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")Ve.blob=!1;else{Pu=new ArrayBuffer(0);try{Ve.blob=new Blob([Pu],{type:"application/zip"}).size===0}catch{try{yy=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,Lu=new yy,Lu.append(Pu),Ve.blob=Lu.getBlob("application/zip").size===0}catch{Ve.blob=!1}}}var Pu,yy,Lu;try{Ve.nodestream=!!Ru().Readable}catch{Ve.nodestream=!1}});var zu=M(Bu=>{"use strict";var cT=te(),uT=Wt(),vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";Bu.encode=function(t){for(var e=[],n,r,i,s,o,a,l,c=0,u=t.length,d=u,f=cT.getTypeOf(t)!=="string";c>2,o=(n&3)<<4|r>>4,a=d>1?(r&15)<<2|i>>6:64,l=d>2?i&63:64,e.push(vt.charAt(s)+vt.charAt(o)+vt.charAt(a)+vt.charAt(l));return e.join("")};Bu.decode=function(t){var e,n,r,i,s,o,a,l=0,c=0,u="data:";if(t.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");t=t.replace(/[^A-Za-z0-9+/=]/g,"");var d=t.length*3/4;if(t.charAt(t.length-1)===vt.charAt(64)&&d--,t.charAt(t.length-2)===vt.charAt(64)&&d--,d%1!==0)throw new Error("Invalid base64 input, bad content length.");var f;for(uT.uint8array?f=new Uint8Array(d|0):f=new Array(d|0);l>4,n=(s&15)<<4|o>>2,r=(o&3)<<6|a,f[c++]=e,o!==64&&(f[c++]=n),a!==64&&(f[c++]=r);return f}});var qi=M((_R,by)=>{"use strict";by.exports={isNode:typeof Buffer<"u",newBufferFrom:function(t,e){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(t,e);if(typeof t=="number")throw new Error('The "data" argument must not be a number');return new Buffer(t,e)},allocBuffer:function(t){if(Buffer.alloc)return Buffer.alloc(t);var e=new Buffer(t);return e.fill(0),e},isBuffer:function(t){return Buffer.isBuffer(t)},isStream:function(t){return t&&typeof t.on=="function"&&typeof t.pause=="function"&&typeof t.resume=="function"}}});var ky=M((NR,xy)=>{"use strict";var vy=global.MutationObserver||global.WebKitMutationObserver,Nr;process.browser?vy?(Fu=0,wy=new vy(Ki),$u=global.document.createTextNode(""),wy.observe($u,{characterData:!0}),Nr=function(){$u.data=Fu=++Fu%2}):!global.setImmediate&&typeof global.MessageChannel<"u"?(Hu=new global.MessageChannel,Hu.port1.onmessage=Ki,Nr=function(){Hu.port2.postMessage(0)}):"document"in global&&"onreadystatechange"in global.document.createElement("script")?Nr=function(){var t=global.document.createElement("script");t.onreadystatechange=function(){Ki(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},global.document.documentElement.appendChild(t)}:Nr=function(){setTimeout(Ki,0)}:Nr=function(){process.nextTick(Ki)};var Fu,wy,$u,Hu,Vu,Ji=[];function Ki(){Vu=!0;for(var t,e,n=Ji.length;n;){for(e=Ji,Ji=[],t=-1;++t{"use strict";var Sy=ky();function Or(){}var Oe={},Cy=["REJECTED"],Uu=["FULFILLED"],Ey=["PENDING"];process.browser||(Zi=["UNHANDLED"]);var Zi;My.exports=ln;function ln(t){if(typeof t!="function")throw new TypeError("resolver must be a function");this.state=Ey,this.queue=[],this.outcome=void 0,process.browser||(this.handled=Zi),t!==Or&&Ty(this,t)}ln.prototype.finally=function(t){if(typeof t!="function")return this;var e=this.constructor;return this.then(n,r);function n(i){function s(){return i}return e.resolve(t()).then(s)}function r(i){function s(){throw i}return e.resolve(t()).then(s)}};ln.prototype.catch=function(t){return this.then(null,t)};ln.prototype.then=function(t,e){if(typeof t!="function"&&this.state===Uu||typeof e!="function"&&this.state===Cy)return this;var n=new this.constructor(Or);if(process.browser||this.handled===Zi&&(this.handled=null),this.state!==Ey){var r=this.state===Uu?t:e;Wu(n,r,this.outcome)}else this.queue.push(new Xi(n,t,e));return n};function Xi(t,e,n){this.promise=t,typeof e=="function"&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),typeof n=="function"&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}Xi.prototype.callFulfilled=function(t){Oe.resolve(this.promise,t)};Xi.prototype.otherCallFulfilled=function(t){Wu(this.promise,this.onFulfilled,t)};Xi.prototype.callRejected=function(t){Oe.reject(this.promise,t)};Xi.prototype.otherCallRejected=function(t){Wu(this.promise,this.onRejected,t)};function Wu(t,e,n){Sy(function(){var r;try{r=e(n)}catch(i){return Oe.reject(t,i)}r===t?Oe.reject(t,new TypeError("Cannot resolve promise with itself")):Oe.resolve(t,r)})}Oe.resolve=function(t,e){var n=Ay(fT,e);if(n.status==="error")return Oe.reject(t,n.value);var r=n.value;if(r)Ty(t,r);else{t.state=Uu,t.outcome=e;for(var i=-1,s=t.queue.length;++i{"use strict";var ju=null;typeof Promise<"u"?ju=Promise:ju=_y();Ny.exports={Promise:ju}});var Iy=M(Oy=>{(function(t,e){"use strict";if(t.setImmediate)return;var n=1,r={},i=!1,s=t.document,o;function a(b){typeof b!="function"&&(b=new Function(""+b));for(var x=new Array(arguments.length-1),w=0;w"u"?typeof global>"u"?Oy:global:self)});var te=M(fe=>{"use strict";var cn=Wt(),yT=zu(),Dr=qi(),qu=Ir();Iy();function bT(t){var e=null;return cn.uint8array?e=new Uint8Array(t.length):e=new Array(t.length),jo(t,e)}fe.newBlob=function(t,e){fe.checkSupport("blob");try{return new Blob([t],{type:e})}catch{try{var n=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,r=new n;return r.append(t),r.getBlob(e)}catch{throw new Error("Bug : can't construct the Blob.")}}};function Gi(t){return t}function jo(t,e){for(var n=0;n1;)try{return Wo.stringifyByChunk(t,n,e)}catch{e=Math.floor(e/2)}return Wo.stringifyByChar(t)}fe.applyFromCharCode=Yi;function qo(t,e){for(var n=0;n"u"&&(t[n]=arguments[e][n]);return t};fe.prepareContent=function(t,e,n,r,i){var s=qu.Promise.resolve(e).then(function(o){var a=cn.blob&&(o instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(o))!==-1);return a&&typeof FileReader<"u"?new qu.Promise(function(l,c){var u=new FileReader;u.onload=function(d){l(d.target.result)},u.onerror=function(d){c(d.target.error)},u.readAsArrayBuffer(o)}):o});return s.then(function(o){var a=fe.getTypeOf(o);return a?(a==="arraybuffer"?o=fe.transformTo("uint8array",o):a==="string"&&(i?o=yT.decode(o):n&&r!==!0&&(o=bT(o))),o):qu.Promise.reject(new Error("Can't read the data of '"+t+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}});var Ue=M((PR,Ry)=>{"use strict";function Dy(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}Dy.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return this.isFinished?!1:(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var n=0;n "+t:t}};Ry.exports=Dy});var Pr=M(dn=>{"use strict";var Rr=te(),Un=Wt(),vT=qi(),Ko=Ue(),Qi=new Array(256);for(jt=0;jt<256;jt++)Qi[jt]=jt>=252?6:jt>=248?5:jt>=240?4:jt>=224?3:jt>=192?2:1;var jt;Qi[254]=Qi[254]=1;var wT=function(t){var e,n,r,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|n&63):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|n&63):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|n&63);return e},xT=function(t,e){var n;for(e=e||t.length,e>t.length&&(e=t.length),n=e-1;n>=0&&(t[n]&192)===128;)n--;return n<0||n===0?e:n+Qi[t[n]]>e?n:e},kT=function(t){var e,n,r,i,s=t.length,o=new Array(s*2);for(n=0,e=0;e4){o[n++]=65533,e+=i-1;continue}for(r&=i===2?31:i===3?15:7;i>1&&e1){o[n++]=65533;continue}r<65536?o[n++]=r:(r-=65536,o[n++]=55296|r>>10&1023,o[n++]=56320|r&1023)}return o.length!==n&&(o.subarray?o=o.subarray(0,n):o.length=n),Rr.applyFromCharCode(o)};dn.utf8encode=function(e){return Un.nodebuffer?vT.newBufferFrom(e,"utf-8"):wT(e)};dn.utf8decode=function(e){return Un.nodebuffer?Rr.transformTo("nodebuffer",e).toString("utf-8"):(e=Rr.transformTo(Un.uint8array?"uint8array":"array",e),kT(e))};function Jo(){Ko.call(this,"utf-8 decode"),this.leftOver=null}Rr.inherits(Jo,Ko);Jo.prototype.processChunk=function(t){var e=Rr.transformTo(Un.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(Un.uint8array){var n=e;e=new Uint8Array(n.length+this.leftOver.length),e.set(this.leftOver,0),e.set(n,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var r=xT(e),i=e;r!==e.length&&(Un.uint8array?(i=e.subarray(0,r),this.leftOver=e.subarray(r,e.length)):(i=e.slice(0,r),this.leftOver=e.slice(r,e.length))),this.push({data:dn.utf8decode(i),meta:t.meta})};Jo.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:dn.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)};dn.Utf8DecodeWorker=Jo;function Ku(){Ko.call(this,"utf-8 encode")}Rr.inherits(Ku,Ko);Ku.prototype.processChunk=function(t){this.push({data:dn.utf8encode(t.data),meta:t.meta})};dn.Utf8EncodeWorker=Ku});var zy=M((BR,By)=>{"use strict";var Py=Ue(),Ly=te();function Ju(t){Py.call(this,"ConvertWorker to "+t),this.destType=t}Ly.inherits(Ju,Py);Ju.prototype.processChunk=function(t){this.push({data:Ly.transformTo(this.destType,t.data),meta:t.meta})};By.exports=Ju});var Hy=M((zR,$y)=>{"use strict";var Fy=Ru().Readable,ST=te();ST.inherits(Zu,Fy);function Zu(t,e,n){Fy.call(this,e),this._helper=t;var r=this;t.on("data",function(i,s){r.push(i)||r._helper.pause(),n&&n(s)}).on("error",function(i){r.emit("error",i)}).on("end",function(){r.push(null)})}Zu.prototype._read=function(){this._helper.resume()};$y.exports=Zu});var Xu=M((FR,Wy)=>{"use strict";var Wn=te(),CT=zy(),ET=Ue(),TT=zu(),AT=Wt(),MT=Ir(),Vy=null;if(AT.nodestream)try{Vy=Hy()}catch{}function _T(t,e,n){switch(t){case"blob":return Wn.newBlob(Wn.transformTo("arraybuffer",e),n);case"base64":return TT.encode(e);default:return Wn.transformTo(t,e)}}function NT(t,e){var n,r=0,i=null,s=0;for(n=0;n{"use strict";it.base64=!1;it.binary=!1;it.dir=!1;it.createFolders=!0;it.date=null;it.compression=null;it.compressionOptions=null;it.comment=null;it.unixPermissions=null;it.dosPermissions=null});var Yu=M((HR,jy)=>{"use strict";var Zo=te(),Xo=Ue(),IT=16*1024;function Lr(t){Xo.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then(function(n){e.dataIsReady=!0,e.data=n,e.max=n&&n.length||0,e.type=Zo.getTypeOf(n),e.isPaused||e._tickAndRepeat()},function(n){e.error(n)})}Zo.inherits(Lr,Xo);Lr.prototype.cleanUp=function(){Xo.prototype.cleanUp.call(this),this.data=null};Lr.prototype.resume=function(){return Xo.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,Zo.delay(this._tickAndRepeat,[],this)),!0):!1};Lr.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(Zo.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))};Lr.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=IT,e=null,n=Math.min(this.max,this.index+t);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,n);break;case"uint8array":e=this.data.subarray(this.index,n);break;case"array":case"nodebuffer":e=this.data.slice(this.index,n);break}return this.index=n,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})};jy.exports=Lr});var Go=M((VR,Ky)=>{"use strict";var DT=te();function RT(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e}var qy=RT();function PT(t,e,n,r){var i=qy,s=r+n;t=t^-1;for(var o=r;o>>8^i[(t^e[o])&255];return t^-1}function LT(t,e,n,r){var i=qy,s=r+n;t=t^-1;for(var o=r;o>>8^i[(t^e.charCodeAt(o))&255];return t^-1}Ky.exports=function(e,n){if(typeof e>"u"||!e.length)return 0;var r=DT.getTypeOf(e)!=="string";return r?PT(n|0,e,e.length,0):LT(n|0,e,e.length,0)}});var ed=M((UR,Zy)=>{"use strict";var Jy=Ue(),BT=Go(),zT=te();function Qu(){Jy.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}zT.inherits(Qu,Jy);Qu.prototype.processChunk=function(t){this.streamInfo.crc32=BT(t.data,this.streamInfo.crc32||0),this.push(t)};Zy.exports=Qu});var Gy=M((WR,Xy)=>{"use strict";var FT=te(),td=Ue();function nd(t){td.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}FT.inherits(nd,td);nd.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}td.prototype.processChunk.call(this,t)};Xy.exports=nd});var Yo=M((jR,e0)=>{"use strict";var Yy=Ir(),Qy=Yu(),$T=ed(),rd=Gy();function id(t,e,n,r,i){this.compressedSize=t,this.uncompressedSize=e,this.crc32=n,this.compression=r,this.compressedContent=i}id.prototype={getContentWorker:function(){var t=new Qy(Yy.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new rd("data_length")),e=this;return t.on("end",function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),t},getCompressedWorker:function(){return new Qy(Yy.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};id.createWorkerFrom=function(t,e,n){return t.pipe(new $T).pipe(new rd("uncompressedSize")).pipe(e.compressWorker(n)).pipe(new rd("compressedSize")).withStreamInfo("compression",e)};e0.exports=id});var i0=M((qR,r0)=>{"use strict";var HT=Xu(),VT=Yu(),sd=Pr(),od=Yo(),t0=Ue(),ad=function(t,e,n){this.name=t,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=e,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}};ad.prototype={internalStream:function(t){var e=null,n="string";try{if(!t)throw new Error("No output type specified.");n=t.toLowerCase();var r=n==="string"||n==="text";(n==="binarystring"||n==="text")&&(n="string"),e=this._decompressWorker();var i=!this._dataBinary;i&&!r&&(e=e.pipe(new sd.Utf8EncodeWorker)),!i&&r&&(e=e.pipe(new sd.Utf8DecodeWorker))}catch(s){e=new t0("error"),e.error(s)}return new HT(e,n,"")},async:function(t,e){return this.internalStream(t).accumulate(e)},nodeStream:function(t,e){return this.internalStream(t||"nodebuffer").toNodejsStream(e)},_compressWorker:function(t,e){if(this._data instanceof od&&this._data.compression.magic===t.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new sd.Utf8EncodeWorker)),od.createWorkerFrom(n,t,e)},_decompressWorker:function(){return this._data instanceof od?this._data.getContentWorker():this._data instanceof t0?this._data:new VT(this._data)}};var n0=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],UT=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(Qo=0;Qo{"use strict";var WT=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function jT(t,e){return Object.prototype.hasOwnProperty.call(t,e)}Pe.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var r in n)jT(n,r)&&(t[r]=n[r])}}return t};Pe.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var qT={arraySet:function(t,e,n,r,i){if(e.subarray&&t.subarray){t.set(e.subarray(n,n+r),i);return}for(var s=0;s{"use strict";var JT=qt(),ZT=4,s0=0,o0=1,XT=2;function zr(t){for(var e=t.length;--e>=0;)t[e]=0}var GT=0,f0=1,YT=2,QT=3,eA=258,pd=29,ss=256,ts=ss+1+pd,Br=30,md=19,h0=2*ts+1,jn=15,ld=16,tA=7,gd=256,p0=16,m0=17,g0=18,fd=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ea=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],nA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],y0=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],rA=512,Kt=new Array((ts+2)*2);zr(Kt);var es=new Array(Br*2);zr(es);var ns=new Array(rA);zr(ns);var rs=new Array(eA-QT+1);zr(rs);var yd=new Array(pd);zr(yd);var ta=new Array(Br);zr(ta);function cd(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}var b0,v0,w0;function ud(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function x0(t){return t<256?ns[t]:ns[256+(t>>>7)]}function is(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function $e(t,e,n){t.bi_valid>ld-n?(t.bi_buf|=e<>ld-t.bi_valid,t.bi_valid+=n-ld):(t.bi_buf|=e<>>=1,n<<=1;while(--e>0);return n>>>1}function iA(t){t.bi_valid===16?(is(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function sA(t,e){var n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,u,d,f,h,p,m=0;for(f=0;f<=jn;f++)t.bl_count[f]=0;for(n[t.heap[t.heap_max]*2+1]=0,c=t.heap_max+1;cl&&(f=l,m++),n[u*2+1]=f,!(u>r)&&(t.bl_count[f]++,h=0,u>=a&&(h=o[u-a]),p=n[u*2],t.opt_len+=p*(f+h),s&&(t.static_len+=p*(i[u*2+1]+h)));if(m!==0){do{for(f=l-1;t.bl_count[f]===0;)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(f=l;f!==0;f--)for(u=t.bl_count[f];u!==0;)d=t.heap[--c],!(d>r)&&(n[d*2+1]!==f&&(t.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}}function S0(t,e,n){var r=new Array(jn+1),i=0,s,o;for(s=1;s<=jn;s++)r[s]=i=i+n[s-1]<<1;for(o=0;o<=e;o++){var a=t[o*2+1];a!==0&&(t[o*2]=k0(r[a]++,a))}}function oA(){var t,e,n,r,i,s=new Array(jn+1);for(n=0,r=0;r>=7;r8?is(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function aA(t,e,n,r){E0(t),r&&(is(t,n),is(t,~n)),JT.arraySet(t.pending_buf,t.window,e,n,t.pending),t.pending+=n}function a0(t,e,n,r){var i=e*2,s=n*2;return t[i]>1;o>=1;o--)dd(t,n,o);c=s;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],dd(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[c*2]=n[o*2]+n[a*2],t.depth[c]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[o*2+1]=n[a*2+1]=c,t.heap[1]=c++,dd(t,n,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],sA(t,e),S0(n,l,t.bl_count)}function c0(t,e,n){var r,i=-1,s,o=e[1],a=0,l=7,c=4;for(o===0&&(l=138,c=3),e[(n+1)*2+1]=65535,r=0;r<=n;r++)s=o,o=e[(r+1)*2+1],!(++a=3&&t.bl_tree[y0[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function cA(t,e,n,r){var i;for($e(t,e-257,5),$e(t,n-1,5),$e(t,r-4,4),i=0;i>>=1)if(e&1&&t.dyn_ltree[n*2]!==0)return s0;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return o0;for(n=32;n0?(t.strm.data_type===XT&&(t.strm.data_type=uA(t)),hd(t,t.l_desc),hd(t,t.d_desc),o=lA(t),i=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=i&&(i=s)):i=s=n+5,n+4<=i&&e!==-1?T0(t,e,n,r):t.strategy===ZT||s===i?($e(t,(f0<<1)+(r?1:0),3),l0(t,Kt,es)):($e(t,(YT<<1)+(r?1:0),3),cA(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),l0(t,t.dyn_ltree,t.dyn_dtree)),C0(t),r&&E0(t)}function pA(t,e,n){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=n&255,t.last_lit++,e===0?t.dyn_ltree[n*2]++:(t.matches++,e--,t.dyn_ltree[(rs[n]+ss+1)*2]++,t.dyn_dtree[x0(e)*2]++),t.last_lit===t.lit_bufsize-1}Fr._tr_init=dA;Fr._tr_stored_block=T0;Fr._tr_flush_block=hA;Fr._tr_tally=pA;Fr._tr_align=fA});var bd=M((ZR,M0)=>{"use strict";function mA(t,e,n,r){for(var i=t&65535|0,s=t>>>16&65535|0,o=0;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+e[r++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0}M0.exports=mA});var vd=M((XR,_0)=>{"use strict";function gA(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e}var yA=gA();function bA(t,e,n,r){var i=yA,s=r+n;t^=-1;for(var o=r;o>>8^i[(t^e[o])&255];return t^-1}_0.exports=bA});var na=M((GR,N0)=>{"use strict";N0.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var F0=M(St=>{"use strict";var Le=qt(),Ye=A0(),R0=bd(),fn=vd(),vA=na(),Zn=0,wA=1,xA=3,yn=4,O0=5,kt=0,I0=1,Qe=-2,kA=-3,wd=-5,SA=-1,CA=1,ra=2,EA=3,TA=4,AA=0,MA=2,aa=8,_A=9,NA=15,OA=8,IA=29,DA=256,kd=DA+1+IA,RA=30,PA=19,LA=2*kd+1,BA=15,H=3,mn=258,st=mn+H+1,zA=32,la=42,Sd=69,ia=73,sa=91,oa=103,qn=113,ls=666,he=1,cs=2,Kn=3,Vr=4,FA=3;function gn(t,e){return t.msg=vA[e],e}function D0(t){return(t<<1)-(t>4?9:0)}function pn(t){for(var e=t.length;--e>=0;)t[e]=0}function hn(t){var e=t.state,n=e.pending;n>t.avail_out&&(n=t.avail_out),n!==0&&(Le.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,e.pending===0&&(e.pending_out=0))}function Ce(t,e){Ye._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,hn(t.strm)}function q(t,e){t.pending_buf[t.pending++]=e}function as(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function $A(t,e,n,r){var i=t.avail_in;return i>r&&(i=r),i===0?0:(t.avail_in-=i,Le.arraySet(e,t.input,t.next_in,i,n),t.state.wrap===1?t.adler=R0(t.adler,e,i,n):t.state.wrap===2&&(t.adler=fn(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)}function P0(t,e){var n=t.max_chain_length,r=t.strstart,i,s,o=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-st?t.strstart-(t.w_size-st):0,c=t.window,u=t.w_mask,d=t.prev,f=t.strstart+mn,h=c[r+o-1],p=c[r+o];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do if(i=e,!(c[i+o]!==p||c[i+o-1]!==h||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&ro){if(t.match_start=e,o=s,s>=a)break;h=c[r+o-1],p=c[r+o]}}while((e=d[e&u])>l&&--n!==0);return o<=t.lookahead?o:t.lookahead}function Jn(t){var e=t.w_size,n,r,i,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-st)){Le.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,r=t.hash_size,n=r;do i=t.head[--n],t.head[n]=i>=e?i-e:0;while(--r);r=e,n=r;do i=t.prev[--n],t.prev[n]=i>=e?i-e:0;while(--r);s+=e}if(t.strm.avail_in===0)break;if(r=$A(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=r,t.lookahead+t.insert>=H)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Jn(t),t.lookahead===0&&e===Zn)return he;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((t.strstart===0||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,Ce(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-st&&(Ce(t,!1),t.strm.avail_out===0))return he}return t.insert=0,e===yn?(Ce(t,!0),t.strm.avail_out===0?Kn:Vr):(t.strstart>t.block_start&&(Ce(t,!1),t.strm.avail_out===0),he)}function xd(t,e){for(var n,r;;){if(t.lookahead=H&&(t.ins_h=(t.ins_h<=H)if(r=Ye._tr_tally(t,t.strstart-t.match_start,t.match_length-H),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=H){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<=H&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=H-1)),t.prev_length>=H&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-H,r=Ye._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-H),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=(t.ins_h<=H&&t.strstart>0&&(i=t.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){s=t.strstart+mn;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=H?(n=Ye._tr_tally(t,1,t.match_length-H),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=Ye._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(Ce(t,!1),t.strm.avail_out===0))return he}return t.insert=0,e===yn?(Ce(t,!0),t.strm.avail_out===0?Kn:Vr):t.last_lit&&(Ce(t,!1),t.strm.avail_out===0)?he:cs}function UA(t,e){for(var n;;){if(t.lookahead===0&&(Jn(t),t.lookahead===0)){if(e===Zn)return he;break}if(t.match_length=0,n=Ye._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(Ce(t,!1),t.strm.avail_out===0))return he}return t.insert=0,e===yn?(Ce(t,!0),t.strm.avail_out===0?Kn:Vr):t.last_lit&&(Ce(t,!1),t.strm.avail_out===0)?he:cs}function xt(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}var Hr;Hr=[new xt(0,0,0,0,HA),new xt(4,4,8,4,xd),new xt(4,5,16,8,xd),new xt(4,6,32,32,xd),new xt(4,4,16,16,$r),new xt(8,16,32,32,$r),new xt(8,16,128,128,$r),new xt(8,32,128,256,$r),new xt(32,128,258,1024,$r),new xt(32,258,258,4096,$r)];function WA(t){t.window_size=2*t.w_size,pn(t.head),t.max_lazy_match=Hr[t.level].max_lazy,t.good_match=Hr[t.level].good_length,t.nice_match=Hr[t.level].nice_length,t.max_chain_length=Hr[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=H-1,t.match_available=0,t.ins_h=0}function jA(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=aa,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Le.Buf16(LA*2),this.dyn_dtree=new Le.Buf16((2*RA+1)*2),this.bl_tree=new Le.Buf16((2*PA+1)*2),pn(this.dyn_ltree),pn(this.dyn_dtree),pn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Le.Buf16(BA+1),this.heap=new Le.Buf16(2*kd+1),pn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Le.Buf16(2*kd+1),pn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function L0(t){var e;return!t||!t.state?gn(t,Qe):(t.total_in=t.total_out=0,t.data_type=MA,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?la:qn,t.adler=e.wrap===2?0:1,e.last_flush=Zn,Ye._tr_init(e),kt)}function B0(t){var e=L0(t);return e===kt&&WA(t.state),e}function qA(t,e){return!t||!t.state||t.state.wrap!==2?Qe:(t.state.gzhead=e,kt)}function z0(t,e,n,r,i,s){if(!t)return Qe;var o=1;if(e===SA&&(e=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>_A||n!==aa||r<8||r>15||e<0||e>9||s<0||s>TA)return gn(t,Qe);r===8&&(r=9);var a=new jA;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=r,a.w_size=1<O0||e<0)return t?gn(t,Qe):Qe;if(r=t.state,!t.output||!t.input&&t.avail_in!==0||r.status===ls&&e!==yn)return gn(t,t.avail_out===0?wd:Qe);if(r.strm=t,n=r.last_flush,r.last_flush=e,r.status===la)if(r.wrap===2)t.adler=0,q(r,31),q(r,139),q(r,8),r.gzhead?(q(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),q(r,r.gzhead.time&255),q(r,r.gzhead.time>>8&255),q(r,r.gzhead.time>>16&255),q(r,r.gzhead.time>>24&255),q(r,r.level===9?2:r.strategy>=ra||r.level<2?4:0),q(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(q(r,r.gzhead.extra.length&255),q(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=fn(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Sd):(q(r,0),q(r,0),q(r,0),q(r,0),q(r,0),q(r,r.level===9?2:r.strategy>=ra||r.level<2?4:0),q(r,FA),r.status=qn);else{var o=aa+(r.w_bits-8<<4)<<8,a=-1;r.strategy>=ra||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,o|=a<<6,r.strstart!==0&&(o|=zA),o+=31-o%31,r.status=qn,as(r,o),r.strstart!==0&&(as(r,t.adler>>>16),as(r,t.adler&65535)),t.adler=1}if(r.status===Sd)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),hn(t),i=r.pending,r.pending===r.pending_buf_size));)q(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=ia)}else r.status=ia;if(r.status===ia)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),hn(t),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindexi&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.gzindex=0,r.status=sa)}else r.status=sa;if(r.status===sa)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),hn(t),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindexi&&(t.adler=fn(t.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.status=oa)}else r.status=oa;if(r.status===oa&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&hn(t),r.pending+2<=r.pending_buf_size&&(q(r,t.adler&255),q(r,t.adler>>8&255),t.adler=0,r.status=qn)):r.status=qn),r.pending!==0){if(hn(t),t.avail_out===0)return r.last_flush=-1,kt}else if(t.avail_in===0&&D0(e)<=D0(n)&&e!==yn)return gn(t,wd);if(r.status===ls&&t.avail_in!==0)return gn(t,wd);if(t.avail_in!==0||r.lookahead!==0||e!==Zn&&r.status!==ls){var l=r.strategy===ra?UA(r,e):r.strategy===EA?VA(r,e):Hr[r.level].func(r,e);if((l===Kn||l===Vr)&&(r.status=ls),l===he||l===Kn)return t.avail_out===0&&(r.last_flush=-1),kt;if(l===cs&&(e===wA?Ye._tr_align(r):e!==O0&&(Ye._tr_stored_block(r,0,0,!1),e===xA&&(pn(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),hn(t),t.avail_out===0))return r.last_flush=-1,kt}return e!==yn?kt:r.wrap<=0?I0:(r.wrap===2?(q(r,t.adler&255),q(r,t.adler>>8&255),q(r,t.adler>>16&255),q(r,t.adler>>24&255),q(r,t.total_in&255),q(r,t.total_in>>8&255),q(r,t.total_in>>16&255),q(r,t.total_in>>24&255)):(as(r,t.adler>>>16),as(r,t.adler&65535)),hn(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?kt:I0)}function ZA(t){var e;return!t||!t.state?Qe:(e=t.state.status,e!==la&&e!==Sd&&e!==ia&&e!==sa&&e!==oa&&e!==qn&&e!==ls?gn(t,Qe):(t.state=null,e===qn?gn(t,kA):kt))}function XA(t,e){var n=e.length,r,i,s,o,a,l,c,u;if(!t||!t.state||(r=t.state,o=r.wrap,o===2||o===1&&r.status!==la||r.lookahead))return Qe;for(o===1&&(t.adler=R0(t.adler,e,n,0)),r.wrap=0,n>=r.w_size&&(o===0&&(pn(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new Le.Buf8(r.w_size),Le.arraySet(u,e,n-r.w_size,r.w_size,0),e=u,n=r.w_size),a=t.avail_in,l=t.next_in,c=t.input,t.avail_in=n,t.next_in=0,t.input=e,Jn(r);r.lookahead>=H;){i=r.strstart,s=r.lookahead-(H-1);do r.ins_h=(r.ins_h<{"use strict";var ca=qt(),$0=!0,H0=!0;try{String.fromCharCode.apply(null,[0])}catch{$0=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{H0=!1}var us=new ca.Buf8(256);for(Jt=0;Jt<256;Jt++)us[Jt]=Jt>=252?6:Jt>=248?5:Jt>=240?4:Jt>=224?3:Jt>=192?2:1;var Jt;us[254]=us[254]=1;Ur.string2buf=function(t){var e,n,r,i,s,o=t.length,a=0;for(i=0;i>>6,e[s++]=128|n&63):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|n&63):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|n&63);return e};function V0(t,e){if(e<65534&&(t.subarray&&H0||!t.subarray&&$0))return String.fromCharCode.apply(null,ca.shrinkBuf(t,e));for(var n="",r=0;r4){a[r++]=65533,n+=s-1;continue}for(i&=s===2?31:s===3?15:7;s>1&&n1){a[r++]=65533;continue}i<65536?a[r++]=i:(i-=65536,a[r++]=55296|i>>10&1023,a[r++]=56320|i&1023)}return V0(a,r)};Ur.utf8border=function(t,e){var n;for(e=e||t.length,e>t.length&&(e=t.length),n=e-1;n>=0&&(t[n]&192)===128;)n--;return n<0||n===0?e:n+us[t[n]]>e?n:e}});var Ed=M((e2,U0)=>{"use strict";function GA(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}U0.exports=GA});var K0=M(hs=>{"use strict";var ds=F0(),fs=qt(),Ad=Cd(),Md=na(),YA=Ed(),q0=Object.prototype.toString,QA=0,Td=4,Wr=0,W0=1,j0=2,eM=-1,tM=0,nM=8;function Xn(t){if(!(this instanceof Xn))return new Xn(t);this.options=fs.assign({level:eM,method:nM,chunkSize:16384,windowBits:15,memLevel:8,strategy:tM,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new YA,this.strm.avail_out=0;var n=ds.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Wr)throw new Error(Md[n]);if(e.header&&ds.deflateSetHeader(this.strm,e.header),e.dictionary){var r;if(typeof e.dictionary=="string"?r=Ad.string2buf(e.dictionary):q0.call(e.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(e.dictionary):r=e.dictionary,n=ds.deflateSetDictionary(this.strm,r),n!==Wr)throw new Error(Md[n]);this._dict_set=!0}}Xn.prototype.push=function(t,e){var n=this.strm,r=this.options.chunkSize,i,s;if(this.ended)return!1;s=e===~~e?e:e===!0?Td:QA,typeof t=="string"?n.input=Ad.string2buf(t):q0.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new fs.Buf8(r),n.next_out=0,n.avail_out=r),i=ds.deflate(n,s),i!==W0&&i!==Wr)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(s===Td||s===j0))&&(this.options.to==="string"?this.onData(Ad.buf2binstring(fs.shrinkBuf(n.output,n.next_out))):this.onData(fs.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==W0);return s===Td?(i=ds.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Wr):(s===j0&&(this.onEnd(Wr),n.avail_out=0),!0)};Xn.prototype.onData=function(t){this.chunks.push(t)};Xn.prototype.onEnd=function(t){t===Wr&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=fs.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function _d(t,e){var n=new Xn(e);if(n.push(t,!0),n.err)throw n.msg||Md[n.err];return n.result}function rM(t,e){return e=e||{},e.raw=!0,_d(t,e)}function iM(t,e){return e=e||{},e.gzip=!0,_d(t,e)}hs.Deflate=Xn;hs.deflate=_d;hs.deflateRaw=rM;hs.gzip=iM});var Z0=M((n2,J0)=>{"use strict";var ua=30,sM=12;J0.exports=function(e,n){var r,i,s,o,a,l,c,u,d,f,h,p,m,g,y,b,x,w,v,T,k,E,_,z,N;r=e.state,i=e.next_in,z=e.input,s=i+(e.avail_in-5),o=e.next_out,N=e.output,a=o-(n-e.avail_out),l=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,f=r.wnext,h=r.window,p=r.hold,m=r.bits,g=r.lencode,y=r.distcode,b=(1<>>24,p>>>=v,m-=v,v=w>>>16&255,v===0)N[o++]=w&65535;else if(v&16){T=w&65535,v&=15,v&&(m>>=v,m-=v),m<15&&(p+=z[i++]<>>24,p>>>=v,m-=v,v=w>>>16&255,v&16){if(k=w&65535,v&=15,mc){e.msg="invalid distance too far back",r.mode=ua;break e}if(p>>>=v,m-=v,v=o-a,k>v){if(v=k-v,v>d&&r.sane){e.msg="invalid distance too far back",r.mode=ua;break e}if(E=0,_=h,f===0){if(E+=u-v,v2;)N[o++]=_[E++],N[o++]=_[E++],N[o++]=_[E++],T-=3;T&&(N[o++]=_[E++],T>1&&(N[o++]=_[E++]))}else{E=o-k;do N[o++]=N[E++],N[o++]=N[E++],N[o++]=N[E++],T-=3;while(T>2);T&&(N[o++]=N[E++],T>1&&(N[o++]=N[E++]))}}else if((v&64)===0){w=y[(w&65535)+(p&(1<>3,i-=T,m-=T<<3,p&=(1<{"use strict";var X0=qt(),jr=15,G0=852,Y0=592,Q0=0,Nd=1,eb=2,oM=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],aM=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],lM=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],cM=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];tb.exports=function(e,n,r,i,s,o,a,l){var c=l.bits,u=0,d=0,f=0,h=0,p=0,m=0,g=0,y=0,b=0,x=0,w,v,T,k,E,_=null,z=0,N,X=new X0.Buf16(jr+1),ne=new X0.Buf16(jr+1),re=null,ie=0,Nt,ct,Ps;for(u=0;u<=jr;u++)X[u]=0;for(d=0;d=1&&X[h]===0;h--);if(p>h&&(p=h),h===0)return s[o++]=1<<24|64<<16|0,s[o++]=1<<24|64<<16|0,l.bits=1,0;for(f=1;f0&&(e===Q0||h!==1))return-1;for(ne[1]=0,u=1;uG0||e===eb&&b>Y0)return 1;for(;;){Nt=u-g,a[d]N?(ct=re[ie+a[d]],Ps=_[z+a[d]]):(ct=96,Ps=0),w=1<>g)+v]=Nt<<24|ct<<16|Ps|0;while(v!==0);for(w=1<>=1;if(w!==0?(x&=w-1,x+=w):x=0,d++,--X[u]===0){if(u===h)break;u=n[r+a[d]]}if(u>p&&(x&k)!==T){for(g===0&&(g=p),E+=f,m=u-g,y=1<G0||e===eb&&b>Y0)return 1;T=x&k,s[T]=p<<24|m<<16|E-o|0}}return x!==0&&(s[E+x]=u-g<<24|64<<16|0),l.bits=p,0}});var Bb=M(ot=>{"use strict";var We=qt(),Ld=bd(),Ct=vd(),uM=Z0(),ps=nb(),dM=0,Mb=1,_b=2,rb=4,fM=5,da=6,Gn=0,hM=1,pM=2,et=-2,Nb=-3,Bd=-4,mM=-5,ib=8,Ob=1,sb=2,ob=3,ab=4,lb=5,cb=6,ub=7,db=8,fb=9,hb=10,pa=11,Zt=12,Od=13,pb=14,Id=15,mb=16,gb=17,yb=18,bb=19,fa=20,ha=21,vb=22,wb=23,xb=24,kb=25,Sb=26,Dd=27,Cb=28,Eb=29,Y=30,zd=31,gM=32,yM=852,bM=592,vM=15,wM=vM;function Tb(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function xM(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new We.Buf16(320),this.work=new We.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Ib(t){var e;return!t||!t.state?et:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Ob,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new We.Buf32(yM),e.distcode=e.distdyn=new We.Buf32(bM),e.sane=1,e.back=-1,Gn)}function Db(t){var e;return!t||!t.state?et:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,Ib(t))}function Rb(t,e){var n,r;return!t||!t.state||(r=t.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?et:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,Db(t))}function Pb(t,e){var n,r;return t?(r=new xM,t.state=r,r.window=null,n=Rb(t,e),n!==Gn&&(t.state=null),n):et}function kM(t){return Pb(t,wM)}var Ab=!0,Rd,Pd;function SM(t){if(Ab){var e;for(Rd=new We.Buf32(512),Pd=new We.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ps(Mb,t.lens,0,288,Rd,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ps(_b,t.lens,0,32,Pd,0,t.work,{bits:5}),Ab=!1}t.lencode=Rd,t.lenbits=9,t.distcode=Pd,t.distbits=5}function Lb(t,e,n,r){var i,s=t.state;return s.window===null&&(s.wsize=1<=s.wsize?(We.arraySet(s.window,e,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),We.arraySet(s.window,e,n-r,i,s.wnext),r-=i,r?(We.arraySet(s.window,e,n-r,r,0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=Ct(n.check,_,2,0),c=0,u=0,n.mode=sb;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=Y;break}if((c&15)!==ib){t.msg="unknown compression method",n.mode=Y;break}if(c>>>=4,u-=4,k=(c&15)+8,n.wbits===0)n.wbits=k;else if(k>n.wbits){t.msg="invalid window size",n.mode=Y;break}n.dmax=1<>8&1),n.flags&512&&(_[0]=c&255,_[1]=c>>>8&255,n.check=Ct(n.check,_,2,0)),c=0,u=0,n.mode=ob;case ob:for(;u<32;){if(a===0)break e;a--,c+=r[s++]<>>8&255,_[2]=c>>>16&255,_[3]=c>>>24&255,n.check=Ct(n.check,_,4,0)),c=0,u=0,n.mode=ab;case ab:for(;u<16;){if(a===0)break e;a--,c+=r[s++]<>8),n.flags&512&&(_[0]=c&255,_[1]=c>>>8&255,n.check=Ct(n.check,_,2,0)),c=0,u=0,n.mode=lb;case lb:if(n.flags&1024){for(;u<16;){if(a===0)break e;a--,c+=r[s++]<>>8&255,n.check=Ct(n.check,_,2,0)),c=0,u=0}else n.head&&(n.head.extra=null);n.mode=cb;case cb:if(n.flags&1024&&(h=n.length,h>a&&(h=a),h&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),We.arraySet(n.head.extra,r,s,h,k)),n.flags&512&&(n.check=Ct(n.check,r,h,s)),a-=h,s+=h,n.length-=h),n.length))break e;n.length=0,n.mode=ub;case ub:if(n.flags&2048){if(a===0)break e;h=0;do k=r[s+h++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k));while(k&&h>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=Zt;break;case hb:for(;u<32;){if(a===0)break e;a--,c+=r[s++]<>>=u&7,u-=u&7,n.mode=Dd;break}for(;u<3;){if(a===0)break e;a--,c+=r[s++]<>>=1,u-=1,c&3){case 0:n.mode=pb;break;case 1:if(SM(n),n.mode=fa,e===da){c>>>=2,u-=2;break e}break;case 2:n.mode=gb;break;case 3:t.msg="invalid block type",n.mode=Y}c>>>=2,u-=2;break;case pb:for(c>>>=u&7,u-=u&7;u<32;){if(a===0)break e;a--,c+=r[s++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=Y;break}if(n.length=c&65535,c=0,u=0,n.mode=Id,e===da)break e;case Id:n.mode=mb;case mb:if(h=n.length,h){if(h>a&&(h=a),h>l&&(h=l),h===0)break e;We.arraySet(i,r,s,h,o),a-=h,s+=h,l-=h,o+=h,n.length-=h;break}n.mode=Zt;break;case gb:for(;u<14;){if(a===0)break e;a--,c+=r[s++]<>>=5,u-=5,n.ndist=(c&31)+1,c>>>=5,u-=5,n.ncode=(c&15)+4,c>>>=4,u-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Y;break}n.have=0,n.mode=yb;case yb:for(;n.have>>=3,u-=3}for(;n.have<19;)n.lens[X[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,z={bits:n.lenbits},E=ps(dM,n.lens,0,19,n.lencode,0,n.work,z),n.lenbits=z.bits,E){t.msg="invalid code lengths set",n.mode=Y;break}n.have=0,n.mode=bb;case bb:for(;n.have>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(a===0)break e;a--,c+=r[s++]<>>=y,u-=y,n.lens[n.have++]=x;else{if(x===16){for(N=y+2;u>>=y,u-=y,n.have===0){t.msg="invalid bit length repeat",n.mode=Y;break}k=n.lens[n.have-1],h=3+(c&3),c>>>=2,u-=2}else if(x===17){for(N=y+3;u>>=y,u-=y,k=0,h=3+(c&7),c>>>=3,u-=3}else{for(N=y+7;u>>=y,u-=y,k=0,h=11+(c&127),c>>>=7,u-=7}if(n.have+h>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Y;break}for(;h--;)n.lens[n.have++]=k}}if(n.mode===Y)break;if(n.lens[256]===0){t.msg="invalid code -- missing end-of-block",n.mode=Y;break}if(n.lenbits=9,z={bits:n.lenbits},E=ps(Mb,n.lens,0,n.nlen,n.lencode,0,n.work,z),n.lenbits=z.bits,E){t.msg="invalid literal/lengths set",n.mode=Y;break}if(n.distbits=6,n.distcode=n.distdyn,z={bits:n.distbits},E=ps(_b,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,z),n.distbits=z.bits,E){t.msg="invalid distances set",n.mode=Y;break}if(n.mode=fa,e===da)break e;case fa:n.mode=ha;case ha:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=u,uM(t,f),o=t.next_out,i=t.output,l=t.avail_out,s=t.next_in,r=t.input,a=t.avail_in,c=n.hold,u=n.bits,n.mode===Zt&&(n.back=-1);break}for(n.back=0;g=n.lencode[c&(1<>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(a===0)break e;a--,c+=r[s++]<>w)],y=g>>>24,b=g>>>16&255,x=g&65535,!(w+y<=u);){if(a===0)break e;a--,c+=r[s++]<>>=w,u-=w,n.back+=w}if(c>>>=y,u-=y,n.back+=y,n.length=x,b===0){n.mode=Sb;break}if(b&32){n.back=-1,n.mode=Zt;break}if(b&64){t.msg="invalid literal/length code",n.mode=Y;break}n.extra=b&15,n.mode=vb;case vb:if(n.extra){for(N=n.extra;u>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=wb;case wb:for(;g=n.distcode[c&(1<>>24,b=g>>>16&255,x=g&65535,!(y<=u);){if(a===0)break e;a--,c+=r[s++]<>w)],y=g>>>24,b=g>>>16&255,x=g&65535,!(w+y<=u);){if(a===0)break e;a--,c+=r[s++]<>>=w,u-=w,n.back+=w}if(c>>>=y,u-=y,n.back+=y,b&64){t.msg="invalid distance code",n.mode=Y;break}n.offset=x,n.extra=b&15,n.mode=xb;case xb:if(n.extra){for(N=n.extra;u>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Y;break}n.mode=kb;case kb:if(l===0)break e;if(h=f-l,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Y;break}h>n.wnext?(h-=n.wnext,p=n.wsize-h):p=n.wnext-h,h>n.length&&(h=n.length),m=n.window}else m=i,p=o-n.offset,h=n.length;h>l&&(h=l),l-=h,n.length-=h;do i[o++]=m[p++];while(--h);n.length===0&&(n.mode=ha);break;case Sb:if(l===0)break e;i[o++]=n.length,l--,n.mode=ha;break;case Dd:if(n.wrap){for(;u<32;){if(a===0)break e;a--,c|=r[s++]<{"use strict";zb.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var $b=M((o2,Fb)=>{"use strict";function MM(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}Fb.exports=MM});var Vb=M(gs=>{"use strict";var qr=Bb(),ms=qt(),ma=Cd(),le=Fd(),$d=na(),_M=Ed(),NM=$b(),Hb=Object.prototype.toString;function Yn(t){if(!(this instanceof Yn))return new Yn(t);this.options=ms.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _M,this.strm.avail_out=0;var n=qr.inflateInit2(this.strm,e.windowBits);if(n!==le.Z_OK)throw new Error($d[n]);if(this.header=new NM,qr.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=ma.string2buf(e.dictionary):Hb.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=qr.inflateSetDictionary(this.strm,e.dictionary),n!==le.Z_OK)))throw new Error($d[n])}Yn.prototype.push=function(t,e){var n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,s,o,a,l,c,u=!1;if(this.ended)return!1;o=e===~~e?e:e===!0?le.Z_FINISH:le.Z_NO_FLUSH,typeof t=="string"?n.input=ma.binstring2buf(t):Hb.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new ms.Buf8(r),n.next_out=0,n.avail_out=r),s=qr.inflate(n,le.Z_NO_FLUSH),s===le.Z_NEED_DICT&&i&&(s=qr.inflateSetDictionary(this.strm,i)),s===le.Z_BUF_ERROR&&u===!0&&(s=le.Z_OK,u=!1),s!==le.Z_STREAM_END&&s!==le.Z_OK)return this.onEnd(s),this.ended=!0,!1;n.next_out&&(n.avail_out===0||s===le.Z_STREAM_END||n.avail_in===0&&(o===le.Z_FINISH||o===le.Z_SYNC_FLUSH))&&(this.options.to==="string"?(a=ma.utf8border(n.output,n.next_out),l=n.next_out-a,c=ma.buf2string(n.output,a),n.next_out=l,n.avail_out=r-l,l&&ms.arraySet(n.output,n.output,a,l,0),this.onData(c)):this.onData(ms.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&s!==le.Z_STREAM_END);return s===le.Z_STREAM_END&&(o=le.Z_FINISH),o===le.Z_FINISH?(s=qr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===le.Z_OK):(o===le.Z_SYNC_FLUSH&&(this.onEnd(le.Z_OK),n.avail_out=0),!0)};Yn.prototype.onData=function(t){this.chunks.push(t)};Yn.prototype.onEnd=function(t){t===le.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ms.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Hd(t,e){var n=new Yn(e);if(n.push(t,!0),n.err)throw n.msg||$d[n.err];return n.result}function OM(t,e){return e=e||{},e.raw=!0,Hd(t,e)}gs.Inflate=Yn;gs.inflate=Hd;gs.inflateRaw=OM;gs.ungzip=Hd});var jb=M((l2,Wb)=>{"use strict";var IM=qt().assign,DM=K0(),RM=Vb(),PM=Fd(),Ub={};IM(Ub,DM,RM,PM);Wb.exports=Ub});var Kb=M(ya=>{"use strict";var LM=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",BM=jb(),qb=te(),ga=Ue(),zM=LM?"uint8array":"array";ya.magic="\b\0";function Qn(t,e){ga.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}qb.inherits(Qn,ga);Qn.prototype.processChunk=function(t){this.meta=t.meta,this._pako===null&&this._createPako(),this._pako.push(qb.transformTo(zM,t.data),!1)};Qn.prototype.flush=function(){ga.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)};Qn.prototype.cleanUp=function(){ga.prototype.cleanUp.call(this),this._pako=null};Qn.prototype._createPako=function(){this._pako=new BM[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}};ya.compressWorker=function(t){return new Qn("Deflate",t)};ya.uncompressWorker=function(){return new Qn("Inflate",{})}});var Ud=M(Vd=>{"use strict";var Jb=Ue();Vd.STORE={magic:"\0\0",compressWorker:function(){return new Jb("STORE compression")},uncompressWorker:function(){return new Jb("STORE decompression")}};Vd.DEFLATE=Kb()});var Wd=M(er=>{"use strict";er.LOCAL_FILE_HEADER="PK";er.CENTRAL_FILE_HEADER="PK";er.CENTRAL_DIRECTORY_END="PK";er.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07";er.ZIP64_CENTRAL_DIRECTORY_END="PK";er.DATA_DESCRIPTOR="PK\x07\b"});var Yb=M((f2,Gb)=>{"use strict";var Kr=te(),Jr=Ue(),jd=Pr(),Zb=Go(),ba=Wd(),Z=function(t,e){var n="",r;for(r=0;r>>8;return n},FM=function(t,e){var n=t;return t||(n=e?16893:33204),(n&65535)<<16},$M=function(t){return(t||0)&63},Xb=function(t,e,n,r,i,s){var o=t.file,a=t.compression,l=s!==jd.utf8encode,c=Kr.transformTo("string",s(o.name)),u=Kr.transformTo("string",jd.utf8encode(o.name)),d=o.comment,f=Kr.transformTo("string",s(d)),h=Kr.transformTo("string",jd.utf8encode(d)),p=u.length!==o.name.length,m=h.length!==d.length,g,y,b="",x="",w="",v=o.dir,T=o.date,k={crc32:0,compressedSize:0,uncompressedSize:0};(!e||n)&&(k.crc32=t.crc32,k.compressedSize=t.compressedSize,k.uncompressedSize=t.uncompressedSize);var E=0;e&&(E|=8),!l&&(p||m)&&(E|=2048);var _=0,z=0;v&&(_|=16),i==="UNIX"?(z=798,_|=FM(o.unixPermissions,v)):(z=20,_|=$M(o.dosPermissions,v)),g=T.getUTCHours(),g=g<<6,g=g|T.getUTCMinutes(),g=g<<5,g=g|T.getUTCSeconds()/2,y=T.getUTCFullYear()-1980,y=y<<4,y=y|T.getUTCMonth()+1,y=y<<5,y=y|T.getUTCDate(),p&&(x=Z(1,1)+Z(Zb(c),4)+u,b+="up"+Z(x.length,2)+x),m&&(w=Z(1,1)+Z(Zb(f),4)+h,b+="uc"+Z(w.length,2)+w);var N="";N+=` -\0`,N+=Z(E,2),N+=a.magic,N+=Z(g,2),N+=Z(y,2),N+=Z(k.crc32,4),N+=Z(k.compressedSize,4),N+=Z(k.uncompressedSize,4),N+=Z(c.length,2),N+=Z(b.length,2);var X=ba.LOCAL_FILE_HEADER+N+c+b,ne=ba.CENTRAL_FILE_HEADER+Z(z,2)+N+Z(f.length,2)+"\0\0\0\0"+Z(_,4)+Z(r,4)+c+b+f;return{fileRecord:X,dirRecord:ne}},HM=function(t,e,n,r,i){var s="",o=Kr.transformTo("string",i(r));return s=ba.CENTRAL_DIRECTORY_END+"\0\0\0\0"+Z(t,2)+Z(t,2)+Z(e,4)+Z(n,4)+Z(o.length,2)+o,s},VM=function(t){var e="";return e=ba.DATA_DESCRIPTOR+Z(t.crc32,4)+Z(t.compressedSize,4)+Z(t.uncompressedSize,4),e};function at(t,e,n,r){Jr.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Kr.inherits(at,Jr);at.prototype.push=function(t){var e=t.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,Jr.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:n?(e+100*(n-r-1))/n:100}}))};at.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var n=Xb(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0};at.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,n=Xb(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),e)this.push({data:VM(t),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null};at.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e{"use strict";var UM=Ud(),WM=Yb(),jM=function(t,e){var n=t||e,r=UM[n];if(!r)throw new Error(n+" is not a valid compression method !");return r};Qb.generateWorker=function(t,e,n){var r=new WM(e.streamFiles,n,e.platform,e.encodeFileName),i=0;try{t.forEach(function(s,o){i++;var a=jM(o.options.compression,e.compression),l=o.options.compressionOptions||e.compressionOptions||{},c=o.dir,u=o.date;o._compressWorker(a,l).withStreamInfo("file",{name:s,dir:c,date:u,comment:o.comment||"",unixPermissions:o.unixPermissions,dosPermissions:o.dosPermissions}).pipe(r)}),r.entriesCount=i}catch(s){r.error(s)}return r}});var nv=M((p2,tv)=>{"use strict";var qM=te(),va=Ue();function ys(t,e){va.call(this,"Nodejs stream input adapter for "+t),this._upstreamEnded=!1,this._bindStream(e)}qM.inherits(ys,va);ys.prototype._bindStream=function(t){var e=this;this._stream=t,t.pause(),t.on("data",function(n){e.push({data:n,meta:{percent:0}})}).on("error",function(n){e.isPaused?this.generatedError=n:e.error(n)}).on("end",function(){e.isPaused?e._upstreamEnded=!0:e.end()})};ys.prototype.pause=function(){return va.prototype.pause.call(this)?(this._stream.pause(),!0):!1};ys.prototype.resume=function(){return va.prototype.resume.call(this)?(this._upstreamEnded?this.end():this._stream.resume(),!0):!1};tv.exports=ys});var fv=M((m2,dv)=>{"use strict";var KM=Pr(),bs=te(),ov=Ue(),JM=Xu(),av=Gu(),rv=Yo(),ZM=i0(),XM=ev(),iv=qi(),GM=nv(),lv=function(t,e,n){var r=bs.getTypeOf(e),i,s=bs.extend(n||{},av);s.date=s.date||new Date,s.compression!==null&&(s.compression=s.compression.toUpperCase()),typeof s.unixPermissions=="string"&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&s.unixPermissions&16384&&(s.dir=!0),s.dosPermissions&&s.dosPermissions&16&&(s.dir=!0),s.dir&&(t=cv(t)),s.createFolders&&(i=YM(t))&&uv.call(this,i,!0);var o=r==="string"&&s.binary===!1&&s.base64===!1;(!n||typeof n.binary>"u")&&(s.binary=!o);var a=e instanceof rv&&e.uncompressedSize===0;(a||s.dir||!e||e.length===0)&&(s.base64=!1,s.binary=!0,e="",s.compression="STORE",r="string");var l=null;e instanceof rv||e instanceof ov?l=e:iv.isNode&&iv.isStream(e)?l=new GM(t,e):l=bs.prepareContent(t,e,s.binary,s.optimizedBinaryString,s.base64);var c=new ZM(t,l,s);this.files[t]=c},YM=function(t){t.slice(-1)==="/"&&(t=t.substring(0,t.length-1));var e=t.lastIndexOf("/");return e>0?t.substring(0,e):""},cv=function(t){return t.slice(-1)!=="/"&&(t+="/"),t},uv=function(t,e){return e=typeof e<"u"?e:av.createFolders,t=cv(t),this.files[t]||lv.call(this,t,null,{dir:!0,createFolders:e}),this.files[t]};function sv(t){return Object.prototype.toString.call(t)==="[object RegExp]"}var QM={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(t){var e,n,r;for(e in this.files)r=this.files[e],n=e.slice(this.root.length,e.length),n&&e.slice(0,this.root.length)===this.root&&t(n,r)},filter:function(t){var e=[];return this.forEach(function(n,r){t(n,r)&&e.push(r)}),e},file:function(t,e,n){if(arguments.length===1)if(sv(t)){var r=t;return this.filter(function(s,o){return!o.dir&&r.test(s)})}else{var i=this.files[this.root+t];return i&&!i.dir?i:null}else t=this.root+t,lv.call(this,t,e,n);return this},folder:function(t){if(!t)return this;if(sv(t))return this.filter(function(i,s){return s.dir&&t.test(i)});var e=this.root+t,n=uv.call(this,e),r=this.clone();return r.root=n.name,r},remove:function(t){t=this.root+t;var e=this.files[t];if(e||(t.slice(-1)!=="/"&&(t+="/"),e=this.files[t]),e&&!e.dir)delete this.files[t];else for(var n=this.filter(function(i,s){return s.name.slice(0,t.length)===t}),r=0;r{"use strict";var e_=te();function hv(t){this.data=t,this.length=t.length,this.index=0,this.zero=0}hv.prototype={checkOffset:function(t){this.checkIndex(this.index+t)},checkIndex:function(t){if(this.length=this.index;n--)e=(e<<8)+this.byteAt(n);return this.index+=t,e},readString:function(t){return e_.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC((t>>25&127)+1980,(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(t&31)<<1))}};pv.exports=hv});var Kd=M((y2,gv)=>{"use strict";var mv=qd(),t_=te();function Zr(t){mv.call(this,t);for(var e=0;e=0;--s)if(this.data[s]===e&&this.data[s+1]===n&&this.data[s+2]===r&&this.data[s+3]===i)return s-this.zero;return-1};Zr.prototype.readAndCheckSignature=function(t){var e=t.charCodeAt(0),n=t.charCodeAt(1),r=t.charCodeAt(2),i=t.charCodeAt(3),s=this.readData(4);return e===s[0]&&n===s[1]&&r===s[2]&&i===s[3]};Zr.prototype.readData=function(t){if(this.checkOffset(t),t===0)return[];var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e};gv.exports=Zr});var vv=M((b2,bv)=>{"use strict";var yv=qd(),n_=te();function Xr(t){yv.call(this,t)}n_.inherits(Xr,yv);Xr.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)};Xr.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero};Xr.prototype.readAndCheckSignature=function(t){var e=this.readData(4);return t===e};Xr.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e};bv.exports=Xr});var Zd=M((v2,xv)=>{"use strict";var wv=Kd(),r_=te();function Jd(t){wv.call(this,t)}r_.inherits(Jd,wv);Jd.prototype.readData=function(t){if(this.checkOffset(t),t===0)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e};xv.exports=Jd});var Cv=M((w2,Sv)=>{"use strict";var kv=Zd(),i_=te();function Xd(t){kv.call(this,t)}i_.inherits(Xd,kv);Xd.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e};Sv.exports=Xd});var Gd=M((x2,Tv)=>{"use strict";var wa=te(),Ev=Wt(),s_=Kd(),o_=vv(),a_=Cv(),l_=Zd();Tv.exports=function(t){var e=wa.getTypeOf(t);return wa.checkSupport(e),e==="string"&&!Ev.uint8array?new o_(t):e==="nodebuffer"?new a_(t):Ev.uint8array?new l_(wa.transformTo("uint8array",t)):new s_(wa.transformTo("array",t))}});var Nv=M((k2,_v)=>{"use strict";var Yd=Gd(),bn=te(),c_=Yo(),Av=Go(),xa=Pr(),ka=Ud(),u_=Wt(),d_=0,f_=3,h_=function(t){for(var e in ka)if(Object.prototype.hasOwnProperty.call(ka,e)&&ka[e].magic===t)return ka[e];return null};function Mv(t,e){this.options=t,this.loadOptions=e}Mv.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(t){var e,n;if(t.skip(22),this.fileNameLength=t.readInt(2),n=t.readInt(2),this.fileName=t.readData(this.fileNameLength),t.skip(n),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(e=h_(this.compressionMethod),e===null)throw new Error("Corrupted zip : compression "+bn.pretty(this.compressionMethod)+" unknown (inner file : "+bn.transformTo("string",this.fileName)+")");this.decompressed=new c_(this.compressedSize,this.uncompressedSize,this.crc32,e,t.readData(this.compressedSize))},readCentralPart:function(t){this.versionMadeBy=t.readInt(2),t.skip(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4);var e=t.readInt(2);if(this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");t.skip(e),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var t=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),t===d_&&(this.dosPermissions=this.externalFileAttributes&63),t===f_&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=Yd(this.extraFields[1].value);this.uncompressedSize===bn.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===bn.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===bn.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===bn.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e=t.index+this.extraFieldsLength,n,r,i;for(this.extraFields||(this.extraFields={});t.index+4{"use strict";var p_=Gd(),Xt=te(),lt=Wd(),m_=Nv(),g_=Wt();function Ov(t){this.files=[],this.loadOptions=t}Ov.prototype={checkSignature:function(t){if(!this.reader.readAndCheckSignature(t)){this.reader.index-=4;var e=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+Xt.pretty(e)+", expected "+Xt.pretty(t)+")")}},isSignature:function(t,e){var n=this.reader.index;this.reader.setIndex(t);var r=this.reader.readString(4),i=r===e;return this.reader.setIndex(n),i},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var t=this.reader.readData(this.zipCommentLength),e=g_.uint8array?"uint8array":"array",n=Xt.transformTo(e,t);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var t=this.zip64EndOfCentralSize-44,e=0,n,r,i;e1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var t,e;for(t=0;t0)this.isSignature(n,lt.CENTRAL_FILE_HEADER)||(this.reader.zero=i);else if(i<0)throw new Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},prepareReader:function(t){this.reader=p_(t)},load:function(t){this.prepareReader(t),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};Iv.exports=Ov});var Lv=M((C2,Pv)=>{"use strict";var Qd=te(),Sa=Ir(),y_=Pr(),b_=Dv(),v_=ed(),Rv=qi();function w_(t){return new Sa.Promise(function(e,n){var r=t.decompressed.getContentWorker().pipe(new v_);r.on("error",function(i){n(i)}).on("end",function(){r.streamInfo.crc32!==t.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}Pv.exports=function(t,e){var n=this;return e=Qd.extend(e||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:y_.utf8decode}),Rv.isNode&&Rv.isStream(t)?Sa.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):Qd.prepareContent("the loaded zip file",t,!0,e.optimizedBinaryString,e.base64).then(function(r){var i=new b_(e);return i.load(r),i}).then(function(i){var s=[Sa.Promise.resolve(i)],o=i.files;if(e.checkCRC32)for(var a=0;a{"use strict";function tt(){if(!(this instanceof tt))return new tt;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var t=new tt;for(var e in this)typeof this[e]!="function"&&(t[e]=this[e]);return t}}tt.prototype=fv();tt.prototype.loadAsync=Lv();tt.support=Wt();tt.defaults=Gu();tt.version="3.10.1";tt.loadAsync=function(t,e){return new tt().loadAsync(t,e)};tt.external=Ir();Bv.exports=tt});var al=M(be=>{"use strict";var D_="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",R_="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",af="numeric",lf="ascii",cf="alpha",ks="asciinumeric",ws="alphanumeric",uf="domain",tw="emoji",P_="scheme",L_="slashscheme",nf="whitespace";function B_(t,e){return t in e||(e[t]=[]),e[t]}function nr(t,e,n){e[af]&&(e[ks]=!0,e[ws]=!0),e[lf]&&(e[ks]=!0,e[cf]=!0),e[ks]&&(e[ws]=!0),e[cf]&&(e[ws]=!0),e[ws]&&(e[uf]=!0),e[tw]&&(e[uf]=!0);for(let r in e){let i=B_(r,n);i.indexOf(t)<0&&i.push(t)}}function z_(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Be(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Be.groups={};Be.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),oe=(t,e,n,r,i)=>t.tr(e,n,r,i),Gv=(t,e,n,r,i)=>t.ts(e,n,r,i),C=(t,e,n,r,i)=>t.tt(e,n,r,i),Gt="WORD",df="UWORD",nw="ASCIINUMERICAL",rw="ALPHANUMERICAL",Ms="LOCALHOST",ff="TLD",hf="UTLD",Na="SCHEME",Qr="SLASH_SCHEME",yf="NUM",pf="WS",bf="NL",Ss="OPENBRACE",Cs="CLOSEBRACE",Da="OPENBRACKET",Ra="CLOSEBRACKET",Pa="OPENPAREN",La="CLOSEPAREN",Ba="OPENANGLEBRACKET",za="CLOSEANGLEBRACKET",Fa="FULLWIDTHLEFTPAREN",$a="FULLWIDTHRIGHTPAREN",Ha="LEFTCORNERBRACKET",Va="RIGHTCORNERBRACKET",Ua="LEFTWHITECORNERBRACKET",Wa="RIGHTWHITECORNERBRACKET",ja="FULLWIDTHLESSTHAN",qa="FULLWIDTHGREATERTHAN",Ka="AMPERSAND",Ja="APOSTROPHE",Za="ASTERISK",wn="AT",Xa="BACKSLASH",Ga="BACKTICK",Ya="CARET",xn="COLON",vf="COMMA",Qa="DOLLAR",At="DOT",el="EQUALS",wf="EXCLAMATION",rt="HYPHEN",Es="PERCENT",tl="PIPE",nl="PLUS",rl="POUND",Ts="QUERY",xf="QUOTE",iw="FULLWIDTHMIDDLEDOT",kf="SEMI",Mt="SLASH",As="TILDE",il="UNDERSCORE",sw="EMOJI",sl="SYM",ow=Object.freeze({__proto__:null,ALPHANUMERICAL:rw,AMPERSAND:Ka,APOSTROPHE:Ja,ASCIINUMERICAL:nw,ASTERISK:Za,AT:wn,BACKSLASH:Xa,BACKTICK:Ga,CARET:Ya,CLOSEANGLEBRACKET:za,CLOSEBRACE:Cs,CLOSEBRACKET:Ra,CLOSEPAREN:La,COLON:xn,COMMA:vf,DOLLAR:Qa,DOT:At,EMOJI:sw,EQUALS:el,EXCLAMATION:wf,FULLWIDTHGREATERTHAN:qa,FULLWIDTHLEFTPAREN:Fa,FULLWIDTHLESSTHAN:ja,FULLWIDTHMIDDLEDOT:iw,FULLWIDTHRIGHTPAREN:$a,HYPHEN:rt,LEFTCORNERBRACKET:Ha,LEFTWHITECORNERBRACKET:Ua,LOCALHOST:Ms,NL:bf,NUM:yf,OPENANGLEBRACKET:Ba,OPENBRACE:Ss,OPENBRACKET:Da,OPENPAREN:Pa,PERCENT:Es,PIPE:tl,PLUS:nl,POUND:rl,QUERY:Ts,QUOTE:xf,RIGHTCORNERBRACKET:Va,RIGHTWHITECORNERBRACKET:Wa,SCHEME:Na,SEMI:kf,SLASH:Mt,SLASH_SCHEME:Qr,SYM:sl,TILDE:As,TLD:ff,UNDERSCORE:il,UTLD:hf,UWORD:df,WORD:Gt,WS:pf}),Et=/[a-z]/,ei=/\p{L}/u,Oa=/\p{Emoji}/u,F_=/\ufe0f/,Tt=/\d/,Ia=/\s/,$_=Object.freeze({__proto__:null,ASCII_LETTER:Et,DIGIT:Tt,EMOJI:Oa,EMOJI_VARIATION:F_,LETTER:ei,SPACE:Ia}),Yv="\r",rf=` -`,H_="\uFE0F",V_="\u200D",sf="\uFFFC",Ma=null,_a=null;function U_(t=[]){let e={};Be.groups=e;let n=new Be;Ma==null&&(Ma=Qv(D_)),_a==null&&(_a=Qv(R_)),C(n,"'",Ja),C(n,"{",Ss),C(n,"}",Cs),C(n,"[",Da),C(n,"]",Ra),C(n,"(",Pa),C(n,")",La),C(n,"<",Ba),C(n,">",za),C(n,"\uFF08",Fa),C(n,"\uFF09",$a),C(n,"\u300C",Ha),C(n,"\u300D",Va),C(n,"\u300E",Ua),C(n,"\u300F",Wa),C(n,"\uFF1C",ja),C(n,"\uFF1E",qa),C(n,"&",Ka),C(n,"*",Za),C(n,"@",wn),C(n,"`",Ga),C(n,"^",Ya),C(n,":",xn),C(n,",",vf),C(n,"$",Qa),C(n,".",At),C(n,"=",el),C(n,"!",wf),C(n,"-",rt),C(n,"%",Es),C(n,"|",tl),C(n,"+",nl),C(n,"#",rl),C(n,"?",Ts),C(n,'"',xf),C(n,"/",Mt),C(n,";",kf),C(n,"~",As),C(n,"_",il),C(n,"\\",Xa),C(n,"\u30FB",iw);let r=oe(n,Tt,yf,{[af]:!0});oe(r,Tt,r);let i=oe(r,Et,nw,{[ks]:!0}),s=oe(r,ei,rw,{[ws]:!0}),o=oe(n,Et,Gt,{[lf]:!0});oe(o,Tt,i),oe(o,Et,o),oe(i,Tt,i),oe(i,Et,i);let a=oe(n,ei,df,{[cf]:!0});oe(a,Et),oe(a,Tt,s),oe(a,ei,a),oe(s,Tt,s),oe(s,Et),oe(s,ei,s);let l=C(n,rf,bf,{[nf]:!0}),c=C(n,Yv,pf,{[nf]:!0}),u=oe(n,Ia,pf,{[nf]:!0});C(n,sf,u),C(c,rf,l),C(c,sf,u),oe(c,Ia,u),C(u,Yv),C(u,rf),oe(u,Ia,u),C(u,sf,u);let d=oe(n,Oa,sw,{[tw]:!0});C(d,"#"),oe(d,Oa,d),C(d,H_,d);let f=C(d,V_);C(f,"#"),oe(f,Oa,d);let h=[[Et,o],[Tt,i]],p=[[Et,null],[ei,a],[Tt,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[uf]=!0:Et.test(g)?Tt.test(g)?b[ks]=!0:b[lf]=!0:b[af]=!0,Gv(n,g,g,b)}return Gv(n,"localhost",Ms,{ascii:!0}),n.jd=new Be(sl),{start:n,tokens:Object.assign({groups:e},ow)}}function aw(t,e){let n=lw(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[],s=0,o=0;for(;o=0&&(d+=n[o].length,f++),c+=n[o].length,s+=n[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function lw(t){let e=[],n=t.length,r=0;for(;r56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function vn(t,e,n,r,i){let s,o=e.length;for(let a=0;a=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}var ti={defaultProtocol:"http",events:null,format:ew,formatHref:ew,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Os(t,e=null){let n=Object.assign({},ti);t&&(n=Object.assign(n,t instanceof Os?t.o:t));let r=n.ignoreTags,i=[];for(let s=0;sn?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ti.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function ni(t,e){class n extends _s{constructor(i,s){super(i,s),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var mf=ni("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),gf=ni("text"),cw=ni("nl"),xs=ni("url",{isLink:!0,toHref(t=ti.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==Ms&&t[1].t===xn}}),uw=Object.freeze({__proto__:null,Base:_s,Email:mf,MultiToken:_s,Nl:cw,Text:gf,Url:xs,createTokenClass:ni}),nt=t=>new Be(t);function j_({groups:t}){let e=t.domain.concat([Ka,Za,wn,Xa,Ga,Ya,Qa,el,rt,yf,Es,tl,nl,rl,Mt,sl,As,il]),n=[Ja,xn,vf,At,wf,Es,Ts,xf,kf,Ba,za,Ss,Cs,Ra,Da,Pa,La,Fa,$a,Ha,Va,Ua,Wa,ja,qa],r=[Ka,Ja,Za,Xa,Ga,Ya,Qa,el,rt,Ss,Cs,Es,tl,nl,rl,Ts,Mt,sl,As,il],i=nt(),s=C(i,As);$(s,r,s),$(s,t.domain,s);let o=nt(),a=nt(),l=nt();$(i,t.domain,o),$(i,t.scheme,a),$(i,t.slashscheme,l),$(o,r,s),$(o,t.domain,o);let c=C(o,wn);C(s,wn,c),C(a,wn,c),C(l,wn,c);let u=C(s,At);$(u,r,s),$(u,t.domain,s);let d=nt();$(c,t.domain,d),$(d,t.domain,d);let f=C(d,At);$(f,t.domain,d);let h=nt(mf);$(f,t.tld,h),$(f,t.utld,h),C(c,Ms,h);let p=C(d,rt);C(p,rt,p),$(p,t.domain,d),$(h,t.domain,d),C(h,At,f),C(h,rt,p);let m=C(h,xn);$(m,t.numeric,mf);let g=C(o,rt),y=C(o,At);C(g,rt,g),$(g,t.domain,o),$(y,r,s),$(y,t.domain,o);let b=nt(xs);$(y,t.tld,b),$(y,t.utld,b),$(b,t.domain,o),$(b,r,s),C(b,At,y),C(b,rt,g),C(b,wn,c);let x=C(b,xn),w=nt(xs);$(x,t.numeric,w);let v=nt(xs),T=nt();$(v,e,v),$(v,n,T),$(T,e,v),$(T,n,T),C(b,Mt,v),C(w,Mt,v);let k=C(a,xn),E=C(l,xn),_=C(E,Mt),z=C(_,Mt);$(a,t.domain,o),C(a,At,y),C(a,rt,g),$(l,t.domain,o),C(l,At,y),C(l,rt,g),$(k,t.domain,v),C(k,Mt,v),C(k,Ts,v),$(z,t.domain,v),$(z,e,v),C(z,Mt,v);let N=[[Ss,Cs],[Da,Ra],[Pa,La],[Ba,za],[Fa,$a],[Ha,Va],[Ua,Wa],[ja,qa]];for(let X=0;X=0&&f++,i++,u++;if(f<0)i-=u,i0&&(s.push(of(gf,e,o)),o=[]),i-=f,u-=f;let h=d.t,p=n.slice(i-u,i);s.push(of(h,e,p))}}return o.length>0&&s.push(of(gf,e,o)),s}function of(t,e,n){let r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}var Ns=typeof console<"u"&&console&&console.warn||(()=>{}),Sf="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function K_(){return Be.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function J_(t,e){if(typeof e!="function")throw new Error(`linkifyjs: Invalid token plugin ${e} (expects function)`);for(let n=0;n()=>(t||n((t={exports:{}}).exports,t),t.exports),yf=(n,t)=>{for(var e in t)Er(n,e,{get:t[e],enumerable:!0})},dl=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pf(t))!gf.call(n,i)&&i!==e&&Er(n,i,{get:()=>t[i],enumerable:!(r=ff(t,i))||r.enumerable});return n};var Tr=(n,t,e)=>(e=n!=null?df(mf(n)):{},dl(t||!n||!n.__esModule?Er(e,"default",{value:n,enumerable:!0}):e,n)),bf=n=>dl(Er({},"__esModule",{value:!0}),n);var ls=hl(at=>{"use strict";var X0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Q0="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Ia="numeric",Da="ascii",Pa="alpha",dr="asciinumeric",ur="alphanumeric",Ra="domain",Rd="emoji",Y0="scheme",Z0="slashscheme",Ma="whitespace";function tb(n,t){return n in t||(t[n]=[]),t[n]}function Ge(n,t,e){t[Ia]&&(t[dr]=!0,t[ur]=!0),t[Da]&&(t[dr]=!0,t[Pa]=!0),t[dr]&&(t[ur]=!0),t[Pa]&&(t[ur]=!0),t[ur]&&(t[Ra]=!0),t[Rd]&&(t[Ra]=!0);for(let r in t){let i=tb(r,e);i.indexOf(n)<0&&i.push(n)}}function eb(n,t){let e={};for(let r in t)t[r].indexOf(n)>=0&&(e[r]=!0);return e}function Et(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Et.groups={};Et.prototype={accepts(){return!!this.t},go(n){let t=this,e=t.j[n];if(e)return e;for(let r=0;rn.ta(t,e,r,i),Z=(n,t,e,r,i)=>n.tr(t,e,r,i),Od=(n,t,e,r,i)=>n.ts(t,e,r,i),w=(n,t,e,r,i)=>n.tt(t,e,r,i),pe="WORD",La="UWORD",Ld="ASCIINUMERICAL",zd="ALPHANUMERICAL",br="LOCALHOST",za="TLD",Ba="UTLD",Oi="SCHEME",xn="SLASH_SCHEME",Va="NUM",Fa="WS",Wa="NL",fr="OPENBRACE",pr="CLOSEBRACE",Pi="OPENBRACKET",Ri="CLOSEBRACKET",Li="OPENPAREN",zi="CLOSEPAREN",Bi="OPENANGLEBRACKET",Fi="CLOSEANGLEBRACKET",$i="FULLWIDTHLEFTPAREN",Hi="FULLWIDTHRIGHTPAREN",Vi="LEFTCORNERBRACKET",Wi="RIGHTCORNERBRACKET",Ui="LEFTWHITECORNERBRACKET",ji="RIGHTWHITECORNERBRACKET",_i="FULLWIDTHLESSTHAN",Ki="FULLWIDTHGREATERTHAN",qi="AMPERSAND",Ji="APOSTROPHE",Gi="ASTERISK",Te="AT",Xi="BACKSLASH",Qi="BACKTICK",Yi="CARET",Me="COLON",Ua="COMMA",Zi="DOLLAR",Zt="DOT",ts="EQUALS",ja="EXCLAMATION",$t="HYPHEN",mr="PERCENT",es="PIPE",ns="PLUS",rs="POUND",gr="QUERY",_a="QUOTE",Bd="FULLWIDTHMIDDLEDOT",Ka="SEMI",te="SLASH",yr="TILDE",is="UNDERSCORE",Fd="EMOJI",ss="SYM",$d=Object.freeze({__proto__:null,ALPHANUMERICAL:zd,AMPERSAND:qi,APOSTROPHE:Ji,ASCIINUMERICAL:Ld,ASTERISK:Gi,AT:Te,BACKSLASH:Xi,BACKTICK:Qi,CARET:Yi,CLOSEANGLEBRACKET:Fi,CLOSEBRACE:pr,CLOSEBRACKET:Ri,CLOSEPAREN:zi,COLON:Me,COMMA:Ua,DOLLAR:Zi,DOT:Zt,EMOJI:Fd,EQUALS:ts,EXCLAMATION:ja,FULLWIDTHGREATERTHAN:Ki,FULLWIDTHLEFTPAREN:$i,FULLWIDTHLESSTHAN:_i,FULLWIDTHMIDDLEDOT:Bd,FULLWIDTHRIGHTPAREN:Hi,HYPHEN:$t,LEFTCORNERBRACKET:Vi,LEFTWHITECORNERBRACKET:Ui,LOCALHOST:br,NL:Wa,NUM:Va,OPENANGLEBRACKET:Bi,OPENBRACE:fr,OPENBRACKET:Pi,OPENPAREN:Li,PERCENT:mr,PIPE:es,PLUS:ns,POUND:rs,QUERY:gr,QUOTE:_a,RIGHTCORNERBRACKET:Wi,RIGHTWHITECORNERBRACKET:ji,SCHEME:Oi,SEMI:Ka,SLASH:te,SLASH_SCHEME:xn,SYM:ss,TILDE:yr,TLD:za,UNDERSCORE:is,UTLD:Ba,UWORD:La,WORD:pe,WS:Fa}),Qt=/[a-z]/,Sn=/\p{L}/u,Ii=/\p{Emoji}/u,nb=/\ufe0f/,Yt=/\d/,Di=/\s/,rb=Object.freeze({__proto__:null,ASCII_LETTER:Qt,DIGIT:Yt,EMOJI:Ii,EMOJI_VARIATION:nb,LETTER:Sn,SPACE:Di}),Id="\r",Aa=` +`,ib="\uFE0F",sb="\u200D",Na="\uFFFC",Ai=null,Ni=null;function ob(n=[]){let t={};Et.groups=t;let e=new Et;Ai==null&&(Ai=Dd(X0)),Ni==null&&(Ni=Dd(Q0)),w(e,"'",Ji),w(e,"{",fr),w(e,"}",pr),w(e,"[",Pi),w(e,"]",Ri),w(e,"(",Li),w(e,")",zi),w(e,"<",Bi),w(e,">",Fi),w(e,"\uFF08",$i),w(e,"\uFF09",Hi),w(e,"\u300C",Vi),w(e,"\u300D",Wi),w(e,"\u300E",Ui),w(e,"\u300F",ji),w(e,"\uFF1C",_i),w(e,"\uFF1E",Ki),w(e,"&",qi),w(e,"*",Gi),w(e,"@",Te),w(e,"`",Qi),w(e,"^",Yi),w(e,":",Me),w(e,",",Ua),w(e,"$",Zi),w(e,".",Zt),w(e,"=",ts),w(e,"!",ja),w(e,"-",$t),w(e,"%",mr),w(e,"|",es),w(e,"+",ns),w(e,"#",rs),w(e,"?",gr),w(e,'"',_a),w(e,"/",te),w(e,";",Ka),w(e,"~",yr),w(e,"_",is),w(e,"\\",Xi),w(e,"\u30FB",Bd);let r=Z(e,Yt,Va,{[Ia]:!0});Z(r,Yt,r);let i=Z(r,Qt,Ld,{[dr]:!0}),s=Z(r,Sn,zd,{[ur]:!0}),o=Z(e,Qt,pe,{[Da]:!0});Z(o,Yt,i),Z(o,Qt,o),Z(i,Yt,i),Z(i,Qt,i);let a=Z(e,Sn,La,{[Pa]:!0});Z(a,Qt),Z(a,Yt,s),Z(a,Sn,a),Z(s,Yt,s),Z(s,Qt),Z(s,Sn,s);let l=w(e,Aa,Wa,{[Ma]:!0}),c=w(e,Id,Fa,{[Ma]:!0}),u=Z(e,Di,Fa,{[Ma]:!0});w(e,Na,u),w(c,Aa,l),w(c,Na,u),Z(c,Di,u),w(u,Id),w(u,Aa),Z(u,Di,u),w(u,Na,u);let h=Z(e,Ii,Fd,{[Rd]:!0});w(h,"#"),Z(h,Ii,h),w(h,ib,h);let d=w(h,sb);w(d,"#"),Z(d,Ii,h);let f=[[Qt,o],[Yt,i]],p=[[Qt,null],[Sn,a],[Yt,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[Ra]=!0:Qt.test(g)?Yt.test(g)?b[dr]=!0:b[Da]=!0:b[Ia]=!0,Od(e,g,g,b)}return Od(e,"localhost",br,{ascii:!0}),e.jd=new Et(ss),{start:e,tokens:Object.assign({groups:t},$d)}}function Hd(n,t){let e=Vd(t.replace(/[A-Z]/g,a=>a.toLowerCase())),r=e.length,i=[],s=0,o=0;for(;o=0&&(h+=e[o].length,d++),c+=e[o].length,s+=e[o].length,o++;s-=h,o-=d,c-=h,i.push({t:u.t,v:t.slice(s-c,s),s:s-c,e:s})}return i}function Vd(n){let t=[],e=n.length,r=0;for(;r56319||r+1===e||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);t.push(o),r+=o.length}return t}function Ee(n,t,e,r,i){let s,o=t.length;for(let a=0;a=0;)s++;if(s>0){t.push(e.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)e.pop();r+=s}else e.push(n[r]),r++}return t}var Cn={defaultProtocol:"http",events:null,format:Pd,formatHref:Pd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function kr(n,t=null){let e=Object.assign({},Cn);n&&(e=Object.assign(e,n instanceof kr?n.o:n));let r=e.ignoreTags,i=[];for(let s=0;se?r.substring(0,e)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Cn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let t=this,e=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",e,this),i=n.get("tagName",e,t),s=this.toFormattedString(n),o={},a=n.get("className",e,t),l=n.get("target",e,t),c=n.get("rel",e,t),u=n.getObj("attributes",e,t),h=n.getObj("events",e,t);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:h}}};function En(n,t){class e extends vr{constructor(i,s){super(i,s),this.t=n}}for(let r in t)e.prototype[r]=t[r];return e.t=n,e}var $a=En("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ha=En("text"),Wd=En("nl"),hr=En("url",{isLink:!0,toHref(n=Cn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==br&&n[1].t===Me}}),Ud=Object.freeze({__proto__:null,Base:vr,Email:$a,MultiToken:vr,Nl:Wd,Text:Ha,Url:hr,createTokenClass:En}),Ft=n=>new Et(n);function lb({groups:n}){let t=n.domain.concat([qi,Gi,Te,Xi,Qi,Yi,Zi,ts,$t,Va,mr,es,ns,rs,te,ss,yr,is]),e=[Ji,Me,Ua,Zt,ja,mr,gr,_a,Ka,Bi,Fi,fr,pr,Ri,Pi,Li,zi,$i,Hi,Vi,Wi,Ui,ji,_i,Ki],r=[qi,Ji,Gi,Xi,Qi,Yi,Zi,ts,$t,fr,pr,mr,es,ns,rs,gr,te,ss,yr,is],i=Ft(),s=w(i,yr);B(s,r,s),B(s,n.domain,s);let o=Ft(),a=Ft(),l=Ft();B(i,n.domain,o),B(i,n.scheme,a),B(i,n.slashscheme,l),B(o,r,s),B(o,n.domain,o);let c=w(o,Te);w(s,Te,c),w(a,Te,c),w(l,Te,c);let u=w(s,Zt);B(u,r,s),B(u,n.domain,s);let h=Ft();B(c,n.domain,h),B(h,n.domain,h);let d=w(h,Zt);B(d,n.domain,h);let f=Ft($a);B(d,n.tld,f),B(d,n.utld,f),w(c,br,f);let p=w(h,$t);w(p,$t,p),B(p,n.domain,h),B(f,n.domain,h),w(f,Zt,d),w(f,$t,p);let m=w(f,Me);B(m,n.numeric,$a);let g=w(o,$t),y=w(o,Zt);w(g,$t,g),B(g,n.domain,o),B(y,r,s),B(y,n.domain,o);let b=Ft(hr);B(y,n.tld,b),B(y,n.utld,b),B(b,n.domain,o),B(b,r,s),w(b,Zt,y),w(b,$t,g),w(b,Te,c);let C=w(b,Me),M=Ft(hr);B(C,n.numeric,M);let x=Ft(hr),N=Ft();B(x,t,x),B(x,e,N),B(N,t,x),B(N,e,N),w(b,te,x),w(M,te,x);let k=w(a,Me),E=w(l,Me),T=w(E,te),$=w(T,te);B(a,n.domain,o),w(a,Zt,y),w(a,$t,g),B(l,n.domain,o),w(l,Zt,y),w(l,$t,g),B(k,n.domain,x),w(k,te,x),w(k,gr,x),B($,n.domain,x),B($,t,x),w($,te,x);let kt=[[fr,pr],[Pi,Ri],[Li,zi],[Bi,Fi],[$i,Hi],[Vi,Wi],[Ui,ji],[_i,Ki]];for(let q=0;q=0&&d++,i++,u++;if(d<0)i-=u,i0&&(s.push(Oa(Ha,t,o)),o=[]),i-=d,u-=d;let f=h.t,p=e.slice(i-u,i);s.push(Oa(f,t,p))}}return o.length>0&&s.push(Oa(Ha,t,o)),s}function Oa(n,t,e){let r=e[0].s,i=e[e.length-1].e,s=t.slice(r,i);return new n(s,e)}var wr=typeof console<"u"&&console&&console.warn||(()=>{}),qa="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",F={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ub(){return Et.groups={},F.scanner=null,F.parser=null,F.tokenQueue=[],F.pluginQueue=[],F.customSchemes=[],F.initialized=!1,F}function hb(n,t){if(typeof t!="function")throw new Error(`linkifyjs: Invalid token plugin ${t} (expects function)`);for(let e=0;e{var Pf=class{constructor(){}dehydrate(e,n={},r={}){if(!e||!e.content)return"";let i=[];e.content.forEach(a=>{let l=this.serializeNode(a);l&&i.push(l)});let s=i.join(` +3. "-" cannot repeat`);F.customSchemes.push([n,t])}function jd(){F.scanner=ob(F.customSchemes);for(let n=0;n{var sl=class{constructor(){}dehydrate(t,e={},r={}){if(!t||!t.content)return"";let i=[];t.content.forEach(a=>{let l=this.serializeNode(a);l&&i.push(l)});let s=i.join(` -`),o=Object.entries(n);return o.length>0&&(s+=` +`),o=Object.entries(e);return o.length>0&&(s+=` --- `,o.forEach(([a,l])=>{let c=l.content.map(u=>this.serializeNode(u)).join(" ").trim();s+=`[^${a}]: ${c} -`})),s}hydrate(e){let n=e.split(` +`})),s}hydrate(t){let e=t.split(` `),r=[],i={},s=null,o=[],a=()=>{if(o.length===0&&!s)return;let l=o.join(` -`).trim();if(!l&&!s)return;let c=s?.type||"body",u={id:s?.id||this.generateShortId()},d=l.match(/^(#{1,4})\s+([\s\S]*)/);if(d&&!s){let f=d[1].length;f<=3?c=`heading-${f}`:c="body",l=d[2]}r.push({type:c,attrs:u,content:this.parseInline(l)}),o=[],s=null};for(let l=0;ln.length-20){a();continue}let d=c.match(//);if(d){a(),s={id:d[1],type:d[2]};continue}if(c.trim()===""){a();continue}o.push(c)}return a(),{type:"manuscript",doc:{type:"doc",content:r},footnotes:i,comments:{}}}serializeNode(e){if(!e)return"";switch(e.type){case"heading":case"heading-1":case"heading-2":case"heading-3":let n=e.attrs?.level;return!n&&e.type.startsWith("heading-")&&(n=parseInt(e.type.split("-")[1])),`${"#".repeat(n||1)} ${this.serializeInline(e.content)}`;case"body":case"paragraph":case"supertitle":case"title":case"subtitle":case"epigraph":case"body-first":case"footnote":return this.serializeInline(e.content);case"horizontalRule":return"---";case"hardBreak":return` -`;default:return this.serializeInline(e.content)}}serializeInline(e){return!e||!Array.isArray(e)?"":e.map(n=>{if(n.type==="footnoteMarker"||n.type==="footnote")return`[^${n.attrs?.id}]`;if(n.type==="internalLink"){let i=n.attrs?.alias||n.attrs?.target;return`[[${n.attrs?.target}|${i}]]`}let r=n.text||"";return n.marks&&n.marks.forEach(i=>{switch(i.type){case"bold":r=`**${r}**`;break;case"italic":r=`*${r}*`;break;case"code":r=`\`${r}\``;break;case"strike":r=`~~${r}~~`;break;case"underline":r=`${r}`;break;case"commentHighlight":r=`${r}`;break}}),r}).join("")}parseInline(e){let n=[],r=/(\[\^([\w-]+)\])|(\[\[(.*?)(?:\|(.*?))?\]\])|(([\s\S]*?))|(\*\*(.*?)\*\*)|(\*(.*?)\*)|(`(.*?)`)|(~~(.*?)~~)|((.*?)<\/u>)/g,i=0,s;for(;(s=r.exec(e))!==null;){if(s.index>i&&n.push({type:"text",text:e.substring(i,s.index)}),s[1])n.push({type:"footnoteMarker",attrs:{id:s[2]}});else if(s[3]){let o=s[4],a=s[5]||o;n.push({type:"internalLink",attrs:{target:o,alias:a}})}else if(s[6]){let o=s[7],a=s[8];this.parseInline(a).forEach(c=>{c.type==="text"&&(c.marks||(c.marks=[]),c.marks.push({type:"commentHighlight",attrs:{threadId:o}})),n.push(c)})}else s[9]?n.push({type:"text",text:s[10],marks:[{type:"bold"}]}):s[11]?n.push({type:"text",text:s[12],marks:[{type:"italic"}]}):s[13]?n.push({type:"text",text:s[14],marks:[{type:"code"}]}):s[15]?n.push({type:"text",text:s[16],marks:[{type:"strike"}]}):s[17]&&n.push({type:"text",text:s[18],marks:[{type:"underline"}]});i=r.lastIndex}return ibl});module.exports=Bw(wN);var Q=require("obsidian");var ii=require("obsidian");function Ee(t){this.content=t}Ee.prototype={constructor:Ee,find:function(t){for(var e=0;e>1}};Ee.from=function(t){if(t instanceof Ee)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ee(e)};var vl=Ee;function Kf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Kf(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Jf(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;ce&&r(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);se)for(let s=0,o=0;oe&&((on)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new t(r,i)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new t(i,s)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?Bs(n+1,s):Bs(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new t(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};W.none=[];var Cn=class extends Error{},A=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Xf(this.content,e+this.openStart,n);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(Zf(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(S.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new t(e,r,i)}};A.empty=new A(S.empty,0,0);function Zf(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Zf(s.content,e-i-1,n-i-1)))}function Xf(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Xf(o.content,e-s-1,n,o);return a&&t.replaceChild(i,o.copy(a))}function zw(t,e,n){if(n.openStart>t.depth)throw new Cn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Cn("Inconsistent open depths");return Gf(t,e,n,0)}function Gf(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function oi(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(kn(t.nodeAfter,r),s++));for(let a=s;ai&&kl(t,e,i+1),o=r.depth>i&&kl(n,r,i+1),a=[];return oi(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(Yf(s,o),kn(Sn(s,Qf(t,e,n,r,i+1)),a)):(s&&kn(Sn(s,$s(t,e,i+1)),a),oi(e,n,i,a),o&&kn(Sn(o,$s(n,r,i+1)),a)),oi(r,null,i,a),new S(a)}function $s(t,e,n){let r=[];if(oi(null,t,n,r),t.depth>n){let i=kl(t,e,n+1);kn(Sn(i,$s(t,e,n+1)),r)}return oi(e,null,n,r),new S(r)}function Fw(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}var Hs=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new En(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new t(n,r,s)}static resolveCached(e,n){let r=zf.get(e);if(r)for(let s=0;se&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),eh(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;ln.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=S.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};ze.prototype.text=void 0;var Cl=class t extends ze{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):eh(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function eh(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var Tn=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new El(e,n);if(r.next==null)return t.empty;let i=th(r);r.next&&r.err("Unexpected trailing text");let s=Jw(Kw(i));return Zw(s,r),s}matchType(e){for(let n=0;nc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` -`)}};Tn.empty=new Tn(!0);var El=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function th(t){let e=[];do e.push(Vw(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vw(t){let e=[];do e.push(Uw(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Uw(t){let e=qw(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Ww(t,e);else break;return e}function Ff(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ww(t,e){let n=Ff(t),r=n;return t.eat(",")&&(t.next!="}"?r=Ff(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function jw(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function qw(t){if(t.eat("(")){let e=th(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=jw(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Kw(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Tn(r.indexOf(t.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ih(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),S.from(n),W.setFrom(r))}createChecked(e=null,n,r){return n=S.from(n),this.checkContent(n),new ze(this,this.computeAttrs(e),n,W.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=S.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(S.empty,!0);return s?new ze(this,e,n.append(s),W.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[s]=new t(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Xw(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}var Tl=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Xw(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},li=class t{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=oh(e,i.attrs),this.excluded=null;let s=rh(this.attrs);this.instance=s?new W(this,s):null}create(e=null){return!e&&this.instance?this.instance:new W(this,ih(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new t(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}},ar=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=vl.from(e.nodes),n.marks=vl.from(e.marks||{}),this.nodes=Vs.compile(this.spec.nodes,this),this.marks=li.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Tn.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Hf(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Hf(this,o.split(" "))}this.nodeFromJSON=i=>ze.fromJSON(this,i),this.markFromJSON=i=>W.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vs){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new Cl(r,r.defaultAttrs,e,W.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Hf(t,e){let n=[];for(let r=0;r-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Gw(t){return t.tag!=null}function Yw(t){return t.style!=null}var ut=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Gw(i))this.tags.push(i);else if(Yw(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new Us(this,n,!1);return r.addAll(e,W.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Us(this,n,!0);return r.addAll(e,W.none,n.from,n.to),A.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=Uf(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Uf(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},ah={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Qw={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},lh={ol:!0,ul:!0},ci=1,Al=2,ai=4;function Vf(t,e,n){return e!=null?(e?ci:0)|(e==="full"?Al:0):t&&t.whitespace=="pre"?ci|Al:n&~ai}var or=class{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=W.none,this.match=s||(o&ai?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(S.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ci)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=S.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ah.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Us=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=Vf(null,n.preserveWhitespace,0)|(r?ai:0);i?s=new or(i.type,i.attrs,W.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new or(null,null,W.none,!0,null,o):s=new or(e.schema.topNodeType,null,W.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&Al?"full":this.localPreserveWS||(i.options&ci)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,` -`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o(o.type?o.type.allowsMarkType(c.type):Wf(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new or(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ci)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function ex(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&lh.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function tx(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Uf(t){let e={};for(let n in t)e[n]=t[n];return e}function Wf(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l{if(s.length||o.marks.length){let a=0,l=0;for(;a=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&zs(xl(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return zs(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jf(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jf(e.marks)}};function jf(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function xl(t){return t.document||window.document}var qf=new WeakMap;function nx(t){let e=qf.get(t);return e===void 0&&qf.set(t,e=rx(t)),e}function rx(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;du)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=zs(t,f,n,r);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}var dh=65535,fh=Math.pow(2,16);function ix(t,e){return t+e*fh}function ch(t){return t&dh}function sx(t){return(t-(t&dh))/fh}var hh=1,ph=2,Ws=4,mh=8,fi=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&mh)>0}get deletedBefore(){return(this.delInfo&(hh|Ws))>0}get deletedAfter(){return(this.delInfo&(ph|Ws))>0}get deletedAcross(){return(this.delInfo&Ws)>0}},It=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=ch(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[a+s],u=this.ranges[a+o],d=l+c;if(e<=d){let f=c?e==l?-1:e==d?1:n:n,h=l+i+(f<0?0:u);if(r)return h;let p=e==(n<0?l:d)?null:ix(a/3,e-l),m=e==l?ph:e==d?hh:Ws;return(n<0?e!=l:e!=d)&&(m|=mh),new fi(h,m,p)}i+=u-c}return r?e+i:new fi(e+i,0,null)}touches(e,n){let r=0,i=ch(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;ae)break;let c=this.ranges[a+s],u=l+c;if(e<=u&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;rs&&l!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return ve.fromReplace(e,this.from,this.to,s)}invert(){return new Dt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};me.jsonID("addMark",pi);var Dt=class t extends me{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new A(Dl(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ve.fromReplace(e,this.from,this.to,r)}invert(){return new pi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};me.jsonID("removeMark",Dt);var mi=class t extends me{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ve.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ve.fromReplace(e,this.pos,this.pos+1,new A(S.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new t(n.pos,r.pos,i,s,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,A.fromJSON(e,n.slice),n.insert,!!n.structure)}};me.jsonID("replaceAround",ce);function Ol(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function ox(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),p=r.addToSet(d);for(let m=0;mt.step(l)),s.forEach(l=>t.step(l))}function ax(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof li){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,n);for(let u=0;ut.step(new Dt(o.from,o.to,o.style)))}function Rl(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l=0;l--)t.step(o[l])}function lx(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(rn;p--)m||r.index(p)>0?(m=!0,u=S.from(r.node(p).copy(u)),d++):l--;let f=S.empty,h=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new ce(i,s,i,s,new A(r,0,0),n.length,!0))}function hx(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&px(t.doc,t.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&yh(t,o,a,s),Rl(t,t.mapping.slice(s).map(a,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(a,1),f=u.map(a+o.nodeSize,1);return t.step(new ce(d,f,d+1,f-1,new A(S.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&gh(t,o,a,s),!1}})}function gh(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function yh(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(` -`))}})}function px(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function mx(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ce(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new A(S.from(o),0,0),1,!0))}function He(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<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 c=i.depth-1,u=n-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function gx(t,e,n=1,r){let i=t.doc.resolve(e),s=S.empty,o=S.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){s=S.from(i.node(a).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(a).copy(o))}t.step(new Te(e,e,new A(s.append(o),n,n),!0))}function qe(t,e){let n=t.resolve(e),r=n.index();return bh(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function yx(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&bh(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function bx(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);yh(t,u.node(),u.before(),a)}o.inlineContent&&Rl(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Te(c,l.map(e+n,-1),A.empty,!0)),r===!0){let u=t.doc.resolve(c);gh(t,u.node(),u.before(),t.steps.length)}return t}function vx(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(l,l,i);else{let d=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function gi(t,e,n=e,r=A.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return vh(i,s,r)?new Te(e,n,r):new Il(i,s,r).fit()}function vh(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Il=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=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 s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new A(s,o,a);return e>-1?new ce(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Te(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=_l(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=_l(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new A(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=_l(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new A(ui(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new A(ui(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m1||l==0||m.content.size)&&(d=g,u.push(wh(m.mark(f.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=di(this.placed,n,S.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n=0;a--){let{match:l,type:c}=this.frontier[a],u=Nl(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=di(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=di(this.placed,this.depth,S.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(S.empty,!0);n.childCount&&(this.placed=di(this.placed,this.frontier.length,n))}};function ui(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ui(t.firstChild.content,e-1,n)))}function di(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(di(t.lastChild.content,e-1,n)))}function _l(t,e){for(let n=0;n1&&(r=r.replaceChild(0,wh(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),t.copy(r)}function Nl(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!wx(n,s.content,o)?a:null}function wx(t,e,n){for(let r=n;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=xx(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function xh(t,e,n,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return t}function Sx(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=vx(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new A(S.from(r),0,0))}function Cx(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=kh(r,i);for(let o=0;o0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function kh(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(se.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}var js=class t extends me{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ve.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ve.fromReplace(e,this.pos,this.pos+1,new A(S.from(i),0,n.isLeaf?0:1))}getMap(){return It.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};me.jsonID("attr",js);var qs=class t extends me{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ve.ok(r)}getMap(){return It.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};me.jsonID("docAttr",qs);var cr=class extends Error{};cr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};cr.prototype=Object.create(Error.prototype);cr.prototype.constructor=cr;cr.prototype.name="TransformError";var ur=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new hi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new cr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=A.empty){let i=gi(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new A(S.from(r),0,0))}delete(e,n){return this.replace(e,n,A.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return kx(this,e,n,r),this}replaceRangeWith(e,n,r){return Sx(this,e,n,r),this}deleteRange(e,n){return Cx(this,e,n),this}lift(e,n){return cx(this,e,n),this}join(e,n=1){return bx(this,e,n),this}wrap(e,n){return fx(this,e,n),this}setBlockType(e,n=e,r,i=null){return hx(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return mx(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new js(e,n,r)),this}setDocAttribute(e,n){return this.step(new qs(e,n)),this}addNodeMark(e,n){return this.step(new mi(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof W)n.isInSet(r.marks)&&this.step(new lr(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new lr(e,s)),i=s.removeFromSet(i);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,n=1,r){return gx(this,e,n,r),this}addMark(e,n,r){return ox(this,e,n,r),this}removeMark(e,n,r){return ax(this,e,n,r),this}clearIncompatible(e,n,r){return Rl(this,e,n,r),this}};var Pl=Object.create(null),L=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Zs(e.min(n),e.max(n))]}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 n=0;n=0;s--){let o=n<0?fr(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):fr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ie(e.node(0))}static atStart(e){return fr(e,e,0,0,1)||new Ie(e)}static atEnd(e){return fr(e,e,e.content.size,e.childCount,-1)||new Ie(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Pl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Pl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Pl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return D.between(this.$anchor,this.$head).getBookmark()}};L.prototype.visible=!0;var Zs=class{constructor(e,n){this.$from=e,this.$to=n}},Sh=!1;function Ch(t){!Sh&&!t.parent.inlineContent&&(Sh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var D=class t extends L{constructor(e,n=e){Ch(e),Ch(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return L.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(e,n=A.empty){if(super.replace(e,n),n==A.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Xs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=L.findFrom(n,r,!0)||L.findFrom(n,-r,!0);if(s)n=s.$head;else return L.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(L.findFrom(e,-r,!0)||L.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&O.isSelectable(a))return O.create(t,n-(i<0?a.nodeSize:0))}else{let l=fr(t,a,n+i,i<0?a.childCount:0,i,s);if(l)return l}n+=a.nodeSize*i}return null}function Eh(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=u)}),t.setSelection(L.near(t.doc.resolve(o),n))}var Th=1,Js=2,Ah=4,zl=class extends ur{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Js,this}ensureMarks(e){return W.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),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(this.updated&Js)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Js,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(L.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ah,this}get scrolledIntoView(){return(this.updated&Ah)>0}};function Mh(t,e){return!e||!t?t:t.bind(e)}var Mn=class{constructor(e,n,r){this.name=e,this.init=Mh(n.init,r),this.apply=Mh(n.apply,r)}},Tx=[new Mn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mn("selection",{init(t,e){return t.selection||L.atStart(e.doc)},apply(t){return t.selection}}),new Mn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],yi=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tx.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Mn(r.key,r.spec.state,r))})}},Gs=class t{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,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new yi(e.schema,e.plugins),s=new t(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=ze.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=L.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){s[o.name]=c.fromJSON.call(l,e,n[a],s);return}}s[o.name]=o.init(e,s)}}),s}};function _h(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=_h(i,e,{})),n[r]=i}return n}var R=class{constructor(e){this.spec=e,this.props={},e.props&&_h(e.props,this,this.props),this.key=e.key?e.key.key:Nh("plugin")}getState(e){return e[this.key]}},Ll=Object.create(null);function Nh(t){return t in Ll?t+"$"+ ++Ll[t]:(Ll[t]=0,t+"$")}var F=class{constructor(e="key"){this.key=Nh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ys=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ih(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var $l=(t,e,n)=>{let r=Ih(t,n);if(!r)return!1;let i=Vl(r);if(!i){let o=r.blockRange(),a=o&&Rt(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(Hh(t,i,e,-1))return!0;if(r.parent.content.size==0&&(hr(s,"end")||O.isSelectable(s)))for(let o=r.depth;;o--){let a=gi(t.doc,r.before(o),r.after(o),A.empty);if(a&&a.slice.size1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Dh=(t,e,n)=>{let r=Ih(t,n);if(!r)return!1;let i=Vl(r);return i?Ph(t,i,e):!1},Rh=(t,e,n)=>{let r=Lh(t,n);if(!r)return!1;let i=jl(r);return i?Ph(t,i,e):!1};function Ph(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=gi(t.doc,s,l,A.empty);if(!c||c.from!=s||c instanceof Te&&c.slice.size>=l-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(D.create(u.doc,s)),n(u.scrollIntoView())}return!0}function hr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Hl=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Vl(r)}let o=s&&s.nodeBefore;return!o||!O.isSelectable(o)?!1:(e&&e(t.tr.setSelection(O.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Vl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Lh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=Lh(t,n);if(!r)return!1;let i=jl(r);if(!i)return!1;let s=i.nodeAfter;if(Hh(t,i,e,1))return!0;if(r.parent.content.size==0&&(hr(s,"start")||O.isSelectable(s))){let o=gi(t.doc,r.before(),r.after(),A.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof O,i;if(r){if(n.node.isTextblock||!qe(t.doc,n.from))return!1;i=n.from}else if(i=An(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(O.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},zh=(t,e)=>{let n=t.selection,r;if(n instanceof O){if(n.node.isTextblock||!qe(t.doc,n.to))return!1;r=n.to}else if(r=An(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Fh=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Rt(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},ql=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function Kl(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Kl(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(L.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Zl=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ie||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Kl(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(He(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Rt(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Ax(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof O&&e.selection.node.isBlock)return!r.parentOffset||!He(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,a,l=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),a=Kl(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=t&&t(i.parent,l,r);s.unshift(m||(l&&a?{type:a}:null)),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof D||e.selection instanceof Ie)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=He(u.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=He(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!l&&c&&r.node(o).type!=a){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);a&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return n&&n(u.scrollIntoView()),!0}}var Mx=Ax();var $h=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(O.create(t.doc,i))),!0)},_x=(t,e)=>(e&&e(t.tr.setSelection(new Ie(t.doc))),!0);function Nx(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||qe(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Hh(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,a,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&Nx(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&a.matchType(o[0]||s.type).validEnd){if(n){let h=e.pos+s.nodeSize,p=S.empty;for(let y=o.length-1;y>=0;y--)p=S.from(o[y].create(null,p));p=S.from(i.copy(p));let m=t.tr.step(new ce(e.pos-1,h,e.pos,h,new A(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&qe(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&l?null:L.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Rt(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&hr(s,"start",!0)&&hr(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=S.empty;for(let x=p.length-1;x>=0;x--)y=S.from(p[x].copy(y));let b=t.tr.step(new ce(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new A(y,p.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function Vh(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(D.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}var Gl=Vh(-1),Yl=Vh(1);function Uh(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&dr(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Ql(t,e=null){return function(n,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);s=new En(l,l,e.depth),e.endIndex=0;u--)s=S.from(n[u].type.create(n[u].attrs,s));t.step(new ce(e.start-(r?2:0),e.end,e.start,e.end,new A(s,0,0),n.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Rx(e,n,t,s):Px(e,n,s):!0:!1}}function Rx(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new ce(d-(a?1:0),f+(l?1:0),d+1,f-1,new A((a?S.empty:S.from(i.copy(S.empty))).append(l?S.empty:S.from(i.copy(S.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function qh(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=S.from(c?t.create():null),d=new A(S.from(t.create(null,S.from(a.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new ce(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var we=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},br=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},oc=null,Lt=function(t,e,n){let r=oc||(oc=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Lx=function(){oc=null},Pn=function(t,e,n,r){return n&&(Kh(t,e,n,r,-1)||Kh(t,e,n,r,1))},Bx=/^(img|br|input|textarea|hr)$/i;function Kh(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Je(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ei(t)||Bx.test(t.nodeName)||t.contentEditable=="false")return!1;e=we(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Je(t):0}else return!1}}function Je(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zx(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Je(t)}else if(t.parentNode&&!Ei(t))e=we(t),t=t.parentNode;else return null}}function Fx(t,e){for(;;){if(t.nodeType==3&&e2),Ke=vr||(dt?/Mac/.test(dt.platform):!1),Mp=dt?/Win/.test(dt.platform):!1,Bt=/Android \d/.test(an),Ti=!!Jh&&"webkitFontSmoothing"in Jh.documentElement.style,Ux=Ti?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Wx(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Pt(t,e){return typeof t=="number"?t:t[e]}function jx(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Zh(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=br(o);continue}let a=o,l=a==s.body,c=l?Wx(s):jx(a),u=0,d=0;if(e.topc.bottom-Pt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Pt(i,"top")-c.top:e.bottom-c.bottom+Pt(i,"bottom")),e.leftc.right-Pt(r,"right")&&(u=e.right-c.right+Pt(i,"right")),u||d)if(l)s.defaultView.scrollBy(u,d);else{let h=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let m=a.scrollLeft-h,g=a.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:br(o)}}function qx(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:_p(t.dom)}}function _p(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=br(r));return e}function Kx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Np(n,r==0?0:r-e)}function Np(t,e){for(let n=0;n=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?Zx(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Op(n,i)}function Zx(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Cc(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Xx(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Yx(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let a=t.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>r.top?i=a.posBefore:(!o&&l.right-1?i:t.docView.posFromDOM(e,n,-1)}function Ip(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let c;Ti&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=Yx(t,r,i,e))}a==null&&(a=Gx(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Xh(t){return t.top=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,bi(tn(Lt(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Je(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return tc(l.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(n<0||i==Je(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Lt(l,Je(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return bi(tn(c,1),!1)}if(s==null&&i=0)}function bi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function tc(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Rp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function tk(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Rp(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=Dp(t,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Lt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var nk=/[\u0590-\u08ac]/;function rk(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return a?!nk.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:o:Rp(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var Gh=null,Yh=null,Qh=!1;function ik(t,e,n){return Gh==e&&Yh==n?Qh:(Gh=e,Yh=n,Qh=n=="up"||n=="down"?tk(t,e,n):rk(t,e,n))}var Xe=0,ep=1,Nn=2,ft=3,Ln=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nwe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof to){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Qs&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?we(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=o;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=we(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;up&&on){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let a=r+s.border,l=o-s.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?Nn:ep,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ft:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Nn:ft}r=o}this.dirty=Nn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nn:ep;n.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},uc=class extends Ln{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},wr=class t extends Ln{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Ot.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ft||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ft&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=pc(s,0,e,r));for(let a=0;a{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ot.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Bp(u,r,n),c?l=new dc(e,n,r,i,u,d||null,f,c,s,o+1):n.isText?new eo(e,n,r,i,u,f,s):new t(e,n,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,n,r){return this.dirty==Xe&&e.eq(this.node)&&no(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new hc(this,o&&o.node,e);lk(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?W.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,i)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e,f);let h;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(c,u,d,h,e)||l.updateNextNode(c,u,d,e,f,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Nn)&&(o&&this.protectLocalComposition(e,o),Pp(this.contentDOM,this.children,e),vr&&ck(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof D)||rn+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=uk(this.node.content,o,r-n,i-n);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new uc(this,s,n,i);e.input.compositionNodes.push(o),this.children=pc(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==ft||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(no(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Lp(this.dom,this.nodeDOM,fc(this.outerDeco,this.node,n),fc(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function tp(t,e,n,r,i){Bp(r,e,t);let s=new on(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}var eo=class t extends on{constructor(e,n,r,i,s,o,a){super(e,n,r,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==ft||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new t(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ft)}get domAtom(){return!1}isText(e){return this.node.text==e}},to=class extends Ln{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},dc=class extends on{constructor(e,n,r,i,s,o,a,l,c,u){super(e,n,r,i,s,o,a,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==ft)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Pp(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s>1,a=Math.min(o,e.length);for(;s-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=wr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof wr)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function ak(t,e){return t.type.side-e.type.side}function lk(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;cs;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function ck(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function uk(t,e,n,r){for(let i=0,s=0;i=n){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function pc(t,e,n,r,i){let s=[];for(let o=0,a=0;o=n||u<=e?s.push(l):(cn&&s.push(l.slice(n-c,l.size,r)))}return s}function Ec(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(co(n)){for(l=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&O.isSelectable(d)&&i.parent&&!(d.isInline&&$x(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;c=new O(o==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,f=o;for(let h=0;h{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function fk(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,we(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Fe&&sn<=11&&(n.disabled=!0,n.disabled=!1)}function Fp(t,e){if(e instanceof O){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(op(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else op(t)}function op(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Tc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||D.between(e,n,r)}function ap(t){return t.editable&&!t.hasFocus()?!1:$p(t)}function $p(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function hk(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Pn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function mc(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&L.findFrom(s,e)}function nn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function lp(t,e,n){let r=t.state.selection;if(r instanceof D)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return nn(t,new D(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=mc(t.state,e);return i&&i instanceof O?nn(t,i):!1}else if(!(Ke&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?O.isSelectable(s)?nn(t,new O(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Ti?nn(t,new D(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return nn(t,new D(e>0?r.$to:r.$from));{let i=mc(t.state,e);return i?nn(t,i):!1}}}function ro(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wi(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mr(t,e){return e<0?pk(t):mk(t)}function pk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Ze&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(wi(a,-1))i=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(Hp(n))break;{let a=n.previousSibling;for(;a&&wi(a,-1);)i=n.parentNode,s=we(a),a=a.previousSibling;if(a)n=a,r=ro(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?gc(t,n,r):i&&gc(t,i,s)}function mk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=ro(n),s,o;for(;;)if(r{t.state==i&&zt(t)},50)}function cp(t,e){let n=t.state.doc.resolve(e);if(!(ge||Mp)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function up(t,e,n){let r=t.state.selection;if(r instanceof D&&!r.empty||n.indexOf("s")>-1||Ke&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=mc(t.state,e);if(o&&o instanceof O)return nn(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof Ie?L.near(o,e):L.findFrom(o,e);return a?nn(t,a):!1}return!1}function dp(t,e){if(!(t.state.selection instanceof D))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function fp(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function bk(t){if(!xe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fp(t,r,"true"),setTimeout(()=>fp(t,r,"false"),20)}return!1}function vk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function wk(t,e){let n=e.keyCode,r=vk(e);if(n==8||Ke&&n==72&&r=="c")return dp(t,-1)||mr(t,-1);if(n==46&&!e.shiftKey||Ke&&n==68&&r=="c")return dp(t,1)||mr(t,1);if(n==13||n==27)return!0;if(n==37||Ke&&n==66&&r=="c"){let i=n==37?cp(t,t.state.selection.from)=="ltr"?-1:1:-1;return lp(t,i,r)||mr(t,i)}else if(n==39||Ke&&n==70&&r=="c"){let i=n==39?cp(t,t.state.selection.from)=="ltr"?1:-1:1;return lp(t,i,r)||mr(t,i)}else{if(n==38||Ke&&n==80&&r=="c")return up(t,-1,r)||mr(t,-1);if(n==40||Ke&&n==78&&r=="c")return bk(t)||up(t,1,r)||mr(t,1);if(r==(Ke?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ac(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Ot.fromSchema(t.state.schema),a=Kp(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=qp[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=a.createElement(u[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` +`).trim();if(!l&&!s)return;let c=s?.type||"body",u={id:s?.id||this.generateShortId()},h=l.match(/^(#{1,4})\s+([\s\S]*)/);if(h&&!s){let d=h[1].length;d<=3?c=`heading-${d}`:c="body",l=h[2]}r.push({type:c,attrs:u,content:this.parseInline(l)}),o=[],s=null};for(let l=0;le.length-20){a();continue}let h=c.match(//);if(h){a(),s={id:h[1],type:h[2]};continue}if(c.trim()===""){a();continue}o.push(c)}return a(),{type:"manuscript",doc:{type:"doc",content:r},footnotes:i,comments:{}}}serializeNode(t){if(!t)return"";switch(t.type){case"heading":case"heading-1":case"heading-2":case"heading-3":let e=t.attrs?.level;return!e&&t.type.startsWith("heading-")&&(e=parseInt(t.type.split("-")[1])),`${"#".repeat(e||1)} ${this.serializeInline(t.content)}`;case"body":case"paragraph":case"supertitle":case"title":case"subtitle":case"epigraph":case"body-first":case"footnote":return this.serializeInline(t.content);case"horizontalRule":return"---";case"hardBreak":return` +`;default:return this.serializeInline(t.content)}}serializeInline(t){return!t||!Array.isArray(t)?"":t.map(e=>{if(e.type==="footnoteMarker"||e.type==="footnote")return`[^${e.attrs?.id}]`;if(e.type==="internalLink"){let i=e.attrs?.alias||e.attrs?.target;return`[[${e.attrs?.target}|${i}]]`}let r=e.text||"";return e.marks&&e.marks.forEach(i=>{switch(i.type){case"bold":r=`**${r}**`;break;case"italic":r=`*${r}*`;break;case"code":r=`\`${r}\``;break;case"strike":r=`~~${r}~~`;break;case"underline":r=`${r}`;break;case"commentHighlight":r=`${r}`;break}}),r}).join("")}parseInline(t){let e=[],r=/(\[\^([\w-]+)\])|(\[\[(.*?)(?:\|(.*?))?\]\])|(([\s\S]*?))|(\*\*(.*?)\*\*)|(\*(.*?)\*)|(`(.*?)`)|(~~(.*?)~~)|((.*?)<\/u>)/g,i=0,s;for(;(s=r.exec(t))!==null;){if(s.index>i&&e.push({type:"text",text:t.substring(i,s.index)}),s[1])e.push({type:"footnoteMarker",attrs:{id:s[2]}});else if(s[3]){let o=s[4],a=s[5]||o;e.push({type:"internalLink",attrs:{target:o,alias:a}})}else if(s[6]){let o=s[7],a=s[8];this.parseInline(a).forEach(c=>{c.type==="text"&&(c.marks||(c.marks=[]),c.marks.push({type:"commentHighlight",attrs:{threadId:o}})),e.push(c)})}else s[9]?e.push({type:"text",text:s[10],marks:[{type:"bold"}]}):s[11]?e.push({type:"text",text:s[12],marks:[{type:"italic"}]}):s[13]?e.push({type:"text",text:s[14],marks:[{type:"code"}]}):s[15]?e.push({type:"text",text:s[16],marks:[{type:"strike"}]}):s[17]&&e.push({type:"text",text:s[18],marks:[{type:"underline"}]});i=r.lastIndex}return ivs});module.exports=bf(Bb);var J=require("obsidian");var Mn=require("obsidian");function gt(n){this.content=n}gt.prototype={constructor:gt,find:function(n){for(var t=0;t>1}};gt.from=function(n){if(n instanceof gt)return n;var t=[];if(n)for(var e in n)t.push(e,n[e]);return new gt(t)};var Cs=gt;function xl(n,t,e){for(let r=0;;r++){if(r==n.childCount||r==t.childCount)return n.childCount==t.childCount?null:e;let i=n.child(r),s=t.child(r);if(i==s){e+=i.nodeSize;continue}if(!i.sameMarkup(s))return e;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)e++;return e}if(i.content.size||s.content.size){let o=xl(i.content,s.content,e+1);if(o!=null)return o}e+=i.nodeSize}}function Sl(n,t,e,r){for(let i=n.childCount,s=t.childCount;;){if(i==0||s==0)return i==s?null:{a:e,b:r};let o=n.child(--i),a=t.child(--s),l=o.nodeSize;if(o==a){e-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:e,b:r};if(o.isText&&o.text!=a.text){let c=0,u=Math.min(o.text.length,a.text.length);for(;ct&&r(l,i+a,s||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,t-u),Math.min(l.content.size,e-u),r,i+u)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let s="",o=!0;return this.nodesBetween(t,e,(a,l)=>{let c=a.isText?a.text.slice(Math.max(t,l)-l,e-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),s=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),s=1);st)for(let s=0,o=0;ot&&((oe)&&(a.isText?a=a.cut(Math.max(0,t-o),Math.min(a.text.length,e-o)):a=a.cut(Math.max(0,t-o-1),Math.min(a.content.size,e-o-1))),r.push(a),i+=a.nodeSize),o=l}return new n(r,i)}cutByIndex(t,e){return t==e?n.empty:t==0&&e==this.content.length?this:new n(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),s=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new n(i,s)}addToStart(t){return new n([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new n(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;ethis.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let i=this.child(e),s=r+i.nodeSize;if(s>=t)return s==t?Mr(e+1,s):Mr(e,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return n.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return n.empty;let e,r=0;for(let i=0;ithis.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(s)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;er.type.rank-i.type.rank),e}};V.none=[];var Oe=class extends Error{},S=class n{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=El(this.content,t+this.openStart,e);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(t,e){return new n(Cl(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return n.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(v.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let s=t.firstChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=t.lastChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.lastChild)i++;return new n(t,r,i)}};S.empty=new S(v.empty,0,0);function Cl(n,t,e){let{index:r,offset:i}=n.findIndex(t),s=n.maybeChild(r),{index:o,offset:a}=n.findIndex(e);if(i==t||s.isText){if(a!=e&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,t).append(n.cut(e))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Cl(s.content,t-i-1,e-i-1)))}function El(n,t,e,r){let{index:i,offset:s}=n.findIndex(t),o=n.maybeChild(i);if(s==t||o.isText)return r&&!r.canReplace(i,i,e)?null:n.cut(0,t).append(e).append(n.cut(t));let a=El(o.content,t-s-1,e,o);return a&&n.replaceChild(i,o.copy(a))}function vf(n,t,e){if(e.openStart>n.depth)throw new Oe("Inserted content deeper than insertion position");if(n.depth-e.openStart!=t.depth-e.openEnd)throw new Oe("Inconsistent open depths");return Tl(n,t,e,0)}function Tl(n,t,e,r){let i=n.index(r),s=n.node(r);if(i==t.index(r)&&r=0&&n.isText&&n.sameMarkup(t[e])?t[e]=n.withText(t[e].text+n.text):t.push(n)}function Nn(n,t,e,r){let i=(t||n).node(e),s=0,o=t?t.index(e):i.childCount;n&&(s=n.index(e),n.depth>e?s++:n.textOffset&&(Ae(n.nodeAfter,r),s++));for(let a=s;ai&&Ms(n,t,i+1),o=r.depth>i&&Ms(e,r,i+1),a=[];return Nn(null,n,i,a),s&&o&&t.index(i)==e.index(i)?(Ml(s,o),Ae(Ne(s,Al(n,t,e,r,i+1)),a)):(s&&Ae(Ne(s,Or(n,t,i+1)),a),Nn(t,e,i,a),o&&Ae(Ne(o,Or(e,r,i+1)),a)),Nn(r,null,i,a),new v(a)}function Or(n,t,e){let r=[];if(Nn(null,n,e,r),n.depth>e){let i=Ms(n,t,e+1);Ae(Ne(i,Or(n,t,e+1)),r)}return Nn(t,null,e,r),new v(r)}function wf(n,t){let e=t.depth-n.openStart,i=t.node(e).copy(n.content);for(let s=e-1;s>=0;s--)i=t.node(s).copy(v.from(i));return{start:i.resolveNoCache(n.openStart+e),end:i.resolveNoCache(i.content.size-n.openEnd-e)}}var Ir=class n{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],i=e==0?0:this.path[e*3-1]+1;for(let s=0;s0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Ie(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,s=e;for(let o=t;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new n(e,r,s)}static resolveCached(t,e){let r=fl.get(t);if(r)for(let s=0;st&&this.nodesBetween(t,e,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Nl(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=v.empty,i=0,s=r.childCount){let o=this.contentMatchAt(t).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(let l=i;le.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(e=>e.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=v.fromJSON(t,e.content),s=t.nodeType(e.type).create(e.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Tt.prototype.text=void 0;var Ns=class n extends Tt{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Nl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new n(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new n(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return t==0&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function Nl(n,t){for(let e=n.length-1;e>=0;e--)t=n[e].type.name+"("+t+")";return t}var De=class n{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new Os(t,e);if(r.next==null)return n.empty;let i=Ol(r);r.next&&r.err("Unexpected trailing text");let s=Nf(Af(i));return Of(s,r),s}matchType(t){for(let e=0;ec.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+t.indexOf(r.next[o].next);return s}).join(` +`)}};De.empty=new De(!0);var Os=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function Ol(n){let t=[];do t.push(Sf(n));while(n.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function Sf(n){let t=[];do t.push(Cf(n));while(n.next&&n.next!=")"&&n.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Cf(n){let t=Mf(n);for(;;)if(n.eat("+"))t={type:"plus",expr:t};else if(n.eat("*"))t={type:"star",expr:t};else if(n.eat("?"))t={type:"opt",expr:t};else if(n.eat("{"))t=Ef(n,t);else break;return t}function pl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let t=Number(n.next);return n.pos++,t}function Ef(n,t){let e=pl(n),r=e;return n.eat(",")&&(n.next!="}"?r=pl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:e,max:r,expr:t}}function Tf(n,t){let e=n.nodeTypes,r=e[t];if(r)return[r];let i=[];for(let s in e){let o=e[s];o.isInGroup(t)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+t+"' found"),i}function Mf(n){if(n.eat("(")){let t=Ol(n);return n.eat(")")||n.err("Missing closing paren"),t}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let t=Tf(n,n.next).map(e=>(n.inline==null?n.inline=e.isInline:n.inline!=e.isInline&&n.err("Mixing inline and block content"),{type:"name",value:e}));return n.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function Af(n){let t=[[]];return i(s(n,0),e()),t;function e(){return t.push([])-1}function r(o,a,l){let c={term:l,to:a};return t[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=e())}else if(o.type=="star"){let l=e();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=e();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c{n[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=t[r.join(",")]=new De(r.indexOf(n.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Pl(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Tt(this,this.computeAttrs(t),v.from(e),V.setFrom(r))}createChecked(t=null,e,r){return e=v.from(e),this.checkContent(e),new Tt(this,this.computeAttrs(t),e,V.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),e=v.from(e),e.size){let o=this.contentMatch.fillBefore(e);if(!o)return null;e=o.append(e)}let i=this.contentMatch.matchFragment(e),s=i&&i.fillBefore(v.empty,!0);return s?new Tt(this,t,e.append(s),V.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let r=0;r-1}allowsMarks(t){if(this.markSet==null)return!0;for(let e=0;er[s]=new n(s,e,o));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function If(n,t,e){let r=e.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${n}, got ${s}`)}}var Is=class{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?If(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}},In=class n{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=Ll(t,i.attrs),this.excluded=null;let s=Dl(this.attrs);this.instance=s?new V(this,s):null}create(t=null){return!t&&this.instance?this.instance:new V(this,Pl(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach((s,o)=>r[s]=new n(s,i++,e,o)),r}removeFromSet(t){for(var e=0;e-1}},nn=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=Cs.from(t.nodes),e.marks=Cs.from(t.marks||{}),this.nodes=Dr.compile(this.spec.nodes,this),this.marks=In.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=De.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?gl(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:gl(this,o.split(" "))}this.nodeFromJSON=i=>Tt.fromJSON(this,i),this.markFromJSON=i=>V.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof Dr){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new Ns(r,r.defaultAttrs,t,V.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function gl(n,t){let e=[];for(let r=0;r-1)&&e.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return e}function Df(n){return n.tag!=null}function Pf(n){return n.style!=null}var Ut=class n{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach(i=>{if(Df(i))this.tags.push(i);else if(Pf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=t.nodes[i.node];return s.contentMatch.matchType(s)})}parse(t,e={}){let r=new Pr(this,e,!1);return r.addAll(t,V.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new Pr(this,e,!0);return r.addAll(t,V.none,e.from,e.to),S.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;it.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=e))){if(o.getAttrs){let l=o.getAttrs(e);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(t){let e=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=bl(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in t.nodes){let s=t.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=bl(o)),o.node||o.ignore||o.mark||(o.node=i)})}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new n(t,n.schemaRules(t)))}},zl={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Rf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bl={ol:!0,ul:!0},Dn=1,Ds=2,On=4;function yl(n,t,e){return t!=null?(t?Dn:0)|(t==="full"?Ds:0):n&&n.whitespace=="pre"?Dn|Ds:e&~On}var en=class{constructor(t,e,r,i,s,o){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=V.none,this.match=s||(o&On?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(v.from(t));if(e)this.match=this.type.contentMatch.matchFragment(e);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(t.type))?(this.match=r,i):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Dn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let e=v.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!zl.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}},Pr=class{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=e.topNode,s,o=yl(null,e.preserveWhitespace,0)|(r?On:0);i?s=new en(i.type,i.attrs,V.none,!0,e.topMatch||i.type.contentMatch,o):r?s=new en(null,null,V.none,!0,null,o):s=new en(t.schema.topNodeType,null,V.none,!0,null,o),this.nodes=[s],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){t.nodeType==3?this.addTextNode(t,e):t.nodeType==1&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top,s=i.options&Ds?"full":this.localPreserveWS||(i.options&Dn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,` +`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l!l.clearMark(c)):e=e.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return e}addElementByRule(t,e,r,i){let s,o;if(e.node)if(o=this.parser.schema.nodes[e.node],o.isLeaf)this.insertNode(o.create(e.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let l=this.enter(o,e.attrs||null,r,e.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[e.mark];r=r.concat(l.create(e.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=t;typeof e.contentElement=="string"?l=t.querySelector(e.contentElement):typeof e.contentElement=="function"?l=e.contentElement(t):e.contentElement&&(l=e.contentElement),this.findAround(t,l,!0),this.addAll(l,r),this.findAround(t,l,!1)}s&&this.sync(a)&&this.open--}addAll(t,e,r,i){let s=r||0;for(let o=r?t.childNodes[r]:t.firstChild,a=i==null?null:t.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(t,s),this.addDOM(o,e);this.findAtPoint(t,s)}findPlace(t,e,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(t);if(c&&(!i||i.length>c.length+a)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o(o.type?o.type.allowsMarkType(c.type):vl(c.type,t))?(l=c.addToSet(l),!1):!0),this.nodes.push(new en(t,e,l,i,null,a)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=Dn)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let i=r.length-1;i>=0;i--)t+=r[i].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=e[a];if(c==""){if(a==e.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return o(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let e in this.parser.schema.nodes){let r=this.parser.schema.nodes[e];if(r.isTextblock&&r.defaultAttrs)return r}}};function Lf(n){for(let t=n.firstChild,e=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Bl.hasOwnProperty(r)&&e?(e.appendChild(t),t=e):r=="li"?e=t:r&&(e=null)}}function zf(n,t){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,t)}function bl(n){let t={};for(let e in n)t[e]=n[e];return t}function vl(n,t){let e=t.schema.nodes;for(let r in e){let i=e[r];if(!i.allowsMarkType(n))continue;let s=[],o=a=>{s.push(a);for(let l=0;l{if(s.length||o.marks.length){let a=0,l=0;for(;a=0;i--){let s=this.serializeMark(t.marks[i],t.isInline,e);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&Ar(Ts(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return Ar(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new n(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=wl(t.nodes);return e.text||(e.text=r=>r.text),e}static marksFromSchema(t){return wl(t.marks)}};function wl(n){let t={};for(let e in n){let r=n[e].spec.toDOM;r&&(t[e]=r)}return t}function Ts(n){return n.document||window.document}var kl=new WeakMap;function Bf(n){let t=kl.get(n);return t===void 0&&kl.set(n,t=Ff(n)),t}function Ff(n){let t=null;function e(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(e=i.slice(0,o),i=i.slice(o+1));let a,l=e?n.createElementNS(e,i):n.createElement(i),c=t[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let h in c)if(c[h]!=null){let d=h.indexOf(" ");d>0?l.setAttributeNS(h.slice(0,d),h.slice(d+1),c[h]):h=="style"&&l.style?l.style.cssText=c[h]:l.setAttribute(h,c[h])}}for(let h=u;hu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:p}=Ar(n,d,e,r);if(l.appendChild(f),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}var Hl=65535,Vl=Math.pow(2,16);function $f(n,t){return n+t*Vl}function Fl(n){return n&Hl}function Hf(n){return(n-(n&Hl))/Vl}var Wl=1,Ul=2,Rr=4,jl=8,Ln=class{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(this.delInfo&jl)>0}get deletedBefore(){return(this.delInfo&(Wl|Rr))>0}get deletedAfter(){return(this.delInfo&(Ul|Rr))>0}get deletedAcross(){return(this.delInfo&Rr)>0}},re=class n{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&n.empty)return n.empty}recover(t){let e=0,r=Fl(t);if(!this.inverted)for(let i=0;it)break;let c=this.ranges[a+s],u=this.ranges[a+o],h=l+c;if(t<=h){let d=c?t==l?-1:t==h?1:e:e,f=l+i+(d<0?0:u);if(r)return f;let p=t==(e<0?l:h)?null:$f(a/3,t-l),m=t==l?Ul:t==h?Wl:Rr;return(e<0?t!=l:t!=h)&&(m|=jl),new Ln(f,m,p)}i+=u-c}return r?t+i:new Ln(t+i,0,null)}touches(t,e){let r=0,i=Fl(e),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;at)break;let c=this.ranges[a+s],u=l+c;if(t<=u&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;e--){let i=t.getMirror(e);this.appendMap(t._maps[e].invert(),i!=null&&i>e?r-i-1:void 0)}}invert(){let t=new n;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let r=this.from;rs&&l!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),e.openStart,e.openEnd);return ct.fromReplace(t,this.from,this.to,s)}invert(){return new ie(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new n(e.pos,r.pos,this.mark)}merge(t){return t instanceof n&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new n(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(e.from,e.to,t.markFromJSON(e.mark))}};it.jsonID("addMark",Bn);var ie=class n extends it{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=new S(Fs(e.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),e.openStart,e.openEnd);return ct.fromReplace(t,this.from,this.to,r)}invert(){return new Bn(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new n(e.pos,r.pos,this.mark)}merge(t){return t instanceof n&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new n(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(e.from,e.to,t.markFromJSON(e.mark))}};it.jsonID("removeMark",ie);var Fn=class n extends it{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ct.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return ct.fromReplace(t,this.pos,this.pos+1,new S(v.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let r=this.mark.addToSet(e.marks);if(r.length==e.marks.length){for(let i=0;ir.pos?null:new n(e.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(e.from,e.to,e.gapFrom,e.gapTo,S.fromJSON(t,e.slice),e.insert,!!e.structure)}};it.jsonID("replaceAround",et);function zs(n,t,e){let r=n.resolve(t),i=e-t,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Vf(n,t,e,r){let i=[],s=[],o,a;n.doc.nodesBetween(t,e,(l,c,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,t),f=Math.min(c+l.nodeSize,e),p=r.addToSet(h);for(let m=0;mn.step(l)),s.forEach(l=>n.step(l))}function Wf(n,t,e,r){let i=[],s=0;n.doc.nodesBetween(t,e,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof In){let c=o.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,e);for(let u=0;un.step(new ie(o.from,o.to,o.style)))}function $s(n,t,e,r=e.contentMatch,i=!0){let s=n.doc.nodeAt(t),o=[],a=t+1;for(let l=0;l=0;l--)n.step(o[l])}function Uf(n,t,e){return(t==0||n.canReplace(t,n.childCount))&&(e==n.childCount||n.canReplace(0,e))}function se(n){let e=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),a=n.$from.index(r)+i,l=n.$to.indexAfter(r)-s;if(re;p--)m||r.index(p)>0?(m=!0,u=v.from(r.node(p).copy(u)),h++):l--;let d=v.empty,f=0;for(let p=s,m=!1;p>e;p--)m||i.after(p+1)=0;o--){if(r.size){let a=e[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(e[o].type.create(e[o].attrs,r))}let i=t.start,s=t.end;n.step(new et(i,s,i,s,new S(r,0,0),e.length,!0))}function Jf(n,t,e,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(t,e,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&Gf(n.doc,n.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Kl(n,o,a,s),$s(n,n.mapping.slice(s).map(a,1),r,void 0,c===null);let u=n.mapping.slice(s),h=u.map(a,1),d=u.map(a+o.nodeSize,1);return n.step(new et(h,d,h+1,d-1,new S(v.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&_l(n,o,a,s),!1}})}function _l(n,t,e,r){t.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=n.mapping.slice(r).map(e+1+s+o.index);n.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function Kl(n,t,e,r){t.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(e+1+s);n.replaceWith(o,o+1,t.type.schema.text(` +`))}})}function Gf(n,t,e){let r=n.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,e)}function Xf(n,t,e,r,i){let s=n.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");e||(e=s.type);let o=e.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(t,t+s.nodeSize,o);if(!e.validContent(s.content))throw new RangeError("Invalid content for node type "+e.name);n.step(new et(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new S(v.from(o),0,0),1,!0))}function At(n,t,e=1,r){let i=n.resolve(t),s=i.depth-e,o=r&&r[r.length-1]||i.parent;if(s<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 c=i.depth-1,u=e-2;c>s;c--,u--){let h=i.node(c),d=i.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(d,h.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||h;if(!h.canReplace(d+1,h.childCount)||!m.type.validContent(f))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Qf(n,t,e=1,r){let i=n.doc.resolve(t),s=v.empty,o=v.empty;for(let a=i.depth,l=i.depth-e,c=e-1;a>l;a--,c--){s=v.from(i.node(a).copy(s));let u=r&&r[c];o=v.from(u?u.type.create(u.attrs,o):i.node(a).copy(o))}n.step(new yt(t,t,new S(s.append(o),e,e),!0))}function It(n,t){let e=n.resolve(t),r=e.index();return ql(e.nodeBefore,e.nodeAfter)&&e.parent.canReplace(r,r+1)}function Yf(n,t){t.content.size||n.type.compatibleContent(t.type);let e=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&ql(s,o)&&r.node(i).canReplace(a,a+1))return t;if(i==0)break;t=e<0?r.before(i):r.after(i)}}function Zf(n,t,e){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(t-e),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let a=n.steps.length;if(r===!1){let u=n.doc.resolve(t+e);Kl(n,u.node(),u.before(),a)}o.inlineContent&&$s(n,t+e-1,o,s.node().contentMatchAt(s.index()),r==null);let l=n.mapping.slice(a),c=l.map(t-e);if(n.step(new yt(c,l.map(t+e,-1),S.empty,!0)),r===!0){let u=n.doc.resolve(c);_l(n,u.node(),u.before(),n.steps.length)}return n}function tp(n,t,e){let r=n.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),e))return t;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,e))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,e))return r.after(i+1);if(s=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(l,l,i);else{let h=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=h&&c.canReplaceWith(l,l,h[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function $n(n,t,e=t,r=S.empty){if(t==e&&!r.size)return null;let i=n.resolve(t),s=n.resolve(e);return Jl(i,s,r)?new yt(t,e,r):new Bs(i,s,r).fit()}function Jl(n,t,e){return!e.openStart&&!e.openEnd&&n.start()==t.start()&&n.parent.canReplace(n.index(),t.index(),e.content)}var Bs=class{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let i=0;i<=t.depth;i++){let s=t.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(t.indexAfter(i))})}for(let i=t.depth;i>0;i--)this.placed=v.from(t.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new S(s,o,a);return t>-1?new et(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new yt(r.pos,i.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){t=r;break}e=s.content}for(let e=1;e<=2;e++)for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Rs(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,h=null;if(e==1&&(o?c.matchType(o.type)||(h=c.fillBefore(v.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:h};if(e==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=Rs(t,e);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=Rs(t,e);if(i.childCount<=1&&e>0){let s=t.size-e<=e+i.size;this.unplaced=new S(Pn(t,e-1,1),e-1,s?e-1:r)}else this.unplaced=new S(Pn(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:s}){for(;this.depth>e;)this.closeFrontierNode();if(s)for(let m=0;m1||l==0||m.content.size)&&(h=g,u.push(Gl(m.mark(d.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?f:-1)))}let p=c==a.childCount;p||(f=-1),this.placed=Rn(this.placed,e,v.from(u)),this.frontier[e].match=h,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e],s=e=0;a--){let{match:l,type:c}=this.frontier[a],u=Ls(t,a,c,l,!0);if(!u||u.childCount)continue t}return{depth:e,fit:o,move:s?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Rn(this.placed,e.depth,e.fit)),t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let i=t.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,t.index(r));this.openFrontierNode(i.type,i.attrs,s)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=Rn(this.placed,this.depth,v.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(v.empty,!0);e.childCount&&(this.placed=Rn(this.placed,this.frontier.length,e))}};function Pn(n,t,e){return t==0?n.cutByIndex(e,n.childCount):n.replaceChild(0,n.firstChild.copy(Pn(n.firstChild.content,t-1,e)))}function Rn(n,t,e){return t==0?n.append(e):n.replaceChild(n.childCount-1,n.lastChild.copy(Rn(n.lastChild.content,t-1,e)))}function Rs(n,t){for(let e=0;e1&&(r=r.replaceChild(0,Gl(r.firstChild,t-1,r.childCount==1?e-1:0))),t>0&&(r=n.type.contentMatch.fillBefore(r).append(r),e<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),n.copy(r)}function Ls(n,t,e,r,i){let s=n.node(t),o=i?n.indexAfter(t):n.index(t);if(o==s.childCount&&!e.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!ep(e,s.content,o)?a:null}function ep(n,t,e){for(let r=e;r0;d--,f--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?a=d:i.before(d)==f&&o.splice(1,0,-d)}let l=o.indexOf(a),c=[],u=r.openStart;for(let d=r.content,f=0;;f++){let p=d.firstChild;if(c.push(p),f==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let f=c[d],p=np(f.type);if(p&&!f.sameMarkup(i.node(Math.abs(a)-1)))u=d;else if(p||!f.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let f=(d+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m=0&&(n.replace(t,e,r),!(n.steps.length>h));d--){let f=o[d];f<0||(t=i.before(f),e=s.after(f))}}function Xl(n,t,e,r,i){if(tr){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(v.empty,!0))}return n}function ip(n,t,e,r){if(!r.isInline&&t==e&&n.doc.resolve(t).parent.content.size){let i=tp(n.doc,t,r.type);i!=null&&(t=e=i)}n.replaceRange(t,e,new S(v.from(r),0,0))}function sp(n,t,e){let r=n.doc.resolve(t),i=n.doc.resolve(e),s=Ql(r,i);for(let o=0;o0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(t-r.start(o)==r.depth-o&&e>r.end(o)&&i.end(o)-e!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),e);n.delete(t,e)}function Ql(n,t){let e=[],r=Math.min(n.depth,t.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(st.pos+(t.depth-i)||n.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(s==t.start(i)||i==n.depth&&i==t.depth&&n.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==s-1)&&e.push(i)}return e}var Lr=class n extends it{constructor(t,e,r){super(),this.pos=t,this.attr=e,this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return ct.fail("No node at attribute step's position");let r=Object.create(null);for(let s in e.attrs)r[s]=e.attrs[s];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return ct.fromReplace(t,this.pos,this.pos+1,new S(v.from(i),0,e.isLeaf?0:1))}getMap(){return re.empty}invert(t){return new n(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new n(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(e.pos,e.attr,e.value)}};it.jsonID("attr",Lr);var zr=class n extends it{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return ct.ok(r)}getMap(){return re.empty}invert(t){return new n(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(e.attr,e.value)}};it.jsonID("docAttr",zr);var sn=class extends Error{};sn=function n(t){let e=Error.call(this,t);return e.__proto__=n.prototype,e};sn.prototype=Object.create(Error.prototype);sn.prototype.constructor=sn;sn.prototype.name="TransformError";var on=class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new zn}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new sn(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,e=-1e9;for(let r=0;r{t=Math.min(t,a),e=Math.max(e,l)})}return t==1e9?null:{from:t,to:e}}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,r=S.empty){let i=$n(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new S(v.from(r),0,0))}delete(t,e){return this.replace(t,e,S.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return rp(this,t,e,r),this}replaceRangeWith(t,e,r){return ip(this,t,e,r),this}deleteRange(t,e){return sp(this,t,e),this}lift(t,e){return jf(this,t,e),this}join(t,e=1){return Zf(this,t,e),this}wrap(t,e){return qf(this,t,e),this}setBlockType(t,e=t,r,i=null){return Jf(this,t,e,r,i),this}setNodeMarkup(t,e,r=null,i){return Xf(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new Lr(t,e,r)),this}setDocAttribute(t,e){return this.step(new zr(t,e)),this}addNodeMark(t,e){return this.step(new Fn(t,e)),this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(e instanceof V)e.isInSet(r.marks)&&this.step(new rn(t,e));else{let i=r.marks,s,o=[];for(;s=e.isInSet(i);)o.push(new rn(t,s)),i=s.removeFromSet(i);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(t,e=1,r){return Qf(this,t,e,r),this}addMark(t,e,r){return Vf(this,t,e,r),this}removeMark(t,e,r){return Wf(this,t,e,r),this}clearIncompatible(t,e,r){return $s(this,t,e,r),this}};var Hs=Object.create(null),R=class{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new $r(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e=0;s--){let o=e<0?ln(t.node(0),t.node(s),t.before(s+1),t.index(s),e,r):ln(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,r);if(o)return o}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new xt(t.node(0))}static atStart(t){return ln(t,t,0,0,1)||new xt(t)}static atEnd(t){return ln(t,t,t.content.size,t.childCount,-1)||new xt(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Hs[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Hs)throw new RangeError("Duplicate use of selection JSON ID "+t);return Hs[t]=e,e.prototype.jsonID=t,e}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};R.prototype.visible=!0;var $r=class{constructor(t,e){this.$from=t,this.$to=e}},Yl=!1;function Zl(n){!Yl&&!n.parent.inlineContent&&(Yl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var I=class n extends R{constructor(t,e=t){Zl(t),Zl(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return R.near(r);let i=t.resolve(e.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(t,e=S.empty){if(super.replace(t,e),e==S.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof n&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Hr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if((!r||i)&&(r=i>=0?1:-1),!e.parent.inlineContent){let s=R.findFrom(e,r,!0)||R.findFrom(e,-r,!0);if(s)e=s.$head;else return R.near(e,r)}return t.parent.inlineContent||(i==0?t=e:(t=(R.findFrom(t,-r,!0)||R.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let a=t.child(o);if(a.isAtom){if(!s&&A.isSelectable(a))return A.create(n,e-(i<0?a.nodeSize:0))}else{let l=ln(n,a,e+i,i<0?a.childCount:0,i,s);if(l)return l}e+=a.nodeSize*i}return null}function tc(n,t,e){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(R.near(n.doc.resolve(o),e))}var ec=1,Fr=2,nc=4,Us=class extends on{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=Fr,this}ensureMarks(t){return V.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Fr)>0}addStep(t,e){super.addStep(t,e),this.updated=this.updated&~Fr,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||V.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null)return t?this.replaceSelectionWith(i.text(t),!0):this.deleteSelection();{if(r==null&&(r=e),!t)return this.deleteRange(e,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(e);s=r==e?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,i.text(t,s)),!this.selection.empty&&this.selection.to==e+t.length&&this.setSelection(R.near(this.selection.$to)),this}}setMeta(t,e){return this.meta[typeof t=="string"?t:t.key]=e,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=nc,this}get scrolledIntoView(){return(this.updated&nc)>0}};function rc(n,t){return!t||!n?n:n.bind(t)}var Re=class{constructor(t,e,r){this.name=t,this.init=rc(e.init,r),this.apply=rc(e.apply,r)}},ap=[new Re("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Re("selection",{init(n,t){return n.selection||R.atStart(t.doc)},apply(n){return n.selection}}),new Re("storedMarks",{init(n){return n.storedMarks||null},apply(n,t,e,r){return r.selection.$cursor?n.storedMarks:null}}),new Re("scrollToSelection",{init(){return 0},apply(n,t){return n.scrolledIntoView?t+1:t}})],Hn=class{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ap.slice(),e&&e.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Re(r.key,r.spec.state,r))})}},Vr=class n{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;rr.toJSON())),t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],s=i.spec.state;s&&s.toJSON&&(e[r]=s.toJSON.call(i,this[i.key]))}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Hn(t.schema,t.plugins),s=new n(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Tt.fromJSON(t.schema,e.doc);else if(o.name=="selection")s.selection=R.fromJSON(s.doc,e.selection);else if(o.name=="storedMarks")e.storedMarks&&(s.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(e,a)){s[o.name]=c.fromJSON.call(l,t,e[a],s);return}}s[o.name]=o.init(t,s)}}),s}};function ic(n,t,e){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(t):r=="handleDOMEvents"&&(i=ic(i,t,{})),e[r]=i}return e}var D=class{constructor(t){this.spec=t,this.props={},t.props&&ic(t.props,this,this.props),this.key=t.key?t.key.key:sc("plugin")}getState(t){return t[this.key]}},Vs=Object.create(null);function sc(n){return n in Vs?n+"$"+ ++Vs[n]:(Vs[n]=0,n+"$")}var z=class{constructor(t="key"){this.key=sc(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}};var Wr=(n,t)=>n.selection.empty?!1:(t&&t(n.tr.deleteSelection().scrollIntoView()),!0);function ac(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("backward",n):e.parentOffset>0)?null:e}var _s=(n,t,e)=>{let r=ac(n,e);if(!r)return!1;let i=qs(r);if(!i){let o=r.blockRange(),a=o&&se(o);return a==null?!1:(t&&t(n.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(gc(n,i,t,-1))return!0;if(r.parent.content.size==0&&(cn(s,"end")||A.isSelectable(s)))for(let o=r.depth;;o--){let a=$n(n.doc,r.before(o),r.after(o),S.empty);if(a&&a.slice.size1)break}return s.isAtom&&i.depth==r.depth-1?(t&&t(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},lc=(n,t,e)=>{let r=ac(n,e);if(!r)return!1;let i=qs(r);return i?uc(n,i,t):!1},cc=(n,t,e)=>{let r=hc(n,e);if(!r)return!1;let i=Xs(r);return i?uc(n,i,t):!1};function uc(n,t,e){let r=t.nodeBefore,i=r,s=t.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=t.nodeAfter,a=o,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=$n(n.doc,s,l,S.empty);if(!c||c.from!=s||c instanceof yt&&c.slice.size>=l-s)return!1;if(e){let u=n.tr.step(c);u.setSelection(I.create(u.doc,s)),e(u.scrollIntoView())}return!0}function cn(n,t,e=!1){for(let r=n;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(e&&r.childCount!=1)return!1}return!1}var Ks=(n,t,e)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(e?!e.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=qs(r)}let o=s&&s.nodeBefore;return!o||!A.isSelectable(o)?!1:(t&&t(n.tr.setSelection(A.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function qs(n){if(!n.parent.type.spec.isolating)for(let t=n.depth-1;t>=0;t--){if(n.index(t)>0)return n.doc.resolve(n.before(t+1));if(n.node(t).type.spec.isolating)break}return null}function hc(n,t){let{$cursor:e}=n.selection;return!e||(t?!t.endOfTextblock("forward",n):e.parentOffset{let r=hc(n,e);if(!r)return!1;let i=Xs(r);if(!i)return!1;let s=i.nodeAfter;if(gc(n,i,t,1))return!0;if(r.parent.content.size==0&&(cn(s,"start")||A.isSelectable(s))){let o=$n(n.doc,r.before(),r.after(),S.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(e?!e.endOfTextblock("forward",n):r.parentOffset=0;t--){let e=n.node(t);if(n.index(t)+1{let e=n.selection,r=e instanceof A,i;if(r){if(e.node.isTextblock||!It(n.doc,e.from))return!1;i=e.from}else if(i=Pe(n.doc,e.from,-1),i==null)return!1;if(t){let s=n.tr.join(i);r&&s.setSelection(A.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),t(s.scrollIntoView())}return!0},fc=(n,t)=>{let e=n.selection,r;if(e instanceof A){if(e.node.isTextblock||!It(n.doc,e.to))return!1;r=e.to}else if(r=Pe(n.doc,e.to,1),r==null)return!1;return t&&t(n.tr.join(r).scrollIntoView()),!0},pc=(n,t)=>{let{$from:e,$to:r}=n.selection,i=e.blockRange(r),s=i&&se(i);return s==null?!1:(t&&t(n.tr.lift(i,s).scrollIntoView()),!0)},Qs=(n,t)=>{let{$head:e,$anchor:r}=n.selection;return!e.parent.type.spec.code||!e.sameParent(r)?!1:(t&&t(n.tr.insertText(` +`).scrollIntoView()),!0)};function Ys(n){for(let t=0;t{let{$head:e,$anchor:r}=n.selection;if(!e.parent.type.spec.code||!e.sameParent(r))return!1;let i=e.node(-1),s=e.indexAfter(-1),o=Ys(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(t){let a=e.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(R.near(l.doc.resolve(a),1)),t(l.scrollIntoView())}return!0},to=(n,t)=>{let e=n.selection,{$from:r,$to:i}=e;if(e instanceof xt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ys(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let o=(!r.parentOffset&&i.index(){let{$cursor:e}=n.selection;if(!e||e.parent.content.size)return!1;if(e.depth>1&&e.after()!=e.end(-1)){let s=e.before();if(At(n.doc,s))return t&&t(n.tr.split(s).scrollIntoView()),!0}let r=e.blockRange(),i=r&&se(r);return i==null?!1:(t&&t(n.tr.lift(r,i).scrollIntoView()),!0)};function lp(n){return(t,e)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof A&&t.selection.node.isBlock)return!r.parentOffset||!At(t.doc,r.pos)?!1:(e&&e(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,a,l=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){l=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),a=Ys(r.node(f-1).contentMatchAt(r.indexAfter(f-1)));let m=n&&n(i.parent,l,r);s.unshift(m||(l&&a?{type:a}:null)),o=f;break}else{if(f==1)return!1;s.unshift(null)}let u=t.tr;(t.selection instanceof I||t.selection instanceof xt)&&u.deleteSelection();let h=u.mapping.map(r.pos),d=At(u.doc,h,s.length,s);if(d||(s[0]=a?{type:a}:null,d=At(u.doc,h,s.length,s)),!d)return!1;if(u.split(h,s.length,s),!l&&c&&r.node(o).type!=a){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);a&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(o)),a)}return e&&e(u.scrollIntoView()),!0}}var cp=lp();var mc=(n,t)=>{let{$from:e,to:r}=n.selection,i,s=e.sharedDepth(r);return s==0?!1:(i=e.before(s),t&&t(n.tr.setSelection(A.create(n.doc,i))),!0)},up=(n,t)=>(t&&t(n.tr.setSelection(new xt(n.doc))),!0);function hp(n,t,e){let r=t.nodeBefore,i=t.nodeAfter,s=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(s-1,s)?(e&&e(n.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(s,s+1)||!(i.isTextblock||It(n.doc,t.pos))?!1:(e&&e(n.tr.join(t.pos).scrollIntoView()),!0)}function gc(n,t,e,r){let i=t.nodeBefore,s=t.nodeAfter,o,a,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&hp(n,t,e))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(a=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&a.matchType(o[0]||s.type).validEnd){if(e){let f=t.pos+s.nodeSize,p=v.empty;for(let y=o.length-1;y>=0;y--)p=v.from(o[y].create(null,p));p=v.from(i.copy(p));let m=n.tr.step(new et(t.pos-1,f,t.pos,f,new S(p,1,0),o.length,!0)),g=m.doc.resolve(f+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&It(m.doc,g.pos)&&m.join(g.pos),e(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&l?null:R.findFrom(t,1),h=u&&u.$from.blockRange(u.$to),d=h&&se(h);if(d!=null&&d>=t.depth)return e&&e(n.tr.lift(h,d).scrollIntoView()),!0;if(c&&cn(s,"start",!0)&&cn(i,"end")){let f=i,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(e){let y=v.empty;for(let C=p.length-1;C>=0;C--)y=v.from(p[C].copy(y));let b=n.tr.step(new et(t.pos-p.length,t.pos+s.nodeSize,t.pos+g,t.pos+s.nodeSize-g,new S(y,p.length,0),0,!0));e(b.scrollIntoView())}return!0}}return!1}function yc(n){return function(t,e){let r=t.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(e&&e(t.tr.setSelection(I.create(t.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var no=yc(-1),ro=yc(1);function bc(n,t=null){return function(e,r){let{$from:i,$to:s}=e.selection,o=i.blockRange(s),a=o&&an(o,n,t);return a?(r&&r(e.tr.wrap(o,a).scrollIntoView()),!0):!1}}function io(n,t=null){return function(e,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(n,t)))if(l.type==n)i=!0;else{let u=e.doc.resolve(c),h=u.index();i=u.parent.canReplaceWith(h,h+1,n)}})}if(!i)return!1;if(r){let s=e.tr;for(let o=0;o=2&&t.$from.node(t.depth-1).type.compatibleContent(e)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let l=o.resolve(t.start-2);s=new Ie(l,l,t.depth),t.endIndex=0;u--)s=v.from(e[u].type.create(e[u].attrs,s));n.step(new et(t.start-(r?2:0),t.end,t.start,t.end,new S(s,0,0),e.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return s?e?r.node(s.depth-1).type==n?mp(t,e,n,s):gp(t,e,s):!0:!1}}function mp(n,t,e,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)f-=i.child(p).nodeSize,r.delete(f-1,f+1);let s=r.doc.resolve(e.start),o=s.nodeAfter;if(r.mapping.map(e.end)!=e.start+s.nodeAfter.nodeSize)return!1;let a=e.startIndex==0,l=e.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(a?0:1),u+1,o.content.append(l?v.empty:v.from(i))))return!1;let h=s.pos,d=h+o.nodeSize;return r.step(new et(h-(a?1:0),d+(l?1:0),h+1,d-1,new S((a?v.empty:v.from(i.copy(v.empty))).append(l?v.empty:v.from(i.copy(v.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}function kc(n){return function(t,e){let{$from:r,$to:i}=t.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=n)return!1;if(e){let c=l.lastChild&&l.lastChild.type==a.type,u=v.from(c?n.create():null),h=new S(v.from(n.create(null,v.from(a.type.create(null,u)))),c?3:1,0),d=s.start,f=s.end;e(t.tr.step(new et(d-(c?3:1),f,d,f,h,1,!0)).scrollIntoView())}return!0}}var ut=function(n){for(var t=0;;t++)if(n=n.previousSibling,!n)return t},pn=function(n){let t=n.assignedSlot||n.parentNode;return t&&t.nodeType==11?t.host:t},ho=null,ae=function(n,t,e){let r=ho||(ho=document.createRange());return r.setEnd(n,e??n.nodeValue.length),r.setStart(n,t||0),r},yp=function(){ho=null},Ve=function(n,t,e,r){return e&&(xc(n,t,e,r,-1)||xc(n,t,e,r,1))},bp=/^(img|br|input|textarea|hr)$/i;function xc(n,t,e,r,i){for(var s;;){if(n==e&&t==r)return!0;if(t==(i<0?0:Pt(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Jn(n)||bp.test(n.nodeName)||n.contentEditable=="false")return!1;t=ut(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[t+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)t+=i;else return!1;else n=o,t=i<0?Pt(n):0}else return!1}}function Pt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function vp(n,t){for(;;){if(n.nodeType==3&&t)return n;if(n.nodeType==1&&t>0){if(n.contentEditable=="false")return null;n=n.childNodes[t-1],t=Pt(n)}else if(n.parentNode&&!Jn(n))t=ut(n),n=n.parentNode;else return null}}function wp(n,t){for(;;){if(n.nodeType==3&&t2),Dt=mn||(jt?/Mac/.test(jt.platform):!1),ru=jt?/Win/.test(jt.platform):!1,le=/Android \d/.test(Ce),Gn=!!Sc&&"webkitFontSmoothing"in Sc.documentElement.style,Cp=Gn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ep(n){let t=n.defaultView&&n.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function oe(n,t){return typeof n=="number"?n:n[t]}function Tp(n){let t=n.getBoundingClientRect(),e=t.width/n.offsetWidth||1,r=t.height/n.offsetHeight||1;return{left:t.left,right:t.left+n.clientWidth*e,top:t.top,bottom:t.top+n.clientHeight*r}}function Cc(n,t,e){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=e||n.dom;o;){if(o.nodeType!=1){o=pn(o);continue}let a=o,l=a==s.body,c=l?Ep(s):Tp(a),u=0,h=0;if(t.topc.bottom-oe(r,"bottom")&&(h=t.bottom-t.top>c.bottom-c.top?t.top+oe(i,"top")-c.top:t.bottom-c.bottom+oe(i,"bottom")),t.leftc.right-oe(r,"right")&&(u=t.right-c.right+oe(i,"right")),u||h)if(l)s.defaultView.scrollBy(u,h);else{let f=a.scrollLeft,p=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let m=a.scrollLeft-f,g=a.scrollTop-p;t={left:t.left-m,top:t.top-g,right:t.right-m,bottom:t.bottom-g}}let d=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:pn(o)}}function Mp(n){let t=n.dom.getBoundingClientRect(),e=Math.max(0,t.top),r,i;for(let s=(t.left+t.right)/2,o=e+1;o=e-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:iu(n.dom)}}function iu(n){let t=[],e=n.ownerDocument;for(let r=n;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=e);r=pn(r));return t}function Ap({refDOM:n,refTop:t,stack:e}){let r=n?n.getBoundingClientRect().top:0;su(e,r==0?0:r-t)}function su(n,t){for(let e=0;e=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!l&&p.left<=t.left&&p.right>=t.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!e&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(s=h+1)}}return!e&&l&&(e=l,i=c,r=0),e&&e.nodeType==3?Op(e,i):!e||r&&e.nodeType==1?{node:n,offset:s}:ou(e,i)}function Op(n,t){let e=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Oo(n,t){return n.left>=t.left-1&&n.left<=t.right+1&&n.top>=t.top-1&&n.top<=t.bottom+1}function Ip(n,t){let e=n.parentNode;return e&&/^li$/i.test(e.nodeName)&&t.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Pp(n,t,e,r){let i=-1;for(let s=t,o=!1;s!=n.dom;){let a=n.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>r.top?i=a.posBefore:(!o&&l.right-1?i:n.docView.posFromDOM(t,e,-1)}function au(n,t,e){let r=n.childNodes.length;if(r&&e.topt.top&&i++}let c;Gn&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=Pp(n,r,i,t))}a==null&&(a=Dp(n,o,t));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Ec(n){return n.top=0&&i==r.nodeValue.length?(l--,u=1):e<0?l--:c++,Vn(ve(ae(r,l,c),u),u<0)}if(!n.state.doc.resolve(t-(s||0)).parent.inlineContent){if(s==null&&i&&(e<0||i==Pt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return oo(l.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(e<0||i==Pt(r))){let l=r.childNodes[i-1],c=l.nodeType==3?ae(l,Pt(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Vn(ve(c,1),!1)}if(s==null&&i=0)}function Vn(n,t){if(n.width==0)return n;let e=t?n.left:n.right;return{top:n.top,bottom:n.bottom,left:e,right:e}}function oo(n,t){if(n.height==0)return n;let e=t?n.top:n.bottom;return{top:e,bottom:e,left:n.left,right:n.right}}function cu(n,t,e){let r=n.state,i=n.root.activeElement;r!=t&&n.updateState(t),i!=n.dom&&n.focus();try{return e()}finally{r!=t&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function zp(n,t,e){let r=t.selection,i=e=="up"?r.$from:r.$to;return cu(n,t,()=>{let{node:s}=n.docView.domFromPos(i.pos,e=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=lu(n,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=ae(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(e=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var Bp=/[\u0590-\u08ac]/;function Fp(n,t,e){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=n.domSelection();return a?!Bp.test(r.parent.textContent)||!a.modify?e=="left"||e=="backward"?s:o:cu(n,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:h}=n.domSelectionRange(),d=a.caretBidiLevel;a.modify("move",e,"character");let f=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,h),l&&(l!=u||c!=h)&&a.extend&&a.extend(l,c)}catch{}return d!=null&&(a.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}var Tc=null,Mc=null,Ac=!1;function $p(n,t,e){return Tc==t&&Mc==e?Ac:(Tc=t,Mc=e,Ac=e=="up"||e=="down"?zp(n,t,e):Fp(n,t,e))}var Lt=0,Nc=1,ze=2,_t=3,We=class{constructor(t,e,r,i){this.parent=t,this.children=e,this.dom=r,this.contentDOM=i,this.dirty=Lt,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;eut(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(e==0)for(let s=t;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let s=t;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let r=!0,i=t;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!e||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(t.nodeType==1?t:t.parentNode):o==t))r=!1;else return s}}getDesc(t){let e=t.pmViewDesc;for(let r=e;r;r=r.parent)if(r==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;et||o instanceof _r){i=t-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ur&&s.side>=0;r--);if(e<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&e&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,e):{node:this.contentDOM,offset:s?ut(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&e<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,e,u);t=o;for(let h=a;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ut(d.dom)+1;break}t-=d.size}i==-1&&(i=0)}if(i>-1&&(c>e||a==this.children.length-1)){e=c;for(let u=a+1;up&&oe){let p=a;a=l,l=p}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i=r:tr){let a=r+s.border,l=o-s.border;if(t>=a&&e<=l){this.dirty=t==r||e==o?ze:Nc,t==a&&e==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=_t:s.markDirty(t-a,e-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ze:_t}r=o}this.dirty=ze}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?ze:Nc;e.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!e.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(t,[],o,null),this.widget=e,this.widget=e,s=this}matchesWidget(t){return this.dirty==Lt&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},go=class extends We{constructor(t,e,r,i){super(t,[],e,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},gn=class n extends We{constructor(t,e,r,i,s){super(t,[],r,i),this.mark=e,this.spec=s}static create(t,e,r,i){let s=i.nodeViews[e.type.name],o=s&&s(e,i,r);return(!o||!o.dom)&&(o=ne.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs)),new n(t,e,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&_t||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=_t&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),this.dirty!=Lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=wo(s,0,t,r));for(let a=0;a{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,h=c&&c.contentDOM;if(e.isText){if(!u)u=document.createTextNode(e.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=ne.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs));!h&&!e.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),e.type.spec.draggable&&(u.draggable=!0));let d=u;return u=du(u,r,e),c?l=new yo(t,e,r,i,u,h||null,d,c,s,o+1):e.isText?new jr(t,e,r,i,u,d,s):new n(t,e,r,i,u,h||null,d,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=()=>v.empty)}return t}matchesNode(t,e,r){return this.dirty==Lt&&t.eq(this.node)&&Kr(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e,s=t.composing?this.localCompositionInfo(t,e):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new vo(this,o&&o.node,t);Up(this.node,this.innerDeco,(c,u,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,t,u):c.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?V.none:this.node.child(u).marks,r,t,u),l.placeWidget(c,t,i)},(c,u,h,d)=>{l.syncToMarks(c.marks,r,t,d);let f;l.findNodeMatch(c,u,h,d)||a&&t.state.selection.from>i&&t.state.selection.to-1&&l.updateNodeAt(c,u,h,f,t)||l.updateNextNode(c,u,h,t,d,i)||l.addNode(c,u,h,t,i),i+=c.nodeSize}),l.syncToMarks([],r,t,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==ze)&&(o&&this.protectLocalComposition(t,o),uu(this.contentDOM,this.children,t),mn&&jp(this.dom))}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof I)||re+this.node.content.size)return null;let s=t.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=_p(this.node.content,o,r-e,i-e);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let s=e;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new go(this,s,e,i);t.input.compositionNodes.push(o),this.children=wo(this.children,r,r+i.length,t,o)}update(t,e,r,i){return this.dirty==_t||!t.sameMarkup(this.node)?!1:(this.updateInner(t,e,r,i),!0)}updateInner(t,e,r,i){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Lt}updateOuterDeco(t){if(Kr(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=hu(this.dom,this.nodeDOM,bo(this.outerDeco,this.node,e),bo(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Oc(n,t,e,r,i){du(r,t,n);let s=new Se(void 0,n,t,e,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}var jr=class n extends Se{constructor(t,e,r,i,s,o,a){super(t,e,r,i,s,null,o,a,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,r,i){return this.dirty==_t||this.dirty!=Lt&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(e),(this.dirty!=Lt||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=Lt,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),s=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length)&&(this.dirty=_t)}get domAtom(){return!1}isText(t){return this.node.text==t}},_r=class extends We{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==Lt&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},yo=class extends Se{constructor(t,e,r,i,s,o,a,l,c,u){super(t,e,r,i,s,o,a,c,u),this.spec=l}update(t,e,r,i){if(this.dirty==_t)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let s=this.spec.update(t,e,r);return s&&this.updateInner(t,e,r,i),s}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,e,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function uu(n,t,e){let r=n.firstChild,i=!1;for(let s=0;s>1,a=Math.min(o,t.length);for(;s-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=gn.create(this.top,t[o],e,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(t,e,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let c=e.children[r-1];if(c instanceof gn)e=c,r=c.children.length;else{a=c,r--;break}}else{if(e==t)break t;r=e.parent.children.indexOf(e),e=e.parent}let l=a.node;if(l){if(l!=n.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function Wp(n,t){return n.type.side-t.type.side}function Up(n,t,e,r){let i=t.locals(n),s=0;if(i.length==0){for(let c=0;cs;)a.push(i[o++]);let p=s+d.nodeSize;if(d.isText){let g=p;o!g.inline):a.slice();r(d,m,t.forChild(s,d),f),s=p}}function jp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let t=n.style.cssText;n.style.cssText=t+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=t}}function _p(n,t,e,r){for(let i=0,s=0;i=e){if(s>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let c=a=0&&c+t.length+a>=e)return a+c;if(e==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}function wo(n,t,e,r,i){let s=[];for(let o=0,a=0;o=e||u<=t?s.push(l):(ce&&s.push(l.slice(e-c,l.size,r)))}return s}function Io(n,t=null){let e=n.domSelectionRange(),r=n.state.doc;if(!e.focusNode)return null;let i=n.docView.nearestDesc(e.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(Zr(e)){for(l=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&A.isSelectable(h)&&i.parent&&!(h.isInline&&kp(e.focusNode,e.focusOffset,i.dom))){let d=i.posBefore;c=new A(o==d?a:r.resolve(d))}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let h=o,d=o;for(let f=0;f{(e.anchorNode!=r||e.anchorOffset!=i)&&(t.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!fu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function qp(n){let t=n.domSelection();if(!t)return;let e=n.cursorWrapper.dom,r=e.nodeName=="IMG";r?t.collapse(e.parentNode,ut(e)+1):t.collapse(e,0),!r&&!n.state.selection.visible&&Mt&&xe<=11&&(e.disabled=!0,e.disabled=!1)}function pu(n,t){if(t instanceof A){let e=n.docView.descAt(t.from);e!=n.lastSelectedViewDesc&&(Lc(n),e&&e.selectNode(),n.lastSelectedViewDesc=e)}else Lc(n)}function Lc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Do(n,t,e,r){return n.someProp("createSelectionBetween",i=>i(n,t,e))||I.between(t,e,r)}function zc(n){return n.editable&&!n.hasFocus()?!1:mu(n)}function mu(n){let t=n.domSelectionRange();if(!t.anchorNode)return!1;try{return n.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(n.editable||n.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Jp(n){let t=n.docView.domFromPos(n.state.selection.anchor,0),e=n.domSelectionRange();return Ve(t.node,t.offset,e.anchorNode,e.anchorOffset)}function ko(n,t){let{$anchor:e,$head:r}=n.selection,i=t>0?e.max(r):e.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(t>0?i.after():i.before()):null:i;return s&&R.findFrom(s,t)}function we(n,t){return n.dispatch(n.state.tr.setSelection(t).scrollIntoView()),!0}function Bc(n,t,e){let r=n.state.selection;if(r instanceof I)if(e.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(t<0?-1:1));return we(n,new I(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(t>0?"forward":"backward")){let i=ko(n.state,t);return i&&i instanceof A?we(n,i):!1}else if(!(Dt&&e.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=t<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?A.isSelectable(s)?we(n,new A(t<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Gn?we(n,new I(n.state.doc.resolve(t<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return we(n,new I(t>0?r.$to:r.$from));{let i=ko(n.state,t);return i?we(n,i):!1}}}function qr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Un(n,t){let e=n.pmViewDesc;return e&&e.size==0&&(t<0||n.nextSibling||n.nodeName!="BR")}function hn(n,t){return t<0?Gp(n):Xp(n)}function Gp(n){let t=n.domSelectionRange(),e=t.focusNode,r=t.focusOffset;if(!e)return;let i,s,o=!1;for(Rt&&e.nodeType==1&&r0){if(e.nodeType!=1)break;{let a=e.childNodes[r-1];if(Un(a,-1))i=e,s=--r;else if(a.nodeType==3)e=a,r=e.nodeValue.length;else break}}else{if(gu(e))break;{let a=e.previousSibling;for(;a&&Un(a,-1);)i=e.parentNode,s=ut(a),a=a.previousSibling;if(a)e=a,r=qr(e);else{if(e=e.parentNode,e==n.dom)break;r=0}}}o?xo(n,e,r):i&&xo(n,i,s)}function Xp(n){let t=n.domSelectionRange(),e=t.focusNode,r=t.focusOffset;if(!e)return;let i=qr(e),s,o;for(;;)if(r{n.state==i&&ce(n)},50)}function Fc(n,t){let e=n.state.doc.resolve(t);if(!(st||ru)&&e.parent.inlineContent){let i=n.coordsAtPos(t);if(t>e.start()){let s=n.coordsAtPos(t-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function $c(n,t,e){let r=n.state.selection;if(r instanceof I&&!r.empty||e.indexOf("s")>-1||Dt&&e.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(t<0?"up":"down")){let o=ko(n.state,t);if(o&&o instanceof A)return we(n,o)}if(!i.parent.inlineContent){let o=t<0?i:s,a=r instanceof xt?R.near(o,t):R.findFrom(o,t);return a?we(n,a):!1}return!1}function Hc(n,t){if(!(n.state.selection instanceof I))return!0;let{$head:e,$anchor:r,empty:i}=n.state.selection;if(!e.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!e.textOffset&&(t<0?e.nodeBefore:e.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return t<0?o.delete(e.pos-s.nodeSize,e.pos):o.delete(e.pos,e.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Vc(n,t,e){n.domObserver.stop(),t.contentEditable=e,n.domObserver.start()}function Zp(n){if(!ht||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:e}=n.domSelectionRange();if(t&&t.nodeType==1&&e==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;Vc(n,r,"true"),setTimeout(()=>Vc(n,r,"false"),20)}return!1}function tm(n){let t="";return n.ctrlKey&&(t+="c"),n.metaKey&&(t+="m"),n.altKey&&(t+="a"),n.shiftKey&&(t+="s"),t}function em(n,t){let e=t.keyCode,r=tm(t);if(e==8||Dt&&e==72&&r=="c")return Hc(n,-1)||hn(n,-1);if(e==46&&!t.shiftKey||Dt&&e==68&&r=="c")return Hc(n,1)||hn(n,1);if(e==13||e==27)return!0;if(e==37||Dt&&e==66&&r=="c"){let i=e==37?Fc(n,n.state.selection.from)=="ltr"?-1:1:-1;return Bc(n,i,r)||hn(n,i)}else if(e==39||Dt&&e==70&&r=="c"){let i=e==39?Fc(n,n.state.selection.from)=="ltr"?1:-1:1;return Bc(n,i,r)||hn(n,i)}else{if(e==38||Dt&&e==80&&r=="c")return $c(n,-1,r)||hn(n,-1);if(e==40||Dt&&e==78&&r=="c")return Zp(n)||$c(n,1,r)||hn(n,1);if(r==(Dt?"m":"c")&&(e==66||e==73||e==89||e==90))return!0}return!1}function Po(n,t){n.someProp("transformCopied",f=>{t=f(t,n)});let e=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let f=r.firstChild;e.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=n.someProp("clipboardSerializer")||ne.fromSchema(n.state.schema),a=xu(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,u,h=0;for(;c&&c.nodeType==1&&(u=ku[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=a.createElement(u[f]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(e)}`);let d=n.someProp("clipboardTextSerializer",f=>f(t,n))||t.content.textBetween(0,t.content.size,` -`);return{dom:l,text:f,slice:e}}function Vp(t,e,n,r,i){let s=i.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return a=new A(S.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)a=d;else{let f=i.marks(),{schema:h}=t.state,p=Ot.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=Ck(n),Ti&&Ek(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||ut.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!xk.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Tk(hp(a,+u[1],+u[2]),u[4]);else if(a=A.maxOpen(kk(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d{a=d(a,t,l)}),a}var xk=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function kk(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&Wp(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=jp(o[o.length-1],s.length));let u=Up(a,l);o.push(u),i=i.matchType(u.type),s=l}}),o)return S.from(o)}return t}function Up(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,S.from(t));return t}function Wp(t,e,n,r,i){if(i1&&(s=0),i=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function hp(t,e,n){return en})),rc.createHTML(t)):t}function Ck(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Kp().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&qp[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"").reverse().join("")),n.innerHTML=Sk(t),i)for(let s=0;s=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=S.from(l.create(r[a+1],i)),s++,o++}return new A(i,s,o)}var De={},Re={},Ak={touchstart:!0,touchmove:!0},bc=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Mk(t){for(let e in De){let n=De[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Nk(t,r)&&!Mc(t,r)&&(t.editable||!(r.type in Re))&&n(t,r)},Ak[e]?{passive:!0}:void 0)}xe&&t.dom.addEventListener("input",()=>null),vc(t)}function rn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function _k(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function vc(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Mc(t,r))})}function Mc(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Nk(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Ok(t,e){!Mc(t,e)&&De[e.type]&&(t.editable||!(e.type in Re))&&De[e.type](t,e)}Re.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Zp(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Bt&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),vr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,_n(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||wk(t,n)?n.preventDefault():rn(t,"key")};Re.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Re.keypress=(t,e)=>{let n=e;if(Zp(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ke&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof D)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function uo(t){return{left:t.clientX,top:t.clientY}}function Ik(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function _c(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,a=>o>s.depth?a(t,n,s.nodeAfter,s.before(o),i,!0):a(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function yr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function Dk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(yr(t,new O(n),"pointer"),!0):!1}function Rk(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof O&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(O.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(yr(t,O.create(t.state.doc,i),"pointer"),!0):!1}function Pk(t,e,n,r,i){return _c(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?Rk(t,n):Dk(t,n))}function Lk(t,e,n,r){return _c(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Bk(t,e,n,r){return _c(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||zk(t,n,r)}function zk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(yr(t,D.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)yr(t,D.create(r,a+1,a+1+o.content.size),"pointer");else if(O.isSelectable(o))yr(t,O.create(r,a),"pointer");else continue;return!0}}function Nc(t){return io(t)}var Jp=Ke?"metaKey":"ctrlKey";De.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Nc(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&Ik(n,t.input.lastClick)&&!n[Jp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(uo(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new wc(t,o,n,!!r)):(s=="doubleClick"?Lk:Bk)(t,o.pos,o.inside,n)?n.preventDefault():rn(t,"pointer"))};var wc=class{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Jp],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.before():0}let a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ze&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),rn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>zt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(uo(e))),this.updateAllowDefault(e),this.allowDefault||!n?rn(this.view,"pointer"):Pk(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(yr(this.view,L.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):rn(this.view,"pointer")}move(e){this.updateAllowDefault(e),rn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};De.touchstart=t=>{t.input.lastTouch=Date.now(),Nc(t),rn(t,"pointer")};De.touchmove=t=>{t.input.lastTouch=Date.now(),rn(t,"pointer")};De.contextmenu=t=>Nc(t);function Zp(t,e){return t.composing?!0:xe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Fk=Bt?5e3:-1;Re.compositionstart=Re.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof D&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ge&&Mp&&$k(t)))t.markCursor=t.state.storedMarks||n.marks(),io(t,!0),t.markCursor=null;else if(io(t,!e.selection.empty),Ze&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Xp(t,Fk)};function $k(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Re.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Xp(t,20))};function Xp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>io(t),e))}function Gp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Vk());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Hk(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=zx(e.focusNode,e.focusOffset),r=Fx(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Vk(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function io(t,e=!1){if(!(Bt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Gp(t),e||t.docView&&t.docView.dirty){let n=Ec(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Uk(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var xi=Fe&&sn<15||vr&&Ux<604;De.copy=Re.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=xi?null:n.clipboardData,o=r.content(),{dom:a,text:l}=Ac(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Uk(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Wk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function jk(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ki(t,r.value,null,i,e):ki(t,r.textContent,r.innerHTML,i,e)},50)}function ki(t,e,n,r,i){let s=Vp(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||A.empty)))return!0;if(!s)return!1;let o=Wk(s),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Yp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Re.paste=(t,e)=>{let n=e;if(t.composing&&!Bt)return;let r=xi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ki(t,Yp(r),r.getData("text/html"),i,n)?n.preventDefault():jk(t,n)};var so=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},qk=Ke?"altKey":"ctrlKey";function Qp(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[qk]}De.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(uo(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof O?i.to-1:i.to))){if(r&&r.mightDrag)o=O.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=O.create(t.state.doc,d.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:u}=Ac(t,a);(!n.dataTransfer.files.length||!ge||Ap>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(xi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",xi||n.dataTransfer.setData("text/plain",c),t.dragging=new so(u,Qp(t,n),o)};De.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Re.dragover=Re.dragenter=(t,e)=>e.preventDefault();Re.drop=(t,e)=>{try{Kk(t,e,t.dragging)}finally{t.dragging=null}};function Kk(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(uo(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",h=>{s=h(s,t,!1)}):s=Vp(t,Yp(e.dataTransfer),xi?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Qp(t,e));if(t.someProp("handleDrop",h=>h(t,e,s||A.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let a=s?Ks(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(o){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&O.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new O(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),l.setSelection(Tc(t,f,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}De.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&zt(t)},20))};De.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};De.beforeinput=(t,e)=>{if(ge&&Bt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,_n(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Re)De[t]=Re[t];function Si(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var oo=class t{constructor(e,n){this.toDOM=e,this.spec=n||Dn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ye(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Si(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},In=class t{constructor(e,n){this.attrs=e,this.spec=n||Dn}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ye(s,o,this)}valid(e,n){return n.from=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;oe){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,i+a,s)}}map(e,n,r){return this==Ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Dn)}mapInner(e,n,r,i,s){let o;for(let a=0;a{let c=l+r,u;if(u=tm(n,a,c)){for(i||(i=this.children.slice());sa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+n.content.size;for(let a=0;as&&l.type instanceof In){let c=Math.max(s,l.from)-s,u=Math.min(o,l.to)-s;ci.map(e,n,Dn));return t.from(r)}forChild(e,n){if(n.isLeaf)return ee.empty;let r=[];for(let i=0;in instanceof ee)?e:e.reduce((n,r)=>n.concat(r instanceof ee?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let g=m-p-(h-f);for(let y=0;yb+u-d)continue;let x=a[y]+u-d;h>=x?a[y+1]=f<=x?-2:-1:f>=u&&g&&(a[y]+=g,a[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c=r.content.size){l=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=a[c+2].mapInner(n,g,u+1,t[c]+s+1,o);y!=Ae?(a[c]=d,a[c+1]=h,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Zk(a,t,e,n,i,s,o),u=lo(c,r,0,o);e=u.local;for(let d=0;dn&&o.to{let c=tm(t,a,l+n);if(c){s=!0;let u=lo(c,a,n+l+1,r);u!=Ae&&i.push(l,l+a.nodeSize,u)}});let o=em(s?nm(t):t,-n).sort(Rn);for(let a=0;a0;)e++;t.splice(e,0,n)}function ic(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ae&&e.push(r)}),t.cursorWrapper&&e.push(ee.create(t.state.doc,[t.cursorWrapper.deco])),ao.from(e)}var Xk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gk=Fe&&sn<=11,kc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Sc=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():xe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Gk&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Xk)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ap(this.view)){if(this.suppressingSelectionUpdates)return zt(this.view);if(Fe&&sn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=br(s))n.add(s);for(let s=e.anchorNode;s;s=br(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ap(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let u=0;ud.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||eS(e,d)!=h)&&f.remove()}}}else if((ge||xe)&&l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Yk(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,tS(e,l)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||zt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let y=r.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){s=g;break}if(!b||b.size)break}let d=t.state.doc,f=t.someProp("domParser")||ut.fromSchema(t.state.schema),h=d.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:rS,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:a}}function rS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(xe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||xe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var iS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function sS(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,E=Ec(t,k);if(E&&!t.state.selection.eq(E)){if(ge&&Bt&&t.input.lastKeyCode===13&&Date.now()-100z(t,_n(13,"Enter"))))return;let _=t.state.tr.setSelection(E);k=="pointer"?_.setMeta("pointer",!0):k=="key"&&_.scrollIntoView(),s&&_.setMeta("composition",s),t.dispatch(_)}return}let o=t.state.doc.resolve(e),a=o.sharedDepth(n);e=o.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=nS(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Bt)&&i.some(k=>k.nodeType==1&&!iS.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,_n(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof D&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let k=vp(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let E=t.state.tr.setSelection(k);s&&E.setMeta("composition",s),t.dispatch(E)}}return}t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Fe&&sn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((vr&&t.input.lastIOSEnter>Date.now()-225&&(!b||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!b&&m.posk(t,_n(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&aS(u,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",k=>k(t,_n(8,"Backspace")))){Bt&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Bt&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,_n(13,"Enter"))})},20));let x=p.start,w=p.endA,v=k=>{let E=k||t.state.tr.replace(x,w,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let _=vp(t,E.doc,c.sel);_&&!(ge&&t.composing&&_.empty&&(p.start!=p.endB||t.input.lastChromeDeletezt(t),20));let k=v(t.state.tr.delete(x,w)),E=u.resolve(p.start).marksAcross(u.resolve(p.endA));E&&k.ensureMarks(E),t.dispatch(k)}else if(p.endA==p.endB&&(T=oS(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let k=v(t.state.tr);T.type=="add"?k.addMark(x,w,T.mark):k.removeMark(x,w,T.mark),t.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset),E=()=>v(t.state.tr.insertText(k,x,w));t.someProp("handleTextInput",_=>_(t,x,w,k,E))||t.dispatch(E())}else t.dispatch(v());else t.dispatch(v())}function vp(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Tc(t,e.resolve(n.anchor),e.resolve(n.head))}function oS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;un||sc(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function lS(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o=o?s-r:0;s-=l,s&&s=a?s-r:0;s-=l,s&&s=56320&&e<=57343&&n>=55296&&n<=56319}var Ci=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new bc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Ep),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Sp(this),kp(this),this.nodeViews=Cp(this),this.docView=tp(this.state.doc,xp(this),ic(this),this.dom,this),this.domObserver=new Sc(this,(r,i,s,o)=>sS(this,r,i,s,o)),this.domObserver.start(),Mk(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&vc(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ep),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Gp(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Cp(this);uS(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&vc(this),this.editable=Sp(this),kp(this);let l=ic(this),c=xp(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&qx(this);if(o){this.domObserver.stop();let h=d&&(Fe||ge)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&cS(i.selection,e.selection);if(d){let p=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Hk(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=tp(e.doc,c,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&hk(this))?zt(this,h):(Fp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Kx(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof O){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Zh(this,n.getBoundingClientRect(),e)}else Zh(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new so(e.slice,e.move,i<0?void 0:O.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Qx(this,e)}coordsAtPos(e,n=1){return Dp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return ik(this,n||this.state,e)}pasteHTML(e,n){return ki(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ki(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ac(this,e)}destroy(){this.docView&&(_k(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ic(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ok(this,e)}domSelectionRange(){let e=this.domSelection();return e?xe&&this.root.nodeType===11&&Hx(this.dom.ownerDocument)==this.dom&&Qk(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ci.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function xp(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[ye.node(0,t.state.doc.content.size,e)]}function kp(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:ye.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Sp(t){return!t.someProp("editable",e=>e(t.state)===!1)}function cS(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Cp(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function uS(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Ep(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ft={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:"'"},ho={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dS=typeof navigator<"u"&&/Mac/.test(navigator.platform),fS=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ue=0;ue<10;ue++)Ft[48+ue]=Ft[96+ue]=String(ue);var ue;for(ue=1;ue<=24;ue++)Ft[ue+111]="F"+ue;var ue;for(ue=65;ue<=90;ue++)Ft[ue]=String.fromCharCode(ue+32),ho[ue]=String.fromCharCode(ue);var ue;for(fo in Ft)ho.hasOwnProperty(fo)||(ho[fo]=Ft[fo]);var fo;function rm(t){var e=dS&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||fS&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ho:Ft)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var hS=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pS=typeof navigator<"u"&&/Win/.test(navigator.platform);function mS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let a=0;a{for(var n in e)yS(t,n,{get:e[n],enumerable:!0})};function xo(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var ko=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,a])=>[o,(...c)=>{let u=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){let{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!t,l=t||i.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,f])=>[d,(...p)=>{let m=this.buildProps(l,e),g=f(...p)(m);return o.push(g),u}])),run:c};return u}createCan(t){let{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){let{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:xo({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)(o)]))}};return o}},pm={};Fc(pm,{blur:()=>bS,clearContent:()=>vS,clearNodes:()=>wS,command:()=>xS,createParagraphNear:()=>kS,cut:()=>SS,deleteCurrentNode:()=>CS,deleteNode:()=>ES,deleteRange:()=>TS,deleteSelection:()=>AS,enter:()=>MS,exitCode:()=>_S,extendMarkRange:()=>NS,first:()=>OS,focus:()=>DS,forEach:()=>RS,insertContent:()=>PS,insertContentAt:()=>zS,joinBackward:()=>HS,joinDown:()=>$S,joinForward:()=>VS,joinItemBackward:()=>US,joinItemForward:()=>WS,joinTextblockBackward:()=>jS,joinTextblockForward:()=>qS,joinUp:()=>FS,keyboardShortcut:()=>JS,lift:()=>ZS,liftEmptyBlock:()=>XS,liftListItem:()=>GS,newlineInCode:()=>YS,resetAttributes:()=>QS,scrollIntoView:()=>e1,selectAll:()=>t1,selectNodeBackward:()=>n1,selectNodeForward:()=>r1,selectParentNode:()=>i1,selectTextblockEnd:()=>s1,selectTextblockStart:()=>o1,setContent:()=>a1,setMark:()=>C1,setMeta:()=>E1,setNode:()=>T1,setNodeSelection:()=>A1,setTextDirection:()=>M1,setTextSelection:()=>_1,sinkListItem:()=>N1,splitBlock:()=>O1,splitListItem:()=>I1,toggleList:()=>R1,toggleMark:()=>P1,toggleNode:()=>L1,toggleWrap:()=>B1,undoInputRule:()=>z1,unsetAllMarks:()=>F1,unsetMark:()=>$1,unsetTextDirection:()=>H1,updateAttributes:()=>V1,wrapIn:()=>U1,wrapInList:()=>W1});var bS=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),vS=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wS=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;let p=Rt(h);if(a.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},xS=t=>e=>t(e),kS=()=>({state:t,dispatch:e})=>Zl(t,e),SS=(t,e)=>({editor:n,tr:r})=>{let{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new D(r.doc.resolve(Math.max(o-1,0)))),!0},CS=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){let a=i.before(s),l=i.after(s);t.delete(a,l).scrollIntoView()}return!0}return!1};function se(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ES=t=>({tr:e,state:n,dispatch:r})=>{let i=se(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){let l=s.before(o),c=s.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},TS=t=>({tr:e,dispatch:n})=>{let{from:r,to:i}=t;return n&&e.delete(r,i),!0},AS=()=>({state:t,dispatch:e})=>Ys(t,e),MS=()=>({commands:t})=>t.keyboardShortcut("Enter"),_S=()=>({state:t,dispatch:e})=>Jl(t,e);function $c(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function vo(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:$c(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function mm(t,e,n={}){return t.find(r=>r.type===e&&vo(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function sm(t,e,n={}){return!!mm(t,e,n)}function Hc(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){let c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!mm([...r.node.marks],e,n))return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(;s>0&&sm([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;a({tr:n,state:r,dispatch:i})=>{let s=$t(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){let d=Hc(l,s,e);if(d&&d.from<=c&&d.to>=u){let f=D.create(o,d.from,d.to);n.setSelection(f)}}return!0},OS=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};let o=()=>{(wo()||om())&&r.dom.focus(),IS()&&!wo()&&!om()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!gm(n.state.selection))return o(),!0;let a=ym(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},RS=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),PS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),bm=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&bm(r)}return t};function po(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return bm(n)}function Ni(t,e,n){if(t instanceof ze||t instanceof S)return t;n={slice:!0,parseOptions:{},...n};let r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return S.fromArray(t.map(a=>e.nodeFromJSON(a)));let o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Ni("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,a="",l=new ar({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?ut.fromSchema(l).parseSlice(po(t),n.parseOptions):ut.fromSchema(l).parse(po(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}let s=ut.fromSchema(e);return n.slice?s.parseSlice(po(t),n.parseOptions).content:s.parse(po(t),n.parseOptions)}return Ni("",e,n)}function LS(t,e,n){let r=t.steps.length-1;if(r{o===0&&(o=u)}),t.setSelection(L.near(t.doc.resolve(o),n))}var BS=t=>!("type"in t),zS=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a,l=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Ni(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Ni(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((BS(a)?a:[a]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof S){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=a;let g=r.doc.resolve(u),y=g.node(),b=g.parentOffset===0,x=y.isText||y.isTextblock,w=y.content.size>0;b&&x&&w&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&LS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},FS=()=>({state:t,dispatch:e})=>Bh(t,e),$S=()=>({state:t,dispatch:e})=>zh(t,e),HS=()=>({state:t,dispatch:e})=>$l(t,e),VS=()=>({state:t,dispatch:e})=>Ul(t,e),US=()=>({state:t,dispatch:e,tr:n})=>{try{let r=An(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},WS=()=>({state:t,dispatch:e,tr:n})=>{try{let r=An(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},jS=()=>({state:t,dispatch:e})=>Dh(t,e),qS=()=>({state:t,dispatch:e})=>Rh(t,e);function vm(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function KS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let a=0;a({editor:e,view:n,tr:r,dispatch:i})=>{let s=KS(t).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function ht(t,e,n={}){let{from:r,to:i,empty:s}=t.selection,o=e?se(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;let h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);a.push({node:d,from:h,to:p})});let l=i-r,c=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>vo(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}var ZS=(t,e={})=>({state:n,dispatch:r})=>{let i=se(t,n.schema);return ht(n,i,e)?Fh(n,r):!1},XS=()=>({state:t,dispatch:e})=>Xl(t,e),GS=t=>({state:e,dispatch:n})=>{let r=se(t,e.schema);return jh(r)(e,n)},YS=()=>({state:t,dispatch:e})=>ql(t,e);function So(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function am(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var QS=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null,a=So(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=se(t,r.schema)),a==="mark"&&(o=$t(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(l=!0,i&&n.setNodeMarkup(d,void 0,am(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(l=!0,i&&n.addMark(d,d+u.nodeSize,o.create(am(f.attrs,e))))})})}),l},e1=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),t1=()=>({tr:t,dispatch:e})=>{if(e){let n=new Ie(t.doc);t.setSelection(n)}return!0},n1=()=>({state:t,dispatch:e})=>Hl(t,e),r1=()=>({state:t,dispatch:e})=>Wl(t,e),i1=()=>({state:t,dispatch:e})=>$h(t,e),s1=()=>({state:t,dispatch:e})=>Yl(t,e),o1=()=>({state:t,dispatch:e})=>Gl(t,e);function Bc(t,e,n={},r={}){return Ni(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var a1=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{let{doc:l}=s;if(r.preserveWhitespace!=="full"){let c=Bc(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function wm(t,e){let n=$t(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});let a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Vc(t,e){let n=new ur(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function l1(t){for(let e=0;e{n(i)&&r.push({node:i,pos:s})}),r}function c1(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Co(t){return e=>c1(e.$from,t)}function I(t,e,n){return t.config[e]===void 0&&t.parent?I(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?I(t.parent,e,n):null}):t.config[e]}function Uc(t){return t.map(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=I(e,"addExtensions",n);return r?[e,...Uc(r())]:e}).flat(10)}function Wc(t,e){let n=Ot.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function km(t){return typeof t=="function"}function J(t,e=void 0,...n){return km(t)?e?t.bind(e)(...n):t(...n):t}function u1(t={}){return Object.keys(t).length===0&&t.constructor===Object}function xr(t){let e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Sm(t){let e=[],{nodeExtensions:n,markExtensions:r}=xr(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...o,...a];return t.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage,extensions:i},d=I(c,"addGlobalAttributes",u);if(!d)return;d().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=l:h.types==="nodes"?p=o:h.types==="marks"?p=a:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...s,...y}})})})})}),i.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage},d=I(c,"addAttributes",u);if(!d)return;let f=d();Object.entries(f).forEach(([h,p])=>{let m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function d1(t){let e=[],n="",r=!1,i=!1,s=0,o=t.length;for(let a=0;a0){s-=1,n+=l;continue}if(l===";"&&s===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function lm(t){let e=[],n=d1(t||""),r=n.length;for(let i=0;i!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){let a=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){let a=new Map([...lm(r[i]),...lm(s)]);r[i]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[i]=s}),r},{})}function kr(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>P(n,r),{})}function f1(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function cm(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let i=e.reduce((s,o)=>{let a=o.attribute.parseHTML?o.attribute.parseHTML(n):f1(n.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function um(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&u1(n)?!1:n!=null))}function dm(t){var e,n;let r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function h1(t,e){var n;let r=Sm(t),{nodeExtensions:i,markExtensions:s}=xr(t),o=(n=i.find(c=>I(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(i.map(c=>{let u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,b)=>{let x=I(b,"extendNodeSchema",d);return{...y,...x?x(c):{}}},{}),h=um({...f,content:J(I(c,"content",d)),marks:J(I(c,"marks",d)),group:J(I(c,"group",d)),inline:J(I(c,"inline",d)),atom:J(I(c,"atom",d)),selectable:J(I(c,"selectable",d)),draggable:J(I(c,"draggable",d)),code:J(I(c,"code",d)),whitespace:J(I(c,"whitespace",d)),linebreakReplacement:J(I(c,"linebreakReplacement",d)),defining:J(I(c,"defining",d)),isolating:J(I(c,"isolating",d)),attrs:Object.fromEntries(u.map(dm))}),p=J(I(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>cm(y,u)));let m=I(c,"renderHTML",d);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:kr(y,u)}));let g=I(c,"renderText",d);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{let u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,y)=>{let b=I(y,"extendMarkSchema",d);return{...g,...b?b(c):{}}},{}),h=um({...f,inclusive:J(I(c,"inclusive",d)),excludes:J(I(c,"excludes",d)),group:J(I(c,"group",d)),spanning:J(I(c,"spanning",d)),code:J(I(c,"code",d)),attrs:Object.fromEntries(u.map(dm))}),p=J(I(c,"parseHTML",d));p&&(h.parseDOM=p.map(g=>cm(g,u)));let m=I(c,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:kr(g,u)})),[c.name,h]}));return new ar({topNode:o,nodes:a,marks:l})}function p1(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function _i(t){return t.sort((n,r)=>{let i=I(n,"priority")||100,s=I(r,"priority")||100;return i>s?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Em(t,e,n){let{from:r,to:i}=e,{blockSeparator:s=` +`);return{dom:l,text:d,slice:t}}function yu(n,t,e,r,i){let s=i.parent.type.spec.code,o,a;if(!e&&!t)return null;let l=!!t&&(r||s||!e);if(l){if(n.someProp("transformPastedText",d=>{t=d(t,s||r,n)}),s)return a=new S(v.from(n.state.schema.text(t.replace(/\r\n?/g,` +`))),0,0),n.someProp("transformPasted",d=>{a=d(a,n,!0)}),a;let h=n.someProp("clipboardTextParser",d=>d(t,i,r,n));if(h)a=h;else{let d=i.marks(),{schema:f}=n.state,p=ne.fromSchema(f);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,d)))})}}else n.someProp("transformPastedHTML",h=>{e=h(e,n)}),o=sm(e),Gn&&om(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||Ut.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!nm.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)a=am(Wc(a,+u[1],+u[2]),u[4]);else if(a=S.maxOpen(rm(a.content,i),!0),a.openStart||a.openEnd){let h=0,d=0;for(let f=a.content.firstChild;h{a=h(a,n,l)}),a}var nm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function rm(n,t){if(n.childCount<2)return n;for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.index(e)),s,o=[];if(n.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&vu(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=wu(o[o.length-1],s.length));let u=bu(a,l);o.push(u),i=i.matchType(u.type),s=l}}),o)return v.from(o)}return n}function bu(n,t,e=0){for(let r=t.length-1;r>=e;r--)n=t[r].create(null,v.from(n));return n}function vu(n,t,e,r,i){if(i1&&(s=0),i=e&&(a=t<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(v.empty,!0))),n.replaceChild(t<0?0:n.childCount-1,o.copy(a))}function Wc(n,t,e){return te})),lo.createHTML(n)):n}function sm(n){let t=/^(\s*]*>)*/.exec(n);t&&(n=n.slice(t[0].length));let e=xu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&ku[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"").reverse().join("")),e.innerHTML=im(n),i)for(let s=0;s=0;a-=2){let l=e.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=v.from(l.create(r[a+1],i)),s++,o++}return new S(i,s,o)}var St={},Ct={},lm={touchstart:!0,touchmove:!0},Co=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function cm(n){for(let t in St){let e=St[t];n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>{hm(n,r)&&!Ro(n,r)&&(n.editable||!(r.type in Ct))&&e(n,r)},lm[t]?{passive:!0}:void 0)}ht&&n.dom.addEventListener("input",()=>null),Eo(n)}function ke(n,t){n.input.lastSelectionOrigin=t,n.input.lastSelectionTime=Date.now()}function um(n){n.domObserver.stop();for(let t in n.input.eventHandlers)n.dom.removeEventListener(t,n.input.eventHandlers[t]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Eo(n){n.someProp("handleDOMEvents",t=>{for(let e in t)n.input.eventHandlers[e]||n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>Ro(n,r))})}function Ro(n,t){return n.someProp("handleDOMEvents",e=>{let r=e[t.type];return r?r(n,t)||t.defaultPrevented:!1})}function hm(n,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target;e!=n.dom;e=e.parentNode)if(!e||e.nodeType==11||e.pmViewDesc&&e.pmViewDesc.stopEvent(t))return!1;return!0}function dm(n,t){!Ro(n,t)&&St[t.type]&&(n.editable||!(t.type in Ct))&&St[t.type](n,t)}Ct.keydown=(n,t)=>{let e=t;if(n.input.shiftKey=e.keyCode==16||e.shiftKey,!Cu(n,e)&&(n.input.lastKeyCode=e.keyCode,n.input.lastKeyCodeTime=Date.now(),!(le&&st&&e.keyCode==13)))if(e.keyCode!=229&&n.domObserver.forceFlush(),mn&&e.keyCode==13&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Le(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,e))||em(n,e)?e.preventDefault():ke(n,"key")};Ct.keyup=(n,t)=>{t.keyCode==16&&(n.input.shiftKey=!1)};Ct.keypress=(n,t)=>{let e=t;if(Cu(n,e)||!e.charCode||e.ctrlKey&&!e.altKey||Dt&&e.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,e))){e.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(e.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),e.preventDefault()}};function ti(n){return{left:n.clientX,top:n.clientY}}function fm(n,t){let e=t.x-n.clientX,r=t.y-n.clientY;return e*e+r*r<100}function Lo(n,t,e,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(t,a=>o>s.depth?a(n,e,s.nodeAfter,s.before(o),i,!0):a(n,e,s.node(o),s.before(o),i,!1)))return!0;return!1}function fn(n,t,e){if(n.focused||n.focus(),n.state.selection.eq(t))return;let r=n.state.tr.setSelection(t);e=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function pm(n,t){if(t==-1)return!1;let e=n.state.doc.resolve(t),r=e.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(fn(n,new A(e),"pointer"),!0):!1}function mm(n,t){if(t==-1)return!1;let e=n.state.selection,r,i;e instanceof A&&(r=e.node);let s=n.state.doc.resolve(t);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(A.isSelectable(a)){r&&e.$from.depth>0&&o>=e.$from.depth&&s.before(e.$from.depth+1)==e.$from.pos?i=s.before(e.$from.depth):i=s.before(o);break}}return i!=null?(fn(n,A.create(n.state.doc,i),"pointer"),!0):!1}function gm(n,t,e,r,i){return Lo(n,"handleClickOn",t,e,r)||n.someProp("handleClick",s=>s(n,t,r))||(i?mm(n,e):pm(n,e))}function ym(n,t,e,r){return Lo(n,"handleDoubleClickOn",t,e,r)||n.someProp("handleDoubleClick",i=>i(n,t,r))}function bm(n,t,e,r){return Lo(n,"handleTripleClickOn",t,e,r)||n.someProp("handleTripleClick",i=>i(n,t,r))||vm(n,e,r)}function vm(n,t,e){if(e.button!=0)return!1;let r=n.state.doc;if(t==-1)return r.inlineContent?(fn(n,I.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(t);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)fn(n,I.create(r,a+1,a+1+o.content.size),"pointer");else if(A.isSelectable(o))fn(n,A.create(r,a),"pointer");else continue;return!0}}function zo(n){return Jr(n)}var Su=Dt?"metaKey":"ctrlKey";St.mousedown=(n,t)=>{let e=t;n.input.shiftKey=e.shiftKey;let r=zo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&fm(e,n.input.lastClick)&&!e[Su]&&n.input.lastClick.button==e.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:e.clientX,y:e.clientY,type:s,button:e.button};let o=n.posAtCoords(ti(e));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new To(n,o,e,!!r)):(s=="doubleClick"?ym:bm)(n,o.pos,o.inside,e)?e.preventDefault():ke(n,"pointer"))};var To=class{constructor(t,e,r,i){this.view=t,this.pos=e,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Su],this.allowDefault=r.shiftKey;let s,o;if(e.inside>-1)s=t.state.doc.nodeAt(e.inside),o=e.inside;else{let u=t.state.doc.resolve(e.pos);s=u.parent,o=u.depth?u.before():0}let a=i?null:r.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=t.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof A&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Rt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),ke(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ce(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ti(t))),this.updateAllowDefault(t),this.allowDefault||!e?ke(this.view,"pointer"):gm(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||ht&&this.mightDrag&&!this.mightDrag.node.isAtom||st&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(fn(this.view,R.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):ke(this.view,"pointer")}move(t){this.updateAllowDefault(t),ke(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}};St.touchstart=n=>{n.input.lastTouch=Date.now(),zo(n),ke(n,"pointer")};St.touchmove=n=>{n.input.lastTouch=Date.now(),ke(n,"pointer")};St.contextmenu=n=>zo(n);function Cu(n,t){return n.composing?!0:ht&&Math.abs(t.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var wm=le?5e3:-1;Ct.compositionstart=Ct.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:t}=n,e=t.selection.$to;if(t.selection instanceof I&&(t.storedMarks||!e.textOffset&&e.parentOffset&&e.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||st&&ru&&km(n)))n.markCursor=n.state.storedMarks||e.marks(),Jr(n,!0),n.markCursor=null;else if(Jr(n,!t.selection.empty),Rt&&t.selection.empty&&e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let a=n.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}Eu(n,wm)};function km(n){let{focusNode:t,focusOffset:e}=n.domSelectionRange();if(!t||t.nodeType!=1||e>=t.childNodes.length)return!1;let r=t.childNodes[e];return r.nodeType==1&&r.contentEditable=="false"}Ct.compositionend=(n,t)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=t.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Eu(n,20))};function Eu(n,t){clearTimeout(n.input.composingTimeout),t>-1&&(n.input.composingTimeout=setTimeout(()=>Jr(n),t))}function Tu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Sm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function xm(n){let t=n.domSelectionRange();if(!t.focusNode)return null;let e=vp(t.focusNode,t.focusOffset),r=wp(t.focusNode,t.focusOffset);if(e&&r&&e!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(e==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=e.pmViewDesc;if(!(!o||!o.isText(e.nodeValue)))return r}}return e||r}function Sm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jr(n,t=!1){if(!(le&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Tu(n),t||n.docView&&n.docView.dirty){let e=Io(n),r=n.state.selection;return e&&!e.eq(r)?n.dispatch(n.state.tr.setSelection(e)):(n.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Cm(n,t){if(!n.dom.parentNode)return;let e=n.dom.parentNode.appendChild(document.createElement("div"));e.appendChild(t),e.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e),n.focus()},50)}var jn=Mt&&xe<15||mn&&Cp<604;St.copy=Ct.cut=(n,t)=>{let e=t,r=n.state.selection,i=e.type=="cut";if(r.empty)return;let s=jn?null:e.clipboardData,o=r.content(),{dom:a,text:l}=Po(n,o);s?(e.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Cm(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Em(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Tm(n,t){if(!n.dom.parentNode)return;let e=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(e?"textarea":"div"));e||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),e?_n(n,r.value,null,i,t):_n(n,r.textContent,r.innerHTML,i,t)},50)}function _n(n,t,e,r,i){let s=yu(n,t,e,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,s||S.empty)))return!0;if(!s)return!1;let o=Em(s),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Mu(n){let t=n.getData("text/plain")||n.getData("Text");if(t)return t;let e=n.getData("text/uri-list");return e?e.replace(/\r?\n/g," "):""}Ct.paste=(n,t)=>{let e=t;if(n.composing&&!le)return;let r=jn?null:e.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&_n(n,Mu(r),r.getData("text/html"),i,e)?e.preventDefault():Tm(n,e)};var Gr=class{constructor(t,e,r){this.slice=t,this.move=e,this.node=r}},Mm=Dt?"altKey":"ctrlKey";function Au(n,t){let e=n.someProp("dragCopies",r=>!r(t));return e??!t[Mm]}St.dragstart=(n,t)=>{let e=t,r=n.input.mouseDown;if(r&&r.done(),!e.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(ti(e)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)o=A.create(n.state.doc,r.mightDrag.pos);else if(e.target&&e.target.nodeType==1){let h=n.docView.nearestDesc(e.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=A.create(n.state.doc,h.posBefore))}}let a=(o||n.state.selection).content(),{dom:l,text:c,slice:u}=Po(n,a);(!e.dataTransfer.files.length||!st||nu>120)&&e.dataTransfer.clearData(),e.dataTransfer.setData(jn?"Text":"text/html",l.innerHTML),e.dataTransfer.effectAllowed="copyMove",jn||e.dataTransfer.setData("text/plain",c),n.dragging=new Gr(u,Au(n,e),o)};St.dragend=n=>{let t=n.dragging;window.setTimeout(()=>{n.dragging==t&&(n.dragging=null)},50)};Ct.dragover=Ct.dragenter=(n,t)=>t.preventDefault();Ct.drop=(n,t)=>{try{Am(n,t,n.dragging)}finally{n.dragging=null}};function Am(n,t,e){if(!t.dataTransfer)return;let r=n.posAtCoords(ti(t));if(!r)return;let i=n.state.doc.resolve(r.pos),s=e&&e.slice;s?n.someProp("transformPasted",f=>{s=f(s,n,!1)}):s=yu(n,Mu(t.dataTransfer),jn?null:t.dataTransfer.getData("text/html"),!1,i);let o=!!(e&&Au(n,t));if(n.someProp("handleDrop",f=>f(n,t,s||S.empty,o))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Br(n.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let l=n.state.tr;if(o){let{node:f}=e;f?f.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=l.doc;if(u?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(h))return;let d=l.doc.resolve(c);if(u&&A.isSelectable(s.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new A(d));else{let f=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,y)=>f=y),l.setSelection(Do(n,d,l.doc.resolve(f)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}St.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ce(n)},20))};St.blur=(n,t)=>{let e=t;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),e.relatedTarget&&n.dom.contains(e.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};St.beforeinput=(n,t)=>{if(st&&le&&t.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Le(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ct)St[n]=Ct[n];function Kn(n,t){if(n==t)return!0;for(let e in n)if(n[e]!==t[e])return!1;for(let e in t)if(!(e in n))return!1;return!0}var Xr=class n{constructor(t,e){this.toDOM=t,this.spec=e||$e,this.side=this.spec.side||0}map(t,e,r,i){let{pos:s,deleted:o}=t.mapResult(e.from+i,this.side<0?-1:1);return o?null:new ot(s-r,s-r,this)}valid(){return!0}eq(t){return this==t||t instanceof n&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Kn(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},Fe=class n{constructor(t,e){this.attrs=t,this.spec=e||$e}map(t,e,r,i){let s=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r,o=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ot(s,o,this)}valid(t,e){return e.from=t&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;ot){let a=this.children[o]+1;this.children[o+2].findInner(t-a,e-a,r,i+a,s)}}map(t,e,r){return this==bt||t.maps.length==0?this:this.mapInner(t,e,0,0,r||$e)}mapInner(t,e,r,i,s){let o;for(let a=0;a{let c=l+r,u;if(u=Ou(e,a,c)){for(i||(i=this.children.slice());sa&&h.to=t){this.children[a]==t&&(r=this.children[a+2]);break}let s=t+1,o=s+e.content.size;for(let a=0;as&&l.type instanceof Fe){let c=Math.max(s,l.from)-s,u=Math.min(o,l.to)-s;ci.map(t,e,$e));return n.from(r)}forChild(t,e){if(e.isLeaf)return X.empty;let r=[];for(let i=0;ie instanceof X)?t:t.reduce((e,r)=>e.concat(r instanceof X?r:r.members),[]))}}forEachSet(t){for(let e=0;e{let g=m-p-(f-d);for(let y=0;yb+u-h)continue;let C=a[y]+u-h;f>=C?a[y+1]=d<=C?-2:-1:d>=u&&g&&(a[y]+=g,a[y+1]+=g)}h+=g}),u=e.maps[c].map(u,-1)}let l=!1;for(let c=0;c=r.content.size){l=!0;continue}let d=e.map(n[c+1]+s,-1),f=d-i,{index:p,offset:m}=r.content.findIndex(h),g=r.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let y=a[c+2].mapInner(e,g,u+1,n[c]+s+1,o);y!=bt?(a[c]=h,a[c+1]=f,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Om(a,n,t,e,i,s,o),u=Yr(c,r,0,o);t=u.local;for(let h=0;he&&o.to{let c=Ou(n,a,l+e);if(c){s=!0;let u=Yr(c,a,e+l+1,r);u!=bt&&i.push(l,l+a.nodeSize,u)}});let o=Nu(s?Iu(n):n,-e).sort(He);for(let a=0;a0;)t++;n.splice(t,0,e)}function co(n){let t=[];return n.someProp("decorations",e=>{let r=e(n.state);r&&r!=bt&&t.push(r)}),n.cursorWrapper&&t.push(X.create(n.state.doc,[n.cursorWrapper.deco])),Qr.from(t)}var Im={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dm=Mt&&xe<=11,Ao=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},No=class{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ao,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ht&&t.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Dm&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Im)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;ethis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(zc(this.view)){if(this.suppressingSelectionUpdates)return ce(this.view);if(Mt&&xe<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Ve(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e=new Set,r;for(let s=t.focusNode;s;s=pn(s))e.add(s);for(let s=t.anchorNode;s;s=pn(s))if(e.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&zc(t)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(t.editable)for(let u=0;uh.nodeName=="BR");if(u.length==2){let[h,d]=u;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of u){let f=d.parentNode;f&&f.nodeName=="LI"&&(!h||Lm(t,h)!=f)&&d.remove()}}}else if((st||ht)&&l.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&u.parentNode.removeChild(u)}}let c=null;s<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)-1||i)&&(s>-1&&(t.docView.markDirty(s,o),Pm(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,zm(t,l)),this.handleDOMChange(s,o,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||ce(t),this.currentSelection.set(r))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;ui;g--){let y=r.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){s=g;break}if(!b||b.size)break}let h=n.state.doc,d=n.someProp("domParser")||Ut.fromSchema(n.state.schema),f=h.resolve(o),p=null,m=d.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:s,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Fm,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:a}}function Fm(n){let t=n.pmViewDesc;if(t)return t.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ht&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(n.parentNode.lastChild==n||ht&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var $m=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Hm(n,t,e,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,t<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,E=Io(n,k);if(E&&!n.state.selection.eq(E)){if(st&&le&&n.input.lastKeyCode===13&&Date.now()-100$(n,Le(13,"Enter"))))return;let T=n.state.tr.setSelection(E);k=="pointer"?T.setMeta("pointer",!0):k=="key"&&T.scrollIntoView(),s&&T.setMeta("composition",s),n.dispatch(T)}return}let o=n.state.doc.resolve(t),a=o.sharedDepth(e);t=o.before(a+1),e=n.state.doc.resolve(e).after(a+1);let l=n.state.selection,c=Bm(n,t,e),u=n.state.doc,h=u.slice(c.from,c.to),d,f;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||le)&&i.some(k=>k.nodeType==1&&!$m.test(k.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",k=>k(n,Le(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof I&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let k=Jc(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let E=n.state.tr.setSelection(k);s&&E.setMeta("composition",s),n.dispatch(E)}}return}n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Mt&&xe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((mn&&n.input.lastIOSEnter>Date.now()-225&&(!b||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!b&&m.posk(n,Le(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Wm(u,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,Le(8,"Backspace")))){le&&st&&n.domObserver.suppressSelectionUpdates();return}st&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),le&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,Le(13,"Enter"))})},20));let C=p.start,M=p.endA,x=k=>{let E=k||n.state.tr.replace(C,M,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=Jc(n,E.doc,c.sel);T&&!(st&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastChromeDeletece(n),20));let k=x(n.state.tr.delete(C,M)),E=u.resolve(p.start).marksAcross(u.resolve(p.endA));E&&k.ensureMarks(E),n.dispatch(k)}else if(p.endA==p.endB&&(N=Vm(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let k=x(n.state.tr);N.type=="add"?k.addMark(C,M,N.mark):k.removeMark(C,M,N.mark),n.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset),E=()=>x(n.state.tr.insertText(k,C,M));n.someProp("handleTextInput",T=>T(n,C,M,k,E))||n.dispatch(E())}else n.dispatch(x());else n.dispatch(x())}function Jc(n,t,e){return Math.max(e.anchor,e.head)>t.content.size?null:Do(n,t.resolve(e.anchor),t.resolve(e.head))}function Vm(n,t){let e=n.firstChild.marks,r=t.firstChild.marks,i=e,s=r,o,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ue||uo(o,!0,!1)0&&(t||n.indexAfter(r)==n.node(r).childCount);)r--,i++,t=!1;if(e){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Um(n,t,e,r,i){let s=n.findDiffStart(t,e);if(s==null)return null;let{a:o,b:a}=n.findDiffEnd(t,e+n.size,e+t.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o=o?s-r:0;s-=l,s&&s=a?s-r:0;s-=l,s&&s=56320&&t<=57343&&e>=55296&&e<=56319}var qn=class{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Co,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(tu),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Yc(this),Qc(this),this.nodeViews=Zc(this),this.docView=Oc(this.state.doc,Xc(this),co(this),this.dom,this),this.domObserver=new No(this,(r,i,s,o)=>Hm(this,r,i,s,o)),this.domObserver.start(),cm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Eo(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(tu),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let r in this._props)e[r]=this._props[r];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,s=!1,o=!1;t.storedMarks&&this.composing&&(Tu(this),o=!0),this.state=t;let a=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(a||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let f=Zc(this);_m(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(a||e.handleDOMEvents!=this._props.handleDOMEvents)&&Eo(this),this.editable=Yc(this),Qc(this);let l=co(this),c=Xc(this),u=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(t.doc,c,l);(h||!t.selection.eq(i.selection))&&(o=!0);let d=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Mp(this);if(o){this.domObserver.stop();let f=h&&(Mt||st)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&jm(i.selection,t.selection);if(h){let p=st?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=xm(this)),(s||!this.docView.update(t.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Oc(t.doc,c,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Jp(this))?ce(this,f):(pu(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&Ap(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof A){let e=this.docView.domAfterPos(this.state.selection.from);e.nodeType==1&&Cc(this,e.getBoundingClientRect(),t)}else Cc(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Gr(t.slice,t.move,i<0?void 0:A.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let o=0;oe.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(t){return Rp(this,t)}coordsAtPos(t,e=1){return lu(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return $p(this,e||this.state,t)}pasteHTML(t,e){return _n(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return _n(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Po(this,t)}destroy(){this.docView&&(um(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],co(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yp())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return dm(this,t)}domSelectionRange(){let t=this.domSelection();return t?ht&&this.root.nodeType===11&&xp(this.dom.ownerDocument)==this.dom&&Rm(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};qn.prototype.dispatch=function(n){let t=this._props.dispatchTransaction;t?t.call(this,n):this.updateState(this.state.apply(n))};function Xc(n){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(n.editable),n.someProp("attributes",e=>{if(typeof e=="function"&&(e=e(n.state)),e)for(let r in e)r=="class"?t.class+=" "+e[r]:r=="style"?t.style=(t.style?t.style+";":"")+e[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(e[r]))}),t.translate||(t.translate="no"),[ot.node(0,n.state.doc.content.size,t)]}function Qc(n){if(n.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),n.cursorWrapper={dom:t,deco:ot.widget(n.state.selection.from,t,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Yc(n){return!n.someProp("editable",t=>t(n.state)===!1)}function jm(n,t){let e=Math.min(n.$anchor.sharedDepth(n.head),t.$anchor.sharedDepth(t.head));return n.$anchor.start(e)!=t.$anchor.start(e)}function Zc(n){let t=Object.create(null);function e(r){for(let i in r)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=r[i])}return n.someProp("nodeViews",e),n.someProp("markViews",e),t}function _m(n,t){let e=0,r=0;for(let i in n){if(n[i]!=t[i])return!0;e++}for(let i in t)r++;return e!=r}function tu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ue={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:"'"},ni={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Km=typeof navigator<"u"&&/Mac/.test(navigator.platform),qm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(nt=0;nt<10;nt++)ue[48+nt]=ue[96+nt]=String(nt);var nt;for(nt=1;nt<=24;nt++)ue[nt+111]="F"+nt;var nt;for(nt=65;nt<=90;nt++)ue[nt]=String.fromCharCode(nt+32),ni[nt]=String.fromCharCode(nt);var nt;for(ei in ue)ni.hasOwnProperty(ei)||(ni[ei]=ue[ei]);var ei;function Du(n){var t=Km&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||qm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",e=!t&&n.key||(n.shiftKey?ni:ue)[n.keyCode]||n.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}var Jm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Gm=typeof navigator<"u"&&/Win/.test(navigator.platform);function Xm(n){let t=n.split(/-(?!$)/),e=t[t.length-1];e=="Space"&&(e=" ");let r,i,s,o;for(let a=0;a{for(var e in t)Ym(n,e,{get:t[e],enumerable:!0})};function ui(n){let{state:t,transaction:e}=n,{selection:r}=e,{doc:i}=e,{storedMarks:s}=e;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=e.selection,i=e.doc,s=e.storedMarks,e}}}var hi=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:n,editor:t,state:e}=this,{view:r}=t,{tr:i}=e,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,a])=>[o,(...c)=>{let u=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,t=!0){let{rawCommands:e,editor:r,state:i}=this,{view:s}=r,o=[],a=!!n,l=n||i.tr,c=()=>(!a&&t&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),o.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(e).map(([h,d])=>[h,(...p)=>{let m=this.buildProps(l,t),g=d(...p)(m);return o.push(g),u}])),run:c};return u}createCan(n){let{rawCommands:t,state:e}=this,r=!1,i=n||e.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,t=!0){let{rawCommands:e,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:ui({state:i,transaction:n}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(n,t),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)(o)]))}};return o}},Uu={};_o(Uu,{blur:()=>Zm,clearContent:()=>tg,clearNodes:()=>eg,command:()=>ng,createParagraphNear:()=>rg,cut:()=>ig,deleteCurrentNode:()=>sg,deleteNode:()=>og,deleteRange:()=>ag,deleteSelection:()=>lg,enter:()=>cg,exitCode:()=>ug,extendMarkRange:()=>hg,first:()=>dg,focus:()=>pg,forEach:()=>mg,insertContent:()=>gg,insertContentAt:()=>vg,joinBackward:()=>xg,joinDown:()=>kg,joinForward:()=>Sg,joinItemBackward:()=>Cg,joinItemForward:()=>Eg,joinTextblockBackward:()=>Tg,joinTextblockForward:()=>Mg,joinUp:()=>wg,keyboardShortcut:()=>Ng,lift:()=>Og,liftEmptyBlock:()=>Ig,liftListItem:()=>Dg,newlineInCode:()=>Pg,resetAttributes:()=>Rg,scrollIntoView:()=>Lg,selectAll:()=>zg,selectNodeBackward:()=>Bg,selectNodeForward:()=>Fg,selectParentNode:()=>$g,selectTextblockEnd:()=>Hg,selectTextblockStart:()=>Vg,setContent:()=>Wg,setMark:()=>sy,setMeta:()=>oy,setNode:()=>ay,setNodeSelection:()=>ly,setTextDirection:()=>cy,setTextSelection:()=>uy,sinkListItem:()=>hy,splitBlock:()=>dy,splitListItem:()=>fy,toggleList:()=>my,toggleMark:()=>gy,toggleNode:()=>yy,toggleWrap:()=>by,undoInputRule:()=>vy,unsetAllMarks:()=>wy,unsetMark:()=>ky,unsetTextDirection:()=>xy,updateAttributes:()=>Sy,wrapIn:()=>Cy,wrapInList:()=>Ey});var Zm=()=>({editor:n,view:t})=>(requestAnimationFrame(()=>{var e;n.isDestroyed||(t.dom.blur(),(e=window?.getSelection())==null||e.removeAllRanges())}),!0),tg=(n=!0)=>({commands:t})=>t.setContent("",{emitUpdate:n}),eg=()=>({state:n,tr:t,dispatch:e})=>{let{selection:r}=t,{ranges:i}=r;return e&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;let{doc:c,mapping:u}=t,h=c.resolve(u.map(l)),d=c.resolve(u.map(l+a.nodeSize)),f=h.blockRange(d);if(!f)return;let p=se(f);if(a.type.isTextblock){let{defaultType:m}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(f.start,m)}(p||p===0)&&t.lift(f,p)})}),!0},ng=n=>t=>n(t),rg=()=>({state:n,dispatch:t})=>to(n,t),ig=(n,t)=>({editor:e,tr:r})=>{let{state:i}=e,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let o=r.mapping.map(t);return r.insert(o,s.content),r.setSelection(new I(r.doc.resolve(Math.max(o-1,0)))),!0},sg=()=>({tr:n,dispatch:t})=>{let{selection:e}=n,r=e.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(t){let a=i.before(s),l=i.after(s);n.delete(a,l).scrollIntoView()}return!0}return!1};function Y(n,t){if(typeof n=="string"){if(!t.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return t.nodes[n]}return n}var og=n=>({tr:t,state:e,dispatch:r})=>{let i=Y(n,e.schema),s=t.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){let l=s.before(o),c=s.after(o);t.delete(l,c).scrollIntoView()}return!0}return!1},ag=n=>({tr:t,dispatch:e})=>{let{from:r,to:i}=n;return e&&t.delete(r,i),!0},lg=()=>({state:n,dispatch:t})=>Wr(n,t),cg=()=>({commands:n})=>n.keyboardShortcut("Enter"),ug=()=>({state:n,dispatch:t})=>Zs(n,t);function Ko(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function li(n,t,e={strict:!0}){let r=Object.keys(t);return r.length?r.every(i=>e.strict?t[i]===n[i]:Ko(t[i])?t[i].test(n[i]):t[i]===n[i]):!0}function ju(n,t,e={}){return n.find(r=>r.type===t&&li(Object.fromEntries(Object.keys(e).map(i=>[i,r.attrs[i]])),e))}function Ru(n,t,e={}){return!!ju(n,t,e)}function qo(n,t,e){if(!n||!t)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===t))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===t))return;if(!e){let c=r.node.marks.find(u=>u.type===t);c&&(e=c.attrs)}if(!ju([...r.node.marks],t,e))return;let s=r.index,o=n.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(;s>0&&Ru([...n.parent.child(s-1).marks],t,e);)s-=1,o-=n.parent.child(s).nodeSize;for(;a({tr:e,state:r,dispatch:i})=>{let s=he(n,r.schema),{doc:o,selection:a}=e,{$from:l,from:c,to:u}=a;if(i){let h=qo(l,s,t);if(h&&h.from<=c&&h.to>=u){let d=I.create(o,h.from,h.to);e.setSelection(d)}}return!0},dg=n=>t=>{let e=typeof n=="function"?n(t):n;for(let r=0;r({editor:e,view:r,tr:i,dispatch:s})=>{t={scrollIntoView:!0,...t};let o=()=>{(ci()||Lu())&&r.dom.focus(),fg()&&!ci()&&!Lu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{e.isDestroyed||(r.focus(),t?.scrollIntoView&&e.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!_u(e.state.selection))return o(),!0;let a=Ku(i.doc,n)||e.state.selection,l=e.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},mg=(n,t)=>e=>n.every((r,i)=>t(r,{...e,index:i})),gg=(n,t)=>({tr:e,commands:r})=>r.insertContentAt({from:e.selection.from,to:e.selection.to},n,t),qu=n=>{let t=n.childNodes;for(let e=t.length-1;e>=0;e-=1){let r=t[e];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&qu(r)}return n};function ri(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`${n}`,e=new window.DOMParser().parseFromString(t,"text/html").body;return qu(e)}function Zn(n,t,e){if(n instanceof Tt||n instanceof v)return n;e={slice:!0,parseOptions:{},...e};let r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return v.fromArray(n.map(a=>t.nodeFromJSON(a)));let o=t.nodeFromJSON(n);return e.errorOnInvalidContent&&o.check(),o}catch(s){if(e.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Zn("",t,e)}if(i){if(e.errorOnInvalidContent){let o=!1,a="",l=new nn({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(e.slice?Ut.fromSchema(l).parseSlice(ri(n),e.parseOptions):Ut.fromSchema(l).parse(ri(n),e.parseOptions),e.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}let s=Ut.fromSchema(t);return e.slice?s.parseSlice(ri(n),e.parseOptions).content:s.parse(ri(n),e.parseOptions)}return Zn("",t,e)}function yg(n,t,e){let r=n.steps.length-1;if(r{o===0&&(o=u)}),n.setSelection(R.near(n.doc.resolve(o),e))}var bg=n=>!("type"in n),vg=(n,t,e)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){e={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...e};let a,l=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...e.parseOptions};if(!e.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Zn(t,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Zn(t,s.schema,{parseOptions:c,errorOnInvalidContent:(o=e.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:h}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,f=!0;if((bg(a)?a:[a]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,f=f?g.isBlock:!1}),u===h&&f){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,h+=1)}let m;if(d){if(Array.isArray(t))m=t.map(g=>g.text||"").join("");else if(t instanceof v){let g="";t.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof t=="object"&&t&&t.text?m=t.text:m=t;r.insertText(m,u,h)}else{m=a;let g=r.doc.resolve(u),y=g.node(),b=g.parentOffset===0,C=y.isText||y.isTextblock,M=y.content.size>0;b&&C&&M&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,h,m)}e.updateSelection&&yg(r,r.steps.length-1,-1),e.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),e.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},wg=()=>({state:n,dispatch:t})=>dc(n,t),kg=()=>({state:n,dispatch:t})=>fc(n,t),xg=()=>({state:n,dispatch:t})=>_s(n,t),Sg=()=>({state:n,dispatch:t})=>Js(n,t),Cg=()=>({state:n,dispatch:t,tr:e})=>{try{let r=Pe(n.doc,n.selection.$from.pos,-1);return r==null?!1:(e.join(r,2),t&&t(e),!0)}catch{return!1}},Eg=()=>({state:n,dispatch:t,tr:e})=>{try{let r=Pe(n.doc,n.selection.$from.pos,1);return r==null?!1:(e.join(r,2),t&&t(e),!0)}catch{return!1}},Tg=()=>({state:n,dispatch:t})=>lc(n,t),Mg=()=>({state:n,dispatch:t})=>cc(n,t);function Ju(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ag(n){let t=n.split(/-(?!$)/),e=t[t.length-1];e==="Space"&&(e=" ");let r,i,s,o;for(let a=0;a({editor:t,view:e,tr:r,dispatch:i})=>{let s=Ag(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{e.someProp("handleKeyDown",c=>c(e,a))});return l?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Kt(n,t,e={}){let{from:r,to:i,empty:s}=n.selection,o=t?Y(t,n.schema):null,a=[];n.doc.nodesBetween(r,i,(h,d)=>{if(h.isText)return;let f=Math.max(r,d),p=Math.min(i,d+h.nodeSize);a.push({node:h,from:f,to:p})});let l=i-r,c=a.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>li(h.node.attrs,e,{strict:!1}));return s?!!c.length:c.reduce((h,d)=>h+d.to-d.from,0)>=l}var Og=(n,t={})=>({state:e,dispatch:r})=>{let i=Y(n,e.schema);return Kt(e,i,t)?pc(e,r):!1},Ig=()=>({state:n,dispatch:t})=>eo(n,t),Dg=n=>({state:t,dispatch:e})=>{let r=Y(n,t.schema);return wc(r)(t,e)},Pg=()=>({state:n,dispatch:t})=>Qs(n,t);function di(n,t){return t.nodes[n]?"node":t.marks[n]?"mark":null}function zu(n,t){let e=typeof t=="string"?[t]:t;return Object.keys(n).reduce((r,i)=>(e.includes(i)||(r[i]=n[i]),r),{})}var Rg=(n,t)=>({tr:e,state:r,dispatch:i})=>{let s=null,o=null,a=di(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=Y(n,r.schema)),a==="mark"&&(o=he(n,r.schema));let l=!1;return e.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,h)=>{s&&s===u.type&&(l=!0,i&&e.setNodeMarkup(h,void 0,zu(u.attrs,t))),o&&u.marks.length&&u.marks.forEach(d=>{o===d.type&&(l=!0,i&&e.addMark(h,h+u.nodeSize,o.create(zu(d.attrs,t))))})})}),l},Lg=()=>({tr:n,dispatch:t})=>(t&&n.scrollIntoView(),!0),zg=()=>({tr:n,dispatch:t})=>{if(t){let e=new xt(n.doc);n.setSelection(e)}return!0},Bg=()=>({state:n,dispatch:t})=>Ks(n,t),Fg=()=>({state:n,dispatch:t})=>Gs(n,t),$g=()=>({state:n,dispatch:t})=>mc(n,t),Hg=()=>({state:n,dispatch:t})=>ro(n,t),Vg=()=>({state:n,dispatch:t})=>no(n,t);function Uo(n,t,e={},r={}){return Zn(n,t,{slice:!1,parseOptions:e,errorOnInvalidContent:r.errorOnInvalidContent})}var Wg=(n,{errorOnInvalidContent:t,emitUpdate:e=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{let{doc:l}=s;if(r.preserveWhitespace!=="full"){let c=Uo(n,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function Gu(n,t){let e=he(t,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});let a=o.find(l=>l.type.name===e.name);return a?{...a.attrs}:{}}function Jo(n,t){let e=new on(n);return t.forEach(r=>{r.steps.forEach(i=>{e.step(i)})}),e}function Ug(n){for(let t=0;t{e(i)&&r.push({node:i,pos:s})}),r}function jg(n,t){for(let e=n.depth;e>0;e-=1){let r=n.node(e);if(t(r))return{pos:e>0?n.before(e):0,start:n.start(e),depth:e,node:r}}}function fi(n){return t=>jg(t.$from,n)}function O(n,t,e){return n.config[t]===void 0&&n.parent?O(n.parent,t,e):typeof n.config[t]=="function"?n.config[t].bind({...e,parent:n.parent?O(n.parent,t,e):null}):n.config[t]}function Go(n){return n.map(t=>{let e={name:t.name,options:t.options,storage:t.storage},r=O(t,"addExtensions",e);return r?[t,...Go(r())]:t}).flat(10)}function Xo(n,t){let e=ne.fromSchema(t).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(e),i.innerHTML}function Qu(n){return typeof n=="function"}function _(n,t=void 0,...e){return Qu(n)?t?n.bind(t)(...e):n(...e):n}function _g(n={}){return Object.keys(n).length===0&&n.constructor===Object}function yn(n){let t=n.filter(i=>i.type==="extension"),e=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:t,nodeExtensions:e,markExtensions:r}}function Yu(n){let t=[],{nodeExtensions:e,markExtensions:r}=yn(n),i=[...e,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=e.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...o,...a];return n.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage,extensions:i},h=O(c,"addGlobalAttributes",u);if(!h)return;h().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=l:f.types==="nodes"?p=o:f.types==="marks"?p=a:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([g,y])=>{t.push({type:m,name:g,attribute:{...s,...y}})})})})}),i.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage},h=O(c,"addAttributes",u);if(!h)return;let d=h();Object.entries(d).forEach(([f,p])=>{let m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,t.push({type:c.name,name:f,attribute:m})})}),t}function Kg(n){let t=[],e="",r=!1,i=!1,s=0,o=n.length;for(let a=0;a0){s-=1,e+=l;continue}if(l===";"&&s===0){t.push(e),e="";continue}}e+=l}return e&&t.push(e),t}function Bu(n){let t=[],e=Kg(n||""),r=e.length;for(let i=0;i!!t).reduce((t,e)=>{let r={...t};return Object.entries(e).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){let a=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){let a=new Map([...Bu(r[i]),...Bu(s)]);r[i]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[i]=s}),r},{})}function bn(n,t){return t.filter(e=>e.type===n.type.name).filter(e=>e.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(n.attrs)||{}:{[e.name]:n.attrs[e.name]}).reduce((e,r)=>P(e,r),{})}function qg(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Fu(n,t){return"style"in n?n:{...n,getAttrs:e=>{let r=n.getAttrs?n.getAttrs(e):n.attrs;if(r===!1)return!1;let i=t.reduce((s,o)=>{let a=o.attribute.parseHTML?o.attribute.parseHTML(e):qg(e.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function $u(n){return Object.fromEntries(Object.entries(n).filter(([t,e])=>t==="attrs"&&_g(e)?!1:e!=null))}function Hu(n){var t,e;let r={};return!((t=n?.attribute)!=null&&t.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((e=n?.attribute)==null?void 0:e.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function Jg(n,t){var e;let r=Yu(n),{nodeExtensions:i,markExtensions:s}=yn(n),o=(e=i.find(c=>O(c,"topNode")))==null?void 0:e.name,a=Object.fromEntries(i.map(c=>{let u=r.filter(y=>y.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:t},d=n.reduce((y,b)=>{let C=O(b,"extendNodeSchema",h);return{...y,...C?C(c):{}}},{}),f=$u({...d,content:_(O(c,"content",h)),marks:_(O(c,"marks",h)),group:_(O(c,"group",h)),inline:_(O(c,"inline",h)),atom:_(O(c,"atom",h)),selectable:_(O(c,"selectable",h)),draggable:_(O(c,"draggable",h)),code:_(O(c,"code",h)),whitespace:_(O(c,"whitespace",h)),linebreakReplacement:_(O(c,"linebreakReplacement",h)),defining:_(O(c,"defining",h)),isolating:_(O(c,"isolating",h)),attrs:Object.fromEntries(u.map(Hu))}),p=_(O(c,"parseHTML",h));p&&(f.parseDOM=p.map(y=>Fu(y,u)));let m=O(c,"renderHTML",h);m&&(f.toDOM=y=>m({node:y,HTMLAttributes:bn(y,u)}));let g=O(c,"renderText",h);return g&&(f.toText=g),[c.name,f]})),l=Object.fromEntries(s.map(c=>{let u=r.filter(g=>g.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:t},d=n.reduce((g,y)=>{let b=O(y,"extendMarkSchema",h);return{...g,...b?b(c):{}}},{}),f=$u({...d,inclusive:_(O(c,"inclusive",h)),excludes:_(O(c,"excludes",h)),group:_(O(c,"group",h)),spanning:_(O(c,"spanning",h)),code:_(O(c,"code",h)),attrs:Object.fromEntries(u.map(Hu))}),p=_(O(c,"parseHTML",h));p&&(f.parseDOM=p.map(g=>Fu(g,u)));let m=O(c,"renderHTML",h);return m&&(f.toDOM=g=>m({mark:g,HTMLAttributes:bn(g,u)})),[c.name,f]}));return new nn({topNode:o,nodes:a,marks:l})}function Gg(n){let t=n.filter((e,r)=>n.indexOf(e)!==r);return Array.from(new Set(t))}function Yn(n){return n.sort((e,r)=>{let i=O(e,"priority")||100,s=O(r,"priority")||100;return i>s?-1:ir.name));return e.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${e.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),t}function th(n,t,e){let{from:r,to:i}=t,{blockSeparator:s=` -`,textSerializers:o={}}=n||{},a="";return t.nodesBetween(r,i,(l,c,u,d)=>{var f;l.isBlock&&c>r&&(a+=s);let h=o?.[l.type.name];if(h)return u&&(a+=h({node:l,pos:c,parent:u,index:d,range:e})),!1;l.isText&&(a+=(f=l?.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),a}function m1(t,e){let n={from:0,to:t.content.size};return Em(t,n,e)}function Tm(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function g1(t,e){let n=se(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,a=>{s.push(a)});let o=s.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function jc(t,e){let n=So(typeof e=="string"?e:e.name,t.schema);return n==="node"?g1(t,e):n==="mark"?wm(t,e):{}}function y1(t,e=JSON.stringify){let n={};return t.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function b1(t){let e=y1(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function qc(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{let o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{let{from:a,to:l}=n[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{let c=e.slice(s).map(a,-1),u=e.slice(s).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),b1(r)}function Eo(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(i=>{let s=n.resolve(t),o=Hc(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Am=(t,e,n,r=20)=>{let i=t.doc.resolve(n),s=r,o=null;for(;s>0&&o===null;){let a=i.node(s);a?.type.name===e?o=a:s-=1}return[o,s]};function Ai(t,e){return e.nodes[t]||e.marks[t]||null}function bo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var v1=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,c;let u=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),n};function zc(t,e,n={}){let{empty:r,ranges:i}=t.selection,s=e?$t(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>vo(d.attrs,n,{strict:!1}));let o=0,a=[];if(i.forEach(({$from:d,$to:f})=>{let h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(h,g),b=Math.min(p,g+m.nodeSize),x=b-y;o+=x,a.push(...m.marks.map(w=>({mark:w,from:y,to:b})))})}),o===0)return!1;let l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>vo(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+c:l)>=o}function w1(t,e,n={}){if(!e)return ht(t,null,n)||zc(t,null,n);let r=So(e,t.schema);return r==="node"?ht(t,e,n):r==="mark"?zc(t,e,n):!1}var Mm=(t,e)=>{let{$from:n,$to:r,$anchor:i}=t.selection;if(e){let s=Co(a=>a.type.name===e)(t.selection);if(!s)return!1;let o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function fm(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Rc(t,e){let{nodeExtensions:n}=xr(e),r=n.find(o=>o.name===t);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},s=J(I(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Oi(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(Oi(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function To(t){return t instanceof O}var Nm=class Om{constructor(e){this.position=e}static fromJSON(e){return new Om(e.position)}toJSON(){return{position:this.position}}};function x1(t,e){let n=e.mapping.mapResult(t.position);return{position:new Nm(n.pos),mapResult:n}}function k1(t){return new Nm(t)}function S1(t,e,n){var r;let{selection:i}=e,s=null;if(gm(i)&&(s=i.$cursor),s){let a=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(c=>c.type.excludes(n)))}let{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var C1=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let{selection:s}=n,{empty:o,ranges:a}=s,l=$t(t,r.schema);if(i)if(o){let c=wm(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===l)?f.marks.forEach(y=>{l===y.type&&n.addMark(p,m,l.create({...y.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return S1(r,n,l)},E1=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),T1=(t,e={})=>({state:n,dispatch:r,chain:i})=>{let s=se(t,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:a})=>Ql(s,{...o,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Ql(s,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},A1=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,i=Bn(t,0,r.content.size),s=O.create(r,i);e.setSelection(s)}return!0},M1=(t,e)=>({tr:n,state:r,dispatch:i})=>{let{selection:s}=r,o,a;return typeof e=="number"?(o=e,a=e):e&&"from"in e&&"to"in e?(o=e.from,a=e.to):(o=s.from,a=s.to),i&&n.doc.nodesBetween(o,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},_1=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=D.atStart(r).from,a=D.atEnd(r).to,l=Bn(i,o,a),c=Bn(s,o,a),u=D.create(r,l,c);e.setSelection(u)}return!0},N1=t=>({state:e,dispatch:n})=>{let r=se(t,e.schema);return qh(r)(e,n)};function hm(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var O1=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{let{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=i.extensionManager.attributes,u=bo(c,a.node().type.name,a.node().attrs);if(s instanceof O&&s.node.isBlock)return!a.parentOffset||!He(o,a.pos)?!1:(r&&(t&&hm(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let d=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:l1(a.node(-1).contentMatchAt(a.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=He(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&He(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(s instanceof D&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){let m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&hm(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},I1=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;let a=se(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;let d=l.node(-1);if(d.type!==a)return!1;let f=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let y=S.empty,b=l.index(-1)?1:l.index(-2)?2:3;for(let E=l.depth-b;E>=l.depth-3;E-=1)y=S.from(l.node(E).copy(y));let x=l.indexAfter(-1){if(k>-1)return!1;E.isTextblock&&E.content.size===0&&(k=_+1)}),k>-1&&n.setSelection(D.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}let h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...bo(f,d.type.name,d.attrs),...e},m={...bo(f,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);let g=h?[{type:a,attrs:p},{type:h,attrs:m}]:[{type:a,attrs:p}];if(!He(n.doc,l.pos,2))return!1;if(i){let{selection:y,storedMarks:b}=r,{splittableMarks:x}=s.extensionManager,w=b||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!w||!i)return!0;let v=w.filter(T=>x.includes(T.type.name));n.ensureMarks(v)}return!0},Pc=(t,e)=>{let n=Co(o=>o.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&qe(t.doc,n.pos)&&t.join(n.pos),!0},Lc=(t,e)=>{let n=Co(o=>o.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&qe(t.doc,r)&&t.join(r),!0};function D1(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),i=e.resolve(n.nodeSize-1);return D.between(r,i)}var R1=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,h=se(t,o.schema),p=se(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:b}=m,x=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;let v=Co(ne=>Rc(ne.type.name,d))(m),T=m.from===0&&m.to===o.doc.content.size,k=o.doc.content.content,E=k.length===1?k[0]:null,_=T&&E&&Rc(E.type.name,d)?{node:E,pos:0,depth:0}:null,z=v??_,N=!!v&&x.depth>=1&&x.depth-v.depth<=1,X=!!_;if((N||X)&&z){if(z.node.type===h)return T&&X?l().command(({tr:ne,dispatch:re})=>{let ie=D1(ne);return ie?(ne.setSelection(ie),re&&re(ne),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Rc(z.node.type.name,d)&&h.validContent(z.node.content))return l().command(()=>(s.setNodeMarkup(z.pos,h),!0)).command(()=>Pc(s,h)).command(()=>Lc(s,h)).run()}return!n||!w||!a?l().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Pc(s,h)).command(()=>Lc(s,h)).run():l().command(()=>{let ne=u().wrapInList(h,r),re=w.filter(ie=>f.includes(ie.type.name));return s.ensureMarks(re),ne?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Pc(s,h)).command(()=>Lc(s,h)).run()},P1=(t,e={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:s=!1}=n,o=$t(t,r.schema);return zc(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},L1=(t,e,n={})=>({state:r,commands:i})=>{let s=se(t,r.schema),o=se(e,r.schema),a=ht(r,s,n),l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(o,l):i.setNode(s,{...l,...n})},B1=(t,e={})=>({state:n,commands:r})=>{let i=se(t,n.schema);return ht(n,i,e)?r.lift(i):r.wrapIn(i,e)},z1=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){let l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},F1=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},$1=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;let{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=$t(t,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&o){let{from:f,to:h}=a,p=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=Hc(c,l,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},H1=t=>({tr:e,state:n,dispatch:r})=>{let{selection:i}=n,s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(a,l)=>{if(a.isText)return;let c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},V1=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null,a=So(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=se(t,r.schema)),a==="mark"&&(o=$t(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{s&&s===g.type&&(l=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y=u&&y<=d&&(s&&s===g.type&&(l=!0,i&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type&&(l=!0,i)){let x=Math.max(y,u),w=Math.min(y+g.nodeSize,d);n.addMark(x,w,o.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&i&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),l},U1=(t,e={})=>({state:n,dispatch:r})=>{let i=se(t,n.schema);return Uh(i,e)(n,r)},W1=(t,e={})=>({state:n,dispatch:r})=>{let i=se(t,n.schema);return Wh(i,e)(n,r)},j1=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Me=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},q1=(t,e)=>{if($c(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function mo(t){var e;let{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1,d=v1(c)+s;return o.forEach(f=>{if(u)return;let h=q1(d,f.find);if(!h)return;let p=l.state.tr,m=xo({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:y,chain:b,can:x}=new ko({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:b,can:x})===null||!p.steps.length||(f.undoable&&p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),u=!0)}),u}function K1(t){let{editor:e,rules:n}=t,r=new R({state:{init(){return null},apply(i,s,o){let a=i.getMeta(r);if(a)return a;let l=i.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Wc(S.from(u),o.schema);let{from:d}=l,f=d+u.length;mo({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return mo({editor:e,from:s,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:s}=i.state.selection;s&&mo({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;let{$cursor:o}=i.state.selection;return o?mo({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function J1(t){return Object.prototype.toString.call(t).slice(8,-1)}function go(t){return J1(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Im(t,e){let n={...t};return go(t)&&go(e)&&Object.keys(e).forEach(r=>{go(e[r])&&go(t[r])?n[r]=Im(t[r],e[r]):n[r]=e[r]}),n}var Kc=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...J(I(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...J(I(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Im(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ae=class Dm extends Kc{constructor(){super(...arguments),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new Dm(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let o=i.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;let l=o.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Z1(t){return typeof t=="number"}var X1=class{constructor(t){this.find=t.find,this.handler=t.handler}},G1=(t,e,n)=>{if($c(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(i=>{let s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Y1(t){let{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:c,can:u}=new ko({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(h,p)=>{var m,g,y,b,x;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;let w=(x=(b=(y=h.content)==null?void 0:y.size)!=null?b:h.nodeSize)!=null?x:0,v=Math.max(r,p),T=Math.min(i,p+w);if(v>=T)return;let k=h.isText?h.text||"":h.textBetween(v-p,T-p,void 0,"\uFFFC");G1(k,s.find,o).forEach(_=>{if(_.index===void 0)return;let z=v+_.index+1,N=z+_[0].length,X={from:n.tr.mapping.map(z),to:n.tr.mapping.map(N)},ne=s.handler({state:n,range:X,match:_,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});d.push(ne)})}),d.every(h=>h!==null)}var yo=null,Q1=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function eC(t){let{editor:e,rules:n}=t,r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}let l=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{let m=u.tr,g=xo({state:u,transaction:m});if(!(!Y1({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new R({view(d){let f=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(yo=e)},h=()=>{yo&&(yo=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(s=r===d.dom.parentElement,a=f,!s){let h=yo;h?.isEditable&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;let p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{let p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:v}=y;typeof v=="string"?v=v:v=Wc(S.from(v),h.schema);let{from:T}=y,k=T+v.length,E=Q1(v);return l({rule:u,state:h,from:T,to:{b:k},pasteEvt:E})}let x=f.doc.content.findDiffStart(h.doc.content),w=f.doc.content.findDiffEnd(h.doc.content);if(!(!Z1(x)||!w||x===w.b))return l({rule:u,state:h,from:x,to:w,pasteEvt:o})}}))}var Ao=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Cm(t),this.schema=h1(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ai(e.name,this.schema)},r=I(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){let{editor:t}=this;return _i([...this.extensions].reverse()).flatMap(r=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ai(r.name,this.schema)},s=[],o=I(r,"addKeyboardShortcuts",i),a={};if(r.type==="mark"&&I(r,"exitable",i)&&(a.ArrowRight=()=>ae.handleExit({editor:t,mark:r})),o){let f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:t})]));a={...a,...f}}let l=im(a);s.push(l);let c=I(r,"addInputRules",i);if(fm(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=K1({editor:t,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}let u=I(r,"addPasteRules",i);if(fm(r,t.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=eC({editor:t,rules:f});s.push(...h)}}let d=I(r,"addProseMirrorPlugins",i);if(d){let f=d();s.push(...f)}return s})}get attributes(){return Sm(this.extensions)}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=xr(this.extensions);return Object.fromEntries(e.filter(n=>!!I(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:se(n.name,this.schema)},s=I(n,"addNodeView",i);if(!s)return[];let o=s();if(!o)return[];let a=(l,c,u,d,f)=>{let h=kr(l,r);return o({node:l,view:c,getPos:u,decorations:d,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,a]}))}dispatchTransaction(t){let{editor:e}=this;return _i([...this.extensions].reverse()).reduceRight((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Ai(i.name,this.schema)},o=I(i,"dispatchTransaction",s);return o?a=>{o.call(s,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){let{editor:e}=this;return _i([...this.extensions]).reduce((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Ai(i.name,this.schema)},o=I(i,"transformPastedHTML",s);return o?(a,l)=>{let c=r(a,l);return o.call(s,c)}:r},t||(r=>r))}get markViews(){let{editor:t}=this,{markExtensions:e}=xr(this.extensions);return Object.fromEntries(e.filter(n=>!!I(n,"addMarkView")).map(n=>{let r=this.attributes.filter(a=>a.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:$t(n.name,this.schema)},s=I(n,"addMarkView",i);if(!s)return[];let o=(a,l,c)=>{let u=kr(a,r);return s()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{dC(a,t,d)}})};return[n.name,o]}))}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;let r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ai(e.name,this.schema)};e.type==="mark"&&((n=J(I(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);let i=I(e,"onBeforeCreate",r),s=I(e,"onCreate",r),o=I(e,"onUpdate",r),a=I(e,"onSelectionUpdate",r),l=I(e,"onTransaction",r),c=I(e,"onFocus",r),u=I(e,"onBlur",r),d=I(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};Ao.resolve=Cm;Ao.sort=_i;Ao.flatten=Uc;var tC={};Fc(tC,{ClipboardTextSerializer:()=>Pm,Commands:()=>Lm,Delete:()=>Bm,Drop:()=>zm,Editable:()=>Fm,FocusEvents:()=>Hm,Keymap:()=>Vm,Paste:()=>Um,Tabindex:()=>Wm,TextDirection:()=>jm,focusEventsPluginKey:()=>$m});var B=class Rm extends Kc{constructor(){super(...arguments),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new Rm(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Pm=B.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new R({key:new F("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),l=Tm(n);return Em(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Lm=B.create({name:"commands",addCommands(){return{...pm}}}),Bm=B.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;let s=()=>{var o,a,l,c;if((c=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,t))!=null?c:t.getMeta("y-sync$"))return;let u=Vc(t.before,[t,...e]);qc(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});let f=u.mapping;u.steps.forEach((h,p)=>{var m,g;if(h instanceof Dt){let y=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),x=f.invert().map(y,-1),w=f.invert().map(b),v=y>0?(m=u.doc.nodeAt(y-1))==null?void 0:m.marks.some(k=>k.eq(h.mark)):!1,T=(g=u.doc.nodeAt(b))==null?void 0:g.marks.some(k=>k.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:x,to:w},newRange:{from:y,to:b},partial:!!(T||v),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),zm=B.create({name:"drop",addProseMirrorPlugins(){return[new R({key:new F("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Fm=B.create({name:"editable",addProseMirrorPlugins(){return[new R({key:new F("editable"),props:{editable:()=>this.editor.options.editable}})]}}),$m=new F("focusEvents"),Hm=B.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new R({key:$m,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Vm=B.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:L.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return wo()||vm()?s:i},addProseMirrorPlugins(){return[new R({key:new F("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;let r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),i=t.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:s,from:o,to:a}=e.selection,l=L.atStart(e.doc).from,c=L.atEnd(e.doc).to;if(s||!(o===l&&a===c)||!Oi(n.doc))return;let f=n.tr,h=xo({state:n,transaction:f}),{commands:p}=new ko({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Um=B.create({name:"paste",addProseMirrorPlugins(){return[new R({key:new F("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Wm=B.create({name:"tabindex",addProseMirrorPlugins(){return[new R({key:new F("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),jm=B.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=xr(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new R({key:new F("textDirection"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}}),nC=class Mi{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Mi(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Mi(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Mi(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(a);if(!i&&!o&&l.depth<=this.depth)return;let c=new Mi(l,this.editor,i,i||o?n:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){let s=i.node.attrs,o=Object.keys(n);for(let a=0;a{r&&i.length>0||(o.node.type.name===e&&s.every(l=>n[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},rC=`.ProseMirror { +`,textSerializers:o={}}=e||{},a="";return n.nodesBetween(r,i,(l,c,u,h)=>{var d;l.isBlock&&c>r&&(a+=s);let f=o?.[l.type.name];if(f)return u&&(a+=f({node:l,pos:c,parent:u,index:h,range:t})),!1;l.isText&&(a+=(d=l?.text)==null?void 0:d.slice(Math.max(r,c)-c,i-c))}),a}function Xg(n,t){let e={from:0,to:n.content.size};return th(n,e,t)}function eh(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function Qg(n,t){let e=Y(t,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,a=>{s.push(a)});let o=s.reverse().find(a=>a.type.name===e.name);return o?{...o.attrs}:{}}function Qo(n,t){let e=di(typeof t=="string"?t:t.name,n.schema);return e==="node"?Qg(n,t):e==="mark"?Gu(n,t):{}}function Yg(n,t=JSON.stringify){let e={};return n.filter(r=>{let i=t(r);return Object.prototype.hasOwnProperty.call(e,i)?!1:e[i]=!0})}function Zg(n){let t=Yg(n);return t.length===1?t:t.filter((e,r)=>!t.filter((s,o)=>o!==r).some(s=>e.oldRange.from>=s.oldRange.from&&e.oldRange.to<=s.oldRange.to&&e.newRange.from>=s.newRange.from&&e.newRange.to<=s.newRange.to))}function Yo(n){let{mapping:t,steps:e}=n,r=[];return t.maps.forEach((i,s)=>{let o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{let{from:a,to:l}=e[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{let c=t.slice(s).map(a,-1),u=t.slice(s).map(l),h=t.invert().map(c,-1),d=t.invert().map(u);r.push({oldRange:{from:h,to:d},newRange:{from:c,to:u}})})}),Zg(r)}function pi(n,t,e){let r=[];return n===t?e.resolve(n).marks().forEach(i=>{let s=e.resolve(n),o=qo(s,i.type);o&&r.push({mark:i,...o})}):e.nodesBetween(n,t,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var nh=(n,t,e,r=20)=>{let i=n.doc.resolve(e),s=r,o=null;for(;s>0&&o===null;){let a=i.node(s);a?.type.name===t?o=a:s-=1}return[o,s]};function Xn(n,t){return t.nodes[n]||t.marks[n]||null}function ai(n,t,e){return Object.fromEntries(Object.entries(e).filter(([r])=>{let i=n.find(s=>s.type===t&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var ty=(n,t=500)=>{let e="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-t),r,(i,s,o,a)=>{var l,c;let u=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";e+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),e};function jo(n,t,e={}){let{empty:r,ranges:i}=n.selection,s=t?he(t,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>li(h.attrs,e,{strict:!1}));let o=0,a=[];if(i.forEach(({$from:h,$to:d})=>{let f=h.pos,p=d.pos;n.doc.nodesBetween(f,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(f,g),b=Math.min(p,g+m.nodeSize),C=b-y;o+=C,a.push(...m.marks.map(M=>({mark:M,from:y,to:b})))})}),o===0)return!1;let l=a.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>li(h.mark.attrs,e,{strict:!1})).reduce((h,d)=>h+d.to-d.from,0),c=a.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,d)=>h+d.to-d.from,0);return(l>0?l+c:l)>=o}function ey(n,t,e={}){if(!t)return Kt(n,null,e)||jo(n,null,e);let r=di(t,n.schema);return r==="node"?Kt(n,t,e):r==="mark"?jo(n,t,e):!1}var rh=(n,t)=>{let{$from:e,$to:r,$anchor:i}=n.selection;if(t){let s=fi(a=>a.type.name===t)(n.selection);if(!s)return!1;let o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{let{$from:t,$to:e}=n.selection;return!(t.parentOffset>0||t.pos!==e.pos)};function Vu(n,t){return Array.isArray(t)?t.some(e=>(typeof e=="string"?e:e.name)===n.name):t}function Ho(n,t){let{nodeExtensions:e}=yn(t),r=e.find(o=>o.name===n);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},s=_(O(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function tr(n,{checkChildren:t=!0,ignoreWhitespace:e=!1}={}){var r;if(e){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(t){let i=!0;return n.content.forEach(s=>{i!==!1&&(tr(s,{ignoreWhitespace:e,checkChildren:t})||(i=!1))}),i}return!1}function mi(n){return n instanceof A}var sh=class oh{constructor(t){this.position=t}static fromJSON(t){return new oh(t.position)}toJSON(){return{position:this.position}}};function ny(n,t){let e=t.mapping.mapResult(n.position);return{position:new sh(e.pos),mapResult:e}}function ry(n){return new sh(n)}function iy(n,t,e){var r;let{selection:i}=t,s=null;if(_u(i)&&(s=i.$cursor),s){let a=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(e)&&(!!e.isInSet(a)||!a.some(c=>c.type.excludes(e)))}let{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(e):!1;return n.doc.nodesBetween(a.pos,l.pos,(u,h,d)=>{if(c)return!1;if(u.isInline){let f=!d||d.type.allowsMarkType(e),p=!!e.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(e));c=f&&p}return!c}),c})}var sy=(n,t={})=>({tr:e,state:r,dispatch:i})=>{let{selection:s}=e,{empty:o,ranges:a}=s,l=he(n,r.schema);if(i)if(o){let c=Gu(r,l);e.addStoredMark(l.create({...c,...t}))}else a.forEach(c=>{let u=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(u,h,(d,f)=>{let p=Math.max(f,u),m=Math.min(f+d.nodeSize,h);d.marks.find(y=>y.type===l)?d.marks.forEach(y=>{l===y.type&&e.addMark(p,m,l.create({...y.attrs,...t}))}):e.addMark(p,m,l.create(t))})});return iy(r,e,l)},oy=(n,t)=>({tr:e})=>(e.setMeta(n,t),!0),ay=(n,t={})=>({state:e,dispatch:r,chain:i})=>{let s=Y(n,e.schema),o;return e.selection.$anchor.sameParent(e.selection.$head)&&(o=e.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:a})=>io(s,{...o,...t})(e)?!0:a.clearNodes()).command(({state:a})=>io(s,{...o,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ly=n=>({tr:t,dispatch:e})=>{if(e){let{doc:r}=t,i=Ue(n,0,r.content.size),s=A.create(r,i);t.setSelection(s)}return!0},cy=(n,t)=>({tr:e,state:r,dispatch:i})=>{let{selection:s}=r,o,a;return typeof t=="number"?(o=t,a=t):t&&"from"in t&&"to"in t?(o=t.from,a=t.to):(o=s.from,a=s.to),i&&e.doc.nodesBetween(o,a,(l,c)=>{l.isText||e.setNodeMarkup(c,void 0,{...l.attrs,dir:n})}),!0},uy=n=>({tr:t,dispatch:e})=>{if(e){let{doc:r}=t,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=I.atStart(r).from,a=I.atEnd(r).to,l=Ue(i,o,a),c=Ue(s,o,a),u=I.create(r,l,c);t.setSelection(u)}return!0},hy=n=>({state:t,dispatch:e})=>{let r=Y(n,t.schema);return kc(r)(t,e)};function Wu(n,t){let e=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(e){let r=e.filter(i=>t?.includes(i.type.name));n.tr.ensureMarks(r)}}var dy=({keepMarks:n=!0}={})=>({tr:t,state:e,dispatch:r,editor:i})=>{let{selection:s,doc:o}=t,{$from:a,$to:l}=s,c=i.extensionManager.attributes,u=ai(c,a.node().type.name,a.node().attrs);if(s instanceof A&&s.node.isBlock)return!a.parentOffset||!At(o,a.pos)?!1:(r&&(n&&Wu(e,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let h=l.parentOffset===l.parent.content.size,d=a.depth===0?void 0:Ug(a.node(-1).contentMatchAt(a.indexAfter(-1))),f=h&&d?[{type:d,attrs:u}]:void 0,p=At(t.doc,t.mapping.map(a.pos),1,f);if(!f&&!p&&At(t.doc,t.mapping.map(a.pos),1,d?[{type:d}]:void 0)&&(p=!0,f=d?[{type:d,attrs:u}]:void 0),r){if(p&&(s instanceof I&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,f),d&&!h&&!a.parentOffset&&a.parent.type!==d)){let m=t.mapping.map(a.before()),g=t.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&t.setNodeMarkup(t.mapping.map(a.before()),d)}n&&Wu(e,i.extensionManager.splittableMarks),t.scrollIntoView()}return p},fy=(n,t={})=>({tr:e,state:r,dispatch:i,editor:s})=>{var o;let a=Y(n,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;let h=l.node(-1);if(h.type!==a)return!1;let d=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let y=v.empty,b=l.index(-1)?1:l.index(-2)?2:3;for(let E=l.depth-b;E>=l.depth-3;E-=1)y=v.from(l.node(E).copy(y));let C=l.indexAfter(-1){if(k>-1)return!1;E.isTextblock&&E.content.size===0&&(k=T+1)}),k>-1&&e.setSelection(I.near(e.doc.resolve(k))),e.scrollIntoView()}return!0}let f=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,p={...ai(d,h.type.name,h.attrs),...t},m={...ai(d,l.node().type.name,l.node().attrs),...t};e.delete(l.pos,c.pos);let g=f?[{type:a,attrs:p},{type:f,attrs:m}]:[{type:a,attrs:p}];if(!At(e.doc,l.pos,2))return!1;if(i){let{selection:y,storedMarks:b}=r,{splittableMarks:C}=s.extensionManager,M=b||y.$to.parentOffset&&y.$from.marks();if(e.split(l.pos,2,g).scrollIntoView(),!M||!i)return!0;let x=M.filter(N=>C.includes(N.type.name));e.ensureMarks(x)}return!0},Vo=(n,t)=>{let e=fi(o=>o.type===t)(n.selection);if(!e)return!0;let r=n.doc.resolve(Math.max(0,e.pos-1)).before(e.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return e.node.type===i?.type&&It(n.doc,e.pos)&&n.join(e.pos),!0},Wo=(n,t)=>{let e=fi(o=>o.type===t)(n.selection);if(!e)return!0;let r=n.doc.resolve(e.start).after(e.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return e.node.type===i?.type&&It(n.doc,r)&&n.join(r),!0};function py(n){let t=n.doc,e=t.firstChild;if(!e)return null;let r=1,i=e.nodeSize-1;return I.create(t,r,i)}var my=(n,t,e,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:u})=>{let{extensions:h,splittableMarks:d}=i.extensionManager,f=Y(n,o.schema),p=Y(t,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:b}=m,C=y.blockRange(b),M=g||m.$to.parentOffset&&m.$from.marks();if(!C)return!1;let x=fi(Q=>Ho(Q.type.name,h))(m),N=m.from===0&&m.to===o.doc.content.size,k=o.doc.content.content,E=k.length===1?k[0]:null,T=N&&E&&Ho(E.type.name,h)?{node:E,pos:0,depth:0}:null,$=x??T,kt=!!x&&C.depth>=1&&C.depth-x.depth<=1,q=!!T;if((kt||q)&&$){if($.node.type===f)return N&&q?l().command(({tr:Q,dispatch:K})=>{let U=py(Q);return U?(Q.setSelection(U),K&&K(Q),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Ho($.node.type.name,h)&&f.validContent($.node.content))return l().command(()=>(s.setNodeMarkup($.pos,f),!0)).command(()=>Vo(s,f)).command(()=>Wo(s,f)).run()}return!e||!M||!a?l().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Vo(s,f)).command(()=>Wo(s,f)).run():l().command(()=>{let Q=u().wrapInList(f,r),K=M.filter(U=>d.includes(U.type.name));return s.ensureMarks(K),Q?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Vo(s,f)).command(()=>Wo(s,f)).run()},gy=(n,t={},e={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:s=!1}=e,o=he(n,r.schema);return jo(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,t)},yy=(n,t,e={})=>({state:r,commands:i})=>{let s=Y(n,r.schema),o=Y(t,r.schema),a=Kt(r,s,e),l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(o,l):i.setNode(s,{...l,...e})},by=(n,t={})=>({state:e,commands:r})=>{let i=Y(n,e.schema);return Kt(e,i,t)?r.lift(i):r.wrapIn(i,t)},vy=()=>({state:n,dispatch:t})=>{let e=n.plugins;for(let r=0;r=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){let l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},wy=()=>({tr:n,dispatch:t})=>{let{selection:e}=n,{empty:r,ranges:i}=e;return r||t&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},ky=(n,t={})=>({tr:e,state:r,dispatch:i})=>{var s;let{extendEmptyMarkRange:o=!1}=t,{selection:a}=e,l=he(n,r.schema),{$from:c,empty:u,ranges:h}=a;if(!i)return!0;if(u&&o){let{from:d,to:f}=a,p=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=qo(c,l,p);m&&(d=m.from,f=m.to),e.removeMark(d,f,l)}else h.forEach(d=>{e.removeMark(d.$from.pos,d.$to.pos,l)});return e.removeStoredMark(l),!0},xy=n=>({tr:t,state:e,dispatch:r})=>{let{selection:i}=e,s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&t.doc.nodesBetween(s,o,(a,l)=>{if(a.isText)return;let c={...a.attrs};delete c.dir,t.setNodeMarkup(l,void 0,c)}),!0},Sy=(n,t={})=>({tr:e,state:r,dispatch:i})=>{let s=null,o=null,a=di(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=Y(n,r.schema)),a==="mark"&&(o=he(n,r.schema));let l=!1;return e.selection.ranges.forEach(c=>{let u=c.$from.pos,h=c.$to.pos,d,f,p,m;e.selection.empty?r.doc.nodesBetween(u,h,(g,y)=>{s&&s===g.type&&(l=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,h),d=y,f=g)}):r.doc.nodesBetween(u,h,(g,y)=>{y=u&&y<=h&&(s&&s===g.type&&(l=!0,i&&e.setNodeMarkup(y,void 0,{...g.attrs,...t})),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type&&(l=!0,i)){let C=Math.max(y,u),M=Math.min(y+g.nodeSize,h);e.addMark(C,M,o.create({...b.attrs,...t}))}}))}),f&&(d!==void 0&&i&&e.setNodeMarkup(d,void 0,{...f.attrs,...t}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&i&&e.addMark(p,m,o.create({...g.attrs,...t}))}))}),l},Cy=(n,t={})=>({state:e,dispatch:r})=>{let i=Y(n,e.schema);return bc(i,t)(e,r)},Ey=(n,t={})=>({state:e,dispatch:r})=>{let i=Y(n,e.schema);return vc(i,t)(e,r)},Ty=class{constructor(){this.callbacks={}}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),this}emit(n,...t){let e=this.callbacks[n];return e&&e.forEach(r=>r.apply(this,t)),this}off(n,t){let e=this.callbacks[n];return e&&(t?this.callbacks[n]=e.filter(r=>r!==t):delete this.callbacks[n]),this}once(n,t){let e=(...r)=>{this.off(n,e),t.apply(this,r)};return this.on(n,e)}removeAllListeners(){this.callbacks={}}},vt=class{constructor(n){var t;this.find=n.find,this.handler=n.handler,this.undoable=(t=n.undoable)!=null?t:!0}},My=(n,t)=>{if(Ko(t))return t.exec(n);let e=t(n);if(!e)return null;let r=[e.text];return r.index=e.index,r.input=n,r.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(e.replaceWith)),r};function ii(n){var t;let{editor:e,from:r,to:i,text:s,rules:o,plugin:a}=n,{view:l}=e;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(t=c.nodeBefore||c.nodeAfter)!=null&&t.marks.find(d=>d.type.spec.code))return!1;let u=!1,h=ty(c)+s;return o.forEach(d=>{if(u)return;let f=My(h,d.find);if(!f)return;let p=l.state.tr,m=ui({state:l.state,transaction:p}),g={from:r-(f[0].length-s.length),to:i},{commands:y,chain:b,can:C}=new hi({editor:e,state:m});d.handler({state:m,range:g,match:f,commands:y,chain:b,can:C})===null||!p.steps.length||(d.undoable&&p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),u=!0)}),u}function Ay(n){let{editor:t,rules:e}=n,r=new D({state:{init(){return null},apply(i,s,o){let a=i.getMeta(r);if(a)return a;let l=i.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Xo(v.from(u),o.schema);let{from:h}=l,d=h+u.length;ii({editor:t,from:h,to:d,text:u,rules:e,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return ii({editor:t,from:s,to:o,text:a,rules:e,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:s}=i.state.selection;s&&ii({editor:t,from:s.pos,to:s.pos,text:"",rules:e,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;let{$cursor:o}=i.state.selection;return o?ii({editor:t,from:o.pos,to:o.pos,text:` +`,rules:e,plugin:r}):!1}},isInputRules:!0});return r}function Ny(n){return Object.prototype.toString.call(n).slice(8,-1)}function si(n){return Ny(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function ah(n,t){let e={...n};return si(n)&&si(t)&&Object.keys(t).forEach(r=>{si(t[r])&&si(n[r])?e[r]=ah(n[r],t[r]):e[r]=t[r]}),e}var Zo=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{..._(O(this,"addOptions",{name:this.name}))||{}}}get storage(){return{..._(O(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){let t=this.extend({...this.config,addOptions:()=>ah(this.options,n)});return t.name=this.name,t.parent=this.parent,t}extend(n={}){let t=new this.constructor({...this.config,...n});return t.parent=this,this.child=t,t.name="name"in n?n.name:t.parent.name,t}},tt=class lh extends Zo{constructor(){super(...arguments),this.type="mark"}static create(t={}){let e=typeof t=="function"?t():t;return new lh(e)}static handleExit({editor:t,mark:e}){let{tr:r}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){let o=i.marks();if(!!!o.find(c=>c?.type.name===e.name))return!1;let l=o.find(c=>c?.type.name===e.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),t.view.dispatch(r),!0}return!1}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}};function Oy(n){return typeof n=="number"}var Iy=class{constructor(n){this.find=n.find,this.handler=n.handler}},Dy=(n,t,e)=>{if(Ko(t))return[...n.matchAll(t)];let r=t(n,e);return r?r.map(i=>{let s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Py(n){let{editor:t,state:e,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:c,can:u}=new hi({editor:t,state:e}),h=[];return e.doc.nodesBetween(r,i,(f,p)=>{var m,g,y,b,C;if((g=(m=f.type)==null?void 0:m.spec)!=null&&g.code||!(f.isText||f.isTextblock||f.isInline))return;let M=(C=(b=(y=f.content)==null?void 0:y.size)!=null?b:f.nodeSize)!=null?C:0,x=Math.max(r,p),N=Math.min(i,p+M);if(x>=N)return;let k=f.isText?f.text||"":f.textBetween(x-p,N-p,void 0,"\uFFFC");Dy(k,s.find,o).forEach(T=>{if(T.index===void 0)return;let $=x+T.index+1,kt=$+T[0].length,q={from:e.tr.mapping.map($),to:e.tr.mapping.map(kt)},Q=s.handler({state:e,range:q,match:T,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});h.push(Q)})}),h.every(f=>f!==null)}var oi=null,Ry=n=>{var t;let e=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=e.clipboardData)==null||t.setData("text/html",n),e};function Ly(n){let{editor:t,rules:e}=n,r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}let l=({state:u,from:h,to:d,rule:f,pasteEvt:p})=>{let m=u.tr,g=ui({state:u,transaction:m});if(!(!Py({editor:t,state:g,from:Math.max(h-1,0),to:d.b-1,rule:f,pasteEvent:p,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return e.map(u=>new D({view(h){let d=p=>{var m;r=(m=h.dom.parentElement)!=null&&m.contains(p.target)?h.dom.parentElement:null,r&&(oi=t)},f=()=>{oi&&(oi=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(h,d)=>{if(s=r===h.dom.parentElement,a=d,!s){let f=oi;f?.isEditable&&setTimeout(()=>{let p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(h,d)=>{var f;let p=(f=d.clipboardData)==null?void 0:f.getData("text/html");return o=d,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(h,d,f)=>{let p=h[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:x}=y;typeof x=="string"?x=x:x=Xo(v.from(x),f.schema);let{from:N}=y,k=N+x.length,E=Ry(x);return l({rule:u,state:f,from:N,to:{b:k},pasteEvt:E})}let C=d.doc.content.findDiffStart(f.doc.content),M=d.doc.content.findDiffEnd(f.doc.content);if(!(!Oy(C)||!M||C===M.b))return l({rule:u,state:f,from:C,to:M,pasteEvt:o})}}))}var gi=class{constructor(n,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=n,this.extensions=Zu(n),this.schema=Jg(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((n,t)=>{let e={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Xn(t.name,this.schema)},r=O(t,"addCommands",e);return r?{...n,...r()}:n},{})}get plugins(){let{editor:n}=this;return Yn([...this.extensions].reverse()).flatMap(r=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Xn(r.name,this.schema)},s=[],o=O(r,"addKeyboardShortcuts",i),a={};if(r.type==="mark"&&O(r,"exitable",i)&&(a.ArrowRight=()=>tt.handleExit({editor:n,mark:r})),o){let d=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:n})]));a={...a,...d}}let l=Pu(a);s.push(l);let c=O(r,"addInputRules",i);if(Vu(r,n.options.enableInputRules)&&c){let d=c();if(d&&d.length){let f=Ay({editor:n,rules:d}),p=Array.isArray(f)?f:[f];s.push(...p)}}let u=O(r,"addPasteRules",i);if(Vu(r,n.options.enablePasteRules)&&u){let d=u();if(d&&d.length){let f=Ly({editor:n,rules:d});s.push(...f)}}let h=O(r,"addProseMirrorPlugins",i);if(h){let d=h();s.push(...d)}return s})}get attributes(){return Yu(this.extensions)}get nodeViews(){let{editor:n}=this,{nodeExtensions:t}=yn(this.extensions);return Object.fromEntries(t.filter(e=>!!O(e,"addNodeView")).map(e=>{let r=this.attributes.filter(l=>l.type===e.name),i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:Y(e.name,this.schema)},s=O(e,"addNodeView",i);if(!s)return[];let o=s();if(!o)return[];let a=(l,c,u,h,d)=>{let f=bn(l,r);return o({node:l,view:c,getPos:u,decorations:h,innerDecorations:d,editor:n,extension:e,HTMLAttributes:f})};return[e.name,a]}))}dispatchTransaction(n){let{editor:t}=this;return Yn([...this.extensions].reverse()).reduceRight((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:t,type:Xn(i.name,this.schema)},o=O(i,"dispatchTransaction",s);return o?a=>{o.call(s,{transaction:a,next:r})}:r},n)}transformPastedHTML(n){let{editor:t}=this;return Yn([...this.extensions]).reduce((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:t,type:Xn(i.name,this.schema)},o=O(i,"transformPastedHTML",s);return o?(a,l)=>{let c=r(a,l);return o.call(s,c)}:r},n||(r=>r))}get markViews(){let{editor:n}=this,{markExtensions:t}=yn(this.extensions);return Object.fromEntries(t.filter(e=>!!O(e,"addMarkView")).map(e=>{let r=this.attributes.filter(a=>a.type===e.name),i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:he(e.name,this.schema)},s=O(e,"addMarkView",i);if(!s)return[];let o=(a,l,c)=>{let u=bn(a,r);return s()({mark:a,view:l,inline:c,editor:n,extension:e,HTMLAttributes:u,updateAttributes:h=>{Ky(a,n,h)}})};return[e.name,o]}))}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(t=>[t.name,t.storage])),n.forEach(t=>{var e;let r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Xn(t.name,this.schema)};t.type==="mark"&&((e=_(O(t,"keepOnSplit",r)))==null||e)&&this.splittableMarks.push(t.name);let i=O(t,"onBeforeCreate",r),s=O(t,"onCreate",r),o=O(t,"onUpdate",r),a=O(t,"onSelectionUpdate",r),l=O(t,"onTransaction",r),c=O(t,"onFocus",r),u=O(t,"onBlur",r),h=O(t,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};gi.resolve=Zu;gi.sort=Yn;gi.flatten=Go;var zy={};_o(zy,{ClipboardTextSerializer:()=>uh,Commands:()=>hh,Delete:()=>dh,Drop:()=>fh,Editable:()=>ph,FocusEvents:()=>gh,Keymap:()=>yh,Paste:()=>bh,Tabindex:()=>vh,TextDirection:()=>wh,focusEventsPluginKey:()=>mh});var L=class ch extends Zo{constructor(){super(...arguments),this.type="extension"}static create(t={}){let e=typeof t=="function"?t():t;return new ch(e)}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}},uh=L.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new D({key:new z("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:t,schema:e}=n,{doc:r,selection:i}=t,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),l=eh(e);return th(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),hh=L.create({name:"commands",addCommands(){return{...Uu}}}),dh=L.create({name:"delete",onUpdate({transaction:n,appendedTransactions:t}){var e,r,i;let s=()=>{var o,a,l,c;if((c=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?c:n.getMeta("y-sync$"))return;let u=Jo(n.before,[n,...t]);Yo(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=f.oldRange.from<=m&&g<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:f.oldRange,newRange:f.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:u})})});let d=u.mapping;u.steps.forEach((f,p)=>{var m,g;if(f instanceof ie){let y=d.slice(p).map(f.from,-1),b=d.slice(p).map(f.to),C=d.invert().map(y,-1),M=d.invert().map(b),x=y>0?(m=u.doc.nodeAt(y-1))==null?void 0:m.marks.some(k=>k.eq(f.mark)):!1,N=(g=u.doc.nodeAt(b))==null?void 0:g.marks.some(k=>k.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:C,to:M},newRange:{from:y,to:b},partial:!!(N||x),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(e=this.editor.options.coreExtensionOptions)==null?void 0:e.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),fh=L.create({name:"drop",addProseMirrorPlugins(){return[new D({key:new z("tiptapDrop"),props:{handleDrop:(n,t,e,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:e,moved:r})}}})]}}),ph=L.create({name:"editable",addProseMirrorPlugins(){return[new D({key:new z("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mh=new z("focusEvents"),gh=L.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new D({key:mh,props:{handleDOMEvents:{focus:(t,e)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:e}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,e)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:e}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),yh=L.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:u,$anchor:h}=l,{pos:d,parent:f}=h,p=h.parent.isTextblock&&d>0?a.doc.resolve(d-1):h,m=p.parent.type.spec.isolating,g=h.pos-h.parentOffset,y=m&&p.parent.childCount===1?g===h.pos:R.atStart(c).from===d;return!u||!f.type.isTextblock||f.textContent.length||!y||y&&h.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ci()||Ju()?s:i},addProseMirrorPlugins(){return[new D({key:new z("clearDocument"),appendTransaction:(n,t,e)=>{if(n.some(m=>m.getMeta("composition")))return;let r=n.some(m=>m.docChanged)&&!t.doc.eq(e.doc),i=n.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:s,from:o,to:a}=t.selection,l=R.atStart(t.doc).from,c=R.atEnd(t.doc).to;if(s||!(o===l&&a===c)||!tr(e.doc))return;let d=e.tr,f=ui({state:e,transaction:d}),{commands:p}=new hi({editor:this.editor,state:f});if(p.clearNodes(),!!d.steps.length)return d}})]}}),bh=L.create({name:"paste",addProseMirrorPlugins(){return[new D({key:new z("tiptapPaste"),props:{handlePaste:(n,t,e)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:e})}}})]}}),vh=L.create({name:"tabindex",addProseMirrorPlugins(){return[new D({key:new z("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),wh=L.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=yn(this.extensions);return[{types:n.filter(t=>t.name!=="text").map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{let e=t.getAttribute("dir");return e&&(e==="ltr"||e==="rtl"||e==="auto")?e:this.options.direction},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new D({key:new z("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}}),By=class Qn{constructor(t,e,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=e,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!=null?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:e,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new Qn(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Qn(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Qn(t,this.editor)}get children(){let t=[];return this.node.content.forEach((e,r)=>{let i=e.isBlock&&!e.isTextblock,s=e.isAtom&&!e.isText,o=e.isInline,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(a);if(!i&&!o&&l.depth<=this.depth)return;let c=new Qn(l,this.editor,i,i||o?e:null);i&&(c.actualDepth=this.depth+1),t.push(c)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let t=this.children;return t[t.length-1]||null}closest(t,e={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===t)if(Object.keys(e).length>0){let s=i.node.attrs,o=Object.keys(e);for(let a=0;a{r&&i.length>0||(o.node.type.name===t&&s.every(l=>e[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(t,e,r))))}),i}setAttribute(t){let{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}},Fy=`.ProseMirror { position: relative; } @@ -95,30 +94,30 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`;function iC(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var Ii=class extends j1{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:x1,createMappablePosition:k1},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);let e=this.createDoc(),n=ym(e,this.options.autofocus);this.editorState=Gs.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=iC(rC,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=km(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let r=[...this.options.enableCoreExtensions?[Fm,Pm.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Lm,Hm,Vm,Wm,zm,Um,Bm,jm.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new Ao(r,this)}createCommandManager(){this.commandManager=new ko({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Bc(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Bc(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Ci(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();let l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=o?.getMeta("focus"),l=o?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return jc(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return w1(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Wc(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=` +}`;function $y(n,t,e){let r=document.querySelector(`style[data-tiptap-style${e?`-${e}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute(`data-tiptap-style${e?`-${e}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var er=class extends Ty{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:ny,createMappablePosition:ry},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);let t=this.createDoc(),e=Ku(t,this.options.autofocus);this.editorState=Vr.create({doc:t,schema:this.schema,selection:e||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=$y(Fy,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,t=!0){this.setOptions({editable:n}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in n)return Reflect.get(n,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,t){let e=Qu(t)?t(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:e});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;let t=this.state.plugins,e=t;if([].concat(n).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;e=e.filter(o=>!o.key.startsWith(s))}),t.length===e.length)return;let r=this.state.reconfigure({plugins:e});return this.view.updateState(r),r}createExtensionManager(){var n,t;let r=[...this.options.enableCoreExtensions?[ph,uh.configure({blockSeparator:(t=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:t.blockSeparator}),hh,gh,yh,vh,fh,bh,dh,wh.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new gi(r,this)}createCommandManager(){this.commandManager=new hi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Uo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!=="collaboration"),this.createExtensionManager()}}),n=Uo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){let{editorProps:t,enableExtensionDispatchTransaction:e}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=e?this.extensionManager.dispatchTransaction(r):r,s=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new qn(n,{...t,attributes:{role:"textbox",...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();let l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}let{state:t,transactions:e}=this.state.applyTransaction(n),r=!this.state.selection.eq(t.selection),i=e.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:t}),!i)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:e.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});let o=e.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=o?.getMeta("focus"),l=o?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(n.getMeta("preventUpdate")||!e.some(c=>c.docChanged)||s.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:e.slice(1)})}getAttributes(n){return Qo(this.state,n)}isActive(n,t){let e=typeof n=="string"?n:null,r=typeof n=="string"?t:n;return ey(this.state,e,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xo(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:t=` -`,textSerializers:n={}}=t||{};return m1(this.state.doc,{blockSeparator:e,textSerializers:{...Tm(this.schema),...n}})}get isEmpty(){return Oi(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t);return new nC(e,this)}get $doc(){return this.$pos(0)}};function pt(t){return new Me({find:t.find,handler:({state:e,range:n,match:r})=>{let i=J(t.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:s}=e,o=r[r.length-1],a=r[0];if(o){let l=a.search(/\S/),c=n.from+a.indexOf(o),u=c+o.length;if(Eo(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;un.from&&s.delete(n.from+l,c);let f=n.from+l+o.length;s.addMark(n.from+l,f,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function qm(t){return new Me({find:t.find,handler:({state:e,range:n,match:r})=>{let i=J(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from,a=n.to,l=t.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=o+c;u>a?u=a:a=u+r[1].length;let d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,a,l)}else if(r[0]){let c=t.type.isInline?o:o-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()},undoable:t.undoable})}function zn(t){return new Me({find:t.find,handler:({state:e,range:n,match:r})=>{let i=e.doc.resolve(n.from),s=J(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function mt(t){return new Me({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{let s=J(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),c=l&&dr(l,t.type,s);if(!c)return null;if(o.wrap(l,c),t.keepMarks&&t.editor){let{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){let m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){let d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}let u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&qe(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}function Km(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof O){let s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){let s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var sC={};Fc(sC,{createAtomBlockMarkdownSpec:()=>oC,createBlockMarkdownSpec:()=>aC,createInlineMarkdownSpec:()=>uC,parseAttributes:()=>Jc,parseIndentedBlocks:()=>Mo,renderNestedMarkdownContent:()=>Di,serializeAttributes:()=>Zc});function Jc(t){if(!t?.trim())return{};let e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){let c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}let s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);let o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;let f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=n[f];h&&(e[c]=h.slice(1,-1))});let l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Zc(t){if(!t||Object.keys(t).length===0)return"";let e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function oC(t){let{nodeName:e,name:n,parseAttributes:r=Jc,serializeAttributes:i=Zc,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:a}=t,l=n||e,c=u=>{if(!a)return u;let d={};return a.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{let f={...s,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;let f=new RegExp(`^:::${l}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){let h=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(h);if(!p)return;let m=p[1]||"",g=r(m);if(!o.find(b=>!(b in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{let d=c(u.attrs||{}),f=i(d),h=f?` {${f}}`:"";return`:::${l}${h} :::`}}}function aC(t){let{nodeName:e,name:n,getContent:r,parseAttributes:i=Jc,serializeAttributes:s=Zc,defaultAttributes:o={},content:a="block",allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;let f={};return l.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){let m=r(d);h=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);let p={...o,...d.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;let h=new RegExp(`^:::${c}`,"m"),p=(f=d.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,h){var p;let m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;let[y,b=""]=g,x=i(b),w=1,v=y.length,T="",k=/^:::([\w-]*)(\s.*)?/gm,E=d.slice(v);for(k.lastIndex=0;;){let _=k.exec(E);if(_===null)break;let z=_.index,N=_[1];if(!((p=_[2])!=null&&p.endsWith(":::"))){if(N)w+=1;else if(w-=1,w===0){let X=E.slice(0,z);T=X.trim();let ne=d.slice(0,v+z+_[0].length),re=[];if(T)if(a==="block")for(re=h.blockTokens(X),re.forEach(ie=>{ie.text&&(!ie.tokens||ie.tokens.length===0)&&(ie.tokens=h.inlineTokens(ie.text))});re.length>0;){let ie=re[re.length-1];if(ie.type==="paragraph"&&(!ie.text||ie.text.trim()===""))re.pop();else break}else re=h.inlineTokens(T);return{type:e,raw:ne,attributes:x,content:T,tokens:re}}}}}},renderMarkdown:(d,f)=>{let h=u(d.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=f.renderChildren(d.content||[],` +`,textSerializers:e={}}=n||{};return Xg(this.state.doc,{blockSeparator:t,textSerializers:{...eh(this.schema),...e}})}get isEmpty(){return tr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,t;return(t=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?t:!0}$node(n,t){var e;return((e=this.$doc)==null?void 0:e.querySelector(n,t))||null}$nodes(n,t){var e;return((e=this.$doc)==null?void 0:e.querySelectorAll(n,t))||null}$pos(n){let t=this.state.doc.resolve(n);return new By(t,this)}get $doc(){return this.$pos(0)}};function qt(n){return new vt({find:n.find,handler:({state:t,range:e,match:r})=>{let i=_(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:s}=t,o=r[r.length-1],a=r[0];if(o){let l=a.search(/\S/),c=e.from+a.indexOf(o),u=c+o.length;if(pi(e.from,e.to,t.doc).filter(f=>f.mark.type.excluded.find(m=>m===n.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;ue.from&&s.delete(e.from+l,c);let d=e.from+l+o.length;s.addMark(e.from+l,d,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function kh(n){return new vt({find:n.find,handler:({state:t,range:e,match:r})=>{let i=_(n.getAttributes,void 0,r)||{},{tr:s}=t,o=e.from,a=e.to,l=n.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=o+c;u>a?u=a:a=u+r[1].length;let h=r[0][r[0].length-1];s.insertText(h,o+r[0].length-1),s.replaceWith(u,a,l)}else if(r[0]){let c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()},undoable:n.undoable})}function je(n){return new vt({find:n.find,handler:({state:t,range:e,match:r})=>{let i=t.doc.resolve(e.from),s=_(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;t.tr.delete(e.from,e.to).setBlockType(e.from,e.from,n.type,s)},undoable:n.undoable})}function Jt(n){return new vt({find:n.find,handler:({state:t,range:e,match:r,chain:i})=>{let s=_(n.getAttributes,void 0,r)||{},o=t.tr.delete(e.from,e.to),l=o.doc.resolve(e.from).blockRange(),c=l&&an(l,n.type,s);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){let{selection:h,storedMarks:d}=t,{splittableMarks:f}=n.editor.extensionManager,p=d||h.$to.parentOffset&&h.$from.marks();if(p){let m=p.filter(g=>f.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){let h=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}let u=o.doc.resolve(e.from-1).nodeBefore;u&&u.type===n.type&&It(o.doc,e.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(e.from-1)},undoable:n.undoable})}function xh(n,t){let{selection:e}=n,{$from:r}=e;if(e instanceof A){let s=r.index();return r.parent.canReplaceWith(s,s+1,t)}let i=r.depth;for(;i>=0;){let s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(t))return!0;i-=1}return!1}var Hy={};_o(Hy,{createAtomBlockMarkdownSpec:()=>Vy,createBlockMarkdownSpec:()=>Wy,createInlineMarkdownSpec:()=>_y,parseAttributes:()=>ta,parseIndentedBlocks:()=>yi,renderNestedMarkdownContent:()=>nr,serializeAttributes:()=>ea});function ta(n){if(!n?.trim())return{};let t={},e=[],r=n.replace(/["']([^"']*)["']/g,c=>(e.push(c),`__QUOTED_${e.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){let c=i.map(u=>u.trim().slice(1));t.class=c.join(" ")}let s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(t.id=s[1]);let o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var h;let d=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),f=e[d];f&&(t[c]=f.slice(1,-1))});let l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(t[u]=!0)}),t}function ea(n){if(!n||Object.keys(n).length===0)return"";let t=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>t.push(`.${r}`)),n.id&&t.push(`#${n.id}`),Object.entries(n).forEach(([e,r])=>{e==="class"||e==="id"||(r===!0?t.push(e):r!==!1&&r!=null&&t.push(`${e}="${String(r)}"`))}),t.join(" ")}function Vy(n){let{nodeName:t,name:e,parseAttributes:r=ta,serializeAttributes:i=ea,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:a}=n,l=e||t,c=u=>{if(!a)return u;let h={};return a.forEach(d=>{d in u&&(h[d]=u[d])}),h};return{parseMarkdown:(u,h)=>{let d={...s,...u.attributes};return h.createNode(t,d,[])},markdownTokenizer:{name:t,level:"block",start(u){var h;let d=new RegExp(`^:::${l}(?:\\s|$)`,"m"),f=(h=u.match(d))==null?void 0:h.index;return f!==void 0?f:-1},tokenize(u,h,d){let f=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;let m=p[1]||"",g=r(m);if(!o.find(b=>!(b in g)))return{type:t,raw:p[0],attributes:g}}},renderMarkdown:u=>{let h=c(u.attrs||{}),d=i(h),f=d?` {${d}}`:"";return`:::${l}${f} :::`}}}function Wy(n){let{nodeName:t,name:e,getContent:r,parseAttributes:i=ta,serializeAttributes:s=ea,defaultAttributes:o={},content:a="block",allowedAttributes:l}=n,c=e||t,u=h=>{if(!l)return h;let d={};return l.forEach(f=>{f in h&&(d[f]=h[f])}),d};return{parseMarkdown:(h,d)=>{let f;if(r){let m=r(h);f=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?f=d.parseChildren(h.tokens||[]):f=d.parseInline(h.tokens||[]);let p={...o,...h.attributes};return d.createNode(t,p,f)},markdownTokenizer:{name:t,level:"block",start(h){var d;let f=new RegExp(`^:::${c}`,"m"),p=(d=h.match(f))==null?void 0:d.index;return p!==void 0?p:-1},tokenize(h,d,f){var p;let m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=h.match(m);if(!g)return;let[y,b=""]=g,C=i(b),M=1,x=y.length,N="",k=/^:::([\w-]*)(\s.*)?/gm,E=h.slice(x);for(k.lastIndex=0;;){let T=k.exec(E);if(T===null)break;let $=T.index,kt=T[1];if(!((p=T[2])!=null&&p.endsWith(":::"))){if(kt)M+=1;else if(M-=1,M===0){let q=E.slice(0,$);N=q.trim();let Q=h.slice(0,x+$+T[0].length),K=[];if(N)if(a==="block")for(K=f.blockTokens(q),K.forEach(U=>{U.text&&(!U.tokens||U.tokens.length===0)&&(U.tokens=f.inlineTokens(U.text))});K.length>0;){let U=K[K.length-1];if(U.type==="paragraph"&&(!U.text||U.text.trim()===""))K.pop();else break}else K=f.inlineTokens(N);return{type:t,raw:Q,attributes:C,content:N,tokens:K}}}}}},renderMarkdown:(h,d)=>{let f=u(h.attrs||{}),p=s(f),m=p?` {${p}}`:"",g=d.renderChildren(h.content||[],` `);return`:::${c}${m} ${g} -:::`}}}function lC(t){if(!t.trim())return{};let e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(t);for(;r!==null;){let[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function cC(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function uC(t){let{nodeName:e,name:n,getContent:r,parseAttributes:i=lC,serializeAttributes:s=cC,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,u=f=>{if(!l)return f;let h={};return l.forEach(p=>{let m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){let y=f[m];if(g!==void 0&&y===g)return;h[m]=y}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{let p={...o,...f.attributes};if(a)return h.createNode(e,p);let m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){let h=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=f.match(h),m=p?.index;return m!==void 0?m:-1},tokenize(f,h,p){let m=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=f.match(m);if(!g)return;let y="",b="";if(a){let[,w]=g;b=w}else{let[,w,v]=g;b=w,y=v||""}let x=i(b.trim());return{type:e,raw:g[0],content:y.trim(),attributes:x}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));let p=u(f.attrs||{}),m=s(p),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Mo(t,e,n){var r,i,s,o;let a=t.split(` -`),l=[],c="",u=0,d=e.baseIndentSize||2;for(;u0)break;if(f.trim()===""){u+=1,c=`${c}${f} -`;continue}else return}let p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f} -`;let y=[g];for(u+=1;uz.trim()!=="");if(k===-1)break;if((((i=(r=a[u+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>m){y.push(v),c=`${c}${v} -`,u+=1;continue}else break}if((((o=(s=v.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(v),c=`${c}${v} -`,u+=1;else break}let b,x=y.slice(1);if(x.length>0){let v=x.map(T=>T.slice(m+d)).join(` -`);v.trim()&&(e.customNestedParser?b=e.customNestedParser(v):b=n.blockTokens(v))}let w=e.createToken(p,b);l.push(w)}if(l.length!==0)return{items:l,raw:c}}function Di(t,e,n,r){if(!t||!Array.isArray(t.content))return"";let i=typeof n=="function"?n(r):n,[s,...o]=t.content,a=e.renderChildren([s]),l=`${i}${a}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,f;let h=(f=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?f:e.renderChildren([c]);if(h!=null){let p=h.split(` -`).map(m=>m?e.indent(m):e.indent("")).join(` +:::`}}}function Uy(n){if(!n.trim())return{};let t={},e=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=e.exec(n);for(;r!==null;){let[,i,s,o]=r;t[i]=s||o,r=e.exec(n)}return t}function jy(n){return Object.entries(n).filter(([,t])=>t!=null).map(([t,e])=>`${t}="${e}"`).join(" ")}function _y(n){let{nodeName:t,name:e,getContent:r,parseAttributes:i=Uy,serializeAttributes:s=jy,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=n,c=e||t,u=d=>{if(!l)return d;let f={};return l.forEach(p=>{let m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in d){let y=d[m];if(g!==void 0&&y===g)return;f[m]=y}}),f},h=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(d,f)=>{let p={...o,...d.attributes};if(a)return f.createNode(t,p);let m=r?r(d):d.content||"";return m?f.createNode(t,p,[f.createTextNode(m)]):f.createNode(t,p,[])},markdownTokenizer:{name:t,level:"inline",start(d){let f=a?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),p=d.match(f),m=p?.index;return m!==void 0?m:-1},tokenize(d,f,p){let m=a?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),g=d.match(m);if(!g)return;let y="",b="";if(a){let[,M]=g;b=M}else{let[,M,x]=g;b=M,y=x||""}let C=i(b.trim());return{type:t,raw:g[0],content:y.trim(),attributes:C}}},renderMarkdown:d=>{let f="";r?f=r(d):d.content&&d.content.length>0&&(f=d.content.filter(y=>y.type==="text").map(y=>y.text).join(""));let p=u(d.attrs||{}),m=s(p),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${f}[/${c}]`}}}function yi(n,t,e){var r,i,s,o;let a=n.split(` +`),l=[],c="",u=0,h=t.baseIndentSize||2;for(;u0)break;if(d.trim()===""){u+=1,c=`${c}${d} +`;continue}else return}let p=t.extractItemData(f),{indentLevel:m,mainContent:g}=p;c=`${c}${d} +`;let y=[g];for(u+=1;u$.trim()!=="");if(k===-1)break;if((((i=(r=a[u+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>m){y.push(x),c=`${c}${x} +`,u+=1;continue}else break}if((((o=(s=x.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(x),c=`${c}${x} +`,u+=1;else break}let b,C=y.slice(1);if(C.length>0){let x=C.map(N=>N.slice(m+h)).join(` +`);x.trim()&&(t.customNestedParser?b=t.customNestedParser(x):b=e.blockTokens(x))}let M=t.createToken(p,b);l.push(M)}if(l.length!==0)return{items:l,raw:c}}function nr(n,t,e,r){if(!n||!Array.isArray(n.content))return"";let i=typeof e=="function"?e(r):e,[s,...o]=n.content,a=t.renderChildren([s]),l=`${i}${a}`;return o&&o.length>0&&o.forEach((c,u)=>{var h,d;let f=(d=(h=t.renderChild)==null?void 0:h.call(t,c,u+1))!=null?d:t.renderChildren([c]);if(f!=null){let p=f.split(` +`).map(m=>m?t.indent(m):t.indent("")).join(` `);l+=c.type==="paragraph"?` ${p}`:` -${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((a,l)=>{let c=s.mapping.map(l),u=s.mapping.map(l)+a.nodeSize,d=null;if(a.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var j=class Jm extends Kc{constructor(){super(...arguments),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new Jm(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Ge(t){return new X1({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{let s=J(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;let{tr:o}=e,a=r[r.length-1],l=r[0],c=n.to;if(a){let u=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if(Eo(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;fn.from&&o.delete(n.from+u,d),c=n.from+u+a.length,o.addMark(n.from+u,c,t.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}var Xc=j.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +${p}`}}),l}function Ky(n,t,e={}){let{state:r}=t,{doc:i,tr:s}=r,o=n;i.descendants((a,l)=>{let c=s.mapping.map(l),u=s.mapping.map(l)+a.nodeSize,h=null;if(a.marks.forEach(f=>{if(f!==o)return!1;h=f}),!h)return;let d=!1;if(Object.keys(e).forEach(f=>{e[f]!==h.attrs[f]&&(d=!0)}),d){let f=n.type.create({...n.attrs,...e});s.removeMark(c,u,n.type),s.addMark(c,u,f)}}),s.docChanged&&t.view.dispatch(s)}var W=class Sh extends Zo{constructor(){super(...arguments),this.type="node"}static create(t={}){let e=typeof t=="function"?t():t;return new Sh(e)}configure(t){return super.configure(t)}extend(t){let e=typeof t=="function"?t():t;return super.extend(e)}};function zt(n){return new Iy({find:n.find,handler:({state:t,range:e,match:r,pasteEvent:i})=>{let s=_(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;let{tr:o}=t,a=r[r.length-1],l=r[0],c=e.to;if(a){let u=l.search(/\S/),h=e.from+l.indexOf(a),d=h+a.length;if(pi(e.from,e.to,t.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>h).length)return null;de.from&&o.delete(e.from+u,h),c=e.from+u+a.length,o.addMark(e.from+u,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}var na=W.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,t)=>n.content?t.renderChildren(n.content,` -`):""}),Zm=Xc;var Gc=j.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Xm=Gc;var Yc=j.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",P(this.options.HTMLAttributes,t)]},renderText(){return` +`):""}),Ch=na;var ra=W.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Eh=ra;var ia=W.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",P(this.options.HTMLAttributes,n)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){let d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Gm=Yc;var Sr=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};var fC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,hC=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,pC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mC=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Qc=ae.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Sr("strong",{...P(this.options.HTMLAttributes,t),children:Sr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[pt({find:fC,type:this.type}),pt({find:pC,type:this.type})]},addPasteRules(){return[Ge({find:hC,type:this.type}),Ge({find:mC,type:this.type})]}}),Ym=Qc;var gC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,yC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,bC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,vC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,eu=ae.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",P(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[pt({find:gC,type:this.type}),pt({find:bC,type:this.type})]},addPasteRules(){return[Ge({find:yC,type:this.type}),Ge({find:vC,type:this.type})]}}),Qm=eu;var wC=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,xC=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,tu=ae.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",P(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[pt({find:wC,type:this.type})]},addPasteRules(){return[Ge({find:xC,type:this.type})]}}),eg=tu;var nu=ae.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",P(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){let i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;let s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),tg=nu;function ng(t={}){return new R({view(e){return new ru(e,t)}})}var ru=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=l.getBoundingClientRect(),f=d.width/l.offsetWidth,h=d.height/l.offsetHeight;c=d.left-l.scrollLeft*f,u=d.top-l.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Ks(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var _e=class t extends L{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):L.near(r)}content(){return A.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new iu(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!kC(e)||!SC(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>0?e.indexAfter(o)0){s=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let l=e.doc.resolve(i);if(t.valid(l))return l}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let a=e.doc.resolve(i);if(t.valid(a))return a}return null}}};_e.prototype.visible=!1;_e.findFrom=_e.findGapCursorFrom;L.jsonID("gapcursor",_e);var iu=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return _e.valid(n)?new _e(n):L.near(n)}};function rg(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function kC(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||rg(i.type))return!0;if(i.inlineContent)return!1}}return!0}function SC(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||rg(i.type))return!0;if(i.inlineContent)return!1}}return!0}function ig(){return new R({props:{decorations:AC,createSelectionBetween(t,e,n){return e.pos==n.pos&&_e.valid(n)?new _e(n):null},handleClick:EC,handleKeyDown:CC,handleDOMEvents:{beforeinput:TC}}})}var CC=Dc({ArrowLeft:_o("horiz",-1),ArrowRight:_o("horiz",1),ArrowUp:_o("vert",-1),ArrowDown:_o("vert",1)});function _o(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof D){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=_e.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new _e(c))),!0):!1}}function EC(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!_e.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&O.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new _e(r))),!0)}function TC(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof _e))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let o=r.length-1;o>=0;o--)i=S.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new A(i,0,0));return s.setSelection(D.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function AC(t){if(!(t.selection instanceof _e))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ee.create(t.doc,[ye.widget(t.selection.head,e,{key:"gapcursor"})])}var No=200,ke=function(){};ke.prototype.append=function(e){return e.length?(e=ke.from(e),!this.length&&e||e.length=n?ke.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ke.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ke.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ke.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};ke.from=function(e){return e instanceof ke?e:e&&e.length?new sg(e):ke.empty};var sg=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=No)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=No)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ke);ke.empty=new sg([]);var MC=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ke),su=ke;var _C=500,$n=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new gt(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new gt(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;uOC&&(a=NC(a,c),o-=c),new t(a.append(s),o)}remapping(e,n){let r=new hi;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new gt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new gt(p,m,g))}else r.push(new gt(p))},i);let c=[];for(let f=n;f_C&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&s++;let d=new gt(c.invert(),l,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new t(su.from(i.reverse()),s)}};$n.empty=new $n(su.empty,0);function NC(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}var gt=class t{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},yt=class{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}},OC=20;function IC(t,e,n,r){let i=n.getMeta(Fn),s;if(i)return i.historyState;n.getMeta(PC)&&(t=new yt(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Fn))return o.getMeta(Fn).redo?new yt(t.done.addTransform(n,void 0,r,Oo(e)),t.undone,og(n.mapping.maps),t.prevTime,t.prevComposition):new yt(t.done,t.undone.addTransform(n,void 0,r,Oo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!DC(n,t.prevRanges)),c=o?ou(t.prevRanges,n.mapping):og(n.mapping.maps);return new yt(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Oo(e)),$n.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new yt(t.done.rebased(n,s),t.undone.rebased(n,s),ou(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new yt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ou(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function DC(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(n=!0)}),n}function og(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function ou(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=Fn.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=RC(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}var lu=Io(!1,!0),cu=Io(!0,!0),sD=Io(!1,!1),oD=Io(!0,!1);var fD=B.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new R({key:new F("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let i=this.options.limit;if(i==null||i===0){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>i){let o=s-i,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;let a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),Ri=B.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ng(this.options)]}}),bD=B.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new R({key:new F("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return ee.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;o+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(ye.node(c,c+l.nodeSize,{class:this.options.className}))}),ee.create(t,s)}}})]}}),Pi=B.create({name:"gapCursor",addProseMirrorPlugins(){return[ig()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=J(I(t,"allowGapCursor",n)))!=null?e:null}}}),cg="placeholder";function LC(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var CD=B.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:cg,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let t=this.options.dataAttribute?`data-${LC(this.options.dataAttribute)}`:`data-${cg}`;return[new R({key:new F("placeholder"),props:{decorations:({doc:e,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,s=[];if(!r)return null;let o=this.editor.isEmpty;return e.descendants((a,l)=>{let c=i>=l&&i<=l+a.nodeSize,u=!a.isLeaf&&Oi(a);if(!a.type.isTextblock)return this.options.includeChildren;if((c||!this.options.showOnlyCurrent)&&u){let d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);let f=ye.node(l,l+a.nodeSize,{class:d.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),ee.create(e,s)}}})]}}),MD=B.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new R({key:new F("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||To(n.selection)||t.view.dragging?null:ee.create(n.doc,[ye.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}}),BC="skipTrailingNode";function ug({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var dg=B.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new F(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new R({key:e,appendTransaction:(i,s,o)=>{let{doc:a,tr:l,schema:c}=o,u=e.getState(o),d=a.content.size,f=c.nodes[n];if(!i.some(h=>h.getMeta(BC))&&u)return l.insert(d,f.create())},state:{init:(i,s)=>{let o=s.tr.doc.lastChild;return!ug({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;let o=i.doc.lastChild;return!ug({node:o,types:r})}}})]}}),Li=B.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>lu(t,e),redo:()=>({state:t,dispatch:e})=>cu(t,e)}},addProseMirrorPlugins(){return[lg(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var fg=Li;var hg=Ri;var pg=Pi;var uu=j.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",P(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Km(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,i=t();return To(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:a})=>{if(a){let{$to:l}=o.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(D.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(O.create(o.doc,l.pos)):o.setSelection(D.create(o.doc,l.pos));else{let u=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(D.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[qm({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),mg=uu;var zC=ae.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",P(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),gg=zC;var FC=ae.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",P(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),yg=FC;function bg(){return Math.random().toString(36).substring(2,8)}function vg(t){if(t.startsWith("heading-")){let e=t.split("-")[1];if(e&&!isNaN(e))return`h${e}`}return"p"}var $C=B.create({name:"universalBlockEnter",addOptions(){return{blocks:{},type:"manuscript"}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{let{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i)return!1;let s=r.parent.type.name,o=this.options.blocks[s];if(!o)return!1;let a=r.parentOffset===r.parent.content.size,l=(o["following-entity"]||o["following-block"])?.toLowerCase();if(a&&l&&e.schema.nodes[l]){let c=e.schema.nodes[l];return t.chain().command(({tr:u,dispatch:d})=>(d&&u.split(r.pos,1,[{type:c}]),!0)).scrollIntoView().run()}return!1},Tab:({editor:t})=>{let{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i)return!1;let s=r.parent.type.name;return this.options.type==="script"?s==="script-action"&&r.parent.content.size===0?t.chain().setNode("script-character").run():s==="script-character"&&r.parent.content.size===0?t.chain().setNode("script-parenthetical").run():!1:!1}}}});function HC(t,e){return j.create({name:t,group:"block",content:"inline*",draggable:!1,addAttributes(){return{id:{default:null,keepOnSplit:!1,parseHTML:n=>n.getAttribute("data-block-id"),renderHTML:n=>(n.id||(n.id=bg()),{"data-block-id":n.id})}}},parseHTML(){return[{tag:vg(t),getAttrs:r=>r.classList.contains(t)&&{id:r.getAttribute("data-block-id")}}]},renderHTML({HTMLAttributes:n}){let r=vg(t);return n["data-block-id"]||(n["data-block-id"]=bg()),[r,P(n,{class:t}),0]},addInputRules(){if(e["syntax-trigger"]){let n=e["syntax-trigger"].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return[zn({find:new RegExp(`^${n} $`),type:this.type})]}return[]}})}function wg(t,e="manuscript"){if(!t||!t.blocks)return[];let n=[];n.push($C.configure({blocks:t.blocks,type:e}));for(let[r,i]of Object.entries(t.blocks))n.push(HC(r,i));return n}var xg=B.create({name:"substitutions",addOptions(){return{smartQuotes:!0,smartDashes:!0,doubleQuoteStyle:"\u201C|\u201D",singleQuoteStyle:"\u2018|\u2019"}},addInputRules(){let t=[];if(this.options.smartDashes&&(t.push(new Me({find:/---\s$/,handler:({state:e,range:n})=>e.tr.insertText("\u2014 ",n.from,n.to)})),t.push(new Me({find:/--\s$/,handler:({state:e,range:n})=>e.tr.insertText("\u2013 ",n.from,n.to)}))),this.options.smartQuotes){let[e,n]=this.options.doubleQuoteStyle.split("|"),[r,i]=this.options.singleQuoteStyle.split("|");t.push(new Me({find:/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,handler:({state:s,range:o,match:a})=>{let l=a[0],c=l.substring(0,l.length-1);return s.tr.insertText(c+e,o.from,o.to)}})),t.push(new Me({find:/"$/,handler:({state:s,range:o})=>s.tr.insertText(n,o.from,o.to)})),t.push(new Me({find:/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,handler:({state:s,range:o,match:a})=>{let l=a[0],c=l.substring(0,l.length-1);return s.tr.insertText(c+r,o.from,o.to)}})),t.push(new Me({find:/'$/,handler:({state:s,range:o})=>s.tr.insertText(i,o.from,o.to)}))}return t}});var kg=j.create({name:"internalLink",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{target:{default:null},alias:{default:null},blockId:{default:null}}},parseHTML(){return[{tag:"span[data-colophon-link]"}]},renderHTML({node:t,HTMLAttributes:e}){let{target:n,alias:r}=t.attrs;return["span",P(e,{"data-colophon-link":n,class:"colophon-internal-link",title:`Click to open ${n}`}),r||n.split("/").pop().replace(".md","").replace(".colophon","")]},renderText({node:t}){let{target:e,alias:n}=t.attrs;return n||e},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let i=document.createElement("span");i.className="colophon-internal-link",i.setAttribute("data-colophon-link",t.attrs.target),i.title=`Click to open ${t.attrs.target}`;let s=null,o=null,a=()=>{o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let l=typeof n=="function"?n():null;if(l===null)return;let{selection:c}=r.state,u=c.from>=l&&c.from<=l+t.nodeSize||c.to>=l&&c.to<=l+t.nodeSize;if(u!==s)if(s=u,u){i.classList.add("is-selected");let d=t.attrs.target,f=t.attrs.alias,h=f?`[[${d}|${f}]]`:`[[${d}]]`;i.textContent!==h&&(i.textContent=h)}else{i.classList.remove("is-selected");let d=t.attrs.alias||t.attrs.target.split("/").pop().replace(".md","").replace(".colophon","");i.textContent!==d&&(i.textContent=d)}})};return i.addEventListener("mousedown",l=>{if(l.metaKey||l.ctrlKey){l.preventDefault(),l.stopPropagation();let c=r.options.app;c&&c.workspace.openLinkText(t.attrs.target,"",l.shiftKey);return}}),i.addEventListener("click",l=>{if(i.classList.contains("is-selected")){let c=r.options.app;c&&c.workspace.openLinkText(t.attrs.target,"",l.shiftKey)}}),r.on("selectionUpdate",a),r.on("transaction",a),a(),{dom:i,update:l=>l.type!==t.type?!1:(JSON.stringify(l.attrs)!==JSON.stringify(t.attrs)&&(t.attrs=l.attrs,s=null,a()),!0),destroy:()=>{o&&cancelAnimationFrame(o),r.off("selectionUpdate",a),r.off("transaction",a)}}}},addCommands(){return{insertInternalLink:t=>({chain:e})=>e().insertContent({type:this.name,attrs:t}).run()}},addInputRules(){return[new Me({find:/\[\[([^\]]+)\]\]$/,handler:({state:t,range:e,match:n})=>{let r=n[1],[i,s]=r.split("|");return t.tr.replaceWith(e.from,e.to,this.type.create({target:i.trim(),alias:s?s.trim():null}))}}),new Me({find:/\[([^\]]+)\]\(([^)]+)\)$/,handler:({state:t,range:e,match:n})=>{let r=n[1],i=n[2];return t.tr.replaceWith(e.from,e.to,this.type.create({target:i.trim(),alias:r.trim()}))}})]}});var Sg=j.create({name:"footnoteMarker",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{trigger:"(("}},addAttributes(){return{id:{default:null},number:{default:"?"}}},parseHTML(){return[{tag:"span[data-footnote-id]"}]},renderHTML({node:t,HTMLAttributes:e}){return["span",P(e,{class:"colophon-footnote-marker","data-footnote-id":t.attrs.id}),t.attrs.number.toString()]},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let i=document.createElement("span");return i.className="colophon-footnote-marker",i.dataset.footnoteId=t.attrs.id,i.textContent=t.attrs.number.toString(),i.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),document.body.dispatchEvent(new CustomEvent("colophon:footnote:focus",{detail:{id:t.attrs.id}}))}),{dom:i,update:s=>s.type!==t.type?!1:(i.textContent=s.attrs.number.toString(),!0)}}},addInputRules(){let e=this.options.trigger.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`${e}$`);return[new Me({find:n,handler:({state:r,range:i})=>{let s=`fn-${crypto.randomUUID()}`,{tr:o}=r;return o.replaceWith(i.from,i.to,this.type.create({id:s})),setTimeout(()=>{document.body.dispatchEvent(new CustomEvent("colophon:footnote:create",{detail:{id:s}}))},10),o}})]}});var Cg=ae.create({name:"commentHighlight",addAttributes(){return{threadId:{default:null,parseHTML:t=>t.getAttribute("data-comment-thread-id"),renderHTML:t=>t.threadId?{"data-comment-thread-id":t.threadId}:{}}}},parseHTML(){return[{tag:"span[data-comment-thread-id]"}]},renderHTML({HTMLAttributes:t}){return["span",P(t,{class:"colophon-comment-highlight"}),0]},addCommands(){return{setComment:t=>({commands:e})=>e.setMark(this.name,{threadId:t}),unsetComment:()=>({commands:t})=>t.unsetMark(this.name)}}});var Eg=ae.create({name:"smallCaps",parseHTML(){return[{tag:"span",getAttrs:t=>t.classList.contains("colophon-small-caps")&&null}]},renderHTML({HTMLAttributes:t}){return["span",P(t,{class:"colophon-small-caps"}),0]},addCommands(){return{toggleSmallCaps:()=>({commands:t})=>t.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-k":()=>this.editor.commands.toggleSmallCaps()}}});var Tg=B.create({name:"trailingNode",addOptions(){return{node:"body",notAfter:["body","supertitle","title","subtitle","epigraph","body-first","heading-1","heading-2","heading-3","heading-4"]}},addProseMirrorPlugins(){let t=new F(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>this.options.notAfter.includes(n.name));return[new R({key:t,appendTransaction:(n,r,i)=>{let{doc:s,tr:o,schema:a}=i,l=s.lastChild;if(!l||!e.includes(l.type)){let c=a.nodes[this.options.node];return c?o.insert(s.content.size,c.create()):null}return null}})]}});var Fv=si(zv()),Ca=class{constructor(e={}){this.paragraphs=e.paragraphs||[],this.styles=e.styles||[],this.fonts=e.fonts||["Times New Roman","Arial"],this.footnotes=e.footnotes||{};let n=e.pageSize||"Letter";this.pageSize=typeof n=="string"?{width:n}:n,this.margins=e.margins||{top:1,bottom:1,left:1,right:1},this.stylesConfig=e.stylesConfig||{},this.scale=(e.scale||100)/100,this.footnoteIdMap=new Map,this.comments=e.comments||{},this.commentIdMap=new Map}async generate(){let e=new Fv.default,n=1;Object.keys(this.footnotes).forEach(s=>{this.footnoteIdMap.set(s,n++)});let r=0;Object.keys(this.comments).forEach(s=>{this.commentIdMap.set(s,r++)}),e.file("[Content_Types].xml",this.createContentTypesXml()),e.folder("_rels").file(".rels",this.createRelsXml());let i=e.folder("word");return i.file("document.xml",this.createDocumentXml()),i.file("styles.xml",this.createStylesXml()),i.file("fontTable.xml",this.createFontTableXml()),i.file("footnotes.xml",this.createFootnotesXml()),i.file("settings.xml",this.createSettingsXml()),i.file("comments.xml",this.createCommentsXml()),i.folder("_rels").file("document.xml.rels",this.createDocumentRelsXml()),e.generateAsync({type:"nodebuffer"})}createContentTypesXml(){return` +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:t,state:e,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:s}=e;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return t().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){let h=l.filter(d=>a.includes(d.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Th=ia;var vn=(n,t)=>{if(n==="slot")return 0;if(n instanceof Function)return n(t);let{children:e,...r}=t??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,e]};var qy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Jy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Gy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Xy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,sa=tt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return vn("strong",{...P(this.options.HTMLAttributes,n),children:vn("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,t)=>t.applyMark("bold",t.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,t)=>`**${t.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[qt({find:qy,type:this.type}),qt({find:Gy,type:this.type})]},addPasteRules(){return[zt({find:Jy,type:this.type}),zt({find:Xy,type:this.type})]}}),Mh=sa;var Qy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Yy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Zy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,t0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,oa=tt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",P(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,t)=>t.applyMark("italic",t.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,t)=>`*${t.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[qt({find:Qy,type:this.type}),qt({find:Zy,type:this.type})]},addPasteRules(){return[zt({find:Yy,type:this.type}),zt({find:t0,type:this.type})]}}),Ah=oa;var e0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,n0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,aa=tt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",P(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,t)=>t.applyMark("strike",t.parseInline(n.tokens||[])),renderMarkdown:(n,t)=>`~~${t.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[qt({find:e0,type:this.type})]},addPasteRules(){return[zt({find:n0,type:this.type})]}}),Nh=aa;var la=tt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",P(this.options.HTMLAttributes,n),0]},parseMarkdown(n,t){return t.applyMark(this.name||"underline",t.parseInline(n.tokens||[]))},renderMarkdown(n,t){return`++${t.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,t,e){let i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!i)return;let s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:e.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Oh=la;function Ih(n={}){return new D({view(t){return new ca(t,n)}})}var ca=class{constructor(t,e){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=e.width)!==null&&r!==void 0?r:1,this.color=e.color===!1?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return t.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){this.cursorPos!=null&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),e=!t.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(e){let h=t.nodeBefore,d=t.nodeAfter;if(h||d){let f=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=h?p.bottom:p.top;h&&d&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*o;r={left:h.left-d,right:h.left+d,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",e),this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),d=h.width/l.offsetWidth,f=h.height/l.offsetHeight;c=h.left-l.scrollLeft*d,u=h.top-l.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!s){let o=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Br(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}};var wt=class n extends R{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return n.valid(r)?new n(r):R.near(r)}content(){return S.empty}eq(t){return t instanceof n&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(t.resolve(e.pos))}getBookmark(){return new ua(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!r0(t)||!i0(t))return!1;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=!1){t:for(;;){if(!r&&n.valid(t))return t;let i=t.pos,s=null;for(let o=t.depth;;o--){let a=t.node(o);if(e>0?t.indexAfter(o)0){s=a.child(e>0?t.indexAfter(o):t.index(o)-1);break}else if(o==0)return null;i+=e;let l=t.doc.resolve(i);if(n.valid(l))return l}for(;;){let o=e>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!A.isSelectable(s)){t=t.doc.resolve(i+s.nodeSize*e),r=!1;continue t}break}s=o,i+=e;let a=t.doc.resolve(i);if(n.valid(a))return a}return null}}};wt.prototype.visible=!1;wt.findFrom=wt.findGapCursorFrom;R.jsonID("gapcursor",wt);var ua=class n{constructor(t){this.pos=t}map(t){return new n(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return wt.valid(e)?new wt(e):R.near(e)}};function Dh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function r0(n){for(let t=n.depth;t>=0;t--){let e=n.index(t),r=n.node(t);if(e==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(e-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Dh(i.type))return!0;if(i.inlineContent)return!1}}return!0}function i0(n){for(let t=n.depth;t>=0;t--){let e=n.indexAfter(t),r=n.node(t);if(e==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(e);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Dh(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Ph(){return new D({props:{decorations:l0,createSelectionBetween(n,t,e){return t.pos==e.pos&&wt.valid(e)?new wt(e):null},handleClick:o0,handleKeyDown:s0,handleDOMEvents:{beforeinput:a0}}})}var s0=$o({ArrowLeft:bi("horiz",-1),ArrowRight:bi("horiz",1),ArrowUp:bi("vert",-1),ArrowDown:bi("vert",1)});function bi(n,t){let e=n=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,i,s){let o=r.selection,a=t>0?o.$to:o.$from,l=o.empty;if(o instanceof I){if(!s.endOfTextblock(e)||a.depth==0)return!1;l=!1,a=r.doc.resolve(t>0?a.after():a.before())}let c=wt.findGapCursorFrom(a,t,l);return c?(i&&i(r.tr.setSelection(new wt(c))),!0):!1}}function o0(n,t,e){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(t);if(!wt.valid(r))return!1;let i=n.posAtCoords({left:e.clientX,top:e.clientY});return i&&i.inside>-1&&A.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new wt(r))),!0)}function a0(n,t){if(t.inputType!="insertCompositionText"||!(n.state.selection instanceof wt))return!1;let{$from:e}=n.state.selection,r=e.parent.contentMatchAt(e.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=v.empty;for(let o=r.length-1;o>=0;o--)i=v.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(e.pos,e.pos,new S(i,0,0));return s.setSelection(I.near(s.doc.resolve(e.pos+1))),n.dispatch(s),!1}function l0(n){if(!(n.selection instanceof wt))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",X.create(n.doc,[ot.widget(n.selection.head,t,{key:"gapcursor"})])}var vi=200,dt=function(){};dt.prototype.append=function(t){return t.length?(t=dt.from(t),!this.length&&t||t.length=e?dt.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))};dt.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};dt.prototype.forEach=function(t,e,r){e===void 0&&(e=0),r===void 0&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)};dt.prototype.map=function(t,e,r){e===void 0&&(e=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(t(s,o))},e,r),i};dt.from=function(t){return t instanceof dt?t:t&&t.length?new Rh(t):dt.empty};var Rh=(function(n){function t(r){n.call(this),this.values=r}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;var e={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new t(this.values.slice(i,s))},t.prototype.getInner=function(i){return this.values[i]},t.prototype.forEachInner=function(i,s,o,a){for(var l=s;l=o;l--)if(i(this.values[l],a+l)===!1)return!1},t.prototype.leafAppend=function(i){if(this.length+i.length<=vi)return new t(this.values.concat(i.flatten()))},t.prototype.leafPrepend=function(i){if(this.length+i.length<=vi)return new t(i.flatten().concat(this.values))},e.length.get=function(){return this.values.length},e.depth.get=function(){return 0},Object.defineProperties(t.prototype,e),t})(dt);dt.empty=new Rh([]);var c0=(function(n){function t(e,r){n.call(this),this.left=e,this.right=r,this.length=e.length+r.length,this.depth=Math.max(e.depth,r.depth)+1}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},t.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},t.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new t(this.left,i)},t.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new t(i,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(dt),ha=dt;var u0=500,Ke=class n{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;e&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=t.tr,a,l,c=[],u=[];return this.items.forEach((h,d)=>{if(!h.step){i||(i=this.remapping(r,d+1),s=i.maps.length),s--,u.push(h);return}if(i){u.push(new Gt(h.map));let f=h.step.map(i.slice(s)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Gt(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(h.step);if(h.selection)return a=i?h.selection.map(i.slice(s)):h.selection,l=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(t,e,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;ud0&&(a=h0(a,c),o-=c),new n(a.append(s),o)}remapping(t,e){let r=new zn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=t?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},t,e),r}addMaps(t){return this.eventCount==0?this:new n(this.items.append(t.map(e=>new Gt(e))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e),s=t.mapping,o=t.steps.length,a=this.eventCount;this.items.forEach(d=>{d.selection&&a--},i);let l=e;this.items.forEach(d=>{let f=s.getMirror(--l);if(f==null)return;o=Math.min(o,f);let p=s.maps[f];if(d.step){let m=t.steps[f].invert(t.docs[f]),g=d.selection&&d.selection.map(s.slice(l+1,f));g&&a++,r.push(new Gt(p,m,g))}else r.push(new Gt(p))},i);let c=[];for(let d=e;du0&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=t)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(e.slice(r)),c=l&&l.getMap();if(r--,c&&e.appendMap(c,r),l){let u=o.selection&&o.selection.map(e.slice(r));u&&s++;let h=new Gt(c.invert(),l,u),d,f=i.length-1;(d=i.length&&i[f].merge(h))?i[f]=d:i.push(h)}}else o.map&&r--},this.items.length,0),new n(ha.from(i.reverse()),s)}};Ke.empty=new Ke(ha.empty,0);function h0(n,t){let e;return n.forEach((r,i)=>{if(r.selection&&t--==0)return e=i,!1}),n.slice(e)}var Gt=class n{constructor(t,e,r,i){this.map=t,this.step=e,this.selection=r,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new n(e.getMap().invert(),e,this.selection)}}},Xt=class{constructor(t,e,r,i,s){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}},d0=20;function f0(n,t,e,r){let i=e.getMeta(_e),s;if(i)return i.historyState;e.getMeta(g0)&&(n=new Xt(n.done,n.undone,null,0,-1));let o=e.getMeta("appendedTransaction");if(e.steps.length==0)return n;if(o&&o.getMeta(_e))return o.getMeta(_e).redo?new Xt(n.done.addTransform(e,void 0,r,wi(t)),n.undone,Lh(e.mapping.maps),n.prevTime,n.prevComposition):new Xt(n.done,n.undone.addTransform(e,void 0,r,wi(t)),null,n.prevTime,n.prevComposition);if(e.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=e.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(e.time||0)-r.newGroupDelay||!p0(e,n.prevRanges)),c=o?da(n.prevRanges,e.mapping):Lh(e.mapping.maps);return new Xt(n.done.addTransform(e,l?t.selection.getBookmark():void 0,r,wi(t)),Ke.empty,c,e.time,a??n.prevComposition)}else return(s=e.getMeta("rebased"))?new Xt(n.done.rebased(e,s),n.undone.rebased(e,s),da(n.prevRanges,e.mapping),n.prevTime,n.prevComposition):new Xt(n.done.addMaps(e.mapping.maps),n.undone.addMaps(e.mapping.maps),da(n.prevRanges,e.mapping),n.prevTime,n.prevComposition)}function p0(n,t){if(!t)return!1;if(!n.docChanged)return!0;let e=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=t[s]&&(e=!0)}),e}function Lh(n){let t=[];for(let e=n.length-1;e>=0&&t.length==0;e--)n[e].forEach((r,i,s,o)=>t.push(s,o));return t}function da(n,t){if(!n)return null;let e=[];for(let r=0;r{let i=_e.getState(e);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=m0(i,e,n);s&&r(t?s.scrollIntoView():s)}return!0}}var pa=ki(!1,!0),ma=ki(!0,!0),xk=ki(!1,!1),Sk=ki(!0,!1);var Nk=L.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let t=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=n=>{let t=n?.node||this.editor.state.doc,e=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(e)}},addProseMirrorPlugins(){let n=!1;return[new D({key:new z("characterCount"),appendTransaction:(t,e,r)=>{if(n)return;let i=this.options.limit;if(i==null||i===0){n=!0;return}let s=this.storage.characters({node:r.doc});if(s>i){let o=s-i,a=0,l=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(a,l);return n=!0,c}n=!0},filterTransaction:(t,e)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let i=this.storage.characters({node:e.doc}),s=this.storage.characters({node:t.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!t.getMeta("paste"))return!1;let a=t.selection.$head.pos,l=s-r,c=a-l,u=a;return t.deleteRange(c,u),!(this.storage.characters({node:t.doc})>r)}})]}}),rr=L.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ih(this.options)]}}),Lk=L.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new D({key:new z("focus"),props:{decorations:({doc:n,selection:t})=>{let{isEditable:e,isFocused:r}=this.editor,{anchor:i}=t,s=[];if(!e||!r)return X.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;o+=1});let a=0;return n.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(ot.node(c,c+l.nodeSize,{class:this.options.className}))}),X.create(n,s)}}})]}}),ir=L.create({name:"gapCursor",addProseMirrorPlugins(){return[Ph()]},extendNodeSchema(n){var t;let e={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(t=_(O(n,"allowGapCursor",e)))!=null?t:null}}}),Fh="placeholder";function y0(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Vk=L.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Fh,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let n=this.options.dataAttribute?`data-${y0(this.options.dataAttribute)}`:`data-${Fh}`;return[new D({key:new z("placeholder"),props:{decorations:({doc:t,selection:e})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,s=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((a,l)=>{let c=i>=l&&i<=l+a.nodeSize,u=!a.isLeaf&&tr(a);if(!a.type.isTextblock)return this.options.includeChildren;if((c||!this.options.showOnlyCurrent)&&u){let h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);let d=ot.node(l,l+a.nodeSize,{class:h.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),X.create(t,s)}}})]}}),_k=L.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:t}=this;return[new D({key:new z("selection"),props:{decorations(e){return e.selection.empty||n.isFocused||!n.isEditable||mi(e.selection)||n.view.dragging?null:X.create(e.doc,[ot.inline(e.selection.from,e.selection.to,{class:t.className})])}}})]}}),b0="skipTrailingNode";function $h({types:n,node:t}){return t&&Array.isArray(n)&&n.includes(t.type)||t?.type===n}var Hh=L.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;let t=new z(this.name),e=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(e).includes(i.name));return[new D({key:t,appendTransaction:(i,s,o)=>{let{doc:a,tr:l,schema:c}=o,u=t.getState(o),h=a.content.size,d=c.nodes[e];if(!i.some(f=>f.getMeta(b0))&&u)return l.insert(h,d.create())},state:{init:(i,s)=>{let o=s.tr.doc.lastChild;return!$h({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;let o=i.doc.lastChild;return!$h({node:o,types:r})}}})]}}),sr=L.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:t})=>pa(n,t),redo:()=>({state:n,dispatch:t})=>ma(n,t)}},addProseMirrorPlugins(){return[Bh(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Vh=sr;var Wh=rr;var Uh=ir;var ga=W.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",P(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:t})=>{if(!xh(t,t.schema.nodes[this.name]))return!1;let{selection:e}=t,{$to:r}=e,i=n();return mi(e)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:a})=>{if(a){let{$to:l}=o.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(I.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(A.create(o.doc,l.pos)):o.setSelection(I.create(o.doc,l.pos));else{let u=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=u?.create();h&&(o.insert(c,h),o.setSelection(I.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[kh({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),jh=ga;var v0=tt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",P(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),_h=v0;var w0=tt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",P(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Kh=w0;function qh(){return Math.random().toString(36).substring(2,8)}function Jh(n){if(n.startsWith("heading-")){let t=n.split("-")[1];if(t&&!isNaN(t))return`h${t}`}return"p"}var k0=L.create({name:"universalBlockEnter",addOptions(){return{blocks:{},type:"manuscript"}},addKeyboardShortcuts(){return{Enter:({editor:n})=>{let{state:t}=n,{selection:e}=t,{$from:r,empty:i}=e;if(!i)return!1;let s=r.parent.type.name,o=this.options.blocks[s];if(!o)return!1;let a=r.parentOffset===r.parent.content.size,l=(o["following-entity"]||o["following-block"])?.toLowerCase();if(a&&l&&t.schema.nodes[l]){let c=t.schema.nodes[l];return n.chain().command(({tr:u,dispatch:h})=>(h&&u.split(r.pos,1,[{type:c}]),!0)).scrollIntoView().run()}return!1},Tab:({editor:n})=>{let{state:t}=n,{selection:e}=t,{$from:r,empty:i}=e;if(!i)return!1;let s=r.parent.type.name;return this.options.type==="script"?s==="script-action"&&r.parent.content.size===0?n.chain().setNode("script-character").run():s==="script-character"&&r.parent.content.size===0?n.chain().setNode("script-parenthetical").run():!1:!1}}}});function x0(n,t){return W.create({name:n,group:"block",content:"inline*",draggable:!1,addAttributes(){return{id:{default:null,keepOnSplit:!1,parseHTML:e=>e.getAttribute("data-block-id"),renderHTML:e=>(e.id||(e.id=qh()),{"data-block-id":e.id})}}},parseHTML(){return[{tag:Jh(n),getAttrs:r=>r.classList.contains(n)&&{id:r.getAttribute("data-block-id")}}]},renderHTML({HTMLAttributes:e}){let r=Jh(n);return e["data-block-id"]||(e["data-block-id"]=qh()),[r,P(e,{class:n}),0]},addInputRules(){if(t["syntax-trigger"]){let e=t["syntax-trigger"].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return[je({find:new RegExp(`^${e} $`),type:this.type})]}return[]}})}function Gh(n,t="manuscript"){if(!n||!n.blocks)return[];let e=[];e.push(k0.configure({blocks:n.blocks,type:t}));for(let[r,i]of Object.entries(n.blocks))e.push(x0(r,i));return e}var Xh=L.create({name:"substitutions",addOptions(){return{smartQuotes:!0,smartDashes:!0,doubleQuoteStyle:"\u201C|\u201D",singleQuoteStyle:"\u2018|\u2019"}},addInputRules(){let n=[];if(this.options.smartDashes&&(n.push(new vt({find:/---\s$/,handler:({state:t,range:e})=>t.tr.insertText("\u2014 ",e.from,e.to)})),n.push(new vt({find:/--\s$/,handler:({state:t,range:e})=>t.tr.insertText("\u2013 ",e.from,e.to)}))),this.options.smartQuotes){let[t,e]=this.options.doubleQuoteStyle.split("|"),[r,i]=this.options.singleQuoteStyle.split("|");n.push(new vt({find:/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,handler:({state:s,range:o,match:a})=>{let l=a[0],c=l.substring(0,l.length-1);return s.tr.insertText(c+t,o.from,o.to)}})),n.push(new vt({find:/"$/,handler:({state:s,range:o})=>s.tr.insertText(e,o.from,o.to)})),n.push(new vt({find:/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,handler:({state:s,range:o,match:a})=>{let l=a[0],c=l.substring(0,l.length-1);return s.tr.insertText(c+r,o.from,o.to)}})),n.push(new vt({find:/'$/,handler:({state:s,range:o})=>s.tr.insertText(i,o.from,o.to)}))}return n}});var Qh=W.create({name:"internalLink",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{target:{default:null},alias:{default:null},blockId:{default:null}}},parseHTML(){return[{tag:"span[data-colophon-link]"}]},renderHTML({node:n,HTMLAttributes:t}){let{target:e,alias:r}=n.attrs;return["span",P(t,{"data-colophon-link":e,class:"colophon-internal-link",title:`Click to open ${e}`}),r||e.split("/").pop().replace(".md","").replace(".colophon","")]},renderText({node:n}){let{target:t,alias:e}=n.attrs;return e||t},addNodeView(){return({node:n,HTMLAttributes:t,getPos:e,editor:r})=>{let i=document.createElement("span");i.className="colophon-internal-link",i.setAttribute("data-colophon-link",n.attrs.target),i.title=`Click to open ${n.attrs.target}`;let s=null,o=null,a=()=>{o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let l=typeof e=="function"?e():null;if(l===null)return;let{selection:c}=r.state,u=c.from>=l&&c.from<=l+n.nodeSize||c.to>=l&&c.to<=l+n.nodeSize;if(u!==s)if(s=u,u){i.classList.add("is-selected");let h=n.attrs.target,d=n.attrs.alias,f=d?`[[${h}|${d}]]`:`[[${h}]]`;i.textContent!==f&&(i.textContent=f)}else{i.classList.remove("is-selected");let h=n.attrs.alias||n.attrs.target.split("/").pop().replace(".md","").replace(".colophon","");i.textContent!==h&&(i.textContent=h)}})};return i.addEventListener("mousedown",l=>{if(l.metaKey||l.ctrlKey){l.preventDefault(),l.stopPropagation();let c=r.options.app;c&&c.workspace.openLinkText(n.attrs.target,"",l.shiftKey);return}}),i.addEventListener("click",l=>{if(i.classList.contains("is-selected")){let c=r.options.app;c&&c.workspace.openLinkText(n.attrs.target,"",l.shiftKey)}}),r.on("selectionUpdate",a),r.on("transaction",a),a(),{dom:i,update:l=>l.type!==n.type?!1:(JSON.stringify(l.attrs)!==JSON.stringify(n.attrs)&&(n.attrs=l.attrs,s=null,a()),!0),destroy:()=>{o&&cancelAnimationFrame(o),r.off("selectionUpdate",a),r.off("transaction",a)}}}},addCommands(){return{insertInternalLink:n=>({chain:t})=>t().insertContent({type:this.name,attrs:n}).run()}},addInputRules(){return[new vt({find:/\[\[([^\]]+)\]\]$/,handler:({state:n,range:t,match:e})=>{let r=e[1],[i,s]=r.split("|");return n.tr.replaceWith(t.from,t.to,this.type.create({target:i.trim(),alias:s?s.trim():null}))}}),new vt({find:/\[([^\]]+)\]\(([^)]+)\)$/,handler:({state:n,range:t,match:e})=>{let r=e[1],i=e[2];return n.tr.replaceWith(t.from,t.to,this.type.create({target:i.trim(),alias:r.trim()}))}})]}});var Yh=W.create({name:"footnoteMarker",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{trigger:"(("}},addAttributes(){return{id:{default:null},number:{default:"?"}}},parseHTML(){return[{tag:"span[data-footnote-id]"}]},renderHTML({node:n,HTMLAttributes:t}){return["span",P(t,{class:"colophon-footnote-marker","data-footnote-id":n.attrs.id}),n.attrs.number.toString()]},addNodeView(){return({node:n,HTMLAttributes:t,getPos:e,editor:r})=>{let i=document.createElement("span");return i.className="colophon-footnote-marker",i.dataset.footnoteId=n.attrs.id,i.textContent=n.attrs.number.toString(),i.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),document.body.dispatchEvent(new CustomEvent("colophon:footnote:focus",{detail:{id:n.attrs.id}}))}),{dom:i,update:s=>s.type!==n.type?!1:(i.textContent=s.attrs.number.toString(),!0)}}},addInputRules(){let t=this.options.trigger.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),e=new RegExp(`${t}$`);return[new vt({find:e,handler:({state:r,range:i})=>{let s=`fn-${crypto.randomUUID()}`,{tr:o}=r;return o.replaceWith(i.from,i.to,this.type.create({id:s})),setTimeout(()=>{document.body.dispatchEvent(new CustomEvent("colophon:footnote:create",{detail:{id:s}}))},10),o}})]}});var Zh=tt.create({name:"commentHighlight",addAttributes(){return{threadId:{default:null,parseHTML:n=>n.getAttribute("data-comment-thread-id"),renderHTML:n=>n.threadId?{"data-comment-thread-id":n.threadId}:{}}}},parseHTML(){return[{tag:"span[data-comment-thread-id]"}]},renderHTML({HTMLAttributes:n}){return["span",P(n,{class:"colophon-comment-highlight"}),0]},addCommands(){return{setComment:n=>({commands:t})=>t.setMark(this.name,{threadId:n}),unsetComment:()=>({commands:n})=>n.unsetMark(this.name)}}});var td=tt.create({name:"smallCaps",parseHTML(){return[{tag:"span",getAttrs:n=>n.classList.contains("colophon-small-caps")&&null}]},renderHTML({HTMLAttributes:n}){return["span",P(n,{class:"colophon-small-caps"}),0]},addCommands(){return{toggleSmallCaps:()=>({commands:n})=>n.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-k":()=>this.editor.commands.toggleSmallCaps()}}});var ed=L.create({name:"trailingNode",addOptions(){return{node:"body",notAfter:["body","supertitle","title","subtitle","epigraph","body-first","heading-1","heading-2","heading-3","heading-4"]}},addProseMirrorPlugins(){let n=new z(this.name),t=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>this.options.notAfter.includes(e.name));return[new D({key:n,appendTransaction:(e,r,i)=>{let{doc:s,tr:o,schema:a}=i,l=s.lastChild;if(!l||!t.includes(l.type)){let c=a.nodes[this.options.node];return c?o.insert(s.content.size,c.create()):null}return null}})]}});var ld=require("module"),S0=(0,ld.createRequire)("/"),C0;try{C0=S0("worker_threads").Worker}catch{}var pt=Uint8Array,Nt=Uint16Array,xa=Int32Array,Sa=new pt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ca=new pt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nd=new pt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cd=function(n,t){for(var e=new Nt(31),r=0;r<31;++r)e[r]=t+=1<>1|(j&21845)<<1,de=(de&52428)>>2|(de&13107)<<2,de=(de&61680)>>4|(de&3855)<<4,va[j]=((de&65280)>>8|(de&255)<<8)>>1;var de,j,lr=(function(n,t,e){for(var r=n.length,i=0,s=new Nt(t);i>l]=c}else for(a=new Nt(r),i=0;i>15-n[i]);return a}),qe=new pt(288);for(j=0;j<144;++j)qe[j]=8;var j;for(j=144;j<256;++j)qe[j]=9;var j;for(j=256;j<280;++j)qe[j]=7;var j;for(j=280;j<288;++j)qe[j]=8;var j,xi=new pt(32);for(j=0;j<32;++j)xi[j]=5;var j,T0=lr(qe,9,0);var M0=lr(xi,5,0);var dd=function(n){return(n+7)/8|0},fd=function(n,t,e){return(t==null||t<0)&&(t=0),(e==null||e>n.length)&&(e=n.length),new pt(n.subarray(t,e))};var A0=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Si=function(n,t,e){var r=new Error(t||A0[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,Si),!e)throw r;return r};var fe=function(n,t,e){e<<=t&7;var r=t/8|0;n[r]|=e,n[r+1]|=e>>8},or=function(n,t,e){e<<=t&7;var r=t/8|0;n[r]|=e,n[r+1]|=e>>8,n[r+2]|=e>>16},ya=function(n,t){for(var e=[],r=0;rd&&(d=s[r].s);var f=new Nt(d+1),p=wa(e[u-1],f,0);if(p>t){var r=0,m=0,g=p-t,y=1<t)m+=y-(1<>=g;m>0;){var C=s[r].s;f[C]=0&&m;--r){var M=s[r].s;f[M]==t&&(--f[M],++m)}p=t}return{t:new pt(f),l:p}},wa=function(n,t,e){return n.s==-1?Math.max(wa(n.l,t,e+1),wa(n.r,t,e+1)):t[n.s]=e},id=function(n){for(var t=n.length;t&&!n[--t];);for(var e=new Nt(++t),r=0,i=n[0],s=1,o=function(l){e[r++]=l},a=1;a<=t;++a)if(n[a]==i&&a!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return{c:e.subarray(0,r),n:t}},ar=function(n,t){for(var e=0,r=0;r>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!$[nd[q-1]];--q);var Q=c+5<<3,K=ar(i,qe)+ar(s,xi)+o,U=ar(i,d)+ar(s,m)+o+14+3*q+ar(k,$)+2*k[16]+3*k[17]+7*k[18];if(l>=0&&Q<=K&&Q<=U)return pd(t,u,n.subarray(l,l+c));var lt,G,Ht,ye;if(fe(t,u,1+(U15&&(fe(t,u,Ze[E]>>5&127),u+=Ze[E]>>12)}}else lt=T0,G=qe,Ht=M0,ye=xi;for(var E=0;E255){var Wt=mt>>18&31;or(t,u,lt[Wt+257]),u+=G[Wt+257],Wt>7&&(fe(t,u,mt>>23&31),u+=Sa[Wt]);var tn=mt&31;or(t,u,Ht[tn]),u+=ye[tn],tn>3&&(or(t,u,mt>>5&8191),u+=Ca[tn])}else or(t,u,lt[mt]),u+=G[mt]}return or(t,u,lt[256]),u+G[256]},N0=new xa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),md=new pt(0),O0=function(n,t,e,r,i,s){var o=s.z||n.length,a=new pt(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=s.l,u=(s.r||0)&7;if(t){u&&(l[0]=s.r>>3);for(var h=N0[t-1],d=h>>13,f=h&8191,p=(1<7e3||$>24576)&&(lt>423||!c)){u=sd(n,l,0,M,x,N,E,$,q,T-q,u),$=k=E=0,q=T;for(var G=0;G<286;++G)x[G]=0;for(var G=0;G<30;++G)N[G]=0}var Ht=2,ye=0,ws=f,Vt=K-U&32767;if(lt>2&&Q==C(T-Vt))for(var An=Math.min(d,lt)-1,Ze=Math.min(32767,T),Wt=Math.min(258,lt);Vt<=Ze&&--ws&&K!=U;){if(n[T+Ht]==n[T+Ht-Vt]){for(var mt=0;mtHt){if(Ht=mt,ye=Vt,mt>An)break;for(var tn=Math.min(Vt,mt-2),al=0,G=0;Gal&&(al=ll,U=ks)}}}K=U,U=m[K],Vt+=K-U&32767}if(ye){M[$++]=268435456|ba[Ht]<<18|rd[ye];var cl=ba[Ht]&31,ul=rd[ye]&31;E+=Sa[cl]+Ca[ul],++x[257+cl],++N[ul],kt=T+Ht,++k}else M[$++]=n[T],++x[n[T]]}}for(T=Math.max(T,kt);T=o&&(l[u/8|0]=c,xs=o),u=pd(l,u+1,n.subarray(T,xs))}s.i=o}return fd(a,0,r+dd(u)+i)},I0=(function(){for(var n=new Int32Array(256),t=0;t<256;++t){for(var e=t,r=9;--r;)e=(e&1&&-306674912)^e>>>1;n[t]=e}return n})(),D0=function(){var n=-1;return{p:function(t){for(var e=n,r=0;r>>8;n=e},d:function(){return~n}}};var P0=function(n,t,e,r,i){if(!i&&(i={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new pt(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return O0(n,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+t.mem,e,r,i)},gd=function(n,t){var e={};for(var r in n)e[r]=n[r];for(var r in t)e[r]=t[r];return e};var ft=function(n,t,e){for(;e;++t)n[t]=e,e>>>=8};function R0(n,t){return P0(n,t||{},0,0)}var yd=function(n,t,e,r){for(var i in n){var s=n[i],o=t+i,a=r;Array.isArray(s)&&(a=gd(r,s[1]),s=s[0]),s instanceof pt?e[o]=[s,a]:(e[o+="/"]=[new pt(0),a],yd(s,o,e,r))}},od=typeof TextEncoder<"u"&&new TextEncoder,L0=typeof TextDecoder<"u"&&new TextDecoder,z0=0;try{L0.decode(md,{stream:!0}),z0=1}catch{}function Bt(n,t){if(t){for(var e=new pt(n.length),r=0;r>1)),o=0,a=function(u){s[o++]=u},r=0;rs.length){var l=new pt(o+8+(i-r<<1));l.set(s),s=l}var c=n.charCodeAt(r);c<128||t?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|n.charCodeAt(++r)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return fd(s,0,o)}var ka=function(n){var t=0;if(n)for(var e in n){var r=n[e].length;r>65535&&Si(9),t+=r+4}return t},ad=function(n,t,e,r,i,s,o,a){var l=r.length,c=e.extra,u=a&&a.length,h=ka(c);ft(n,t,o!=null?33639248:67324752),t+=4,o!=null&&(n[t++]=20,n[t++]=e.os),n[t]=20,t+=2,n[t++]=e.flag<<1|(s<0&&8),n[t++]=i&&8,n[t++]=e.compression&255,n[t++]=e.compression>>8;var d=new Date(e.mtime==null?Date.now():e.mtime),f=d.getFullYear()-1980;if((f<0||f>119)&&Si(10),ft(n,t,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),t+=4,s!=-1&&(ft(n,t,e.crc),ft(n,t+4,s<0?-s-2:s),ft(n,t+8,e.size)),ft(n,t+12,l),ft(n,t+14,h),t+=16,o!=null&&(ft(n,t,u),ft(n,t+6,e.attrs),ft(n,t+10,o),t+=14),n.set(r,t),t+=l,h)for(var p in c){var m=c[p],g=m.length;ft(n,t,+p),ft(n,t+2,g),n.set(m,t+4),t+=4+g}return u&&(n.set(a,t),t+=u),t},B0=function(n,t,e,r,i){ft(n,t,101010256),ft(n,t+8,e),ft(n,t+10,e),ft(n,t+12,r),ft(n,t+16,i)};function bd(n,t){t||(t={});var e={},r=[];yd(n,"",e,t);var i=0,s=0;for(var o in e){var a=e[o],l=a[0],c=a[1],u=c.level==0?0:8,h=Bt(o),d=h.length,f=c.comment,p=f&&Bt(f),m=p&&p.length,g=ka(c.extra);d>65535&&Si(11);var y=u?R0(l,c):l,b=y.length,C=D0();C.p(l),r.push(gd(c,{size:l.length,crc:C.d(),c:y,f:h,m:p,u:d!=o.length||p&&f.length!=m,o:i,compression:u})),i+=30+d+g+b,s+=76+2*(d+g)+(m||0)+b}for(var M=new pt(s+22),x=i,N=s-i,k=0;k{this.footnoteIdMap.set(i,t++)});let e=0;Object.keys(this.comments).forEach(i=>{this.commentIdMap.set(i,e++)});let r={"[Content_Types].xml":Bt(this.createContentTypesXml()),"_rels/.rels":Bt(this.createRelsXml()),"word/document.xml":Bt(this.createDocumentXml()),"word/styles.xml":Bt(this.createStylesXml()),"word/fontTable.xml":Bt(this.createFontTableXml()),"word/footnotes.xml":Bt(this.createFootnotesXml()),"word/settings.xml":Bt(this.createSettingsXml()),"word/comments.xml":Bt(this.createCommentsXml()),"word/_rels/document.xml.rels":Bt(this.createDocumentRelsXml())};return Buffer.from(bd(r))}createContentTypesXml(){return` @@ -140,8 +139,8 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants `}createFontTableXml(){return` - ${this.fonts.map(n=>` - + ${this.fonts.map(e=>` + @@ -153,7 +152,7 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants -`}createStylesXml(){let e=new Set,n="";for(let[i,s]of Object.entries(this.stylesConfig)){let{id:o,name:a,basedOn:l}=this.getDocxStyleInfo(i,s),c=this.cssToParaProps(null,o),u=this.cssToRunProps(null,o);n+=` +`}createStylesXml(){let t=new Set,e="";for(let[i,s]of Object.entries(this.stylesConfig)){let{id:o,name:a,basedOn:l}=this.getDocxStyleInfo(i,s),c=this.cssToParaProps(null,o),u=this.cssToRunProps(null,o);e+=` ${l?``:""} @@ -163,7 +162,7 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants ${u} - `,e.add(o)}this.styles.forEach(i=>{if(!e.has(i.id)){let s=i.computed,o=this.cssToParaProps(s,i.id),a=this.cssToRunProps(s,i.id);n+=` + `,t.add(o)}this.styles.forEach(i=>{if(!t.has(i.id)){let s=i.computed,o=this.cssToParaProps(s,i.id),a=this.cssToRunProps(s,i.id);e+=` ${i.basedOn?``:""} @@ -173,7 +172,7 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants ${a} - `,e.add(i.id)}});let r=` + `,t.add(i.id)}});let r=` @@ -198,14 +197,14 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants - ${n} + ${e} ${r} -`}createDocumentXml(){let e=this.paragraphs.map(s=>this.createParagraphXml(s)).join(""),n=12240,r=15840;this.pageSize.width==="A4"?(n=11906,r=16838):this.pageSize.width==="Legal"&&(n=12240,r=20160);let i={top:Math.round(this.margins.top*1440),bottom:Math.round(this.margins.bottom*1440),left:Math.round(this.margins.left*1440),right:Math.round(this.margins.right*1440)};return` +`}createDocumentXml(){let t=this.paragraphs.map(s=>this.createParagraphXml(s)).join(""),e=12240,r=15840;this.pageSize.width==="A4"?(e=11906,r=16838):this.pageSize.width==="Legal"&&(e=12240,r=20160);let i={top:Math.round(this.margins.top*1440),bottom:Math.round(this.margins.bottom*1440),left:Math.round(this.margins.left*1440),right:Math.round(this.margins.right*1440)};return` - ${e} + ${t} - + @@ -217,29 +216,29 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants - ${Object.entries(this.footnotes).map(([n,r])=>{let i=this.footnoteIdMap.get(n),o=(r.paragraphs||(Array.isArray(r)?r:[r])).map((a,l)=>{let c={...a,styleId:"FootnoteText"};if(l===0){let u=` + ${Object.entries(this.footnotes).map(([e,r])=>{let i=this.footnoteIdMap.get(e),o=(r.paragraphs||(Array.isArray(r)?r:[r])).map((a,l)=>{let c={...a,styleId:"FootnoteText"};if(l===0){let u=` ${this.cssToParaProps(a.computed,"FootnoteText")} - `,d=' ',f=a.runs.map(h=>this.createRunXml(h,"FootnoteText")).join("");return`${u}${d}${f}`}return this.createParagraphXml(c)}).join("");return`${o}`}).join("")} + `,h=' ',d=a.runs.map(f=>this.createRunXml(f,"FootnoteText")).join("");return`${u}${h}${d}`}return this.createParagraphXml(c)}).join("");return`${o}`}).join("")} `}createCommentsXml(){return` - ${Object.entries(this.comments).map(([n,r])=>{let i=this.commentIdMap.get(n),s=r[0]||{},o=s.author||"Author",a=s.date||new Date().toISOString(),l=r.map(c=>c.content.content.map(d=>{let f=[];return d.content&&d.content.forEach(h=>{h.type==="text"&&f.push(`${this.escapeXml(h.text)}`)}),`${f.join("")}`}).join("")).join("---");return` + ${Object.entries(this.comments).map(([e,r])=>{let i=this.commentIdMap.get(e),s=r[0]||{},o=s.author||"Author",a=s.date||new Date().toISOString(),l=r.map(c=>c.content.content.map(h=>{let d=[];return h.content&&h.content.forEach(f=>{f.type==="text"&&d.push(`${this.escapeXml(f.text)}`)}),`${d.join("")}`}).join("")).join("---");return` ${l} `}).join("")} -`}createParagraphXml(e){let n=` +`}createParagraphXml(t){let e=` - - ${this.cssToParaProps(e.computed,e.styleId)} - `,r=e.runs.map(i=>this.createRunXml(i,e.styleId)).join("");return`${n}${r}`}createRunXml(e,n){if(e.type==="footnoteMarker"){let o=this.footnoteIdMap.get(e.attrs.id),a=o!==void 0?o:e.attrs.id;return``}let r=` + + ${this.cssToParaProps(t.computed,t.styleId)} + `,r=t.runs.map(i=>this.createRunXml(i,t.styleId)).join("");return`${e}${r}`}createRunXml(t,e){if(t.type==="footnoteMarker"){let o=this.footnoteIdMap.get(t.attrs.id),a=o!==void 0?o:t.attrs.id;return``}let r=` - ${this.cssToRunProps(e.style,n)} - ${this.marksToRunProps(e.marks)} - `,i="",s=e.marks?.find(o=>o.type==="commentHighlight");if(s){let o=this.commentIdMap.get(s.attrs.threadId);if(o!==void 0)return i+=``,i+=`${r}${this.escapeXml(e.text)}`,i+=``,i+=``,i}return`${r}${this.escapeXml(e.text)}`}getDocxStyleInfo(e,n){let r=e,i=n.name||e,s="Normal";if(e==="body")r="Normal",i="Normal",s=null;else if(e==="title")r="Title",i="Title",s="Normal";else if(e==="subtitle")r="Subtitle",i="Subtitle",s="Title";else if(e.startsWith("heading-")){let o=e.replace("heading-","");r=`Heading${o}`,i=`Heading ${o}`,s="Normal"}else e==="footnote"?(r="FootnoteText",i="Footnote Text",s="Normal"):e==="footnote-symbol"&&(r="FootnoteSymbol",i="Footnote Symbol",s="DefaultParagraphFont");return{id:r,name:i,basedOn:s}}cssToParaProps(e,n){let r=null;n==="Normal"?r="body":n==="Title"?r="title":n==="Subtitle"?r="subtitle":n==="FootnoteText"?r="footnote":n==="FootnoteSymbol"?r="footnote-symbol":n&&n.startsWith("Heading")?r=`heading-${n.replace("Heading","")}`:r=n;let i=r?this.stylesConfig[r]:null,s="left";i&&i["text-align"]?s=i["text-align"]:e&&e.textAlign&&(e.textAlign==="center"&&(s="center"),e.textAlign==="right"&&(s="right"),e.textAlign==="justify"&&(s="both"));let o=0,a=0,l=240,c="auto";if(i&&i["before-block"]?o=this.parseUnit(i["before-block"],"twips"):e&&(o=this.parseUnit(e.marginTop,"twips")),i&&i["after-block"]?a=this.parseUnit(i["after-block"],"twips"):e&&(a=this.parseUnit(e.marginBottom,"twips")),i&&i["line-spacing"]){let h=i["line-spacing"];String(h).match(/^[0-9.]+$/)?(l=Math.round(parseFloat(h)*240*this.scale),c="auto"):(l=Math.round(this.parseUnit(h,"twips")*this.scale),c="exact")}else e&&e.lineHeight!=="normal"&&(e.lineHeight.endsWith("px")?(l=Math.round(this.parseUnit(e.lineHeight,"twips")*this.scale),c="exact"):isNaN(parseFloat(e.lineHeight))||(l=Math.round(parseFloat(e.lineHeight)*240*this.scale)));let u=0,d=0,f=0;return i&&i["left-indent"]?u=this.parseUnit(i["left-indent"],"twips"):e&&(u=this.parseUnit(e.marginLeft,"twips")+this.parseUnit(e.paddingLeft,"twips")),i&&i["right-indent"]?d=this.parseUnit(i["right-indent"],"twips"):e&&(d=this.parseUnit(e.marginRight,"twips")+this.parseUnit(e.paddingRight,"twips")),i&&i["first-indent"]?f=this.parseUnit(i["first-indent"],"twips"):e&&(f=this.parseUnit(e.textIndent,"twips")),` + ${this.cssToRunProps(t.style,e)} + ${this.marksToRunProps(t.marks)} + `,i="",s=t.marks?.find(o=>o.type==="commentHighlight");if(s){let o=this.commentIdMap.get(s.attrs.threadId);if(o!==void 0)return i+=``,i+=`${r}${this.escapeXml(t.text)}`,i+=``,i+=``,i}return`${r}${this.escapeXml(t.text)}`}getDocxStyleInfo(t,e){let r=t,i=e.name||t,s="Normal";if(t==="body")r="Normal",i="Normal",s=null;else if(t==="title")r="Title",i="Title",s="Normal";else if(t==="subtitle")r="Subtitle",i="Subtitle",s="Title";else if(t.startsWith("heading-")){let o=t.replace("heading-","");r=`Heading${o}`,i=`Heading ${o}`,s="Normal"}else t==="footnote"?(r="FootnoteText",i="Footnote Text",s="Normal"):t==="footnote-symbol"&&(r="FootnoteSymbol",i="Footnote Symbol",s="DefaultParagraphFont");return{id:r,name:i,basedOn:s}}cssToParaProps(t,e){let r=null;e==="Normal"?r="body":e==="Title"?r="title":e==="Subtitle"?r="subtitle":e==="FootnoteText"?r="footnote":e==="FootnoteSymbol"?r="footnote-symbol":e&&e.startsWith("Heading")?r=`heading-${e.replace("Heading","")}`:r=e;let i=r?this.stylesConfig[r]:null,s="left";i&&i["text-align"]?s=i["text-align"]:t&&t.textAlign&&(t.textAlign==="center"&&(s="center"),t.textAlign==="right"&&(s="right"),t.textAlign==="justify"&&(s="both"));let o=0,a=0,l=240,c="auto";if(i&&i["before-block"]?o=this.parseUnit(i["before-block"],"twips"):t&&(o=this.parseUnit(t.marginTop,"twips")),i&&i["after-block"]?a=this.parseUnit(i["after-block"],"twips"):t&&(a=this.parseUnit(t.marginBottom,"twips")),i&&i["line-spacing"]){let f=i["line-spacing"];String(f).match(/^[0-9.]+$/)?(l=Math.round(parseFloat(f)*240*this.scale),c="auto"):(l=Math.round(this.parseUnit(f,"twips")*this.scale),c="exact")}else t&&t.lineHeight!=="normal"&&(t.lineHeight.endsWith("px")?(l=Math.round(this.parseUnit(t.lineHeight,"twips")*this.scale),c="exact"):isNaN(parseFloat(t.lineHeight))||(l=Math.round(parseFloat(t.lineHeight)*240*this.scale)));let u=0,h=0,d=0;return i&&i["left-indent"]?u=this.parseUnit(i["left-indent"],"twips"):t&&(u=this.parseUnit(t.marginLeft,"twips")+this.parseUnit(t.paddingLeft,"twips")),i&&i["right-indent"]?h=this.parseUnit(i["right-indent"],"twips"):t&&(h=this.parseUnit(t.marginRight,"twips")+this.parseUnit(t.paddingRight,"twips")),i&&i["first-indent"]?d=this.parseUnit(i["first-indent"],"twips"):t&&(d=this.parseUnit(t.textIndent,"twips")),` - - `}cssToRunProps(e,n){let r=null;n==="Normal"?r="body":n==="Title"?r="title":n==="Subtitle"?r="subtitle":n==="FootnoteText"?r="footnote":n==="FootnoteSymbol"?r="footnote-symbol":n&&n.startsWith("Heading")?r=`heading-${n.replace("Heading","")}`:r=n;let i=r?this.stylesConfig[r]:null,s="Times New Roman";i&&i["font-family"]?s=Ea(i["font-family"]):e&&e.fontFamily&&(s=Ea(e.fontFamily));let o=24;i&&i["font-size"]?o=Math.round(this.parseUnit(i["font-size"],"half-points")*this.scale):e&&e.fontSize&&(o=Math.round(this.parseUnit(e.fontSize,"half-points")*this.scale));let a="auto",l="",c="",u="",d="",f="",h="";return i?(i["font-weight"]==="bold"&&(l=""),(i["font-variant"]==="italic"||i["font-style"]==="italic")&&(c=""),i["text-decoration"]==="underline"&&(u=''),i["text-decoration"]==="line-through"&&(d=""),(i["font-variant"]==="small-caps"||i.capitalization==="small-caps")&&(f=""),i["vertical-align"]==="super"&&(h=''),i["vertical-align"]==="sub"&&(h='')):e&&((e.fontWeight==="bold"||parseInt(e.fontWeight)>=700)&&(l=""),e.fontStyle==="italic"&&(c=""),e.textDecorationLine?.includes("underline")&&(u=''),e.textDecorationLine?.includes("line-through")&&(d=""),e.fontVariant==="small-caps"&&(f=""),e.verticalAlign==="super"&&(h=''),e.verticalAlign==="sub"&&(h='')),` + + `}cssToRunProps(t,e){let r=null;e==="Normal"?r="body":e==="Title"?r="title":e==="Subtitle"?r="subtitle":e==="FootnoteText"?r="footnote":e==="FootnoteSymbol"?r="footnote-symbol":e&&e.startsWith("Heading")?r=`heading-${e.replace("Heading","")}`:r=e;let i=r?this.stylesConfig[r]:null,s="Times New Roman";i&&i["font-family"]?s=Ei(i["font-family"]):t&&t.fontFamily&&(s=Ei(t.fontFamily));let o=24;i&&i["font-size"]?o=Math.round(this.parseUnit(i["font-size"],"half-points")*this.scale):t&&t.fontSize&&(o=Math.round(this.parseUnit(t.fontSize,"half-points")*this.scale));let a="auto",l="",c="",u="",h="",d="",f="";return i?(i["font-weight"]==="bold"&&(l=""),(i["font-variant"]==="italic"||i["font-style"]==="italic")&&(c=""),i["text-decoration"]==="underline"&&(u=''),i["text-decoration"]==="line-through"&&(h=""),(i["font-variant"]==="small-caps"||i.capitalization==="small-caps")&&(d=""),i["vertical-align"]==="super"&&(f=''),i["vertical-align"]==="sub"&&(f='')):t&&((t.fontWeight==="bold"||parseInt(t.fontWeight)>=700)&&(l=""),t.fontStyle==="italic"&&(c=""),t.textDecorationLine?.includes("underline")&&(u=''),t.textDecorationLine?.includes("line-through")&&(h=""),t.fontVariant==="small-caps"&&(d=""),t.verticalAlign==="super"&&(f=''),t.verticalAlign==="sub"&&(f='')),` @@ -247,82 +246,82 @@ ${p}`}}),l}function dC(t,e,n={}){let{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants ${l} ${c} ${u} + ${h} ${d} ${f} - ${h} - `}marksToRunProps(e){if(!e)return"";let n="";return e.forEach(r=>{r.type==="bold"&&(n+=""),r.type==="italic"&&(n+=""),r.type==="underline"&&(n+=''),r.type==="strike"&&(n+=""),r.type==="superscript"&&(n+=''),r.type==="subscript"&&(n+=''),r.type==="smallCaps"&&(n+="")}),n}escapeXml(e){return e==null?"":String(e).replace(/[<>&'"]/g,function(n){switch(n){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case'"':return"""}})}parseUnit(e,n="twips"){if(!e)return 0;let r=String(e).trim(),i=parseFloat(r);if(isNaN(i))return 0;let s=0;return r.endsWith("pt")?s=i:r.endsWith("in")?s=i*72:r.endsWith("mm")?s=i*2.835:r.endsWith("cm")?s=i*28.35:r.endsWith("px")?s=i*.75:r.endsWith("pc")?s=i*12:s=i,Math.round(n==="twips"?s*20:s*2)}};function Ea(t){return t?(typeof window<"u"&&typeof document<"u"&&t.includes("var(")&&(t=t.replace(/var\((--[^)]+)\)/g,(r,i)=>getComputedStyle(document.body).getPropertyValue(i).trim()||"")),t.split(",").map(r=>r.trim().replace(/['"]/g,"")).find(r=>r&&r!=="??"&&r.toLowerCase()!=="undefined"&&r!=="")||"Times New Roman"):"Times New Roman"}var Gr=require("obsidian"),$v=window.electron,x_=require("fs").promises,Hv=B.create({name:"docxSerializer",addCommands(){return{exportToDocx:t=>async({editor:e,view:n})=>{let{settings:r,footnotes:i,comments:s,stylesConfig:o}=t;try{new Gr.Notice("Preparing DOCX export...");let{paragraphs:a,styles:l,fonts:c}=k_(e.view,e.state.doc,o),u=S_(e.view,i,o),f=await new Ca({paragraphs:a,styles:l,fonts:c,footnotes:u,comments:s,pageSize:r.pageSize,margins:r.margins,scale:r.scale,stylesConfig:o}).generate(),p=(e.options.adapter?.view?.file?.basename||"Untitled")+".docx";if(!$v)return new Gr.Notice("Desktop required for DOCX export."),!1;let m=await $v.remote.dialog.showSaveDialog({title:"Export to Word (.docx)",defaultPath:p,filters:[{name:"Word Document",extensions:["docx"]}]});return m.canceled||!m.filePath?(new Gr.Notice("Export cancelled."),!0):(await x_.writeFile(m.filePath,f),new Gr.Notice("File saved successfully!"),!0)}catch(a){return console.error("DOCX Export Error:",a),new Gr.Notice(`Export failed: ${a.message}`),!1}}}}});function k_(t,e,n){let r=[],i=new Map,s=new Set(["Times New Roman","Arial","Symbol"]);return e.descendants((o,a)=>{if(o.isText)return!1;if(o.isBlock&&o.type.name!=="doc"){let c=t.nodeDOM(a),u=c&&c instanceof Element?getComputedStyle(c):{},d=C_(i,u,o.type.name,o.attrs,n);if(u.fontFamily){let h=Ea(u.fontFamily);h&&s.add(h)}let f=[];return o.content.forEach(h=>{let p=h.marks?h.marks.map(m=>({type:m.type.name,attrs:m.attrs})):[];if(h.type.name==="internalLink"){let m=h.attrs.alias||h.attrs.target||"Link";f.push({text:m,style:{},marks:[...p,{type:"bold"}],type:"text",attrs:{}});return}h.isText?f.push({text:h.text||"",style:{},marks:p,type:"text",attrs:{}}):h.type.name==="footnoteMarker"&&f.push({text:"",style:{},marks:[],type:"footnoteMarker",attrs:h.attrs})}),r.push({type:o.type.name,styleId:d,computed:u,runs:f,attrs:o.attrs}),!1}return!0}),{paragraphs:r,styles:Array.from(i.values()),fonts:Array.from(s)}}function S_(t,e,n){let r={};if(!e)return r;for(let[i,s]of Object.entries(e)){let o=[];s.content.forEach(a=>{let l="FootnoteText",c=[];a.content&&Array.isArray(a.content)&&a.content.forEach(u=>{u.type==="text"?c.push({text:u.text||"",style:{},marks:u.marks?u.marks.map(d=>({type:d.type.name,attrs:d.attrs})):[],type:"text",attrs:{}}):u.type==="internalLink"&&c.push({text:u.attrs.alias||u.attrs.target||"Link",style:{},marks:[{type:"bold"}],type:"text",attrs:{}})}),o.push({type:a.type,styleId:l,computed:{},runs:c,attrs:a.attrs||{}})}),r[i]={paragraphs:o}}return r}function C_(t,e,n,r,i){let s="Normal",o="Normal",a=null;if(n==="body"||n==="body-first")s="Normal",o="Normal";else if(n==="title")s="Title",o="Title",a="Normal";else if(n==="subtitle")s="Subtitle",o="Subtitle",a="Title";else if(n.startsWith("heading-")){let l=n.replace("heading-","");s=`Heading${l}`,o=`Heading ${l}`,a="Normal"}else n==="footnote"?(s="FootnoteText",o="Footnote Text",a="Normal"):i&&i[n]&&(s=n,o=i[n].name||n,a="Normal");return t.has(s)||t.set(s,{id:s,name:o,type:"paragraph",basedOn:a,computed:e}),s}var Yr=require("obsidian"),Vv=typeof window<"u"?window.electron:null,E_=require("fs").promises,Uv=B.create({name:"fountainSerializer",addCommands(){return{exportToFountain:()=>async({editor:t})=>{try{new Yr.Notice("Preparing Fountain export...");let e=T_(t.state.doc),r=(t.options.adapter?.view?.file?.basename||"Untitled")+".fountain";if(!Vv)return new Yr.Notice("Desktop required for direct file dialog output."),!1;let i=await Vv.remote.dialog.showSaveDialog({title:"Export to Fountain (.fountain)",defaultPath:r,filters:[{name:"Fountain Document",extensions:["fountain"]}]});return i.canceled||!i.filePath?(new Yr.Notice("Export cancelled."),!0):(await E_.writeFile(i.filePath,e),new Yr.Notice("Fountain file saved successfully!"),!0)}catch(e){return console.error("Fountain Export Error:",e),new Yr.Notice(`Export failed: ${e.message}`),!1}}}}});function T_(t){let e="";return t.descendants((n,r)=>{if(n.isText)return!1;if(n.isBlock&&n.type.name!=="doc"){let s="";n.content.forEach(a=>{if(a.isText){let l=a.text||"";if(a.marks){let c=a.marks.some(f=>f.type.name==="bold"),u=a.marks.some(f=>f.type.name==="italic"),d=a.marks.some(f=>f.type.name==="underline");c&&(l=`**${l}**`),u&&(l=`*${l}*`),d&&(l=`_${l}_`)}s+=l}});let o=n.type.name;return o==="script-scene"?(s=s.toUpperCase(),["INT.","EXT.","INT/","I/E","EST."].some(c=>s.startsWith(c))||(s="."+s),e+=s+` + `}marksToRunProps(t){if(!t)return"";let e="";return t.forEach(r=>{r.type==="bold"&&(e+=""),r.type==="italic"&&(e+=""),r.type==="underline"&&(e+=''),r.type==="strike"&&(e+=""),r.type==="superscript"&&(e+=''),r.type==="subscript"&&(e+=''),r.type==="smallCaps"&&(e+="")}),e}escapeXml(t){return t==null?"":String(t).replace(/[<>&'"]/g,function(e){switch(e){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case'"':return"""}})}parseUnit(t,e="twips"){if(!t)return 0;let r=String(t).trim(),i=parseFloat(r);if(isNaN(i))return 0;let s=0;return r.endsWith("pt")?s=i:r.endsWith("in")?s=i*72:r.endsWith("mm")?s=i*2.835:r.endsWith("cm")?s=i*28.35:r.endsWith("px")?s=i*.75:r.endsWith("pc")?s=i*12:s=i,Math.round(e==="twips"?s*20:s*2)}};function Ei(n){return n?(typeof window<"u"&&typeof document<"u"&&n.includes("var(")&&(n=n.replace(/var\((--[^)]+)\)/g,(r,i)=>getComputedStyle(document.body).getPropertyValue(i).trim()||"")),n.split(",").map(r=>r.trim().replace(/['"]/g,"")).find(r=>r&&r!=="??"&&r.toLowerCase()!=="undefined"&&r!=="")||"Times New Roman"):"Times New Roman"}var wn=require("obsidian"),vd=window.electron,F0=require("fs").promises,wd=L.create({name:"docxSerializer",addCommands(){return{exportToDocx:n=>async({editor:t,view:e})=>{let{settings:r,footnotes:i,comments:s,stylesConfig:o}=n;try{new wn.Notice("Preparing DOCX export...");let{paragraphs:a,styles:l,fonts:c}=$0(t.view,t.state.doc,o),u=H0(t.view,i,o),d=await new Ci({paragraphs:a,styles:l,fonts:c,footnotes:u,comments:s,pageSize:r.pageSize,margins:r.margins,scale:r.scale,stylesConfig:o}).generate(),p=(t.options.adapter?.view?.file?.basename||"Untitled")+".docx";if(!vd)return new wn.Notice("Desktop required for DOCX export."),!1;let m=await vd.remote.dialog.showSaveDialog({title:"Export to Word (.docx)",defaultPath:p,filters:[{name:"Word Document",extensions:["docx"]}]});return m.canceled||!m.filePath?(new wn.Notice("Export cancelled."),!0):(await F0.writeFile(m.filePath,d),new wn.Notice("File saved successfully!"),!0)}catch(a){return console.error("DOCX Export Error:",a),new wn.Notice(`Export failed: ${a.message}`),!1}}}}});function $0(n,t,e){let r=[],i=new Map,s=new Set(["Times New Roman","Arial","Symbol"]);return t.descendants((o,a)=>{if(o.isText)return!1;if(o.isBlock&&o.type.name!=="doc"){let c=n.nodeDOM(a),u=c&&c instanceof Element?getComputedStyle(c):{},h=V0(i,u,o.type.name,o.attrs,e);if(u.fontFamily){let f=Ei(u.fontFamily);f&&s.add(f)}let d=[];return o.content.forEach(f=>{let p=f.marks?f.marks.map(m=>({type:m.type.name,attrs:m.attrs})):[];if(f.type.name==="internalLink"){let m=f.attrs.alias||f.attrs.target||"Link";d.push({text:m,style:{},marks:[...p,{type:"bold"}],type:"text",attrs:{}});return}f.isText?d.push({text:f.text||"",style:{},marks:p,type:"text",attrs:{}}):f.type.name==="footnoteMarker"&&d.push({text:"",style:{},marks:[],type:"footnoteMarker",attrs:f.attrs})}),r.push({type:o.type.name,styleId:h,computed:u,runs:d,attrs:o.attrs}),!1}return!0}),{paragraphs:r,styles:Array.from(i.values()),fonts:Array.from(s)}}function H0(n,t,e){let r={};if(!t)return r;for(let[i,s]of Object.entries(t)){let o=[];s.content.forEach(a=>{let l="FootnoteText",c=[];a.content&&Array.isArray(a.content)&&a.content.forEach(u=>{u.type==="text"?c.push({text:u.text||"",style:{},marks:u.marks?u.marks.map(h=>({type:h.type.name,attrs:h.attrs})):[],type:"text",attrs:{}}):u.type==="internalLink"&&c.push({text:u.attrs.alias||u.attrs.target||"Link",style:{},marks:[{type:"bold"}],type:"text",attrs:{}})}),o.push({type:a.type,styleId:l,computed:{},runs:c,attrs:a.attrs||{}})}),r[i]={paragraphs:o}}return r}function V0(n,t,e,r,i){let s="Normal",o="Normal",a=null;if(e==="body"||e==="body-first")s="Normal",o="Normal";else if(e==="title")s="Title",o="Title",a="Normal";else if(e==="subtitle")s="Subtitle",o="Subtitle",a="Title";else if(e.startsWith("heading-")){let l=e.replace("heading-","");s=`Heading${l}`,o=`Heading ${l}`,a="Normal"}else e==="footnote"?(s="FootnoteText",o="Footnote Text",a="Normal"):i&&i[e]&&(s=e,o=i[e].name||e,a="Normal");return n.has(s)||n.set(s,{id:s,name:o,type:"paragraph",basedOn:a,computed:t}),s}var kn=require("obsidian"),kd=typeof window<"u"?window.electron:null,W0=require("fs").promises,xd=L.create({name:"fountainSerializer",addCommands(){return{exportToFountain:()=>async({editor:n})=>{try{new kn.Notice("Preparing Fountain export...");let t=U0(n.state.doc),r=(n.options.adapter?.view?.file?.basename||"Untitled")+".fountain";if(!kd)return new kn.Notice("Desktop required for direct file dialog output."),!1;let i=await kd.remote.dialog.showSaveDialog({title:"Export to Fountain (.fountain)",defaultPath:r,filters:[{name:"Fountain Document",extensions:["fountain"]}]});return i.canceled||!i.filePath?(new kn.Notice("Export cancelled."),!0):(await W0.writeFile(i.filePath,t),new kn.Notice("Fountain file saved successfully!"),!0)}catch(t){return console.error("Fountain Export Error:",t),new kn.Notice(`Export failed: ${t.message}`),!1}}}}});function U0(n){let t="";return n.descendants((e,r)=>{if(e.isText)return!1;if(e.isBlock&&e.type.name!=="doc"){let s="";e.content.forEach(a=>{if(a.isText){let l=a.text||"";if(a.marks){let c=a.marks.some(d=>d.type.name==="bold"),u=a.marks.some(d=>d.type.name==="italic"),h=a.marks.some(d=>d.type.name==="underline");c&&(l=`**${l}**`),u&&(l=`*${l}*`),h&&(l=`_${l}_`)}s+=l}});let o=e.type.name;return o==="script-scene"?(s=s.toUpperCase(),["INT.","EXT.","INT/","I/E","EST."].some(c=>s.startsWith(c))||(s="."+s),t+=s+` -`):o==="script-action"||o==="body"?e+=s+` +`):o==="script-action"||o==="body"?t+=s+` -`:o==="script-character"?(s=s.toUpperCase(),s.startsWith("@")||(s="@"+s),e+=s+` -`):o==="script-parenthetical"?(s.startsWith("(")||(s="("+s),s.endsWith(")")||(s=s+")"),e+=s+` -`):o==="script-dialogue"?e+=s+` +`:o==="script-character"?(s=s.toUpperCase(),s.startsWith("@")||(s="@"+s),t+=s+` +`):o==="script-parenthetical"?(s.startsWith("(")||(s="("+s),s.endsWith(")")||(s=s+")"),t+=s+` +`):o==="script-dialogue"?t+=s+` -`:o==="script-transition"?(s=s.toUpperCase(),s.startsWith(">")||(s="> "+s),e+=s+` +`:o==="script-transition"?(s=s.toUpperCase(),s.startsWith(">")||(s="> "+s),t+=s+` -`):s.trim().length>0&&(e+=s+` +`):s.trim().length>0&&(t+=s+` -`),!1}return!0}),e.trim()}var ef=(t,e)=>{let{query:n}=e.storage,{caseSensitive:r,disableRegex:i,wholeWord:s}=e.options,o=[];if(!n)return e.storage.results=[],e.storage.activeIndex=-1,o;let a;try{if(i){let l=n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");s&&(l=`\\b${l}\\b`),a=new RegExp(l,r?"g":"gi")}else a=new RegExp(n,r?"g":"gi")}catch{return e.storage.results=[],e.storage.activeIndex=-1,o}return t.doc.descendants((l,c)=>{if(l.isText){let u=l.text,d;for(;(d=a.exec(u))!==null;)o.push({from:c+d.index,to:c+d.index+d[0].length})}}),e.storage.results=o,o.length===0?e.storage.activeIndex=-1:(e.storage.activeIndex===-1||e.storage.activeIndex>=o.length)&&(e.storage.activeIndex=0),o},Wv=(t,e)=>{if(t.isDestroyed)return;let{activeIndex:n,results:r}=e.storage;if(n===-1||r.length===0)return;let{from:i,to:s}=r[n];t.commands.setTextSelection({from:i,to:s}),t.commands.scrollIntoView()},jv=B.create({name:"search",addOptions(){return{searchResultClass:"colophon-search-result",activeSearchResultClass:"colophon-search-result-active",caseSensitive:!1,disableRegex:!0,wholeWord:!1}},addStorage(){return{query:"",results:[],activeIndex:-1}},addCommands(){return{setSearchQuery:t=>({state:e,dispatch:n})=>(this.storage.query=t,ef(e,this),n&&n(e.tr.setMeta("search-update",!0)),!0),setSearchOptions:t=>({state:e,dispatch:n})=>(Object.assign(this.options,t),ef(e,this),n&&n(e.tr.setMeta("search-update",!0)),!0),nextSearchResult:()=>({editor:t,state:e,dispatch:n})=>this.storage.results.length===0?!1:(this.storage.activeIndex=(this.storage.activeIndex+1)%this.storage.results.length,n&&(n(e.tr.setMeta("search-update",!0)),setTimeout(()=>Wv(t,this),0)),!0),previousSearchResult:()=>({editor:t,state:e,dispatch:n})=>this.storage.results.length===0?!1:(this.storage.activeIndex=(this.storage.activeIndex-1+this.storage.results.length)%this.storage.results.length,n&&(n(e.tr.setMeta("search-update",!0)),setTimeout(()=>Wv(t,this),0)),!0),replace:t=>({state:e,dispatch:n})=>{let{activeIndex:r,results:i}=this.storage;if(r===-1||i.length===0)return!1;let{from:s,to:o}=i[r];return n&&n(e.tr.replaceWith(s,o,e.schema.text(t))),!0},replaceAll:t=>({state:e,dispatch:n})=>{let{results:r}=this.storage;if(r.length===0)return!1;if(n){let i=e.tr;[...r].reverse().forEach(({from:s,to:o})=>{i=i.replaceWith(s,o,e.schema.text(t))}),n(i)}return!0}}},onUpdate({editor:t,transaction:e}){e&&e.getMeta("search-update")||e&&(e.docChanged||e.getMeta("search-options-changed"))&&setTimeout(()=>{t.isDestroyed||(ef(t.state,this),t.view.dispatch(t.state.tr.setMeta("search-update",!0)))},0)},addKeyboardShortcuts(){return{"Mod-f":()=>{let t=this.editor.options.adapter?.view;return t&&t.findReplaceBar?(t.findReplaceBar.open(),!0):!1},"Mod-Alt-f":()=>{let t=this.editor.options.adapter?.view;return t&&t.findReplaceBar?(t.findReplaceBar.openReplace(),!0):!1},"Mod-g":()=>this.editor.commands.nextSearchResult(),"Mod-Shift-g":()=>this.editor.commands.previousSearchResult()}},addProseMirrorPlugins(){let t=this;return[new R({key:new F("search"),props:{decorations(e){let{results:n,activeIndex:r}=t.storage,i=n.map((s,o)=>{let a=o===r?`${t.options.searchResultClass} ${t.options.activeSearchResultClass}`:t.options.searchResultClass;return ye.inline(s.from,s.to,{class:a})});return ee.create(e.doc,i)}}})]}});var L2=require("obsidian"),tr=class{constructor(e,n,r){this.app=e,this.plugin=n,this.editor=r,this.suggestionEl=null,this.suggestions=[],this.selectedIndex=0,this.context=null,this.setup()}setup(){this.editor.on("selectionUpdate",()=>this.onUpdate()),this.editor.on("update",()=>this.onUpdate()),this.editor.on("destroy",()=>this.close());let e=this.editor.options.editorProps?.handleKeyDown;this.editor.setOptions({editorProps:{handleKeyDown:(n,r)=>{if(this.suggestionEl){if(r.key==="ArrowDown")return this.moveSelection(1),!0;if(r.key==="ArrowUp")return this.moveSelection(-1),!0;if(r.key==="Enter"||r.key==="Tab")return this.selectCurrent(),!0;if(r.key==="Escape")return this.close(),!0}return e?e(n,r):!1}}})}onUpdate(){let{state:e}=this.editor,{selection:n}=e,{$from:r,empty:i}=n;if(!i){this.close();return}let s=r.parent.textBetween(0,r.parentOffset,null,"\0"),o=s.match(/\[\[([^\]]*)$/);if(o){this.showSuggestions(o[1],r.pos-o[1].length-2,r.pos,"wiki");return}if(this.app.vault.getConfig("useMarkdownLinks")){let l=s.match(/\[([^\]]*)$/);if(l){if(r.parent.textBetween(r.parentOffset,r.parent.content.size,null,"\0").startsWith("](")){this.close();return}this.showSuggestions(l[1],r.pos-l[1].length-1,r.pos,"md");return}}this.close()}showSuggestions(e,n,r,i){this.context={query:e,start:n,end:r,type:i};let s=e.toLowerCase().split(/\s+/).filter(l=>l.length>0),o=this.app.vault.getConfig("showUnsupportedFiles"),a=this.app.vault.getFiles().filter(l=>{if(!o&&!["md","colophon","canvas"].includes(l.extension))return!1;let c=l.path.toLowerCase(),u=l.basename.toLowerCase();return s.length===0?!0:s.every(d=>c.includes(d)||u.includes(d))}).sort((l,c)=>{let u=e.toLowerCase(),d=l.basename.toLowerCase(),f=c.basename.toLowerCase();return d===u&&f!==u?-1:f===u&&d!==u?1:d.startsWith(u)&&!f.startsWith(u)?-1:f.startsWith(u)&&!d.startsWith(u)?1:d.localeCompare(f)}).slice(0,50);if(a.length===0&&s.length>0){this.close();return}this.suggestions=a,this.render()}render(){this.suggestionEl||(this.suggestionEl=document.createElement("div"),this.suggestionEl.className="suggestion-container colophon-link-suggestions",document.body.appendChild(this.suggestionEl));let e=this.editor.view.coordsAtPos(this.context.end),n=10;this.suggestionEl.setAttribute("style","position: fixed; display: flex; visibility: hidden; top: 0px; left: 0px;"),this.suggestionEl.empty();let r=this.suggestionEl.createDiv({cls:"suggestion"});this.suggestions.forEach((h,p)=>{let m=r.createDiv({cls:`suggestion-item ${p===this.selectedIndex?"is-selected":""}`});m.createDiv({text:h.basename,cls:"suggestion-title"}),m.createDiv({text:h.path,cls:"suggestion-content"}),m.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.selectedIndex=p,this.selectCurrent()})});let i=this.suggestionEl.createDiv({cls:"prompt-instructions"}),s=i.createDiv({cls:"prompt-instruction"});s.createSpan({cls:"prompt-instruction-command",text:"Type #"}),s.appendText(" to link heading");let o=i.createDiv({cls:"prompt-instruction"});o.createSpan({cls:"prompt-instruction-command",text:"Type ^"}),o.appendText(" to link blocks");let a=i.createDiv({cls:"prompt-instruction"});a.createSpan({cls:"prompt-instruction-command",text:"Type |"}),a.appendText(" to change display text");let l=this.suggestionEl.getBoundingClientRect(),c=l.width,u=l.height,d=e.bottom+2;d+u>window.innerHeight-n&&(d=e.top-u-2);let f=e.left;f+c>window.innerWidth-n&&(f=e.right-c),f=Math.max(n,Math.min(f,window.innerWidth-c-n)),d=Math.max(n,Math.min(d,window.innerHeight-u-n)),this.suggestionEl.style.top=`${d}px`,this.suggestionEl.style.left=`${f}px`,this.suggestionEl.style.visibility="visible"}moveSelection(e){this.selectedIndex=(this.selectedIndex+e+this.suggestions.length)%this.suggestions.length,this.render()}selectCurrent(){let e=this.suggestions[this.selectedIndex];if(!e)return;let{start:n,end:r}=this.context,i=this.app.workspace.getActiveFile(),s=this.app.metadataCache.fileToLinktext(e,i?i.path:"");this.editor.chain().focus().deleteRange({from:n,to:r}).insertContent({type:"internalLink",attrs:{target:s,alias:e.basename!==s?e.basename:null}}).run(),this.close()}close(){this.suggestionEl&&(this.suggestionEl.remove(),this.suggestionEl=null),this.suggestions=[],this.selectedIndex=0,this.context=null}};var A_=B.create({name:"colophonAgentCommands",addCommands(){return{"colophon:add-link":t=>({chain:e})=>e().insertInternalLink(t).run(),"colophon:set-block-type":t=>({chain:e})=>e().setNode(t).run(),"colophon:focus-footnote":t=>({editor:e})=>(e.options.adapter&&e.options.adapter.focusNote(t),!0)}}});function qv(){return Math.random().toString(36).substring(2,8)}var Ta=class{constructor(e,{content:n,footnotes:r,comments:i,type:s,settings:o,isSpellcheckEnabled:a,onUpdate:l,app:c,plugin:u,view:d}){this.parentElement=e,this.type=s||"manuscript",this.settings=o,this.isSpellcheckEnabled=a,this.onUpdate=l,this.app=c,this.plugin=u,this.view=d,this.view&&(this.view.adapter=this),this.editor=null,this.footnotes=r||{},this.comments=i||{},this.sharedExtensions=null,this.mount(n)}repairDocument(e){if(!e||!e.content)return e;let n=new Set;for(;e.content.length>0&&e.content[0].type==="horizontalRule";)e.content.shift();let r=!1;return e.content.forEach(i=>{i.type!=="horizontalRule"&&(r=!0),i.attrs||(i.attrs={}),(!i.attrs.id||n.has(i.attrs.id))&&(i.attrs.id=qv()),n.add(i.attrs.id)}),r||e.content.push({type:this.type==="script"?"script-action":"body",attrs:{id:qv()},content:[]}),e}mount(e){let n=this.repairDocument(e);if(!this.sharedExtensions){let r=this.settings?wg(this.settings,this.type):[];this.sharedExtensions=[Zm,Xm,...r,fg,Gm,Ym,Qm,eg,tg,hg,pg,mg,gg,yg,Eg,kg,Cg,Tg.configure({node:this.type==="script"?"script-action":"body",notAfter:this.type==="script"?["script-action","script-scene","script-character","script-parenthetical","script-dialogue","script-transition"]:["body","supertitle","title","subtitle","epigraph","body-first","heading-1","heading-2","heading-3","heading-4"]}),Hv,Uv,jv,Sg.configure({trigger:this.settings?.footnoteTrigger??"(("}),A_,xg.configure({smartQuotes:this.settings?.smartQuotes??!0,smartDashes:this.settings?.smartDashes??!0,doubleQuoteStyle:this.settings?.doubleQuoteStyle??"\u201C|\u201D",singleQuoteStyle:this.settings?.singleQuoteStyle??"\u2018|\u2019"})]}this.editor=new Ii({element:this.parentElement,app:this.app,plugin:this.plugin,adapter:this,extensions:this.sharedExtensions,content:n||{type:"doc",content:[{type:this.type==="script"?"script-action":"body"}]},onUpdate:({editor:r,transaction:i})=>{this.onUpdate&&this.onUpdate(),i&&i.docChanged&&!i.getMeta("colophon-sync")&&this.checkIfResequenceNeeded(i)&&this.updateFootnoteSequence()},onSelectionUpdate:({editor:r})=>{this.view&&this.view.updateActiveEditor(r),this.handleScroll()},onFocus:({editor:r})=>{this.view&&this.view.updateActiveEditor(r),this.plugin&&this.plugin.setActiveEditor(r),this.handleScroll()},editorProps:{handleClick:(r,i,s)=>{let{schema:o,doc:a}=r.state,l=o.marks.commentHighlight;if(!l)return!1;let u=a.resolve(i).marks().find(d=>d.type===l);return u&&u.attrs.threadId?(this.focusComment(u.attrs.threadId),!0):!1},attributes:{class:`colophon-editor colophon-main-editor type-${this.type} is-${this.type}-mode`,spellcheck:this.isSpellcheckEnabled?"true":"false"}}}),this.app&&this.plugin&&(this.linkSuggest=new tr(this.app,this.plugin,this.editor)),this.editor.view.dom.addEventListener("beforeinput",r=>{let i={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};i[r.inputType]&&(r.preventDefault(),this.editor.chain().focus()[i[r.inputType]]().run())}),this.handleScroll(),this.updateFootnoteSequence(),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible&&this.view.zAxisPanel.debouncedUpdate()}setContent(e,n,r){if(this.editor){this.footnotes=n||{},this.comments=r||{};let i=this.repairDocument(e);this.editor.commands.setContent(i),this.updateFootnoteSequence(),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible&&this.view.zAxisPanel.debouncedUpdate()}}getJSON(){return this.editor?this.editor.getJSON():null}getWordCount(){if(!this.editor)return{doc:0,total:0};let n=this.editor.state.doc.textContent.split(/\s+/).filter(i=>i.length>0).length,r=0;if(this.footnotes)for(let i of Object.values(this.footnotes))r+=this.countWordsInNode(i);return{doc:n,total:n+r}}countWordsInNode(e){if(!e)return 0;let n=0;return e.text&&(n+=e.text.split(/\s+/).filter(r=>r.length>0).length),e.content&&Array.isArray(e.content)&&e.content.forEach(r=>{n+=this.countWordsInNode(r)}),n}focus(){this.editor&&this.editor.commands.focus()}toggleBold(){this.editor&&this.editor.chain().focus().toggleBold().run()}toggleItalic(){this.editor&&this.editor.chain().focus().toggleItalic().run()}toggleStrike(){this.editor&&this.editor.chain().focus().toggleStrike().run()}toggleUnderline(){this.editor&&this.editor.chain().focus().toggleUnderline().run()}toggleSuperscript(){this.editor&&this.editor.chain().focus().toggleSuperscript().unsetSubscript().run()}toggleSubscript(){this.editor&&this.editor.chain().focus().toggleSubscript().unsetSuperscript().run()}toggleSmallCaps(){this.editor&&this.editor.chain().focus().toggleSmallCaps().run()}addLink({target:e,alias:n}){this.editor&&this.editor.commands["colophon:add-link"]({target:e,alias:n})}setBlockType(e){this.editor&&this.editor.commands["colophon:set-block-type"](e)}updateSettings(e){if(!this.editor){this.settings=e;return}let n=Object.keys(this.settings.blocks).sort().join(","),r=Object.keys(e.blocks).sort().join(","),i=JSON.stringify(Object.values(this.settings.blocks).map(a=>({t:a["syntax-trigger"],f:a["following-entity"]||a["following-block"]}))),s=JSON.stringify(Object.values(e.blocks).map(a=>({t:a["syntax-trigger"],f:a["following-entity"]||a["following-block"]}))),o=n!==r||i!==s||this.settings.footnoteTrigger!==e.footnoteTrigger;if(this.settings=e,o){let a=this.getJSON(),l=this.footnotes;this.sharedExtensions=null,this.destroy(),this.mount(a),this.footnotes=l,this.focus();return}this.editor.setOptions("substitutions",{smartQuotes:e.smartQuotes,smartDashes:e.smartDashes,doubleQuoteStyle:e.doubleQuoteStyle,singleQuoteStyle:e.singleQuoteStyle}),this.handleScroll()}handleScroll(){!this.editor||!this.settings||!this.settings.fixedFeedPosition||requestAnimationFrame(()=>{let e=this.parentElement;if(!e||!this.editor.view||!this.editor.view.dom)return;let n=this.editor.state.selection;if(!n)return;let r=this.editor.view,i=e.getBoundingClientRect(),o=1-(this.settings.feedPadding??40)/100,a=i.height*o,l=i.top+a,d=r.coordsAtPos(n.from).bottom-l;Math.abs(d)>2&&e.scrollBy({top:d,behavior:"auto"})})}destroy(){this.linkSuggest&&(this.linkSuggest.close(),this.linkSuggest=null),this.editor&&(this.plugin&&this.plugin.activeTiptapEditor===this.editor&&this.plugin.setActiveEditor(null),this.editor.destroy(),this.editor=null)}getActiveFootnoteIds(){let e=new Set;return this.editor&&this.editor.state.doc.descendants(n=>{n.type.name==="footnoteMarker"&&e.add(n.attrs.id)}),e}getActiveCommentThreadIds(){let e=new Set;if(!this.editor)return e;if(this.editor.state.doc.descendants(n=>{n.marks&&n.marks.forEach(r=>{r.type.name==="commentHighlight"&&r.attrs.threadId&&e.add(r.attrs.threadId)})}),this.footnotes)for(let n of Object.values(this.footnotes))this.scanForThreadIds(n,e);return e}scanForThreadIds(e,n){e&&(e.marks&&e.marks.forEach(r=>{r.type.name==="commentHighlight"&&r.attrs.threadId&&n.add(r.attrs.threadId)}),e.content&&Array.isArray(e.content)&&e.content.forEach(r=>this.scanForThreadIds(r,n)))}getFootnotes(){let e=[];return this.editor?(this.editor.state.doc.descendants((n,r)=>{n.type.name==="footnoteMarker"&&e.push({id:n.attrs.id,number:n.attrs.number,pos:r})}),e.map(n=>({id:n.id,number:n.number,content:this.footnotes[n.id]||{type:"doc",content:[{type:"body"}]}}))):[]}updateFootnote(e,n){let r=JSON.stringify(this.footnotes[e]),i=JSON.stringify(n);r!==i&&(this.footnotes[e]=n,this.onUpdate&&this.onUpdate())}checkIfResequenceNeeded(e){if(!e||!e.docChanged)return!1;let n=l=>{let c=0;return l.descendants(u=>{u.type.name==="footnoteMarker"&&c++}),c},r=n(e.before),i=n(e.doc);if(r!==i)return!0;let s=l=>{let c=[];return l.descendants(u=>{u.type.name==="footnoteMarker"&&c.push(u.attrs.id)}),c},o=s(e.before),a=s(e.doc);return o.join(",")!==a.join(",")}updateFootnoteSequence(){if(!this.editor)return;let{tr:e}=this.editor.state,n=1,r=!1,i=new Set;this.editor.state.doc.descendants((s,o)=>{if(s.type.name==="footnoteMarker"){let a=s.attrs.id,l=i.has(a),c=!1,u={...s.attrs};if(l||!a){let d=`fn-${crypto.randomUUID()}`;a&&this.footnotes[a]?this.footnotes[d]=JSON.parse(JSON.stringify(this.footnotes[a])):this.footnotes[d]={type:"doc",content:[{type:"body"}]},u.id=d,a=d,c=!0}i.add(a),u.number!==n&&(u.number=n,c=!0),c&&(e.setNodeMarkup(o,null,u),r=!0),n++}}),r&&this.editor.view.dispatch(e.setMeta("colophon-sync",!0)),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible?this.view.zAxisPanel.debouncedUpdate():this.plugin&&this.plugin.settings.sidebarLocation==="global"&&this.plugin.sidebarManager.update()}focusMarker(e){if(!this.editor)return;let n=null;if(this.editor.state.doc.descendants((r,i)=>{if(r.type.name==="footnoteMarker"&&r.attrs.id===e)return n=i,!1}),n!==null){let r=this.editor.state.doc.nodeAt(n).nodeSize;this.editor.chain().focus().setTextSelection(n+r).scrollIntoView().run()}}focusNote(e){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar().then(()=>{let n=this.app.workspace.getLeavesOfType("colophon-sidebar")[0];n&&n.view.zAxisPanel&&n.view.zAxisPanel.show("footnotes",()=>{n.view.zAxisPanel.focusEditor(e)})});return}this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.show("footnotes",()=>{this.view.zAxisPanel.focusEditor(e)})}focusComment(e){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar().then(()=>{let n=this.app.workspace.getLeavesOfType("colophon-sidebar")[0];n&&n.view.zAxisPanel&&n.view.zAxisPanel.focusComment(e)});return}this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.focusComment(e)}};var vs=require("obsidian"),Aa=class{constructor(e,n){this.view=e,this.parentEl=n,this.containerEl=null,this.blockSelectBtn=null,this.render(),this.update()}render(){this.containerEl=this.parentEl.createDiv({cls:"colophon-toolbar"}),this.renderBlockSelector();let e=this.containerEl.createDiv({cls:"colophon-btn-group"});this.boldBtn=this.createButton(e,"bold","Bold",()=>this.view.toggleBold()),this.italicBtn=this.createButton(e,"italic","Italic",()=>this.view.toggleItalic()),this.strikeBtn=this.createButton(e,"strikethrough","Strikethrough",()=>this.view.toggleStrike()),this.underlineBtn=this.createButton(e,"underline","Underline",()=>this.view.toggleUnderline()),this.superBtn=this.createButton(e,"superscript","Superscript",()=>this.view.toggleSuperscript()),this.subBtn=this.createButton(e,"subscript","Subscript",()=>this.view.toggleSubscript()),this.smallCapsBtn=this.createButton(e,"a-large-small","Small Caps",()=>this.view.toggleSmallCaps()),this.insertCommentBtn=this.createButton(e,"message-square-plus","Add Comment",()=>this.view.insertComment()),this.createSpacer(),this.zAxisGroup=this.containerEl.createDiv({cls:"colophon-btn-group"}),this.footnoteBtn=this.createButton(this.zAxisGroup,"list-ordered","Footnotes",()=>{this.view.toggleFootnotes()}),this.commentBtn=this.createButton(this.zAxisGroup,"message-square","Comments",()=>{this.view.toggleComments()}),this.docxExportBtn=this.createButton(this.zAxisGroup,"download","Export to DOCX",()=>{this.view.plugin.app.commands.executeCommandById("colophon-writer:export-to-docx")}),this.fountainExportBtn=this.createButton(this.zAxisGroup,"file-output","Export to Fountain",()=>{this.view.plugin.app.commands.executeCommandById("colophon-writer:export-to-fountain")})}renderBlockSelector(){let e=this.containerEl.createDiv({cls:"colophon-dropdown-wrapper"});this.blockSelectBtn=e.createEl("button",{cls:"colophon-ui-btn colophon-dropdown-trigger",text:"Body"});let n=this.blockSelectBtn.createSpan({cls:"colophon-select-icon"});(0,vs.setIcon)(n,"chevron-down"),this.blockSelectBtn.onclick=r=>{if(this.isBlockMenuDisabled){r.preventDefault();return}r.stopPropagation(),this.showBlockMenu(r)}}showBlockMenu(e){if(this.isBlockMenuDisabled)return;let n=new vs.Menu,r=this.view.plugin.settings.blocks,i=this.view.docType==="script";for(let[s,o]of Object.entries(r)){let a=o["script-mode"]===!0;i===a&&(["footnote","footnote-number","footnote-symbol"].includes(s)||n.addItem(l=>{l.setTitle(o.name).onClick(()=>{this.applyBlockType(s)}),this.currentBlockType===s&&l.setChecked(!0)}))}n.showAtMouseEvent(e)}applyBlockType(e){let n=this.view.activeEditor||(this.view.adapter?this.view.adapter.editor:null);n&&(n.commands.setNode(e),this.update())}createButton(e,n,r,i){let s=e.createEl("button",{cls:"colophon-ui-btn colophon-icon-only",attr:{"aria-label":r}});return(0,vs.setIcon)(s,n),s.onclick=o=>{o.preventDefault(),i()},s}createSeparator(){this.containerEl.createDiv({cls:"colophon-toolbar-separator"}).setAttribute("style","width: 1px; height: 16px; background-color: var(--background-modifier-border); margin: 0 8px;")}createSpacer(){this.containerEl.createDiv({cls:"colophon-toolbar-spacer"}).setAttribute("style","flex: 1;")}update(){let e=this.view.activeEditor||(this.view.adapter?this.view.adapter.editor:null);if(!e||e.isDestroyed)return;let n=null;try{n=e.view?.dom}catch{return}if(this.toggleBtnState(this.boldBtn,e.isActive("bold")),this.toggleBtnState(this.italicBtn,e.isActive("italic")),this.toggleBtnState(this.strikeBtn,e.isActive("strike")),this.toggleBtnState(this.underlineBtn,e.isActive("underline")),this.toggleBtnState(this.superBtn,e.isActive("superscript")),this.toggleBtnState(this.subBtn,e.isActive("subscript")),this.toggleBtnState(this.smallCapsBtn,e.isActive("smallCaps")),!e.state.selection.empty?this.insertCommentBtn.removeClass("is-disabled"):this.insertCommentBtn.addClass("is-disabled"),n?.classList?.contains("footnote"))this.blockSelectBtn.firstChild.textContent="Footnote",this.blockSelectBtn.addClass("is-disabled"),this.isBlockMenuDisabled=!0;else{this.blockSelectBtn.removeClass("is-disabled"),this.isBlockMenuDisabled=!1;let s=this.view.plugin.settings.blocks,o="Body";this.currentBlockType="body";for(let[a,l]of Object.entries(s))if(e.isActive(a)){o=l.name,this.currentBlockType=a;break}this.blockSelectBtn.firstChild.textContent=o}if(this.view.plugin.settings.sidebarLocation==="global")this.zAxisGroup.hide();else if(this.zAxisGroup.show(),this.view.zAxisPanel){let s=this.view.zAxisPanel;this.toggleBtnState(this.footnoteBtn,s.isVisible&&s.activeTab==="footnotes"),this.toggleBtnState(this.commentBtn,s.isVisible&&s.activeTab==="comments")}this.view.docType==="script"?(this.docxExportBtn.hide(),this.fountainExportBtn.show()):(this.docxExportBtn.show(),this.fountainExportBtn.hide())}toggleBtnState(e,n){n?e.addClass("colophon-active"):e.removeClass("colophon-active")}destroy(){this.containerEl&&this.containerEl.remove()}};var Ds=require("obsidian");var M_=/^\s*>\s$/,Kv=j.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Sr("blockquote",{...P(this.options.HTMLAttributes,t),children:Sr("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((i,s)=>{var o,a;let u=((a=(o=e.renderChild)==null?void 0:o.call(e,i,s))!=null?a:e.renderChildren([i])).split(` -`).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(u.join(` +`),!1}return!0}),t.trim()}var Ea=(n,t)=>{let{query:e}=t.storage,{caseSensitive:r,disableRegex:i,wholeWord:s}=t.options,o=[];if(!e)return t.storage.results=[],t.storage.activeIndex=-1,o;let a;try{if(i){let l=e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");s&&(l=`\\b${l}\\b`),a=new RegExp(l,r?"g":"gi")}else a=new RegExp(e,r?"g":"gi")}catch{return t.storage.results=[],t.storage.activeIndex=-1,o}return n.doc.descendants((l,c)=>{if(l.isText){let u=l.text,h;for(;(h=a.exec(u))!==null;)o.push({from:c+h.index,to:c+h.index+h[0].length})}}),t.storage.results=o,o.length===0?t.storage.activeIndex=-1:(t.storage.activeIndex===-1||t.storage.activeIndex>=o.length)&&(t.storage.activeIndex=0),o},Sd=(n,t)=>{if(n.isDestroyed)return;let{activeIndex:e,results:r}=t.storage;if(e===-1||r.length===0)return;let{from:i,to:s}=r[e];n.commands.setTextSelection({from:i,to:s}),n.commands.scrollIntoView()},Cd=L.create({name:"search",addOptions(){return{searchResultClass:"colophon-search-result",activeSearchResultClass:"colophon-search-result-active",caseSensitive:!1,disableRegex:!0,wholeWord:!1}},addStorage(){return{query:"",results:[],activeIndex:-1}},addCommands(){return{setSearchQuery:n=>({state:t,dispatch:e})=>(this.storage.query=n,Ea(t,this),e&&e(t.tr.setMeta("search-update",!0)),!0),setSearchOptions:n=>({state:t,dispatch:e})=>(Object.assign(this.options,n),Ea(t,this),e&&e(t.tr.setMeta("search-update",!0)),!0),nextSearchResult:()=>({editor:n,state:t,dispatch:e})=>this.storage.results.length===0?!1:(this.storage.activeIndex=(this.storage.activeIndex+1)%this.storage.results.length,e&&(e(t.tr.setMeta("search-update",!0)),setTimeout(()=>Sd(n,this),0)),!0),previousSearchResult:()=>({editor:n,state:t,dispatch:e})=>this.storage.results.length===0?!1:(this.storage.activeIndex=(this.storage.activeIndex-1+this.storage.results.length)%this.storage.results.length,e&&(e(t.tr.setMeta("search-update",!0)),setTimeout(()=>Sd(n,this),0)),!0),replace:n=>({state:t,dispatch:e})=>{let{activeIndex:r,results:i}=this.storage;if(r===-1||i.length===0)return!1;let{from:s,to:o}=i[r];return e&&e(t.tr.replaceWith(s,o,t.schema.text(n))),!0},replaceAll:n=>({state:t,dispatch:e})=>{let{results:r}=this.storage;if(r.length===0)return!1;if(e){let i=t.tr;[...r].reverse().forEach(({from:s,to:o})=>{i=i.replaceWith(s,o,t.schema.text(n))}),e(i)}return!0}}},onUpdate({editor:n,transaction:t}){t&&t.getMeta("search-update")||t&&(t.docChanged||t.getMeta("search-options-changed"))&&setTimeout(()=>{n.isDestroyed||(Ea(n.state,this),n.view.dispatch(n.state.tr.setMeta("search-update",!0)))},0)},addKeyboardShortcuts(){return{"Mod-f":()=>{let n=this.editor.options.adapter?.view;return n&&n.findReplaceBar?(n.findReplaceBar.open(),!0):!1},"Mod-Alt-f":()=>{let n=this.editor.options.adapter?.view;return n&&n.findReplaceBar?(n.findReplaceBar.openReplace(),!0):!1},"Mod-g":()=>this.editor.commands.nextSearchResult(),"Mod-Shift-g":()=>this.editor.commands.previousSearchResult()}},addProseMirrorPlugins(){let n=this;return[new D({key:new z("search"),props:{decorations(t){let{results:e,activeIndex:r}=n.storage,i=e.map((s,o)=>{let a=o===r?`${n.options.searchResultClass} ${n.options.activeSearchResultClass}`:n.options.searchResultClass;return ot.inline(s.from,s.to,{class:a})});return X.create(t.doc,i)}}})]}});var Vx=require("obsidian"),Je=class{constructor(t,e,r){this.app=t,this.plugin=e,this.editor=r,this.suggestionEl=null,this.suggestions=[],this.selectedIndex=0,this.context=null,this.setup()}setup(){this.editor.on("selectionUpdate",()=>this.onUpdate()),this.editor.on("update",()=>this.onUpdate()),this.editor.on("destroy",()=>this.close());let t=this.editor.options.editorProps?.handleKeyDown;this.editor.setOptions({editorProps:{handleKeyDown:(e,r)=>{if(this.suggestionEl){if(r.key==="ArrowDown")return this.moveSelection(1),!0;if(r.key==="ArrowUp")return this.moveSelection(-1),!0;if(r.key==="Enter"||r.key==="Tab")return this.selectCurrent(),!0;if(r.key==="Escape")return this.close(),!0}return t?t(e,r):!1}}})}onUpdate(){let{state:t}=this.editor,{selection:e}=t,{$from:r,empty:i}=e;if(!i){this.close();return}let s=r.parent.textBetween(0,r.parentOffset,null,"\0"),o=s.match(/\[\[([^\]]*)$/);if(o){this.showSuggestions(o[1],r.pos-o[1].length-2,r.pos,"wiki");return}if(this.app.vault.getConfig("useMarkdownLinks")){let l=s.match(/\[([^\]]*)$/);if(l){if(r.parent.textBetween(r.parentOffset,r.parent.content.size,null,"\0").startsWith("](")){this.close();return}this.showSuggestions(l[1],r.pos-l[1].length-1,r.pos,"md");return}}this.close()}showSuggestions(t,e,r,i){this.context={query:t,start:e,end:r,type:i};let s=t.toLowerCase().split(/\s+/).filter(l=>l.length>0),o=this.app.vault.getConfig("showUnsupportedFiles"),a=this.app.vault.getFiles().filter(l=>{if(!o&&!["md","colophon","canvas"].includes(l.extension))return!1;let c=l.path.toLowerCase(),u=l.basename.toLowerCase();return s.length===0?!0:s.every(h=>c.includes(h)||u.includes(h))}).sort((l,c)=>{let u=t.toLowerCase(),h=l.basename.toLowerCase(),d=c.basename.toLowerCase();return h===u&&d!==u?-1:d===u&&h!==u?1:h.startsWith(u)&&!d.startsWith(u)?-1:d.startsWith(u)&&!h.startsWith(u)?1:h.localeCompare(d)}).slice(0,50);if(a.length===0&&s.length>0){this.close();return}this.suggestions=a,this.render()}render(){this.suggestionEl||(this.suggestionEl=document.createElement("div"),this.suggestionEl.className="suggestion-container colophon-link-suggestions",document.body.appendChild(this.suggestionEl));let t=this.editor.view.coordsAtPos(this.context.end),e=10;this.suggestionEl.setAttribute("style","position: fixed; display: flex; visibility: hidden; top: 0px; left: 0px;"),this.suggestionEl.empty();let r=this.suggestionEl.createDiv({cls:"suggestion"});this.suggestions.forEach((f,p)=>{let m=r.createDiv({cls:`suggestion-item ${p===this.selectedIndex?"is-selected":""}`});m.createDiv({text:f.basename,cls:"suggestion-title"}),m.createDiv({text:f.path,cls:"suggestion-content"}),m.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.selectedIndex=p,this.selectCurrent()})});let i=this.suggestionEl.createDiv({cls:"prompt-instructions"}),s=i.createDiv({cls:"prompt-instruction"});s.createSpan({cls:"prompt-instruction-command",text:"Type #"}),s.appendText(" to link heading");let o=i.createDiv({cls:"prompt-instruction"});o.createSpan({cls:"prompt-instruction-command",text:"Type ^"}),o.appendText(" to link blocks");let a=i.createDiv({cls:"prompt-instruction"});a.createSpan({cls:"prompt-instruction-command",text:"Type |"}),a.appendText(" to change display text");let l=this.suggestionEl.getBoundingClientRect(),c=l.width,u=l.height,h=t.bottom+2;h+u>window.innerHeight-e&&(h=t.top-u-2);let d=t.left;d+c>window.innerWidth-e&&(d=t.right-c),d=Math.max(e,Math.min(d,window.innerWidth-c-e)),h=Math.max(e,Math.min(h,window.innerHeight-u-e)),this.suggestionEl.style.top=`${h}px`,this.suggestionEl.style.left=`${d}px`,this.suggestionEl.style.visibility="visible"}moveSelection(t){this.selectedIndex=(this.selectedIndex+t+this.suggestions.length)%this.suggestions.length,this.render()}selectCurrent(){let t=this.suggestions[this.selectedIndex];if(!t)return;let{start:e,end:r}=this.context,i=this.app.workspace.getActiveFile(),s=this.app.metadataCache.fileToLinktext(t,i?i.path:"");this.editor.chain().focus().deleteRange({from:e,to:r}).insertContent({type:"internalLink",attrs:{target:s,alias:t.basename!==s?t.basename:null}}).run(),this.close()}close(){this.suggestionEl&&(this.suggestionEl.remove(),this.suggestionEl=null),this.suggestions=[],this.selectedIndex=0,this.context=null}};var j0=L.create({name:"colophonAgentCommands",addCommands(){return{"colophon:add-link":n=>({chain:t})=>t().insertInternalLink(n).run(),"colophon:set-block-type":n=>({chain:t})=>t().setNode(n).run(),"colophon:focus-footnote":n=>({editor:t})=>(t.options.adapter&&t.options.adapter.focusNote(n),!0)}}});function Ed(){return Math.random().toString(36).substring(2,8)}var Ti=class{constructor(t,{content:e,footnotes:r,comments:i,type:s,settings:o,isSpellcheckEnabled:a,onUpdate:l,app:c,plugin:u,view:h}){this.parentElement=t,this.type=s||"manuscript",this.settings=o,this.isSpellcheckEnabled=a,this.onUpdate=l,this.app=c,this.plugin=u,this.view=h,this.view&&(this.view.adapter=this),this.editor=null,this.footnotes=r||{},this.comments=i||{},this.sharedExtensions=null,this.mount(e)}repairDocument(t){if(!t||!t.content)return t;let e=new Set;for(;t.content.length>0&&t.content[0].type==="horizontalRule";)t.content.shift();let r=!1;return t.content.forEach(i=>{i.type!=="horizontalRule"&&(r=!0),i.attrs||(i.attrs={}),(!i.attrs.id||e.has(i.attrs.id))&&(i.attrs.id=Ed()),e.add(i.attrs.id)}),r||t.content.push({type:this.type==="script"?"script-action":"body",attrs:{id:Ed()},content:[]}),t}mount(t){let e=this.repairDocument(t);if(!this.sharedExtensions){let r=this.settings?Gh(this.settings,this.type):[];this.sharedExtensions=[Ch,Eh,...r,Vh,Th,Mh,Ah,Nh,Oh,Wh,Uh,jh,_h,Kh,td,Qh,Zh,ed.configure({node:this.type==="script"?"script-action":"body",notAfter:this.type==="script"?["script-action","script-scene","script-character","script-parenthetical","script-dialogue","script-transition"]:["body","supertitle","title","subtitle","epigraph","body-first","heading-1","heading-2","heading-3","heading-4"]}),wd,xd,Cd,Yh.configure({trigger:this.settings?.footnoteTrigger??"(("}),j0,Xh.configure({smartQuotes:this.settings?.smartQuotes??!0,smartDashes:this.settings?.smartDashes??!0,doubleQuoteStyle:this.settings?.doubleQuoteStyle??"\u201C|\u201D",singleQuoteStyle:this.settings?.singleQuoteStyle??"\u2018|\u2019"})]}this.editor=new er({element:this.parentElement,app:this.app,plugin:this.plugin,adapter:this,extensions:this.sharedExtensions,content:e||{type:"doc",content:[{type:this.type==="script"?"script-action":"body"}]},onUpdate:({editor:r,transaction:i})=>{this.onUpdate&&this.onUpdate(),i&&i.docChanged&&!i.getMeta("colophon-sync")&&this.checkIfResequenceNeeded(i)&&this.updateFootnoteSequence()},onSelectionUpdate:({editor:r})=>{this.view&&this.view.updateActiveEditor(r),this.handleScroll()},onFocus:({editor:r})=>{this.view&&this.view.updateActiveEditor(r),this.plugin&&this.plugin.setActiveEditor(r),this.handleScroll()},editorProps:{handleClick:(r,i,s)=>{let{schema:o,doc:a}=r.state,l=o.marks.commentHighlight;if(!l)return!1;let u=a.resolve(i).marks().find(h=>h.type===l);return u&&u.attrs.threadId?(this.focusComment(u.attrs.threadId),!0):!1},attributes:{class:`colophon-editor colophon-main-editor type-${this.type} is-${this.type}-mode`,spellcheck:this.isSpellcheckEnabled?"true":"false"}}}),this.app&&this.plugin&&(this.linkSuggest=new Je(this.app,this.plugin,this.editor)),this.editor.view.dom.addEventListener("beforeinput",r=>{let i={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};i[r.inputType]&&(r.preventDefault(),this.editor.chain().focus()[i[r.inputType]]().run())}),this.handleScroll(),this.updateFootnoteSequence(),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible&&this.view.zAxisPanel.debouncedUpdate()}setContent(t,e,r){if(this.editor){this.footnotes=e||{},this.comments=r||{};let i=this.repairDocument(t);this.editor.commands.setContent(i),this.updateFootnoteSequence(),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible&&this.view.zAxisPanel.debouncedUpdate()}}getJSON(){return this.editor?this.editor.getJSON():null}getWordCount(){if(!this.editor)return{doc:0,total:0};let e=this.editor.state.doc.textContent.split(/\s+/).filter(i=>i.length>0).length,r=0;if(this.footnotes)for(let i of Object.values(this.footnotes))r+=this.countWordsInNode(i);return{doc:e,total:e+r}}countWordsInNode(t){if(!t)return 0;let e=0;return t.text&&(e+=t.text.split(/\s+/).filter(r=>r.length>0).length),t.content&&Array.isArray(t.content)&&t.content.forEach(r=>{e+=this.countWordsInNode(r)}),e}focus(){this.editor&&this.editor.commands.focus()}toggleBold(){this.editor&&this.editor.chain().focus().toggleBold().run()}toggleItalic(){this.editor&&this.editor.chain().focus().toggleItalic().run()}toggleStrike(){this.editor&&this.editor.chain().focus().toggleStrike().run()}toggleUnderline(){this.editor&&this.editor.chain().focus().toggleUnderline().run()}toggleSuperscript(){this.editor&&this.editor.chain().focus().toggleSuperscript().unsetSubscript().run()}toggleSubscript(){this.editor&&this.editor.chain().focus().toggleSubscript().unsetSuperscript().run()}toggleSmallCaps(){this.editor&&this.editor.chain().focus().toggleSmallCaps().run()}addLink({target:t,alias:e}){this.editor&&this.editor.commands["colophon:add-link"]({target:t,alias:e})}setBlockType(t){this.editor&&this.editor.commands["colophon:set-block-type"](t)}updateSettings(t){if(!this.editor){this.settings=t;return}let e=Object.keys(this.settings.blocks).sort().join(","),r=Object.keys(t.blocks).sort().join(","),i=JSON.stringify(Object.values(this.settings.blocks).map(a=>({t:a["syntax-trigger"],f:a["following-entity"]||a["following-block"]}))),s=JSON.stringify(Object.values(t.blocks).map(a=>({t:a["syntax-trigger"],f:a["following-entity"]||a["following-block"]}))),o=e!==r||i!==s||this.settings.footnoteTrigger!==t.footnoteTrigger;if(this.settings=t,o){let a=this.getJSON(),l=this.footnotes;this.sharedExtensions=null,this.destroy(),this.mount(a),this.footnotes=l,this.focus();return}this.editor.setOptions("substitutions",{smartQuotes:t.smartQuotes,smartDashes:t.smartDashes,doubleQuoteStyle:t.doubleQuoteStyle,singleQuoteStyle:t.singleQuoteStyle}),this.handleScroll()}handleScroll(){!this.editor||!this.settings||!this.settings.fixedFeedPosition||requestAnimationFrame(()=>{let t=this.parentElement;if(!t||!this.editor.view||!this.editor.view.dom)return;let e=this.editor.state.selection;if(!e)return;let r=this.editor.view,i=t.getBoundingClientRect(),o=1-(this.settings.feedPadding??40)/100,a=i.height*o,l=i.top+a,h=r.coordsAtPos(e.from).bottom-l;Math.abs(h)>2&&t.scrollBy({top:h,behavior:"auto"})})}destroy(){this.linkSuggest&&(this.linkSuggest.close(),this.linkSuggest=null),this.editor&&(this.plugin&&this.plugin.activeTiptapEditor===this.editor&&this.plugin.setActiveEditor(null),this.editor.destroy(),this.editor=null)}getActiveFootnoteIds(){let t=new Set;return this.editor&&this.editor.state.doc.descendants(e=>{e.type.name==="footnoteMarker"&&t.add(e.attrs.id)}),t}getActiveCommentThreadIds(){let t=new Set;if(!this.editor)return t;if(this.editor.state.doc.descendants(e=>{e.marks&&e.marks.forEach(r=>{r.type.name==="commentHighlight"&&r.attrs.threadId&&t.add(r.attrs.threadId)})}),this.footnotes)for(let e of Object.values(this.footnotes))this.scanForThreadIds(e,t);return t}scanForThreadIds(t,e){t&&(t.marks&&t.marks.forEach(r=>{r.type.name==="commentHighlight"&&r.attrs.threadId&&e.add(r.attrs.threadId)}),t.content&&Array.isArray(t.content)&&t.content.forEach(r=>this.scanForThreadIds(r,e)))}getFootnotes(){let t=[];return this.editor?(this.editor.state.doc.descendants((e,r)=>{e.type.name==="footnoteMarker"&&t.push({id:e.attrs.id,number:e.attrs.number,pos:r})}),t.map(e=>({id:e.id,number:e.number,content:this.footnotes[e.id]||{type:"doc",content:[{type:"body"}]}}))):[]}updateFootnote(t,e){let r=JSON.stringify(this.footnotes[t]),i=JSON.stringify(e);r!==i&&(this.footnotes[t]=e,this.onUpdate&&this.onUpdate())}checkIfResequenceNeeded(t){if(!t||!t.docChanged)return!1;let e=l=>{let c=0;return l.descendants(u=>{u.type.name==="footnoteMarker"&&c++}),c},r=e(t.before),i=e(t.doc);if(r!==i)return!0;let s=l=>{let c=[];return l.descendants(u=>{u.type.name==="footnoteMarker"&&c.push(u.attrs.id)}),c},o=s(t.before),a=s(t.doc);return o.join(",")!==a.join(",")}updateFootnoteSequence(){if(!this.editor)return;let{tr:t}=this.editor.state,e=1,r=!1,i=new Set;this.editor.state.doc.descendants((s,o)=>{if(s.type.name==="footnoteMarker"){let a=s.attrs.id,l=i.has(a),c=!1,u={...s.attrs};if(l||!a){let h=`fn-${crypto.randomUUID()}`;a&&this.footnotes[a]?this.footnotes[h]=JSON.parse(JSON.stringify(this.footnotes[a])):this.footnotes[h]={type:"doc",content:[{type:"body"}]},u.id=h,a=h,c=!0}i.add(a),u.number!==e&&(u.number=e,c=!0),c&&(t.setNodeMarkup(o,null,u),r=!0),e++}}),r&&this.editor.view.dispatch(t.setMeta("colophon-sync",!0)),this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.isVisible?this.view.zAxisPanel.debouncedUpdate():this.plugin&&this.plugin.settings.sidebarLocation==="global"&&this.plugin.sidebarManager.update()}focusMarker(t){if(!this.editor)return;let e=null;if(this.editor.state.doc.descendants((r,i)=>{if(r.type.name==="footnoteMarker"&&r.attrs.id===t)return e=i,!1}),e!==null){let r=this.editor.state.doc.nodeAt(e).nodeSize;this.editor.chain().focus().setTextSelection(e+r).scrollIntoView().run()}}focusNote(t){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar().then(()=>{let e=this.app.workspace.getLeavesOfType("colophon-sidebar")[0];e&&e.view.zAxisPanel&&e.view.zAxisPanel.show("footnotes",()=>{e.view.zAxisPanel.focusEditor(t)})});return}this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.show("footnotes",()=>{this.view.zAxisPanel.focusEditor(t)})}focusComment(t){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar().then(()=>{let e=this.app.workspace.getLeavesOfType("colophon-sidebar")[0];e&&e.view.zAxisPanel&&e.view.zAxisPanel.focusComment(t)});return}this.view&&this.view.zAxisPanel&&this.view.zAxisPanel.focusComment(t)}};var cr=require("obsidian"),Mi=class{constructor(t,e){this.view=t,this.parentEl=e,this.containerEl=null,this.blockSelectBtn=null,this.render(),this.update()}render(){this.containerEl=this.parentEl.createDiv({cls:"colophon-toolbar"}),this.renderBlockSelector();let t=this.containerEl.createDiv({cls:"colophon-btn-group"});this.boldBtn=this.createButton(t,"bold","Bold",()=>this.view.toggleBold()),this.italicBtn=this.createButton(t,"italic","Italic",()=>this.view.toggleItalic()),this.strikeBtn=this.createButton(t,"strikethrough","Strikethrough",()=>this.view.toggleStrike()),this.underlineBtn=this.createButton(t,"underline","Underline",()=>this.view.toggleUnderline()),this.superBtn=this.createButton(t,"superscript","Superscript",()=>this.view.toggleSuperscript()),this.subBtn=this.createButton(t,"subscript","Subscript",()=>this.view.toggleSubscript()),this.smallCapsBtn=this.createButton(t,"a-large-small","Small Caps",()=>this.view.toggleSmallCaps()),this.insertCommentBtn=this.createButton(t,"message-square-plus","Add Comment",()=>this.view.insertComment()),this.createSpacer(),this.zAxisGroup=this.containerEl.createDiv({cls:"colophon-btn-group"}),this.footnoteBtn=this.createButton(this.zAxisGroup,"list-ordered","Footnotes",()=>{this.view.toggleFootnotes()}),this.commentBtn=this.createButton(this.zAxisGroup,"message-square","Comments",()=>{this.view.toggleComments()}),this.docxExportBtn=this.createButton(this.zAxisGroup,"download","Export to DOCX",()=>{this.view.plugin.app.commands.executeCommandById("colophon-writer:export-to-docx")}),this.fountainExportBtn=this.createButton(this.zAxisGroup,"file-output","Export to Fountain",()=>{this.view.plugin.app.commands.executeCommandById("colophon-writer:export-to-fountain")})}renderBlockSelector(){let t=this.containerEl.createDiv({cls:"colophon-dropdown-wrapper"});this.blockSelectBtn=t.createEl("button",{cls:"colophon-ui-btn colophon-dropdown-trigger",text:"Body"});let e=this.blockSelectBtn.createSpan({cls:"colophon-select-icon"});(0,cr.setIcon)(e,"chevron-down"),this.blockSelectBtn.onclick=r=>{if(this.isBlockMenuDisabled){r.preventDefault();return}r.stopPropagation(),this.showBlockMenu(r)}}showBlockMenu(t){if(this.isBlockMenuDisabled)return;let e=new cr.Menu,r=this.view.plugin.settings.blocks,i=this.view.docType==="script";for(let[s,o]of Object.entries(r)){let a=o["script-mode"]===!0;i===a&&(["footnote","footnote-number","footnote-symbol"].includes(s)||e.addItem(l=>{l.setTitle(o.name).onClick(()=>{this.applyBlockType(s)}),this.currentBlockType===s&&l.setChecked(!0)}))}e.showAtMouseEvent(t)}applyBlockType(t){let e=this.view.activeEditor||(this.view.adapter?this.view.adapter.editor:null);e&&(e.commands.setNode(t),this.update())}createButton(t,e,r,i){let s=t.createEl("button",{cls:"colophon-ui-btn colophon-icon-only",attr:{"aria-label":r}});return(0,cr.setIcon)(s,e),s.onclick=o=>{o.preventDefault(),i()},s}createSeparator(){this.containerEl.createDiv({cls:"colophon-toolbar-separator"}).setAttribute("style","width: 1px; height: 16px; background-color: var(--background-modifier-border); margin: 0 8px;")}createSpacer(){this.containerEl.createDiv({cls:"colophon-toolbar-spacer"}).setAttribute("style","flex: 1;")}update(){let t=this.view.activeEditor||(this.view.adapter?this.view.adapter.editor:null);if(!t||t.isDestroyed)return;let e=null;try{e=t.view?.dom}catch{return}if(this.toggleBtnState(this.boldBtn,t.isActive("bold")),this.toggleBtnState(this.italicBtn,t.isActive("italic")),this.toggleBtnState(this.strikeBtn,t.isActive("strike")),this.toggleBtnState(this.underlineBtn,t.isActive("underline")),this.toggleBtnState(this.superBtn,t.isActive("superscript")),this.toggleBtnState(this.subBtn,t.isActive("subscript")),this.toggleBtnState(this.smallCapsBtn,t.isActive("smallCaps")),!t.state.selection.empty?this.insertCommentBtn.removeClass("is-disabled"):this.insertCommentBtn.addClass("is-disabled"),e?.classList?.contains("footnote"))this.blockSelectBtn.firstChild.textContent="Footnote",this.blockSelectBtn.addClass("is-disabled"),this.isBlockMenuDisabled=!0;else{this.blockSelectBtn.removeClass("is-disabled"),this.isBlockMenuDisabled=!1;let s=this.view.plugin.settings.blocks,o="Body";this.currentBlockType="body";for(let[a,l]of Object.entries(s))if(t.isActive(a)){o=l.name,this.currentBlockType=a;break}this.blockSelectBtn.firstChild.textContent=o}if(this.view.plugin.settings.sidebarLocation==="global")this.zAxisGroup.hide();else if(this.zAxisGroup.show(),this.view.zAxisPanel){let s=this.view.zAxisPanel;this.toggleBtnState(this.footnoteBtn,s.isVisible&&s.activeTab==="footnotes"),this.toggleBtnState(this.commentBtn,s.isVisible&&s.activeTab==="comments")}this.view.docType==="script"?(this.docxExportBtn.hide(),this.fountainExportBtn.show()):(this.docxExportBtn.show(),this.fountainExportBtn.hide())}toggleBtnState(t,e){e?t.addClass("colophon-active"):t.removeClass("colophon-active")}destroy(){this.containerEl&&this.containerEl.remove()}};var Sr=require("obsidian");var _0=/^\s*>\s$/,Td=W.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return vn("blockquote",{...P(this.options.HTMLAttributes,n),children:vn("slot",{})})},parseMarkdown:(n,t)=>{var e;let r=(e=t.parseBlockChildren)!=null?e:t.parseChildren;return t.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,t)=>{if(!n.content)return"";let e=">",r=[];return n.content.forEach((i,s)=>{var o,a;let u=((a=(o=t.renderChild)==null?void 0:o.call(t,i,s))!=null?a:t.renderChildren([i])).split(` +`).map(h=>h.trim()===""?e:`${e} ${h}`);r.push(u.join(` `))}),r.join(` -${n} -`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[mt({find:M_,type:this.type})]}});var __=/(^|[^`])`([^`]+)`(?!`)$/,N_=/(^|[^`])`([^`]+)`(?!`)/g,Jv=ae.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",P(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[pt({find:__,type:this.type})]},addPasteRules(){return[Ge({find:N_,type:this.type})]}});var tf=4,O_=/^```([a-z]+)?[\s\n]$/,I_=/^~~~([a-z]+)?[\s\n]$/,Zv=j.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:tf,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",P(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` +${e} +`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Jt({find:_0,type:this.type})]}});var K0=/(^|[^`])`([^`]+)`(?!`)$/,q0=/(^|[^`])`([^`]+)`(?!`)/g,Md=tt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",P(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,t)=>t.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,t)=>n.content?`\`${t.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[qt({find:K0,type:this.type})]},addPasteRules(){return[zt({find:q0,type:this.type})]}});var Ta=4,J0=/^```([a-z]+)?[\s\n]$/,G0=/^~~~([a-z]+)?[\s\n]$/,Ad=W.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ta,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var t;let{languageClassPrefix:e}=this.options;if(!e)return null;let s=[...((t=n.firstElementChild)==null?void 0:t.classList)||[]].filter(o=>o.startsWith(e)).map(o=>o.replace(e,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:t}){return["pre",P(this.options.HTMLAttributes,t),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,t)=>{var e,r;return((e=n.raw)==null?void 0:e.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:t.createNode("codeBlock",{language:n.lang||null},n.text?[t.createTextNode(n.text)]:[])},renderMarkdown:(n,t)=>{var e;let r="",i=((e=n.attrs)==null?void 0:e.language)||"";return n.content?r=[`\`\`\`${i}`,t.renderChildren(n.content),"```"].join(` `):r=`\`\`\`${i} -\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!=null?e:tf,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;let a=" ".repeat(n);return o?t.commands.insertContent(a):t.commands.command(({tr:l})=>{let{from:c,to:u}=i,h=r.doc.textBetween(c,u,` +\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:t})=>t.setNode(this.name,n),toggleCodeBlock:n=>({commands:t})=>t.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:t}=this.editor.state.selection,e=t.pos===1;return!n||t.parent.type.name!==this.name?!1:e||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var t;if(!this.options.enableTabIndentation)return!1;let e=(t=this.options.tabSize)!=null?t:Ta,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;let a=" ".repeat(e);return o?n.commands.insertContent(a):n.commands.command(({tr:l})=>{let{from:c,to:u}=i,f=r.doc.textBetween(c,u,` `,` `).split(` `).map(p=>a+p).join(` -`);return l.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!=null?e:tf,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:a})=>{var l;let{pos:c}=s,u=s.start(),d=s.end(),h=r.doc.textBetween(u,d,` +`);return l.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:n})=>{var t;if(!this.options.enableTabIndentation)return!1;let e=(t=this.options.tabSize)!=null?t:Ta,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?n.commands.command(({tr:a})=>{var l;let{pos:c}=s,u=s.start(),h=s.end(),f=r.doc.textBetween(u,h,` `,` `).split(` -`),p=0,m=0,g=c-u;for(let T=0;T=g){p=T;break}m+=h[T].length+1}let b=((l=h[p].match(/^ */))==null?void 0:l[0])||"",x=Math.min(b.length,n);if(x===0)return!0;let w=u;for(let T=0;T{let{from:l,to:c}=i,f=r.doc.textBetween(l,c,` +`),p=0,m=0,g=c-u;for(let N=0;N=g){p=N;break}m+=f[N].length+1}let b=((l=f[p].match(/^ */))==null?void 0:l[0])||"",C=Math.min(b.length,e);if(C===0)return!0;let M=u;for(let N=0;N{let{from:l,to:c}=i,d=r.doc.textBetween(l,c,` `,` `).split(` -`).map(h=>{var p;let m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return h.slice(g)}).join(` -`);return a.replaceWith(l,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` +`).map(f=>{var p;let m=((p=f.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,e);return f.slice(g)}).join(` +`);return a.replaceWith(l,c,r.schema.text(d)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=n,{selection:e}=t,{$from:r,empty:i}=e;if(!i||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!s||!o?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let a=i.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(L.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[zn({find:O_,type:this.type,getAttributes:t=>({language:t[1]})}),zn({find:I_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new R({key:new F("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;let{tr:o,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,` -`));return o.replaceSelectionWith(this.type.create({language:s},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(D.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}});var Xv=j.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,P(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;let r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>zn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var ir=si(al(),1);var fw=si(al(),1);var hw=si(al(),1),Cf="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",Q_=new RegExp(Cf),eN=new RegExp(`${Cf}$`),tN=new RegExp(Cf,"g");function nN(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function rN(t){return new R({key:new F("autolink"),appendTransaction:(e,n,r)=>{let i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;let{tr:o}=r,a=Vc(n.doc,[...e]);if(qc(a).forEach(({newRange:c})=>{let u=xm(r.doc,c,h=>h.isTextblock),d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!eN.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){let h=f.split(Q_).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;let g=(0,fw.tokenize)(p).map(y=>y.toObject(t.defaultProtocol));if(!nN(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{Eo(y.from,y.to,r.doc).some(b=>b.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function iN(t){return new R({key:new F("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let l=r.target;if(!l)return!1;let c=t.editor.view.dom;o=l.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let l=jc(e.state,t.type.name),c=(i=o.href)!=null?i:l.href,u=(s=o.target)!=null?s:l.target;c&&(window.open(c,u),a=!0)}return a}}})}function sN(t){return new R({key:new F("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});let c=(0,hw.find)(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||i!==void 0&&!i(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function rr(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(tN,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var pw=ae.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){(0,ir.registerCustomProtocol)(t);return}(0,ir.registerCustomProtocol)(t.scheme,t.optionalSlashes)})},onDestroy(){(0,ir.reset)()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!rr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!rr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!rr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",P(this.options.HTMLAttributes,t),0]:["a",P(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,i,s;let o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",l=e.renderChildren(t);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!rr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!rr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ge({find:t=>{let e=[];if(t){let{protocols:n,defaultProtocol:r}=this.options,i=(0,ir.find)(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!rr(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(rN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!rr(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(iN({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(sN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var oN=Object.defineProperty,aN=(t,e)=>{for(var n in e)oN(t,n,{get:e[n],enumerable:!0})},lN="listItem",mw="textStyle",gw=/^\s*([-+*])\s$/,Af=j.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",P(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(lN,this.editor.getAttributes(mw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=mt({find:gw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=mt({find:gw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(mw),editor:this.editor})),[t]}}),Mf=j.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",P(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!=null?n:e.parseChildren,i=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(o=>o.type==="paragraph"))i=r(t.tokens);else{let o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){let l=t.tokens.slice(1),c=r(l);i.push(...c)}}else i=r(t.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>Di(t,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),cN={};aN(cN,{findListItemPos:()=>Is,getNextListDepth:()=>_f,handleBackspace:()=>Ef,handleDelete:()=>Tf,hasListBefore:()=>ww,hasListItemAfter:()=>uN,hasListItemBefore:()=>xw,listItemHasSubList:()=>kw,nextListIsDeeper:()=>Sw,nextListIsHigher:()=>Cw});var Is=(t,e)=>{let{$from:n}=e.selection,r=se(t,e.schema),i=null,s=n.depth,o=n.pos,a=null;for(;s>0&&a===null;)i=n.node(s),i.type===r?a=s:(s-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},_f=(t,e)=>{let n=Is(t,e);if(!n)return!1;let[,r]=Am(e,t,n.$pos.pos+4);return r},ww=(t,e,n)=>{let{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},xw=(t,e)=>{var n;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},kw=(t,e,n)=>{if(!n)return!1;let r=se(t,e.schema),i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},Ef=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ht(t.state,e)&&ww(t.state,e,n)){let{$anchor:a}=t.state.selection,l=t.state.doc.resolve(a.before()-1),c=[];l.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});let u=c.at(-1);if(!u)return!1;let d=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:a.start()-1,to:a.end()+1},d.end()).joinForward().run()}if(!ht(t.state,e)||!_m(t.state))return!1;let r=Is(e,t.state);if(!r)return!1;let s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=kw(e,t.state,s);return xw(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Sw=(t,e)=>{let n=_f(t,e),r=Is(t,e);return!r||!n?!1:n>r.depth},Cw=(t,e)=>{let n=_f(t,e),r=Is(t,e);return!r||!n?!1:n{if(!ht(t.state,e)||!Mm(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Sw(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Cw(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},uN=(t,e)=>{var n;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},Nf=B.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Tf(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Tf(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ef(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ef(t,n,r)&&(e=!0)}),e}}}}),yw=/^(\s*)(\d+)\.\s+(.*)$/,dN=/^\s/;function fN(t){let e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function hN(t){let e=[],n=[],r=!1;return t.forEach(i=>{if(r){n.push(i);return}if(i.trim()===""){r=!0,n.push(i);return}if(e.length>0&&fN(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function pN(t){let e=[],n=0,r=0;for(;ne;)f.push(t[d]),d+=1;if(f.length>0){let h=Math.min(...f.map(m=>m.indent)),p=Ew(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(` -`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return r}function mN(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){let s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{let s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var gN="listItem",bw="textStyle",vw=/^(\d+)\.\s$/,Of=j.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",P(this.options.HTMLAttributes,n),0]:["ol",P(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.items?mN(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{let e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;let i=t.split(` -`),[s,o]=pN(i);if(s.length===0)return;let a=Ew(s,0,n);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:i.slice(0,o).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(gN,this.editor.getAttributes(bw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=mt({find:vw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=mt({find:vw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(bw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),yN=/^\s*(\[([( |x])?\])\s$/,bN=j.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",P(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Di(t,e,i)},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var f,h;a.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,s.append(a,o),i.append(s,l),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=kr(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[mt({find:yN,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),vN=j.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",P(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=s=>{let o=Mo(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=Mo(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),VP=B.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Af.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Mf.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Nf.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Of.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(bN.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(vN.configure(this.options.taskList)),t}});var ll=" ",If="\xA0",Tw=j.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",P(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ll||n[0].text===ll||n[0].raw===If||n[0].text===If)&&r.length===1&&r[0].type==="text"&&(r[0].text===ll||r[0].text===If)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,i;if(!t)return"";let s=Array.isArray(t.content)?t.content:[];if(s.length===0){let o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((i=n?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?ll:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var cL=B.create({name:"starterKit",addExtensions(){var t,e,n,r;let i=[];return this.options.bold!==!1&&i.push(Qc.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Kv.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Af.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Jv.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Zv.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Xc.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Ri.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(Pi.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(Yc.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Xv.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Li.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(uu.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(eu.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Mf.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Nf.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(pw.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Of.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Tw.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(tu.configure(this.options.strike)),this.options.text!==!1&&i.push(Gc.configure(this.options.text)),this.options.underline!==!1&&i.push(nu.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(dg.configure((r=this.options)==null?void 0:r.trailingNode)),i}});var ri=class{constructor(e,n,r,i){this.app=e,this.plugin=n,this.provider=r,this.parentEl=i,this.containerEl=null,this.isVisible=!1,this.activeTab="footnotes",this.editors=new Map,this.extensions=null,this.lastFootnotesJSON=null,this.lastCommentsJSON=null,this.focusTimer=null,this.blurTimers=new Map,this.debouncedUpdate=(0,Ds.debounce)(this.refresh.bind(this),250),this.render()}render(){this.containerEl=this.parentEl.createDiv({cls:"colophon-z-axis-panel"}),this.renderSwitcher(),this.contentEl=this.containerEl.createDiv({cls:"colophon-panel-content"}),this.refresh()}renderSwitcher(){if(!this.parentEl.classList.contains("colophon-sidebar-view"))return;this.switcherEl=this.containerEl.createDiv({cls:"colophon-panel-switcher"});let n=this.switcherEl.createDiv({cls:"colophon-switcher-group"});this.fnSwitchBtn=n.createEl("button",{cls:"colophon-switcher-btn",text:"Footnotes"}),this.fnSwitchBtn.onclick=()=>this.show("footnotes"),this.cmSwitchBtn=n.createEl("button",{cls:"colophon-switcher-btn",text:"Comments"}),this.cmSwitchBtn.onclick=()=>this.show("comments"),this.updateSwitcher()}updateSwitcher(){this.switcherEl&&(this.fnSwitchBtn.classList.toggle("colophon-active",this.activeTab==="footnotes"),this.cmSwitchBtn.classList.toggle("colophon-active",this.activeTab==="comments"))}update(){this.refresh()}refresh(){this.isVisible&&(this.updateSwitcher(),this.activeTab==="footnotes"?this.renderFootnotes():this.renderComments())}focusComment(e){this.focusTimer&&clearTimeout(this.focusTimer),this.show("comments",()=>{this.focusTimer=setTimeout(()=>{let n=this.containerEl.querySelector(`[data-thread-id="${e}"]`);if(n){n.scrollIntoView({behavior:"smooth",block:"center"});let r=`${e}:0`,i=this.editors.get(r);if(!i){let s=n.querySelector(".colophon-comment-editor-container"),o=this.provider.getAdapter();if(s&&o&&o.comments[e]){let a=o.comments[e];this.createCommentEditor(e,0,a[0],s),i=this.editors.get(r)}}i&&i.commands.focus("end")}this.focusTimer=null},100)})}renderFootnotes(){let e=this.provider.getAdapter();if(!e){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let n=e.getFootnotes(),r=JSON.stringify(n),i=!!this.contentEl.querySelector(".colophon-footnote-list");if(this.lastFootnotesJSON===r&&i)return;if(this.lastFootnotesJSON=r,n.length===0){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let s=this.contentEl.querySelector(".colophon-footnote-list");s||(this.contentEl.empty(),s=this.contentEl.createDiv({cls:"colophon-footnote-list"}));let o=new Set(n.map(l=>l.id));for(let[l,c]of this.editors)o.has(l)||(c.destroy(),this.editors.delete(l));s.querySelectorAll(".colophon-footnote-item").forEach(l=>{let c=l.dataset.footnoteId;o.has(c)||l.remove()}),n.forEach((l,c)=>{let u=s.querySelector(`[data-footnote-id="${l.id}"]`);if(u){let d=u.querySelector(".colophon-footnote-number");d&&d.getText()!==`${l.number}.`&&d.setText(`${l.number}.`);let f=this.editors.get(l.id);if(f){if(!f.isFocused){let h=JSON.stringify(f.getJSON()),p=JSON.stringify(l.content);h!==p&&f.commands.setContent(l.content,!1)}}else{let h=u.querySelector(".colophon-footnote-editor-container");h&&this.renderPreview(l.id,l.content,h,()=>{this.createMiniEditor(l.id,l.content,h)})}}else{u=s.createDiv({cls:"colophon-footnote-item"}),u.dataset.footnoteId=l.id;let d=u.createDiv({cls:"colophon-footnote-number",text:`${l.number}.`});d.onclick=h=>{h.stopPropagation();let p=this.provider.getAdapter();p&&p.focusMarker(l.id)};let f=u.createDiv({cls:"colophon-footnote-editor-container"});this.renderPreview(l.id,l.content,f,()=>{this.createMiniEditor(l.id,l.content,f)}),f.onclick=()=>{this.editors.has(l.id)||this.createMiniEditor(l.id,l.content,f)}}}),n.forEach((l,c)=>{let u=s.querySelector(`[data-footnote-id="${l.id}"]`);u&&s.children[c]!==u&&s.insertBefore(u,s.children[c])})}renderPreview(e,n,r,i=null){if(this.editors.has(e))return;r.empty();let o=e.startsWith("comment-")?"colophon-comment-preview":"colophon-footnote-preview",a=r.createDiv({cls:o}),l=(c,u)=>{if(c)if(c.type==="text"){let d=u;c.marks&&c.marks.forEach(f=>{let h="span",p="";f.type==="bold"?h="strong":f.type==="italic"?h="em":f.type==="underline"?h="u":f.type==="strike"?h="s":f.type==="superscript"?h="sup":f.type==="subscript"?h="sub":f.type==="smallCaps"&&(p="colophon-small-caps");let m=document.createElement(h);p&&(m.className=p),d.appendChild(m),d=m}),d.appendChild(document.createTextNode(c.text))}else if(c.type==="internalLink"){let d=u.createSpan({cls:"colophon-internal-link"}),f=c.attrs?.target||"",h=c.attrs?.alias;d.textContent=h||f.split("/").pop().replace(".md","").replace(".colophon",""),d.title=`Click to open ${f}`}else{let d=u;(c.type==="paragraph"||c.type==="body")&&(d=u.createEl("p",{cls:c.type})),c.content&&c.content.forEach(f=>l(f,d))}};n&&n.content?l(n,a):a.setText("Click to edit..."),a.tabIndex=0,a.onfocus=()=>{this.editors.has(e)||(i?i():this.createMiniEditor(e,n,r))}}createMiniEditor(e,n,r){r.empty();let i=this.provider.getAdapter();if(!i)return;let s=i.sharedExtensions,o=this.app.vault.getConfig("spellcheck"),a=new Ii({element:r,app:this.app,plugin:this.plugin,extensions:s,content:n,onUpdate:({editor:l})=>{let c=this.provider.getAdapter();c&&c.updateFootnote(e,l.getJSON())},onSelectionUpdate:({editor:l})=>{this.provider.updateActiveEditor(l)},onFocus:({editor:l})=>{this.blurTimers.has(e)&&(clearTimeout(this.blurTimers.get(e)),this.blurTimers.delete(e)),this.provider.updateActiveEditor(l),this.plugin&&this.plugin.setActiveEditor(l)},onBlur:({editor:l})=>{let c=l.getJSON(),u=this.provider.getAdapter();u&&u.updateFootnote(e,c);let d=setTimeout(()=>{if(!l.isFocused&&this.editors.has(e)){let f=this.provider.getAdapter();(this.provider.getActiveEditor?this.provider.getActiveEditor():f?f.view.activeEditor:null)===l&&this.provider.updateActiveEditor(null),this.plugin&&this.plugin.activeTiptapEditor===l&&this.plugin.setActiveEditor(null),l.destroy(),this.editors.delete(e),this.renderPreview(e,c,r)}this.blurTimers.delete(e)},150);this.blurTimers.set(e,d)},editorProps:{handleKeyDown:(l,c)=>{if(c.key==="Tab"&&c.shiftKey){c.preventDefault();let u=this.provider.getAdapter();return u&&u.focusMarker(e),!0}return!1},attributes:{class:"colophon-footnote-editor footnote",spellcheck:o?"true":"false"}}});this.editors.set(e,a),a.commands.focus("end"),a.view.dom.addEventListener("beforeinput",l=>{let c={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};c[l.inputType]&&(l.preventDefault(),a.chain().focus()[c[l.inputType]]().run())}),this.app&&this.plugin&&new tr(this.app,this.plugin,a)}focusEditor(e){this.focusTimer&&clearTimeout(this.focusTimer),this.focusTimer=setTimeout(()=>{let n=this.editors.get(e);if(!n){let r=this.containerEl.querySelector(`[data-footnote-id="${e}"]`);if(r){let i=r.querySelector(".colophon-footnote-editor-container"),s=this.provider.getAdapter(),a=(s?s.getFootnotes():[]).find(l=>l.id===e);a&&i&&(this.createMiniEditor(e,a.content,i),n=this.editors.get(e))}}if(n){n.commands.focus("end");let r=this.containerEl.querySelector(`[data-footnote-id="${e}"]`);r&&r.scrollIntoView({behavior:"smooth",block:"center"})}this.focusTimer=null},50)}renderComments(){let e=this.provider.getAdapter();if(!e){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let n=e.comments||{},r=JSON.stringify(n),i=!!this.contentEl.querySelector(".colophon-comment-list");if(this.lastCommentsJSON===r&&i)return;this.lastCommentsJSON=r;let s=[];if(e.editor.state.doc.descendants(c=>{c.marks&&c.marks.forEach(u=>{if(u.type.name==="commentHighlight"&&u.attrs.threadId){let d=u.attrs.threadId;n[d]&&!s.some(f=>f.id===d)&&s.push({id:d,data:n[d]})}})}),s.length===0){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"No comments here yet."});return}let o=this.contentEl.querySelector(".colophon-comment-list");o||(this.contentEl.empty(),o=this.contentEl.createDiv({cls:"colophon-comment-list"}));let a=new Set(s.map(c=>c.id));for(let[c,u]of this.editors)c.startsWith("comment-")&&!a.has(c.split(":")[0])&&(u.destroy(),this.editors.delete(c));o.querySelectorAll(".colophon-comment-thread").forEach(c=>{a.has(c.dataset.threadId)||c.remove()}),s.forEach((c,u)=>{let d=o.querySelector(`[data-thread-id="${c.id}"]`);d||(d=o.createDiv({cls:"colophon-comment-thread"}),d.dataset.threadId=c.id),this.renderCommentCard(c.id,c.data,d)}),s.forEach((c,u)=>{let d=o.querySelector(`[data-thread-id="${c.id}"]`);d&&o.children[u]!==d&&o.insertBefore(d,o.children[u])})}renderCommentCard(e,n,r){let i=r.querySelector(".colophon-comment-card");i||(i=r.createDiv({cls:"colophon-comment-card"}));let s=i.querySelector(".colophon-comment-items");s||(s=i.createDiv({cls:"colophon-comment-items"}));let o=new Set(n.map((c,u)=>u.toString()));s.querySelectorAll("[data-comment-index]").forEach(c=>{o.has(c.dataset.commentIndex)||c.remove()}),n.forEach((c,u)=>{let d=s.querySelector(`[data-comment-index="${u}"]`);if(!d){let y=u>0;d=s.createDiv({cls:y?"colophon-comment-reply":"colophon-comment-parent"}),d.dataset.commentIndex=u;let b=d.createDiv({cls:"colophon-comment-header"});b.createSpan({cls:"colophon-comment-author",text:c.author}),b.createSpan({cls:"colophon-comment-date"}),d.createDiv({cls:"colophon-comment-editor-container"})}let f=d.querySelector(".colophon-comment-date"),h=new Date(c.date).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});f.getText()!==h&&f.setText(h);let p=d.querySelector(".colophon-comment-editor-container"),m=`${e}:${u}`,g=this.editors.get(m);if(g){if(!g.isFocused){let y=JSON.stringify(g.getJSON()),b=JSON.stringify(c.content);y!==b&&g.commands.setContent(c.content,!1)}}else this.renderPreview(m,c.content,p,()=>{this.createCommentEditor(e,u,c,p)}),p.onclick=()=>{this.editors.has(m)||this.createCommentEditor(e,u,c,p)}});let l=i.querySelector(".colophon-comment-footer");if(!l){l=i.createDiv({cls:"colophon-comment-footer"});let c=l.createEl("button",{cls:"colophon-comment-action"});(0,Ds.setIcon)(c.createSpan({cls:"colophon-comment-action-icon"}),"reply"),c.createSpan({text:"Reply"}),c.onclick=()=>this.addReply(e);let u=l.createEl("button",{cls:"colophon-comment-action is-danger"});(0,Ds.setIcon)(u.createSpan({cls:"colophon-comment-action-icon"}),"trash-2"),u.createSpan({text:"Delete"}),u.onclick=()=>this.deleteThread(e)}}addReply(e){let n=this.provider.getAdapter();if(!n||!n.comments[e])return;let r=this.plugin.settings.authorName||this.app.vault.getName(),i=new Date().toISOString(),s={author:r,date:i,content:{type:"doc",content:[{type:"body"}]},replies:[]};n.comments[e].push(s),this.refresh();let o=n.comments[e].length-1;setTimeout(()=>{let a=this.containerEl.querySelector(`[data-thread-id="${e}"]`);if(a){let c=a.querySelector(".colophon-comment-reply:last-of-type")?.querySelector(".colophon-comment-editor-container");c&&this.createCommentEditor(e,o,s,c)}},50)}deleteThread(e){let n=this.provider.getAdapter();if(!n)return;let{tr:r}=n.editor.state;n.editor.state.doc.descendants((i,s)=>{i.marks&&i.marks.forEach(o=>{o.type.name==="commentHighlight"&&o.attrs.threadId===e&&r.removeMark(s,s+i.nodeSize,o.type)})}),n.editor.view.dispatch(r),delete n.comments[e],this.refresh()}createCommentEditor(e,n,r,i){let s=`${e}:${n}`;if(this.editors.has(s))return;i.empty();let o=this.provider.getAdapter();if(!o)return;let a=o.sharedExtensions,l=this.app.vault.getConfig("spellcheck"),c=JSON.parse(JSON.stringify(r.content)),u=new Ii({element:i,app:this.app,plugin:this.plugin,extensions:a,content:c,onUpdate:({editor:d})=>{r.content=d.getJSON();let f=this.provider.getAdapter();f&&f.onUpdate&&f.onUpdate()},onSelectionUpdate:({editor:d})=>{this.provider.updateActiveEditor(d)},onFocus:({editor:d})=>{this.blurTimers.has(s)&&(clearTimeout(this.blurTimers.get(s)),this.blurTimers.delete(s)),this.provider.updateActiveEditor(d),this.plugin&&this.plugin.setActiveEditor(d)},onBlur:({editor:d})=>{let f=d.getJSON();r.content=f;let h=this.provider.getAdapter();h&&h.onUpdate&&h.onUpdate();let p=setTimeout(()=>{!d.isFocused&&this.editors.has(s)&&((this.provider.getActiveEditor?this.provider.getActiveEditor():h?h.view.activeEditor:null)===d&&this.provider.updateActiveEditor(null),this.plugin&&this.plugin.activeTiptapEditor===d&&this.plugin.setActiveEditor(null),d.destroy(),this.editors.delete(s),this.renderPreview(s,f,i)),this.blurTimers.delete(s)},150);this.blurTimers.set(s,p)},editorProps:{attributes:{class:"colophon-comment-editor",spellcheck:l?"true":"false"}}});this.editors.set(s,u),u.commands.focus("end"),u.view.dom.addEventListener("beforeinput",d=>{let f={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};f[d.inputType]&&(d.preventDefault(),u.chain().focus()[f[d.inputType]]().run())}),this.app&&this.plugin&&new tr(this.app,this.plugin,u)}show(e="footnotes",n=null){this.activeTab!==e&&(this.lastFootnotesJSON=null,this.provider.updateActiveEditor(null)),this.activeTab=e,this.isVisible=!0,this.containerEl.addClass("is-visible"),this.lastFootnotesJSON=null,this.lastCommentsJSON=null,this.refresh();let r=this.provider.getToolbar?this.provider.getToolbar():null;r&&r.update(),n&&requestAnimationFrame(()=>n())}hide(){this.isVisible=!1,this.containerEl.removeClass("is-visible");let e=this.provider.getToolbar?this.provider.getToolbar():null;e&&e.update()}toggle(e="footnotes"){this.isVisible&&this.activeTab===e?this.hide():this.show(e)}cleanupEditors(){this.editors.forEach(e=>e.destroy()),this.editors.clear()}destroy(){this.cleanupEditors(),this.containerEl&&this.containerEl.remove()}};var cl=require("obsidian"),ul=class{constructor(e,n){this.view=e,this.parentEl=n,this.isVisible=!1,this.caseSensitive=!1,this.useRegex=!1,this.wholeWord=!1,this.render()}render(){this.containerEl=document.createElement("div"),this.containerEl.className="colophon-find-replace-bar",this.containerEl.setAttribute("style","display: none;");let e=this.containerEl.createDiv({cls:"cfr-main-row"}),n=e.createDiv({cls:"cfr-section cfr-find-section"});this.findInput=n.createEl("input",{type:"text",placeholder:"Find...",cls:"cfr-input"}),this.searchInfo=n.createDiv({cls:"cfr-info",text:"0 of 0"});let r=n.createDiv({cls:"cfr-button-group"});this.prevBtn=r.createEl("button",{cls:"cfr-button",attr:{tabindex:"-1"}}),(0,cl.setIcon)(this.prevBtn,"chevron-up"),this.nextBtn=r.createEl("button",{cls:"cfr-button",attr:{tabindex:"-1"}}),(0,cl.setIcon)(this.nextBtn,"chevron-down");let i=n.createDiv({cls:"cfr-button-group"});this.caseBtn=i.createEl("button",{cls:"cfr-button",text:"Aa",title:"Match Case",attr:{tabindex:"-1"}}),this.regexBtn=i.createEl("button",{cls:"cfr-button",text:".*",title:"Use Regular Expression",attr:{tabindex:"-1"}}),this.wordBtn=i.createEl("button",{cls:"cfr-button",text:'""',title:"Match Whole Word",attr:{tabindex:"-1"}});let s=e.createDiv({cls:"cfr-section cfr-replace-section"});this.replaceInput=s.createEl("input",{type:"text",placeholder:"Replace...",cls:"cfr-input"});let o=s.createDiv({cls:"cfr-button-group"});this.replaceBtn=o.createEl("button",{cls:"cfr-button",text:"Replace",attr:{tabindex:"-1"}}),this.replaceAllBtn=o.createEl("button",{cls:"cfr-button",text:"Replace All",attr:{tabindex:"-1"}}),this.closeBtn=e.createEl("button",{cls:"cfr-button cfr-close",attr:{tabindex:"-1"}}),(0,cl.setIcon)(this.closeBtn,"x"),this.setupEvents()}setupEvents(){this.findInput.addEventListener("input",()=>this.updateSearch()),this.findInput.addEventListener("keydown",e=>{e.key==="Enter"?e.shiftKey?this.prev():this.next():e.key==="Escape"&&this.close()}),this.replaceInput.addEventListener("keydown",e=>{e.key==="Enter"?this.replace():e.key==="Escape"&&this.close()}),this.nextBtn.addEventListener("click",()=>this.next()),this.prevBtn.addEventListener("click",()=>this.prev()),this.caseBtn.addEventListener("click",()=>{this.caseSensitive=!this.caseSensitive,this.caseBtn.toggleClass("is-active",this.caseSensitive),this.updateSearch()}),this.regexBtn.addEventListener("click",()=>{this.useRegex=!this.useRegex,this.regexBtn.toggleClass("is-active",this.useRegex),this.updateSearch()}),this.wordBtn.addEventListener("click",()=>{this.wholeWord=!this.wholeWord,this.wordBtn.toggleClass("is-active",this.wholeWord),this.updateSearch()}),this.replaceBtn.addEventListener("click",()=>this.replace()),this.replaceAllBtn.addEventListener("click",()=>this.replaceAll()),this.closeBtn.addEventListener("click",()=>this.close())}updateSearch(){let e=this.findInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.setSearchOptions({caseSensitive:this.caseSensitive,disableRegex:!this.useRegex,wholeWord:this.wholeWord}),this.view.adapter.editor.commands.setSearchQuery(e),this.updateInfo())}updateInfo(){if(!this.view.adapter||!this.view.adapter.editor)return;let e=this.view.adapter.editor.storage.search,n=e.results.length,r=n>0?e.activeIndex+1:0;this.searchInfo.setText(`${r} of ${n}`)}next(){this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.nextSearchResult(),this.updateInfo())}prev(){this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.previousSearchResult(),this.updateInfo())}replace(){let e=this.replaceInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.replace(e),this.updateInfo())}replaceAll(){let e=this.replaceInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.replaceAll(e),this.updateInfo())}open(){this.isVisible=!0,this.containerEl.setAttribute("style","display: flex;"),this.findInput.focus(),this.findInput.select(),this.updateSearch()}openReplace(){this.isVisible=!0,this.containerEl.setAttribute("style","display: flex;"),this.replaceInput.focus(),this.replaceInput.select(),this.updateSearch()}close(){this.isVisible=!1,this.containerEl.setAttribute("style","display: none;"),this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.setSearchQuery(""),this.view.adapter.editor.commands.focus())}toggle(){this.isVisible?this.close():this.open()}};var _t="colophon-view",pe=class extends ii.TextFileView{constructor(e,n){super(e),this.plugin=n,this.scope=new ii.Scope(this.app.scope),this.adapter=null,this.docType="manuscript",this.activeEditor=null,this.wordCountIndicator=null}updateActiveEditor(e){this.activeEditor=e,this.toolbar&&this.toolbar.update()}getViewType(){return _t}getDisplayText(){return this.file?this.file.basename:"No File"}getIcon(){return this.docType==="script"?"clapperboard":"feather"}onPaneMenu(e,n){super.onPaneMenu(e,n),e.addItem(r=>{r.setTitle("Export to DOCX format").setIcon("download").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-docx")})}),e.addItem(r=>{r.setTitle("Export to Markdown format").setIcon("file-text").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-markdown")})}),this.docType==="script"&&e.addItem(r=>{r.setTitle("Export to Fountain format").setIcon("file-output").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-fountain")})}),e.addItem(r=>{let i=this.plugin.settings.showWordCount;r.setTitle(i?"Hide word count":"Show word count").setIcon("hash").onClick(()=>{this.toggleWordCount()})}),e.addItem(r=>{let i=this.docType==="script";r.setTitle(i?"Switch to Manuscript mode":"Switch to Script mode").setIcon(i?"feather":"clapperboard").onClick(()=>{this.toggleMode()})})}toggleMode(){this.docType=this.docType==="script"?"manuscript":"script";let{state:e}=this.adapter.editor;if(e.doc.content.size<=2){let n=this.docType==="script"?"script-action":"body";this.adapter.editor.chain().setNode(n).run()}this.updateViewMode(),this.requestSave()}updateViewMode(){if(this.contentEl.removeClass("type-manuscript","type-script","is-manuscript-mode","is-script-mode"),this.contentEl.addClass(`type-${this.docType}`),this.contentEl.addClass(`is-${this.docType}-mode`),this.scrollContainer&&(this.scrollContainer.removeClass("is-manuscript-mode","is-script-mode"),this.scrollContainer.addClass(`is-${this.docType}-mode`)),this.adapter&&(this.adapter.type=this.docType,this.adapter.editor)){let e=this.app.vault.getConfig("spellcheck");this.adapter.editor.setOptions({editorProps:{attributes:{class:`colophon-editor colophon-main-editor type-${this.docType} is-${this.docType}-mode`,spellcheck:e?"true":"false"}}})}this.leaf&&this.leaf.tabHeaderInnerIconEl&&((0,ii.setIcon)(this.leaf.tabHeaderInnerIconEl,this.getIcon()),this.icon=this.getIcon())}toggleWordCount(){this.plugin.settings.showWordCount=!this.plugin.settings.showWordCount,this.plugin.saveSettings(),this.updateWordCountIndicator()}updateWordCountIndicator(){if(!this.plugin.settings.showWordCount){this.wordCountIndicator&&(this.wordCountIndicator.remove(),this.wordCountIndicator=null);return}this.wordCountIndicator||(this.wordCountIndicator=this.contentEl.createDiv({cls:"colophon-word-count-indicator"}));let e=this.adapter?this.adapter.getWordCount():{doc:0,total:0};this.wordCountIndicator.setText(`${e.doc} words / ${e.total} with footnotes`)}async onOpen(){if(await super.onOpen(),this.contentEl.addClass("colophon-view"),this.contentEl.addClass("colophon-workspace"),this.mainLayout){this.mainLayout.parentElement!==this.contentEl&&(this.contentEl.empty(),this.contentEl.appendChild(this.mainLayout)),this.refreshSidebarVisibility();return}this.mainLayout=this.contentEl.createDiv({cls:"colophon-main-layout"}),this.layoutBody=this.mainLayout.createDiv({cls:"colophon-layout-body"}),this.scrollContainer=this.layoutBody.createDiv({cls:"colophon-scroll-container colophon-editor-host"}),this.zAxisPanel=new ri(this.app,this.plugin,{getAdapter:()=>this.adapter,updateActiveEditor:n=>this.updateActiveEditor(n),getActiveEditor:()=>this.activeEditor,getToolbar:()=>this.toolbar},this.layoutBody);let e=this.containerEl.querySelector(".view-header");if(e){e.addClass("colophon-view-header");let n=e.querySelector(".view-header-title-container");n&&(n.setAttribute("style","display: flex;"),this.toolbar=new Aa(this,n))}this.updateWordCountIndicator(),this.refreshSidebarVisibility(),this.findReplaceBar=new ul(this,this.mainLayout),this.mainLayout.prepend(this.findReplaceBar.containerEl),this.registerHotkeyFromCommand("editor:toggle-bold",()=>this.toggleBold()),this.registerHotkeyFromCommand("editor:toggle-italics",()=>this.toggleItalic()),this.registerHotkeyFromCommand("editor:toggle-strikethrough",()=>this.toggleStrike()),this.registerHotkeyFromCommand("editor:toggle-underline",()=>this.toggleUnderline()),this.registerHotkeyFromCommand("editor:insert-footnote",()=>this.insertFootnote()),this.registerHotkeyFromCommand("editor:open-search",()=>this.findReplaceBar.open()),this.registerHotkeyFromCommand("editor:open-replace",()=>this.findReplaceBar.openReplace()),this.registerHotkeyFromCommand("editor:find-next",()=>{this.adapter&&this.adapter.editor&&this.adapter.editor.commands.nextSearchResult()}),this.registerHotkeyFromCommand("editor:find-previous",()=>{this.adapter&&this.adapter.editor&&this.adapter.editor.commands.previousSearchResult()}),this.registerHotkeyFromCommand("colophon-writer:insert-comment",()=>this.insertComment()),this.registerHotkeyFromCommand("colophon-writer:toggle-small-caps",()=>this.toggleSmallCaps()),this.scope.register(["Mod"],"b",n=>(n.preventDefault(),this.toggleBold(),!0)),this.scope.register(["Mod"],"i",n=>(n.preventDefault(),this.toggleItalic(),!0))}registerHotkeyFromCommand(e,n){let r=this.app.hotkeyManager;if(!r)return;let i=r.getHotkeys(e),s=r.getDefaultHotkeys(e),o=i&&i.length>0?i:s;o&&Array.isArray(o)&&o.forEach(a=>{let l=a.key.toLowerCase();this.scope.register(a.modifiers,l,c=>(c.preventDefault(),n(),!0))})}showZAxisTab(e){this.zAxisPanel&&this.zAxisPanel.show(e)}async onClose(){await super.onClose(),this.adapter&&(this.adapter.destroy(),this.adapter=null),this.zAxisPanel&&(this.zAxisPanel.destroy(),this.zAxisPanel=null),this.scrollContainer&&this.scrollContainer.empty()}refreshSidebarVisibility(){this.plugin.settings.sidebarLocation==="global"?(this.mainLayout.addClass("is-global-sidebar"),this.zAxisPanel&&this.zAxisPanel.hide()):this.mainLayout.removeClass("is-global-sidebar")}toggleFootnotes(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&(this.zAxisPanel.toggle("footnotes"),this.plugin.settings.lastZAxisState={visible:this.zAxisPanel.isVisible,activeTab:this.zAxisPanel.activeTab},this.plugin.saveSettings())}toggleComments(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&(this.zAxisPanel.toggle("comments"),this.plugin.settings.lastZAxisState={visible:this.zAxisPanel.isVisible,activeTab:this.zAxisPanel.activeTab},this.plugin.saveSettings())}showFootnotes(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&this.zAxisPanel.show("footnotes")}showComments(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&this.zAxisPanel.show("comments")}setViewData(e,n){if(!n&&e===this.lastLoadedData)return;this.lastLoadedData=e;let r={type:"manuscript",doc:null,footnotes:{},comments:{}};try{e&&e.trim()!==""&&(r=JSON.parse(e))}catch(s){console.error("Colophon: Error parsing file data",s)}r&&r.doc&&this.migrateContent(r.doc),r&&r.footnotes&&this.migrateComments(r),this.docType=r.type||"manuscript",this.updateViewMode(),this.updateSettings();let i=this.app.vault.getConfig("spellcheck");this.adapter?n&&(this.adapter.type=this.docType,this.adapter.setContent(r.doc||{},r.footnotes||{},r.comments||{}),this.adapter.editor&&this.adapter.editor.setOptions({editorProps:{attributes:{class:`colophon-editor colophon-main-editor type-${this.docType} is-${this.docType}-mode`,spellcheck:i?"true":"false"}}}),this.zAxisPanel&&this.zAxisPanel.isVisible&&this.zAxisPanel.update()):(this.adapter=new Ta(this.scrollContainer,{content:r.doc,footnotes:r.footnotes||{},comments:r.comments||{},type:this.docType,settings:this.plugin?this.plugin.settings:null,isSpellcheckEnabled:i,app:this.app,plugin:this.plugin,view:this,onUpdate:()=>{this.requestSave(),this.toolbar&&this.toolbar.update(),this.findReplaceBar&&this.findReplaceBar.updateInfo(),this.updateWordCountIndicator(),this.plugin.settings.sidebarLocation==="global"?this.plugin.sidebarManager.update():this.zAxisPanel&&this.zAxisPanel.debouncedUpdate()}}),this.zAxisPanel&&this.plugin.settings.sidebarLocation!=="global"&&this.plugin.settings.lastZAxisState.visible?this.zAxisPanel.show(this.plugin.settings.lastZAxisState.activeTab):this.zAxisPanel&&this.zAxisPanel.isVisible&&this.zAxisPanel.update())}getViewData(){if(!this.adapter)return"";let e=this.adapter.getActiveFootnoteIds(),n={};if(this.adapter.footnotes)for(let o in this.adapter.footnotes)e.has(o)&&(n[o]=this.adapter.footnotes[o]);let r=this.adapter.getActiveCommentThreadIds(),i={};if(this.adapter.comments)for(let o in this.adapter.comments)r.has(o)&&(i[o]=this.adapter.comments[o]);let s={type:this.docType,doc:this.adapter.getJSON(),footnotes:n,comments:i};return JSON.stringify(s,null,2)}clear(){this.adapter&&this.adapter.editor&&this.adapter.editor.commands.clearContent()}toggleBold(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleBold().run()}toggleItalic(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleItalic().run()}toggleStrike(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleStrike().run()}toggleUnderline(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleUnderline().run()}toggleSuperscript(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleSuperscript().unsetSubscript().run()}toggleSubscript(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleSubscript().unsetSuperscript().run()}toggleSmallCaps(){let e=this.activeEditor||(this.adapter?this.adapter.editor:null);e&&e.chain().focus().toggleSmallCaps().run()}insertFootnote(){if(!this.adapter||this.docType==="script")return;let e=`fn-${crypto.randomUUID()}`;this.adapter.editor.chain().insertContent({type:"footnoteMarker",attrs:{id:e}}).run(),this.adapter.focusNote(e)}insertComment(){if(!this.adapter)return;let e=this.activeEditor||this.adapter.editor;if(!e||e.state.selection.empty)return;let n=`comment-${crypto.randomUUID()}`,r=this.plugin.settings.authorName||this.app.vault.getName(),i=new Date().toISOString();this.adapter.comments||(this.adapter.comments={}),this.adapter.comments[n]=[{author:r,date:i,content:{type:"doc",content:[{type:"body"}]},replies:[]}],e.chain().focus().setMark("commentHighlight",{threadId:n}).run(),this.adapter.focusComment(n)}updateSettings(){let e=this.plugin.settings;e.fixedFeedPosition?this.contentEl.addClass("is-fixed-feed"):this.contentEl.removeClass("is-fixed-feed"),this.adapter&&this.adapter.updateSettings(e),this.refreshSidebarVisibility()}migrateContent(e){e&&(e.type==="paragraph"&&(e.type="body"),e.content&&Array.isArray(e.content)&&e.content.forEach(n=>this.migrateContent(n)))}migrateComments(e){e.comments||(e.comments={});for(let n in e.footnotes)if(n.startsWith("comment-")){let r=n.split(":");if(r.length===2){let i=r[0],s=parseInt(r[1]),o=e.footnotes[n];e.comments[i]||(e.comments[i]=[]),e.comments[i][s]?e.comments[i][s].content=o:e.comments[i][s]={author:this.plugin.settings.authorName||this.app.vault.getName(),date:new Date().toISOString(),content:o,replies:[]},delete e.footnotes[n]}}}};var Aw=require("obsidian");var Yt="colophon-sidebar",dl=class extends Aw.ItemView{constructor(e,n){super(e),this.plugin=n,this.zAxisPanel=null,this.unsubscribe=null}getViewType(){return Yt}getDisplayText(){return"Colophon Sidebar"}getIcon(){return"columns"}async onOpen(){let{contentEl:e}=this;e.empty(),e.addClass("colophon-sidebar-view"),e.addClass("colophon-workspace"),this.zAxisPanel=new ri(this.app,this.plugin,{getAdapter:()=>this.plugin.sidebarManager.getAdapter(),updateActiveEditor:n=>{let r=this.plugin.sidebarManager.activeView;r&&r.updateActiveEditor(n)},getActiveEditor:()=>{let n=this.plugin.sidebarManager.activeView;return n?n.activeEditor:null},getToolbar:()=>{let n=this.plugin.sidebarManager.activeView;return n?n.toolbar:null}},e),this.unsubscribe=this.plugin.sidebarManager.onUpdate(()=>{this.zAxisPanel.update()}),this.zAxisPanel.isVisible=!0,this.zAxisPanel.update()}async onClose(){this.unsubscribe&&this.unsubscribe(),this.zAxisPanel&&this.zAxisPanel.destroy()}};var Rs={globalScale:1,textColumnWidth:700,fixedFeedPosition:!1,feedPadding:40,sidebarLocation:"local",authorName:"",showWordCount:!0,lastZAxisState:{visible:!1,activeTab:"footnotes"},smartQuotes:!0,doubleQuoteStyle:"\u201C|\u201D",singleQuoteStyle:"\u2018|\u2019",smartDashes:!0,footnoteTrigger:"((",blocks:{body:{"after-block":"0pt","before-block":"0pt","first-indent":"0.3in","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0pt","line-spacing":"16pt",name:"Body","text-align":"left"},supertitle:{"after-block":"18pt","before-block":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","line-spacing":"14pt",name:"Supertitle","text-align":"center"},title:{"after-block":"4pt","before-block":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"18pt","font-variant":"regular","line-spacing":"18pt",name:"Title","text-align":"center"},subtitle:{"after-block":"28pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"14pt","font-variant":"regular","line-spacing":"18pt",name:"Subtitle","text-align":"center"},epigraph:{"after-block":"56pt","before-block":"48pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"1in","line-spacing":"16pt",name:"Epigraph","right-indent":"1in"},"body-first":{"after-block":"0pt","before-block":"0pt","first-indent":"0in","following-entity":"body","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"16pt",name:"Body First","text-align":"left"},footnote:{"after-block":"0pt","before-block":"0pt","first-indent":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","font-variant":"regular","left-indent":"0in","line-spacing":"9pt",name:"Footnote","right-indent":"0pt","space-between-notes":"10pt"},"footnote-number":{"font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","font-weight":"bold","line-spacing":"9pt",name:"Footnote Number"},"footnote-symbol":{align:"4pt",color:"var(--text-normal)","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","line-height":"0pt",name:"Footnote Symbol"},"heading-1":{"after-block":"14pt","before-block":"28pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"italic","left-indent":"0in","line-spacing":"28pt",name:"Heading 1","right-indent":"0in","text-align":"left","syntax-trigger":"# "},"heading-2":{"after-block":"14pt","before-block":"28pt",capitalization:"small-caps","character-spacing":"4pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"28pt",name:"Heading 2","right-indent":"0in","text-align":"left","syntax-trigger":"## "},"heading-3":{"after-block":"14pt","before-block":"28pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"28pt",name:"Heading 3","right-indent":"0in","text-align":"center","syntax-trigger":"### "},"script-scene":{"after-block":"12pt","before-block":"24pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Scene Heading","text-align":"left","following-block":"script-action","syntax-trigger":"INT."},"script-action":{"after-block":"12pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Action","text-align":"left","following-block":"script-action"},"script-character":{"after-block":"0pt","before-block":"12pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"2.0in",name:"Character","text-align":"left","following-block":"script-dialogue"},"script-parenthetical":{"after-block":"0pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"1.5in",name:"Parenthetical","text-align":"left","following-block":"script-dialogue","syntax-trigger":"("},"script-dialogue":{"after-block":"12pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"1.0in","right-indent":"1.5in",name:"Dialogue","text-align":"left","following-block":"script-character"},"script-transition":{"after-block":"12pt","before-block":"12pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Transition","text-align":"right","following-block":"script-scene","syntax-trigger":">"}}};var fl=class{constructor(){this.styleTagId="colophon-dynamic-styles",this.settings=null}applyStyles(e){if(!e||!e.blocks)return;this.settings=e;let n="";n+=`.colophon-workspace { --colophon-editor-width: ${e.textColumnWidth||700}px; } -`;let r=e.blocks["footnote-symbol"];r&&(n+=`.colophon-footnote-marker { -`,r["font-family"]&&(n+=` font-family: ${this.normalizeValue(r["font-family"],"font-family")}; -`),r["font-size"]&&(n+=` font-size: ${this.normalizeValue(r["font-size"],"font-size")}; -`),r.color&&(n+=` color: ${r.color}; -`),r.align&&(n+=` vertical-align: ${this.normalizeValue(r.align,"align")}; -`,n+=` line-height: 0; -`),n+=`} -`);let i=e.blocks.footnote;if(i){let o=".colophon-workspace",a=".ProseMirror.colophon-footnote-editor",l=".colophon-footnote-preview";n+=`${o} ${a}, ${o} ${a} p, ${o} ${l}, ${o} ${l} p { -`;let c=this.getPropertyMap();for(let[u,d]of Object.entries(i))if(c[u]){let f=this.normalizeValue(d,u);n+=` ${c[u]}: ${f} !important; -`}if(i["font-variant"]){let u=i["font-variant"].toLowerCase();u==="italic"?n+=` font-style: italic !important; -`:u==="small-caps"&&(n+=` font-variant: small-caps !important; -`)}i["font-style"]&&(n+=` font-style: ${i["font-style"]} !important; -`),n+=` min-height: 1.2em !important; -`,n+=`} -`,i["space-between-notes"]&&(n+=`.colophon-footnote-item { margin-bottom: ${this.normalizeValue(i["space-between-notes"],"space-between-notes")}; } -`)}let s=e.blocks["footnote-number"];s&&(n+=`.colophon-footnote-number { -`,s["font-family"]&&(n+=` font-family: ${this.normalizeValue(s["font-family"],"font-family")}; -`),s["font-size"]&&(n+=` font-size: ${this.normalizeValue(s["font-size"],"font-size")}; -`),s["font-weight"]&&(n+=` font-weight: ${s["font-weight"]}; -`),n+=`} -`);for(let[o,a]of Object.entries(e.blocks))n+=this.generateBlockStyles(o,a);this.injectStyles(n)}getPropertyMap(){return{"after-block":"margin-bottom","before-block":"margin-top",color:"color","first-indent":"text-indent","font-family":"font-family","font-size":"font-size","line-spacing":"line-height","text-align":"text-align","left-indent":"padding-left","right-indent":"padding-right","font-weight":"font-weight","text-transform":"text-transform"}}generateBlockStyles(e,n){let r=".colophon-main-editor",i="p";if(e.startsWith("heading-")){let l=e.split("-")[1];l&&!isNaN(l)&&(i=`h${l}`)}let o=`${`${r} ${i}.${e}`} { -`,a=this.getPropertyMap();if(n.capitalization&&((n.capitalization==="all-caps"||n.capitalization==="uppercase")&&(o+=` text-transform: uppercase; -`),n.capitalization==="small-caps"&&(o+=` font-variant: small-caps; -`)),n["font-variant"]){let l=n["font-variant"].toLowerCase();l==="italic"?o+=` font-style: italic; +`);return!s||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=n,{selection:e,doc:r}=t,{$from:i,empty:s}=e;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let a=i.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(R.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[je({find:J0,type:this.type,getAttributes:n=>({language:n[1]})}),je({find:G0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new D({key:new z("codeBlockVSCodeHandler"),props:{handlePaste:(n,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let e=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!e||!s)return!1;let{tr:o,schema:a}=n.state,l=a.text(e.replace(/\r\n?/g,` +`));return o.replaceSelectionWith(this.type.create({language:s},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(I.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}});var Nd=W.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:t}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,P(this.options.HTMLAttributes,t),0]},parseMarkdown:(n,t)=>t.createNode("heading",{level:n.depth||1},t.parseInline(n.tokens||[])),renderMarkdown:(n,t)=>{var e;let r=(e=n.attrs)!=null&&e.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${t.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:t})=>this.options.levels.includes(n.level)?t.setNode(this.name,n):!1,toggleHeading:n=>({commands:t})=>this.options.levels.includes(n.level)?t.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,t)=>({...n,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(n=>je({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Qe=Tr(ls(),1);var _d=Tr(ls(),1);var Kd=Tr(ls(),1),Ja="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",gb=new RegExp(Ja),yb=new RegExp(`${Ja}$`),bb=new RegExp(Ja,"g");function vb(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function wb(n){return new D({key:new z("autolink"),appendTransaction:(t,e,r)=>{let i=t.some(c=>c.docChanged)&&!e.doc.eq(r.doc),s=t.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;let{tr:o}=r,a=Jo(e.doc,[...t]);if(Yo(a).forEach(({newRange:c})=>{let u=Xu(r.doc,c,f=>f.isTextblock),h,d;if(u.length>1)h=u[0],d=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){let f=r.doc.textBetween(c.from,c.to," "," ");if(!yb.test(f))return;h=u[0],d=r.doc.textBetween(h.pos,c.to,void 0," ")}if(h&&d){let f=d.split(gb).filter(Boolean);if(f.length<=0)return!1;let p=f[f.length-1],m=h.pos+d.lastIndexOf(p);if(!p)return!1;let g=(0,_d.tokenize)(p).map(y=>y.toObject(n.defaultProtocol));if(!vb(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{pi(y.from,y.to,r.doc).some(b=>b.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function kb(n){return new D({key:new z("handleClickLink"),props:{handleClick:(t,e,r)=>{var i,s;if(r.button!==0||!t.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let l=r.target;if(!l)return!1;let c=n.editor.view.dom;o=l.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(n.enableClickSelection&&(a=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let l=Qo(t.state,n.type.name),c=(i=o.href)!=null?i:l.href,u=(s=o.target)!=null?s:l.target;c&&(window.open(c,u),a=!0)}return a}}})}function xb(n){return new D({key:new z("handlePasteLink"),props:{handlePaste:(t,e,r)=>{let{shouldAutoLink:i}=n,{state:s}=t,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});let c=(0,Kd.find)(l,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Xe(n,t){let e=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&e.push(i)}),!n||n.replace(bb,"").match(new RegExp(`^(?:(?:${e.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var qd=tt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){(0,Qe.registerCustomProtocol)(n);return}(0,Qe.registerCustomProtocol)(n.scheme,n.optionalSlashes)})},onDestroy(){(0,Qe.reset)()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,t)=>!!Xe(n,t.protocols),validate:n=>!!n,shouldAutoLink:n=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),e=/^[a-z][a-z0-9+.-]*:/i.test(n);if(t||e&&!n.includes("@"))return!0;let i=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let t=n.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Xe(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:t=>!!Xe(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",P(this.options.HTMLAttributes,n),0]:["a",P(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,t)=>t.applyMark("link",t.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,t)=>{var e,r,i,s;let o=(r=(e=n.attrs)==null?void 0:e.href)!=null?r:"",a=(s=(i=n.attrs)==null?void 0:i.title)!=null?s:"",l=t.renderChildren(n);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:n=>({chain:t})=>{let{href:e}=n;return this.options.isAllowedUri(e,{defaultValidate:r=>!!Xe(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:t})=>{let{href:e}=n||{};return e&&!this.options.isAllowedUri(e,{defaultValidate:r=>!!Xe(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[zt({find:n=>{let t=[];if(n){let{protocols:e,defaultProtocol:r}=this.options,i=(0,Qe.find)(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Xe(o,e),protocols:e,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&t.push({text:s.value,data:{href:s.href},index:s.start})})}return t},type:this.type,getAttributes:n=>{var t;return{href:(t=n.data)==null?void 0:t.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:t,defaultProtocol:e}=this.options;return this.options.autolink&&n.push(wb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Xe(i,t),protocols:t,defaultProtocol:e}),shouldAutoLink:this.options.shouldAutoLink})),n.push(kb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(xb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}});var Sb=Object.defineProperty,Cb=(n,t)=>{for(var e in t)Sb(n,e,{get:t[e],enumerable:!0})},Eb="listItem",Jd="textStyle",Gd=/^\s*([-+*])\s$/,Qa=W.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",P(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,t)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?t.parseChildren(n.items):[]},renderMarkdown:(n,t)=>n.content?t.renderChildren(n.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Eb,this.editor.getAttributes(Jd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Jt({find:Gd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Jt({find:Gd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Jd),editor:this.editor})),[n]}}),Ya=W.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",P(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,t)=>{var e;if(n.type!=="list_item")return[];let r=(e=t.parseBlockChildren)!=null?e:t.parseChildren,i=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(o=>o.type==="paragraph"))i=r(n.tokens);else{let o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:t.parseInline(o.tokens)}],n.tokens.length>1){let l=n.tokens.slice(1),c=r(l);i.push(...c)}}else i=r(n.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,t,e)=>nr(n,t,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},e),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Tb={};Cb(Tb,{findListItemPos:()=>xr,getNextListDepth:()=>Za,handleBackspace:()=>Ga,handleDelete:()=>Xa,hasListBefore:()=>Zd,hasListItemAfter:()=>Mb,hasListItemBefore:()=>tf,listItemHasSubList:()=>ef,nextListIsDeeper:()=>nf,nextListIsHigher:()=>rf});var xr=(n,t)=>{let{$from:e}=t.selection,r=Y(n,t.schema),i=null,s=e.depth,o=e.pos,a=null;for(;s>0&&a===null;)i=e.node(s),i.type===r?a=s:(s-=1,o-=1);return a===null?null:{$pos:t.doc.resolve(o),depth:a}},Za=(n,t)=>{let e=xr(n,t);if(!e)return!1;let[,r]=nh(t,n,e.$pos.pos+4);return r},Zd=(n,t,e)=>{let{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!e.includes(s.type.name))},tf=(n,t)=>{var e;let{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-2);return!(i.index()===0||((e=i.nodeBefore)==null?void 0:e.type.name)!==n)},ef=(n,t,e)=>{if(!e)return!1;let r=Y(n,t.schema),i=!1;return e.descendants(s=>{s.type===r&&(i=!0)}),i},Ga=(n,t,e)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Kt(n.state,t)&&Zd(n.state,t,e)){let{$anchor:a}=n.state.selection,l=n.state.doc.resolve(a.before()-1),c=[];l.node().descendants((d,f)=>{d.type.name===t&&c.push({node:d,pos:f})});let u=c.at(-1);if(!u)return!1;let h=n.state.doc.resolve(l.start()+u.pos+1);return n.chain().cut({from:a.start()-1,to:a.end()+1},h.end()).joinForward().run()}if(!Kt(n.state,t)||!ih(n.state))return!1;let r=xr(t,n.state);if(!r)return!1;let s=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=ef(t,n.state,s);return tf(t,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(t).run()},nf=(n,t)=>{let e=Za(n,t),r=xr(n,t);return!r||!e?!1:e>r.depth},rf=(n,t)=>{let e=Za(n,t),r=xr(n,t);return!r||!e?!1:e{if(!Kt(n.state,t)||!rh(n.state,t))return!1;let{selection:e}=n.state,{$from:r,$to:i}=e;return!e.empty&&r.sameParent(i)?!1:nf(t,n.state)?n.chain().focus(n.state.selection.from+4).lift(t).joinBackward().run():rf(t,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Mb=(n,t)=>{var e;let{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((e=i.nodeAfter)==null?void 0:e.type.name)!==n)},tl=L.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e})=>{n.state.schema.nodes[e]!==void 0&&Xa(n,e)&&(t=!0)}),t},"Mod-Delete":({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e})=>{n.state.schema.nodes[e]!==void 0&&Xa(n,e)&&(t=!0)}),t},Backspace:({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e,wrapperNames:r})=>{n.state.schema.nodes[e]!==void 0&&Ga(n,e,r)&&(t=!0)}),t},"Mod-Backspace":({editor:n})=>{let t=!1;return this.options.listTypes.forEach(({itemName:e,wrapperNames:r})=>{n.state.schema.nodes[e]!==void 0&&Ga(n,e,r)&&(t=!0)}),t}}}}),Xd=/^(\s*)(\d+)\.\s+(.*)$/,Ab=/^\s/;function Nb(n){let t=n.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}function Ob(n){let t=[],e=[],r=!1;return n.forEach(i=>{if(r){e.push(i);return}if(i.trim()===""){r=!0,e.push(i);return}if(t.length>0&&Nb(i)){r=!0,e.push(i);return}t.push(i)}),{paragraphLines:t,blockLines:e}}function Ib(n){let t=[],e=0,r=0;for(;et;)d.push(n[h]),h+=1;if(d.length>0){let f=Math.min(...d.map(m=>m.indent)),p=sf(d,f,e);c.push({type:"list",ordered:!0,start:d[0].number,items:p,raw:d.map(m=>m.raw).join(` +`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=h}else i+=1}return r}function Db(n,t){return n.map(e=>{if(e.type!=="list_item")return t.parseChildren([e])[0];let r=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...t.parseChildren([i]));else if(i.type==="text"&&i.tokens){let s=t.parseChildren([i]);r.push({type:"paragraph",content:s})}else{let s=t.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var Pb="listItem",Qd="textStyle",Yd=/^(\d+)\.\s$/,el=W.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:t,...e}=n;return t===1?["ol",P(this.options.HTMLAttributes,e),0]:["ol",P(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,t)=>{if(n.type!=="list"||!n.ordered)return[];let e=n.start||1,r=n.items?Db(n.items,t):[];return e!==1?{type:"orderedList",attrs:{start:e},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,t)=>n.content?t.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{let t=n.match(/^(\s*)(\d+)\.\s+/),e=t?.index;return e!==void 0?e:-1},tokenize:(n,t,e)=>{var r;let i=n.split(` +`),[s,o]=Ib(i);if(s.length===0)return;let a=sf(s,0,e);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:i.slice(0,o).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Pb,this.editor.getAttributes(Qd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Jt({find:Yd,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Jt({find:Yd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Qd)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[n]}}),Rb=/^\s*(\[([( |x])?\])\s$/,Lb=W.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let t=n.getAttribute("data-checked");return t===""||t==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:t}){return["li",P(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,t)=>{let e=[];if(n.tokens&&n.tokens.length>0?e.push(t.createNode("paragraph",{},t.parseInline(n.tokens))):n.text?e.push(t.createNode("paragraph",{},[t.createNode("text",{text:n.text})])):e.push(t.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){let r=t.parseChildren(n.nestedTokens);e.push(...r)}return t.createNode("taskItem",{checked:n.checked||!1},e)},renderMarkdown:(n,t)=>{var e;let i=`- [${(e=n.attrs)!=null&&e.checked?"x":" "}] `;return nr(n,t,i)},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:t,getPos:e,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=h=>{var d,f;a.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,h,a.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};c(n),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",h=>h.preventDefault()),a.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:d}=h.target;r.isEditable&&typeof e=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{let p=e();if(typeof p!="number")return!1;let m=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...m?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,d])=>{i.setAttribute(h,d)}),i.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,s.append(a,o),i.append(s,l),Object.entries(t).forEach(([h,d])=>{i.setAttribute(h,d)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:l,update:h=>{if(h.type!==this.type)return!1;i.dataset.checked=h.attrs.checked,a.checked=h.attrs.checked,c(h);let d=r.extensionManager.attributes,f=bn(h,d),p=new Set(Object.keys(f)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(f).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[Jt({find:Rb,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),zb=W.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",P(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,t)=>t.createNode("taskList",{},t.parseChildren(n.items||[])),renderMarkdown:(n,t)=>n.content?t.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var t;let e=(t=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:t.index;return e!==void 0?e:-1},tokenize(n,t,e){let r=s=>{let o=yi(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:e.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},e);return o?[{type:"taskList",raw:o.raw,items:o.items}]:e.blockTokens(s)},i=yi(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:e.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},e);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),qS=L.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(Qa.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(tl.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(el.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Lb.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(zb.configure(this.options.taskList)),n}});var cs=" ",nl="\xA0",of=W.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",P(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,t)=>{let e=n.tokens||[];if(e.length===1&&e[0].type==="image")return t.parseChildren([e[0]]);let r=t.parseInline(e);return e.length===1&&e[0].type==="text"&&(e[0].raw===cs||e[0].text===cs||e[0].raw===nl||e[0].text===nl)&&r.length===1&&r[0].type==="text"&&(r[0].text===cs||r[0].text===nl)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(n,t,e)=>{var r,i;if(!n)return"";let s=Array.isArray(n.content)?n.content:[];if(s.length===0){let o=Array.isArray((r=e?.previousNode)==null?void 0:r.content)?e.previousNode.content:[];return((i=e?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?cs:""}return t.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var p1=L.create({name:"starterKit",addExtensions(){var n,t,e,r;let i=[];return this.options.bold!==!1&&i.push(sa.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Td.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Qa.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Md.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Ad.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(na.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(rr.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(ir.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(ia.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Nd.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(sr.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(ga.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(oa.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Ya.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(tl.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(qd.configure((t=this.options)==null?void 0:t.link)),this.options.orderedList!==!1&&i.push(el.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(of.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(aa.configure(this.options.strike)),this.options.text!==!1&&i.push(ra.configure(this.options.text)),this.options.underline!==!1&&i.push(la.configure((e=this.options)==null?void 0:e.underline)),this.options.trailingNode!==!1&&i.push(Hh.configure((r=this.options)==null?void 0:r.trailingNode)),i}});var Tn=class{constructor(t,e,r,i){this.app=t,this.plugin=e,this.provider=r,this.parentEl=i,this.containerEl=null,this.isVisible=!1,this.activeTab="footnotes",this.editors=new Map,this.extensions=null,this.lastFootnotesJSON=null,this.lastCommentsJSON=null,this.focusTimer=null,this.blurTimers=new Map,this.debouncedUpdate=(0,Sr.debounce)(this.refresh.bind(this),250),this.render()}render(){this.containerEl=this.parentEl.createDiv({cls:"colophon-z-axis-panel"}),this.renderSwitcher(),this.contentEl=this.containerEl.createDiv({cls:"colophon-panel-content"}),this.refresh()}renderSwitcher(){if(!this.parentEl.classList.contains("colophon-sidebar-view"))return;this.switcherEl=this.containerEl.createDiv({cls:"colophon-panel-switcher"});let e=this.switcherEl.createDiv({cls:"colophon-switcher-group"});this.fnSwitchBtn=e.createEl("button",{cls:"colophon-switcher-btn",text:"Footnotes"}),this.fnSwitchBtn.onclick=()=>this.show("footnotes"),this.cmSwitchBtn=e.createEl("button",{cls:"colophon-switcher-btn",text:"Comments"}),this.cmSwitchBtn.onclick=()=>this.show("comments"),this.updateSwitcher()}updateSwitcher(){this.switcherEl&&(this.fnSwitchBtn.classList.toggle("colophon-active",this.activeTab==="footnotes"),this.cmSwitchBtn.classList.toggle("colophon-active",this.activeTab==="comments"))}update(){this.refresh()}refresh(){this.isVisible&&(this.updateSwitcher(),this.activeTab==="footnotes"?this.renderFootnotes():this.renderComments())}focusComment(t){this.focusTimer&&clearTimeout(this.focusTimer),this.show("comments",()=>{this.focusTimer=setTimeout(()=>{let e=this.containerEl.querySelector(`[data-thread-id="${t}"]`);if(e){e.scrollIntoView({behavior:"smooth",block:"center"});let r=`${t}:0`,i=this.editors.get(r);if(!i){let s=e.querySelector(".colophon-comment-editor-container"),o=this.provider.getAdapter();if(s&&o&&o.comments[t]){let a=o.comments[t];this.createCommentEditor(t,0,a[0],s),i=this.editors.get(r)}}i&&i.commands.focus("end")}this.focusTimer=null},100)})}renderFootnotes(){let t=this.provider.getAdapter();if(!t){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let e=t.getFootnotes(),r=JSON.stringify(e),i=!!this.contentEl.querySelector(".colophon-footnote-list");if(this.lastFootnotesJSON===r&&i)return;if(this.lastFootnotesJSON=r,e.length===0){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let s=this.contentEl.querySelector(".colophon-footnote-list");s||(this.contentEl.empty(),s=this.contentEl.createDiv({cls:"colophon-footnote-list"}));let o=new Set(e.map(l=>l.id));for(let[l,c]of this.editors)o.has(l)||(c.destroy(),this.editors.delete(l));s.querySelectorAll(".colophon-footnote-item").forEach(l=>{let c=l.dataset.footnoteId;o.has(c)||l.remove()}),e.forEach((l,c)=>{let u=s.querySelector(`[data-footnote-id="${l.id}"]`);if(u){let h=u.querySelector(".colophon-footnote-number");h&&h.getText()!==`${l.number}.`&&h.setText(`${l.number}.`);let d=this.editors.get(l.id);if(d){if(!d.isFocused){let f=JSON.stringify(d.getJSON()),p=JSON.stringify(l.content);f!==p&&d.commands.setContent(l.content,!1)}}else{let f=u.querySelector(".colophon-footnote-editor-container");f&&this.renderPreview(l.id,l.content,f,()=>{this.createMiniEditor(l.id,l.content,f)})}}else{u=s.createDiv({cls:"colophon-footnote-item"}),u.dataset.footnoteId=l.id;let h=u.createDiv({cls:"colophon-footnote-number",text:`${l.number}.`});h.onclick=f=>{f.stopPropagation();let p=this.provider.getAdapter();p&&p.focusMarker(l.id)};let d=u.createDiv({cls:"colophon-footnote-editor-container"});this.renderPreview(l.id,l.content,d,()=>{this.createMiniEditor(l.id,l.content,d)}),d.onclick=()=>{this.editors.has(l.id)||this.createMiniEditor(l.id,l.content,d)}}}),e.forEach((l,c)=>{let u=s.querySelector(`[data-footnote-id="${l.id}"]`);u&&s.children[c]!==u&&s.insertBefore(u,s.children[c])})}renderPreview(t,e,r,i=null){if(this.editors.has(t))return;r.empty();let o=t.startsWith("comment-")?"colophon-comment-preview":"colophon-footnote-preview",a=r.createDiv({cls:o}),l=(c,u)=>{if(c)if(c.type==="text"){let h=u;c.marks&&c.marks.forEach(d=>{let f="span",p="";d.type==="bold"?f="strong":d.type==="italic"?f="em":d.type==="underline"?f="u":d.type==="strike"?f="s":d.type==="superscript"?f="sup":d.type==="subscript"?f="sub":d.type==="smallCaps"&&(p="colophon-small-caps");let m=document.createElement(f);p&&(m.className=p),h.appendChild(m),h=m}),h.appendChild(document.createTextNode(c.text))}else if(c.type==="internalLink"){let h=u.createSpan({cls:"colophon-internal-link"}),d=c.attrs?.target||"",f=c.attrs?.alias;h.textContent=f||d.split("/").pop().replace(".md","").replace(".colophon",""),h.title=`Click to open ${d}`}else{let h=u;(c.type==="paragraph"||c.type==="body")&&(h=u.createEl("p",{cls:c.type})),c.content&&c.content.forEach(d=>l(d,h))}};e&&e.content?l(e,a):a.setText("Click to edit..."),a.tabIndex=0,a.onfocus=()=>{this.editors.has(t)||(i?i():this.createMiniEditor(t,e,r))}}createMiniEditor(t,e,r){r.empty();let i=this.provider.getAdapter();if(!i)return;let s=i.sharedExtensions,o=this.app.vault.getConfig("spellcheck"),a=new er({element:r,app:this.app,plugin:this.plugin,extensions:s,content:e,onUpdate:({editor:l})=>{let c=this.provider.getAdapter();c&&c.updateFootnote(t,l.getJSON())},onSelectionUpdate:({editor:l})=>{this.provider.updateActiveEditor(l)},onFocus:({editor:l})=>{this.blurTimers.has(t)&&(clearTimeout(this.blurTimers.get(t)),this.blurTimers.delete(t)),this.provider.updateActiveEditor(l),this.plugin&&this.plugin.setActiveEditor(l)},onBlur:({editor:l})=>{let c=l.getJSON(),u=this.provider.getAdapter();u&&u.updateFootnote(t,c);let h=setTimeout(()=>{if(!l.isFocused&&this.editors.has(t)){let d=this.provider.getAdapter();(this.provider.getActiveEditor?this.provider.getActiveEditor():d?d.view.activeEditor:null)===l&&this.provider.updateActiveEditor(null),this.plugin&&this.plugin.activeTiptapEditor===l&&this.plugin.setActiveEditor(null),l.destroy(),this.editors.delete(t),this.renderPreview(t,c,r)}this.blurTimers.delete(t)},150);this.blurTimers.set(t,h)},editorProps:{handleKeyDown:(l,c)=>{if(c.key==="Tab"&&c.shiftKey){c.preventDefault();let u=this.provider.getAdapter();return u&&u.focusMarker(t),!0}return!1},attributes:{class:"colophon-footnote-editor footnote",spellcheck:o?"true":"false"}}});this.editors.set(t,a),a.commands.focus("end"),a.view.dom.addEventListener("beforeinput",l=>{let c={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};c[l.inputType]&&(l.preventDefault(),a.chain().focus()[c[l.inputType]]().run())}),this.app&&this.plugin&&new Je(this.app,this.plugin,a)}focusEditor(t){this.focusTimer&&clearTimeout(this.focusTimer),this.focusTimer=setTimeout(()=>{let e=this.editors.get(t);if(!e){let r=this.containerEl.querySelector(`[data-footnote-id="${t}"]`);if(r){let i=r.querySelector(".colophon-footnote-editor-container"),s=this.provider.getAdapter(),a=(s?s.getFootnotes():[]).find(l=>l.id===t);a&&i&&(this.createMiniEditor(t,a.content,i),e=this.editors.get(t))}}if(e){e.commands.focus("end");let r=this.containerEl.querySelector(`[data-footnote-id="${t}"]`);r&&r.scrollIntoView({behavior:"smooth",block:"center"})}this.focusTimer=null},50)}renderComments(){let t=this.provider.getAdapter();if(!t){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"The margins are quiet."});return}let e=t.comments||{},r=JSON.stringify(e),i=!!this.contentEl.querySelector(".colophon-comment-list");if(this.lastCommentsJSON===r&&i)return;this.lastCommentsJSON=r;let s=[];if(t.editor.state.doc.descendants(c=>{c.marks&&c.marks.forEach(u=>{if(u.type.name==="commentHighlight"&&u.attrs.threadId){let h=u.attrs.threadId;e[h]&&!s.some(d=>d.id===h)&&s.push({id:h,data:e[h]})}})}),s.length===0){this.cleanupEditors(),this.contentEl.empty(),this.contentEl.createDiv({cls:"colophon-panel-empty",text:"No comments here yet."});return}let o=this.contentEl.querySelector(".colophon-comment-list");o||(this.contentEl.empty(),o=this.contentEl.createDiv({cls:"colophon-comment-list"}));let a=new Set(s.map(c=>c.id));for(let[c,u]of this.editors)c.startsWith("comment-")&&!a.has(c.split(":")[0])&&(u.destroy(),this.editors.delete(c));o.querySelectorAll(".colophon-comment-thread").forEach(c=>{a.has(c.dataset.threadId)||c.remove()}),s.forEach((c,u)=>{let h=o.querySelector(`[data-thread-id="${c.id}"]`);h||(h=o.createDiv({cls:"colophon-comment-thread"}),h.dataset.threadId=c.id),this.renderCommentCard(c.id,c.data,h)}),s.forEach((c,u)=>{let h=o.querySelector(`[data-thread-id="${c.id}"]`);h&&o.children[u]!==h&&o.insertBefore(h,o.children[u])})}renderCommentCard(t,e,r){let i=r.querySelector(".colophon-comment-card");i||(i=r.createDiv({cls:"colophon-comment-card"}));let s=i.querySelector(".colophon-comment-items");s||(s=i.createDiv({cls:"colophon-comment-items"}));let o=new Set(e.map((c,u)=>u.toString()));s.querySelectorAll("[data-comment-index]").forEach(c=>{o.has(c.dataset.commentIndex)||c.remove()}),e.forEach((c,u)=>{let h=s.querySelector(`[data-comment-index="${u}"]`);if(!h){let y=u>0;h=s.createDiv({cls:y?"colophon-comment-reply":"colophon-comment-parent"}),h.dataset.commentIndex=u;let b=h.createDiv({cls:"colophon-comment-header"});b.createSpan({cls:"colophon-comment-author",text:c.author}),b.createSpan({cls:"colophon-comment-date"}),h.createDiv({cls:"colophon-comment-editor-container"})}let d=h.querySelector(".colophon-comment-date"),f=new Date(c.date).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});d.getText()!==f&&d.setText(f);let p=h.querySelector(".colophon-comment-editor-container"),m=`${t}:${u}`,g=this.editors.get(m);if(g){if(!g.isFocused){let y=JSON.stringify(g.getJSON()),b=JSON.stringify(c.content);y!==b&&g.commands.setContent(c.content,!1)}}else this.renderPreview(m,c.content,p,()=>{this.createCommentEditor(t,u,c,p)}),p.onclick=()=>{this.editors.has(m)||this.createCommentEditor(t,u,c,p)}});let l=i.querySelector(".colophon-comment-footer");if(!l){l=i.createDiv({cls:"colophon-comment-footer"});let c=l.createEl("button",{cls:"colophon-comment-action"});(0,Sr.setIcon)(c.createSpan({cls:"colophon-comment-action-icon"}),"reply"),c.createSpan({text:"Reply"}),c.onclick=()=>this.addReply(t);let u=l.createEl("button",{cls:"colophon-comment-action is-danger"});(0,Sr.setIcon)(u.createSpan({cls:"colophon-comment-action-icon"}),"trash-2"),u.createSpan({text:"Delete"}),u.onclick=()=>this.deleteThread(t)}}addReply(t){let e=this.provider.getAdapter();if(!e||!e.comments[t])return;let r=this.plugin.settings.authorName||this.app.vault.getName(),i=new Date().toISOString(),s={author:r,date:i,content:{type:"doc",content:[{type:"body"}]},replies:[]};e.comments[t].push(s),this.refresh();let o=e.comments[t].length-1;setTimeout(()=>{let a=this.containerEl.querySelector(`[data-thread-id="${t}"]`);if(a){let c=a.querySelector(".colophon-comment-reply:last-of-type")?.querySelector(".colophon-comment-editor-container");c&&this.createCommentEditor(t,o,s,c)}},50)}deleteThread(t){let e=this.provider.getAdapter();if(!e)return;let{tr:r}=e.editor.state;e.editor.state.doc.descendants((i,s)=>{i.marks&&i.marks.forEach(o=>{o.type.name==="commentHighlight"&&o.attrs.threadId===t&&r.removeMark(s,s+i.nodeSize,o.type)})}),e.editor.view.dispatch(r),delete e.comments[t],this.refresh()}createCommentEditor(t,e,r,i){let s=`${t}:${e}`;if(this.editors.has(s))return;i.empty();let o=this.provider.getAdapter();if(!o)return;let a=o.sharedExtensions,l=this.app.vault.getConfig("spellcheck"),c=JSON.parse(JSON.stringify(r.content)),u=new er({element:i,app:this.app,plugin:this.plugin,extensions:a,content:c,onUpdate:({editor:h})=>{r.content=h.getJSON();let d=this.provider.getAdapter();d&&d.onUpdate&&d.onUpdate()},onSelectionUpdate:({editor:h})=>{this.provider.updateActiveEditor(h)},onFocus:({editor:h})=>{this.blurTimers.has(s)&&(clearTimeout(this.blurTimers.get(s)),this.blurTimers.delete(s)),this.provider.updateActiveEditor(h),this.plugin&&this.plugin.setActiveEditor(h)},onBlur:({editor:h})=>{let d=h.getJSON();r.content=d;let f=this.provider.getAdapter();f&&f.onUpdate&&f.onUpdate();let p=setTimeout(()=>{!h.isFocused&&this.editors.has(s)&&((this.provider.getActiveEditor?this.provider.getActiveEditor():f?f.view.activeEditor:null)===h&&this.provider.updateActiveEditor(null),this.plugin&&this.plugin.activeTiptapEditor===h&&this.plugin.setActiveEditor(null),h.destroy(),this.editors.delete(s),this.renderPreview(s,d,i)),this.blurTimers.delete(s)},150);this.blurTimers.set(s,p)},editorProps:{attributes:{class:"colophon-comment-editor",spellcheck:l?"true":"false"}}});this.editors.set(s,u),u.commands.focus("end"),u.view.dom.addEventListener("beforeinput",h=>{let d={formatBold:"toggleBold",formatItalic:"toggleItalic",formatUnderline:"toggleUnderline",formatStrikeThrough:"toggleStrike"};d[h.inputType]&&(h.preventDefault(),u.chain().focus()[d[h.inputType]]().run())}),this.app&&this.plugin&&new Je(this.app,this.plugin,u)}show(t="footnotes",e=null){this.activeTab!==t&&(this.lastFootnotesJSON=null,this.provider.updateActiveEditor(null)),this.activeTab=t,this.isVisible=!0,this.containerEl.addClass("is-visible"),this.lastFootnotesJSON=null,this.lastCommentsJSON=null,this.refresh();let r=this.provider.getToolbar?this.provider.getToolbar():null;r&&r.update(),e&&requestAnimationFrame(()=>e())}hide(){this.isVisible=!1,this.containerEl.removeClass("is-visible");let t=this.provider.getToolbar?this.provider.getToolbar():null;t&&t.update()}toggle(t="footnotes"){this.isVisible&&this.activeTab===t?this.hide():this.show(t)}cleanupEditors(){this.editors.forEach(t=>t.destroy()),this.editors.clear()}destroy(){this.cleanupEditors(),this.containerEl&&this.containerEl.remove()}};var us=require("obsidian"),hs=class{constructor(t,e){this.view=t,this.parentEl=e,this.isVisible=!1,this.caseSensitive=!1,this.useRegex=!1,this.wholeWord=!1,this.render()}render(){this.containerEl=document.createElement("div"),this.containerEl.className="colophon-find-replace-bar",this.containerEl.setAttribute("style","display: none;");let t=this.containerEl.createDiv({cls:"cfr-main-row"}),e=t.createDiv({cls:"cfr-section cfr-find-section"});this.findInput=e.createEl("input",{type:"text",placeholder:"Find...",cls:"cfr-input"}),this.searchInfo=e.createDiv({cls:"cfr-info",text:"0 of 0"});let r=e.createDiv({cls:"cfr-button-group"});this.prevBtn=r.createEl("button",{cls:"cfr-button",attr:{tabindex:"-1"}}),(0,us.setIcon)(this.prevBtn,"chevron-up"),this.nextBtn=r.createEl("button",{cls:"cfr-button",attr:{tabindex:"-1"}}),(0,us.setIcon)(this.nextBtn,"chevron-down");let i=e.createDiv({cls:"cfr-button-group"});this.caseBtn=i.createEl("button",{cls:"cfr-button",text:"Aa",title:"Match Case",attr:{tabindex:"-1"}}),this.regexBtn=i.createEl("button",{cls:"cfr-button",text:".*",title:"Use Regular Expression",attr:{tabindex:"-1"}}),this.wordBtn=i.createEl("button",{cls:"cfr-button",text:'""',title:"Match Whole Word",attr:{tabindex:"-1"}});let s=t.createDiv({cls:"cfr-section cfr-replace-section"});this.replaceInput=s.createEl("input",{type:"text",placeholder:"Replace...",cls:"cfr-input"});let o=s.createDiv({cls:"cfr-button-group"});this.replaceBtn=o.createEl("button",{cls:"cfr-button",text:"Replace",attr:{tabindex:"-1"}}),this.replaceAllBtn=o.createEl("button",{cls:"cfr-button",text:"Replace All",attr:{tabindex:"-1"}}),this.closeBtn=t.createEl("button",{cls:"cfr-button cfr-close",attr:{tabindex:"-1"}}),(0,us.setIcon)(this.closeBtn,"x"),this.setupEvents()}setupEvents(){this.findInput.addEventListener("input",()=>this.updateSearch()),this.findInput.addEventListener("keydown",t=>{t.key==="Enter"?t.shiftKey?this.prev():this.next():t.key==="Escape"&&this.close()}),this.replaceInput.addEventListener("keydown",t=>{t.key==="Enter"?this.replace():t.key==="Escape"&&this.close()}),this.nextBtn.addEventListener("click",()=>this.next()),this.prevBtn.addEventListener("click",()=>this.prev()),this.caseBtn.addEventListener("click",()=>{this.caseSensitive=!this.caseSensitive,this.caseBtn.toggleClass("is-active",this.caseSensitive),this.updateSearch()}),this.regexBtn.addEventListener("click",()=>{this.useRegex=!this.useRegex,this.regexBtn.toggleClass("is-active",this.useRegex),this.updateSearch()}),this.wordBtn.addEventListener("click",()=>{this.wholeWord=!this.wholeWord,this.wordBtn.toggleClass("is-active",this.wholeWord),this.updateSearch()}),this.replaceBtn.addEventListener("click",()=>this.replace()),this.replaceAllBtn.addEventListener("click",()=>this.replaceAll()),this.closeBtn.addEventListener("click",()=>this.close())}updateSearch(){let t=this.findInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.setSearchOptions({caseSensitive:this.caseSensitive,disableRegex:!this.useRegex,wholeWord:this.wholeWord}),this.view.adapter.editor.commands.setSearchQuery(t),this.updateInfo())}updateInfo(){if(!this.view.adapter||!this.view.adapter.editor)return;let t=this.view.adapter.editor.storage.search,e=t.results.length,r=e>0?t.activeIndex+1:0;this.searchInfo.setText(`${r} of ${e}`)}next(){this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.nextSearchResult(),this.updateInfo())}prev(){this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.previousSearchResult(),this.updateInfo())}replace(){let t=this.replaceInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.replace(t),this.updateInfo())}replaceAll(){let t=this.replaceInput.value;this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.replaceAll(t),this.updateInfo())}open(){this.isVisible=!0,this.containerEl.setAttribute("style","display: flex;"),this.findInput.focus(),this.findInput.select(),this.updateSearch()}openReplace(){this.isVisible=!0,this.containerEl.setAttribute("style","display: flex;"),this.replaceInput.focus(),this.replaceInput.select(),this.updateSearch()}close(){this.isVisible=!1,this.containerEl.setAttribute("style","display: none;"),this.view.adapter&&this.view.adapter.editor&&(this.view.adapter.editor.commands.setSearchQuery(""),this.view.adapter.editor.commands.focus())}toggle(){this.isVisible?this.close():this.open()}};var ee="colophon-view",rt=class extends Mn.TextFileView{constructor(t,e){super(t),this.plugin=e,this.scope=new Mn.Scope(this.app.scope),this.adapter=null,this.docType="manuscript",this.activeEditor=null,this.wordCountIndicator=null}updateActiveEditor(t){this.activeEditor=t,this.toolbar&&this.toolbar.update()}getViewType(){return ee}getDisplayText(){return this.file?this.file.basename:"No File"}getIcon(){return this.docType==="script"?"clapperboard":"feather"}onPaneMenu(t,e){super.onPaneMenu(t,e),t.addItem(r=>{r.setTitle("Export to DOCX format").setIcon("download").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-docx")})}),t.addItem(r=>{r.setTitle("Export to Markdown format").setIcon("file-text").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-markdown")})}),this.docType==="script"&&t.addItem(r=>{r.setTitle("Export to Fountain format").setIcon("file-output").onClick(()=>{this.app.commands.executeCommandById("colophon-writer:export-to-fountain")})}),t.addItem(r=>{let i=this.plugin.settings.showWordCount;r.setTitle(i?"Hide word count":"Show word count").setIcon("hash").onClick(()=>{this.toggleWordCount()})}),t.addItem(r=>{let i=this.docType==="script";r.setTitle(i?"Switch to Manuscript mode":"Switch to Script mode").setIcon(i?"feather":"clapperboard").onClick(()=>{this.toggleMode()})})}toggleMode(){this.docType=this.docType==="script"?"manuscript":"script";let{state:t}=this.adapter.editor;if(t.doc.content.size<=2){let e=this.docType==="script"?"script-action":"body";this.adapter.editor.chain().setNode(e).run()}this.updateViewMode(),this.requestSave()}updateViewMode(){if(this.contentEl.removeClass("type-manuscript","type-script","is-manuscript-mode","is-script-mode"),this.contentEl.addClass(`type-${this.docType}`),this.contentEl.addClass(`is-${this.docType}-mode`),this.scrollContainer&&(this.scrollContainer.removeClass("is-manuscript-mode","is-script-mode"),this.scrollContainer.addClass(`is-${this.docType}-mode`)),this.adapter&&(this.adapter.type=this.docType,this.adapter.editor)){let t=this.app.vault.getConfig("spellcheck");this.adapter.editor.setOptions({editorProps:{attributes:{class:`colophon-editor colophon-main-editor type-${this.docType} is-${this.docType}-mode`,spellcheck:t?"true":"false"}}})}this.leaf&&this.leaf.tabHeaderInnerIconEl&&((0,Mn.setIcon)(this.leaf.tabHeaderInnerIconEl,this.getIcon()),this.icon=this.getIcon())}toggleWordCount(){this.plugin.settings.showWordCount=!this.plugin.settings.showWordCount,this.plugin.saveSettings(),this.updateWordCountIndicator()}updateWordCountIndicator(){if(!this.plugin.settings.showWordCount){this.wordCountIndicator&&(this.wordCountIndicator.remove(),this.wordCountIndicator=null);return}this.wordCountIndicator||(this.wordCountIndicator=this.contentEl.createDiv({cls:"colophon-word-count-indicator"}));let t=this.adapter?this.adapter.getWordCount():{doc:0,total:0};this.wordCountIndicator.setText(`${t.doc} words / ${t.total} with footnotes`)}async onOpen(){if(await super.onOpen(),this.contentEl.addClass("colophon-view"),this.contentEl.addClass("colophon-workspace"),this.mainLayout){this.mainLayout.parentElement!==this.contentEl&&(this.contentEl.empty(),this.contentEl.appendChild(this.mainLayout)),this.refreshSidebarVisibility();return}this.mainLayout=this.contentEl.createDiv({cls:"colophon-main-layout"}),this.layoutBody=this.mainLayout.createDiv({cls:"colophon-layout-body"}),this.scrollContainer=this.layoutBody.createDiv({cls:"colophon-scroll-container colophon-editor-host"}),this.zAxisPanel=new Tn(this.app,this.plugin,{getAdapter:()=>this.adapter,updateActiveEditor:e=>this.updateActiveEditor(e),getActiveEditor:()=>this.activeEditor,getToolbar:()=>this.toolbar},this.layoutBody);let t=this.containerEl.querySelector(".view-header");if(t){t.addClass("colophon-view-header");let e=t.querySelector(".view-header-title-container");e&&(e.setAttribute("style","display: flex;"),this.toolbar=new Mi(this,e))}this.updateWordCountIndicator(),this.refreshSidebarVisibility(),this.findReplaceBar=new hs(this,this.mainLayout),this.mainLayout.prepend(this.findReplaceBar.containerEl),this.registerHotkeyFromCommand("editor:toggle-bold",()=>this.toggleBold()),this.registerHotkeyFromCommand("editor:toggle-italics",()=>this.toggleItalic()),this.registerHotkeyFromCommand("editor:toggle-strikethrough",()=>this.toggleStrike()),this.registerHotkeyFromCommand("editor:toggle-underline",()=>this.toggleUnderline()),this.registerHotkeyFromCommand("editor:insert-footnote",()=>this.insertFootnote()),this.registerHotkeyFromCommand("editor:open-search",()=>this.findReplaceBar.open()),this.registerHotkeyFromCommand("editor:open-replace",()=>this.findReplaceBar.openReplace()),this.registerHotkeyFromCommand("editor:find-next",()=>{this.adapter&&this.adapter.editor&&this.adapter.editor.commands.nextSearchResult()}),this.registerHotkeyFromCommand("editor:find-previous",()=>{this.adapter&&this.adapter.editor&&this.adapter.editor.commands.previousSearchResult()}),this.registerHotkeyFromCommand("colophon-writer:insert-comment",()=>this.insertComment()),this.registerHotkeyFromCommand("colophon-writer:toggle-small-caps",()=>this.toggleSmallCaps()),this.scope.register(["Mod"],"b",e=>(e.preventDefault(),this.toggleBold(),!0)),this.scope.register(["Mod"],"i",e=>(e.preventDefault(),this.toggleItalic(),!0))}registerHotkeyFromCommand(t,e){let r=this.app.hotkeyManager;if(!r)return;let i=r.getHotkeys(t),s=r.getDefaultHotkeys(t),o=i&&i.length>0?i:s;o&&Array.isArray(o)&&o.forEach(a=>{let l=a.key.toLowerCase();this.scope.register(a.modifiers,l,c=>(c.preventDefault(),e(),!0))})}showZAxisTab(t){this.zAxisPanel&&this.zAxisPanel.show(t)}async onClose(){await super.onClose(),this.adapter&&(this.adapter.destroy(),this.adapter=null),this.zAxisPanel&&(this.zAxisPanel.destroy(),this.zAxisPanel=null),this.scrollContainer&&this.scrollContainer.empty()}refreshSidebarVisibility(){this.plugin.settings.sidebarLocation==="global"?(this.mainLayout.addClass("is-global-sidebar"),this.zAxisPanel&&this.zAxisPanel.hide()):this.mainLayout.removeClass("is-global-sidebar")}toggleFootnotes(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&(this.zAxisPanel.toggle("footnotes"),this.plugin.settings.lastZAxisState={visible:this.zAxisPanel.isVisible,activeTab:this.zAxisPanel.activeTab},this.plugin.saveSettings())}toggleComments(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&(this.zAxisPanel.toggle("comments"),this.plugin.settings.lastZAxisState={visible:this.zAxisPanel.isVisible,activeTab:this.zAxisPanel.activeTab},this.plugin.saveSettings())}showFootnotes(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&this.zAxisPanel.show("footnotes")}showComments(){if(this.plugin.settings.sidebarLocation==="global"){this.plugin.openSidebar();return}this.zAxisPanel&&this.zAxisPanel.show("comments")}setViewData(t,e){if(!e&&t===this.lastLoadedData)return;this.lastLoadedData=t;let r={type:"manuscript",doc:null,footnotes:{},comments:{}};try{t&&t.trim()!==""&&(r=JSON.parse(t))}catch(s){console.error("Colophon: Error parsing file data",s)}r&&r.doc&&this.migrateContent(r.doc),r&&r.footnotes&&this.migrateComments(r),this.docType=r.type||"manuscript",this.updateViewMode(),this.updateSettings();let i=this.app.vault.getConfig("spellcheck");this.adapter?e&&(this.adapter.type=this.docType,this.adapter.setContent(r.doc||{},r.footnotes||{},r.comments||{}),this.adapter.editor&&this.adapter.editor.setOptions({editorProps:{attributes:{class:`colophon-editor colophon-main-editor type-${this.docType} is-${this.docType}-mode`,spellcheck:i?"true":"false"}}}),this.zAxisPanel&&this.zAxisPanel.isVisible&&this.zAxisPanel.update()):(this.adapter=new Ti(this.scrollContainer,{content:r.doc,footnotes:r.footnotes||{},comments:r.comments||{},type:this.docType,settings:this.plugin?this.plugin.settings:null,isSpellcheckEnabled:i,app:this.app,plugin:this.plugin,view:this,onUpdate:()=>{this.requestSave(),this.toolbar&&this.toolbar.update(),this.findReplaceBar&&this.findReplaceBar.updateInfo(),this.updateWordCountIndicator(),this.plugin.settings.sidebarLocation==="global"?this.plugin.sidebarManager.update():this.zAxisPanel&&this.zAxisPanel.debouncedUpdate()}}),this.zAxisPanel&&this.plugin.settings.sidebarLocation!=="global"&&this.plugin.settings.lastZAxisState.visible?this.zAxisPanel.show(this.plugin.settings.lastZAxisState.activeTab):this.zAxisPanel&&this.zAxisPanel.isVisible&&this.zAxisPanel.update())}getViewData(){if(!this.adapter)return"";let t=this.adapter.getActiveFootnoteIds(),e={};if(this.adapter.footnotes)for(let o in this.adapter.footnotes)t.has(o)&&(e[o]=this.adapter.footnotes[o]);let r=this.adapter.getActiveCommentThreadIds(),i={};if(this.adapter.comments)for(let o in this.adapter.comments)r.has(o)&&(i[o]=this.adapter.comments[o]);let s={type:this.docType,doc:this.adapter.getJSON(),footnotes:e,comments:i};return JSON.stringify(s,null,2)}clear(){this.adapter&&this.adapter.editor&&this.adapter.editor.commands.clearContent()}toggleBold(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleBold().run()}toggleItalic(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleItalic().run()}toggleStrike(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleStrike().run()}toggleUnderline(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleUnderline().run()}toggleSuperscript(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleSuperscript().unsetSubscript().run()}toggleSubscript(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleSubscript().unsetSuperscript().run()}toggleSmallCaps(){let t=this.activeEditor||(this.adapter?this.adapter.editor:null);t&&t.chain().focus().toggleSmallCaps().run()}insertFootnote(){if(!this.adapter||this.docType==="script")return;let t=`fn-${crypto.randomUUID()}`;this.adapter.editor.chain().insertContent({type:"footnoteMarker",attrs:{id:t}}).run(),this.adapter.focusNote(t)}insertComment(){if(!this.adapter)return;let t=this.activeEditor||this.adapter.editor;if(!t||t.state.selection.empty)return;let e=`comment-${crypto.randomUUID()}`,r=this.plugin.settings.authorName||this.app.vault.getName(),i=new Date().toISOString();this.adapter.comments||(this.adapter.comments={}),this.adapter.comments[e]=[{author:r,date:i,content:{type:"doc",content:[{type:"body"}]},replies:[]}],t.chain().focus().setMark("commentHighlight",{threadId:e}).run(),this.adapter.focusComment(e)}updateSettings(){let t=this.plugin.settings;t.fixedFeedPosition?this.contentEl.addClass("is-fixed-feed"):this.contentEl.removeClass("is-fixed-feed"),this.adapter&&this.adapter.updateSettings(t),this.refreshSidebarVisibility()}migrateContent(t){t&&(t.type==="paragraph"&&(t.type="body"),t.content&&Array.isArray(t.content)&&t.content.forEach(e=>this.migrateContent(e)))}migrateComments(t){t.comments||(t.comments={});for(let e in t.footnotes)if(e.startsWith("comment-")){let r=e.split(":");if(r.length===2){let i=r[0],s=parseInt(r[1]),o=t.footnotes[e];t.comments[i]||(t.comments[i]=[]),t.comments[i][s]?t.comments[i][s].content=o:t.comments[i][s]={author:this.plugin.settings.authorName||this.app.vault.getName(),date:new Date().toISOString(),content:o,replies:[]},delete t.footnotes[e]}}}};var af=require("obsidian");var me="colophon-sidebar",ds=class extends af.ItemView{constructor(t,e){super(t),this.plugin=e,this.zAxisPanel=null,this.unsubscribe=null}getViewType(){return me}getDisplayText(){return"Colophon Sidebar"}getIcon(){return"columns"}async onOpen(){let{contentEl:t}=this;t.empty(),t.addClass("colophon-sidebar-view"),t.addClass("colophon-workspace"),this.zAxisPanel=new Tn(this.app,this.plugin,{getAdapter:()=>this.plugin.sidebarManager.getAdapter(),updateActiveEditor:e=>{let r=this.plugin.sidebarManager.activeView;r&&r.updateActiveEditor(e)},getActiveEditor:()=>{let e=this.plugin.sidebarManager.activeView;return e?e.activeEditor:null},getToolbar:()=>{let e=this.plugin.sidebarManager.activeView;return e?e.toolbar:null}},t),this.unsubscribe=this.plugin.sidebarManager.onUpdate(()=>{this.zAxisPanel.update()}),this.zAxisPanel.isVisible=!0,this.zAxisPanel.update()}async onClose(){this.unsubscribe&&this.unsubscribe(),this.zAxisPanel&&this.zAxisPanel.destroy()}};var Cr={globalScale:1,textColumnWidth:700,fixedFeedPosition:!1,feedPadding:40,sidebarLocation:"local",authorName:"",showWordCount:!0,lastZAxisState:{visible:!1,activeTab:"footnotes"},smartQuotes:!0,doubleQuoteStyle:"\u201C|\u201D",singleQuoteStyle:"\u2018|\u2019",smartDashes:!0,footnoteTrigger:"((",blocks:{body:{"after-block":"0pt","before-block":"0pt","first-indent":"0.3in","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0pt","line-spacing":"16pt",name:"Body","text-align":"left"},supertitle:{"after-block":"18pt","before-block":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","line-spacing":"14pt",name:"Supertitle","text-align":"center"},title:{"after-block":"4pt","before-block":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"18pt","font-variant":"regular","line-spacing":"18pt",name:"Title","text-align":"center"},subtitle:{"after-block":"28pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"14pt","font-variant":"regular","line-spacing":"18pt",name:"Subtitle","text-align":"center"},epigraph:{"after-block":"56pt","before-block":"48pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"1in","line-spacing":"16pt",name:"Epigraph","right-indent":"1in"},"body-first":{"after-block":"0pt","before-block":"0pt","first-indent":"0in","following-entity":"body","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"16pt",name:"Body First","text-align":"left"},footnote:{"after-block":"0pt","before-block":"0pt","first-indent":"0pt","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","font-variant":"regular","left-indent":"0in","line-spacing":"9pt",name:"Footnote","right-indent":"0pt","space-between-notes":"10pt"},"footnote-number":{"font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","font-weight":"bold","line-spacing":"9pt",name:"Footnote Number"},"footnote-symbol":{align:"4pt",color:"var(--text-normal)","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"7pt","line-height":"0pt",name:"Footnote Symbol"},"heading-1":{"after-block":"14pt","before-block":"28pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"italic","left-indent":"0in","line-spacing":"28pt",name:"Heading 1","right-indent":"0in","text-align":"left","syntax-trigger":"# "},"heading-2":{"after-block":"14pt","before-block":"28pt",capitalization:"small-caps","character-spacing":"4pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"28pt",name:"Heading 2","right-indent":"0in","text-align":"left","syntax-trigger":"## "},"heading-3":{"after-block":"14pt","before-block":"28pt","first-indent":"0in","following-block":"body-first","font-family":"var(--font-text-theme), var(--font-text-override)","font-size":"11.5pt","font-variant":"regular","left-indent":"0in","line-spacing":"28pt",name:"Heading 3","right-indent":"0in","text-align":"center","syntax-trigger":"### "},"script-scene":{"after-block":"12pt","before-block":"24pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Scene Heading","text-align":"left","following-block":"script-action","syntax-trigger":"INT."},"script-action":{"after-block":"12pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Action","text-align":"left","following-block":"script-action"},"script-character":{"after-block":"0pt","before-block":"12pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"2.0in",name:"Character","text-align":"left","following-block":"script-dialogue"},"script-parenthetical":{"after-block":"0pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"1.5in",name:"Parenthetical","text-align":"left","following-block":"script-dialogue","syntax-trigger":"("},"script-dialogue":{"after-block":"12pt","before-block":"0pt","script-mode":!0,"font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt","left-indent":"1.0in","right-indent":"1.5in",name:"Dialogue","text-align":"left","following-block":"script-character"},"script-transition":{"after-block":"12pt","before-block":"12pt","script-mode":!0,capitalization:"uppercase","font-family":"Courier, 'Courier New', monospace","font-size":"12pt","line-spacing":"12pt",name:"Transition","text-align":"right","following-block":"script-scene","syntax-trigger":">"}}};var fs=class{constructor(){this.styleTagId="colophon-dynamic-styles",this.settings=null}applyStyles(t){if(!t||!t.blocks)return;this.settings=t;let e="";e+=`.colophon-workspace { --colophon-editor-width: ${t.textColumnWidth||700}px; } +`;let r=t.blocks["footnote-symbol"];r&&(e+=`.colophon-footnote-marker { +`,r["font-family"]&&(e+=` font-family: ${this.normalizeValue(r["font-family"],"font-family")}; +`),r["font-size"]&&(e+=` font-size: ${this.normalizeValue(r["font-size"],"font-size")}; +`),r.color&&(e+=` color: ${r.color}; +`),r.align&&(e+=` vertical-align: ${this.normalizeValue(r.align,"align")}; +`,e+=` line-height: 0; +`),e+=`} +`);let i=t.blocks.footnote;if(i){let o=".colophon-workspace",a=".ProseMirror.colophon-footnote-editor",l=".colophon-footnote-preview";e+=`${o} ${a}, ${o} ${a} p, ${o} ${l}, ${o} ${l} p { +`;let c=this.getPropertyMap();for(let[u,h]of Object.entries(i))if(c[u]){let d=this.normalizeValue(h,u);e+=` ${c[u]}: ${d} !important; +`}if(i["font-variant"]){let u=i["font-variant"].toLowerCase();u==="italic"?e+=` font-style: italic !important; +`:u==="small-caps"&&(e+=` font-variant: small-caps !important; +`)}i["font-style"]&&(e+=` font-style: ${i["font-style"]} !important; +`),e+=` min-height: 1.2em !important; +`,e+=`} +`,i["space-between-notes"]&&(e+=`.colophon-footnote-item { margin-bottom: ${this.normalizeValue(i["space-between-notes"],"space-between-notes")}; } +`)}let s=t.blocks["footnote-number"];s&&(e+=`.colophon-footnote-number { +`,s["font-family"]&&(e+=` font-family: ${this.normalizeValue(s["font-family"],"font-family")}; +`),s["font-size"]&&(e+=` font-size: ${this.normalizeValue(s["font-size"],"font-size")}; +`),s["font-weight"]&&(e+=` font-weight: ${s["font-weight"]}; +`),e+=`} +`);for(let[o,a]of Object.entries(t.blocks))e+=this.generateBlockStyles(o,a);this.injectStyles(e)}getPropertyMap(){return{"after-block":"margin-bottom","before-block":"margin-top",color:"color","first-indent":"text-indent","font-family":"font-family","font-size":"font-size","line-spacing":"line-height","text-align":"text-align","left-indent":"padding-left","right-indent":"padding-right","font-weight":"font-weight","text-transform":"text-transform"}}generateBlockStyles(t,e){let r=".colophon-main-editor",i="p";if(t.startsWith("heading-")){let l=t.split("-")[1];l&&!isNaN(l)&&(i=`h${l}`)}let o=`${`${r} ${i}.${t}`} { +`,a=this.getPropertyMap();if(e.capitalization&&((e.capitalization==="all-caps"||e.capitalization==="uppercase")&&(o+=` text-transform: uppercase; +`),e.capitalization==="small-caps"&&(o+=` font-variant: small-caps; +`)),e["font-variant"]){let l=e["font-variant"].toLowerCase();l==="italic"?o+=` font-style: italic; `:l==="small-caps"?o+=` font-variant: small-caps; `:l!=="regular"&&l!=="normal"&&(o+=` font-variant: ${l}; -`)}n["font-style"]&&(o+=` font-style: ${n["font-style"]}; -`);for(let[l,c]of Object.entries(n))if(a[l]){let u=this.normalizeValue(c,l);o+=` ${a[l]}: ${u}; +`)}e["font-style"]&&(o+=` font-style: ${e["font-style"]}; +`);for(let[l,c]of Object.entries(e))if(a[l]){let u=this.normalizeValue(c,l);o+=` ${a[l]}: ${u}; `}return o+=`} -`,o}sanitizeFontFamily(e){if(typeof e!="string"||!e)return"";let n=["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fan-out"];return e.split(",").map(r=>{let i=r.trim();return i?(i=i.replace(/[;{}<>\\]/g,""),n.includes(i.toLowerCase())||i.startsWith("var(")?i:(i=i.replace(/^["'](.*)["']$/,"$1"),`"${i.replace(/"/g,'\\"')}"`)):""}).filter(r=>r!=="").join(", ")}normalizeValue(e,n){if(typeof e!="string")return e;if(n==="font-family")return this.sanitizeFontFamily(e);let r=e.match(/^([\d.]+)([a-z%]+)?$/);if(!r)return e;let i=parseFloat(r[1]),s=r[2];if(!s)return e;let o=this.settings?.globalScale||1;switch(s){case"pt":return`calc(${i/12} * ${o} * var(--font-text-size))`;case"pc":return`calc(${i} * ${o} * var(--font-text-size))`;case"in":return`calc(${i*6} * ${o} * var(--font-text-size))`;case"cm":return`calc(${i*(6/2.54)} * ${o} * var(--font-text-size))`;case"mm":return`calc(${i*(.6/2.54)} * ${o} * var(--font-text-size))`;case"px":return`${i}px`;case"rem":case"em":case"%":return e;default:return e}}injectStyles(e){let n=document.getElementById(this.styleTagId);n||(n=document.createElement("style"),n.id=this.styleTagId,document.head.appendChild(n)),n.textContent=e}};var je=require("obsidian");var U=require("obsidian");var Df=class extends U.Modal{constructor(e,n){super(e),this.onSubmit=n,this.id=""}onOpen(){let{contentEl:e}=this;new U.Setting(e).setName("New Block ID").setHeading(),new U.Setting(e).setName('Enter a unique ID for the new block (e.g., "quote", "sidebar-note"):').addText(n=>n.onChange(r=>{this.id=r})),new U.Setting(e).addButton(n=>n.setButtonText("Create").setCta().onClick(()=>{this.close(),this.onSubmit(this.id)}))}onClose(){let{contentEl:e}=this;e.empty()}},Rf=class extends U.Modal{constructor(e,n,r,i){super(e),this.title=n,this.message=r,this.onConfirm=i}onOpen(){let{contentEl:e}=this;new U.Setting(e).setName(this.title).setHeading(),e.createEl("p",{text:this.message}),new U.Setting(e).addButton(n=>n.setButtonText("Cancel").onClick(()=>this.close())).addButton(n=>n.setButtonText("Confirm").setWarning().onClick(()=>{this.close(),this.onConfirm()}))}onClose(){let{contentEl:e}=this;e.empty()}},hl=class{constructor(e,n){this.plugin=e,this.containerEl=n,this.blockSettingsContainer=null}display(){this.containerEl.empty(),this.containerEl.addClass("colophon-block-settings"),new U.Setting(this.containerEl).setName("Block Definitions").setHeading(),this.blockSettingsContainer=this.containerEl.createDiv("colophon-block-list"),this.renderBlockList(),new U.Setting(this.containerEl).setName("Add Custom Block").setDesc("Create a new block type with a unique ID.").addButton(e=>e.setButtonText("Add Block").setCta().onClick(()=>{this.addNewBlock()}))}renderBlockList(){this.blockSettingsContainer.empty();let e=this.plugin.settings.blocks,n=[],r=[];for(let[s,o]of Object.entries(e))o["script-mode"]===!0?r.push([s,o]):n.push([s,o]);let i=(s,o)=>{let a=String(s[1].name||s[0]).toLowerCase(),l=String(o[1].name||o[0]).toLowerCase();return a.localeCompare(l)};n.sort(i),r.sort(i),new U.Setting(this.blockSettingsContainer).setName("Manuscript Mode").setHeading();for(let[s,o]of n)this.renderBlockRow(s,o);if(r.length>0){this.blockSettingsContainer.createEl("br"),new U.Setting(this.blockSettingsContainer).setName("Script Mode").setHeading();for(let[s,o]of r)this.renderBlockRow(s,o)}}renderBlockRow(e,n){let r=Rs.blocks.hasOwnProperty(e),i=this.blockSettingsContainer.createEl("details",{cls:"colophon-block-row"}),s=i.createEl("summary"),o=new U.Setting(s).setName(n.name||e).setDesc(r?"Standard Block":"Custom Block");r||o.addExtraButton(d=>d.setIcon("trash").setTooltip("Delete Block").onClick(async f=>{f.stopPropagation(),new Rf(this.plugin.app,"Delete Block",`Are you sure you want to delete the block "${n.name||e}"?`,async()=>{delete this.plugin.settings.blocks[e],await this.plugin.saveSettings(),this.renderBlockList()}).open()}));let a=i.createDiv("colophon-block-content");new U.Setting(a).setName("Name").addText(d=>{d.setValue(n.name||""),r?d.setDisabled(!0):d.onChange(async f=>{this.plugin.settings.blocks[e].name=f,o.setName(f),await this.plugin.saveSettings()})}),new U.Setting(a).setName("Syntax Trigger").setDesc('Text that triggers this block (e.g. "### ").').addText(d=>d.setValue(n["syntax-trigger"]||"").onChange(async f=>{f?this.plugin.settings.blocks[e]["syntax-trigger"]=f:delete this.plugin.settings.blocks[e]["syntax-trigger"],await this.plugin.saveSettings()}));let l=a.createDiv("colophon-block-properties"),c=l.createDiv("colophon-add-property"),u=l.createDiv("colophon-properties-list");this.renderAddProperty(c,e,u),this.renderProperties(u,e)}renderProperties(e,n){e.empty();let r=this.plugin.settings.blocks[n],i=["name","syntax-trigger","hotkey"],s=Object.keys(r).filter(o=>!i.includes(o)).sort();for(let o of s)this.renderPropertyRow(e,n,o,r[o])}renderPropertyRow(e,n,r,i){let s=e.createDiv("colophon-property-row");s.createDiv("colophon-property-label").setText(r);let a=s.createDiv("colophon-property-input");this.renderField(a,n,r,i),new U.ButtonComponent(s).setIcon("trash").setTooltip("Remove Property").onClick(async()=>{delete this.plugin.settings.blocks[n][r],await this.plugin.saveSettings(),this.renderProperties(e,n)}).buttonEl.addClass("colophon-property-delete")}renderAddProperty(e,n,r){e.empty();let i=["after-block","before-block","capitalization","color","first-indent","following-entity","font-family","font-size","font-variant","inline-spacing","left-indent","line-spacing","list-type","marker","marker-baseline","marker-indent","marker-outdent","marker-size","marker-suffix","right-indent","space-between-notes","text-align","font-style","font-weight","text-transform"],s=Object.keys(this.plugin.settings.blocks[n]),o=i.filter(c=>!s.includes(c)).sort();if(o.length===0){e.createDiv({text:"All properties added.",cls:"colophon-text-muted"});return}let a=e.createDiv("colophon-add-prop-wrapper"),l=o[0];new U.DropdownComponent(a).addOptions(o.reduce((c,u)=>({...c,[u]:u}),{})).setValue(l).onChange(c=>l=c),new U.ButtonComponent(a).setButtonText("Add Property").onClick(async()=>{this.plugin.settings.blocks[n][l]=this.getDefaultValueFor(l),await this.plugin.saveSettings(),this.renderProperties(r,n),this.renderAddProperty(e,n,r)})}getDefaultValueFor(e){return e.includes("color")?"#000000":e.includes("list-type")?"unordered":e.includes("align")?"left":e.includes("capitalization")?"none":"0pt"}renderField(e,n,r,i){if(["after-block","before-block","first-indent","font-size","inline-spacing","left-indent","line-spacing","marker-baseline","marker-indent","marker-outdent","right-indent","space-between-notes"].includes(r)){this.renderMeasurementField(e,n,r,i);return}if(r==="color"){let s=new U.ColorComponent(e).setValue(i).onChange(async o=>{this.plugin.settings.blocks[n][r]=o,await this.plugin.saveSettings()});return}if(r==="capitalization"){new U.DropdownComponent(e).addOptions({none:"None","small-caps":"Small Caps","all-caps":"All Caps"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[n][r]=s,await this.plugin.saveSettings()});return}if(r==="list-type"){new U.DropdownComponent(e).addOptions({none:"None",ordered:"Ordered",unordered:"Unordered"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[n][r]=s,await this.plugin.saveSettings()});return}if(r==="text-align"){new U.DropdownComponent(e).addOptions({left:"Left",center:"Center",right:"Right",justify:"Justify"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[n][r]=s,await this.plugin.saveSettings()});return}if(r==="marker"){new U.DropdownComponent(e).addOptions({disc:"\u2022 Disc",circle:"\xB0 Circle",square:"\u25A0 Square",decimal:"1, 2, 3","lower-roman":"i, ii, iii","upper-roman":"I, II, III","lower-latin":"a, b, c","upper-latin":"A, B, C",none:"None"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[n][r]=s,await this.plugin.saveSettings()});return}new U.TextComponent(e).setValue(String(i)).onChange(async s=>{this.plugin.settings.blocks[n][r]=s,await this.plugin.saveSettings()})}renderMeasurementField(e,n,r,i){let s=String(i).match(/^([\d.-]+)([a-z%]+)?$/),o=s?s[1]:i,a=s?s[2]:"",l=e.createDiv("colophon-measurement-wrapper"),c=new U.TextComponent(l).setValue(o).onChange(async d=>{let f=u.getValue(),h=d+f;this.plugin.settings.blocks[n][r]=h,await this.plugin.saveSettings()});c.inputEl.style.width="60px";let u=new U.DropdownComponent(l).addOptions({pt:"pt",pc:"pc",in:"in",cm:"cm",mm:"mm",px:"px",em:"em",rem:"rem"}).setValue(a||"pt").onChange(async d=>{let h=c.getValue()+d;this.plugin.settings.blocks[n][r]=h,await this.plugin.saveSettings()})}addNewBlock(){new Df(this.plugin.app,e=>{if(e){let n=e.toLowerCase().replace(/[^a-z0-9-]/g,"-");if(this.plugin.settings.blocks[n]){new U.Notice("Block ID already exists.");return}this.plugin.settings.blocks[n]={name:e,"font-family":"inherit","font-size":"11pt","line-spacing":"14pt"},this.plugin.saveSettings().then(()=>{this.renderBlockList()})}}).open()}};var pl=class extends je.PluginSettingTab{constructor(e,n){super(e,n),this.plugin=n,this.id="colophon-writer",this.icon="feather"}display(){let{containerEl:e}=this;e.empty();let r=e.createDiv({cls:"setting-group"}).createDiv({cls:"setting-items"});new je.Setting(r).setName("Global scale").setDesc("Scale all typographic units (pt, in, etc.) relative to Obsidian's text size. 12pt = (Scale * Obsidian Text Size).").addSlider(a=>a.setLimits(.5,2,.1).setValue(this.plugin.settings.globalScale||1).setDynamicTooltip().onChange(async l=>{this.plugin.settings.globalScale=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Text column width").setDesc("Adjust the width of the writing canvas (500px - 1240px).").addSlider(a=>a.setLimits(500,1240,10).setValue(this.plugin.settings.textColumnWidth).setDynamicTooltip().onChange(async l=>{this.plugin.settings.textColumnWidth=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Fixed feed position").setDesc("Enforce a typewriter-style fixed active line position.").addToggle(a=>a.setValue(this.plugin.settings.fixedFeedPosition).onChange(async l=>{this.plugin.settings.fixedFeedPosition=l,await this.plugin.saveSettings(),this.display()})),this.plugin.settings.fixedFeedPosition&&new je.Setting(r).setName("Feed padding").setDesc("Vertical position of the active line (0% = bottom, 75% = top quarter).").addSlider(a=>a.setLimits(0,75,1).setValue(this.plugin.settings.feedPadding).setDynamicTooltip().onChange(async l=>{this.plugin.settings.feedPadding=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Smart quotes").setDesc("Automatically replace straight quotes with smart quotes.").addToggle(a=>a.setValue(this.plugin.settings.smartQuotes).onChange(async l=>{this.plugin.settings.smartQuotes=l,await this.plugin.saveSettings(),this.display()})),this.plugin.settings.smartQuotes&&(new je.Setting(r).setName("Double quote style").setDesc("Choose the style for double quotes.").addDropdown(a=>a.addOption("\u201C|\u201D","\u201Cabc\u201D").addOption("\u201E|\u201C","\u201Eabc\u201C").addOption("\u201E|\u201D","\u201Eabc\u201D").addOption("\u201D|\u201D","\u201Dabc\u201D").addOption("\xAB|\xBB","\xABabc\xBB").addOption("\xBB|\xAB","\xBBabc\xAB").addOption('"|"','"abc"').setValue(this.plugin.settings.doubleQuoteStyle).onChange(async l=>{this.plugin.settings.doubleQuoteStyle=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Single quote style").setDesc("Choose the style for single quotes.").addDropdown(a=>a.addOption("\u2018|\u2019","\u2018abc\u2019").addOption("\u201A|\u2018","\u201Aabc\u2018").addOption("\u201A|\u2019","\u201Aabc\u2019").addOption("\u2019|\u2019","\u2019abc\u2019").addOption("\u2039|\u203A","\u2039abc\u203A").addOption("\u203A|\u2039","\u203Aabc\u2039").addOption("'|'","'abc'").setValue(this.plugin.settings.singleQuoteStyle).onChange(async l=>{this.plugin.settings.singleQuoteStyle=l,await this.plugin.saveSettings()}))),new je.Setting(r).setName("Smart dashes").setDesc("Replace -- with em-dash (\u2014) and --- with en-dash (\u2013).").addToggle(a=>a.setValue(this.plugin.settings.smartDashes).onChange(async l=>{this.plugin.settings.smartDashes=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Footnote trigger").setDesc('Syntax trigger to insert a footnote. Default: "(("').addText(a=>a.setPlaceholder("((").setValue(this.plugin.settings.footnoteTrigger).onChange(async l=>{this.plugin.settings.footnoteTrigger=l,await this.plugin.saveSettings()})),new je.Setting(r).setName("Sidebar location").setDesc("Where to show footnotes and comments: in the document or the global sidebar.").addDropdown(a=>a.addOption("local","In Document").addOption("global","Global Sidebar").setValue(this.plugin.settings.sidebarLocation||"local").onChange(async l=>{this.plugin.settings.sidebarLocation=l,await this.plugin.saveSettings(),this.plugin.refreshLayout&&this.plugin.refreshLayout()}));let s=e.createDiv({cls:"setting-group"}).createDiv({cls:"setting-items"});new hl(this.plugin,s).display()}};var sr=require("obsidian"),ml=class{constructor(e){this.plugin=e,this.app=e.app,this.cacheFolderName=`${this.app.vault.configDir}/plugins/obsidian-colophon/.colophon-cache`,this.oldCacheFolderName=".colophon-cache"}setup(){this.app.workspace.onLayoutReady(async()=>{await this.cleanupOldCache(),await this.ensureCacheFolder(),await this.indexAllFiles()}),this.plugin.registerEvent(this.app.vault.on("modify",async e=>{e instanceof sr.TFile&&e.extension==="colophon"&&await this.indexFile(e)})),this.plugin.registerEvent(this.app.vault.on("rename",async(e,n)=>{e instanceof sr.TFile&&(e.extension==="colophon"?await this.handleColophonRename(e,n):await this.handleGenericRename(e,n))})),this.plugin.registerEvent(this.app.vault.on("delete",async e=>{e instanceof sr.TFile&&e.extension==="colophon"&&await this.removeShadowFile(e)}))}async cleanupOldCache(){if(await this.app.vault.adapter.exists(this.oldCacheFolderName))try{await this.app.vault.adapter.rmdir(this.oldCacheFolderName,!0)}catch{}}async ensureCacheFolder(){if(!await this.app.vault.adapter.exists(this.cacheFolderName)){let e=this.cacheFolderName.split("/"),n="";for(let r of e)n=n?`${n}/${r}`:r,await this.app.vault.adapter.exists(n)||await this.app.vault.adapter.mkdir(n)}}async indexAllFiles(){let e=this.app.vault.getFiles().filter(n=>n.extension==="colophon");for(let n of e)await this.indexFile(n)}async indexFile(e){try{let n=await this.app.vault.read(e),r=JSON.parse(n),i=[],s=[];if(this.extractMetadata(r.doc,i,s),r.footnotes)for(let o of Object.values(r.footnotes))this.extractMetadata(o,i,s);if(r.comments)for(let o of Object.values(r.comments))Array.isArray(o)&&o.forEach(a=>{a.content&&this.extractMetadata(a.content,i,s)});await this.updateShadowFile(e,i,s)}catch{}}extractMetadata(e,n,r){e&&(e.attrs&&e.attrs.id&&r.push(e.attrs.id),e.type==="internalLink"&&e.attrs&&e.attrs.target&&n.push(e.attrs.target),e.content&&Array.isArray(e.content)&&e.content.forEach(i=>this.extractMetadata(i,n,r)))}async updateShadowFile(e,n,r){let i=this.getShadowPath(e.path),s="";n.length>0&&(s+=n.map(o=>`[[${o}]]`).join(" "),s+=` +`,o}sanitizeFontFamily(t){if(typeof t!="string"||!t)return"";let e=["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fan-out"];return t.split(",").map(r=>{let i=r.trim();return i?(i=i.replace(/[;{}<>\\]/g,""),e.includes(i.toLowerCase())||i.startsWith("var(")?i:(i=i.replace(/^["'](.*)["']$/,"$1"),`"${i.replace(/"/g,'\\"')}"`)):""}).filter(r=>r!=="").join(", ")}normalizeValue(t,e){if(typeof t!="string")return t;if(e==="font-family")return this.sanitizeFontFamily(t);let r=t.match(/^([\d.]+)([a-z%]+)?$/);if(!r)return t;let i=parseFloat(r[1]),s=r[2];if(!s)return t;let o=this.settings?.globalScale||1;switch(s){case"pt":return`calc(${i/12} * ${o} * var(--font-text-size))`;case"pc":return`calc(${i} * ${o} * var(--font-text-size))`;case"in":return`calc(${i*6} * ${o} * var(--font-text-size))`;case"cm":return`calc(${i*(6/2.54)} * ${o} * var(--font-text-size))`;case"mm":return`calc(${i*(.6/2.54)} * ${o} * var(--font-text-size))`;case"px":return`${i}px`;case"rem":case"em":case"%":return t;default:return t}}injectStyles(t){let e=document.getElementById(this.styleTagId);e||(e=document.createElement("style"),e.id=this.styleTagId,document.head.appendChild(e)),e.textContent=t}};var Ot=require("obsidian");var H=require("obsidian");var rl=class extends H.Modal{constructor(t,e){super(t),this.onSubmit=e,this.id=""}onOpen(){let{contentEl:t}=this;new H.Setting(t).setName("New Block ID").setHeading(),new H.Setting(t).setName('Enter a unique ID for the new block (e.g., "quote", "sidebar-note"):').addText(e=>e.onChange(r=>{this.id=r})),new H.Setting(t).addButton(e=>e.setButtonText("Create").setCta().onClick(()=>{this.close(),this.onSubmit(this.id)}))}onClose(){let{contentEl:t}=this;t.empty()}},il=class extends H.Modal{constructor(t,e,r,i){super(t),this.title=e,this.message=r,this.onConfirm=i}onOpen(){let{contentEl:t}=this;new H.Setting(t).setName(this.title).setHeading(),t.createEl("p",{text:this.message}),new H.Setting(t).addButton(e=>e.setButtonText("Cancel").onClick(()=>this.close())).addButton(e=>e.setButtonText("Confirm").setWarning().onClick(()=>{this.close(),this.onConfirm()}))}onClose(){let{contentEl:t}=this;t.empty()}},ps=class{constructor(t,e){this.plugin=t,this.containerEl=e,this.blockSettingsContainer=null}display(){this.containerEl.empty(),this.containerEl.addClass("colophon-block-settings"),new H.Setting(this.containerEl).setName("Block Definitions").setHeading(),this.blockSettingsContainer=this.containerEl.createDiv("colophon-block-list"),this.renderBlockList(),new H.Setting(this.containerEl).setName("Add Custom Block").setDesc("Create a new block type with a unique ID.").addButton(t=>t.setButtonText("Add Block").setCta().onClick(()=>{this.addNewBlock()}))}renderBlockList(){this.blockSettingsContainer.empty();let t=this.plugin.settings.blocks,e=[],r=[];for(let[s,o]of Object.entries(t))o["script-mode"]===!0?r.push([s,o]):e.push([s,o]);let i=(s,o)=>{let a=String(s[1].name||s[0]).toLowerCase(),l=String(o[1].name||o[0]).toLowerCase();return a.localeCompare(l)};e.sort(i),r.sort(i),new H.Setting(this.blockSettingsContainer).setName("Manuscript Mode").setHeading();for(let[s,o]of e)this.renderBlockRow(s,o);if(r.length>0){this.blockSettingsContainer.createEl("br"),new H.Setting(this.blockSettingsContainer).setName("Script Mode").setHeading();for(let[s,o]of r)this.renderBlockRow(s,o)}}renderBlockRow(t,e){let r=Cr.blocks.hasOwnProperty(t),i=this.blockSettingsContainer.createEl("details",{cls:"colophon-block-row"}),s=i.createEl("summary"),o=new H.Setting(s).setName(e.name||t).setDesc(r?"Standard Block":"Custom Block");r||o.addExtraButton(h=>h.setIcon("trash").setTooltip("Delete Block").onClick(async d=>{d.stopPropagation(),new il(this.plugin.app,"Delete Block",`Are you sure you want to delete the block "${e.name||t}"?`,async()=>{delete this.plugin.settings.blocks[t],await this.plugin.saveSettings(),this.renderBlockList()}).open()}));let a=i.createDiv("colophon-block-content");new H.Setting(a).setName("Name").addText(h=>{h.setValue(e.name||""),r?h.setDisabled(!0):h.onChange(async d=>{this.plugin.settings.blocks[t].name=d,o.setName(d),await this.plugin.saveSettings()})}),new H.Setting(a).setName("Syntax Trigger").setDesc('Text that triggers this block (e.g. "### ").').addText(h=>h.setValue(e["syntax-trigger"]||"").onChange(async d=>{d?this.plugin.settings.blocks[t]["syntax-trigger"]=d:delete this.plugin.settings.blocks[t]["syntax-trigger"],await this.plugin.saveSettings()}));let l=a.createDiv("colophon-block-properties"),c=l.createDiv("colophon-add-property"),u=l.createDiv("colophon-properties-list");this.renderAddProperty(c,t,u),this.renderProperties(u,t)}renderProperties(t,e){t.empty();let r=this.plugin.settings.blocks[e],i=["name","syntax-trigger","hotkey"],s=Object.keys(r).filter(o=>!i.includes(o)).sort();for(let o of s)this.renderPropertyRow(t,e,o,r[o])}renderPropertyRow(t,e,r,i){let s=t.createDiv("colophon-property-row");s.createDiv("colophon-property-label").setText(r);let a=s.createDiv("colophon-property-input");this.renderField(a,e,r,i),new H.ButtonComponent(s).setIcon("trash").setTooltip("Remove Property").onClick(async()=>{delete this.plugin.settings.blocks[e][r],await this.plugin.saveSettings(),this.renderProperties(t,e)}).buttonEl.addClass("colophon-property-delete")}renderAddProperty(t,e,r){t.empty();let i=["after-block","before-block","capitalization","color","first-indent","following-entity","font-family","font-size","font-variant","inline-spacing","left-indent","line-spacing","list-type","marker","marker-baseline","marker-indent","marker-outdent","marker-size","marker-suffix","right-indent","space-between-notes","text-align","font-style","font-weight","text-transform"],s=Object.keys(this.plugin.settings.blocks[e]),o=i.filter(c=>!s.includes(c)).sort();if(o.length===0){t.createDiv({text:"All properties added.",cls:"colophon-text-muted"});return}let a=t.createDiv("colophon-add-prop-wrapper"),l=o[0];new H.DropdownComponent(a).addOptions(o.reduce((c,u)=>({...c,[u]:u}),{})).setValue(l).onChange(c=>l=c),new H.ButtonComponent(a).setButtonText("Add Property").onClick(async()=>{this.plugin.settings.blocks[e][l]=this.getDefaultValueFor(l),await this.plugin.saveSettings(),this.renderProperties(r,e),this.renderAddProperty(t,e,r)})}getDefaultValueFor(t){return t.includes("color")?"#000000":t.includes("list-type")?"unordered":t.includes("align")?"left":t.includes("capitalization")?"none":"0pt"}renderField(t,e,r,i){if(["after-block","before-block","first-indent","font-size","inline-spacing","left-indent","line-spacing","marker-baseline","marker-indent","marker-outdent","right-indent","space-between-notes"].includes(r)){this.renderMeasurementField(t,e,r,i);return}if(r==="color"){let s=new H.ColorComponent(t).setValue(i).onChange(async o=>{this.plugin.settings.blocks[e][r]=o,await this.plugin.saveSettings()});return}if(r==="capitalization"){new H.DropdownComponent(t).addOptions({none:"None","small-caps":"Small Caps","all-caps":"All Caps"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[e][r]=s,await this.plugin.saveSettings()});return}if(r==="list-type"){new H.DropdownComponent(t).addOptions({none:"None",ordered:"Ordered",unordered:"Unordered"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[e][r]=s,await this.plugin.saveSettings()});return}if(r==="text-align"){new H.DropdownComponent(t).addOptions({left:"Left",center:"Center",right:"Right",justify:"Justify"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[e][r]=s,await this.plugin.saveSettings()});return}if(r==="marker"){new H.DropdownComponent(t).addOptions({disc:"\u2022 Disc",circle:"\xB0 Circle",square:"\u25A0 Square",decimal:"1, 2, 3","lower-roman":"i, ii, iii","upper-roman":"I, II, III","lower-latin":"a, b, c","upper-latin":"A, B, C",none:"None"}).setValue(i).onChange(async s=>{this.plugin.settings.blocks[e][r]=s,await this.plugin.saveSettings()});return}new H.TextComponent(t).setValue(String(i)).onChange(async s=>{this.plugin.settings.blocks[e][r]=s,await this.plugin.saveSettings()})}renderMeasurementField(t,e,r,i){let s=String(i).match(/^([\d.-]+)([a-z%]+)?$/),o=s?s[1]:i,a=s?s[2]:"",l=t.createDiv("colophon-measurement-wrapper"),c=new H.TextComponent(l).setValue(o).onChange(async h=>{let d=u.getValue(),f=h+d;this.plugin.settings.blocks[e][r]=f,await this.plugin.saveSettings()});c.inputEl.style.width="60px";let u=new H.DropdownComponent(l).addOptions({pt:"pt",pc:"pc",in:"in",cm:"cm",mm:"mm",px:"px",em:"em",rem:"rem"}).setValue(a||"pt").onChange(async h=>{let f=c.getValue()+h;this.plugin.settings.blocks[e][r]=f,await this.plugin.saveSettings()})}addNewBlock(){new rl(this.plugin.app,t=>{if(t){let e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-");if(this.plugin.settings.blocks[e]){new H.Notice("Block ID already exists.");return}this.plugin.settings.blocks[e]={name:t,"font-family":"inherit","font-size":"11pt","line-spacing":"14pt"},this.plugin.saveSettings().then(()=>{this.renderBlockList()})}}).open()}};var ms=class extends Ot.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e,this.id="colophon-writer",this.icon="feather"}display(){let{containerEl:t}=this;t.empty();let r=t.createDiv({cls:"setting-group"}).createDiv({cls:"setting-items"});new Ot.Setting(r).setName("Global scale").setDesc("Scale all typographic units (pt, in, etc.) relative to Obsidian's text size. 12pt = (Scale * Obsidian Text Size).").addSlider(a=>a.setLimits(.5,2,.1).setValue(this.plugin.settings.globalScale||1).setDynamicTooltip().onChange(async l=>{this.plugin.settings.globalScale=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Text column width").setDesc("Adjust the width of the writing canvas (500px - 1240px).").addSlider(a=>a.setLimits(500,1240,10).setValue(this.plugin.settings.textColumnWidth).setDynamicTooltip().onChange(async l=>{this.plugin.settings.textColumnWidth=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Fixed feed position").setDesc("Enforce a typewriter-style fixed active line position.").addToggle(a=>a.setValue(this.plugin.settings.fixedFeedPosition).onChange(async l=>{this.plugin.settings.fixedFeedPosition=l,await this.plugin.saveSettings(),this.display()})),this.plugin.settings.fixedFeedPosition&&new Ot.Setting(r).setName("Feed padding").setDesc("Vertical position of the active line (0% = bottom, 75% = top quarter).").addSlider(a=>a.setLimits(0,75,1).setValue(this.plugin.settings.feedPadding).setDynamicTooltip().onChange(async l=>{this.plugin.settings.feedPadding=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Smart quotes").setDesc("Automatically replace straight quotes with smart quotes.").addToggle(a=>a.setValue(this.plugin.settings.smartQuotes).onChange(async l=>{this.plugin.settings.smartQuotes=l,await this.plugin.saveSettings(),this.display()})),this.plugin.settings.smartQuotes&&(new Ot.Setting(r).setName("Double quote style").setDesc("Choose the style for double quotes.").addDropdown(a=>a.addOption("\u201C|\u201D","\u201Cabc\u201D").addOption("\u201E|\u201C","\u201Eabc\u201C").addOption("\u201E|\u201D","\u201Eabc\u201D").addOption("\u201D|\u201D","\u201Dabc\u201D").addOption("\xAB|\xBB","\xABabc\xBB").addOption("\xBB|\xAB","\xBBabc\xAB").addOption('"|"','"abc"').setValue(this.plugin.settings.doubleQuoteStyle).onChange(async l=>{this.plugin.settings.doubleQuoteStyle=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Single quote style").setDesc("Choose the style for single quotes.").addDropdown(a=>a.addOption("\u2018|\u2019","\u2018abc\u2019").addOption("\u201A|\u2018","\u201Aabc\u2018").addOption("\u201A|\u2019","\u201Aabc\u2019").addOption("\u2019|\u2019","\u2019abc\u2019").addOption("\u2039|\u203A","\u2039abc\u203A").addOption("\u203A|\u2039","\u203Aabc\u2039").addOption("'|'","'abc'").setValue(this.plugin.settings.singleQuoteStyle).onChange(async l=>{this.plugin.settings.singleQuoteStyle=l,await this.plugin.saveSettings()}))),new Ot.Setting(r).setName("Smart dashes").setDesc("Replace -- with em-dash (\u2014) and --- with en-dash (\u2013).").addToggle(a=>a.setValue(this.plugin.settings.smartDashes).onChange(async l=>{this.plugin.settings.smartDashes=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Footnote trigger").setDesc('Syntax trigger to insert a footnote. Default: "(("').addText(a=>a.setPlaceholder("((").setValue(this.plugin.settings.footnoteTrigger).onChange(async l=>{this.plugin.settings.footnoteTrigger=l,await this.plugin.saveSettings()})),new Ot.Setting(r).setName("Sidebar location").setDesc("Where to show footnotes and comments: in the document or the global sidebar.").addDropdown(a=>a.addOption("local","In Document").addOption("global","Global Sidebar").setValue(this.plugin.settings.sidebarLocation||"local").onChange(async l=>{this.plugin.settings.sidebarLocation=l,await this.plugin.saveSettings(),this.plugin.refreshLayout&&this.plugin.refreshLayout()}));let s=t.createDiv({cls:"setting-group"}).createDiv({cls:"setting-items"});new ps(this.plugin,s).display()}};var Ye=require("obsidian"),gs=class{constructor(t){this.plugin=t,this.app=t.app,this.cacheFolderName=`${this.app.vault.configDir}/plugins/obsidian-colophon/.colophon-cache`,this.oldCacheFolderName=".colophon-cache"}setup(){this.app.workspace.onLayoutReady(async()=>{await this.cleanupOldCache(),await this.ensureCacheFolder(),await this.indexAllFiles()}),this.plugin.registerEvent(this.app.vault.on("modify",async t=>{t instanceof Ye.TFile&&t.extension==="colophon"&&await this.indexFile(t)})),this.plugin.registerEvent(this.app.vault.on("rename",async(t,e)=>{t instanceof Ye.TFile&&(t.extension==="colophon"?await this.handleColophonRename(t,e):await this.handleGenericRename(t,e))})),this.plugin.registerEvent(this.app.vault.on("delete",async t=>{t instanceof Ye.TFile&&t.extension==="colophon"&&await this.removeShadowFile(t)}))}async cleanupOldCache(){if(await this.app.vault.adapter.exists(this.oldCacheFolderName))try{await this.app.vault.adapter.rmdir(this.oldCacheFolderName,!0)}catch{}}async ensureCacheFolder(){if(!await this.app.vault.adapter.exists(this.cacheFolderName)){let t=this.cacheFolderName.split("/"),e="";for(let r of t)e=e?`${e}/${r}`:r,await this.app.vault.adapter.exists(e)||await this.app.vault.adapter.mkdir(e)}}async indexAllFiles(){let t=this.app.vault.getFiles().filter(e=>e.extension==="colophon");for(let e of t)await this.indexFile(e)}async indexFile(t){try{let e=await this.app.vault.read(t),r=JSON.parse(e),i=[],s=[];if(this.extractMetadata(r.doc,i,s),r.footnotes)for(let o of Object.values(r.footnotes))this.extractMetadata(o,i,s);if(r.comments)for(let o of Object.values(r.comments))Array.isArray(o)&&o.forEach(a=>{a.content&&this.extractMetadata(a.content,i,s)});await this.updateShadowFile(t,i,s)}catch{}}extractMetadata(t,e,r){t&&(t.attrs&&t.attrs.id&&r.push(t.attrs.id),t.type==="internalLink"&&t.attrs&&t.attrs.target&&e.push(t.attrs.target),t.content&&Array.isArray(t.content)&&t.content.forEach(i=>this.extractMetadata(i,e,r)))}async updateShadowFile(t,e,r){let i=this.getShadowPath(t.path),s="";e.length>0&&(s+=e.map(o=>`[[${o}]]`).join(" "),s+=` `),r.length>0&&(s+=r.map(o=>`^${o}`).join(" "),s+=` -`),await this.app.vault.adapter.exists(i)?await this.app.vault.adapter.read(i)!==s&&await this.app.vault.adapter.write(i,s):await this.app.vault.adapter.write(i,s)}getShadowPath(e){let n=btoa(e).replace(/\//g,"_").replace(/=/g,"");return(0,sr.normalizePath)(`${this.cacheFolderName}/${n}.md`)}getColophonPathFromShadow(e){let n=e.split("/").pop().replace(".md","");try{let r=n.replace(/_/g,"/");for(;r.length%4;)r+="=";return atob(r)}catch{return null}}async removeShadowFile(e){let n=this.getShadowPath(e.path);await this.app.vault.adapter.exists(n)&&await this.app.vault.adapter.remove(n)}async handleColophonRename(e,n){let r=this.getShadowPath(n);await this.app.vault.adapter.exists(r)&&await this.app.vault.adapter.remove(r),await this.indexFile(e)}async handleGenericRename(e,n){let r=this.app.metadataCache.resolvedLinks,i=new Set;for(let[s,o]of Object.entries(r))if(o[n]!==void 0&&s.startsWith(this.cacheFolderName)){let a=this.getColophonPathFromShadow(s);a&&i.add(a)}for(let s of i){let o=this.app.vault.getAbstractFileByPath(s);if(!(o instanceof sr.TFile))continue;let a=await this.app.vault.read(o),l=JSON.parse(a),c=!1,u=d=>{d.type==="internalLink"&&d.attrs&&d.attrs.target===n&&(d.attrs.target=e.path,c=!0),d.content&&Array.isArray(d.content)&&d.content.forEach(u)};if(u(l.doc),l.footnotes)for(let d of Object.values(l.footnotes))u(d);if(l.comments)for(let d of Object.values(l.comments))Array.isArray(d)&&d.forEach(f=>{f.content&&u(f.content)});c&&(await this.app.vault.modify(o,JSON.stringify(l,null,2)),await this.indexFile(o))}}};var gl=class{constructor(e){this.plugin=e,this.app=e.app,this.activeView=null,this.listeners=new Set}setup(){this.plugin.registerEvent(this.app.workspace.on("active-leaf-change",e=>{this.handleActiveLeafChange(e)})),this.plugin.registerEvent(this.app.workspace.on("layout-change",()=>{this.activeView&&(this.app.workspace.getLeavesOfType(_t).some(r=>r.view===this.activeView)||this.setActiveView(null))})),this.focusHandler=e=>{e instanceof CustomEvent&&this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusNote(e.detail.id)},this.createHandler=e=>{e instanceof CustomEvent&&this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusNote(e.detail.id)},document.body.addEventListener("colophon:footnote:focus",this.focusHandler),document.body.addEventListener("colophon:footnote:create",this.createHandler),this.app.workspace.onLayoutReady(()=>{let e=this.app.workspace.getLeavesOfType(_t);e.length>0&&!this.activeView&&this.setActiveView(e[0].view)})}destroy(){document.body.removeEventListener("colophon:footnote:focus",this.focusHandler),document.body.removeEventListener("colophon:footnote:create",this.createHandler)}handleActiveLeafChange(e){if(!e){this.setActiveView(null);return}let n=e.view;if(n.getViewType()===_t)this.setActiveView(n);else{if(n.getViewType()===Yt)return;(n.getViewType()==="markdown"||n.file&&n.file.extension!=="colophon")&&this.setActiveView(null)}}setActiveView(e){this.activeView!==e&&(this.activeView=e,this.notifyListeners())}getAdapter(){return this.activeView?this.activeView.adapter:null}onUpdate(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.activeView))}update(){this.notifyListeners()}focusMarker(e){this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusMarker(e)}};var Qt=require("obsidian"),yl=class extends Qt.Modal{constructor(e,n){super(e),this.onExport=n,this.settings={pageSize:"Letter",margins:{top:1,bottom:1,left:1,right:1},scale:100}}onOpen(){let{contentEl:e}=this;e.empty(),new Qt.Setting(e).setName("Export to Word (.docx)").setHeading(),new Qt.Setting(e).setName("Page size").setDesc("Select the page size for the exported document.").addDropdown(s=>{s.addOption("Letter",'Letter (8.5" x 11")').addOption("Legal",'Legal (8.5" x 14")').addOption("A4","A4 (210mm x 297mm)").setValue(this.settings.pageSize).onChange(o=>{this.settings.pageSize=o})}),new Qt.Setting(e).setName("Margins").setHeading();let n=new Qt.Setting(e).setName("Margins (inches)");n.settingEl.addClass("colophon-export-margins");let r=n.controlEl.createDiv({cls:"colophon-export-margins__grid"}),i=(s,o)=>{let a=r.createDiv({cls:"colophon-export-margins__field"});a.createDiv({text:s,cls:"colophon-export-margins__label"});let l=a.createEl("input",{type:"number"});l.addClass("colophon-export-margins__input"),l.step="0.1",l.min="0",l.max="5",l.value=String(this.settings.margins?.[o]??1),l.addEventListener("change",()=>{let c=parseFloat(l.value);isNaN(c)||(c=Math.max(0,Math.min(5,c)),l.value=String(c),this.settings.margins[o]=c)})};i("Top","top"),i("Right","right"),i("Bottom","bottom"),i("Left","left"),new Qt.Setting(e).setName("Scale (%)").setDesc("Adjust the font size scale for the exported document.").addSlider(s=>{s.setLimits(50,200,5).setValue(this.settings.scale).setDynamicTooltip().onChange(o=>{this.settings.scale=o})}),new Qt.Setting(e).setName("Export").setDesc("Generate a .docx using the settings above.").addButton(s=>{s.setButtonText("Export").setCta().onClick(()=>{this.close(),this.onExport(this.settings)})})}onClose(){let{contentEl:e}=this;e.empty()}};var Nw=si(_w()),bl=class extends Q.Plugin{activeTiptapEditor=null;setActiveEditor(e){this.activeTiptapEditor=e}interceptCoreCommands(){[{id:"editor:toggle-bold",method:"toggleBold"},{id:"editor:toggle-italics",method:"toggleItalic"},{id:"editor:toggle-strikethrough",method:"toggleStrike"},{id:"editor:toggle-highlight",method:"toggleUnderline"}].forEach(n=>{let r=this.app.commands.commands[n.id];r&&(r.originalCheckCallback||(r.originalCheckCallback=r.checkCallback||r.callback),r.checkCallback=i=>this.activeTiptapEditor?(i||this.activeTiptapEditor.chain().focus()[n.method]().run(),!0):r.originalCheckCallback?r.originalCheckCallback(i):!1)})}async onload(){let e=await this.loadData()||{};this.settings=Object.assign({},Rs,e),e.blocks&&(this.settings.blocks=Object.assign({},Rs.blocks,e.blocks)),this.markdownBridge=new Nw.default,this.metadataManager=new ml(this),this.metadataManager.setup(),this.sidebarManager=new gl(this),this.sidebarManager.setup(),this.styleManager=new fl,this.styleManager.applyStyles(this.settings),this.addSettingTab(new pl(this.app,this)),this.registerView(_t,n=>new pe(n,this)),this.registerView(Yt,n=>new dl(n,this)),this.registerExtensions(["colophon"],_t),this.addRibbonIcon("feather","New Colophon Manuscript",()=>{this.createNewColophonFile("manuscript")}),this.addRibbonIcon("clapperboard","New Colophon Script",()=>{this.createNewColophonFile("script")}),this.addCommand({id:"new-manuscript",name:"New Manuscript",callback:()=>this.createNewColophonFile("manuscript")}),this.addCommand({id:"new-script",name:"New Script",callback:()=>this.createNewColophonFile("script")}),this.addCommand({id:"open-sidebar",name:"Open Sidebar",callback:()=>this.openSidebar()}),this.addCommand({id:"open-find-replace",name:"Open Find/Replace",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r?(n||r.findReplaceBar&&r.findReplaceBar.open(),!0):!1}}),this.addCommand({id:"open-replace",name:"Open Replace",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r?(n||r.findReplaceBar&&r.findReplaceBar.openReplace(),!0):!1}}),this.addCommand({id:"find-next",name:"Find Next",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter&&r.adapter.editor?(n||r.adapter.editor.commands.nextSearchResult(),!0):!1}}),this.addCommand({id:"find-previous",name:"Find Previous",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter&&r.adapter.editor?(n||r.adapter.editor.commands.previousSearchResult(),!0):!1}}),this.addCommand({id:"export-to-docx",name:"Export to Word (.docx)",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter?(n||new yl(this.app,i=>{r.adapter.editor.commands.exportToDocx({settings:i,footnotes:r.adapter.footnotes,comments:r.adapter.comments,stylesConfig:this.settings.blocks})}).open(),!0):!1}}),this.addCommand({id:"export-to-markdown",name:"Export to Markdown (.md)",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter?(n||this.exportToMarkdown(r),!0):!1}}),this.addCommand({id:"export-to-fountain",name:"Export to Fountain (.fountain)",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter&&r.docType==="script"?(n||r.adapter.editor.commands.exportToFountain({}),!0):!1}}),this.addCommand({id:"insert-internal-link",name:"Insert Internal Link",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter?(n||r.adapter.editor.commands.insertContent("[["),!0):!1}}),this.addCommand({id:"insert-footnote",name:"Insert Footnote",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);return r&&r.adapter?(n||r.insertFootnote(),!0):!1}}),this.addCommand({id:"insert-comment",name:"Insert Comment",checkCallback:n=>{let r=this.app.workspace.getActiveViewOfType(pe);if(r&&r.adapter){let i=r.activeEditor||(r.adapter?r.adapter.editor:null);if(i&&!i.state.selection.empty)return n||r.insertComment(),!0}return!1}}),this.addCommand({id:"toggle-bold",name:"Toggle Bold",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleBold().run(),!0):!1}),this.addCommand({id:"toggle-italic",name:"Toggle Italic",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleItalic().run(),!0):!1}),this.addCommand({id:"toggle-strikethrough",name:"Toggle Strikethrough",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleStrike().run(),!0):!1}),this.addCommand({id:"toggle-underline",name:"Toggle Underline",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleUnderline().run(),!0):!1}),this.addCommand({id:"toggle-superscript",name:"Toggle Superscript",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleSuperscript().unsetSubscript().run(),!0):!1}),this.addCommand({id:"toggle-subscript",name:"Toggle Subscript",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleSubscript().unsetSuperscript().run(),!0):!1}),this.addCommand({id:"toggle-small-caps",name:"Toggle Small Caps",checkCallback:n=>this.activeTiptapEditor?(n||this.activeTiptapEditor.chain().focus().toggleSmallCaps().run(),!0):!1}),this.addCommand({id:"colophon:add-link",name:"Agent: Add Link",callback:n=>{let{target:r,alias:i}=n||{},s=this.app.workspace.getActiveViewOfType(pe);s&&s.adapter&&s.adapter.addLink({target:r,alias:i})}}),this.addCommand({id:"colophon:set-block-type",name:"Agent: Set Block Type",callback:n=>{let{typeId:r}=n||{};if(!r)return;let i=this.app.workspace.getActiveViewOfType(pe);i&&i.adapter&&i.adapter.setBlockType(r)}}),this.addCommand({id:"colophon:focus-footnote",name:"Agent: Focus Footnote",callback:n=>{let{id:r}=n||{};if(!r)return;let i=this.app.workspace.getActiveViewOfType(pe);i&&i.adapter&&i.adapter.focusNote(r)}}),this.addCommand({id:"convert-legacy-manuscripts",name:"Convert Legacy Manuscript Files",callback:()=>this.convertLegacyManuscriptFiles()}),this.registerEvent(this.app.workspace.on("editor-menu",(n,r,i)=>{if(i instanceof pe)r.getSelection()&&n.addItem(s=>{s.setTitle("Add comment").setIcon("message-square-plus").onClick(()=>{i.insertComment()})});else{let s=i.file;s&&s.extension==="md"&&this.app.metadataCache.getFileCache(s)?.frontmatter?.["colophon-plugin"]==="manuscript"&&n.addItem(l=>{l.setTitle("Convert legacy to standard Colophon").setIcon("zap").onClick(async()=>{await this.convertSingleLegacyFile(s)})})}})),this.registerEvent(this.app.workspace.on("file-menu",(n,r)=>{r instanceof Q.TFolder?(n.addItem(i=>{i.setTitle("New manuscript").setIcon("feather").onClick(async()=>{await this.createNewColophonFile("manuscript",r.path)})}),n.addItem(i=>{i.setTitle("New script").setIcon("clapperboard").onClick(async()=>{await this.createNewColophonFile("script",r.path)})})):r instanceof Q.TFile&&r.extension==="md"&&(this.app.metadataCache.getFileCache(r)?.frontmatter?.["colophon-plugin"]==="manuscript"&&n.addItem(o=>{o.setTitle("Convert legacy to standard Colophon").setIcon("zap").onClick(async()=>{await this.convertSingleLegacyFile(r)})}),n.addItem(o=>{o.setTitle("Convert to Colophon manuscript format").setIcon("feather").onClick(async()=>{await this.convertToColophon(r)})}))})),this.app.workspace.onLayoutReady(()=>{this.settings.sidebarLocation!=="global"&&this.app.workspace.getLeavesOfType(Yt).forEach(n=>{n.detach()}),console.log("Colophon plugin loaded")}),this.app.workspace.onLayoutReady(()=>{this.interceptCoreCommands()})}onunload(){["editor:toggle-bold","editor:toggle-italics","editor:toggle-strikethrough","editor:toggle-highlight"].forEach(n=>{let r=this.app.commands.commands[n];r&&r.originalCheckCallback&&(r.checkCallback=r.originalCheckCallback,delete r.originalCheckCallback)}),this.sidebarManager&&this.sidebarManager.destroy()}async exportToMarkdown(e){if(!e||!e.adapter)return;let n=e.file,r=JSON.parse(e.getViewData()),i=this.markdownBridge.dehydrate(r.doc,r.footnotes||{},r.comments||{}),s=n.path.replace(/\.colophon$/,".md"),o=s,a=1;for(;this.app.vault.getAbstractFileByPath(o)!==null;)o=s.replace(/\.md$/,` ${a}.md`),a++;try{await this.app.vault.create(o,i),new Q.Notice(`Exported to ${o}`)}catch(l){console.error("Colophon: Failed to export Markdown",l),new Q.Notice("Failed to export Markdown")}}async convertToColophon(e){if(e instanceof Q.TFile)try{let n=await this.app.vault.read(e),r=this.markdownBridge.hydrate(n),i=e.path.replace(/\.md$/,".colophon"),s=i,o=1;for(;this.app.vault.getAbstractFileByPath(s)!==null;)s=i.replace(/\.colophon$/,` ${o}.colophon`),o++;await this.app.vault.create(s,JSON.stringify(r,null,2)),new Q.Notice(`Converted to ${s}`);let a=this.app.vault.getAbstractFileByPath(s);a instanceof Q.TFile&&await this.app.workspace.getLeaf(!0).openFile(a)}catch(n){console.error("Colophon: Failed to convert to Colophon",n),new Q.Notice("Failed to convert to Colophon")}}async convertSingleLegacyFile(e){try{let n=await this.app.vault.read(e),r=this.parseLegacyFormat(n);if(!r){new Q.Notice("Failed to parse legacy data block");return}let i=this.transformLegacyData(r),s=this.markdownBridge.dehydrate(i.doc,i.footnotes||{},i.comments||{}),o=this.markdownBridge.hydrate(s),a=e.path.replace(/\.md$/,".colophon"),l=a,c=1;for(;this.app.vault.getAbstractFileByPath(l)!==null;)l=a.replace(/\.colophon$/,` ${c}.colophon`),c++;await this.app.vault.create(l,JSON.stringify(o,null,2)),await this.app.vault.delete(e),new Q.Notice(`Converted legacy file to ${l}`);let u=this.app.vault.getAbstractFileByPath(l);u instanceof Q.TFile&&await this.app.workspace.getLeaf(!0).openFile(u)}catch(n){console.error(`Colophon: Error converting ${e.path}:`,n),new Q.Notice(`Error converting file: ${n.message}`)}}async saveSettings(){await this.saveData(this.settings),this.styleManager&&this.styleManager.applyStyles(this.settings),this.app.workspace.getLeavesOfType(_t).forEach(e=>{e.view&&typeof e.view.updateSettings=="function"&&e.view.updateSettings()})}async createNewColophonFile(e,n=""){let r="Untitled",i=(0,Q.normalizePath)(n?`${n}/${r}.colophon`:`${r}.colophon`),s=1;for(;this.app.vault.getAbstractFileByPath(i)!==null;)i=(0,Q.normalizePath)(n?`${n}/${r} ${s}.colophon`:`${r} ${s}.colophon`),s++;let o={type:e,doc:{type:"doc",content:[{type:e==="script"?"script-action":"body",content:[]}]}};try{let a=await this.app.vault.create(i,JSON.stringify(o,null,2));await this.app.workspace.getLeaf(!0).openFile(a),setTimeout(()=>{let c=this.app.workspace.getLeavesOfType("file-explorer")[0];c&&(this.app.workspace.revealLeaf(c),c.view&&c.view.revealInFolder&&c.view.revealInFolder(a)),new Lf(this.app,a,async u=>{let d=n?`${n}/${u}.colophon`:`${u}.colophon`;await this.app.fileManager.renameFile(a,d)}).open()},100)}catch(a){console.error("Failed to create Colophon file:",a)}}refreshLayout(){let e=this.settings.sidebarLocation==="global";this.app.workspace.getLeavesOfType(_t).forEach(n=>{n.view instanceof pe&&n.view.refreshSidebarVisibility()}),e||this.app.workspace.getLeavesOfType(Yt).forEach(n=>{n.detach()}),this.sidebarManager&&this.sidebarManager.update()}async openSidebar(){let{workspace:e}=this.app,n=null,r=e.getLeavesOfType(Yt);r.length>0?n=r[0]:(n=e.getRightLeaf(!1),await n.setViewState({type:Yt,active:!0})),e.revealLeaf(n)}async convertLegacyManuscriptFiles(){let e=this.app.vault.getFiles().filter(s=>s.extension==="md"),n=[];for(let s of e)this.app.metadataCache.getCache(s.path)?.frontmatter?.["colophon-plugin"]==="manuscript"&&n.push(s);if(n.length===0){new Q.Notice("No legacy manuscript files found.");return}let r={converted:0,skipped:0,errors:[]};for(let s of n)try{let o=await this.app.vault.read(s),a=this.parseLegacyFormat(o);if(!a){r.skipped++,r.errors.push({file:s.path,error:"Failed to parse colophon data block"}),console.error(`Colophon: Failed to parse legacy file: ${s.path}`);continue}let l=this.transformLegacyData(a),c=s.path.replace(/\.md$/,".colophon");if(this.app.vault.getAbstractFileByPath(c)!==null){let u=1,d=c.replace(".colophon","");for(;this.app.vault.getAbstractFileByPath(`${d} ${u}.colophon`)!==null;)u++;await this.app.vault.create(`${d} ${u}.colophon`,JSON.stringify(l,null,2))}else await this.app.vault.create(c,JSON.stringify(l,null,2));await this.app.vault.delete(s),r.converted++}catch(o){r.errors.push({file:s.path,error:o.message}),console.error(`Colophon: Error converting ${s.path}:`,o)}let i=`Converted ${r.converted} files.`;r.skipped>0&&(i+=` ${r.skipped} skipped.`),r.errors.length>0&&(i+=` ${r.errors.length} errors.`),new Q.Notice(i),r.errors.length>0&&console.error("Colophon: Legacy conversion errors:",r.errors)}parseLegacyFormat(e){let n=e.match(/%% colophon:data\s*(\{[\s\S]*\})\s*%%/);if(!n)return null;try{return JSON.parse(n[1])}catch(r){return console.error("Colophon: Failed to parse legacy data block:",r),null}}transformLegacyData(e){if(this.migrateContentNodes(e.doc),Array.isArray(e.footnotes)){let n={};e.footnotes.forEach(r=>{let i=r.id||`fn-${crypto.randomUUID()}`,s=r.content||{type:"doc",content:[{type:"body"}]};this.migrateContentNodes(s),n[i]=s}),e.footnotes=n}else e.footnotes=e.footnotes||{};if(Array.isArray(e.comments)){let n={};e.comments.forEach(r=>{let i=r.id||`comment-${crypto.randomUUID()}`;r.content&&this.migrateContentNodes(r.content),r.replies||(r.replies=[]),n[i]=[r]}),e.comments=n}else e.comments=e.comments||{};return{type:"manuscript",doc:e.doc,footnotes:e.footnotes,comments:e.comments}}migrateContentNodes(e){if(!e)return;let n=()=>Math.random().toString(36).substring(2,8),r=e.attrs?.class,i=["body","supertitle","title","subtitle","epigraph","body-first","footnote","heading-1","heading-2","heading-3"],s=["MsoNormal","MsoNoSpacing","MsoFootnoteText","MsoListParagraph"];if(e.type==="paragraph"||e.type==="blockquote"||e.type==="codeBlock"||e.type==="listItem"||r&&s.includes(r))r&&i.includes(r)?e.type=r:e.type="body",e.attrs||(e.attrs={}),e.attrs.id=n(),delete e.attrs.class;else if(e.type==="heading"){let a=e.attrs?.level;r==="title"?e.type="title":a?e.type=`heading-${a}`:e.type="heading-1",e.attrs||(e.attrs={}),e.attrs.id=n(),delete e.attrs.level,delete e.attrs.class}else e.type==="footnote"&&(e.type="footnoteMarker");if((["body","title","subtitle","supertitle","epigraph","body-first","footnote","footnoteMarker","heading-1","heading-2","heading-3","paragraph","listItem"].includes(e.type)||e.type.startsWith("heading-"))&&this.migrateMarks(e),e.content&&Array.isArray(e.content)){let a=[];for(let l of e.content)if(l.type==="bulletList"||l.type==="orderedList"){if(l.content&&Array.isArray(l.content))for(let c of l.content)c.type==="listItem"&&c.content&&(c.content.forEach(u=>this.migrateContentNodes(u)),a.push(...c.content))}else a.push(l);e.content=a,e.content.forEach(l=>{(!l.attrs?.id||!i.includes(l.type))&&this.migrateContentNodes(l)})}}migrateMarks(e){if(!e||!e.content||!Array.isArray(e.content))return;let n=[];for(let r of e.content){let i=r.marks?.find(s=>s.type==="internallink"||s.type==="link"&&s.attrs?.class==="internal-link");if(i&&r.type==="text"){n.push({type:"internalLink",attrs:{target:i.attrs?.href||"",alias:i.attrs?.text||r.text||""}});continue}r.marks&&(r.marks=r.marks.map(s=>s.type==="comment"?{type:"commentHighlight",attrs:{threadId:s.attrs?.id||s.attrs?.threadId}}:s),r.marks=r.marks.filter(s=>s.type!=="internallink"&&!(s.type==="link"&&s.attrs?.class==="internal-link")),r.marks.length===0&&delete r.marks),n.push(r)}e.content=n}},Lf=class extends Q.Modal{constructor(e,n,r){super(e),this.file=n,this.onSubmit=r,this.basename=n.basename}onOpen(){let{contentEl:e}=this;e.empty(),e.createDiv({cls:"modal-header"}).createEl("div",{cls:"modal-title",text:"File name"});let i=e.createDiv({cls:"modal-content"}).createEl("input",{type:"text",value:this.basename});i.setAttribute("style","width: 100%; margin-bottom: 1rem;"),i.select();let s=e.createDiv({cls:"modal-button-container"}),o=s.createEl("button",{text:"Cancel"}),a=s.createEl("button",{cls:"mod-cta",text:"Save"});o.addEventListener("click",()=>this.close());let l=()=>{let c=i.value.trim();c&&c!==this.basename&&this.onSubmit(c),this.close()};a.addEventListener("click",l),i.addEventListener("keydown",c=>{c.key==="Enter"?l():c.key==="Escape"&&this.close()})}onClose(){let{contentEl:e}=this;e.empty()}}; +`),await this.app.vault.adapter.exists(i)?await this.app.vault.adapter.read(i)!==s&&await this.app.vault.adapter.write(i,s):await this.app.vault.adapter.write(i,s)}getShadowPath(t){let e=btoa(t).replace(/\//g,"_").replace(/=/g,"");return(0,Ye.normalizePath)(`${this.cacheFolderName}/${e}.md`)}getColophonPathFromShadow(t){let e=t.split("/").pop().replace(".md","");try{let r=e.replace(/_/g,"/");for(;r.length%4;)r+="=";return atob(r)}catch{return null}}async removeShadowFile(t){let e=this.getShadowPath(t.path);await this.app.vault.adapter.exists(e)&&await this.app.vault.adapter.remove(e)}async handleColophonRename(t,e){let r=this.getShadowPath(e);await this.app.vault.adapter.exists(r)&&await this.app.vault.adapter.remove(r),await this.indexFile(t)}async handleGenericRename(t,e){let r=this.app.metadataCache.resolvedLinks,i=new Set;for(let[s,o]of Object.entries(r))if(o[e]!==void 0&&s.startsWith(this.cacheFolderName)){let a=this.getColophonPathFromShadow(s);a&&i.add(a)}for(let s of i){let o=this.app.vault.getAbstractFileByPath(s);if(!(o instanceof Ye.TFile))continue;let a=await this.app.vault.read(o),l=JSON.parse(a),c=!1,u=h=>{h.type==="internalLink"&&h.attrs&&h.attrs.target===e&&(h.attrs.target=t.path,c=!0),h.content&&Array.isArray(h.content)&&h.content.forEach(u)};if(u(l.doc),l.footnotes)for(let h of Object.values(l.footnotes))u(h);if(l.comments)for(let h of Object.values(l.comments))Array.isArray(h)&&h.forEach(d=>{d.content&&u(d.content)});c&&(await this.app.vault.modify(o,JSON.stringify(l,null,2)),await this.indexFile(o))}}};var ys=class{constructor(t){this.plugin=t,this.app=t.app,this.activeView=null,this.listeners=new Set}setup(){this.plugin.registerEvent(this.app.workspace.on("active-leaf-change",t=>{this.handleActiveLeafChange(t)})),this.plugin.registerEvent(this.app.workspace.on("layout-change",()=>{this.activeView&&(this.app.workspace.getLeavesOfType(ee).some(r=>r.view===this.activeView)||this.setActiveView(null))})),this.focusHandler=t=>{t instanceof CustomEvent&&this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusNote(t.detail.id)},this.createHandler=t=>{t instanceof CustomEvent&&this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusNote(t.detail.id)},document.body.addEventListener("colophon:footnote:focus",this.focusHandler),document.body.addEventListener("colophon:footnote:create",this.createHandler),this.app.workspace.onLayoutReady(()=>{let t=this.app.workspace.getLeavesOfType(ee);t.length>0&&!this.activeView&&this.setActiveView(t[0].view)})}destroy(){document.body.removeEventListener("colophon:footnote:focus",this.focusHandler),document.body.removeEventListener("colophon:footnote:create",this.createHandler)}handleActiveLeafChange(t){if(!t){this.setActiveView(null);return}let e=t.view;if(e.getViewType()===ee)this.setActiveView(e);else{if(e.getViewType()===me)return;(e.getViewType()==="markdown"||e.file&&e.file.extension!=="colophon")&&this.setActiveView(null)}}setActiveView(t){this.activeView!==t&&(this.activeView=t,this.notifyListeners())}getAdapter(){return this.activeView?this.activeView.adapter:null}onUpdate(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t(this.activeView))}update(){this.notifyListeners()}focusMarker(t){this.activeView&&this.activeView.adapter&&this.activeView.adapter.focusMarker(t)}};var ge=require("obsidian"),bs=class extends ge.Modal{constructor(t,e){super(t),this.onExport=e,this.settings={pageSize:"Letter",margins:{top:1,bottom:1,left:1,right:1},scale:100}}onOpen(){let{contentEl:t}=this;t.empty(),new ge.Setting(t).setName("Export to Word (.docx)").setHeading(),new ge.Setting(t).setName("Page size").setDesc("Select the page size for the exported document.").addDropdown(s=>{s.addOption("Letter",'Letter (8.5" x 11")').addOption("Legal",'Legal (8.5" x 14")').addOption("A4","A4 (210mm x 297mm)").setValue(this.settings.pageSize).onChange(o=>{this.settings.pageSize=o})}),new ge.Setting(t).setName("Margins").setHeading();let e=new ge.Setting(t).setName("Margins (inches)");e.settingEl.addClass("colophon-export-margins");let r=e.controlEl.createDiv({cls:"colophon-export-margins__grid"}),i=(s,o)=>{let a=r.createDiv({cls:"colophon-export-margins__field"});a.createDiv({text:s,cls:"colophon-export-margins__label"});let l=a.createEl("input",{type:"number"});l.addClass("colophon-export-margins__input"),l.step="0.1",l.min="0",l.max="5",l.value=String(this.settings.margins?.[o]??1),l.addEventListener("change",()=>{let c=parseFloat(l.value);isNaN(c)||(c=Math.max(0,Math.min(5,c)),l.value=String(c),this.settings.margins[o]=c)})};i("Top","top"),i("Right","right"),i("Bottom","bottom"),i("Left","left"),new ge.Setting(t).setName("Scale (%)").setDesc("Adjust the font size scale for the exported document.").addSlider(s=>{s.setLimits(50,200,5).setValue(this.settings.scale).setDynamicTooltip().onChange(o=>{this.settings.scale=o})}),new ge.Setting(t).setName("Export").setDesc("Generate a .docx using the settings above.").addButton(s=>{s.setButtonText("Export").setCta().onClick(()=>{this.close(),this.onExport(this.settings)})})}onClose(){let{contentEl:t}=this;t.empty()}};var uf=Tr(cf()),vs=class extends J.Plugin{activeTiptapEditor=null;setActiveEditor(t){this.activeTiptapEditor=t}interceptCoreCommands(){[{id:"editor:toggle-bold",method:"toggleBold"},{id:"editor:toggle-italics",method:"toggleItalic"},{id:"editor:toggle-strikethrough",method:"toggleStrike"},{id:"editor:toggle-highlight",method:"toggleUnderline"}].forEach(e=>{let r=this.app.commands.commands[e.id];r&&(r.originalCheckCallback||(r.originalCheckCallback=r.checkCallback||r.callback),r.checkCallback=i=>this.activeTiptapEditor?(i||this.activeTiptapEditor.chain().focus()[e.method]().run(),!0):r.originalCheckCallback?r.originalCheckCallback(i):!1)})}async onload(){let t=await this.loadData()||{};this.settings=Object.assign({},Cr,t),t.blocks&&(this.settings.blocks=Object.assign({},Cr.blocks,t.blocks)),this.markdownBridge=new uf.default,this.metadataManager=new gs(this),this.metadataManager.setup(),this.sidebarManager=new ys(this),this.sidebarManager.setup(),this.styleManager=new fs,this.styleManager.applyStyles(this.settings),this.addSettingTab(new ms(this.app,this)),this.registerView(ee,e=>new rt(e,this)),this.registerView(me,e=>new ds(e,this)),this.registerExtensions(["colophon"],ee),this.addRibbonIcon("feather","New Colophon Manuscript",()=>{this.createNewColophonFile("manuscript")}),this.addRibbonIcon("clapperboard","New Colophon Script",()=>{this.createNewColophonFile("script")}),this.addCommand({id:"new-manuscript",name:"New Manuscript",callback:()=>this.createNewColophonFile("manuscript")}),this.addCommand({id:"new-script",name:"New Script",callback:()=>this.createNewColophonFile("script")}),this.addCommand({id:"open-sidebar",name:"Open Sidebar",callback:()=>this.openSidebar()}),this.addCommand({id:"open-find-replace",name:"Open Find/Replace",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r?(e||r.findReplaceBar&&r.findReplaceBar.open(),!0):!1}}),this.addCommand({id:"open-replace",name:"Open Replace",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r?(e||r.findReplaceBar&&r.findReplaceBar.openReplace(),!0):!1}}),this.addCommand({id:"find-next",name:"Find Next",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter&&r.adapter.editor?(e||r.adapter.editor.commands.nextSearchResult(),!0):!1}}),this.addCommand({id:"find-previous",name:"Find Previous",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter&&r.adapter.editor?(e||r.adapter.editor.commands.previousSearchResult(),!0):!1}}),this.addCommand({id:"export-to-docx",name:"Export to Word (.docx)",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter?(e||new bs(this.app,i=>{r.adapter.editor.commands.exportToDocx({settings:i,footnotes:r.adapter.footnotes,comments:r.adapter.comments,stylesConfig:this.settings.blocks})}).open(),!0):!1}}),this.addCommand({id:"export-to-markdown",name:"Export to Markdown (.md)",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter?(e||this.exportToMarkdown(r),!0):!1}}),this.addCommand({id:"export-to-fountain",name:"Export to Fountain (.fountain)",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter&&r.docType==="script"?(e||r.adapter.editor.commands.exportToFountain({}),!0):!1}}),this.addCommand({id:"insert-internal-link",name:"Insert Internal Link",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter?(e||r.adapter.editor.commands.insertContent("[["),!0):!1}}),this.addCommand({id:"insert-footnote",name:"Insert Footnote",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);return r&&r.adapter?(e||r.insertFootnote(),!0):!1}}),this.addCommand({id:"insert-comment",name:"Insert Comment",checkCallback:e=>{let r=this.app.workspace.getActiveViewOfType(rt);if(r&&r.adapter){let i=r.activeEditor||(r.adapter?r.adapter.editor:null);if(i&&!i.state.selection.empty)return e||r.insertComment(),!0}return!1}}),this.addCommand({id:"toggle-bold",name:"Toggle Bold",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleBold().run(),!0):!1}),this.addCommand({id:"toggle-italic",name:"Toggle Italic",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleItalic().run(),!0):!1}),this.addCommand({id:"toggle-strikethrough",name:"Toggle Strikethrough",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleStrike().run(),!0):!1}),this.addCommand({id:"toggle-underline",name:"Toggle Underline",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleUnderline().run(),!0):!1}),this.addCommand({id:"toggle-superscript",name:"Toggle Superscript",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleSuperscript().unsetSubscript().run(),!0):!1}),this.addCommand({id:"toggle-subscript",name:"Toggle Subscript",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleSubscript().unsetSuperscript().run(),!0):!1}),this.addCommand({id:"toggle-small-caps",name:"Toggle Small Caps",checkCallback:e=>this.activeTiptapEditor?(e||this.activeTiptapEditor.chain().focus().toggleSmallCaps().run(),!0):!1}),this.addCommand({id:"colophon:add-link",name:"Agent: Add Link",callback:e=>{let{target:r,alias:i}=e||{},s=this.app.workspace.getActiveViewOfType(rt);s&&s.adapter&&s.adapter.addLink({target:r,alias:i})}}),this.addCommand({id:"colophon:set-block-type",name:"Agent: Set Block Type",callback:e=>{let{typeId:r}=e||{};if(!r)return;let i=this.app.workspace.getActiveViewOfType(rt);i&&i.adapter&&i.adapter.setBlockType(r)}}),this.addCommand({id:"colophon:focus-footnote",name:"Agent: Focus Footnote",callback:e=>{let{id:r}=e||{};if(!r)return;let i=this.app.workspace.getActiveViewOfType(rt);i&&i.adapter&&i.adapter.focusNote(r)}}),this.addCommand({id:"convert-legacy-manuscripts",name:"Convert Legacy Manuscript Files",callback:()=>this.convertLegacyManuscriptFiles()}),this.registerEvent(this.app.workspace.on("editor-menu",(e,r,i)=>{if(i instanceof rt)r.getSelection()&&e.addItem(s=>{s.setTitle("Add comment").setIcon("message-square-plus").onClick(()=>{i.insertComment()})});else{let s=i.file;s&&s.extension==="md"&&this.app.metadataCache.getFileCache(s)?.frontmatter?.["colophon-plugin"]==="manuscript"&&e.addItem(l=>{l.setTitle("Convert legacy to standard Colophon").setIcon("zap").onClick(async()=>{await this.convertSingleLegacyFile(s)})})}})),this.registerEvent(this.app.workspace.on("file-menu",(e,r)=>{r instanceof J.TFolder?(e.addItem(i=>{i.setTitle("New manuscript").setIcon("feather").onClick(async()=>{await this.createNewColophonFile("manuscript",r.path)})}),e.addItem(i=>{i.setTitle("New script").setIcon("clapperboard").onClick(async()=>{await this.createNewColophonFile("script",r.path)})})):r instanceof J.TFile&&r.extension==="md"&&(this.app.metadataCache.getFileCache(r)?.frontmatter?.["colophon-plugin"]==="manuscript"&&e.addItem(o=>{o.setTitle("Convert legacy to standard Colophon").setIcon("zap").onClick(async()=>{await this.convertSingleLegacyFile(r)})}),e.addItem(o=>{o.setTitle("Convert to Colophon manuscript format").setIcon("feather").onClick(async()=>{await this.convertToColophon(r)})}))})),this.app.workspace.onLayoutReady(()=>{this.settings.sidebarLocation!=="global"&&this.app.workspace.getLeavesOfType(me).forEach(e=>{e.detach()})}),this.app.workspace.onLayoutReady(()=>{this.interceptCoreCommands()})}onunload(){["editor:toggle-bold","editor:toggle-italics","editor:toggle-strikethrough","editor:toggle-highlight"].forEach(e=>{let r=this.app.commands.commands[e];r&&r.originalCheckCallback&&(r.checkCallback=r.originalCheckCallback,delete r.originalCheckCallback)}),this.sidebarManager&&this.sidebarManager.destroy()}async exportToMarkdown(t){if(!t||!t.adapter)return;let e=t.file,r=JSON.parse(t.getViewData()),i=this.markdownBridge.dehydrate(r.doc,r.footnotes||{},r.comments||{}),s=e.path.replace(/\.colophon$/,".md"),o=s,a=1;for(;this.app.vault.getAbstractFileByPath(o)!==null;)o=s.replace(/\.md$/,` ${a}.md`),a++;try{await this.app.vault.create(o,i),new J.Notice(`Exported to ${o}`)}catch(l){console.error("Colophon: Failed to export Markdown",l),new J.Notice("Failed to export Markdown")}}async convertToColophon(t){if(t instanceof J.TFile)try{let e=await this.app.vault.read(t),r=this.markdownBridge.hydrate(e),i=t.path.replace(/\.md$/,".colophon"),s=i,o=1;for(;this.app.vault.getAbstractFileByPath(s)!==null;)s=i.replace(/\.colophon$/,` ${o}.colophon`),o++;await this.app.vault.create(s,JSON.stringify(r,null,2)),new J.Notice(`Converted to ${s}`);let a=this.app.vault.getAbstractFileByPath(s);a instanceof J.TFile&&await this.app.workspace.getLeaf(!0).openFile(a)}catch(e){console.error("Colophon: Failed to convert to Colophon",e),new J.Notice("Failed to convert to Colophon")}}async convertSingleLegacyFile(t){try{let e=await this.app.vault.read(t),r=this.parseLegacyFormat(e);if(!r){new J.Notice("Failed to parse legacy data block");return}let i=this.transformLegacyData(r),s=this.markdownBridge.dehydrate(i.doc,i.footnotes||{},i.comments||{}),o=this.markdownBridge.hydrate(s),a=t.path.replace(/\.md$/,".colophon"),l=a,c=1;for(;this.app.vault.getAbstractFileByPath(l)!==null;)l=a.replace(/\.colophon$/,` ${c}.colophon`),c++;await this.app.vault.create(l,JSON.stringify(o,null,2)),await this.app.vault.delete(t),new J.Notice(`Converted legacy file to ${l}`);let u=this.app.vault.getAbstractFileByPath(l);u instanceof J.TFile&&await this.app.workspace.getLeaf(!0).openFile(u)}catch(e){console.error(`Colophon: Error converting ${t.path}:`,e),new J.Notice(`Error converting file: ${e.message}`)}}async saveSettings(){await this.saveData(this.settings),this.styleManager&&this.styleManager.applyStyles(this.settings),this.app.workspace.getLeavesOfType(ee).forEach(t=>{t.view&&typeof t.view.updateSettings=="function"&&t.view.updateSettings()})}async createNewColophonFile(t,e=""){let r="Untitled",i=(0,J.normalizePath)(e?`${e}/${r}.colophon`:`${r}.colophon`),s=1;for(;this.app.vault.getAbstractFileByPath(i)!==null;)i=(0,J.normalizePath)(e?`${e}/${r} ${s}.colophon`:`${r} ${s}.colophon`),s++;let o={type:t,doc:{type:"doc",content:[{type:t==="script"?"script-action":"body",content:[]}]}};try{let a=await this.app.vault.create(i,JSON.stringify(o,null,2));await this.app.workspace.getLeaf(!0).openFile(a),setTimeout(()=>{let c=this.app.workspace.getLeavesOfType("file-explorer")[0];c&&(this.app.workspace.revealLeaf(c),c.view&&c.view.revealInFolder&&c.view.revealInFolder(a)),new ol(this.app,a,async u=>{let h=e?`${e}/${u}.colophon`:`${u}.colophon`;await this.app.fileManager.renameFile(a,h)}).open()},100)}catch(a){console.error("Failed to create Colophon file:",a)}}refreshLayout(){let t=this.settings.sidebarLocation==="global";this.app.workspace.getLeavesOfType(ee).forEach(e=>{e.view instanceof rt&&e.view.refreshSidebarVisibility()}),t||this.app.workspace.getLeavesOfType(me).forEach(e=>{e.detach()}),this.sidebarManager&&this.sidebarManager.update()}async openSidebar(){let{workspace:t}=this.app,e=null,r=t.getLeavesOfType(me);r.length>0?e=r[0]:(e=t.getRightLeaf(!1),await e.setViewState({type:me,active:!0})),t.revealLeaf(e)}async convertLegacyManuscriptFiles(){let t=this.app.vault.getFiles().filter(s=>s.extension==="md"),e=[];for(let s of t)this.app.metadataCache.getCache(s.path)?.frontmatter?.["colophon-plugin"]==="manuscript"&&e.push(s);if(e.length===0){new J.Notice("No legacy manuscript files found.");return}let r={converted:0,skipped:0,errors:[]};for(let s of e)try{let o=await this.app.vault.read(s),a=this.parseLegacyFormat(o);if(!a){r.skipped++,r.errors.push({file:s.path,error:"Failed to parse colophon data block"}),console.error(`Colophon: Failed to parse legacy file: ${s.path}`);continue}let l=this.transformLegacyData(a),c=s.path.replace(/\.md$/,".colophon");if(this.app.vault.getAbstractFileByPath(c)!==null){let u=1,h=c.replace(".colophon","");for(;this.app.vault.getAbstractFileByPath(`${h} ${u}.colophon`)!==null;)u++;await this.app.vault.create(`${h} ${u}.colophon`,JSON.stringify(l,null,2))}else await this.app.vault.create(c,JSON.stringify(l,null,2));await this.app.vault.delete(s),r.converted++}catch(o){r.errors.push({file:s.path,error:o.message}),console.error(`Colophon: Error converting ${s.path}:`,o)}let i=`Converted ${r.converted} files.`;r.skipped>0&&(i+=` ${r.skipped} skipped.`),r.errors.length>0&&(i+=` ${r.errors.length} errors.`),new J.Notice(i),r.errors.length>0&&console.error("Colophon: Legacy conversion errors:",r.errors)}parseLegacyFormat(t){let e=t.match(/%% colophon:data\s*(\{[\s\S]*\})\s*%%/);if(!e)return null;try{return JSON.parse(e[1])}catch(r){return console.error("Colophon: Failed to parse legacy data block:",r),null}}transformLegacyData(t){if(this.migrateContentNodes(t.doc),Array.isArray(t.footnotes)){let e={};t.footnotes.forEach(r=>{let i=r.id||`fn-${crypto.randomUUID()}`,s=r.content||{type:"doc",content:[{type:"body"}]};this.migrateContentNodes(s),e[i]=s}),t.footnotes=e}else t.footnotes=t.footnotes||{};if(Array.isArray(t.comments)){let e={};t.comments.forEach(r=>{let i=r.id||`comment-${crypto.randomUUID()}`;r.content&&this.migrateContentNodes(r.content),r.replies||(r.replies=[]),e[i]=[r]}),t.comments=e}else t.comments=t.comments||{};return{type:"manuscript",doc:t.doc,footnotes:t.footnotes,comments:t.comments}}migrateContentNodes(t){if(!t)return;let e=()=>Math.random().toString(36).substring(2,8),r=t.attrs?.class,i=["body","supertitle","title","subtitle","epigraph","body-first","footnote","heading-1","heading-2","heading-3"],s=["MsoNormal","MsoNoSpacing","MsoFootnoteText","MsoListParagraph"];if(t.type==="paragraph"||t.type==="blockquote"||t.type==="codeBlock"||t.type==="listItem"||r&&s.includes(r))r&&i.includes(r)?t.type=r:t.type="body",t.attrs||(t.attrs={}),t.attrs.id=e(),delete t.attrs.class;else if(t.type==="heading"){let a=t.attrs?.level;r==="title"?t.type="title":a?t.type=`heading-${a}`:t.type="heading-1",t.attrs||(t.attrs={}),t.attrs.id=e(),delete t.attrs.level,delete t.attrs.class}else t.type==="footnote"&&(t.type="footnoteMarker");if((["body","title","subtitle","supertitle","epigraph","body-first","footnote","footnoteMarker","heading-1","heading-2","heading-3","paragraph","listItem"].includes(t.type)||t.type.startsWith("heading-"))&&this.migrateMarks(t),t.content&&Array.isArray(t.content)){let a=[];for(let l of t.content)if(l.type==="bulletList"||l.type==="orderedList"){if(l.content&&Array.isArray(l.content))for(let c of l.content)c.type==="listItem"&&c.content&&(c.content.forEach(u=>this.migrateContentNodes(u)),a.push(...c.content))}else a.push(l);t.content=a,t.content.forEach(l=>{(!l.attrs?.id||!i.includes(l.type))&&this.migrateContentNodes(l)})}}migrateMarks(t){if(!t||!t.content||!Array.isArray(t.content))return;let e=[];for(let r of t.content){let i=r.marks?.find(s=>s.type==="internallink"||s.type==="link"&&s.attrs?.class==="internal-link");if(i&&r.type==="text"){e.push({type:"internalLink",attrs:{target:i.attrs?.href||"",alias:i.attrs?.text||r.text||""}});continue}r.marks&&(r.marks=r.marks.map(s=>s.type==="comment"?{type:"commentHighlight",attrs:{threadId:s.attrs?.id||s.attrs?.threadId}}:s),r.marks=r.marks.filter(s=>s.type!=="internallink"&&!(s.type==="link"&&s.attrs?.class==="internal-link")),r.marks.length===0&&delete r.marks),e.push(r)}t.content=e}},ol=class extends J.Modal{constructor(t,e,r){super(t),this.file=e,this.onSubmit=r,this.basename=e.basename}onOpen(){let{contentEl:t}=this;t.empty(),t.createDiv({cls:"modal-header"}).createEl("div",{cls:"modal-title",text:"File name"});let i=t.createDiv({cls:"modal-content"}).createEl("input",{type:"text",value:this.basename});i.setAttribute("style","width: 100%; margin-bottom: 1rem;"),i.select();let s=t.createDiv({cls:"modal-button-container"}),o=s.createEl("button",{text:"Cancel"}),a=s.createEl("button",{cls:"mod-cta",text:"Save"});o.addEventListener("click",()=>this.close());let l=()=>{let c=i.value.trim();c&&c!==this.basename&&this.onSubmit(c),this.close()};a.addEventListener("click",l),i.addEventListener("keydown",c=>{c.key==="Enter"?l():c.key==="Escape"&&this.close()})}onClose(){let{contentEl:t}=this;t.empty()}}; diff --git a/manifest.json b/manifest.json index 37e7105..0edaa82 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "colophon-writer", "name": "Colophon", - "version": "2.2.4", + "version": "2.2.5", "minAppVersion": "1.7.5", "description": "A dedicated, typographically refined writing canvas for structuring long-form manuscripts and screenplays.", "author": "David Golding", diff --git a/package.json b/package.json index bff4cf9..b9d9e36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-colophon", - "version": "2.2.4", + "version": "2.2.5", "description": "A dedicated, typographically refined writing canvas for structuring long-form manuscripts and screenplays.", "main": "main.js", "scripts": { @@ -16,25 +16,25 @@ "vitest": "^4.1.0" }, "dependencies": { - "@tiptap/core": "^3.22.3", - "@tiptap/extension-bold": "^3.22.3", - "@tiptap/extension-document": "^3.22.3", - "@tiptap/extension-dropcursor": "^3.22.3", - "@tiptap/extension-gapcursor": "^3.22.3", - "@tiptap/extension-hard-break": "^3.22.3", - "@tiptap/extension-history": "^3.22.3", - "@tiptap/extension-horizontal-rule": "^3.22.3", - "@tiptap/extension-italic": "^3.22.3", - "@tiptap/extension-paragraph": "^3.22.3", - "@tiptap/extension-strike": "^3.22.3", - "@tiptap/extension-subscript": "^3.22.3", - "@tiptap/extension-superscript": "^3.22.3", - "@tiptap/extension-text": "^3.22.3", - "@tiptap/extension-text-style": "^3.22.3", - "@tiptap/extension-underline": "^3.22.3", - "@tiptap/pm": "^3.22.3", - "@tiptap/starter-kit": "^3.22.3", - "fast-diff": "^1.3.0", - "jszip": "^3.10.1" + "@tiptap/core": "3.22.3", + "@tiptap/extension-bold": "3.22.3", + "@tiptap/extension-document": "3.22.3", + "@tiptap/extension-dropcursor": "3.22.3", + "@tiptap/extension-gapcursor": "3.22.3", + "@tiptap/extension-hard-break": "3.22.3", + "@tiptap/extension-history": "3.22.3", + "@tiptap/extension-horizontal-rule": "3.22.3", + "@tiptap/extension-italic": "3.22.3", + "@tiptap/extension-paragraph": "3.22.3", + "@tiptap/extension-strike": "3.22.3", + "@tiptap/extension-subscript": "3.22.3", + "@tiptap/extension-superscript": "3.22.3", + "@tiptap/extension-text": "3.22.3", + "@tiptap/extension-text-style": "3.22.3", + "@tiptap/extension-underline": "3.22.3", + "@tiptap/pm": "3.22.3", + "@tiptap/starter-kit": "3.22.3", + "fast-diff": "1.3.0", + "fflate": "0.8.2" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..65c9434 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,1656 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@tiptap/core': + specifier: 3.22.3 + version: 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/extension-bold': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-document': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-dropcursor': + specifier: 3.22.3 + version: 3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-gapcursor': + specifier: 3.22.3 + version: 3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-hard-break': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-history': + specifier: 3.22.3 + version: 3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-horizontal-rule': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-italic': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-paragraph': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-strike': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-subscript': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-superscript': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-text': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-text-style': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-underline': + specifier: 3.22.3 + version: 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/pm': + specifier: 3.22.3 + version: 3.22.3 + '@tiptap/starter-kit': + specifier: 3.22.3 + version: 3.22.3 + fast-diff: + specifier: 1.3.0 + version: 1.3.0 + fflate: + specifier: 0.8.2 + version: 0.8.2 + devDependencies: + esbuild: + specifier: ^0.28.0 + version: 0.28.0 + vitest: + specifier: ^4.1.0 + version: 4.1.0(vite@8.0.0(esbuild@0.28.0)) + +packages: + + '@emnapi/core@1.9.0': + resolution: {integrity: sha512-0DQ98G9ZQZOxfUcQn1waV2yS8aWdZ6kJMbYCJB3oUBecjWYO1fqJ+a1DRfPF3O5JEkwqwP1A9QEN/9mYm2Yd0w==} + + '@emnapi/runtime@1.9.0': + resolution: {integrity: sha512-QN75eB0IH2ywSpRpNddCRfQIhmJYBCJ1x5Lb3IscKAL8bMnVAKnRg8dCoXbHzVLLH7P38N2Z3mtulB7W0J0FKw==} + + '@emnapi/wasi-threads@1.2.0': + resolution: {integrity: sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==} + + '@esbuild/aix-ppc64@0.28.0': + resolution: {integrity: sha512-lhRUCeuOyJQURhTxl4WkpFTjIsbDayJHih5kZC1giwE+MhIzAb7mEsQMqMf18rHLsrb5qI1tafG20mLxEWcWlA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.28.0': + resolution: {integrity: sha512-+WzIXQOSaGs33tLEgYPYe/yQHf0WTU0X42Jca3y8NWMbUVhp7rUnw+vAsRC/QiDrdD31IszMrZy+qwPOPjd+rw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.28.0': + resolution: {integrity: sha512-wqh0ByljabXLKHeWXYLqoJ5jKC4XBaw6Hk08OfMrCRd2nP2ZQ5eleDZC41XHyCNgktBGYMbqnrJKq/K/lzPMSQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.28.0': + resolution: {integrity: sha512-+VJggoaKhk2VNNqVL7f6S189UzShHC/mR9EE8rDdSkdpN0KflSwWY/gWjDrNxxisg8Fp1ZCD9jLMo4m0OUfeUA==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.28.0': + resolution: {integrity: sha512-0T+A9WZm+bZ84nZBtk1ckYsOvyA3x7e2Acj1KdVfV4/2tdG4fzUp91YHx+GArWLtwqp77pBXVCPn2We7Letr0Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.28.0': + resolution: {integrity: sha512-fyzLm/DLDl/84OCfp2f/XQ4flmORsjU7VKt8HLjvIXChJoFFOIL6pLJPH4Yhd1n1gGFF9mPwtlN5Wf82DZs+LQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.28.0': + resolution: {integrity: sha512-l9GeW5UZBT9k9brBYI+0WDffcRxgHQD8ShN2Ur4xWq/NFzUKm3k5lsH4PdaRgb2w7mI9u61nr2gI2mLI27Nh3Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.28.0': + resolution: {integrity: sha512-BXoQai/A0wPO6Es3yFJ7APCiKGc1tdAEOgeTNy3SsB491S3aHn4S4r3e976eUnPdU+NbdtmBuLncYir2tMU9Nw==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.28.0': + resolution: {integrity: sha512-RVyzfb3FWsGA55n6WY0MEIEPURL1FcbhFE6BffZEMEekfCzCIMtB5yyDcFnVbTnwk+CLAgTujmV/Lgvih56W+A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.28.0': + resolution: {integrity: sha512-CjaaREJagqJp7iTaNQjjidaNbCKYcd4IDkzbwwxtSvjI7NZm79qiHc8HqciMddQ6CKvJT6aBd8lO9kN/ZudLlw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.28.0': + resolution: {integrity: sha512-KBnSTt1kxl9x70q+ydterVdl+Cn0H18ngRMRCEQfrbqdUuntQQ0LoMZv47uB97NljZFzY6HcfqEZ2SAyIUTQBQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.28.0': + resolution: {integrity: sha512-zpSlUce1mnxzgBADvxKXX5sl8aYQHo2ezvMNI8I0lbblJtp8V4odlm3Yzlj7gPyt3T8ReksE6bK+pT3WD+aJRg==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.28.0': + resolution: {integrity: sha512-2jIfP6mmjkdmeTlsX/9vmdmhBmKADrWqN7zcdtHIeNSCH1SqIoNI63cYsjQR8J+wGa4Y5izRcSHSm8K3QWmk3w==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.28.0': + resolution: {integrity: sha512-bc0FE9wWeC0WBm49IQMPSPILRocGTQt3j5KPCA8os6VprfuJ7KD+5PzESSrJ6GmPIPJK965ZJHTUlSA6GNYEhg==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.28.0': + resolution: {integrity: sha512-SQPZOwoTTT/HXFXQJG/vBX8sOFagGqvZyXcgLA3NhIqcBv1BJU1d46c0rGcrij2B56Z2rNiSLaZOYW5cUk7yLQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.28.0': + resolution: {integrity: sha512-SCfR0HN8CEEjnYnySJTd2cw0k9OHB/YFzt5zgJEwa+wL/T/raGWYMBqwDNAC6dqFKmJYZoQBRfHjgwLHGSrn3Q==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.28.0': + resolution: {integrity: sha512-us0dSb9iFxIi8srnpl931Nvs65it/Jd2a2K3qs7fz2WfGPHqzfzZTfec7oxZJRNPXPnNYZtanmRc4AL/JwVzHQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.28.0': + resolution: {integrity: sha512-CR/RYotgtCKwtftMwJlUU7xCVNg3lMYZ0RzTmAHSfLCXw3NtZtNpswLEj/Kkf6kEL3Gw+BpOekRX0BYCtklhUw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.28.0': + resolution: {integrity: sha512-nU1yhmYutL+fQ71Kxnhg8uEOdC0pwEW9entHykTgEbna2pw2dkbFSMeqjjyHZoCmt8SBkOSvV+yNmm94aUrrqw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.28.0': + resolution: {integrity: sha512-cXb5vApOsRsxsEl4mcZ1XY3D4DzcoMxR/nnc4IyqYs0rTI8ZKmW6kyyg+11Z8yvgMfAEldKzP7AdP64HnSC/6g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.28.0': + resolution: {integrity: sha512-8wZM2qqtv9UP3mzy7HiGYNH/zjTA355mpeuA+859TyR+e+Tc08IHYpLJuMsfpDJwoLo1ikIJI8jC3GFjnRClzA==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.28.0': + resolution: {integrity: sha512-FLGfyizszcef5C3YtoyQDACyg95+dndv79i2EekILBofh5wpCa1KuBqOWKrEHZg3zrL3t5ouE5jgr94vA+Wb2w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.28.0': + resolution: {integrity: sha512-1ZgjUoEdHZZl/YlV76TSCz9Hqj9h9YmMGAgAPYd+q4SicWNX3G5GCyx9uhQWSLcbvPW8Ni7lj4gDa1T40akdlw==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.28.0': + resolution: {integrity: sha512-Q9StnDmQ/enxnpxCCLSg0oo4+34B9TdXpuyPeTedN/6+iXBJ4J+zwfQI28u/Jl40nOYAxGoNi7mFP40RUtkmUA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.28.0': + resolution: {integrity: sha512-zF3ag/gfiCe6U2iczcRzSYJKH1DCI+ByzSENHlM2FcDbEeo5Zd2C86Aq0tKUYAJJ1obRP84ymxIAksZUcdztHA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.28.0': + resolution: {integrity: sha512-pEl1bO9mfAmIC+tW5btTmrKaujg3zGtUmWNdCw/xs70FBjwAL3o9OEKNHvNmnyylD6ubxUERiEhdsL0xBQ9efw==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + + '@napi-rs/wasm-runtime@1.1.1': + resolution: {integrity: sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==} + + '@oxc-project/runtime@0.115.0': + resolution: {integrity: sha512-Rg8Wlt5dCbXhQnsXPrkOjL1DTSvXLgb2R/KYfnf1/K+R0k6UMLEmbQXPM+kwrWqSmWA2t0B1EtHy2/3zikQpvQ==} + engines: {node: ^20.19.0 || >=22.12.0} + + '@oxc-project/types@0.115.0': + resolution: {integrity: sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw==} + + '@remirror/core-constants@3.0.0': + resolution: {integrity: sha512-42aWfPrimMfDKDi4YegyS7x+/0tlzaqwPQCULLanv3DMIlu96KTJR0fM5isWX2UViOqlGnX6YFgqWepcX+XMNg==} + + '@rolldown/binding-android-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-lcJL0bN5hpgJfSIz/8PIf02irmyL43P+j1pTCfbD1DbLkmGRuFIA4DD3B3ZOvGqG0XiVvRznbKtN0COQVaKUTg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-J7Zk3kLYFsLtuH6U+F4pS2sYVzac0qkjcO5QxHS7OS7yZu2LRs+IXo+uvJ/mvpyUljDJ3LROZPoQfgBIpCMhdQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.9': + resolution: {integrity: sha512-iwtmmghy8nhfRGeNAIltcNXzD0QMNaaA5U/NyZc1Ia4bxrzFByNMDoppoC+hl7cDiUq5/1CnFthpT9n+UtfFyg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.0.0-rc.9': + resolution: {integrity: sha512-DLFYI78SCiZr5VvdEplsVC2Vx53lnA4/Ga5C65iyldMVaErr86aiqCoNBLl92PXPfDtUYjUh+xFFor40ueNs4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': + resolution: {integrity: sha512-CsjTmTwd0Hri6iTw/DRMK7kOZ7FwAkrO4h8YWKoX/kcj833e4coqo2wzIFywtch/8Eb5enQ/lwLM7w6JX1W5RQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-2x9O2JbSPxpxMDhP9Z74mahAStibTlrBMW0520+epJH5sac7/LwZW5Bmg/E6CXuEF53JJFW509uP+lSedaUNxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': + resolution: {integrity: sha512-JA1QRW31ogheAIRhIg9tjMfsYbglXXYGNPLdPEYrwFxdbkQCAzvpSCSHCDWNl4hTtrol8WeboCSEpjdZK8qrCg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-aOKU9dJheda8Kj8Y3w9gnt9QFOO+qKPAl8SWd7JPHP+Cu0EuDAE5wokQubLzIDQWg2myXq2XhTpOVS07qqvT+w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-OalO94fqj7IWRn3VdXWty75jC5dk4C197AWEuMhIpvVv2lw9fiPhud0+bW2ctCxb3YoBZor71QHbY+9/WToadA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-cVEl1vZtBsBZna3YMjGXNvnYYrOJ7RzuWvZU0ffvJUexWkukMaDuGhUXn0rjnV0ptzGVkvc+vW9Yqy6h8YX4pg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': + resolution: {integrity: sha512-UzYnKCIIc4heAKgI4PZ3dfBGUZefGCJ1TPDuLHoCzgrMYPb5Rv6TLFuYtyM4rWyHM7hymNdsg5ik2C+UD9VDbA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-+6zoiF+RRyf5cdlFQP7nm58mq7+/2PFaY2DNQeD4B87N36JzfF/l9mdBkkmTvSYcYPE8tMh/o3cRlsx1ldLfog==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': + resolution: {integrity: sha512-rgFN6sA/dyebil3YTlL2evvi/M+ivhfnyxec7AccTpRPccno/rPoNlqybEZQBkcbZu8Hy+eqNJCqfBR8P7Pg8g==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': + resolution: {integrity: sha512-lHVNUG/8nlF1IQk1C0Ci574qKYyty2goMiPlRqkC5R+3LkXDkL5Dhx8ytbxq35m+pkHVIvIxviD+TWLdfeuadA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': + resolution: {integrity: sha512-G0oA4+w1iY5AGi5HcDTxWsoxF509hrFIPB2rduV5aDqS9FtDg1CAfa7V34qImbjfhIcA8C+RekocJZA96EarwQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.0-rc.9': + resolution: {integrity: sha512-w6oiRWgEBl04QkFZgmW+jnU1EC9b57Oihi2ot3HNWIQRqgHp5PnYDia5iZ5FF7rpa4EQdiqMDXjlqKGXBhsoXw==} + + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + + '@tiptap/core@3.22.3': + resolution: {integrity: sha512-Dv9MKK5BDWCF0N2l6/Pxv3JNCce2kwuWf2cKMBc2bEetx0Pn6o7zlFmSxMvYK4UtG1Tw9Yg/ZHi6QOFWK0Zm9Q==} + peerDependencies: + '@tiptap/pm': ^3.22.3 + + '@tiptap/extension-blockquote@3.22.4': + resolution: {integrity: sha512-7/61kNPbGFhMgM//zMknD0pSb69rGdRIkpulXOWS1JBrFHkH6hjZDfrOETNzgKkO+NlmzVl9rXSTv0xauS3lzA==} + peerDependencies: + '@tiptap/core': 3.22.4 + + '@tiptap/extension-bold@3.22.3': + resolution: {integrity: sha512-tysipHla2zCWr8XNIWRaW9O+7i7/SoEqnRqSRUUi2ailcJjlia+RBy3RykhkgyThrQDStu5KGBS/UvrXwA+O1A==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-bullet-list@3.22.4': + resolution: {integrity: sha512-TB+d3fGcTixYjO7coKqTr1mGTJuqr8hjDCPUFgzuvKyJnBhqWITmBzQ/8CLq4rr6mihgGURbD3N+xkQuPAKFiw==} + peerDependencies: + '@tiptap/extension-list': 3.22.4 + + '@tiptap/extension-code-block@3.22.4': + resolution: {integrity: sha512-MEurzNXfMET3rhjpoPJYUgMfxTdTqbzT9+ToFrqNGAHocdXVm6m1hhO2frVC7fEtHPnxXKsn0Z3NUbCRkRTLuA==} + peerDependencies: + '@tiptap/core': 3.22.4 + '@tiptap/pm': 3.22.4 + + '@tiptap/extension-code@3.22.4': + resolution: {integrity: sha512-cnbxmVhAcc7X3G81QUYEmKP0ve2hRmvAiFXBuuv9RUtQlBiRnzmhHoJOMgkX0CsMR7+8kMRpTfeDUYq2xp5s5w==} + peerDependencies: + '@tiptap/core': 3.22.4 + + '@tiptap/extension-document@3.22.3': + resolution: {integrity: sha512-MCSr1PFPtTd++lA3H1RNgqAczAE59XXJ5wUFIQf2F+/0DPY5q2SU4g5QsNJVxPPft5mrNT4C6ty8xBPrALFEdA==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-dropcursor@3.22.3': + resolution: {integrity: sha512-taXq9Tl5aybdFbptJtFRHX9LFJzbXphAbPp4/vutFyTrBu5meXDxuS+B9pEmE+Or0XcolTlW2nDZB0Tqnr18JQ==} + peerDependencies: + '@tiptap/extensions': ^3.22.3 + + '@tiptap/extension-gapcursor@3.22.3': + resolution: {integrity: sha512-L/Px4UeQEVG/D9WIlcAOIej+4wyIBCMUSYicSR+hW68UsObe4rxVbUas1QgidQKm6DOhoT7U7D4KQHA/Gdg/7A==} + peerDependencies: + '@tiptap/extensions': ^3.22.3 + + '@tiptap/extension-hard-break@3.22.3': + resolution: {integrity: sha512-J0v8I99y9tbvVmgKYKzKP/JYNsWaZYS7avn4rzLft2OhnyTfwt3OoY8DtpHmmi6apSUaCtoWHWta/TmoEfK1nQ==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-heading@3.22.4': + resolution: {integrity: sha512-TUaj5f0Ir5qy9HKKt2ocnwfXKpZDYeHgbbP9gshKFzdq5PLe1RbIgkjfy6bnoI865cYjmPYWRjcT7XsKyIcb9Q==} + peerDependencies: + '@tiptap/core': 3.22.4 + + '@tiptap/extension-history@3.22.3': + resolution: {integrity: sha512-3kev2iP84YPjwUk8BaM28EQiVHbBmE0lkcIjh/6yvgRxRwblzRwyJuFcsVOY5ouBVxl9Rg1rcFFCAs8CFNFkUg==} + peerDependencies: + '@tiptap/extensions': ^3.22.3 + + '@tiptap/extension-horizontal-rule@3.22.3': + resolution: {integrity: sha512-wI2bFzScs+KgWeBH/BtypcVKeYelCyqV0RG8nxsZMWtPrBhqixzNd0Oi3gEKtjSjKUqMQ/kjJAIRuESr5UzlHA==} + peerDependencies: + '@tiptap/core': ^3.22.3 + '@tiptap/pm': ^3.22.3 + + '@tiptap/extension-italic@3.22.3': + resolution: {integrity: sha512-LteA4cb4EGCiUtrK2JHvDF/Zg0/YqV4DUyHhAAho+oGEQDupZlsS6m0ia5wQcclkiTLzsoPrwcSNu6RDGQ16wQ==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-link@3.22.4': + resolution: {integrity: sha512-uoP3yus02uwGPVzW2QaEPJWVIrUb/r5nKm6c8DiJv9fNSX1+gykZZMg42c6GwRFLZ/vyfWjVCbAE03VMUqafgA==} + peerDependencies: + '@tiptap/core': 3.22.4 + '@tiptap/pm': 3.22.4 + + '@tiptap/extension-list-item@3.22.4': + resolution: {integrity: sha512-H659KXTvggSypIDWSOJBZ37jh9pKjQriDDvYPYvOZCdfij0D0hsDXN/wXoypArneUkoBdgruHfTtMkFOaQlgkw==} + peerDependencies: + '@tiptap/extension-list': 3.22.4 + + '@tiptap/extension-list-keymap@3.22.4': + resolution: {integrity: sha512-t/zhker4oIS78AIGYDdFFfZC6zSBlszfD7z/zqFLGCg5PHNNgkZK5hKj6Vyix6D2SapRn/ajnx+8mhbKIUH5eA==} + peerDependencies: + '@tiptap/extension-list': 3.22.4 + + '@tiptap/extension-list@3.22.4': + resolution: {integrity: sha512-Xe8UFvvHmyp/c/TJsFwlwU9CWACYbBirNsluJ3U1+H8BTu1wqdrT/AXR5uIXeyCl5kiWKgX5q71eHWbYFOrqrg==} + peerDependencies: + '@tiptap/core': 3.22.4 + '@tiptap/pm': 3.22.4 + + '@tiptap/extension-ordered-list@3.22.4': + resolution: {integrity: sha512-w77hPVf7pcHt97vfrybg/l0t5CimCd4y75OJKuHuo3CfgM5xbUP/gaPNMDyLLe7MYole/UHi/XvG3XjgzqTzAw==} + peerDependencies: + '@tiptap/extension-list': 3.22.4 + + '@tiptap/extension-paragraph@3.22.3': + resolution: {integrity: sha512-oO7rhfyhEuwm+50s9K3GZPjYyEEEvFAvm1wXopvZnhbkBLydIWImBfrZoC5IQh4/sRDlTIjosV2C+ji5y0tUSg==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-strike@3.22.3': + resolution: {integrity: sha512-jY2InoUlKkuk5KHoIDGdML1OCA2n6PRHAtxwHNkAmiYh0Khf0zaVPGFpx4dgQrN7W5Q1WE6oBZnjrvy6qb7w0g==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-subscript@3.22.3': + resolution: {integrity: sha512-fcHinQMye6tPSxTB74CLW4Z/HbA9FX4epKOQ0ld0wIFsQB2bVz0NH9FfwrTEsYWLjeFWkDcL41VOReZXqKz1jQ==} + peerDependencies: + '@tiptap/core': ^3.22.3 + '@tiptap/pm': ^3.22.3 + + '@tiptap/extension-superscript@3.22.3': + resolution: {integrity: sha512-q+yPA+vbvaqiVGTJddjBhvWgqLXu6j39knz3TgJKw4nBuvoAXWrlWtgOy44wwIIs8vILI4wENoUuoI0+vOzynA==} + peerDependencies: + '@tiptap/core': ^3.22.3 + '@tiptap/pm': ^3.22.3 + + '@tiptap/extension-text-style@3.22.3': + resolution: {integrity: sha512-JKmWAogM/LX9ZJmXJQalpcR77wWVtVXdRFgvHGsFomW9WFhZqcnIEDWR2sbpZHWtu8dml6eBQGhdLppJmxeFfA==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-text@3.22.3': + resolution: {integrity: sha512-Q9R7JsTdomP5uUjtPjNKxHT1xoh/i9OJZnmgJLe7FcgZEaPOQ3bWxmKZoLZQfDfZjyB8BtH+Hc7nUvhCMOePxw==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extension-underline@3.22.3': + resolution: {integrity: sha512-Ch6CBWRa5w90yYSPUW6x9Py9JdrXMqk3pZ9OIlMYD8A7BqyZGfiHerX7XDMYDS09KjyK3U9XH60/zxYOzXdDLA==} + peerDependencies: + '@tiptap/core': ^3.22.3 + + '@tiptap/extensions@3.22.4': + resolution: {integrity: sha512-fOe8VptJvLPs32bNdUYo8SRyljwqKNQVXWW056VoXIc5en/59OdJlJQVeHI0jRRciH3MtrqODi/gfJR0VHNZ8A==} + peerDependencies: + '@tiptap/core': 3.22.4 + '@tiptap/pm': 3.22.4 + + '@tiptap/pm@3.22.3': + resolution: {integrity: sha512-NjfWjZuvrqmpICT+GZWNIjtOdhPyqFKDMtQy7tsQ5rErM9L2ZQdy/+T/BKSO1JdTeBhdg9OP+0yfsqoYp2aT6A==} + + '@tiptap/starter-kit@3.22.3': + resolution: {integrity: sha512-vdW/Oo1fdwTL1VOQ5YYbTov00ANeHLquBVEZyL/EkV7Xv5io9rXQsCysJfTSHhiQlyr2MtWFB4+CPGuwXjQWOQ==} + + '@tybys/wasm-util@0.10.1': + resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/estree@1.0.8': + resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + + '@types/linkify-it@5.0.0': + resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==} + + '@types/markdown-it@14.1.2': + resolution: {integrity: sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==} + + '@types/mdurl@2.0.0': + resolution: {integrity: sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==} + + '@vitest/expect@4.1.0': + resolution: {integrity: sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==} + + '@vitest/mocker@4.1.0': + resolution: {integrity: sha512-evxREh+Hork43+Y4IOhTo+h5lGmVRyjqI739Rz4RlUPqwrkFFDF6EMvOOYjTx4E8Tl6gyCLRL8Mu7Ry12a13Tw==} + peerDependencies: + msw: ^2.4.9 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/pretty-format@4.1.0': + resolution: {integrity: sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==} + + '@vitest/runner@4.1.0': + resolution: {integrity: sha512-Duvx2OzQ7d6OjchL+trw+aSrb9idh7pnNfxrklo14p3zmNL4qPCDeIJAK+eBKYjkIwG96Bc6vYuxhqDXQOWpoQ==} + + '@vitest/snapshot@4.1.0': + resolution: {integrity: sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==} + + '@vitest/spy@4.1.0': + resolution: {integrity: sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==} + + '@vitest/utils@4.1.0': + resolution: {integrity: sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==} + + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + chai@6.2.2: + resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} + engines: {node: '>=18'} + + convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + + crelt@1.0.6: + resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} + + es-module-lexer@2.0.0: + resolution: {integrity: sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==} + + esbuild@0.28.0: + resolution: {integrity: sha512-sNR9MHpXSUV/XB4zmsFKN+QgVG82Cc7+/aaxJ8Adi8hyOac+EXptIp45QBPaVyX3N70664wRbTcLTOemCAnyqw==} + engines: {node: '>=18'} + hasBin: true + + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + expect-type@1.3.0: + resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} + engines: {node: '>=12.0.0'} + + fast-diff@1.3.0: + resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fflate@0.8.2: + resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + lightningcss-android-arm64@1.32.0: + resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.32.0: + resolution: {integrity: sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.32.0: + resolution: {integrity: sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.32.0: + resolution: {integrity: sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.32.0: + resolution: {integrity: sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.32.0: + resolution: {integrity: sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + + lightningcss-linux-arm64-musl@1.32.0: + resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + + lightningcss-linux-x64-gnu@1.32.0: + resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + + lightningcss-linux-x64-musl@1.32.0: + resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + + lightningcss-win32-arm64-msvc@1.32.0: + resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.32.0: + resolution: {integrity: sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.32.0: + resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==} + engines: {node: '>= 12.0.0'} + + linkify-it@5.0.0: + resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} + + linkifyjs@4.3.2: + resolution: {integrity: sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA==} + + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + + markdown-it@14.1.1: + resolution: {integrity: sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==} + hasBin: true + + mdurl@2.0.0: + resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} + + nanoid@3.3.11: + resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + obug@2.1.1: + resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} + + orderedmap@2.1.1: + resolution: {integrity: sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==} + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.3: + resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} + engines: {node: '>=12'} + + postcss@8.5.8: + resolution: {integrity: sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==} + engines: {node: ^10 || ^12 || >=14} + + prosemirror-changeset@2.3.1: + resolution: {integrity: sha512-j0kORIBm8ayJNl3zQvD1TTPHJX3g042et6y/KQhZhnPrruO8exkTgG8X+NRpj7kIyMMEx74Xb3DyMIBtO0IKkQ==} + + prosemirror-collab@1.3.1: + resolution: {integrity: sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ==} + + prosemirror-commands@1.7.1: + resolution: {integrity: sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w==} + + prosemirror-dropcursor@1.8.2: + resolution: {integrity: sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==} + + prosemirror-gapcursor@1.4.0: + resolution: {integrity: sha512-z00qvurSdCEWUIulij/isHaqu4uLS8r/Fi61IbjdIPJEonQgggbJsLnstW7Lgdk4zQ68/yr6B6bf7sJXowIgdQ==} + + prosemirror-history@1.5.0: + resolution: {integrity: sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==} + + prosemirror-inputrules@1.5.1: + resolution: {integrity: sha512-7wj4uMjKaXWAQ1CDgxNzNtR9AlsuwzHfdFH1ygEHA2KHF2DOEaXl1CJfNPAKCg9qNEh4rum975QLaCiQPyY6Fw==} + + prosemirror-keymap@1.2.3: + resolution: {integrity: sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==} + + prosemirror-markdown@1.13.4: + resolution: {integrity: sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==} + + prosemirror-menu@1.3.2: + resolution: {integrity: sha512-6VgUJTYod0nMBlCaYJGhXGLu7Gt4AvcwcOq0YfJCY/6Uh+3S7UsWhpy6rJFCBFOmonq1hD8KyWOtZhkppd4YPg==} + + prosemirror-model@1.25.4: + resolution: {integrity: sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==} + + prosemirror-schema-basic@1.2.4: + resolution: {integrity: sha512-ELxP4TlX3yr2v5rM7Sb70SqStq5NvI15c0j9j/gjsrO5vaw+fnnpovCLEGIcpeGfifkuqJwl4fon6b+KdrODYQ==} + + prosemirror-schema-list@1.5.1: + resolution: {integrity: sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==} + + prosemirror-state@1.4.4: + resolution: {integrity: sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==} + + prosemirror-tables@1.8.5: + resolution: {integrity: sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==} + + prosemirror-trailing-node@3.0.0: + resolution: {integrity: sha512-xiun5/3q0w5eRnGYfNlW1uU9W6x5MoFKWwq/0TIRgt09lv7Hcser2QYV8t4muXbEr+Fwo0geYn79Xs4GKywrRQ==} + peerDependencies: + prosemirror-model: ^1.22.1 + prosemirror-state: ^1.4.2 + prosemirror-view: ^1.33.8 + + prosemirror-transform@1.11.0: + resolution: {integrity: sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==} + + prosemirror-view@1.41.5: + resolution: {integrity: sha512-UDQbIPnDrjE8tqUBbPmCOZgtd75htE6W3r0JCmY9bL6W1iemDM37MZEKC49d+tdQ0v/CKx4gjxLoLsfkD2NiZA==} + + punycode.js@2.3.1: + resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==} + engines: {node: '>=6'} + + rolldown@1.0.0-rc.9: + resolution: {integrity: sha512-9EbgWge7ZH+yqb4d2EnELAntgPTWbfL8ajiTW+SyhJEC4qhBbkCKbqFV4Ge4zmu5ziQuVbWxb/XwLZ+RIO7E8Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rope-sequence@1.3.4: + resolution: {integrity: sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==} + + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + + source-map-js@1.2.1: + resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + engines: {node: '>=0.10.0'} + + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + + std-env@4.0.0: + resolution: {integrity: sha512-zUMPtQ/HBY3/50VbpkupYHbRroTRZJPRLvreamgErJVys0ceuzMkD44J/QjqhHjOzK42GQ3QZIeFG1OYfOtKqQ==} + + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinyexec@1.0.4: + resolution: {integrity: sha512-u9r3uZC0bdpGOXtlxUIdwf9pkmvhqJdrVCH9fapQtgy/OeTTMZ1nqH7agtvEfmGui6e1XxjcdrlxvxJvc3sMqw==} + engines: {node: '>=18'} + + tinyglobby@0.2.15: + resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} + engines: {node: '>=12.0.0'} + + tinyrainbow@3.1.0: + resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==} + engines: {node: '>=14.0.0'} + + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + uc.micro@2.1.0: + resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==} + + vite@8.0.0: + resolution: {integrity: sha512-fPGaRNj9Zytaf8LEiBhY7Z6ijnFKdzU/+mL8EFBaKr7Vw1/FWcTBAMW0wLPJAGMPX38ZPVCVgLceWiEqeoqL2Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.0.0-alpha.31 + esbuild: ^0.27.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@4.1.0: + resolution: {integrity: sha512-YbDrMF9jM2Lqc++2530UourxZHmkKLxrs4+mYhEwqWS97WJ7wOYEkcr+QfRgJ3PW9wz3odRijLZjHEaRLTNbqw==} + engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 4.1.0 + '@vitest/browser-preview': 4.1.0 + '@vitest/browser-webdriverio': 4.1.0 + '@vitest/ui': 4.1.0 + happy-dom: '*' + jsdom: '*' + vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + w3c-keyname@2.2.8: + resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==} + + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + +snapshots: + + '@emnapi/core@1.9.0': + dependencies: + '@emnapi/wasi-threads': 1.2.0 + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.9.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.2.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@esbuild/aix-ppc64@0.28.0': + optional: true + + '@esbuild/android-arm64@0.28.0': + optional: true + + '@esbuild/android-arm@0.28.0': + optional: true + + '@esbuild/android-x64@0.28.0': + optional: true + + '@esbuild/darwin-arm64@0.28.0': + optional: true + + '@esbuild/darwin-x64@0.28.0': + optional: true + + '@esbuild/freebsd-arm64@0.28.0': + optional: true + + '@esbuild/freebsd-x64@0.28.0': + optional: true + + '@esbuild/linux-arm64@0.28.0': + optional: true + + '@esbuild/linux-arm@0.28.0': + optional: true + + '@esbuild/linux-ia32@0.28.0': + optional: true + + '@esbuild/linux-loong64@0.28.0': + optional: true + + '@esbuild/linux-mips64el@0.28.0': + optional: true + + '@esbuild/linux-ppc64@0.28.0': + optional: true + + '@esbuild/linux-riscv64@0.28.0': + optional: true + + '@esbuild/linux-s390x@0.28.0': + optional: true + + '@esbuild/linux-x64@0.28.0': + optional: true + + '@esbuild/netbsd-arm64@0.28.0': + optional: true + + '@esbuild/netbsd-x64@0.28.0': + optional: true + + '@esbuild/openbsd-arm64@0.28.0': + optional: true + + '@esbuild/openbsd-x64@0.28.0': + optional: true + + '@esbuild/openharmony-arm64@0.28.0': + optional: true + + '@esbuild/sunos-x64@0.28.0': + optional: true + + '@esbuild/win32-arm64@0.28.0': + optional: true + + '@esbuild/win32-ia32@0.28.0': + optional: true + + '@esbuild/win32-x64@0.28.0': + optional: true + + '@jridgewell/sourcemap-codec@1.5.5': {} + + '@napi-rs/wasm-runtime@1.1.1': + dependencies: + '@emnapi/core': 1.9.0 + '@emnapi/runtime': 1.9.0 + '@tybys/wasm-util': 0.10.1 + optional: true + + '@oxc-project/runtime@0.115.0': {} + + '@oxc-project/types@0.115.0': {} + + '@remirror/core-constants@3.0.0': {} + + '@rolldown/binding-android-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-darwin-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-darwin-x64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-freebsd-x64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': + dependencies: + '@napi-rs/wasm-runtime': 1.1.1 + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': + optional: true + + '@rolldown/pluginutils@1.0.0-rc.9': {} + + '@standard-schema/spec@1.1.0': {} + + '@tiptap/core@3.22.3(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-blockquote@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-bold@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-bullet-list@3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extension-list': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-code-block@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-code@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-document@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-dropcursor@3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extensions': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-gapcursor@3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extensions': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-hard-break@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-heading@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-history@3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extensions': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-horizontal-rule@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-italic@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-link@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + linkifyjs: 4.3.2 + + '@tiptap/extension-list-item@3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extension-list': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-list-keymap@3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extension-list': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-ordered-list@3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/extension-list': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + + '@tiptap/extension-paragraph@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-strike@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-subscript@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-superscript@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/extension-text-style@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-text@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extension-underline@3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + + '@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tiptap/pm@3.22.3': + dependencies: + prosemirror-changeset: 2.3.1 + prosemirror-collab: 1.3.1 + prosemirror-commands: 1.7.1 + prosemirror-dropcursor: 1.8.2 + prosemirror-gapcursor: 1.4.0 + prosemirror-history: 1.5.0 + prosemirror-inputrules: 1.5.1 + prosemirror-keymap: 1.2.3 + prosemirror-markdown: 1.13.4 + prosemirror-menu: 1.3.2 + prosemirror-model: 1.25.4 + prosemirror-schema-basic: 1.2.4 + prosemirror-schema-list: 1.5.1 + prosemirror-state: 1.4.4 + prosemirror-tables: 1.8.5 + prosemirror-trailing-node: 3.0.0(prosemirror-model@1.25.4)(prosemirror-state@1.4.4)(prosemirror-view@1.41.5) + prosemirror-transform: 1.11.0 + prosemirror-view: 1.41.5 + + '@tiptap/starter-kit@3.22.3': + dependencies: + '@tiptap/core': 3.22.3(@tiptap/pm@3.22.3) + '@tiptap/extension-blockquote': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-bold': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-bullet-list': 3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-code': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-code-block': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-document': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-dropcursor': 3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-gapcursor': 3.22.3(@tiptap/extensions@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-hard-break': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-heading': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-horizontal-rule': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-italic': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-link': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-list': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/extension-list-item': 3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-list-keymap': 3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-ordered-list': 3.22.4(@tiptap/extension-list@3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3)) + '@tiptap/extension-paragraph': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-strike': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-text': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extension-underline': 3.22.3(@tiptap/core@3.22.3(@tiptap/pm@3.22.3)) + '@tiptap/extensions': 3.22.4(@tiptap/core@3.22.3(@tiptap/pm@3.22.3))(@tiptap/pm@3.22.3) + '@tiptap/pm': 3.22.3 + + '@tybys/wasm-util@0.10.1': + dependencies: + tslib: 2.8.1 + optional: true + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + + '@types/estree@1.0.8': {} + + '@types/linkify-it@5.0.0': {} + + '@types/markdown-it@14.1.2': + dependencies: + '@types/linkify-it': 5.0.0 + '@types/mdurl': 2.0.0 + + '@types/mdurl@2.0.0': {} + + '@vitest/expect@4.1.0': + dependencies: + '@standard-schema/spec': 1.1.0 + '@types/chai': 5.2.3 + '@vitest/spy': 4.1.0 + '@vitest/utils': 4.1.0 + chai: 6.2.2 + tinyrainbow: 3.1.0 + + '@vitest/mocker@4.1.0(vite@8.0.0(esbuild@0.28.0))': + dependencies: + '@vitest/spy': 4.1.0 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + vite: 8.0.0(esbuild@0.28.0) + + '@vitest/pretty-format@4.1.0': + dependencies: + tinyrainbow: 3.1.0 + + '@vitest/runner@4.1.0': + dependencies: + '@vitest/utils': 4.1.0 + pathe: 2.0.3 + + '@vitest/snapshot@4.1.0': + dependencies: + '@vitest/pretty-format': 4.1.0 + '@vitest/utils': 4.1.0 + magic-string: 0.30.21 + pathe: 2.0.3 + + '@vitest/spy@4.1.0': {} + + '@vitest/utils@4.1.0': + dependencies: + '@vitest/pretty-format': 4.1.0 + convert-source-map: 2.0.0 + tinyrainbow: 3.1.0 + + argparse@2.0.1: {} + + assertion-error@2.0.1: {} + + chai@6.2.2: {} + + convert-source-map@2.0.0: {} + + crelt@1.0.6: {} + + detect-libc@2.1.2: {} + + entities@4.5.0: {} + + es-module-lexer@2.0.0: {} + + esbuild@0.28.0: + optionalDependencies: + '@esbuild/aix-ppc64': 0.28.0 + '@esbuild/android-arm': 0.28.0 + '@esbuild/android-arm64': 0.28.0 + '@esbuild/android-x64': 0.28.0 + '@esbuild/darwin-arm64': 0.28.0 + '@esbuild/darwin-x64': 0.28.0 + '@esbuild/freebsd-arm64': 0.28.0 + '@esbuild/freebsd-x64': 0.28.0 + '@esbuild/linux-arm': 0.28.0 + '@esbuild/linux-arm64': 0.28.0 + '@esbuild/linux-ia32': 0.28.0 + '@esbuild/linux-loong64': 0.28.0 + '@esbuild/linux-mips64el': 0.28.0 + '@esbuild/linux-ppc64': 0.28.0 + '@esbuild/linux-riscv64': 0.28.0 + '@esbuild/linux-s390x': 0.28.0 + '@esbuild/linux-x64': 0.28.0 + '@esbuild/netbsd-arm64': 0.28.0 + '@esbuild/netbsd-x64': 0.28.0 + '@esbuild/openbsd-arm64': 0.28.0 + '@esbuild/openbsd-x64': 0.28.0 + '@esbuild/openharmony-arm64': 0.28.0 + '@esbuild/sunos-x64': 0.28.0 + '@esbuild/win32-arm64': 0.28.0 + '@esbuild/win32-ia32': 0.28.0 + '@esbuild/win32-x64': 0.28.0 + + escape-string-regexp@4.0.0: {} + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.8 + + expect-type@1.3.0: {} + + fast-diff@1.3.0: {} + + fdir@6.5.0(picomatch@4.0.3): + optionalDependencies: + picomatch: 4.0.3 + + fflate@0.8.2: {} + + fsevents@2.3.3: + optional: true + + lightningcss-android-arm64@1.32.0: + optional: true + + lightningcss-darwin-arm64@1.32.0: + optional: true + + lightningcss-darwin-x64@1.32.0: + optional: true + + lightningcss-freebsd-x64@1.32.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.32.0: + optional: true + + lightningcss-linux-arm64-gnu@1.32.0: + optional: true + + lightningcss-linux-arm64-musl@1.32.0: + optional: true + + lightningcss-linux-x64-gnu@1.32.0: + optional: true + + lightningcss-linux-x64-musl@1.32.0: + optional: true + + lightningcss-win32-arm64-msvc@1.32.0: + optional: true + + lightningcss-win32-x64-msvc@1.32.0: + optional: true + + lightningcss@1.32.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.32.0 + lightningcss-darwin-arm64: 1.32.0 + lightningcss-darwin-x64: 1.32.0 + lightningcss-freebsd-x64: 1.32.0 + lightningcss-linux-arm-gnueabihf: 1.32.0 + lightningcss-linux-arm64-gnu: 1.32.0 + lightningcss-linux-arm64-musl: 1.32.0 + lightningcss-linux-x64-gnu: 1.32.0 + lightningcss-linux-x64-musl: 1.32.0 + lightningcss-win32-arm64-msvc: 1.32.0 + lightningcss-win32-x64-msvc: 1.32.0 + + linkify-it@5.0.0: + dependencies: + uc.micro: 2.1.0 + + linkifyjs@4.3.2: {} + + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + + markdown-it@14.1.1: + dependencies: + argparse: 2.0.1 + entities: 4.5.0 + linkify-it: 5.0.0 + mdurl: 2.0.0 + punycode.js: 2.3.1 + uc.micro: 2.1.0 + + mdurl@2.0.0: {} + + nanoid@3.3.11: {} + + obug@2.1.1: {} + + orderedmap@2.1.1: {} + + pathe@2.0.3: {} + + picocolors@1.1.1: {} + + picomatch@4.0.3: {} + + postcss@8.5.8: + dependencies: + nanoid: 3.3.11 + picocolors: 1.1.1 + source-map-js: 1.2.1 + + prosemirror-changeset@2.3.1: + dependencies: + prosemirror-transform: 1.11.0 + + prosemirror-collab@1.3.1: + dependencies: + prosemirror-state: 1.4.4 + + prosemirror-commands@1.7.1: + dependencies: + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + + prosemirror-dropcursor@1.8.2: + dependencies: + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + prosemirror-view: 1.41.5 + + prosemirror-gapcursor@1.4.0: + dependencies: + prosemirror-keymap: 1.2.3 + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-view: 1.41.5 + + prosemirror-history@1.5.0: + dependencies: + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + prosemirror-view: 1.41.5 + rope-sequence: 1.3.4 + + prosemirror-inputrules@1.5.1: + dependencies: + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + + prosemirror-keymap@1.2.3: + dependencies: + prosemirror-state: 1.4.4 + w3c-keyname: 2.2.8 + + prosemirror-markdown@1.13.4: + dependencies: + '@types/markdown-it': 14.1.2 + markdown-it: 14.1.1 + prosemirror-model: 1.25.4 + + prosemirror-menu@1.3.2: + dependencies: + crelt: 1.0.6 + prosemirror-commands: 1.7.1 + prosemirror-history: 1.5.0 + prosemirror-state: 1.4.4 + + prosemirror-model@1.25.4: + dependencies: + orderedmap: 2.1.1 + + prosemirror-schema-basic@1.2.4: + dependencies: + prosemirror-model: 1.25.4 + + prosemirror-schema-list@1.5.1: + dependencies: + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + + prosemirror-state@1.4.4: + dependencies: + prosemirror-model: 1.25.4 + prosemirror-transform: 1.11.0 + prosemirror-view: 1.41.5 + + prosemirror-tables@1.8.5: + dependencies: + prosemirror-keymap: 1.2.3 + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + prosemirror-view: 1.41.5 + + prosemirror-trailing-node@3.0.0(prosemirror-model@1.25.4)(prosemirror-state@1.4.4)(prosemirror-view@1.41.5): + dependencies: + '@remirror/core-constants': 3.0.0 + escape-string-regexp: 4.0.0 + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-view: 1.41.5 + + prosemirror-transform@1.11.0: + dependencies: + prosemirror-model: 1.25.4 + + prosemirror-view@1.41.5: + dependencies: + prosemirror-model: 1.25.4 + prosemirror-state: 1.4.4 + prosemirror-transform: 1.11.0 + + punycode.js@2.3.1: {} + + rolldown@1.0.0-rc.9: + dependencies: + '@oxc-project/types': 0.115.0 + '@rolldown/pluginutils': 1.0.0-rc.9 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-rc.9 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.9 + '@rolldown/binding-darwin-x64': 1.0.0-rc.9 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.9 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.9 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.9 + '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.9 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.9 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.9 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.9 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.9 + + rope-sequence@1.3.4: {} + + siginfo@2.0.0: {} + + source-map-js@1.2.1: {} + + stackback@0.0.2: {} + + std-env@4.0.0: {} + + tinybench@2.9.0: {} + + tinyexec@1.0.4: {} + + tinyglobby@0.2.15: + dependencies: + fdir: 6.5.0(picomatch@4.0.3) + picomatch: 4.0.3 + + tinyrainbow@3.1.0: {} + + tslib@2.8.1: + optional: true + + uc.micro@2.1.0: {} + + vite@8.0.0(esbuild@0.28.0): + dependencies: + '@oxc-project/runtime': 0.115.0 + lightningcss: 1.32.0 + picomatch: 4.0.3 + postcss: 8.5.8 + rolldown: 1.0.0-rc.9 + tinyglobby: 0.2.15 + optionalDependencies: + esbuild: 0.28.0 + fsevents: 2.3.3 + + vitest@4.1.0(vite@8.0.0(esbuild@0.28.0)): + dependencies: + '@vitest/expect': 4.1.0 + '@vitest/mocker': 4.1.0(vite@8.0.0(esbuild@0.28.0)) + '@vitest/pretty-format': 4.1.0 + '@vitest/runner': 4.1.0 + '@vitest/snapshot': 4.1.0 + '@vitest/spy': 4.1.0 + '@vitest/utils': 4.1.0 + es-module-lexer: 2.0.0 + expect-type: 1.3.0 + magic-string: 0.30.21 + obug: 2.1.1 + pathe: 2.0.3 + picomatch: 4.0.3 + std-env: 4.0.0 + tinybench: 2.9.0 + tinyexec: 1.0.4 + tinyglobby: 0.2.15 + tinyrainbow: 3.1.0 + vite: 8.0.0(esbuild@0.28.0) + why-is-node-running: 2.3.0 + transitivePeerDependencies: + - msw + + w3c-keyname@2.2.8: {} + + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 diff --git a/src/minimal-docx.js b/src/minimal-docx.js index 3063063..5123d76 100644 --- a/src/minimal-docx.js +++ b/src/minimal-docx.js @@ -1,4 +1,4 @@ -import JSZip from 'jszip'; +import { strToU8, zipSync } from 'fflate'; export class MinimalDocxGenerator { constructor(options = {}) { @@ -23,8 +23,6 @@ export class MinimalDocxGenerator { } async generate() { - const zip = new JSZip(); - // 0. Map IDs to Integers (1-based) let fnIndex = 1; Object.keys(this.footnotes).forEach(id => { @@ -36,20 +34,19 @@ export class MinimalDocxGenerator { this.commentIdMap.set(id, cmIndex++); }); - zip.file('[Content_Types].xml', this.createContentTypesXml()); - zip.folder('_rels').file('.rels', this.createRelsXml()); + const zipObj = { + '[Content_Types].xml': strToU8(this.createContentTypesXml()), + '_rels/.rels': strToU8(this.createRelsXml()), + 'word/document.xml': strToU8(this.createDocumentXml()), + 'word/styles.xml': strToU8(this.createStylesXml()), + 'word/fontTable.xml': strToU8(this.createFontTableXml()), + 'word/footnotes.xml': strToU8(this.createFootnotesXml()), + 'word/settings.xml': strToU8(this.createSettingsXml()), + 'word/comments.xml': strToU8(this.createCommentsXml()), + 'word/_rels/document.xml.rels': strToU8(this.createDocumentRelsXml()) + }; - const word = zip.folder('word'); - word.file('document.xml', this.createDocumentXml()); - word.file('styles.xml', this.createStylesXml()); - word.file('fontTable.xml', this.createFontTableXml()); - word.file('footnotes.xml', this.createFootnotesXml()); - word.file('settings.xml', this.createSettingsXml()); - word.file('comments.xml', this.createCommentsXml()); - - word.folder('_rels').file('document.xml.rels', this.createDocumentRelsXml()); - - return zip.generateAsync({ type: 'nodebuffer' }); + return Buffer.from(zipSync(zipObj)); } // --- XML Generators --- diff --git a/styles.css b/styles.css index 2bd5b44..c11c59a 100644 --- a/styles.css +++ b/styles.css @@ -13,7 +13,7 @@ } /* 1. WORKSPACE CONTAINER */ -.colophon-workspace { +.workspace-leaf .colophon-workspace { background-color: var(--background-primary); position: relative; width: 100%; @@ -21,7 +21,7 @@ overflow: hidden; display: flex; flex-direction: column; - padding: 0 !important; + padding: 0; } .colophon-scroll-container { @@ -37,14 +37,14 @@ /* 2. THE EDITOR CANVAS (Main) */ -.colophon-main-editor { +.workspace-leaf .colophon-main-editor { /* Layout */ width: 100%; /* Use the variable set by JS, or fallback to 1080px (new default) */ max-width: var(--colophon-editor-width, 1080px); min-height: 100%; margin: 0 auto; - padding: 0 2rem 75vh 2rem !important; + padding: 0 2rem 75vh; /* Top padding 0, Bottom 75vh, Sides 2rem */ /* Appearance */ @@ -74,8 +74,8 @@ } /* Ensure first element is flush with top */ -.colophon-main-editor > *:first-child { - margin-top: 0 !important; +.workspace-leaf .colophon-main-editor > *:first-child { + margin-top: 0; } /* Selection Styling - Applies to all editors in workspace */ @@ -458,28 +458,26 @@ width: 100%; } -.colophon-comment-editor { +.workspace-leaf .colophon-comment-editor { font-size: 0.9rem; line-height: 1.4; min-height: 1.2em; outline: none; /* Revert to theme defaults for comments */ - font-family: var(--font-interface) !important; - font-variant: normal !important; - text-indent: 0 !important; + font-family: var(--font-interface); + font-variant: normal; } /* Comment Preview Overrides */ -.colophon-comment-preview, -.colophon-comment-preview p { - font-family: var(--font-text-interface) !important; - font-size: 0.9rem !important; - font-variant: normal !important; - font-style: normal !important; - text-indent: 0 !important; - padding: 0 !important; - color: var(--text-normal) !important; - line-height: 1.4 !important; +.workspace-leaf .colophon-comment-preview, +.workspace-leaf .colophon-comment-preview p { + font-family: var(--font-text-interface); + font-size: 0.9rem; + font-variant: normal; + font-style: normal; + padding: 0; + color: var(--text-normal); + line-height: 1.4; cursor: pointer; min-height: 1.2em; white-space: pre-wrap; @@ -625,10 +623,10 @@ } /* 12. GLOBAL SIDEBAR OVERRIDES */ -.colophon-main-layout.is-global-sidebar .colophon-z-axis-panel { +.workspace-leaf .colophon-main-layout.is-global-sidebar .colophon-z-axis-panel { display: none; - width: 0 !important; - border-left: none !important; + width: 0; + border-left: none; } .colophon-sidebar-view .colophon-z-axis-panel { @@ -721,13 +719,13 @@ width: 100%; } -.colophon-footnote-editor { +.workspace-leaf .colophon-footnote-editor { outline: none; min-height: auto; cursor: text; width: 100%; - background-color: transparent !important; - border: 0 !important; + background-color: transparent; + border: 0; } .colophon-footnote-preview { @@ -755,20 +753,20 @@ box-shadow: 0 0 0 1px var(--interactive-accent); } -.colophon-footnote-editor .ProseMirror { - padding: 0 !important; - margin: 0 !important; - width: 100% !important; - min-height: auto !important; - background-color: transparent !important; - box-shadow: none !important; - border: 0 !important; +.workspace-leaf .colophon-footnote-editor .ProseMirror { + padding: 0; + margin: 0; + width: 100%; + min-height: auto; + background-color: transparent; + box-shadow: none; + border: 0; } /* Base reset for paragraphs in mini-editors */ -.colophon-footnote-editor p { - margin: 0 !important; - padding: 0 !important; +.workspace-leaf .colophon-footnote-editor p { + margin: 0; + padding: 0; } /* Footnote Marker in Canvas */ @@ -999,26 +997,7 @@ margin-top: 10px; } -.colophon-export-margins__label { - font-size: 11px; - line-height: 1.2; - color: var(--text-muted); - margin-bottom: 4px; -} -.colophon-export-margins__input { - width: 100%; - padding: 6px 8px; - border-radius: var(--radius-s); - border: 1px solid var(--background-modifier-border); - background: var(--background-modifier-form-field); - color: var(--text-normal); -} - -.colophon-export-margins__input:focus { - outline: none; - border-color: var(--interactive-accent); -} /* BLOCK SETTINGS UI */ .colophon-block-settings { margin-top: 20px;