md-editor-v3 2.11.2 → 2.11.3
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/lib/md-editor-v3.cjs +2 -2
- package/lib/md-editor-v3.mjs +6 -5
- package/lib/md-editor-v3.umd.js +2 -2
- package/package.json +1 -1
package/lib/md-editor-v3.cjs
CHANGED
|
@@ -49,7 +49,7 @@ Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An
|
|
|
49
49
|
Expects a CSS selector, a Node element, a NodeList or an array.
|
|
50
50
|
See: https://github.com/francoischalifour/medium-zoom`)}},Ui=function(e){var t=document.createElement("div");return t.classList.add("medium-zoom-overlay"),t.style.background=e,t},qi=function(e){var t=e.getBoundingClientRect(),n=t.top,i=t.left,l=t.width,a=t.height,o=e.cloneNode(),u=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,f=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return o.removeAttribute("id"),o.style.position="absolute",o.style.top=n+u+"px",o.style.left=i+f+"px",o.style.width=l+"px",o.style.height=a+"px",o.style.transform="",o},Ge=function(e,t){var n=Pe({bubbles:!1,cancelable:!1,detail:void 0},t);if(typeof window.CustomEvent=="function")return new CustomEvent(e,n);var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),i},Wi=function s(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=window.Promise||function(A){function R(){}A(R,R)},i=function(A){var R=A.target;if(R===q){$();return}S.indexOf(R)!==-1&&b({target:R})},l=function(){if(!(N||!k.original)){var A=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(H-A)>V.scrollOffset&&setTimeout($,150)}},a=function(A){var R=A.key||A.keyCode;(R==="Escape"||R==="Esc"||R===27)&&$()},o=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A;if(A.background&&(q.style.background=A.background),A.container&&A.container instanceof Object&&(R.container=Pe({},V.container,A.container)),A.template){var P=Tt(A.template)?A.template:document.querySelector(A.template);R.template=P}return V=Pe({},V,R),S.forEach(function(z){z.dispatchEvent(Ge("medium-zoom:update",{detail:{zoom:M}}))}),M},u=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s(Pe({},V,A))},f=function(){for(var A=arguments.length,R=Array(A),P=0;P<A;P++)R[P]=arguments[P];var z=R.reduce(function(C,O){return[].concat(C,xn(O))},[]);return z.filter(function(C){return S.indexOf(C)===-1}).forEach(function(C){S.push(C),C.classList.add("medium-zoom-image")}),T.forEach(function(C){var O=C.type,K=C.listener,Y=C.options;z.forEach(function(ee){ee.addEventListener(O,K,Y)})}),M},h=function(){for(var A=arguments.length,R=Array(A),P=0;P<A;P++)R[P]=arguments[P];k.zoomed&&$();var z=R.length>0?R.reduce(function(C,O){return[].concat(C,xn(O))},[]):S;return z.forEach(function(C){C.classList.remove("medium-zoom-image"),C.dispatchEvent(Ge("medium-zoom:detach",{detail:{zoom:M}}))}),S=S.filter(function(C){return z.indexOf(C)===-1}),M},m=function(A,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.addEventListener("medium-zoom:"+A,R,P)}),T.push({type:"medium-zoom:"+A,listener:R,options:P}),M},v=function(A,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.removeEventListener("medium-zoom:"+A,R,P)}),T=T.filter(function(z){return!(z.type==="medium-zoom:"+A&&z.listener.toString()===R.toString())}),M},g=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A.target,P=function(){var C={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},O=void 0,K=void 0;if(V.container)if(V.container instanceof Object)C=Pe({},C,V.container),O=C.width-C.left-C.right-V.margin*2,K=C.height-C.top-C.bottom-V.margin*2;else{var Y=Tt(V.container)?V.container:document.querySelector(V.container),ee=Y.getBoundingClientRect(),fe=ee.width,it=ee.height,De=ee.left,Ie=ee.top;C=Pe({},C,{width:fe,height:it,left:De,top:Ie})}O=O||C.width-V.margin*2,K=K||C.height-V.margin*2;var Le=k.zoomedHd||k.original,mt=wn(Le)?O:Le.naturalWidth||O,gt=wn(Le)?K:Le.naturalHeight||K,He=Le.getBoundingClientRect(),pt=He.top,vt=He.left,qe=He.width,We=He.height,bt=Math.min(Math.max(qe,mt),O)/qe,kt=Math.min(Math.max(We,gt),K)/We,Ke=Math.min(bt,kt),yt=(-vt+(O-qe)/2+V.margin+C.left)/Ke,wt=(-pt+(K-We)/2+V.margin+C.top)/Ke,st="scale("+Ke+") translate3d("+yt+"px, "+wt+"px, 0)";k.zoomed.style.transform=st,k.zoomedHd&&(k.zoomedHd.style.transform=st)};return new n(function(z){if(R&&S.indexOf(R)===-1){z(M);return}var C=function fe(){N=!1,k.zoomed.removeEventListener("transitionend",fe),k.original.dispatchEvent(Ge("medium-zoom:opened",{detail:{zoom:M}})),z(M)};if(k.zoomed){z(M);return}if(R)k.original=R;else if(S.length>0){var O=S;k.original=O[0]}else{z(M);return}if(k.original.dispatchEvent(Ge("medium-zoom:open",{detail:{zoom:M}})),H=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,N=!0,k.zoomed=qi(k.original),document.body.appendChild(q),V.template){var K=Tt(V.template)?V.template:document.querySelector(V.template);k.template=document.createElement("div"),k.template.appendChild(K.content.cloneNode(!0)),document.body.appendChild(k.template)}if(k.original.parentElement&&k.original.parentElement.tagName==="PICTURE"&&k.original.currentSrc&&(k.zoomed.src=k.original.currentSrc),document.body.appendChild(k.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),k.original.classList.add("medium-zoom-image--hidden"),k.zoomed.classList.add("medium-zoom-image--opened"),k.zoomed.addEventListener("click",$),k.zoomed.addEventListener("transitionend",C),k.original.getAttribute("data-zoom-src")){k.zoomedHd=k.zoomed.cloneNode(),k.zoomedHd.removeAttribute("srcset"),k.zoomedHd.removeAttribute("sizes"),k.zoomedHd.removeAttribute("loading"),k.zoomedHd.src=k.zoomed.getAttribute("data-zoom-src"),k.zoomedHd.onerror=function(){clearInterval(Y),console.warn("Unable to reach the zoom image target "+k.zoomedHd.src),k.zoomedHd=null,P()};var Y=setInterval(function(){k.zoomedHd.complete&&(clearInterval(Y),k.zoomedHd.classList.add("medium-zoom-image--opened"),k.zoomedHd.addEventListener("click",$),document.body.appendChild(k.zoomedHd),P())},10)}else if(k.original.hasAttribute("srcset")){k.zoomedHd=k.zoomed.cloneNode(),k.zoomedHd.removeAttribute("sizes"),k.zoomedHd.removeAttribute("loading");var ee=k.zoomedHd.addEventListener("load",function(){k.zoomedHd.removeEventListener("load",ee),k.zoomedHd.classList.add("medium-zoom-image--opened"),k.zoomedHd.addEventListener("click",$),document.body.appendChild(k.zoomedHd),P()})}else P()})},$=function(){return new n(function(A){if(N||!k.original){A(M);return}var R=function P(){k.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(k.zoomed),k.zoomedHd&&document.body.removeChild(k.zoomedHd),document.body.removeChild(q),k.zoomed.classList.remove("medium-zoom-image--opened"),k.template&&document.body.removeChild(k.template),N=!1,k.zoomed.removeEventListener("transitionend",P),k.original.dispatchEvent(Ge("medium-zoom:closed",{detail:{zoom:M}})),k.original=null,k.zoomed=null,k.zoomedHd=null,k.template=null,A(M)};N=!0,document.body.classList.remove("medium-zoom--opened"),k.zoomed.style.transform="",k.zoomedHd&&(k.zoomedHd.style.transform=""),k.template&&(k.template.style.transition="opacity 150ms",k.template.style.opacity=0),k.original.dispatchEvent(Ge("medium-zoom:close",{detail:{zoom:M}})),k.zoomed.addEventListener("transitionend",R)})},b=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A.target;return k.original?$():g({target:R})},y=function(){return V},p=function(){return S},w=function(){return k.original},S=[],T=[],N=!1,H=0,V=t,k={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(e)==="[object Object]"?V=e:(e||typeof e=="string")&&f(e),V=Pe({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},V);var q=Ui(V.background);document.addEventListener("click",i),document.addEventListener("keyup",a),document.addEventListener("scroll",l),window.addEventListener("resize",$);var M={open:g,close:$,toggle:b,update:o,clone:u,attach:f,detach:h,on:m,off:v,getOptions:y,getImages:p,getZoomedImage:w};return M};function Ki(s,e){e===void 0&&(e={});var t=e.insertAt;if(!(!s||typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var Gi=".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";Ki(Gi);const Zi=Wi,lt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Fn=new Set,Xi=(s,e,t,n)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`)},Qi=s=>!Fn.has(s),Fe=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Rn=s=>Fe(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Et:null:null;class Et extends Array{constructor(e){super(e),this.fill(0)}}var Qe;const Xe=class{constructor(e,t){te(this,"heap");te(this,"length");if(!c(Xe,Qe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=Rn(e);if(!t)return[];F(Xe,Qe,!0);const n=new Xe(e,t);return F(Xe,Qe,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};let Nt=Xe;Qe=new WeakMap,D(Nt,Qe,!1);var me,ue,xe,ge,Ye,ne,pe,ie,G,j,ae,de,re,se,ve,le,Ne,ze,be,$e,Oe,ce,ct,Pt,Me,Ve,ut,he,Lt,jn,Be,Je,dt,Se,Re,Ce,je,ht,Mt,et,zt,tt,Vt,Z,Q,ft,Bt,Ue,at;const Qt=class{constructor(e){D(this,ct);D(this,Lt);D(this,Se);D(this,Ce);D(this,ht);D(this,et);D(this,tt);D(this,Z);D(this,ft);D(this,Ue);D(this,me,void 0);D(this,ue,void 0);D(this,xe,void 0);D(this,ge,void 0);D(this,Ye,void 0);te(this,"ttl");te(this,"ttlResolution");te(this,"ttlAutopurge");te(this,"updateAgeOnGet");te(this,"updateAgeOnHas");te(this,"allowStale");te(this,"noDisposeOnSet");te(this,"noUpdateTTL");te(this,"maxEntrySize");te(this,"sizeCalculation");te(this,"noDeleteOnFetchRejection");te(this,"noDeleteOnStaleGet");te(this,"allowStaleOnFetchAbort");te(this,"allowStaleOnFetchRejection");te(this,"ignoreFetchAbort");D(this,ne,void 0);D(this,pe,void 0);D(this,ie,void 0);D(this,G,void 0);D(this,j,void 0);D(this,ae,void 0);D(this,de,void 0);D(this,re,void 0);D(this,se,void 0);D(this,ve,void 0);D(this,le,void 0);D(this,Ne,void 0);D(this,ze,void 0);D(this,be,void 0);D(this,$e,void 0);D(this,Oe,void 0);D(this,ce,void 0);D(this,Me,()=>{});D(this,Ve,()=>{});D(this,ut,()=>{});D(this,he,()=>!1);D(this,Be,e=>{});D(this,Je,(e,t,n)=>{});D(this,dt,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:l,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:u,dispose:f,disposeAfter:h,noDisposeOnSet:m,noUpdateTTL:v,maxSize:g=0,maxEntrySize:$=0,sizeCalculation:b,fetchMethod:y,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:T,ignoreFetchAbort:N}=e;if(t!==0&&!Fe(t))throw new TypeError("max option must be a nonnegative integer");const H=t?Rn(t):Array;if(!H)throw new Error("invalid max value: "+t);if(F(this,me,t),F(this,ue,g),this.maxEntrySize=$||c(this,ue),this.sizeCalculation=b,this.sizeCalculation){if(!c(this,ue)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(F(this,Ye,y),F(this,Oe,!!y),F(this,ie,new Map),F(this,G,new Array(t).fill(void 0)),F(this,j,new Array(t).fill(void 0)),F(this,ae,new H(t)),F(this,de,new H(t)),F(this,re,0),F(this,se,0),F(this,ve,Nt.create(t)),F(this,ne,0),F(this,pe,0),typeof f=="function"&&F(this,xe,f),typeof h=="function"?(F(this,ge,h),F(this,le,[])):(F(this,ge,void 0),F(this,le,void 0)),F(this,$e,!!c(this,xe)),F(this,ce,!!c(this,ge)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!v,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(c(this,ue)!==0&&!Fe(c(this,ue)))throw new TypeError("maxSize must be a positive integer if specified");if(!Fe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");I(this,Lt,jn).call(this)}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Fe(i)||i===0?i:1,this.ttlAutopurge=!!l,this.ttl=n||0,this.ttl){if(!Fe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");I(this,ct,Pt).call(this)}if(c(this,me)===0&&this.ttl===0&&c(this,ue)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!c(this,me)&&!c(this,ue)){const V="LRU_CACHE_UNBOUNDED";Qi(V)&&(Fn.add(V),Xi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",V,Qt))}}static unsafeExposeInternals(e){return{starts:c(e,ze),ttls:c(e,be),sizes:c(e,Ne),keyMap:c(e,ie),keyList:c(e,G),valList:c(e,j),next:c(e,ae),prev:c(e,de),get head(){return c(e,re)},get tail(){return c(e,se)},free:c(e,ve),isBackgroundFetch:t=>{var n;return I(n=e,Z,Q).call(n,t)},backgroundFetch:(t,n,i,l)=>{var a;return I(a=e,tt,Vt).call(a,t,n,i,l)},moveToTail:t=>{var n;return I(n=e,Ue,at).call(n,t)},indexes:t=>{var n;return I(n=e,Se,Re).call(n,t)},rindexes:t=>{var n;return I(n=e,Ce,je).call(n,t)},isStale:t=>{var n;return c(n=e,he).call(n,t)}}}get max(){return c(this,me)}get maxSize(){return c(this,ue)}get calculatedSize(){return c(this,pe)}get size(){return c(this,ne)}get fetchMethod(){return c(this,Ye)}get dispose(){return c(this,xe)}get disposeAfter(){return c(this,ge)}getRemainingTTL(e){return c(this,ie).has(e)?1/0:0}*entries(){for(const e of I(this,Se,Re).call(this))c(this,j)[e]!==void 0&&c(this,G)[e]!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield[c(this,G)[e],c(this,j)[e]])}*rentries(){for(const e of I(this,Ce,je).call(this))c(this,j)[e]!==void 0&&c(this,G)[e]!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield[c(this,G)[e],c(this,j)[e]])}*keys(){for(const e of I(this,Se,Re).call(this)){const t=c(this,G)[e];t!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield t)}}*rkeys(){for(const e of I(this,Ce,je).call(this)){const t=c(this,G)[e];t!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield t)}}*values(){for(const e of I(this,Se,Re).call(this))c(this,j)[e]!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield c(this,j)[e])}*rvalues(){for(const e of I(this,Ce,je).call(this))c(this,j)[e]!==void 0&&!I(this,Z,Q).call(this,c(this,j)[e])&&(yield c(this,j)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const n of I(this,Se,Re).call(this)){const i=c(this,j)[n],l=I(this,Z,Q).call(this,i)?i.__staleWhileFetching:i;if(l!==void 0&&e(l,c(this,G)[n],this))return this.get(c(this,G)[n],t)}}forEach(e,t=this){for(const n of I(this,Se,Re).call(this)){const i=c(this,j)[n],l=I(this,Z,Q).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&e.call(t,l,c(this,G)[n],this)}}rforEach(e,t=this){for(const n of I(this,Ce,je).call(this)){const i=c(this,j)[n],l=I(this,Z,Q).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&e.call(t,l,c(this,G)[n],this)}}purgeStale(){let e=!1;for(const t of I(this,Ce,je).call(this,{allowStale:!0}))c(this,he).call(this,t)&&(this.delete(c(this,G)[t]),e=!0);return e}dump(){const e=[];for(const t of I(this,Se,Re).call(this,{allowStale:!0})){const n=c(this,G)[t],i=c(this,j)[t],l=I(this,Z,Q).call(this,i)?i.__staleWhileFetching:i;if(l===void 0||n===void 0)continue;const a={value:l};if(c(this,be)&&c(this,ze)){a.ttl=c(this,be)[t];const o=lt.now()-c(this,ze)[t];a.start=Math.floor(Date.now()-o)}c(this,Ne)&&(a.size=c(this,Ne)[t]),e.unshift([n,a])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const i=Date.now()-n.start;n.start=lt.now()-i}this.set(t,n.value,n)}}set(e,t,n={}){var v,g,$;const{ttl:i=this.ttl,start:l,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:u}=n;let{noUpdateTTL:f=this.noUpdateTTL}=n;const h=c(this,dt).call(this,e,t,n.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.delete(e),this;let m=c(this,ne)===0?void 0:c(this,ie).get(e);if(m===void 0)m=c(this,ne)===0?c(this,se):c(this,ve).length!==0?c(this,ve).pop():c(this,ne)===c(this,me)?I(this,et,zt).call(this,!1):c(this,ne),c(this,G)[m]=e,c(this,j)[m]=t,c(this,ie).set(e,m),c(this,ae)[c(this,se)]=m,c(this,de)[m]=c(this,se),F(this,se,m),xt(this,ne)._++,c(this,Je).call(this,m,h,u),u&&(u.set="add"),f=!1;else{I(this,Ue,at).call(this,m);const b=c(this,j)[m];if(t!==b){if(c(this,Oe)&&I(this,Z,Q).call(this,b)?b.__abortController.abort(new Error("replaced")):a||(c(this,$e)&&((v=c(this,xe))==null||v.call(this,b,e,"set")),c(this,ce)&&((g=c(this,le))==null||g.push([b,e,"set"]))),c(this,Be).call(this,m),c(this,Je).call(this,m,h,u),c(this,j)[m]=t,u){u.set="replace";const y=b&&I(this,Z,Q).call(this,b)?b.__staleWhileFetching:b;y!==void 0&&(u.oldValue=y)}}else u&&(u.set="update")}if(i!==0&&!c(this,be)&&I(this,ct,Pt).call(this),c(this,be)&&(f||c(this,ut).call(this,m,i,l),u&&c(this,Ve).call(this,u,m)),!a&&c(this,ce)&&c(this,le)){const b=c(this,le);let y;for(;y=b==null?void 0:b.shift();)($=c(this,ge))==null||$.call(this,...y)}return this}pop(){var e;try{for(;c(this,ne);){const t=c(this,j)[c(this,re)];if(I(this,et,zt).call(this,!0),I(this,Z,Q).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(c(this,ce)&&c(this,le)){const t=c(this,le);let n;for(;n=t==null?void 0:t.shift();)(e=c(this,ge))==null||e.call(this,...n)}}}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,l=c(this,ie).get(e);if(l!==void 0)if(c(this,he).call(this,l))i&&(i.has="stale",c(this,Ve).call(this,i,l));else return n&&c(this,Me).call(this,l),i&&(i.has="hit",c(this,Ve).call(this,i,l)),!0;else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=c(this,ie).get(e);if(i!==void 0&&(n||!c(this,he).call(this,i))){const l=c(this,j)[i];return I(this,Z,Q).call(this,l)?l.__staleWhileFetching:l}}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:u=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:b,forceRefresh:y=!1,status:p,signal:w}=t;if(!c(this,Oe))return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,status:p});const S={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,ttl:a,noDisposeOnSet:o,size:u,sizeCalculation:f,noUpdateTTL:h,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:$,ignoreFetchAbort:g,status:p,signal:w};let T=c(this,ie).get(e);if(T===void 0){p&&(p.fetch="miss");const N=I(this,tt,Vt).call(this,e,T,S,b);return N.__returned=N}else{const N=c(this,j)[T];if(I(this,Z,Q).call(this,N)){const M=n&&N.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",M&&(p.returnedStale=!0)),M?N.__staleWhileFetching:N.__returned=N}const H=c(this,he).call(this,T);if(!y&&!H)return p&&(p.fetch="hit"),I(this,Ue,at).call(this,T),i&&c(this,Me).call(this,T),p&&c(this,Ve).call(this,p,T),N;const V=I(this,tt,Vt).call(this,e,T,S,b),q=V.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=H?"stale":"refresh",q&&H&&(p.returnedStale=!0)),q?V.__staleWhileFetching:V.__returned=V}}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,status:a}=t,o=c(this,ie).get(e);if(o!==void 0){const u=c(this,j)[o],f=I(this,Z,Q).call(this,u);return a&&c(this,Ve).call(this,a,o),c(this,he).call(this,o)?(a&&(a.get="stale"),f?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?u.__staleWhileFetching:void 0):(l||this.delete(e),a&&n&&(a.returnedStale=!0),n?u:void 0)):(a&&(a.get="hit"),f?u.__staleWhileFetching:(I(this,Ue,at).call(this,o),i&&c(this,Me).call(this,o),u))}else a&&(a.get="miss")}delete(e){var n,i,l,a;let t=!1;if(c(this,ne)!==0){const o=c(this,ie).get(e);if(o!==void 0)if(t=!0,c(this,ne)===1)this.clear();else{c(this,Be).call(this,o);const u=c(this,j)[o];I(this,Z,Q).call(this,u)?u.__abortController.abort(new Error("deleted")):(c(this,$e)||c(this,ce))&&(c(this,$e)&&((n=c(this,xe))==null||n.call(this,u,e,"delete")),c(this,ce)&&((i=c(this,le))==null||i.push([u,e,"delete"]))),c(this,ie).delete(e),c(this,G)[o]=void 0,c(this,j)[o]=void 0,o===c(this,se)?F(this,se,c(this,de)[o]):o===c(this,re)?F(this,re,c(this,ae)[o]):(c(this,ae)[c(this,de)[o]]=c(this,ae)[o],c(this,de)[c(this,ae)[o]]=c(this,de)[o]),xt(this,ne)._--,c(this,ve).push(o)}}if(c(this,ce)&&((l=c(this,le))!=null&&l.length)){const o=c(this,le);let u;for(;u=o==null?void 0:o.shift();)(a=c(this,ge))==null||a.call(this,...u)}return t}clear(){var e,t,n;for(const i of I(this,Ce,je).call(this,{allowStale:!0})){const l=c(this,j)[i];if(I(this,Z,Q).call(this,l))l.__abortController.abort(new Error("deleted"));else{const a=c(this,G)[i];c(this,$e)&&((e=c(this,xe))==null||e.call(this,l,a,"delete")),c(this,ce)&&((t=c(this,le))==null||t.push([l,a,"delete"]))}}if(c(this,ie).clear(),c(this,j).fill(void 0),c(this,G).fill(void 0),c(this,be)&&c(this,ze)&&(c(this,be).fill(0),c(this,ze).fill(0)),c(this,Ne)&&c(this,Ne).fill(0),F(this,re,0),F(this,se,0),c(this,ve).length=0,F(this,pe,0),F(this,ne,0),c(this,ce)&&c(this,le)){const i=c(this,le);let l;for(;l=i==null?void 0:i.shift();)(n=c(this,ge))==null||n.call(this,...l)}}};let Ht=Qt;me=new WeakMap,ue=new WeakMap,xe=new WeakMap,ge=new WeakMap,Ye=new WeakMap,ne=new WeakMap,pe=new WeakMap,ie=new WeakMap,G=new WeakMap,j=new WeakMap,ae=new WeakMap,de=new WeakMap,re=new WeakMap,se=new WeakMap,ve=new WeakMap,le=new WeakMap,Ne=new WeakMap,ze=new WeakMap,be=new WeakMap,$e=new WeakMap,Oe=new WeakMap,ce=new WeakMap,ct=new WeakSet,Pt=function(){const e=new Et(c(this,me)),t=new Et(c(this,me));F(this,be,e),F(this,ze,t),F(this,ut,(l,a,o=lt.now())=>{if(t[l]=a!==0?o:0,e[l]=a,a!==0&&this.ttlAutopurge){const u=setTimeout(()=>{c(this,he).call(this,l)&&this.delete(c(this,G)[l])},a+1);u.unref&&u.unref()}}),F(this,Me,l=>{t[l]=e[l]!==0?lt.now():0}),F(this,Ve,(l,a)=>{if(e[a]){const o=e[a],u=t[a];l.ttl=o,l.start=u,l.now=n||i(),l.remainingTTL=l.now+o-u}});let n=0;const i=()=>{const l=lt.now();if(this.ttlResolution>0){n=l;const a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return l};this.getRemainingTTL=l=>{const a=c(this,ie).get(l);return a===void 0?0:e[a]===0||t[a]===0?1/0:t[a]+e[a]-(n||i())},F(this,he,l=>e[l]!==0&&t[l]!==0&&(n||i())-t[l]>e[l])},Me=new WeakMap,Ve=new WeakMap,ut=new WeakMap,he=new WeakMap,Lt=new WeakSet,jn=function(){const e=new Et(c(this,me));F(this,pe,0),F(this,Ne,e),F(this,Be,t=>{F(this,pe,c(this,pe)-e[t]),e[t]=0}),F(this,dt,(t,n,i,l)=>{if(I(this,Z,Q).call(this,n))return 0;if(!Fe(i))if(l){if(typeof l!="function")throw new TypeError("sizeCalculation must be a function");if(i=l(n,t),!Fe(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),F(this,Je,(t,n,i)=>{if(e[t]=n,c(this,ue)){const l=c(this,ue)-e[t];for(;c(this,pe)>l;)I(this,et,zt).call(this,!0)}F(this,pe,c(this,pe)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=c(this,pe))})},Be=new WeakMap,Je=new WeakMap,dt=new WeakMap,Se=new WeakSet,Re=function*({allowStale:e=this.allowStale}={}){if(c(this,ne))for(let t=c(this,se);!(!I(this,ht,Mt).call(this,t)||((e||!c(this,he).call(this,t))&&(yield t),t===c(this,re)));)t=c(this,de)[t]},Ce=new WeakSet,je=function*({allowStale:e=this.allowStale}={}){if(c(this,ne))for(let t=c(this,re);!(!I(this,ht,Mt).call(this,t)||((e||!c(this,he).call(this,t))&&(yield t),t===c(this,se)));)t=c(this,ae)[t]},ht=new WeakSet,Mt=function(e){return e!==void 0&&c(this,ie).get(c(this,G)[e])===e},et=new WeakSet,zt=function(e){var l,a;const t=c(this,re),n=c(this,G)[t],i=c(this,j)[t];return c(this,Oe)&&I(this,Z,Q).call(this,i)?i.__abortController.abort(new Error("evicted")):(c(this,$e)||c(this,ce))&&(c(this,$e)&&((l=c(this,xe))==null||l.call(this,i,n,"evict")),c(this,ce)&&((a=c(this,le))==null||a.push([i,n,"evict"]))),c(this,Be).call(this,t),e&&(c(this,G)[t]=void 0,c(this,j)[t]=void 0,c(this,ve).push(t)),c(this,ne)===1?(F(this,re,F(this,se,0)),c(this,ve).length=0):F(this,re,c(this,ae)[t]),c(this,ie).delete(n),xt(this,ne)._--,t},tt=new WeakSet,Vt=function(e,t,n,i){const l=t===void 0?void 0:c(this,j)[t];if(I(this,Z,Q).call(this,l))return l;const a=new AbortController,{signal:o}=n;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const u={signal:a.signal,options:n,context:i},f=(b,y=!1)=>{const{aborted:p}=a.signal,w=n.ignoreFetchAbort&&b!==void 0;if(n.status&&(p&&!y?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,w&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!w&&!y)return m(a.signal.reason);const S=g;return c(this,j)[t]===g&&(b===void 0?S.__staleWhileFetching?c(this,j)[t]=S.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,b,u.options))),b},h=b=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=b),m(b)),m=b=>{const{aborted:y}=a.signal,p=y&&n.allowStaleOnFetchAbort,w=p||n.allowStaleOnFetchRejection,S=w||n.noDeleteOnFetchRejection,T=g;if(c(this,j)[t]===g&&(!S||T.__staleWhileFetching===void 0?this.delete(e):p||(c(this,j)[t]=T.__staleWhileFetching)),w)return n.status&&T.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),T.__staleWhileFetching;if(T.__returned===T)throw b},v=(b,y)=>{var w;const p=(w=c(this,Ye))==null?void 0:w.call(this,e,l,u);p&&p instanceof Promise&&p.then(S=>b(S),y),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(b(),n.allowStaleOnFetchAbort&&(b=S=>f(S,!0)))})};n.status&&(n.status.fetchDispatched=!0);const g=new Promise(v).then(f,h),$=Object.assign(g,{__abortController:a,__staleWhileFetching:l,__returned:void 0});return t===void 0?(this.set(e,$,{...u.options,status:void 0}),t=c(this,ie).get(e)):c(this,j)[t]=$,$},Z=new WeakSet,Q=function(e){if(!c(this,Oe))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},ft=new WeakSet,Bt=function(e,t){c(this,de)[t]=e,c(this,ae)[e]=t},Ue=new WeakSet,at=function(e){e!==c(this,se)&&(e===c(this,re)?F(this,re,c(this,ae)[e]):I(this,ft,Bt).call(this,c(this,de)[e],c(this,ae)[e]),I(this,ft,Bt).call(this,c(this,se),e),F(this,se,e))};const Yi=Ht,ot=s=>{const e=s.value,t=e.substring(0,s.selectionStart),n=e.substring(s.selectionEnd,e.length),i=t.lastIndexOf(`
|
|
51
51
|
`),l=t.substring(0,i+1),a=n.indexOf(`
|
|
52
|
-
`),o=n.substring(a===-1?n.length:a,n.length),u=t.substring(i+1,t.length),f=n.substring(0,a);return{prefixStr:t,subfixStr:n,prefixStrEndRow:l,subfixStrEndRow:o,prefixSupply:u,subfixSupply:f}},Ji=(s,e="",t,n)=>{var m,v,g,$,b,y;let i="",l=0,a=0,o=!1,u,f;const h=(m=J.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(s)){const p=s.replace(/^h(\d)/,(w,S)=>new Array(Number(S)).fill("#",0,S).join(""));i=`${p} ${e}`,l=p.length+1}else if(s==="prettier"){const p=window.prettier||((g=(v=J.editorExtensions)==null?void 0:v.prettier)==null?void 0:g.prettierInstance),w=[(($=window.prettierPlugins)==null?void 0:$.markdown)||((y=(b=J.editorExtensions)==null?void 0:b.prettier)==null?void 0:y.parserMarkdownInstance)];return!p||w[0]===void 0?(x.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),t.value):p.format(t.value,{parser:"markdown",plugins:w})}else switch(s){case"bold":{i=`**${e}**`,l=2,a=-2;break}case"underline":{i=`<u>${e}</u>`,l=3,a=-4;break}case"italic":{i=`*${e}*`,l=1,a=-1;break}case"strikeThrough":{i
|
|
52
|
+
`),o=n.substring(a===-1?n.length:a,n.length),u=t.substring(i+1,t.length),f=n.substring(0,a);return{prefixStr:t,subfixStr:n,prefixStrEndRow:l,subfixStrEndRow:o,prefixSupply:u,subfixSupply:f}},Ji=(s,e="",t,n)=>{var m,v,g,$,b,y;let i="",l=0,a=0,o=!1,u,f;const h=(m=J.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(s)){const p=s.replace(/^h(\d)/,(w,S)=>new Array(Number(S)).fill("#",0,S).join(""));i=`${p} ${e}`,l=p.length+1}else if(s==="prettier"){const p=window.prettier||((g=(v=J.editorExtensions)==null?void 0:v.prettier)==null?void 0:g.prettierInstance),w=[(($=window.prettierPlugins)==null?void 0:$.markdown)||((y=(b=J.editorExtensions)==null?void 0:b.prettier)==null?void 0:y.parserMarkdownInstance)];return!p||w[0]===void 0?(x.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),t.value):p.format(t.value,{parser:"markdown",plugins:w})}else switch(s){case"bold":{i=`**${e}**`,l=2,a=-2;break}case"underline":{i=`<u>${e}</u>`,l=3,a=-4;break}case"italic":{i=`*${e}*`,l=1,a=-1;break}case"strikeThrough":{i=`~~${e}~~`,l=2,a=-2;break}case"sub":{i=`<sub>${e}</sub>`,l=5,a=-6;break}case"sup":{i=`<sup>${e}</sup>`,l=5,a=-6;break}case"codeRow":{i="`"+e+"`",l=1,a=-1;break}case"quote":{i=`> ${e}`,l=2;break}case"orderedList":{i=`1. ${e}`,l=3;break}case"unorderedList":{i=`- ${e}`,l=2;break}case"task":{i=`- [ ] ${e}`,l=6,o=!0;break}case"code":{const p=n.text||e||"",w=n.mode||"language";i=`\`\`\`${w}
|
|
53
53
|
${p}
|
|
54
54
|
\`\`\`
|
|
55
55
|
`,l=3,a=3+w.length-i.length,o=!0;break}case"table":{i="|";const{selectedShape:p={x:1,y:1}}=n,{x:w,y:S}=p;for(let T=0;T<=S;T++)i+=" col |";i+=`
|
|
@@ -117,7 +117,7 @@ $$
|
|
|
117
117
|
`),icon:a,title:o,text:u,titleTokens:[],tokens:[],childTokens:["title","text"]};return this.lexer.inlineTokens(h.title,h.titleTokens),this.lexer.blockTokens(h.text,h.tokens),h}}},renderer(s){return`<div class="md-editor-alert md-editor-alert-${s.icon}">
|
|
118
118
|
<p class="md-editor-alert-title">${this.parser.parseInline(s.titleTokens,null)}</p>
|
|
119
119
|
${this.parser.parse(s.tokens)}
|
|
120
|
-
</div>`}},ns=typeof window>"u",is=(s,e,t)=>{var g,$;const n=r.inject("previewOnly"),i=r.inject("historyLength"),l=r.inject("editorId");if(n)return;let a=-1;const o={list:[{content:s.value,startPos:((g=e.value)==null?void 0:g.selectionStart)||0,endPos:(($=e.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},u=[0,0];let f=u;const h=b=>{var S,T;const y=((S=e.value)==null?void 0:S.selectionStart)||0,p=((T=e.value)==null?void 0:T.selectionEnd)||0;o.list[o.curr].startPos=y,o.list[o.curr].endPos=p,o.userUpdated=!1,o.curr=b;const w=o.list[o.curr];f=[w.startPos,w.endPos],s.onChange(w.content),Ee(e.value,w.startPos,w.endPos).then(()=>{x.emit(l,"selectTextChange")})},m=b=>{var w,S;clearTimeout(a);const y=((w=e.value)==null?void 0:w.selectionStart)||0,p=((S=e.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(o.userUpdated){o.curr<o.list.length-1&&(o.list=o.list.slice(0,o.curr+1)),o.list.length>i&&o.list.shift();const T=o.list.pop()||{startPos:0,endPos:0,content:b};T.startPos=f[0],T.endPos=f[1],f=u,Array.prototype.push.call(o.list,T,{content:b,startPos:y,endPos:p}),o.curr=o.list.length-1}else o.userUpdated=!0},150)},v=b=>{var y,p;(f===u||b)&&(f=[(y=e.value)==null?void 0:y.selectionStart,(p=e.value)==null?void 0:p.selectionEnd])};r.watch([r.toRef(s,"value"),t],()=>{t.value&&m(s.value)}),r.watch(()=>s.value,()=>{x.emit(l,"selectTextChange")},{flush:"post"}),r.onMounted(()=>{x.on(l,{name:"ctrlZ",callback(){h(o.curr-1<0?0:o.curr-1)}}),x.on(l,{name:"ctrlShiftZ",callback(){h(o.curr+1===o.list.length?o.curr:o.curr+1)}}),x.on(l,{name:"saveHistoryPos",callback:v})})},ss=(s,e)=>{var l;const t=(l=J.editorExtensions)==null?void 0:l.katex,n=t==null?void 0:t.instance,i=r.ref(!!n);return s.noKatex||e.use({extensions:[$n.inline(d,n),$n.block(d,n)]}),r.onMounted(()=>{if(!s.noKatex&&!n){const a=document.createElement("script");a.src=(t==null?void 0:t.js)||sn.js,a.onload=()=>{i.value=!0},a.id=`${d}-katex`;const o=document.createElement("link");o.rel="stylesheet",o.href=(t==null?void 0:t.css)||sn.css,o.id=`${d}-katexCss`,ke(a,"katex"),ke(o)}}),i},ls=s=>{var R,P;const{markedRenderer:e,markedExtensions:t,markedOptions:n,editorExtensions:i,editorConfig:l}=J,a=r.inject("showCodeRowNumber"),o=r.inject("editorId"),u=r.inject("highlight"),f=r.inject("previewOnly"),h=r.inject("theme"),m=(R=i==null?void 0:i.highlight)==null?void 0:R.instance,v=(P=i==null?void 0:i.mermaid)==null?void 0:P.instance,g=r.ref(!!m),$=r.ref([]);let b=[],y=[];const p=new Yi({max:1e3,ttl:6e5}),w=as(s),S=ss(s,_),T=r.computed(()=>(s.noMermaid||w.mermaidInited)&&g.value&&(s.noKatex||S.value));let N=new _.Renderer;N.image=(z,C,O)=>`<span class="figure"><img src="${z}" title="${C||""}" alt="${O||""}" zoom><span class="figcaption">${O||""}</span></span>`,N.listitem=(z,C)=>C?`<li class="li-task">${z}</li>`:`<li>${z}</li>`,e instanceof Function&&(N=e(N));const H=N.code;N.code=(z,C,O)=>{if(!s.noMermaid&&C==="mermaid"){const K=ti();try{if(ns)return`<p class="${d}-mermaid">${z}</p>`;{const ee=p.get(z);if(ee)return`<p class="${d}-mermaid" data-processed>${ee}</p>`;const fe=v||window.mermaid;if(w.mermaidInited){const De=(fe.renderAsync||fe.render)(K,z);De.then(Ie=>{p.set(z,typeof Ie=="string"?Ie:Ie.svg)}),b.push(De)}else return`<p class="${d}-mermaid">${z}</p>`}const Y=`<script type="text/tmplate">${K}<\/script>`;return y.push(Y),Y}catch(Y){return`<p class="${d}-mermaid-error">Error: ${(Y==null?void 0:Y.message)||""}</p>`}}return H.call(N,z,C,O).replace(/^<pre><code\sclass="language-([^>]*)">/,'<pre><code class="language-$1" language="$1">')};const V=N.heading,k=V!==new _.Renderer().heading;N.heading=(z,C,O,K)=>{$.value.push({text:O,level:C});const Y=s.markedHeadingId(O,C,$.value.length);return k?V.call(N,z,C,O,K,$.value.length,Y):z!==O?`<h${C} id="${Y}">${z}</h${C}>`:`<h${C} id="${Y}"><a href="#${Y}">${O}</a></h${C}>`},m&&_.setOptions({highlight:(z,C)=>{let O;const K=m.getLanguage(C);return C&&K?O=m.highlight(z,{language:C,ignoreIllegals:!0}).value:O=m.highlightAuto(z).value,a?rn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),_.setOptions({breaks:!0,...n}),t instanceof Array&&t.length>0&&_.use({extensions:t}),_.use({extensions:[ts]});const q=r.ref(s.sanitize(_(s.value||"",{renderer:N}))),M=async z=>{let C=s.sanitize(_(z,{renderer:N}));const O=[...b],K=[...y];return y=[],b=[],(await Promise.allSettled(O)).forEach((ee,fe)=>{ee.status==="fulfilled"?C=C.replace(K[fe],`<p class="${d}-mermaid" data-processed>${typeof ee.value=="string"?ee.value:ee.value.svg}</p>`):C=C.replace(K[fe],`<p class="${d}-mermaid-error">${ee.reason||""}</p>`)}),C},B=Ft(async()=>{$.value=[];const z=await M(s.value||"");q.value=z,x.emit(o,"buildFinished",q.value),s.onHtmlChanged(q.value)},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:f?0:500);r.watch([T,r.toRef(w,"reRender"),r.toRef(s,"value")],B),r.watch([h],()=>{p.clear()});const A=()=>{_.setOptions({highlight:(z,C)=>{let O;const K=window.hljs.getLanguage(C);return C&&K?O=window.hljs.highlight(z,{language:C,ignoreIllegals:!0}).value:O=window.hljs.highlightAuto(z).value,a?rn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),g.value=!0};return r.watch(()=>$.value,z=>{s.onGetCatalog(z),x.emit(o,"catalogChanged",z)}),r.onMounted(()=>{const z=document.createElement("
|
|
120
|
+
</div>`}},ns=typeof window>"u",is=(s,e,t)=>{var g,$;const n=r.inject("previewOnly"),i=r.inject("historyLength"),l=r.inject("editorId");if(n)return;let a=-1;const o={list:[{content:s.value,startPos:((g=e.value)==null?void 0:g.selectionStart)||0,endPos:(($=e.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},u=[0,0];let f=u;const h=b=>{var S,T;const y=((S=e.value)==null?void 0:S.selectionStart)||0,p=((T=e.value)==null?void 0:T.selectionEnd)||0;o.list[o.curr].startPos=y,o.list[o.curr].endPos=p,o.userUpdated=!1,o.curr=b;const w=o.list[o.curr];f=[w.startPos,w.endPos],s.onChange(w.content),Ee(e.value,w.startPos,w.endPos).then(()=>{x.emit(l,"selectTextChange")})},m=b=>{var w,S;clearTimeout(a);const y=((w=e.value)==null?void 0:w.selectionStart)||0,p=((S=e.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(o.userUpdated){o.curr<o.list.length-1&&(o.list=o.list.slice(0,o.curr+1)),o.list.length>i&&o.list.shift();const T=o.list.pop()||{startPos:0,endPos:0,content:b};T.startPos=f[0],T.endPos=f[1],f=u,Array.prototype.push.call(o.list,T,{content:b,startPos:y,endPos:p}),o.curr=o.list.length-1}else o.userUpdated=!0},150)},v=b=>{var y,p;(f===u||b)&&(f=[(y=e.value)==null?void 0:y.selectionStart,(p=e.value)==null?void 0:p.selectionEnd])};r.watch([r.toRef(s,"value"),t],()=>{t.value&&m(s.value)}),r.watch(()=>s.value,()=>{x.emit(l,"selectTextChange")},{flush:"post"}),r.onMounted(()=>{x.on(l,{name:"ctrlZ",callback(){h(o.curr-1<0?0:o.curr-1)}}),x.on(l,{name:"ctrlShiftZ",callback(){h(o.curr+1===o.list.length?o.curr:o.curr+1)}}),x.on(l,{name:"saveHistoryPos",callback:v})})},ss=(s,e)=>{var l;const t=(l=J.editorExtensions)==null?void 0:l.katex,n=t==null?void 0:t.instance,i=r.ref(!!n);return s.noKatex||e.use({extensions:[$n.inline(d,n),$n.block(d,n)]}),r.onMounted(()=>{if(!s.noKatex&&!n){const a=document.createElement("script");a.src=(t==null?void 0:t.js)||sn.js,a.onload=()=>{i.value=!0},a.id=`${d}-katex`;const o=document.createElement("link");o.rel="stylesheet",o.href=(t==null?void 0:t.css)||sn.css,o.id=`${d}-katexCss`,ke(a,"katex"),ke(o)}}),i},ls=s=>{var R,P;const{markedRenderer:e,markedExtensions:t,markedOptions:n,editorExtensions:i,editorConfig:l}=J,a=r.inject("showCodeRowNumber"),o=r.inject("editorId"),u=r.inject("highlight"),f=r.inject("previewOnly"),h=r.inject("theme"),m=(R=i==null?void 0:i.highlight)==null?void 0:R.instance,v=(P=i==null?void 0:i.mermaid)==null?void 0:P.instance,g=r.ref(!!m),$=r.ref([]);let b=[],y=[];const p=new Yi({max:1e3,ttl:6e5}),w=as(s),S=ss(s,_),T=r.computed(()=>(s.noMermaid||w.mermaidInited)&&g.value&&(s.noKatex||S.value));let N=new _.Renderer;N.image=(z,C,O)=>`<span class="figure"><img src="${z}" title="${C||""}" alt="${O||""}" zoom><span class="figcaption">${O||""}</span></span>`,N.listitem=(z,C)=>C?`<li class="li-task">${z}</li>`:`<li>${z}</li>`,e instanceof Function&&(N=e(N));const H=N.code;N.code=(z,C,O)=>{if(!s.noMermaid&&C==="mermaid"){const K=ti();try{if(ns)return`<p class="${d}-mermaid">${z}</p>`;{const ee=p.get(z);if(ee)return`<p class="${d}-mermaid" data-processed>${ee}</p>`;const fe=v||window.mermaid;if(w.mermaidInited){const De=(fe.renderAsync||fe.render)(K,z);De.then(Ie=>{p.set(z,typeof Ie=="string"?Ie:Ie.svg)}),b.push(De)}else return`<p class="${d}-mermaid">${z}</p>`}const Y=`<script type="text/tmplate">${K}<\/script>`;return y.push(Y),Y}catch(Y){return`<p class="${d}-mermaid-error">Error: ${(Y==null?void 0:Y.message)||""}</p>`}}return H.call(N,z,C,O).replace(/^<pre><code\sclass="language-([^>]*)">/,'<pre><code class="language-$1" language="$1">')};const V=N.heading,k=V!==new _.Renderer().heading;N.heading=(z,C,O,K)=>{$.value.push({text:O,level:C});const Y=s.markedHeadingId(O,C,$.value.length);return k?V.call(N,z,C,O,K,$.value.length,Y):z!==O?`<h${C} id="${Y}">${z}</h${C}>`:`<h${C} id="${Y}"><a href="#${Y}">${O}</a></h${C}>`},m&&_.setOptions({highlight:(z,C)=>{let O;const K=m.getLanguage(C);return C&&K?O=m.highlight(z,{language:C,ignoreIllegals:!0}).value:O=m.highlightAuto(z).value,a?rn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),_.setOptions({breaks:!0,...n}),t instanceof Array&&t.length>0&&_.use({extensions:t}),_.use({extensions:[ts]});const q=r.ref(s.sanitize(_(s.value||"",{renderer:N}))),M=async z=>{let C=s.sanitize(_(z,{renderer:N}));const O=[...b],K=[...y];return y=[],b=[],(await Promise.allSettled(O)).forEach((ee,fe)=>{ee.status==="fulfilled"?C=C.replace(K[fe],`<p class="${d}-mermaid" data-processed>${typeof ee.value=="string"?ee.value:ee.value.svg}</p>`):C=C.replace(K[fe],`<p class="${d}-mermaid-error">${ee.reason||""}</p>`)}),C},B=Ft(async()=>{$.value=[];const z=await M(s.value||"");q.value=z,x.emit(o,"buildFinished",q.value),s.onHtmlChanged(q.value)},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:f?0:500);r.watch([T,r.toRef(w,"reRender"),r.toRef(s,"value")],B),r.watch([h],()=>{p.clear()});const A=()=>{_.setOptions({highlight:(z,C)=>{let O;const K=window.hljs.getLanguage(C);return C&&K?O=window.hljs.highlight(z,{language:C,ignoreIllegals:!0}).value:O=window.hljs.highlightAuto(z).value,a?rn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),g.value=!0};return r.watch(()=>$.value,z=>{s.onGetCatalog(z),x.emit(o,"catalogChanged",z)}),r.onMounted(()=>{if(!m){const z=document.createElement("script");z.src=u.value.js,z.onload=A,z.id=`${d}-hljs`,ke(z,"hljs");const C=document.createElement("link");C.rel="stylesheet",C.href=u.value.css,C.id=`${d}-hlCss`,ke(C)}}),r.watch(()=>u.value.css,z=>{ni(`${d}-hlCss`,"href",z)}),r.onMounted(()=>{x.on(o,{name:"pushCatalog",callback(){x.emit(o,"catalogChanged",$.value)}})}),q},os=(s,e,t,n,i)=>{const l=r.inject("previewOnly"),a=r.inject("usedLanguageText"),o=r.inject("editorId");let u=()=>{},f=()=>{};const h=()=>{document.querySelectorAll(`#${o}-preview pre`).forEach(g=>{var p,w;let $=-1;(p=g.querySelector(".copy-button"))==null||p.remove();const b=((w=a.value.copyCode)==null?void 0:w.text)||"复制代码",y=document.createElement("span");y.setAttribute("class","copy-button"),y.dataset.tips=b,y.innerHTML=`<svg class="${d}-icon" aria-hidden="true"><use xlink:href="#${d}-icon-copy"></use></svg>`,y.addEventListener("click",()=>{var V,k;clearTimeout($);const S=g.querySelector("code").innerText,T=rt(s.formatCopiedText(S)),N=((V=a.value.copyCode)==null?void 0:V.successTips)||"已复制!",H=((k=a.value.copyCode)==null?void 0:k.failTips)||"已复制!";y.dataset.tips=T?N:H,$=window.setTimeout(()=>{y.dataset.tips=b},1500)}),g.appendChild(y)})},m=()=>{r.nextTick(()=>{s.setting.preview&&!l&&s.scrollAuto&&(u(),f()),h()})},v=g=>{g&&!l&&r.nextTick(()=>{u(),[f,u]=on(t.value,n.value||i.value),f(),h()})};r.watch(()=>e.value,m),r.watch(()=>a.value,h),r.watch(()=>s.setting.preview,v),r.watch(()=>s.setting.htmlPreview,v),r.watch(()=>s.scrollAuto,g=>{g?f():u()}),r.onMounted(()=>{h(),!l&&(n.value||i.value)&&([f,u]=on(t.value,n.value||i.value)),s.scrollAuto&&f()})},rs=(s,e)=>{const t=r.inject("previewOnly"),n=r.inject("tabWidth"),i=r.inject("editorId"),l=r.ref("");r.onMounted(()=>{var a;t||((a=e.value)==null||a.addEventListener("keypress",o=>{var u,f,h;if(o.key==="Enter"){const m=(u=e.value)==null?void 0:u.selectionStart,v=(f=e.value)==null?void 0:f.value.substring(0,m),g=(h=e.value)==null?void 0:h.value.substring(m),$=v==null?void 0:v.lastIndexOf(`
|
|
121
121
|
`),b=v==null?void 0:v.substring($+1,m);if(/^\d+\.\s|^-\s/.test(b))if(o.cancelBubble=!0,o.preventDefault(),o.stopPropagation(),/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(b)){const y=v==null?void 0:v.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/,"");s.onChange(y+g),Ee(e.value,y==null?void 0:y.length)}else if(/^-\s+.+/.test(b)){const y=/^-\s+\[[x\s]\]/.test(b)?`
|
|
122
122
|
- [ ] `:`
|
|
123
123
|
- `;s.onChange(Ot(e.value,y,{}))}else{const y=b==null?void 0:b.match(/\d+(?=\.)/),p=y&&Number(y[0])+1||1,w=/^\d\.\s+\[[x\s]\]/.test(b)?`
|
package/lib/md-editor-v3.mjs
CHANGED
|
@@ -4656,7 +4656,7 @@ const fs = Yt, gt = (s) => {
|
|
|
4656
4656
|
break;
|
|
4657
4657
|
}
|
|
4658
4658
|
case "strikeThrough": {
|
|
4659
|
-
i =
|
|
4659
|
+
i = `~~${e}~~`, l = 2, r = -2;
|
|
4660
4660
|
break;
|
|
4661
4661
|
}
|
|
4662
4662
|
case "sub": {
|
|
@@ -5254,10 +5254,11 @@ $$
|
|
|
5254
5254
|
s.onGetCatalog(_), x.emit(o, "catalogChanged", _);
|
|
5255
5255
|
}
|
|
5256
5256
|
), ie(() => {
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5257
|
+
if (!m) {
|
|
5258
|
+
const _ = document.createElement("script");
|
|
5259
|
+
_.src = c.value.js, _.onload = L, _.id = `${d}-hljs`, Ce(_, "hljs");
|
|
5260
|
+
const C = document.createElement("link");
|
|
5261
|
+
C.rel = "stylesheet", C.href = c.value.css, C.id = `${d}-hlCss`, Ce(C);
|
|
5261
5262
|
}
|
|
5262
5263
|
}), W(
|
|
5263
5264
|
() => c.value.css,
|
package/lib/md-editor-v3.umd.js
CHANGED
|
@@ -49,7 +49,7 @@ Please report this to https://github.com/markedjs/marked.`,t.silent)return"<p>An
|
|
|
49
49
|
Expects a CSS selector, a Node element, a NodeList or an array.
|
|
50
50
|
See: https://github.com/francoischalifour/medium-zoom`)}},Mi=function(t){var e=document.createElement("div");return e.classList.add("medium-zoom-overlay"),e.style.background=t,e},Bi=function(t){var e=t.getBoundingClientRect(),n=e.top,i=e.left,l=e.width,a=e.height,r=t.cloneNode(),d=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,f=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return r.removeAttribute("id"),r.style.position="absolute",r.style.top=n+d+"px",r.style.left=i+f+"px",r.style.width=l+"px",r.style.height=a+"px",r.style.transform="",r},Ze=function(t,e){var n=He({bubbles:!1,cancelable:!1,detail:void 0},e);if(typeof window.CustomEvent=="function")return new CustomEvent(t,n);var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,n.bubbles,n.cancelable,n.detail),i},Ui=function s(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=window.Promise||function(A){function R(){}A(R,R)},i=function(A){var R=A.target;if(R===K){$();return}S.indexOf(R)!==-1&&k({target:R})},l=function(){if(!(N||!y.original)){var A=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(H-A)>V.scrollOffset&&setTimeout($,150)}},a=function(A){var R=A.key||A.keyCode;(R==="Escape"||R==="Esc"||R===27)&&$()},r=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A;if(A.background&&(K.style.background=A.background),A.container&&A.container instanceof Object&&(R.container=He({},V.container,A.container)),A.template){var P=vt(A.template)?A.template:document.querySelector(A.template);R.template=P}return V=He({},V,R),S.forEach(function(z){z.dispatchEvent(Ze("medium-zoom:update",{detail:{zoom:M}}))}),M},d=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s(He({},V,A))},f=function(){for(var A=arguments.length,R=Array(A),P=0;P<A;P++)R[P]=arguments[P];var z=R.reduce(function(C,O){return[].concat(C,In(O))},[]);return z.filter(function(C){return S.indexOf(C)===-1}).forEach(function(C){S.push(C),C.classList.add("medium-zoom-image")}),T.forEach(function(C){var O=C.type,G=C.listener,ee=C.options;z.forEach(function(te){te.addEventListener(O,G,ee)})}),M},h=function(){for(var A=arguments.length,R=Array(A),P=0;P<A;P++)R[P]=arguments[P];y.zoomed&&$();var z=R.length>0?R.reduce(function(C,O){return[].concat(C,In(O))},[]):S;return z.forEach(function(C){C.classList.remove("medium-zoom-image"),C.dispatchEvent(Ze("medium-zoom:detach",{detail:{zoom:M}}))}),S=S.filter(function(C){return z.indexOf(C)===-1}),M},m=function(A,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.addEventListener("medium-zoom:"+A,R,P)}),T.push({type:"medium-zoom:"+A,listener:R,options:P}),M},b=function(A,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.removeEventListener("medium-zoom:"+A,R,P)}),T=T.filter(function(z){return!(z.type==="medium-zoom:"+A&&z.listener.toString()===R.toString())}),M},g=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A.target,P=function(){var C={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},O=void 0,G=void 0;if(V.container)if(V.container instanceof Object)C=He({},C,V.container),O=C.width-C.left-C.right-V.margin*2,G=C.height-C.top-C.bottom-V.margin*2;else{var ee=vt(V.container)?V.container:document.querySelector(V.container),te=ee.getBoundingClientRect(),me=te.width,ft=te.height,Ue=te.left,Re=te.top;C=He({},C,{width:me,height:ft,left:Ue,top:Re})}O=O||C.width-V.margin*2,G=G||C.height-V.margin*2;var je=y.zoomedHd||y.original,Et=An(je)?O:je.naturalWidth||O,Nt=An(je)?G:je.naturalHeight||G,qe=je.getBoundingClientRect(),zt=qe.top,Vt=qe.left,nt=qe.width,it=qe.height,_t=Math.min(Math.max(nt,Et),O)/nt,At=Math.min(Math.max(it,Nt),G)/it,st=Math.min(_t,At),It=(-Vt+(O-nt)/2+V.margin+C.left)/st,Lt=(-zt+(G-it)/2+V.margin+C.top)/st,mt="scale("+st+") translate3d("+It+"px, "+Lt+"px, 0)";y.zoomed.style.transform=mt,y.zoomedHd&&(y.zoomedHd.style.transform=mt)};return new n(function(z){if(R&&S.indexOf(R)===-1){z(M);return}var C=function me(){N=!1,y.zoomed.removeEventListener("transitionend",me),y.original.dispatchEvent(Ze("medium-zoom:opened",{detail:{zoom:M}})),z(M)};if(y.zoomed){z(M);return}if(R)y.original=R;else if(S.length>0){var O=S;y.original=O[0]}else{z(M);return}if(y.original.dispatchEvent(Ze("medium-zoom:open",{detail:{zoom:M}})),H=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,N=!0,y.zoomed=Bi(y.original),document.body.appendChild(K),V.template){var G=vt(V.template)?V.template:document.querySelector(V.template);y.template=document.createElement("div"),y.template.appendChild(G.content.cloneNode(!0)),document.body.appendChild(y.template)}if(y.original.parentElement&&y.original.parentElement.tagName==="PICTURE"&&y.original.currentSrc&&(y.zoomed.src=y.original.currentSrc),document.body.appendChild(y.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),y.original.classList.add("medium-zoom-image--hidden"),y.zoomed.classList.add("medium-zoom-image--opened"),y.zoomed.addEventListener("click",$),y.zoomed.addEventListener("transitionend",C),y.original.getAttribute("data-zoom-src")){y.zoomedHd=y.zoomed.cloneNode(),y.zoomedHd.removeAttribute("srcset"),y.zoomedHd.removeAttribute("sizes"),y.zoomedHd.removeAttribute("loading"),y.zoomedHd.src=y.zoomed.getAttribute("data-zoom-src"),y.zoomedHd.onerror=function(){clearInterval(ee),console.warn("Unable to reach the zoom image target "+y.zoomedHd.src),y.zoomedHd=null,P()};var ee=setInterval(function(){y.zoomedHd.complete&&(clearInterval(ee),y.zoomedHd.classList.add("medium-zoom-image--opened"),y.zoomedHd.addEventListener("click",$),document.body.appendChild(y.zoomedHd),P())},10)}else if(y.original.hasAttribute("srcset")){y.zoomedHd=y.zoomed.cloneNode(),y.zoomedHd.removeAttribute("sizes"),y.zoomedHd.removeAttribute("loading");var te=y.zoomedHd.addEventListener("load",function(){y.zoomedHd.removeEventListener("load",te),y.zoomedHd.classList.add("medium-zoom-image--opened"),y.zoomedHd.addEventListener("click",$),document.body.appendChild(y.zoomedHd),P()})}else P()})},$=function(){return new n(function(A){if(N||!y.original){A(M);return}var R=function P(){y.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(y.zoomed),y.zoomedHd&&document.body.removeChild(y.zoomedHd),document.body.removeChild(K),y.zoomed.classList.remove("medium-zoom-image--opened"),y.template&&document.body.removeChild(y.template),N=!1,y.zoomed.removeEventListener("transitionend",P),y.original.dispatchEvent(Ze("medium-zoom:closed",{detail:{zoom:M}})),y.original=null,y.zoomed=null,y.zoomedHd=null,y.template=null,A(M)};N=!0,document.body.classList.remove("medium-zoom--opened"),y.zoomed.style.transform="",y.zoomedHd&&(y.zoomedHd.style.transform=""),y.template&&(y.template.style.transition="opacity 150ms",y.template.style.opacity=0),y.original.dispatchEvent(Ze("medium-zoom:close",{detail:{zoom:M}})),y.zoomed.addEventListener("transitionend",R)})},k=function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A.target;return y.original?$():g({target:R})},w=function(){return V},p=function(){return S},x=function(){return y.original},S=[],T=[],N=!1,H=0,V=e,y={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(t)==="[object Object]"?V=t:(t||typeof t=="string")&&f(t),V=He({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},V);var K=Mi(V.background);document.addEventListener("click",i),document.addEventListener("keyup",a),document.addEventListener("scroll",l),window.addEventListener("resize",$);var M={open:g,close:$,toggle:k,update:r,clone:d,attach:f,detach:h,on:m,off:b,getOptions:w,getImages:p,getZoomedImage:x};return M};function qi(s,t){t===void 0&&(t={});var e=t.insertAt;if(!(!s||typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var Wi=".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";qi(Wi);const Ki=Ui,ot=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ln=new Set,Gi=(s,t,e,n)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(s,t,e,n):console.error(`[${e}] ${t}: ${s}`)},Zi=s=>!Ln.has(s),Le=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Fn=s=>Le(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?$t:null:null;class $t extends Array{constructor(t){super(t),this.fill(0)}}const Qe=class{constructor(t,e){se(this,"heap");se(this,"length");if(!c(Qe,Xe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}static create(t){const e=Fn(t);if(!e)return[];F(Qe,Xe,!0);const n=new Qe(t,e);return F(Qe,Xe,!1),n}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}};let St=Qe;Xe=new WeakMap,D(St,Xe,!1);const Zt=class{constructor(t){D(this,at);D(this,Tt);D(this,Te);D(this,Ee);D(this,ut);D(this,et);D(this,tt);D(this,X);D(this,ht);D(this,Be);D(this,ke,void 0);D(this,ue,void 0);D(this,Se,void 0);D(this,ye,void 0);D(this,Ye,void 0);se(this,"ttl");se(this,"ttlResolution");se(this,"ttlAutopurge");se(this,"updateAgeOnGet");se(this,"updateAgeOnHas");se(this,"allowStale");se(this,"noDisposeOnSet");se(this,"noUpdateTTL");se(this,"maxEntrySize");se(this,"sizeCalculation");se(this,"noDeleteOnFetchRejection");se(this,"noDeleteOnStaleGet");se(this,"allowStaleOnFetchAbort");se(this,"allowStaleOnFetchRejection");se(this,"ignoreFetchAbort");D(this,ne,void 0);D(this,we,void 0);D(this,ie,void 0);D(this,Z,void 0);D(this,j,void 0);D(this,ce,void 0);D(this,he,void 0);D(this,ae,void 0);D(this,le,void 0);D(this,xe,void 0);D(this,re,void 0);D(this,_e,void 0);D(this,Ae,void 0);D(this,ve,void 0);D(this,Ce,void 0);D(this,Fe,void 0);D(this,de,void 0);D(this,Pe,()=>{});D(this,Ie,()=>{});D(this,ct,()=>{});D(this,fe,()=>!1);D(this,Me,t=>{});D(this,Je,(t,e,n)=>{});D(this,dt,(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:l,updateAgeOnGet:a,updateAgeOnHas:r,allowStale:d,dispose:f,disposeAfter:h,noDisposeOnSet:m,noUpdateTTL:b,maxSize:g=0,maxEntrySize:$=0,sizeCalculation:k,fetchMethod:w,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:T,ignoreFetchAbort:N}=t;if(e!==0&&!Le(e))throw new TypeError("max option must be a nonnegative integer");const H=e?Fn(e):Array;if(!H)throw new Error("invalid max value: "+e);if(F(this,ke,e),F(this,ue,g),this.maxEntrySize=$||c(this,ue),this.sizeCalculation=k,this.sizeCalculation){if(!c(this,ue)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(F(this,Ye,w),F(this,Fe,!!w),F(this,ie,new Map),F(this,Z,new Array(e).fill(void 0)),F(this,j,new Array(e).fill(void 0)),F(this,ce,new H(e)),F(this,he,new H(e)),F(this,ae,0),F(this,le,0),F(this,xe,St.create(e)),F(this,ne,0),F(this,we,0),typeof f=="function"&&F(this,Se,f),typeof h=="function"?(F(this,ye,h),F(this,re,[])):(F(this,ye,void 0),F(this,re,void 0)),F(this,Ce,!!c(this,Se)),F(this,de,!!c(this,ye)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(c(this,ue)!==0&&!Le(c(this,ue)))throw new TypeError("maxSize must be a positive integer if specified");if(!Le(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");I(this,Tt,Pn).call(this)}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!r,this.ttlResolution=Le(i)||i===0?i:1,this.ttlAutopurge=!!l,this.ttl=n||0,this.ttl){if(!Le(this.ttl))throw new TypeError("ttl must be a positive integer if specified");I(this,at,Qt).call(this)}if(c(this,ke)===0&&this.ttl===0&&c(this,ue)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!c(this,ke)&&!c(this,ue)){const V="LRU_CACHE_UNBOUNDED";Zi(V)&&(Ln.add(V),Gi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",V,Zt))}}static unsafeExposeInternals(t){return{starts:c(t,Ae),ttls:c(t,ve),sizes:c(t,_e),keyMap:c(t,ie),keyList:c(t,Z),valList:c(t,j),next:c(t,ce),prev:c(t,he),get head(){return c(t,ae)},get tail(){return c(t,le)},free:c(t,xe),isBackgroundFetch:e=>{var n;return I(n=t,X,Q).call(n,e)},backgroundFetch:(e,n,i,l)=>{var a;return I(a=t,tt,jt).call(a,e,n,i,l)},moveToTail:e=>{var n;return I(n=t,Be,gt).call(n,e)},indexes:e=>{var n;return I(n=t,Te,Oe).call(n,e)},rindexes:e=>{var n;return I(n=t,Ee,De).call(n,e)},isStale:e=>{var n;return c(n=t,fe).call(n,e)}}}get max(){return c(this,ke)}get maxSize(){return c(this,ue)}get calculatedSize(){return c(this,we)}get size(){return c(this,ne)}get fetchMethod(){return c(this,Ye)}get dispose(){return c(this,Se)}get disposeAfter(){return c(this,ye)}getRemainingTTL(t){return c(this,ie).has(t)?1/0:0}*entries(){for(const t of I(this,Te,Oe).call(this))c(this,j)[t]!==void 0&&c(this,Z)[t]!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield[c(this,Z)[t],c(this,j)[t]])}*rentries(){for(const t of I(this,Ee,De).call(this))c(this,j)[t]!==void 0&&c(this,Z)[t]!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield[c(this,Z)[t],c(this,j)[t]])}*keys(){for(const t of I(this,Te,Oe).call(this)){const e=c(this,Z)[t];e!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield e)}}*rkeys(){for(const t of I(this,Ee,De).call(this)){const e=c(this,Z)[t];e!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield e)}}*values(){for(const t of I(this,Te,Oe).call(this))c(this,j)[t]!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield c(this,j)[t])}*rvalues(){for(const t of I(this,Ee,De).call(this))c(this,j)[t]!==void 0&&!I(this,X,Q).call(this,c(this,j)[t])&&(yield c(this,j)[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of I(this,Te,Oe).call(this)){const i=c(this,j)[n],l=I(this,X,Q).call(this,i)?i.__staleWhileFetching:i;if(l!==void 0&&t(l,c(this,Z)[n],this))return this.get(c(this,Z)[n],e)}}forEach(t,e=this){for(const n of I(this,Te,Oe).call(this)){const i=c(this,j)[n],l=I(this,X,Q).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&t.call(e,l,c(this,Z)[n],this)}}rforEach(t,e=this){for(const n of I(this,Ee,De).call(this)){const i=c(this,j)[n],l=I(this,X,Q).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&t.call(e,l,c(this,Z)[n],this)}}purgeStale(){let t=!1;for(const e of I(this,Ee,De).call(this,{allowStale:!0}))c(this,fe).call(this,e)&&(this.delete(c(this,Z)[e]),t=!0);return t}dump(){const t=[];for(const e of I(this,Te,Oe).call(this,{allowStale:!0})){const n=c(this,Z)[e],i=c(this,j)[e],l=I(this,X,Q).call(this,i)?i.__staleWhileFetching:i;if(l===void 0||n===void 0)continue;const a={value:l};if(c(this,ve)&&c(this,Ae)){a.ttl=c(this,ve)[e];const r=ot.now()-c(this,Ae)[e];a.start=Math.floor(Date.now()-r)}c(this,_e)&&(a.size=c(this,_e)[e]),t.unshift([n,a])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const i=Date.now()-n.start;n.start=ot.now()-i}this.set(e,n.value,n)}}set(t,e,n={}){var b,g,$;const{ttl:i=this.ttl,start:l,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:r=this.sizeCalculation,status:d}=n;let{noUpdateTTL:f=this.noUpdateTTL}=n;const h=c(this,dt).call(this,t,e,n.size||0,r);if(this.maxEntrySize&&h>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(t),this;let m=c(this,ne)===0?void 0:c(this,ie).get(t);if(m===void 0)m=c(this,ne)===0?c(this,le):c(this,xe).length!==0?c(this,xe).pop():c(this,ne)===c(this,ke)?I(this,et,Rt).call(this,!1):c(this,ne),c(this,Z)[m]=t,c(this,j)[m]=e,c(this,ie).set(t,m),c(this,ce)[c(this,le)]=m,c(this,he)[m]=c(this,le),F(this,le,m),Ft(this,ne)._++,c(this,Je).call(this,m,h,d),d&&(d.set="add"),f=!1;else{I(this,Be,gt).call(this,m);const k=c(this,j)[m];if(e!==k){if(c(this,Fe)&&I(this,X,Q).call(this,k)?k.__abortController.abort(new Error("replaced")):a||(c(this,Ce)&&((b=c(this,Se))==null||b.call(this,k,t,"set")),c(this,de)&&((g=c(this,re))==null||g.push([k,t,"set"]))),c(this,Me).call(this,m),c(this,Je).call(this,m,h,d),c(this,j)[m]=e,d){d.set="replace";const w=k&&I(this,X,Q).call(this,k)?k.__staleWhileFetching:k;w!==void 0&&(d.oldValue=w)}}else d&&(d.set="update")}if(i!==0&&!c(this,ve)&&I(this,at,Qt).call(this),c(this,ve)&&(f||c(this,ct).call(this,m,i,l),d&&c(this,Ie).call(this,d,m)),!a&&c(this,de)&&c(this,re)){const k=c(this,re);let w;for(;w=k==null?void 0:k.shift();)($=c(this,ye))==null||$.call(this,...w)}return this}pop(){var t;try{for(;c(this,ne);){const e=c(this,j)[c(this,ae)];if(I(this,et,Rt).call(this,!0),I(this,X,Q).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(c(this,de)&&c(this,re)){const e=c(this,re);let n;for(;n=e==null?void 0:e.shift();)(t=c(this,ye))==null||t.call(this,...n)}}}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,l=c(this,ie).get(t);if(l!==void 0)if(c(this,fe).call(this,l))i&&(i.has="stale",c(this,Ie).call(this,i,l));else return n&&c(this,Pe).call(this,l),i&&(i.has="hit",c(this,Ie).call(this,i,l)),!0;else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=c(this,ie).get(t);if(i!==void 0&&(n||!c(this,fe).call(this,i))){const l=c(this,j)[i];return I(this,X,Q).call(this,l)?l.__staleWhileFetching:l}}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:r=this.noDisposeOnSet,size:d=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:k,forceRefresh:w=!1,status:p,signal:x}=e;if(!c(this,Fe))return p&&(p.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,status:p});const S={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,ttl:a,noDisposeOnSet:r,size:d,sizeCalculation:f,noUpdateTTL:h,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:$,ignoreFetchAbort:g,status:p,signal:x};let T=c(this,ie).get(t);if(T===void 0){p&&(p.fetch="miss");const N=I(this,tt,jt).call(this,t,T,S,k);return N.__returned=N}else{const N=c(this,j)[T];if(I(this,X,Q).call(this,N)){const M=n&&N.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",M&&(p.returnedStale=!0)),M?N.__staleWhileFetching:N.__returned=N}const H=c(this,fe).call(this,T);if(!w&&!H)return p&&(p.fetch="hit"),I(this,Be,gt).call(this,T),i&&c(this,Pe).call(this,T),p&&c(this,Ie).call(this,p,T),N;const V=I(this,tt,jt).call(this,t,T,S,k),K=V.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=H?"stale":"refresh",K&&H&&(p.returnedStale=!0)),K?V.__staleWhileFetching:V.__returned=V}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,status:a}=e,r=c(this,ie).get(t);if(r!==void 0){const d=c(this,j)[r],f=I(this,X,Q).call(this,d);return a&&c(this,Ie).call(this,a,r),c(this,fe).call(this,r)?(a&&(a.get="stale"),f?(a&&n&&d.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?d.__staleWhileFetching:void 0):(l||this.delete(t),a&&n&&(a.returnedStale=!0),n?d:void 0)):(a&&(a.get="hit"),f?d.__staleWhileFetching:(I(this,Be,gt).call(this,r),i&&c(this,Pe).call(this,r),d))}else a&&(a.get="miss")}delete(t){var n,i,l,a;let e=!1;if(c(this,ne)!==0){const r=c(this,ie).get(t);if(r!==void 0)if(e=!0,c(this,ne)===1)this.clear();else{c(this,Me).call(this,r);const d=c(this,j)[r];I(this,X,Q).call(this,d)?d.__abortController.abort(new Error("deleted")):(c(this,Ce)||c(this,de))&&(c(this,Ce)&&((n=c(this,Se))==null||n.call(this,d,t,"delete")),c(this,de)&&((i=c(this,re))==null||i.push([d,t,"delete"]))),c(this,ie).delete(t),c(this,Z)[r]=void 0,c(this,j)[r]=void 0,r===c(this,le)?F(this,le,c(this,he)[r]):r===c(this,ae)?F(this,ae,c(this,ce)[r]):(c(this,ce)[c(this,he)[r]]=c(this,ce)[r],c(this,he)[c(this,ce)[r]]=c(this,he)[r]),Ft(this,ne)._--,c(this,xe).push(r)}}if(c(this,de)&&((l=c(this,re))!=null&&l.length)){const r=c(this,re);let d;for(;d=r==null?void 0:r.shift();)(a=c(this,ye))==null||a.call(this,...d)}return e}clear(){var t,e,n;for(const i of I(this,Ee,De).call(this,{allowStale:!0})){const l=c(this,j)[i];if(I(this,X,Q).call(this,l))l.__abortController.abort(new Error("deleted"));else{const a=c(this,Z)[i];c(this,Ce)&&((t=c(this,Se))==null||t.call(this,l,a,"delete")),c(this,de)&&((e=c(this,re))==null||e.push([l,a,"delete"]))}}if(c(this,ie).clear(),c(this,j).fill(void 0),c(this,Z).fill(void 0),c(this,ve)&&c(this,Ae)&&(c(this,ve).fill(0),c(this,Ae).fill(0)),c(this,_e)&&c(this,_e).fill(0),F(this,ae,0),F(this,le,0),c(this,xe).length=0,F(this,we,0),F(this,ne,0),c(this,de)&&c(this,re)){const i=c(this,re);let l;for(;l=i==null?void 0:i.shift();)(n=c(this,ye))==null||n.call(this,...l)}}};let Ut=Zt;ke=new WeakMap,ue=new WeakMap,Se=new WeakMap,ye=new WeakMap,Ye=new WeakMap,ne=new WeakMap,we=new WeakMap,ie=new WeakMap,Z=new WeakMap,j=new WeakMap,ce=new WeakMap,he=new WeakMap,ae=new WeakMap,le=new WeakMap,xe=new WeakMap,re=new WeakMap,_e=new WeakMap,Ae=new WeakMap,ve=new WeakMap,Ce=new WeakMap,Fe=new WeakMap,de=new WeakMap,at=new WeakSet,Qt=function(){const t=new $t(c(this,ke)),e=new $t(c(this,ke));F(this,ve,t),F(this,Ae,e),F(this,ct,(l,a,r=ot.now())=>{if(e[l]=a!==0?r:0,t[l]=a,a!==0&&this.ttlAutopurge){const d=setTimeout(()=>{c(this,fe).call(this,l)&&this.delete(c(this,Z)[l])},a+1);d.unref&&d.unref()}}),F(this,Pe,l=>{e[l]=t[l]!==0?ot.now():0}),F(this,Ie,(l,a)=>{if(t[a]){const r=t[a],d=e[a];l.ttl=r,l.start=d,l.now=n||i(),l.remainingTTL=l.now+r-d}});let n=0;const i=()=>{const l=ot.now();if(this.ttlResolution>0){n=l;const a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return l};this.getRemainingTTL=l=>{const a=c(this,ie).get(l);return a===void 0?0:t[a]===0||e[a]===0?1/0:e[a]+t[a]-(n||i())},F(this,fe,l=>t[l]!==0&&e[l]!==0&&(n||i())-e[l]>t[l])},Pe=new WeakMap,Ie=new WeakMap,ct=new WeakMap,fe=new WeakMap,Tt=new WeakSet,Pn=function(){const t=new $t(c(this,ke));F(this,we,0),F(this,_e,t),F(this,Me,e=>{F(this,we,c(this,we)-t[e]),t[e]=0}),F(this,dt,(e,n,i,l)=>{if(I(this,X,Q).call(this,n))return 0;if(!Le(i))if(l){if(typeof l!="function")throw new TypeError("sizeCalculation must be a function");if(i=l(n,e),!Le(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),F(this,Je,(e,n,i)=>{if(t[e]=n,c(this,ue)){const l=c(this,ue)-t[e];for(;c(this,we)>l;)I(this,et,Rt).call(this,!0)}F(this,we,c(this,we)+t[e]),i&&(i.entrySize=n,i.totalCalculatedSize=c(this,we))})},Me=new WeakMap,Je=new WeakMap,dt=new WeakMap,Te=new WeakSet,Oe=function*({allowStale:t=this.allowStale}={}){if(c(this,ne))for(let e=c(this,le);!(!I(this,ut,Yt).call(this,e)||((t||!c(this,fe).call(this,e))&&(yield e),e===c(this,ae)));)e=c(this,he)[e]},Ee=new WeakSet,De=function*({allowStale:t=this.allowStale}={}){if(c(this,ne))for(let e=c(this,ae);!(!I(this,ut,Yt).call(this,e)||((t||!c(this,fe).call(this,e))&&(yield e),e===c(this,le)));)e=c(this,ce)[e]},ut=new WeakSet,Yt=function(t){return t!==void 0&&c(this,ie).get(c(this,Z)[t])===t},et=new WeakSet,Rt=function(t){var l,a;const e=c(this,ae),n=c(this,Z)[e],i=c(this,j)[e];return c(this,Fe)&&I(this,X,Q).call(this,i)?i.__abortController.abort(new Error("evicted")):(c(this,Ce)||c(this,de))&&(c(this,Ce)&&((l=c(this,Se))==null||l.call(this,i,n,"evict")),c(this,de)&&((a=c(this,re))==null||a.push([i,n,"evict"]))),c(this,Me).call(this,e),t&&(c(this,Z)[e]=void 0,c(this,j)[e]=void 0,c(this,xe).push(e)),c(this,ne)===1?(F(this,ae,F(this,le,0)),c(this,xe).length=0):F(this,ae,c(this,ce)[e]),c(this,ie).delete(n),Ft(this,ne)._--,e},tt=new WeakSet,jt=function(t,e,n,i){const l=e===void 0?void 0:c(this,j)[e];if(I(this,X,Q).call(this,l))return l;const a=new AbortController,{signal:r}=n;r==null||r.addEventListener("abort",()=>a.abort(r.reason),{signal:a.signal});const d={signal:a.signal,options:n,context:i},f=(k,w=!1)=>{const{aborted:p}=a.signal,x=n.ignoreFetchAbort&&k!==void 0;if(n.status&&(p&&!w?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,x&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!x&&!w)return m(a.signal.reason);const S=g;return c(this,j)[e]===g&&(k===void 0?S.__staleWhileFetching?c(this,j)[e]=S.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,k,d.options))),k},h=k=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=k),m(k)),m=k=>{const{aborted:w}=a.signal,p=w&&n.allowStaleOnFetchAbort,x=p||n.allowStaleOnFetchRejection,S=x||n.noDeleteOnFetchRejection,T=g;if(c(this,j)[e]===g&&(!S||T.__staleWhileFetching===void 0?this.delete(t):p||(c(this,j)[e]=T.__staleWhileFetching)),x)return n.status&&T.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),T.__staleWhileFetching;if(T.__returned===T)throw k},b=(k,w)=>{var x;const p=(x=c(this,Ye))==null?void 0:x.call(this,t,l,d);p&&p instanceof Promise&&p.then(S=>k(S),w),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(k(),n.allowStaleOnFetchAbort&&(k=S=>f(S,!0)))})};n.status&&(n.status.fetchDispatched=!0);const g=new Promise(b).then(f,h),$=Object.assign(g,{__abortController:a,__staleWhileFetching:l,__returned:void 0});return e===void 0?(this.set(t,$,{...d.options,status:void 0}),e=c(this,ie).get(t)):c(this,j)[e]=$,$},X=new WeakSet,Q=function(t){if(!c(this,Fe))return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof AbortController},ht=new WeakSet,Jt=function(t,e){c(this,he)[e]=t,c(this,ce)[t]=e},Be=new WeakSet,gt=function(t){t!==c(this,le)&&(t===c(this,ae)?F(this,ae,c(this,ce)[t]):I(this,ht,Jt).call(this,c(this,he)[t],c(this,ce)[t]),I(this,ht,Jt).call(this,c(this,le),t),F(this,le,t))};const Xi=Ut,rt=s=>{const t=s.value,e=t.substring(0,s.selectionStart),n=t.substring(s.selectionEnd,t.length),i=e.lastIndexOf(`
|
|
51
51
|
`),l=e.substring(0,i+1),a=n.indexOf(`
|
|
52
|
-
`),r=n.substring(a===-1?n.length:a,n.length),d=e.substring(i+1,e.length),f=n.substring(0,a);return{prefixStr:e,subfixStr:n,prefixStrEndRow:l,subfixStrEndRow:r,prefixSupply:d,subfixSupply:f}},Qi=(s,t="",e,n)=>{var m,b,g,$,k,w;let i="",l=0,a=0,r=!1,d,f;const h=(m=J.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(s)){const p=s.replace(/^h(\d)/,(x,S)=>new Array(Number(S)).fill("#",0,S).join(""));i=`${p} ${t}`,l=p.length+1}else if(s==="prettier"){const p=window.prettier||((g=(b=J.editorExtensions)==null?void 0:b.prettier)==null?void 0:g.prettierInstance),x=[(($=window.prettierPlugins)==null?void 0:$.markdown)||((w=(k=J.editorExtensions)==null?void 0:k.prettier)==null?void 0:w.parserMarkdownInstance)];return!p||x[0]===void 0?(v.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),e.value):p.format(e.value,{parser:"markdown",plugins:x})}else switch(s){case"bold":{i=`**${t}**`,l=2,a=-2;break}case"underline":{i=`<u>${t}</u>`,l=3,a=-4;break}case"italic":{i=`*${t}*`,l=1,a=-1;break}case"strikeThrough":{i
|
|
52
|
+
`),r=n.substring(a===-1?n.length:a,n.length),d=e.substring(i+1,e.length),f=n.substring(0,a);return{prefixStr:e,subfixStr:n,prefixStrEndRow:l,subfixStrEndRow:r,prefixSupply:d,subfixSupply:f}},Qi=(s,t="",e,n)=>{var m,b,g,$,k,w;let i="",l=0,a=0,r=!1,d,f;const h=(m=J.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(s)){const p=s.replace(/^h(\d)/,(x,S)=>new Array(Number(S)).fill("#",0,S).join(""));i=`${p} ${t}`,l=p.length+1}else if(s==="prettier"){const p=window.prettier||((g=(b=J.editorExtensions)==null?void 0:b.prettier)==null?void 0:g.prettierInstance),x=[(($=window.prettierPlugins)==null?void 0:$.markdown)||((w=(k=J.editorExtensions)==null?void 0:k.prettier)==null?void 0:w.parserMarkdownInstance)];return!p||x[0]===void 0?(v.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),e.value):p.format(e.value,{parser:"markdown",plugins:x})}else switch(s){case"bold":{i=`**${t}**`,l=2,a=-2;break}case"underline":{i=`<u>${t}</u>`,l=3,a=-4;break}case"italic":{i=`*${t}*`,l=1,a=-1;break}case"strikeThrough":{i=`~~${t}~~`,l=2,a=-2;break}case"sub":{i=`<sub>${t}</sub>`,l=5,a=-6;break}case"sup":{i=`<sup>${t}</sup>`,l=5,a=-6;break}case"codeRow":{i="`"+t+"`",l=1,a=-1;break}case"quote":{i=`> ${t}`,l=2;break}case"orderedList":{i=`1. ${t}`,l=3;break}case"unorderedList":{i=`- ${t}`,l=2;break}case"task":{i=`- [ ] ${t}`,l=6,r=!0;break}case"code":{const p=n.text||t||"",x=n.mode||"language";i=`\`\`\`${x}
|
|
53
53
|
${p}
|
|
54
54
|
\`\`\`
|
|
55
55
|
`,l=3,a=3+x.length-i.length,r=!0;break}case"table":{i="|";const{selectedShape:p={x:1,y:1}}=n,{x,y:S}=p;for(let T=0;T<=S;T++)i+=" col |";i+=`
|
|
@@ -117,7 +117,7 @@ $$
|
|
|
117
117
|
`),icon:a,title:r,text:d,titleTokens:[],tokens:[],childTokens:["title","text"]};return this.lexer.inlineTokens(h.title,h.titleTokens),this.lexer.blockTokens(h.text,h.tokens),h}}},renderer(s){return`<div class="md-editor-alert md-editor-alert-${s.icon}">
|
|
118
118
|
<p class="md-editor-alert-title">${this.parser.parseInline(s.titleTokens,null)}</p>
|
|
119
119
|
${this.parser.parse(s.tokens)}
|
|
120
|
-
</div>`}},es=typeof window>"u",ts=(s,t,e)=>{var g,$;const n=o.inject("previewOnly"),i=o.inject("historyLength"),l=o.inject("editorId");if(n)return;let a=-1;const r={list:[{content:s.value,startPos:((g=t.value)==null?void 0:g.selectionStart)||0,endPos:(($=t.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},d=[0,0];let f=d;const h=k=>{var S,T;const w=((S=t.value)==null?void 0:S.selectionStart)||0,p=((T=t.value)==null?void 0:T.selectionEnd)||0;r.list[r.curr].startPos=w,r.list[r.curr].endPos=p,r.userUpdated=!1,r.curr=k;const x=r.list[r.curr];f=[x.startPos,x.endPos],s.onChange(x.content),Ne(t.value,x.startPos,x.endPos).then(()=>{v.emit(l,"selectTextChange")})},m=k=>{var x,S;clearTimeout(a);const w=((x=t.value)==null?void 0:x.selectionStart)||0,p=((S=t.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(r.userUpdated){r.curr<r.list.length-1&&(r.list=r.list.slice(0,r.curr+1)),r.list.length>i&&r.list.shift();const T=r.list.pop()||{startPos:0,endPos:0,content:k};T.startPos=f[0],T.endPos=f[1],f=d,Array.prototype.push.call(r.list,T,{content:k,startPos:w,endPos:p}),r.curr=r.list.length-1}else r.userUpdated=!0},150)},b=k=>{var w,p;(f===d||k)&&(f=[(w=t.value)==null?void 0:w.selectionStart,(p=t.value)==null?void 0:p.selectionEnd])};o.watch([o.toRef(s,"value"),e],()=>{e.value&&m(s.value)}),o.watch(()=>s.value,()=>{v.emit(l,"selectTextChange")},{flush:"post"}),o.onMounted(()=>{v.on(l,{name:"ctrlZ",callback(){h(r.curr-1<0?0:r.curr-1)}}),v.on(l,{name:"ctrlShiftZ",callback(){h(r.curr+1===r.list.length?r.curr:r.curr+1)}}),v.on(l,{name:"saveHistoryPos",callback:b})})},ns=(s,t)=>{var l;const e=(l=J.editorExtensions)==null?void 0:l.katex,n=e==null?void 0:e.instance,i=o.ref(!!n);return s.noKatex||t.use({extensions:[Rn.inline(u,n),Rn.block(u,n)]}),o.onMounted(()=>{if(!s.noKatex&&!n){const a=document.createElement("script");a.src=(e==null?void 0:e.js)||on.js,a.onload=()=>{i.value=!0},a.id=`${u}-katex`;const r=document.createElement("link");r.rel="stylesheet",r.href=(e==null?void 0:e.css)||on.css,r.id=`${u}-katexCss`,ge(a,"katex"),ge(r)}}),i},is=s=>{var R,P;const{markedRenderer:t,markedExtensions:e,markedOptions:n,editorExtensions:i,editorConfig:l}=J,a=o.inject("showCodeRowNumber"),r=o.inject("editorId"),d=o.inject("highlight"),f=o.inject("previewOnly"),h=o.inject("theme"),m=(R=i==null?void 0:i.highlight)==null?void 0:R.instance,b=(P=i==null?void 0:i.mermaid)==null?void 0:P.instance,g=o.ref(!!m),$=o.ref([]);let k=[],w=[];const p=new Xi({max:1e3,ttl:6e5}),x=os(s),S=ns(s,_),T=o.computed(()=>(s.noMermaid||x.mermaidInited)&&g.value&&(s.noKatex||S.value));let N=new _.Renderer;N.image=(z,C,O)=>`<span class="figure"><img src="${z}" title="${C||""}" alt="${O||""}" zoom><span class="figcaption">${O||""}</span></span>`,N.listitem=(z,C)=>C?`<li class="li-task">${z}</li>`:`<li>${z}</li>`,t instanceof Function&&(N=t(N));const H=N.code;N.code=(z,C,O)=>{if(!s.noMermaid&&C==="mermaid"){const G=Jn();try{if(es)return`<p class="${u}-mermaid">${z}</p>`;{const te=p.get(z);if(te)return`<p class="${u}-mermaid" data-processed>${te}</p>`;const me=b||window.mermaid;if(x.mermaidInited){const Ue=(me.renderAsync||me.render)(G,z);Ue.then(Re=>{p.set(z,typeof Re=="string"?Re:Re.svg)}),k.push(Ue)}else return`<p class="${u}-mermaid">${z}</p>`}const ee=`<script type="text/tmplate">${G}<\/script>`;return w.push(ee),ee}catch(ee){return`<p class="${u}-mermaid-error">Error: ${(ee==null?void 0:ee.message)||""}</p>`}}return H.call(N,z,C,O).replace(/^<pre><code\sclass="language-([^>]*)">/,'<pre><code class="language-$1" language="$1">')};const V=N.heading,y=V!==new _.Renderer().heading;N.heading=(z,C,O,G)=>{$.value.push({text:O,level:C});const ee=s.markedHeadingId(O,C,$.value.length);return y?V.call(N,z,C,O,G,$.value.length,ee):z!==O?`<h${C} id="${ee}">${z}</h${C}>`:`<h${C} id="${ee}"><a href="#${ee}">${O}</a></h${C}>`},m&&_.setOptions({highlight:(z,C)=>{let O;const G=m.getLanguage(C);return C&&G?O=m.highlight(z,{language:C,ignoreIllegals:!0}).value:O=m.highlightAuto(z).value,a?cn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),_.setOptions({breaks:!0,...n}),e instanceof Array&&e.length>0&&_.use({extensions:e}),_.use({extensions:[Ji]});const K=o.ref(s.sanitize(_(s.value||"",{renderer:N}))),M=async z=>{let C=s.sanitize(_(z,{renderer:N}));const O=[...k],G=[...w];return w=[],k=[],(await Promise.allSettled(O)).forEach((te,me)=>{te.status==="fulfilled"?C=C.replace(G[me],`<p class="${u}-mermaid" data-processed>${typeof te.value=="string"?te.value:te.value.svg}</p>`):C=C.replace(G[me],`<p class="${u}-mermaid-error">${te.reason||""}</p>`)}),C},B=pt(async()=>{$.value=[];const z=await M(s.value||"");K.value=z,v.emit(r,"buildFinished",K.value),s.onHtmlChanged(K.value)},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:f?0:500);o.watch([T,o.toRef(x,"reRender"),o.toRef(s,"value")],B),o.watch([h],()=>{p.clear()});const A=()=>{_.setOptions({highlight:(z,C)=>{let O;const G=window.hljs.getLanguage(C);return C&&G?O=window.hljs.highlight(z,{language:C,ignoreIllegals:!0}).value:O=window.hljs.highlightAuto(z).value,a?cn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),g.value=!0};return o.watch(()=>$.value,z=>{s.onGetCatalog(z),v.emit(r,"catalogChanged",z)}),o.onMounted(()=>{const z=document.createElement("
|
|
120
|
+
</div>`}},es=typeof window>"u",ts=(s,t,e)=>{var g,$;const n=o.inject("previewOnly"),i=o.inject("historyLength"),l=o.inject("editorId");if(n)return;let a=-1;const r={list:[{content:s.value,startPos:((g=t.value)==null?void 0:g.selectionStart)||0,endPos:(($=t.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},d=[0,0];let f=d;const h=k=>{var S,T;const w=((S=t.value)==null?void 0:S.selectionStart)||0,p=((T=t.value)==null?void 0:T.selectionEnd)||0;r.list[r.curr].startPos=w,r.list[r.curr].endPos=p,r.userUpdated=!1,r.curr=k;const x=r.list[r.curr];f=[x.startPos,x.endPos],s.onChange(x.content),Ne(t.value,x.startPos,x.endPos).then(()=>{v.emit(l,"selectTextChange")})},m=k=>{var x,S;clearTimeout(a);const w=((x=t.value)==null?void 0:x.selectionStart)||0,p=((S=t.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(r.userUpdated){r.curr<r.list.length-1&&(r.list=r.list.slice(0,r.curr+1)),r.list.length>i&&r.list.shift();const T=r.list.pop()||{startPos:0,endPos:0,content:k};T.startPos=f[0],T.endPos=f[1],f=d,Array.prototype.push.call(r.list,T,{content:k,startPos:w,endPos:p}),r.curr=r.list.length-1}else r.userUpdated=!0},150)},b=k=>{var w,p;(f===d||k)&&(f=[(w=t.value)==null?void 0:w.selectionStart,(p=t.value)==null?void 0:p.selectionEnd])};o.watch([o.toRef(s,"value"),e],()=>{e.value&&m(s.value)}),o.watch(()=>s.value,()=>{v.emit(l,"selectTextChange")},{flush:"post"}),o.onMounted(()=>{v.on(l,{name:"ctrlZ",callback(){h(r.curr-1<0?0:r.curr-1)}}),v.on(l,{name:"ctrlShiftZ",callback(){h(r.curr+1===r.list.length?r.curr:r.curr+1)}}),v.on(l,{name:"saveHistoryPos",callback:b})})},ns=(s,t)=>{var l;const e=(l=J.editorExtensions)==null?void 0:l.katex,n=e==null?void 0:e.instance,i=o.ref(!!n);return s.noKatex||t.use({extensions:[Rn.inline(u,n),Rn.block(u,n)]}),o.onMounted(()=>{if(!s.noKatex&&!n){const a=document.createElement("script");a.src=(e==null?void 0:e.js)||on.js,a.onload=()=>{i.value=!0},a.id=`${u}-katex`;const r=document.createElement("link");r.rel="stylesheet",r.href=(e==null?void 0:e.css)||on.css,r.id=`${u}-katexCss`,ge(a,"katex"),ge(r)}}),i},is=s=>{var R,P;const{markedRenderer:t,markedExtensions:e,markedOptions:n,editorExtensions:i,editorConfig:l}=J,a=o.inject("showCodeRowNumber"),r=o.inject("editorId"),d=o.inject("highlight"),f=o.inject("previewOnly"),h=o.inject("theme"),m=(R=i==null?void 0:i.highlight)==null?void 0:R.instance,b=(P=i==null?void 0:i.mermaid)==null?void 0:P.instance,g=o.ref(!!m),$=o.ref([]);let k=[],w=[];const p=new Xi({max:1e3,ttl:6e5}),x=os(s),S=ns(s,_),T=o.computed(()=>(s.noMermaid||x.mermaidInited)&&g.value&&(s.noKatex||S.value));let N=new _.Renderer;N.image=(z,C,O)=>`<span class="figure"><img src="${z}" title="${C||""}" alt="${O||""}" zoom><span class="figcaption">${O||""}</span></span>`,N.listitem=(z,C)=>C?`<li class="li-task">${z}</li>`:`<li>${z}</li>`,t instanceof Function&&(N=t(N));const H=N.code;N.code=(z,C,O)=>{if(!s.noMermaid&&C==="mermaid"){const G=Jn();try{if(es)return`<p class="${u}-mermaid">${z}</p>`;{const te=p.get(z);if(te)return`<p class="${u}-mermaid" data-processed>${te}</p>`;const me=b||window.mermaid;if(x.mermaidInited){const Ue=(me.renderAsync||me.render)(G,z);Ue.then(Re=>{p.set(z,typeof Re=="string"?Re:Re.svg)}),k.push(Ue)}else return`<p class="${u}-mermaid">${z}</p>`}const ee=`<script type="text/tmplate">${G}<\/script>`;return w.push(ee),ee}catch(ee){return`<p class="${u}-mermaid-error">Error: ${(ee==null?void 0:ee.message)||""}</p>`}}return H.call(N,z,C,O).replace(/^<pre><code\sclass="language-([^>]*)">/,'<pre><code class="language-$1" language="$1">')};const V=N.heading,y=V!==new _.Renderer().heading;N.heading=(z,C,O,G)=>{$.value.push({text:O,level:C});const ee=s.markedHeadingId(O,C,$.value.length);return y?V.call(N,z,C,O,G,$.value.length,ee):z!==O?`<h${C} id="${ee}">${z}</h${C}>`:`<h${C} id="${ee}"><a href="#${ee}">${O}</a></h${C}>`},m&&_.setOptions({highlight:(z,C)=>{let O;const G=m.getLanguage(C);return C&&G?O=m.highlight(z,{language:C,ignoreIllegals:!0}).value:O=m.highlightAuto(z).value,a?cn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),_.setOptions({breaks:!0,...n}),e instanceof Array&&e.length>0&&_.use({extensions:e}),_.use({extensions:[Ji]});const K=o.ref(s.sanitize(_(s.value||"",{renderer:N}))),M=async z=>{let C=s.sanitize(_(z,{renderer:N}));const O=[...k],G=[...w];return w=[],k=[],(await Promise.allSettled(O)).forEach((te,me)=>{te.status==="fulfilled"?C=C.replace(G[me],`<p class="${u}-mermaid" data-processed>${typeof te.value=="string"?te.value:te.value.svg}</p>`):C=C.replace(G[me],`<p class="${u}-mermaid-error">${te.reason||""}</p>`)}),C},B=pt(async()=>{$.value=[];const z=await M(s.value||"");K.value=z,v.emit(r,"buildFinished",K.value),s.onHtmlChanged(K.value)},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:f?0:500);o.watch([T,o.toRef(x,"reRender"),o.toRef(s,"value")],B),o.watch([h],()=>{p.clear()});const A=()=>{_.setOptions({highlight:(z,C)=>{let O;const G=window.hljs.getLanguage(C);return C&&G?O=window.hljs.highlight(z,{language:C,ignoreIllegals:!0}).value:O=window.hljs.highlightAuto(z).value,a?cn(O.trim()):`<span class="code-block">${O.trim()}</span>`}}),g.value=!0};return o.watch(()=>$.value,z=>{s.onGetCatalog(z),v.emit(r,"catalogChanged",z)}),o.onMounted(()=>{if(!m){const z=document.createElement("script");z.src=d.value.js,z.onload=A,z.id=`${u}-hljs`,ge(z,"hljs");const C=document.createElement("link");C.rel="stylesheet",C.href=d.value.css,C.id=`${u}-hlCss`,ge(C)}}),o.watch(()=>d.value.css,z=>{ei(`${u}-hlCss`,"href",z)}),o.onMounted(()=>{v.on(r,{name:"pushCatalog",callback(){v.emit(r,"catalogChanged",$.value)}})}),K},ss=(s,t,e,n,i)=>{const l=o.inject("previewOnly"),a=o.inject("usedLanguageText"),r=o.inject("editorId");let d=()=>{},f=()=>{};const h=()=>{document.querySelectorAll(`#${r}-preview pre`).forEach(g=>{var p,x;let $=-1;(p=g.querySelector(".copy-button"))==null||p.remove();const k=((x=a.value.copyCode)==null?void 0:x.text)||"复制代码",w=document.createElement("span");w.setAttribute("class","copy-button"),w.dataset.tips=k,w.innerHTML=`<svg class="${u}-icon" aria-hidden="true"><use xlink:href="#${u}-icon-copy"></use></svg>`,w.addEventListener("click",()=>{var V,y;clearTimeout($);const S=g.querySelector("code").innerText,T=lt(s.formatCopiedText(S)),N=((V=a.value.copyCode)==null?void 0:V.successTips)||"已复制!",H=((y=a.value.copyCode)==null?void 0:y.failTips)||"已复制!";w.dataset.tips=T?N:H,$=window.setTimeout(()=>{w.dataset.tips=k},1500)}),g.appendChild(w)})},m=()=>{o.nextTick(()=>{s.setting.preview&&!l&&s.scrollAuto&&(d(),f()),h()})},b=g=>{g&&!l&&o.nextTick(()=>{d(),[f,d]=an(e.value,n.value||i.value),f(),h()})};o.watch(()=>t.value,m),o.watch(()=>a.value,h),o.watch(()=>s.setting.preview,b),o.watch(()=>s.setting.htmlPreview,b),o.watch(()=>s.scrollAuto,g=>{g?f():d()}),o.onMounted(()=>{h(),!l&&(n.value||i.value)&&([f,d]=an(e.value,n.value||i.value)),s.scrollAuto&&f()})},ls=(s,t)=>{const e=o.inject("previewOnly"),n=o.inject("tabWidth"),i=o.inject("editorId"),l=o.ref("");o.onMounted(()=>{var a;e||((a=t.value)==null||a.addEventListener("keypress",r=>{var d,f,h;if(r.key==="Enter"){const m=(d=t.value)==null?void 0:d.selectionStart,b=(f=t.value)==null?void 0:f.value.substring(0,m),g=(h=t.value)==null?void 0:h.value.substring(m),$=b==null?void 0:b.lastIndexOf(`
|
|
121
121
|
`),k=b==null?void 0:b.substring($+1,m);if(/^\d+\.\s|^-\s/.test(k))if(r.cancelBubble=!0,r.preventDefault(),r.stopPropagation(),/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(k)){const w=b==null?void 0:b.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/,"");s.onChange(w+g),Ne(t.value,w==null?void 0:w.length)}else if(/^-\s+.+/.test(k)){const w=/^-\s+\[[x\s]\]/.test(k)?`
|
|
122
122
|
- [ ] `:`
|
|
123
123
|
- `;s.onChange(Ot(t.value,w,{}))}else{const w=k==null?void 0:k.match(/\d+(?=\.)/),p=w&&Number(w[0])+1||1,x=/^\d\.\s+\[[x\s]\]/.test(k)?`
|