mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-16 19:59:16 +00:00
fix: Autoscroll detection (#23026)
This commit is contained in:
parent
9ed6e19b9d
commit
320a6a44a5
3 changed files with 208 additions and 223 deletions
|
|
@ -7006,210 +7006,209 @@ $$slots:{default:!0}}),reset(div_7),append($$anchor5,div_7)};if_block(node_11,$$
|
|||
()=>set_class(button,1,`group/expand w-full text-left ${!get$3(isExpanded)&&get$3(showExpandButton)?"cursor-pointer":"cursor-auto"}`)),delegated("click",button,function(...$$args){(get$3(showExpandButton)&&!get$3(isExpanded)?toggleExpand:void 0)?.apply(this,$$args)}),append($$anchor3,div_3)},d2=user_derived(()=>$$props.message.content.trim());if_block(node_5,$$render=>{get$3(d2)&&$$render(consequent_4)})}var node_13=sibling(node_5,2);{var consequent_5=$$anchor3=>{var div_8=root_13$8(),node_14=child(
|
||||
div_8);ChatMessageActionIcons(node_14,{actionsPosition:"right",get deletionInfo(){return $$props.deletionInfo},justify:"end",get onConfirmDelete(){return $$props.onConfirmDelete},get onCopy(){return $$props.onCopy},get onDelete(){return $$props.onDelete},get onEdit(){return $$props.onEdit},get onNavigateToSibling(){return $$props.onNavigateToSibling},get onShowDeleteDialogChange(){return $$props.onShowDeleteDialogChange},get siblingInfo(){return siblingInfo()},get showDeleteDialog(){return $$props.
|
||||
showDeleteDialog},get role(){return MessageRole.USER}}),reset(div_8),append($$anchor3,div_8)};if_block(node_13,$$render=>{$$props.message.timestamp&&$$render(consequent_5)})}append($$anchor2,fragment_2)};if_block(node2,$$render=>{editCtx.isEditing?$$render(consequent):$$render(alternate_1,-1)})}reset(div),template_effect(()=>set_class(div,1,`group flex flex-col items-end gap-3 md:gap-2 ${className()??""}`)),append($$anchor,div),pop()}delegate(["keydown","input","click"]);class AutoScrollController{#_autoScrollEnabled=state$1(
|
||||
!0);get _autoScrollEnabled(){return get$3(this.#_autoScrollEnabled)}set _autoScrollEnabled(value){set$1(this.#_autoScrollEnabled,value,!0)}#_userScrolledUp=state$1(!1);get _userScrolledUp(){return get$3(this.#_userScrolledUp)}set _userScrolledUp(value){set$1(this.#_userScrolledUp,value,!0)}#_lastScrollTop=state$1(0);get _lastScrollTop(){return get$3(this.#_lastScrollTop)}set _lastScrollTop(value){set$1(this.#_lastScrollTop,value,!0)}_scrollInterval;_scrollTimeout;_container;_disabled;_mutationObserver=null;_rafPending=!1;_observerEnabled=!1;constructor(options={}){
|
||||
this._disabled=options.disabled??!1}get autoScrollEnabled(){return this._autoScrollEnabled}get userScrolledUp(){return this._userScrolledUp}setContainer(container2){this._doStopObserving(),this._container=container2,this._observerEnabled&&container2&&!this._disabled&&this._doStartObserving()}setDisabled(disabled){this._disabled=disabled,disabled?(this._autoScrollEnabled=!1,this.stopInterval(),this._doStopObserving()):this._observerEnabled&&this._container&&!this._mutationObserver&&this._doStartObserving()}handleScroll(){
|
||||
if(this._disabled||!this._container)return;const{scrollTop,scrollHeight,clientHeight}=this._container,distanceFromBottom=scrollHeight-clientHeight-scrollTop,isScrollingUp=scrollTop<this._lastScrollTop,isAtBottom=distanceFromBottom<AUTO_SCROLL_AT_BOTTOM_THRESHOLD;isScrollingUp&&!isAtBottom?(this._userScrolledUp=!0,this._autoScrollEnabled=!1):isAtBottom&&this._userScrolledUp&&(this._userScrolledUp=!1,this._autoScrollEnabled=!0),this._scrollTimeout&&clearTimeout(this._scrollTimeout),this._scrollTimeout=
|
||||
setTimeout(()=>{isAtBottom&&(this._userScrolledUp=!1,this._autoScrollEnabled=!0)},AUTO_SCROLL_INTERVAL),this._lastScrollTop=scrollTop}scrollToBottom(behavior="smooth"){this._disabled||!this._container||this._container.scrollTo({top:this._container.scrollHeight,behavior})}enable(){this._disabled||(this._userScrolledUp=!1,this._autoScrollEnabled=!0)}startInterval(){this._disabled||this._scrollInterval||(this._scrollInterval=setInterval(()=>{this.scrollToBottom()},AUTO_SCROLL_INTERVAL))}stopInterval(){
|
||||
this._scrollInterval&&(clearInterval(this._scrollInterval),this._scrollInterval=void 0)}updateInterval(isStreaming){if(this._disabled){this.stopInterval();return}isStreaming&&this._autoScrollEnabled?this._scrollInterval||this.startInterval():this.stopInterval()}destroy(){this.stopInterval(),this._doStopObserving(),this._scrollTimeout&&(clearTimeout(this._scrollTimeout),this._scrollTimeout=void 0)}startObserving(){this._observerEnabled=!0,this._container&&!this._disabled&&!this._mutationObserver&&
|
||||
this._doStartObserving()}stopObserving(){this._observerEnabled=!1,this._doStopObserving()}_doStartObserving(){!this._container||this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>{!this._autoScrollEnabled||this._rafPending||(this._rafPending=!0,requestAnimationFrame(()=>{this._rafPending=!1,this._autoScrollEnabled&&this._container&&(this._container.scrollTop=this._container.scrollHeight)}))}),this._mutationObserver.observe(this._container,{childList:!0,subtree:!0,characterData:!0}))}_doStopObserving(){
|
||||
this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this._rafPending=!1}}function createAutoScrollController(options={}){return new AutoScrollController(options)}function useKeyboardShortcuts(callbacks){function handleKeydown(event2){const isCmdOrCtrl=event2.metaKey||event2.ctrlKey;isCmdOrCtrl&&event2.key===KeyboardKey.K_LOWER&&(event2.preventDefault(),callbacks.activateSearchMode?.(),callbacks.onSearchActivated?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key===
|
||||
KeyboardKey.O_LOWER||event2.key===KeyboardKey.O_UPPER)&&(event2.preventDefault(),goto(ROUTES.NEW_CHAT)),event2.shiftKey&&isCmdOrCtrl&&event2.key===KeyboardKey.E_UPPER&&(event2.preventDefault(),callbacks.editActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key===KeyboardKey.D_LOWER||event2.key===KeyboardKey.D_UPPER)&&(event2.preventDefault(),callbacks.deleteActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_UP&&(event2.preventDefault(),callbacks.navigateToPrevConversation?.()),
|
||||
isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_DOWN&&(event2.preventDefault(),callbacks.navigateToNextConversation?.())}return{handleKeydown}}var root_5$i=from_html('<div class="mb-8 px-4 text-center"><h1 class="mb-2 text-2xl font-semibold tracking-tight md:text-3xl">Hello there</h1> <p class="text-muted-foreground md:text-lg"> </p></div>'),root_9$d=from_html('<span>Server unavailable</span> <button class="flex items-center gap-1.5 rounded-lg bg-destructive/20 px-2 py-1 text-xs fon\
|
||||
t-medium hover:bg-destructive/30 disabled:opacity-50"><!> </button>',1),root_8$j=from_html("<!> <!> <!>",1),root_7$h=from_html('<div class="pointer-events-auto mx-auto mb-4 max-w-[48rem] px-1"><!></div>'),root_3$D=from_html('<div aria-label="Chat interface with file drop zone" class="flex h-full flex-col overflow-y-auto px-4 md:px-6" role="main"><div class="flex grow flex-col pt-14"><!> <div><!> <!> <!> <div class="conversation-chat-form pointer-events-auto rounded-t-3xl"><!></div></div></div></\
|
||||
div>'),root$$=from_html("<!> <!> <!> <!> <!> <!>",1);function ChatScreen($$anchor,$$props){push$1($$props,!0);let showCenteredEmpty=prop($$props,"showCenteredEmpty",3,!1);const autoScroll=createAutoScrollController();let disableAutoScroll=user_derived(()=>!!config$1().disableAutoScroll),chatScrollContainer=state$1(void 0),dragCounter=state$1(0),isDragOver=state$1(!1),showFileErrorDialog=state$1(!1),uploadedFiles=state$1(proxy([])),fileErrorData=state$1(proxy({generallyUnsupported:[],modalityUnsupported:[],
|
||||
modalityReasons:{},supportedTypes:[]})),showDeleteDialog=state$1(!1),showEmptyFileDialog=state$1(!1),emptyFileNames=state$1(proxy([])),initialMessage=state$1(""),isEmpty=user_derived(()=>showCenteredEmpty()&&!activeConversation()&&activeMessages().length===0&&!isLoading()),activeErrorDialog=user_derived(errorDialog),isServerLoading=user_derived(serverLoading),hasPropsError=user_derived(()=>!!serverError()),isCurrentConversationLoading=user_derived(()=>isLoading()||isChatStreaming()),showProcessingInfo=user_derived(
|
||||
()=>get$3(isCurrentConversationLoading)||config$1().keepStatsVisible&&!!page$1.params.id||activeProcessingState()!==null),isRouter=user_derived(isRouterMode),conversationModel=user_derived(()=>chatStore.getConversationModel(activeMessages())),activeModelId=user_derived(()=>{const options=modelOptions();if(!get$3(isRouter))return options.length>0?options[0].model:null;const selectedId=selectedModelId();if(selectedId){const model=options.find(m=>m.id===selectedId);if(model)return model.model}if(get$3(
|
||||
conversationModel)){const model=options.find(m=>m.model===get$3(conversationModel));if(model)return model.model}return null}),modelPropsVersion=state$1(0);setProcessingInfoContext({get showProcessingInfo(){return get$3(showProcessingInfo)}}),user_effect(()=>{get$3(activeModelId)&&(modelsStore.getModelProps(get$3(activeModelId))||modelsStore.fetchModelProps(get$3(activeModelId)).then(()=>{update$1(modelPropsVersion)}))});let hasAudioModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),
|
||||
modelsStore.modelSupportsAudio(get$3(activeModelId))):!1),hasVisionModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsVision(get$3(activeModelId))):!1);async function handleDeleteConfirm(){const conversation=activeConversation();conversation&&await conversationsStore.deleteConversation(conversation.id),set$1(showDeleteDialog,!1)}function handleDragEnter(event2){event2.preventDefault(),update$1(dragCounter),event2.dataTransfer?.types.includes("Files")&&
|
||||
set$1(isDragOver,!0)}function handleDragLeave(event2){event2.preventDefault(),update$1(dragCounter,-1),get$3(dragCounter)===0&&set$1(isDragOver,!1)}function handleErrorDialogOpenChange(open2){open2||chatStore.dismissErrorDialog()}function handleDragOver(event2){event2.preventDefault()}function handleDrop(event2){if(event2.preventDefault(),set$1(isDragOver,!1),set$1(dragCounter,0),event2.dataTransfer?.files){const files=Array.from(event2.dataTransfer.files);if(isEditing()){const handler=getAddFilesHandler();
|
||||
if(handler){handler(files);return}}processFiles(files)}}function handleFileRemove(fileId){set$1(uploadedFiles,get$3(uploadedFiles).filter(f=>f.id!==fileId),!0)}function handleFileUpload(files){processFiles(files)}const{handleKeydown}=useKeyboardShortcuts({deleteActiveConversation:()=>{activeConversation()&&set$1(showDeleteDialog,!0)}});async function handleSystemPromptAdd(draft){(draft.message||draft.files.length>0)&&chatStore.savePendingDraft(draft.message,draft.files),await chatStore.addSystemPrompt()}
|
||||
function handleScroll(){autoScroll.handleScroll()}async function handleSendMessage(message,files){const plainFiles=files?snapshot(files):void 0,result=plainFiles?await parseFilesToMessageExtras(plainFiles,get$3(activeModelId)??void 0):void 0;if(result?.emptyFiles&&result.emptyFiles.length>0){if(set$1(emptyFileNames,result.emptyFiles,!0),set$1(showEmptyFileDialog,!0),files){const emptyFileNamesSet=new Set(result.emptyFiles);set$1(uploadedFiles,get$3(uploadedFiles).filter(file=>!emptyFileNamesSet.
|
||||
has(file.name)),!0)}return!1}const extras=result?.extras;return autoScroll.enable(),await chatStore.sendMessage(message,extras),autoScroll.scrollToBottom(),!0}async function processFiles(files){const generallySupported=[],generallyUnsupported=[];for(const file of files)isFileTypeSupported(file.name,file.type)?generallySupported.push(file):generallyUnsupported.push(file);const capabilities={hasVision:get$3(hasVisionModality),hasAudio:get$3(hasAudioModality)},{supportedFiles,unsupportedFiles,modalityReasons}=filterFilesByModalities(
|
||||
generallySupported,capabilities);if([...generallyUnsupported,...unsupportedFiles].length>0){const supportedTypes=["text files","PDFs"];get$3(hasVisionModality)&&supportedTypes.push("images"),get$3(hasAudioModality)&&supportedTypes.push("audio files"),set$1(fileErrorData,{generallyUnsupported,modalityUnsupported:unsupportedFiles,modalityReasons,supportedTypes},!0),set$1(showFileErrorDialog,!0)}if(supportedFiles.length>0){const processed=await processFilesToChatUploaded(supportedFiles,get$3(activeModelId)??
|
||||
void 0);set$1(uploadedFiles,[...get$3(uploadedFiles),...processed],!0)}}afterNavigate(()=>{get$3(disableAutoScroll)||autoScroll.enable()});function handleMessagesReady(){get$3(disableAutoScroll)||requestAnimationFrame(()=>{autoScroll.scrollToBottom("instant")})}onMount$1(()=>{autoScroll.startObserving(),get$3(disableAutoScroll)||autoScroll.enable();const pendingDraft=chatStore.consumePendingDraft();pendingDraft&&(set$1(initialMessage,pendingDraft.message,!0),set$1(uploadedFiles,pendingDraft.files,
|
||||
!0))}),user_effect(()=>{autoScroll.setContainer(get$3(chatScrollContainer))}),user_effect(()=>{autoScroll.setDisabled(get$3(disableAutoScroll))});var fragment=root$$();event("keydown",$window,handleKeydown);var node2=first_child(fragment);{var consequent=$$anchor2=>{ChatScreenDragOverlay($$anchor2)};if_block(node2,$$render=>{get$3(isDragOver)&&$$render(consequent)})}var node_1=sibling(node2,2);{var consequent_1=$$anchor2=>{ServerLoadingSplash($$anchor2,{})},alternate=$$anchor2=>{var div=root_3$D(),
|
||||
div_1=child(div),node_2=child(div_1);{var consequent_2=$$anchor3=>{{let $0=user_derived(activeMessages);ChatMessages($$anchor3,{get messages(){return get$3($0)},onUserAction:()=>{autoScroll.enable(),autoScroll.scrollToBottom()},onMessagesReady:handleMessagesReady})}};if_block(node_2,$$render=>{get$3(isEmpty)||$$render(consequent_2)})}var div_2=sibling(node_2,2),node_3=child(div_2);{var consequent_3=$$anchor3=>{var div_3=root_5$i(),p2=sibling(child(div_3),2),text2=child(p2);reset(p2),reset(div_3),
|
||||
action(div_3,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({duration:300})),template_effect(()=>set_text(text2,`${serverStore.props?.modalities?.audio?"Record audio, type a message ":"Type a message"} or upload files to get started`)),append($$anchor3,div_3)};if_block(node_3,$$render=>{get$3(isEmpty)&&$$render(consequent_3)})}var node_4=sibling(node_3,2);{var consequent_4=$$anchor3=>{ChatScreenProcessingInfo($$anchor3,{})};if_block(node_4,$$render=>{page$1.params.id&&$$render(consequent_4)})}
|
||||
var node_5=sibling(node_4,2);{var consequent_5=$$anchor3=>{var div_4=root_7$h(),node_6=child(div_4);component(node_6,()=>Alert,($$anchor4,Alert_Root)=>{Alert_Root($$anchor4,{variant:"destructive",children:($$anchor5,$$slotProps)=>{var fragment_5=root_8$j(),node_7=first_child(fragment_5);Triangle_alert(node_7,{class:"h-4 w-4"});var node_8=sibling(node_7,2);component(node_8,()=>Alert_title,($$anchor6,Alert_Title)=>{Alert_Title($$anchor6,{class:"flex items-center justify-between",children:($$anchor7,$$slotProps2)=>{
|
||||
var fragment_6=root_9$d(),button=sibling(first_child(fragment_6),2),node_9=child(button);{let $0=user_derived(()=>get$3(isServerLoading)?"animate-spin":"");Refresh_cw(node_9,{get class(){return`h-3 w-3 ${get$3($0)??""}`}})}var text_1=sibling(node_9);reset(button),template_effect(()=>{button.disabled=get$3(isServerLoading),set_text(text_1,` ${get$3(isServerLoading)?"Retrying...":"Retry"}`)}),delegated("click",button,()=>serverStore.fetch()),append($$anchor7,fragment_6)},$$slots:{default:!0}})});var node_10=sibling(
|
||||
node_8,2);component(node_10,()=>Alert_description,($$anchor6,Alert_Description)=>{Alert_Description($$anchor6,{children:($$anchor7,$$slotProps2)=>{next$1();var text_2=text$8();template_effect($0=>set_text(text_2,$0),[()=>serverError()]),append($$anchor7,text_2)},$$slots:{default:!0}})}),append($$anchor5,fragment_5)},$$slots:{default:!0}})}),reset(div_4),action(div_4,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({y:10,duration:250})),append($$anchor3,div_4)};if_block(node_5,$$render=>{
|
||||
get$3(hasPropsError)&&$$render(consequent_5)})}var div_5=sibling(node_5,2),node_11=child(div_5);{let $0=user_derived(()=>get$3(hasPropsError)||isEditing());ChatScreenForm(node_11,{get disabled(){return get$3($0)},get initialMessage(){return get$3(initialMessage)},get isLoading(){return get$3(isCurrentConversationLoading)},onFileRemove:handleFileRemove,onFileUpload:handleFileUpload,onSend:handleSendMessage,onStop:()=>chatStore.stopGeneration(),onSystemPromptAdd:handleSystemPromptAdd,get uploadedFiles(){
|
||||
return get$3(uploadedFiles)},set uploadedFiles($$value){set$1(uploadedFiles,$$value,!0)}})}reset(div_5),reset(div_2),reset(div_1),reset(div),bind_this(div,$$value=>set$1(chatScrollContainer,$$value),()=>get$3(chatScrollContainer)),template_effect(()=>set_class(div_2,1,`pointer-events-none ${get$3(isEmpty)?"absolute bottom-[calc(50dvh-7rem)]":"sticky bottom-4"} right-4 left-4 mt-auto pt-16 transition-all duration-200`)),event("dragenter",div,handleDragEnter),event("dragleave",div,handleDragLeave),
|
||||
event("dragover",div,handleDragOver),event("drop",div,handleDrop),event("scroll",div,handleScroll),append($$anchor2,div)};if_block(node_1,$$render=>{get$3(isServerLoading)?$$render(consequent_1):$$render(alternate,-1)})}var node_12=sibling(node_1,2);DialogFileUploadError(node_12,{get fileErrorData(){return get$3(fileErrorData)},get open(){return get$3(showFileErrorDialog)},set open($$value){set$1(showFileErrorDialog,$$value,!0)}});var node_13=sibling(node_12,2);DialogConfirmation(node_13,{title:"\
|
||||
Delete Conversation",description:"Are you sure you want to delete this conversation? This action cannot be undone and will permanently remove all messages in this conversation.",confirmText:"Delete",cancelText:"Cancel",variant:"destructive",get icon(){return Trash_2},onConfirm:handleDeleteConfirm,onCancel:()=>set$1(showDeleteDialog,!1),get open(){return get$3(showDeleteDialog)},set open($$value){set$1(showDeleteDialog,$$value,!0)}});var node_14=sibling(node_13,2);DialogEmptyFileAlert(node_14,{get emptyFiles(){
|
||||
return get$3(emptyFileNames)},onOpenChange:open2=>{open2||set$1(emptyFileNames,[],!0)},get open(){return get$3(showEmptyFileDialog)},set open($$value){set$1(showEmptyFileDialog,$$value,!0)}});var node_15=sibling(node_14,2);{let $0=user_derived(()=>get$3(activeErrorDialog)?.message??""),$1=user_derived(()=>get$3(activeErrorDialog)?.contextInfo),$2=user_derived(()=>!!get$3(activeErrorDialog)),$3=user_derived(()=>get$3(activeErrorDialog)?.type??ErrorDialogType.SERVER);DialogChatError(node_15,{get message(){
|
||||
return get$3($0)},get contextInfo(){return get$3($1)},onOpenChange:handleErrorDialogOpenChange,get open(){return get$3($2)},get type(){return get$3($3)}})}append($$anchor,fragment),pop()}delegate(["click"]);var root$_=from_html('<div class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"><div class="flex flex-col items-center justify-center rounded-2xl border-2 border-dashed border-border bg-background p-12 shadow-lg"><!> <p class="text-lg fo\
|
||||
nt-medium text-foreground">Attach a file</p> <p class="text-sm text-muted-foreground">Drop your files here to upload</p></div></div>');function ChatScreenDragOverlay($$anchor){var div=root$_(),div_1=child(div),node2=child(div_1);Upload(node2,{class:"mb-4 h-12 w-12 text-muted-foreground"}),next$1(4),reset(div_1),reset(div),append($$anchor,div)}class DraftMessagesStore{drafts=new Map;getDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;return this.drafts.get(key2)??{message:"",files:[]}}saveDraftMessage(chatId,message,files){
|
||||
const key2=chatId??NEW_CHAT_DRAFT_KEY;message||files.length>0?this.drafts.set(key2,{message,files:[...files]}):this.drafts.delete(key2)}clearDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;this.drafts.delete(key2)}}const draftMessagesStore=new DraftMessagesStore;function useDraftMessages(options){onMount$1(()=>{const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);(draft.message||draft.files.length>0)&&!options.getInitialMessage()&&(options.setMessage(draft.
|
||||
message),options.setFiles(draft.files))}),beforeNavigate(()=>{const chatId=options.getChatId();draftMessagesStore.saveDraftMessage(chatId,options.getMessage(),options.getFiles())}),afterNavigate(navigation=>{if(navigation?.from!=null){const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);options.setMessage(draft.message),options.setFiles(draft.files)}});function clearDraft(){const chatId=options.getChatId();draftMessagesStore.clearDraftMessage(chatId)}return{clearDraft}}
|
||||
var root$Z=from_html('<div class="relative mx-auto max-w-[48rem]"><!></div>');function ChatScreenForm($$anchor,$$props){push$1($$props,!0);let disabled=prop($$props,"disabled",3,!1),initialMessage=prop($$props,"initialMessage",3,""),isLoading2=prop($$props,"isLoading",3,!1),uploadedFiles=prop($$props,"uploadedFiles",31,()=>proxy([])),chatFormRef=state$1(void 0),chatId=user_derived(()=>page$1.params.id),hasLoadingAttachments=user_derived(()=>uploadedFiles().some(f=>f.isLoading)),message=user_derived(
|
||||
initialMessage),previousIsLoading=user_derived(isLoading2),previousInitialMessage=user_derived(initialMessage);const{clearDraft}=useDraftMessages({getChatId:()=>get$3(chatId),getMessage:()=>get$3(message),getFiles:()=>uploadedFiles(),setMessage:m=>set$1(message,m),setFiles:f=>uploadedFiles(f),getInitialMessage:()=>initialMessage()});function handleFilesAdd(files){$$props.onFileUpload?.(files)}async function handleSubmit(){if(!get$3(message).trim()&&uploadedFiles().length===0||disabled()||get$3(hasLoadingAttachments)||
|
||||
!get$3(chatFormRef)?.checkModelSelected())return;const messageToSend=get$3(message).trim(),filesToSend=[...uploadedFiles()];set$1(message,""),uploadedFiles([]),clearDraft(),get$3(chatFormRef)?.resetTextareaHeight(),await $$props.onSend?.(messageToSend,filesToSend)||(set$1(message,messageToSend),uploadedFiles(filesToSend))}function handleSystemPromptClick(){$$props.onSystemPromptAdd?.({message:get$3(message),files:uploadedFiles()})}function handleUploadedFileRemove(fileId){$$props.onFileRemove?.(
|
||||
fileId)}onMount$1(()=>{setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),afterNavigate(navigation=>{navigation?.from!=null&&setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),user_effect(()=>{initialMessage()!==get$3(previousInitialMessage)&&(set$1(message,initialMessage()),set$1(previousInitialMessage,initialMessage()))}),user_effect(()=>{get$3(previousIsLoading)&&!isLoading2()&&setTimeout(()=>get$3(chatFormRef)?.focus(),10),set$1(previousIsLoading,isLoading2())});var div=root$Z(),node2=child(div);
|
||||
bind_this(ChatForm(node2,{get class(){return $$props.class},get disabled(){return disabled()},get isLoading(){return isLoading2()},showMcpPromptButton:!0,onFilesAdd:handleFilesAdd,get onStop(){return $$props.onStop},onSubmit:handleSubmit,onSystemPromptClick:handleSystemPromptClick,onUploadedFileRemove:handleUploadedFileRemove,get value(){return get$3(message)},set value($$value){set$1(message,$$value)},get uploadedFiles(){return uploadedFiles()},set uploadedFiles($$value){uploadedFiles($$value)}}),
|
||||
$$value=>set$1(chatFormRef,$$value,!0),()=>get$3(chatFormRef)),reset(div),append($$anchor,div),pop()}var root_1$u=from_html('<span class="chat-processing-info-detail pointer-events-auto backdrop-blur-sm svelte-1ktvj8d"> </span>'),root$Y=from_html('<div><div class="chat-processing-info-content svelte-1ktvj8d"></div></div>');function ChatScreenProcessingInfo($$anchor,$$props){push$1($$props,!0);const processingState=useProcessingState(),processingInfoCtx=getProcessingInfoContext();let showProcessingInfo=user_derived(
|
||||
()=>processingInfoCtx.showProcessingInfo),isCurrentConversationLoading=user_derived(isLoading),isStreaming=user_derived(isChatStreaming),processingDetails=user_derived(()=>processingState.getTechnicalDetails());user_effect(()=>{const conversation=activeConversation();untrack$1(()=>chatStore.setActiveProcessingConversation(conversation?.id??null))}),user_effect(()=>{const keepStatsVisible=config$1().keepStatsVisible;if((keepStatsVisible||get$3(isCurrentConversationLoading)||get$3(isStreaming))&&processingState.
|
||||
startMonitoring(),!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&!keepStatsVisible){const timeout=setTimeout(()=>{!config$1().keepStatsVisible&&!isChatStreaming()&&processingState.stopMonitoring()},PROCESSING_INFO_TIMEOUT);return()=>clearTimeout(timeout)}}),user_effect(()=>{const conversation=activeConversation(),messages=activeMessages();if(config$1().keepStatsVisible&&conversation){if(messages.length===0){untrack$1(()=>chatStore.clearProcessingState(conversation.id));return}!get$3(
|
||||
isCurrentConversationLoading)&&!get$3(isStreaming)&&untrack$1(()=>chatStore.restoreProcessingStateFromMessages(messages,conversation.id))}});var div=root$Y(),div_1=child(div);each(div_1,20,()=>get$3(processingDetails),detail=>detail,($$anchor2,detail)=>{var span=root_1$u(),text2=child(span,!0);reset(span),template_effect(()=>set_text(text2,detail)),append($$anchor2,span)}),reset(div_1),reset(div),template_effect(()=>set_class(div,1,clsx(["chat-processing-info-container pointer-events-none",get$3(
|
||||
showProcessingInfo)&&"visible"]),"svelte-1ktvj8d")),append($$anchor,div),pop()}const emptyOptions$7={};function toString$1(value,options){const settings=emptyOptions$7,includeImageAlt=typeof settings.includeImageAlt=="boolean"?settings.includeImageAlt:!0,includeHtml=typeof settings.includeHtml=="boolean"?settings.includeHtml:!0;return one$2(value,includeImageAlt,includeHtml)}function one$2(value,includeImageAlt,includeHtml){if(node(value)){if("value"in value)return value.type==="html"&&!includeHtml?
|
||||
"":value.value;if(includeImageAlt&&"alt"in value&&value.alt)return value.alt;if("children"in value)return all$2(value.children,includeImageAlt,includeHtml)}return Array.isArray(value)?all$2(value,includeImageAlt,includeHtml):""}function all$2(values,includeImageAlt,includeHtml){const result=[];let index2=-1;for(;++index2<values.length;)result[index2]=one$2(values[index2],includeImageAlt,includeHtml);return result.join("")}function node(value){return!!(value&&typeof value=="object")}const element$3=document.
|
||||
createElement("i");function decodeNamedCharacterReference(value){const characterReference2="&"+value+";";element$3.innerHTML=characterReference2;const character=element$3.textContent;return character.charCodeAt(character.length-1)===59&&value!=="semi"||character===characterReference2?!1:character}function splice(list2,start2,remove2,items2){const end=list2.length;let chunkStart=0,parameters;if(start2<0?start2=-start2>end?0:end+start2:start2=start2>end?end:start2,remove2=remove2>0?remove2:0,items2.
|
||||
length<1e4)parameters=Array.from(items2),parameters.unshift(start2,remove2),list2.splice(...parameters);else for(remove2&&list2.splice(start2,remove2);chunkStart<items2.length;)parameters=items2.slice(chunkStart,chunkStart+1e4),parameters.unshift(start2,0),list2.splice(...parameters),chunkStart+=1e4,start2+=1e4}function push(list2,items2){return list2.length>0?(splice(list2,list2.length,0,items2),list2):items2}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(extensions){const all2={};
|
||||
let index2=-1;for(;++index2<extensions.length;)syntaxExtension(all2,extensions[index2]);return all2}function syntaxExtension(all2,extension2){let hook;for(hook in extension2){const left=(hasOwnProperty.call(all2,hook)?all2[hook]:void 0)||(all2[hook]={}),right=extension2[hook];let code2;if(right)for(code2 in right){hasOwnProperty.call(left,code2)||(left[code2]=[]);const value=right[code2];constructs(left[code2],Array.isArray(value)?value:value?[value]:[])}}}function constructs(existing,list2){let index2=-1;
|
||||
const before=[];for(;++index2<list2.length;)(list2[index2].add==="after"?existing:before).push(list2[index2]);splice(existing,0,0,before)}function decodeNumericCharacterReference(value,base2){const code2=Number.parseInt(value,base2);return code2<9||code2===11||code2>13&&code2<32||code2>126&&code2<160||code2>55295&&code2<57344||code2>64975&&code2<65008||(code2&65535)===65535||(code2&65535)===65534||code2>1114111?"<22>":String.fromCodePoint(code2)}function normalizeIdentifier(value){return value.replace(
|
||||
/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);function asciiControl(code2){return code2!==null&&(code2<32||code2===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(code2){return code2!==null&&code2<-2}function markdownLineEndingOrSpace(code2){return code2!==
|
||||
null&&(code2<0||code2===32)}function markdownSpace(code2){return code2===-2||code2===-1||code2===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(/\s/);function regexCheck(regex){return check;function check(code2){return code2!==null&&code2>-1&®ex.test(String.fromCharCode(code2))}}function normalizeUri(value){const result=[];let index2=-1,start2=0,skip=0;for(;++index2<value.length;){const code2=value.charCodeAt(index2);let replace2="";if(code2===
|
||||
37&&asciiAlphanumeric(value.charCodeAt(index2+1))&&asciiAlphanumeric(value.charCodeAt(index2+2)))skip=2;else if(code2<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code2))||(replace2=String.fromCharCode(code2));else if(code2>55295&&code2<57344){const next2=value.charCodeAt(index2+1);code2<56320&&next2>56319&&next2<57344?(replace2=String.fromCharCode(code2,next2),skip=1):replace2="<22>"}else replace2=String.fromCharCode(code2);replace2&&(result.push(value.slice(start2,index2),encodeURIComponent(
|
||||
replace2)),start2=index2+skip+1,replace2=""),skip&&(index2+=skip,skip=0)}return result.join("")+value.slice(start2)}function factorySpace(effects,ok,type2,max2){const limit2=max2?max2-1:Number.POSITIVE_INFINITY;let size2=0;return start2;function start2(code2){return markdownSpace(code2)?(effects.enter(type2),prefix(code2)):ok(code2)}function prefix(code2){return markdownSpace(code2)&&size2++<limit2?(effects.consume(code2),prefix):(effects.exit(type2),ok(code2))}}const content$1={tokenize:initializeContent};
|
||||
function initializeContent(effects){const contentStart=effects.attempt(this.parser.constructs.contentInitial,afterContentStartConstruct,paragraphInitial);let previous2;return contentStart;function afterContentStartConstruct(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,contentStart,"linePrefix")}function paragraphInitial(code2){return effects.enter("paragraph"),lineStart(code2)}function lineStart(code2){
|
||||
const token2=effects.enter("chunkText",{contentType:"text",previous:previous2});return previous2&&(previous2.next=token2),previous2=token2,data(code2)}function data(code2){if(code2===null){effects.exit("chunkText"),effects.exit("paragraph"),effects.consume(code2);return}return markdownLineEnding(code2)?(effects.consume(code2),effects.exit("chunkText"),lineStart):(effects.consume(code2),data)}}const document$2={tokenize:initializeDocument},containerConstruct={tokenize:tokenizeContainer};function initializeDocument(effects){
|
||||
const self2=this,stack=[];let continued=0,childFlow,childToken,lineStartOffset;return start2;function start2(code2){if(continued<stack.length){const item=stack[continued];return self2.containerState=item[1],effects.attempt(item[0].continuation,documentContinue,checkNewContainers)(code2)}return checkNewContainers(code2)}function documentContinue(code2){if(continued++,self2.containerState._closeFlow){self2.containerState._closeFlow=void 0,childFlow&&closeFlow();const indexBeforeExits=self2.events.
|
||||
length;let indexBeforeFlow=indexBeforeExits,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]==="exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){point2=self2.events[indexBeforeFlow][1].end;break}exitContainers(continued);let index2=indexBeforeExits;for(;index2<self2.events.length;)self2.events[index2][1].end={...point2},index2++;return splice(self2.events,indexBeforeFlow+1,0,self2.events.slice(indexBeforeExits)),self2.events.length=index2,checkNewContainers(code2)}return start2(
|
||||
code2)}function checkNewContainers(code2){if(continued===stack.length){if(!childFlow)return documentContinued(code2);if(childFlow.currentConstruct&&childFlow.currentConstruct.concrete)return flowStart(code2);self2.interrupt=!!(childFlow.currentConstruct&&!childFlow._gfmTableDynamicInterruptHack)}return self2.containerState={},effects.check(containerConstruct,thereIsANewContainer,thereIsNoNewContainer)(code2)}function thereIsANewContainer(code2){return childFlow&&closeFlow(),exitContainers(continued),
|
||||
documentContinued(code2)}function thereIsNoNewContainer(code2){return self2.parser.lazy[self2.now().line]=continued!==stack.length,lineStartOffset=self2.now().offset,flowStart(code2)}function documentContinued(code2){return self2.containerState={},effects.attempt(containerConstruct,containerContinue,flowStart)(code2)}function containerContinue(code2){return continued++,stack.push([self2.currentConstruct,self2.containerState]),documentContinued(code2)}function flowStart(code2){if(code2===null){childFlow&&
|
||||
closeFlow(),exitContainers(0),effects.consume(code2);return}return childFlow=childFlow||self2.parser.flow(self2.now()),effects.enter("chunkFlow",{_tokenizer:childFlow,contentType:"flow",previous:childToken}),flowContinue(code2)}function flowContinue(code2){if(code2===null){writeToChild(effects.exit("chunkFlow"),!0),exitContainers(0),effects.consume(code2);return}return markdownLineEnding(code2)?(effects.consume(code2),writeToChild(effects.exit("chunkFlow")),continued=0,self2.interrupt=void 0,start2):
|
||||
(effects.consume(code2),flowContinue)}function writeToChild(token2,endOfFile){const stream=self2.sliceStream(token2);if(endOfFile&&stream.push(null),token2.previous=childToken,childToken&&(childToken.next=token2),childToken=token2,childFlow.defineSkip(token2.start),childFlow.write(stream),self2.parser.lazy[token2.start.line]){let index2=childFlow.events.length;for(;index2--;)if(childFlow.events[index2][1].start.offset<lineStartOffset&&(!childFlow.events[index2][1].end||childFlow.events[index2][1].
|
||||
end.offset>lineStartOffset))return;const indexBeforeExits=self2.events.length;let indexBeforeFlow=indexBeforeExits,seen2,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]==="exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){if(seen2){point2=self2.events[indexBeforeFlow][1].end;break}seen2=!0}for(exitContainers(continued),index2=indexBeforeExits;index2<self2.events.length;)self2.events[index2][1].end={...point2},index2++;splice(self2.events,indexBeforeFlow+1,0,self2.events.
|
||||
slice(indexBeforeExits)),self2.events.length=index2}}function exitContainers(size2){let index2=stack.length;for(;index2-- >size2;){const entry=stack[index2];self2.containerState=entry[1],entry[0].exit.call(self2,effects)}stack.length=size2}function closeFlow(){childFlow.write([null]),childToken=void 0,childFlow=void 0,self2.containerState._closeFlow=void 0}}function tokenizeContainer(effects,ok,nok){return factorySpace(effects,effects.attempt(this.parser.constructs.document,ok,nok),"linePrefix",
|
||||
this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(code2){if(code2===null||markdownLineEndingOrSpace(code2)||unicodeWhitespace(code2))return 1;if(unicodePunctuation(code2))return 2}function resolveAll(constructs2,events,context){const called=[];let index2=-1;for(;++index2<constructs2.length;){const resolve2=constructs2[index2].resolveAll;resolve2&&!called.includes(resolve2)&&(events=resolve2(events,context),called.push(resolve2))}return events}const attention={
|
||||
name:"attention",resolveAll:resolveAllAttention,tokenize:tokenizeAttention};function resolveAllAttention(events,context){let index2=-1,open2,group,text2,openingSequence,closingSequence,use,nextEvents,offset2;for(;++index2<events.length;)if(events[index2][0]==="enter"&&events[index2][1].type==="attentionSequence"&&events[index2][1]._close){for(open2=index2;open2--;)if(events[open2][0]==="exit"&&events[open2][1].type==="attentionSequence"&&events[open2][1]._open&&context.sliceSerialize(events[open2][1]).
|
||||
charCodeAt(0)===context.sliceSerialize(events[index2][1]).charCodeAt(0)){if((events[open2][1]._close||events[index2][1]._open)&&(events[index2][1].end.offset-events[index2][1].start.offset)%3&&!((events[open2][1].end.offset-events[open2][1].start.offset+events[index2][1].end.offset-events[index2][1].start.offset)%3))continue;use=events[open2][1].end.offset-events[open2][1].start.offset>1&&events[index2][1].end.offset-events[index2][1].start.offset>1?2:1;const start2={...events[open2][1].end},end={
|
||||
...events[index2][1].start};movePoint(start2,-use),movePoint(end,use),openingSequence={type:use>1?"strongSequence":"emphasisSequence",start:start2,end:{...events[open2][1].end}},closingSequence={type:use>1?"strongSequence":"emphasisSequence",start:{...events[index2][1].start},end},text2={type:use>1?"strongText":"emphasisText",start:{...events[open2][1].end},end:{...events[index2][1].start}},group={type:use>1?"strong":"emphasis",start:{...openingSequence.start},end:{...closingSequence.end}},events[open2][1].
|
||||
end={...openingSequence.start},events[index2][1].start={...closingSequence.end},nextEvents=[],events[open2][1].end.offset-events[open2][1].start.offset&&(nextEvents=push(nextEvents,[["enter",events[open2][1],context],["exit",events[open2][1],context]])),nextEvents=push(nextEvents,[["enter",group,context],["enter",openingSequence,context],["exit",openingSequence,context],["enter",text2,context]]),nextEvents=push(nextEvents,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+1,
|
||||
index2),context)),nextEvents=push(nextEvents,[["exit",text2,context],["enter",closingSequence,context],["exit",closingSequence,context],["exit",group,context]]),events[index2][1].end.offset-events[index2][1].start.offset?(offset2=2,nextEvents=push(nextEvents,[["enter",events[index2][1],context],["exit",events[index2][1],context]])):offset2=0,splice(events,open2-1,index2-open2+3,nextEvents),index2=open2+nextEvents.length-offset2-2;break}}for(index2=-1;++index2<events.length;)events[index2][1].type===
|
||||
"attentionSequence"&&(events[index2][1].type="data");return events}function tokenizeAttention(effects,ok){const attentionMarkers2=this.parser.constructs.attentionMarkers.null,previous2=this.previous,before=classifyCharacter(previous2);let marker;return start2;function start2(code2){return marker=code2,effects.enter("attentionSequence"),inside(code2)}function inside(code2){if(code2===marker)return effects.consume(code2),inside;const token2=effects.exit("attentionSequence"),after=classifyCharacter(
|
||||
code2),open2=!after||after===2&&before||attentionMarkers2.includes(code2),close2=!before||before===2&&after||attentionMarkers2.includes(previous2);return token2._open=!!(marker===42?open2:open2&&(before||!close2)),token2._close=!!(marker===42?close2:close2&&(after||!open2)),ok(code2)}}function movePoint(point2,offset2){point2.column+=offset2,point2.offset+=offset2,point2._bufferIndex+=offset2}const autolink={name:"autolink",tokenize:tokenizeAutolink};function tokenizeAutolink(effects,ok,nok){let size2=0;
|
||||
return start2;function start2(code2){return effects.enter("autolink"),effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarker"),effects.enter("autolinkProtocol"),open2}function open2(code2){return asciiAlpha(code2)?(effects.consume(code2),schemeOrEmailAtext):code2===64?nok(code2):emailAtext(code2)}function schemeOrEmailAtext(code2){return code2===43||code2===45||code2===46||asciiAlphanumeric(code2)?(size2=1,schemeInsideOrEmailAtext(code2)):emailAtext(code2)}function schemeInsideOrEmailAtext(code2){
|
||||
return code2===58?(effects.consume(code2),size2=0,urlInside):(code2===43||code2===45||code2===46||asciiAlphanumeric(code2))&&size2++<32?(effects.consume(code2),schemeInsideOrEmailAtext):(size2=0,emailAtext(code2))}function urlInside(code2){return code2===62?(effects.exit("autolinkProtocol"),effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarker"),effects.exit("autolink"),ok):code2===null||code2===32||code2===60||asciiControl(code2)?nok(code2):(effects.consume(code2),
|
||||
urlInside)}function emailAtext(code2){return code2===64?(effects.consume(code2),emailAtSignOrDot):asciiAtext(code2)?(effects.consume(code2),emailAtext):nok(code2)}function emailAtSignOrDot(code2){return asciiAlphanumeric(code2)?emailLabel(code2):nok(code2)}function emailLabel(code2){return code2===46?(effects.consume(code2),size2=0,emailAtSignOrDot):code2===62?(effects.exit("autolinkProtocol").type="autolinkEmail",effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarke\
|
||||
r"),effects.exit("autolink"),ok):emailValue(code2)}function emailValue(code2){if((code2===45||asciiAlphanumeric(code2))&&size2++<63){const next2=code2===45?emailValue:emailLabel;return effects.consume(code2),next2}return nok(code2)}}const blankLine={partial:!0,tokenize:tokenizeBlankLine};function tokenizeBlankLine(effects,ok,nok){return start2;function start2(code2){return markdownSpace(code2)?factorySpace(effects,after,"linePrefix")(code2):after(code2)}function after(code2){return code2===null||
|
||||
markdownLineEnding(code2)?ok(code2):nok(code2)}}const blockQuote={continuation:{tokenize:tokenizeBlockQuoteContinuation},exit:exit$1,name:"blockQuote",tokenize:tokenizeBlockQuoteStart};function tokenizeBlockQuoteStart(effects,ok,nok){const self2=this;return start2;function start2(code2){if(code2===62){const state2=self2.containerState;return state2.open||(effects.enter("blockQuote",{_container:!0}),state2.open=!0),effects.enter("blockQuotePrefix"),effects.enter("blockQuoteMarker"),effects.consume(
|
||||
code2),effects.exit("blockQuoteMarker"),after}return nok(code2)}function after(code2){return markdownSpace(code2)?(effects.enter("blockQuotePrefixWhitespace"),effects.consume(code2),effects.exit("blockQuotePrefixWhitespace"),effects.exit("blockQuotePrefix"),ok):(effects.exit("blockQuotePrefix"),ok(code2))}}function tokenizeBlockQuoteContinuation(effects,ok,nok){const self2=this;return contStart;function contStart(code2){return markdownSpace(code2)?factorySpace(effects,contBefore,"linePrefix",self2.
|
||||
parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):contBefore(code2)}function contBefore(code2){return effects.attempt(blockQuote,ok,nok)(code2)}}function exit$1(effects){effects.exit("blockQuote")}const characterEscape={name:"characterEscape",tokenize:tokenizeCharacterEscape};function tokenizeCharacterEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("characterEscape"),effects.enter("escapeMarker"),effects.consume(code2),effects.exit("escapeM\
|
||||
arker"),inside}function inside(code2){return asciiPunctuation(code2)?(effects.enter("characterEscapeValue"),effects.consume(code2),effects.exit("characterEscapeValue"),effects.exit("characterEscape"),ok):nok(code2)}}const characterReference={name:"characterReference",tokenize:tokenizeCharacterReference};function tokenizeCharacterReference(effects,ok,nok){const self2=this;let size2=0,max2,test;return start2;function start2(code2){return effects.enter("characterReference"),effects.enter("character\
|
||||
ReferenceMarker"),effects.consume(code2),effects.exit("characterReferenceMarker"),open2}function open2(code2){return code2===35?(effects.enter("characterReferenceMarkerNumeric"),effects.consume(code2),effects.exit("characterReferenceMarkerNumeric"),numeric):(effects.enter("characterReferenceValue"),max2=31,test=asciiAlphanumeric,value(code2))}function numeric(code2){return code2===88||code2===120?(effects.enter("characterReferenceMarkerHexadecimal"),effects.consume(code2),effects.exit("character\
|
||||
ReferenceMarkerHexadecimal"),effects.enter("characterReferenceValue"),max2=6,test=asciiHexDigit,value):(effects.enter("characterReferenceValue"),max2=7,test=asciiDigit,value(code2))}function value(code2){if(code2===59&&size2){const token2=effects.exit("characterReferenceValue");return test===asciiAlphanumeric&&!decodeNamedCharacterReference(self2.sliceSerialize(token2))?nok(code2):(effects.enter("characterReferenceMarker"),effects.consume(code2),effects.exit("characterReferenceMarker"),effects.exit(
|
||||
"characterReference"),ok)}return test(code2)&&size2++<max2?(effects.consume(code2),value):nok(code2)}}const nonLazyContinuation$1={partial:!0,tokenize:tokenizeNonLazyContinuation$1},codeFenced={concrete:!0,name:"codeFenced",tokenize:tokenizeCodeFenced};function tokenizeCodeFenced(effects,ok,nok){const self2=this,closeStart={partial:!0,tokenize:tokenizeCloseStart};let initialPrefix=0,sizeOpen=0,marker;return start2;function start2(code2){return beforeSequenceOpen(code2)}function beforeSequenceOpen(code2){
|
||||
const tail=self2.events[self2.events.length-1];return initialPrefix=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,marker=code2,effects.enter("codeFenced"),effects.enter("codeFencedFence"),effects.enter("codeFencedFenceSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===marker?(sizeOpen++,effects.consume(code2),sequenceOpen):sizeOpen<3?nok(code2):(effects.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects,infoBefore,"wh\
|
||||
itespace")(code2):infoBefore(code2))}function infoBefore(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFencedFence"),self2.interrupt?ok(code2):effects.check(nonLazyContinuation$1,atNonLazyBreak,after)(code2)):(effects.enter("codeFencedFenceInfo"),effects.enter("chunkString",{contentType:"string"}),info2(code2))}function info2(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),effects.exit("codeFencedFenceInfo"),infoBefore(code2)):markdownSpace(
|
||||
code2)?(effects.exit("chunkString"),effects.exit("codeFencedFenceInfo"),factorySpace(effects,metaBefore,"whitespace")(code2)):code2===96&&code2===marker?nok(code2):(effects.consume(code2),info2)}function metaBefore(code2){return code2===null||markdownLineEnding(code2)?infoBefore(code2):(effects.enter("codeFencedFenceMeta"),effects.enter("chunkString",{contentType:"string"}),meta(code2))}function meta(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),effects.exit(
|
||||
"codeFencedFenceMeta"),infoBefore(code2)):code2===96&&code2===marker?nok(code2):(effects.consume(code2),meta)}function atNonLazyBreak(code2){return effects.attempt(closeStart,after,contentBefore)(code2)}function contentBefore(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),contentStart}function contentStart(code2){return initialPrefix>0&&markdownSpace(code2)?factorySpace(effects,beforeContentChunk,"linePrefix",initialPrefix+1)(code2):beforeContentChunk(
|
||||
code2)}function beforeContentChunk(code2){return code2===null||markdownLineEnding(code2)?effects.check(nonLazyContinuation$1,atNonLazyBreak,after)(code2):(effects.enter("codeFlowValue"),contentChunk(code2))}function contentChunk(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),beforeContentChunk(code2)):(effects.consume(code2),contentChunk)}function after(code2){return effects.exit("codeFenced"),ok(code2)}function tokenizeCloseStart(effects2,ok2,nok2){let size2=0;
|
||||
return startBefore;function startBefore(code2){return effects2.enter("lineEnding"),effects2.consume(code2),effects2.exit("lineEnding"),start3}function start3(code2){return effects2.enter("codeFencedFence"),markdownSpace(code2)?factorySpace(effects2,beforeSequenceClose,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):beforeSequenceClose(code2)}function beforeSequenceClose(code2){return code2===marker?(effects2.enter("codeFencedFenceSequence"),sequenceClose(
|
||||
code2)):nok2(code2)}function sequenceClose(code2){return code2===marker?(size2++,effects2.consume(code2),sequenceClose):size2>=sizeOpen?(effects2.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects2,sequenceCloseAfter,"whitespace")(code2):sequenceCloseAfter(code2)):nok2(code2)}function sequenceCloseAfter(code2){return code2===null||markdownLineEnding(code2)?(effects2.exit("codeFencedFence"),ok2(code2)):nok2(code2)}}}function tokenizeNonLazyContinuation$1(effects,ok,nok){const self2=this;
|
||||
return start2;function start2(code2){return code2===null?nok(code2):(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineStart)}function lineStart(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={partial:!0,tokenize:tokenizeFurtherStart};function tokenizeCodeIndented(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("co\
|
||||
deIndented"),factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?atBreak(code2):nok(code2)}function atBreak(code2){return code2===null?after(code2):markdownLineEnding(code2)?effects.attempt(furtherStart,atBreak,after)(code2):(effects.enter("codeFlowValue"),inside(code2))}function inside(code2){return code2===null||markdownLineEnding(
|
||||
code2)?(effects.exit("codeFlowValue"),atBreak(code2)):(effects.consume(code2),inside)}function after(code2){return effects.exit("codeIndented"),ok(code2)}}function tokenizeFurtherStart(effects,ok,nok){const self2=this;return furtherStart2;function furtherStart2(code2){return self2.parser.lazy[self2.now().line]?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),furtherStart2):factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){
|
||||
const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?ok(code2):markdownLineEnding(code2)?furtherStart2(code2):nok(code2)}}const codeText={name:"codeText",previous:previous$2,resolve:resolveCodeText,tokenize:tokenizeCodeText};function resolveCodeText(events){let tailExitIndex=events.length-4,headEnterIndex=3,index2,enter;if((events[headEnterIndex][1].type==="lineEnding"||events[headEnterIndex][1].type==="space")&&(events[tailExitIndex][1].
|
||||
type==="lineEnding"||events[tailExitIndex][1].type==="space")){for(index2=headEnterIndex;++index2<tailExitIndex;)if(events[index2][1].type==="codeTextData"){events[headEnterIndex][1].type="codeTextPadding",events[tailExitIndex][1].type="codeTextPadding",headEnterIndex+=2,tailExitIndex-=2;break}}for(index2=headEnterIndex-1,tailExitIndex++;++index2<=tailExitIndex;)enter===void 0?index2!==tailExitIndex&&events[index2][1].type!=="lineEnding"&&(enter=index2):(index2===tailExitIndex||events[index2][1].
|
||||
type==="lineEnding")&&(events[enter][1].type="codeTextData",index2!==enter+2&&(events[enter][1].end=events[index2-1][1].end,events.splice(enter+2,index2-enter-2),tailExitIndex-=index2-enter-2,index2=enter+2),enter=void 0);return events}function previous$2(code2){return code2!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tokenizeCodeText(effects,ok,nok){let sizeOpen=0,size2,token2;return start2;function start2(code2){return effects.enter("codeText"),effects.enter("c\
|
||||
odeTextSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===96?(effects.consume(code2),sizeOpen++,sequenceOpen):(effects.exit("codeTextSequence"),between2(code2))}function between2(code2){return code2===null?nok(code2):code2===32?(effects.enter("space"),effects.consume(code2),effects.exit("space"),between2):code2===96?(token2=effects.enter("codeTextSequence"),size2=0,sequenceClose(code2)):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.
|
||||
exit("lineEnding"),between2):(effects.enter("codeTextData"),data(code2))}function data(code2){return code2===null||code2===32||code2===96||markdownLineEnding(code2)?(effects.exit("codeTextData"),between2(code2)):(effects.consume(code2),data)}function sequenceClose(code2){return code2===96?(effects.consume(code2),size2++,sequenceClose):size2===sizeOpen?(effects.exit("codeTextSequence"),effects.exit("codeText"),ok(code2)):(token2.type="codeTextData",data(code2))}}class SpliceBuffer{constructor(initial){
|
||||
this.left=initial?[...initial]:[],this.right=[]}get(index2){if(index2<0||index2>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+index2+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return index2<this.left.length?this.left[index2]:this.right[this.right.length-index2+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(start2,end){const stop=end??Number.POSITIVE_INFINITY;
|
||||
return stop<this.left.length?this.left.slice(start2,stop):start2>this.left.length?this.right.slice(this.right.length-stop+this.left.length,this.right.length-start2+this.left.length).reverse():this.left.slice(start2).concat(this.right.slice(this.right.length-stop+this.left.length).reverse())}splice(start2,deleteCount,items2){const count=deleteCount||0;this.setCursor(Math.trunc(start2));const removed=this.right.splice(this.right.length-count,Number.POSITIVE_INFINITY);return items2&&chunkedPush(this.
|
||||
left,items2),removed.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(item){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(item)}pushMany(items2){this.setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,items2)}unshift(item){this.setCursor(0),this.right.push(item)}unshiftMany(items2){this.setCursor(0),chunkedPush(this.right,items2.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===
|
||||
0))if(n<this.left.length){const removed=this.left.splice(n,Number.POSITIVE_INFINITY);chunkedPush(this.right,removed.reverse())}else{const removed=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);chunkedPush(this.left,removed.reverse())}}}function chunkedPush(list2,right){let chunkStart=0;if(right.length<1e4)list2.push(...right);else for(;chunkStart<right.length;)list2.push(...right.slice(chunkStart,chunkStart+1e4)),chunkStart+=1e4}function subtokenize(eventsArray){
|
||||
const jumps={};let index2=-1,event2,lineIndex,otherIndex,otherEvent,parameters,subevents,more;const events=new SpliceBuffer(eventsArray);for(;++index2<events.length;){for(;index2 in jumps;)index2=jumps[index2];if(event2=events.get(index2),index2&&event2[1].type==="chunkFlow"&&events.get(index2-1)[1].type==="listItemPrefix"&&(subevents=event2[1]._tokenizer.events,otherIndex=0,otherIndex<subevents.length&&subevents[otherIndex][1].type==="lineEndingBlank"&&(otherIndex+=2),otherIndex<subevents.length&&
|
||||
subevents[otherIndex][1].type==="content"))for(;++otherIndex<subevents.length&&subevents[otherIndex][1].type!=="content";)subevents[otherIndex][1].type==="chunkText"&&(subevents[otherIndex][1]._isInFirstContentOfListItem=!0,otherIndex++);if(event2[0]==="enter")event2[1].contentType&&(Object.assign(jumps,subcontent(events,index2)),index2=jumps[index2],more=!0);else if(event2[1]._container){for(otherIndex=index2,lineIndex=void 0;otherIndex--;)if(otherEvent=events.get(otherIndex),otherEvent[1].type===
|
||||
"lineEnding"||otherEvent[1].type==="lineEndingBlank")otherEvent[0]==="enter"&&(lineIndex&&(events.get(lineIndex)[1].type="lineEndingBlank"),otherEvent[1].type="lineEnding",lineIndex=otherIndex);else if(!(otherEvent[1].type==="linePrefix"||otherEvent[1].type==="listItemIndent"))break;lineIndex&&(event2[1].end={...events.get(lineIndex)[1].start},parameters=events.slice(lineIndex,index2),parameters.unshift(event2),events.splice(lineIndex,index2-lineIndex+1,parameters))}}return splice(eventsArray,0,
|
||||
Number.POSITIVE_INFINITY,events.slice(0)),!more}function subcontent(events,eventIndex){const token2=events.get(eventIndex)[1],context=events.get(eventIndex)[2];let startPosition=eventIndex-1;const startPositions=[];let tokenizer=token2._tokenizer;tokenizer||(tokenizer=context.parser[token2.contentType](token2.start),token2._contentTypeTextTrailing&&(tokenizer._contentTypeTextTrailing=!0));const childEvents=tokenizer.events,jumps=[],gaps={};let stream,previous2,index2=-1,current2=token2,adjust=0,
|
||||
start2=0;const breaks=[start2];for(;current2;){for(;events.get(++startPosition)[1]!==current2;);startPositions.push(startPosition),current2._tokenizer||(stream=context.sliceStream(current2),current2.next||stream.push(null),previous2&&tokenizer.defineSkip(current2.start),current2._isInFirstContentOfListItem&&(tokenizer._gfmTasklistFirstContentOfListItem=!0),tokenizer.write(stream),current2._isInFirstContentOfListItem&&(tokenizer._gfmTasklistFirstContentOfListItem=void 0)),previous2=current2,current2=
|
||||
current2.next}for(current2=token2;++index2<childEvents.length;)childEvents[index2][0]==="exit"&&childEvents[index2-1][0]==="enter"&&childEvents[index2][1].type===childEvents[index2-1][1].type&&childEvents[index2][1].start.line!==childEvents[index2][1].end.line&&(start2=index2+1,breaks.push(start2),current2._tokenizer=void 0,current2.previous=void 0,current2=current2.next);for(tokenizer.events=[],current2?(current2._tokenizer=void 0,current2.previous=void 0):breaks.pop(),index2=breaks.length;index2--;){
|
||||
const slice=childEvents.slice(breaks[index2],breaks[index2+1]),start3=startPositions.pop();jumps.push([start3,start3+slice.length-1]),events.splice(start3,2,slice)}for(jumps.reverse(),index2=-1;++index2<jumps.length;)gaps[adjust+jumps[index2][0]]=adjust+jumps[index2][1],adjust+=jumps[index2][1]-jumps[index2][0]-1;return gaps}const content={resolve:resolveContent,tokenize:tokenizeContent},continuationConstruct={partial:!0,tokenize:tokenizeContinuation};function resolveContent(events){return subtokenize(
|
||||
events),events}function tokenizeContent(effects,ok){let previous2;return chunkStart;function chunkStart(code2){return effects.enter("content"),previous2=effects.enter("chunkContent",{contentType:"content"}),chunkInside(code2)}function chunkInside(code2){return code2===null?contentEnd(code2):markdownLineEnding(code2)?effects.check(continuationConstruct,contentContinue,contentEnd)(code2):(effects.consume(code2),chunkInside)}function contentEnd(code2){return effects.exit("chunkContent"),effects.exit(
|
||||
"content"),ok(code2)}function contentContinue(code2){return effects.consume(code2),effects.exit("chunkContent"),previous2.next=effects.enter("chunkContent",{contentType:"content",previous:previous2}),previous2=previous2.next,chunkInside}}function tokenizeContinuation(effects,ok,nok){const self2=this;return startLookahead;function startLookahead(code2){return effects.exit("chunkContent"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,prefixed,"l\
|
||||
inePrefix")}function prefixed(code2){if(code2===null||markdownLineEnding(code2))return nok(code2);const tail=self2.events[self2.events.length-1];return!self2.parser.constructs.disable.null.includes("codeIndented")&&tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?ok(code2):effects.interrupt(self2.parser.constructs.flow,nok,ok)(code2)}}function factoryDestination(effects,ok,nok,type2,literalType,literalMarkerType,rawType,stringType,max2){const limit2=max2||Number.POSITIVE_INFINITY;
|
||||
let balance=0;return start2;function start2(code2){return code2===60?(effects.enter(type2),effects.enter(literalType),effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),enclosedBefore):code2===null||code2===32||code2===41||asciiControl(code2)?nok(code2):(effects.enter(type2),effects.enter(rawType),effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),raw2(code2))}function enclosedBefore(code2){return code2===62?(effects.enter(literalMarkerType),
|
||||
effects.consume(code2),effects.exit(literalMarkerType),effects.exit(literalType),effects.exit(type2),ok):(effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),enclosed(code2))}function enclosed(code2){return code2===62?(effects.exit("chunkString"),effects.exit(stringType),enclosedBefore(code2)):code2===null||code2===60||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),code2===92?enclosedEscape:enclosed)}function enclosedEscape(code2){return code2===60||code2===
|
||||
62||code2===92?(effects.consume(code2),enclosed):enclosed(code2)}function raw2(code2){return!balance&&(code2===null||code2===41||markdownLineEndingOrSpace(code2))?(effects.exit("chunkString"),effects.exit(stringType),effects.exit(rawType),effects.exit(type2),ok(code2)):balance<limit2&&code2===40?(effects.consume(code2),balance++,raw2):code2===41?(effects.consume(code2),balance--,raw2):code2===null||code2===32||code2===40||asciiControl(code2)?nok(code2):(effects.consume(code2),code2===92?rawEscape:
|
||||
raw2)}function rawEscape(code2){return code2===40||code2===41||code2===92?(effects.consume(code2),raw2):raw2(code2)}}function factoryLabel(effects,ok,nok,type2,markerType,stringType){const self2=this;let size2=0,seen2;return start2;function start2(code2){return effects.enter(type2),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.enter(stringType),atBreak}function atBreak(code2){return size2>999||code2===null||code2===91||code2===93&&!seen2||code2===94&&!size2&&"\
|
||||
_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):code2===93?(effects.exit(stringType),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),atBreak):(effects.enter("chunkString",{contentType:"string"}),labelInside(code2))}function labelInside(code2){return code2===null||code2===91||code2===93||markdownLineEnding(code2)||size2++>999?(effects.
|
||||
exit("chunkString"),atBreak(code2)):(effects.consume(code2),seen2||(seen2=!markdownSpace(code2)),code2===92?labelEscape:labelInside)}function labelEscape(code2){return code2===91||code2===92||code2===93?(effects.consume(code2),size2++,labelInside):labelInside(code2)}}function factoryTitle(effects,ok,nok,type2,markerType,stringType){let marker;return start2;function start2(code2){return code2===34||code2===39||code2===40?(effects.enter(type2),effects.enter(markerType),effects.consume(code2),effects.
|
||||
exit(markerType),marker=code2===40?41:code2,begin):nok(code2)}function begin(code2){return code2===marker?(effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):(effects.enter(stringType),atBreak(code2))}function atBreak(code2){return code2===marker?(effects.exit(stringType),begin(marker)):code2===null?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,atBreak,"linePr\
|
||||
efix")):(effects.enter("chunkString",{contentType:"string"}),inside(code2))}function inside(code2){return code2===marker||code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),code2===92?escape2:inside)}function escape2(code2){return code2===marker||code2===92?(effects.consume(code2),inside):inside(code2)}}function factoryWhitespace(effects,ok){let seen2;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("li\
|
||||
neEnding"),effects.consume(code2),effects.exit("lineEnding"),seen2=!0,start2):markdownSpace(code2)?factorySpace(effects,start2,seen2?"linePrefix":"lineSuffix")(code2):ok(code2)}}const definition$1={name:"definition",tokenize:tokenizeDefinition},titleBefore={partial:!0,tokenize:tokenizeTitleBefore};function tokenizeDefinition(effects,ok,nok){const self2=this;let identifier2;return start2;function start2(code2){return effects.enter("definition"),before(code2)}function before(code2){return factoryLabel.
|
||||
call(self2,effects,labelAfter,nok,"definitionLabel","definitionLabelMarker","definitionLabelString")(code2)}function labelAfter(code2){return identifier2=normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length-1][1]).slice(1,-1)),code2===58?(effects.enter("definitionMarker"),effects.consume(code2),effects.exit("definitionMarker"),markerAfter):nok(code2)}function markerAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,destinationBefore)(code2):destinationBefore(
|
||||
code2)}function destinationBefore(code2){return factoryDestination(effects,destinationAfter,nok,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(code2)}function destinationAfter(code2){return effects.attempt(titleBefore,after,after)(code2)}function after(code2){return markdownSpace(code2)?factorySpace(effects,afterWhitespace,"whitespace")(code2):afterWhitespace(code2)}function afterWhitespace(code2){
|
||||
return code2===null||markdownLineEnding(code2)?(effects.exit("definition"),self2.parser.defined.push(identifier2),ok(code2)):nok(code2)}}function tokenizeTitleBefore(effects,ok,nok){return titleBefore2;function titleBefore2(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,beforeMarker)(code2):nok(code2)}function beforeMarker(code2){return factoryTitle(effects,titleAfter,nok,"definitionTitle","definitionTitleMarker","definitionTitleString")(code2)}function titleAfter(code2){
|
||||
return markdownSpace(code2)?factorySpace(effects,titleAfterOptionalWhitespace,"whitespace")(code2):titleAfterOptionalWhitespace(code2)}function titleAfterOptionalWhitespace(code2){return code2===null||markdownLineEnding(code2)?ok(code2):nok(code2)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};function tokenizeHardBreakEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("hardBreakEscape"),effects.consume(code2),after}function after(code2){
|
||||
return markdownLineEnding(code2)?(effects.exit("hardBreakEscape"),ok(code2)):nok(code2)}}const headingAtx={name:"headingAtx",resolve:resolveHeadingAtx,tokenize:tokenizeHeadingAtx};function resolveHeadingAtx(events,context){let contentEnd=events.length-2,contentStart=3,content2,text2;return events[contentStart][1].type==="whitespace"&&(contentStart+=2),contentEnd-2>contentStart&&events[contentEnd][1].type==="whitespace"&&(contentEnd-=2),events[contentEnd][1].type==="atxHeadingSequence"&&(contentStart===
|
||||
contentEnd-1||contentEnd-4>contentStart&&events[contentEnd-2][1].type==="whitespace")&&(contentEnd-=contentStart+1===contentEnd?2:4),contentEnd>contentStart&&(content2={type:"atxHeadingText",start:events[contentStart][1].start,end:events[contentEnd][1].end},text2={type:"chunkText",start:events[contentStart][1].start,end:events[contentEnd][1].end,contentType:"text"},splice(events,contentStart,contentEnd-contentStart+1,[["enter",content2,context],["enter",text2,context],["exit",text2,context],["ex\
|
||||
it",content2,context]])),events}function tokenizeHeadingAtx(effects,ok,nok){let size2=0;return start2;function start2(code2){return effects.enter("atxHeading"),before(code2)}function before(code2){return effects.enter("atxHeadingSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===35&&size2++<6?(effects.consume(code2),sequenceOpen):code2===null||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingSequence"),atBreak(code2)):nok(code2)}function atBreak(code2){return code2===
|
||||
35?(effects.enter("atxHeadingSequence"),sequenceFurther(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("atxHeading"),ok(code2)):markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):(effects.enter("atxHeadingText"),data(code2))}function sequenceFurther(code2){return code2===35?(effects.consume(code2),sequenceFurther):(effects.exit("atxHeadingSequence"),atBreak(code2))}function data(code2){return code2===null||code2===35||markdownLineEndingOrSpace(code2)?(effects.exit(
|
||||
"atxHeadingText"),atBreak(code2)):(effects.consume(code2),data)}}const htmlBlockNames=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","\
|
||||
table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={concrete:!0,name:"htmlFlow",resolveTo:resolveToHtmlFlow,tokenize:tokenizeHtmlFlow},blankLineBefore={partial:!0,tokenize:tokenizeBlankLineBefore},nonLazyContinuationStart={partial:!0,tokenize:tokenizeNonLazyContinuationStart};function resolveToHtmlFlow(events){let index2=events.length;for(;index2--&&!(events[index2][0]==="enter"&&events[index2][1].type==="htmlFlow"););return index2>
|
||||
1&&events[index2-2][1].type==="linePrefix"&&(events[index2][1].start=events[index2-2][1].start,events[index2+1][1].start=events[index2-2][1].start,events.splice(index2-2,2)),events}function tokenizeHtmlFlow(effects,ok,nok){const self2=this;let marker,closingTag,buffer,index2,markerB;return start2;function start2(code2){return before(code2)}function before(code2){return effects.enter("htmlFlow"),effects.enter("htmlFlowData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.
|
||||
consume(code2),declarationOpen):code2===47?(effects.consume(code2),closingTag=!0,tagCloseStart):code2===63?(effects.consume(code2),marker=3,self2.interrupt?ok:continuationDeclarationInside):asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),marker=2,commentOpenInside):code2===91?(effects.consume(code2),marker=5,index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),
|
||||
marker=4,self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value.length?self2.interrupt?ok:continuation:cdataOpenInside):nok(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),buffer=String.
|
||||
fromCharCode(code2),tagName):nok(code2)}function tagName(code2){if(code2===null||code2===47||code2===62||markdownLineEndingOrSpace(code2)){const slash=code2===47,name=buffer.toLowerCase();return!slash&&!closingTag&&htmlRawNames.includes(name)?(marker=1,self2.interrupt?ok(code2):continuation(code2)):htmlBlockNames.includes(buffer.toLowerCase())?(marker=6,slash?(effects.consume(code2),basicSelfClosing):self2.interrupt?ok(code2):continuation(code2)):(marker=7,self2.interrupt&&!self2.parser.lazy[self2.
|
||||
now().line]?nok(code2):closingTag?completeClosingTagAfter(code2):completeAttributeNameBefore(code2))}return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),buffer+=String.fromCharCode(code2),tagName):nok(code2)}function basicSelfClosing(code2){return code2===62?(effects.consume(code2),self2.interrupt?ok:continuation):nok(code2)}function completeClosingTagAfter(code2){return markdownSpace(code2)?(effects.consume(code2),completeClosingTagAfter):completeEnd(code2)}function completeAttributeNameBefore(code2){
|
||||
return code2===47?(effects.consume(code2),completeEnd):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),completeAttributeName):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameBefore):completeEnd(code2)}function completeAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),completeAttributeName):completeAttributeNameAfter(code2)}function completeAttributeNameAfter(code2){return code2===61?(effects.
|
||||
consume(code2),completeAttributeValueBefore):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameAfter):completeAttributeNameBefore(code2)}function completeAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),markerB=code2,completeAttributeValueQuoted):markdownSpace(code2)?(effects.consume(code2),completeAttributeValueBefore):completeAttributeValueUnquoted(code2)}function completeAttributeValueQuoted(code2){
|
||||
return code2===markerB?(effects.consume(code2),markerB=null,completeAttributeValueQuotedAfter):code2===null||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),completeAttributeValueQuoted)}function completeAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===47||code2===60||code2===61||code2===62||code2===96||markdownLineEndingOrSpace(code2)?completeAttributeNameAfter(code2):(effects.consume(code2),completeAttributeValueUnquoted)}function completeAttributeValueQuotedAfter(code2){
|
||||
return code2===47||code2===62||markdownSpace(code2)?completeAttributeNameBefore(code2):nok(code2)}function completeEnd(code2){return code2===62?(effects.consume(code2),completeAfter):nok(code2)}function completeAfter(code2){return code2===null||markdownLineEnding(code2)?continuation(code2):markdownSpace(code2)?(effects.consume(code2),completeAfter):nok(code2)}function continuation(code2){return code2===45&&marker===2?(effects.consume(code2),continuationCommentInside):code2===60&&marker===1?(effects.
|
||||
consume(code2),continuationRawTagOpen):code2===62&&marker===4?(effects.consume(code2),continuationClose):code2===63&&marker===3?(effects.consume(code2),continuationDeclarationInside):code2===93&&marker===5?(effects.consume(code2),continuationCdataInside):markdownLineEnding(code2)&&(marker===6||marker===7)?(effects.exit("htmlFlowData"),effects.check(blankLineBefore,continuationAfter,continuationStart)(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationStart(
|
||||
code2)):(effects.consume(code2),continuation)}function continuationStart(code2){return effects.check(nonLazyContinuationStart,continuationStartNonLazy,continuationAfter)(code2)}function continuationStartNonLazy(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),continuationBefore}function continuationBefore(code2){return code2===null||markdownLineEnding(code2)?continuationStart(code2):(effects.enter("htmlFlowData"),continuation(code2))}function continuationCommentInside(code2){
|
||||
return code2===45?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationRawTagOpen(code2){return code2===47?(effects.consume(code2),buffer="",continuationRawEndTag):continuation(code2)}function continuationRawEndTag(code2){if(code2===62){const name=buffer.toLowerCase();return htmlRawNames.includes(name)?(effects.consume(code2),continuationClose):continuation(code2)}return asciiAlpha(code2)&&buffer.length<8?(effects.consume(code2),buffer+=String.fromCharCode(
|
||||
code2),continuationRawEndTag):continuation(code2)}function continuationCdataInside(code2){return code2===93?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationDeclarationInside(code2){return code2===62?(effects.consume(code2),continuationClose):code2===45&&marker===2?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationClose(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationAfter(
|
||||
code2)):(effects.consume(code2),continuationClose)}function continuationAfter(code2){return effects.exit("htmlFlow"),ok(code2)}}function tokenizeNonLazyContinuationStart(effects,ok,nok){const self2=this;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),after):nok(code2)}function after(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}function tokenizeBlankLineBefore(effects,ok,nok){
|
||||
return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),effects.attempt(blankLine,ok,nok)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(effects,ok,nok){const self2=this;let marker,index2,returnState;return start2;function start2(code2){return effects.enter("htmlText"),effects.enter("htmlTextData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen):
|
||||
code2===47?(effects.consume(code2),tagCloseStart):code2===63?(effects.consume(code2),instruction):asciiAlpha(code2)?(effects.consume(code2),tagOpen):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),commentOpenInside):code2===91?(effects.consume(code2),index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),declaration):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),commentEnd):nok(code2)}function comment2(code2){
|
||||
return code2===null?nok(code2):code2===45?(effects.consume(code2),commentClose):markdownLineEnding(code2)?(returnState=comment2,lineEndingBefore(code2)):(effects.consume(code2),comment2)}function commentClose(code2){return code2===45?(effects.consume(code2),commentEnd):comment2(code2)}function commentEnd(code2){return code2===62?end(code2):code2===45?commentClose(code2):comment2(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(
|
||||
code2),index2===value.length?cdata:cdataOpenInside):nok(code2)}function cdata(code2){return code2===null?nok(code2):code2===93?(effects.consume(code2),cdataClose):markdownLineEnding(code2)?(returnState=cdata,lineEndingBefore(code2)):(effects.consume(code2),cdata)}function cdataClose(code2){return code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function cdataEnd(code2){return code2===62?end(code2):code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function declaration(code2){return code2===
|
||||
null||code2===62?end(code2):markdownLineEnding(code2)?(returnState=declaration,lineEndingBefore(code2)):(effects.consume(code2),declaration)}function instruction(code2){return code2===null?nok(code2):code2===63?(effects.consume(code2),instructionClose):markdownLineEnding(code2)?(returnState=instruction,lineEndingBefore(code2)):(effects.consume(code2),instruction)}function instructionClose(code2){return code2===62?end(code2):instruction(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?
|
||||
(effects.consume(code2),tagClose):nok(code2)}function tagClose(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagClose):tagCloseBetween(code2)}function tagCloseBetween(code2){return markdownLineEnding(code2)?(returnState=tagCloseBetween,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagCloseBetween):end(code2)}function tagOpen(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpen):code2===47||code2===62||markdownLineEndingOrSpace(
|
||||
code2)?tagOpenBetween(code2):nok(code2)}function tagOpenBetween(code2){return code2===47?(effects.consume(code2),end):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),tagOpenAttributeName):markdownLineEnding(code2)?(returnState=tagOpenBetween,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenBetween):end(code2)}function tagOpenAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpenAttributeName):
|
||||
tagOpenAttributeNameAfter(code2)}function tagOpenAttributeNameAfter(code2){return code2===61?(effects.consume(code2),tagOpenAttributeValueBefore):markdownLineEnding(code2)?(returnState=tagOpenAttributeNameAfter,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeNameAfter):tagOpenBetween(code2)}function tagOpenAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),
|
||||
marker=code2,tagOpenAttributeValueQuoted):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueBefore,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeValueBefore):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuoted(code2){return code2===marker?(effects.consume(code2),marker=void 0,tagOpenAttributeValueQuotedAfter):code2===null?nok(code2):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueQuoted,lineEndingBefore(
|
||||
code2)):(effects.consume(code2),tagOpenAttributeValueQuoted)}function tagOpenAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===60||code2===61||code2===96?nok(code2):code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function end(code2){return code2===
|
||||
62?(effects.consume(code2),effects.exit("htmlTextData"),effects.exit("htmlText"),ok):nok(code2)}function lineEndingBefore(code2){return effects.exit("htmlTextData"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineEndingAfter}function lineEndingAfter(code2){return markdownSpace(code2)?factorySpace(effects,lineEndingAfterPrefix,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):lineEndingAfterPrefix(code2)}function lineEndingAfterPrefix(code2){
|
||||
return effects.enter("htmlTextData"),returnState(code2)}}const labelEnd={name:"labelEnd",resolveAll:resolveAllLabelEnd,resolveTo:resolveToLabelEnd,tokenize:tokenizeLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(events){let index2=-1;const newEvents=[];for(;++index2<events.length;){const token2=events[index2][1];if(newEvents.push(events[index2]),
|
||||
token2.type==="labelImage"||token2.type==="labelLink"||token2.type==="labelEnd"){const offset2=token2.type==="labelImage"?4:2;token2.type="data",index2+=offset2}}return events.length!==newEvents.length&&splice(events,0,events.length,newEvents),events}function resolveToLabelEnd(events,context){let index2=events.length,offset2=0,token2,open2,close2,media;for(;index2--;)if(token2=events[index2][1],open2){if(token2.type==="link"||token2.type==="labelLink"&&token2._inactive)break;events[index2][0]===
|
||||
"enter"&&token2.type==="labelLink"&&(token2._inactive=!0)}else if(close2){if(events[index2][0]==="enter"&&(token2.type==="labelImage"||token2.type==="labelLink")&&!token2._balanced&&(open2=index2,token2.type!=="labelLink")){offset2=2;break}}else token2.type==="labelEnd"&&(close2=index2);const group={type:events[open2][1].type==="labelLink"?"link":"image",start:{...events[open2][1].start},end:{...events[events.length-1][1].end}},label={type:"label",start:{...events[open2][1].start},end:{...events[close2][1].
|
||||
end}},text2={type:"labelText",start:{...events[open2+offset2+2][1].end},end:{...events[close2-2][1].start}};return media=[["enter",group,context],["enter",label,context]],media=push(media,events.slice(open2+1,open2+offset2+3)),media=push(media,[["enter",text2,context]]),media=push(media,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+offset2+4,close2-3),context)),media=push(media,[["exit",text2,context],events[close2-2],events[close2-1],["exit",label,context]]),media=push(
|
||||
media,events.slice(close2+1)),media=push(media,[["exit",group,context]]),splice(events,open2,events.length,media),events}function tokenizeLabelEnd(effects,ok,nok){const self2=this;let index2=self2.events.length,labelStart,defined;for(;index2--;)if((self2.events[index2][1].type==="labelImage"||self2.events[index2][1].type==="labelLink")&&!self2.events[index2][1]._balanced){labelStart=self2.events[index2][1];break}return start2;function start2(code2){return labelStart?labelStart._inactive?labelEndNok(
|
||||
code2):(defined=self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize({start:labelStart.end,end:self2.now()}))),effects.enter("labelEnd"),effects.enter("labelMarker"),effects.consume(code2),effects.exit("labelMarker"),effects.exit("labelEnd"),after):nok(code2)}function after(code2){return code2===40?effects.attempt(resourceConstruct,labelEndOk,defined?labelEndOk:labelEndNok)(code2):code2===91?effects.attempt(referenceFullConstruct,labelEndOk,defined?referenceNotFull:labelEndNok)(
|
||||
code2):defined?labelEndOk(code2):labelEndNok(code2)}function referenceNotFull(code2){return effects.attempt(referenceCollapsedConstruct,labelEndOk,labelEndNok)(code2)}function labelEndOk(code2){return ok(code2)}function labelEndNok(code2){return labelStart._balanced=!0,nok(code2)}}function tokenizeResource(effects,ok,nok){return resourceStart;function resourceStart(code2){return effects.enter("resource"),effects.enter("resourceMarker"),effects.consume(code2),effects.exit("resourceMarker"),resourceBefore}
|
||||
function resourceBefore(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,resourceOpen)(code2):resourceOpen(code2)}function resourceOpen(code2){return code2===41?resourceEnd(code2):factoryDestination(effects,resourceDestinationAfter,resourceDestinationMissing,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(code2)}function resourceDestinationAfter(code2){return markdownLineEndingOrSpace(
|
||||
code2)?factoryWhitespace(effects,resourceBetween)(code2):resourceEnd(code2)}function resourceDestinationMissing(code2){return nok(code2)}function resourceBetween(code2){return code2===34||code2===39||code2===40?factoryTitle(effects,resourceTitleAfter,nok,"resourceTitle","resourceTitleMarker","resourceTitleString")(code2):resourceEnd(code2)}function resourceTitleAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,resourceEnd)(code2):resourceEnd(code2)}function resourceEnd(code2){
|
||||
return code2===41?(effects.enter("resourceMarker"),effects.consume(code2),effects.exit("resourceMarker"),effects.exit("resource"),ok):nok(code2)}}function tokenizeReferenceFull(effects,ok,nok){const self2=this;return referenceFull;function referenceFull(code2){return factoryLabel.call(self2,effects,referenceFullAfter,referenceFullMissing,"reference","referenceMarker","referenceString")(code2)}function referenceFullAfter(code2){return self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize(
|
||||
self2.events[self2.events.length-1][1]).slice(1,-1)))?ok(code2):nok(code2)}function referenceFullMissing(code2){return nok(code2)}}function tokenizeReferenceCollapsed(effects,ok,nok){return referenceCollapsedStart;function referenceCollapsedStart(code2){return effects.enter("reference"),effects.enter("referenceMarker"),effects.consume(code2),effects.exit("referenceMarker"),referenceCollapsedOpen}function referenceCollapsedOpen(code2){return code2===93?(effects.enter("referenceMarker"),effects.consume(
|
||||
code2),effects.exit("referenceMarker"),effects.exit("reference"),ok):nok(code2)}}const labelStartImage={name:"labelStartImage",resolveAll:labelEnd.resolveAll,tokenize:tokenizeLabelStartImage};function tokenizeLabelStartImage(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("labelImage"),effects.enter("labelImageMarker"),effects.consume(code2),effects.exit("labelImageMarker"),open2}function open2(code2){return code2===91?(effects.enter("labelMarker"),effects.
|
||||
consume(code2),effects.exit("labelMarker"),effects.exit("labelImage"),after):nok(code2)}function after(code2){return code2===94&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):ok(code2)}}const labelStartLink={name:"labelStartLink",resolveAll:labelEnd.resolveAll,tokenize:tokenizeLabelStartLink};function tokenizeLabelStartLink(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("labelLink"),effects.enter("labelMarker"),effects.consume(code2),effects.
|
||||
exit("labelMarker"),effects.exit("labelLink"),after}function after(code2){return code2===94&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):ok(code2)}}const lineEnding={name:"lineEnding",tokenize:tokenizeLineEnding};function tokenizeLineEnding(effects,ok){return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,ok,"linePrefix")}}const thematicBreak$2={name:"thematicBreak",tokenize:tokenizeThematicBreak};
|
||||
function tokenizeThematicBreak(effects,ok,nok){let size2=0,marker;return start2;function start2(code2){return effects.enter("thematicBreak"),before(code2)}function before(code2){return marker=code2,atBreak(code2)}function atBreak(code2){return code2===marker?(effects.enter("thematicBreakSequence"),sequence(code2)):size2>=3&&(code2===null||markdownLineEnding(code2))?(effects.exit("thematicBreak"),ok(code2)):nok(code2)}function sequence(code2){return code2===marker?(effects.consume(code2),size2++,
|
||||
sequence):(effects.exit("thematicBreakSequence"),markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):atBreak(code2))}}const list$3={continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd,name:"list",tokenize:tokenizeListStart},listItemPrefixWhitespaceConstruct={partial:!0,tokenize:tokenizeListItemPrefixWhitespace},indentConstruct={partial:!0,tokenize:tokenizeIndent$1};function tokenizeListStart(effects,ok,nok){const self2=this,tail=self2.events[self2.events.length-
|
||||
1];let initialSize=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,size2=0;return start2;function start2(code2){const kind=self2.containerState.type||(code2===42||code2===43||code2===45?"listUnordered":"listOrdered");if(kind==="listUnordered"?!self2.containerState.marker||code2===self2.containerState.marker:asciiDigit(code2)){if(self2.containerState.type||(self2.containerState.type=kind,effects.enter(kind,{_container:!0})),kind==="listUnordered")return effects.enter(
|
||||
"listItemPrefix"),code2===42||code2===45?effects.check(thematicBreak$2,nok,atMarker)(code2):atMarker(code2);if(!self2.interrupt||code2===49)return effects.enter("listItemPrefix"),effects.enter("listItemValue"),inside(code2)}return nok(code2)}function inside(code2){return asciiDigit(code2)&&++size2<10?(effects.consume(code2),inside):(!self2.interrupt||size2<2)&&(self2.containerState.marker?code2===self2.containerState.marker:code2===41||code2===46)?(effects.exit("listItemValue"),atMarker(code2)):
|
||||
nok(code2)}function atMarker(code2){return effects.enter("listItemMarker"),effects.consume(code2),effects.exit("listItemMarker"),self2.containerState.marker=self2.containerState.marker||code2,effects.check(blankLine,self2.interrupt?nok:onBlank,effects.attempt(listItemPrefixWhitespaceConstruct,endOfPrefix,otherPrefix))}function onBlank(code2){return self2.containerState.initialBlankLine=!0,initialSize++,endOfPrefix(code2)}function otherPrefix(code2){return markdownSpace(code2)?(effects.enter("lis\
|
||||
tItemPrefixWhitespace"),effects.consume(code2),effects.exit("listItemPrefixWhitespace"),endOfPrefix):nok(code2)}function endOfPrefix(code2){return self2.containerState.size=initialSize+self2.sliceSerialize(effects.exit("listItemPrefix"),!0).length,ok(code2)}}function tokenizeListContinuation(effects,ok,nok){const self2=this;return self2.containerState._closeFlow=void 0,effects.check(blankLine,onBlank,notBlank);function onBlank(code2){return self2.containerState.furtherBlankLines=self2.containerState.
|
||||
furtherBlankLines||self2.containerState.initialBlankLine,factorySpace(effects,ok,"listItemIndent",self2.containerState.size+1)(code2)}function notBlank(code2){return self2.containerState.furtherBlankLines||!markdownSpace(code2)?(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,notInCurrentItem(code2)):(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,effects.attempt(indentConstruct,ok,notInCurrentItem)(code2))}function notInCurrentItem(code2){
|
||||
return self2.containerState._closeFlow=!0,self2.interrupt=void 0,factorySpace(effects,effects.attempt(list$3,ok,nok),"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2)}}function tokenizeIndent$1(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemIndent",self2.containerState.size+1);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="listItemIndent"&&tail[2].sliceSerialize(tail[1],
|
||||
!0).length===self2.containerState.size?ok(code2):nok(code2)}}function tokenizeListEnd(effects){effects.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemPrefixWhitespace",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return!markdownSpace(code2)&&tail&&tail[1].type==="listItemPrefixWhitespace"?
|
||||
ok(code2):nok(code2)}}const setextUnderline={name:"setextUnderline",resolveTo:resolveToSetextUnderline,tokenize:tokenizeSetextUnderline};function resolveToSetextUnderline(events,context){let index2=events.length,content2,text2,definition2;for(;index2--;)if(events[index2][0]==="enter"){if(events[index2][1].type==="content"){content2=index2;break}events[index2][1].type==="paragraph"&&(text2=index2)}else events[index2][1].type==="content"&&events.splice(index2,1),!definition2&&events[index2][1].type===
|
||||
"definition"&&(definition2=index2);const heading2={type:"setextHeading",start:{...events[content2][1].start},end:{...events[events.length-1][1].end}};return events[text2][1].type="setextHeadingText",definition2?(events.splice(text2,0,["enter",heading2,context]),events.splice(definition2+1,0,["exit",events[content2][1],context]),events[content2][1].end={...events[definition2][1].end}):events[content2][1]=heading2,events.push(["exit",heading2,context]),events}function tokenizeSetextUnderline(effects,ok,nok){
|
||||
const self2=this;let marker;return start2;function start2(code2){let index2=self2.events.length,paragraph2;for(;index2--;)if(self2.events[index2][1].type!=="lineEnding"&&self2.events[index2][1].type!=="linePrefix"&&self2.events[index2][1].type!=="content"){paragraph2=self2.events[index2][1].type==="paragraph";break}return!self2.parser.lazy[self2.now().line]&&(self2.interrupt||paragraph2)?(effects.enter("setextHeadingLine"),marker=code2,before(code2)):nok(code2)}function before(code2){return effects.
|
||||
enter("setextHeadingLineSequence"),inside(code2)}function inside(code2){return code2===marker?(effects.consume(code2),inside):(effects.exit("setextHeadingLineSequence"),markdownSpace(code2)?factorySpace(effects,after,"lineSuffix")(code2):after(code2))}function after(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("setextHeadingLine"),ok(code2)):nok(code2)}}const flow$1={tokenize:initializeFlow};function initializeFlow(effects){const self2=this,initial=effects.attempt(blankLine,
|
||||
atBlankEnding,effects.attempt(this.parser.constructs.flowInitial,afterConstruct,factorySpace(effects,effects.attempt(this.parser.constructs.flow,afterConstruct,effects.attempt(content,afterConstruct)),"linePrefix")));return initial;function atBlankEnding(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEndingBlank"),effects.consume(code2),effects.exit("lineEndingBlank"),self2.currentConstruct=void 0,initial}function afterConstruct(code2){if(code2===null){effects.consume(
|
||||
code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),self2.currentConstruct=void 0,initial}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$7=initializeFactory("text");function initializeFactory(field){return{resolveAll:createResolver(field==="text"?resolveAllLineSuffixes:void 0),tokenize:initializeText};function initializeText(effects){const self2=this,constructs2=this.parser.constructs[field],text2=effects.attempt(
|
||||
constructs2,start2,notText);return start2;function start2(code2){return atBreak(code2)?text2(code2):notText(code2)}function notText(code2){if(code2===null){effects.consume(code2);return}return effects.enter("data"),effects.consume(code2),data}function data(code2){return atBreak(code2)?(effects.exit("data"),text2(code2)):(effects.consume(code2),data)}function atBreak(code2){if(code2===null)return!0;const list2=constructs2[code2];let index2=-1;if(list2)for(;++index2<list2.length;){const item=list2[index2];
|
||||
if(!item.previous||item.previous.call(self2,self2.previous))return!0}return!1}}}function createResolver(extraResolver){return resolveAllText;function resolveAllText(events,context){let index2=-1,enter;for(;++index2<=events.length;)enter===void 0?events[index2]&&events[index2][1].type==="data"&&(enter=index2,index2++):(!events[index2]||events[index2][1].type!=="data")&&(index2!==enter+2&&(events[enter][1].end=events[index2-1][1].end,events.splice(enter+2,index2-enter-2),index2=enter+2),enter=void 0);
|
||||
return extraResolver?extraResolver(events,context):events}}function resolveAllLineSuffixes(events,context){let eventIndex=0;for(;++eventIndex<=events.length;)if((eventIndex===events.length||events[eventIndex][1].type==="lineEnding")&&events[eventIndex-1][1].type==="data"){const data=events[eventIndex-1][1],chunks=context.sliceStream(data);let index2=chunks.length,bufferIndex=-1,size2=0,tabs;for(;index2--;){const chunk=chunks[index2];if(typeof chunk=="string"){for(bufferIndex=chunk.length;chunk.charCodeAt(
|
||||
bufferIndex-1)===32;)size2++,bufferIndex--;if(bufferIndex)break;bufferIndex=-1}else if(chunk===-2)tabs=!0,size2++;else if(chunk!==-1){index2++;break}}if(context._contentTypeTextTrailing&&eventIndex===events.length&&(size2=0),size2){const token2={type:eventIndex===events.length||tabs||size2<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:index2?bufferIndex:data.start._bufferIndex+bufferIndex,_index:data.start._index+index2,line:data.end.line,column:data.end.column-size2,offset:data.end.offset-
|
||||
size2},end:{...data.end}};data.end={...token2.start},data.start.offset===data.end.offset?Object.assign(data,token2):(events.splice(eventIndex,0,["enter",token2,context],["exit",token2,context]),eventIndex+=2)}eventIndex++}return events}const document$1={42:list$3,43:list$3,45:list$3,48:list$3,49:list$3,50:list$3,51:list$3,52:list$3,53:list$3,54:list$3,55:list$3,56:list$3,57:list$3,62:blockQuote},contentInitial={91:definition$1},flowInitial={[-2]:codeIndented,[-1]:codeIndented,32:codeIndented},flow={
|
||||
35:headingAtx,42:thematicBreak$2,45:[setextUnderline,thematicBreak$2],60:htmlFlow,61:setextUnderline,95:thematicBreak$2,96:codeFenced,126:codeFenced},string={38:characterReference,92:characterEscape},text$6={[-5]:lineEnding,[-4]:lineEnding,[-3]:lineEnding,33:labelStartImage,38:characterReference,42:attention,60:[autolink,htmlText],91:labelStartLink,92:[hardBreakEscape,characterEscape],93:labelEnd,95:attention,96:codeText},insideSpan={null:[attention,resolver]},attentionMarkers={null:[42,95]},disable={
|
||||
null:[]},defaultConstructs=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers,contentInitial,disable,document:document$1,flow,flowInitial,insideSpan,string,text:text$6},Symbol.toStringTag,{value:"Module"}));function createTokenizer(parser,initialize2,from){let point2={_bufferIndex:-1,_index:0,line:from&&from.line||1,column:from&&from.column||1,offset:from&&from.offset||0};const columnStart={},resolveAllConstructs=[];let chunks=[],stack=[];const effects={attempt:constructFactory(
|
||||
onsuccessfulconstruct),check:constructFactory(onsuccessfulcheck),consume,enter,exit:exit2,interrupt:constructFactory(onsuccessfulcheck,{interrupt:!0})},context={code:null,containerState:{},defineSkip,events:[],now:now2,parser,previous:null,sliceSerialize,sliceStream,write};let state2=initialize2.tokenize.call(context,effects);return initialize2.resolveAll&&resolveAllConstructs.push(initialize2),context;function write(slice){return chunks=push(chunks,slice),main2(),chunks[chunks.length-1]!==null?
|
||||
[]:(addResult(initialize2,0),context.events=resolveAll(resolveAllConstructs,context.events,context),context.events)}function sliceSerialize(token2,expandTabs){return serializeChunks(sliceStream(token2),expandTabs)}function sliceStream(token2){return sliceChunks(chunks,token2)}function now2(){const{_bufferIndex,_index,line,column,offset:offset2}=point2;return{_bufferIndex,_index,line,column,offset:offset2}}function defineSkip(value){columnStart[value.line]=value.column,accountForPotentialSkip()}function main2(){
|
||||
let chunkIndex;for(;point2._index<chunks.length;){const chunk=chunks[point2._index];if(typeof chunk=="string")for(chunkIndex=point2._index,point2._bufferIndex<0&&(point2._bufferIndex=0);point2._index===chunkIndex&&point2._bufferIndex<chunk.length;)go2(chunk.charCodeAt(point2._bufferIndex));else go2(chunk)}}function go2(code2){state2=state2(code2)}function consume(code2){markdownLineEnding(code2)?(point2.line++,point2.column=1,point2.offset+=code2===-3?2:1,accountForPotentialSkip()):code2!==-1&&(point2.
|
||||
column++,point2.offset++),point2._bufferIndex<0?point2._index++:(point2._bufferIndex++,point2._bufferIndex===chunks[point2._index].length&&(point2._bufferIndex=-1,point2._index++)),context.previous=code2}function enter(type2,fields){const token2=fields||{};return token2.type=type2,token2.start=now2(),context.events.push(["enter",token2,context]),stack.push(token2),token2}function exit2(type2){const token2=stack.pop();return token2.end=now2(),context.events.push(["exit",token2,context]),token2}function onsuccessfulconstruct(construct,info2){
|
||||
addResult(construct,info2.from)}function onsuccessfulcheck(_,info2){info2.restore()}function constructFactory(onreturn,fields){return hook;function hook(constructs2,returnState,bogusState){let listOfConstructs,constructIndex,currentConstruct,info2;return Array.isArray(constructs2)?handleListOfConstructs(constructs2):"tokenize"in constructs2?handleListOfConstructs([constructs2]):handleMapOfConstructs(constructs2);function handleMapOfConstructs(map2){return start2;function start2(code2){const left=code2!==
|
||||
null&&map2[code2],all2=code2!==null&&map2.null,list2=[...Array.isArray(left)?left:left?[left]:[],...Array.isArray(all2)?all2:all2?[all2]:[]];return handleListOfConstructs(list2)(code2)}}function handleListOfConstructs(list2){return listOfConstructs=list2,constructIndex=0,list2.length===0?bogusState:handleConstruct(list2[constructIndex])}function handleConstruct(construct){return start2;function start2(code2){return info2=store(),currentConstruct=construct,construct.partial||(context.currentConstruct=
|
||||
construct),construct.name&&context.parser.constructs.disable.null.includes(construct.name)?nok():construct.tokenize.call(fields?Object.assign(Object.create(context),fields):context,effects,ok,nok)(code2)}}function ok(code2){return onreturn(currentConstruct,info2),returnState}function nok(code2){return info2.restore(),++constructIndex<listOfConstructs.length?handleConstruct(listOfConstructs[constructIndex]):bogusState}}}function addResult(construct,from2){construct.resolveAll&&!resolveAllConstructs.
|
||||
includes(construct)&&resolveAllConstructs.push(construct),construct.resolve&&splice(context.events,from2,context.events.length-from2,construct.resolve(context.events.slice(from2),context)),construct.resolveTo&&(context.events=construct.resolveTo(context.events,context))}function store(){const startPoint=now2(),startPrevious=context.previous,startCurrentConstruct=context.currentConstruct,startEventsIndex=context.events.length,startStack=Array.from(stack);return{from:startEventsIndex,restore};function restore(){
|
||||
point2=startPoint,context.previous=startPrevious,context.currentConstruct=startCurrentConstruct,context.events.length=startEventsIndex,stack=startStack,accountForPotentialSkip()}}function accountForPotentialSkip(){point2.line in columnStart&&point2.column<2&&(point2.column=columnStart[point2.line],point2.offset+=columnStart[point2.line]-1)}}function sliceChunks(chunks,token2){const startIndex=token2.start._index,startBufferIndex=token2.start._bufferIndex,endIndex=token2.end._index,endBufferIndex=token2.
|
||||
end._bufferIndex;let view;if(startIndex===endIndex)view=[chunks[startIndex].slice(startBufferIndex,endBufferIndex)];else{if(view=chunks.slice(startIndex,endIndex),startBufferIndex>-1){const head2=view[0];typeof head2=="string"?view[0]=head2.slice(startBufferIndex):view.shift()}endBufferIndex>0&&view.push(chunks[endIndex].slice(0,endBufferIndex))}return view}function serializeChunks(chunks,expandTabs){let index2=-1;const result=[];let atTab;for(;++index2<chunks.length;){const chunk=chunks[index2];
|
||||
let value;if(typeof chunk=="string")value=chunk;else switch(chunk){case-5:{value="\r";break}case-4:{value=`
|
||||
!0);get _autoScrollEnabled(){return get$3(this.#_autoScrollEnabled)}set _autoScrollEnabled(value){set$1(this.#_autoScrollEnabled,value,!0)}#_userScrolledUp=state$1(!1);get _userScrolledUp(){return get$3(this.#_userScrolledUp)}set _userScrolledUp(value){set$1(this.#_userScrolledUp,value,!0)}#_lastScrollTop=state$1(0);get _lastScrollTop(){return get$3(this.#_lastScrollTop)}set _lastScrollTop(value){set$1(this.#_lastScrollTop,value,!0)}_scrollInterval;_container;_disabled;_mutationObserver=null;_rafPending=!1;_observerEnabled=!1;constructor(options={}){
|
||||
this._disabled=options.disabled??!1}get autoScrollEnabled(){return this._autoScrollEnabled}get userScrolledUp(){return this._userScrolledUp}setContainer(container2){this._doStopObserving(),this._container=container2,this._observerEnabled&&container2&&!this._disabled&&this._doStartObserving()}setDisabled(disabled){this._disabled!==disabled&&(this._disabled=disabled,disabled?(this._autoScrollEnabled=!1,this.stopInterval(),this._doStopObserving()):this._observerEnabled&&this._container&&!this._mutationObserver&&
|
||||
this._doStartObserving())}handleScroll(){if(this._disabled||!this._container)return;const{scrollTop,scrollHeight,clientHeight}=this._container,distanceFromBottom=scrollHeight-clientHeight-scrollTop,isScrollingUp=scrollTop<this._lastScrollTop,isAtBottom=distanceFromBottom<AUTO_SCROLL_AT_BOTTOM_THRESHOLD;isScrollingUp&&!isAtBottom?(this._userScrolledUp=!0,this._autoScrollEnabled=!1):isAtBottom&&this._userScrolledUp&&(this._userScrolledUp=!1,this._autoScrollEnabled=!0),this._lastScrollTop=scrollTop}scrollToBottom(behavior="\
|
||||
smooth"){this._disabled||!this._container||this._container.scrollTo({top:this._container.scrollHeight,behavior})}enable(){this._disabled||(this._userScrolledUp=!1,this._autoScrollEnabled=!0)}startInterval(){this._disabled||this._scrollInterval||(this._scrollInterval=setInterval(()=>{this.scrollToBottom()},AUTO_SCROLL_INTERVAL))}stopInterval(){this._scrollInterval&&(clearInterval(this._scrollInterval),this._scrollInterval=void 0)}updateInterval(isStreaming){if(this._disabled){this.stopInterval();
|
||||
return}isStreaming&&this._autoScrollEnabled?this._scrollInterval||this.startInterval():this.stopInterval()}destroy(){this.stopInterval(),this._doStopObserving()}startObserving(){this._observerEnabled=!0,this._container&&!this._disabled&&!this._mutationObserver&&this._doStartObserving()}stopObserving(){this._observerEnabled=!1,this._doStopObserving()}_doStartObserving(){!this._container||this._mutationObserver||(this._mutationObserver=new MutationObserver(()=>{!this._autoScrollEnabled||this._rafPending||
|
||||
(this._rafPending=!0,requestAnimationFrame(()=>{this._rafPending=!1,this._autoScrollEnabled&&this._container&&(this._container.scrollTop=this._container.scrollHeight)}))}),this._mutationObserver.observe(this._container,{childList:!0,subtree:!0,characterData:!0}))}_doStopObserving(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this._rafPending=!1}}function createAutoScrollController(options={}){return new AutoScrollController(options)}function useKeyboardShortcuts(callbacks){
|
||||
function handleKeydown(event2){const isCmdOrCtrl=event2.metaKey||event2.ctrlKey;isCmdOrCtrl&&event2.key===KeyboardKey.K_LOWER&&(event2.preventDefault(),callbacks.activateSearchMode?.(),callbacks.onSearchActivated?.()),isCmdOrCtrl&&event2.shiftKey&&(event2.key===KeyboardKey.O_LOWER||event2.key===KeyboardKey.O_UPPER)&&(event2.preventDefault(),goto(ROUTES.NEW_CHAT)),event2.shiftKey&&isCmdOrCtrl&&event2.key===KeyboardKey.E_UPPER&&(event2.preventDefault(),callbacks.editActiveConversation?.()),isCmdOrCtrl&&
|
||||
event2.shiftKey&&(event2.key===KeyboardKey.D_LOWER||event2.key===KeyboardKey.D_UPPER)&&(event2.preventDefault(),callbacks.deleteActiveConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_UP&&(event2.preventDefault(),callbacks.navigateToPrevConversation?.()),isCmdOrCtrl&&event2.shiftKey&&event2.key===KeyboardKey.ARROW_DOWN&&(event2.preventDefault(),callbacks.navigateToNextConversation?.())}return{handleKeydown}}var root_5$i=from_html('<div class="mb-8 px-4 text-center"><\
|
||||
h1 class="mb-2 text-2xl font-semibold tracking-tight md:text-3xl">Hello there</h1> <p class="text-muted-foreground md:text-lg"> </p></div>'),root_9$d=from_html('<span>Server unavailable</span> <button class="flex items-center gap-1.5 rounded-lg bg-destructive/20 px-2 py-1 text-xs font-medium hover:bg-destructive/30 disabled:opacity-50"><!> </button>',1),root_8$j=from_html("<!> <!> <!>",1),root_7$h=from_html('<div class="pointer-events-auto mx-auto mb-4 max-w-[48rem] px-1"><!></div>'),root_3$D=from_html(
|
||||
'<div aria-label="Chat interface with file drop zone" class="flex h-full flex-col overflow-y-auto px-4 md:px-6" role="main"><div class="flex grow flex-col pt-14"><!> <div><!> <!> <!> <div class="conversation-chat-form pointer-events-auto rounded-t-3xl"><!></div></div></div></div>'),root$$=from_html("<!> <!> <!> <!> <!> <!>",1);function ChatScreen($$anchor,$$props){push$1($$props,!0);let showCenteredEmpty=prop($$props,"showCenteredEmpty",3,!1);const autoScroll=createAutoScrollController();let disableAutoScroll=user_derived(
|
||||
()=>!!config$1().disableAutoScroll),chatScrollContainer=state$1(void 0),dragCounter=state$1(0),isDragOver=state$1(!1),showFileErrorDialog=state$1(!1),uploadedFiles=state$1(proxy([])),fileErrorData=state$1(proxy({generallyUnsupported:[],modalityUnsupported:[],modalityReasons:{},supportedTypes:[]})),showDeleteDialog=state$1(!1),showEmptyFileDialog=state$1(!1),emptyFileNames=state$1(proxy([])),initialMessage=state$1(""),isEmpty=user_derived(()=>showCenteredEmpty()&&!activeConversation()&&activeMessages().
|
||||
length===0&&!isLoading()),activeErrorDialog=user_derived(errorDialog),isServerLoading=user_derived(serverLoading),hasPropsError=user_derived(()=>!!serverError()),isCurrentConversationLoading=user_derived(()=>isLoading()||isChatStreaming()),showProcessingInfo=user_derived(()=>get$3(isCurrentConversationLoading)||config$1().keepStatsVisible&&!!page$1.params.id||activeProcessingState()!==null),isRouter=user_derived(isRouterMode),conversationModel=user_derived(()=>chatStore.getConversationModel(activeMessages())),
|
||||
activeModelId=user_derived(()=>{const options=modelOptions();if(!get$3(isRouter))return options.length>0?options[0].model:null;const selectedId=selectedModelId();if(selectedId){const model=options.find(m=>m.id===selectedId);if(model)return model.model}if(get$3(conversationModel)){const model=options.find(m=>m.model===get$3(conversationModel));if(model)return model.model}return null}),modelPropsVersion=state$1(0);setProcessingInfoContext({get showProcessingInfo(){return get$3(showProcessingInfo)}}),
|
||||
user_effect(()=>{get$3(activeModelId)&&(modelsStore.getModelProps(get$3(activeModelId))||modelsStore.fetchModelProps(get$3(activeModelId)).then(()=>{update$1(modelPropsVersion)}))});let hasAudioModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsAudio(get$3(activeModelId))):!1),hasVisionModality=user_derived(()=>get$3(activeModelId)?(get$3(modelPropsVersion),modelsStore.modelSupportsVision(get$3(activeModelId))):!1);async function handleDeleteConfirm(){
|
||||
const conversation=activeConversation();conversation&&await conversationsStore.deleteConversation(conversation.id),set$1(showDeleteDialog,!1)}function handleDragEnter(event2){event2.preventDefault(),update$1(dragCounter),event2.dataTransfer?.types.includes("Files")&&set$1(isDragOver,!0)}function handleDragLeave(event2){event2.preventDefault(),update$1(dragCounter,-1),get$3(dragCounter)===0&&set$1(isDragOver,!1)}function handleErrorDialogOpenChange(open2){open2||chatStore.dismissErrorDialog()}function handleDragOver(event2){
|
||||
event2.preventDefault()}function handleDrop(event2){if(event2.preventDefault(),set$1(isDragOver,!1),set$1(dragCounter,0),event2.dataTransfer?.files){const files=Array.from(event2.dataTransfer.files);if(isEditing()){const handler=getAddFilesHandler();if(handler){handler(files);return}}processFiles(files)}}function handleFileRemove(fileId){set$1(uploadedFiles,get$3(uploadedFiles).filter(f=>f.id!==fileId),!0)}function handleFileUpload(files){processFiles(files)}const{handleKeydown}=useKeyboardShortcuts(
|
||||
{deleteActiveConversation:()=>{activeConversation()&&set$1(showDeleteDialog,!0)}});async function handleSystemPromptAdd(draft){(draft.message||draft.files.length>0)&&chatStore.savePendingDraft(draft.message,draft.files),await chatStore.addSystemPrompt()}function handleScroll(){autoScroll.handleScroll()}async function handleSendMessage(message,files){const plainFiles=files?snapshot(files):void 0,result=plainFiles?await parseFilesToMessageExtras(plainFiles,get$3(activeModelId)??void 0):void 0;if(result?.
|
||||
emptyFiles&&result.emptyFiles.length>0){if(set$1(emptyFileNames,result.emptyFiles,!0),set$1(showEmptyFileDialog,!0),files){const emptyFileNamesSet=new Set(result.emptyFiles);set$1(uploadedFiles,get$3(uploadedFiles).filter(file=>!emptyFileNamesSet.has(file.name)),!0)}return!1}const extras=result?.extras;return autoScroll.enable(),await chatStore.sendMessage(message,extras),autoScroll.scrollToBottom(),!0}async function processFiles(files){const generallySupported=[],generallyUnsupported=[];for(const file of files)
|
||||
isFileTypeSupported(file.name,file.type)?generallySupported.push(file):generallyUnsupported.push(file);const capabilities={hasVision:get$3(hasVisionModality),hasAudio:get$3(hasAudioModality)},{supportedFiles,unsupportedFiles,modalityReasons}=filterFilesByModalities(generallySupported,capabilities);if([...generallyUnsupported,...unsupportedFiles].length>0){const supportedTypes=["text files","PDFs"];get$3(hasVisionModality)&&supportedTypes.push("images"),get$3(hasAudioModality)&&supportedTypes.push(
|
||||
"audio files"),set$1(fileErrorData,{generallyUnsupported,modalityUnsupported:unsupportedFiles,modalityReasons,supportedTypes},!0),set$1(showFileErrorDialog,!0)}if(supportedFiles.length>0){const processed=await processFilesToChatUploaded(supportedFiles,get$3(activeModelId)??void 0);set$1(uploadedFiles,[...get$3(uploadedFiles),...processed],!0)}}afterNavigate(()=>{get$3(disableAutoScroll)||autoScroll.enable()});function handleMessagesReady(){!get$3(disableAutoScroll)&&!autoScroll.userScrolledUp&&requestAnimationFrame(
|
||||
()=>{autoScroll.scrollToBottom("instant")})}onMount$1(()=>{autoScroll.startObserving(),get$3(disableAutoScroll)||autoScroll.enable();const pendingDraft=chatStore.consumePendingDraft();pendingDraft&&(set$1(initialMessage,pendingDraft.message,!0),set$1(uploadedFiles,pendingDraft.files,!0))}),user_effect(()=>{autoScroll.setContainer(get$3(chatScrollContainer))}),user_effect(()=>{autoScroll.setDisabled(get$3(disableAutoScroll))});var fragment=root$$();event("keydown",$window,handleKeydown);var node2=first_child(
|
||||
fragment);{var consequent=$$anchor2=>{ChatScreenDragOverlay($$anchor2)};if_block(node2,$$render=>{get$3(isDragOver)&&$$render(consequent)})}var node_1=sibling(node2,2);{var consequent_1=$$anchor2=>{ServerLoadingSplash($$anchor2,{})},alternate=$$anchor2=>{var div=root_3$D(),div_1=child(div),node_2=child(div_1);{var consequent_2=$$anchor3=>{{let $0=user_derived(activeMessages);ChatMessages($$anchor3,{get messages(){return get$3($0)},onUserAction:()=>{autoScroll.enable(),autoScroll.userScrolledUp||
|
||||
autoScroll.scrollToBottom()},onMessagesReady:handleMessagesReady})}};if_block(node_2,$$render=>{get$3(isEmpty)||$$render(consequent_2)})}var div_2=sibling(node_2,2),node_3=child(div_2);{var consequent_3=$$anchor3=>{var div_3=root_5$i(),p2=sibling(child(div_3),2),text2=child(p2);reset(p2),reset(div_3),action(div_3,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({duration:300})),template_effect(()=>set_text(text2,`${serverStore.props?.modalities?.audio?"Record audio, type a message ":
|
||||
"Type a message"} or upload files to get started`)),append($$anchor3,div_3)};if_block(node_3,$$render=>{get$3(isEmpty)&&$$render(consequent_3)})}var node_4=sibling(node_3,2);{var consequent_4=$$anchor3=>{ChatScreenProcessingInfo($$anchor3,{})};if_block(node_4,$$render=>{page$1.params.id&&$$render(consequent_4)})}var node_5=sibling(node_4,2);{var consequent_5=$$anchor3=>{var div_4=root_7$h(),node_6=child(div_4);component(node_6,()=>Alert,($$anchor4,Alert_Root)=>{Alert_Root($$anchor4,{variant:"des\
|
||||
tructive",children:($$anchor5,$$slotProps)=>{var fragment_5=root_8$j(),node_7=first_child(fragment_5);Triangle_alert(node_7,{class:"h-4 w-4"});var node_8=sibling(node_7,2);component(node_8,()=>Alert_title,($$anchor6,Alert_Title)=>{Alert_Title($$anchor6,{class:"flex items-center justify-between",children:($$anchor7,$$slotProps2)=>{var fragment_6=root_9$d(),button=sibling(first_child(fragment_6),2),node_9=child(button);{let $0=user_derived(()=>get$3(isServerLoading)?"animate-spin":"");Refresh_cw(node_9,
|
||||
{get class(){return`h-3 w-3 ${get$3($0)??""}`}})}var text_1=sibling(node_9);reset(button),template_effect(()=>{button.disabled=get$3(isServerLoading),set_text(text_1,` ${get$3(isServerLoading)?"Retrying...":"Retry"}`)}),delegated("click",button,()=>serverStore.fetch()),append($$anchor7,fragment_6)},$$slots:{default:!0}})});var node_10=sibling(node_8,2);component(node_10,()=>Alert_description,($$anchor6,Alert_Description)=>{Alert_Description($$anchor6,{children:($$anchor7,$$slotProps2)=>{next$1();
|
||||
var text_2=text$8();template_effect($0=>set_text(text_2,$0),[()=>serverError()]),append($$anchor7,text_2)},$$slots:{default:!0}})}),append($$anchor5,fragment_5)},$$slots:{default:!0}})}),reset(div_4),action(div_4,($$node,$$action_arg)=>fadeInView?.($$node,$$action_arg),()=>({y:10,duration:250})),append($$anchor3,div_4)};if_block(node_5,$$render=>{get$3(hasPropsError)&&$$render(consequent_5)})}var div_5=sibling(node_5,2),node_11=child(div_5);{let $0=user_derived(()=>get$3(hasPropsError)||isEditing());
|
||||
ChatScreenForm(node_11,{get disabled(){return get$3($0)},get initialMessage(){return get$3(initialMessage)},get isLoading(){return get$3(isCurrentConversationLoading)},onFileRemove:handleFileRemove,onFileUpload:handleFileUpload,onSend:handleSendMessage,onStop:()=>chatStore.stopGeneration(),onSystemPromptAdd:handleSystemPromptAdd,get uploadedFiles(){return get$3(uploadedFiles)},set uploadedFiles($$value){set$1(uploadedFiles,$$value,!0)}})}reset(div_5),reset(div_2),reset(div_1),reset(div),bind_this(
|
||||
div,$$value=>set$1(chatScrollContainer,$$value),()=>get$3(chatScrollContainer)),template_effect(()=>set_class(div_2,1,`pointer-events-none ${get$3(isEmpty)?"absolute bottom-[calc(50dvh-7rem)]":"sticky bottom-4"} right-4 left-4 mt-auto pt-16 transition-all duration-200`)),event("dragenter",div,handleDragEnter),event("dragleave",div,handleDragLeave),event("dragover",div,handleDragOver),event("drop",div,handleDrop),event("scroll",div,handleScroll),append($$anchor2,div)};if_block(node_1,$$render=>{get$3(
|
||||
isServerLoading)?$$render(consequent_1):$$render(alternate,-1)})}var node_12=sibling(node_1,2);DialogFileUploadError(node_12,{get fileErrorData(){return get$3(fileErrorData)},get open(){return get$3(showFileErrorDialog)},set open($$value){set$1(showFileErrorDialog,$$value,!0)}});var node_13=sibling(node_12,2);DialogConfirmation(node_13,{title:"Delete Conversation",description:"Are you sure you want to delete this conversation? This action cannot be undone and will permanently remove all messages\
|
||||
in this conversation.",confirmText:"Delete",cancelText:"Cancel",variant:"destructive",get icon(){return Trash_2},onConfirm:handleDeleteConfirm,onCancel:()=>set$1(showDeleteDialog,!1),get open(){return get$3(showDeleteDialog)},set open($$value){set$1(showDeleteDialog,$$value,!0)}});var node_14=sibling(node_13,2);DialogEmptyFileAlert(node_14,{get emptyFiles(){return get$3(emptyFileNames)},onOpenChange:open2=>{open2||set$1(emptyFileNames,[],!0)},get open(){return get$3(showEmptyFileDialog)},set open($$value){
|
||||
set$1(showEmptyFileDialog,$$value,!0)}});var node_15=sibling(node_14,2);{let $0=user_derived(()=>get$3(activeErrorDialog)?.message??""),$1=user_derived(()=>get$3(activeErrorDialog)?.contextInfo),$2=user_derived(()=>!!get$3(activeErrorDialog)),$3=user_derived(()=>get$3(activeErrorDialog)?.type??ErrorDialogType.SERVER);DialogChatError(node_15,{get message(){return get$3($0)},get contextInfo(){return get$3($1)},onOpenChange:handleErrorDialogOpenChange,get open(){return get$3($2)},get type(){return get$3(
|
||||
$3)}})}append($$anchor,fragment),pop()}delegate(["click"]);var root$_=from_html('<div class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"><div class="flex flex-col items-center justify-center rounded-2xl border-2 border-dashed border-border bg-background p-12 shadow-lg"><!> <p class="text-lg font-medium text-foreground">Attach a file</p> <p class="text-sm text-muted-foreground">Drop your files here to upload</p></div></div>');function ChatScreenDragOverlay($$anchor){
|
||||
var div=root$_(),div_1=child(div),node2=child(div_1);Upload(node2,{class:"mb-4 h-12 w-12 text-muted-foreground"}),next$1(4),reset(div_1),reset(div),append($$anchor,div)}class DraftMessagesStore{drafts=new Map;getDraftMessage(chatId){const key2=chatId??NEW_CHAT_DRAFT_KEY;return this.drafts.get(key2)??{message:"",files:[]}}saveDraftMessage(chatId,message,files){const key2=chatId??NEW_CHAT_DRAFT_KEY;message||files.length>0?this.drafts.set(key2,{message,files:[...files]}):this.drafts.delete(key2)}clearDraftMessage(chatId){
|
||||
const key2=chatId??NEW_CHAT_DRAFT_KEY;this.drafts.delete(key2)}}const draftMessagesStore=new DraftMessagesStore;function useDraftMessages(options){onMount$1(()=>{const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);(draft.message||draft.files.length>0)&&!options.getInitialMessage()&&(options.setMessage(draft.message),options.setFiles(draft.files))}),beforeNavigate(()=>{const chatId=options.getChatId();draftMessagesStore.saveDraftMessage(chatId,options.getMessage(),options.
|
||||
getFiles())}),afterNavigate(navigation=>{if(navigation?.from!=null){const chatId=options.getChatId(),draft=draftMessagesStore.getDraftMessage(chatId);options.setMessage(draft.message),options.setFiles(draft.files)}});function clearDraft(){const chatId=options.getChatId();draftMessagesStore.clearDraftMessage(chatId)}return{clearDraft}}var root$Z=from_html('<div class="relative mx-auto max-w-[48rem]"><!></div>');function ChatScreenForm($$anchor,$$props){push$1($$props,!0);let disabled=prop($$props,
|
||||
"disabled",3,!1),initialMessage=prop($$props,"initialMessage",3,""),isLoading2=prop($$props,"isLoading",3,!1),uploadedFiles=prop($$props,"uploadedFiles",31,()=>proxy([])),chatFormRef=state$1(void 0),chatId=user_derived(()=>page$1.params.id),hasLoadingAttachments=user_derived(()=>uploadedFiles().some(f=>f.isLoading)),message=user_derived(initialMessage),previousIsLoading=user_derived(isLoading2),previousInitialMessage=user_derived(initialMessage);const{clearDraft}=useDraftMessages({getChatId:()=>get$3(
|
||||
chatId),getMessage:()=>get$3(message),getFiles:()=>uploadedFiles(),setMessage:m=>set$1(message,m),setFiles:f=>uploadedFiles(f),getInitialMessage:()=>initialMessage()});function handleFilesAdd(files){$$props.onFileUpload?.(files)}async function handleSubmit(){if(!get$3(message).trim()&&uploadedFiles().length===0||disabled()||get$3(hasLoadingAttachments)||!get$3(chatFormRef)?.checkModelSelected())return;const messageToSend=get$3(message).trim(),filesToSend=[...uploadedFiles()];set$1(message,""),uploadedFiles(
|
||||
[]),clearDraft(),get$3(chatFormRef)?.resetTextareaHeight(),await $$props.onSend?.(messageToSend,filesToSend)||(set$1(message,messageToSend),uploadedFiles(filesToSend))}function handleSystemPromptClick(){$$props.onSystemPromptAdd?.({message:get$3(message),files:uploadedFiles()})}function handleUploadedFileRemove(fileId){$$props.onFileRemove?.(fileId)}onMount$1(()=>{setTimeout(()=>get$3(chatFormRef)?.focus(),10)}),afterNavigate(navigation=>{navigation?.from!=null&&setTimeout(()=>get$3(chatFormRef)?.
|
||||
focus(),10)}),user_effect(()=>{initialMessage()!==get$3(previousInitialMessage)&&(set$1(message,initialMessage()),set$1(previousInitialMessage,initialMessage()))}),user_effect(()=>{get$3(previousIsLoading)&&!isLoading2()&&setTimeout(()=>get$3(chatFormRef)?.focus(),10),set$1(previousIsLoading,isLoading2())});var div=root$Z(),node2=child(div);bind_this(ChatForm(node2,{get class(){return $$props.class},get disabled(){return disabled()},get isLoading(){return isLoading2()},showMcpPromptButton:!0,onFilesAdd:handleFilesAdd,
|
||||
get onStop(){return $$props.onStop},onSubmit:handleSubmit,onSystemPromptClick:handleSystemPromptClick,onUploadedFileRemove:handleUploadedFileRemove,get value(){return get$3(message)},set value($$value){set$1(message,$$value)},get uploadedFiles(){return uploadedFiles()},set uploadedFiles($$value){uploadedFiles($$value)}}),$$value=>set$1(chatFormRef,$$value,!0),()=>get$3(chatFormRef)),reset(div),append($$anchor,div),pop()}var root_1$u=from_html('<span class="chat-processing-info-detail pointer-eve\
|
||||
nts-auto backdrop-blur-sm svelte-1ktvj8d"> </span>'),root$Y=from_html('<div><div class="chat-processing-info-content svelte-1ktvj8d"></div></div>');function ChatScreenProcessingInfo($$anchor,$$props){push$1($$props,!0);const processingState=useProcessingState(),processingInfoCtx=getProcessingInfoContext();let showProcessingInfo=user_derived(()=>processingInfoCtx.showProcessingInfo),isCurrentConversationLoading=user_derived(isLoading),isStreaming=user_derived(isChatStreaming),processingDetails=user_derived(
|
||||
()=>processingState.getTechnicalDetails());user_effect(()=>{const conversation=activeConversation();untrack$1(()=>chatStore.setActiveProcessingConversation(conversation?.id??null))}),user_effect(()=>{const keepStatsVisible=config$1().keepStatsVisible;if((keepStatsVisible||get$3(isCurrentConversationLoading)||get$3(isStreaming))&&processingState.startMonitoring(),!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&!keepStatsVisible){const timeout=setTimeout(()=>{!config$1().keepStatsVisible&&
|
||||
!isChatStreaming()&&processingState.stopMonitoring()},PROCESSING_INFO_TIMEOUT);return()=>clearTimeout(timeout)}}),user_effect(()=>{const conversation=activeConversation(),messages=activeMessages();if(config$1().keepStatsVisible&&conversation){if(messages.length===0){untrack$1(()=>chatStore.clearProcessingState(conversation.id));return}!get$3(isCurrentConversationLoading)&&!get$3(isStreaming)&&untrack$1(()=>chatStore.restoreProcessingStateFromMessages(messages,conversation.id))}});var div=root$Y(),
|
||||
div_1=child(div);each(div_1,20,()=>get$3(processingDetails),detail=>detail,($$anchor2,detail)=>{var span=root_1$u(),text2=child(span,!0);reset(span),template_effect(()=>set_text(text2,detail)),append($$anchor2,span)}),reset(div_1),reset(div),template_effect(()=>set_class(div,1,clsx(["chat-processing-info-container pointer-events-none",get$3(showProcessingInfo)&&"visible"]),"svelte-1ktvj8d")),append($$anchor,div),pop()}const emptyOptions$7={};function toString$1(value,options){const settings=emptyOptions$7,
|
||||
includeImageAlt=typeof settings.includeImageAlt=="boolean"?settings.includeImageAlt:!0,includeHtml=typeof settings.includeHtml=="boolean"?settings.includeHtml:!0;return one$2(value,includeImageAlt,includeHtml)}function one$2(value,includeImageAlt,includeHtml){if(node(value)){if("value"in value)return value.type==="html"&&!includeHtml?"":value.value;if(includeImageAlt&&"alt"in value&&value.alt)return value.alt;if("children"in value)return all$2(value.children,includeImageAlt,includeHtml)}return Array.
|
||||
isArray(value)?all$2(value,includeImageAlt,includeHtml):""}function all$2(values,includeImageAlt,includeHtml){const result=[];let index2=-1;for(;++index2<values.length;)result[index2]=one$2(values[index2],includeImageAlt,includeHtml);return result.join("")}function node(value){return!!(value&&typeof value=="object")}const element$3=document.createElement("i");function decodeNamedCharacterReference(value){const characterReference2="&"+value+";";element$3.innerHTML=characterReference2;const character=element$3.
|
||||
textContent;return character.charCodeAt(character.length-1)===59&&value!=="semi"||character===characterReference2?!1:character}function splice(list2,start2,remove2,items2){const end=list2.length;let chunkStart=0,parameters;if(start2<0?start2=-start2>end?0:end+start2:start2=start2>end?end:start2,remove2=remove2>0?remove2:0,items2.length<1e4)parameters=Array.from(items2),parameters.unshift(start2,remove2),list2.splice(...parameters);else for(remove2&&list2.splice(start2,remove2);chunkStart<items2.
|
||||
length;)parameters=items2.slice(chunkStart,chunkStart+1e4),parameters.unshift(start2,0),list2.splice(...parameters),chunkStart+=1e4,start2+=1e4}function push(list2,items2){return list2.length>0?(splice(list2,list2.length,0,items2),list2):items2}const hasOwnProperty={}.hasOwnProperty;function combineExtensions(extensions){const all2={};let index2=-1;for(;++index2<extensions.length;)syntaxExtension(all2,extensions[index2]);return all2}function syntaxExtension(all2,extension2){let hook;for(hook in extension2){
|
||||
const left=(hasOwnProperty.call(all2,hook)?all2[hook]:void 0)||(all2[hook]={}),right=extension2[hook];let code2;if(right)for(code2 in right){hasOwnProperty.call(left,code2)||(left[code2]=[]);const value=right[code2];constructs(left[code2],Array.isArray(value)?value:value?[value]:[])}}}function constructs(existing,list2){let index2=-1;const before=[];for(;++index2<list2.length;)(list2[index2].add==="after"?existing:before).push(list2[index2]);splice(existing,0,0,before)}function decodeNumericCharacterReference(value,base2){
|
||||
const code2=Number.parseInt(value,base2);return code2<9||code2===11||code2>13&&code2<32||code2>126&&code2<160||code2>55295&&code2<57344||code2>64975&&code2<65008||(code2&65535)===65535||(code2&65535)===65534||code2>1114111?"<22>":String.fromCodePoint(code2)}function normalizeIdentifier(value){return value.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
||||
function asciiControl(code2){return code2!==null&&(code2<32||code2===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(code2){return code2!==null&&code2<-2}function markdownLineEndingOrSpace(code2){return code2!==null&&(code2<0||code2===32)}function markdownSpace(code2){return code2===-2||code2===-1||code2===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(
|
||||
/\s/);function regexCheck(regex){return check;function check(code2){return code2!==null&&code2>-1&®ex.test(String.fromCharCode(code2))}}function normalizeUri(value){const result=[];let index2=-1,start2=0,skip=0;for(;++index2<value.length;){const code2=value.charCodeAt(index2);let replace2="";if(code2===37&&asciiAlphanumeric(value.charCodeAt(index2+1))&&asciiAlphanumeric(value.charCodeAt(index2+2)))skip=2;else if(code2<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code2))||(replace2=String.
|
||||
fromCharCode(code2));else if(code2>55295&&code2<57344){const next2=value.charCodeAt(index2+1);code2<56320&&next2>56319&&next2<57344?(replace2=String.fromCharCode(code2,next2),skip=1):replace2="<22>"}else replace2=String.fromCharCode(code2);replace2&&(result.push(value.slice(start2,index2),encodeURIComponent(replace2)),start2=index2+skip+1,replace2=""),skip&&(index2+=skip,skip=0)}return result.join("")+value.slice(start2)}function factorySpace(effects,ok,type2,max2){const limit2=max2?max2-1:Number.
|
||||
POSITIVE_INFINITY;let size2=0;return start2;function start2(code2){return markdownSpace(code2)?(effects.enter(type2),prefix(code2)):ok(code2)}function prefix(code2){return markdownSpace(code2)&&size2++<limit2?(effects.consume(code2),prefix):(effects.exit(type2),ok(code2))}}const content$1={tokenize:initializeContent};function initializeContent(effects){const contentStart=effects.attempt(this.parser.constructs.contentInitial,afterContentStartConstruct,paragraphInitial);let previous2;return contentStart;
|
||||
function afterContentStartConstruct(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,contentStart,"linePrefix")}function paragraphInitial(code2){return effects.enter("paragraph"),lineStart(code2)}function lineStart(code2){const token2=effects.enter("chunkText",{contentType:"text",previous:previous2});return previous2&&(previous2.next=token2),previous2=token2,data(code2)}function data(code2){
|
||||
if(code2===null){effects.exit("chunkText"),effects.exit("paragraph"),effects.consume(code2);return}return markdownLineEnding(code2)?(effects.consume(code2),effects.exit("chunkText"),lineStart):(effects.consume(code2),data)}}const document$2={tokenize:initializeDocument},containerConstruct={tokenize:tokenizeContainer};function initializeDocument(effects){const self2=this,stack=[];let continued=0,childFlow,childToken,lineStartOffset;return start2;function start2(code2){if(continued<stack.length){const item=stack[continued];
|
||||
return self2.containerState=item[1],effects.attempt(item[0].continuation,documentContinue,checkNewContainers)(code2)}return checkNewContainers(code2)}function documentContinue(code2){if(continued++,self2.containerState._closeFlow){self2.containerState._closeFlow=void 0,childFlow&&closeFlow();const indexBeforeExits=self2.events.length;let indexBeforeFlow=indexBeforeExits,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]==="exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){
|
||||
point2=self2.events[indexBeforeFlow][1].end;break}exitContainers(continued);let index2=indexBeforeExits;for(;index2<self2.events.length;)self2.events[index2][1].end={...point2},index2++;return splice(self2.events,indexBeforeFlow+1,0,self2.events.slice(indexBeforeExits)),self2.events.length=index2,checkNewContainers(code2)}return start2(code2)}function checkNewContainers(code2){if(continued===stack.length){if(!childFlow)return documentContinued(code2);if(childFlow.currentConstruct&&childFlow.currentConstruct.
|
||||
concrete)return flowStart(code2);self2.interrupt=!!(childFlow.currentConstruct&&!childFlow._gfmTableDynamicInterruptHack)}return self2.containerState={},effects.check(containerConstruct,thereIsANewContainer,thereIsNoNewContainer)(code2)}function thereIsANewContainer(code2){return childFlow&&closeFlow(),exitContainers(continued),documentContinued(code2)}function thereIsNoNewContainer(code2){return self2.parser.lazy[self2.now().line]=continued!==stack.length,lineStartOffset=self2.now().offset,flowStart(
|
||||
code2)}function documentContinued(code2){return self2.containerState={},effects.attempt(containerConstruct,containerContinue,flowStart)(code2)}function containerContinue(code2){return continued++,stack.push([self2.currentConstruct,self2.containerState]),documentContinued(code2)}function flowStart(code2){if(code2===null){childFlow&&closeFlow(),exitContainers(0),effects.consume(code2);return}return childFlow=childFlow||self2.parser.flow(self2.now()),effects.enter("chunkFlow",{_tokenizer:childFlow,
|
||||
contentType:"flow",previous:childToken}),flowContinue(code2)}function flowContinue(code2){if(code2===null){writeToChild(effects.exit("chunkFlow"),!0),exitContainers(0),effects.consume(code2);return}return markdownLineEnding(code2)?(effects.consume(code2),writeToChild(effects.exit("chunkFlow")),continued=0,self2.interrupt=void 0,start2):(effects.consume(code2),flowContinue)}function writeToChild(token2,endOfFile){const stream=self2.sliceStream(token2);if(endOfFile&&stream.push(null),token2.previous=
|
||||
childToken,childToken&&(childToken.next=token2),childToken=token2,childFlow.defineSkip(token2.start),childFlow.write(stream),self2.parser.lazy[token2.start.line]){let index2=childFlow.events.length;for(;index2--;)if(childFlow.events[index2][1].start.offset<lineStartOffset&&(!childFlow.events[index2][1].end||childFlow.events[index2][1].end.offset>lineStartOffset))return;const indexBeforeExits=self2.events.length;let indexBeforeFlow=indexBeforeExits,seen2,point2;for(;indexBeforeFlow--;)if(self2.events[indexBeforeFlow][0]===
|
||||
"exit"&&self2.events[indexBeforeFlow][1].type==="chunkFlow"){if(seen2){point2=self2.events[indexBeforeFlow][1].end;break}seen2=!0}for(exitContainers(continued),index2=indexBeforeExits;index2<self2.events.length;)self2.events[index2][1].end={...point2},index2++;splice(self2.events,indexBeforeFlow+1,0,self2.events.slice(indexBeforeExits)),self2.events.length=index2}}function exitContainers(size2){let index2=stack.length;for(;index2-- >size2;){const entry=stack[index2];self2.containerState=entry[1],
|
||||
entry[0].exit.call(self2,effects)}stack.length=size2}function closeFlow(){childFlow.write([null]),childToken=void 0,childFlow=void 0,self2.containerState._closeFlow=void 0}}function tokenizeContainer(effects,ok,nok){return factorySpace(effects,effects.attempt(this.parser.constructs.document,ok,nok),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(code2){if(code2===null||markdownLineEndingOrSpace(code2)||unicodeWhitespace(code2))return 1;
|
||||
if(unicodePunctuation(code2))return 2}function resolveAll(constructs2,events,context){const called=[];let index2=-1;for(;++index2<constructs2.length;){const resolve2=constructs2[index2].resolveAll;resolve2&&!called.includes(resolve2)&&(events=resolve2(events,context),called.push(resolve2))}return events}const attention={name:"attention",resolveAll:resolveAllAttention,tokenize:tokenizeAttention};function resolveAllAttention(events,context){let index2=-1,open2,group,text2,openingSequence,closingSequence,
|
||||
use,nextEvents,offset2;for(;++index2<events.length;)if(events[index2][0]==="enter"&&events[index2][1].type==="attentionSequence"&&events[index2][1]._close){for(open2=index2;open2--;)if(events[open2][0]==="exit"&&events[open2][1].type==="attentionSequence"&&events[open2][1]._open&&context.sliceSerialize(events[open2][1]).charCodeAt(0)===context.sliceSerialize(events[index2][1]).charCodeAt(0)){if((events[open2][1]._close||events[index2][1]._open)&&(events[index2][1].end.offset-events[index2][1].start.
|
||||
offset)%3&&!((events[open2][1].end.offset-events[open2][1].start.offset+events[index2][1].end.offset-events[index2][1].start.offset)%3))continue;use=events[open2][1].end.offset-events[open2][1].start.offset>1&&events[index2][1].end.offset-events[index2][1].start.offset>1?2:1;const start2={...events[open2][1].end},end={...events[index2][1].start};movePoint(start2,-use),movePoint(end,use),openingSequence={type:use>1?"strongSequence":"emphasisSequence",start:start2,end:{...events[open2][1].end}},closingSequence=
|
||||
{type:use>1?"strongSequence":"emphasisSequence",start:{...events[index2][1].start},end},text2={type:use>1?"strongText":"emphasisText",start:{...events[open2][1].end},end:{...events[index2][1].start}},group={type:use>1?"strong":"emphasis",start:{...openingSequence.start},end:{...closingSequence.end}},events[open2][1].end={...openingSequence.start},events[index2][1].start={...closingSequence.end},nextEvents=[],events[open2][1].end.offset-events[open2][1].start.offset&&(nextEvents=push(nextEvents,[
|
||||
["enter",events[open2][1],context],["exit",events[open2][1],context]])),nextEvents=push(nextEvents,[["enter",group,context],["enter",openingSequence,context],["exit",openingSequence,context],["enter",text2,context]]),nextEvents=push(nextEvents,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+1,index2),context)),nextEvents=push(nextEvents,[["exit",text2,context],["enter",closingSequence,context],["exit",closingSequence,context],["exit",group,context]]),events[index2][1].end.
|
||||
offset-events[index2][1].start.offset?(offset2=2,nextEvents=push(nextEvents,[["enter",events[index2][1],context],["exit",events[index2][1],context]])):offset2=0,splice(events,open2-1,index2-open2+3,nextEvents),index2=open2+nextEvents.length-offset2-2;break}}for(index2=-1;++index2<events.length;)events[index2][1].type==="attentionSequence"&&(events[index2][1].type="data");return events}function tokenizeAttention(effects,ok){const attentionMarkers2=this.parser.constructs.attentionMarkers.null,previous2=this.
|
||||
previous,before=classifyCharacter(previous2);let marker;return start2;function start2(code2){return marker=code2,effects.enter("attentionSequence"),inside(code2)}function inside(code2){if(code2===marker)return effects.consume(code2),inside;const token2=effects.exit("attentionSequence"),after=classifyCharacter(code2),open2=!after||after===2&&before||attentionMarkers2.includes(code2),close2=!before||before===2&&after||attentionMarkers2.includes(previous2);return token2._open=!!(marker===42?open2:open2&&
|
||||
(before||!close2)),token2._close=!!(marker===42?close2:close2&&(after||!open2)),ok(code2)}}function movePoint(point2,offset2){point2.column+=offset2,point2.offset+=offset2,point2._bufferIndex+=offset2}const autolink={name:"autolink",tokenize:tokenizeAutolink};function tokenizeAutolink(effects,ok,nok){let size2=0;return start2;function start2(code2){return effects.enter("autolink"),effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarker"),effects.enter("autolinkProtoco\
|
||||
l"),open2}function open2(code2){return asciiAlpha(code2)?(effects.consume(code2),schemeOrEmailAtext):code2===64?nok(code2):emailAtext(code2)}function schemeOrEmailAtext(code2){return code2===43||code2===45||code2===46||asciiAlphanumeric(code2)?(size2=1,schemeInsideOrEmailAtext(code2)):emailAtext(code2)}function schemeInsideOrEmailAtext(code2){return code2===58?(effects.consume(code2),size2=0,urlInside):(code2===43||code2===45||code2===46||asciiAlphanumeric(code2))&&size2++<32?(effects.consume(code2),
|
||||
schemeInsideOrEmailAtext):(size2=0,emailAtext(code2))}function urlInside(code2){return code2===62?(effects.exit("autolinkProtocol"),effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarker"),effects.exit("autolink"),ok):code2===null||code2===32||code2===60||asciiControl(code2)?nok(code2):(effects.consume(code2),urlInside)}function emailAtext(code2){return code2===64?(effects.consume(code2),emailAtSignOrDot):asciiAtext(code2)?(effects.consume(code2),emailAtext):nok(code2)}
|
||||
function emailAtSignOrDot(code2){return asciiAlphanumeric(code2)?emailLabel(code2):nok(code2)}function emailLabel(code2){return code2===46?(effects.consume(code2),size2=0,emailAtSignOrDot):code2===62?(effects.exit("autolinkProtocol").type="autolinkEmail",effects.enter("autolinkMarker"),effects.consume(code2),effects.exit("autolinkMarker"),effects.exit("autolink"),ok):emailValue(code2)}function emailValue(code2){if((code2===45||asciiAlphanumeric(code2))&&size2++<63){const next2=code2===45?emailValue:
|
||||
emailLabel;return effects.consume(code2),next2}return nok(code2)}}const blankLine={partial:!0,tokenize:tokenizeBlankLine};function tokenizeBlankLine(effects,ok,nok){return start2;function start2(code2){return markdownSpace(code2)?factorySpace(effects,after,"linePrefix")(code2):after(code2)}function after(code2){return code2===null||markdownLineEnding(code2)?ok(code2):nok(code2)}}const blockQuote={continuation:{tokenize:tokenizeBlockQuoteContinuation},exit:exit$1,name:"blockQuote",tokenize:tokenizeBlockQuoteStart};
|
||||
function tokenizeBlockQuoteStart(effects,ok,nok){const self2=this;return start2;function start2(code2){if(code2===62){const state2=self2.containerState;return state2.open||(effects.enter("blockQuote",{_container:!0}),state2.open=!0),effects.enter("blockQuotePrefix"),effects.enter("blockQuoteMarker"),effects.consume(code2),effects.exit("blockQuoteMarker"),after}return nok(code2)}function after(code2){return markdownSpace(code2)?(effects.enter("blockQuotePrefixWhitespace"),effects.consume(code2),effects.
|
||||
exit("blockQuotePrefixWhitespace"),effects.exit("blockQuotePrefix"),ok):(effects.exit("blockQuotePrefix"),ok(code2))}}function tokenizeBlockQuoteContinuation(effects,ok,nok){const self2=this;return contStart;function contStart(code2){return markdownSpace(code2)?factorySpace(effects,contBefore,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):contBefore(code2)}function contBefore(code2){return effects.attempt(blockQuote,ok,nok)(code2)}}function exit$1(effects){
|
||||
effects.exit("blockQuote")}const characterEscape={name:"characterEscape",tokenize:tokenizeCharacterEscape};function tokenizeCharacterEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("characterEscape"),effects.enter("escapeMarker"),effects.consume(code2),effects.exit("escapeMarker"),inside}function inside(code2){return asciiPunctuation(code2)?(effects.enter("characterEscapeValue"),effects.consume(code2),effects.exit("characterEscapeValue"),effects.exit("characterEs\
|
||||
cape"),ok):nok(code2)}}const characterReference={name:"characterReference",tokenize:tokenizeCharacterReference};function tokenizeCharacterReference(effects,ok,nok){const self2=this;let size2=0,max2,test;return start2;function start2(code2){return effects.enter("characterReference"),effects.enter("characterReferenceMarker"),effects.consume(code2),effects.exit("characterReferenceMarker"),open2}function open2(code2){return code2===35?(effects.enter("characterReferenceMarkerNumeric"),effects.consume(
|
||||
code2),effects.exit("characterReferenceMarkerNumeric"),numeric):(effects.enter("characterReferenceValue"),max2=31,test=asciiAlphanumeric,value(code2))}function numeric(code2){return code2===88||code2===120?(effects.enter("characterReferenceMarkerHexadecimal"),effects.consume(code2),effects.exit("characterReferenceMarkerHexadecimal"),effects.enter("characterReferenceValue"),max2=6,test=asciiHexDigit,value):(effects.enter("characterReferenceValue"),max2=7,test=asciiDigit,value(code2))}function value(code2){
|
||||
if(code2===59&&size2){const token2=effects.exit("characterReferenceValue");return test===asciiAlphanumeric&&!decodeNamedCharacterReference(self2.sliceSerialize(token2))?nok(code2):(effects.enter("characterReferenceMarker"),effects.consume(code2),effects.exit("characterReferenceMarker"),effects.exit("characterReference"),ok)}return test(code2)&&size2++<max2?(effects.consume(code2),value):nok(code2)}}const nonLazyContinuation$1={partial:!0,tokenize:tokenizeNonLazyContinuation$1},codeFenced={concrete:!0,
|
||||
name:"codeFenced",tokenize:tokenizeCodeFenced};function tokenizeCodeFenced(effects,ok,nok){const self2=this,closeStart={partial:!0,tokenize:tokenizeCloseStart};let initialPrefix=0,sizeOpen=0,marker;return start2;function start2(code2){return beforeSequenceOpen(code2)}function beforeSequenceOpen(code2){const tail=self2.events[self2.events.length-1];return initialPrefix=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,marker=code2,effects.enter("codeFenced"),effects.enter(
|
||||
"codeFencedFence"),effects.enter("codeFencedFenceSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===marker?(sizeOpen++,effects.consume(code2),sequenceOpen):sizeOpen<3?nok(code2):(effects.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects,infoBefore,"whitespace")(code2):infoBefore(code2))}function infoBefore(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFencedFence"),self2.interrupt?ok(code2):effects.check(nonLazyContinuation$1,
|
||||
atNonLazyBreak,after)(code2)):(effects.enter("codeFencedFenceInfo"),effects.enter("chunkString",{contentType:"string"}),info2(code2))}function info2(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),effects.exit("codeFencedFenceInfo"),infoBefore(code2)):markdownSpace(code2)?(effects.exit("chunkString"),effects.exit("codeFencedFenceInfo"),factorySpace(effects,metaBefore,"whitespace")(code2)):code2===96&&code2===marker?nok(code2):(effects.consume(code2),info2)}function metaBefore(code2){
|
||||
return code2===null||markdownLineEnding(code2)?infoBefore(code2):(effects.enter("codeFencedFenceMeta"),effects.enter("chunkString",{contentType:"string"}),meta(code2))}function meta(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),effects.exit("codeFencedFenceMeta"),infoBefore(code2)):code2===96&&code2===marker?nok(code2):(effects.consume(code2),meta)}function atNonLazyBreak(code2){return effects.attempt(closeStart,after,contentBefore)(code2)}function contentBefore(code2){
|
||||
return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),contentStart}function contentStart(code2){return initialPrefix>0&&markdownSpace(code2)?factorySpace(effects,beforeContentChunk,"linePrefix",initialPrefix+1)(code2):beforeContentChunk(code2)}function beforeContentChunk(code2){return code2===null||markdownLineEnding(code2)?effects.check(nonLazyContinuation$1,atNonLazyBreak,after)(code2):(effects.enter("codeFlowValue"),contentChunk(code2))}function contentChunk(code2){
|
||||
return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),beforeContentChunk(code2)):(effects.consume(code2),contentChunk)}function after(code2){return effects.exit("codeFenced"),ok(code2)}function tokenizeCloseStart(effects2,ok2,nok2){let size2=0;return startBefore;function startBefore(code2){return effects2.enter("lineEnding"),effects2.consume(code2),effects2.exit("lineEnding"),start3}function start3(code2){return effects2.enter("codeFencedFence"),markdownSpace(code2)?factorySpace(
|
||||
effects2,beforeSequenceClose,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):beforeSequenceClose(code2)}function beforeSequenceClose(code2){return code2===marker?(effects2.enter("codeFencedFenceSequence"),sequenceClose(code2)):nok2(code2)}function sequenceClose(code2){return code2===marker?(size2++,effects2.consume(code2),sequenceClose):size2>=sizeOpen?(effects2.exit("codeFencedFenceSequence"),markdownSpace(code2)?factorySpace(effects2,sequenceCloseAfter,
|
||||
"whitespace")(code2):sequenceCloseAfter(code2)):nok2(code2)}function sequenceCloseAfter(code2){return code2===null||markdownLineEnding(code2)?(effects2.exit("codeFencedFence"),ok2(code2)):nok2(code2)}}}function tokenizeNonLazyContinuation$1(effects,ok,nok){const self2=this;return start2;function start2(code2){return code2===null?nok(code2):(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),lineStart)}function lineStart(code2){return self2.parser.lazy[self2.now().line]?
|
||||
nok(code2):ok(code2)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={partial:!0,tokenize:tokenizeFurtherStart};function tokenizeCodeIndented(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("codeIndented"),factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=
|
||||
4?atBreak(code2):nok(code2)}function atBreak(code2){return code2===null?after(code2):markdownLineEnding(code2)?effects.attempt(furtherStart,atBreak,after)(code2):(effects.enter("codeFlowValue"),inside(code2))}function inside(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("codeFlowValue"),atBreak(code2)):(effects.consume(code2),inside)}function after(code2){return effects.exit("codeIndented"),ok(code2)}}function tokenizeFurtherStart(effects,ok,nok){const self2=this;return furtherStart2;
|
||||
function furtherStart2(code2){return self2.parser.lazy[self2.now().line]?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),furtherStart2):factorySpace(effects,afterPrefix,"linePrefix",5)(code2)}function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).length>=4?ok(code2):markdownLineEnding(code2)?furtherStart2(code2):nok(code2)}}const codeText={
|
||||
name:"codeText",previous:previous$2,resolve:resolveCodeText,tokenize:tokenizeCodeText};function resolveCodeText(events){let tailExitIndex=events.length-4,headEnterIndex=3,index2,enter;if((events[headEnterIndex][1].type==="lineEnding"||events[headEnterIndex][1].type==="space")&&(events[tailExitIndex][1].type==="lineEnding"||events[tailExitIndex][1].type==="space")){for(index2=headEnterIndex;++index2<tailExitIndex;)if(events[index2][1].type==="codeTextData"){events[headEnterIndex][1].type="codeTex\
|
||||
tPadding",events[tailExitIndex][1].type="codeTextPadding",headEnterIndex+=2,tailExitIndex-=2;break}}for(index2=headEnterIndex-1,tailExitIndex++;++index2<=tailExitIndex;)enter===void 0?index2!==tailExitIndex&&events[index2][1].type!=="lineEnding"&&(enter=index2):(index2===tailExitIndex||events[index2][1].type==="lineEnding")&&(events[enter][1].type="codeTextData",index2!==enter+2&&(events[enter][1].end=events[index2-1][1].end,events.splice(enter+2,index2-enter-2),tailExitIndex-=index2-enter-2,index2=
|
||||
enter+2),enter=void 0);return events}function previous$2(code2){return code2!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tokenizeCodeText(effects,ok,nok){let sizeOpen=0,size2,token2;return start2;function start2(code2){return effects.enter("codeText"),effects.enter("codeTextSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===96?(effects.consume(code2),sizeOpen++,sequenceOpen):(effects.exit("codeTextSequence"),between2(code2))}function between2(code2){
|
||||
return code2===null?nok(code2):code2===32?(effects.enter("space"),effects.consume(code2),effects.exit("space"),between2):code2===96?(token2=effects.enter("codeTextSequence"),size2=0,sequenceClose(code2)):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),between2):(effects.enter("codeTextData"),data(code2))}function data(code2){return code2===null||code2===32||code2===96||markdownLineEnding(code2)?(effects.exit("codeTextData"),between2(code2)):
|
||||
(effects.consume(code2),data)}function sequenceClose(code2){return code2===96?(effects.consume(code2),size2++,sequenceClose):size2===sizeOpen?(effects.exit("codeTextSequence"),effects.exit("codeText"),ok(code2)):(token2.type="codeTextData",data(code2))}}class SpliceBuffer{constructor(initial){this.left=initial?[...initial]:[],this.right=[]}get(index2){if(index2<0||index2>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+index2+"` in a splice buffer of size `"+(this.
|
||||
left.length+this.right.length)+"`");return index2<this.left.length?this.left[index2]:this.right[this.right.length-index2+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(start2,end){const stop=end??Number.POSITIVE_INFINITY;return stop<this.left.length?this.left.slice(start2,stop):start2>this.left.length?this.right.slice(this.right.length-stop+this.left.length,this.right.length-start2+this.left.length).reverse():this.
|
||||
left.slice(start2).concat(this.right.slice(this.right.length-stop+this.left.length).reverse())}splice(start2,deleteCount,items2){const count=deleteCount||0;this.setCursor(Math.trunc(start2));const removed=this.right.splice(this.right.length-count,Number.POSITIVE_INFINITY);return items2&&chunkedPush(this.left,items2),removed.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(item){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(item)}pushMany(items2){this.
|
||||
setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,items2)}unshift(item){this.setCursor(0),this.right.push(item)}unshiftMany(items2){this.setCursor(0),chunkedPush(this.right,items2.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const removed=this.left.splice(n,Number.POSITIVE_INFINITY);chunkedPush(this.right,removed.reverse())}else{const removed=this.right.splice(this.left.length+this.right.length-
|
||||
n,Number.POSITIVE_INFINITY);chunkedPush(this.left,removed.reverse())}}}function chunkedPush(list2,right){let chunkStart=0;if(right.length<1e4)list2.push(...right);else for(;chunkStart<right.length;)list2.push(...right.slice(chunkStart,chunkStart+1e4)),chunkStart+=1e4}function subtokenize(eventsArray){const jumps={};let index2=-1,event2,lineIndex,otherIndex,otherEvent,parameters,subevents,more;const events=new SpliceBuffer(eventsArray);for(;++index2<events.length;){for(;index2 in jumps;)index2=jumps[index2];
|
||||
if(event2=events.get(index2),index2&&event2[1].type==="chunkFlow"&&events.get(index2-1)[1].type==="listItemPrefix"&&(subevents=event2[1]._tokenizer.events,otherIndex=0,otherIndex<subevents.length&&subevents[otherIndex][1].type==="lineEndingBlank"&&(otherIndex+=2),otherIndex<subevents.length&&subevents[otherIndex][1].type==="content"))for(;++otherIndex<subevents.length&&subevents[otherIndex][1].type!=="content";)subevents[otherIndex][1].type==="chunkText"&&(subevents[otherIndex][1]._isInFirstContentOfListItem=
|
||||
!0,otherIndex++);if(event2[0]==="enter")event2[1].contentType&&(Object.assign(jumps,subcontent(events,index2)),index2=jumps[index2],more=!0);else if(event2[1]._container){for(otherIndex=index2,lineIndex=void 0;otherIndex--;)if(otherEvent=events.get(otherIndex),otherEvent[1].type==="lineEnding"||otherEvent[1].type==="lineEndingBlank")otherEvent[0]==="enter"&&(lineIndex&&(events.get(lineIndex)[1].type="lineEndingBlank"),otherEvent[1].type="lineEnding",lineIndex=otherIndex);else if(!(otherEvent[1].
|
||||
type==="linePrefix"||otherEvent[1].type==="listItemIndent"))break;lineIndex&&(event2[1].end={...events.get(lineIndex)[1].start},parameters=events.slice(lineIndex,index2),parameters.unshift(event2),events.splice(lineIndex,index2-lineIndex+1,parameters))}}return splice(eventsArray,0,Number.POSITIVE_INFINITY,events.slice(0)),!more}function subcontent(events,eventIndex){const token2=events.get(eventIndex)[1],context=events.get(eventIndex)[2];let startPosition=eventIndex-1;const startPositions=[];let tokenizer=token2.
|
||||
_tokenizer;tokenizer||(tokenizer=context.parser[token2.contentType](token2.start),token2._contentTypeTextTrailing&&(tokenizer._contentTypeTextTrailing=!0));const childEvents=tokenizer.events,jumps=[],gaps={};let stream,previous2,index2=-1,current2=token2,adjust=0,start2=0;const breaks=[start2];for(;current2;){for(;events.get(++startPosition)[1]!==current2;);startPositions.push(startPosition),current2._tokenizer||(stream=context.sliceStream(current2),current2.next||stream.push(null),previous2&&tokenizer.
|
||||
defineSkip(current2.start),current2._isInFirstContentOfListItem&&(tokenizer._gfmTasklistFirstContentOfListItem=!0),tokenizer.write(stream),current2._isInFirstContentOfListItem&&(tokenizer._gfmTasklistFirstContentOfListItem=void 0)),previous2=current2,current2=current2.next}for(current2=token2;++index2<childEvents.length;)childEvents[index2][0]==="exit"&&childEvents[index2-1][0]==="enter"&&childEvents[index2][1].type===childEvents[index2-1][1].type&&childEvents[index2][1].start.line!==childEvents[index2][1].
|
||||
end.line&&(start2=index2+1,breaks.push(start2),current2._tokenizer=void 0,current2.previous=void 0,current2=current2.next);for(tokenizer.events=[],current2?(current2._tokenizer=void 0,current2.previous=void 0):breaks.pop(),index2=breaks.length;index2--;){const slice=childEvents.slice(breaks[index2],breaks[index2+1]),start3=startPositions.pop();jumps.push([start3,start3+slice.length-1]),events.splice(start3,2,slice)}for(jumps.reverse(),index2=-1;++index2<jumps.length;)gaps[adjust+jumps[index2][0]]=
|
||||
adjust+jumps[index2][1],adjust+=jumps[index2][1]-jumps[index2][0]-1;return gaps}const content={resolve:resolveContent,tokenize:tokenizeContent},continuationConstruct={partial:!0,tokenize:tokenizeContinuation};function resolveContent(events){return subtokenize(events),events}function tokenizeContent(effects,ok){let previous2;return chunkStart;function chunkStart(code2){return effects.enter("content"),previous2=effects.enter("chunkContent",{contentType:"content"}),chunkInside(code2)}function chunkInside(code2){
|
||||
return code2===null?contentEnd(code2):markdownLineEnding(code2)?effects.check(continuationConstruct,contentContinue,contentEnd)(code2):(effects.consume(code2),chunkInside)}function contentEnd(code2){return effects.exit("chunkContent"),effects.exit("content"),ok(code2)}function contentContinue(code2){return effects.consume(code2),effects.exit("chunkContent"),previous2.next=effects.enter("chunkContent",{contentType:"content",previous:previous2}),previous2=previous2.next,chunkInside}}function tokenizeContinuation(effects,ok,nok){
|
||||
const self2=this;return startLookahead;function startLookahead(code2){return effects.exit("chunkContent"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,prefixed,"linePrefix")}function prefixed(code2){if(code2===null||markdownLineEnding(code2))return nok(code2);const tail=self2.events[self2.events.length-1];return!self2.parser.constructs.disable.null.includes("codeIndented")&&tail&&tail[1].type==="linePrefix"&&tail[2].sliceSerialize(tail[1],!0).
|
||||
length>=4?ok(code2):effects.interrupt(self2.parser.constructs.flow,nok,ok)(code2)}}function factoryDestination(effects,ok,nok,type2,literalType,literalMarkerType,rawType,stringType,max2){const limit2=max2||Number.POSITIVE_INFINITY;let balance=0;return start2;function start2(code2){return code2===60?(effects.enter(type2),effects.enter(literalType),effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),enclosedBefore):code2===null||code2===32||code2===41||asciiControl(
|
||||
code2)?nok(code2):(effects.enter(type2),effects.enter(rawType),effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),raw2(code2))}function enclosedBefore(code2){return code2===62?(effects.enter(literalMarkerType),effects.consume(code2),effects.exit(literalMarkerType),effects.exit(literalType),effects.exit(type2),ok):(effects.enter(stringType),effects.enter("chunkString",{contentType:"string"}),enclosed(code2))}function enclosed(code2){return code2===62?(effects.exit("chun\
|
||||
kString"),effects.exit(stringType),enclosedBefore(code2)):code2===null||code2===60||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),code2===92?enclosedEscape:enclosed)}function enclosedEscape(code2){return code2===60||code2===62||code2===92?(effects.consume(code2),enclosed):enclosed(code2)}function raw2(code2){return!balance&&(code2===null||code2===41||markdownLineEndingOrSpace(code2))?(effects.exit("chunkString"),effects.exit(stringType),effects.exit(rawType),effects.exit(type2),ok(
|
||||
code2)):balance<limit2&&code2===40?(effects.consume(code2),balance++,raw2):code2===41?(effects.consume(code2),balance--,raw2):code2===null||code2===32||code2===40||asciiControl(code2)?nok(code2):(effects.consume(code2),code2===92?rawEscape:raw2)}function rawEscape(code2){return code2===40||code2===41||code2===92?(effects.consume(code2),raw2):raw2(code2)}}function factoryLabel(effects,ok,nok,type2,markerType,stringType){const self2=this;let size2=0,seen2;return start2;function start2(code2){return effects.
|
||||
enter(type2),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.enter(stringType),atBreak}function atBreak(code2){return size2>999||code2===null||code2===91||code2===93&&!seen2||code2===94&&!size2&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):code2===93?(effects.exit(stringType),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),
|
||||
effects.exit("lineEnding"),atBreak):(effects.enter("chunkString",{contentType:"string"}),labelInside(code2))}function labelInside(code2){return code2===null||code2===91||code2===93||markdownLineEnding(code2)||size2++>999?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),seen2||(seen2=!markdownSpace(code2)),code2===92?labelEscape:labelInside)}function labelEscape(code2){return code2===91||code2===92||code2===93?(effects.consume(code2),size2++,labelInside):labelInside(code2)}}function factoryTitle(effects,ok,nok,type2,markerType,stringType){
|
||||
let marker;return start2;function start2(code2){return code2===34||code2===39||code2===40?(effects.enter(type2),effects.enter(markerType),effects.consume(code2),effects.exit(markerType),marker=code2===40?41:code2,begin):nok(code2)}function begin(code2){return code2===marker?(effects.enter(markerType),effects.consume(code2),effects.exit(markerType),effects.exit(type2),ok):(effects.enter(stringType),atBreak(code2))}function atBreak(code2){return code2===marker?(effects.exit(stringType),begin(marker)):
|
||||
code2===null?nok(code2):markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,atBreak,"linePrefix")):(effects.enter("chunkString",{contentType:"string"}),inside(code2))}function inside(code2){return code2===marker||code2===null||markdownLineEnding(code2)?(effects.exit("chunkString"),atBreak(code2)):(effects.consume(code2),code2===92?escape2:inside)}function escape2(code2){return code2===marker||code2===92?(effects.consume(code2),
|
||||
inside):inside(code2)}}function factoryWhitespace(effects,ok){let seen2;return start2;function start2(code2){return markdownLineEnding(code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),seen2=!0,start2):markdownSpace(code2)?factorySpace(effects,start2,seen2?"linePrefix":"lineSuffix")(code2):ok(code2)}}const definition$1={name:"definition",tokenize:tokenizeDefinition},titleBefore={partial:!0,tokenize:tokenizeTitleBefore};function tokenizeDefinition(effects,ok,nok){
|
||||
const self2=this;let identifier2;return start2;function start2(code2){return effects.enter("definition"),before(code2)}function before(code2){return factoryLabel.call(self2,effects,labelAfter,nok,"definitionLabel","definitionLabelMarker","definitionLabelString")(code2)}function labelAfter(code2){return identifier2=normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length-1][1]).slice(1,-1)),code2===58?(effects.enter("definitionMarker"),effects.consume(code2),effects.exit("definit\
|
||||
ionMarker"),markerAfter):nok(code2)}function markerAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,destinationBefore)(code2):destinationBefore(code2)}function destinationBefore(code2){return factoryDestination(effects,destinationAfter,nok,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(code2)}function destinationAfter(code2){return effects.attempt(titleBefore,after,
|
||||
after)(code2)}function after(code2){return markdownSpace(code2)?factorySpace(effects,afterWhitespace,"whitespace")(code2):afterWhitespace(code2)}function afterWhitespace(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("definition"),self2.parser.defined.push(identifier2),ok(code2)):nok(code2)}}function tokenizeTitleBefore(effects,ok,nok){return titleBefore2;function titleBefore2(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,beforeMarker)(code2):nok(code2)}
|
||||
function beforeMarker(code2){return factoryTitle(effects,titleAfter,nok,"definitionTitle","definitionTitleMarker","definitionTitleString")(code2)}function titleAfter(code2){return markdownSpace(code2)?factorySpace(effects,titleAfterOptionalWhitespace,"whitespace")(code2):titleAfterOptionalWhitespace(code2)}function titleAfterOptionalWhitespace(code2){return code2===null||markdownLineEnding(code2)?ok(code2):nok(code2)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};
|
||||
function tokenizeHardBreakEscape(effects,ok,nok){return start2;function start2(code2){return effects.enter("hardBreakEscape"),effects.consume(code2),after}function after(code2){return markdownLineEnding(code2)?(effects.exit("hardBreakEscape"),ok(code2)):nok(code2)}}const headingAtx={name:"headingAtx",resolve:resolveHeadingAtx,tokenize:tokenizeHeadingAtx};function resolveHeadingAtx(events,context){let contentEnd=events.length-2,contentStart=3,content2,text2;return events[contentStart][1].type==="\
|
||||
whitespace"&&(contentStart+=2),contentEnd-2>contentStart&&events[contentEnd][1].type==="whitespace"&&(contentEnd-=2),events[contentEnd][1].type==="atxHeadingSequence"&&(contentStart===contentEnd-1||contentEnd-4>contentStart&&events[contentEnd-2][1].type==="whitespace")&&(contentEnd-=contentStart+1===contentEnd?2:4),contentEnd>contentStart&&(content2={type:"atxHeadingText",start:events[contentStart][1].start,end:events[contentEnd][1].end},text2={type:"chunkText",start:events[contentStart][1].start,
|
||||
end:events[contentEnd][1].end,contentType:"text"},splice(events,contentStart,contentEnd-contentStart+1,[["enter",content2,context],["enter",text2,context],["exit",text2,context],["exit",content2,context]])),events}function tokenizeHeadingAtx(effects,ok,nok){let size2=0;return start2;function start2(code2){return effects.enter("atxHeading"),before(code2)}function before(code2){return effects.enter("atxHeadingSequence"),sequenceOpen(code2)}function sequenceOpen(code2){return code2===35&&size2++<6?
|
||||
(effects.consume(code2),sequenceOpen):code2===null||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingSequence"),atBreak(code2)):nok(code2)}function atBreak(code2){return code2===35?(effects.enter("atxHeadingSequence"),sequenceFurther(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("atxHeading"),ok(code2)):markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):(effects.enter("atxHeadingText"),data(code2))}function sequenceFurther(code2){return code2===35?(effects.
|
||||
consume(code2),sequenceFurther):(effects.exit("atxHeadingSequence"),atBreak(code2))}function data(code2){return code2===null||code2===35||markdownLineEndingOrSpace(code2)?(effects.exit("atxHeadingText"),atBreak(code2)):(effects.consume(code2),data)}}const htmlBlockNames=["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","h1","h2","h\
|
||||
3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={concrete:!0,name:"htmlFlow",resolveTo:resolveToHtmlFlow,tokenize:tokenizeHtmlFlow},blankLineBefore={partial:!0,tokenize:tokenizeBlankLineBefore},nonLazyContinuationStart={partial:!0,tokenize:tokenizeNonLazyContinuationStart};
|
||||
function resolveToHtmlFlow(events){let index2=events.length;for(;index2--&&!(events[index2][0]==="enter"&&events[index2][1].type==="htmlFlow"););return index2>1&&events[index2-2][1].type==="linePrefix"&&(events[index2][1].start=events[index2-2][1].start,events[index2+1][1].start=events[index2-2][1].start,events.splice(index2-2,2)),events}function tokenizeHtmlFlow(effects,ok,nok){const self2=this;let marker,closingTag,buffer,index2,markerB;return start2;function start2(code2){return before(code2)}
|
||||
function before(code2){return effects.enter("htmlFlow"),effects.enter("htmlFlowData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen):code2===47?(effects.consume(code2),closingTag=!0,tagCloseStart):code2===63?(effects.consume(code2),marker=3,self2.interrupt?ok:continuationDeclarationInside):asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function declarationOpen(code2){return code2===45?
|
||||
(effects.consume(code2),marker=2,commentOpenInside):code2===91?(effects.consume(code2),marker=5,index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),marker=4,self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),self2.interrupt?ok:continuationDeclarationInside):nok(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value.
|
||||
length?self2.interrupt?ok:continuation:cdataOpenInside):nok(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),buffer=String.fromCharCode(code2),tagName):nok(code2)}function tagName(code2){if(code2===null||code2===47||code2===62||markdownLineEndingOrSpace(code2)){const slash=code2===47,name=buffer.toLowerCase();return!slash&&!closingTag&&htmlRawNames.includes(name)?(marker=1,self2.interrupt?ok(code2):continuation(code2)):htmlBlockNames.includes(buffer.toLowerCase())?
|
||||
(marker=6,slash?(effects.consume(code2),basicSelfClosing):self2.interrupt?ok(code2):continuation(code2)):(marker=7,self2.interrupt&&!self2.parser.lazy[self2.now().line]?nok(code2):closingTag?completeClosingTagAfter(code2):completeAttributeNameBefore(code2))}return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),buffer+=String.fromCharCode(code2),tagName):nok(code2)}function basicSelfClosing(code2){return code2===62?(effects.consume(code2),self2.interrupt?ok:continuation):nok(code2)}
|
||||
function completeClosingTagAfter(code2){return markdownSpace(code2)?(effects.consume(code2),completeClosingTagAfter):completeEnd(code2)}function completeAttributeNameBefore(code2){return code2===47?(effects.consume(code2),completeEnd):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),completeAttributeName):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameBefore):completeEnd(code2)}function completeAttributeName(code2){return code2===45||code2===46||code2===58||code2===
|
||||
95||asciiAlphanumeric(code2)?(effects.consume(code2),completeAttributeName):completeAttributeNameAfter(code2)}function completeAttributeNameAfter(code2){return code2===61?(effects.consume(code2),completeAttributeValueBefore):markdownSpace(code2)?(effects.consume(code2),completeAttributeNameAfter):completeAttributeNameBefore(code2)}function completeAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),
|
||||
markerB=code2,completeAttributeValueQuoted):markdownSpace(code2)?(effects.consume(code2),completeAttributeValueBefore):completeAttributeValueUnquoted(code2)}function completeAttributeValueQuoted(code2){return code2===markerB?(effects.consume(code2),markerB=null,completeAttributeValueQuotedAfter):code2===null||markdownLineEnding(code2)?nok(code2):(effects.consume(code2),completeAttributeValueQuoted)}function completeAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===
|
||||
47||code2===60||code2===61||code2===62||code2===96||markdownLineEndingOrSpace(code2)?completeAttributeNameAfter(code2):(effects.consume(code2),completeAttributeValueUnquoted)}function completeAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownSpace(code2)?completeAttributeNameBefore(code2):nok(code2)}function completeEnd(code2){return code2===62?(effects.consume(code2),completeAfter):nok(code2)}function completeAfter(code2){return code2===null||markdownLineEnding(code2)?continuation(
|
||||
code2):markdownSpace(code2)?(effects.consume(code2),completeAfter):nok(code2)}function continuation(code2){return code2===45&&marker===2?(effects.consume(code2),continuationCommentInside):code2===60&&marker===1?(effects.consume(code2),continuationRawTagOpen):code2===62&&marker===4?(effects.consume(code2),continuationClose):code2===63&&marker===3?(effects.consume(code2),continuationDeclarationInside):code2===93&&marker===5?(effects.consume(code2),continuationCdataInside):markdownLineEnding(code2)&&
|
||||
(marker===6||marker===7)?(effects.exit("htmlFlowData"),effects.check(blankLineBefore,continuationAfter,continuationStart)(code2)):code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationStart(code2)):(effects.consume(code2),continuation)}function continuationStart(code2){return effects.check(nonLazyContinuationStart,continuationStartNonLazy,continuationAfter)(code2)}function continuationStartNonLazy(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.
|
||||
exit("lineEnding"),continuationBefore}function continuationBefore(code2){return code2===null||markdownLineEnding(code2)?continuationStart(code2):(effects.enter("htmlFlowData"),continuation(code2))}function continuationCommentInside(code2){return code2===45?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationRawTagOpen(code2){return code2===47?(effects.consume(code2),buffer="",continuationRawEndTag):continuation(code2)}function continuationRawEndTag(code2){
|
||||
if(code2===62){const name=buffer.toLowerCase();return htmlRawNames.includes(name)?(effects.consume(code2),continuationClose):continuation(code2)}return asciiAlpha(code2)&&buffer.length<8?(effects.consume(code2),buffer+=String.fromCharCode(code2),continuationRawEndTag):continuation(code2)}function continuationCdataInside(code2){return code2===93?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationDeclarationInside(code2){return code2===62?(effects.consume(
|
||||
code2),continuationClose):code2===45&&marker===2?(effects.consume(code2),continuationDeclarationInside):continuation(code2)}function continuationClose(code2){return code2===null||markdownLineEnding(code2)?(effects.exit("htmlFlowData"),continuationAfter(code2)):(effects.consume(code2),continuationClose)}function continuationAfter(code2){return effects.exit("htmlFlow"),ok(code2)}}function tokenizeNonLazyContinuationStart(effects,ok,nok){const self2=this;return start2;function start2(code2){return markdownLineEnding(
|
||||
code2)?(effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),after):nok(code2)}function after(code2){return self2.parser.lazy[self2.now().line]?nok(code2):ok(code2)}}function tokenizeBlankLineBefore(effects,ok,nok){return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),effects.attempt(blankLine,ok,nok)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(effects,ok,nok){const self2=this;
|
||||
let marker,index2,returnState;return start2;function start2(code2){return effects.enter("htmlText"),effects.enter("htmlTextData"),effects.consume(code2),open2}function open2(code2){return code2===33?(effects.consume(code2),declarationOpen):code2===47?(effects.consume(code2),tagCloseStart):code2===63?(effects.consume(code2),instruction):asciiAlpha(code2)?(effects.consume(code2),tagOpen):nok(code2)}function declarationOpen(code2){return code2===45?(effects.consume(code2),commentOpenInside):code2===
|
||||
91?(effects.consume(code2),index2=0,cdataOpenInside):asciiAlpha(code2)?(effects.consume(code2),declaration):nok(code2)}function commentOpenInside(code2){return code2===45?(effects.consume(code2),commentEnd):nok(code2)}function comment2(code2){return code2===null?nok(code2):code2===45?(effects.consume(code2),commentClose):markdownLineEnding(code2)?(returnState=comment2,lineEndingBefore(code2)):(effects.consume(code2),comment2)}function commentClose(code2){return code2===45?(effects.consume(code2),
|
||||
commentEnd):comment2(code2)}function commentEnd(code2){return code2===62?end(code2):code2===45?commentClose(code2):comment2(code2)}function cdataOpenInside(code2){const value="CDATA[";return code2===value.charCodeAt(index2++)?(effects.consume(code2),index2===value.length?cdata:cdataOpenInside):nok(code2)}function cdata(code2){return code2===null?nok(code2):code2===93?(effects.consume(code2),cdataClose):markdownLineEnding(code2)?(returnState=cdata,lineEndingBefore(code2)):(effects.consume(code2),
|
||||
cdata)}function cdataClose(code2){return code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function cdataEnd(code2){return code2===62?end(code2):code2===93?(effects.consume(code2),cdataEnd):cdata(code2)}function declaration(code2){return code2===null||code2===62?end(code2):markdownLineEnding(code2)?(returnState=declaration,lineEndingBefore(code2)):(effects.consume(code2),declaration)}function instruction(code2){return code2===null?nok(code2):code2===63?(effects.consume(code2),instructionClose):
|
||||
markdownLineEnding(code2)?(returnState=instruction,lineEndingBefore(code2)):(effects.consume(code2),instruction)}function instructionClose(code2){return code2===62?end(code2):instruction(code2)}function tagCloseStart(code2){return asciiAlpha(code2)?(effects.consume(code2),tagClose):nok(code2)}function tagClose(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagClose):tagCloseBetween(code2)}function tagCloseBetween(code2){return markdownLineEnding(code2)?(returnState=tagCloseBetween,
|
||||
lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagCloseBetween):end(code2)}function tagOpen(code2){return code2===45||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpen):code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function tagOpenBetween(code2){return code2===47?(effects.consume(code2),end):code2===58||code2===95||asciiAlpha(code2)?(effects.consume(code2),tagOpenAttributeName):markdownLineEnding(code2)?(returnState=tagOpenBetween,
|
||||
lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenBetween):end(code2)}function tagOpenAttributeName(code2){return code2===45||code2===46||code2===58||code2===95||asciiAlphanumeric(code2)?(effects.consume(code2),tagOpenAttributeName):tagOpenAttributeNameAfter(code2)}function tagOpenAttributeNameAfter(code2){return code2===61?(effects.consume(code2),tagOpenAttributeValueBefore):markdownLineEnding(code2)?(returnState=tagOpenAttributeNameAfter,lineEndingBefore(code2)):markdownSpace(
|
||||
code2)?(effects.consume(code2),tagOpenAttributeNameAfter):tagOpenBetween(code2)}function tagOpenAttributeValueBefore(code2){return code2===null||code2===60||code2===61||code2===62||code2===96?nok(code2):code2===34||code2===39?(effects.consume(code2),marker=code2,tagOpenAttributeValueQuoted):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueBefore,lineEndingBefore(code2)):markdownSpace(code2)?(effects.consume(code2),tagOpenAttributeValueBefore):(effects.consume(code2),tagOpenAttributeValueUnquoted)}
|
||||
function tagOpenAttributeValueQuoted(code2){return code2===marker?(effects.consume(code2),marker=void 0,tagOpenAttributeValueQuotedAfter):code2===null?nok(code2):markdownLineEnding(code2)?(returnState=tagOpenAttributeValueQuoted,lineEndingBefore(code2)):(effects.consume(code2),tagOpenAttributeValueQuoted)}function tagOpenAttributeValueUnquoted(code2){return code2===null||code2===34||code2===39||code2===60||code2===61||code2===96?nok(code2):code2===47||code2===62||markdownLineEndingOrSpace(code2)?
|
||||
tagOpenBetween(code2):(effects.consume(code2),tagOpenAttributeValueUnquoted)}function tagOpenAttributeValueQuotedAfter(code2){return code2===47||code2===62||markdownLineEndingOrSpace(code2)?tagOpenBetween(code2):nok(code2)}function end(code2){return code2===62?(effects.consume(code2),effects.exit("htmlTextData"),effects.exit("htmlText"),ok):nok(code2)}function lineEndingBefore(code2){return effects.exit("htmlTextData"),effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),
|
||||
lineEndingAfter}function lineEndingAfter(code2){return markdownSpace(code2)?factorySpace(effects,lineEndingAfterPrefix,"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2):lineEndingAfterPrefix(code2)}function lineEndingAfterPrefix(code2){return effects.enter("htmlTextData"),returnState(code2)}}const labelEnd={name:"labelEnd",resolveAll:resolveAllLabelEnd,resolveTo:resolveToLabelEnd,tokenize:tokenizeLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={
|
||||
tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(events){let index2=-1;const newEvents=[];for(;++index2<events.length;){const token2=events[index2][1];if(newEvents.push(events[index2]),token2.type==="labelImage"||token2.type==="labelLink"||token2.type==="labelEnd"){const offset2=token2.type==="labelImage"?4:2;token2.type="data",index2+=offset2}}return events.length!==newEvents.length&&splice(events,0,events.length,newEvents),
|
||||
events}function resolveToLabelEnd(events,context){let index2=events.length,offset2=0,token2,open2,close2,media;for(;index2--;)if(token2=events[index2][1],open2){if(token2.type==="link"||token2.type==="labelLink"&&token2._inactive)break;events[index2][0]==="enter"&&token2.type==="labelLink"&&(token2._inactive=!0)}else if(close2){if(events[index2][0]==="enter"&&(token2.type==="labelImage"||token2.type==="labelLink")&&!token2._balanced&&(open2=index2,token2.type!=="labelLink")){offset2=2;break}}else
|
||||
token2.type==="labelEnd"&&(close2=index2);const group={type:events[open2][1].type==="labelLink"?"link":"image",start:{...events[open2][1].start},end:{...events[events.length-1][1].end}},label={type:"label",start:{...events[open2][1].start},end:{...events[close2][1].end}},text2={type:"labelText",start:{...events[open2+offset2+2][1].end},end:{...events[close2-2][1].start}};return media=[["enter",group,context],["enter",label,context]],media=push(media,events.slice(open2+1,open2+offset2+3)),media=push(
|
||||
media,[["enter",text2,context]]),media=push(media,resolveAll(context.parser.constructs.insideSpan.null,events.slice(open2+offset2+4,close2-3),context)),media=push(media,[["exit",text2,context],events[close2-2],events[close2-1],["exit",label,context]]),media=push(media,events.slice(close2+1)),media=push(media,[["exit",group,context]]),splice(events,open2,events.length,media),events}function tokenizeLabelEnd(effects,ok,nok){const self2=this;let index2=self2.events.length,labelStart,defined;for(;index2--;)
|
||||
if((self2.events[index2][1].type==="labelImage"||self2.events[index2][1].type==="labelLink")&&!self2.events[index2][1]._balanced){labelStart=self2.events[index2][1];break}return start2;function start2(code2){return labelStart?labelStart._inactive?labelEndNok(code2):(defined=self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize({start:labelStart.end,end:self2.now()}))),effects.enter("labelEnd"),effects.enter("labelMarker"),effects.consume(code2),effects.exit("labelMarker"),effects.
|
||||
exit("labelEnd"),after):nok(code2)}function after(code2){return code2===40?effects.attempt(resourceConstruct,labelEndOk,defined?labelEndOk:labelEndNok)(code2):code2===91?effects.attempt(referenceFullConstruct,labelEndOk,defined?referenceNotFull:labelEndNok)(code2):defined?labelEndOk(code2):labelEndNok(code2)}function referenceNotFull(code2){return effects.attempt(referenceCollapsedConstruct,labelEndOk,labelEndNok)(code2)}function labelEndOk(code2){return ok(code2)}function labelEndNok(code2){return labelStart.
|
||||
_balanced=!0,nok(code2)}}function tokenizeResource(effects,ok,nok){return resourceStart;function resourceStart(code2){return effects.enter("resource"),effects.enter("resourceMarker"),effects.consume(code2),effects.exit("resourceMarker"),resourceBefore}function resourceBefore(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,resourceOpen)(code2):resourceOpen(code2)}function resourceOpen(code2){return code2===41?resourceEnd(code2):factoryDestination(effects,resourceDestinationAfter,
|
||||
resourceDestinationMissing,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(code2)}function resourceDestinationAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,resourceBetween)(code2):resourceEnd(code2)}function resourceDestinationMissing(code2){return nok(code2)}function resourceBetween(code2){return code2===34||code2===39||code2===40?factoryTitle(effects,resourceTitleAfter,
|
||||
nok,"resourceTitle","resourceTitleMarker","resourceTitleString")(code2):resourceEnd(code2)}function resourceTitleAfter(code2){return markdownLineEndingOrSpace(code2)?factoryWhitespace(effects,resourceEnd)(code2):resourceEnd(code2)}function resourceEnd(code2){return code2===41?(effects.enter("resourceMarker"),effects.consume(code2),effects.exit("resourceMarker"),effects.exit("resource"),ok):nok(code2)}}function tokenizeReferenceFull(effects,ok,nok){const self2=this;return referenceFull;function referenceFull(code2){
|
||||
return factoryLabel.call(self2,effects,referenceFullAfter,referenceFullMissing,"reference","referenceMarker","referenceString")(code2)}function referenceFullAfter(code2){return self2.parser.defined.includes(normalizeIdentifier(self2.sliceSerialize(self2.events[self2.events.length-1][1]).slice(1,-1)))?ok(code2):nok(code2)}function referenceFullMissing(code2){return nok(code2)}}function tokenizeReferenceCollapsed(effects,ok,nok){return referenceCollapsedStart;function referenceCollapsedStart(code2){
|
||||
return effects.enter("reference"),effects.enter("referenceMarker"),effects.consume(code2),effects.exit("referenceMarker"),referenceCollapsedOpen}function referenceCollapsedOpen(code2){return code2===93?(effects.enter("referenceMarker"),effects.consume(code2),effects.exit("referenceMarker"),effects.exit("reference"),ok):nok(code2)}}const labelStartImage={name:"labelStartImage",resolveAll:labelEnd.resolveAll,tokenize:tokenizeLabelStartImage};function tokenizeLabelStartImage(effects,ok,nok){const self2=this;
|
||||
return start2;function start2(code2){return effects.enter("labelImage"),effects.enter("labelImageMarker"),effects.consume(code2),effects.exit("labelImageMarker"),open2}function open2(code2){return code2===91?(effects.enter("labelMarker"),effects.consume(code2),effects.exit("labelMarker"),effects.exit("labelImage"),after):nok(code2)}function after(code2){return code2===94&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):ok(code2)}}const labelStartLink={name:"labelStartLink",resolveAll:labelEnd.
|
||||
resolveAll,tokenize:tokenizeLabelStartLink};function tokenizeLabelStartLink(effects,ok,nok){const self2=this;return start2;function start2(code2){return effects.enter("labelLink"),effects.enter("labelMarker"),effects.consume(code2),effects.exit("labelMarker"),effects.exit("labelLink"),after}function after(code2){return code2===94&&"_hiddenFootnoteSupport"in self2.parser.constructs?nok(code2):ok(code2)}}const lineEnding={name:"lineEnding",tokenize:tokenizeLineEnding};function tokenizeLineEnding(effects,ok){
|
||||
return start2;function start2(code2){return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),factorySpace(effects,ok,"linePrefix")}}const thematicBreak$2={name:"thematicBreak",tokenize:tokenizeThematicBreak};function tokenizeThematicBreak(effects,ok,nok){let size2=0,marker;return start2;function start2(code2){return effects.enter("thematicBreak"),before(code2)}function before(code2){return marker=code2,atBreak(code2)}function atBreak(code2){return code2===marker?(effects.
|
||||
enter("thematicBreakSequence"),sequence(code2)):size2>=3&&(code2===null||markdownLineEnding(code2))?(effects.exit("thematicBreak"),ok(code2)):nok(code2)}function sequence(code2){return code2===marker?(effects.consume(code2),size2++,sequence):(effects.exit("thematicBreakSequence"),markdownSpace(code2)?factorySpace(effects,atBreak,"whitespace")(code2):atBreak(code2))}}const list$3={continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd,name:"list",tokenize:tokenizeListStart},listItemPrefixWhitespaceConstruct={
|
||||
partial:!0,tokenize:tokenizeListItemPrefixWhitespace},indentConstruct={partial:!0,tokenize:tokenizeIndent$1};function tokenizeListStart(effects,ok,nok){const self2=this,tail=self2.events[self2.events.length-1];let initialSize=tail&&tail[1].type==="linePrefix"?tail[2].sliceSerialize(tail[1],!0).length:0,size2=0;return start2;function start2(code2){const kind=self2.containerState.type||(code2===42||code2===43||code2===45?"listUnordered":"listOrdered");if(kind==="listUnordered"?!self2.containerState.
|
||||
marker||code2===self2.containerState.marker:asciiDigit(code2)){if(self2.containerState.type||(self2.containerState.type=kind,effects.enter(kind,{_container:!0})),kind==="listUnordered")return effects.enter("listItemPrefix"),code2===42||code2===45?effects.check(thematicBreak$2,nok,atMarker)(code2):atMarker(code2);if(!self2.interrupt||code2===49)return effects.enter("listItemPrefix"),effects.enter("listItemValue"),inside(code2)}return nok(code2)}function inside(code2){return asciiDigit(code2)&&++size2<
|
||||
10?(effects.consume(code2),inside):(!self2.interrupt||size2<2)&&(self2.containerState.marker?code2===self2.containerState.marker:code2===41||code2===46)?(effects.exit("listItemValue"),atMarker(code2)):nok(code2)}function atMarker(code2){return effects.enter("listItemMarker"),effects.consume(code2),effects.exit("listItemMarker"),self2.containerState.marker=self2.containerState.marker||code2,effects.check(blankLine,self2.interrupt?nok:onBlank,effects.attempt(listItemPrefixWhitespaceConstruct,endOfPrefix,
|
||||
otherPrefix))}function onBlank(code2){return self2.containerState.initialBlankLine=!0,initialSize++,endOfPrefix(code2)}function otherPrefix(code2){return markdownSpace(code2)?(effects.enter("listItemPrefixWhitespace"),effects.consume(code2),effects.exit("listItemPrefixWhitespace"),endOfPrefix):nok(code2)}function endOfPrefix(code2){return self2.containerState.size=initialSize+self2.sliceSerialize(effects.exit("listItemPrefix"),!0).length,ok(code2)}}function tokenizeListContinuation(effects,ok,nok){
|
||||
const self2=this;return self2.containerState._closeFlow=void 0,effects.check(blankLine,onBlank,notBlank);function onBlank(code2){return self2.containerState.furtherBlankLines=self2.containerState.furtherBlankLines||self2.containerState.initialBlankLine,factorySpace(effects,ok,"listItemIndent",self2.containerState.size+1)(code2)}function notBlank(code2){return self2.containerState.furtherBlankLines||!markdownSpace(code2)?(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=
|
||||
void 0,notInCurrentItem(code2)):(self2.containerState.furtherBlankLines=void 0,self2.containerState.initialBlankLine=void 0,effects.attempt(indentConstruct,ok,notInCurrentItem)(code2))}function notInCurrentItem(code2){return self2.containerState._closeFlow=!0,self2.interrupt=void 0,factorySpace(effects,effects.attempt(list$3,ok,nok),"linePrefix",self2.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(code2)}}function tokenizeIndent$1(effects,ok,nok){const self2=this;return factorySpace(
|
||||
effects,afterPrefix,"listItemIndent",self2.containerState.size+1);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return tail&&tail[1].type==="listItemIndent"&&tail[2].sliceSerialize(tail[1],!0).length===self2.containerState.size?ok(code2):nok(code2)}}function tokenizeListEnd(effects){effects.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(effects,ok,nok){const self2=this;return factorySpace(effects,afterPrefix,"listItemPrefixWhitespace",self2.
|
||||
parser.constructs.disable.null.includes("codeIndented")?void 0:5);function afterPrefix(code2){const tail=self2.events[self2.events.length-1];return!markdownSpace(code2)&&tail&&tail[1].type==="listItemPrefixWhitespace"?ok(code2):nok(code2)}}const setextUnderline={name:"setextUnderline",resolveTo:resolveToSetextUnderline,tokenize:tokenizeSetextUnderline};function resolveToSetextUnderline(events,context){let index2=events.length,content2,text2,definition2;for(;index2--;)if(events[index2][0]==="ente\
|
||||
r"){if(events[index2][1].type==="content"){content2=index2;break}events[index2][1].type==="paragraph"&&(text2=index2)}else events[index2][1].type==="content"&&events.splice(index2,1),!definition2&&events[index2][1].type==="definition"&&(definition2=index2);const heading2={type:"setextHeading",start:{...events[content2][1].start},end:{...events[events.length-1][1].end}};return events[text2][1].type="setextHeadingText",definition2?(events.splice(text2,0,["enter",heading2,context]),events.splice(definition2+
|
||||
1,0,["exit",events[content2][1],context]),events[content2][1].end={...events[definition2][1].end}):events[content2][1]=heading2,events.push(["exit",heading2,context]),events}function tokenizeSetextUnderline(effects,ok,nok){const self2=this;let marker;return start2;function start2(code2){let index2=self2.events.length,paragraph2;for(;index2--;)if(self2.events[index2][1].type!=="lineEnding"&&self2.events[index2][1].type!=="linePrefix"&&self2.events[index2][1].type!=="content"){paragraph2=self2.events[index2][1].
|
||||
type==="paragraph";break}return!self2.parser.lazy[self2.now().line]&&(self2.interrupt||paragraph2)?(effects.enter("setextHeadingLine"),marker=code2,before(code2)):nok(code2)}function before(code2){return effects.enter("setextHeadingLineSequence"),inside(code2)}function inside(code2){return code2===marker?(effects.consume(code2),inside):(effects.exit("setextHeadingLineSequence"),markdownSpace(code2)?factorySpace(effects,after,"lineSuffix")(code2):after(code2))}function after(code2){return code2===
|
||||
null||markdownLineEnding(code2)?(effects.exit("setextHeadingLine"),ok(code2)):nok(code2)}}const flow$1={tokenize:initializeFlow};function initializeFlow(effects){const self2=this,initial=effects.attempt(blankLine,atBlankEnding,effects.attempt(this.parser.constructs.flowInitial,afterConstruct,factorySpace(effects,effects.attempt(this.parser.constructs.flow,afterConstruct,effects.attempt(content,afterConstruct)),"linePrefix")));return initial;function atBlankEnding(code2){if(code2===null){effects.
|
||||
consume(code2);return}return effects.enter("lineEndingBlank"),effects.consume(code2),effects.exit("lineEndingBlank"),self2.currentConstruct=void 0,initial}function afterConstruct(code2){if(code2===null){effects.consume(code2);return}return effects.enter("lineEnding"),effects.consume(code2),effects.exit("lineEnding"),self2.currentConstruct=void 0,initial}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$7=initializeFactory("text");function initializeFactory(field){
|
||||
return{resolveAll:createResolver(field==="text"?resolveAllLineSuffixes:void 0),tokenize:initializeText};function initializeText(effects){const self2=this,constructs2=this.parser.constructs[field],text2=effects.attempt(constructs2,start2,notText);return start2;function start2(code2){return atBreak(code2)?text2(code2):notText(code2)}function notText(code2){if(code2===null){effects.consume(code2);return}return effects.enter("data"),effects.consume(code2),data}function data(code2){return atBreak(code2)?
|
||||
(effects.exit("data"),text2(code2)):(effects.consume(code2),data)}function atBreak(code2){if(code2===null)return!0;const list2=constructs2[code2];let index2=-1;if(list2)for(;++index2<list2.length;){const item=list2[index2];if(!item.previous||item.previous.call(self2,self2.previous))return!0}return!1}}}function createResolver(extraResolver){return resolveAllText;function resolveAllText(events,context){let index2=-1,enter;for(;++index2<=events.length;)enter===void 0?events[index2]&&events[index2][1].
|
||||
type==="data"&&(enter=index2,index2++):(!events[index2]||events[index2][1].type!=="data")&&(index2!==enter+2&&(events[enter][1].end=events[index2-1][1].end,events.splice(enter+2,index2-enter-2),index2=enter+2),enter=void 0);return extraResolver?extraResolver(events,context):events}}function resolveAllLineSuffixes(events,context){let eventIndex=0;for(;++eventIndex<=events.length;)if((eventIndex===events.length||events[eventIndex][1].type==="lineEnding")&&events[eventIndex-1][1].type==="data"){const data=events[eventIndex-
|
||||
1][1],chunks=context.sliceStream(data);let index2=chunks.length,bufferIndex=-1,size2=0,tabs;for(;index2--;){const chunk=chunks[index2];if(typeof chunk=="string"){for(bufferIndex=chunk.length;chunk.charCodeAt(bufferIndex-1)===32;)size2++,bufferIndex--;if(bufferIndex)break;bufferIndex=-1}else if(chunk===-2)tabs=!0,size2++;else if(chunk!==-1){index2++;break}}if(context._contentTypeTextTrailing&&eventIndex===events.length&&(size2=0),size2){const token2={type:eventIndex===events.length||tabs||size2<2?
|
||||
"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:index2?bufferIndex:data.start._bufferIndex+bufferIndex,_index:data.start._index+index2,line:data.end.line,column:data.end.column-size2,offset:data.end.offset-size2},end:{...data.end}};data.end={...token2.start},data.start.offset===data.end.offset?Object.assign(data,token2):(events.splice(eventIndex,0,["enter",token2,context],["exit",token2,context]),eventIndex+=2)}eventIndex++}return events}const document$1={42:list$3,43:list$3,45:list$3,48:list$3,
|
||||
49:list$3,50:list$3,51:list$3,52:list$3,53:list$3,54:list$3,55:list$3,56:list$3,57:list$3,62:blockQuote},contentInitial={91:definition$1},flowInitial={[-2]:codeIndented,[-1]:codeIndented,32:codeIndented},flow={35:headingAtx,42:thematicBreak$2,45:[setextUnderline,thematicBreak$2],60:htmlFlow,61:setextUnderline,95:thematicBreak$2,96:codeFenced,126:codeFenced},string={38:characterReference,92:characterEscape},text$6={[-5]:lineEnding,[-4]:lineEnding,[-3]:lineEnding,33:labelStartImage,38:characterReference,
|
||||
42:attention,60:[autolink,htmlText],91:labelStartLink,92:[hardBreakEscape,characterEscape],93:labelEnd,95:attention,96:codeText},insideSpan={null:[attention,resolver]},attentionMarkers={null:[42,95]},disable={null:[]},defaultConstructs=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers,contentInitial,disable,document:document$1,flow,flowInitial,insideSpan,string,text:text$6},Symbol.toStringTag,{value:"Module"}));function createTokenizer(parser,initialize2,from){let point2={_bufferIndex:-1,
|
||||
_index:0,line:from&&from.line||1,column:from&&from.column||1,offset:from&&from.offset||0};const columnStart={},resolveAllConstructs=[];let chunks=[],stack=[];const effects={attempt:constructFactory(onsuccessfulconstruct),check:constructFactory(onsuccessfulcheck),consume,enter,exit:exit2,interrupt:constructFactory(onsuccessfulcheck,{interrupt:!0})},context={code:null,containerState:{},defineSkip,events:[],now:now2,parser,previous:null,sliceSerialize,sliceStream,write};let state2=initialize2.tokenize.
|
||||
call(context,effects);return initialize2.resolveAll&&resolveAllConstructs.push(initialize2),context;function write(slice){return chunks=push(chunks,slice),main2(),chunks[chunks.length-1]!==null?[]:(addResult(initialize2,0),context.events=resolveAll(resolveAllConstructs,context.events,context),context.events)}function sliceSerialize(token2,expandTabs){return serializeChunks(sliceStream(token2),expandTabs)}function sliceStream(token2){return sliceChunks(chunks,token2)}function now2(){const{_bufferIndex,
|
||||
_index,line,column,offset:offset2}=point2;return{_bufferIndex,_index,line,column,offset:offset2}}function defineSkip(value){columnStart[value.line]=value.column,accountForPotentialSkip()}function main2(){let chunkIndex;for(;point2._index<chunks.length;){const chunk=chunks[point2._index];if(typeof chunk=="string")for(chunkIndex=point2._index,point2._bufferIndex<0&&(point2._bufferIndex=0);point2._index===chunkIndex&&point2._bufferIndex<chunk.length;)go2(chunk.charCodeAt(point2._bufferIndex));else go2(
|
||||
chunk)}}function go2(code2){state2=state2(code2)}function consume(code2){markdownLineEnding(code2)?(point2.line++,point2.column=1,point2.offset+=code2===-3?2:1,accountForPotentialSkip()):code2!==-1&&(point2.column++,point2.offset++),point2._bufferIndex<0?point2._index++:(point2._bufferIndex++,point2._bufferIndex===chunks[point2._index].length&&(point2._bufferIndex=-1,point2._index++)),context.previous=code2}function enter(type2,fields){const token2=fields||{};return token2.type=type2,token2.start=
|
||||
now2(),context.events.push(["enter",token2,context]),stack.push(token2),token2}function exit2(type2){const token2=stack.pop();return token2.end=now2(),context.events.push(["exit",token2,context]),token2}function onsuccessfulconstruct(construct,info2){addResult(construct,info2.from)}function onsuccessfulcheck(_,info2){info2.restore()}function constructFactory(onreturn,fields){return hook;function hook(constructs2,returnState,bogusState){let listOfConstructs,constructIndex,currentConstruct,info2;return Array.
|
||||
isArray(constructs2)?handleListOfConstructs(constructs2):"tokenize"in constructs2?handleListOfConstructs([constructs2]):handleMapOfConstructs(constructs2);function handleMapOfConstructs(map2){return start2;function start2(code2){const left=code2!==null&&map2[code2],all2=code2!==null&&map2.null,list2=[...Array.isArray(left)?left:left?[left]:[],...Array.isArray(all2)?all2:all2?[all2]:[]];return handleListOfConstructs(list2)(code2)}}function handleListOfConstructs(list2){return listOfConstructs=list2,
|
||||
constructIndex=0,list2.length===0?bogusState:handleConstruct(list2[constructIndex])}function handleConstruct(construct){return start2;function start2(code2){return info2=store(),currentConstruct=construct,construct.partial||(context.currentConstruct=construct),construct.name&&context.parser.constructs.disable.null.includes(construct.name)?nok():construct.tokenize.call(fields?Object.assign(Object.create(context),fields):context,effects,ok,nok)(code2)}}function ok(code2){return onreturn(currentConstruct,
|
||||
info2),returnState}function nok(code2){return info2.restore(),++constructIndex<listOfConstructs.length?handleConstruct(listOfConstructs[constructIndex]):bogusState}}}function addResult(construct,from2){construct.resolveAll&&!resolveAllConstructs.includes(construct)&&resolveAllConstructs.push(construct),construct.resolve&&splice(context.events,from2,context.events.length-from2,construct.resolve(context.events.slice(from2),context)),construct.resolveTo&&(context.events=construct.resolveTo(context.
|
||||
events,context))}function store(){const startPoint=now2(),startPrevious=context.previous,startCurrentConstruct=context.currentConstruct,startEventsIndex=context.events.length,startStack=Array.from(stack);return{from:startEventsIndex,restore};function restore(){point2=startPoint,context.previous=startPrevious,context.currentConstruct=startCurrentConstruct,context.events.length=startEventsIndex,stack=startStack,accountForPotentialSkip()}}function accountForPotentialSkip(){point2.line in columnStart&&
|
||||
point2.column<2&&(point2.column=columnStart[point2.line],point2.offset+=columnStart[point2.line]-1)}}function sliceChunks(chunks,token2){const startIndex=token2.start._index,startBufferIndex=token2.start._bufferIndex,endIndex=token2.end._index,endBufferIndex=token2.end._bufferIndex;let view;if(startIndex===endIndex)view=[chunks[startIndex].slice(startBufferIndex,endBufferIndex)];else{if(view=chunks.slice(startIndex,endIndex),startBufferIndex>-1){const head2=view[0];typeof head2=="string"?view[0]=
|
||||
head2.slice(startBufferIndex):view.shift()}endBufferIndex>0&&view.push(chunks[endIndex].slice(0,endBufferIndex))}return view}function serializeChunks(chunks,expandTabs){let index2=-1;const result=[];let atTab;for(;++index2<chunks.length;){const chunk=chunks[index2];let value;if(typeof chunk=="string")value=chunk;else switch(chunk){case-5:{value="\r";break}case-4:{value=`
|
||||
`;break}case-3:{value=`\r
|
||||
`;break}case-2:{value=expandTabs?" ":" ";break}case-1:{if(!expandTabs&&atTab)continue;value=" ";break}default:value=String.fromCharCode(chunk)}atTab=chunk===-2,result.push(value)}return result.join("")}function parse$2(options){const parser={constructs:combineExtensions([defaultConstructs,...(options||{}).extensions||[]]),content:create2(content$1),defined:[],document:create2(document$2),flow:create2(flow$1),lazy:{},string:create2(string$1),text:create2(text$7)};return parser;function create2(initial){
|
||||
return creator;function creator(from){return createTokenizer(parser,initial,from)}}}function postprocess(events){for(;!subtokenize(events););return events}const search$1=/[\0\t\n\r]/g;function preprocess(){let column=1,buffer="",start2=!0,atCarriageReturn;return preprocessor;function preprocessor(value,encoding,end){const chunks=[];let match,next2,startPosition,endPosition,code2;for(value=buffer+(typeof value=="string"?value.toString():new TextDecoder(encoding||void 0).decode(value)),startPosition=
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@
|
|||
});
|
||||
|
||||
function handleMessagesReady() {
|
||||
if (!disableAutoScroll) {
|
||||
if (!disableAutoScroll && !autoScroll.userScrolledUp) {
|
||||
requestAnimationFrame(() => {
|
||||
autoScroll.scrollToBottom('instant');
|
||||
});
|
||||
|
|
@ -379,7 +379,9 @@
|
|||
messages={activeMessages()}
|
||||
onUserAction={() => {
|
||||
autoScroll.enable();
|
||||
autoScroll.scrollToBottom();
|
||||
if (!autoScroll.userScrolledUp) {
|
||||
autoScroll.scrollToBottom();
|
||||
}
|
||||
}}
|
||||
onMessagesReady={handleMessagesReady}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ export class AutoScrollController {
|
|||
private _userScrolledUp = $state(false);
|
||||
private _lastScrollTop = $state(0);
|
||||
private _scrollInterval: ReturnType<typeof setInterval> | undefined;
|
||||
private _scrollTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||
private _container: HTMLElement | undefined;
|
||||
private _disabled: boolean;
|
||||
private _mutationObserver: MutationObserver | null = null;
|
||||
|
|
@ -51,6 +50,7 @@ export class AutoScrollController {
|
|||
* Updates the disabled state.
|
||||
*/
|
||||
setDisabled(disabled: boolean): void {
|
||||
if (this._disabled === disabled) return;
|
||||
this._disabled = disabled;
|
||||
if (disabled) {
|
||||
this._autoScrollEnabled = false;
|
||||
|
|
@ -80,17 +80,6 @@ export class AutoScrollController {
|
|||
this._autoScrollEnabled = true;
|
||||
}
|
||||
|
||||
if (this._scrollTimeout) {
|
||||
clearTimeout(this._scrollTimeout);
|
||||
}
|
||||
|
||||
this._scrollTimeout = setTimeout(() => {
|
||||
if (isAtBottom) {
|
||||
this._userScrolledUp = false;
|
||||
this._autoScrollEnabled = true;
|
||||
}
|
||||
}, AUTO_SCROLL_INTERVAL);
|
||||
|
||||
this._lastScrollTop = scrollTop;
|
||||
}
|
||||
|
||||
|
|
@ -157,11 +146,6 @@ export class AutoScrollController {
|
|||
destroy(): void {
|
||||
this.stopInterval();
|
||||
this._doStopObserving();
|
||||
|
||||
if (this._scrollTimeout) {
|
||||
clearTimeout(this._scrollTimeout);
|
||||
this._scrollTimeout = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue