| 1 | //#region plugin/notes/speaker-view.html?raw |
| 2 | var e = "<!--\n NOTE: You need to build the notes plugin after making changes to this file.\n-->\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n\n <title>reveal.js - Speaker View</title>\n\n <style>\n body {\n font-family: Helvetica;\n font-size: 18px;\n }\n\n #current-slide,\n #upcoming-slide,\n #speaker-controls {\n padding: 6px;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n }\n\n #current-slide iframe,\n #upcoming-slide iframe {\n width: 100%;\n height: 100%;\n border: 1px solid #ddd;\n }\n\n #current-slide .label,\n #upcoming-slide .label {\n position: absolute;\n top: 10px;\n left: 10px;\n z-index: 2;\n }\n\n #connection-status {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 20;\n padding: 30% 20% 20% 20%;\n font-size: 18px;\n color: #222;\n background: #fff;\n text-align: center;\n box-sizing: border-box;\n line-height: 1.4;\n }\n\n .overlay-element {\n height: 34px;\n line-height: 34px;\n padding: 0 10px;\n text-shadow: none;\n background: rgba( 220, 220, 220, 0.8 );\n color: #222;\n font-size: 14px;\n }\n\n .overlay-element.interactive:hover {\n background: rgba( 220, 220, 220, 1 );\n }\n\n #current-slide {\n position: absolute;\n width: 60%;\n height: 100%;\n top: 0;\n left: 0;\n padding-right: 0;\n }\n\n #upcoming-slide {\n position: absolute;\n width: 40%;\n height: 40%;\n right: 0;\n top: 0;\n }\n\n /* Speaker controls */\n #speaker-controls {\n position: absolute;\n top: 40%;\n right: 0;\n width: 40%;\n height: 60%;\n overflow: auto;\n font-size: 18px;\n }\n\n .speaker-controls-time.hidden,\n .speaker-controls-notes.hidden {\n display: none;\n }\n\n .speaker-controls-time .label,\n .speaker-controls-pace .label,\n .speaker-controls-notes .label {\n text-transform: uppercase;\n font-weight: normal;\n font-size: 0.66em;\n color: #666;\n margin: 0;\n }\n\n .speaker-controls-time, .speaker-controls-pace {\n border-bottom: 1px solid rgba( 200, 200, 200, 0.5 );\n margin-bottom: 10px;\n padding: 10px 16px;\n padding-bottom: 20px;\n cursor: pointer;\n }\n\n .speaker-controls-time .reset-button {\n opacity: 0;\n float: right;\n color: #666;\n text-decoration: none;\n }\n .speaker-controls-time:hover .reset-button {\n opacity: 1;\n }\n\n .speaker-controls-time .timer,\n .speaker-controls-time .clock {\n width: 50%;\n }\n\n .speaker-controls-time .timer,\n .speaker-controls-time .clock,\n .speaker-controls-time .pacing .hours-value,\n .speaker-controls-time .pacing .minutes-value,\n .speaker-controls-time .pacing .seconds-value {\n font-size: 1.9em;\n }\n\n .speaker-controls-time .timer {\n float: left;\n }\n\n .speaker-controls-time .clock {\n float: right;\n text-align: right;\n }\n\n .speaker-controls-time span.mute {\n opacity: 0.3;\n }\n\n .speaker-controls-time .pacing-title {\n margin-top: 5px;\n }\n\n .speaker-controls-time .pacing.ahead {\n color: blue;\n }\n\n .speaker-controls-time .pacing.on-track {\n color: green;\n }\n\n .speaker-controls-time .pacing.behind {\n color: red;\n }\n\n .speaker-controls-notes {\n padding: 10px 16px;\n }\n\n .speaker-controls-notes .value {\n margin-top: 5px;\n line-height: 1.4;\n font-size: 1.2em;\n }\n\n /* Layout selector\xA0*/\n #speaker-layout {\n position: absolute;\n top: 10px;\n right: 10px;\n color: #222;\n z-index: 10;\n }\n #speaker-layout select {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n border: 0;\n box-shadow: 0;\n cursor: pointer;\n opacity: 0;\n\n font-size: 1em;\n background-color: transparent;\n\n -moz-appearance: none;\n -webkit-appearance: none;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n }\n\n #speaker-layout select:focus {\n outline: none;\n box-shadow: none;\n }\n\n .clear {\n clear: both;\n }\n\n /* Speaker layout: Wide */\n body[data-speaker-layout=\"wide\"] #current-slide,\n body[data-speaker-layout=\"wide\"] #upcoming-slide {\n width: 50%;\n height: 45%;\n padding: 6px;\n }\n\n body[data-speaker-layout=\"wide\"] #current-slide {\n top: 0;\n left: 0;\n }\n\n body[data-speaker-layout=\"wide\"] #upcoming-slide {\n top: 0;\n left: 50%;\n }\n\n body[data-speaker-layout=\"wide\"] #speaker-controls {\n top: 45%;\n left: 0;\n width: 100%;\n height: 50%;\n font-size: 1.25em;\n }\n\n /* Speaker layout: Tall */\n body[data-speaker-layout=\"tall\"] #current-slide,\n body[data-speaker-layout=\"tall\"] #upcoming-slide {\n width: 45%;\n height: 50%;\n padding: 6px;\n }\n\n body[data-speaker-layout=\"tall\"] #current-slide {\n top: 0;\n left: 0;\n }\n\n body[data-speaker-layout=\"tall\"] #upcoming-slide {\n top: 50%;\n left: 0;\n }\n\n body[data-speaker-layout=\"tall\"] #speaker-controls {\n padding-top: 40px;\n top: 0;\n left: 45%;\n width: 55%;\n height: 100%;\n font-size: 1.25em;\n }\n\n /* Speaker layout: Notes only */\n body[data-speaker-layout=\"notes-only\"] #current-slide,\n body[data-speaker-layout=\"notes-only\"] #upcoming-slide {\n display: none;\n }\n\n body[data-speaker-layout=\"notes-only\"] #speaker-controls {\n padding-top: 40px;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n font-size: 1.25em;\n }\n\n @media screen and (max-width: 1080px) {\n body[data-speaker-layout=\"default\"] #speaker-controls {\n font-size: 16px;\n }\n }\n\n @media screen and (max-width: 900px) {\n body[data-speaker-layout=\"default\"] #speaker-controls {\n font-size: 14px;\n }\n }\n\n @media screen and (max-width: 800px) {\n body[data-speaker-layout=\"default\"] #speaker-controls {\n font-size: 12px;\n }\n }\n\n </style>\n </head>\n\n <body>\n\n <div id=\"connection-status\">Loading speaker view...</div>\n\n <div id=\"current-slide\"></div>\n <div id=\"upcoming-slide\"><span class=\"overlay-element label\">Upcoming</span></div>\n <div id=\"speaker-controls\">\n <div class=\"speaker-controls-time\">\n <h4 class=\"label\">Time <span class=\"reset-button\">Click to Reset</span></h4>\n <div class=\"clock\">\n <span class=\"clock-value\">0:00 AM</span>\n </div>\n <div class=\"timer\">\n <span class=\"hours-value\">00</span><span class=\"minutes-value\">:00</span><span class=\"seconds-value\">:00</span>\n </div>\n <div class=\"clear\"></div>\n\n <h4 class=\"label pacing-title\" style=\"display: none\">Pacing – Time to finish current slide</h4>\n <div class=\"pacing\" style=\"display: none\">\n <span class=\"hours-value\">00</span><span class=\"minutes-value\">:00</span><span class=\"seconds-value\">:00</span>\n </div>\n </div>\n\n <div class=\"speaker-controls-notes hidden\">\n <h4 class=\"label\">Notes</h4>\n <div class=\"value\"></div>\n </div>\n </div>\n <div id=\"speaker-layout\" class=\"overlay-element interactive\">\n <span class=\"speaker-layout-label\"></span>\n <select class=\"speaker-layout-dropdown\"></select>\n </div>\n\n <script>\n\n (function() {\n\n var notes,\n notesValue,\n currentState,\n currentSlide,\n upcomingSlide,\n layoutLabel,\n layoutDropdown,\n pendingCalls = {},\n lastRevealApiCallId = 0,\n connected = false\n\n var connectionStatus = document.querySelector( '#connection-status' );\n\n var SPEAKER_LAYOUTS = {\n 'default': 'Default',\n 'wide': 'Wide',\n 'tall': 'Tall',\n 'notes-only': 'Notes only'\n };\n\n setupLayout();\n\n let openerOrigin;\n\n try {\n openerOrigin = window.opener.location.origin;\n }\n catch ( error ) { console.warn( error ) }\n\n // In order to prevent XSS, the speaker view will only run if its\n // opener has the same origin as itself\n if( window.location.origin !== openerOrigin ) {\n connectionStatus.innerHTML = 'Cross origin error.<br>The speaker window can only be opened from the same origin.';\n return;\n }\n\n var connectionTimeout = setTimeout( function() {\n connectionStatus.innerHTML = 'Error connecting to main window.<br>Please try closing and reopening the speaker view.';\n }, 5000 );\n\n window.addEventListener( 'message', function( event ) {\n\n // Validate the origin of all messages to avoid parsing messages\n // that aren't meant for us. Ignore when running off file:// so\n // that the speaker view continues to work without a web server.\n if( window.location.origin !== event.origin && window.location.origin !== 'file://' ) {\n return\n }\n\n clearTimeout( connectionTimeout );\n connectionStatus.style.display = 'none';\n\n var data = JSON.parse( event.data );\n\n // The overview mode is only useful to the reveal.js instance\n // where navigation occurs so we don't sync it\n if( data.state ) delete data.state.overview;\n\n // Messages sent by the notes plugin inside of the main window\n if( data && data.namespace === 'reveal-notes' ) {\n if( data.type === 'connect' ) {\n handleConnectMessage( data );\n }\n else if( data.type === 'state' ) {\n handleStateMessage( data );\n }\n else if( data.type === 'return' ) {\n pendingCalls[data.callId](data.result);\n delete pendingCalls[data.callId];\n }\n }\n // Messages sent by the reveal.js inside of the current slide preview\n else if( data && data.namespace === 'reveal' ) {\n const supportedEvents = [\n 'slidechanged',\n 'fragmentshown',\n 'fragmenthidden',\n 'paused',\n 'resumed',\n 'previewiframe',\n 'previewimage',\n 'previewvideo',\n 'closeoverlay'\n ];\n\n if( /ready/.test( data.eventName ) ) {\n // Send a message back to notify that the handshake is complete\n window.opener.postMessage( JSON.stringify({ namespace: 'reveal-notes', type: 'connected'} ), '*' );\n }\n else if( supportedEvents.includes( data.eventName ) && currentState !== JSON.stringify( data.state ) ) {\n dispatchStateToMainWindow( data.state );\n }\n }\n\n } );\n\n /**\n * Updates the presentation in the main window to match the state\n * of the presentation in the notes window.\n */\n const dispatchStateToMainWindow = debounce(( state ) => {\n window.opener.postMessage( JSON.stringify({ method: 'setState', args: [ state ]} ), '*' );\n }, 500);\n\n /**\n * Asynchronously calls the Reveal.js API of the main frame.\n */\n function callRevealApi( methodName, methodArguments, callback ) {\n\n var callId = ++lastRevealApiCallId;\n pendingCalls[callId] = callback;\n window.opener.postMessage( JSON.stringify( {\n namespace: 'reveal-notes',\n type: 'call',\n callId: callId,\n methodName: methodName,\n arguments: methodArguments\n } ), '*' );\n\n }\n\n /**\n * Called when the main window is trying to establish a\n * connection.\n */\n function handleConnectMessage( data ) {\n\n if( connected === false ) {\n connected = true;\n\n setupIframes( data );\n setupKeyboard();\n setupNotes();\n setupTimer();\n setupHeartbeat();\n }\n\n }\n\n /**\n * Called when the main window sends an updated state.\n */\n function handleStateMessage( data ) {\n\n // Store the most recently set state to avoid circular loops\n // applying the same state\n currentState = JSON.stringify( data.state );\n\n // No need for updating the notes in case of fragment changes\n if ( data.notes ) {\n notes.classList.remove( 'hidden' );\n notesValue.style.whiteSpace = data.whitespace;\n if( data.markdown ) {\n notesValue.innerHTML = marked.parse( data.notes );\n }\n else {\n notesValue.innerHTML = data.notes;\n }\n }\n else {\n notes.classList.add( 'hidden' );\n }\n\n // Don't show lightboxes in the upcoming slide\n const { previewVideo, previewImage, previewIframe, ...upcomingState } = data.state;\n\n // Update the note slides\n currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' );\n upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ upcomingState ] }), '*' );\n upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'next' }), '*' );\n\n }\n\n // Limit to max one state update per X ms\n handleStateMessage = debounce( handleStateMessage, 200 );\n\n /**\n * Forward keyboard events to the current slide window.\n * This enables keyboard events to work even if focus\n * isn't set on the current slide iframe.\n *\n * Block F5 default handling, it reloads and disconnects\n * the speaker notes window.\n */\n function setupKeyboard() {\n\n document.addEventListener( 'keydown', function( event ) {\n if( event.keyCode === 116 || ( event.metaKey && event.keyCode === 82 ) ) {\n event.preventDefault();\n return false;\n }\n currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' );\n } );\n\n }\n\n /**\n * Creates the preview iframes.\n */\n function setupIframes( data ) {\n\n var params = [\n 'receiver',\n 'progress=false',\n 'history=false',\n 'transition=none',\n 'autoSlide=0',\n 'backgroundTransition=none'\n ].join( '&' );\n\n var urlSeparator = /\\?/.test(data.url) ? '&' : '?';\n var hash = '#/' + data.state.indexh + '/' + data.state.indexv;\n var currentURL = data.url + urlSeparator + params + '&scrollActivationWidth=false&postMessageEvents=true' + hash;\n var upcomingURL = data.url + urlSeparator + params + '&scrollActivationWidth=false&controls=false' + hash;\n\n currentSlide = document.createElement( 'iframe' );\n currentSlide.setAttribute( 'width', 1280 );\n currentSlide.setAttribute( 'height', 1024 );\n currentSlide.setAttribute( 'src', currentURL );\n document.querySelector( '#current-slide' ).appendChild( currentSlide );\n\n upcomingSlide = document.createElement( 'iframe' );\n upcomingSlide.setAttribute( 'width', 640 );\n upcomingSlide.setAttribute( 'height', 512 );\n upcomingSlide.setAttribute( 'src', upcomingURL );\n document.querySelector( '#upcoming-slide' ).appendChild( upcomingSlide );\n\n }\n\n /**\n * Setup the notes UI.\n */\n function setupNotes() {\n\n notes = document.querySelector( '.speaker-controls-notes' );\n notesValue = document.querySelector( '.speaker-controls-notes .value' );\n\n }\n\n /**\n * We send out a heartbeat at all times to ensure we can\n * reconnect with the main presentation window after reloads.\n */\n function setupHeartbeat() {\n\n setInterval( () => {\n window.opener.postMessage( JSON.stringify({ namespace: 'reveal-notes', type: 'heartbeat'} ), '*' );\n }, 1000 );\n\n }\n\n function getTimings( callback ) {\n\n callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {\n callRevealApi( 'getConfig', [], function ( config ) {\n var totalTime = config.totalTime;\n var minTimePerSlide = config.minimumTimePerSlide || 0;\n var defaultTiming = config.defaultTiming;\n if ((defaultTiming == null) && (totalTime == null)) {\n callback(null);\n return;\n }\n // Setting totalTime overrides defaultTiming\n if (totalTime) {\n defaultTiming = 0;\n }\n var timings = [];\n for ( var i in slideAttributes ) {\n var slide = slideAttributes[ i ];\n var timing = defaultTiming;\n if( slide.hasOwnProperty( 'data-timing' )) {\n var t = slide[ 'data-timing' ];\n timing = parseInt(t);\n if( isNaN(timing) ) {\n console.warn(\"Could not parse timing '\" + t + \"' of slide \" + i + \"; using default of \" + defaultTiming);\n timing = defaultTiming;\n }\n }\n timings.push(timing);\n }\n if ( totalTime ) {\n // After we've allocated time to individual slides, we summarize it and\n // subtract it from the total time\n var remainingTime = totalTime - timings.reduce( function(a, b) { return a + b; }, 0 );\n // The remaining time is divided by the number of slides that have 0 seconds\n // allocated at the moment, giving the average time-per-slide on the remaining slides\n var remainingSlides = (timings.filter( function(x) { return x == 0 }) ).length\n var timePerSlide = Math.round( remainingTime / remainingSlides, 0 )\n // And now we replace every zero-value timing with that average\n timings = timings.map( function(x) { return (x==0 ? timePerSlide : x) } );\n }\n var slidesUnderMinimum = timings.filter( function(x) { return (x < minTimePerSlide) } ).length\n if ( slidesUnderMinimum ) {\n message = \"The pacing time for \" + slidesUnderMinimum + \" slide(s) is under the configured minimum of \" + minTimePerSlide + \" seconds. Check the data-timing attribute on individual slides, or consider increasing the totalTime or minimumTimePerSlide configuration options (or removing some slides).\";\n alert(message);\n }\n callback( timings );\n } );\n } );\n\n }\n\n /**\n * Return the number of seconds allocated for presenting\n * all slides up to and including this one.\n */\n function getTimeAllocated( timings, callback ) {\n\n callRevealApi( 'getSlidePastCount', [], function ( currentSlide ) {\n var allocated = 0;\n for (var i in timings.slice(0, currentSlide + 1)) {\n allocated += timings[i];\n }\n callback( allocated );\n } );\n\n }\n\n /**\n * Create the timer and clock and start updating them\n * at an interval.\n */\n function setupTimer() {\n\n var start = new Date(),\n timeEl = document.querySelector( '.speaker-controls-time' ),\n clockEl = timeEl.querySelector( '.clock-value' ),\n hoursEl = timeEl.querySelector( '.hours-value' ),\n minutesEl = timeEl.querySelector( '.minutes-value' ),\n secondsEl = timeEl.querySelector( '.seconds-value' ),\n pacingTitleEl = timeEl.querySelector( '.pacing-title' ),\n pacingEl = timeEl.querySelector( '.pacing' ),\n pacingHoursEl = pacingEl.querySelector( '.hours-value' ),\n pacingMinutesEl = pacingEl.querySelector( '.minutes-value' ),\n pacingSecondsEl = pacingEl.querySelector( '.seconds-value' );\n\n var timings = null;\n getTimings( function ( _timings ) {\n\n timings = _timings;\n if (_timings !== null) {\n pacingTitleEl.style.removeProperty('display');\n pacingEl.style.removeProperty('display');\n }\n\n // Update once directly\n _updateTimer();\n\n // Then update every second\n setInterval( _updateTimer, 1000 );\n\n } );\n\n\n function _resetTimer() {\n\n if (timings == null) {\n start = new Date();\n _updateTimer();\n }\n else {\n // Reset timer to beginning of current slide\n getTimeAllocated( timings, function ( slideEndTimingSeconds ) {\n var slideEndTiming = slideEndTimingSeconds * 1000;\n callRevealApi( 'getSlidePastCount', [], function ( currentSlide ) {\n var currentSlideTiming = timings[currentSlide] * 1000;\n var previousSlidesTiming = slideEndTiming - currentSlideTiming;\n var now = new Date();\n start = new Date(now.getTime() - previousSlidesTiming);\n _updateTimer();\n } );\n } );\n }\n\n }\n\n timeEl.addEventListener( 'click', function() {\n _resetTimer();\n return false;\n } );\n\n function _displayTime( hrEl, minEl, secEl, time) {\n\n var sign = Math.sign(time) == -1 ? \"-\" : \"\";\n time = Math.abs(Math.round(time / 1000));\n var seconds = time % 60;\n var minutes = Math.floor( time / 60 ) % 60 ;\n var hours = Math.floor( time / ( 60 * 60 )) ;\n hrEl.innerHTML = sign + zeroPadInteger( hours );\n if (hours == 0) {\n hrEl.classList.add( 'mute' );\n }\n else {\n hrEl.classList.remove( 'mute' );\n }\n minEl.innerHTML = ':' + zeroPadInteger( minutes );\n if (hours == 0 && minutes == 0) {\n minEl.classList.add( 'mute' );\n }\n else {\n minEl.classList.remove( 'mute' );\n }\n secEl.innerHTML = ':' + zeroPadInteger( seconds );\n }\n\n function _updateTimer() {\n\n var diff, hours, minutes, seconds,\n now = new Date();\n\n diff = now.getTime() - start.getTime();\n\n clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } );\n _displayTime( hoursEl, minutesEl, secondsEl, diff );\n if (timings !== null) {\n _updatePacing(diff);\n }\n\n }\n\n function _updatePacing(diff) {\n\n getTimeAllocated( timings, function ( slideEndTimingSeconds ) {\n var slideEndTiming = slideEndTimingSeconds * 1000;\n\n callRevealApi( 'getSlidePastCount', [], function ( currentSlide ) {\n var currentSlideTiming = timings[currentSlide] * 1000;\n var timeLeftCurrentSlide = slideEndTiming - diff;\n if (timeLeftCurrentSlide < 0) {\n pacingEl.className = 'pacing behind';\n }\n else if (timeLeftCurrentSlide < currentSlideTiming) {\n pacingEl.className = 'pacing on-track';\n }\n else {\n pacingEl.className = 'pacing ahead';\n }\n _displayTime( pacingHoursEl, pacingMinutesEl, pacingSecondsEl, timeLeftCurrentSlide );\n } );\n } );\n }\n\n }\n\n /**\n * Sets up the speaker view layout and layout selector.\n */\n function setupLayout() {\n\n layoutDropdown = document.querySelector( '.speaker-layout-dropdown' );\n layoutLabel = document.querySelector( '.speaker-layout-label' );\n\n // Render the list of available layouts\n for( var id in SPEAKER_LAYOUTS ) {\n var option = document.createElement( 'option' );\n option.setAttribute( 'value', id );\n option.textContent = SPEAKER_LAYOUTS[ id ];\n layoutDropdown.appendChild( option );\n }\n\n // Monitor the dropdown for changes\n layoutDropdown.addEventListener( 'change', function( event ) {\n\n setLayout( layoutDropdown.value );\n\n }, false );\n\n // Restore any currently persisted layout\n setLayout( getLayout() );\n\n }\n\n /**\n * Sets a new speaker view layout. The layout is persisted\n * in local storage.\n */\n function setLayout( value ) {\n\n var title = SPEAKER_LAYOUTS[ value ];\n\n layoutLabel.innerHTML = 'Layout' + ( title ? ( ': ' + title ) : '' );\n layoutDropdown.value = value;\n\n document.body.setAttribute( 'data-speaker-layout', value );\n\n // Persist locally\n if( supportsLocalStorage() ) {\n window.localStorage.setItem( 'reveal-speaker-layout', value );\n }\n\n }\n\n /**\n * Returns the ID of the most recently set speaker layout\n * or our default layout if none has been set.\n */\n function getLayout() {\n\n if( supportsLocalStorage() ) {\n var layout = window.localStorage.getItem( 'reveal-speaker-layout' );\n if( layout ) {\n return layout;\n }\n }\n\n // Default to the first record in the layouts hash\n for( var id in SPEAKER_LAYOUTS ) {\n return id;\n }\n\n }\n\n function supportsLocalStorage() {\n\n try {\n localStorage.setItem('test', 'test');\n localStorage.removeItem('test');\n return true;\n }\n catch( e ) {\n return false;\n }\n\n }\n\n function zeroPadInteger( num ) {\n\n var str = '00' + parseInt( num );\n return str.substring( str.length - 2 );\n\n }\n\n /**\n * Limits the frequency at which a function can be called.\n */\n function debounce( fn, ms ) {\n\n var lastTime = 0,\n timeout;\n\n return function() {\n\n var args = arguments;\n var context = this;\n\n clearTimeout( timeout );\n\n var timeSinceLastCall = Date.now() - lastTime;\n if( timeSinceLastCall > ms ) {\n fn.apply( context, args );\n lastTime = Date.now();\n }\n else {\n timeout = setTimeout( function() {\n fn.apply( context, args );\n lastTime = Date.now();\n }, ms - timeSinceLastCall );\n }\n\n }\n\n }\n\n })();\n\n <\/script>\n </body>\n</html>"; |
| 3 | //#endregion |
| 4 | //#region node_modules/marked/lib/marked.esm.js |
| 5 | function t() { |
| 6 | return { |
| 7 | async: !1, |
| 8 | breaks: !1, |
| 9 | extensions: null, |
| 10 | gfm: !0, |
| 11 | hooks: null, |
| 12 | pedantic: !1, |
| 13 | renderer: null, |
| 14 | silent: !1, |
| 15 | tokenizer: null, |
| 16 | walkTokens: null |
| 17 | }; |
| 18 | } |
| 19 | var n = t(); |
| 20 | function r(e) { |
| 21 | n = e; |
| 22 | } |
| 23 | var i = { exec: () => null }; |
| 24 | function a(e, t = "") { |
| 25 | let n = typeof e == "string" ? e : e.source, r = { |
| 26 | replace: (e, t) => { |
| 27 | let i = typeof t == "string" ? t : t.source; |
| 28 | return i = i.replace(s.caret, "$1"), n = n.replace(e, i), r; |
| 29 | }, |
| 30 | getRegex: () => new RegExp(n, t) |
| 31 | }; |
| 32 | return r; |
| 33 | } |
| 34 | var o = (() => { |
| 35 | try { |
| 36 | return !0; |
| 37 | } catch { |
| 38 | return !1; |
| 39 | } |
| 40 | })(), s = { |
| 41 | codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, |
| 42 | outputLinkReplace: /\\([\[\]])/g, |
| 43 | indentCodeCompensation: /^(\s+)(?:```)/, |
| 44 | beginningSpace: /^\s+/, |
| 45 | endingHash: /#$/, |
| 46 | startingSpaceChar: /^ /, |
| 47 | endingSpaceChar: / $/, |
| 48 | nonSpaceChar: /[^ ]/, |
| 49 | newLineCharGlobal: /\n/g, |
| 50 | tabCharGlobal: /\t/g, |
| 51 | multipleSpaceGlobal: /\s+/g, |
| 52 | blankLine: /^[ \t]*$/, |
| 53 | doubleBlankLine: /\n[ \t]*\n[ \t]*$/, |
| 54 | blockquoteStart: /^ {0,3}>/, |
| 55 | blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, |
| 56 | blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, |
| 57 | listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, |
| 58 | listIsTask: /^\[[ xX]\] +\S/, |
| 59 | listReplaceTask: /^\[[ xX]\] +/, |
| 60 | listTaskCheckbox: /\[[ xX]\]/, |
| 61 | anyLine: /\n.*\n/, |
| 62 | hrefBrackets: /^<(.*)>$/, |
| 63 | tableDelimiter: /[:|]/, |
| 64 | tableAlignChars: /^\||\| *$/g, |
| 65 | tableRowBlankLine: /\n[ \t]*$/, |
| 66 | tableAlignRight: /^ *-+: *$/, |
| 67 | tableAlignCenter: /^ *:-+: *$/, |
| 68 | tableAlignLeft: /^ *:-+ *$/, |
| 69 | startATag: /^<a /i, |
| 70 | endATag: /^<\/a>/i, |
| 71 | startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, |
| 72 | endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, |
| 73 | startAngleBracket: /^</, |
| 74 | endAngleBracket: />$/, |
| 75 | pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, |
| 76 | unicodeAlphaNumeric: /[\p{L}\p{N}]/u, |
| 77 | escapeTest: /[&<>"']/, |
| 78 | escapeReplace: /[&<>"']/g, |
| 79 | escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, |
| 80 | escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, |
| 81 | caret: /(^|[^\[])\^/g, |
| 82 | percentDecode: /%25/g, |
| 83 | findPipe: /\|/g, |
| 84 | splitPipe: / \|/, |
| 85 | slashPipe: /\\\|/g, |
| 86 | carriageReturn: /\r\n|\r/g, |
| 87 | spaceLine: /^ +$/gm, |
| 88 | notSpaceStart: /^\S*/, |
| 89 | endingNewline: /\n$/, |
| 90 | listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`), |
| 91 | nextBulletRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), |
| 92 | hrRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), |
| 93 | fencesBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`), |
| 94 | headingBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}#`), |
| 95 | htmlBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, "i"), |
| 96 | blockquoteBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}>`) |
| 97 | }, c = /^(?:[ \t]*(?:\n|$))+/, l = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, u = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, d = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, f = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, p = / {0,3}(?:[*+-]|\d{1,9}[.)])/, m = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, h = a(m).replace(/bull/g, p).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), ee = a(m).replace(/bull/g, p).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), g = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, te = /^[^\n]+/, _ = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, ne = a(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), re = a(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, p).getRegex(), v = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", y = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, ie = a("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", y).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), b = a(g).replace("hr", d).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), x = { |
| 98 | blockquote: a(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", b).getRegex(), |
| 99 | code: l, |
| 100 | def: ne, |
| 101 | fences: u, |
| 102 | heading: f, |
| 103 | hr: d, |
| 104 | html: ie, |
| 105 | lheading: h, |
| 106 | list: re, |
| 107 | newline: c, |
| 108 | paragraph: b, |
| 109 | table: i, |
| 110 | text: te |
| 111 | }, S = a("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", d).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(), ae = { |
| 112 | ...x, |
| 113 | lheading: ee, |
| 114 | table: S, |
| 115 | paragraph: a(g).replace("hr", d).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", S).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() |
| 116 | }, oe = { |
| 117 | ...x, |
| 118 | html: a("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", y).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), |
| 119 | def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, |
| 120 | heading: /^(#{1,6})(.*)(?:\n+|$)/, |
| 121 | fences: i, |
| 122 | lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, |
| 123 | paragraph: a(g).replace("hr", d).replace("heading", " *#{1,6} *[^\n]").replace("lheading", h).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() |
| 124 | }, se = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, C = /^( {2,}|\\)\n(?!\s*$)/, w = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, T = /[\p{P}\p{S}]/u, E = /[\s\p{P}\p{S}]/u, D = /[^\s\p{P}\p{S}]/u, le = a(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, E).getRegex(), O = /(?!~)[\p{P}\p{S}]/u, ue = /(?!~)[\s\p{P}\p{S}]/u, de = /(?:[^\s\p{P}\p{S}]|~)/u, fe = a(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", o ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), k = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, pe = a(k, "u").replace(/punct/g, T).getRegex(), me = a(k, "u").replace(/punct/g, O).getRegex(), A = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", he = a(A, "gu").replace(/notPunctSpace/g, D).replace(/punctSpace/g, E).replace(/punct/g, T).getRegex(), ge = a(A, "gu").replace(/notPunctSpace/g, de).replace(/punctSpace/g, ue).replace(/punct/g, O).getRegex(), _e = a("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, D).replace(/punctSpace/g, E).replace(/punct/g, T).getRegex(), ve = a(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, T).getRegex(), ye = a("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, D).replace(/punctSpace/g, E).replace(/punct/g, T).getRegex(), be = a(/\\(punct)/, "gu").replace(/punct/g, T).getRegex(), xe = a(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Se = a(y).replace("(?:-->|$)", "-->").getRegex(), j = a("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Se).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), M = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Ce = a(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", M).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), N = a(/^!?\[(label)\]\[(ref)\]/).replace("label", M).replace("ref", _).getRegex(), P = a(/^!?\[(ref)\](?:\[\])?/).replace("ref", _).getRegex(), we = a("reflink|nolink(?!\\()", "g").replace("reflink", N).replace("nolink", P).getRegex(), F = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, I = { |
| 125 | _backpedal: i, |
| 126 | anyPunctuation: be, |
| 127 | autolink: xe, |
| 128 | blockSkip: fe, |
| 129 | br: C, |
| 130 | code: ce, |
| 131 | del: i, |
| 132 | delLDelim: i, |
| 133 | delRDelim: i, |
| 134 | emStrongLDelim: pe, |
| 135 | emStrongRDelimAst: he, |
| 136 | emStrongRDelimUnd: _e, |
| 137 | escape: se, |
| 138 | link: Ce, |
| 139 | nolink: P, |
| 140 | punctuation: le, |
| 141 | reflink: N, |
| 142 | reflinkSearch: we, |
| 143 | tag: j, |
| 144 | text: w, |
| 145 | url: i |
| 146 | }, Te = { |
| 147 | ...I, |
| 148 | link: a(/^!?\[(label)\]\((.*?)\)/).replace("label", M).getRegex(), |
| 149 | reflink: a(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", M).getRegex() |
| 150 | }, L = { |
| 151 | ...I, |
| 152 | emStrongRDelimAst: ge, |
| 153 | emStrongLDelim: me, |
| 154 | delLDelim: ve, |
| 155 | delRDelim: ye, |
| 156 | url: a(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", F).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), |
| 157 | _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, |
| 158 | del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, |
| 159 | text: a(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", F).getRegex() |
| 160 | }, Ee = { |
| 161 | ...L, |
| 162 | br: a(C).replace("{2,}", "*").getRegex(), |
| 163 | text: a(L.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() |
| 164 | }, R = { |
| 165 | normal: x, |
| 166 | gfm: ae, |
| 167 | pedantic: oe |
| 168 | }, z = { |
| 169 | normal: I, |
| 170 | gfm: L, |
| 171 | breaks: Ee, |
| 172 | pedantic: Te |
| 173 | }, De = { |
| 174 | "&": "&", |
| 175 | "<": "<", |
| 176 | ">": ">", |
| 177 | "\"": """, |
| 178 | "'": "'" |
| 179 | }, B = (e) => De[e]; |
| 180 | function V(e, t) { |
| 181 | if (t) { |
| 182 | if (s.escapeTest.test(e)) return e.replace(s.escapeReplace, B); |
| 183 | } else if (s.escapeTestNoEncode.test(e)) return e.replace(s.escapeReplaceNoEncode, B); |
| 184 | return e; |
| 185 | } |
| 186 | function H(e) { |
| 187 | try { |
| 188 | e = encodeURI(e).replace(s.percentDecode, "%"); |
| 189 | } catch { |
| 190 | return null; |
| 191 | } |
| 192 | return e; |
| 193 | } |
| 194 | function U(e, t) { |
| 195 | let n = e.replace(s.findPipe, (e, t, n) => { |
| 196 | let r = !1, i = t; |
| 197 | for (; --i >= 0 && n[i] === "\\";) r = !r; |
| 198 | return r ? "|" : " |"; |
| 199 | }).split(s.splitPipe), r = 0; |
| 200 | if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) if (n.length > t) n.splice(t); |
| 201 | else for (; n.length < t;) n.push(""); |
| 202 | for (; r < n.length; r++) n[r] = n[r].trim().replace(s.slashPipe, "|"); |
| 203 | return n; |
| 204 | } |
| 205 | function W(e, t, n) { |
| 206 | let r = e.length; |
| 207 | if (r === 0) return ""; |
| 208 | let i = 0; |
| 209 | for (; i < r;) { |
| 210 | let a = e.charAt(r - i - 1); |
| 211 | if (a === t && !n) i++; |
| 212 | else if (a !== t && n) i++; |
| 213 | else break; |
| 214 | } |
| 215 | return e.slice(0, r - i); |
| 216 | } |
| 217 | function Oe(e, t) { |
| 218 | if (e.indexOf(t[1]) === -1) return -1; |
| 219 | let n = 0; |
| 220 | for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++; |
| 221 | else if (e[r] === t[0]) n++; |
| 222 | else if (e[r] === t[1] && (n--, n < 0)) return r; |
| 223 | return n > 0 ? -2 : -1; |
| 224 | } |
| 225 | function ke(e, t = 0) { |
| 226 | let n = t, r = ""; |
| 227 | for (let t of e) if (t === " ") { |
| 228 | let e = 4 - n % 4; |
| 229 | r += " ".repeat(e), n += e; |
| 230 | } else r += t, n++; |
| 231 | return r; |
| 232 | } |
| 233 | function G(e, t, n, r, i) { |
| 234 | let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1"); |
| 235 | r.state.inLink = !0; |
| 236 | let c = { |
| 237 | type: e[0].charAt(0) === "!" ? "image" : "link", |
| 238 | raw: n, |
| 239 | href: a, |
| 240 | title: o, |
| 241 | text: s, |
| 242 | tokens: r.inlineTokens(s) |
| 243 | }; |
| 244 | return r.state.inLink = !1, c; |
| 245 | } |
| 246 | function Ae(e, t, n) { |
| 247 | let r = e.match(n.other.indentCodeCompensation); |
| 248 | if (r === null) return t; |
| 249 | let i = r[1]; |
| 250 | return t.split("\n").map((e) => { |
| 251 | let t = e.match(n.other.beginningSpace); |
| 252 | if (t === null) return e; |
| 253 | let [r] = t; |
| 254 | return r.length >= i.length ? e.slice(i.length) : e; |
| 255 | }).join("\n"); |
| 256 | } |
| 257 | var K = class { |
| 258 | options; |
| 259 | rules; |
| 260 | lexer; |
| 261 | constructor(e) { |
| 262 | this.options = e || n; |
| 263 | } |
| 264 | space(e) { |
| 265 | let t = this.rules.block.newline.exec(e); |
| 266 | if (t && t[0].length > 0) return { |
| 267 | type: "space", |
| 268 | raw: t[0] |
| 269 | }; |
| 270 | } |
| 271 | code(e) { |
| 272 | let t = this.rules.block.code.exec(e); |
| 273 | if (t) { |
| 274 | let e = t[0].replace(this.rules.other.codeRemoveIndent, ""); |
| 275 | return { |
| 276 | type: "code", |
| 277 | raw: t[0], |
| 278 | codeBlockStyle: "indented", |
| 279 | text: this.options.pedantic ? e : W(e, "\n") |
| 280 | }; |
| 281 | } |
| 282 | } |
| 283 | fences(e) { |
| 284 | let t = this.rules.block.fences.exec(e); |
| 285 | if (t) { |
| 286 | let e = t[0], n = Ae(e, t[3] || "", this.rules); |
| 287 | return { |
| 288 | type: "code", |
| 289 | raw: e, |
| 290 | lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], |
| 291 | text: n |
| 292 | }; |
| 293 | } |
| 294 | } |
| 295 | heading(e) { |
| 296 | let t = this.rules.block.heading.exec(e); |
| 297 | if (t) { |
| 298 | let e = t[2].trim(); |
| 299 | if (this.rules.other.endingHash.test(e)) { |
| 300 | let t = W(e, "#"); |
| 301 | (this.options.pedantic || !t || this.rules.other.endingSpaceChar.test(t)) && (e = t.trim()); |
| 302 | } |
| 303 | return { |
| 304 | type: "heading", |
| 305 | raw: t[0], |
| 306 | depth: t[1].length, |
| 307 | text: e, |
| 308 | tokens: this.lexer.inline(e) |
| 309 | }; |
| 310 | } |
| 311 | } |
| 312 | hr(e) { |
| 313 | let t = this.rules.block.hr.exec(e); |
| 314 | if (t) return { |
| 315 | type: "hr", |
| 316 | raw: W(t[0], "\n") |
| 317 | }; |
| 318 | } |
| 319 | blockquote(e) { |
| 320 | let t = this.rules.block.blockquote.exec(e); |
| 321 | if (t) { |
| 322 | let e = W(t[0], "\n").split("\n"), n = "", r = "", i = []; |
| 323 | for (; e.length > 0;) { |
| 324 | let t = !1, a = [], o; |
| 325 | for (o = 0; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0; |
| 326 | else if (!t) a.push(e[o]); |
| 327 | else break; |
| 328 | e = e.slice(o); |
| 329 | let s = a.join("\n"), c = s.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, ""); |
| 330 | n = n ? `${n} |
| 331 | ${s}` : s, r = r ? `${r} |
| 332 | ${c}` : c; |
| 333 | let l = this.lexer.state.top; |
| 334 | if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = l, e.length === 0) break; |
| 335 | let u = i.at(-1); |
| 336 | if (u?.type === "code") break; |
| 337 | if (u?.type === "blockquote") { |
| 338 | let t = u, a = t.raw + "\n" + e.join("\n"), o = this.blockquote(a); |
| 339 | i[i.length - 1] = o, n = n.substring(0, n.length - t.raw.length) + o.raw, r = r.substring(0, r.length - t.text.length) + o.text; |
| 340 | break; |
| 341 | } else if (u?.type === "list") { |
| 342 | let t = u, a = t.raw + "\n" + e.join("\n"), o = this.list(a); |
| 343 | i[i.length - 1] = o, n = n.substring(0, n.length - u.raw.length) + o.raw, r = r.substring(0, r.length - t.raw.length) + o.raw, e = a.substring(i.at(-1).raw.length).split("\n"); |
| 344 | continue; |
| 345 | } |
| 346 | } |
| 347 | return { |
| 348 | type: "blockquote", |
| 349 | raw: n, |
| 350 | tokens: i, |
| 351 | text: r |
| 352 | }; |
| 353 | } |
| 354 | } |
| 355 | list(e) { |
| 356 | let t = this.rules.block.list.exec(e); |
| 357 | if (t) { |
| 358 | let n = t[1].trim(), r = n.length > 1, i = { |
| 359 | type: "list", |
| 360 | raw: "", |
| 361 | ordered: r, |
| 362 | start: r ? +n.slice(0, -1) : "", |
| 363 | loose: !1, |
| 364 | items: [] |
| 365 | }; |
| 366 | n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]"); |
| 367 | let a = this.rules.other.listItemRegex(n), o = !1; |
| 368 | for (; e;) { |
| 369 | let n = !1, r = "", s = ""; |
| 370 | if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break; |
| 371 | r = t[0], e = e.substring(r.length); |
| 372 | let c = ke(t[2].split("\n", 1)[0], t[1].length), l = e.split("\n", 1)[0], u = !c.trim(), d = 0; |
| 373 | if (this.options.pedantic ? (d = 2, s = c.trimStart()) : u ? d = t[1].length + 1 : (d = c.search(this.rules.other.nonSpaceChar), d = d > 4 ? 1 : d, s = c.slice(d), d += t[1].length), u && this.rules.other.blankLine.test(l) && (r += l + "\n", e = e.substring(l.length + 1), n = !0), !n) { |
| 374 | let t = this.rules.other.nextBulletRegex(d), n = this.rules.other.hrRegex(d), i = this.rules.other.fencesBeginRegex(d), a = this.rules.other.headingBeginRegex(d), o = this.rules.other.htmlBeginRegex(d), f = this.rules.other.blockquoteBeginRegex(d); |
| 375 | for (; e;) { |
| 376 | let p = e.split("\n", 1)[0], m; |
| 377 | if (l = p, this.options.pedantic ? (l = l.replace(this.rules.other.listReplaceNesting, " "), m = l) : m = l.replace(this.rules.other.tabCharGlobal, " "), i.test(l) || a.test(l) || o.test(l) || f.test(l) || t.test(l) || n.test(l)) break; |
| 378 | if (m.search(this.rules.other.nonSpaceChar) >= d || !l.trim()) s += "\n" + m.slice(d); |
| 379 | else { |
| 380 | if (u || c.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || i.test(c) || a.test(c) || n.test(c)) break; |
| 381 | s += "\n" + l; |
| 382 | } |
| 383 | u = !l.trim(), r += p + "\n", e = e.substring(p.length + 1), c = m.slice(d); |
| 384 | } |
| 385 | } |
| 386 | i.loose || (o ? i.loose = !0 : this.rules.other.doubleBlankLine.test(r) && (o = !0)), i.items.push({ |
| 387 | type: "list_item", |
| 388 | raw: r, |
| 389 | task: !!this.options.gfm && this.rules.other.listIsTask.test(s), |
| 390 | loose: !1, |
| 391 | text: s, |
| 392 | tokens: [] |
| 393 | }), i.raw += r; |
| 394 | } |
| 395 | let s = i.items.at(-1); |
| 396 | if (s) s.raw = s.raw.trimEnd(), s.text = s.text.trimEnd(); |
| 397 | else return; |
| 398 | i.raw = i.raw.trimEnd(); |
| 399 | for (let e of i.items) { |
| 400 | if (this.lexer.state.top = !1, e.tokens = this.lexer.blockTokens(e.text, []), e.task) { |
| 401 | if (e.text = e.text.replace(this.rules.other.listReplaceTask, ""), e.tokens[0]?.type === "text" || e.tokens[0]?.type === "paragraph") { |
| 402 | e.tokens[0].raw = e.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), e.tokens[0].text = e.tokens[0].text.replace(this.rules.other.listReplaceTask, ""); |
| 403 | for (let e = this.lexer.inlineQueue.length - 1; e >= 0; e--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)) { |
| 404 | this.lexer.inlineQueue[e].src = this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask, ""); |
| 405 | break; |
| 406 | } |
| 407 | } |
| 408 | let t = this.rules.other.listTaskCheckbox.exec(e.raw); |
| 409 | if (t) { |
| 410 | let n = { |
| 411 | type: "checkbox", |
| 412 | raw: t[0] + " ", |
| 413 | checked: t[0] !== "[ ]" |
| 414 | }; |
| 415 | e.checked = n.checked, i.loose ? e.tokens[0] && ["paragraph", "text"].includes(e.tokens[0].type) && "tokens" in e.tokens[0] && e.tokens[0].tokens ? (e.tokens[0].raw = n.raw + e.tokens[0].raw, e.tokens[0].text = n.raw + e.tokens[0].text, e.tokens[0].tokens.unshift(n)) : e.tokens.unshift({ |
| 416 | type: "paragraph", |
| 417 | raw: n.raw, |
| 418 | text: n.raw, |
| 419 | tokens: [n] |
| 420 | }) : e.tokens.unshift(n); |
| 421 | } |
| 422 | } |
| 423 | if (!i.loose) { |
| 424 | let t = e.tokens.filter((e) => e.type === "space"); |
| 425 | i.loose = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw)); |
| 426 | } |
| 427 | } |
| 428 | if (i.loose) for (let e of i.items) { |
| 429 | e.loose = !0; |
| 430 | for (let t of e.tokens) t.type === "text" && (t.type = "paragraph"); |
| 431 | } |
| 432 | return i; |
| 433 | } |
| 434 | } |
| 435 | html(e) { |
| 436 | let t = this.rules.block.html.exec(e); |
| 437 | if (t) return { |
| 438 | type: "html", |
| 439 | block: !0, |
| 440 | raw: t[0], |
| 441 | pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", |
| 442 | text: t[0] |
| 443 | }; |
| 444 | } |
| 445 | def(e) { |
| 446 | let t = this.rules.block.def.exec(e); |
| 447 | if (t) { |
| 448 | let e = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), n = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3]; |
| 449 | return { |
| 450 | type: "def", |
| 451 | tag: e, |
| 452 | raw: t[0], |
| 453 | href: n, |
| 454 | title: r |
| 455 | }; |
| 456 | } |
| 457 | } |
| 458 | table(e) { |
| 459 | let t = this.rules.block.table.exec(e); |
| 460 | if (!t || !this.rules.other.tableDelimiter.test(t[2])) return; |
| 461 | let n = U(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = { |
| 462 | type: "table", |
| 463 | raw: t[0], |
| 464 | header: [], |
| 465 | align: [], |
| 466 | rows: [] |
| 467 | }; |
| 468 | if (n.length === r.length) { |
| 469 | for (let e of r) this.rules.other.tableAlignRight.test(e) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(e) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(e) ? a.align.push("left") : a.align.push(null); |
| 470 | for (let e = 0; e < n.length; e++) a.header.push({ |
| 471 | text: n[e], |
| 472 | tokens: this.lexer.inline(n[e]), |
| 473 | header: !0, |
| 474 | align: a.align[e] |
| 475 | }); |
| 476 | for (let e of i) a.rows.push(U(e, a.header.length).map((e, t) => ({ |
| 477 | text: e, |
| 478 | tokens: this.lexer.inline(e), |
| 479 | header: !1, |
| 480 | align: a.align[t] |
| 481 | }))); |
| 482 | return a; |
| 483 | } |
| 484 | } |
| 485 | lheading(e) { |
| 486 | let t = this.rules.block.lheading.exec(e); |
| 487 | if (t) { |
| 488 | let e = t[1].trim(); |
| 489 | return { |
| 490 | type: "heading", |
| 491 | raw: t[0], |
| 492 | depth: t[2].charAt(0) === "=" ? 1 : 2, |
| 493 | text: e, |
| 494 | tokens: this.lexer.inline(e) |
| 495 | }; |
| 496 | } |
| 497 | } |
| 498 | paragraph(e) { |
| 499 | let t = this.rules.block.paragraph.exec(e); |
| 500 | if (t) { |
| 501 | let e = t[1].charAt(t[1].length - 1) === "\n" ? t[1].slice(0, -1) : t[1]; |
| 502 | return { |
| 503 | type: "paragraph", |
| 504 | raw: t[0], |
| 505 | text: e, |
| 506 | tokens: this.lexer.inline(e) |
| 507 | }; |
| 508 | } |
| 509 | } |
| 510 | text(e) { |
| 511 | let t = this.rules.block.text.exec(e); |
| 512 | if (t) return { |
| 513 | type: "text", |
| 514 | raw: t[0], |
| 515 | text: t[0], |
| 516 | tokens: this.lexer.inline(t[0]) |
| 517 | }; |
| 518 | } |
| 519 | escape(e) { |
| 520 | let t = this.rules.inline.escape.exec(e); |
| 521 | if (t) return { |
| 522 | type: "escape", |
| 523 | raw: t[0], |
| 524 | text: t[1] |
| 525 | }; |
| 526 | } |
| 527 | tag(e) { |
| 528 | let t = this.rules.inline.tag.exec(e); |
| 529 | if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), { |
| 530 | type: "html", |
| 531 | raw: t[0], |
| 532 | inLink: this.lexer.state.inLink, |
| 533 | inRawBlock: this.lexer.state.inRawBlock, |
| 534 | block: !1, |
| 535 | text: t[0] |
| 536 | }; |
| 537 | } |
| 538 | link(e) { |
| 539 | let t = this.rules.inline.link.exec(e); |
| 540 | if (t) { |
| 541 | let e = t[2].trim(); |
| 542 | if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e)) { |
| 543 | if (!this.rules.other.endAngleBracket.test(e)) return; |
| 544 | let t = W(e.slice(0, -1), "\\"); |
| 545 | if ((e.length - t.length) % 2 == 0) return; |
| 546 | } else { |
| 547 | let e = Oe(t[2], "()"); |
| 548 | if (e === -2) return; |
| 549 | if (e > -1) { |
| 550 | let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e; |
| 551 | t[2] = t[2].substring(0, e), t[0] = t[0].substring(0, n).trim(), t[3] = ""; |
| 552 | } |
| 553 | } |
| 554 | let n = t[2], r = ""; |
| 555 | if (this.options.pedantic) { |
| 556 | let e = this.rules.other.pedanticHrefTitle.exec(n); |
| 557 | e && (n = e[1], r = e[3]); |
| 558 | } else r = t[3] ? t[3].slice(1, -1) : ""; |
| 559 | return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (n = this.options.pedantic && !this.rules.other.endAngleBracket.test(e) ? n.slice(1) : n.slice(1, -1)), G(t, { |
| 560 | href: n && n.replace(this.rules.inline.anyPunctuation, "$1"), |
| 561 | title: r && r.replace(this.rules.inline.anyPunctuation, "$1") |
| 562 | }, t[0], this.lexer, this.rules); |
| 563 | } |
| 564 | } |
| 565 | reflink(e, t) { |
| 566 | let n; |
| 567 | if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) { |
| 568 | let e = t[(n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()]; |
| 569 | if (!e) { |
| 570 | let e = n[0].charAt(0); |
| 571 | return { |
| 572 | type: "text", |
| 573 | raw: e, |
| 574 | text: e |
| 575 | }; |
| 576 | } |
| 577 | return G(n, e, n[0], this.lexer, this.rules); |
| 578 | } |
| 579 | } |
| 580 | emStrong(e, t, n = "") { |
| 581 | let r = this.rules.inline.emStrongLDelim.exec(e); |
| 582 | if (!(!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(r[1] || r[3]) || !n || this.rules.inline.punctuation.exec(n))) { |
| 583 | let n = [...r[0]].length - 1, i, a, o = n, s = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; |
| 584 | for (c.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = c.exec(t)) != null;) { |
| 585 | if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i) continue; |
| 586 | if (a = [...i].length, r[3] || r[4]) { |
| 587 | o += a; |
| 588 | continue; |
| 589 | } else if ((r[5] || r[6]) && n % 3 && !((n + a) % 3)) { |
| 590 | s += a; |
| 591 | continue; |
| 592 | } |
| 593 | if (o -= a, o > 0) continue; |
| 594 | a = Math.min(a, a + o + s); |
| 595 | let t = [...r[0]][0].length, c = e.slice(0, n + r.index + t + a); |
| 596 | if (Math.min(n, a) % 2) { |
| 597 | let e = c.slice(1, -1); |
| 598 | return { |
| 599 | type: "em", |
| 600 | raw: c, |
| 601 | text: e, |
| 602 | tokens: this.lexer.inlineTokens(e) |
| 603 | }; |
| 604 | } |
| 605 | let l = c.slice(2, -2); |
| 606 | return { |
| 607 | type: "strong", |
| 608 | raw: c, |
| 609 | text: l, |
| 610 | tokens: this.lexer.inlineTokens(l) |
| 611 | }; |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | codespan(e) { |
| 616 | let t = this.rules.inline.code.exec(e); |
| 617 | if (t) { |
| 618 | let e = t[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(e), r = this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e); |
| 619 | return n && r && (e = e.substring(1, e.length - 1)), { |
| 620 | type: "codespan", |
| 621 | raw: t[0], |
| 622 | text: e |
| 623 | }; |
| 624 | } |
| 625 | } |
| 626 | br(e) { |
| 627 | let t = this.rules.inline.br.exec(e); |
| 628 | if (t) return { |
| 629 | type: "br", |
| 630 | raw: t[0] |
| 631 | }; |
| 632 | } |
| 633 | del(e, t, n = "") { |
| 634 | let r = this.rules.inline.delLDelim.exec(e); |
| 635 | if (r && (!r[1] || !n || this.rules.inline.punctuation.exec(n))) { |
| 636 | let n = [...r[0]].length - 1, i, a, o = n, s = this.rules.inline.delRDelim; |
| 637 | for (s.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = s.exec(t)) != null;) { |
| 638 | if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== n)) continue; |
| 639 | if (r[3] || r[4]) { |
| 640 | o += a; |
| 641 | continue; |
| 642 | } |
| 643 | if (o -= a, o > 0) continue; |
| 644 | a = Math.min(a, a + o); |
| 645 | let t = [...r[0]][0].length, s = e.slice(0, n + r.index + t + a), c = s.slice(n, -n); |
| 646 | return { |
| 647 | type: "del", |
| 648 | raw: s, |
| 649 | text: c, |
| 650 | tokens: this.lexer.inlineTokens(c) |
| 651 | }; |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | autolink(e) { |
| 656 | let t = this.rules.inline.autolink.exec(e); |
| 657 | if (t) { |
| 658 | let e, n; |
| 659 | return t[2] === "@" ? (e = t[1], n = "mailto:" + e) : (e = t[1], n = e), { |
| 660 | type: "link", |
| 661 | raw: t[0], |
| 662 | text: e, |
| 663 | href: n, |
| 664 | tokens: [{ |
| 665 | type: "text", |
| 666 | raw: e, |
| 667 | text: e |
| 668 | }] |
| 669 | }; |
| 670 | } |
| 671 | } |
| 672 | url(e) { |
| 673 | let t; |
| 674 | if (t = this.rules.inline.url.exec(e)) { |
| 675 | let e, n; |
| 676 | if (t[2] === "@") e = t[0], n = "mailto:" + e; |
| 677 | else { |
| 678 | let r; |
| 679 | do |
| 680 | r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? ""; |
| 681 | while (r !== t[0]); |
| 682 | e = t[0], n = t[1] === "www." ? "http://" + t[0] : t[0]; |
| 683 | } |
| 684 | return { |
| 685 | type: "link", |
| 686 | raw: t[0], |
| 687 | text: e, |
| 688 | href: n, |
| 689 | tokens: [{ |
| 690 | type: "text", |
| 691 | raw: e, |
| 692 | text: e |
| 693 | }] |
| 694 | }; |
| 695 | } |
| 696 | } |
| 697 | inlineText(e) { |
| 698 | let t = this.rules.inline.text.exec(e); |
| 699 | if (t) { |
| 700 | let e = this.lexer.state.inRawBlock; |
| 701 | return { |
| 702 | type: "text", |
| 703 | raw: t[0], |
| 704 | text: t[0], |
| 705 | escaped: e |
| 706 | }; |
| 707 | } |
| 708 | } |
| 709 | }, q = class e { |
| 710 | tokens; |
| 711 | options; |
| 712 | state; |
| 713 | inlineQueue; |
| 714 | tokenizer; |
| 715 | constructor(e) { |
| 716 | this.tokens = [], this.tokens.links = Object.create(null), this.options = e || n, this.options.tokenizer = this.options.tokenizer || new K(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { |
| 717 | inLink: !1, |
| 718 | inRawBlock: !1, |
| 719 | top: !0 |
| 720 | }; |
| 721 | let t = { |
| 722 | other: s, |
| 723 | block: R.normal, |
| 724 | inline: z.normal |
| 725 | }; |
| 726 | this.options.pedantic ? (t.block = R.pedantic, t.inline = z.pedantic) : this.options.gfm && (t.block = R.gfm, this.options.breaks ? t.inline = z.breaks : t.inline = z.gfm), this.tokenizer.rules = t; |
| 727 | } |
| 728 | static get rules() { |
| 729 | return { |
| 730 | block: R, |
| 731 | inline: z |
| 732 | }; |
| 733 | } |
| 734 | static lex(t, n) { |
| 735 | return new e(n).lex(t); |
| 736 | } |
| 737 | static lexInline(t, n) { |
| 738 | return new e(n).inlineTokens(t); |
| 739 | } |
| 740 | lex(e) { |
| 741 | e = e.replace(s.carriageReturn, "\n"), this.blockTokens(e, this.tokens); |
| 742 | for (let e = 0; e < this.inlineQueue.length; e++) { |
| 743 | let t = this.inlineQueue[e]; |
| 744 | this.inlineTokens(t.src, t.tokens); |
| 745 | } |
| 746 | return this.inlineQueue = [], this.tokens; |
| 747 | } |
| 748 | blockTokens(e, t = [], n = !1) { |
| 749 | for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(s.tabCharGlobal, " ").replace(s.spaceLine, "")); e;) { |
| 750 | let r; |
| 751 | if (this.options.extensions?.block?.some((n) => (r = n.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue; |
| 752 | if (r = this.tokenizer.space(e)) { |
| 753 | e = e.substring(r.raw.length); |
| 754 | let n = t.at(-1); |
| 755 | r.raw.length === 1 && n !== void 0 ? n.raw += "\n" : t.push(r); |
| 756 | continue; |
| 757 | } |
| 758 | if (r = this.tokenizer.code(e)) { |
| 759 | e = e.substring(r.raw.length); |
| 760 | let n = t.at(-1); |
| 761 | n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.text, this.inlineQueue.at(-1).src = n.text) : t.push(r); |
| 762 | continue; |
| 763 | } |
| 764 | if (r = this.tokenizer.fences(e)) { |
| 765 | e = e.substring(r.raw.length), t.push(r); |
| 766 | continue; |
| 767 | } |
| 768 | if (r = this.tokenizer.heading(e)) { |
| 769 | e = e.substring(r.raw.length), t.push(r); |
| 770 | continue; |
| 771 | } |
| 772 | if (r = this.tokenizer.hr(e)) { |
| 773 | e = e.substring(r.raw.length), t.push(r); |
| 774 | continue; |
| 775 | } |
| 776 | if (r = this.tokenizer.blockquote(e)) { |
| 777 | e = e.substring(r.raw.length), t.push(r); |
| 778 | continue; |
| 779 | } |
| 780 | if (r = this.tokenizer.list(e)) { |
| 781 | e = e.substring(r.raw.length), t.push(r); |
| 782 | continue; |
| 783 | } |
| 784 | if (r = this.tokenizer.html(e)) { |
| 785 | e = e.substring(r.raw.length), t.push(r); |
| 786 | continue; |
| 787 | } |
| 788 | if (r = this.tokenizer.def(e)) { |
| 789 | e = e.substring(r.raw.length); |
| 790 | let n = t.at(-1); |
| 791 | n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.raw, this.inlineQueue.at(-1).src = n.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { |
| 792 | href: r.href, |
| 793 | title: r.title |
| 794 | }, t.push(r)); |
| 795 | continue; |
| 796 | } |
| 797 | if (r = this.tokenizer.table(e)) { |
| 798 | e = e.substring(r.raw.length), t.push(r); |
| 799 | continue; |
| 800 | } |
| 801 | if (r = this.tokenizer.lheading(e)) { |
| 802 | e = e.substring(r.raw.length), t.push(r); |
| 803 | continue; |
| 804 | } |
| 805 | let i = e; |
| 806 | if (this.options.extensions?.startBlock) { |
| 807 | let t = Infinity, n = e.slice(1), r; |
| 808 | this.options.extensions.startBlock.forEach((e) => { |
| 809 | r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r)); |
| 810 | }), t < Infinity && t >= 0 && (i = e.substring(0, t + 1)); |
| 811 | } |
| 812 | if (this.state.top && (r = this.tokenizer.paragraph(i))) { |
| 813 | let a = t.at(-1); |
| 814 | n && a?.type === "paragraph" ? (a.raw += (a.raw.endsWith("\n") ? "" : "\n") + r.raw, a.text += "\n" + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length); |
| 815 | continue; |
| 816 | } |
| 817 | if (r = this.tokenizer.text(e)) { |
| 818 | e = e.substring(r.raw.length); |
| 819 | let n = t.at(-1); |
| 820 | n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = n.text) : t.push(r); |
| 821 | continue; |
| 822 | } |
| 823 | if (e) { |
| 824 | let t = "Infinite loop on byte: " + e.charCodeAt(0); |
| 825 | if (this.options.silent) { |
| 826 | console.error(t); |
| 827 | break; |
| 828 | } else throw Error(t); |
| 829 | } |
| 830 | } |
| 831 | return this.state.top = !0, t; |
| 832 | } |
| 833 | inline(e, t = []) { |
| 834 | return this.inlineQueue.push({ |
| 835 | src: e, |
| 836 | tokens: t |
| 837 | }), t; |
| 838 | } |
| 839 | inlineTokens(e, t = []) { |
| 840 | this.tokenizer.lexer = this; |
| 841 | let n = e, r = null; |
| 842 | if (this.tokens.links) { |
| 843 | let e = Object.keys(this.tokens.links); |
| 844 | if (e.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null;) e.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex)); |
| 845 | } |
| 846 | for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); |
| 847 | let i; |
| 848 | for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null;) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); |
| 849 | n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n; |
| 850 | let a = !1, o = ""; |
| 851 | for (; e;) { |
| 852 | a || (o = ""), a = !1; |
| 853 | let r; |
| 854 | if (this.options.extensions?.inline?.some((n) => (r = n.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue; |
| 855 | if (r = this.tokenizer.escape(e)) { |
| 856 | e = e.substring(r.raw.length), t.push(r); |
| 857 | continue; |
| 858 | } |
| 859 | if (r = this.tokenizer.tag(e)) { |
| 860 | e = e.substring(r.raw.length), t.push(r); |
| 861 | continue; |
| 862 | } |
| 863 | if (r = this.tokenizer.link(e)) { |
| 864 | e = e.substring(r.raw.length), t.push(r); |
| 865 | continue; |
| 866 | } |
| 867 | if (r = this.tokenizer.reflink(e, this.tokens.links)) { |
| 868 | e = e.substring(r.raw.length); |
| 869 | let n = t.at(-1); |
| 870 | r.type === "text" && n?.type === "text" ? (n.raw += r.raw, n.text += r.text) : t.push(r); |
| 871 | continue; |
| 872 | } |
| 873 | if (r = this.tokenizer.emStrong(e, n, o)) { |
| 874 | e = e.substring(r.raw.length), t.push(r); |
| 875 | continue; |
| 876 | } |
| 877 | if (r = this.tokenizer.codespan(e)) { |
| 878 | e = e.substring(r.raw.length), t.push(r); |
| 879 | continue; |
| 880 | } |
| 881 | if (r = this.tokenizer.br(e)) { |
| 882 | e = e.substring(r.raw.length), t.push(r); |
| 883 | continue; |
| 884 | } |
| 885 | if (r = this.tokenizer.del(e, n, o)) { |
| 886 | e = e.substring(r.raw.length), t.push(r); |
| 887 | continue; |
| 888 | } |
| 889 | if (r = this.tokenizer.autolink(e)) { |
| 890 | e = e.substring(r.raw.length), t.push(r); |
| 891 | continue; |
| 892 | } |
| 893 | if (!this.state.inLink && (r = this.tokenizer.url(e))) { |
| 894 | e = e.substring(r.raw.length), t.push(r); |
| 895 | continue; |
| 896 | } |
| 897 | let i = e; |
| 898 | if (this.options.extensions?.startInline) { |
| 899 | let t = Infinity, n = e.slice(1), r; |
| 900 | this.options.extensions.startInline.forEach((e) => { |
| 901 | r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r)); |
| 902 | }), t < Infinity && t >= 0 && (i = e.substring(0, t + 1)); |
| 903 | } |
| 904 | if (r = this.tokenizer.inlineText(i)) { |
| 905 | e = e.substring(r.raw.length), r.raw.slice(-1) !== "_" && (o = r.raw.slice(-1)), a = !0; |
| 906 | let n = t.at(-1); |
| 907 | n?.type === "text" ? (n.raw += r.raw, n.text += r.text) : t.push(r); |
| 908 | continue; |
| 909 | } |
| 910 | if (e) { |
| 911 | let t = "Infinite loop on byte: " + e.charCodeAt(0); |
| 912 | if (this.options.silent) { |
| 913 | console.error(t); |
| 914 | break; |
| 915 | } else throw Error(t); |
| 916 | } |
| 917 | } |
| 918 | return t; |
| 919 | } |
| 920 | }, J = class { |
| 921 | options; |
| 922 | parser; |
| 923 | constructor(e) { |
| 924 | this.options = e || n; |
| 925 | } |
| 926 | space(e) { |
| 927 | return ""; |
| 928 | } |
| 929 | code({ text: e, lang: t, escaped: n }) { |
| 930 | let r = (t || "").match(s.notSpaceStart)?.[0], i = e.replace(s.endingNewline, "") + "\n"; |
| 931 | return r ? "<pre><code class=\"language-" + V(r) + "\">" + (n ? i : V(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : V(i, !0)) + "</code></pre>\n"; |
| 932 | } |
| 933 | blockquote({ tokens: e }) { |
| 934 | return `<blockquote> |
| 935 | ${this.parser.parse(e)}</blockquote> |
| 936 | `; |
| 937 | } |
| 938 | html({ text: e }) { |
| 939 | return e; |
| 940 | } |
| 941 | def(e) { |
| 942 | return ""; |
| 943 | } |
| 944 | heading({ tokens: e, depth: t }) { |
| 945 | return `<h${t}>${this.parser.parseInline(e)}</h${t}> |
| 946 | `; |
| 947 | } |
| 948 | hr(e) { |
| 949 | return "<hr>\n"; |
| 950 | } |
| 951 | list(e) { |
| 952 | let t = e.ordered, n = e.start, r = ""; |
| 953 | for (let t = 0; t < e.items.length; t++) { |
| 954 | let n = e.items[t]; |
| 955 | r += this.listitem(n); |
| 956 | } |
| 957 | let i = t ? "ol" : "ul", a = t && n !== 1 ? " start=\"" + n + "\"" : ""; |
| 958 | return "<" + i + a + ">\n" + r + "</" + i + ">\n"; |
| 959 | } |
| 960 | listitem(e) { |
| 961 | return `<li>${this.parser.parse(e.tokens)}</li> |
| 962 | `; |
| 963 | } |
| 964 | checkbox({ checked: e }) { |
| 965 | return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> "; |
| 966 | } |
| 967 | paragraph({ tokens: e }) { |
| 968 | return `<p>${this.parser.parseInline(e)}</p> |
| 969 | `; |
| 970 | } |
| 971 | table(e) { |
| 972 | let t = "", n = ""; |
| 973 | for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]); |
| 974 | t += this.tablerow({ text: n }); |
| 975 | let r = ""; |
| 976 | for (let t = 0; t < e.rows.length; t++) { |
| 977 | let i = e.rows[t]; |
| 978 | n = ""; |
| 979 | for (let e = 0; e < i.length; e++) n += this.tablecell(i[e]); |
| 980 | r += this.tablerow({ text: n }); |
| 981 | } |
| 982 | return r &&= `<tbody>${r}</tbody>`, "<table>\n<thead>\n" + t + "</thead>\n" + r + "</table>\n"; |
| 983 | } |
| 984 | tablerow({ text: e }) { |
| 985 | return `<tr> |
| 986 | ${e}</tr> |
| 987 | `; |
| 988 | } |
| 989 | tablecell(e) { |
| 990 | let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td"; |
| 991 | return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}> |
| 992 | `; |
| 993 | } |
| 994 | strong({ tokens: e }) { |
| 995 | return `<strong>${this.parser.parseInline(e)}</strong>`; |
| 996 | } |
| 997 | em({ tokens: e }) { |
| 998 | return `<em>${this.parser.parseInline(e)}</em>`; |
| 999 | } |
| 1000 | codespan({ text: e }) { |
| 1001 | return `<code>${V(e, !0)}</code>`; |
| 1002 | } |
| 1003 | br(e) { |
| 1004 | return "<br>"; |
| 1005 | } |
| 1006 | del({ tokens: e }) { |
| 1007 | return `<del>${this.parser.parseInline(e)}</del>`; |
| 1008 | } |
| 1009 | link({ href: e, title: t, tokens: n }) { |
| 1010 | let r = this.parser.parseInline(n), i = H(e); |
| 1011 | if (i === null) return r; |
| 1012 | e = i; |
| 1013 | let a = "<a href=\"" + e + "\""; |
| 1014 | return t && (a += " title=\"" + V(t) + "\""), a += ">" + r + "</a>", a; |
| 1015 | } |
| 1016 | image({ href: e, title: t, text: n, tokens: r }) { |
| 1017 | r && (n = this.parser.parseInline(r, this.parser.textRenderer)); |
| 1018 | let i = H(e); |
| 1019 | if (i === null) return V(n); |
| 1020 | e = i; |
| 1021 | let a = `<img src="${e}" alt="${V(n)}"`; |
| 1022 | return t && (a += ` title="${V(t)}"`), a += ">", a; |
| 1023 | } |
| 1024 | text(e) { |
| 1025 | return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : V(e.text); |
| 1026 | } |
| 1027 | }, Y = class { |
| 1028 | strong({ text: e }) { |
| 1029 | return e; |
| 1030 | } |
| 1031 | em({ text: e }) { |
| 1032 | return e; |
| 1033 | } |
| 1034 | codespan({ text: e }) { |
| 1035 | return e; |
| 1036 | } |
| 1037 | del({ text: e }) { |
| 1038 | return e; |
| 1039 | } |
| 1040 | html({ text: e }) { |
| 1041 | return e; |
| 1042 | } |
| 1043 | text({ text: e }) { |
| 1044 | return e; |
| 1045 | } |
| 1046 | link({ text: e }) { |
| 1047 | return "" + e; |
| 1048 | } |
| 1049 | image({ text: e }) { |
| 1050 | return "" + e; |
| 1051 | } |
| 1052 | br() { |
| 1053 | return ""; |
| 1054 | } |
| 1055 | checkbox({ raw: e }) { |
| 1056 | return e; |
| 1057 | } |
| 1058 | }, X = class e { |
| 1059 | options; |
| 1060 | renderer; |
| 1061 | textRenderer; |
| 1062 | constructor(e) { |
| 1063 | this.options = e || n, this.options.renderer = this.options.renderer || new J(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Y(); |
| 1064 | } |
| 1065 | static parse(t, n) { |
| 1066 | return new e(n).parse(t); |
| 1067 | } |
| 1068 | static parseInline(t, n) { |
| 1069 | return new e(n).parseInline(t); |
| 1070 | } |
| 1071 | parse(e) { |
| 1072 | this.renderer.parser = this; |
| 1073 | let t = ""; |
| 1074 | for (let n = 0; n < e.length; n++) { |
| 1075 | let r = e[n]; |
| 1076 | if (this.options.extensions?.renderers?.[r.type]) { |
| 1077 | let e = r, n = this.options.extensions.renderers[e.type].call({ parser: this }, e); |
| 1078 | if (n !== !1 || ![ |
| 1079 | "space", |
| 1080 | "hr", |
| 1081 | "heading", |
| 1082 | "code", |
| 1083 | "table", |
| 1084 | "blockquote", |
| 1085 | "list", |
| 1086 | "html", |
| 1087 | "def", |
| 1088 | "paragraph", |
| 1089 | "text" |
| 1090 | ].includes(e.type)) { |
| 1091 | t += n || ""; |
| 1092 | continue; |
| 1093 | } |
| 1094 | } |
| 1095 | let i = r; |
| 1096 | switch (i.type) { |
| 1097 | case "space": |
| 1098 | t += this.renderer.space(i); |
| 1099 | break; |
| 1100 | case "hr": |
| 1101 | t += this.renderer.hr(i); |
| 1102 | break; |
| 1103 | case "heading": |
| 1104 | t += this.renderer.heading(i); |
| 1105 | break; |
| 1106 | case "code": |
| 1107 | t += this.renderer.code(i); |
| 1108 | break; |
| 1109 | case "table": |
| 1110 | t += this.renderer.table(i); |
| 1111 | break; |
| 1112 | case "blockquote": |
| 1113 | t += this.renderer.blockquote(i); |
| 1114 | break; |
| 1115 | case "list": |
| 1116 | t += this.renderer.list(i); |
| 1117 | break; |
| 1118 | case "checkbox": |
| 1119 | t += this.renderer.checkbox(i); |
| 1120 | break; |
| 1121 | case "html": |
| 1122 | t += this.renderer.html(i); |
| 1123 | break; |
| 1124 | case "def": |
| 1125 | t += this.renderer.def(i); |
| 1126 | break; |
| 1127 | case "paragraph": |
| 1128 | t += this.renderer.paragraph(i); |
| 1129 | break; |
| 1130 | case "text": |
| 1131 | t += this.renderer.text(i); |
| 1132 | break; |
| 1133 | default: { |
| 1134 | let e = "Token with \"" + i.type + "\" type was not found."; |
| 1135 | if (this.options.silent) return console.error(e), ""; |
| 1136 | throw Error(e); |
| 1137 | } |
| 1138 | } |
| 1139 | } |
| 1140 | return t; |
| 1141 | } |
| 1142 | parseInline(e, t = this.renderer) { |
| 1143 | this.renderer.parser = this; |
| 1144 | let n = ""; |
| 1145 | for (let r = 0; r < e.length; r++) { |
| 1146 | let i = e[r]; |
| 1147 | if (this.options.extensions?.renderers?.[i.type]) { |
| 1148 | let e = this.options.extensions.renderers[i.type].call({ parser: this }, i); |
| 1149 | if (e !== !1 || ![ |
| 1150 | "escape", |
| 1151 | "html", |
| 1152 | "link", |
| 1153 | "image", |
| 1154 | "strong", |
| 1155 | "em", |
| 1156 | "codespan", |
| 1157 | "br", |
| 1158 | "del", |
| 1159 | "text" |
| 1160 | ].includes(i.type)) { |
| 1161 | n += e || ""; |
| 1162 | continue; |
| 1163 | } |
| 1164 | } |
| 1165 | let a = i; |
| 1166 | switch (a.type) { |
| 1167 | case "escape": |
| 1168 | n += t.text(a); |
| 1169 | break; |
| 1170 | case "html": |
| 1171 | n += t.html(a); |
| 1172 | break; |
| 1173 | case "link": |
| 1174 | n += t.link(a); |
| 1175 | break; |
| 1176 | case "image": |
| 1177 | n += t.image(a); |
| 1178 | break; |
| 1179 | case "checkbox": |
| 1180 | n += t.checkbox(a); |
| 1181 | break; |
| 1182 | case "strong": |
| 1183 | n += t.strong(a); |
| 1184 | break; |
| 1185 | case "em": |
| 1186 | n += t.em(a); |
| 1187 | break; |
| 1188 | case "codespan": |
| 1189 | n += t.codespan(a); |
| 1190 | break; |
| 1191 | case "br": |
| 1192 | n += t.br(a); |
| 1193 | break; |
| 1194 | case "del": |
| 1195 | n += t.del(a); |
| 1196 | break; |
| 1197 | case "text": |
| 1198 | n += t.text(a); |
| 1199 | break; |
| 1200 | default: { |
| 1201 | let e = "Token with \"" + a.type + "\" type was not found."; |
| 1202 | if (this.options.silent) return console.error(e), ""; |
| 1203 | throw Error(e); |
| 1204 | } |
| 1205 | } |
| 1206 | } |
| 1207 | return n; |
| 1208 | } |
| 1209 | }, Z = class { |
| 1210 | options; |
| 1211 | block; |
| 1212 | constructor(e) { |
| 1213 | this.options = e || n; |
| 1214 | } |
| 1215 | static passThroughHooks = new Set([ |
| 1216 | "preprocess", |
| 1217 | "postprocess", |
| 1218 | "processAllTokens", |
| 1219 | "emStrongMask" |
| 1220 | ]); |
| 1221 | static passThroughHooksRespectAsync = new Set([ |
| 1222 | "preprocess", |
| 1223 | "postprocess", |
| 1224 | "processAllTokens" |
| 1225 | ]); |
| 1226 | preprocess(e) { |
| 1227 | return e; |
| 1228 | } |
| 1229 | postprocess(e) { |
| 1230 | return e; |
| 1231 | } |
| 1232 | processAllTokens(e) { |
| 1233 | return e; |
| 1234 | } |
| 1235 | emStrongMask(e) { |
| 1236 | return e; |
| 1237 | } |
| 1238 | provideLexer() { |
| 1239 | return this.block ? q.lex : q.lexInline; |
| 1240 | } |
| 1241 | provideParser() { |
| 1242 | return this.block ? X.parse : X.parseInline; |
| 1243 | } |
| 1244 | }, Q = new class { |
| 1245 | defaults = t(); |
| 1246 | options = this.setOptions; |
| 1247 | parse = this.parseMarkdown(!0); |
| 1248 | parseInline = this.parseMarkdown(!1); |
| 1249 | Parser = X; |
| 1250 | Renderer = J; |
| 1251 | TextRenderer = Y; |
| 1252 | Lexer = q; |
| 1253 | Tokenizer = K; |
| 1254 | Hooks = Z; |
| 1255 | constructor(...e) { |
| 1256 | this.use(...e); |
| 1257 | } |
| 1258 | walkTokens(e, t) { |
| 1259 | let n = []; |
| 1260 | for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) { |
| 1261 | case "table": { |
| 1262 | let e = r; |
| 1263 | for (let r of e.header) n = n.concat(this.walkTokens(r.tokens, t)); |
| 1264 | for (let r of e.rows) for (let e of r) n = n.concat(this.walkTokens(e.tokens, t)); |
| 1265 | break; |
| 1266 | } |
| 1267 | case "list": { |
| 1268 | let e = r; |
| 1269 | n = n.concat(this.walkTokens(e.items, t)); |
| 1270 | break; |
| 1271 | } |
| 1272 | default: { |
| 1273 | let e = r; |
| 1274 | this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((r) => { |
| 1275 | let i = e[r].flat(Infinity); |
| 1276 | n = n.concat(this.walkTokens(i, t)); |
| 1277 | }) : e.tokens && (n = n.concat(this.walkTokens(e.tokens, t))); |
| 1278 | } |
| 1279 | } |
| 1280 | return n; |
| 1281 | } |
| 1282 | use(...e) { |
| 1283 | let t = this.defaults.extensions || { |
| 1284 | renderers: {}, |
| 1285 | childTokens: {} |
| 1286 | }; |
| 1287 | return e.forEach((e) => { |
| 1288 | let n = { ...e }; |
| 1289 | if (n.async = this.defaults.async || n.async || !1, e.extensions && (e.extensions.forEach((e) => { |
| 1290 | if (!e.name) throw Error("extension name required"); |
| 1291 | if ("renderer" in e) { |
| 1292 | let n = t.renderers[e.name]; |
| 1293 | n ? t.renderers[e.name] = function(...t) { |
| 1294 | let r = e.renderer.apply(this, t); |
| 1295 | return r === !1 && (r = n.apply(this, t)), r; |
| 1296 | } : t.renderers[e.name] = e.renderer; |
| 1297 | } |
| 1298 | if ("tokenizer" in e) { |
| 1299 | if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'"); |
| 1300 | let n = t[e.level]; |
| 1301 | n ? n.unshift(e.tokenizer) : t[e.level] = [e.tokenizer], e.start && (e.level === "block" ? t.startBlock ? t.startBlock.push(e.start) : t.startBlock = [e.start] : e.level === "inline" && (t.startInline ? t.startInline.push(e.start) : t.startInline = [e.start])); |
| 1302 | } |
| 1303 | "childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens); |
| 1304 | }), n.extensions = t), e.renderer) { |
| 1305 | let t = this.defaults.renderer || new J(this.defaults); |
| 1306 | for (let n in e.renderer) { |
| 1307 | if (!(n in t)) throw Error(`renderer '${n}' does not exist`); |
| 1308 | if (["options", "parser"].includes(n)) continue; |
| 1309 | let r = n, i = e.renderer[r], a = t[r]; |
| 1310 | t[r] = (...e) => { |
| 1311 | let n = i.apply(t, e); |
| 1312 | return n === !1 && (n = a.apply(t, e)), n || ""; |
| 1313 | }; |
| 1314 | } |
| 1315 | n.renderer = t; |
| 1316 | } |
| 1317 | if (e.tokenizer) { |
| 1318 | let t = this.defaults.tokenizer || new K(this.defaults); |
| 1319 | for (let n in e.tokenizer) { |
| 1320 | if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`); |
| 1321 | if ([ |
| 1322 | "options", |
| 1323 | "rules", |
| 1324 | "lexer" |
| 1325 | ].includes(n)) continue; |
| 1326 | let r = n, i = e.tokenizer[r], a = t[r]; |
| 1327 | t[r] = (...e) => { |
| 1328 | let n = i.apply(t, e); |
| 1329 | return n === !1 && (n = a.apply(t, e)), n; |
| 1330 | }; |
| 1331 | } |
| 1332 | n.tokenizer = t; |
| 1333 | } |
| 1334 | if (e.hooks) { |
| 1335 | let t = this.defaults.hooks || new Z(); |
| 1336 | for (let n in e.hooks) { |
| 1337 | if (!(n in t)) throw Error(`hook '${n}' does not exist`); |
| 1338 | if (["options", "block"].includes(n)) continue; |
| 1339 | let r = n, i = e.hooks[r], a = t[r]; |
| 1340 | Z.passThroughHooks.has(n) ? t[r] = (e) => { |
| 1341 | if (this.defaults.async && Z.passThroughHooksRespectAsync.has(n)) return (async () => { |
| 1342 | let n = await i.call(t, e); |
| 1343 | return a.call(t, n); |
| 1344 | })(); |
| 1345 | let r = i.call(t, e); |
| 1346 | return a.call(t, r); |
| 1347 | } : t[r] = (...e) => { |
| 1348 | if (this.defaults.async) return (async () => { |
| 1349 | let n = await i.apply(t, e); |
| 1350 | return n === !1 && (n = await a.apply(t, e)), n; |
| 1351 | })(); |
| 1352 | let n = i.apply(t, e); |
| 1353 | return n === !1 && (n = a.apply(t, e)), n; |
| 1354 | }; |
| 1355 | } |
| 1356 | n.hooks = t; |
| 1357 | } |
| 1358 | if (e.walkTokens) { |
| 1359 | let t = this.defaults.walkTokens, r = e.walkTokens; |
| 1360 | n.walkTokens = function(e) { |
| 1361 | let n = []; |
| 1362 | return n.push(r.call(this, e)), t && (n = n.concat(t.call(this, e))), n; |
| 1363 | }; |
| 1364 | } |
| 1365 | this.defaults = { |
| 1366 | ...this.defaults, |
| 1367 | ...n |
| 1368 | }; |
| 1369 | }), this; |
| 1370 | } |
| 1371 | setOptions(e) { |
| 1372 | return this.defaults = { |
| 1373 | ...this.defaults, |
| 1374 | ...e |
| 1375 | }, this; |
| 1376 | } |
| 1377 | lexer(e, t) { |
| 1378 | return q.lex(e, t ?? this.defaults); |
| 1379 | } |
| 1380 | parser(e, t) { |
| 1381 | return X.parse(e, t ?? this.defaults); |
| 1382 | } |
| 1383 | parseMarkdown(e) { |
| 1384 | return (t, n) => { |
| 1385 | let r = { ...n }, i = { |
| 1386 | ...this.defaults, |
| 1387 | ...r |
| 1388 | }, a = this.onError(!!i.silent, !!i.async); |
| 1389 | if (this.defaults.async === !0 && r.async === !1) return a(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); |
| 1390 | if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null")); |
| 1391 | if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected")); |
| 1392 | if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => { |
| 1393 | let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer() : e ? q.lex : q.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r; |
| 1394 | i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens)); |
| 1395 | let o = await (i.hooks ? await i.hooks.provideParser() : e ? X.parse : X.parseInline)(a, i); |
| 1396 | return i.hooks ? await i.hooks.postprocess(o) : o; |
| 1397 | })().catch(a); |
| 1398 | try { |
| 1399 | i.hooks && (t = i.hooks.preprocess(t)); |
| 1400 | let n = (i.hooks ? i.hooks.provideLexer() : e ? q.lex : q.lexInline)(t, i); |
| 1401 | i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens); |
| 1402 | let r = (i.hooks ? i.hooks.provideParser() : e ? X.parse : X.parseInline)(n, i); |
| 1403 | return i.hooks && (r = i.hooks.postprocess(r)), r; |
| 1404 | } catch (e) { |
| 1405 | return a(e); |
| 1406 | } |
| 1407 | }; |
| 1408 | } |
| 1409 | onError(e, t) { |
| 1410 | return (n) => { |
| 1411 | if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) { |
| 1412 | let e = "<p>An error occurred:</p><pre>" + V(n.message + "", !0) + "</pre>"; |
| 1413 | return t ? Promise.resolve(e) : e; |
| 1414 | } |
| 1415 | if (t) return Promise.reject(n); |
| 1416 | throw n; |
| 1417 | }; |
| 1418 | } |
| 1419 | }(); |
| 1420 | function $(e, t) { |
| 1421 | return Q.parse(e, t); |
| 1422 | } |
| 1423 | $.options = $.setOptions = function(e) { |
| 1424 | return Q.setOptions(e), $.defaults = Q.defaults, r($.defaults), $; |
| 1425 | }, $.getDefaults = t, $.defaults = n, $.use = function(...e) { |
| 1426 | return Q.use(...e), $.defaults = Q.defaults, r($.defaults), $; |
| 1427 | }, $.walkTokens = function(e, t) { |
| 1428 | return Q.walkTokens(e, t); |
| 1429 | }, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = J, $.TextRenderer = Y, $.Lexer = q, $.lexer = q.lex, $.Tokenizer = K, $.Hooks = Z, $.parse = $, $.options, $.setOptions, $.use, $.walkTokens, $.parseInline, X.parse, q.lex; |
| 1430 | //#endregion |
| 1431 | //#region plugin/notes/index.ts |
| 1432 | var je = () => { |
| 1433 | let t, n = null, r; |
| 1434 | function i() { |
| 1435 | if (n && !n.closed) n.focus(); |
| 1436 | else { |
| 1437 | if (n = window.open("about:blank", "reveal.js - Notes", "width=1100,height=700"), n.marked = $, n.document.write(e), !n) { |
| 1438 | alert("Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view."); |
| 1439 | return; |
| 1440 | } |
| 1441 | o(); |
| 1442 | } |
| 1443 | } |
| 1444 | function a(e) { |
| 1445 | n && !n.closed ? n.focus() : (n = e, window.addEventListener("message", u), d()); |
| 1446 | } |
| 1447 | function o() { |
| 1448 | let e = r.getConfig().url, i = typeof e == "string" ? e : window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; |
| 1449 | t = setInterval(function() { |
| 1450 | n.postMessage(JSON.stringify({ |
| 1451 | namespace: "reveal-notes", |
| 1452 | type: "connect", |
| 1453 | state: r.getState(), |
| 1454 | url: i |
| 1455 | }), "*"); |
| 1456 | }, 500), window.addEventListener("message", u); |
| 1457 | } |
| 1458 | function s(e, t, i) { |
| 1459 | let a = r[e].apply(r, t); |
| 1460 | n.postMessage(JSON.stringify({ |
| 1461 | namespace: "reveal-notes", |
| 1462 | type: "return", |
| 1463 | result: a, |
| 1464 | callId: i |
| 1465 | }), "*"); |
| 1466 | } |
| 1467 | function c(e) { |
| 1468 | let t = r.getCurrentSlide(), i = t.querySelectorAll("aside.notes"), a = t.querySelector(".current-fragment"), o = { |
| 1469 | namespace: "reveal-notes", |
| 1470 | type: "state", |
| 1471 | notes: "", |
| 1472 | markdown: !1, |
| 1473 | whitespace: "normal", |
| 1474 | state: r.getState() |
| 1475 | }; |
| 1476 | if (t.hasAttribute("data-notes") && (o.notes = t.getAttribute("data-notes"), o.whitespace = "pre-wrap"), a) { |
| 1477 | let e = a.querySelector("aside.notes"); |
| 1478 | e ? (o.notes = e.innerHTML, o.markdown = typeof e.getAttribute("data-markdown") == "string", i = null) : a.hasAttribute("data-notes") && (o.notes = a.getAttribute("data-notes"), o.whitespace = "pre-wrap", i = null); |
| 1479 | } |
| 1480 | i && i.length && (i = Array.from(i).filter((e) => e.closest(".fragment") === null), o.notes = i.map((e) => e.innerHTML).join("\n"), o.markdown = i[0] && typeof i[0].getAttribute("data-markdown") == "string"), n.postMessage(JSON.stringify(o), "*"); |
| 1481 | } |
| 1482 | function l(e) { |
| 1483 | try { |
| 1484 | return window.location.origin === e.source.location.origin; |
| 1485 | } catch { |
| 1486 | return !1; |
| 1487 | } |
| 1488 | } |
| 1489 | function u(e) { |
| 1490 | if (l(e)) try { |
| 1491 | let n = JSON.parse(e.data); |
| 1492 | n && n.namespace === "reveal-notes" && n.type === "connected" ? (clearInterval(t), d()) : n && n.namespace === "reveal-notes" && n.type === "call" && s(n.methodName, n.arguments, n.callId); |
| 1493 | } catch {} |
| 1494 | } |
| 1495 | function d() { |
| 1496 | r.on("slidechanged", c), r.on("fragmentshown", c), r.on("fragmenthidden", c), r.on("overviewhidden", c), r.on("overviewshown", c), r.on("paused", c), r.on("resumed", c), r.on("previewiframe", c), r.on("previewimage", c), r.on("previewvideo", c), r.on("closeoverlay", c), c(); |
| 1497 | } |
| 1498 | return { |
| 1499 | id: "notes", |
| 1500 | init: function(e) { |
| 1501 | r = e, /receiver/i.test(window.location.search) || (window.location.search.match(/(\?|\&)notes/gi) === null ? window.addEventListener("message", (e) => { |
| 1502 | if (!n && typeof e.data == "string") { |
| 1503 | let t; |
| 1504 | try { |
| 1505 | t = JSON.parse(e.data); |
| 1506 | } catch {} |
| 1507 | t && t.namespace === "reveal-notes" && t.type === "heartbeat" && a(e.source); |
| 1508 | } |
| 1509 | }) : i(), r.addKeyBinding({ |
| 1510 | keyCode: 83, |
| 1511 | key: "S", |
| 1512 | description: "Speaker notes view" |
| 1513 | }, function() { |
| 1514 | i(); |
| 1515 | })); |
| 1516 | }, |
| 1517 | open: i |
| 1518 | }; |
| 1519 | }; |
| 1520 | //#endregion |
| 1521 | export { je as default }; |
| 1522 |