zt-react-milkdown 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -50,7 +50,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
50
50
  `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?gC:hC))),s(),o}}function hC(e,t,n){return t===0?e:gC(e,t,n)}function gC(e,t,n){return(n?``:` `)+e}var _C=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];SC.peek=CC;function vC(){return{canContainEols:[`delete`],enter:{strikethrough:bC},exit:{strikethrough:xC}}}function yC(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:_C}],handlers:{delete:SC}}}function bC(e){this.enter({type:`delete`,children:[]},e)}function xC(e){this.exit(e)}function SC(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function CC(){return`~`}function wC(e){return e.length}function TC(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||wC,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=EC(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=DC(r[d]);else{let e=DC(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
51
51
  `)}function EC(e){return e==null?``:String(e)}function DC(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function OC(){return{enter:{table:kC,tableData:NC,tableHeader:NC,tableRow:jC},exit:{codeText:PC,table:AC,tableData:MC,tableHeader:MC,tableRow:MC}}}function kC(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function AC(e){this.exit(e),this.data.inTable=void 0}function jC(e){this.enter({type:`tableRow`,children:[]},e)}function MC(e){this.exit(e)}function NC(e){this.enter({type:`tableCell`,children:[]},e)}function PC(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,FC));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function FC(e,t){return t===`|`?t:e}function IC(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
52
52
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
53
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return TC(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Ys.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function LC(){return{exit:{taskListCheckValueChecked:zC,taskListCheckValueUnchecked:zC,paragraph:BC}}}function RC(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:VC}}}function zC(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function BC(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function VC(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Ys.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function HC(){return[US(),pC(),vC(),OC(),LC()]}function UC(e){return{extensions:[WS(),mC(e),yC(),IC(e),RC()]}}var WC={tokenize:iw,partial:!0},GC={tokenize:aw,partial:!0},KC={tokenize:ow,partial:!0},qC={tokenize:sw,partial:!0},JC={tokenize:cw,partial:!0},YC={name:`wwwAutolink`,tokenize:nw,previous:lw},XC={name:`protocolAutolink`,tokenize:rw,previous:uw},ZC={name:`emailAutolink`,tokenize:tw,previous:dw},QC={};function $C(){return{text:QC}}for(var ew=48;ew<123;)QC[ew]=ZC,ew++,ew===58?ew=65:ew===91&&(ew=97);QC[43]=ZC,QC[45]=ZC,QC[46]=ZC,QC[95]=ZC,QC[72]=[ZC,XC],QC[104]=[ZC,XC],QC[87]=[ZC,YC],QC[119]=[ZC,YC];function tw(e,t,n){let r=this,i,a;return o;function o(t){return!fw(t)||!dw.call(r,r.previous)||pw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return fw(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(JC,u,l)(t):t===45||t===95||Kr(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Gr(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function nw(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!lw.call(r,r.previous)||pw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(WC,e.attempt(GC,e.attempt(KC,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function rw(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&uw.call(r,r.previous)&&!pw(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Gr(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Jr(t)||Qr(t)||ti(t)||ei(t)?n(t):e.attempt(GC,e.attempt(KC,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function iw(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function aw(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(qC,c,s)(t):t===null||Qr(t)||ti(t)||t!==45&&ei(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function ow(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(qC,t,a)(o):o===null||Qr(o)||ti(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function sw(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Qr(o)||ti(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Qr(e)||ti(e)?t(e):r(e)}function a(e){return Gr(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Gr(t)?(e.consume(t),o):n(t)}}function cw(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Kr(e)?n(e):t(e)}}function lw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Qr(e)}function uw(e){return!Gr(e)}function dw(e){return!(e===47||fw(e))}function fw(e){return e===43||e===45||e===46||e===95||Kr(e)}function pw(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var mw={tokenize:Sw,partial:!0};function hw(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:yw,continuation:{tokenize:bw},exit:xw}},text:{91:{name:`gfmFootnoteCall`,tokenize:vw},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:gw,resolveTo:_w}}}}function gw(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Wr(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function _w(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function vw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Qr(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Wr(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Qr(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function yw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Qr(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Wr(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Qr(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),ri(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function bw(e,t,n){return e.check(vi,t,e.attempt(mw,t,n))}function xw(e){e.exit(`gfmFootnoteDefinition`)}function Sw(e,t,n){let r=this;return ri(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Cw(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Lr(o,o.length,0,di(s,e.slice(r+1,n),t)),Lr(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Lr(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ui(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ui(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ww=class{constructor(){this.map=[]}add(e,t,n){Tw(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Tw(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Ew(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Dw(){return{flow:{null:{name:`table`,tokenize:Ow,resolveAll:kw}}}}function Ow(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):N(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):$r(t)?ri(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Qr(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,$r(t)?ri(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return $r(t)?ri(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||N(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return $r(t)?ri(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||N(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||N(n)?(e.exit(`tableRow`),t(n)):$r(n)?ri(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Qr(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function kw(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new ww;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(jw(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Aw(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Aw(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Aw(f,t,o,i,n,d)):(o[0]=o[1],d=Aw(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&jw(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Ew(t.events,n))}return e}function Aw(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Mw(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Mw(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Mw(t.events,n[2]),a=Mw(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Mw(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function jw(e,t,n,r,i){let a=[],o=Mw(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Mw(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Nw={name:`tasklistCheck`,tokenize:Fw};function Pw(){return{text:{91:Nw}}}function Fw(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Qr(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return N(r)?t(r):$r(r)?e.check({tokenize:Iw},t,n)(r):n(r)}}function Iw(e,t,n){return ri(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Lw(e){return Br([$C(),hw(),Cw(e),Dw(),Pw()])}var Rw={};function zw(e){let t=this,n=e||Rw,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Lw(n)),a.push(HC()),o.push(UC(n))}function Bw(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var Vw=Kg(`strike_through`);Bw(Vw,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var Hw=Ug(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(Vw.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));Bw(Hw.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),Bw(Hw.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var Uw=Pg(`ToggleStrikeThrough`,e=>()=>Ml(Hw.type(e)));Bw(Uw,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var Ww=Fg(e=>ru(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,Hw.type(e)));Bw(Ww,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var Gw=Wg(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(Uh);return()=>t.call(Uw.key)}}});Bw(Gw.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),Bw(Gw.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var Kw=Fb({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),qw=Hg(`table`,()=>({...Kw.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));Bw(qw.node,{displayName:`NodeSchema<table>`,group:`Table`}),Bw(qw.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var Jw=Hg(`table_header_row`,()=>({...Kw.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));Bw(Jw.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),Bw(Jw.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var Yw=Hg(`table_row`,()=>({...Kw.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));Bw(Yw.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),Bw(Yw.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var Xw=Hg(`table_cell`,()=>({...Kw.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));Bw(Xw.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),Bw(Xw.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var Zw=Hg(`table_header`,()=>({...Kw.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));Bw(Zw.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),Bw(Zw.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function Qw(e,t=3,n=3){let r=Array(n).fill(0).map(()=>Xw.type(e).createAndFill()),i=Array(n).fill(0).map(()=>Zw.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?Jw.type(e).create(null,i):Yw.type(e).create(null,r));return qw.type(e).create(null,a)}function $w(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=Cu(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=Db.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?Yb.rowSelection:Yb.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return hu(r.setSelection(a(i,l)))}}return r}}var eT=$w(`row`),tT=$w(`col`);function nT(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return Xw.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,Yw.type(e).create(null,s)),t}function rT(e){let t=cx(e.$from);if(!t)return;let n=Db.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function iT(e){let t=rT(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return hu(e.setSelection(new Yb(t,n)))}}return e}var aT=Pg(`GoToPrevTableCell`,()=>()=>Ix(-1));Bw(aT,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var oT=Pg(`GoToNextTableCell`,()=>()=>Ix(1));Bw(oT,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var sT=Pg(`ExitTable`,e=>()=>(t,n)=>{if(!zb(t))return!1;let{$head:r}=t.selection,i=xu(r,qw.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,ny.type(e).createAndFill());return o.setSelection(Nn.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});Bw(sT,{displayName:`Command<breakTableCommand>`,group:`Table`});var cT=Pg(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=Qw(e,t,n),l=o.replaceSelectionWith(c),u=Nn.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});Bw(cT,{displayName:`Command<insertTableCommand>`,group:`Table`});var lT=Pg(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>zx({from:e??0,to:t??0,pos:n}));Bw(lT,{displayName:`Command<moveRowCommand>`,group:`Table`});var uT=Pg(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>Bx({from:e??0,to:t??0,pos:n}));Bw(uT,{displayName:`Command<moveColCommand>`,group:`Table`});var dT=Pg(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(eT(e.index,e.pos)(r))});Bw(dT,{displayName:`Command<selectRowCommand>`,group:`Table`});var fT=Pg(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(tT(e.index,e.pos)(r))});Bw(fT,{displayName:`Command<selectColCommand>`,group:`Table`});var pT=Pg(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(iT(n))});Bw(pT,{displayName:`Command<selectTableCommand>`,group:`Table`});var mT=Pg(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof Yb))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Lx(e,t):i?wx(e,t):Ax(e,t)});Bw(mT,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var hT=Pg(`AddColBefore`,()=>()=>xx);Bw(hT,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var gT=Pg(`AddColAfter`,()=>()=>Sx);Bw(gT,{displayName:`Command<addColAfterCommand>`,group:`Table`});var _T=Pg(`AddRowBefore`,e=>()=>(t,n)=>{if(!zb(t))return!1;if(n){let r=yx(t);n(nT(e,t.tr,r,r.top))}return!0});Bw(_T,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var vT=Pg(`AddRowAfter`,e=>()=>(t,n)=>{if(!zb(t))return!1;if(n){let r=yx(t);n(nT(e,t.tr,r,r.bottom))}return!0});Bw(vT,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var yT=Pg(`SetAlign`,()=>(e=`left`)=>jx(`alignment`,e));Bw(yT,{displayName:`Command<setAlignCommand>`,group:`Table`});var bT=Fg(e=>new zl(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),qw.type(e)))return null;let o=Qw(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(j.create(s.doc,r+3)).scrollIntoView()}));Bw(bT,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var xT=Ig(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return ny.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push(Zw.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>Zw.type(e).createAndFill()),o=new k(D.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new k(D.from(s),0,0))}function a(t){let n=Yw.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=Jw.type(e).createAndFill(),n=qw.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?D.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===qw.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?D.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===ny.type(e)&&i.content.size===0&&a&&a.type===qw.type(e)||n.push(i)}return n.length<r.length?D.from(n):t}let c=o(t.content);return c=s(c),new k(D.from(c),t.openStart,t.openEnd)}}));Bw(xT,{displayName:`PasteRule<table>`,group:`Table`});var ST=Wg(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(Uh);return()=>t.call(oT.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(Uh);return()=>t.call(aT.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(Uh);return()=>t.call(sT.key)}}});Bw(ST.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),Bw(ST.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var CT=`footnote_definition`,wT=`footnoteDefinition`,TT=Hg(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${CT}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":CT},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===wT,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===CT,runner:(e,t)=>{e.openNode(wT,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));Bw(TT.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),Bw(TT.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var ET=`footnote_reference`,DT=Hg(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${ET}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":ET},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===ET,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));Bw(DT.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),Bw(DT.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var OT=Jy.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});Bw(OT.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),Bw(OT.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var kT=Fg(()=>new zl(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));Bw(kT,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var AT=[Gw,ST].flat(),jT=[bT,kT],MT=[Ww],NT=[xT],PT=zg(()=>PS);Bw(PT,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),Bw(zg(()=>cS({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var FT=zg(()=>SS({allowTableNodeSelection:!0}));Bw(FT,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var IT=qg(`remarkGFM`,()=>zw);Bw(IT.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),Bw(IT.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var LT=new nr(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function RT(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var zT=zg(()=>new $n({key:LT,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=RT(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));Bw(zT,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var BT=[zT,PT,IT,FT].flat(),VT=[[OT,qw,Jw,Yw,Zw,Xw,TT,DT,Vw,Hw].flat(),jT,NT,MT,AT,[oT,aT,sT,cT,lT,uT,dT,fT,pT,mT,_T,vT,hT,gT,yT,Uw],BT].flat(),HT=(e,t)=>typeof e==`function`?n=>{t.action(e(n))}:()=>void 0,UT=(e,t,n)=>{if(Array.isArray(n)){n.forEach((n,r)=>{e.push({name:`${t}-${r}`,plugin:n})});return}e.push({name:t,plugin:n})},WT=(e,t={})=>{let n=[],r=t.includeRuntime??!0;return UT(n,`listener`,e.listener),UT(n,`commonmark`,e.commonmark),UT(n,`gfm`,e.gfm),UT(n,`history`,e.history),UT(n,`code-block-prism`,e.codeBlockPrism),UT(n,`code-block-language-picker`,e.codeBlockLanguagePicker),r&&(UT(n,`clipboard`,e.clipboard),UT(n,`indent`,e.indent)),UT(n,`image-delete-selection`,e.imageDeleteSelection),UT(n,`image-paste`,e.imagePaste),UT(n,`table-arrow-entry`,e.tableArrowEntry),UT(n,`block-boundary-navigation`,e.blockBoundaryNavigation),UT(n,`heading-backspace-empty-paragraph`,e.headingBackspaceEmptyParagraph),UT(n,`math-backspace-entry`,e.mathBackspaceEntry),UT(n,`blockquote-backspace-lift`,e.blockquoteBackspaceLift),UT(n,`table-focus-actions`,e.tableFocusActions),UT(n,`selection-tooltip`,e.selectionTooltip),UT(n,`gap-cursor`,e.gapCursor),UT(n,`drop-cursor`,e.dropCursor),UT(n,`math`,e.math),UT(n,`math-inline-edit`,e.mathInlineEdit),UT(n,`math-inline-arrow-navigation`,e.mathInlineArrowNavigation),UT(n,`task-list-toggle`,e.taskListToggle),UT(n,`tab-space-indent`,e.tabSpaceIndent),UT(n,`code-block-mod-a-select`,e.codeBlockModASelect),e.slash&&UT(n,`slash`,e.slash),n};function GT(e={}){return new $n({view(t){return new KT(t,e)}})}var KT=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=fn(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},qT=2,JT=`var(--zt-primary)`,YT=zg(()=>GT({color:JT,width:qT})),XT=class e extends Nn{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Nn.near(r)}content(){return k.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new ZT(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!$T(e)||!eE(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!M.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};XT.prototype.visible=!1,XT.findFrom=XT.findGapCursorFrom,Nn.jsonID(`gapcursor`,XT);var ZT=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return XT.valid(t)?new XT(t):Nn.near(t)}};function QT(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function $T(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||QT(e.type))return!0;if(e.inlineContent)return!1}}return!0}function eE(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||QT(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tE(){return new $n({props:{decorations:oE,createSelectionBetween(e,t,n){return t.pos==n.pos&&XT.valid(n)?new XT(n):null},handleClick:iE,handleKeyDown:nE,handleDOMEvents:{beforeinput:aE}}})}var nE=zu({ArrowLeft:rE(`horiz`,-1),ArrowRight:rE(`horiz`,1),ArrowUp:rE(`vert`,-1),ArrowDown:rE(`vert`,1)});function rE(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof j){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=XT.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new XT(c))),!0):!1}}function iE(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!XT.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&M.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new XT(r))),!0)}function aE(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof XT))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let e=r.length-1;e>=0;e--)i=D.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return a.setSelection(j.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function oE(e){if(!(e.selection instanceof XT))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,km.create(e.doc,[Em.widget(e.selection.head,t,{key:`gapcursor`})])}var sE=zg(()=>tE()),cE=-1,lE=1,uE=new Set([`math_block`,`code_block`,`table`,`image`,`hr`]),dE=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,fE=(e,t,n)=>{let r=e.state.doc.resolve(t);return XT.valid(r)?new XT(r):j.near(r,n)},pE=(e,t)=>t===cE?e.nodeBefore!==null:e.nodeAfter!==null,mE=(e,t)=>{let n=e.state.schema.nodes.paragraph;if(!n)return!1;let r=e.state.doc.resolve(t),i=r.index();if(!r.parent.canReplaceWith(i,i,n))return!1;let a=n.createAndFill();if(!a)return!1;let o=e.state.tr.insert(t,a),s=t+1;return o.setSelection(j.near(o.doc.resolve(s),1)).scrollIntoView(),e.dispatch(o),e.focus(),!0},hE=(e,t,n,r)=>{if(!uE.has(n.type.name))return!1;let i=r===cE?t:t+n.nodeSize;if(i<0||i>e.state.doc.content.size)return!1;if(!pE(e.state.doc.resolve(i),r)&&mE(e,i))return!0;let a=e.state.tr.setSelection(fE(e,i,r)).scrollIntoView();return e.dispatch(a),e.focus(),!0},gE=e=>{for(let t=e.depth;t>0;--t){let n=e.node(t);if(uE.has(n.type.name))return{node:n,position:e.before(t),depth:t}}return null},_E=(e,t,n)=>{for(let r=t;r<e.depth;r+=1){let t=e.node(r);if(e.index(r)!==(n===cE?0:t.childCount-1))return!1}return!0},vE=(e,t)=>{let{selection:n}=e.state;if(n instanceof M)return hE(e,n.from,n.node,t);if(!n.empty)return!1;let r=gE(n.$from);return!r||!_E(n.$from,r.depth,t)||!e.endOfTextblock(t===cE?`up`:`down`)?!1:hE(e,r.position,r.node,t)},yE=e=>{let{doc:t,selection:n}=e.state;return!(n instanceof j)||!n.empty||!(n.$from.after(1)===t.content.size&&_E(n.$from,1,lE))||!e.endOfTextblock(`down`)?!1:mE(e,t.content.size)},bE={ArrowUp:e=>vE(e,cE),ArrowDown:e=>vE(e,lE)||yE(e)},xE=(e,t)=>t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!dE(e),SE=(e,t,n,r)=>{let i=r===`ArrowUp`?cE:r===`ArrowDown`?lE:null;return i===null||!dE(e)?!1:hE(e,t,n,i)},CE=zg(()=>new $n({key:new nr(`zt-md-block-boundary-navigation`),props:{handleKeyDown:(e,t)=>{let n=bE[t.key];if(!n||xE(e,t))return!1;let r=n(e);return r&&t.preventDefault(),r}}})),wE=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),TE=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),EE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),DE=e=>{let t=EE(e);return t.charAt(0).toUpperCase()+t.slice(1)},OE={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},kE=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},AE=(0,d.createContext)({}),jE=()=>(0,d.useContext)(AE),ME=(0,d.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,color:p=`currentColor`,className:m=``}=jE()??{},h=r??f?Number(n??u)*24/Number(t??l):n??u;return(0,d.createElement)(`svg`,{ref:c,...OE,width:t??l??OE.width,height:t??l??OE.height,stroke:e??p,strokeWidth:h,className:wE(`lucide`,m,i),...!a&&!kE(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,d.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),NE=(e,t)=>{let n=(0,d.forwardRef)(({className:n,...r},i)=>(0,d.createElement)(ME,{ref:i,iconNode:t,className:wE(`lucide-${TE(DE(e))}`,`lucide-${e}`,n),...r}));return n.displayName=DE(e),n},PE=NE(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),FE=NE(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),IE=NE(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),LE=NE(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),RE=NE(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),zE=NE(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),BE=NE(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),VE=NE(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),HE=NE(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),UE=NE(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),WE=NE(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),GE=NE(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),KE=NE(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),qE=NE(`heading-4`,[[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 10v3a1 1 0 0 0 1 1h3`,key:`tj5zdr`}],[`path`,{d:`M21 10v8`,key:`1kdml4`}],[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}]]),JE=NE(`heading-6`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`circle`,{cx:`19`,cy:`16`,r:`2`,key:`15mx69`}],[`path`,{d:`M20 10c-2 2-3 3.5-3 6`,key:`f35dl0`}]]),YE=NE(`heading-5`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 13v-3h4`,key:`1nvgqp`}],[`path`,{d:`M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17`,key:`2nebdn`}]]),XE=NE(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),ZE=NE(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),QE=NE(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),$E=NE(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),eD=NE(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),tD=NE(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),nD=NE(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),rD=NE(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),iD=NE(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),aD=NE(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),oD=NE(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),sD=NE(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),cD=NE(`square-code`,[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),lD=NE(`square-function`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3`,key:`m1af9g`}],[`path`,{d:`M9 11.2h5.7`,key:`3zgcl2`}]]),uD=NE(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),dD=NE(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),fD=NE(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),pD=NE(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),mD=NE(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),hD=NE(`text-quote`,[[`path`,{d:`M17 5H3`,key:`1cn7zz`}],[`path`,{d:`M21 12H8`,key:`scolzb`}],[`path`,{d:`M21 19H8`,key:`13qgcb`}],[`path`,{d:`M3 12v7`,key:`1ri8j3`}]]),gD=NE(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),_D=NE(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),vD=NE(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),yD=e=>typeof e==`string`,bD=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},xD=e=>e==null?``:String(e),SD=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},CD=/###/g,wD=e=>e&&e.includes(`###`)?e.replace(CD,`.`):e,TD=e=>!e||yD(e),ED=(e,t,n)=>{let r=yD(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(TD(e))return{};let t=wD(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return TD(e)?{}:{obj:e,k:wD(r[i])}},DD=(e,t,n)=>{let{obj:r,k:i}=ED(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=ED(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=ED(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},OD=(e,t,n,r)=>{let{obj:i,k:a}=ED(e,t,Object);i[a]=i[a]||[],i[a].push(n)},kD=(e,t)=>{let{obj:n,k:r}=ED(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},AD=(e,t,n)=>{let r=kD(e,n);return r===void 0?kD(t,n):r},jD=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?yD(e[r])||e[r]instanceof String||yD(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):jD(e[r],t[r],n):e[r]=t[r]);return e},MD=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),ND={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},PD=e=>yD(e)?e.replace(/[&<>"'\/]/g,e=>ND[e]):e,FD=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},ID=[` `,`,`,`?`,`!`,`;`],LD=new FD(20),RD=(e,t,n)=>{t||=``,n||=``;let r=ID.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=LD.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},zD=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},BD=e=>e?.replace(/_/g,`-`),VD={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},HD=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||VD,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>yD(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),yD(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},UD=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},WD=class extends UD{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):yD(n)&&i?o.push(...n.split(i)):o.push(n)));let s=kD(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!yD(n)?s:zD(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),DD(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(yD(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=kD(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?jD(s,n,i):s={...s,...n},DD(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},GD={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},KD=Symbol(`i18next/PATH_KEY`);function qD(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===KD?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function JD(e,t){let{[KD]:n}=e(qD()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var YD=e=>!yD(e)&&typeof e!=`boolean`&&typeof e!=`number`,XD=class e extends UD{constructor(e,t={}){super(),SD([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=HD.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=YD(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!RD(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:yD(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:yD(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=JD(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?JD(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!yD(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let ee=YD(E),te=Object.prototype.toString.apply(E);if(y&&E&&ee&&!_.includes(te)&&!(yD(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;x&&!m?t[e]=this.translate(r,{...i,defaultValue:YD(T)?T[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&yD(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=yD(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!yD(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=yD(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=GD.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return yD(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?JD(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!yD(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(yD(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!yD(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},ZD=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=HD.create(`languageUtils`)}getScriptPartFromCode(e){if(e=BD(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=BD(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(yD(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),yD(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return yD(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):yD(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.includes(e)||i(this.formatLanguageCode(e))}),r}},QD={zero:0,one:1,two:2,few:3,many:4,other:5},$D={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},eO=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=HD.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=BD(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),$D;if(!e.match(/-|_/))return $D;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>QD[e]-QD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},tO=(e,t,n,r=`.`,i=!0)=>{let a=AD(e,t,n);return!a&&i&&yD(n)&&(a=zD(e,n,r),a===void 0&&(a=zD(t,n,r))),a},nO=e=>e.replace(/\$/g,`$$$$`),rO=class{constructor(e={}){this.logger=HD.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?PD:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?MD(i):a||`{{`,this.suffix=o?MD(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?MD(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?MD(l):``,this.nestingPrefix=d?MD(d):f||MD(`$t(`),this.nestingSuffix=p?MD(p):m||MD(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=tO(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(tO(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>nO(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?nO(this.escape(e)):nO(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=yD(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else !yD(a)&&!this.useRawValueToEscape&&(a=xD(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${MD(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!yD(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!yD(i))return i;yD(i)||(i=xD(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},iO=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},aO=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(BD(r),i),t[o]=s),s(n)}},oO=e=>(t,n,r)=>e(BD(n),r)(t),sO=class{constructor(e={}){this.logger=HD.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?aO:oO;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=aO(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf(`(`)>1&&!i[0].includes(`)`)&&i.find(e=>e.includes(`)`))){let e=i.findIndex(e=>e.includes(`)`));i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:a}=iO(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},cO=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},lO=class extends UD{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=HD.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{OD(n.loaded,[i],a),cO(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();yD(e)&&(e=this.languageUtils.toResolveHierarchy(e)),yD(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},uO=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),yD(e[1])&&(t.defaultValue=e[1]),yD(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),dO=e=>(yD(e.ns)&&(e.ns=[e.ns]),yD(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),yD(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),fO=()=>{},pO=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},mO=class e extends UD{constructor(e={},t){if(super(),this.options=dO(e),this.services={},this.logger=HD,this.modules={external:[]},pO(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(yD(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=uO();this.options={...n,...this.options,...dO(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?HD.init(r(this.modules.logger),this.options):HD.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:sO;let t=new ZD(this.options);this.store=new WD(this.options.resources,this.options);let n=this.services;n.logger=HD,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new eO(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new rO(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new lO(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new XD(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=fO,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=bD(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=fO){let n=t,r=yD(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=bD();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=fO,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&GD.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=bD();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=yD(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(yD(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=JD(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=JD(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=JD(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return yD(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=bD();return this.options.ns?(yD(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=bD();yD(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new ZD(uO());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=fO){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new WD(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...uO().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new rO(n)}return a.translator=new XD(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();mO.createInstance,mO.dir,mO.init,mO.loadResources,mO.reloadResources,mO.use,mO.changeLanguage,mO.getFixedT,mO.t,mO.exists,mO.setDefaultNamespace,mO.hasLoadedNamespace,mO.loadNamespaces,mO.loadLanguages;var hO={placeholder:`Type / to open the command menu...`,initError:`Editor initialization failed. Please refresh the page and try again.`,editorAriaLabel:`Markdown editor`,mathBlockSourceAriaLabel:`Math block source`,mathBlockCopyAriaLabel:`Copy math source`,mathBlockDeleteAriaLabel:`Delete math block`,imageDeleteAriaLabel:`Delete image`,tableDeleteAriaLabel:`Delete table`,tableMoreAriaLabel:`More table actions`,tableAlignLeftAriaLabel:`Align current column left`,tableAlignCenterAriaLabel:`Align current column center`,tableAlignRightAriaLabel:`Align current column right`,tableInsertRowAboveLabel:`Insert row above`,tableInsertRowBelowLabel:`Insert row below`,tableInsertColumnLeftLabel:`Insert column left`,tableInsertColumnRightLabel:`Insert column right`,tableDeleteRowLabel:`Delete row`,tableDeleteColumnLabel:`Delete column`,mathRenderError:`Formula rendering failed. Please check the formula syntax.`,imageUploadDialogTitle:`Insert image`,imageUploadDropLabel:`Drop an image here, or choose a file`,imageUploadPickFileLabel:`Choose file`,imageUploadFileTab:`Upload file`,imageUploadUrlTab:`Image URL`,imageUploadUrlPlaceholder:`Paste image URL`,imageUploadInsertUrlLabel:`Insert URL`,imageUploadConfirmLabel:`Insert image`,imageUploadAltLabel:`Alternative text (optional)`,imageUploadAltPlaceholder:`Describe the image`,imageUploadUploadingLabel:`Uploading...`,imageUploadInsertingLabel:`Inserting...`,imageUploadCancelLabel:`Cancel`,imageUploadLoadFailed:`Image failed to load`,imageUploadReselectHint:`Click or drag to reselect`,imageUploadSupportsAndMax:`Supports PNG, JPG, GIF, WebP, SVG, and more, max {size}`,imageUploadFileTooLarge:`The image file is too large.`,imageUploadFileSizeExceeded:`Image size must not exceed {size}`,imageUploadInvalidType:`Please choose an image file.`,imageUploadFailed:`Image upload failed. Please try again.`,imageUploadFileReadFailed:`File read failed. Please try again.`,imageUploadInvalidUrl:`Please enter a valid image URL.`,imageUploadUrlRequired:`Please enter an image URL.`,imageUploadSelectOrEnterImage:`Please select an image or enter an image URL.`,imageUploadUploadingWait:`Image is uploading, please wait.`,selectionTooltipStrongTitle:`Bold`,selectionTooltipEmTitle:`Italic`,selectionTooltipStrikeTitle:`Strikethrough`,selectionTooltipInlineCodeTitle:`Inline code`,selectionTooltipLinkTitle:`Link`,selectionTooltipTransformLabel:`Turn into`,selectionTooltipTransformParagraphLabel:`Paragraph`,selectionTooltipTransformHeading1Label:`Heading 1`,selectionTooltipTransformHeading2Label:`Heading 2`,selectionTooltipTransformHeading3Label:`Heading 3`,selectionTooltipTransformHeading4Label:`Heading 4`,selectionTooltipTransformHeading5Label:`Heading 5`,selectionTooltipTransformHeading6Label:`Heading 6`,selectionTooltipTransformBulletListLabel:`Bullet list`,selectionTooltipTransformOrderedListLabel:`Ordered list`,selectionTooltipTransformTaskListLabel:`Task list`,selectionTooltipTransformBlockquoteLabel:`Blockquote`,selectionTooltipTransformCodeBlockLabel:`Code block`,selectionLinkInputPlaceholder:`Type or paste a link`,selectionLinkSaveAriaLabel:`Save link`,selectionLinkRemoveAriaLabel:`Remove link`,codeBlockLanguageSearchPlaceholder:`Search languages`,codeBlockLanguagePlainText:`text`,codeBlockCopyAriaLabel:`Copy code block`,codeBlockPreviewAriaLabel:`Preview code block`,codeBlockSourceAriaLabel:`View code block source`,codeBlockDeleteAriaLabel:`Delete code block`},gO={placeholder:`请输入 / 打开命令菜单...`,initError:`编辑器初始化失败,请刷新页面后重试。`,editorAriaLabel:`Markdown 编辑器`,mathBlockSourceAriaLabel:`公式块源码`,mathBlockCopyAriaLabel:`复制公式源码`,mathBlockDeleteAriaLabel:`删除公式块`,imageDeleteAriaLabel:`删除图片`,tableDeleteAriaLabel:`删除表格`,tableMoreAriaLabel:`更多表格操作`,tableAlignLeftAriaLabel:`当前列左对齐`,tableAlignCenterAriaLabel:`当前列居中对齐`,tableAlignRightAriaLabel:`当前列右对齐`,tableInsertRowAboveLabel:`上方插入行`,tableInsertRowBelowLabel:`下方插入行`,tableInsertColumnLeftLabel:`左侧插入列`,tableInsertColumnRightLabel:`右侧插入列`,tableDeleteRowLabel:`删除该行`,tableDeleteColumnLabel:`删除该列`,mathRenderError:`公式渲染失败,请检查公式语法。`,imageUploadDialogTitle:`插入图片`,imageUploadDropLabel:`拖拽图片到这里,或选择文件`,imageUploadPickFileLabel:`选择文件`,imageUploadFileTab:`上传文件`,imageUploadUrlTab:`图片链接`,imageUploadUrlPlaceholder:`粘贴图片链接`,imageUploadInsertUrlLabel:`插入链接`,imageUploadConfirmLabel:`插入图片`,imageUploadAltLabel:`替代文本(可选)`,imageUploadAltPlaceholder:`描述图片内容`,imageUploadUploadingLabel:`上传中...`,imageUploadInsertingLabel:`正在插入...`,imageUploadCancelLabel:`取消`,imageUploadLoadFailed:`图片加载失败`,imageUploadReselectHint:`点击或拖拽重新选择`,imageUploadSupportsAndMax:`支持 PNG、JPG、GIF、WebP、SVG 等,最大 {size}`,imageUploadFileTooLarge:`图片文件过大。`,imageUploadFileSizeExceeded:`图片大小不能超过 {size}`,imageUploadInvalidType:`请选择图片文件。`,imageUploadFailed:`图片上传失败,请重试。`,imageUploadFileReadFailed:`文件读取失败,请重试。`,imageUploadInvalidUrl:`请输入有效的图片链接。`,imageUploadUrlRequired:`请输入图片链接。`,imageUploadSelectOrEnterImage:`请选择图片或输入图片链接。`,imageUploadUploadingWait:`图片正在上传,请稍候。`,selectionTooltipStrongTitle:`加粗`,selectionTooltipEmTitle:`斜体`,selectionTooltipStrikeTitle:`删除线`,selectionTooltipInlineCodeTitle:`行内代码`,selectionTooltipLinkTitle:`链接`,selectionTooltipTransformLabel:`转换为`,selectionTooltipTransformParagraphLabel:`段落`,selectionTooltipTransformHeading1Label:`标题 1`,selectionTooltipTransformHeading2Label:`标题 2`,selectionTooltipTransformHeading3Label:`标题 3`,selectionTooltipTransformHeading4Label:`标题 4`,selectionTooltipTransformHeading5Label:`标题 5`,selectionTooltipTransformHeading6Label:`标题 6`,selectionTooltipTransformBulletListLabel:`无序列表`,selectionTooltipTransformOrderedListLabel:`有序列表`,selectionTooltipTransformTaskListLabel:`任务列表`,selectionTooltipTransformBlockquoteLabel:`引用块`,selectionTooltipTransformCodeBlockLabel:`代码块`,selectionLinkInputPlaceholder:`输入或粘贴链接`,selectionLinkSaveAriaLabel:`保存链接`,selectionLinkRemoveAriaLabel:`移除链接`,codeBlockLanguageSearchPlaceholder:`搜索语言`,codeBlockLanguagePlainText:`text`,codeBlockCopyAriaLabel:`复制代码块`,codeBlockPreviewAriaLabel:`预览代码块`,codeBlockSourceAriaLabel:`查看代码块源码`,codeBlockDeleteAriaLabel:`删除代码块`},_O=`zh-CN`,vO={"zh-CN":{translation:gO},"en-US":{translation:hO}},yO=mO.createInstance(),bO=!1,xO=()=>{bO||=(yO.init({resources:vO,fallbackLng:_O,lng:_O,interpolation:{escapeValue:!1}}),!0)},SO=(e=_O,t,n)=>{xO();let r={...yO.getResourceBundle(e,`translation`),...t};return n!==void 0&&(r.placeholder=n),r},CO=new Set([`http:`,`https:`,`mailto:`,`tel:`]),wO=new Set([`data:`]),TO=/[\u0000-\u0020\u007f]+/g,EO=/^([a-z][a-z\d+\-.]*:)/i,DO=/[<>"'`]/,OO=new Set([`src`,`alt`,`title`,`style`]),kO=(e,t)=>{if(typeof e!=`string`)return``;let n=e.trim();if(!n||DO.test(n)||/[\u0000-\u001f\u007f]/.test(n))return``;let r=n.replace(TO,``);if(r.startsWith(`//`))return``;let i=r.match(EO)?.[1]?.toLowerCase()??``;if(!i)return n;if(!t.has(i))return``;try{return new URL(n).toString()}catch{return``}},AO=e=>kO(e,CO),jO=(e,t=[])=>kO(e,new Set([...CO,...wO,...t.map(e=>e.trim().toLowerCase())])),MO=(e,t,n=[])=>{if(typeof e!=`string`)return null;let r=e.trim();if(!r)return null;let i=new DOMParser().parseFromString(r,`text/html`),a=null;for(let e of Array.from(i.body.childNodes))if(!(e.nodeType===Node.TEXT_NODE&&!(e.textContent??``).trim())){if(e instanceof HTMLImageElement&&a===null){a=e;continue}return null}if(!a||a.tagName.toLowerCase()!==`img`)return null;for(let e of Array.from(a.attributes))if(!OO.has(e.name.toLowerCase()))return null;let o=jO(a.getAttribute(`src`)??``,n);return o?{src:o,alt:a.getAttribute(`alt`)??``,title:a.getAttribute(`title`)??``,style:t(a.getAttribute(`style`)??``)}:null},NO=/^\s*width\s*:\s*(\d{1,3})%\s*;?\s*$/i,PO=(e,t)=>{let n=Array.isArray(e.children)?e.children:[],r=n[0];return n.length===1&&(r?.type===`image`||r?.type===`html`&&MO(r.value,RO,t)!==null)?r:null},FO=e=>Math.min(100,Math.max(10,e)),IO=e=>`width: ${FO(Math.round(e))}%;`,LO=e=>{if(typeof e!=`string`)return null;let t=e.match(NO);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?FO(n):null},RO=e=>{let t=LO(e);return t===null?``:IO(t)},zO=e=>typeof e==`string`?e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`):``,BO=(e,t)=>{let n=jO(e.src,t);if(!n)return``;let r=typeof e.alt==`string`?e.alt:``,i=typeof e.title==`string`?e.title:``,a=i?` title="${zO(i)}"`:``,o=RO(e.style);return`<img src="${zO(n)}" alt="${zO(r)}"${a} style="${zO(o)}">`},VO=(e,t)=>n=>{let r=e(n);return{...r,inline:!1,group:`block`,attrs:{...r.attrs,style:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{let n=e,r=jO(n.getAttribute(`src`)??``,t);return r?{src:r,alt:n.getAttribute(`alt`)??``,title:n.getAttribute(`title`)??n.getAttribute(`alt`)??``,style:RO(n.getAttribute(`style`)??``)}:!1}}],parseMarkdown:{match:e=>e.type===`image`||e.type===`html`&&MO(e.value,RO,t)!==null,runner:(e,n,r)=>{if(n.type===`html`){let i=MO(n.value,RO,t);i&&e.addNode(r,i);return}let i=jO(String(n.url??``),t);i&&e.addNode(r,{src:i,alt:String(n.alt??``),title:String(n.title??``),style:``})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,n)=>{let r=jO(n.attrs.src,t);if(!r)return;let i=RO(n.attrs.style);if(i){let a=BO({...n.attrs,src:r,style:i},t);a&&e.addNode(`html`,void 0,a);return}let a={type:`image`,title:n.attrs.title,url:r,alt:n.attrs.alt};e.addNode(`paragraph`,[a])}}}},HO=(e,t)=>n=>{let r=e(n);return{...r,parseMarkdown:{...r.parseMarkdown,runner:(e,n,i)=>{let a=PO(n,t);if(a){e.next(a);return}r.parseMarkdown.runner(e,n,i)}}}},UO=(e,t=[])=>{let n=e.get(Ey.key),r=e.get(ny.key);e.set(Ey.key,VO(n,t)),e.set(ny.key,HO(r,t))},WO=`image`,GO=`left`,KO=`right`,qO=160,JO=e=>(0,f.renderToStaticMarkup)((0,d.createElement)(e,{size:14,strokeWidth:2,"aria-hidden":`true`})),YO=JO(gD),XO=JO(XE),ZO=e=>typeof e==`function`?e():null,QO=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,$O=class{constructor(e,t,n,r){this.resizeState=null,this.isSelected=!1,this.currentImageSrc=``,this.imageLoadingStartedAt=0,this.imageLoadingFinishTimer=null,this.handleDeleteClick=e=>{e.preventDefault(),e.stopPropagation(),QO(this.view)&&this.deleteCurrentImage()},this.handleImageLoad=()=>{delete this.dom.dataset.loadError,this.finishImageLoadingWithMinimumDuration()},this.handleImageError=()=>{this.dom.dataset.loadError=`true`,this.finishImageLoadingWithMinimumDuration()},this.handleResizePointerDown=e=>{if(e.preventDefault(),e.stopPropagation(),!QO(this.view))return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=t.dataset.side===GO?GO:KO,r=this.dom.parentElement;if(!r)return;let i=this.imageElement.getBoundingClientRect(),a=r.getBoundingClientRect();if(i.width<=0||a.width<=0)return;let o=FO(i.width/a.width*100);this.resizeState={side:n,startClientX:e.clientX,startWidth:i.width,containerWidth:a.width,widthPercent:o},this.dom.dataset.resizing=`true`,this.applyPreviewWidth(o),window.addEventListener(`pointermove`,this.handleResizePointerMove),window.addEventListener(`pointerup`,this.handleResizePointerUp),window.addEventListener(`pointercancel`,this.handleResizePointerUp)},this.handleResizePointerMove=e=>{if(!this.resizeState)return;e.preventDefault();let t=e.clientX-this.resizeState.startClientX,n=this.resizeState.side===GO?-t:t,r=FO((this.resizeState.startWidth+n)/this.resizeState.containerWidth*100);this.resizeState.widthPercent=r,this.applyPreviewWidth(r)},this.handleResizePointerUp=e=>{if(e.preventDefault(),!this.resizeState)return;let t=Math.round(this.resizeState.widthPercent);this.resizeState=null,delete this.dom.dataset.resizing,this.removeResizeWindowListeners(),this.commitImageWidth(t)},this.node=e,this.view=t,this.getPos=n,this.deleteAriaLabel=r.imageDeleteAriaLabel,this.dom=document.createElement(`span`),this.dom.dataset.type=WO,this.dom.className=`zt-md-image`,this.updateEditableState(),this.syncSelectedState(),this.imageElement=document.createElement(`img`),this.imageElement.addEventListener(`load`,this.handleImageLoad),this.imageElement.addEventListener(`error`,this.handleImageError),this.imageLoadErrorElement=document.createElement(`span`),this.imageLoadErrorElement.className=`zt-md-image-load-error`,this.imageLoadErrorElement.contentEditable=`false`,this.imageLoadErrorElement.innerHTML=XO,this.imageLoadErrorElement.append(r.imageUploadLoadFailed),this.leftResizeHandle=this.createResizeHandle(GO),this.rightResizeHandle=this.createResizeHandle(KO),this.actionsContainer=document.createElement(`span`),this.actionsContainer.className=`zt-md-image-actions`,this.deleteButton=document.createElement(`button`),this.deleteButton.type=`button`,this.deleteButton.className=`zt-md-image-action-button zt-md-image-action-button-danger`,this.deleteButton.setAttribute(`aria-label`,this.deleteAriaLabel),this.deleteButton.innerHTML=YO,this.actionsContainer.appendChild(this.deleteButton),this.dom.append(this.imageElement,this.imageLoadErrorElement,this.leftResizeHandle,this.rightResizeHandle,this.actionsContainer),this.syncFromNode(e),this.deleteButton.addEventListener(`click`,this.handleDeleteClick),this.leftResizeHandle.addEventListener(`pointerdown`,this.handleResizePointerDown),this.rightResizeHandle.addEventListener(`pointerdown`,this.handleResizePointerDown)}createResizeHandle(e){let t=document.createElement(`span`);return t.className=`zt-md-image-resize-handle zt-md-image-resize-handle-${e}`,t.dataset.side=e,t.setAttribute(`aria-hidden`,`true`),t}deleteCurrentImage(){let e=ZO(this.getPos);if(e===null)return;let t=this.view.state.tr.delete(e,e+this.node.nodeSize).scrollIntoView();this.view.dispatch(t),requestAnimationFrame(()=>{this.view.focus()})}updateEditableState(){this.dom.dataset.editable=QO(this.view)?`true`:`false`}syncSelectedState(){this.dom.dataset.selected=this.isSelected?`true`:`false`}markImageLoading(){this.clearImageLoadingFinishTimer(),this.imageLoadingStartedAt=performance.now(),delete this.dom.dataset.loadError,this.dom.dataset.loading=`true`}finishImageLoading(){this.clearImageLoadingFinishTimer(),delete this.dom.dataset.loading}finishImageLoadingWithMinimumDuration(){let e=performance.now()-this.imageLoadingStartedAt,t=Math.max(0,qO-e);if(t<=0){this.finishImageLoading();return}this.clearImageLoadingFinishTimer(),this.imageLoadingFinishTimer=window.setTimeout(()=>{this.finishImageLoading()},t)}clearImageLoadingFinishTimer(){this.imageLoadingFinishTimer!==null&&(window.clearTimeout(this.imageLoadingFinishTimer),this.imageLoadingFinishTimer=null)}removeResizeWindowListeners(){window.removeEventListener(`pointermove`,this.handleResizePointerMove),window.removeEventListener(`pointerup`,this.handleResizePointerUp),window.removeEventListener(`pointercancel`,this.handleResizePointerUp)}applyPreviewWidth(e){this.dom.style.width=`${Math.round(e)}%`,this.dom.dataset.hasWidth=`true`}commitImageWidth(e){let t=ZO(this.getPos);if(t===null)return;let n={...this.node.attrs,style:IO(e)},r=this.view.state.tr.setNodeMarkup(t,void 0,n);this.view.dispatch(r),requestAnimationFrame(()=>{this.view.focus()})}syncFromNode(e){this.updateEditableState();let t=typeof e.attrs.src==`string`?e.attrs.src:``,n=typeof e.attrs.alt==`string`?e.attrs.alt:``,r=typeof e.attrs.title==`string`?e.attrs.title:``,i=LO(RO(e.attrs.style));t!==this.currentImageSrc&&(delete this.dom.dataset.loadError,t&&this.markImageLoading()),this.imageElement.setAttribute(`src`,t),this.currentImageSrc=t,this.imageElement.setAttribute(`alt`,n),r?this.imageElement.title=r:this.imageElement.removeAttribute(`title`),i===null?(this.dom.style.removeProperty(`width`),delete this.dom.dataset.hasWidth):(this.dom.style.width=`${i}%`,this.dom.dataset.hasWidth=`true`),t?this.imageElement.complete&&this.imageElement.naturalWidth>0&&this.finishImageLoadingWithMinimumDuration():this.finishImageLoading()}update(e){return e.type.name===WO?(this.node=e,this.syncFromNode(e),!0):!1}selectNode(){this.isSelected=!0,this.syncSelectedState()}deselectNode(){this.isSelected=!1,this.syncSelectedState()}stopEvent(e){let t=e.target;return t instanceof Node?this.deleteButton.contains(t)||this.leftResizeHandle.contains(t)||this.rightResizeHandle.contains(t)||this.resizeState!==null:!1}ignoreMutation(){return!0}destroy(){this.removeResizeWindowListeners(),this.clearImageLoadingFinishTimer(),this.imageElement.removeEventListener(`load`,this.handleImageLoad),this.imageElement.removeEventListener(`error`,this.handleImageError),this.deleteButton.removeEventListener(`click`,this.handleDeleteClick),this.leftResizeHandle.removeEventListener(`pointerdown`,this.handleResizePointerDown),this.rightResizeHandle.removeEventListener(`pointerdown`,this.handleResizePointerDown)}},ek=(e=SO())=>(t,n,r)=>new $O(t,n,typeof r==`function`?()=>{let e=r();return typeof e==`number`?e:0}:!1,e),tk=`image`,nk={Backspace:`before`,Delete:`after`},rk=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,ik=e=>e instanceof Element?!!e.closest(`.zt-md-image-actions, .zt-md-image-resize-handle`):!1,ak=e=>e?.type.name===tk,ok=(e,t)=>!nk[t.key]||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!rk(e)||ik(t.target)||ik(document.activeElement),sk=e=>{if(e.parent.type.name!==`paragraph`||e.parentOffset!==0||e.parent.textContent.length>0||e.depth<1)return null;let t=e.index(e.depth-1);if(t<=0)return null;let n=e.node(e.depth-1).child(t-1);return ak(n)?{previousBlockStart:e.before(e.depth)-n.nodeSize}:null},ck=(e,t)=>{try{return j.create(e,t)}catch{return j.near(e.resolve(t),-1)}},lk=(e,t,n)=>{n.preventDefault();let r=t.from,i=e.state.tr.delete(t.from,t.to),a=i.doc.content.size,o=Math.min(r,a);return i.setSelection(ck(i.doc,o)).scrollIntoView(),e.dispatch(i),e.focus(),!0},uk=(e,t)=>{if(t.key!==`Backspace`)return!1;let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from,i=sk(r);if(!i)return!1;let a=r.before(r.depth),o=a+r.parent.nodeSize;t.preventDefault();let s=e.state.tr;return s.delete(a,o),s.setSelection(M.create(s.doc,i.previousBlockStart)).scrollIntoView(),e.dispatch(s),e.focus(),!0},dk=(e,t)=>{if(uk(e,t))return!0;let n=nk[t.key];if(!n)return!1;let{selection:r}=e.state;if(!r.empty)return!1;let i=r.$from,a=n===`before`?i.nodeBefore:i.nodeAfter;if(!ak(a))return!1;t.preventDefault();let o=n===`before`?r.from-a.nodeSize:r.from;return e.dispatch(e.state.tr.setSelection(M.create(e.state.doc,o)).scrollIntoView()),e.focus(),!0},fk=(e,t)=>{if(ok(e,t))return!1;let{selection:n}=e.state;return n instanceof M&&ak(n.node)?lk(e,n,t):dk(e,t)},pk=zg(()=>new $n({key:new nr(`zt-md-image-delete-selection`),props:{handleKeyDown:(e,t)=>fk(e,t)}})),mk=e=>e.state.schema.nodes.paragraph?.createAndFill()??null,hk=(e,t)=>e.state.schema.nodes.image?.create(t)??null,gk=e=>{let t=e.$to.parent;if(e.$to.parentOffset<t.content.size)return!0;if(e.$to.depth<1)return!1;let n=e.$to.node(e.$to.depth-1);return e.$to.index(e.$to.depth-1)<n.childCount-1},_k=(e,t)=>{let n=[t,t-1,t+1];for(let t of n)if(!(t<0||t>e.content.size)&&e.nodeAt(t)?.type.name===`image`)return t;return null},vk=(e,t)=>{let n=e.selection.from-t,r=_k(e.doc,n);return r===null?null:M.create(e.doc,r)},yk=(e,t,n=e.state.selection)=>{let r=hk(e,t);if(!r)return!1;let i=gk(n),a=e.state.tr.setSelection(n).replaceSelectionWith(r),o=a.selection.to;if(!i){let t=mk(e);t&&a.insert(o,t)}let s=vk(a,r.nodeSize);return s?(a.setSelection(s).scrollIntoView(),e.dispatch(a),!0):!1},bk=`zt-md-image-upload-file-input`,xk=`zt-md-image-upload-alt-input`,Sk=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;if(typeof e==`string`){t(e);return}n(Error(`Invalid file result`))},r.onerror=()=>{n(r.error??Error(`File read failed`))},r.readAsDataURL(e)}),Ck=e=>e<1024*1024?`${Math.ceil(e/1024)}KB`:`${(e/1024/1024).toFixed(1)}MB`,wk=e=>{try{let t=new URL(e);return!!(t.protocol&&t.host)}catch{return!1}},Tk=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t()},r.onerror=()=>{n(Error(`Image load failed`))},r.src=e}),Ek=e=>e.replace(/\.[^/.]+$/,``),Dk=new nr(`zt-md-image-paste`),Ok=0,kk=e=>(typeof e.props.editable==`function`?e.props.editable(e.state):e.editable)&&!e.state.selection.$from.parent.type.spec.code,Ak=e=>Array.from(e.items).find(e=>e.kind===`file`&&e.type.startsWith(`image/`))?.getAsFile()||(Array.from(e.files).find(e=>e.type.startsWith(`image/`))??null),jk=()=>(Ok+=1,`image-paste-${Ok}`),Mk=(e,t)=>{let n=new Map;t.forEach((t,r)=>{n.set(r,t.map(e.mapping))});let r=e.getMeta(Dk);return r?.type===`add`&&n.set(r.requestId,r.bookmark),r?.type===`remove`&&n.delete(r.requestId),n},Nk=(e,t)=>{e.isDestroyed||!Dk.getState(e.state)?.has(t)||e.dispatch(e.state.tr.setMeta(Dk,{type:`remove`,requestId:t}))},Pk=async(e,t,n)=>{let r=t?.upload?await t.upload(e):await Sk(e);if(!r)throw Error(n.imageUploadFailed);return r},Fk=async(e,t,n,r,i)=>{try{let a=await Pk(t,r,i);if(e.isDestroyed)return;let o=Dk.getState(e.state)?.get(n);if(!o)return;let s=o.resolve(e.state.doc);Nk(e,n),yk(e,{src:a,alt:Ek(t.name),title:``},s)}catch(e){console.error(e)}finally{Nk(e,n)}},Ik=(e,t)=>zg(()=>new $n({key:Dk,state:{init:()=>new Map,apply:Mk},props:{handlePaste:(n,r)=>{if(!kk(n))return!1;let i=r.clipboardData?Ak(r.clipboardData):null;if(!i)return!1;r.preventDefault();let a=e?.maxFileSize??5242880;if(i.size>a)return console.error(Error(t.imageUploadFileSizeExceeded.replace(`{size}`,Ck(a)))),!0;let o=jk(),s=n.state.selection.getBookmark();return n.dispatch(n.state.tr.setMeta(Dk,{type:`add`,requestId:o,bookmark:s})),Fk(n,i,o,e,t),!0}}})),Lk=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Rk=S,zk=(e,t)=>n=>{if(t?.variants==null)return Rk(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Lk(t)||Lk(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Rk(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)};function Bk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Vk(...e){return t=>{let n=!1,r=e.map(e=>{let r=Bk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Bk(e[t],null)}}}}function Hk(...e){return d.useCallback(Vk(...e),e)}function Uk(e){let t=Gk(e),n=d.forwardRef((e,n)=>{let{children:r,...i}=e,a=d.Children.toArray(r),o=a.find(qk);if(o){let e=o.props.children,r=a.map(t=>t===o?d.Children.count(e)>1?d.Children.only(null):d.isValidElement(e)?e.props.children:null:t);return(0,h.jsx)(t,{...i,ref:n,children:d.isValidElement(e)?d.cloneElement(e,void 0,r):null})}return(0,h.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var Wk=Uk(`Slot`);function Gk(e){let t=d.forwardRef((e,t)=>{let{children:n,...r}=e;if(d.isValidElement(n)){let e=Yk(n),i=Jk(r,n.props);return n.type!==d.Fragment&&(i.ref=t?Vk(t,e):e),d.cloneElement(n,i)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Kk=Symbol(`radix.slottable`);function qk(e){return d.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Kk}function Jk(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Yk(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xk=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Uk(`Primitive.${t}`),r=d.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,h.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Zk(e,t){e&&m.flushSync(()=>e.dispatchEvent(t))}function Qk(e,t){let n=d.createContext(t),r=e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,h.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function $k(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,h.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=d.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,eA(i,...t)]}function eA(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function tA(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var nA=globalThis?.document?d.useLayoutEffect:()=>{},rA=d.useInsertionEffect||nA;function iA({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=aA({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=d.useRef(e!==void 0);d.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,d.useCallback(t=>{if(s){let n=oA(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function aA({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return rA(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function oA(e){return typeof e==`function`}function sA(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}var cA=e=>{let{present:t,children:n}=e,r=lA(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=Hk(r.ref,dA(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null};cA.displayName=`Presence`;function lA(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),[o,s]=sA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{let e=uA(r.current);a.current=o===`mounted`?e:`none`},[o]),nA(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=uA(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),nA(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=uA(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=uA(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:d.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function uA(e){return e?.animationName||`none`}function dA(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fA=d.useId||(()=>void 0),pA=0;function mA(e){let[t,n]=d.useState(fA());return nA(()=>{e||n(e=>e??String(pA++))},[e]),e||(t?`radix-${t}`:``)}function hA(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...e)=>t.current?.(...e),[])}function gA(e,t=globalThis?.document){let n=hA(e);d.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var _A=`DismissableLayer`,vA=`dismissableLayer.update`,yA=`dismissableLayer.pointerDownOutside`,bA=`dismissableLayer.focusOutside`,xA,SA=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),CA=d.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=d.useContext(SA),[u,f]=d.useState(null),p=u?.ownerDocument??globalThis?.document,[,m]=d.useState({}),g=Hk(t,e=>f(e)),_=Array.from(l.layers),[v]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=_.indexOf(v),b=u?_.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=EA(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!S||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},p),w=DA(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},p);return gA(e=>{b===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},p),d.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(xA=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),OA(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=xA)}},[u,p,n,l]),d.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),OA())},[u,l]),d.useEffect(()=>{let e=()=>m({});return document.addEventListener(vA,e),()=>document.removeEventListener(vA,e)},[]),(0,h.jsx)(Xk.div,{...c,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:tA(e.onFocusCapture,w.onFocusCapture),onBlurCapture:tA(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:tA(e.onPointerDownCapture,C.onPointerDownCapture)})});CA.displayName=_A;var wA=`DismissableLayerBranch`,TA=d.forwardRef((e,t)=>{let n=d.useContext(SA),r=d.useRef(null),i=Hk(t,r);return d.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,h.jsx)(Xk.div,{...e,ref:i})});TA.displayName=wA;function EA(e,t=globalThis?.document){let n=hA(e),r=d.useRef(!1),i=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){kA(yA,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function DA(e,t=globalThis?.document){let n=hA(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&kA(bA,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function OA(){let e=new CustomEvent(vA);document.dispatchEvent(e)}function kA(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Zk(i,a):i.dispatchEvent(a)}var AA=`focusScope.autoFocusOnMount`,jA=`focusScope.autoFocusOnUnmount`,MA={bubbles:!1,cancelable:!0},NA=`FocusScope`,PA=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=d.useState(null),l=hA(i),u=hA(a),f=d.useRef(null),p=Hk(t,e=>c(e)),m=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let e=function(e){if(m.paused||!s)return;let t=e.target;s.contains(t)?f.current=t:VA(f.current,{select:!0})},t=function(e){if(m.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||VA(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&VA(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,m.paused]),d.useEffect(()=>{if(s){HA.add(m);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(AA,MA);s.addEventListener(AA,l),s.dispatchEvent(t),t.defaultPrevented||(FA(GA(LA(s)),{select:!0}),document.activeElement===e&&VA(s))}return()=>{s.removeEventListener(AA,l),setTimeout(()=>{let t=new CustomEvent(jA,MA);s.addEventListener(jA,u),s.dispatchEvent(t),t.defaultPrevented||VA(e??document.body,{select:!0}),s.removeEventListener(jA,u),HA.remove(m)},0)}}},[s,l,u,m]);let g=d.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=IA(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&VA(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&VA(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,h.jsx)(Xk.div,{tabIndex:-1,...o,ref:p,onKeyDown:g})});PA.displayName=NA;function FA(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(VA(r,{select:t}),document.activeElement!==n)return}function IA(e){let t=LA(e);return[RA(t,e),RA(t.reverse(),e)]}function LA(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function RA(e,t){for(let n of e)if(!zA(n,{upTo:t}))return n}function zA(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function BA(e){return e instanceof HTMLInputElement&&`select`in e}function VA(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&BA(e)&&t&&e.select()}}var HA=UA();function UA(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=WA(e,t),e.unshift(t)},remove(t){e=WA(e,t),e[0]?.resume()}}}function WA(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function GA(e){return e.filter(e=>e.tagName!==`A`)}var KA=`Portal`,qA=d.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=d.useState(!1);nA(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?m.default.createPortal((0,h.jsx)(Xk.div,{...r,ref:t}),o):null});qA.displayName=KA;var JA=0;function YA(){d.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??XA()),document.body.insertAdjacentElement(`beforeend`,e[1]??XA()),JA++,()=>{JA===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),JA--}},[])}function XA(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var ZA=function(){return ZA=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ZA.apply(this,arguments)};function QA(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function $A(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ej=`right-scroll-bar-position`,tj=`width-before-scroll-bar`,nj=`with-scroll-bars-hidden`,rj=`--removed-body-scroll-bar-size`;function ij(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function aj(e,t){var n=(0,u.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var oj=typeof window<`u`?u.useLayoutEffect:u.useEffect,sj=new WeakMap;function cj(e,t){var n=aj(t||null,function(t){return e.forEach(function(e){return ij(e,t)})});return oj(function(){var t=sj.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ij(e,null)}),i.forEach(function(e){r.has(e)||ij(e,a)})}sj.set(n,e)},[e]),n}function lj(e){return e}function uj(e,t){t===void 0&&(t=lj);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function dj(e){e===void 0&&(e={});var t=uj(null);return t.options=ZA({async:!0,ssr:!1},e),t}var fj=function(e){var t=e.sideCar,n=QA(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return u.createElement(r,ZA({},n))};fj.isSideCarExport=!0;function pj(e,t){return e.useMedium(t),fj}var mj=dj(),hj=function(){},gj=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:hj,onWheelCapture:hj,onTouchMoveCapture:hj}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=QA(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=cj([n,t]),w=ZA(ZA({},x),i);return u.createElement(u.Fragment,null,d&&u.createElement(S,{sideCar:mj,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?u.cloneElement(u.Children.only(s),ZA(ZA({},w),{ref:C})):u.createElement(y,ZA({},w,{className:c,ref:C}),s))});gj.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gj.classNames={fullWidth:tj,zeroRight:ej};var _j,vj=function(){if(_j)return _j;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function yj(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=vj();return t&&e.setAttribute(`nonce`,t),e}function bj(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xj(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Sj=function(){var e=0,t=null;return{add:function(n){e==0&&(t=yj())&&(bj(t,n),xj(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cj=function(){var e=Sj();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wj=function(){var e=Cj();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Tj={left:0,top:0,right:0,gap:0},Ej=function(e){return parseInt(e||``,10)||0},Dj=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ej(n),Ej(r),Ej(i)]},Oj=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Tj;var t=Dj(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},kj=wj(),Aj=`data-scroll-locked`,jj=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
53
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return TC(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Ys.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function LC(){return{exit:{taskListCheckValueChecked:zC,taskListCheckValueUnchecked:zC,paragraph:BC}}}function RC(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:VC}}}function zC(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function BC(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function VC(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Ys.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function HC(){return[US(),pC(),vC(),OC(),LC()]}function UC(e){return{extensions:[WS(),mC(e),yC(),IC(e),RC()]}}var WC={tokenize:iw,partial:!0},GC={tokenize:aw,partial:!0},KC={tokenize:ow,partial:!0},qC={tokenize:sw,partial:!0},JC={tokenize:cw,partial:!0},YC={name:`wwwAutolink`,tokenize:nw,previous:lw},XC={name:`protocolAutolink`,tokenize:rw,previous:uw},ZC={name:`emailAutolink`,tokenize:tw,previous:dw},QC={};function $C(){return{text:QC}}for(var ew=48;ew<123;)QC[ew]=ZC,ew++,ew===58?ew=65:ew===91&&(ew=97);QC[43]=ZC,QC[45]=ZC,QC[46]=ZC,QC[95]=ZC,QC[72]=[ZC,XC],QC[104]=[ZC,XC],QC[87]=[ZC,YC],QC[119]=[ZC,YC];function tw(e,t,n){let r=this,i,a;return o;function o(t){return!fw(t)||!dw.call(r,r.previous)||pw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return fw(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(JC,u,l)(t):t===45||t===95||Kr(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Gr(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function nw(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!lw.call(r,r.previous)||pw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(WC,e.attempt(GC,e.attempt(KC,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function rw(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&uw.call(r,r.previous)&&!pw(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Gr(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Jr(t)||Qr(t)||ti(t)||ei(t)?n(t):e.attempt(GC,e.attempt(KC,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function iw(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function aw(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(qC,c,s)(t):t===null||Qr(t)||ti(t)||t!==45&&ei(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function ow(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(qC,t,a)(o):o===null||Qr(o)||ti(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function sw(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Qr(o)||ti(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Qr(e)||ti(e)?t(e):r(e)}function a(e){return Gr(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Gr(t)?(e.consume(t),o):n(t)}}function cw(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Kr(e)?n(e):t(e)}}function lw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Qr(e)}function uw(e){return!Gr(e)}function dw(e){return!(e===47||fw(e))}function fw(e){return e===43||e===45||e===46||e===95||Kr(e)}function pw(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var mw={tokenize:Sw,partial:!0};function hw(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:yw,continuation:{tokenize:bw},exit:xw}},text:{91:{name:`gfmFootnoteCall`,tokenize:vw},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:gw,resolveTo:_w}}}}function gw(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Wr(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function _w(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function vw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Qr(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Wr(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Qr(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function yw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Qr(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Wr(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Qr(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),ri(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function bw(e,t,n){return e.check(vi,t,e.attempt(mw,t,n))}function xw(e){e.exit(`gfmFootnoteDefinition`)}function Sw(e,t,n){let r=this;return ri(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Cw(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Lr(o,o.length,0,di(s,e.slice(r+1,n),t)),Lr(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Lr(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ui(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ui(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ww=class{constructor(){this.map=[]}add(e,t,n){Tw(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Tw(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Ew(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Dw(){return{flow:{null:{name:`table`,tokenize:Ow,resolveAll:kw}}}}function Ow(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):N(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):$r(t)?ri(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Qr(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,$r(t)?ri(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return $r(t)?ri(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||N(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return $r(t)?ri(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||N(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||N(n)?(e.exit(`tableRow`),t(n)):$r(n)?ri(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Qr(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function kw(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new ww;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(jw(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Aw(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Aw(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Aw(f,t,o,i,n,d)):(o[0]=o[1],d=Aw(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&jw(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Ew(t.events,n))}return e}function Aw(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Mw(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Mw(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Mw(t.events,n[2]),a=Mw(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Mw(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function jw(e,t,n,r,i){let a=[],o=Mw(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Mw(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Nw={name:`tasklistCheck`,tokenize:Fw};function Pw(){return{text:{91:Nw}}}function Fw(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Qr(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return N(r)?t(r):$r(r)?e.check({tokenize:Iw},t,n)(r):n(r)}}function Iw(e,t,n){return ri(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Lw(e){return Br([$C(),hw(),Cw(e),Dw(),Pw()])}var Rw={};function zw(e){let t=this,n=e||Rw,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Lw(n)),a.push(HC()),o.push(UC(n))}function Bw(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var Vw=Kg(`strike_through`);Bw(Vw,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var Hw=Ug(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(Vw.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));Bw(Hw.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),Bw(Hw.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var Uw=Pg(`ToggleStrikeThrough`,e=>()=>Ml(Hw.type(e)));Bw(Uw,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var Ww=Fg(e=>ru(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,Hw.type(e)));Bw(Ww,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var Gw=Wg(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(Uh);return()=>t.call(Uw.key)}}});Bw(Gw.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),Bw(Gw.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var Kw=Fb({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),qw=Hg(`table`,()=>({...Kw.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));Bw(qw.node,{displayName:`NodeSchema<table>`,group:`Table`}),Bw(qw.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var Jw=Hg(`table_header_row`,()=>({...Kw.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));Bw(Jw.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),Bw(Jw.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var Yw=Hg(`table_row`,()=>({...Kw.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));Bw(Yw.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),Bw(Yw.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var Xw=Hg(`table_cell`,()=>({...Kw.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));Bw(Xw.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),Bw(Xw.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var Zw=Hg(`table_header`,()=>({...Kw.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));Bw(Zw.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),Bw(Zw.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function Qw(e,t=3,n=3){let r=Array(n).fill(0).map(()=>Xw.type(e).createAndFill()),i=Array(n).fill(0).map(()=>Zw.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?Jw.type(e).create(null,i):Yw.type(e).create(null,r));return qw.type(e).create(null,a)}function $w(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=Cu(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=Db.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?Yb.rowSelection:Yb.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return hu(r.setSelection(a(i,l)))}}return r}}var eT=$w(`row`),tT=$w(`col`);function nT(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return Xw.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,Yw.type(e).create(null,s)),t}function rT(e){let t=cx(e.$from);if(!t)return;let n=Db.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function iT(e){let t=rT(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return hu(e.setSelection(new Yb(t,n)))}}return e}var aT=Pg(`GoToPrevTableCell`,()=>()=>Ix(-1));Bw(aT,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var oT=Pg(`GoToNextTableCell`,()=>()=>Ix(1));Bw(oT,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var sT=Pg(`ExitTable`,e=>()=>(t,n)=>{if(!zb(t))return!1;let{$head:r}=t.selection,i=xu(r,qw.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,ny.type(e).createAndFill());return o.setSelection(Nn.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});Bw(sT,{displayName:`Command<breakTableCommand>`,group:`Table`});var cT=Pg(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=Qw(e,t,n),l=o.replaceSelectionWith(c),u=Nn.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});Bw(cT,{displayName:`Command<insertTableCommand>`,group:`Table`});var lT=Pg(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>zx({from:e??0,to:t??0,pos:n}));Bw(lT,{displayName:`Command<moveRowCommand>`,group:`Table`});var uT=Pg(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>Bx({from:e??0,to:t??0,pos:n}));Bw(uT,{displayName:`Command<moveColCommand>`,group:`Table`});var dT=Pg(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(eT(e.index,e.pos)(r))});Bw(dT,{displayName:`Command<selectRowCommand>`,group:`Table`});var fT=Pg(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(tT(e.index,e.pos)(r))});Bw(fT,{displayName:`Command<selectColCommand>`,group:`Table`});var pT=Pg(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(iT(n))});Bw(pT,{displayName:`Command<selectTableCommand>`,group:`Table`});var mT=Pg(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof Yb))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Lx(e,t):i?wx(e,t):Ax(e,t)});Bw(mT,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var hT=Pg(`AddColBefore`,()=>()=>xx);Bw(hT,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var gT=Pg(`AddColAfter`,()=>()=>Sx);Bw(gT,{displayName:`Command<addColAfterCommand>`,group:`Table`});var _T=Pg(`AddRowBefore`,e=>()=>(t,n)=>{if(!zb(t))return!1;if(n){let r=yx(t);n(nT(e,t.tr,r,r.top))}return!0});Bw(_T,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var vT=Pg(`AddRowAfter`,e=>()=>(t,n)=>{if(!zb(t))return!1;if(n){let r=yx(t);n(nT(e,t.tr,r,r.bottom))}return!0});Bw(vT,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var yT=Pg(`SetAlign`,()=>(e=`left`)=>jx(`alignment`,e));Bw(yT,{displayName:`Command<setAlignCommand>`,group:`Table`});var bT=Fg(e=>new zl(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),qw.type(e)))return null;let o=Qw(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(j.create(s.doc,r+3)).scrollIntoView()}));Bw(bT,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var xT=Ig(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return ny.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push(Zw.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>Zw.type(e).createAndFill()),o=new k(D.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new k(D.from(s),0,0))}function a(t){let n=Yw.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=Jw.type(e).createAndFill(),n=qw.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?D.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===qw.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?D.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===ny.type(e)&&i.content.size===0&&a&&a.type===qw.type(e)||n.push(i)}return n.length<r.length?D.from(n):t}let c=o(t.content);return c=s(c),new k(D.from(c),t.openStart,t.openEnd)}}));Bw(xT,{displayName:`PasteRule<table>`,group:`Table`});var ST=Wg(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(Uh);return()=>t.call(oT.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(Uh);return()=>t.call(aT.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(Uh);return()=>t.call(sT.key)}}});Bw(ST.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),Bw(ST.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var CT=`footnote_definition`,wT=`footnoteDefinition`,TT=Hg(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${CT}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":CT},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===wT,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===CT,runner:(e,t)=>{e.openNode(wT,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));Bw(TT.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),Bw(TT.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var ET=`footnote_reference`,DT=Hg(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${ET}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":ET},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===ET,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));Bw(DT.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),Bw(DT.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var OT=Jy.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw gr(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});Bw(OT.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),Bw(OT.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var kT=Fg(()=>new zl(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));Bw(kT,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var AT=[Gw,ST].flat(),jT=[bT,kT],MT=[Ww],NT=[xT],PT=zg(()=>PS);Bw(PT,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),Bw(zg(()=>cS({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var FT=zg(()=>SS({allowTableNodeSelection:!0}));Bw(FT,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var IT=qg(`remarkGFM`,()=>zw);Bw(IT.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),Bw(IT.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var LT=new nr(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function RT(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var zT=zg(()=>new $n({key:LT,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=RT(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));Bw(zT,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var BT=[zT,PT,IT,FT].flat(),VT=[[OT,qw,Jw,Yw,Zw,Xw,TT,DT,Vw,Hw].flat(),jT,NT,MT,AT,[oT,aT,sT,cT,lT,uT,dT,fT,pT,mT,_T,vT,hT,gT,yT,Uw],BT].flat(),HT=(e,t)=>typeof e==`function`?n=>{t.action(e(n))}:()=>void 0,UT=(e,t,n)=>{if(Array.isArray(n)){n.forEach((n,r)=>{e.push({name:`${t}-${r}`,plugin:n})});return}e.push({name:t,plugin:n})},WT=(e,t={})=>{let n=[],r=t.includeRuntime??!0;return UT(n,`listener`,e.listener),UT(n,`commonmark`,e.commonmark),UT(n,`inline-code-boundary-navigation`,e.inlineCodeBoundaryNavigation),UT(n,`gfm`,e.gfm),UT(n,`history`,e.history),UT(n,`code-block-prism`,e.codeBlockPrism),UT(n,`code-block-language-picker`,e.codeBlockLanguagePicker),r&&(UT(n,`clipboard`,e.clipboard),UT(n,`indent`,e.indent)),UT(n,`image-delete-selection`,e.imageDeleteSelection),UT(n,`image-paste`,e.imagePaste),UT(n,`table-arrow-entry`,e.tableArrowEntry),UT(n,`block-boundary-navigation`,e.blockBoundaryNavigation),UT(n,`heading-backspace-empty-paragraph`,e.headingBackspaceEmptyParagraph),UT(n,`math-backspace-entry`,e.mathBackspaceEntry),UT(n,`blockquote-backspace-lift`,e.blockquoteBackspaceLift),UT(n,`table-focus-actions`,e.tableFocusActions),UT(n,`selection-tooltip`,e.selectionTooltip),UT(n,`gap-cursor`,e.gapCursor),UT(n,`drop-cursor`,e.dropCursor),UT(n,`math`,e.math),UT(n,`math-inline-edit`,e.mathInlineEdit),UT(n,`math-inline-arrow-navigation`,e.mathInlineArrowNavigation),UT(n,`task-list-toggle`,e.taskListToggle),UT(n,`tab-space-indent`,e.tabSpaceIndent),UT(n,`code-block-mod-a-select`,e.codeBlockModASelect),e.slash&&UT(n,`slash`,e.slash),n};function GT(e={}){return new $n({view(t){return new KT(t,e)}})}var KT=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=fn(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},qT=2,JT=`var(--zt-primary)`,YT=zg(()=>GT({color:JT,width:qT})),XT=class e extends Nn{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Nn.near(r)}content(){return k.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new ZT(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!$T(e)||!eE(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!M.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};XT.prototype.visible=!1,XT.findFrom=XT.findGapCursorFrom,Nn.jsonID(`gapcursor`,XT);var ZT=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return XT.valid(t)?new XT(t):Nn.near(t)}};function QT(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function $T(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||QT(e.type))return!0;if(e.inlineContent)return!1}}return!0}function eE(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||QT(e.type))return!0;if(e.inlineContent)return!1}}return!0}function tE(){return new $n({props:{decorations:oE,createSelectionBetween(e,t,n){return t.pos==n.pos&&XT.valid(n)?new XT(n):null},handleClick:iE,handleKeyDown:nE,handleDOMEvents:{beforeinput:aE}}})}var nE=zu({ArrowLeft:rE(`horiz`,-1),ArrowRight:rE(`horiz`,1),ArrowUp:rE(`vert`,-1),ArrowDown:rE(`vert`,1)});function rE(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof j){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=XT.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new XT(c))),!0):!1}}function iE(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!XT.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&M.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new XT(r))),!0)}function aE(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof XT))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let e=r.length-1;e>=0;e--)i=D.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return a.setSelection(j.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function oE(e){if(!(e.selection instanceof XT))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,km.create(e.doc,[Em.widget(e.selection.head,t,{key:`gapcursor`})])}var sE=zg(()=>tE()),cE=-1,lE=1,uE=new Set([`math_block`,`code_block`,`table`,`image`,`hr`]),dE=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,fE=(e,t,n)=>{let r=e.state.doc.resolve(t);return XT.valid(r)?new XT(r):j.near(r,n)},pE=(e,t)=>t===cE?e.nodeBefore!==null:e.nodeAfter!==null,mE=(e,t)=>{let n=e.state.schema.nodes.paragraph;if(!n)return!1;let r=e.state.doc.resolve(t),i=r.index();if(!r.parent.canReplaceWith(i,i,n))return!1;let a=n.createAndFill();if(!a)return!1;let o=e.state.tr.insert(t,a),s=t+1;return o.setSelection(j.near(o.doc.resolve(s),1)).scrollIntoView(),e.dispatch(o),e.focus(),!0},hE=(e,t,n,r)=>{if(!uE.has(n.type.name))return!1;let i=r===cE?t:t+n.nodeSize;if(i<0||i>e.state.doc.content.size)return!1;if(!pE(e.state.doc.resolve(i),r)&&mE(e,i))return!0;let a=e.state.tr.setSelection(fE(e,i,r)).scrollIntoView();return e.dispatch(a),e.focus(),!0},gE=e=>{for(let t=e.depth;t>0;--t){let n=e.node(t);if(uE.has(n.type.name))return{node:n,position:e.before(t),depth:t}}return null},_E=(e,t,n)=>{for(let r=t;r<e.depth;r+=1){let t=e.node(r);if(e.index(r)!==(n===cE?0:t.childCount-1))return!1}return!0},vE=(e,t)=>{let{selection:n}=e.state;if(n instanceof M)return hE(e,n.from,n.node,t);if(!n.empty)return!1;let r=gE(n.$from);return!r||!_E(n.$from,r.depth,t)||!e.endOfTextblock(t===cE?`up`:`down`)?!1:hE(e,r.position,r.node,t)},yE=e=>{let{doc:t,selection:n}=e.state;return!(n instanceof j)||!n.empty||!(n.$from.after(1)===t.content.size&&_E(n.$from,1,lE))||!e.endOfTextblock(`down`)?!1:mE(e,t.content.size)},bE={ArrowUp:e=>vE(e,cE),ArrowDown:e=>vE(e,lE)||yE(e)},xE=(e,t)=>t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!dE(e),SE=(e,t,n,r)=>{let i=r===`ArrowUp`?cE:r===`ArrowDown`?lE:null;return i===null||!dE(e)?!1:hE(e,t,n,i)},CE=zg(()=>new $n({key:new nr(`zt-md-block-boundary-navigation`),props:{handleKeyDown:(e,t)=>{let n=bE[t.key];if(!n||xE(e,t))return!1;let r=n(e);return r&&t.preventDefault(),r}}})),wE=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),TE=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),EE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),DE=e=>{let t=EE(e);return t.charAt(0).toUpperCase()+t.slice(1)},OE={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},kE=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},AE=(0,d.createContext)({}),jE=()=>(0,d.useContext)(AE),ME=(0,d.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,color:p=`currentColor`,className:m=``}=jE()??{},h=r??f?Number(n??u)*24/Number(t??l):n??u;return(0,d.createElement)(`svg`,{ref:c,...OE,width:t??l??OE.width,height:t??l??OE.height,stroke:e??p,strokeWidth:h,className:wE(`lucide`,m,i),...!a&&!kE(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,d.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),NE=(e,t)=>{let n=(0,d.forwardRef)(({className:n,...r},i)=>(0,d.createElement)(ME,{ref:i,iconNode:t,className:wE(`lucide-${TE(DE(e))}`,`lucide-${e}`,n),...r}));return n.displayName=DE(e),n},PE=NE(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),FE=NE(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),IE=NE(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),LE=NE(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),RE=NE(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),zE=NE(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),BE=NE(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),VE=NE(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),HE=NE(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),UE=NE(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),WE=NE(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),GE=NE(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),KE=NE(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),qE=NE(`heading-4`,[[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 10v3a1 1 0 0 0 1 1h3`,key:`tj5zdr`}],[`path`,{d:`M21 10v8`,key:`1kdml4`}],[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}]]),JE=NE(`heading-6`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`circle`,{cx:`19`,cy:`16`,r:`2`,key:`15mx69`}],[`path`,{d:`M20 10c-2 2-3 3.5-3 6`,key:`f35dl0`}]]),YE=NE(`heading-5`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17 13v-3h4`,key:`1nvgqp`}],[`path`,{d:`M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17`,key:`2nebdn`}]]),XE=NE(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),ZE=NE(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),QE=NE(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),$E=NE(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),eD=NE(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),tD=NE(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),nD=NE(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),rD=NE(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),iD=NE(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),aD=NE(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),oD=NE(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),sD=NE(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),cD=NE(`square-code`,[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),lD=NE(`square-function`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3`,key:`m1af9g`}],[`path`,{d:`M9 11.2h5.7`,key:`3zgcl2`}]]),uD=NE(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),dD=NE(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),fD=NE(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),pD=NE(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),mD=NE(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),hD=NE(`text-quote`,[[`path`,{d:`M17 5H3`,key:`1cn7zz`}],[`path`,{d:`M21 12H8`,key:`scolzb`}],[`path`,{d:`M21 19H8`,key:`13qgcb`}],[`path`,{d:`M3 12v7`,key:`1ri8j3`}]]),gD=NE(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),_D=NE(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),vD=NE(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),yD=e=>typeof e==`string`,bD=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},xD=e=>e==null?``:String(e),SD=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},CD=/###/g,wD=e=>e&&e.includes(`###`)?e.replace(CD,`.`):e,TD=e=>!e||yD(e),ED=(e,t,n)=>{let r=yD(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(TD(e))return{};let t=wD(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return TD(e)?{}:{obj:e,k:wD(r[i])}},DD=(e,t,n)=>{let{obj:r,k:i}=ED(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=ED(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=ED(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},OD=(e,t,n,r)=>{let{obj:i,k:a}=ED(e,t,Object);i[a]=i[a]||[],i[a].push(n)},kD=(e,t)=>{let{obj:n,k:r}=ED(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},AD=(e,t,n)=>{let r=kD(e,n);return r===void 0?kD(t,n):r},jD=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?yD(e[r])||e[r]instanceof String||yD(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):jD(e[r],t[r],n):e[r]=t[r]);return e},MD=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),ND={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},PD=e=>yD(e)?e.replace(/[&<>"'\/]/g,e=>ND[e]):e,FD=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},ID=[` `,`,`,`?`,`!`,`;`],LD=new FD(20),RD=(e,t,n)=>{t||=``,n||=``;let r=ID.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=LD.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},zD=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},BD=e=>e?.replace(/_/g,`-`),VD={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},HD=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||VD,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>yD(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),yD(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},UD=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},WD=class extends UD{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):yD(n)&&i?o.push(...n.split(i)):o.push(n)));let s=kD(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!yD(n)?s:zD(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),DD(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(yD(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=kD(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?jD(s,n,i):s={...s,...n},DD(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},GD={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},KD=Symbol(`i18next/PATH_KEY`);function qD(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===KD?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function JD(e,t){let{[KD]:n}=e(qD()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var YD=e=>!yD(e)&&typeof e!=`boolean`&&typeof e!=`number`,XD=class e extends UD{constructor(e,t={}){super(),SD([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=HD.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=YD(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!RD(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:yD(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:yD(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=JD(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?JD(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!yD(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let ee=YD(E),te=Object.prototype.toString.apply(E);if(y&&E&&ee&&!_.includes(te)&&!(yD(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;x&&!m?t[e]=this.translate(r,{...i,defaultValue:YD(T)?T[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&yD(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=yD(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!yD(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=yD(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=GD.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return yD(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?JD(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!yD(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(yD(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!yD(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},ZD=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=HD.create(`languageUtils`)}getScriptPartFromCode(e){if(e=BD(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=BD(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(yD(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),yD(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return yD(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):yD(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.includes(e)||i(this.formatLanguageCode(e))}),r}},QD={zero:0,one:1,two:2,few:3,many:4,other:5},$D={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},eO=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=HD.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=BD(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),$D;if(!e.match(/-|_/))return $D;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>QD[e]-QD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},tO=(e,t,n,r=`.`,i=!0)=>{let a=AD(e,t,n);return!a&&i&&yD(n)&&(a=zD(e,n,r),a===void 0&&(a=zD(t,n,r))),a},nO=e=>e.replace(/\$/g,`$$$$`),rO=class{constructor(e={}){this.logger=HD.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?PD:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?MD(i):a||`{{`,this.suffix=o?MD(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?MD(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?MD(l):``,this.nestingPrefix=d?MD(d):f||MD(`$t(`),this.nestingSuffix=p?MD(p):m||MD(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=tO(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(tO(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>nO(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?nO(this.escape(e)):nO(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=yD(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else !yD(a)&&!this.useRawValueToEscape&&(a=xD(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${MD(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!yD(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!yD(i))return i;yD(i)||(i=xD(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},iO=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},aO=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(BD(r),i),t[o]=s),s(n)}},oO=e=>(t,n,r)=>e(BD(n),r)(t),sO=class{constructor(e={}){this.logger=HD.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?aO:oO;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=aO(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf(`(`)>1&&!i[0].includes(`)`)&&i.find(e=>e.includes(`)`))){let e=i.findIndex(e=>e.includes(`)`));i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:a}=iO(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},cO=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},lO=class extends UD{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=HD.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{OD(n.loaded,[i],a),cO(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();yD(e)&&(e=this.languageUtils.toResolveHierarchy(e)),yD(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},uO=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),yD(e[1])&&(t.defaultValue=e[1]),yD(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),dO=e=>(yD(e.ns)&&(e.ns=[e.ns]),yD(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),yD(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),fO=()=>{},pO=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},mO=class e extends UD{constructor(e={},t){if(super(),this.options=dO(e),this.services={},this.logger=HD,this.modules={external:[]},pO(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(yD(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=uO();this.options={...n,...this.options,...dO(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?HD.init(r(this.modules.logger),this.options):HD.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:sO;let t=new ZD(this.options);this.store=new WD(this.options.resources,this.options);let n=this.services;n.logger=HD,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new eO(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new rO(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new lO(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new XD(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=fO,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=bD(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=fO){let n=t,r=yD(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=bD();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=fO,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&GD.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=bD();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=yD(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(yD(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=JD(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=JD(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=JD(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return yD(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=bD();return this.options.ns?(yD(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=bD();yD(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new ZD(uO());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=fO){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new WD(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...uO().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new rO(n)}return a.translator=new XD(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();mO.createInstance,mO.dir,mO.init,mO.loadResources,mO.reloadResources,mO.use,mO.changeLanguage,mO.getFixedT,mO.t,mO.exists,mO.setDefaultNamespace,mO.hasLoadedNamespace,mO.loadNamespaces,mO.loadLanguages;var hO={placeholder:`Type / to open the command menu...`,initError:`Editor initialization failed. Please refresh the page and try again.`,editorAriaLabel:`Markdown editor`,mathBlockSourceAriaLabel:`Math block source`,mathBlockCopyAriaLabel:`Copy math source`,mathBlockDeleteAriaLabel:`Delete math block`,imageDeleteAriaLabel:`Delete image`,tableDeleteAriaLabel:`Delete table`,tableMoreAriaLabel:`More table actions`,tableAlignLeftAriaLabel:`Align current column left`,tableAlignCenterAriaLabel:`Align current column center`,tableAlignRightAriaLabel:`Align current column right`,tableInsertRowAboveLabel:`Insert row above`,tableInsertRowBelowLabel:`Insert row below`,tableInsertColumnLeftLabel:`Insert column left`,tableInsertColumnRightLabel:`Insert column right`,tableDeleteRowLabel:`Delete row`,tableDeleteColumnLabel:`Delete column`,mathRenderError:`Formula rendering failed. Please check the formula syntax.`,imageUploadDialogTitle:`Insert image`,imageUploadDropLabel:`Drop an image here, or choose a file`,imageUploadPickFileLabel:`Choose file`,imageUploadFileTab:`Upload file`,imageUploadUrlTab:`Image URL`,imageUploadUrlPlaceholder:`Paste image URL`,imageUploadInsertUrlLabel:`Insert URL`,imageUploadConfirmLabel:`Insert image`,imageUploadAltLabel:`Alternative text (optional)`,imageUploadAltPlaceholder:`Describe the image`,imageUploadUploadingLabel:`Uploading...`,imageUploadInsertingLabel:`Inserting...`,imageUploadCancelLabel:`Cancel`,imageUploadLoadFailed:`Image failed to load`,imageUploadReselectHint:`Click or drag to reselect`,imageUploadSupportsAndMax:`Supports PNG, JPG, GIF, WebP, SVG, and more, max {size}`,imageUploadFileTooLarge:`The image file is too large.`,imageUploadFileSizeExceeded:`Image size must not exceed {size}`,imageUploadInvalidType:`Please choose an image file.`,imageUploadFailed:`Image upload failed. Please try again.`,imageUploadFileReadFailed:`File read failed. Please try again.`,imageUploadInvalidUrl:`Please enter a valid image URL.`,imageUploadUrlRequired:`Please enter an image URL.`,imageUploadSelectOrEnterImage:`Please select an image or enter an image URL.`,imageUploadUploadingWait:`Image is uploading, please wait.`,selectionTooltipStrongTitle:`Bold`,selectionTooltipEmTitle:`Italic`,selectionTooltipStrikeTitle:`Strikethrough`,selectionTooltipInlineCodeTitle:`Inline code`,selectionTooltipLinkTitle:`Link`,selectionTooltipTransformLabel:`Turn into`,selectionTooltipTransformParagraphLabel:`Paragraph`,selectionTooltipTransformHeading1Label:`Heading 1`,selectionTooltipTransformHeading2Label:`Heading 2`,selectionTooltipTransformHeading3Label:`Heading 3`,selectionTooltipTransformHeading4Label:`Heading 4`,selectionTooltipTransformHeading5Label:`Heading 5`,selectionTooltipTransformHeading6Label:`Heading 6`,selectionTooltipTransformBulletListLabel:`Bullet list`,selectionTooltipTransformOrderedListLabel:`Ordered list`,selectionTooltipTransformTaskListLabel:`Task list`,selectionTooltipTransformBlockquoteLabel:`Blockquote`,selectionTooltipTransformCodeBlockLabel:`Code block`,selectionLinkInputPlaceholder:`Type or paste a link`,selectionLinkSaveAriaLabel:`Save link`,selectionLinkRemoveAriaLabel:`Remove link`,codeBlockLanguageSearchPlaceholder:`Search languages`,codeBlockLanguagePlainText:`text`,codeBlockCopyAriaLabel:`Copy code block`,codeBlockPreviewAriaLabel:`Preview code block`,codeBlockSourceAriaLabel:`View code block source`,codeBlockDeleteAriaLabel:`Delete code block`},gO={placeholder:`请输入 / 打开命令菜单...`,initError:`编辑器初始化失败,请刷新页面后重试。`,editorAriaLabel:`Markdown 编辑器`,mathBlockSourceAriaLabel:`公式块源码`,mathBlockCopyAriaLabel:`复制公式源码`,mathBlockDeleteAriaLabel:`删除公式块`,imageDeleteAriaLabel:`删除图片`,tableDeleteAriaLabel:`删除表格`,tableMoreAriaLabel:`更多表格操作`,tableAlignLeftAriaLabel:`当前列左对齐`,tableAlignCenterAriaLabel:`当前列居中对齐`,tableAlignRightAriaLabel:`当前列右对齐`,tableInsertRowAboveLabel:`上方插入行`,tableInsertRowBelowLabel:`下方插入行`,tableInsertColumnLeftLabel:`左侧插入列`,tableInsertColumnRightLabel:`右侧插入列`,tableDeleteRowLabel:`删除该行`,tableDeleteColumnLabel:`删除该列`,mathRenderError:`公式渲染失败,请检查公式语法。`,imageUploadDialogTitle:`插入图片`,imageUploadDropLabel:`拖拽图片到这里,或选择文件`,imageUploadPickFileLabel:`选择文件`,imageUploadFileTab:`上传文件`,imageUploadUrlTab:`图片链接`,imageUploadUrlPlaceholder:`粘贴图片链接`,imageUploadInsertUrlLabel:`插入链接`,imageUploadConfirmLabel:`插入图片`,imageUploadAltLabel:`替代文本(可选)`,imageUploadAltPlaceholder:`描述图片内容`,imageUploadUploadingLabel:`上传中...`,imageUploadInsertingLabel:`正在插入...`,imageUploadCancelLabel:`取消`,imageUploadLoadFailed:`图片加载失败`,imageUploadReselectHint:`点击或拖拽重新选择`,imageUploadSupportsAndMax:`支持 PNG、JPG、GIF、WebP、SVG 等,最大 {size}`,imageUploadFileTooLarge:`图片文件过大。`,imageUploadFileSizeExceeded:`图片大小不能超过 {size}`,imageUploadInvalidType:`请选择图片文件。`,imageUploadFailed:`图片上传失败,请重试。`,imageUploadFileReadFailed:`文件读取失败,请重试。`,imageUploadInvalidUrl:`请输入有效的图片链接。`,imageUploadUrlRequired:`请输入图片链接。`,imageUploadSelectOrEnterImage:`请选择图片或输入图片链接。`,imageUploadUploadingWait:`图片正在上传,请稍候。`,selectionTooltipStrongTitle:`加粗`,selectionTooltipEmTitle:`斜体`,selectionTooltipStrikeTitle:`删除线`,selectionTooltipInlineCodeTitle:`行内代码`,selectionTooltipLinkTitle:`链接`,selectionTooltipTransformLabel:`转换为`,selectionTooltipTransformParagraphLabel:`段落`,selectionTooltipTransformHeading1Label:`标题 1`,selectionTooltipTransformHeading2Label:`标题 2`,selectionTooltipTransformHeading3Label:`标题 3`,selectionTooltipTransformHeading4Label:`标题 4`,selectionTooltipTransformHeading5Label:`标题 5`,selectionTooltipTransformHeading6Label:`标题 6`,selectionTooltipTransformBulletListLabel:`无序列表`,selectionTooltipTransformOrderedListLabel:`有序列表`,selectionTooltipTransformTaskListLabel:`任务列表`,selectionTooltipTransformBlockquoteLabel:`引用块`,selectionTooltipTransformCodeBlockLabel:`代码块`,selectionLinkInputPlaceholder:`输入或粘贴链接`,selectionLinkSaveAriaLabel:`保存链接`,selectionLinkRemoveAriaLabel:`移除链接`,codeBlockLanguageSearchPlaceholder:`搜索语言`,codeBlockLanguagePlainText:`text`,codeBlockCopyAriaLabel:`复制代码块`,codeBlockPreviewAriaLabel:`预览代码块`,codeBlockSourceAriaLabel:`查看代码块源码`,codeBlockDeleteAriaLabel:`删除代码块`},_O=`zh-CN`,vO={"zh-CN":{translation:gO},"en-US":{translation:hO}},yO=mO.createInstance(),bO=!1,xO=()=>{bO||=(yO.init({resources:vO,fallbackLng:_O,lng:_O,interpolation:{escapeValue:!1}}),!0)},SO=(e=_O,t,n)=>{xO();let r={...yO.getResourceBundle(e,`translation`),...t};return n!==void 0&&(r.placeholder=n),r},CO=new Set([`http:`,`https:`,`mailto:`,`tel:`]),wO=new Set([`data:`]),TO=/[\u0000-\u0020\u007f]+/g,EO=/^([a-z][a-z\d+\-.]*:)/i,DO=/[<>"'`]/,OO=new Set([`src`,`alt`,`title`,`style`]),kO=(e,t)=>{if(typeof e!=`string`)return``;let n=e.trim();if(!n||DO.test(n)||/[\u0000-\u001f\u007f]/.test(n))return``;let r=n.replace(TO,``);if(r.startsWith(`//`))return``;let i=r.match(EO)?.[1]?.toLowerCase()??``;if(!i)return n;if(!t.has(i))return``;try{return new URL(n).toString()}catch{return``}},AO=e=>kO(e,CO),jO=(e,t=[])=>kO(e,new Set([...CO,...wO,...t.map(e=>e.trim().toLowerCase())])),MO=(e,t,n=[])=>{if(typeof e!=`string`)return null;let r=e.trim();if(!r)return null;let i=new DOMParser().parseFromString(r,`text/html`),a=null;for(let e of Array.from(i.body.childNodes))if(!(e.nodeType===Node.TEXT_NODE&&!(e.textContent??``).trim())){if(e instanceof HTMLImageElement&&a===null){a=e;continue}return null}if(!a||a.tagName.toLowerCase()!==`img`)return null;for(let e of Array.from(a.attributes))if(!OO.has(e.name.toLowerCase()))return null;let o=jO(a.getAttribute(`src`)??``,n);return o?{src:o,alt:a.getAttribute(`alt`)??``,title:a.getAttribute(`title`)??``,style:t(a.getAttribute(`style`)??``)}:null},NO=/^\s*width\s*:\s*(\d{1,3})%\s*;?\s*$/i,PO=(e,t)=>{let n=Array.isArray(e.children)?e.children:[],r=n[0];return n.length===1&&(r?.type===`image`||r?.type===`html`&&MO(r.value,RO,t)!==null)?r:null},FO=e=>Math.min(100,Math.max(10,e)),IO=e=>`width: ${FO(Math.round(e))}%;`,LO=e=>{if(typeof e!=`string`)return null;let t=e.match(NO);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?FO(n):null},RO=e=>{let t=LO(e);return t===null?``:IO(t)},zO=e=>typeof e==`string`?e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`):``,BO=(e,t)=>{let n=jO(e.src,t);if(!n)return``;let r=typeof e.alt==`string`?e.alt:``,i=typeof e.title==`string`?e.title:``,a=i?` title="${zO(i)}"`:``,o=RO(e.style);return`<img src="${zO(n)}" alt="${zO(r)}"${a} style="${zO(o)}">`},VO=(e,t)=>n=>{let r=e(n);return{...r,inline:!1,group:`block`,attrs:{...r.attrs,style:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{let n=e,r=jO(n.getAttribute(`src`)??``,t);return r?{src:r,alt:n.getAttribute(`alt`)??``,title:n.getAttribute(`title`)??n.getAttribute(`alt`)??``,style:RO(n.getAttribute(`style`)??``)}:!1}}],parseMarkdown:{match:e=>e.type===`image`||e.type===`html`&&MO(e.value,RO,t)!==null,runner:(e,n,r)=>{if(n.type===`html`){let i=MO(n.value,RO,t);i&&e.addNode(r,i);return}let i=jO(String(n.url??``),t);i&&e.addNode(r,{src:i,alt:String(n.alt??``),title:String(n.title??``),style:``})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,n)=>{let r=jO(n.attrs.src,t);if(!r)return;let i=RO(n.attrs.style);if(i){let a=BO({...n.attrs,src:r,style:i},t);a&&e.addNode(`html`,void 0,a);return}let a={type:`image`,title:n.attrs.title,url:r,alt:n.attrs.alt};e.addNode(`paragraph`,[a])}}}},HO=(e,t)=>n=>{let r=e(n);return{...r,parseMarkdown:{...r.parseMarkdown,runner:(e,n,i)=>{let a=PO(n,t);if(a){e.next(a);return}r.parseMarkdown.runner(e,n,i)}}}},UO=(e,t=[])=>{let n=e.get(Ey.key),r=e.get(ny.key);e.set(Ey.key,VO(n,t)),e.set(ny.key,HO(r,t))},WO=`image`,GO=`left`,KO=`right`,qO=160,JO=e=>(0,f.renderToStaticMarkup)((0,d.createElement)(e,{size:14,strokeWidth:2,"aria-hidden":`true`})),YO=JO(gD),XO=JO(XE),ZO=e=>typeof e==`function`?e():null,QO=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,$O=class{constructor(e,t,n,r){this.resizeState=null,this.isSelected=!1,this.currentImageSrc=``,this.imageLoadingStartedAt=0,this.imageLoadingFinishTimer=null,this.handleDeleteClick=e=>{e.preventDefault(),e.stopPropagation(),QO(this.view)&&this.deleteCurrentImage()},this.handleImageLoad=()=>{delete this.dom.dataset.loadError,this.finishImageLoadingWithMinimumDuration()},this.handleImageError=()=>{this.dom.dataset.loadError=`true`,this.finishImageLoadingWithMinimumDuration()},this.handleResizePointerDown=e=>{if(e.preventDefault(),e.stopPropagation(),!QO(this.view))return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=t.dataset.side===GO?GO:KO,r=this.dom.parentElement;if(!r)return;let i=this.imageElement.getBoundingClientRect(),a=r.getBoundingClientRect();if(i.width<=0||a.width<=0)return;let o=FO(i.width/a.width*100);this.resizeState={side:n,startClientX:e.clientX,startWidth:i.width,containerWidth:a.width,widthPercent:o},this.dom.dataset.resizing=`true`,this.applyPreviewWidth(o),window.addEventListener(`pointermove`,this.handleResizePointerMove),window.addEventListener(`pointerup`,this.handleResizePointerUp),window.addEventListener(`pointercancel`,this.handleResizePointerUp)},this.handleResizePointerMove=e=>{if(!this.resizeState)return;e.preventDefault();let t=e.clientX-this.resizeState.startClientX,n=this.resizeState.side===GO?-t:t,r=FO((this.resizeState.startWidth+n)/this.resizeState.containerWidth*100);this.resizeState.widthPercent=r,this.applyPreviewWidth(r)},this.handleResizePointerUp=e=>{if(e.preventDefault(),!this.resizeState)return;let t=Math.round(this.resizeState.widthPercent);this.resizeState=null,delete this.dom.dataset.resizing,this.removeResizeWindowListeners(),this.commitImageWidth(t)},this.node=e,this.view=t,this.getPos=n,this.deleteAriaLabel=r.imageDeleteAriaLabel,this.dom=document.createElement(`span`),this.dom.dataset.type=WO,this.dom.className=`zt-md-image`,this.updateEditableState(),this.syncSelectedState(),this.imageElement=document.createElement(`img`),this.imageElement.addEventListener(`load`,this.handleImageLoad),this.imageElement.addEventListener(`error`,this.handleImageError),this.imageLoadErrorElement=document.createElement(`span`),this.imageLoadErrorElement.className=`zt-md-image-load-error`,this.imageLoadErrorElement.contentEditable=`false`,this.imageLoadErrorElement.innerHTML=XO,this.imageLoadErrorElement.append(r.imageUploadLoadFailed),this.leftResizeHandle=this.createResizeHandle(GO),this.rightResizeHandle=this.createResizeHandle(KO),this.actionsContainer=document.createElement(`span`),this.actionsContainer.className=`zt-md-image-actions`,this.deleteButton=document.createElement(`button`),this.deleteButton.type=`button`,this.deleteButton.className=`zt-md-image-action-button zt-md-image-action-button-danger`,this.deleteButton.setAttribute(`aria-label`,this.deleteAriaLabel),this.deleteButton.innerHTML=YO,this.actionsContainer.appendChild(this.deleteButton),this.dom.append(this.imageElement,this.imageLoadErrorElement,this.leftResizeHandle,this.rightResizeHandle,this.actionsContainer),this.syncFromNode(e),this.deleteButton.addEventListener(`click`,this.handleDeleteClick),this.leftResizeHandle.addEventListener(`pointerdown`,this.handleResizePointerDown),this.rightResizeHandle.addEventListener(`pointerdown`,this.handleResizePointerDown)}createResizeHandle(e){let t=document.createElement(`span`);return t.className=`zt-md-image-resize-handle zt-md-image-resize-handle-${e}`,t.dataset.side=e,t.setAttribute(`aria-hidden`,`true`),t}deleteCurrentImage(){let e=ZO(this.getPos);if(e===null)return;let t=this.view.state.tr.delete(e,e+this.node.nodeSize).scrollIntoView();this.view.dispatch(t),requestAnimationFrame(()=>{this.view.focus()})}updateEditableState(){this.dom.dataset.editable=QO(this.view)?`true`:`false`}syncSelectedState(){this.dom.dataset.selected=this.isSelected?`true`:`false`}markImageLoading(){this.clearImageLoadingFinishTimer(),this.imageLoadingStartedAt=performance.now(),delete this.dom.dataset.loadError,this.dom.dataset.loading=`true`}finishImageLoading(){this.clearImageLoadingFinishTimer(),delete this.dom.dataset.loading}finishImageLoadingWithMinimumDuration(){let e=performance.now()-this.imageLoadingStartedAt,t=Math.max(0,qO-e);if(t<=0){this.finishImageLoading();return}this.clearImageLoadingFinishTimer(),this.imageLoadingFinishTimer=window.setTimeout(()=>{this.finishImageLoading()},t)}clearImageLoadingFinishTimer(){this.imageLoadingFinishTimer!==null&&(window.clearTimeout(this.imageLoadingFinishTimer),this.imageLoadingFinishTimer=null)}removeResizeWindowListeners(){window.removeEventListener(`pointermove`,this.handleResizePointerMove),window.removeEventListener(`pointerup`,this.handleResizePointerUp),window.removeEventListener(`pointercancel`,this.handleResizePointerUp)}applyPreviewWidth(e){this.dom.style.width=`${Math.round(e)}%`,this.dom.dataset.hasWidth=`true`}commitImageWidth(e){let t=ZO(this.getPos);if(t===null)return;let n={...this.node.attrs,style:IO(e)},r=this.view.state.tr.setNodeMarkup(t,void 0,n);this.view.dispatch(r),requestAnimationFrame(()=>{this.view.focus()})}syncFromNode(e){this.updateEditableState();let t=typeof e.attrs.src==`string`?e.attrs.src:``,n=typeof e.attrs.alt==`string`?e.attrs.alt:``,r=typeof e.attrs.title==`string`?e.attrs.title:``,i=LO(RO(e.attrs.style));t!==this.currentImageSrc&&(delete this.dom.dataset.loadError,t&&this.markImageLoading()),this.imageElement.setAttribute(`src`,t),this.currentImageSrc=t,this.imageElement.setAttribute(`alt`,n),r?this.imageElement.title=r:this.imageElement.removeAttribute(`title`),i===null?(this.dom.style.removeProperty(`width`),delete this.dom.dataset.hasWidth):(this.dom.style.width=`${i}%`,this.dom.dataset.hasWidth=`true`),t?this.imageElement.complete&&this.imageElement.naturalWidth>0&&this.finishImageLoadingWithMinimumDuration():this.finishImageLoading()}update(e){return e.type.name===WO?(this.node=e,this.syncFromNode(e),!0):!1}selectNode(){this.isSelected=!0,this.syncSelectedState()}deselectNode(){this.isSelected=!1,this.syncSelectedState()}stopEvent(e){let t=e.target;return t instanceof Node?this.deleteButton.contains(t)||this.leftResizeHandle.contains(t)||this.rightResizeHandle.contains(t)||this.resizeState!==null:!1}ignoreMutation(){return!0}destroy(){this.removeResizeWindowListeners(),this.clearImageLoadingFinishTimer(),this.imageElement.removeEventListener(`load`,this.handleImageLoad),this.imageElement.removeEventListener(`error`,this.handleImageError),this.deleteButton.removeEventListener(`click`,this.handleDeleteClick),this.leftResizeHandle.removeEventListener(`pointerdown`,this.handleResizePointerDown),this.rightResizeHandle.removeEventListener(`pointerdown`,this.handleResizePointerDown)}},ek=(e=SO())=>(t,n,r)=>new $O(t,n,typeof r==`function`?()=>{let e=r();return typeof e==`number`?e:0}:!1,e),tk=`image`,nk={Backspace:`before`,Delete:`after`},rk=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,ik=e=>e instanceof Element?!!e.closest(`.zt-md-image-actions, .zt-md-image-resize-handle`):!1,ak=e=>e?.type.name===tk,ok=(e,t)=>!nk[t.key]||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!rk(e)||ik(t.target)||ik(document.activeElement),sk=e=>{if(e.parent.type.name!==`paragraph`||e.parentOffset!==0||e.parent.textContent.length>0||e.depth<1)return null;let t=e.index(e.depth-1);if(t<=0)return null;let n=e.node(e.depth-1).child(t-1);return ak(n)?{previousBlockStart:e.before(e.depth)-n.nodeSize}:null},ck=(e,t)=>{try{return j.create(e,t)}catch{return j.near(e.resolve(t),-1)}},lk=(e,t,n)=>{n.preventDefault();let r=t.from,i=e.state.tr.delete(t.from,t.to),a=i.doc.content.size,o=Math.min(r,a);return i.setSelection(ck(i.doc,o)).scrollIntoView(),e.dispatch(i),e.focus(),!0},uk=(e,t)=>{if(t.key!==`Backspace`)return!1;let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from,i=sk(r);if(!i)return!1;let a=r.before(r.depth),o=a+r.parent.nodeSize;t.preventDefault();let s=e.state.tr;return s.delete(a,o),s.setSelection(M.create(s.doc,i.previousBlockStart)).scrollIntoView(),e.dispatch(s),e.focus(),!0},dk=(e,t)=>{if(uk(e,t))return!0;let n=nk[t.key];if(!n)return!1;let{selection:r}=e.state;if(!r.empty)return!1;let i=r.$from,a=n===`before`?i.nodeBefore:i.nodeAfter;if(!ak(a))return!1;t.preventDefault();let o=n===`before`?r.from-a.nodeSize:r.from;return e.dispatch(e.state.tr.setSelection(M.create(e.state.doc,o)).scrollIntoView()),e.focus(),!0},fk=(e,t)=>{if(ok(e,t))return!1;let{selection:n}=e.state;return n instanceof M&&ak(n.node)?lk(e,n,t):dk(e,t)},pk=zg(()=>new $n({key:new nr(`zt-md-image-delete-selection`),props:{handleKeyDown:(e,t)=>fk(e,t)}})),mk=e=>e.state.schema.nodes.paragraph?.createAndFill()??null,hk=(e,t)=>e.state.schema.nodes.image?.create(t)??null,gk=e=>{let t=e.$to.parent;if(e.$to.parentOffset<t.content.size)return!0;if(e.$to.depth<1)return!1;let n=e.$to.node(e.$to.depth-1);return e.$to.index(e.$to.depth-1)<n.childCount-1},_k=(e,t)=>{let n=[t,t-1,t+1];for(let t of n)if(!(t<0||t>e.content.size)&&e.nodeAt(t)?.type.name===`image`)return t;return null},vk=(e,t)=>{let n=e.selection.from-t,r=_k(e.doc,n);return r===null?null:M.create(e.doc,r)},yk=(e,t,n=e.state.selection)=>{let r=hk(e,t);if(!r)return!1;let i=gk(n),a=e.state.tr.setSelection(n).replaceSelectionWith(r),o=a.selection.to;if(!i){let t=mk(e);t&&a.insert(o,t)}let s=vk(a,r.nodeSize);return s?(a.setSelection(s).scrollIntoView(),e.dispatch(a),!0):!1},bk=`zt-md-image-upload-file-input`,xk=`zt-md-image-upload-alt-input`,Sk=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;if(typeof e==`string`){t(e);return}n(Error(`Invalid file result`))},r.onerror=()=>{n(r.error??Error(`File read failed`))},r.readAsDataURL(e)}),Ck=e=>e<1024*1024?`${Math.ceil(e/1024)}KB`:`${(e/1024/1024).toFixed(1)}MB`,wk=e=>{try{let t=new URL(e);return!!(t.protocol&&t.host)}catch{return!1}},Tk=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t()},r.onerror=()=>{n(Error(`Image load failed`))},r.src=e}),Ek=e=>e.replace(/\.[^/.]+$/,``),Dk=new nr(`zt-md-image-paste`),Ok=0,kk=e=>(typeof e.props.editable==`function`?e.props.editable(e.state):e.editable)&&!e.state.selection.$from.parent.type.spec.code,Ak=e=>Array.from(e.items).find(e=>e.kind===`file`&&e.type.startsWith(`image/`))?.getAsFile()||(Array.from(e.files).find(e=>e.type.startsWith(`image/`))??null),jk=()=>(Ok+=1,`image-paste-${Ok}`),Mk=(e,t)=>{let n=new Map;t.forEach((t,r)=>{n.set(r,t.map(e.mapping))});let r=e.getMeta(Dk);return r?.type===`add`&&n.set(r.requestId,r.bookmark),r?.type===`remove`&&n.delete(r.requestId),n},Nk=(e,t)=>{e.isDestroyed||!Dk.getState(e.state)?.has(t)||e.dispatch(e.state.tr.setMeta(Dk,{type:`remove`,requestId:t}))},Pk=async(e,t,n)=>{let r=t?.upload?await t.upload(e):await Sk(e);if(!r)throw Error(n.imageUploadFailed);return r},Fk=async(e,t,n,r,i)=>{try{let a=await Pk(t,r,i);if(e.isDestroyed)return;let o=Dk.getState(e.state)?.get(n);if(!o)return;let s=o.resolve(e.state.doc);Nk(e,n),yk(e,{src:a,alt:Ek(t.name),title:``},s)}catch(e){console.error(e)}finally{Nk(e,n)}},Ik=(e,t)=>zg(()=>new $n({key:Dk,state:{init:()=>new Map,apply:Mk},props:{handlePaste:(n,r)=>{if(!kk(n))return!1;let i=r.clipboardData?Ak(r.clipboardData):null;if(!i)return!1;r.preventDefault();let a=e?.maxFileSize??5242880;if(i.size>a)return console.error(Error(t.imageUploadFileSizeExceeded.replace(`{size}`,Ck(a)))),!0;let o=jk(),s=n.state.selection.getBookmark();return n.dispatch(n.state.tr.setMeta(Dk,{type:`add`,requestId:o,bookmark:s})),Fk(n,i,o,e,t),!0}}})),Lk=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Rk=S,zk=(e,t)=>n=>{if(t?.variants==null)return Rk(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Lk(t)||Lk(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Rk(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)};function Bk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Vk(...e){return t=>{let n=!1,r=e.map(e=>{let r=Bk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Bk(e[t],null)}}}}function Hk(...e){return d.useCallback(Vk(...e),e)}function Uk(e){let t=Gk(e),n=d.forwardRef((e,n)=>{let{children:r,...i}=e,a=d.Children.toArray(r),o=a.find(qk);if(o){let e=o.props.children,r=a.map(t=>t===o?d.Children.count(e)>1?d.Children.only(null):d.isValidElement(e)?e.props.children:null:t);return(0,h.jsx)(t,{...i,ref:n,children:d.isValidElement(e)?d.cloneElement(e,void 0,r):null})}return(0,h.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var Wk=Uk(`Slot`);function Gk(e){let t=d.forwardRef((e,t)=>{let{children:n,...r}=e;if(d.isValidElement(n)){let e=Yk(n),i=Jk(r,n.props);return n.type!==d.Fragment&&(i.ref=t?Vk(t,e):e),d.cloneElement(n,i)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Kk=Symbol(`radix.slottable`);function qk(e){return d.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Kk}function Jk(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Yk(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xk=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Uk(`Primitive.${t}`),r=d.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,h.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Zk(e,t){e&&m.flushSync(()=>e.dispatchEvent(t))}function Qk(e,t){let n=d.createContext(t),r=e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,h.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function $k(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,h.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=d.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,eA(i,...t)]}function eA(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function tA(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var nA=globalThis?.document?d.useLayoutEffect:()=>{},rA=d.useInsertionEffect||nA;function iA({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=aA({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=d.useRef(e!==void 0);d.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,d.useCallback(t=>{if(s){let n=oA(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function aA({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return rA(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function oA(e){return typeof e==`function`}function sA(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}var cA=e=>{let{present:t,children:n}=e,r=lA(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=Hk(r.ref,dA(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null};cA.displayName=`Presence`;function lA(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),[o,s]=sA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{let e=uA(r.current);a.current=o===`mounted`?e:`none`},[o]),nA(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=uA(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),nA(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=uA(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=uA(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:d.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function uA(e){return e?.animationName||`none`}function dA(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fA=d.useId||(()=>void 0),pA=0;function mA(e){let[t,n]=d.useState(fA());return nA(()=>{e||n(e=>e??String(pA++))},[e]),e||(t?`radix-${t}`:``)}function hA(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...e)=>t.current?.(...e),[])}function gA(e,t=globalThis?.document){let n=hA(e);d.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var _A=`DismissableLayer`,vA=`dismissableLayer.update`,yA=`dismissableLayer.pointerDownOutside`,bA=`dismissableLayer.focusOutside`,xA,SA=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),CA=d.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=d.useContext(SA),[u,f]=d.useState(null),p=u?.ownerDocument??globalThis?.document,[,m]=d.useState({}),g=Hk(t,e=>f(e)),_=Array.from(l.layers),[v]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=_.indexOf(v),b=u?_.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=EA(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!S||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},p),w=DA(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},p);return gA(e=>{b===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},p),d.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(xA=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),OA(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=xA)}},[u,p,n,l]),d.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),OA())},[u,l]),d.useEffect(()=>{let e=()=>m({});return document.addEventListener(vA,e),()=>document.removeEventListener(vA,e)},[]),(0,h.jsx)(Xk.div,{...c,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:tA(e.onFocusCapture,w.onFocusCapture),onBlurCapture:tA(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:tA(e.onPointerDownCapture,C.onPointerDownCapture)})});CA.displayName=_A;var wA=`DismissableLayerBranch`,TA=d.forwardRef((e,t)=>{let n=d.useContext(SA),r=d.useRef(null),i=Hk(t,r);return d.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,h.jsx)(Xk.div,{...e,ref:i})});TA.displayName=wA;function EA(e,t=globalThis?.document){let n=hA(e),r=d.useRef(!1),i=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){kA(yA,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function DA(e,t=globalThis?.document){let n=hA(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&kA(bA,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function OA(){let e=new CustomEvent(vA);document.dispatchEvent(e)}function kA(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Zk(i,a):i.dispatchEvent(a)}var AA=`focusScope.autoFocusOnMount`,jA=`focusScope.autoFocusOnUnmount`,MA={bubbles:!1,cancelable:!0},NA=`FocusScope`,PA=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=d.useState(null),l=hA(i),u=hA(a),f=d.useRef(null),p=Hk(t,e=>c(e)),m=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let e=function(e){if(m.paused||!s)return;let t=e.target;s.contains(t)?f.current=t:VA(f.current,{select:!0})},t=function(e){if(m.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||VA(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&VA(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,m.paused]),d.useEffect(()=>{if(s){HA.add(m);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(AA,MA);s.addEventListener(AA,l),s.dispatchEvent(t),t.defaultPrevented||(FA(GA(LA(s)),{select:!0}),document.activeElement===e&&VA(s))}return()=>{s.removeEventListener(AA,l),setTimeout(()=>{let t=new CustomEvent(jA,MA);s.addEventListener(jA,u),s.dispatchEvent(t),t.defaultPrevented||VA(e??document.body,{select:!0}),s.removeEventListener(jA,u),HA.remove(m)},0)}}},[s,l,u,m]);let g=d.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=IA(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&VA(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&VA(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,h.jsx)(Xk.div,{tabIndex:-1,...o,ref:p,onKeyDown:g})});PA.displayName=NA;function FA(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(VA(r,{select:t}),document.activeElement!==n)return}function IA(e){let t=LA(e);return[RA(t,e),RA(t.reverse(),e)]}function LA(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function RA(e,t){for(let n of e)if(!zA(n,{upTo:t}))return n}function zA(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function BA(e){return e instanceof HTMLInputElement&&`select`in e}function VA(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&BA(e)&&t&&e.select()}}var HA=UA();function UA(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=WA(e,t),e.unshift(t)},remove(t){e=WA(e,t),e[0]?.resume()}}}function WA(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function GA(e){return e.filter(e=>e.tagName!==`A`)}var KA=`Portal`,qA=d.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=d.useState(!1);nA(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?m.default.createPortal((0,h.jsx)(Xk.div,{...r,ref:t}),o):null});qA.displayName=KA;var JA=0;function YA(){d.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??XA()),document.body.insertAdjacentElement(`beforeend`,e[1]??XA()),JA++,()=>{JA===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),JA--}},[])}function XA(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var ZA=function(){return ZA=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ZA.apply(this,arguments)};function QA(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function $A(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ej=`right-scroll-bar-position`,tj=`width-before-scroll-bar`,nj=`with-scroll-bars-hidden`,rj=`--removed-body-scroll-bar-size`;function ij(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function aj(e,t){var n=(0,u.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var oj=typeof window<`u`?u.useLayoutEffect:u.useEffect,sj=new WeakMap;function cj(e,t){var n=aj(t||null,function(t){return e.forEach(function(e){return ij(e,t)})});return oj(function(){var t=sj.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ij(e,null)}),i.forEach(function(e){r.has(e)||ij(e,a)})}sj.set(n,e)},[e]),n}function lj(e){return e}function uj(e,t){t===void 0&&(t=lj);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function dj(e){e===void 0&&(e={});var t=uj(null);return t.options=ZA({async:!0,ssr:!1},e),t}var fj=function(e){var t=e.sideCar,n=QA(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return u.createElement(r,ZA({},n))};fj.isSideCarExport=!0;function pj(e,t){return e.useMedium(t),fj}var mj=dj(),hj=function(){},gj=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:hj,onWheelCapture:hj,onTouchMoveCapture:hj}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=QA(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=cj([n,t]),w=ZA(ZA({},x),i);return u.createElement(u.Fragment,null,d&&u.createElement(S,{sideCar:mj,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?u.cloneElement(u.Children.only(s),ZA(ZA({},w),{ref:C})):u.createElement(y,ZA({},w,{className:c,ref:C}),s))});gj.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gj.classNames={fullWidth:tj,zeroRight:ej};var _j,vj=function(){if(_j)return _j;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function yj(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=vj();return t&&e.setAttribute(`nonce`,t),e}function bj(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xj(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Sj=function(){var e=0,t=null;return{add:function(n){e==0&&(t=yj())&&(bj(t,n),xj(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cj=function(){var e=Sj();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wj=function(){var e=Cj();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Tj={left:0,top:0,right:0,gap:0},Ej=function(e){return parseInt(e||``,10)||0},Dj=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ej(n),Ej(r),Ej(i)]},Oj=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Tj;var t=Dj(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},kj=wj(),Aj=`data-scroll-locked`,jj=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
54
54
  .${nj} {
55
55
  overflow: hidden ${r};
56
56
  padding-right: ${s}px ${r};
@@ -376,4 +376,4 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
376
376
  `,`
377
377
  `)},DJ=e=>{let t=EJ(e),n=t.lastIndexOf(`/`);if(n<0)return null;let r=t.slice(n+1);return/\s/.test(r)?null:r},OJ=(e,t)=>{if(t===null||t.length===0)return e;let n=t.toLowerCase();return e.filter(e=>[e.label,e.group,e.command,e.id].some(e=>String(e).toLowerCase().startsWith(n)))},kJ=(e,t)=>{if(!xJ(e))return{visibleItems:[],shouldShow:!1};let n=DJ(e),r=OJ(t,n);return{visibleItems:r,shouldShow:!TJ(e)&&n!==null&&r.length>0}},AJ=e=>{let t=e?.state,n=t?.selection?.$from;if(!t||!n||!e?.dispatch)return!1;let r=n.start(),i=n.pos,a=t.doc.textBetween(r,i,`
378
378
  `,`
379
- `).lastIndexOf(`/`);if(a<0)return!1;let o=r+a,s=t.tr.delete(o,i);return e.dispatch(s.scrollIntoView()),!0},jJ={Type:_D,Heading1:WE,Heading2:GE,Heading3:KE,Heading4:qE,Heading5:YE,Heading6:JE,Image:QE,List:iD,ListOrdered:nD,ListTodo:rD,Code:BE,SquareFunction:lD,SquareCode:cD,TextQuote:hD,Sigma:sD,Table:dD},MJ=RE,NJ=(e,t,n,r)=>{r.splice(0).forEach(e=>{e.unmount()}),e.innerHTML=``;let i=``;t.forEach((t,a)=>{if(t.group!==i){let n=document.createElement(`div`);n.className=`slash-menu-group`,n.textContent=t.group,e.appendChild(n),i=t.group}let o=document.createElement(`div`);o.className=`slash-menu-item`,o.dataset.command=t.command,o.dataset.selected=a===n?`true`:`false`;let s=document.createElement(`span`);s.className=`slash-menu-item-icon`;let c=t.icon?jJ[t.icon]??MJ:null;if(c){let e=(0,p.createRoot)(s);e.render((0,d.createElement)(c,{size:16,strokeWidth:2})),r.push(e)}let l=document.createElement(`span`);l.className=`slash-menu-item-label`,l.textContent=t.label,o.appendChild(s),o.appendChild(l),e.appendChild(o)})},PJ=e=>{let t=document.createElement(`div`);t.className=`slash-menu`,t.style.display=`none`,e.appendChild(t);let n=!1,r=``,i=!1,a=null,o=[],s=()=>{if(!n||!a)return;let{editorWrapper:r,anchorTopInContent:i,anchorBottomInContent:o,anchorLeftInContent:s,placement:c,offsetY:l}=a,u=nq({wrapper:r,anchor:{anchorTopInContent:i,anchorBottomInContent:o,anchorLeftInContent:s},overlaySize:{width:t.offsetWidth||210},placement:c,offsetY:l,boundaryInset:4},e);t.style.left=`${u.left}px`,t.style.top=`${u.top}px`,t.dataset.placement=c},c=rq(()=>{n&&s()}),l=()=>{t.style.top=``,t.style.left=``,t.style.transform=``,delete t.dataset.placement};return{menu:t,isVisible:()=>n,setVisible:(e,a)=>{if(n!==e){if(n=e,t.style.display=e?`block`:`none`,!e){c.unbindGlobal(),c.bindWrapper(null),l(),r=``,i=!0;return}c.bindGlobal(),a&&(a(),i&&=(a(),!1))}},renderIfNeeded:(e,n)=>{let i=`${e.map(e=>e.command).join(`|`)}::${n}`;r!==i&&(NJ(t,e,n,o),r=i)},scrollActiveItemIntoView:e=>{let n=t.querySelector(`.slash-menu-item[data-selected="true"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),e&&e())},updatePositionContext:e=>{a=e,c.bindWrapper(e?.editorWrapper??null)},updatePosition:s,destroy:()=>{o.splice(0).forEach(e=>{e.unmount()}),c.destroy(),t.remove()}}};function FJ(e){let t=Vg({},`${e}_SLASH_SPEC`),n=zg(n=>{let r=n.get(t.key);return new $n({key:new nr(`${e}_SLASH`),...r})}),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:`@milkdown/plugin-slash`,displayName:`Ctx<slashSpec>|${e}`},n.meta={package:`@milkdown/plugin-slash`,displayName:`Prose<slash>|${e}`},r}var IJ=(e,t)=>{if(!(!e||typeof e!=`object`))return e[t]},LJ=()=>{if(typeof FJ!=`function`)return console.error(`[zt-md/slash] slashFactory not found`),null;let e=FJ(`zt-md-slash`),t=Array.isArray(e)?e[0]:void 0,n=Array.isArray(e)?e[1]:e,r=Array.isArray(e)?e[2]:void 0;if(!n)return null;let i=Array.isArray(e)?e.filter((e,t)=>t<2&&e!=null):[n],a=IJ(t,`key`)??IJ(n,`key`)??IJ(r,`key`)??IJ(e,`key`);return i.length===0||a===void 0?null:{plugins:i,key:a}},RJ=(e,t,n,r,i=`zh-CN`)=>{if(t?.enabled===!1)return{plugins:[],config:null};try{let a=LJ();if(!a)return{plugins:[],config:null};let o=wJ(t,i),s=PJ(e),c=0,l=null,u=o,d=!1,f=new Set([`ArrowDown`,`ArrowUp`,`Enter`,`Escape`]),p=e=>!f.has(e.key)||!d?!1:e.key===`ArrowDown`?(e.preventDefault(),u.length===0?!0:(c=(c+1)%u.length,s.renderIfNeeded(u,c),s.scrollActiveItemIntoView(()=>{s.updatePosition()}),!0)):e.key===`ArrowUp`?(e.preventDefault(),u.length===0?!0:(c=(c-1+u.length)%u.length,s.renderIfNeeded(u,c),s.scrollActiveItemIntoView(()=>{s.updatePosition()}),!0)):e.key===`Enter`?(e.preventDefault(),g(),!0):e.key===`Escape`?(e.preventDefault(),s.setVisible(!1),!0):!1,m=e=>{let t=e?.state?.selection?.from;if(typeof t!=`number`)return null;let n=e?.coordsAtPos?.(t);return n?new DOMRect(n.left,n.top,Math.max(n.right-n.left,1),n.bottom-n.top):null},h=e=>{if(!xJ(e)){u=[],d=!1,s.updatePositionContext(null),s.setVisible(!1);return}let t=kJ(e,o);if(u=t.visibleItems,d=t.shouldShow,t.shouldShow&&c>=u.length&&(c=0),t.shouldShow&&!s.isVisible()&&(c=0),!t.shouldShow){s.updatePositionContext(null),s.setVisible(!1);return}let n=m(e),r=ZK(e?.dom);if(n&&r){let e=QK(n,320),t=$K(n,r);s.updatePositionContext({editorWrapper:r,anchorTopInContent:t.anchorTopInContent,anchorBottomInContent:t.anchorBottomInContent,anchorLeftInContent:t.anchorLeftInContent,placement:e,offsetY:8})}s.renderIfNeeded(u,c),s.isVisible()?s.updatePosition():s.setVisible(!0,()=>{s.updatePosition()})},g=async()=>{if(!xJ(l)){d=!1,s.updatePositionContext(null),s.setVisible(!1);return}if(!l||c<0||c>=u.length)return;let t=u[c];if(AJ(l)){if(t.command===`image`){s.setVisible(!1),n&&jI({portalContainer:e,view:l,messages:n,imageUpload:r});return}await bJ(l,t.command)&&(s.setVisible(!1),t.command===`mathBlock`&&queueMicrotask(()=>{let e=l?.dom?.querySelector?.(`.zt-md-math-block-editing .zt-md-math-block-textarea`);!e||document.activeElement===e||e.focus()}))}};return s.menu.addEventListener(`mousedown`,e=>{e.preventDefault();let t=(e.target?.closest(`.slash-menu-item`))?.dataset.command??``;if(!t)return;let n=u.findIndex(e=>e.command===t);n<0||(c=n,g())}),{plugins:a.plugins,config:e=>{e.set(a.key,{props:{handleKeyDown:(e,t)=>p(t)},view:()=>({update:e=>{l=e,h(e)},destroy:()=>{d=!1,s.destroy()}})})}}}catch(e){return console.error(`[zt-md/slash] init failed`,e),{plugins:[],config:null}}},zJ=`table`,BJ=`ArrowUp`,VJ=e=>e.key!==BJ||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey,HJ=(e,t)=>{let n=t.nodeBefore;return!n||n.type.name!==zJ?null:{tableNode:n,tableStart:e-n.nodeSize}},UJ=e=>{if(e.parent.type.name!==`paragraph`||e.parentOffset!==0||e.parent.childCount>0||e.depth<1)return null;let t=e.index(e.depth-1);if(t<=0)return null;let n=e.node(e.depth-1).child(t-1);return n.type.name===zJ?{tableNode:n,tableStart:e.before(e.depth)-n.nodeSize}:null},WJ=(e,t)=>{if(e.childCount===0)return null;let n=e.childCount-1,r=e.child(n);if(r.childCount===0)return null;let i=0;for(let t=0;t<n;t+=1)i+=e.child(t).nodeSize;let a=r.childCount-1,o=r.child(a),s=0;for(let e=0;e<a;e+=1)s+=r.child(e).nodeSize;return t+1+i+1+s+o.nodeSize-1},GJ=e=>{let{selection:t}=e.state,n=t.$from,r=null;if(t instanceof XT?r=HJ(t.from,n):t.empty&&(r=UJ(n)),!r)return!1;let i=WJ(r.tableNode,r.tableStart);if(i===null)return!1;let a=e.state.tr.setSelection(j.near(e.state.doc.resolve(i),-1)).scrollIntoView();return e.dispatch(a),e.focus(),!0},KJ=zg(()=>new $n({key:new nr(`zt-md-table-arrow-entry`),props:{handleKeyDown:(e,t)=>VJ(t)?!1:GJ(e)}})),qJ=`table`,JJ=`table_header_row`,YJ=`table_row`,XJ=`table_header`,ZJ=`table_cell`,QJ=e=>{let t=e.selection.$from,n=-1,r=-1;for(let e=t.depth;e>=0;--e){let i=t.node(e);if(r<0&&(i.type.name===ZJ||i.type.name===XJ)&&(r=t.index(e-1)),n<0&&(i.type.name===YJ||i.type.name===JJ)&&(n=t.index(e-1)),i.type.name===qJ)return{tableNode:i,tableStart:e===0?0:t.before(e),tableNodeSize:i.nodeSize,rowIndex:n,columnIndex:r}}return null},$J=(e,t,n,r)=>{if(n<0||n>=e.childCount)return null;let i=0;for(let t=0;t<n;t+=1)i+=e.child(t).nodeSize;let a=e.child(n);if(r<0||r>=a.childCount)return null;let o=0;for(let e=0;e<r;e+=1)o+=a.child(e).nodeSize;return t+1+i+1+o+1+1},eY=e=>{if(e.columnIndex<0||e.tableNode.childCount===0)return!1;let t=e.tableNode.child(0);return e.columnIndex<t.childCount},tY=(e,t,n,r)=>{let i=$J(t.tableNode,t.tableStart,n,r);if(i===null)return!1;let a=e.state.tr.setSelection(j.near(e.state.tr.doc.resolve(i),1));return e.dispatch(a),!0},nY=(e,t)=>t(e.state,e.dispatch,e)?(e.dispatch(e.state.tr.scrollIntoView()),e.focus(),!0):!1,rY=(e,t,n)=>t.rowIndex<0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,n===`above`?Dx:Ox),iY=(e,t)=>t.rowIndex<=0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,Ax),aY=(e,t,n)=>t.rowIndex<0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,n===`left`?xx:Sx),oY=(e,t)=>t.rowIndex<0||t.columnIndex<0||(t.tableNode.childCount>0?t.tableNode.child(0).childCount:0)<=1||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,wx),sY=(e,t,n)=>{if(t.columnIndex<0)return!1;let r=Db.get(t.tableNode),i=t.tableStart+1,a=t.columnIndex,o=e.state.tr;for(let e=0;e<r.height;e+=1){let t=e*r.width+a,s=r.map[t];if(typeof s!=`number`)continue;let c=i+s,l=o.doc.nodeAt(c);if(!l)continue;let u={...l.attrs,alignment:n};o.setNodeMarkup(c,l.type,u,l.marks)}return o.docChanged?(o.scrollIntoView(),e.dispatch(o),e.focus(),!0):!1},cY=e=>{let t=QJ(e.state);!t||t.rowIndex<=0||iY(e,t)},lY=e=>{let t=QJ(e.state);!t||t.rowIndex<0||t.columnIndex<0||oY(e,t)},uY=e=>{let[t,n]=(0,d.useState)(!1),r=aq({open:t,portalContainer:e.portalContainer,editorWrapper:e.collisionBoundary,horizontalAlign:`end`,offsetY:6,fallbackWidth:168,fallbackHeight:240,onOutside:()=>n(!1)}),i=e=>{e.preventDefault()},a=e=>{n(e)};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(`button`,{ref:r.triggerRef,type:`button`,className:`zt-md-table-action-button`,"aria-label":e.messages.tableMoreAriaLabel,"aria-expanded":t,onMouseDown:i,onClick:()=>{if(t){n(!1);return}r.updatePosition(),a(!0)}},(0,d.createElement)(HE,{size:14,strokeWidth:2,"aria-hidden":`true`})),(0,d.createElement)(oq,{panel:r,portalContainer:e.portalContainer,className:`zt-md-table-action-popover`,onMouseDown:i},(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-group`},(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertRowAbove,onMouseDown:i,onClick:()=>{e.onInsertRowAbove(),n(!1)}},e.messages.tableInsertRowAboveLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,onMouseDown:i,onClick:()=>{e.onInsertRowBelow(),n(!1)}},e.messages.tableInsertRowBelowLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertColumn,onMouseDown:i,onClick:()=>{e.onInsertColumnLeft(),n(!1)}},e.messages.tableInsertColumnLeftLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertColumn,onMouseDown:i,onClick:()=>{e.onInsertColumnRight(),n(!1)}},e.messages.tableInsertColumnRightLabel)),(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-divider`,"aria-hidden":`true`}),(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-group`},(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item zt-md-table-action-menu-item-danger disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canDeleteRow,onMouseDown:i,onClick:()=>{e.onDeleteRow(),n(!1)}},e.messages.tableDeleteRowLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item zt-md-table-action-menu-item-danger disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canDeleteColumn,onMouseDown:i,onClick:()=>{e.onDeleteColumn(),n(!1)}},e.messages.tableDeleteColumnLabel))))},dY=`zt-md-table-focus-actions`,fY=0,pY=24,mY=4,hY=4,gY=`top`,_Y=`left`,vY=e=>(0,f.renderToStaticMarkup)((0,d.createElement)(e,{size:14,strokeWidth:2,"aria-hidden":`true`})),yY=vY(gD),bY=vY(mD),xY=vY(pD),SY=vY(fD),CY=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,wY=class{constructor(e,t,n){this.currentTableStart=null,this.currentTableNodeSize=null,this.currentColumnIndex=null,this.currentColumnAlignment=_Y,this.currentTableElement=null,this.hasPositionContext=!1,this.repositionScheduler=rq(()=>{this.hasPositionContext&&this.updateOverlayPosition()}),this.handleActionsMouseDown=e=>{e.preventDefault()},this.handleDeleteClick=e=>{if(e.preventDefault(),this.currentTableStart===null||this.currentTableNodeSize===null)return;let t=this.currentTableStart,n=this.currentTableStart+this.currentTableNodeSize,r=this.view.state.tr.delete(t,n).scrollIntoView();this.view.dispatch(r),this.view.focus()},this.handleAlignLeftClick=()=>{this.applyColumnAlignment(`left`)},this.handleAlignCenterClick=()=>{this.applyColumnAlignment(`center`)},this.handleAlignRightClick=()=>{this.applyColumnAlignment(`right`)},this.handleInsertRowBelow=()=>{let e=QJ(this.view.state);!e||e.rowIndex<0||rY(this.view,e,`below`)},this.handleInsertRowAbove=()=>{let e=QJ(this.view.state);!e||e.rowIndex<=0||rY(this.view,e,`above`)},this.handleInsertColumnLeft=()=>{this.insertColumn(`left`)},this.handleInsertColumnRight=()=>{this.insertColumn(`right`)},this.handleDeleteRow=()=>{cY(this.view)},this.handleDeleteColumn=()=>{lY(this.view)},this.view=e,this.messages=t,this.portalContainer=n,this.editorWrapper=ZK(e.dom),this.actionsContainer=document.createElement(`div`),this.actionsContainer.className=`zt-md-table-actions-overlay`,this.deleteButton=document.createElement(`button`),this.deleteButton.type=`button`,this.deleteButton.className=`zt-md-table-action-button zt-md-table-action-button-danger`,this.deleteButton.style.display=`inline-flex`,this.deleteButton.setAttribute(`aria-label`,t.tableDeleteAriaLabel),this.deleteButton.innerHTML=yY,this.alignLeftButton=this.createColumnAlignmentButton(t.tableAlignLeftAriaLabel,bY),this.alignCenterButton=this.createColumnAlignmentButton(t.tableAlignCenterAriaLabel,xY),this.alignRightButton=this.createColumnAlignmentButton(t.tableAlignRightAriaLabel,SY),this.moreActionsMount=document.createElement(`span`),this.moreActionsMount.className=`zt-md-table-more-actions-mount`,this.moreActionsRoot=(0,p.createRoot)(this.moreActionsMount),this.actionsContainer.append(this.moreActionsMount,this.alignLeftButton,this.alignCenterButton,this.alignRightButton,this.deleteButton),this.actionsContainer.addEventListener(`mousedown`,this.handleActionsMouseDown),this.deleteButton.addEventListener(`click`,this.handleDeleteClick),this.alignLeftButton.addEventListener(`click`,this.handleAlignLeftClick),this.alignCenterButton.addEventListener(`click`,this.handleAlignCenterClick),this.alignRightButton.addEventListener(`click`,this.handleAlignRightClick),this.repositionScheduler.bindGlobal(),this.repositionScheduler.bindWrapper(this.editorWrapper),this.update(e)}createColumnAlignmentButton(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`zt-md-table-action-button`,n.style.display=`inline-flex`,n.setAttribute(`aria-label`,e),n.innerHTML=t,n}resolveColumnAlignment(e){return e===`center`||e===`right`?e:_Y}updateAlignmentButtonsState(e){this.alignLeftButton.disabled=!e,this.alignCenterButton.disabled=!e,this.alignRightButton.disabled=!e,this.alignLeftButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`left`),this.alignCenterButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`center`),this.alignRightButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`right`)}applyColumnAlignment(e){let t=QJ(this.view.state);!t||t.rowIndex<0||t.columnIndex<0||sY(this.view,t,e)}insertColumn(e){let t=QJ(this.view.state);!t||t.rowIndex<0||t.columnIndex<0||aY(this.view,t,e)}renderMoreActions(e,t,n,r){this.moreActionsRoot.render((0,d.createElement)(uY,{messages:this.messages,portalContainer:this.portalContainer,collisionBoundary:this.editorWrapper,canInsertRowAbove:e,canInsertColumn:t,canDeleteRow:n,canDeleteColumn:r,onInsertRowAbove:this.handleInsertRowAbove,onInsertRowBelow:this.handleInsertRowBelow,onInsertColumnLeft:this.handleInsertColumnLeft,onInsertColumnRight:this.handleInsertColumnRight,onDeleteRow:this.handleDeleteRow,onDeleteColumn:this.handleDeleteColumn}))}resolveTableElement(e){if(e instanceof HTMLTableElement)return e;let t=e.querySelector(`table`);return t instanceof HTMLTableElement?t:null}resolveTableAnchor(e,t){if(!this.editorWrapper)return null;let n=e.getBoundingClientRect(),r=$K(n,this.editorWrapper),i=n.width,a=r.anchorLeftInContent+i-t-fY,o=r.anchorTopInContent-pY+mY;return{anchorLeftInContent:a,anchorTopInContent:o,anchorBottomInContent:o}}resolveActionsContainerWidth(){let e=this.actionsContainer.getBoundingClientRect().width;return e<=0?null:e}updateOverlayPosition(){if(!this.editorWrapper||!this.currentTableElement||this.actionsContainer.parentElement!==this.portalContainer)return;let e=this.resolveActionsContainerWidth();if(e===null)return;let t=this.resolveTableAnchor(this.currentTableElement,e);if(!t)return;let n=nq({wrapper:this.editorWrapper,anchor:t,overlaySize:{width:e},placement:gY,offsetY:0,boundaryInset:hY},this.portalContainer);this.actionsContainer.style.left=`${n.left}px`,this.actionsContainer.style.top=`${n.top}px`}update(e){if(this.view=e,!this.editorWrapper||!CY(e)){this.detach();return}let t=QJ(e.state);if(!t){this.detach();return}let n=e.nodeDOM(t.tableStart);if(!(n instanceof HTMLElement)){this.detach();return}let r=this.resolveTableElement(n);if(!r){this.detach();return}this.actionsContainer.parentElement!==this.portalContainer&&this.portalContainer.append(this.actionsContainer);let i=eY(t),a=i&&t.tableNode.child(0).childCount>1,o=t.rowIndex>0,s=t.rowIndex>0,c=t.tableNode.childCount>0?t.tableNode.child(0):null;this.currentColumnIndex=i?t.columnIndex:null,this.currentColumnAlignment=this.resolveColumnAlignment(this.currentColumnIndex===null?null:c?.maybeChild(this.currentColumnIndex)?.attrs?.alignment),this.updateAlignmentButtonsState(i),this.renderMoreActions(o,i,s,a),this.currentTableElement=r,this.currentTableStart=t.tableStart,this.currentTableNodeSize=t.tableNodeSize,this.hasPositionContext=!0,this.updateOverlayPosition(),this.repositionScheduler.schedule()}detach(){this.moreActionsRoot.render(null),this.actionsContainer.remove(),this.currentTableElement=null,this.currentTableStart=null,this.currentTableNodeSize=null,this.currentColumnIndex=null,this.currentColumnAlignment=_Y,this.updateAlignmentButtonsState(!1),this.hasPositionContext=!1}destroy(){this.detach(),this.repositionScheduler.destroy(),this.moreActionsRoot.unmount(),this.actionsContainer.removeEventListener(`mousedown`,this.handleActionsMouseDown),this.deleteButton.removeEventListener(`click`,this.handleDeleteClick),this.alignLeftButton.removeEventListener(`click`,this.handleAlignLeftClick),this.alignCenterButton.removeEventListener(`click`,this.handleAlignCenterClick),this.alignRightButton.removeEventListener(`click`,this.handleAlignRightClick)}},TY=(e,t)=>{let n=SO(void 0,t);return zg(()=>new $n({key:new nr(dY),view:t=>new wY(t,n,e)}))},EY=`list_item`,DY=`li[data-item-type="task"]`,OY=24,kY=(e,t)=>{let n=t.getBoundingClientRect();return e.clientX>=n.left&&e.clientX<=n.left+OY&&e.clientY>=n.top&&e.clientY<=n.top+OY},AY=e=>{if(!(e instanceof Element))return null;let t=e.closest(DY);return t instanceof HTMLElement?t:null},jY=(e,t)=>{if(!e.editable)return!1;let n=AY(t.target);return!n||!kY(t,n)?!1:(t.preventDefault(),!0)},MY=(e,t)=>{let n=e.posAtDOM(t,0)-1,r=e.state.doc.nodeAt(n);return!r||r.type.name!==EY||r.attrs.checked==null?!1:(e.dispatch(e.state.tr.setNodeMarkup(n,void 0,{...r.attrs,checked:!r.attrs.checked})),!0)},NY=zg(()=>new $n({props:{handleDOMEvents:{mousedown:(e,t)=>jY(e,t),dblclick:(e,t)=>jY(e,t),click:(e,t)=>{if(!e.editable)return!1;let n=AY(t.target);return!n||!kY(t,n)||!MY(e,n)?!1:(t.preventDefault(),!0)}}}})),PY=`Tab`,FY=4,IY=/^ */,LY=`list_item`,RY=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,zY=e=>{let{$from:t}=e.selection;for(let e=t.depth;e>=0;--e){let n=t.node(e);if(n.type.name===LY)return n.type}return null},BY=e=>{let{selection:t,doc:n}=e;if(t.empty)return[t.$from.start()];let r=new Set;return n.nodesBetween(t.from,t.to,(e,t)=>{e.isTextblock&&r.add(t+1)}),Array.from(r)},VY=(e,t)=>{let{state:n}=e,r=` `.repeat(FY),i=BY(n).sort((e,t)=>t-e),a=n.tr;return n.selection.empty?a.insertText(r,n.selection.to):i.forEach(e=>{a.insertText(r,e)}),a.docChanged?(t.preventDefault(),e.dispatch(a),!0):!1},HY=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!(r instanceof j))return!1;let i=BY(n).sort((e,t)=>t-e),a=n.tr;return i.forEach(e=>{let t=n.doc.resolve(e).parent.textContent.match(IY)?.[0].length??0,r=Math.min(t,FY);r<=0||a.delete(e,e+r)}),a.docChanged?(t.preventDefault(),e.dispatch(a),!0):!1},UY=zg(()=>new $n({key:new nr(`zt-md-tab-space-indent`),props:{handleKeyDown:(e,t)=>{let n=e;if(!RY(n)||t.defaultPrevented||t.key!==PY||t.altKey||t.ctrlKey||t.metaKey)return!1;let r=zY(n.state);if(r){let e=(t.shiftKey?wv(r):Dv(r))(n.state,n.dispatch);return t.preventDefault(),e||!0}return t.shiftKey?HY(n,t):VY(n,t)}}})),WY=e=>{let t=e.target;if(!(t instanceof Element))return null;let n=t.closest(`a[href]`);return n instanceof HTMLAnchorElement?n:null},GY=e=>e?.type.name===`image`,KY=(e,t)=>{let n=WY(e);if(!n)return!1;let r=AO(n.getAttribute(`href`));return!r||t||!e.ctrlKey?!1:(e.preventDefault(),e.stopPropagation(),window.open(r,`_blank`,`noopener,noreferrer`),!0)},qY=(e,t)=>!t||!WY(e)?!1:(e.preventDefault(),e.stopPropagation(),!0),JY=e=>{let t=e.messages??SO(),n=TY(e.contentPortalContainer,t),r=uJ(e.contentPortalContainer,t),i=Sq(t,e.contentPortalContainer),a=dU(t,e.contentPortalContainer),o=Ik(e.imageUpload,t),s=RJ(e.portalContainer,e.slashMenu,t,e.imageUpload,e.locale),c=s.plugins,l={listener:yv,commonmark:wb,gfm:VT,history:k_,codeBlockPrism:Fq,codeBlockLanguagePicker:i,clipboard:Qg,indent:N_,imageDeleteSelection:pk,imagePaste:o,tableArrowEntry:KJ,blockBoundaryNavigation:CE,headingBackspaceEmptyParagraph:gW,mathBackspaceEntry:LI,blockquoteBackspaceLift:cW,tableFocusActions:n,selectionTooltip:r,gapCursor:sE,dropCursor:YT,math:tW,mathInlineEdit:a,mathInlineArrowNavigation:NU,taskListToggle:NY,tabSpaceIndent:UY,codeBlockModASelect:kq,slash:c.length>0?c:null},u=WT(l,{includeRuntime:!1}),d=WT(l,{includeRuntime:!0}).filter(e=>e.name===`clipboard`||e.name===`indent`),f=jg.make();f.config(n=>{SW(n),UO(n,e.imageUpload?.allowedProtocols),n.set(Cg,e.root),n.set(lg,e.markdown),n.set(Sg,{editable:()=>!e.readOnly,handleDOMEvents:{mousedown:(t,n)=>n instanceof MouseEvent?qY(n,e.readOnly):!1,click:(t,n)=>n instanceof MouseEvent?qY(n,e.readOnly):!1},handleClick:(t,n,r)=>KY(r,e.readOnly),handleClickOn:(t,n,r,i,a,o)=>KY(a,e.readOnly)?!0:e.readOnly&&o&&GY(r)?(a.preventDefault(),!0):!1});let r=n.get(Eh)??[];n.set(Eh,[...r,[`image`,ek(t)],[`math_block`,rU(t)],[`math_inline`,_U(t)],[`code_block`,zW(t)]]),n.get(_v).markdownUpdated((t,n)=>{e.onChange(n)}),s.config&&s.config(n)}),u.forEach(e=>{f.use(e.plugin)});let p=()=>{d.forEach(e=>{try{f.use(e.plugin),e.name===`indent`&&f.action(e=>{e.set(j_,{type:`space`,size:4})})}catch(e){console.error(e)}})},m=HT(Jg,f);return{editor:f,installRuntimePlugins:p,focusEditor:e=>{f.action(t=>{let n=t.get(yh);if(e!==void 0&&e.top>n.dom.getBoundingClientRect().bottom){let e=n.state.schema.nodes.paragraph,t=n.state.doc.lastChild;if(!(t?.type===e&&t.content.size===0)){let t=n.state.tr.insert(n.state.doc.content.size,e.create());t.setSelection(j.atEnd(t.doc)).scrollIntoView(),n.dispatch(t),n.focus();return}}let r=e?n.posAtCoords(e):null,i=r?j.near(n.state.doc.resolve(r.pos),1):j.atEnd(n.state.doc);n.state.selection.eq(i)||n.dispatch(n.state.tr.setSelection(i).scrollIntoView()),n.focus()})},setMarkdown:e=>{m(e)}}},YY=(e,t,n,r)=>{let i=e,a=i.create.bind(e);return i.create=async()=>{try{let e=await a();return t(),n(),e}catch(e){throw console.error(`Milkdown init failed:`,e),r(e),e}},i},XY=e=>{let t=(0,d.useRef)(null),n=(0,d.useRef)(e.markdown),r=(0,d.useRef)(e.onMarkdownChange),i=(0,d.useRef)(e.onInitError),a=(0,d.useRef)(e.onInitReady),o=(0,d.useRef)(null),s=b(r=>{t.current=null,e.focusEditorRef&&(e.focusEditorRef.current=null),n.current=e.markdown;let s=JY({root:r,portalContainer:e.portalContainer,contentPortalContainer:e.contentPortalContainer,markdown:e.markdown,readOnly:e.readOnly,messages:e.messages,locale:e.locale,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onChange:e=>{n.current=e,o.current?.(e)}});return YY(s.editor,s.installRuntimePlugins,()=>{t.current=s,e.focusEditorRef&&(e.focusEditorRef.current=s.focusEditor),a.current?.()},e=>{i.current?.(e)})},[e.portalContainer,e.contentPortalContainer,e.readOnly,e.locale,e.focusEditorRef]);(0,d.useEffect)(()=>{r.current=e.onMarkdownChange},[e.onMarkdownChange]),(0,d.useEffect)(()=>{i.current=e.onInitError},[e.onInitError]),(0,d.useEffect)(()=>{a.current=e.onInitReady},[e.onInitReady]),(0,d.useEffect)(()=>(o.current&&o.current.cancel(),o.current=T(e=>{r.current(e)},e.debounceMs),()=>{o.current?.cancel(),o.current=null}),[e.debounceMs]),(0,d.useEffect)(()=>()=>{t.current=null,e.focusEditorRef&&(e.focusEditorRef.current=null)},[e.portalContainer,e.contentPortalContainer,e.readOnly,e.locale,e.focusEditorRef]),(0,d.useEffect)(()=>{let r=t.current;!r||s.loading||e.markdown!==n.current&&(n.current=e.markdown,r.setMarkdown(e.markdown))},[s.loading,e.markdown])},ZY=160,QY={"zh-CN":`只读`,"en-US":`Read only`},$Y=e=>e.length===0?`""`:`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\r\n|\r|\n/g,`\\A `)}"`,eX=e=>(XY({markdown:e.markdown,portalContainer:e.portalContainer,contentPortalContainer:e.contentPortalContainer,focusEditorRef:e.focusEditorRef,readOnly:e.readOnly,debounceMs:e.debounceMs,messages:e.messages,locale:e.locale,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onMarkdownChange:e.onMarkdownChange,onInitReady:e.onInitReady,onInitError:e.onInitError}),(0,h.jsx)(v,{})),tX=e=>{let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),c=e.theme??`light`,l=e.readOnly??!1,u=QY[e.locale??`zh-CN`],f=e.debounceMs??ZY,{markdown:p,setMarkdown:m}=w(e.value,e.defaultValue,e.onChange),g=(0,d.useMemo)(()=>SO(e.locale,e.messages,e.placeholder),[e.locale,e.messages,e.placeholder]),_={"--zt-gap-placeholder-content":$Y(g.placeholder),...e.maxHeight===void 0?{}:{maxHeight:e.maxHeight,overflowY:`auto`}},v=(0,d.useCallback)(e=>{m(e)},[m]),b=(0,d.useCallback)(()=>{n(``)},[]),x=(0,d.useCallback)(e=>{n(e instanceof Error?e.message:g.initError)},[g.initError]),C=(0,d.useCallback)(e=>{if(l)return;let t=e.target;t instanceof Element&&(t.closest(`.ProseMirror`)||t.closest(`.zt-md-content-portal`)||(e.preventDefault(),s.current?.({left:e.clientX,top:e.clientY})))},[l]),T=(0,d.useCallback)(e=>{i(e)},[]),E=(0,d.useCallback)(e=>{o(e)},[]);return(0,h.jsxs)(`div`,{className:S(`zt-md`,c===`dark`?`zt-md-dark`:`zt-md-light`,e.className),"data-readonly":l?`true`:`false`,"data-readonly-label":u,children:[e.headerSlot?(0,h.jsx)(`div`,{className:`zt-md-header`,children:e.headerSlot}):null,(0,h.jsxs)(`div`,{className:`zt-md-body`,children:[t?(0,h.jsx)(`div`,{className:`zt-md-error`,children:t}):null,(0,h.jsxs)(`div`,{className:S(`zt-md-editor`,l?`zt-md-readonly`:`zt-md-editable`),"aria-label":g.editorAriaLabel,"aria-readonly":l,onMouseDown:C,style:_,children:[r&&a?(0,h.jsx)(y,{children:(0,h.jsx)(eX,{markdown:p,locale:e.locale,portalContainer:r,contentPortalContainer:a,focusEditorRef:s,readOnly:l,debounceMs:f,messages:g,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onMarkdownChange:v,onInitReady:b,onInitError:x})}):null,(0,h.jsx)(`div`,{ref:E,className:`zt-md-content-portal`})]}),(0,h.jsx)(`div`,{ref:T,className:`zt-md-portal`})]})]})};exports.MilkdownEditor=tX;
379
+ `).lastIndexOf(`/`);if(a<0)return!1;let o=r+a,s=t.tr.delete(o,i);return e.dispatch(s.scrollIntoView()),!0},jJ={Type:_D,Heading1:WE,Heading2:GE,Heading3:KE,Heading4:qE,Heading5:YE,Heading6:JE,Image:QE,List:iD,ListOrdered:nD,ListTodo:rD,Code:BE,SquareFunction:lD,SquareCode:cD,TextQuote:hD,Sigma:sD,Table:dD},MJ=RE,NJ=(e,t,n,r)=>{r.splice(0).forEach(e=>{e.unmount()}),e.innerHTML=``;let i=``;t.forEach((t,a)=>{if(t.group!==i){let n=document.createElement(`div`);n.className=`slash-menu-group`,n.textContent=t.group,e.appendChild(n),i=t.group}let o=document.createElement(`div`);o.className=`slash-menu-item`,o.dataset.command=t.command,o.dataset.selected=a===n?`true`:`false`;let s=document.createElement(`span`);s.className=`slash-menu-item-icon`;let c=t.icon?jJ[t.icon]??MJ:null;if(c){let e=(0,p.createRoot)(s);e.render((0,d.createElement)(c,{size:16,strokeWidth:2})),r.push(e)}let l=document.createElement(`span`);l.className=`slash-menu-item-label`,l.textContent=t.label,o.appendChild(s),o.appendChild(l),e.appendChild(o)})},PJ=e=>{let t=document.createElement(`div`);t.className=`slash-menu`,t.style.display=`none`,e.appendChild(t);let n=!1,r=``,i=!1,a=null,o=[],s=()=>{if(!n||!a)return;let{editorWrapper:r,anchorTopInContent:i,anchorBottomInContent:o,anchorLeftInContent:s,placement:c,offsetY:l}=a,u=nq({wrapper:r,anchor:{anchorTopInContent:i,anchorBottomInContent:o,anchorLeftInContent:s},overlaySize:{width:t.offsetWidth||210},placement:c,offsetY:l,boundaryInset:4},e);t.style.left=`${u.left}px`,t.style.top=`${u.top}px`,t.dataset.placement=c},c=rq(()=>{n&&s()}),l=()=>{t.style.top=``,t.style.left=``,t.style.transform=``,delete t.dataset.placement};return{menu:t,isVisible:()=>n,setVisible:(e,a)=>{if(n!==e){if(n=e,t.style.display=e?`block`:`none`,!e){c.unbindGlobal(),c.bindWrapper(null),l(),r=``,i=!0;return}c.bindGlobal(),a&&(a(),i&&=(a(),!1))}},renderIfNeeded:(e,n)=>{let i=`${e.map(e=>e.command).join(`|`)}::${n}`;r!==i&&(NJ(t,e,n,o),r=i)},scrollActiveItemIntoView:e=>{let n=t.querySelector(`.slash-menu-item[data-selected="true"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),e&&e())},updatePositionContext:e=>{a=e,c.bindWrapper(e?.editorWrapper??null)},updatePosition:s,destroy:()=>{o.splice(0).forEach(e=>{e.unmount()}),c.destroy(),t.remove()}}};function FJ(e){let t=Vg({},`${e}_SLASH_SPEC`),n=zg(n=>{let r=n.get(t.key);return new $n({key:new nr(`${e}_SLASH`),...r})}),r=[t,n];return r.key=t.key,r.pluginKey=n.key,t.meta={package:`@milkdown/plugin-slash`,displayName:`Ctx<slashSpec>|${e}`},n.meta={package:`@milkdown/plugin-slash`,displayName:`Prose<slash>|${e}`},r}var IJ=(e,t)=>{if(!(!e||typeof e!=`object`))return e[t]},LJ=()=>{if(typeof FJ!=`function`)return console.error(`[zt-md/slash] slashFactory not found`),null;let e=FJ(`zt-md-slash`),t=Array.isArray(e)?e[0]:void 0,n=Array.isArray(e)?e[1]:e,r=Array.isArray(e)?e[2]:void 0;if(!n)return null;let i=Array.isArray(e)?e.filter((e,t)=>t<2&&e!=null):[n],a=IJ(t,`key`)??IJ(n,`key`)??IJ(r,`key`)??IJ(e,`key`);return i.length===0||a===void 0?null:{plugins:i,key:a}},RJ=(e,t,n,r,i=`zh-CN`)=>{if(t?.enabled===!1)return{plugins:[],config:null};try{let a=LJ();if(!a)return{plugins:[],config:null};let o=wJ(t,i),s=PJ(e),c=0,l=null,u=o,d=!1,f=new Set([`ArrowDown`,`ArrowUp`,`Enter`,`Escape`]),p=e=>!f.has(e.key)||!d?!1:e.key===`ArrowDown`?(e.preventDefault(),u.length===0?!0:(c=(c+1)%u.length,s.renderIfNeeded(u,c),s.scrollActiveItemIntoView(()=>{s.updatePosition()}),!0)):e.key===`ArrowUp`?(e.preventDefault(),u.length===0?!0:(c=(c-1+u.length)%u.length,s.renderIfNeeded(u,c),s.scrollActiveItemIntoView(()=>{s.updatePosition()}),!0)):e.key===`Enter`?(e.preventDefault(),g(),!0):e.key===`Escape`?(e.preventDefault(),s.setVisible(!1),!0):!1,m=e=>{let t=e?.state?.selection?.from;if(typeof t!=`number`)return null;let n=e?.coordsAtPos?.(t);return n?new DOMRect(n.left,n.top,Math.max(n.right-n.left,1),n.bottom-n.top):null},h=e=>{if(!xJ(e)){u=[],d=!1,s.updatePositionContext(null),s.setVisible(!1);return}let t=kJ(e,o);if(u=t.visibleItems,d=t.shouldShow,t.shouldShow&&c>=u.length&&(c=0),t.shouldShow&&!s.isVisible()&&(c=0),!t.shouldShow){s.updatePositionContext(null),s.setVisible(!1);return}let n=m(e),r=ZK(e?.dom);if(n&&r){let e=QK(n,320),t=$K(n,r);s.updatePositionContext({editorWrapper:r,anchorTopInContent:t.anchorTopInContent,anchorBottomInContent:t.anchorBottomInContent,anchorLeftInContent:t.anchorLeftInContent,placement:e,offsetY:8})}s.renderIfNeeded(u,c),s.isVisible()?s.updatePosition():s.setVisible(!0,()=>{s.updatePosition()})},g=async()=>{if(!xJ(l)){d=!1,s.updatePositionContext(null),s.setVisible(!1);return}if(!l||c<0||c>=u.length)return;let t=u[c];if(AJ(l)){if(t.command===`image`){s.setVisible(!1),n&&jI({portalContainer:e,view:l,messages:n,imageUpload:r});return}await bJ(l,t.command)&&(s.setVisible(!1),t.command===`mathBlock`&&queueMicrotask(()=>{let e=l?.dom?.querySelector?.(`.zt-md-math-block-editing .zt-md-math-block-textarea`);!e||document.activeElement===e||e.focus()}))}};return s.menu.addEventListener(`mousedown`,e=>{e.preventDefault();let t=(e.target?.closest(`.slash-menu-item`))?.dataset.command??``;if(!t)return;let n=u.findIndex(e=>e.command===t);n<0||(c=n,g())}),{plugins:a.plugins,config:e=>{e.set(a.key,{props:{handleKeyDown:(e,t)=>p(t)},view:()=>({update:e=>{l=e,h(e)},destroy:()=>{d=!1,s.destroy()}})})}}}catch(e){return console.error(`[zt-md/slash] init failed`,e),{plugins:[],config:null}}},zJ=`table`,BJ=`ArrowUp`,VJ=e=>e.key!==BJ||e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey,HJ=(e,t)=>{let n=t.nodeBefore;return!n||n.type.name!==zJ?null:{tableNode:n,tableStart:e-n.nodeSize}},UJ=e=>{if(e.parent.type.name!==`paragraph`||e.parentOffset!==0||e.parent.childCount>0||e.depth<1)return null;let t=e.index(e.depth-1);if(t<=0)return null;let n=e.node(e.depth-1).child(t-1);return n.type.name===zJ?{tableNode:n,tableStart:e.before(e.depth)-n.nodeSize}:null},WJ=(e,t)=>{if(e.childCount===0)return null;let n=e.childCount-1,r=e.child(n);if(r.childCount===0)return null;let i=0;for(let t=0;t<n;t+=1)i+=e.child(t).nodeSize;let a=r.childCount-1,o=r.child(a),s=0;for(let e=0;e<a;e+=1)s+=r.child(e).nodeSize;return t+1+i+1+s+o.nodeSize-1},GJ=e=>{let{selection:t}=e.state,n=t.$from,r=null;if(t instanceof XT?r=HJ(t.from,n):t.empty&&(r=UJ(n)),!r)return!1;let i=WJ(r.tableNode,r.tableStart);if(i===null)return!1;let a=e.state.tr.setSelection(j.near(e.state.doc.resolve(i),-1)).scrollIntoView();return e.dispatch(a),e.focus(),!0},KJ=zg(()=>new $n({key:new nr(`zt-md-table-arrow-entry`),props:{handleKeyDown:(e,t)=>VJ(t)?!1:GJ(e)}})),qJ=`table`,JJ=`table_header_row`,YJ=`table_row`,XJ=`table_header`,ZJ=`table_cell`,QJ=e=>{let t=e.selection.$from,n=-1,r=-1;for(let e=t.depth;e>=0;--e){let i=t.node(e);if(r<0&&(i.type.name===ZJ||i.type.name===XJ)&&(r=t.index(e-1)),n<0&&(i.type.name===YJ||i.type.name===JJ)&&(n=t.index(e-1)),i.type.name===qJ)return{tableNode:i,tableStart:e===0?0:t.before(e),tableNodeSize:i.nodeSize,rowIndex:n,columnIndex:r}}return null},$J=(e,t,n,r)=>{if(n<0||n>=e.childCount)return null;let i=0;for(let t=0;t<n;t+=1)i+=e.child(t).nodeSize;let a=e.child(n);if(r<0||r>=a.childCount)return null;let o=0;for(let e=0;e<r;e+=1)o+=a.child(e).nodeSize;return t+1+i+1+o+1+1},eY=e=>{if(e.columnIndex<0||e.tableNode.childCount===0)return!1;let t=e.tableNode.child(0);return e.columnIndex<t.childCount},tY=(e,t,n,r)=>{let i=$J(t.tableNode,t.tableStart,n,r);if(i===null)return!1;let a=e.state.tr.setSelection(j.near(e.state.tr.doc.resolve(i),1));return e.dispatch(a),!0},nY=(e,t)=>t(e.state,e.dispatch,e)?(e.dispatch(e.state.tr.scrollIntoView()),e.focus(),!0):!1,rY=(e,t,n)=>t.rowIndex<0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,n===`above`?Dx:Ox),iY=(e,t)=>t.rowIndex<=0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,Ax),aY=(e,t,n)=>t.rowIndex<0||t.columnIndex<0||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,n===`left`?xx:Sx),oY=(e,t)=>t.rowIndex<0||t.columnIndex<0||(t.tableNode.childCount>0?t.tableNode.child(0).childCount:0)<=1||!tY(e,t,t.rowIndex,t.columnIndex)?!1:nY(e,wx),sY=(e,t,n)=>{if(t.columnIndex<0)return!1;let r=Db.get(t.tableNode),i=t.tableStart+1,a=t.columnIndex,o=e.state.tr;for(let e=0;e<r.height;e+=1){let t=e*r.width+a,s=r.map[t];if(typeof s!=`number`)continue;let c=i+s,l=o.doc.nodeAt(c);if(!l)continue;let u={...l.attrs,alignment:n};o.setNodeMarkup(c,l.type,u,l.marks)}return o.docChanged?(o.scrollIntoView(),e.dispatch(o),e.focus(),!0):!1},cY=e=>{let t=QJ(e.state);!t||t.rowIndex<=0||iY(e,t)},lY=e=>{let t=QJ(e.state);!t||t.rowIndex<0||t.columnIndex<0||oY(e,t)},uY=e=>{let[t,n]=(0,d.useState)(!1),r=aq({open:t,portalContainer:e.portalContainer,editorWrapper:e.collisionBoundary,horizontalAlign:`end`,offsetY:6,fallbackWidth:168,fallbackHeight:240,onOutside:()=>n(!1)}),i=e=>{e.preventDefault()},a=e=>{n(e)};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(`button`,{ref:r.triggerRef,type:`button`,className:`zt-md-table-action-button`,"aria-label":e.messages.tableMoreAriaLabel,"aria-expanded":t,onMouseDown:i,onClick:()=>{if(t){n(!1);return}r.updatePosition(),a(!0)}},(0,d.createElement)(HE,{size:14,strokeWidth:2,"aria-hidden":`true`})),(0,d.createElement)(oq,{panel:r,portalContainer:e.portalContainer,className:`zt-md-table-action-popover`,onMouseDown:i},(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-group`},(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertRowAbove,onMouseDown:i,onClick:()=>{e.onInsertRowAbove(),n(!1)}},e.messages.tableInsertRowAboveLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,onMouseDown:i,onClick:()=>{e.onInsertRowBelow(),n(!1)}},e.messages.tableInsertRowBelowLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertColumn,onMouseDown:i,onClick:()=>{e.onInsertColumnLeft(),n(!1)}},e.messages.tableInsertColumnLeftLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canInsertColumn,onMouseDown:i,onClick:()=>{e.onInsertColumnRight(),n(!1)}},e.messages.tableInsertColumnRightLabel)),(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-divider`,"aria-hidden":`true`}),(0,d.createElement)(`div`,{className:`zt-md-table-action-menu-group`},(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item zt-md-table-action-menu-item-danger disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canDeleteRow,onMouseDown:i,onClick:()=>{e.onDeleteRow(),n(!1)}},e.messages.tableDeleteRowLabel),(0,d.createElement)(vI,{type:`button`,variant:`ghost`,size:`sm`,className:`zt-md-table-action-menu-item zt-md-table-action-menu-item-danger disabled:pointer-events-auto disabled:cursor-not-allowed`,disabled:!e.canDeleteColumn,onMouseDown:i,onClick:()=>{e.onDeleteColumn(),n(!1)}},e.messages.tableDeleteColumnLabel))))},dY=`zt-md-table-focus-actions`,fY=0,pY=24,mY=4,hY=4,gY=`top`,_Y=`left`,vY=e=>(0,f.renderToStaticMarkup)((0,d.createElement)(e,{size:14,strokeWidth:2,"aria-hidden":`true`})),yY=vY(gD),bY=vY(mD),xY=vY(pD),SY=vY(fD),CY=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,wY=class{constructor(e,t,n){this.currentTableStart=null,this.currentTableNodeSize=null,this.currentColumnIndex=null,this.currentColumnAlignment=_Y,this.currentTableElement=null,this.hasPositionContext=!1,this.repositionScheduler=rq(()=>{this.hasPositionContext&&this.updateOverlayPosition()}),this.handleActionsMouseDown=e=>{e.preventDefault()},this.handleDeleteClick=e=>{if(e.preventDefault(),this.currentTableStart===null||this.currentTableNodeSize===null)return;let t=this.currentTableStart,n=this.currentTableStart+this.currentTableNodeSize,r=this.view.state.tr.delete(t,n).scrollIntoView();this.view.dispatch(r),this.view.focus()},this.handleAlignLeftClick=()=>{this.applyColumnAlignment(`left`)},this.handleAlignCenterClick=()=>{this.applyColumnAlignment(`center`)},this.handleAlignRightClick=()=>{this.applyColumnAlignment(`right`)},this.handleInsertRowBelow=()=>{let e=QJ(this.view.state);!e||e.rowIndex<0||rY(this.view,e,`below`)},this.handleInsertRowAbove=()=>{let e=QJ(this.view.state);!e||e.rowIndex<=0||rY(this.view,e,`above`)},this.handleInsertColumnLeft=()=>{this.insertColumn(`left`)},this.handleInsertColumnRight=()=>{this.insertColumn(`right`)},this.handleDeleteRow=()=>{cY(this.view)},this.handleDeleteColumn=()=>{lY(this.view)},this.view=e,this.messages=t,this.portalContainer=n,this.editorWrapper=ZK(e.dom),this.actionsContainer=document.createElement(`div`),this.actionsContainer.className=`zt-md-table-actions-overlay`,this.deleteButton=document.createElement(`button`),this.deleteButton.type=`button`,this.deleteButton.className=`zt-md-table-action-button zt-md-table-action-button-danger`,this.deleteButton.style.display=`inline-flex`,this.deleteButton.setAttribute(`aria-label`,t.tableDeleteAriaLabel),this.deleteButton.innerHTML=yY,this.alignLeftButton=this.createColumnAlignmentButton(t.tableAlignLeftAriaLabel,bY),this.alignCenterButton=this.createColumnAlignmentButton(t.tableAlignCenterAriaLabel,xY),this.alignRightButton=this.createColumnAlignmentButton(t.tableAlignRightAriaLabel,SY),this.moreActionsMount=document.createElement(`span`),this.moreActionsMount.className=`zt-md-table-more-actions-mount`,this.moreActionsRoot=(0,p.createRoot)(this.moreActionsMount),this.actionsContainer.append(this.moreActionsMount,this.alignLeftButton,this.alignCenterButton,this.alignRightButton,this.deleteButton),this.actionsContainer.addEventListener(`mousedown`,this.handleActionsMouseDown),this.deleteButton.addEventListener(`click`,this.handleDeleteClick),this.alignLeftButton.addEventListener(`click`,this.handleAlignLeftClick),this.alignCenterButton.addEventListener(`click`,this.handleAlignCenterClick),this.alignRightButton.addEventListener(`click`,this.handleAlignRightClick),this.repositionScheduler.bindGlobal(),this.repositionScheduler.bindWrapper(this.editorWrapper),this.update(e)}createColumnAlignmentButton(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`zt-md-table-action-button`,n.style.display=`inline-flex`,n.setAttribute(`aria-label`,e),n.innerHTML=t,n}resolveColumnAlignment(e){return e===`center`||e===`right`?e:_Y}updateAlignmentButtonsState(e){this.alignLeftButton.disabled=!e,this.alignCenterButton.disabled=!e,this.alignRightButton.disabled=!e,this.alignLeftButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`left`),this.alignCenterButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`center`),this.alignRightButton.classList.toggle(`zt-md-table-action-button-active`,e&&this.currentColumnAlignment===`right`)}applyColumnAlignment(e){let t=QJ(this.view.state);!t||t.rowIndex<0||t.columnIndex<0||sY(this.view,t,e)}insertColumn(e){let t=QJ(this.view.state);!t||t.rowIndex<0||t.columnIndex<0||aY(this.view,t,e)}renderMoreActions(e,t,n,r){this.moreActionsRoot.render((0,d.createElement)(uY,{messages:this.messages,portalContainer:this.portalContainer,collisionBoundary:this.editorWrapper,canInsertRowAbove:e,canInsertColumn:t,canDeleteRow:n,canDeleteColumn:r,onInsertRowAbove:this.handleInsertRowAbove,onInsertRowBelow:this.handleInsertRowBelow,onInsertColumnLeft:this.handleInsertColumnLeft,onInsertColumnRight:this.handleInsertColumnRight,onDeleteRow:this.handleDeleteRow,onDeleteColumn:this.handleDeleteColumn}))}resolveTableElement(e){if(e instanceof HTMLTableElement)return e;let t=e.querySelector(`table`);return t instanceof HTMLTableElement?t:null}resolveTableAnchor(e,t){if(!this.editorWrapper)return null;let n=e.getBoundingClientRect(),r=$K(n,this.editorWrapper),i=n.width,a=r.anchorLeftInContent+i-t-fY,o=r.anchorTopInContent-pY+mY;return{anchorLeftInContent:a,anchorTopInContent:o,anchorBottomInContent:o}}resolveActionsContainerWidth(){let e=this.actionsContainer.getBoundingClientRect().width;return e<=0?null:e}updateOverlayPosition(){if(!this.editorWrapper||!this.currentTableElement||this.actionsContainer.parentElement!==this.portalContainer)return;let e=this.resolveActionsContainerWidth();if(e===null)return;let t=this.resolveTableAnchor(this.currentTableElement,e);if(!t)return;let n=nq({wrapper:this.editorWrapper,anchor:t,overlaySize:{width:e},placement:gY,offsetY:0,boundaryInset:hY},this.portalContainer);this.actionsContainer.style.left=`${n.left}px`,this.actionsContainer.style.top=`${n.top}px`}update(e){if(this.view=e,!this.editorWrapper||!CY(e)){this.detach();return}let t=QJ(e.state);if(!t){this.detach();return}let n=e.nodeDOM(t.tableStart);if(!(n instanceof HTMLElement)){this.detach();return}let r=this.resolveTableElement(n);if(!r){this.detach();return}this.actionsContainer.parentElement!==this.portalContainer&&this.portalContainer.append(this.actionsContainer);let i=eY(t),a=i&&t.tableNode.child(0).childCount>1,o=t.rowIndex>0,s=t.rowIndex>0,c=t.tableNode.childCount>0?t.tableNode.child(0):null;this.currentColumnIndex=i?t.columnIndex:null,this.currentColumnAlignment=this.resolveColumnAlignment(this.currentColumnIndex===null?null:c?.maybeChild(this.currentColumnIndex)?.attrs?.alignment),this.updateAlignmentButtonsState(i),this.renderMoreActions(o,i,s,a),this.currentTableElement=r,this.currentTableStart=t.tableStart,this.currentTableNodeSize=t.tableNodeSize,this.hasPositionContext=!0,this.updateOverlayPosition(),this.repositionScheduler.schedule()}detach(){this.moreActionsRoot.render(null),this.actionsContainer.remove(),this.currentTableElement=null,this.currentTableStart=null,this.currentTableNodeSize=null,this.currentColumnIndex=null,this.currentColumnAlignment=_Y,this.updateAlignmentButtonsState(!1),this.hasPositionContext=!1}destroy(){this.detach(),this.repositionScheduler.destroy(),this.moreActionsRoot.unmount(),this.actionsContainer.removeEventListener(`mousedown`,this.handleActionsMouseDown),this.deleteButton.removeEventListener(`click`,this.handleDeleteClick),this.alignLeftButton.removeEventListener(`click`,this.handleAlignLeftClick),this.alignCenterButton.removeEventListener(`click`,this.handleAlignCenterClick),this.alignRightButton.removeEventListener(`click`,this.handleAlignRightClick)}},TY=(e,t)=>{let n=SO(void 0,t);return zg(()=>new $n({key:new nr(dY),view:t=>new wY(t,n,e)}))},EY=`list_item`,DY=`li[data-item-type="task"]`,OY=24,kY=(e,t)=>{let n=t.getBoundingClientRect();return e.clientX>=n.left&&e.clientX<=n.left+OY&&e.clientY>=n.top&&e.clientY<=n.top+OY},AY=e=>{if(!(e instanceof Element))return null;let t=e.closest(DY);return t instanceof HTMLElement?t:null},jY=(e,t)=>{if(!e.editable)return!1;let n=AY(t.target);return!n||!kY(t,n)?!1:(t.preventDefault(),!0)},MY=(e,t)=>{let n=e.posAtDOM(t,0)-1,r=e.state.doc.nodeAt(n);return!r||r.type.name!==EY||r.attrs.checked==null?!1:(e.dispatch(e.state.tr.setNodeMarkup(n,void 0,{...r.attrs,checked:!r.attrs.checked})),!0)},NY=zg(()=>new $n({props:{handleDOMEvents:{mousedown:(e,t)=>jY(e,t),dblclick:(e,t)=>jY(e,t),click:(e,t)=>{if(!e.editable)return!1;let n=AY(t.target);return!n||!kY(t,n)||!MY(e,n)?!1:(t.preventDefault(),!0)}}}})),PY=`Tab`,FY=4,IY=/^ */,LY=`list_item`,RY=e=>typeof e.props.editable==`function`?e.props.editable(e.state):e.editable,zY=e=>{let{$from:t}=e.selection;for(let e=t.depth;e>=0;--e){let n=t.node(e);if(n.type.name===LY)return n.type}return null},BY=e=>{let{selection:t,doc:n}=e;if(t.empty)return[t.$from.start()];let r=new Set;return n.nodesBetween(t.from,t.to,(e,t)=>{e.isTextblock&&r.add(t+1)}),Array.from(r)},VY=(e,t)=>{let{state:n}=e,r=` `.repeat(FY),i=BY(n).sort((e,t)=>t-e),a=n.tr;return n.selection.empty?a.insertText(r,n.selection.to):i.forEach(e=>{a.insertText(r,e)}),a.docChanged?(t.preventDefault(),e.dispatch(a),!0):!1},HY=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!(r instanceof j))return!1;let i=BY(n).sort((e,t)=>t-e),a=n.tr;return i.forEach(e=>{let t=n.doc.resolve(e).parent.textContent.match(IY)?.[0].length??0,r=Math.min(t,FY);r<=0||a.delete(e,e+r)}),a.docChanged?(t.preventDefault(),e.dispatch(a),!0):!1},UY=zg(()=>new $n({key:new nr(`zt-md-tab-space-indent`),props:{handleKeyDown:(e,t)=>{let n=e;if(!RY(n)||t.defaultPrevented||t.key!==PY||t.altKey||t.ctrlKey||t.metaKey)return!1;let r=zY(n.state);if(r){let e=(t.shiftKey?wv(r):Dv(r))(n.state,n.dispatch);return t.preventDefault(),e||!0}return t.shiftKey?HY(n,t):VY(n,t)}}})),WY=e=>{let t=(e instanceof Element?e:e.parentElement)?.closest(`code`);return t instanceof HTMLElement&&!t.closest(`pre`)?t:null},GY=(e,t,n)=>WY(e.domAtPos(t,n).node),KY=e=>{let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=t.nextNode(),r=null;for(;n;)n.data.length>0&&(r=n),n=t.nextNode();return r},qY=(e,t,n)=>{let r=e.domAtPos(t,n);e.dom.ownerDocument.getSelection()?.collapse(r.node,r.offset)},JY=(e,t)=>{let n=e.domAtPos(t,-1),r=WY(n.node),i=e.dom.ownerDocument.getSelection();if(!r){i?.collapse(n.node,n.offset);return}let a=KY(r);if(!a){let e=r.childNodes.length;i?.collapse(r,e);return}let o=a.data.length;i?.collapse(a,o)},YY={left:{inwardKey:`ArrowRight`,outwardKey:`ArrowLeft`},right:{inwardKey:`ArrowLeft`,outwardKey:`ArrowRight`}},XY={left:`nodeAfter`,right:`nodeBefore`},ZY=(e,t)=>{e.dispatch(e.state.tr.setMeta(t,null))},QY=(e,t,n,r,i)=>{if(t.key===`ArrowRight`)return ZY(e,i),!1;if(t.key!==`ArrowLeft`)return!1;t.preventDefault();let a=(e.state.storedMarks??e.state.selection.$from.marks()).filter(e=>e.type!==n);return e.dispatch(e.state.tr.setStoredMarks(a).setMeta(i,{...r,placement:`outside`})),!0},$Y=(e,t,n,r,i)=>{if(r.placement===`inside`)return QY(e,t,n,r,i);let a=YY[r.side];if(t.key===a.outwardKey)return ZY(e,i),!1;if(t.key!==a.inwardKey)return!1;let o=XY[r.side],s=e.state.selection.$from[o],c=s?n.isInSet(s.marks):null;if(!c)return ZY(e,i),!1;t.preventDefault();let l=e.state.storedMarks??e.state.selection.$from.marks(),u=c.addToSet(l);return e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,r.position)).setStoredMarks(u).setMeta(i,r.side===`left`?{...r,placement:`inside`}:null)),r.side===`right`&&JY(e,r.position),!0},eX=(e,t)=>!!t.isInSet(e),tX=(e,t,n)=>{let r=e.state.doc.resolve(t),i=r.nodeBefore,a=r.nodeAfter;return!a||eX(i?.marks??[],n)||!eX(a.marks,n)?null:n.isInSet(a.marks)},nX=(e,t,n)=>{let r=e.state.doc.resolve(t),i=r.nodeBefore,a=r.nodeAfter;return!i||!eX(i.marks,n)||eX(a?.marks??[],n)?null:n.isInSet(i.marks)},rX=new nr(`zt-md-inline-code-boundary-navigation`),iX=`inlineCode`,aX=2,oX=(e,t,n,r)=>{let i=t>0?[t,t-1]:[t];for(let[t,a]of i.entries()){let i=nX(e,a,r);if(!i)continue;let o=e.state.doc.resolve(a).nodeAfter;if(o!==null&&!o.isText)continue;let s=GY(e,a,-1);if(!s)continue;let c=n<=s.getBoundingClientRect().right+aX;if(!(t>0&&!c))return{boundaryPosition:a,inlineCodeMark:i,rightPlainTextNode:o,codeElement:s}}return null},sX=(e,t)=>{if(t.button!==0||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!e.editable)return!1;let n=e.posAtCoords({left:t.clientX,top:t.clientY}),r=e.state.schema.marks[iX];if(!n||!r)return!1;let i=n.pos,a=e.state.doc.resolve(i),o=tX(e,i,r),s=a.nodeBefore;if(o&&(!s||s.isText)){let n=GY(e,i,1);if(!n)return!1;let c=n.getBoundingClientRect(),l=t.clientX>=c.left,u=(s?.marks??a.marks()).filter(e=>e.type!==r),d=l?o.addToSet(a.marks()):u,f=l?{position:i,side:`left`,placement:`inside`}:null;return t.preventDefault(),e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,i)).setStoredMarks(d).setMeta(rX,f)),e.focus(),l||qY(e,i,-1),!0}let c=oX(e,i,t.clientX,r);if(!c)return!1;let l=c.boundaryPosition,u=e.state.doc.resolve(l),d=c.codeElement.getBoundingClientRect(),f=t.clientX>=d.right,p=(c.rightPlainTextNode?.marks??u.marks()).filter(e=>e.type!==r),m=f?p:c.inlineCodeMark.addToSet(u.marks()),h=f?{position:l,side:`right`,placement:`outside`}:null;return t.preventDefault(),e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,l)).setStoredMarks(m).setMeta(rX,h)),e.focus(),f||JY(e,l),!0},cX=`inlineCode`,lX=`zt-md-inline-code-boundary-indicator`,uX=`zt-md-inline-code-boundary-indicator-widget`,dX=`zt-md-inline-code-boundary-active`,fX={left:-1,right:1},pX={left:1,right:-1},mX=e=>{let t=document.createElement(`span`);return t.className=lX,t.dataset.side=e.side,t.dataset.placement=e.placement,t.contentEditable=`false`,t.setAttribute(`aria-hidden`,`true`),t},hX=(e,t)=>{if(t.placement===`outside`)return[];let n=e.schema.marks[cX],r=e.doc.resolve(t.position).nodeAfter,i=r&&n?n.isInSet(r.marks):null;return i?[i]:null},gX=e=>{let t=rX.getState(e);if(!t)return km.empty;let n=hX(e,t);if(!n)return km.empty;let r=t.placement===`inside`?1:fX[t.side],i=mX(t),a=Em.widget(t.position,i,{side:r,marks:n,key:`${uX}-${t.side}-${t.placement}`,ignoreSelection:!0,relaxedSide:!0});return km.create(e.doc,[a])},_X=(e,t)=>{if(t?.placement!==`outside`)return;let n=e.dom.querySelector(`.${lX}[data-side='${t.side}'][data-placement='outside']`),r=pX[t.side],i=GY(e,t.position,r);if(!n||!i)return;let a=n.getBoundingClientRect().left,o=i.getBoundingClientRect(),s=t.side===`left`?o.left-1:o.right+1,c=Math.round(s-a);n.style.setProperty(`--zt-md-inline-code-boundary-offset-x`,`${c}px`)},vX=`inlineCode`,yX=(e,t)=>{let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from.nodeBefore,i=n.$from.nodeAfter;return!!(r&&eX(r.marks,t)&&(!i||!eX(i.marks,t)))},bX=(e,t)=>{let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from.nodeBefore,i=n.$from.nodeAfter;return!!(i&&eX(i.marks,t)&&(!r||!eX(r.marks,t)))},xX=(e,t,n)=>{let r=tX(e,t,n);if(!r)return!1;let i=e.state.storedMarks??e.state.doc.resolve(t).marks(),a=r.addToSet(i);return e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,t)).setStoredMarks(a).setMeta(rX,{position:t,side:`left`,placement:`inside`})),!0},SX=(e,t)=>t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!e.editable,CX=(e,t)=>{let{selection:n}=e.state;if(!n.empty)return null;let r=n.$from.nodeBefore;return!r||!eX(r.marks,t)?null:Array.from(r.textContent).length===1?n.from-r.nodeSize:null},wX=(e,t,n)=>{if(t.key!==`ArrowLeft`)return!1;let r=CX(e,n);if(r===null)return!1;let i=e.state.storedMarks??e.state.selection.$from.marks();return eX(i,n)?(t.preventDefault(),e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,r)).setStoredMarks(i).setMeta(rX,{position:r,side:`left`,placement:`inside`})),!0):!1},TX=(e,t,n)=>{if(!bX(e,n))return!1;let r=e.state.storedMarks??e.state.selection.$from.marks();if(!eX(r,n))return MX(e),!1;t.preventDefault();let i=r.filter(e=>e.type!==n);return e.dispatch(e.state.tr.setStoredMarks(i).setMeta(rX,{position:e.state.selection.from,side:`left`,placement:`outside`})),qY(e,e.state.selection.from,-1),!0},EX=(e,t,n)=>{if(t.key!==`ArrowLeft`||!yX(e,n))return!1;let r=e.state.storedMarks??e.state.selection.$from.marks();return eX(r,n)?!1:(t.preventDefault(),e.dispatch(e.state.tr.setStoredMarks(r).setMeta(rX,{position:e.state.selection.from,side:`right`,placement:`outside`})),qY(e,e.state.selection.from,1),!0)},DX=(e,t)=>{let{selection:n}=e.state;if(!n.empty)return null;let r=n.$from.nodeBefore;if(!r?.isText||eX(r.marks,t)||Array.from(r.textContent).length!==1)return null;let i=n.from-r.nodeSize;return nX(e,i,t)?i:null},OX=(e,t,n)=>{if(t.key!==`ArrowLeft`)return!1;let r=DX(e,n);if(r===null)return!1;let i=(e.state.selection.$from.nodeBefore?.marks??[]).filter(e=>e.type!==n);return t.preventDefault(),e.dispatch(e.state.tr.setSelection(j.create(e.state.doc,r)).setStoredMarks(i).setMeta(rX,{position:r,side:`right`,placement:`outside`})),qY(e,r,1),!0},kX=(e,t,n)=>OX(e,t,n)||EX(e,t,n)||wX(e,t,n)||TX(e,t,n),AX=()=>null,jX=(e,t)=>{let n=e.getMeta(rX);return n===void 0?e.docChanged||e.selectionSet||e.storedMarksSet?null:t:n},MX=e=>{rX.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(rX,null))},NX=e=>(MX(e),!1),PX=class{constructor(e){this.editorDom=e.dom,this.update(e)}update(e){let t=rX.getState(e.state),n=t!=null;this.editorDom.classList.toggle(dX,n),_X(e,t)}destroy(){this.editorDom.classList.remove(dX)}},FX=e=>new PX(e),IX=e=>{if(!(e instanceof Element))return!1;let t=e.closest(`code`);return!!(t&&!t.closest(`pre`))},LX=(e,t,n)=>{if(!e.state.selection.empty)return!1;if(sX(e,n))return!0;let r=IX(n.target),i=e.state.schema.marks[vX];if(i&&r&&xX(e,t,i))return n.preventDefault(),!0;let a=rX.getState(e.state);if(!r||!a)return!1;let o=e.state.storedMarks,s=e.state.tr.setMeta(rX,null);return o!==null&&i&&!eX(o,i)&&s.setStoredMarks(null),e.dispatch(s),!1},RX=(e,t,n)=>t.key!==`ArrowRight`||!bX(e,n)||eX(e.state.storedMarks??e.state.selection.$from.marks(),n)||!xX(e,e.state.selection.from,n)?!1:(t.preventDefault(),!0),zX={ArrowLeft:kX,ArrowRight:(e,t,n)=>{if(t.key!==`ArrowRight`)return!1;if(RX(e,t,n))return!0;if(!yX(e,n))return!1;let r=e.state.storedMarks??e.state.selection.$from.marks();if(!eX(r,n))return MX(e),!1;t.preventDefault();let i=r.filter(e=>e.type!==n);return e.dispatch(e.state.tr.setStoredMarks(i).setMeta(rX,{position:e.state.selection.from,side:`right`,placement:`outside`})),qY(e,e.state.selection.from,1),!0}},BX=(e,t)=>{if(SX(e,t))return!1;let n=zX[t.key];if(!n)return!1;let r=e.state.schema.marks[vX];if(!r)return!1;let i=rX.getState(e.state);return i?$Y(e,t,r,i,rX):n(e,t,r)},VX=zg(()=>new $n({key:rX,view:FX,state:{init:AX,apply:jX},props:{handleKeyDown:BX,handleClick:LX,decorations:gX,handleDOMEvents:{blur:NX}}})),HX=e=>{let t=e.target;if(!(t instanceof Element))return null;let n=t.closest(`a[href]`);return n instanceof HTMLAnchorElement?n:null},UX=e=>e?.type.name===`image`,WX=(e,t)=>{let n=HX(e);if(!n)return!1;let r=AO(n.getAttribute(`href`));return!r||t||!e.ctrlKey?!1:(e.preventDefault(),e.stopPropagation(),window.open(r,`_blank`,`noopener,noreferrer`),!0)},GX=(e,t)=>!t||!HX(e)?!1:(e.preventDefault(),e.stopPropagation(),!0),KX=e=>{let t=e.messages??SO(),n=TY(e.contentPortalContainer,t),r=uJ(e.contentPortalContainer,t),i=Sq(t,e.contentPortalContainer),a=dU(t,e.contentPortalContainer),o=Ik(e.imageUpload,t),s=RJ(e.portalContainer,e.slashMenu,t,e.imageUpload,e.locale),c=s.plugins,l={listener:yv,commonmark:wb,inlineCodeBoundaryNavigation:VX,gfm:VT,history:k_,codeBlockPrism:Fq,codeBlockLanguagePicker:i,clipboard:Qg,indent:N_,imageDeleteSelection:pk,imagePaste:o,tableArrowEntry:KJ,blockBoundaryNavigation:CE,headingBackspaceEmptyParagraph:gW,mathBackspaceEntry:LI,blockquoteBackspaceLift:cW,tableFocusActions:n,selectionTooltip:r,gapCursor:sE,dropCursor:YT,math:tW,mathInlineEdit:a,mathInlineArrowNavigation:NU,taskListToggle:NY,tabSpaceIndent:UY,codeBlockModASelect:kq,slash:c.length>0?c:null},u=WT(l,{includeRuntime:!1}),d=WT(l,{includeRuntime:!0}).filter(e=>e.name===`clipboard`||e.name===`indent`),f=jg.make();f.config(n=>{SW(n),UO(n,e.imageUpload?.allowedProtocols),n.set(Cg,e.root),n.set(lg,e.markdown),n.set(Sg,{editable:()=>!e.readOnly,handleDOMEvents:{mousedown:(t,n)=>n instanceof MouseEvent?GX(n,e.readOnly):!1,click:(t,n)=>n instanceof MouseEvent?GX(n,e.readOnly):!1},handleClick:(t,n,r)=>WX(r,e.readOnly),handleClickOn:(t,n,r,i,a,o)=>WX(a,e.readOnly)?!0:e.readOnly&&o&&UX(r)?(a.preventDefault(),!0):!1});let r=n.get(Eh)??[];n.set(Eh,[...r,[`image`,ek(t)],[`math_block`,rU(t)],[`math_inline`,_U(t)],[`code_block`,zW(t)]]),n.get(_v).markdownUpdated((t,n)=>{e.onChange(n)}),s.config&&s.config(n)}),u.forEach(e=>{f.use(e.plugin)});let p=()=>{d.forEach(e=>{try{f.use(e.plugin),e.name===`indent`&&f.action(e=>{e.set(j_,{type:`space`,size:4})})}catch(e){console.error(e)}})},m=HT(Jg,f);return{editor:f,installRuntimePlugins:p,focusEditor:e=>{f.action(t=>{let n=t.get(yh),r=n.state.doc.lastChild,i=r?n.state.doc.content.size-r.nodeSize:null,a=i===null?null:n.nodeDOM(i),o=a instanceof Element?a:a?.parentElement??null;if(e!==void 0&&o!==null&&e.top>o.getBoundingClientRect().bottom){let e=n.state.schema.nodes.paragraph;if(!(r?.type===e&&r.content.size===0)){let t=n.state.tr.insert(n.state.doc.content.size,e.create());t.setSelection(j.atEnd(t.doc)).scrollIntoView(),n.dispatch(t),n.focus();return}}let s=e?n.posAtCoords(e):null,c=s?j.near(n.state.doc.resolve(s.pos),1):j.atEnd(n.state.doc);n.state.selection.eq(c)||n.dispatch(n.state.tr.setSelection(c).scrollIntoView()),n.focus()})},setMarkdown:e=>{m(e)}}},qX=(e,t,n,r)=>{let i=e,a=i.create.bind(e);return i.create=async()=>{try{let e=await a();return t(),n(),e}catch(e){throw console.error(`Milkdown init failed:`,e),r(e),e}},i},JX=e=>{let t=(0,d.useRef)(null),n=(0,d.useRef)(e.markdown),r=(0,d.useRef)(e.onMarkdownChange),i=(0,d.useRef)(e.onInitError),a=(0,d.useRef)(e.onInitReady),o=(0,d.useRef)(null),s=b(r=>{t.current=null,e.focusEditorRef&&(e.focusEditorRef.current=null),n.current=e.markdown;let s=KX({root:r,portalContainer:e.portalContainer,contentPortalContainer:e.contentPortalContainer,markdown:e.markdown,readOnly:e.readOnly,messages:e.messages,locale:e.locale,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onChange:e=>{n.current=e,o.current?.(e)}});return qX(s.editor,s.installRuntimePlugins,()=>{t.current=s,e.focusEditorRef&&(e.focusEditorRef.current=s.focusEditor),a.current?.()},e=>{i.current?.(e)})},[e.portalContainer,e.contentPortalContainer,e.readOnly,e.locale,e.focusEditorRef]);(0,d.useEffect)(()=>{r.current=e.onMarkdownChange},[e.onMarkdownChange]),(0,d.useEffect)(()=>{i.current=e.onInitError},[e.onInitError]),(0,d.useEffect)(()=>{a.current=e.onInitReady},[e.onInitReady]),(0,d.useEffect)(()=>(o.current&&o.current.cancel(),o.current=T(e=>{r.current(e)},e.debounceMs),()=>{o.current?.cancel(),o.current=null}),[e.debounceMs]),(0,d.useEffect)(()=>()=>{t.current=null,e.focusEditorRef&&(e.focusEditorRef.current=null)},[e.portalContainer,e.contentPortalContainer,e.readOnly,e.locale,e.focusEditorRef]),(0,d.useEffect)(()=>{let r=t.current;!r||s.loading||e.markdown!==n.current&&(n.current=e.markdown,r.setMarkdown(e.markdown))},[s.loading,e.markdown])},YX=160,XX={"zh-CN":`只读`,"en-US":`Read only`},ZX=e=>e.length===0?`""`:`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\r\n|\r|\n/g,`\\A `)}"`,QX=e=>(JX({markdown:e.markdown,portalContainer:e.portalContainer,contentPortalContainer:e.contentPortalContainer,focusEditorRef:e.focusEditorRef,readOnly:e.readOnly,debounceMs:e.debounceMs,messages:e.messages,locale:e.locale,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onMarkdownChange:e.onMarkdownChange,onInitReady:e.onInitReady,onInitError:e.onInitError}),(0,h.jsx)(v,{})),$X=e=>{let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),s=(0,d.useRef)(null),c=e.theme??`light`,l=e.readOnly??!1,u=XX[e.locale??`zh-CN`],f=e.debounceMs??YX,{markdown:p,setMarkdown:m}=w(e.value,e.defaultValue,e.onChange),g=(0,d.useMemo)(()=>SO(e.locale,e.messages,e.placeholder),[e.locale,e.messages,e.placeholder]),_={"--zt-gap-placeholder-content":ZX(g.placeholder),...e.maxHeight===void 0?{}:{maxHeight:e.maxHeight,overflowY:`auto`}},v=(0,d.useCallback)(e=>{m(e)},[m]),b=(0,d.useCallback)(()=>{n(``)},[]),x=(0,d.useCallback)(e=>{n(e instanceof Error?e.message:g.initError)},[g.initError]),C=(0,d.useCallback)(e=>{if(l)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.ProseMirror`);t.closest(`.zt-md-content-portal`)||n!==null&&t!==n||(e.preventDefault(),s.current?.({left:e.clientX,top:e.clientY}))},[l]),T=(0,d.useCallback)(e=>{i(e)},[]),E=(0,d.useCallback)(e=>{o(e)},[]);return(0,h.jsxs)(`div`,{className:S(`zt-md`,c===`dark`?`zt-md-dark`:`zt-md-light`,e.className),"data-readonly":l?`true`:`false`,"data-readonly-label":u,children:[e.headerSlot?(0,h.jsx)(`div`,{className:`zt-md-header`,children:e.headerSlot}):null,(0,h.jsxs)(`div`,{className:`zt-md-body`,children:[t?(0,h.jsx)(`div`,{className:`zt-md-error`,children:t}):null,(0,h.jsxs)(`div`,{className:S(`zt-md-editor`,l?`zt-md-readonly`:`zt-md-editable`),"aria-label":g.editorAriaLabel,"aria-readonly":l,onMouseDown:C,style:_,children:[r&&a?(0,h.jsx)(y,{children:(0,h.jsx)(QX,{markdown:p,locale:e.locale,portalContainer:r,contentPortalContainer:a,focusEditorRef:s,readOnly:l,debounceMs:f,messages:g,slashMenu:e.slashMenu,imageUpload:e.imageUpload,onMarkdownChange:v,onInitReady:b,onInitError:x})}):null,(0,h.jsx)(`div`,{ref:E,className:`zt-md-content-portal`})]}),(0,h.jsx)(`div`,{ref:T,className:`zt-md-portal`})]})]})};exports.MilkdownEditor=$X;