@bendyline/gezel-service 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NOTICE.md +3 -3
- package/dist/bin/gezeld.js +8471 -5311
- package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +78 -0
- package/dist/handboek-content/whats-new/{1.26250.md → 1.26251.md} +5 -5
- package/dist/index-store/static-index-worker.js +160 -51
- package/dist/index.d.ts +416 -71
- package/dist/index.js +8465 -5305
- package/dist/memory/embed-worker.js +132 -4
- package/dist/memory/image-embed-worker.js +14 -5
- package/dist/providers/mlx/python/cache_persist.py +52 -8
- package/dist/providers/mlx/python/gezel_mlx_server.py +44 -1
- package/dist/providers/mlx/python/qwen4_ple.py +159 -0
- package/dist/providers/mlx/python/spec_decode.py +73 -31
- package/dist/providers/mlx/python/tool_call_stream.py +10 -2
- package/dist/providers/mlx/python/tool_grammar.py +16 -0
- package/dist/ui/assets/{AmbientDashboardCard-DcVHxEdC.js → AmbientDashboardCard-_xnAQGnk.js} +1 -1
- package/dist/ui/assets/{AudioEngineSettings-BFM2S1mm.js → AudioEngineSettings-CgXgbX0i.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-84-YeULA.js → BenchmarksView-BlExZpYA.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DYXUZQ_t.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-7NAVUk4k.js → ChannelsSettings-EH27HcqZ.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-Dn1TNyVn.js +7 -0
- package/dist/ui/assets/{ConnectedAppsPanel-CIgF4Q3R.js → ConnectedAppsPanel-BROry-Y0.js} +1 -1
- package/dist/ui/assets/CraftbookEditor-B2RNJnFf.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-Ck5tzj3Y.js → CraftbookScriptEditorView-B-vySmHP.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-BWg7FhK_.js → CraftbookTabContent-BW_2KC89.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-EuFOiUzR.js → CraftbookToolsetSetup-J7rEa835.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-BIzQ1VVn.js → CraftbooksView-BjBUWPGF.js} +1 -1
- package/dist/ui/assets/DiffpackReviewView-CD4qJmgT.js +1 -0
- package/dist/ui/assets/DocumentDetail-SYozruTJ.js +1 -0
- package/dist/ui/assets/DocumentsView-DE7eL49Z.js +1 -0
- package/dist/ui/assets/{Ds4Settings-9soZCSeO.js → Ds4Settings-DGzc7JcD.js} +1 -1
- package/dist/ui/assets/{EmbeddedChat-Cce7nxXT.js → EmbeddedChat-D92TaJQ8.js} +1 -1
- package/dist/ui/assets/{FaceRecognitionCard-BVZyOwB8.js → FaceRecognitionCard-CB1Dt9X4.js} +1 -1
- package/dist/ui/assets/FileMapView-kVBG22FU.js +1 -0
- package/dist/ui/assets/FoldersSettings-BWFQU5B4.js +1 -0
- package/dist/ui/assets/GezelDetail-Br4v42Nv.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-DXXt165-.js → GezelJsonEditor-B9XEiW5Y.js} +1 -1
- package/dist/ui/assets/GezellenView-DheEBAy4.js +1 -0
- package/dist/ui/assets/{GildeUpdatesCard-CtY8mUTA.js → GildeUpdatesCard-BeIYv09f.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-DT3l6E0Q.js → GithubSignInChip-eEGCe9ar.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-ByJ4NAzz.js → HandboekMediaProvider-D0zcbbpf.js} +1 -1
- package/dist/ui/assets/HandboekView-p0BZT1rH.js +1 -0
- package/dist/ui/assets/{HistoryView-CkinzFEC.js → HistoryView-CKWcWW-Y.js} +1 -1
- package/dist/ui/assets/{HomeView-DNBrQnwy.js → HomeView-b_TT5oV3.js} +1 -1
- package/dist/ui/assets/{ImageEngineSettings-BfM9HSd_.js → ImageEngineSettings-CJfk4OJ4.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-CaSQu5Br.js → ImageRecognitionSettings-DzbvZk5S.js} +1 -1
- package/dist/ui/assets/{IncompleteDownloads-C36lTCMG.js → IncompleteDownloads-C8_XyP8O.js} +1 -1
- package/dist/ui/assets/{KnowledgeCatalogsCard-CK9bqdf6.js → KnowledgeCatalogsCard-CHopG_j-.js} +1 -1
- package/dist/ui/assets/KnowledgeView-CXNKZUJq.js +1 -0
- package/dist/ui/assets/{LlamaCppSettings-CdNMHBbp.js → LlamaCppSettings-ohcM7kes.js} +1 -1
- package/dist/ui/assets/{MarkdownField-Dugmfr_e.js → MarkdownField-BX0qsaFq.js} +1 -1
- package/dist/ui/assets/{MemoriesTree-CgFqUNEr.js → MemoriesTree-BPj5Rod8.js} +1 -1
- package/dist/ui/assets/{MicrophoneSettings-DzDe9y1q.js → MicrophoneSettings-CWjeYnfI.js} +1 -1
- package/dist/ui/assets/MlxSettings-Dq6dRpcl.js +1 -0
- package/dist/ui/assets/{ModelPicker-BVkJhNAH.js → ModelPicker-0Ue-eEKj.js} +1 -1
- package/dist/ui/assets/NewPathDialog-BhAZm9dp.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-TEAd0KLl.js → NewScriptDialog-DuryIe50.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-BX24flMY.js +2 -0
- package/dist/ui/assets/{OllamaSettings-CPy2vxyZ.js → OllamaSettings-Boj8Nd1G.js} +1 -1
- package/dist/ui/assets/ProjectChat-Dhw_M5bq.js +5 -0
- package/dist/ui/assets/ProjectConnectionsTab-BwpMQNrg.js +1 -0
- package/dist/ui/assets/{ProjectGitStatusBar-BgHZ2ijN.js → ProjectGitStatusBar-BORGYx5l.js} +1 -1
- package/dist/ui/assets/{ProjectGithubView-BV2uTNU0.js → ProjectGithubView-CTP1BOMv.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DLtJdXSL.js → ProjectMailTab-qFmAeV3M.js} +1 -1
- package/dist/ui/assets/{ProjectOverviewView-ZMs9nL5N.js → ProjectOverviewView-Cq1FsoaT.js} +1 -1
- package/dist/ui/assets/{ProjectTimeline-CTPcn4Kc.js → ProjectTimeline-Cqae2Z92.js} +1 -1
- package/dist/ui/assets/ProjectsView-D0uJjUB-.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-iUoisQBi.js → RecommendedBadge-CN1jEmSn.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-CTVJ0IRh.js → RemoteServersPanel-CMakvCCM.js} +1 -1
- package/dist/ui/assets/{ScriptEditorTabs-CCDFZjdC.js → ScriptEditorTabs-st6dJePd.js} +2 -2
- package/dist/ui/assets/{ScriptEditorView-CergLqKj.js → ScriptEditorView-BkySh57_.js} +2 -2
- package/dist/ui/assets/{ScriptsView-v7ckdhDi.js → ScriptsView-7uPKwjDB.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-Bd0-66Gs.js → SecurityComplianceSettings-Tsv_pXfy.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-D0fSeeHO.js +1 -0
- package/dist/ui/assets/SettingsView-cli_z8ZW.js +3 -0
- package/dist/ui/assets/{SquisqIntegration-C5l_OPvD.js → SquisqIntegration-BTZ1kBlg.js} +1 -1
- package/dist/ui/assets/{StorageCleanupDialog-3kv9-2mT.js → StorageCleanupDialog-CDBjl8JQ.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-7sWTrZFa.js → StorageUsageCard-DXY1j0dZ.js} +1 -1
- package/dist/ui/assets/TaskTabContent-C0P681SL.js +1 -0
- package/dist/ui/assets/TasksView-Ddwz10ri.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-ChmdzmCz.js → TerminalCodeEditor-BkNQ6QoQ.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-KVigemfL.js +8 -0
- package/dist/ui/assets/{TransformToolbarButton-gzIxUBH7.js → TransformToolbarButton-8wfJR1bO.js} +2 -2
- package/dist/ui/assets/{UnrecognizedModels-0hptopv6.js → UnrecognizedModels-BzdU1clO.js} +1 -1
- package/dist/ui/assets/{VideoEngineSettings-BdNzCEdR.js → VideoEngineSettings-f79ff57u.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DnsOO916.js → WorkspaceIndexPane-fu5V6o1W.js} +1 -1
- package/dist/ui/assets/{api-C0I7spBl.js → api-CmrgM5Rf.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-8MCtb17Q.js +1 -0
- package/dist/ui/assets/{chunk-6ECMNUIP-BvCy0HUI.js → chunk-6ECMNUIP-D5AA6ozp.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-ofeM4l8g.js → chunk-A6N6IN3I-BpxihS5H.js} +1 -1
- package/dist/ui/assets/{chunk-ATWVNF7D-CYuW1Yc6.js → chunk-ATWVNF7D-CKIWh7bN.js} +1 -1
- package/dist/ui/assets/{chunk-UBFT2CDQ-FexGDigd.js → chunk-CW24CH7I-BD0FIooX.js} +1 -1
- package/dist/ui/assets/{chunk-DXYWKZ52-zxe8pjH4.js → chunk-DXYWKZ52-DMKPZnpo.js} +1 -1
- package/dist/ui/assets/chunk-IIQYS2YH-BtDJt4Xr.js +1 -0
- package/dist/ui/assets/{chunk-KGWT454C-v5-l6U5m.js → chunk-KGWT454C-DsQOBuLg.js} +1 -1
- package/dist/ui/assets/{chunk-Q77KNJIN-BLuPdsQF.js → chunk-Q77KNJIN-BdWizq9s.js} +1 -1
- package/dist/ui/assets/{chunk-USU6HTKB-B_p-YcDp.js → chunk-USU6HTKB-DyGZplh4.js} +1 -1
- package/dist/ui/assets/{chunk-UXEANVBI-Bt0kX-0Z.js → chunk-UXEANVBI-BUBXvqyE.js} +1 -1
- package/dist/ui/assets/{chunk-O7JILDEF-CqcO1qaI.js → chunk-X7BNDUNI-D14WIvlD.js} +2 -2
- package/dist/ui/assets/{chunk-AE3IUKMM-mZjzzO8Z.js → chunk-ZSU5DJLX-CrjQf-vs.js} +1 -1
- package/dist/ui/assets/{container-BI8hxN1N.js → container-iFj1r6Hk.js} +1 -1
- package/dist/ui/assets/csv-Di411Mv-.js +1 -0
- package/dist/ui/assets/data-Q05qqAp4.js +1 -0
- package/dist/ui/assets/{dist-APSIK7H3.js → dist-1FNFiksd.js} +3 -3
- package/dist/ui/assets/dist-BMZhqfv7.js +2 -0
- package/dist/ui/assets/dist-CE5CbmDb.js +225 -0
- package/dist/ui/assets/doc-BHcGsJZd.js +587 -0
- package/dist/ui/assets/{document-import-DPK4r8Am.js → document-import-B2Ya6sbf.js} +1 -1
- package/dist/ui/assets/{docx-DRLuCTaC.js → docx-B8Pwz5Ih.js} +1 -1
- package/dist/ui/assets/{epub-a0p2Xb1b.js → epub-BQ4g8Q9j.js} +1 -1
- package/dist/ui/assets/{export-options-BqYFyzWx.js → export-options-Dylv69b3.js} +1 -1
- package/dist/ui/assets/file-browser-BLOPfnS0.js +5 -0
- package/dist/ui/assets/{html-BbQNmJ5X.js → html-BnA7qFwq.js} +1 -1
- package/dist/ui/assets/icons-CyM7Cg4E.js +1 -0
- package/dist/ui/assets/index-DW6qHqhU.css +1 -0
- package/dist/ui/assets/index-DivKnJyx.js +36 -0
- package/dist/ui/assets/{mail-link-CWfsP5Aq.js → mail-link-NtlcX5OE.js} +1 -1
- package/dist/ui/assets/{markdown-ryKA_OmY.js → markdown-CLKH_zzl.js} +1 -1
- package/dist/ui/assets/markdown-baseline-0dqv9qbV.js +1 -0
- package/dist/ui/assets/materialize-G4WC5UG3-xq2dcwS8.js +1 -0
- package/dist/ui/assets/{monaco-base-C0VTMpv-.js → monaco-base-BSvdAweA.js} +1 -1
- package/dist/ui/assets/{monaco-setup-CX8q88c5.js → monaco-setup-CT7LZ0o_.js} +1 -1
- package/dist/ui/assets/{new-project-meta-ZmDPGYzC.js → new-project-meta-5Y9Blozr.js} +1 -1
- package/dist/ui/assets/outside-in-Msmhxf_U.js +3 -0
- package/dist/ui/assets/{pdf-BHrygJa5.js → pdf-C4BhW3zg.js} +1 -1
- package/dist/ui/assets/{pending-drafts-27ujtQxX.js → pending-drafts-BD227X9H.js} +1 -1
- package/dist/ui/assets/{poppetje-CfaAvFkE.js → poppetje-DvCJO36y.js} +3 -3
- package/dist/ui/assets/{pptx-nDW64jAN.js → pptx-B6uaM2s7.js} +3 -3
- package/dist/ui/assets/{run-export-86KzLZ7R.js → run-export-TscWwR6y.js} +2 -2
- package/dist/ui/assets/{standalone-source-7QdiNsDW.js → standalone-source-Cw9SF7Zk.js} +1 -1
- package/dist/ui/assets/storage-Cmhlwx70.js +1 -0
- package/dist/ui/assets/styles-BjDaWeMA.css +1 -0
- package/dist/ui/assets/styles-CqO-rmOt.js +554 -0
- package/dist/ui/assets/{terminal-monaco-setup-Bar-sYKd.js → terminal-monaco-setup-me523-j-.js} +1 -1
- package/dist/ui/assets/{transform-CmAXy0Ck.js → transform-DxJCwK68.js} +1 -1
- package/dist/ui/assets/{use-local-model-manager-D1yiurrC.js → use-local-model-manager-8wvk-I-y.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BDtPQcDh.js → useCompactLayout-cm4E9Vja.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BHOfHrfT.js → useCopilotAvailability-D9hglSH_.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-B0kYhlWQ.js → useDiffpacks-1BN2XJWg.js} +1 -1
- package/dist/ui/assets/{useGitSync-DOt-ODiw.js → useGitSync-7m9YA7h5.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-BtpredG7.js → useShowWorkInProgressFeatures-D6QOaTUT.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-B8NFM27w.js → useTotalRamBytes-Durk383U.js} +1 -1
- package/dist/ui/assets/{xlsx-B_pu1ZvY.js → xlsx-BbHA9bxA.js} +1 -1
- package/dist/ui/index.html +15 -15
- package/package.json +12 -11
- package/dist/ui/assets/CatalogBrowser-7_jHy5Q3.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Cg_kLK_U.js +0 -7
- package/dist/ui/assets/CraftbookEditor-BKAIsnXv.js +0 -1
- package/dist/ui/assets/DiffpackReviewView-B2a3zgE-.js +0 -1
- package/dist/ui/assets/DocumentDetail-GCYhwQqV.js +0 -1
- package/dist/ui/assets/DocumentsView-Cm3RaQ5N.js +0 -1
- package/dist/ui/assets/FileMapView-BKJovLcL.js +0 -1
- package/dist/ui/assets/FoldersSettings-CuJd2JdE.js +0 -1
- package/dist/ui/assets/GezelDetail-D_KIPDhQ.js +0 -1
- package/dist/ui/assets/GezellenView-BOOW1QQU.js +0 -1
- package/dist/ui/assets/HandboekView-gRzJcIbJ.js +0 -1
- package/dist/ui/assets/KnowledgeView-DJ3cJVHA.js +0 -1
- package/dist/ui/assets/MlxSettings-45mBFHbA.js +0 -1
- package/dist/ui/assets/NewTaskDialog-CIXVunZn.js +0 -2
- package/dist/ui/assets/ProjectChat-BiJRweob.js +0 -5
- package/dist/ui/assets/ProjectConnectionsTab-CQgaIzuv.js +0 -1
- package/dist/ui/assets/ProjectsView-BUdR76n6.js +0 -7
- package/dist/ui/assets/SessionSwitcher-BgZqyiRn.js +0 -1
- package/dist/ui/assets/SettingsView-DLhOYiR5.js +0 -3
- package/dist/ui/assets/TaskTabContent-CG2KmfwV.js +0 -1
- package/dist/ui/assets/TasksView-Dy5Ue4zS.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-J9XxQ5Ms.js +0 -8
- package/dist/ui/assets/chat-thread-memory-CI2-giEq.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-DEkyBlHg.js +0 -1
- package/dist/ui/assets/csv-B0D9jJG2.js +0 -1
- package/dist/ui/assets/data-BIL84EaT.js +0 -1
- package/dist/ui/assets/dist-CJqyWK6E.js +0 -2
- package/dist/ui/assets/dist-DOqbRmFj.js +0 -225
- package/dist/ui/assets/doc-C2Ph2FWI.js +0 -584
- package/dist/ui/assets/document-companion-aDThLOwl.js +0 -1
- package/dist/ui/assets/file-browser-DVyWN0LD.js +0 -5
- package/dist/ui/assets/icons-DWaUNQbT.js +0 -1
- package/dist/ui/assets/index-DDu8nyO6.js +0 -34
- package/dist/ui/assets/index-DEDUSiCx.css +0 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +0 -1
- package/dist/ui/assets/materialize-G4WC5UG3-BlZQe-88.js +0 -1
- package/dist/ui/assets/outside-in-BmIIeMid.js +0 -3
- package/dist/ui/assets/storage-B-vhjyV2.js +0 -1
- package/dist/ui/assets/styles-BvkZd-EV.js +0 -550
- package/dist/ui/assets/styles-IQ4adxWr.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,t}from"./chunk-O7JILDEF-CqcO1qaI.js";import{f as n,i as r}from"./chunk-BAOV476U-CEOFYt8X.js";import{i,n as a,t as o}from"./chunk-XRW6P7IF-BeQQgMVK.js";var s=[/\b(roughly |about |approximately |nearly |over |under |more than |less than )?([\d,]+(?:\.\d+)?)\s*%/gi,/\b([\d,]+(?:\.\d+)?)\s*(million|billion|trillion|thousand|hundred)\b/gi,/\b([\d,]+(?:\.\d+)?)\s*(miles?|feet|ft|meters?|m|kilometers?|km|acres?|square miles?|sq mi|hectares?)\b/gi,/\b([\d,]+(?:\.\d+)?)\s*(x|times)\b/gi,/\b([$€£¥])\s*([\d,]+(?:\.\d+)?)\s*(million|billion|thousand)?\b/gi,/\b(\d+)(st|nd|rd|th)\s+(largest|smallest|oldest|newest|most|least)/gi],c=[/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?(\d{4})\b/gi,/\b(\d{4})s\b|\b(\d{1,2})(st|nd|rd|th)\s+century\b/gi,/\b(from\s+)?(\d{4})\s*(to|–|-|through)\s*(\d{4})\b/gi,/\b(in|by|since|after|before|during)\s+(\d{4})\b/gi],l=[/"([^"]{15,200})"/g,/\u201c([^\u201d]{15,200})\u201d/g,/(\w+(?:\s+\w+)?)\s+(?:said|stated|wrote|noted|observed|commented),?\s*"([^"]+)"/gi],u=`[^.!?;\\r\\n]{2,30}`,d=[RegExp(`from\\s+(${u})\\s+to\\s+(${u})`,`gi`),RegExp(`(${u})\\s+(?:vs\\.?|versus)\\s+(${u})`,`gi`),RegExp(`(${u})\\s+compared\\s+to\\s+(${u})`,`gi`)],f=new Set(`mr.mrs.ms.dr.prof.st.mt.jr.sr.gen.col.capt.lt.sgt.rev.hon.sen.rep.gov.pres.vs.etc.inc.co.ltd.corp.al.fig.eg.ie.approx.dept.univ.assn.bros.ave.blvd.rd`.split(`.`)),p=`largest.smallest.oldest.newest.first.last.most.least.only.unique.rare.famous.important.significant.notable.remarkable.extraordinary.crucial.essential.critical.major.key.discovered.founded.established.created.built.invented.developed.introduced.pioneered.transformed.revolutionized.changed.shaped`.split(`.`),m=[`disaster`,`tragedy`,`death`,`died`,`killed`,`destroyed`,`devastated`,`collapsed`,`lost`,`abandoned`,`declined`,`war`,`battle`,`conflict`,`earthquake`,`fire`,`flood`],h=[`celebration`,`victory`,`success`,`achievement`,`triumph`,`opened`,`completed`,`inaugurated`,`launched`,`won`,`record`,`breakthrough`,`milestone`,`golden`,`grand`],g=[`check`,`watch`,`stop`,`prepare`,`imagine`,`consider`,`look`,`listen`,`notice`,`remember`,`discover`,`explore`,`visit`,`try`,`experience`,`avoid`,`beware`,`enjoy`],_=[/(?:including|such as|namely|like|features?|offers?)\s+([^.]{10,150})/gi,/(?:three|four|five|six|several|many|various)\s+(?:main|key|primary|notable|popular|important)?\s*\w+(?:\s+\w+)?:\s*([^.]{10,150})/gi],v=[/\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+is\s+(?:a|an|the)\s+([^.]{10,120})/g,/known\s+as\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),\s+([^.]{10,120})/gi,/\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+refers?\s+to\s+([^.]{10,120})/g,/called\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),?\s+(?:which|meaning|a)\s+([^.]{10,120})/gi];function y(e,t={}){let{minConfidence:n=.3,types:r=[`stat`,`date`,`quote`,`comparison`,`fact`,`impactLine`,`list`,`definition`],maxPerType:i}=t,a=[];r.includes(`stat`)&&a.push(...b(e)),r.includes(`date`)&&a.push(...x(e)),r.includes(`quote`)&&a.push(...S(e)),r.includes(`comparison`)&&a.push(...ee(e)),r.includes(`fact`)&&a.push(...te(e)),r.includes(`impactLine`)&&a.push(...ne(e)),r.includes(`list`)&&a.push(...re(e)),r.includes(`definition`)&&a.push(...ie(e));let o=a.filter(e=>e.confidence>=n);if(i!==void 0){let e=new Map;for(let t of o){let n=e.get(t.type)||[];n.push(t),e.set(t.type,n)}o=[];for(let[,t]of e)t.sort((e,t)=>t.confidence-e.confidence),o.push(...t.slice(0,i))}return o.sort((e,t)=>e.sourcePosition-t.sourcePosition),o=ue(o),{elements:o,sourceLength:e.length,stats:{statCount:o.filter(e=>e.type===`stat`).length,dateCount:o.filter(e=>e.type===`date`).length,quoteCount:o.filter(e=>e.type===`quote`).length,comparisonCount:o.filter(e=>e.type===`comparison`).length,factCount:o.filter(e=>e.type===`fact`).length,impactLineCount:o.filter(e=>e.type===`impactLine`).length,listCount:o.filter(e=>e.type===`list`).length,definitionCount:o.filter(e=>e.type===`definition`).length,totalCount:o.length}}}function b(e){let t=[],n=new Set;for(let r of s){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=T(e,r,i[0].length),o=i[0].trim();t.push({type:`stat`,text:a.sentence,confidence:ae(o,a.sentence),sourcePosition:a.start,endPosition:a.end,data:{type:`stat`,value:o,description:E(a.sentence,o)}})}}return t}function x(e){let t=[],n=new Set;for(let r of c){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=T(e,r,i[0].length),o=i[0].trim();t.push({type:`date`,text:a.sentence,confidence:oe(o,a.sentence),sourcePosition:a.start,endPosition:a.end,data:{type:`date`,date:o,description:E(a.sentence,o),mood:le(a.sentence)}})}}return t}function S(e){let t=[],n=new Set;for(let r of l){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let e=i.index;if(n.has(e))continue;n.add(e);let r=i.length>2?i[2]:i[1],a=i.length>2?i[1]:void 0;r.length<15||r.length>200||t.push({type:`quote`,text:i[0],confidence:se(r),sourcePosition:e,endPosition:e+i[0].length,data:{type:`quote`,quote:r.trim(),attribution:a?.trim()}})}}return t}function ee(e){let t=[],n=new Set;for(let r of d){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=e=>e.replace(/,\s+.*$/,``).trim(),o=a(i[1].trim()),s=a(i[2].trim());if(o.length<2||o.length>30||s.length<2||s.length>30)continue;let c=e=>e.toLowerCase().split(/\s+/).map(e=>e.replace(/[^a-z0-9]+/g,``)).filter(Boolean),l=c(o),u=c(s);if(l.length>0&&u.length>0&&l[l.length-1]===u[0])continue;let d=T(e,r,i[0].length);t.push({type:`comparison`,text:d.sentence,confidence:.6,sourcePosition:d.start,endPosition:d.end,data:{type:`comparison`,left:{label:o},right:{label:s}}})}}return t}function C(e,t){let n=e[t];if(n===`!`||n===`?`)return!0;if(n!==`.`||e[t+1]===`.`||/[0-9]/.test(e[t-1]??``)&&/[0-9]/.test(e[t+1]??``))return!1;let r=t-1;for(;r>=0&&/[A-Za-z]/.test(e[r]);)r--;let i=e.slice(r+1,t);if(i.length===1||i&&f.has(i.toLowerCase()))return!1;let a=t+1;for(;a<e.length&&/\s/.test(e[a]);)a++;return a>=e.length||!/[a-z]/.test(e[a])}function w(e,t){let n=(n,r)=>{let i=n;for(;i<r&&/\s/.test(e[i]);)i++;let a=r;for(;a>i&&/[\s.!?]/.test(e[a-1]);)a--;if(a<=i)return;let o=e.slice(i,a);o&&t(o,i,a)},r=0,i=0;for(;i<e.length;)if(C(e,i)){let t=i+1;for(;t<e.length&&/[.!?]/.test(e[t]);)t++;n(r,t),r=t,i=t}else i++;r<e.length&&n(r,e.length)}function te(e){let t=[];return w(e,(e,n,r)=>{if(e.length<=20)return;let i=ce(e);i<.4||t.push({type:`fact`,text:e,confidence:i,sourcePosition:n,endPosition:r,data:{type:`fact`,fact:e}})}),t}function ne(e){let t=[];return w(e,(n,r,i)=>{if(n.length<8||n.length>60)return;let a=.3,o=n.toLowerCase();for(let e of g)if(o.startsWith(e)){a+=.25;break}i<e.length&&e[i]===`!`&&(a+=.15),n.length<30&&(a+=.1),n.includes(`,`)&&(a-=.1),/^(and|but|or|the|a|an)\b/i.test(n)&&(a-=.15),!(a<.5)&&t.push({type:`impactLine`,text:n,confidence:Math.min(1,a),sourcePosition:r,endPosition:i,data:{type:`impactLine`,text:n}})}),t}function re(e){let t=[],n=new Set;for(let r of _){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=i[1].trim().split(/,\s*(?:and|or)\s+|,\s+|\s+and\s+|\s+or\s+/).map(e=>e.trim()).filter(e=>e.length>=2&&e.length<=60);if(a.length<3||a.length>5)continue;let o=T(e,r,i[0].length);t.push({type:`list`,text:o.sentence,confidence:.65,sourcePosition:o.start,endPosition:o.end,data:{type:`list`,items:a}})}}return t}function ie(e){let t=[],n=new Set;for(let r of v){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=i[1].trim(),o=i[2].trim();if(a.length<3||a.length>30||o.length<10||o.length>120)continue;let s=T(e,r,i[0].length);t.push({type:`definition`,text:s.sentence,confidence:.6,sourcePosition:s.start,endPosition:s.end,data:{type:`definition`,term:a,definition:o}})}}return t}function T(e,t,n){let r=t;for(;r>0&&!C(e,r-1);)r--;for(;r<t&&/\s/.test(e[r]);)r++;let i=t+n;for(;i<e.length&&!C(e,i);)i++;return i<e.length&&i++,{sentence:e.slice(r,i).trim(),start:r,end:i}}function ae(e,t){let n=.5;return e.includes(`%`)&&(n+=.2),/million|billion|trillion/i.test(e)&&(n+=.15),/increased|decreased|grew|dropped|rose|fell/i.test(t)&&(n+=.15),t.length<30&&(n-=.2),Math.min(1,Math.max(0,n))}function oe(e,t){let n=.5;return/January|February|March|April|May|June|July|August|September|October|November|December/i.test(e)&&(n+=.2),/founded|established|built|opened|discovered|created/i.test(t)&&(n+=.2),/happened|occurred|took place|began|ended/i.test(t)&&(n+=.15),Math.min(1,Math.max(0,n))}function se(e){let t=.5;return e.length>=30&&e.length<=150&&(t+=.2),/\b(I|we|our|my)\b/i.test(e)&&(t+=.1),/[.!?]$/.test(e)||(t-=.1),Math.min(1,Math.max(0,t))}function ce(e){let t=.3,n=e.toLowerCase();for(let e of p)if(n.includes(e)){t+=.1;break}let r=e.match(/\b[A-Z][a-z]+\b/g);return r&&r.length>=2&&(t+=.15),/\d/.test(e)&&(t+=.1),e.endsWith(`?`)&&(t-=.3),e.length>200&&(t-=.15),Math.min(1,Math.max(0,t))}function le(e){let t=e.toLowerCase();for(let e of m)if(t.includes(e))return`somber`;for(let e of h)if(t.includes(e))return`celebratory`;return`neutral`}function E(e,t){let n=[RegExp(`\\b[Ii]n\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Oo]n\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Dd]uring\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Bb]y\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Ss]ince\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Ff]rom\\s+${D(t)}[,.]?\\s*`,`g`)],r=e;for(let e of n)r=r.replace(e,``);return r===e&&(r=e.replace(t,``).trim()),r=r.replace(/^[,:\-–—]+\s*/,``).replace(/\s*[,:\-–—]+$/,``),r=r.replace(/\s+(?:of|on|in|at|by|to|for|from|with|about|over|under|between|than|into|onto|upon)\s*([,.])/gi,`$1`),r=r.replace(/\s+(?:for|of|to|in|at|by|with|from|about|over|under|between|than|into|onto|upon)\s*[.!?]?\s*$/i,`.`),r=r.replace(/\s{2,}/g,` `).replace(/\s+([,.])/g,`$1`),r=r.charAt(0).toUpperCase()+r.slice(1),r.trim()}function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var O={stat:5,date:4,quote:3,definition:3,comparison:2,list:2,impactLine:2,fact:1};function ue(e){if(e.length<=1)return e;let t=new Set;for(let n=0;n<e.length;n++){if(t.has(n))continue;let r=e[n];for(let i=n+1;i<e.length;i++){if(t.has(i))continue;let a=e[i];if(de(r,a))if(O[r.type]>=O[a.type])t.add(i);else{t.add(n);break}}}return e.filter((e,n)=>!t.has(n))}function de(e,t){if(e.sourcePosition===t.sourcePosition||e.sourcePosition<=t.sourcePosition&&e.endPosition>=t.endPosition||t.sourcePosition<=e.sourcePosition&&t.endPosition>=e.endPosition)return!0;let n=Math.max(e.sourcePosition,t.sourcePosition),r=Math.min(e.endPosition,t.endPosition);return r>n&&r-n>Math.min(e.endPosition-e.sourcePosition,t.endPosition-t.sourcePosition)*.5}function fe(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[([^\]]*)\]\([^)]+\)/g,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/\*([^*]+)\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/_([^_]+)_/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^>\s+/gm,``).replace(/^[-*_]{3,}$/gm,``).replace(/\n{3,}/g,`
|
|
1
|
+
import{i as e,t}from"./chunk-X7BNDUNI-D14WIvlD.js";import{f as n,i as r}from"./chunk-BAOV476U-CEOFYt8X.js";import{i,n as a,t as o}from"./chunk-XRW6P7IF-BeQQgMVK.js";var s=[/\b(roughly |about |approximately |nearly |over |under |more than |less than )?([\d,]+(?:\.\d+)?)\s*%/gi,/\b([\d,]+(?:\.\d+)?)\s*(million|billion|trillion|thousand|hundred)\b/gi,/\b([\d,]+(?:\.\d+)?)\s*(miles?|feet|ft|meters?|m|kilometers?|km|acres?|square miles?|sq mi|hectares?)\b/gi,/\b([\d,]+(?:\.\d+)?)\s*(x|times)\b/gi,/\b([$€£¥])\s*([\d,]+(?:\.\d+)?)\s*(million|billion|thousand)?\b/gi,/\b(\d+)(st|nd|rd|th)\s+(largest|smallest|oldest|newest|most|least)/gi],c=[/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?(\d{4})\b/gi,/\b(\d{4})s\b|\b(\d{1,2})(st|nd|rd|th)\s+century\b/gi,/\b(from\s+)?(\d{4})\s*(to|–|-|through)\s*(\d{4})\b/gi,/\b(in|by|since|after|before|during)\s+(\d{4})\b/gi],l=[/"([^"]{15,200})"/g,/\u201c([^\u201d]{15,200})\u201d/g,/(\w+(?:\s+\w+)?)\s+(?:said|stated|wrote|noted|observed|commented),?\s*"([^"]+)"/gi],u=`[^.!?;\\r\\n]{2,30}`,d=[RegExp(`from\\s+(${u})\\s+to\\s+(${u})`,`gi`),RegExp(`(${u})\\s+(?:vs\\.?|versus)\\s+(${u})`,`gi`),RegExp(`(${u})\\s+compared\\s+to\\s+(${u})`,`gi`)],f=new Set(`mr.mrs.ms.dr.prof.st.mt.jr.sr.gen.col.capt.lt.sgt.rev.hon.sen.rep.gov.pres.vs.etc.inc.co.ltd.corp.al.fig.eg.ie.approx.dept.univ.assn.bros.ave.blvd.rd`.split(`.`)),p=`largest.smallest.oldest.newest.first.last.most.least.only.unique.rare.famous.important.significant.notable.remarkable.extraordinary.crucial.essential.critical.major.key.discovered.founded.established.created.built.invented.developed.introduced.pioneered.transformed.revolutionized.changed.shaped`.split(`.`),m=[`disaster`,`tragedy`,`death`,`died`,`killed`,`destroyed`,`devastated`,`collapsed`,`lost`,`abandoned`,`declined`,`war`,`battle`,`conflict`,`earthquake`,`fire`,`flood`],h=[`celebration`,`victory`,`success`,`achievement`,`triumph`,`opened`,`completed`,`inaugurated`,`launched`,`won`,`record`,`breakthrough`,`milestone`,`golden`,`grand`],g=[`check`,`watch`,`stop`,`prepare`,`imagine`,`consider`,`look`,`listen`,`notice`,`remember`,`discover`,`explore`,`visit`,`try`,`experience`,`avoid`,`beware`,`enjoy`],_=[/(?:including|such as|namely|like|features?|offers?)\s+([^.]{10,150})/gi,/(?:three|four|five|six|several|many|various)\s+(?:main|key|primary|notable|popular|important)?\s*\w+(?:\s+\w+)?:\s*([^.]{10,150})/gi],v=[/\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+is\s+(?:a|an|the)\s+([^.]{10,120})/g,/known\s+as\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),\s+([^.]{10,120})/gi,/\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+refers?\s+to\s+([^.]{10,120})/g,/called\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),?\s+(?:which|meaning|a)\s+([^.]{10,120})/gi];function y(e,t={}){let{minConfidence:n=.3,types:r=[`stat`,`date`,`quote`,`comparison`,`fact`,`impactLine`,`list`,`definition`],maxPerType:i}=t,a=[];r.includes(`stat`)&&a.push(...b(e)),r.includes(`date`)&&a.push(...x(e)),r.includes(`quote`)&&a.push(...S(e)),r.includes(`comparison`)&&a.push(...ee(e)),r.includes(`fact`)&&a.push(...te(e)),r.includes(`impactLine`)&&a.push(...ne(e)),r.includes(`list`)&&a.push(...re(e)),r.includes(`definition`)&&a.push(...ie(e));let o=a.filter(e=>e.confidence>=n);if(i!==void 0){let e=new Map;for(let t of o){let n=e.get(t.type)||[];n.push(t),e.set(t.type,n)}o=[];for(let[,t]of e)t.sort((e,t)=>t.confidence-e.confidence),o.push(...t.slice(0,i))}return o.sort((e,t)=>e.sourcePosition-t.sourcePosition),o=ue(o),{elements:o,sourceLength:e.length,stats:{statCount:o.filter(e=>e.type===`stat`).length,dateCount:o.filter(e=>e.type===`date`).length,quoteCount:o.filter(e=>e.type===`quote`).length,comparisonCount:o.filter(e=>e.type===`comparison`).length,factCount:o.filter(e=>e.type===`fact`).length,impactLineCount:o.filter(e=>e.type===`impactLine`).length,listCount:o.filter(e=>e.type===`list`).length,definitionCount:o.filter(e=>e.type===`definition`).length,totalCount:o.length}}}function b(e){let t=[],n=new Set;for(let r of s){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=T(e,r,i[0].length),o=i[0].trim();t.push({type:`stat`,text:a.sentence,confidence:ae(o,a.sentence),sourcePosition:a.start,endPosition:a.end,data:{type:`stat`,value:o,description:E(a.sentence,o)}})}}return t}function x(e){let t=[],n=new Set;for(let r of c){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=T(e,r,i[0].length),o=i[0].trim();t.push({type:`date`,text:a.sentence,confidence:oe(o,a.sentence),sourcePosition:a.start,endPosition:a.end,data:{type:`date`,date:o,description:E(a.sentence,o),mood:le(a.sentence)}})}}return t}function S(e){let t=[],n=new Set;for(let r of l){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let e=i.index;if(n.has(e))continue;n.add(e);let r=i.length>2?i[2]:i[1],a=i.length>2?i[1]:void 0;r.length<15||r.length>200||t.push({type:`quote`,text:i[0],confidence:se(r),sourcePosition:e,endPosition:e+i[0].length,data:{type:`quote`,quote:r.trim(),attribution:a?.trim()}})}}return t}function ee(e){let t=[],n=new Set;for(let r of d){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=e=>e.replace(/,\s+.*$/,``).trim(),o=a(i[1].trim()),s=a(i[2].trim());if(o.length<2||o.length>30||s.length<2||s.length>30)continue;let c=e=>e.toLowerCase().split(/\s+/).map(e=>e.replace(/[^a-z0-9]+/g,``)).filter(Boolean),l=c(o),u=c(s);if(l.length>0&&u.length>0&&l[l.length-1]===u[0])continue;let d=T(e,r,i[0].length);t.push({type:`comparison`,text:d.sentence,confidence:.6,sourcePosition:d.start,endPosition:d.end,data:{type:`comparison`,left:{label:o},right:{label:s}}})}}return t}function C(e,t){let n=e[t];if(n===`!`||n===`?`)return!0;if(n!==`.`||e[t+1]===`.`||/[0-9]/.test(e[t-1]??``)&&/[0-9]/.test(e[t+1]??``))return!1;let r=t-1;for(;r>=0&&/[A-Za-z]/.test(e[r]);)r--;let i=e.slice(r+1,t);if(i.length===1||i&&f.has(i.toLowerCase()))return!1;let a=t+1;for(;a<e.length&&/\s/.test(e[a]);)a++;return a>=e.length||!/[a-z]/.test(e[a])}function w(e,t){let n=(n,r)=>{let i=n;for(;i<r&&/\s/.test(e[i]);)i++;let a=r;for(;a>i&&/[\s.!?]/.test(e[a-1]);)a--;if(a<=i)return;let o=e.slice(i,a);o&&t(o,i,a)},r=0,i=0;for(;i<e.length;)if(C(e,i)){let t=i+1;for(;t<e.length&&/[.!?]/.test(e[t]);)t++;n(r,t),r=t,i=t}else i++;r<e.length&&n(r,e.length)}function te(e){let t=[];return w(e,(e,n,r)=>{if(e.length<=20)return;let i=ce(e);i<.4||t.push({type:`fact`,text:e,confidence:i,sourcePosition:n,endPosition:r,data:{type:`fact`,fact:e}})}),t}function ne(e){let t=[];return w(e,(n,r,i)=>{if(n.length<8||n.length>60)return;let a=.3,o=n.toLowerCase();for(let e of g)if(o.startsWith(e)){a+=.25;break}i<e.length&&e[i]===`!`&&(a+=.15),n.length<30&&(a+=.1),n.includes(`,`)&&(a-=.1),/^(and|but|or|the|a|an)\b/i.test(n)&&(a-=.15),!(a<.5)&&t.push({type:`impactLine`,text:n,confidence:Math.min(1,a),sourcePosition:r,endPosition:i,data:{type:`impactLine`,text:n}})}),t}function re(e){let t=[],n=new Set;for(let r of _){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=i[1].trim().split(/,\s*(?:and|or)\s+|,\s+|\s+and\s+|\s+or\s+/).map(e=>e.trim()).filter(e=>e.length>=2&&e.length<=60);if(a.length<3||a.length>5)continue;let o=T(e,r,i[0].length);t.push({type:`list`,text:o.sentence,confidence:.65,sourcePosition:o.start,endPosition:o.end,data:{type:`list`,items:a}})}}return t}function ie(e){let t=[],n=new Set;for(let r of v){r.lastIndex=0;let i;for(;(i=r.exec(e))!==null;){let r=i.index;if(n.has(r))continue;n.add(r);let a=i[1].trim(),o=i[2].trim();if(a.length<3||a.length>30||o.length<10||o.length>120)continue;let s=T(e,r,i[0].length);t.push({type:`definition`,text:s.sentence,confidence:.6,sourcePosition:s.start,endPosition:s.end,data:{type:`definition`,term:a,definition:o}})}}return t}function T(e,t,n){let r=t;for(;r>0&&!C(e,r-1);)r--;for(;r<t&&/\s/.test(e[r]);)r++;let i=t+n;for(;i<e.length&&!C(e,i);)i++;return i<e.length&&i++,{sentence:e.slice(r,i).trim(),start:r,end:i}}function ae(e,t){let n=.5;return e.includes(`%`)&&(n+=.2),/million|billion|trillion/i.test(e)&&(n+=.15),/increased|decreased|grew|dropped|rose|fell/i.test(t)&&(n+=.15),t.length<30&&(n-=.2),Math.min(1,Math.max(0,n))}function oe(e,t){let n=.5;return/January|February|March|April|May|June|July|August|September|October|November|December/i.test(e)&&(n+=.2),/founded|established|built|opened|discovered|created/i.test(t)&&(n+=.2),/happened|occurred|took place|began|ended/i.test(t)&&(n+=.15),Math.min(1,Math.max(0,n))}function se(e){let t=.5;return e.length>=30&&e.length<=150&&(t+=.2),/\b(I|we|our|my)\b/i.test(e)&&(t+=.1),/[.!?]$/.test(e)||(t-=.1),Math.min(1,Math.max(0,t))}function ce(e){let t=.3,n=e.toLowerCase();for(let e of p)if(n.includes(e)){t+=.1;break}let r=e.match(/\b[A-Z][a-z]+\b/g);return r&&r.length>=2&&(t+=.15),/\d/.test(e)&&(t+=.1),e.endsWith(`?`)&&(t-=.3),e.length>200&&(t-=.15),Math.min(1,Math.max(0,t))}function le(e){let t=e.toLowerCase();for(let e of m)if(t.includes(e))return`somber`;for(let e of h)if(t.includes(e))return`celebratory`;return`neutral`}function E(e,t){let n=[RegExp(`\\b[Ii]n\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Oo]n\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Dd]uring\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Bb]y\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Ss]ince\\s+${D(t)}[,.]?\\s*`,`g`),RegExp(`\\b[Ff]rom\\s+${D(t)}[,.]?\\s*`,`g`)],r=e;for(let e of n)r=r.replace(e,``);return r===e&&(r=e.replace(t,``).trim()),r=r.replace(/^[,:\-–—]+\s*/,``).replace(/\s*[,:\-–—]+$/,``),r=r.replace(/\s+(?:of|on|in|at|by|to|for|from|with|about|over|under|between|than|into|onto|upon)\s*([,.])/gi,`$1`),r=r.replace(/\s+(?:for|of|to|in|at|by|with|from|about|over|under|between|than|into|onto|upon)\s*[.!?]?\s*$/i,`.`),r=r.replace(/\s{2,}/g,` `).replace(/\s+([,.])/g,`$1`),r=r.charAt(0).toUpperCase()+r.slice(1),r.trim()}function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var O={stat:5,date:4,quote:3,definition:3,comparison:2,list:2,impactLine:2,fact:1};function ue(e){if(e.length<=1)return e;let t=new Set;for(let n=0;n<e.length;n++){if(t.has(n))continue;let r=e[n];for(let i=n+1;i<e.length;i++){if(t.has(i))continue;let a=e[i];if(de(r,a))if(O[r.type]>=O[a.type])t.add(i);else{t.add(n);break}}}return e.filter((e,n)=>!t.has(n))}function de(e,t){if(e.sourcePosition===t.sourcePosition||e.sourcePosition<=t.sourcePosition&&e.endPosition>=t.endPosition||t.sourcePosition<=e.sourcePosition&&t.endPosition>=e.endPosition)return!0;let n=Math.max(e.sourcePosition,t.sourcePosition),r=Math.min(e.endPosition,t.endPosition);return r>n&&r-n>Math.min(e.endPosition-e.sourcePosition,t.endPosition-t.sourcePosition)*.5}function fe(e){return e.replace(/```[\s\S]*?```/g,``).replace(/!\[([^\]]*)\]\([^)]+\)/g,``).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/\*([^*]+)\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/_([^_]+)_/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^>\s+/gm,``).replace(/^[-*_]{3,}$/gm,``).replace(/\n{3,}/g,`
|
|
2
2
|
|
|
3
3
|
`).trim()}function pe(e,t){let n={id:t.id,duration:t.duration,audioSegment:t.audioSegment,sourceStartTime:t.sourceStartTime,sourceDuration:t.sourceDuration,sourceBlockId:t.sourceBlockId,sourceCharOffset:t.sourceCharOffset};switch(e.data.type){case`stat`:return me(e.data,n,t);case`date`:return he(e.data,n,t);case`quote`:return ge(e.data,n,t);case`comparison`:return _e(e.data,n,t);case`fact`:return ve(e.data,n,t);case`impactLine`:return ye(e.data,n,t);case`list`:return be(e.data,n,t);case`definition`:return xe(e.data,n,t)}}function me(e,t,n){return{...t,template:`statHighlight`,stat:e.value,description:e.description,colorScheme:n.colorScheme,accentImage:n.accentImage}}function he(e,t,n){return{...t,template:`dateEvent`,date:e.date,description:e.description,mood:e.mood,accentImage:n.accentImage}}function ge(e,t,n){return{...t,template:`quote`,quote:e.quote,attribution:e.attribution,accentImage:n.accentImage}}function _e(e,t,n){return{...t,template:`twoColumn`,left:e.left,right:e.right,header:e.header,leftColor:n.colorScheme}}function ve(e,t,n){return{...t,template:`factCard`,fact:e.fact,explanation:e.explanation??``,accentImage:n.accentImage}}function ye(e,t,n){return{...t,template:`fullBleedQuote`,text:e.text,colorScheme:n.colorScheme}}function be(e,t,n){return{...t,template:`list`,items:e.items,title:e.title,colorScheme:n.colorScheme,accentImage:n.accentImage}}function xe(e,t,n){return{...t,template:`definitionCard`,term:e.term,definition:e.definition,origin:e.origin,colorScheme:n.colorScheme,accentImage:n.accentImage}}var k={id:`documentary`,name:`Documentary`,description:`Conservative — highlights only the strongest stats, dates, and quotes`,minConfidence:.5,transformRatio:.3,preferredTypes:[`stat`,`date`,`quote`,`fact`],colorSchemes:[`blue`,`green`,`purple`],insertSectionHeaders:!1,interleaveImages:!0,blocksPerSection:{max:3},transitionStyle:`fade`,suggestedThemeId:`documentary`,page:{spacing:`generous`,emphasisCurve:`front-loaded`}},A={id:`magazine`,name:`Magazine`,description:`Visual variety with pull quotes, facts, and rich image layouts`,minConfidence:.4,transformRatio:.6,preferredTypes:[`quote`,`fact`,`list`,`definition`,`stat`,`impactLine`],colorSchemes:[`blue`,`green`,`purple`,`orange`,`red`],insertSectionHeaders:!0,interleaveImages:!0,blocksPerSection:{max:5},transitionStyle:`dissolve`,suggestedThemeId:`magazine`,templateMap:{quote:`pullQuote`,impactLine:`fullBleedQuote`},page:{spacing:`comfortable`,emphasisCurve:`front-loaded`}},j={id:`data-driven`,name:`Data-Driven`,description:`Aggressively highlights statistics, comparisons, and timelines`,minConfidence:.3,transformRatio:.8,preferredTypes:[`stat`,`comparison`,`date`,`list`,`fact`],colorSchemes:[`blue`,`orange`,`green`,`purple`,`red`],insertSectionHeaders:!0,interleaveImages:!1,blocksPerSection:{max:6},transitionStyle:`cut`,suggestedThemeId:`tech-dark`,page:{spacing:`compact`,emphasisCurve:`even`}},M={id:`narrative`,name:`Narrative`,description:`Story-driven with timeline events, quotes, and impact moments`,minConfidence:.4,transformRatio:.5,preferredTypes:[`date`,`quote`,`impactLine`,`fact`,`stat`],colorSchemes:[`blue`,`purple`,`green`],insertSectionHeaders:!0,interleaveImages:!0,blocksPerSection:{max:4},transitionStyle:`fade`,suggestedThemeId:`cinematic`,pacing:{intro:!0,outro:!0},page:{spacing:`comfortable`,emphasisCurve:`even`}},N={id:`minimal`,name:`Minimal`,description:`Light touch — only the strongest highlights, mostly text`,minConfidence:.6,transformRatio:.2,preferredTypes:[`stat`,`quote`],colorSchemes:[`blue`,`green`],insertSectionHeaders:!1,interleaveImages:!1,blocksPerSection:{max:2},transitionStyle:`fade`,suggestedThemeId:`minimalist`,page:{spacing:`generous`,emphasisCurve:`even`}},P=Object.freeze({[k.id]:r(k),[A.id]:r(A),[j.id]:r(j),[M.id]:r(M),[N.id]:r(N)}),Se=`documentary`,F=new Set([`stat`,`date`,`quote`,`comparison`,`fact`,`impactLine`,`list`,`definition`]),Ce=new Set([`cut`,`fade`,`dissolve`,`mixed`]);function we(e){let t=e,n=e=>{throw TypeError(`Invalid transform style: ${e}`)};for(let e of[`id`,`name`,`description`])(typeof t[e]!=`string`||!t[e].trim())&&n(`${e} must be a non-empty string`);for(let e of[`minConfidence`,`transformRatio`]){let r=t[e];(typeof r!=`number`||!Number.isFinite(r)||r<0||r>1)&&n(`${e} must be a finite number between 0 and 1`)}(!Array.isArray(t.preferredTypes)||t.preferredTypes.some(e=>!F.has(e)))&&n(`preferredTypes contains an unknown extraction type`),(!Array.isArray(t.colorSchemes)||t.colorSchemes.length===0||t.colorSchemes.some(e=>typeof e!=`string`||!e))&&n(`colorSchemes must contain at least one non-empty string`);for(let e of[`insertSectionHeaders`,`interleaveImages`])typeof t[e]!=`boolean`&&n(`${e} must be a boolean`);let r=t.blocksPerSection;(!r||!Number.isInteger(r.max)||r.max<1)&&n(`blocksPerSection.max must be a positive integer`),(typeof t.transitionStyle!=`string`||!Ce.has(t.transitionStyle))&&n(`transitionStyle must be cut, fade, dissolve, or mixed`);let i=t.templateMap;if(i!==void 0){(!i||typeof i!=`object`||Array.isArray(i))&&n(`templateMap must be an object`);for(let[e,t]of Object.entries(i))(!F.has(e)||typeof t!=`string`||!t)&&n(`templateMap must map known extraction types to non-empty template names`)}t.suggestedThemeId!==void 0&&(typeof t.suggestedThemeId!=`string`||!t.suggestedThemeId)&&n(`suggestedThemeId must be a non-empty string`);let a=t.pacing;if(a!==void 0){(!a||typeof a!=`object`||Array.isArray(a))&&n(`pacing must be an object`);let e=a;for(let t of[`intro`,`outro`])e[t]!==void 0&&typeof e[t]!=`boolean`&&n(`pacing.${t} must be a boolean`)}let o=t.budget;if(t.budget!==void 0&&(!o||typeof o!=`object`||Array.isArray(o))&&n(`budget must be an object`),o&&o.slidesPerMinute!==void 0){let e=o.slidesPerMinute;(typeof e!=`number`||!Number.isFinite(e)||e<=0)&&n(`budget.slidesPerMinute must be a positive finite number`)}let s=t.page;if(s!==void 0){(!s||typeof s!=`object`||Array.isArray(s))&&n(`page must be an object`);let e=s;e.spacing!==void 0&&![`compact`,`comfortable`,`generous`].includes(e.spacing)&&n(`page.spacing must be compact, comfortable, or generous`),e.emphasisCurve!==void 0&&![`even`,`front-loaded`].includes(e.emphasisCurve)&&n(`page.emphasisCurve must be even or front-loaded`)}}function I(e){return we(e),r(e)}function Te(e){return e===`dataDriven`?`data-driven`:e}function Ee(e){return P[Te(e)]??P.documentary}function De(e=[]){let t=new Map,n={register(e){let n=I(e);t.set(n.id,n)},unregister(e){return t.delete(e)},get(e){return t.get(e)},list(){return Array.from(t.values())}};for(let t of e)n.register(t);return Object.freeze(n)}function L(e,t){return typeof e==`string`?t?.get(e)??Ee(e):I(e)}function R(e){return Array.from(new Set([...Object.keys(P),...e?.list().map(e=>e.id)??[]]))}function Oe(e){return R(e).map(t=>{let{name:n,description:r}=L(t,e);return{id:t,name:n,description:r}})}function z(e){return e.map(e=>t(e)).join(`
|
|
4
4
|
`)}function B(t){let n=[];if(`type`in t&&t.type===`image`&&`url`in t){let e=t;e.url&&n.push({src:e.url,alt:e.alt??``})}for(let r of e(t))n.push(...B(r));return n}function ke(e,t){if(!e.contents||e.contents.length===0)return[];let n=[];for(let r of e.contents)for(let e of B(r))n.push({...e,sourceBlockIndex:t});return n}function V(e){let t=new Set,n=[];function r(e){for(let i of e){if(i.contents)for(let e of i.contents)for(let r of B(e))t.has(r.src)||(t.add(r.src),n.push({src:r.src,alt:r.alt}));i.children&&r(i.children)}}return r(e),n}function H(e){let t=[];for(let n of e)n.children&&n.children.length>0?((!n.contents||n.contents.length===0)&&t.push(n),t.push(...H(n.children))):t.push(n);return t}function U(e,t){let n=H(e),r=[];for(let e of n){let n=``;e.contents&&e.contents.length>0?n=z(e.contents):e.title&&(n=e.title);let i=fe(n),a=i.split(/\s+/).filter(e=>e.length>0).length,o=y(i,t),s=ke(e,r.length);r.push({block:e,plainText:i,extractions:o.elements,hasChildren:!!(e.children&&e.children.length>0),bodyWordCount:a,images:s})}return r}var W=[`left-strip`,`right-strip`,`bottom-strip`,`corner-inset`],G=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`];function Ae(e,t,n,r){let i=new o(r),a=je(e,t),s=Math.max(1,Math.floor(e.length*t.transformRatio)),c=t.budget?.slidesPerMinute,l=e.reduce((e,t)=>e+(t.block.duration||0),0),u=c&&l>0?Math.max(1,Math.round(l/60*c)):1/0,d=Math.min(s,u);return Me(e,a.slice(0,d),t,n,i)}function je(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i.bodyWordCount<5))for(let e of i.extractions)e.confidence<t.minConfidence||n.push({element:e,sourceBlock:i.block,sourceIndex:r})}let r=new Map(t.preferredTypes.map((e,t)=>[e,t])),i=t.preferredTypes.length;n.sort((e,t)=>{let n=r.get(e.element.type)??i,a=r.get(t.element.type)??i;return n===a?t.element.confidence-e.element.confidence:n-a});let a=new Set,o=[];for(let e of n){let t=e.element.text.trim().toLowerCase();a.has(t)||(a.add(t),o.push(e))}return o}function Me(e,t,n,r,a){let o=new Map;for(let e of t){let t=o.get(e.sourceIndex)??[];t.push(e),o.set(e.sourceIndex,t)}for(let[e,t]of o){let r=[],i=new Set;for(let e of t)if(!i.has(e.element.type)&&(i.add(e.element.type),r.push(e),r.length>=n.blocksPerSection.max))break;o.set(e,r)}let s=[],c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=``,g=Array.from(o.values()).reduce((e,t)=>e+t.length,0),_=n.interleaveImages&&r.length>0&&g>0?Math.max(2,Math.floor(g/(r.length+1))):1/0;for(let t=0;t<e.length;t++){let g=e[t],v=o.get(t);if(!v||v.length===0){s.push(g.block);continue}if(n.insertSectionHeaders&&g.block.title){let e={template:`sectionHeader`,id:`transform-header-${d++}`,duration:g.block.duration>0?Math.min(3,g.block.duration*.2):3,audioSegment:g.block.audioSegment,title:g.block.title,colorScheme:n.colorSchemes[u%n.colorSchemes.length],sourceBlockId:g.block.id};s.push(e),l++}for(let e of v){let t=n.colorSchemes[u%n.colorSchemes.length],o;if(r.length>0&&n.interleaveImages){let e=r[f%r.length];o={src:e.src,alt:e.alt??``,position:W[p%W.length],ambientMotion:a.pick(G)??`zoomIn`,credit:e.credit,license:e.license},p++}let y=g.block.duration>0?g.block.duration/v.length:6,b=g.block.duration>0?i(g.plainText,e.element.sourcePosition,g.block.duration):0,x=pe(e.element,{id:`transform-${d++}`,duration:y,audioSegment:g.block.audioSegment,colorScheme:t,accentImage:o,sourceStartTime:g.block.startTime+b,sourceDuration:y,sourceBlockId:g.block.id,sourceCharOffset:e.element.sourcePosition}),S=n.templateMap?.[e.element.data.type];if(S&&S!==x.template){let e=Ne(x,S);e&&(x=e)}if(n.transitionStyle!==`cut`){let e=n.transitionStyle===`mixed`?a.pick([`fade`,`dissolve`])??`fade`:n.transitionStyle;x.transition={type:e,duration:.5}}if(x.template===h&&u++,h=x.template,s.push(x),c++,u++,m++,n.interleaveImages&&f<r.length&&m>=_){let e=r[f],t={template:`imageWithCaption`,id:`transform-img-${d++}`,duration:4,audioSegment:g.block.audioSegment,imageSrc:e.src,imageAlt:e.alt??``,ambientMotion:a.pick(G)??`zoomIn`,sourceBlockId:g.block.id};s.push(t),f++,l++,m=0}}}return{blocks:s,transformedCount:c,insertedCount:l}}function Ne(e,t){let n={id:e.id,duration:e.duration,audioSegment:e.audioSegment,sourceStartTime:e.sourceStartTime,sourceDuration:e.sourceDuration,sourceBlockId:e.sourceBlockId,sourceCharOffset:e.sourceCharOffset};if(e.template===`quote`){let r=e;if(t===`fullBleedQuote`)return{...n,template:`fullBleedQuote`,text:r.quote};if(t===`pullQuote`){let e=r.accentImage;return e?{...n,template:`pullQuote`,text:r.quote,attribution:r.attribution,backgroundImage:{src:e.src,alt:e.alt,credit:e.credit,license:e.license}}:null}return null}if(e.template===`fullBleedQuote`&&t===`quote`){let t=e;return{...n,template:`quote`,quote:t.text}}if(e.template===`statHighlight`&&t===`factCard`){let t=e;return{...n,template:`factCard`,fact:t.stat,explanation:t.description,accentImage:t.accentImage}}return null}var K=3,q=20,J=6;function Pe(e,t){return e.length===0?[]:e.some(e=>n(e)&&typeof e.sourceStartTime==`number`)?Ie(e,t):Fe(e,t)}function Fe(e,t){let r=t>0?t:Re(e),i=e.map(e=>!n(e)&&e.duration>0||n(e)&&e.duration>0?e.duration:J);i.reduce((e,t)=>e+t,0)>0&&r>0&&Le(i,r);let a=0,o=[];for(let t=0;t<e.length;t++)o.push(X(e[t],a,i[t])),a+=i[t];return o}var Y=1;function Ie(e,t){let r=e.map(e=>n(e)?{block:e,anchorStart:typeof e.sourceStartTime==`number`?e.sourceStartTime:null,rawDuration:e.duration>0?e.duration:J}:{block:e,anchorStart:e.startTime,rawDuration:e.duration>0?e.duration:J}),i=Array(r.length),a=0,o=!1,s=0;for(;s<r.length;){let e=r[s];if(e.anchorStart!==null){let t=Math.max(a,e.anchorStart);i[s]=t;let r=n(e.block)?e.block.sourceDuration??e.rawDuration:e.rawDuration;a=t+Math.max(Y,r),o=!0,s++;continue}let t=s;for(;s<r.length&&r[s].anchorStart===null;)s++;let c=r.slice(t,s),l=c.reduce((e,t)=>e+t.rawDuration,0),u=s<r.length?Math.max(r[s].anchorStart??a,a):null;if(u===null){let e=a;for(let n=0;n<c.length;n++)i[t+n]=e,e+=c[n].rawDuration;a=e}else if(o){let e=Math.max(0,u-a),n=l>0?Math.min(1,e/l):0,r=Math.max(a,u-l*n);for(let e=0;e<c.length;e++)i[t+e]=r,r+=c[e].rawDuration*n;a=u}else{let e=u-a,n=a;for(let r=0;r<c.length;r++)i[t+r]=n,n+=l>0?c[r].rawDuration/l*e:e/c.length;a=u}}for(let e=0;e<i.length;e++){let t=e>0?i[e-1]+Y:0;i[e]<t&&(i[e]=t)}let c=[];for(let e=0;e<r.length;e++){let a=r[e],o;if(e+1<r.length)o=Math.max(Y,i[e+1]-i[e]);else{let r=n(a.block)?a.block.sourceDuration??a.rawDuration:a.rawDuration;o=Math.max(Y,r,t-i[e])}c.push(X(a.block,i[e],o))}return c}function X(e,t,r){return n(e)?{...e,startTime:t,duration:r,title:ze(e)}:{...e,startTime:t,duration:r}}function Z(e){return Math.max(K,Math.min(q,e))}var Q=60;function $(e,t){let n=0;for(let r of e)n+=Z(r*t);return n}function Le(e,t){let n=e.reduce((e,t)=>e+t,0);if(n<=0)return;let r=t/n;if(e.every(e=>{let t=e*r;return t>=K&&t<=q})){for(let t=0;t<e.length;t++)e[t]*=r;return}let i=0,a=1;for(let n=0;n<Q&&$(e,a)<t;n++)a*=2;for(let n=0;n<Q;n++){let n=(i+a)/2;$(e,n)<t?i=n:a=n}let o=(i+a)/2,s=0,c=0;for(let t of e){let e=t*o;e<K?s+=K:e>q?s+=q:c+=t}let l=c>0?(t-s)/c:o,u=Number.isFinite(l)&&l>0?l:o;for(let t=0;t<e.length;t++)e[t]=Z(e[t]*u)}function Re(e){let t=0;for(let r of e)!n(r)&&r.duration>0?t+=r.duration:t+=J;return Math.max(t,e.length*K)}function ze(e){if(`title`in e&&typeof e.title==`string`)return e.title;if(`stat`in e&&typeof e.stat==`string`)return e.stat;if(`fact`in e&&typeof e.fact==`string`)return e.fact;if(`quote`in e&&typeof e.quote==`string`)return e.quote.slice(0,60)}function Be(e,t,n){let r=L(t,n?.registry),i=n?.overrides?{...r,...n.overrides,id:r.id}:r,o=n?.seed??a(e.articleId||`transform`),s=n?.images??V(e.blocks),c=U(e.blocks,{minConfidence:i.minConfidence,types:i.preferredTypes});if(!c.some(e=>e.bodyWordCount>=5))return{doc:{...e},stats:{totalInputBlocks:e.blocks.length,transformedBlocks:0,insertedBlocks:0}};let l=Ae(c,i,s,o),u=l.blocks,d=0,f=Ve(e);if(i.pacing?.intro&&f&&!e.startBlock&&(u=[{template:`title`,id:`transform-intro`,duration:4,audioSegment:0,title:f},...u],d++),i.pacing?.outro&&f){let e={template:`sectionHeader`,id:`transform-outro`,duration:3,audioSegment:0,title:f,colorScheme:i.colorSchemes[0]};u=[...u,e],d++}let p=Pe(u,e.duration);return{doc:{...e,blocks:p,themeId:n?.themeId??e.themeId??i.suggestedThemeId},stats:{totalInputBlocks:e.blocks.length,transformedBlocks:l.transformedCount,insertedBlocks:l.insertedCount+d}}}function Ve(e){if(e.startBlock?.title)return e.startBlock.title;for(let t of e.blocks)if(t.title)return t.title}export{V as a,L as c,De as i,U as n,R as o,Be as r,Oe as s,Se as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{W as t}from"./index-DivKnJyx.js";import{t as n}from"./jszip.min-DhiFe-R7.js";import{n as r,r as i,t as a}from"./chunk-7AWFHP5U-MiVVPFTx.js";import"./storage-Cmhlwx70.js";var o=e(n(),1);async function s(e,t={}){let n=new o.default,i=await e.listFiles();for(let t of i){r(t.path);let i=await e.readFile(t.path);i&&n.file(t.path,new Uint8Array(i))}let a=t.compression??`DEFLATE`,s=t.compressionLevel??6;if(!Number.isSafeInteger(s)||s<1||s>9)throw Error(`ZIP compression level must be an integer between 1 and 9`);return n.generateAsync({type:`blob`,compression:a,...a===`DEFLATE`?{compressionOptions:{level:s}}:{}})}async function c(e,n={}){let r=await i(e,n),a=new t;for(let{path:e}of r.entries){let t=await r.read(e);t&&await a.writeFile(e,t),r.release(e)}return a}export{a as ZipSafetyError,s as containerToZip,c as zipToContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-DXYWKZ52-DMKPZnpo.js";import{a as e,i as t,n,o as r,r as i,t as a}from"./chunk-Q77KNJIN-BdWizq9s.js";export{a as SIDECAR_CSV_LIMITS,n as csvToContainer,i as csvToMarkdownDoc,t as markdownDocToCsv,e as parseCsv,r as serializeCsvRows};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-7AWFHP5U-MiVVPFTx.js";import"./chunk-DXYWKZ52-DMKPZnpo.js";import"./chunk-Q77KNJIN-BdWizq9s.js";import"./chunk-S5PCVMKU-Df5XzhSE.js";import"./chunk-ATWVNF7D-CKIWh7bN.js";import{i as e,n as t}from"./chunk-UXEANVBI-BUBXvqyE.js";export{t as defaultDataReaders,e as parquetDataReader};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t}from"./jsx-runtime-CEpd2cAX.js";import{t as n}from"./react-dom-OL4w_gzs.js";import{O as r,k as i,y as a,z as o}from"./chunk-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t}from"./jsx-runtime-CEpd2cAX.js";import{t as n}from"./react-dom-OL4w_gzs.js";import{O as r,k as i,y as a,z as o}from"./chunk-CW24CH7I-BD0FIooX.js";import"./markdown-CLKH_zzl.js";import"./icons-CyM7Cg4E.js";var s=/\*\*(?![\s*])(.+?)(?<![\s*])\*\*/g,c=/(?<![\p{L}\p{N}_])__(?![\s_])(.+?)(?<![\s_])__(?![\p{L}\p{N}_])/gu,l=/\*(?![\s*])(.+?)(?<![\s*])\*/g,u=/(?<![\p{L}\p{N}_])_(?![\s_])(.+?)(?<![\s_])_(?![\p{L}\p{N}_])/gu,d=/~~(.+?)~~/g,f=/\*\*(?![\s*])((?:(?!\*\*).)+?)(?<![\s*])([ \t]+)\*\*(?=$|[^\s*])/g,p=/(?<!\*)\*(?![\s*])([^*]+?)(?<![\s*])([ \t]+)\*(?=$|[^\s*])/g,m=[`*`,`_`,`~`,`\\`],h=/\\([*_~\\])/g,g=/`(.+?)`/g,ee="`",te="```",_=/!\[(.*?)\]\((.+?)\)/g,v=/@\[([^\]]+?)\]\(([a-z][a-z0-9+.-]*)\\?:([^)\s]+)\)/gi,y=/<span\b[^>]*?\bdata-mention\b[^>]*?>(?:<[^>]+>)*([^<]*)<\/span>/gi,ne=/\{\[([a-zA-Z0-9_:-]+)\]\}/g,re=/<i\b[^>]*?\bdata-icon="([^"]*)"[^>]*?><\/i>/gi,ie=/<(strong|b|em|i|s|del|sup|sub)>(.*?)<\/\1>/gs,ae=/<code>(.*?)<\/code>/g,oe=/<(sup|sub)>((?:(?!<\/?(?:sup|sub)>)[\s\S])*)<\/\1>/gi,se=/<a\b([^>]*)>(.*?)<\/a>/g,ce=/<img\b([^>]*)>/g,le=/<[^>]+>/g;function ue(e){if(!e.some(e=>e.includes(ee)))return e;let t=[],n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i.startsWith(te)){n=!n,t.push(i);continue}if(n||!de(i)){t.push(i);continue}let a=i,o=r+1,s=!1;for(;o<e.length;){let t=e[o];if(t.trim()===``||t.startsWith(te))break;if(a=`${a} ${t.replace(/^[ \t]+/,``)}`,o++,!de(a)){s=!0;break}}if(!s){t.push(i);continue}t.push(a),r=o-1}return t}function de(e){return e.replace(g,``).includes(ee)}function fe(e){if(!e.trim())return`<p></p>`;let t=ue(e.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`)),n=be(t),r=[],i=!1,a=``,o=[],s=[],c=!1,l=[],u=0,d=!1,f=()=>{if(u===0)return;let e=r.length===0?u:Math.max(0,u-1);for(let t=0;t<e;t++)r.push(`<p></p>`);u=0},p=e=>{f(),r.push(e),d=!1},m=e=>{e.openAttrs!==null&&(e.items.push(`<li${e.openAttrs}>${e.openContent}</li>`),e.openAttrs=null,e.openContent=``)},h=()=>{let e=s.pop();if(!e||(m(e),e.items.length===0))return;let t=e.type===`ol`?`ol`:`ul`,n=e.type===`task`?` data-type="taskList"`:``;e.type===`ol`&&e.start!=null&&e.start!==1&&(n+=` start="${e.start}"`);let r=`<${t}${n}>${e.items.join(``)}</${t}>`,i=s[s.length-1];if(!i){p(r),d=!0;return}i.openAttrs===null&&(i.openAttrs=i.type===`task`?` data-type="taskItem"`:``,i.openContent=`<p></p>`),i.openContent+=r},g=()=>{for(;s.length>0;)h()},ee=(e,t,n,r,i=null)=>{for(;s.length>0&&e<s[s.length-1].minIndent;)h();let a=s[s.length-1];if(!a){s.push({indent:e,minIndent:0,type:t,start:i,items:[],openAttrs:n,openContent:r});return}if(e>a.indent){s.push({indent:e,minIndent:a.indent+1,type:t,start:i,items:[],openAttrs:n,openContent:r});return}if(e<a.indent&&(a.indent=e),a.type!==t){let{indent:e,minIndent:o}=a;h(),s.push({indent:e,minIndent:o,type:t,start:i,items:[],openAttrs:n,openContent:r});return}m(a),a.openAttrs=n,a.openContent=r},te=()=>{if(!c||l.length===0){c=!1,l=[];return}let e=l.length>=2?Ee(l[1]):[],t=e.length>0&&e.every(e=>/^:?-+:?$/.test(e.trim()));if(l.length<2||!t){for(let e of l)p(`<p>${je(e)}</p>`);c=!1,l=[];return}let n=De(l[1]),r=Ee(l[0]).map((e,t)=>{let r=n[t];return`<th${r?` style="text-align: ${r}"`:``}>${je(e)}</th>`}).join(``),i=l.slice(2).map(e=>`<tr>${Ee(e).map((e,t)=>{let r=n[t];return`<td${r?` style="text-align: ${r}"`:``}>${je(e)}</td>`}).join(``)}</tr>`).join(``);p(`<table><thead><tr>${r}</tr></thead><tbody>${i}</tbody></table>`),c=!1,l=[]};for(let e=0;e<t.length;e++){let m=t[e];if(m.startsWith("```"))if(i){p(`<pre><code${a?` class="language-${b(a)}"`:``}>${b(o.join(`
|
|
5
5
|
`))}</code></pre>`),i=!1,a=``,o=[];continue}else{g(),te(),f(),i=!0,a=m.slice(3).trim(),o=[];continue}if(i){o.push(m);continue}if(c&&!/^\|.*\|$/.test(m.trim())&&te(),m.trim()===``){g(),u++;continue}if((u>0||r.length===0)&&!c&&s.length===0&&!d&&Se(m)){let n=[],r=e;for(;r<t.length;r++){let e=t[r];if(e.trim()===``){n.push(``);continue}if(!Se(e))break;n.push(Ce(e))}let i=n.length;for(;i>0&&n[i-1]===``;)i--;let a=n.length-i;n.length=i,e=r-a-1,p(`<pre><code>${b(n.join(`
|
|
6
6
|
`))}</code></pre>`);continue}f();let h=m.match(/^(#{1,6})\s+(.+)$/);if(h){g(),p(we(h[1].length,h[2]));continue}if(/^(---|\*\*\*|___)(\s*)$/.test(m.trim())){g(),p(`<hr>`);continue}if(m.startsWith(`> `)){g();let n=[m.slice(2)];for(;e+1<t.length&&t[e+1].startsWith(`> `);)e++,n.push(t[e].slice(2));p(`<blockquote>${n.map(e=>`<p>${je(e)}</p>`).join(``)}</blockquote>`);continue}let _=m.match(/^([ \t]*)[-*+]\s+\[([xX ])\]\s*(.*)$/);if(_){let e=_[2].toLowerCase()===`x`?` data-checked="true"`:``;ee(Te(_[1]),`task`,` data-type="taskItem"${e}`,`<p>${je(_[3])}</p>`);continue}let v=m.match(/^([ \t]*)[-*+]\s+(.+)$/);if(v){ee(Te(v[1]),`ul`,``,`<p>${je(v[2])}</p>`);continue}let y=m.match(/^([ \t]*)(\d+)\.\s+(.+)$/);if(y){ee(Te(y[1]),`ol`,``,`<p>${je(y[3])}</p>`,parseInt(y[2],10));continue}if(/^\|.*\|$/.test(m.trim())){c||(g(),c=!0,l=[]),l.push(m);continue}let ne=m.trim().match(/^!\[(.*?)\]\((.+?)\)$/);if(ne){g(),p(`<img alt="${b(ne[1]??``)}" src="${b(ne[2]??``)}">`);continue}let re=m.trim();if(/^<img\b[^>]*>$/i.test(re)){g(),p(re);continue}if(/^<(?:video|audio)\b[^>]*>(?:[\s\S]*?<\/(?:video|audio)>)?$/i.test(re)){g(),p(re);continue}let ie=e+1<t.length&&e+1>n?xe(t[e+1]):null;if(ie!==null){g(),e++,p(we(ie,m.trim()));continue}g(),p(`<p>${je(m)}</p>`)}return i&&p(`<pre><code${a?` class="language-${b(a)}"`:``}>${b(o.join(`
|
|
7
7
|
`))}</code></pre>`),g(),te(),f(),r.join(``)||`<p></p>`}function pe(e){if(!e||e===`<p></p>`)return``;let t=[],n=e;for(;n.length>0;){let e=n.match(/^<h([1-6])([^>]*)>(.*?)<\/h\1>/s);if(e){let r=parseInt(e[1],10),i=e[2],a=e[3],o=a.search(/<span\b[^>]*\bclass="[^"]*\bsquisq-(?:template|props)-badge\b[^"]*"[^>]*>/i),s=Ge(o>=0?a.slice(0,o):a),c=i.match(/data-block-attrs="([^"]*)"/),l=i.match(/data-template="([^"]+)"/),u=i.match(/data-template-params="([^"]+)"/),d=/\sdata-template-empty(?:="[^"]*")?/.test(i);if(c){let e=Ae(c[1]);s+=` {${e}}`}if(l||u){let e=l?l[1]:``;u&&(e+=(e?` `:``)+Ae(u[1])),s+=` {[${e}]}`}else d&&(s+=` {[]}`);t.push(`#`.repeat(r)+` `+s),t.push(``),n=n.slice(e[0].length);continue}let r=n.match(/^<pre\b[^>]*><code\b([^>]*)>(.*?)<\/code><\/pre>/s);if(r){let e=/\bclass="language-([^"]*)"/.exec(r[1]??``)?.[1]??``,i=Ae(r[2]);t.push("```"+e),t.push(i),t.push("```"),t.push(``),n=n.slice(r[0].length);continue}let i=n.match(/^<blockquote>(.*?)<\/blockquote>/s);if(i){let e=i[1].split(/<\/p>\s*<p[^>]*>/i).map(e=>e.replace(/^<p[^>]*>/i,``).replace(/<\/p>\s*$/i,``));for(let n of e)for(let e of Ge(n).split(`
|
|
8
|
-
`))t.push(`> `+e);let r=n.slice(i[0].length);/^\s*<blockquote>/.test(r)||t.push(``),n=r;continue}if(n.startsWith(`<hr>`)||n.startsWith(`<hr/>`)||n.startsWith(`<hr />`)){let e=n.match(/^<hr\s*\/?>/);t.push(`---`),t.push(``),n=n.slice(e[0].length);continue}let a=n.match(/^<div[^>]*class="[^"]*tableWrapper[^"]*"[^>]*><table[^>]*>(.*?)<\/table>\s*<\/div>/s)||n.match(/^<table[^>]*>(.*?)<\/table>/s);if(a){let e=a[1],r=[],i=/<tr[^>]*>(.*?)<\/tr>/gs,o;for(;(o=i.exec(e))!==null;){let e=o[1],t=[],n=/<(th|td)([^>]*)>(.*?)<\/\1>/gs,i;for(;(i=n.exec(e))!==null;){let e=i[1],n=i[2],r=Ke(i[3]
|
|
8
|
+
`))t.push(`> `+e);let r=n.slice(i[0].length);/^\s*<blockquote>/.test(r)||t.push(``),n=r;continue}if(n.startsWith(`<hr>`)||n.startsWith(`<hr/>`)||n.startsWith(`<hr />`)){let e=n.match(/^<hr\s*\/?>/);t.push(`---`),t.push(``),n=n.slice(e[0].length);continue}let a=n.match(/^<div[^>]*class="[^"]*tableWrapper[^"]*"[^>]*><table[^>]*>(.*?)<\/table>\s*<\/div>/s)||n.match(/^<table[^>]*>(.*?)<\/table>/s);if(a){let e=a[1],r=[],i=/<tr[^>]*>(.*?)<\/tr>/gs,o;for(;(o=i.exec(e))!==null;){let e=o[1],t=[],n=/<(th|td)([^>]*)>(.*?)<\/\1>/gs,i;for(;(i=n.exec(e))!==null;){let e=i[1],n=i[2],r=Ke(i[3]),a=n.match(/text-align:\s*(left|center|right)/);t.push({content:r,align:a?a[1]:null,isHeader:e===`th`})}t.length>0&&r.push(t)}if(r.length>0){let e=r.findIndex(e=>e.some(e=>e.isHeader)),n=e>=0?e:0,i=r[n],a=r.filter((e,t)=>t!==n),o=i.map(e=>e.align);t.push(`| `+i.map(e=>e.content||` `).join(` | `)+` |`),t.push(`| `+o.map(e=>e===`center`?`:---:`:e===`right`?`---:`:`---`).join(` | `)+` |`);for(let e of a)t.push(`| `+e.map(e=>e.content||` `).join(` | `)+` |`);t.push(``)}n=n.slice(a[0].length);continue}let o=n.match(/^<(ul|ol)\b([^>]*)>/i);if(o){let e=o[1].toLowerCase(),r=me(n,0,e);if(r){let i=/data-type="taskList"/i.test(o[2]??``);t.push(...ve(r.inner,e===`ol`,i,``,ge(o[2]))),t.push(``),n=n.slice(r.end);continue}}let s=n.match(/^<p>(.*?)<\/p>/s);if(s){let e=Ge(s[1]);e.trim()&&t.push(e),t.push(``),n=n.slice(s[0].length);continue}let c=n.match(/^<img\b([^>]*)>/);if(c){let e=c[1]??``,r=/\bsrc="([^"]*)"/i.exec(e)?.[1];if(r){let n=/\balt="([^"]*)"/i.exec(e)?.[1]??``;t.push(ke(r,n,e)),t.push(``)}n=n.slice(c[0].length);continue}let l=n.match(/^<(video|audio)\b([^>]*)>(?:[\s\S]*?<\/\1>)?/);if(l){let e=l[1]===`video`?`video`:`audio`;t.push(Oe(e,l[2]??``)),t.push(``),n=n.slice(l[0].length);continue}let u=n.match(/^(<[^>]+>|\s+)/);if(u){n=n.slice(u[0].length);continue}let d=n.match(/^([^<]+)/);if(d){t.push(Ae(d[1])),n=n.slice(d[0].length);continue}n=n.slice(1)}return t.join(`
|
|
9
9
|
`)}function me(e,t,n){let r=RegExp(`<${n}\\b[^>]*>|</${n}\\s*>`,`gi`);r.lastIndex=t;let i=0,a=-1,o;for(;(o=r.exec(e))!==null;)if(o[0][1]===`/`){if(i--,i===0)return{inner:e.slice(a,o.index),end:o.index+o[0].length};if(i<0)return null}else{if(i===0){if(o.index!==t)return null;a=o.index+o[0].length}i++}return null}function he(e){let t=[],n=/<li\b([^>]*)>|<\/li\s*>/gi,r=0,i=-1,a=``,o;for(;(o=n.exec(e))!==null;)o[0][1]===`/`?(r--,r===0&&i>=0&&t.push({attrs:a,inner:e.slice(i,o.index)}),r<0&&(r=0)):(r===0&&(i=o.index+o[0].length,a=o[1]??``),r++);return t}function ge(e){let t=parseInt(/\bstart="(\d+)"/i.exec(e??``)?.[1]??``,10);return Number.isFinite(t)?t:1}function _e(e){let t=[],n=``,r=0,i=/<(ul|ol)\b([^>]*)>/gi,a;for(;(a=i.exec(e))!==null;){let o=a[1].toLowerCase(),s=me(e,a.index,o);if(!s)break;n+=e.slice(r,a.index),t.push({ordered:o===`ol`,task:/data-type="taskList"/i.test(a[2]??``),inner:s.inner,start:ge(a[2])}),r=s.end,i.lastIndex=s.end}return{content:n+e.slice(r),nested:t}}function ve(e,t,n,r,i=1){let a=[];return he(e).forEach((e,o)=>{let{content:s,nested:c}=_e(e.inner),l=t?`${i+o}. `:`- `;if(n){let t=/data-checked="true"/.test(e.attrs),n=Ge(s.replace(/<label\b[^>]*>.*?<\/label>/s,``).replace(/<[^>]+>/g,``).trim());a.push(`${r}- [${t?`x`:` `}] ${n}`.trimEnd())}else a.push(...ye(l,s,r));let u=r+` `.repeat(n?2:l.length);for(let e of c)a.push(...ve(e.inner,e.ordered,e.task,u,e.start))}),a}function ye(e,t,n=``){let r=n+` `.repeat(e.length),i=[],a=t.replace(/<(video|audio)\b([^>]*)>(?:[\s\S]*?<\/\1>)?/gi,(e,t,n)=>(i.push(Oe(t.toLowerCase()===`video`?`video`:`audio`,n??``)),``)).split(/<\/p>\s*<p[^>]*>/i).map(e=>e.replace(/^<p[^>]*>/i,``).replace(/<\/p>\s*$/i,``)),o=[];if(a.forEach((t,i)=>{let a=Ge(t).trim();a&&a.split(`
|
|
10
10
|
`).forEach((t,a)=>{i===0&&a===0?o.push(n+e+t):(a===0&&o.push(``),o.push(r+t))})}),o.length===0&&i.length===0)return[n+e];let s=[];if(o.length>0){s.push(...o);for(let e of i)s.push(``),s.push(r+e)}else{s.push(n+e+i[0]);for(let e of i.slice(1))s.push(``),s.push(r+e)}return s}function be(e){if(e[0]?.trim()!==`---`)return-1;for(let t=1;t<e.length;t++)if(e[t].trim()===`---`)return t;return-1}function xe(e){let t=/^ {0,3}(=+|-+)[ \t]*$/.exec(e);return t?t[1][0]===`=`?1:2:null}function Se(e){return/^(?: {4}|\t)/.test(e)&&e.trim()!==``}function Ce(e){return e.startsWith(` `)?e.slice(1):e.slice(4)}function we(e,t){let n=t,a=``,s=null,c=null;for(let e=0;e<4;e++){let e=!1;if(s==null){let t=i(n);t&&(s=t.inner.trim(),n=n.slice(0,t.index).trimEnd(),e=!0)}if(c==null){let t=r(n);t&&(c=t.inner.trim(),n=n.slice(0,t.index).trimEnd(),e=!0)}if(!e)break}if(s!=null){let e=o(s);e.length===0&&(a+=` data-template-empty="true"`);let t=e.length>0&&e[0].indexOf(`=`)>0;!t&&e[0]&&(a+=` data-template="${b(e[0])}"`);let n=e.slice(+!t).filter(e=>e.includes(`=`));n.length>0&&(a+=` data-template-params="${b(n.join(` `))}"`)}return c!=null&&(a+=` data-block-attrs="${b(c)}"`),`<h${e}${a}>${je(n)}</h${e}>`}function Te(e){let t=0;for(let n of e)t+=n===` `?4:1;return t}function Ee(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function De(e){return Ee(e).map(e=>{let t=e.replace(/\s/g,``);return t.startsWith(`:`)&&t.endsWith(`:`)?`center`:t.endsWith(`:`)?`right`:t.startsWith(`:`)?`left`:null})}function Oe(e,t){let n=/\bsrc="([^"]*)"/i.exec(t)?.[1]??``,r=/\bcontrols\b/i.test(t),i=/\bwidth="([^"]*)"/i.exec(t)?.[1],a=/\bheight="([^"]*)"/i.exec(t)?.[1],o=e===`video`?/\bposter="([^"]*)"/i.exec(t)?.[1]:void 0,s=e===`video`?/\bdata-squisq-video-placement="([^"]*)"/i.exec(t)?.[1]:void 0,c=e===`video`?/\bdata-squisq-video-lock-to-block="([^"]*)"/i.exec(t)?.[1]:void 0,l=e===`video`?/\bdata-squisq-video-pip-size="([^"]*)"/i.exec(t)?.[1]:void 0,u=e===`video`?/\bdata-squisq-video-pip-shape="([^"]*)"/i.exec(t)?.[1]:void 0,d=e===`video`?/\bdata-squisq-video-pip-position="([^"]*)"/i.exec(t)?.[1]:void 0,f=`data-squisq-${e}`,p=RegExp(`\\b${f}-start-at="([^"]*)"`,`i`).exec(t)?.[1],m=RegExp(`\\b${f}-clip-start="([^"]*)"`,`i`).exec(t)?.[1],h=RegExp(`\\b${f}-clip-end="([^"]*)"`,`i`).exec(t)?.[1],g=[`<${e} src="${n}"`];return r&&g.push(` controls`),i&&g.push(` width="${i}"`),a&&g.push(` height="${a}"`),o&&g.push(` poster="${o}"`),(s===`picture-in-picture`||s===`overlay`)&&g.push(` data-squisq-video-placement="${s}"`),c===`false`&&g.push(` data-squisq-video-lock-to-block="false"`),(l===`small`||l===`large`)&&g.push(` data-squisq-video-pip-size="${l}"`),(u===`square`||u===`wide`)&&g.push(` data-squisq-video-pip-shape="${u}"`),(d===`top-left`||d===`top-right`||d===`bottom-left`||d===`bottom-right`)&&g.push(` data-squisq-video-pip-position="${d}"`),p!=null&&g.push(` ${f}-start-at="${p}"`),m!=null&&g.push(` ${f}-clip-start="${m}"`),h!=null&&g.push(` ${f}-clip-end="${h}"`),g.push(`></${e}>`),g.join(``)}function ke(e,t,n){let r=/\bwidth="([^"]*)"/i.exec(n)?.[1],i=/\bheight="([^"]*)"/i.exec(n)?.[1],a=/\btitle="([^"]*)"/i.exec(n)?.[1];if(!r&&!i)return``;let o=[`<img alt="${t}" src="${e}"`];return r&&o.push(` width="${r}"`),i&&o.push(` height="${i}"`),a&&o.push(` title="${a}"`),o.push(`>`),o.join(``)}function b(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Ae(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/ | | /gi,`\xA0`).replace(/&/g,`&`)}function je(e){let t=[],n=e=>{let n=`\0PH${t.length}\0`;return t.push(e),n},r=e.replace(g,(e,t)=>n(`<code>${b(t)}</code>`));r=r.replace(oe,(e,t,r)=>{let i=t.toLowerCase();return n(`<${i}>${je(r)}</${i}>`)}),r=r.replace(/<br\s*\/?>/gi,()=>n(`<br>`)),r=r.replace(_,(e,t,r)=>n(`<img alt="${b(t)}" src="${b(r)}">`)),r=r.replace(v,(e,t,r,i)=>n(`<span data-mention="true" data-kind="${b(r)}" data-id="${b(i)}" data-label="${b(t)}" class="mention">@${b(t)}</span>`)),r=r.replace(ne,(e,t)=>{let r=a(t);return r?n(`<i class="fa-${r.family} fa-${r.name}" data-icon="${b(t)}" data-family="${r.family}" data-name="${r.name}" contenteditable="false"></i>`):e}),r=Me(r,(e,t)=>{let{url:r,title:i}=Ne(t),a=i===null?``:` title="${b(i)}"`;return n(`<a href="${b(r)}"${a}>${je(e)}</a>`)});let i=b(r);i=i.replace(h,(e,t)=>`\0ESC${m.indexOf(t)}\0`),i=i.replace(f,`<strong>$1</strong>$2`),i=i.replace(s,`<strong>$1</strong>`),i=i.replace(c,`<strong>$1</strong>`),i=i.replace(p,`<em>$1</em>$2`),i=i.replace(l,`<em>$1</em>`),i=i.replace(u,`<em>$1</em>`),i=i.replace(d,`<s>$1</s>`);for(let e=0;e<m.length;e++)i=i.split(`\0ESC${e}\0`).join(m[e]);for(let e=t.length-1;e>=0;e--)i=i.split(`\0PH${e}\0`).join(t[e]??``);return qe(i)}function Me(e,t){let n=``,r=0,i=0;for(;i<e.length;){let a=e.indexOf(`[`,i);if(a<0)break;if(Ie(e,a)){i=a+1;continue}let o=Fe(e,a,`[`,`]`),s=o+1;if(o<0||e[s]!==`(`){i=a+1;continue}let c=Fe(e,s,`(`,`)`);if(c<0){i=a+1;continue}let l=e.slice(a+1,o),u=e.slice(s+1,c);if(!l||!u){i=a+1;continue}n+=e.slice(r,a)+t(l,u),r=c+1,i=r}return n+e.slice(r)}function Ne(e){let t={'"':`"`,"'":`'`,")":`(`},n=e.trimEnd(),r=t[n[n.length-1]??``];if(!r)return{url:e.trim(),title:null};for(let e=n.length-2;e>0;e--){if(n[e]!==r||Ie(n,e)||!/\s/.test(n[e-1]))continue;let t=n.slice(0,e).trim();if(t)return{url:t,title:n.slice(e+1,-1).replace(/\\([\\"'()])/g,`$1`)}}return{url:e.trim(),title:null}}function Pe(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Fe(e,t,n,r){let i=0;for(let a=t;a<e.length;a++)if(!Ie(e,a)&&(e[a]===n&&i++,e[a]===r&&(i--,i===0)))return a;return-1}function Ie(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;r--)n++;return n%2==1}function Le(e){return e!==void 0&&/[\p{L}\p{N}_]/u.test(e)}function Re(e){return e===void 0||/\s/.test(e)}var ze=/(?:https?:\/\/|ftp:\/\/|www\.)(?:\([^\s<>()]*\)|[^\s<>[\]()])+/gi;function Be(e){let t=``,n=0;ze.lastIndex=0;let r;for(;(r=ze.exec(e))!==null;)t+=Ve(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+Ve(e.slice(n))}function Ve(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e[n-1],a=e[n+1];if(r===`\\`){t+=m.includes(a??``)?`\\\\`:`\\`;continue}if(r===`~`){t+=i===`~`||a===`~`?`\\~`:`~`;continue}if(r===`*`){t+=!Re(a)||!Re(i)?`\\*`:`*`;continue}if(r===`_`){let e=!Le(i)&&!Re(a),n=!Le(a)&&!Re(i);t+=e||n?`\\_`:`_`;continue}t+=r}return t}function He(e){let t=``,n=0,r=/<code\b[^>]*>[\s\S]*?<\/code>|<[^>]+>/gi,i;for(;(i=r.exec(e))!==null;)t+=Be(e.slice(n,i.index)),t+=i[0],n=i.index+i[0].length;return t+Be(e.slice(n))}function Ue(e){return e.replace(ie,(e,t,n)=>{let r=Ue(n),i=r.match(/^\s*/)?.[0]??``,a=r.match(/\s*$/)?.[0]??``,o=r.slice(i.length,r.length-a.length);if(!o)return r;if(t===`sup`||t===`sub`)return`${i}<${t}>${o}</${t}>${a}`;let s=t===`strong`||t===`b`?`**`:t===`em`||t===`i`?`*`:`~~`;return`${i}${s}${o}${s}${a}`})}var We=class{constructor(){this.parts=[]}protect(e){return this.parts.push(e),`\0RAW${this.parts.length-1}\0`}restore(e){let t=e;for(let e=this.parts.length-1;e>=0;e--)t=t.split(`\0RAW${e}\0`).join(this.parts[e]);return t}};function Ge(e){let t=e,n=new We;return t=t.replace(/<br\s*\/?>/gi,`
|
|
11
|
-
`),t=He(t),t=t.replace(re,(e,t)=>`{[${t}]}`),t=Ue(t),t=t.replace(/<\/?(?:sup|sub)>/gi,e=>n.protect(e)),t=t.replace(ae,"`$1`"),t=t.replace(y,(e,t)=>{let n=/data-kind="([^"]*)"/i.exec(e)?.[1]??``,r=/data-id="([^"]*)"/i.exec(e)?.[1]??``,i=/data-label="([^"]*)"/i.exec(e)?.[1]??``;return!n||!r||!i?e:`@[${i}](${n}:${r})`}),t=t.replace(se,(e,t,n)=>{let r=/\bhref="([^"]*)"/i.exec(t)?.[1];if(r===void 0)return e;let i=/\btitle="([^"]*)"/i.exec(t)?.[1];return`[${n}](${r}${i?` "${Pe(i)}"`:``})`}),t=t.replace(ce,(e,t)=>{let r=/\bsrc="([^"]*)"/i.exec(t)?.[1];if(!r)return e;let i=ke(r,/\balt="([^"]*)"/i.exec(t)?.[1]??``,t);return i.startsWith(`<`)?n.protect(i):i}),t=t.replace(le,``),t=n.restore(t),Je(Ae(t))}function Ke(e){return Ge(e).replace(/ {2}\n/g,`<br>`)}function qe(e){return e.replace(/^ +/,e=>` `.repeat(e.length))}function Je(e){return e.replace(/(^|\n)(\u00a0+)/g,(e,t,n)=>t+` `.repeat(n.length))}function x(e){this.content=e}x.prototype={constructor:x,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new x(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new x(n)},addToStart:function(e,t){return new x([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new x(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new x(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=x.from(e),e.size?new x(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=x.from(e),e.size?new x(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=x.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},x.from=function(e){if(e instanceof x)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new x(t)};function Ye(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Qe(e.charCodeAt(r-1))&&Ze(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ye(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Xe(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Qe(e.charCodeAt(i-1))&&Ze(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Xe(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ze(e){return e>=56320&&e<57344}function Qe(e){return e>=55296&&e<56320}var S=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ye(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Xe(this,e,t,n)}findIndex(e){if(e==0)return et(0,e);if(e==this.size)return et(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?et(t+1,i):et(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};S.empty=new S([],0);var $e={index:0,offset:0};function et(e,t){return $e.index=e,$e.offset=t,$e}function tt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!tt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!tt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var C=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&tt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};C.none=[];var nt=class extends Error{},w=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=it(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(rt(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(S.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};w.empty=new w(S.empty,0,0);function rt(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(rt(a.content,t-i-1,n-i-1)))}function it(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=it(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function at(e,t,n){if(n.openStart>e.depth)throw new nt(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new nt(`Inconsistent open depths`);return ot(e,t,n,0)}function ot(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=ot(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return dt(a,pt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return dt(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=mt(n,e);return dt(a,ft(e,i,o,t,r))}}function st(e,t){if(!t.type.compatibleContent(e.type))throw new nt(`Cannot join `+t.type.name+` onto `+e.type.name)}function ct(e,t,n){let r=e.node(n);return st(r,t.node(n)),r}function lt(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ut(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(lt(e.nodeAfter,r),a++));for(let e=a;e<o;e++)lt(i.child(e),r);t&&t.depth==n&&t.textOffset&<(t.nodeBefore,r)}function dt(e,t){if(!e.type.validContent(t))throw new nt(`Invalid content for node `+e.type.name);return e.copy(t)}function ft(e,t,n,r,i){let a=e.depth>i&&ct(e,t,i+1),o=r.depth>i&&ct(n,r,i+1),s=[];return ut(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(st(a,o),lt(dt(a,ft(e,t,n,r,i+1)),s)):(a&<(dt(a,pt(e,t,i+1)),s),ut(t,n,i,s),o&<(dt(o,pt(n,r,i+1)),s)),ut(r,null,i,s),new S(s)}function pt(e,t,n){let r=[];return ut(null,e,n,r),e.depth>n&<(dt(ct(e,t,n+1),pt(e,t,n+1)),r),ut(t,null,n,r),new S(r)}function mt(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(S.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ht=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return C.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new yt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=vt.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else vt.set(t,r=new gt);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%_t,i}},gt=class{constructor(){this.elts=[],this.i=0}},_t=12,vt=new WeakMap,yt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},bt=Object.create(null),xt=class e{constructor(e,t,n,r=C.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&tt(this.attrs,t||e.defaultAttrs||bt)&&C.sameSet(this.marks,n||C.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return w.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new w(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return at(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ht.resolveCached(this,e)}resolveNoCache(e){return ht.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Ct(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=S.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=C.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!C.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=S.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};xt.prototype.text=void 0;var St=class e extends xt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ct(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ct(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var wt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Tt(t,n);if(r.next==null)return e.empty;let i=Et(r);r.next&&r.err(`Unexpected trailing text`);let a=It(Nt(i));return Lt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return S.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
11
|
+
`),t=He(t),t=t.replace(re,(e,t)=>`{[${t}]}`),t=Ue(t),t=t.replace(/<\/?(?:sup|sub)>/gi,e=>n.protect(e)),t=t.replace(ae,"`$1`"),t=t.replace(y,(e,t)=>{let n=/data-kind="([^"]*)"/i.exec(e)?.[1]??``,r=/data-id="([^"]*)"/i.exec(e)?.[1]??``,i=/data-label="([^"]*)"/i.exec(e)?.[1]??``;return!n||!r||!i?e:`@[${i}](${n}:${r})`}),t=t.replace(se,(e,t,n)=>{let r=/\bhref="([^"]*)"/i.exec(t)?.[1];if(r===void 0)return e;let i=/\btitle="([^"]*)"/i.exec(t)?.[1];return`[${n}](${r}${i?` "${Pe(i)}"`:``})`}),t=t.replace(ce,(e,t)=>{let r=/\bsrc="([^"]*)"/i.exec(t)?.[1];if(!r)return e;let i=ke(r,/\balt="([^"]*)"/i.exec(t)?.[1]??``,t);return i.startsWith(`<`)?n.protect(i):i}),t=t.replace(le,``),t=n.restore(t),Je(Ae(t))}function Ke(e){return Ge(e.replace(/<\/p>\s*<p(?:\s[^>]*)?>/gi,`<br>`).replace(/^\s*<p(?:\s[^>]*)?>/i,``).replace(/<\/p>\s*$/i,``)).replace(/ {2}\n/g,`<br>`)}function qe(e){return e.replace(/^ +/,e=>` `.repeat(e.length))}function Je(e){return e.replace(/(^|\n)(\u00a0+)/g,(e,t,n)=>t+` `.repeat(n.length))}function x(e){this.content=e}x.prototype={constructor:x,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new x(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new x(n)},addToStart:function(e,t){return new x([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new x(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new x(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=x.from(e),e.size?new x(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=x.from(e),e.size?new x(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=x.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},x.from=function(e){if(e instanceof x)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new x(t)};function Ye(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Qe(e.charCodeAt(r-1))&&Ze(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ye(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Xe(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Qe(e.charCodeAt(i-1))&&Ze(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Xe(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ze(e){return e>=56320&&e<57344}function Qe(e){return e>=55296&&e<56320}var S=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ye(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Xe(this,e,t,n)}findIndex(e){if(e==0)return et(0,e);if(e==this.size)return et(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?et(t+1,i):et(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};S.empty=new S([],0);var $e={index:0,offset:0};function et(e,t){return $e.index=e,$e.offset=t,$e}function tt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!tt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!tt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var C=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&tt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};C.none=[];var nt=class extends Error{},w=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=it(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(rt(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(S.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};w.empty=new w(S.empty,0,0);function rt(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(rt(a.content,t-i-1,n-i-1)))}function it(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=it(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function at(e,t,n){if(n.openStart>e.depth)throw new nt(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new nt(`Inconsistent open depths`);return ot(e,t,n,0)}function ot(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=ot(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return dt(a,pt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return dt(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=mt(n,e);return dt(a,ft(e,i,o,t,r))}}function st(e,t){if(!t.type.compatibleContent(e.type))throw new nt(`Cannot join `+t.type.name+` onto `+e.type.name)}function ct(e,t,n){let r=e.node(n);return st(r,t.node(n)),r}function lt(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ut(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(lt(e.nodeAfter,r),a++));for(let e=a;e<o;e++)lt(i.child(e),r);t&&t.depth==n&&t.textOffset&<(t.nodeBefore,r)}function dt(e,t){if(!e.type.validContent(t))throw new nt(`Invalid content for node `+e.type.name);return e.copy(t)}function ft(e,t,n,r,i){let a=e.depth>i&&ct(e,t,i+1),o=r.depth>i&&ct(n,r,i+1),s=[];return ut(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(st(a,o),lt(dt(a,ft(e,t,n,r,i+1)),s)):(a&<(dt(a,pt(e,t,i+1)),s),ut(t,n,i,s),o&<(dt(o,pt(n,r,i+1)),s)),ut(r,null,i,s),new S(s)}function pt(e,t,n){let r=[];return ut(null,e,n,r),e.depth>n&<(dt(ct(e,t,n+1),pt(e,t,n+1)),r),ut(t,null,n,r),new S(r)}function mt(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(S.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ht=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return C.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new yt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=vt.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else vt.set(t,r=new gt);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%_t,i}},gt=class{constructor(){this.elts=[],this.i=0}},_t=12,vt=new WeakMap,yt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},bt=Object.create(null),xt=class e{constructor(e,t,n,r=C.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&tt(this.attrs,t||e.defaultAttrs||bt)&&C.sameSet(this.marks,n||C.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return w.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new w(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return at(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ht.resolveCached(this,e)}resolveNoCache(e){return ht.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Ct(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=S.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=C.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!C.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=S.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};xt.prototype.text=void 0;var St=class e extends xt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ct(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ct(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var wt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Tt(t,n);if(r.next==null)return e.empty;let i=Et(r);r.next&&r.err(`Unexpected trailing text`);let a=It(Nt(i));return Lt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return S.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
12
12
|
`)}};wt.empty=new wt(!0);var Tt=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Et(e){let t=[];do t.push(Dt(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Dt(e){let t=[];do t.push(Ot(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Ot(e){let t=Mt(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=At(e,t);else break;return t}function kt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function At(e,t){let n=kt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:kt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function jt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Mt(e){if(e.eat(`(`)){let t=Et(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=jt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Nt(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Pt(e,t){return t-e}function Ft(e,t){let n=[];return r(t),n.sort(Pt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function It(e){let t=Object.create(null);return n(Ft(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ft(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new wt(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Pt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Lt(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Rt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function zt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Bt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function Vt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Wt(e,r,t[r]);return n}var Ht=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Vt(e,n.attrs),this.defaultAttrs=Rt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:zt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new xt(this,this.computeAttrs(e),S.from(t),C.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new xt(this,this.computeAttrs(e),t,C.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=S.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(S.empty,!0);return i?new xt(this,e,t.append(i),C.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Bt(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:C.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Ut(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Wt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Ut(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Gt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Vt(e,r.attrs),this.excluded=null;let i=Rt(this.attrs);this.instance=i?new C(this,i):null}create(e=null){return!e&&this.instance?this.instance:new C(this,zt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Bt(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Kt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=x.from(e.nodes),t.marks=x.from(e.marks||{}),this.nodes=Ht.compile(this.spec.nodes,this),this.marks=Gt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=wt.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?qt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:qt(this,n.split(` `))}this.nodeFromJSON=e=>xt.fromJSON(this,e),this.markFromJSON=e=>C.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Ht))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new St(n,n.defaultAttrs,e,C.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function qt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Jt(e){return e.tag!=null}function Yt(e){return e.style!=null}var Xt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Jt(e))this.tags.push(e);else if(Yt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new on(this,t,!1);return n.addAll(e,C.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new on(this,t,!0);return n.addAll(e,C.none,t.from,t.to),w.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(cn(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ln(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ln(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Zt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Qt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$t={ol:!0,ul:!0},en=1,tn=2,nn=4;function rn(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?en:0)|(t===`full`?tn:0)}var an=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=C.none,this.match=i||(a&nn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&en)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Zt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},on=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=rn(null,t.preserveWhitespace,0)|(n?nn:0);i=r?new an(r.type,r.attrs,C.none,!0,t.topMatch||r.type.contentMatch,a):n?new an(null,null,C.none,!0,null,a):new an(e.schema.topNodeType,null,C.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&tn?`full`:this.localPreserveWS||(r.options&en)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
13
13
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;$t.hasOwnProperty(a)&&this.parser.normalizeLists&&sn(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Qt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Zt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
14
14
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=C.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):un(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=rn(e,i,a.options);a.options&nn&&a.content.length==0&&(o|=nn);let s=C.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):un(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new an(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=en);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function sn(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&$t.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function cn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ln(e){let t={};for(let n in e)t[n]=e[n];return t}function un(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var dn=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=pn(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return pn(t).createTextNode(e.text);let{dom:n,contentDOM:r}=_n(pn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&_n(pn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:_n(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=fn(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return fn(e.marks)}};function fn(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function pn(e){return e.document||window.document}var mn=new WeakMap;function hn(e){let t=mn.get(e);return t===void 0&&mn.set(e,t=gn(e)),t}function gn(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function _n(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=hn(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=_n(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var vn=65535,yn=2**16;function bn(e,t){return e+t*yn}function xn(e){return e&vn}function Sn(e){return(e-(e&vn))/yn}var Cn=1,wn=2,Tn=4,En=8,Dn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&En)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Tn)>0}},On=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=xn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Sn(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:bn(o/3,e-s),f=e==s?wn:e==u?Cn:Tn;return(t<0?e!=s:e!=u)&&(f|=En),new Dn(a,f,d)}r+=l-c}return n?e+r:new Dn(e+r,0,null)}touches(e,t){let n=0,r=xn(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};On.empty=new On([]);var kn=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Dn(e,r,null)}},An=Object.create(null),T=class{getMap(){return On.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=An[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in An)throw RangeError(`Duplicate use of step JSON ID `+e);return An[e]=t,t.prototype.jsonID=e,t}},E=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof nt)return e.fail(t.message);throw t}}};function jn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(jn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return S.fromArray(r)}var Mn=class e extends T{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new w(jn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return E.fromReplace(e,this.from,this.to,i)}invert(){return new Nn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};T.jsonID(`addMark`,Mn);var Nn=class e extends T{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new w(jn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return E.fromReplace(e,this.from,this.to,n)}invert(){return new Mn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};T.jsonID(`removeMark`,Nn);var Pn=class e extends T{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return E.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return E.fromReplace(e,this.pos,this.pos+1,new w(S.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Fn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};T.jsonID(`addNodeMark`,Pn);var Fn=class e extends T{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return E.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return E.fromReplace(e,this.pos,this.pos+1,new w(S.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Pn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};T.jsonID(`removeNodeMark`,Fn);var In=class e extends T{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Ln(e,this.from,this.to)?E.fail(`Structure replace would overwrite content`):E.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new On([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?w.empty:new w(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?w.empty:new w(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,w.fromJSON(t,n.slice),!!n.structure)}};In.MAP_BIAS=1,T.jsonID(`replace`,In);var D=class e extends T{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Ln(e,this.from,this.gapFrom)||Ln(e,this.gapTo,this.to)))return E.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return E.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?E.fromReplace(e,this.from,this.to,n):E.fail(`Content does not fit in gap`)}getMap(){return new On([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,w.fromJSON(t,n.slice),n.insert,!!n.structure)}};T.jsonID(`replaceAround`,D);function Ln(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Rn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Nn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Mn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function zn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Gt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Nn(t.from,t.to,t.style)))}function Bn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new In(s,l,w.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Nn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new w(S.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new In(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(S.empty,!0);e.replace(s,s,new w(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Vn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Hn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Vn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Un(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=S.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=S.from(r.node(e).copy(u)),d++):c--;let f=S.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=S.from(i.node(e).copy(f)),p++):l++;e.step(new D(c,l,o,s,new w(u.append(f),d,p),u.size-d,!0))}function Wn(e,t,n=null,r=e){let i=Kn(e,t),a=i&&qn(r,t);return a?i.map(Gn).concat({type:t,attrs:n}).concat(a.map(Gn)):null}function Gn(e){return{type:e,attrs:null}}function Kn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function qn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Jn(e,t,n){let r=S.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=S.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new D(i,a,i,a,new w(r,0,0),n.length,!0))}function Yn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Qn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Zn(e,t,n,a),Bn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new D(c,l,c+1,l-1,new w(S.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Xn(e,t,n,a),!1}})}function Xn(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Zn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|