react-autoql 8.37.1 → 8.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autoql-index-885a2bac.cjs.js +3 -0
- package/dist/autoql-index-885a2bac.cjs.js.gz +0 -0
- package/dist/autoql-index-977e385b.esm.js +3 -0
- package/dist/autoql-index-977e385b.esm.js.gz +0 -0
- package/dist/autoql-onDemandCode-56da79db.esm.js +1 -0
- package/dist/autoql-onDemandCode-56da79db.esm.js.gz +0 -0
- package/dist/autoql-onDemandCode-e3788f3b.cjs.js +1 -0
- package/dist/autoql-onDemandCode-e3788f3b.cjs.js.gz +0 -0
- package/dist/autoql.cjs.js +1 -1
- package/dist/autoql.cjs.js.gz +0 -0
- package/dist/autoql.esm.css +1 -1
- package/dist/autoql.esm.css.gz +0 -0
- package/dist/autoql.esm.js +1 -1
- package/dist/autoql.esm.js.gz +0 -0
- package/package.json +1 -1
- package/src/index.d.ts +8 -3
- package/dist/autoql-index-7c06d9e7.cjs.js +0 -3
- package/dist/autoql-index-7c06d9e7.cjs.js.gz +0 -0
- package/dist/autoql-index-aa32533d.esm.js +0 -3
- package/dist/autoql-index-aa32533d.esm.js.gz +0 -0
- package/dist/autoql-onDemandCode-2202ca8a.esm.js +0 -1
- package/dist/autoql-onDemandCode-2202ca8a.esm.js.gz +0 -0
- package/dist/autoql-onDemandCode-407a71dd.cjs.js +0 -1
- package/dist/autoql-onDemandCode-407a71dd.cjs.js.gz +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,s as t,n,a as r,b as o,c as i,r as a,g as u,d as s,e as l,f as c,h as d,i as f,j as h,k as p,l as v,m,o as g,p as D,C as y,q as k,t as E,u as F,M as b,v as C,R as w,w as A,x,y as S,z as B,A as T,B as M,D as N,I as R,E as O,F as I,H as P,T as L,G as z,J as $,K as q,L as j,N as H,O as V,P as U,Q as W,S as _,U as K,V as J,W as Q,X as G,Y as X,Z,$ as Y,a0 as ee,a1 as te,a2 as ne,a3 as re,a4 as oe,a5 as ie,a6 as ae,a7 as ue,a8 as se,a9 as le,aa as ce,ab as de,ac as fe,ad as he,ae as pe,af as ve,ag as me,ah as ge,ai as De,aj as ye,ak as ke,al as Ee,am as Fe,an as be,ao as Ce,ap as we,aq as Ae,ar as xe,as as Se,at as Be,au as Te,av as Me,aw as Ne,ax as Re,ay as Oe,az as Ie,aA as Pe,aB as Le,aC as ze,aD as $e,aE as qe,aF as je,aG as He,aH as Ve,aI as Ue,aJ as We,aK as _e,aL as Ke,aM as Je,aN as Qe,aO as Ge,aP as Xe,aQ as Ze,aR as Ye,aS as et,aT as tt,aU as nt,aV as rt,aW as ot,aX as it,aY as at,aZ as ut,a_ as st,a$ as lt,b0 as ct,b1 as dt,b2 as ft,b3 as ht}from"./autoql-index-aa32533d.esm.js";import pt,{useRef as vt}from"react";import mt from"prop-types";import gt from"axios";import{v4 as Dt}from"uuid";import{DEFAULT_DATA_PAGE_SIZE as yt,getAuthentication as kt,fetchLLMSummary as Et,getDataFormatting as Ft,isColumnNumberType as bt,formatElement as Ct,deepEqual as wt,getAutoQLConfig as At,isChartType as xt,parseJwt as St,authenticationDefault as Bt,autoQLConfigDefault as Tt,dataFormattingDefault as Mt,REQUEST_CANCELLED_ERROR as Nt}from"autoql-fe-utils";import"lodash.isequal";import"react-device-detect";import"@react-icons/all-files/ai/AiOutlineBook";import"@react-icons/all-files/ai/AiOutlineBulb";import"@react-icons/all-files/ai/AiOutlineDashboard";import"@react-icons/all-files/ai/AiOutlineEdit";import"@react-icons/all-files/ai/AiOutlineFileText";import"@react-icons/all-files/ai/AiOutlineMenu";import"@react-icons/all-files/ai/AiOutlineQuestionCircle";import"@react-icons/all-files/ai/AiOutlineTag";import"@react-icons/all-files/ai/AiOutlineFileSearch";import"@react-icons/all-files/ai/AiOutlineNumber";import"@react-icons/all-files/bi/BiLineChart";import"@react-icons/all-files/bi/BiSearchAlt";import"@react-icons/all-files/bi/BiBookmark";import"@react-icons/all-files/bi/BiBook";import"@react-icons/all-files/bi/BiNote";import"@react-icons/all-files/bi/BiAbacus";import"@react-icons/all-files/bi/BiEnvelope";import"@react-icons/all-files/bi/BiEnvelopeOpen";import"@react-icons/all-files/bi/BiLayerPlus";import"@react-icons/all-files/bi/BiSelectMultiple";import"@react-icons/all-files/bs/BsArrowBarUp";import"@react-icons/all-files/bs/BsArrowBarDown";import"@react-icons/all-files/bs/BsLightning";import"@react-icons/all-files/fa/FaMicrophoneAlt";import"@react-icons/all-files/fi/FiAlertTriangle";import"@react-icons/all-files/fi/FiArrowLeft";import"@react-icons/all-files/fi/FiBell";import"@react-icons/all-files/fi/FiBellOff";import"@react-icons/all-files/fi/FiCalendar";import"@react-icons/all-files/fi/FiCheck";import"@react-icons/all-files/fi/FiDatabase";import"@react-icons/all-files/fi/FiDownload";import"@react-icons/all-files/fi/FiEye";import"@react-icons/all-files/fi/FiLayers";import"@react-icons/all-files/fi/FiMoreHorizontal";import"@react-icons/all-files/fi/FiMoreVertical";import"@react-icons/all-files/fi/FiPauseCircle";import"@react-icons/all-files/fi/FiPlus";import"@react-icons/all-files/fi/FiArrowUp";import"@react-icons/all-files/fi/FiSettings";import"@react-icons/all-files/fi/FiTrash2";import"@react-icons/all-files/fi/FiMaximize";import"@react-icons/all-files/fi/FiMinimize";import"@react-icons/all-files/fi/FiRefreshCw";import"@react-icons/all-files/fi/FiTool";import"@react-icons/all-files/fi/FiMinus";import"react-icons/fi";import"@react-icons/all-files/ri/RiFilterLine";import"@react-icons/all-files/ri/RiFilterOffLine";import"@react-icons/all-files/ri/RiListSettingsLine";import"@react-icons/all-files/ri/RiBroadcastFill";import"@react-icons/all-files/ri/RiDivideFill";import"@react-icons/all-files/go/GoReport";import"react-icons/hi";import"@react-icons/all-files/io/IoIosCloseCircleOutline";import"@react-icons/all-files/io/IoIosGlobe";import"@react-icons/all-files/io/IoIosHourglass";import"@react-icons/all-files/io/IoIosSearch";import"@react-icons/all-files/io/IoIosArrowDown";import"@react-icons/all-files/io/IoIosArrowUp";import"@react-icons/all-files/io/IoIosArrowBack";import"@react-icons/all-files/io/IoIosArrowForward";import"@react-icons/all-files/md/MdClose";import"@react-icons/all-files/md/MdContentCopy";import"@react-icons/all-files/md/MdError";import"@react-icons/all-files/md/MdInfoOutline";import"@react-icons/all-files/md/MdLock";import"@react-icons/all-files/md/MdLockOpen";import"@react-icons/all-files/md/MdPlayCircleOutline";import"@react-icons/all-files/md/MdAttachMoney";import"@react-icons/all-files/md/MdFunctions";import"react-icons/md";import"react-icons/rx";import"react-icons/tfi";import"react-tiny-popover";import"react-dom";import"react-tooltip";import"lodash.clonedeep";import"react-autosuggest";import"react-speech-recognition";import"dayjs";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/localizedFormat";import"dayjs/plugin/utc";import"dayjs/plugin/timezone";import"dayjs/plugin/isBetween";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/quarterOfYear";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/isSameOrBefore";import"dayjs/plugin/isToday";import"dayjs/plugin/minMax";import"react-perfect-scrollbar";import"react-perfect-scrollbar/dist/css/styles.css";import"classnames";import"react/jsx-runtime";import"d3-array";import"react-localization";import"react-grid-layout";import"pako";import"react-splitter-layout";import"react-modal";import"lodash.isempty";import"react-dom/server";import"tabulator-tables";import"lodash.throttle";import"tabulator-tables/dist/css/tabulator.min.css";import"tabulator-tables/dist/css/tabulator_bootstrap3.min.css";import"d3-shape";import"d3-selection";import"d3-transition";import"d3-axis";import"d3-scale";import"react-slider";import"jstat";import"d3-force";import"d3-zoom";import"d3-sankey";import"d3-hierarchy";import"lodash.filter";import"sql-formatter";import"parse-num";import"react-toastify";import"react-toastify/dist/ReactToastify.css";import"react-markdown";import"remark-breaks";import"lodash.debounce";import"react-grid-layout/css/styles.css";import"react-splitter-layout/lib/index.css";import"rc-drawer";import"react-infinite-scroller";import"lodash.has";import"rc-drawer/assets/index.css";import"recordrtc";var Rt={untitled:"Untitled report",titlePlaceholder:"Untitled report",titleLabel:"Report title",run:"Run report",runAgain:"Run again",running:"Running…",cancelRun:"Stop",openPreview:"Preview",backToEditing:"Back to editing",print:"Print…",printTitle:"Opens your browser’s print dialog. Choose “Save as PDF” to download a file.",printing:"Preparing…",zoom:{label:"Zoom",title:"How large the pages show here. They always print at their true size.",fit:function(e){return"Fit (".concat(e,"%)")},level:function(e){return"".concat(e,"%")}},addBlock:"Add a block",paletteHint:"Click a block to see what it does, then insert it.",newReport:"New report",getStarted:"Get started…",getStartedHint:"Start from a question, a dashboard, or a blank page.",paletteNote:"A Data block shows a dashboard tile exactly as its dashboard does, or answers a question.",paletteNoteCaptures:"To add data, use “Add to Report…” on a dashboard tile or an answer in the Query view.",paletteNoteDataBlocks:{tiles:"A Data block keeps a result as it was shown: a question you ask here, dashboard tiles you pick, or an answer added with “Add to Report…”.",ask:"A Data block keeps a result as it was shown: a question you ask here, or an answer added with “Add to Report…”."},dataDetails:{tiles:{what:"A result kept as it was shown: ask a question, or pick dashboard tiles. Nothing reruns by itself.",note:"The block arrives empty — ask it a question, or pick dashboard tiles for it."},ask:{what:"A result kept as it was shown: ask a question, and its answer stays as it came back.",note:"The block arrives empty — ask it a question."}},details:"Details",detailsSub:"Report blocks",previewSample:"Preview · sample data",insert:"Insert block",properties:"Properties",panelToggle:{label:"Properties panel",hide:"Hide the properties panel",show:"Show the properties panel"},resizePanel:"Resize the properties panel",resizePanelHint:"Drag to resize. Double-click to reset.",close:"Close",reportOptions:{label:"Report options",pageSetup:"Page setup",branding:"Branding…"},branding:{title:"Branding",what:"Applies to every report in your organisation. Stored centrally, never on one report.",sample:"Top of every page, and on the cover",sampleBody:"Body text is set in your body font.",name:"Organisation name",nameRequired:"Add your organisation’s name.",logo:"Logo",logoNote:"Your mark or symbol, shown before your name or wordmark.",wordmark:"Wordmark",wordmarkNote:"Your name set as an image, or your whole lockup. It takes the place of the name.",imageNote:"A PNG, JPEG, SVG or WebP image of 256 KB or less.",none:"None",upload:"Upload…",replace:"Replace…",remove:"Remove",imageTooLarge:function(e){return"That image is ".concat(e," KB. Use one of 256 KB or less.")},imageWrongType:"Use a PNG, JPEG, SVG or WebP image.",imageUnreadable:"That image couldn’t be read. Try another one.",position:"Position",positions:[["left","Left"],["center","Center"],["right","Right"]],positionNote:"Where the logo and wordmark sit, in each page’s header and on the cover.",colours:"Brand colours",colourLabel:function(e){return"Brand colour ".concat(e)},colourPick:function(e){return"Pick brand colour ".concat(e)},colourPlaceholder:"#1B4D8F or 27, 77, 143",addColour:"Add a colour",removeColour:function(e){return"Remove brand colour ".concat(e)},colourInvalid:"Use HEX, like #1B4D8F, or RGB, like 27, 77, 143.",coloursNote:function(e){return"Up to ".concat(e,", as HEX or RGB. They’re offered in the colour pickers for text and backgrounds.")},fonts:"Fonts",headingFont:"Headings",bodyFont:"Body text",fontSample:"Aa Bb Cc 123",fontNote:"WOFF2, WOFF, TTF or OTF files of 500 KB or less. Reports on the Theme default typeface use them, on screen and in print; charts keep AutoQL’s own type. Check that your font licence allows embedding.",fontTooLarge:function(e){return"That font is ".concat(e," KB. Use one of 500 KB or less.")},fontWrongType:"Use a WOFF2, WOFF, TTF or OTF font file.",fontUnreadable:"That font couldn’t be read. Try another file.",fontFallbackName:"Brand font",unsaved:"Unsaved changes.",saved:"Saved for your organisation.",saving:"Saving…",saveFailed:"Your branding wasn’t saved. Try again.",discard:"Discard",save:"Save branding"},formatting:{toolbar:"Text formatting",style:"Text style",paragraph:"Normal text",heading:"Heading",subheading:"Subheading",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",bulletList:"Bulleted list",orderedList:"Numbered list",link:"Link",clear:"Clear formatting",linkAddress:"Link address",linkPlaceholder:"Paste or type a link",linkApply:"Apply",linkRemove:"Remove link",linkCancel:"Cancel",linkInvalid:"Use a web address, like example.com, or an email address.",hint:"Click into a paragraph or an analysis to format it."},blockRemoved:"Block deleted.",undoRemove:"Undo",emptyReportTitle:"This report is empty",emptyReportBody:"Add a block from the left. A Data block reads a dashboard tile, or asks a question of its own.",frontMatter:{both:"Starts with a cover page and a table of contents. See them in Preview.",cover:"Starts with a cover page. See it in Preview.",toc:"Starts with a table of contents. See it in Preview."},headingPlaceholder:"Heading",headingNewLine:function(e){return"Shift + ".concat(e?"Return":"Enter"," for a new line")},textPlaceholder:"Write anything here — context, a caveat, what the reader should take away.",pageBreak:"Page break",analyzeResult:"Auto Analyze this result (uses one credit)",moveUp:"Move up",moveDown:"Move down",duplicate:"Duplicate",remove:"Delete",data:{emptyTitle:"What should this block show?",emptyBody:"Ask a question, or pick a dashboard tile in the panel on the right.",askPlaceholder:"Type a query in your own words",pickTiles:"Pick dashboard tiles…",picking:"Picking tiles…",pickBody:"Each tile you pick becomes a Data block here, as its dashboard shows it now.",or:"or",askBody:"Press Enter to ask. The answer is kept as it comes back; nothing reruns by itself.",asking:function(e){return"Asking “".concat(e,"”…")},askFailed:{error:"That question didn’t run.","no-data":"That question came back with no data to show.",unsupported:"That answer can’t be kept in a report yet."},notRun:"Run the report to load this.",noCapture:"No data was kept for this block. Add it again with “Add to Report…” from its dashboard or the Query view.",asOf:function(e){return"As of ".concat(e)},filteredBy:function(e){return"Filtered: ".concat(e)},loading:"Loading…",stale:"Changed since the last run. Run the report to update it.",missing:"This tile is no longer on its dashboard.",unsupported:{unsupported:"This kind of tile can’t be printed yet.","no-query":"This tile has no query to run."},error:"This query didn’t run.",continued:"Continued on the next page",continuedTitle:"(continued)",interpretedAs:"Interpreted as",askedAs:"Asked as",total:"Total"},analysis:{emptyTitle:"Nothing written yet",emptyBody:"Choose a result in the panel on the right, then Analyze.",emptyReady:"Analyze in the panel on the right to write about this result.",emptyBlocked:"Auto Analyze can’t write about this result. Choose another in the panel on the right.",writing:"Auto Analyze is writing…",source:"Auto Analyze",from:function(e){return"from “".concat(e,"”")},focus:function(e){return"focus: ".concat(e)},targetGone:"The result this was written about has been removed from the report.",targetChanged:"Its result has changed since this was written. Analyze again to update the wording.",failed:"Auto Analyze couldn’t write this."},panel:{pageSetup:"Page setup",orientation:"Orientation",margins:"Margins",typeface:"Typeface",typefaceNote:"Applies to the whole report — headings, text and tables. Charts keep the product’s own type.",themeBrandFonts:"Theme default (brand fonts)",brandSwatch:function(e,t){return"Brand colour ".concat(e," (").concat(t.toUpperCase(),")")},headerFooter:"Running header & footer",header:"Header on every page",footer:"Footer on every page",pageNumbers:"Page numbers",repeatTableHeaders:"Repeat table headers",results:"Results",showInterpretation:"Show how each question was read",showInterpretationNote:"Prints AutoQL’s interpretation under each result, so a forwarded PDF can be checked. Answers added from a dashboard tile don’t have one yet.",frontMatter:"Front matter",coverPage:"Cover page",tableOfContents:"Table of contents",nothingSelected:"Select a block to change it. Blocks follow the theme until you override them.",level:"Level",headingNote:function(e){return"Click the heading on the page to edit its words. Shift + ".concat(e?"Return":"Enter"," starts a new line.")},textNote:"Click the paragraph on the page to edit it.",pageBreakNote:"Everything after this starts on a new page. No settings.",unknownNote:"This block was made by a newer version of the report builder. It’s kept as it is.",text:"Text",font:"Font",size:"Size",weight:"Weight",textColour:"Text colour",block:"Block",width:"Width",align:"Align",background:"Background",resetToTheme:"Reset to theme",themeNote:"Left on the defaults, blocks follow the theme your organisation has configured.",default:"Default",themeDefault:"Theme default",none:"None",customColour:"Custom colour",source:"Source",dashboard:"Dashboard",tile:"Tile",question:"Question",sourceNote:"Chart type, columns, sorting and number format come from this tile. To change how it looks, edit the tile on its dashboard — every report that uses it follows.",captured:"Captured",capturedNote:"This is what the answer showed when it was added — its data, sorting, filters, columns and chart settings — kept as it was. Add it again to update it.",noCaptureNote:"Data blocks come from “Add to Report…” on a dashboard tile or an answer in the Query view.",pickTilesNote:"Each tile you pick becomes a Data block of its own, kept as its dashboard shows it now. Nothing reruns by itself.",askCaptureNote:"Press Enter to ask. The answer is kept as it comes back — nothing reruns by itself.",orTiles:"or pick dashboard tiles",askedNote:"This is the answer as it came back when the question was asked, kept as it was.",rerun:"Rerun",rerunning:"Asking again…",rerunNote:"Asks the question again, and keeps the new answer in place of this one.",analysisResult:"Result",chooseResult:"Choose a result…",removedResult:"A result that was removed",thisResult:"This result",noResults:"Add a Data block with a result to the report first.",focus:"Focus (optional)",focusPlaceholder:"e.g., “Anomaly detection”",analyze:"Analyze",analyzeAgain:"Analyze again",analyzing:"Analyzing…",analyzeNote:"The same Auto Analyze an answer has. Each run uses one Auto Analyze credit.",analyzeAgainNote:"Replaces the wording on the page. Each run uses one Auto Analyze credit.",cantAnalyze:"This result can’t be analyzed: it was kept without the query id Auto Analyze needs. Add it again to analyze it.",cantAnalyzeTooLittle:"Auto Analyze needs more than one row to write about, so it isn’t offered for this result, as in the Query view and on dashboards.",cantAnalyzeOption:function(e,t){return"".concat(e,"no-query-id"===t?" (kept without a query id)":" (too little to analyze)")},wording:"Wording",wordingNote:"Edit the wording on the page, formatting it with the bar that appears above it. It prints as written, and Analyze again replaces it.",questionNote:"A question has no tile to inherit from, so it shows AutoQL’s default display.",changeSource:"Change source",cancel:"Cancel",askQuestion:"Ask a question",askNote:"Press Enter to use it. It runs with the rest of the report.",orExisting:"or use existing data",chooseDashboard:"Choose a dashboard…",chooseTile:"Choose a tile…",noDashboards:"No dashboards are available.",hiddenTiles:function(e){return"".concat(e," ").concat(1===e?"tile isn’t":"tiles aren’t"," listed: pivot tables, network graphs, Sankey charts and treemaps can’t be printed yet.")},showAs:"Show as",displayTypes:{table:"Table",column:"Column Chart",bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",heatmap:"Heatmap",bubble:"Bubble Chart",stacked_bar:"Stacked Bar Chart",stacked_column:"Stacked Column Chart",stacked_line:"Stacked Area Chart",column_line:"Column Line Combo Chart",histogram:"Histogram",scatterplot:"Scatterplot"},chartOfSlice:function(e,t){return"The chart draws the ".concat(Number(e).toLocaleString()," rows this block keeps, not all ").concat(Number(t).toLocaleString(),".")},axesNote:"Click an axis title on the chart to choose which column it shows. It prints that way.",rows:"Rows to include",rowsCap:function(e){return"A printed page can’t scroll, so a table shows at most ".concat(e," rows.")},rowsRanked:function(e){return" These are the top rows by ".concat(e," — the tile’s own order.")},rowsRankedUnnamed:" These are the top rows in the tile’s own order.",rowsUnranked:function(e){return" The tile isn’t sorted, so these are the first ".concat(e," rows as returned, not a top ").concat(e,". Sort the tile on its dashboard to rank them.")},rowsQuestion:function(e){return" Nothing sorts a question’s rows, so these are the first ".concat(e," as returned.")},rowsCaptured:function(e){return" These are the top rows by ".concat(e,", sorted as the table was when it was added.")},rowsCapturedUnnamed:" These are the top rows, sorted as the table was when it was added.",rowsCapturedUnsorted:function(e){return" The table wasn’t sorted when it was added, so these are its first ".concat(e," rows, not a top ").concat(e,". To rank them, sort the table and add it again.")},rowsNoTotal:" No total is shown while the table is cut off — only the server can total the full result."},preview:{title:"Print preview",measuring:"Laying out pages…",pages:function(e){return"".concat(e," ").concat(1===e?"page":"pages")},letter:"Letter",overflow:"Taller than a page — it will be cut off.",overflowNotice:function(e){return"".concat(e," ").concat(1===e?"page has":"pages have"," a block taller than a page, which will be cut off when printed.")},chartsTimedOut:function(e){return"".concat(e," ").concat(1===e?"chart hadn’t":"charts hadn’t"," finished drawing and may print blank.")},contents:"Contents",generated:"Generated",dataAsOf:"Data as of",page:function(e,t){return"Page ".concat(e," of ").concat(t)},notRunYet:"Not yet run"}},Ot=["style"],It=["style"],Pt=["displayType","askedHere"],Lt=function(e,t){return e.blocks.findIndex(function(e){return e.id===t})},zt=function(t,n){return e(e({},t),{},{blocks:n})},$t=function(e,t,n){var r=e.blocks.slice(),o=n?Lt(e,n):-1;return r.splice(o>-1?o+1:r.length,0,t),zt(e,r)},qt=function(n,r,o){return zt(n,n.blocks.map(function(n){if(n.id!==r)return n;var i=e(e({},n),o);return"data"===i.type&&"rows"in o&&(i.rows=t(o.rows)),i}))},jt=function(t){var n,r,o=t.block,a=t.tile,u=t.result,s=t.base,l=u.response,k=(null==l||null===(n=l.data)||void 0===n?void 0:n.data)||{},E=Array.isArray(k.rows)?k.rows:[],F=E.length,b=u.countRows,C=null!==(r=u.pageSize)&&void 0!==r?r:yt,w=a?c(a,l).columnOverrides:void 0,A=function(t,n){return t.map(function(t){var r=null==n?void 0:n[t.index];return r?e(e(e({},t),r.type?{type:r.type}:{}),r.precision?{precision:r.precision}:{}):t})}(Array.isArray(k.columns)?k.columns:[],w),x=null==a?void 0:a.orders,S=d(l),B=o.displayType?f(l,o.displayType):null,T=B&&B.displayType===o.displayType?B:f(l,null==a?void 0:a.displayType),M="single-value"===T.kind?[]:h(l);if("table"===T.kind){var N=p(A,a),R=Math.min(o.rows,F),O=E.slice(0,R),I=v({included:R,fetched:F,countRows:b,pageSize:C});return e(e({},s),{},{state:"ready",kind:"table",displayType:"table",displayOptions:M,interpretation:S,columns:N,rows:O,countRows:b,complete:I,orderLabel:m(x,A),caption:g({shown:R,total:b,complete:I,orders:x,columns:A}),total:D({rows:O,columns:N,aggConfig:null==a?void 0:a.aggConfig,complete:I}),split:"full"===o.width})}if("single-value"===T.kind){var P,L,z=p(A,a),$=i(z,1)[0],q=void 0===$?A[0]:$;return e(e({},s),{},{state:"ready",kind:"single-value",interpretation:S,column:q,value:null===(P=E[0])||void 0===P?void 0:P[null!==(L=null==q?void 0:q.index)&&void 0!==L?L:0]})}var j=v({included:F,fetched:F,countRows:b,pageSize:C});return e(e({},s),{},{tile:a,state:"ready",kind:"chart",displayType:T.displayType,displayOptions:M,interpretation:S,response:l,height:"half"===o.width?y.half:y.full,rowCount:F,countRows:b,complete:j,caption:g({shown:F,total:b,complete:j,orders:x,columns:A})})},Ht=function(t){var n,r,o=t.config||{},i=t.data.columns,a=null===(n=t.table)||void 0===n?void 0:n.columnIndices,u=o.columnVisibility;if(Array.isArray(a)&&a.length){var s=new Set(a);u={},i.forEach(function(e,t){null!=e&&e.name&&(u[e.name]=s.has(t))}),r=a.map(function(e){var t;return null===(t=i[e])||void 0===t?void 0:t.name}).filter(Boolean)}return e(e({},o),{},{displayType:t.displayType,columnVisibility:u,columnOrder:r,frozenColumns:void 0,orders:t.table?t.table.sort:o.orders})},Vt=function(t,n){return null!=n&&n.dataConfig||null!=n&&n.aggConfig?e(e(e({},t||{}),n.dataConfig?{dataConfig:n.dataConfig}:{}),n.aggConfig?{aggConfig:n.aggConfig}:{}):t},Ut=new WeakMap,Wt=function(t){var n=t.block,r=t.tileIndex,o=t.result,i=t.requestKey,c=t.running,d=void 0!==c&&c,f=(n||{}).source,h=function(e){var t,n;return!!e&&"object"===k(e)&&Array.isArray(null===(t=e.data)||void 0===t?void 0:t.rows)&&Array.isArray(null===(n=e.data)||void 0===n?void 0:n.columns)}(null==n?void 0:n.capture)?n.capture:null;if(!f&&!h)return{state:"empty"};var p="tile"===(null==f?void 0:f.type)?a(r||{},f):null,v=null==p?void 0:p.tile,m=e(e({},function(e,t){var n,r,o,i,a,u,s,c,d,f=e.source;if(!f){var h,p=null===(h=e.capture)||void 0===h||null===(h=h.data)||void 0===h?void 0:h.text;return{title:p||"Untitled",dashboardName:null,tileTitle:null,query:p}}if("query"===f.type)return{title:f.query,dashboardName:null,tileTitle:null,query:f.query};var v=null==t?void 0:t.tile;return{title:v?l(v):(null===(n=f.snapshot)||void 0===n?void 0:n.tileTitle)||(null===(r=f.snapshot)||void 0===r?void 0:r.query)||"Untitled",dashboardName:null!==(o=null!==(i=null==t||null===(a=t.dashboard)||void 0===a?void 0:a.name)&&void 0!==i?i:null===(u=f.snapshot)||void 0===u?void 0:u.dashboardName)&&void 0!==o?o:null,tileTitle:v?l(v):null!==(s=null===(c=f.snapshot)||void 0===c?void 0:c.tileTitle)&&void 0!==s?s:null,query:v?v.query:null===(d=f.snapshot)||void 0===d?void 0:d.query}}(n,p)),{},{sourceType:null==f?void 0:f.type,tile:v,dashboard:null==p?void 0:p.dashboard}),g=!!o&&o.requestKey===i&&"success"===o.status;if(h&&!g&&!d){var D,y=function(t){return Ut.has(t)||Ut.set(t,{status:"success",response:{data:{reference_id:"1.1.200",data:e({display_type:"data"},t.data)}},countRows:"number"==typeof t.data.count_rows?t.data.count_rows:null,tile:Ht(t)}),Ut.get(t)}(h),E=Vt(y.tile,n);return jt({block:n,tile:E,result:y,base:e(e({},m),{},{tile:E,capturedAt:h.capturedAt,filterLabel:u(null===(D=h.table)||void 0===D?void 0:D.filters,h.data.columns)})})}if("tile"===(null==f?void 0:f.type)){if(!p)return e(e({},m),{},{state:"missing"});var F=s(v);if(!F.supported)return e(e({},m),{},{state:"unsupported",reason:F.reason,displayType:v.displayType})}return o?o.requestKey!==i?e(e({},m),{},{state:d?"loading":"stale"}):"cancelled"===o.status?e(e({},m),{},{state:"not-run"}):"error"===o.status?e(e({},m),{},{state:"error",error:o.error}):jt({block:n,tile:Vt(v,n),result:o,base:m}):e(e({},m),{},{state:d?"loading":"not-run"})},_t=function(e){return Number(e).toLocaleString()},Kt=function(e){return String(null!=e?e:"").replace(/\\n/g,"\n")},Jt=function(e){var t,n=e.target,r=e.targetView,o=null==n||null===(t=n.capture)||void 0===t?void 0:t.data;return o&&"ready"===(null==r?void 0:r.state)?o.query_id?E(!0,{data:{data:o}})?null:"too-little":"no-query-id":"not-ready"},Qt=function(e){var t=e.target,n=e.targetView;if(Jt({target:t,targetView:n}))return null;var r=t.capture,o=r.data,i=Array.isArray(o.rows)?o.rows:[],a="table"===n.kind?n.rows:i,u="number"==typeof o.count_rows?o.count_rows:i.length,s=a.length<u?"first ".concat(_t(a.length)," of ").concat(_t(u)," rows"):null,l=n.title||o.text||"",c=o.text||l;return{queryId:o.query_id,text:s?"".concat(c,", ").concat(s):c,interpretation:"string"==typeof o.interpretation?o.interpretation:"",rows:a,columns:o.columns,asOf:r.capturedAt,title:l}},Gt=function(e){var t,n=e.block,r=e.target,o=e.targetView,i=r?Qt({target:r,targetView:o}):null,a=!!(n.text||"").trim();return{state:a?"written":"empty",text:n.text||"",fromTitle:n.targetTitle||(null==i?void 0:i.title)||null,focusUsed:n.focusUsed||"",writtenAt:n.writtenAt||null,targetGone:!!n.target&&!r,targetChanged:a&&!!r&&!!n.targetAsOf&&(null===(t=r.capture)||void 0===t?void 0:t.capturedAt)!==n.targetAsOf,canAnalyze:!!i,blocker:r?Jt({target:r,targetView:o}):null,input:i}},Xt=function(e,t){return e.filter(function(e){var n;return"data"===e.type&&"ready"===(null===(n=t[e.id])||void 0===n?void 0:n.state)}).map(function(e){var n=t[e.id];return{id:e.id,label:"query"===n.sourceType?"“".concat(n.title,"”"):n.title,blocker:Jt({target:e,targetView:n})}})},Zt=8.5,Yt=11,en=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n="landscape"===t.orientation,r=n?Yt:Zt,o=n?Zt:Yt,i=null!==(e=C[t.margins])&&void 0!==e?e:C.normal,a=t.header?.55:0,u=t.footer||t.pageNumbers?.35:0,s=r-2*i,l=o-2*i-a-u;return{orientation:n?"landscape":"portrait",widthIn:r,heightIn:o,marginIn:i,headerIn:a,footerIn:u,contentWidthIn:s,contentHeightIn:l,contentWidthPx:Math.round(96*s),contentHeightPx:Math.round(96*l)}},tn="data-report-chart",nn="[".concat(tn,"]"),rn=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.timeout,o=void 0===r?15e3:r,i=n.interval,a=void 0===i?100:i,u=n.signal;return new Promise(function(n){var r,i,s=Date.now(),l=function(){var r=function(e){var t=e?Array.from(e.querySelectorAll(nn)):[],n={total:t.length,ready:0,failed:0,pending:0};return t.forEach(function(e){n[function(e){return e?e.querySelector(".query-output-error-message")?"failed":e.querySelector(".react-autoql-chart-container svg")&&!e.querySelector(".react-autoql-chart-loading")?"ready":"pending":"pending"}(e)]+=1}),n}(t),c=!(null==u||!u.aborted),d=!c&&r.pending>0&&Date.now()-s>=o;0===r.pending||d||c?n(e(e({},r),{},{timedOut:d,aborted:c})):i=setTimeout(l,a)};null==u||null===(r=u.addEventListener)||void 0===r||r.call(u,"abort",function(){clearTimeout(i),l()}),l()})},on=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"!=typeof document?document:void 0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3,o=null==n||null===(e=n.fonts)||void 0===e?void 0:e.ready;if(!o||"function"!=typeof o.then)return Promise.resolve(!1);var i=new Promise(function(e){t=setTimeout(function(){return e(!1)},r)});return Promise.race([o.then(function(){return!0},function(){return!1}),i]).then(function(e){return clearTimeout(t),e})},an=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"undefined"!=typeof document?document:void 0;if(!e||null==n||null===(t=n.fonts)||void 0===t||!t.load)return Promise.resolve();var r=e.split(","),o=i(r,1)[0];return Promise.all([n.fonts.load("400 12pt ".concat(o)),n.fonts.load("700 12pt ".concat(o))]).then(function(){},function(){})},un="".concat(w,"-page"),sn=function(e){return String(null!=e?e:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},ln=function(e){return String(e).replace(/<\/(style)/gi,"<\\/$1")},cn=function(e){try{var t=null==e?void 0:e.cssRules;return t&&t.length?Array.from(t).map(function(e){return e.cssText}).join("\n"):null}catch(e){return null}},dn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=[];return e.querySelectorAll('link[rel~="stylesheet"], style').forEach(function(e){var n,r;if(!(null!==(n=e.sheet)&&void 0!==n&&n.disabled||e.disabled)){var o=e.media?' media="'.concat(sn(e.media),'"'):"";if("LINK"!==e.tagName){var i=null!==(r=cn(e.sheet))&&void 0!==r?r:e.textContent;i&&i.trim()&&t.push("<style".concat(o,">").concat(ln(i),"</style>"))}else if(e.href){var a=e.crossOrigin?' crossorigin="'.concat(sn(e.crossOrigin),'"'):"";t.push('<link rel="stylesheet" href="'.concat(sn(e.href),'"').concat(o).concat(a,">"))}}}),(e.adoptedStyleSheets||[]).forEach(function(e){var n=cn(e);n&&t.push("<style>".concat(ln(n),"</style>"))}),t.join("\n")},fn=function(e){var t;return Array.from((null===(t=e.documentElement)||void 0===t?void 0:t.attributes)||[]).map(function(e){var t=e.name,n=e.value;return" ".concat(t,'="').concat(sn(n),'"')}).join("")},hn=function(){var e="landscape"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"portrait"),t=e?Zt:Yt;return"\n@page { size: letter ".concat(e?"landscape":"portrait","; margin: 0; }\nhtml, body {\n margin: 0 !important; padding: 0 !important; background: #fff !important;\n width: auto !important; height: auto !important; min-height: 0 !important; overflow: visible !important;\n}\nbody { -webkit-print-color-adjust: exact; print-color-adjust: exact; }\n.").concat(w,"-print-root { display: block !important; }\n.").concat(un," {\n margin: 0 !important; box-shadow: none !important; overflow: hidden !important;\n height: calc(").concat(t,"in - 1px) !important;\n break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;\n}\n.").concat(un,":last-child { break-after: auto; page-break-after: auto; }\n")},pn=function(e,t){var n=Array.from((null==e?void 0:e.images)||[]).filter(function(e){return!e.complete});if(!n.length)return Promise.resolve();var r=n.map(function(e){return new Promise(function(t){e.addEventListener("load",t,{once:!0}),e.addEventListener("error",t,{once:!0})})});return Promise.race([Promise.all(r),new Promise(function(e){return setTimeout(e,t)})])},vn=function(e){e.focus(),e.print()},mn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.pages,n=e.title,r=void 0===n?"":n,o=e.orientation,i=void 0===o?"portrait":o,a=e.doc,u=void 0===a?document:a,s=e.print,l=void 0===s?vn:s,c=e.assetTimeout,d=void 0===c?5e3:c,f=Array.from(t||[]).map(function(e){return e.outerHTML}).join(""),h="landscape"===i,p=u.createElement("iframe");p.className="".concat(w,"-print-frame"),p.setAttribute("aria-hidden","true"),p.setAttribute("tabindex","-1"),p.title=r||"Report",Object.assign(p.style,{position:"fixed",left:"-10000px",top:"0",width:"".concat(h?Yt:Zt,"in"),height:"".concat(h?Zt:Yt,"in"),border:"0"});var v=u.title,m=!1,g=!1,D=function(){},y=function(){var e;m||(m=!0,r&&u.title===r&&(u.title=v),null===(e=p.parentNode)||void 0===e||e.removeChild(p),g||D(!1))},k=new Promise(function(e,t){var n=!1;D=function(r,o){n||(n=!0,o?t(o):e(r))},p.addEventListener("load",function(){var e=p.contentWindow,t=p.contentDocument;Promise.all([pn(t,d),on(t,d)]).then(function(){m||(e.addEventListener("afterprint",y,{once:!0}),r&&(u.title=r),g=!0,l(e),D(!0))}).catch(function(e){D(void 0,e),y()})},{once:!0})});return p.srcdoc=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.doc,n=void 0===t?document:t,r=e.pagesHtml,o=void 0===r?"":r,i=e.title,a=void 0===i?"":i,u=e.orientation,s=void 0===u?"portrait":u;return["<!doctype html>","<html".concat(fn(n),">"),"<head>",'<meta charset="utf-8">','<base href="'.concat(sn(n.baseURI),'">'),"<title>".concat(sn(a),"</title>"),dn(n),"<style data-report-print>".concat(hn(s),"</style>"),"</head>",'<body class="'.concat(w,'-print-body"><div class="').concat(w,'-print-root">').concat(o,"</div></body>"),"</html>"].join("\n")}({doc:u,pagesHtml:f,title:r,orientation:i}),u.body.appendChild(p),{frame:p,remove:y,printed:k}},gn="fit",Dn=[.5,.75,1,1.25,1.5],yn="react-autoql-report-builder-zoom",kn=function(){try{var e=window.localStorage.getItem(yn),t=Number(e);return null!==e&&Dn.includes(t)?t:gn}catch(e){return gn}},En=function(e,t){return e>0&&t>0?Math.max(.25,Math.min(1,Math.floor(e/t*100)/100)):1},Fn=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"frameRef",pt.createRef()),S(e,"contentRef",pt.createRef()),S(e,"state",{available:0,width:0,height:0}),S(e,"measure",function(){var t,n=e.contentRef.current,r=null===(t=e.frameRef.current)||void 0===t?void 0:t.parentElement;if(n&&r){var o=window.getComputedStyle(r),i=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),a=r.clientWidth-i,u=n.offsetWidth,s=n.offsetHeight;a===e.state.available&&u===e.state.width&&s===e.state.height||e.setState({available:a,width:u,height:s})}}),S(e,"reportFit",function(){var t,n,r=En(e.state.available,e.state.width);r!==e.reportedFit&&(e.reportedFit=r,null===(t=(n=e.props).onFit)||void 0===t||t.call(n,r))}),S(e,"getScale",function(){var t=e.state,n=t.available,r=t.width;return n>0&&r>0?e.props.zoom===gn?En(n,r):e.props.zoom:1}),e}return A(t,e),x(t,[{key:"componentDidMount",value:function(){var e,t=this;if(this.measure(),this.reportFit(),"undefined"!=typeof ResizeObserver){this.observer=new ResizeObserver(function(){return t.measure()});var n=null===(e=this.frameRef.current)||void 0===e?void 0:e.parentElement;n&&this.observer.observe(n),this.contentRef.current&&this.observer.observe(this.contentRef.current)}}},{key:"componentDidUpdate",value:function(){this.reportFit()}},{key:"componentWillUnmount",value:function(){var e;null===(e=this.observer)||void 0===e||e.disconnect()}},{key:"render",value:function(){var e=this.getScale(),t=this.state,n=t.width,r=t.height,o=1!==e&&n>0&&r>0,i=o?S({},B,String(e)):{};return pt.createElement("div",{ref:this.frameRef,className:"".concat(w,"-zoom-frame"),style:o?{width:n*e,height:r*e}:void 0,"data-test":"report-builder-zoom-frame"},pt.createElement("div",T({ref:this.contentRef,className:"".concat(w,"-zoom-content"),style:o?{transform:"scale(".concat(e,")"),"--react-autoql-report-builder-zoom":e}:void 0},i),this.props.children))}}])}(pt.Component);S(Fn,"defaultProps",{zoom:gn,onFit:void 0});var bn=0,Cn=function(e){function t(e){var n;return M(this,t),n=N(this,t,[e]),S(n,"focusButton",function(){var e,t;return null===(e=n.buttonRef.current)||void 0===e||null===(t=e.focus)||void 0===t?void 0:t.call(e)}),S(n,"onDocumentMouseDown",function(e){var t;null!==(t=n.rootRef.current)&&void 0!==t&&t.contains(e.target)||n.setState({open:!1})}),S(n,"toggle",function(){return n.setState(function(e){return{open:!e.open}})}),S(n,"choose",function(e){return n.setState({open:!1},e)}),S(n,"onMenuKeyDown",function(e){var t=n.itemRefs.filter(Boolean),r=t.indexOf(document.activeElement),o=function(e){var n;return null===(n=t[(e+t.length)%t.length])||void 0===n?void 0:n.focus()};"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),n.setState({open:!1},n.focusButton)):"ArrowDown"===e.key?(e.preventDefault(),o(r+1)):"ArrowUp"===e.key?(e.preventDefault(),o(r-1)):"Home"===e.key?(e.preventDefault(),o(0)):"End"===e.key?(e.preventDefault(),o(t.length-1)):"Tab"===e.key&&n.setState({open:!1})}),bn+=1,n.menuId="".concat(w,"-options-menu-").concat(bn),n.rootRef=pt.createRef(),n.buttonRef=pt.createRef(),n.itemRefs=[],n.state={open:!1},n}return A(t,e),x(t,[{key:"componentDidUpdate",value:function(e,t){var n,r;this.state.open&&!t.open?(document.addEventListener("mousedown",this.onDocumentMouseDown),null===(n=this.itemRefs[0])||void 0===n||null===(r=n.focus)||void 0===r||r.call(n)):!this.state.open&&t.open&&document.removeEventListener("mousedown",this.onDocumentMouseDown)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.onDocumentMouseDown)}},{key:"render",value:function(){var e=this,t=this.props,n=t.onPageSetup,r=t.onBranding,o=this.state.open,i=[{key:"page-setup",label:Rt.reportOptions.pageSetup,action:n},r?{key:"branding",label:Rt.reportOptions.branding,action:r}:null].filter(Boolean);return this.itemRefs=[],pt.createElement("span",{className:"".concat(w,"-options"),ref:this.rootRef},pt.createElement("button",{ref:this.buttonRef,type:"button",className:"".concat(w,"-button ").concat(w,"-options-button"),"aria-label":Rt.reportOptions.label,title:Rt.reportOptions.label,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?this.menuId:void 0,"data-test":"report-builder-options",onClick:this.toggle},pt.createElement(R,{name:"more",size:15})),o?pt.createElement("div",{id:this.menuId,className:"".concat(w,"-menu"),role:"menu","aria-label":Rt.reportOptions.label,onKeyDown:this.onMenuKeyDown},i.map(function(t,n){var r=t.key,o=t.label,i=t.action;return pt.createElement("button",{key:r,ref:function(t){e.itemRefs[n]=t},type:"button",role:"menuitem",tabIndex:-1,className:"".concat(w,"-menu-item"),"data-test":"report-builder-options-".concat(r),onClick:function(){return e.choose(i)}},o)})):null)}}])}(pt.Component),wn=function(e){var t=e.title,n=e.onTitleChange,r=e.runLabel,o=e.running,i=e.highlightRun,a=e.hasRun,u=e.canRun,s=e.onRun,l=e.onCancelRun,c=e.showRun,d=void 0===c||c,f=e.previewOpen,h=e.previewMeta,p=e.onOpenPreview,v=e.onClosePreview,m=e.printing,g=e.onPrint,D=e.status,y=e.zoom,k=void 0===y?gn:y,E=e.fitScale,F=void 0===E?1:E,b=e.onZoomChange,C=e.panelOpen,A=void 0===C||C,x=e.panelId,S=e.onTogglePanel,B=e.optionsRef,T=e.onPageSetup,M=e.onBranding;return pt.createElement("div",{className:"".concat(w,"-toolbar"),role:"toolbar","aria-label":Rt.titleLabel},f?pt.createElement("div",{className:"".concat(w,"-toolbar-title"),"data-readonly":""},pt.createElement("span",{className:"".concat(w,"-toolbar-heading")},Rt.preview.title),h?pt.createElement("span",{className:"".concat(w,"-toolbar-meta")},h):null):pt.createElement("input",{type:"text",className:"".concat(w,"-title-input"),value:t,placeholder:Rt.titlePlaceholder,"aria-label":Rt.titleLabel,"data-test":"report-builder-title",onChange:function(e){return n(e.target.value)}}),pt.createElement("div",{className:"".concat(w,"-toolbar-actions")},D?pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-toolbar-status"),"data-test":"report-builder-toolbar-status"},D),pt.createElement("span",{className:"".concat(w,"-toolbar-separator"),"aria-hidden":"true"})):null,d?pt.createElement(pt.Fragment,null,pt.createElement("span",{className:"".concat(w,"-run-label"),"data-attention":i||void 0,"aria-live":"polite"},r),o?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),onClick:l},Rt.cancelRun):pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-variant":i?"primary":void 0,disabled:!u,"data-test":"report-builder-run",onClick:s},pt.createElement(R,{name:"play",size:13}),a?Rt.runAgain:Rt.run),pt.createElement("span",{className:"".concat(w,"-toolbar-separator"),"aria-hidden":"true"})):null,b?pt.createElement("span",{className:"".concat(w,"-zoom")},pt.createElement("select",{className:"".concat(w,"-select ").concat(w,"-zoom-select"),"aria-label":Rt.zoom.label,title:Rt.zoom.title,value:String(k),"data-test":"report-builder-zoom",onChange:function(e){return b(e.target.value===gn?gn:Number(e.target.value))}},pt.createElement("option",{value:gn},Rt.zoom.fit(Math.round(100*F))),Dn.map(function(e){return pt.createElement("option",{key:e,value:String(e)},Rt.zoom.level(Math.round(100*e)))})),pt.createElement(R,{name:"down",size:12})):null,!f&&S?pt.createElement("button",{type:"button",className:"".concat(w,"-button ").concat(w,"-panel-toggle"),"aria-label":Rt.panelToggle.label,"aria-expanded":A,"aria-controls":A?x:void 0,title:A?Rt.panelToggle.hide:Rt.panelToggle.show,"data-test":"report-builder-panel-toggle",onClick:S},pt.createElement(R,{name:"panel",size:15})):null,f?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-test":"report-builder-close-preview",onClick:v},pt.createElement(R,{name:"back",size:13}),Rt.backToEditing):pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-test":"report-builder-open-preview",onClick:p},pt.createElement(R,{name:"eye",size:13}),Rt.openPreview),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-variant":"primary",title:Rt.printTitle,disabled:m,"data-test":"report-builder-print",onClick:g},pt.createElement(R,{name:"printer",size:13}),m?Rt.printing:Rt.print),!f&&T?pt.createElement(Cn,{ref:B,onPageSetup:T,onBranding:M}):null))},An=function(e){var t=e.openType,n=e.onOpen,r=e.types,o=void 0===r?I:r,i=e.note,a=void 0===i?Rt.paletteNote:i,u=e.onGetStarted;return pt.createElement("aside",{className:"".concat(w,"-palette"),"aria-label":Rt.addBlock},pt.createElement("div",{className:"".concat(w,"-section-label")},Rt.addBlock),pt.createElement("div",{className:"".concat(w,"-palette-list")},o.map(function(e){return pt.createElement("button",{key:e,type:"button",className:"".concat(w,"-palette-item"),"data-type":e,"data-selected":t===e||void 0,"aria-expanded":t===e,"aria-haspopup":"dialog",onClick:function(t){return n(e,t.currentTarget)}},pt.createElement(R,{name:e}),O[e].label)})),pt.createElement("p",{className:"".concat(w,"-hint")},Rt.paletteHint),u?pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-section-label")},Rt.newReport),pt.createElement("div",{className:"".concat(w,"-palette-list")},pt.createElement("button",{type:"button",className:"".concat(w,"-palette-item"),"data-type":"get-started","data-test":"report-builder-get-started",onClick:function(){return u()}},pt.createElement(R,{name:"new"}),Rt.getStarted)),pt.createElement("p",{className:"".concat(w,"-hint")},Rt.getStartedHint)):null,pt.createElement("p",{className:"".concat(w,"-hint")},a))},xn=0,Sn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"field",t=vt(null);return null===t.current&&(xn+=1,t.current="".concat(w,"-").concat(e,"-").concat(xn)),t.current},Bn=function(e){var t=e.children;return pt.createElement("div",{className:"".concat(w,"-section-label")},t)},Tn=function(e){var t=e.children,n=e.tone;return pt.createElement("p",{className:"".concat(w,"-note"),"data-tone":n||void 0},t)},Mn=function(){return pt.createElement("hr",{className:"".concat(w,"-divider")})},Nn=function(e){var t=e.label,n=e.htmlFor,r=e.children;return pt.createElement("div",{className:"".concat(w,"-field")},n?pt.createElement("label",{className:"".concat(w,"-label"),htmlFor:n},t):pt.createElement("div",{className:"".concat(w,"-label")},t),r)},Rn=function(e){var t=e.prefix,n=void 0===t?w:t,r=e.inline,o=void 0!==r&&r,i=e.children;return pt.createElement("span",{className:"".concat(n,"-select-box"),"data-inline":o||void 0},i,pt.createElement(R,{name:"down",size:12}))},On=function(e){var t=e.label,n=e.value,r=e.options,o=e.onChange,a=e.disabled,u=e.testId,s=Sn("select"),l=null==n?"":String(n);return pt.createElement(Nn,{label:t,htmlFor:s},pt.createElement(Rn,null,pt.createElement("select",{id:s,className:"".concat(w,"-select"),value:l,disabled:a,"data-test":u,onChange:function(e){var t=r.find(function(t){var n=i(t,1)[0];return String(n)===e.target.value});o(t?t[0]:e.target.value)}},r.map(function(e){var t=i(e,3),n=t[0],r=t[1],o=t[2];return pt.createElement("option",{key:String(n),value:String(n),disabled:!!o},r)}))))},In=function(e){var t=e.label,n=e.value,r=e.options,o=e.onChange,a=e.testId;return pt.createElement(Nn,{label:t},pt.createElement("div",{className:"".concat(w,"-segmented"),role:"group","aria-label":t,"data-test":a},r.map(function(e){var t=i(e,2),r=t[0],a=t[1];return pt.createElement("button",{key:String(r),type:"button",className:"".concat(w,"-segment"),"aria-pressed":r===n,"data-selected":r===n||void 0,onClick:function(){return o(r)}},a)})))},Pn=function(e){var t=e.label,n=e.checked,r=e.onChange,o=e.testId,i=Sn("toggle");return pt.createElement("div",{className:"".concat(w,"-toggle")},pt.createElement("label",{htmlFor:i},t),pt.createElement("input",{id:i,type:"checkbox",role:"switch",className:"".concat(w,"-switch"),checked:!!n,"aria-checked":!!n,"data-test":o,onChange:function(e){return r(e.target.checked)}}))},Ln=function(e){var t=e.label,n=e.value,r=e.swatches,o=e.onChange,a=e.noneLabel,u=void 0===a?Rt.panel.themeDefault:a,s=e.testId,l=Sn("colour"),c=(n||"").toLowerCase(),d=!!c&&!r.some(function(e){return i(e,1)[0].toLowerCase()===c});return pt.createElement(Nn,{label:t},pt.createElement("div",{className:"".concat(w,"-swatches"),"data-test":s},pt.createElement("button",{type:"button",className:"".concat(w,"-swatch"),"data-none":!0,"data-selected":!c||void 0,"aria-pressed":!c,title:u,"aria-label":u,onClick:function(){return o("")}}),r.map(function(e){var t=i(e,2),n=t[0],r=t[1];return pt.createElement("button",{key:n,type:"button",className:"".concat(w,"-swatch"),style:{background:n},"data-selected":n.toLowerCase()===c||void 0,"aria-pressed":n.toLowerCase()===c,title:r,"aria-label":r,onClick:function(){return o(n)}})}),pt.createElement("label",{className:"".concat(w,"-swatch"),"data-custom":!0,"data-selected":d||void 0,title:Rt.panel.customColour},pt.createElement("input",{id:l,type:"color","aria-label":Rt.panel.customColour,value:c||"#26a7e9",onChange:function(e){return o(e.target.value)}}))))},zn=[62,49,41,37,33,14],$n=function(){return pt.createElement("svg",{className:"".concat(w,"-sample-chart"),viewBox:"0 0 180 70",role:"img","aria-label":"Sample column chart"},pt.createElement("line",{x1:"8",y1:"62",x2:"176",y2:"62",stroke:"currentColor",strokeOpacity:"0.25"}),zn.map(function(e,t){return pt.createElement("rect",{key:t,x:14+27*t,y:62-e,width:"18",height:e,rx:"1.5",fill:"#26A7E9"})}))},qn=function(e){var t=e.type,n=e.draft;switch(t){case"heading":return pt.createElement("div",{className:"".concat(w,"-heading"),"data-level":n.level},"Revenue performance");case"text":return pt.createElement("p",{className:"".concat(w,"-text")},"Revenue grew in five of six regions this quarter. South led at $1.42M, up 18% on Q2.");case"data":return pt.createElement("div",{className:"".concat(w,"-data")},pt.createElement("div",{className:"".concat(w,"-data-title")},"Revenue by region"),pt.createElement($n,null));case"analysis":return pt.createElement("div",{className:"".concat(w,"-analysis")},pt.createElement("div",{className:"".concat(w,"-analysis-text")},pt.createElement("p",null,"South led the quarter at $1.42M, up 18% on Q2, while North slipped 3% on softer renewals. International grew fastest, from the smallest base.")),pt.createElement("div",{className:"".concat(w,"-analysis-meta")},"✦ ",Rt.analysis.source," · ",Rt.analysis.from("Revenue by region")));case"pagebreak":return pt.createElement("div",{className:"".concat(w,"-page-break"),role:"separator"},pt.createElement("span",null,Rt.pageBreak));default:return null}},jn=function(e){return"heading"===e?{level:2}:{}},Hn=function(t){function n(){var e;M(this,n);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e=N(this,n,[].concat(r)),S(e,"insertRef",pt.createRef()),e}return A(n,t),x(n,[{key:"componentDidMount",value:function(){var e,t;null===(e=this.insertRef.current)||void 0===e||null===(t=e.focus)||void 0===t||t.call(e)}},{key:"componentDidUpdate",value:function(e){var t,n;e.type!==this.props.type&&(null===(t=this.insertRef.current)||void 0===t||null===(n=t.focus)||void 0===n||n.call(t))}},{key:"render",value:function(){var t=this.props,n=t.type,r=t.draft,o=t.position,i=t.copy,a=t.onDraftChange,u=t.onInsert,s=t.onClose,l=e(e({},O[n]),i),c="".concat(w,"-details-name-").concat(n);return pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-details-backdrop"),onMouseDown:s}),pt.createElement("div",{className:"".concat(w,"-details"),role:"dialog","aria-modal":"true","aria-labelledby":c,style:o?{top:o.top,left:o.left}:void 0,"data-test":"report-builder-details"},pt.createElement("div",{className:"".concat(w,"-details-header")},pt.createElement(R,{name:n,size:16}),pt.createElement("div",{className:"".concat(w,"-details-heading")},pt.createElement("b",null,Rt.details),pt.createElement("span",null,Rt.detailsSub)),pt.createElement("button",{type:"button",className:"".concat(w,"-icon-button"),"aria-label":Rt.close,onClick:s},pt.createElement(R,{name:"close"}))),pt.createElement("div",{className:"".concat(w,"-details-preview")},pt.createElement("div",{className:"".concat(w,"-details-caption")},Rt.previewSample),pt.createElement("div",{className:"".concat(w,"-paper ").concat(w,"-details-paper"),"aria-hidden":"true"},pt.createElement(qn,{type:n,draft:r}))),pt.createElement("div",{className:"".concat(w,"-details-body")},pt.createElement("div",{className:"".concat(w,"-details-name"),id:c},l.label),pt.createElement("p",{className:"".concat(w,"-details-what")},l.what),pt.createElement("button",{ref:this.insertRef,type:"button",className:"".concat(w,"-button"),"data-variant":"primary","data-test":"report-builder-insert",onClick:u},Rt.insert),"heading"===n?pt.createElement("div",{className:"".concat(w,"-details-props")},pt.createElement(Bn,null,Rt.properties),pt.createElement(On,{label:Rt.panel.level,value:r.level,options:P,onChange:function(t){return a(e(e({},r),{},{level:t}))}})):null,pt.createElement("p",{className:"".concat(w,"-note")},l.note))))}}])}(pt.Component),Vn=["left","center","right"],Un="left",Wn=["image/png","image/jpeg","image/svg+xml","image/webp"],_n={woff2:{mime:"font/woff2",format:"woff2"},woff:{mime:"font/woff",format:"woff"},ttf:{mime:"font/ttf",format:"truetype"},otf:{mime:"font/otf",format:"opentype"}},Kn=["heading","body"],Jn={heading:"react-autoql-brand-heading",body:"react-autoql-brand-body"},Qn="var(--react-autoql-font-family, 'Helvetica Neue', Arial, sans-serif)",Gn=/^#?([0-9a-f]{6})$/i,Xn=/^#?([0-9a-f]{3})$/i,Zn=/^(?:rgb\s*\(\s*)?(\d{1,3})\s*[,\s]\s*(\d{1,3})\s*[,\s]\s*(\d{1,3})\s*\)?$/i,Yn=function(e){var t=String(null!=e?e:"").trim(),n=t.match(Gn);if(n)return"#".concat(n[1].toLowerCase());if(n=t.match(Xn))return"#".concat(n[1].split("").map(function(e){return e+e}).join("").toLowerCase());if(n=t.match(Zn)){var r=n.slice(1,4).map(Number);if(r.every(function(e){return e<=255}))return"#".concat(r.map(function(e){return e.toString(16).padStart(2,"0")}).join(""))}return null},er=function(e){return"string"==typeof e&&e.length>0},tr=function(e){return e&&"object"===k(e)&&er(e.url)?{name:er(e.name)?e.name:"",url:e.url}:void 0},nr=function(e){var t=e&&"object"===k(e)?e:{},n=(Array.isArray(t.colors)?t.colors:[]).map(Yn).filter(Boolean).filter(function(e,t,n){return n.indexOf(e)===t}).slice(0,6);return{name:er(t.name)?t.name:"",logoUrl:er(t.logoUrl)?t.logoUrl:void 0,wordmarkUrl:er(t.wordmarkUrl)?t.wordmarkUrl:void 0,position:Vn.includes(t.position)?t.position:Un,colors:n,headingFont:tr(t.headingFont),bodyFont:tr(t.bodyFont)}},rr=function(t,n){var r=e({},t&&"object"===k(t)?t:{});return Object.entries(n&&"object"===k(n)?n:{}).forEach(function(e){var t=i(e,2),n=t[0],o=t[1];(function(e){return null!=e&&""!==e&&!(Array.isArray(e)&&0===e.length)})(o)&&(r[n]=o)}),nr(r)},or=function(e){return e&&"object"===k(e)&&er(e.data)?{name:er(e.name)?e.name:"",url:e.data}:void 0},ir=function(e){var t=e&&"object"===k(e)?e:{},n={name:er(t.name)?t.name:void 0,logoUrl:er(t.logo)?t.logo:void 0,wordmarkUrl:er(t.wordmark)?t.wordmark:void 0,position:Vn.includes(t.position)?t.position:void 0,colors:Array.isArray(t.colors)?t.colors.map(Yn).filter(Boolean):void 0,headingFont:or(t.heading_font),bodyFont:or(t.body_font)};return Object.keys(n).forEach(function(e){return void 0===n[e]&&delete n[e]}),n},ar=function(e){var t=nr(e),n=function(e){return e?{name:e.name,data:e.url}:null};return{name:t.name,logo:t.logoUrl||null,wordmark:t.wordmarkUrl||null,position:t.position,colors:t.colors,heading_font:n(t.headingFont),body_font:n(t.bodyFont)}},ur=/^data:([a-z0-9.+/-]+);base64,[a-z0-9+/=]+$/i,sr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jn;return Kn.map(function(n){var r,o=null==e||null===(r=e["".concat(n,"Font")])||void 0===r?void 0:r.url;if(!er(o)||!ur.test(o))return"";var i=function(e){var t,n,r=null===(t=(e.match(ur)||[])[1])||void 0===t?void 0:t.toLowerCase();return null===(n=Object.values(_n).find(function(e){return e.mime===r}))||void 0===n?void 0:n.format}(o);return"@font-face{font-family:'".concat(t[n],"';src:url(\"").concat(o,'")').concat(i?" format('".concat(i,"')"):"",";font-display:block;}")}).join("")},lr=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jn,o=null===(n=L[null==e?void 0:e.typeface])||void 0===n?void 0:n.stack;if(o)return{fontFamily:o};var i={};return null!=t&&t.bodyFont&&(i["--react-autoql-report-builder-body-font"]="'".concat(r.body,"', ").concat(Qn)),null!=t&&t.headingFont&&(i["--react-autoql-report-builder-heading-font"]="'".concat(r.heading,"', ").concat(Qn)),Object.keys(i).length?i:void 0},cr=function(e,t){return Kn.every(function(n){var r,o;return((null==e||null===(r=e["".concat(n,"Font")])||void 0===r?void 0:r.url)||"")===((null==t||null===(o=t["".concat(n,"Font")])||void 0===o?void 0:o.url)||"")})},dr=function(e,t){var n,r=null===(n=L[null==e?void 0:e.typeface])||void 0===n?void 0:n.stack;return r?[r]:Kn.filter(function(e){return null==t?void 0:t["".concat(e,"Font")]}).map(function(e){return"'".concat(Jn[e],"'")})},fr=function(e){return!(!e||!(e.name||e.logoUrl||e.wordmarkUrl))},hr=function(e){var t=e.branding,n=e.size,r=void 0===n?"small":n;if(!fr(t))return null;var o=t.name,i=t.logoUrl,a=t.wordmarkUrl;return pt.createElement("div",{className:"".concat(w,"-brand"),"data-size":r},i?pt.createElement("img",{className:"".concat(w,"-brand-logo"),src:i,alt:""}):null,a?pt.createElement("img",{className:"".concat(w,"-brand-wordmark"),src:a,alt:o||""}):o?pt.createElement("span",{className:"".concat(w,"-brand-name")},o):null)},pr=function(e){var t=e.branding,n=e.title;return pt.createElement("header",{className:"".concat(w,"-running-header"),"data-brand-position":fr(t)?t.position||Un:void 0},pt.createElement("div",{className:"".concat(w,"-running-title")},n||Rt.untitled),pt.createElement(hr,{branding:t}))},vr=function(e){var t=e.branding,n=e.families,r=sr(t,n);return r?pt.createElement("style",{"data-report-brand-fonts":""},r):null},mr=function(e){var t=e.left,n=e.right;return pt.createElement("footer",{className:"".concat(w,"-running-footer")},pt.createElement("span",null,t),pt.createElement("span",null,n))},gr=function(e){var t=e.dataAsOf,n=e.hasData;return t?"".concat(Rt.preview.dataAsOf," ").concat(t):n?Rt.preview.notRunYet:null},Dr=function(e){var t=e.generated,n=e.dataAsOf,r=e.hasData,o=void 0===r||r;return[t?"".concat(Rt.preview.generated," ").concat(t):null,gr({dataAsOf:n,hasData:o})].filter(Boolean).join(" · ")},yr=function(e){return((null==e?void 0:e.blocks)||[]).some(function(e){return"data"===e.type&&e.source})},kr=Rt.branding,Er={heading:"react-autoql-brand-heading-draft",body:"react-autoql-brand-body-draft"},Fr=function(e,t){return new Promise(function(n,r){var o=new FileReader;o.onload=function(){var e="string"==typeof o.result?o.result:"";n(t?e.replace(/^data:[^;,]*;base64,/,"data:".concat(t,";base64,")):e)},o.onerror=function(){return r(o.error)},o.readAsDataURL(e)})},br=function(e){return((String(e).match(/\.([a-z0-9]+)$/i)||[])[1]||"").toLowerCase()},Cr=function(){try{return new RegExp("[^\\p{L}\\p{M}\\p{Nd} _-]+","gu")}catch(e){return/[^A-Za-z0-9 _-]+/g}}(),wr=function(e){var t=String(e).replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").replace(Cr," ").replace(/\s+/g," ").trim();return Array.from(t).slice(0,80).join("").trim()||kr.fontFallbackName},Ar=function(){var e=z($().m(function e(t){return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if("undefined"!=typeof FontFace){e.n=1;break}return e.a(2,!0);case 1:return e.p=1,e.n=2,new FontFace("react-autoql-font-check",'url("'.concat(t,'")')).load();case 2:return e.a(2,!0);case 3:return e.p=3,e.v,e.a(2,!1)}},e,null,[[1,3]])}));return function(t){return e.apply(this,arguments)}}(),xr=0,Sr=function(){return{key:xr+=1,text:arguments.length>0&&void 0!==arguments[0]?arguments[0]:""}},Br=function(e){var t=nr(e);return{name:t.name,logoUrl:t.logoUrl||"",wordmarkUrl:t.wordmarkUrl||"",position:t.position,colours:t.colors.map(function(e){return Sr(e.toUpperCase())}),headingFont:t.headingFont||null,bodyFont:t.bodyFont||null}},Tr=function(t){var n=t.colours.map(function(e){return e.text.trim()}).filter(Boolean).map(Yn);return n.some(function(e){return!e})?null:e(e(e(e({name:t.name.trim(),position:t.position,colors:n},t.logoUrl?{logoUrl:t.logoUrl}:{}),t.wordmarkUrl?{wordmarkUrl:t.wordmarkUrl}:{}),t.headingFont?{headingFont:t.headingFont}:{}),t.bodyFont?{bodyFont:t.bodyFont}:{})},Mr=function(e){return JSON.stringify(nr(e))},Nr=function(e){var t=e.label,n=e.note,r=e.url,o=e.error,i=e.testId,a=e.onFile,u=e.onRemove,s=pt.useRef(null);return pt.createElement(pt.Fragment,null,pt.createElement(Nn,{label:t},pt.createElement("div",{className:"".concat(w,"-asset-row")},r?pt.createElement("img",{className:"".concat(w,"-asset-thumb"),src:r,alt:t,"data-test":"".concat(i,"-image")}):pt.createElement("span",{className:"".concat(w,"-asset-none")},kr.none),pt.createElement("span",{className:"".concat(w,"-asset-actions")},pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"aria-label":"".concat(r?kr.replace:kr.upload," ").concat(t),"data-test":"".concat(i,"-upload"),onClick:function(){var e;return null===(e=s.current)||void 0===e?void 0:e.click()}},r?kr.replace:kr.upload),r?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"aria-label":"".concat(kr.remove," ").concat(t),"data-test":"".concat(i,"-remove"),onClick:u},kr.remove):null),pt.createElement("input",{ref:s,type:"file",accept:Wn.join(","),hidden:!0,tabIndex:-1,"aria-hidden":"true","data-test":"".concat(i,"-file"),onChange:function(e){var t,n=null===(t=e.target.files)||void 0===t?void 0:t[0];e.target.value="",n&&a(n)}}))),o?pt.createElement(Tn,{tone:"warning"},o):pt.createElement(Tn,null,n))},Rr=function(e){var t=e.label,n=e.font,r=e.family,o=e.error,i=e.testId,a=e.onFile,u=e.onRemove,s=pt.useRef(null);return pt.createElement(pt.Fragment,null,pt.createElement(Nn,{label:t},pt.createElement("div",{className:"".concat(w,"-asset-row")},n?pt.createElement("span",{className:"".concat(w,"-font-sample"),style:{fontFamily:"'".concat(r,"', sans-serif")},"data-test":i},pt.createElement("b",null,n.name||kr.fontSample)," ",kr.fontSample):pt.createElement("span",{className:"".concat(w,"-asset-none")},kr.none),pt.createElement("span",{className:"".concat(w,"-asset-actions")},pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"aria-label":"".concat(n?kr.replace:kr.upload," ").concat(t," ").concat(kr.fonts.toLowerCase()),"data-test":"".concat(i,"-upload"),onClick:function(){var e;return null===(e=s.current)||void 0===e?void 0:e.click()}},n?kr.replace:kr.upload),n?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"aria-label":"".concat(kr.remove," ").concat(t," ").concat(kr.fonts.toLowerCase()),"data-test":"".concat(i,"-remove"),onClick:u},kr.remove):null),pt.createElement("input",{ref:s,type:"file",accept:Object.keys(_n).map(function(e){return".".concat(e)}).join(","),hidden:!0,tabIndex:-1,"aria-hidden":"true","data-test":"".concat(i,"-file"),onChange:function(e){var t,n=null===(t=e.target.files)||void 0===t?void 0:t[0];e.target.value="",n&&a(n)}}))),o?pt.createElement(Tn,{tone:"warning"},o):null)},Or=0,Ir=function(t){function n(t){var r;M(this,n),r=N(this,n,[t]),S(r,"setDraft",function(t){return r.setState(function(n){var r=n.draft;return{draft:e(e({},r),t),error:null}})}),S(r,"setAssetError",function(t,n){return r.setState(function(r){var o=r.assetErrors;return{assetErrors:e(e({},o),{},S({},t,n))}})}),S(r,"close",function(){r.state.saving||r.props.onClose()}),S(r,"onImage",function(){var e=z($().m(function e(t,n){var o;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Wn.includes(n.type)){e.n=1;break}return e.a(2,r.setAssetError(t,kr.imageWrongType));case 1:if(!(n.size>262144)){e.n=2;break}return e.a(2,r.setAssetError(t,kr.imageTooLarge(Math.ceil(n.size/1024))));case 2:return e.p=2,e.n=3,Fr(n);case 3:if(o=e.v,r.mounted){e.n=4;break}return e.a(2);case 4:if(o.startsWith("data:image/")){e.n=5;break}return e.a(2,r.setAssetError(t,kr.imageUnreadable));case 5:r.setAssetError(t,null),r.setDraft(S({},t,o)),e.n=7;break;case 6:e.p=6,e.v,r.mounted&&r.setAssetError(t,kr.imageUnreadable);case 7:return e.a(2)}},e,null,[[2,6]])}));return function(t,n){return e.apply(this,arguments)}}()),S(r,"onFont",function(){var e=z($().m(function e(t,n){var o,i,a;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=_n[br(n.name)]){e.n=1;break}return e.a(2,r.setAssetError(t,kr.fontWrongType));case 1:if(!(n.size>512e3)){e.n=2;break}return e.a(2,r.setAssetError(t,kr.fontTooLarge(Math.ceil(n.size/1024))));case 2:return e.p=2,e.n=3,Fr(n,o.mime);case 3:return i=e.v,e.n=4,Ar(i);case 4:if(a=e.v,r.mounted){e.n=5;break}return e.a(2);case 5:if(a){e.n=6;break}return e.a(2,r.setAssetError(t,kr.fontUnreadable));case 6:r.setAssetError(t,null),r.setDraft(S({},t,{name:wr(n.name),url:i})),e.n=8;break;case 7:e.p=7,e.v,r.mounted&&r.setAssetError(t,kr.fontUnreadable);case 8:return e.a(2)}},e,null,[[2,7]])}));return function(t,n){return e.apply(this,arguments)}}()),S(r,"setColour",function(t,n){return r.setDraft({colours:r.state.draft.colours.map(function(r){return r.key===t?e(e({},r),{},{text:n}):r})})}),S(r,"addColour",function(){var t=Sr();r.setState(function(n){var r=n.draft;return{draft:e(e({},r),{},{colours:[].concat(o(r.colours),[t])}),error:null}},function(){var e,n;return null===(e=r.colourInputs[t.key])||void 0===e||null===(n=e.focus)||void 0===n?void 0:n.call(e)})}),S(r,"removeColour",function(e){return r.setDraft({colours:r.state.draft.colours.filter(function(t){return t.key!==e})})}),S(r,"discard",function(){return r.setState({draft:Br(r.props.branding),error:null,assetErrors:{}})}),S(r,"save",z($().m(function e(){var t;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=Tr(r.state.draft),!r.state.saving&&t&&t.name){e.n=1;break}return e.a(2);case 1:return r.setState({saving:!0,error:null}),e.p=2,e.n=3,r.props.onSave(t);case 3:r.mounted&&r.props.onClose(),e.n=5;break;case 4:e.p=4,e.v,r.mounted&&r.setState({saving:!1,error:kr.saveFailed});case 5:return e.a(2)}},e,null,[[2,4]])}))),S(r,"onKeyDown",function(e){var t;if("Escape"===e.key)return e.preventDefault(),e.stopPropagation(),void r.close();if("Tab"===e.key){var n=Array.from((null===(t=r.dialogRef.current)||void 0===t?void 0:t.querySelectorAll('button:not([disabled]), input:not([disabled]):not([type="file"]), select:not([disabled])'))||[]);if(n.length){var o=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===o?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),o.focus())}}}),Or+=1;var i=function(e){return"".concat(w,"-branding-").concat(e,"-").concat(Or)};return r.ids={title:i("title"),what:i("what"),name:i("name")},r.dialogRef=pt.createRef(),r.nameRef=pt.createRef(),r.colourInputs={},r.state={draft:Br(t.branding),saving:!1,error:null,assetErrors:{}},r}return A(n,t),x(n,[{key:"componentDidMount",value:function(){var e,t;this.mounted=!0,null===(e=this.nameRef.current)||void 0===e||null===(t=e.focus)||void 0===t||t.call(e)}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"renderColours",value:function(){var e=this,t=this.state.draft.colours,n=t.some(function(e){return e.text.trim()&&!Yn(e.text)});return pt.createElement(pt.Fragment,null,pt.createElement(Nn,{label:kr.colours},pt.createElement("div",{className:"".concat(w,"-colour-list"),"data-test":"report-builder-branding-colours"},t.map(function(t,n){var r=Yn(t.text),o=!!t.text.trim()&&!r;return pt.createElement("div",{key:t.key,className:"".concat(w,"-colour-row")},pt.createElement("input",{type:"color",className:"".concat(w,"-colour-swatch"),value:r||"#000000","aria-label":kr.colourPick(n+1),onChange:function(n){return e.setColour(t.key,n.target.value.toUpperCase())}}),pt.createElement("input",{ref:function(n){e.colourInputs[t.key]=n},type:"text",className:"".concat(w,"-input"),value:t.text,placeholder:kr.colourPlaceholder,"aria-label":kr.colourLabel(n+1),"aria-invalid":o||void 0,spellCheck:!1,onChange:function(n){return e.setColour(t.key,n.target.value)}}),pt.createElement("button",{type:"button",className:"".concat(w,"-icon-button"),"aria-label":kr.removeColour(n+1),title:kr.removeColour(n+1),onClick:function(){return e.removeColour(t.key)}},pt.createElement(R,{name:"close"})))}),t.length<6?pt.createElement("button",{type:"button",className:"".concat(w,"-button ").concat(w,"-colour-add"),"data-test":"report-builder-branding-add-colour",onClick:this.addColour},kr.addColour):null)),n?pt.createElement(Tn,{tone:"warning"},kr.colourInvalid):pt.createElement(Tn,null,kr.coloursNote(6)))}},{key:"render",value:function(){var t=this,n=this.props.reportTitle,r=this.state,o=r.draft,i=r.saving,a=r.error,u=r.assetErrors,s=Tr(o),l=!!o.name.trim(),c=!s||Mr(s)!==Mr(this.props.branding),d=a||(c?kr.unsaved:kr.saved),f=s||Tr(e(e({},o),{},{colours:[]}));return pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-modal-backdrop"),onMouseDown:this.close}),pt.createElement("div",{ref:this.dialogRef,className:"".concat(w,"-modal ").concat(w,"-branding"),role:"dialog","aria-modal":"true","aria-labelledby":this.ids.title,"aria-describedby":this.ids.what,"data-test":"report-builder-branding",onKeyDown:this.onKeyDown},pt.createElement(vr,{branding:f,families:Er}),pt.createElement("div",{className:"".concat(w,"-modal-header")},pt.createElement("h2",{className:"".concat(w,"-modal-title"),id:this.ids.title},kr.title),pt.createElement("button",{type:"button",className:"".concat(w,"-icon-button"),"aria-label":Rt.close,disabled:i,onClick:this.close},pt.createElement(R,{name:"close"}))),pt.createElement("div",{className:"".concat(w,"-modal-body")},pt.createElement("p",{className:"".concat(w,"-modal-what"),id:this.ids.what},kr.what),pt.createElement("figure",{className:"".concat(w,"-branding-sample")},pt.createElement("div",{className:"".concat(w,"-paper ").concat(w,"-branding-paper"),style:lr({typeface:"theme"},f,Er),"data-test":"report-builder-branding-sample"},pt.createElement(pr,{branding:nr(f),title:n}),f.bodyFont?pt.createElement("p",{className:"".concat(w,"-branding-sample-body")},kr.sampleBody):null),pt.createElement("figcaption",{className:"".concat(w,"-details-caption")},kr.sample)),pt.createElement(Nn,{label:kr.name,htmlFor:this.ids.name},pt.createElement("input",{ref:this.nameRef,id:this.ids.name,type:"text",className:"".concat(w,"-input"),value:o.name,maxLength:80,autoComplete:"organization","aria-invalid":!l||void 0,"data-test":"report-builder-branding-name",onChange:function(e){return t.setDraft({name:e.target.value})}})),l?null:pt.createElement(Tn,{tone:"warning"},kr.nameRequired),pt.createElement(Nr,{label:kr.logo,note:"".concat(kr.logoNote," ").concat(kr.imageNote),url:o.logoUrl,error:u.logoUrl,testId:"report-builder-branding-logo",onFile:function(e){return t.onImage("logoUrl",e)},onRemove:function(){return t.setDraft({logoUrl:""})}}),pt.createElement(Nr,{label:kr.wordmark,note:"".concat(kr.wordmarkNote," ").concat(kr.imageNote),url:o.wordmarkUrl,error:u.wordmarkUrl,testId:"report-builder-branding-wordmark",onFile:function(e){return t.onImage("wordmarkUrl",e)},onRemove:function(){return t.setDraft({wordmarkUrl:""})}}),pt.createElement(In,{label:kr.position,value:o.position,options:kr.positions,testId:"report-builder-branding-position",onChange:function(e){return t.setDraft({position:e})}}),pt.createElement(Tn,null,kr.positionNote),this.renderColours(),pt.createElement("div",{className:"".concat(w,"-section-label")},kr.fonts),pt.createElement(Rr,{label:kr.headingFont,font:o.headingFont,family:Er.heading,error:u.headingFont,testId:"report-builder-branding-heading-font",onFile:function(e){return t.onFont("headingFont",e)},onRemove:function(){return t.setDraft({headingFont:null})}}),pt.createElement(Rr,{label:kr.bodyFont,font:o.bodyFont,family:Er.body,error:u.bodyFont,testId:"report-builder-branding-body-font",onFile:function(e){return t.onFont("bodyFont",e)},onRemove:function(){return t.setDraft({bodyFont:null})}}),pt.createElement(Tn,null,kr.fontNote)),pt.createElement("div",{className:"".concat(w,"-modal-actions")},pt.createElement("p",{className:"".concat(w,"-modal-status"),role:"status","data-tone":a?"error":void 0,"data-test":"report-builder-branding-status"},d),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),disabled:!c||i,"data-test":"report-builder-branding-discard",onClick:this.discard},kr.discard),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-variant":"primary",disabled:!c||i||!l||!s,"data-test":"report-builder-branding-save",onClick:this.save},i?kr.saving:kr.save))))}}])}(pt.Component),Pr=Object.defineProperty,Lr=function(e,t){var n={};for(var r in e)Pr(n,r,{get:e[r],enumerable:!0});return t||Pr(n,Symbol.toStringTag,{value:"Module"}),n};function zr(e){this.content=e}function $r(e,t,n){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;var o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(var a=o.text,u=i.text,s=0;a[s]==u[s];s++)n++;return s&&s<a.length&&s<u.length&&Hr(a.charCodeAt(s-1))&&jr(a.charCodeAt(s))&&n--,n}if(o.content.size||i.content.size){var l=$r(o.content,i.content,n+1);if(null!=l)return l}n+=o.nodeSize}else n+=o.nodeSize}}function qr(e,t,n,r){for(var o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};var a=e.child(--o),u=t.child(--i),s=a.nodeSize;if(a!=u){if(!a.sameMarkup(u))return{a:n,b:r};if(a.isText&&a.text!=u.text){for(var l=a.text,c=u.text,d=l.length,f=c.length;d>0&&f>0&&l[d-1]==c[f-1];)d--,f--,n--,r--;return d&&f&&d<l.length&&Hr(l.charCodeAt(d-1))&&jr(l.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(a.content.size||u.content.size){var h=qr(a.content,u.content,n-1,r-1);if(h)return h}n-=s,r-=s}else n-=s,r-=s}}function jr(e){return e>=56320&&e<57344}function Hr(e){return e>=55296&&e<56320}zr.prototype={constructor:zr,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-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new zr(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new zr(n)},addToStart:function(e,t){return new zr([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new zr(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new zr(o)},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=zr.from(e)).size?new zr(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=zr.from(e)).size?new zr(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=zr.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}},zr.from=function(e){if(e instanceof zr)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new zr(t)};var Vr=function(){function e(t,n){if(M(this,e),this.content=t,this.size=n||0,null==n)for(var r=0;r<t.length;r++)this.size+=t[r].nodeSize}return x(e,[{key:"nodesBetween",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,i=0,a=0;a<t;i++){var u=this.content[i],s=a+u.nodeSize;if(s>e&&!1!==n(u,r+a,o||null,i)&&u.content.size){var l=a+1;u.nodesBetween(Math.max(0,e-l),Math.min(u.content.size,t-l),n,r+l)}a=s}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,r){var o="",i=!0;return this.nodesBetween(e,t,function(a,u){var s=a.isText?a.text.slice(Math.max(e,u)-u,t-u):a.isLeaf?r?"function"==typeof r?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&s||a.isTextblock)&&n&&(i?i=!1:o+=n),o+=s},0),o}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new e(o,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var r=[],o=0;if(n>t)for(var i=0,a=0;a<n;i++){var u=this.content[i],s=a+u.nodeSize;s>t&&((a<t||s>n)&&(u=u.isText?u.cut(Math.max(0,t-a),Math.min(u.text.length,n-a)):u.cut(Math.max(0,t-a-1),Math.min(u.content.size,n-a-1))),r.push(u),o+=u.nodeSize),a=s}return new e(r,o)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var r=this.content[t];if(r==n)return this;var o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,i)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}}},{key:"findDiffStart",value:function(e){return $r(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return qr(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{key:"findIndex",value:function(e){if(0==e)return Wr(0,e);if(e==this.size)return Wr(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var t=0,n=0;;t++){var r=n+this.child(t).nodeSize;if(r>=e)return r==e?Wr(t+1,r):Wr(t,n);n=r}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return e.fromArray(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,r=0,o=0;o<t.length;o++){var i=t[o];r+=i.nodeSize,o&&i.isText&&t[o-1].sameMarkup(i)?(n||(n=t.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}},{key:"from",value:function(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 new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}])}();Vr.empty=new Vr([],0);var Ur={index:0,offset:0};function Wr(e,t){return Ur.index=e,Ur.offset=t,Ur}function _r(e,t){if(e===t)return!0;if(!e||"object"!=k(e)||!t||"object"!=k(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!_r(e[r],t[r]))return!1}else{for(var o in e)if(!(o in t)||!_r(e[o],t[o]))return!1;for(var i in t)if(!(i in e))return!1}return!0}var Kr=function(){function e(t,n){M(this,e),this.type=t,this.attrs=n}return x(e,[{key:"addToSet",value:function(e){for(var t,n=!1,r=0;r<e.length;r++){var o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&_r(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));return n.create(t.attrs)}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort(function(e,t){return e.type.rank-t.type.rank}),n}}])}();Kr.none=[];var Jr=function(e){function t(){return M(this,t),N(this,t,arguments)}return A(t,e),x(t)}(q(Error)),Qr=function(){function e(t,n,r){M(this,e),this.content=t,this.openStart=n,this.openEnd=r}return x(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var r=Xr(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(Gr(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var r=n.openStart||0,o=n.openEnd||0;if("number"!=typeof r||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new e(Vr.fromJSON(t,n.content),r,o)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=0,o=0,i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(var a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)o++;return new e(t,r,o)}}])}();function Gr(e,t,n){var r=e.findIndex(t),o=r.index,i=r.offset,a=e.maybeChild(o),u=e.findIndex(n),s=u.index,l=u.offset;if(i==t||a.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,a.copy(Gr(a.content,t-i-1,n-i-1)))}function Xr(e,t,n,r,o,i){var a=e.findIndex(t),u=a.index,s=a.offset,l=e.maybeChild(u);if(s==t||l.isText)return i&&r<=0&&o<=0&&!i.canReplace(u,u,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=Xr(l.content,t-s-1,n,0==u?r-1:0,u==e.childCount-1?o-1:0,l);return c&&e.replaceChild(u,l.copy(c))}function Zr(e,t,n){if(n.openStart>e.depth)throw new Jr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Jr("Inconsistent open depths");return Yr(e,t,n,0)}function Yr(e,t,n,r){var o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){var a=Yr(e,t,n,r+1);return i.copy(i.content.replaceChild(o,a))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){var u=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),o=n-1;o>=0;o--)r=t.node(o).copy(Vr.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return oo(i,io(e,u.start,u.end,t,r))}var s=e.parent,l=s.content;return oo(s,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}return oo(i,ao(e,t,r))}function eo(e,t){if(!t.type.compatibleContent(e.type))throw new Jr("Cannot join "+t.type.name+" onto "+e.type.name)}function to(e,t,n){var r=e.node(n);return eo(r,t.node(n)),r}function no(e,t){var 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 ro(e,t,n,r){var o=(t||e).node(n),i=0,a=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(no(e.nodeAfter,r),i++));for(var u=i;u<a;u++)no(o.child(u),r);t&&t.depth==n&&t.textOffset&&no(t.nodeBefore,r)}function oo(e,t){if(!e.type.validContent(t))throw new Jr("Invalid content for node "+e.type.name);return e.copy(t)}function io(e,t,n,r,o){var i=e.depth>o&&to(e,t,o+1),a=r.depth>o&&to(n,r,o+1),u=[];return ro(null,e,o,u),i&&a&&t.index(o)==n.index(o)?(eo(i,a),no(oo(i,io(e,t,n,r,o+1)),u)):(i&&no(oo(i,ao(e,t,o+1)),u),ro(t,n,o,u),a&&no(oo(a,ao(n,r,o+1)),u)),ro(r,null,o,u),new Vr(u)}function ao(e,t,n){var r=[];(ro(null,e,n,r),e.depth>n)&&no(oo(to(e,t,n+1),ao(e,t,n+1)),r);return ro(t,null,n,r),new Vr(r)}Qr.empty=new Qr(Vr.empty,0,0);var uo=function(){function e(t,n,r){M(this,e),this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}return x(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,o=0;o<e;o++)r+=n.child(o).nodeSize;return r}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return Kr.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){var o=n;n=r,r=o}for(var i=n.marks,a=0;a<i.length;a++)!1!==i[a].type.spec.inclusive||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var 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 fo(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var r=[],o=0,i=n,a=t;;){var u=a.content.findIndex(i),s=u.index,l=u.offset,c=i-l;if(r.push(a,s,o+l),!c)break;if((a=a.child(s)).isText)break;i=c-1,o+=l+1}return new e(n,r,i)}},{key:"resolveCached",value:function(t,n){var r=co.get(t);if(r)for(var o=0;o<r.elts.length;o++){var i=r.elts[o];if(i.pos==n)return i}else co.set(t,r=new so);var a=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%lo,a}}])}(),so=x(function e(){M(this,e),this.elts=[],this.i=0}),lo=12,co=new WeakMap,fo=function(){return x(function e(t,n,r){M(this,e),this.$from=t,this.$to=n,this.depth=r},[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}])}(),ho=Object.create(null),po=function(){function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Kr.none;M(this,e),this.type=t,this.attrs=n,this.marks=o,this.content=r||Vr.empty}return x(e,[{key:"children",get:function(){return this.content.content}},{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,r,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,r){return this.content.textBetween(e,t,n,r)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&_r(this.attrs,t||e.defaultAttrs||ho)&&Kr.sameSet(this.marks,n||Kr.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return Qr.empty;var r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),a=r.start(i),u=r.node(i).content.cut(r.pos-a,o.pos-a);return new Qr(u,r.depth-i,o.depth-i)}},{key:"replace",value:function(e,t,n){return Zr(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,o=n.offset;if(!(t=t.maybeChild(r)))return null;if(o==e||t.isText)return t;e-=o+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}},{key:"resolve",value:function(e){return uo.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return uo.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,function(e){return n.isInSet(e.marks)&&(r=!0),!r}),r}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),mo(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Vr.empty,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,i=this.contentMatchAt(e).matchFragment(n,r,o),a=i&&i.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var u=r;u<o;u++)if(!this.type.allowsMarks(n.child(u).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content),go(this.type.attrs,this.attrs,"node",this.type.name);for(var e=Kr.none,t=0;t<this.marks.length;t++){var n=this.marks[t];go(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!Kr.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map(function(e){return e.type.name})));this.content.forEach(function(e){return e.check()})}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var 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(function(e){return e.toJSON()})),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=Vr.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}])}();po.prototype.text=void 0;var vo=function(){function e(t,n,r,o){var i;if(M(this,e),i=N(this,e,[t,n,null,o]),!r)throw new RangeError("Empty text nodes are not allowed");return i.text=r,i}return A(e,po),x(e,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):mo(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}},{key:"withText",value:function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var t=H(e,"toJSON",this,3)([]);return t.text=this.text,t}}])}();function mo(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function go(e,t,n,r){for(var o in t)if(!(o in e))throw new RangeError("Unsupported attribute ".concat(o," for ").concat(n," of type ").concat(r));for(var i in e)e[i].validate&&e[i].validate(t[i])}var Do=function(){function e(t){M(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return x(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,r=this,o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[this];return function o(i,a){var u=i.matchFragment(e,n);if(u&&(!t||u.validEnd))return Vr.from(a.map(function(e){return e.createAndFill()}));for(var s=0;s<i.next.length;s++){var l=i.next[s],c=l.type,d=l.next;if(!c.isText&&!c.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var f=o(d,a.concat(c));if(f)return f}}return null}(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(e)){for(var i=[],a=r;a.type;a=a.via)i.push(a.type);return i.reverse()}for(var u=0;u<o.next.length;u++){var s=o.next[u],l=s.type,c=s.next;l.isLeaf||l.hasRequiredAttrs()||l.name in t||r.type&&!c.validEnd||(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",o=0;o<t.next.length;o++)r+=(o?", ":"")+t.next[o].type.name+"->"+e.indexOf(t.next[o].next);return r}).join("\n")}}],[{key:"parse",value:function(t,n){var r=new yo(t,n);if(null==r.next)return e.empty;var o=ko(r);r.next&&r.err("Unexpected trailing text");var i=xo(function(e){var t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(function(e){return e.to=t})}function i(e,t){if("choice"==e.type)return e.exprs.reduce(function(e,n){return e.concat(i(n,t))},[]);if("seq"!=e.type){if("star"==e.type){var a=n();return r(t,a),o(i(e.expr,a),a),[r(a)]}if("plus"==e.type){var u=n();return o(i(e.expr,t),u),o(i(e.expr,u),u),[r(u)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){for(var s=t,l=0;l<e.min;l++){var c=n();o(i(e.expr,s),c),s=c}if(-1==e.max)o(i(e.expr,s),s);else for(var d=e.min;d<e.max;d++){var f=n();r(s,f),o(i(e.expr,s),f),s=f}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(var h=0;;h++){var p=i(e.exprs[h],t);if(h==e.exprs.length-1)return p;o(p,t=n())}}}(o));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var o=r[n],i=!o.validEnd,a=[],u=0;u<o.next.length;u++){var s=o.next[u],l=s.type,c=s.next;a.push(l.name),!i||l.isText||l.hasRequiredAttrs()||(i=!1),-1==r.indexOf(c)&&r.push(c)}i&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,r),i}}])}();Do.empty=new Do(!0);var yo=function(){return x(function e(t,n){M(this,e),this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}])}();function ko(e){var t=[];do{t.push(Eo(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Eo(e){var t=[];do{t.push(Fo(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Fo(e){for(var t=function(e){if(e.eat("(")){var t=ko(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var o=[];for(var i in n){var a=n[i];a.isInGroup(t)&&o.push(a)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)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("{"))break;t=Co(e,t)}return t}function bo(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function Co(e,t){var n=bo(e),r=n;return e.eat(",")&&(r="}"!=e.next?bo(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function wo(e,t){return t-e}function Ao(e,t){var n=[];return function t(r){var o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var a=o[i],u=a.term,s=a.to;u||-1!=n.indexOf(s)||t(s)}}(t),n.sort(wo)}function xo(e){var t=Object.create(null);return function n(r){var o=[];r.forEach(function(t){e[t].forEach(function(t){var n=t.term,r=t.to;if(n){for(var i,a=0;a<o.length;a++)o[a][0]==n&&(i=o[a][1]);Ao(e,r).forEach(function(e){i||o.push([n,i=[]]),-1==i.indexOf(e)&&i.push(e)})}})});for(var i=t[r.join(",")]=new Do(r.indexOf(e.length-1)>-1),a=0;a<o.length;a++){var u=o[a][1].sort(wo);i.next.push({type:o[a][0],next:t[u.join(",")]||n(u)})}return i}(Ao(e,0))}function So(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Bo(e,t){var n=Object.create(null);for(var r in e){var o=e[r],i=t&&t[r];if(void 0===i){if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}else o.validate&&o.validate(i);n[r]=i}return n}function To(e,t){var n=Object.create(null);if(t)for(var r in t)n[r]=new No(e,r,t[r]);return n}var Mo=function(){function e(t,n,r){M(this,e),this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=To(t,r.attrs),this.defaultAttrs=So(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}return x(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==Do.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"isInGroup",value:function(e){return this.groups.indexOf(e)>-1}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:Bo(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new po(this,this.computeAttrs(e),Vr.from(t),Kr.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=Vr.from(t),this.checkContent(t),new po(this,this.computeAttrs(e),t,Kr.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=Vr.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(Vr.empty,!0);return i?new po(this,e,t.append(i),Kr.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"checkAttrs",value:function(e){}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Kr.none:e}}],[{key:"compile",value:function(t,n){var r=Object.create(null);t.forEach(function(t,o){return r[t]=new e(t,n,o)});var o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}])}();var No=function(){return x(function e(t,n,r){M(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(e,t,n){var r=n.split("|");return function(n){var o=null===n?"null":k(n);if(r.indexOf(o)<0)throw new RangeError("Expected value of type ".concat(r," for attribute ").concat(t," on type ").concat(e,", got ").concat(o))}}(t,n,r.validate):r.validate},[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),Ro=function(){function e(t,n,r,o){M(this,e),this.name=t,this.rank=n,this.schema=r,this.spec=o,this.attrs=To(t,o.attrs),this.excluded=null;var i=So(this.attrs);this.instance=i?new Kr(this,i):null}return x(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new Kr(this,Bo(this.attrs,e))}},{key:"removeFromSet",value:function(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}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var r=Object.create(null),o=0;return t.forEach(function(t,i){return r[t]=new e(t,o++,n,i)}),r}}])}(),Oo=function(){return x(function e(t){var n=this;M(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var r=this.spec={};for(var o in t)r[o]=t[o];r.nodes=zr.from(t.nodes),r.marks=zr.from(t.marks||{}),this.nodes=Mo.compile(this.spec.nodes,this),this.marks=Ro.compile(this.spec.marks,this);var i=Object.create(null);for(var a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");var u=this.nodes[a],s=u.spec.content||"",l=u.spec.marks;if(u.contentMatch=i[s]||(i[s]=Do.parse(s,this.nodes)),u.inlineContent=u.contentMatch.inlineContent,u.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!u.isInline||!u.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=u}u.markSet="_"==l?null:l?Io(this,l.split(" ")):""!=l&&u.inlineContent?null:[]}for(var c in this.marks){var d=this.marks[c],f=d.spec.excludes;d.excluded=null==f?[d]:""==f?[]:Io(this,f.split(" "))}this.nodeFromJSON=function(e){return po.fromJSON(n,e)},this.markFromJSON=function(e){return Kr.fromJSON(n,e)},this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)},[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Mo))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new vo(n,n.defaultAttrs,e,Kr.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}])}();function Io(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r],i=e.marks[o],a=i;if(i)n.push(i);else for(var u in e.marks){var s=e.marks[u];("_"==o||s.spec.group&&s.spec.group.split(" ").indexOf(o)>-1)&&n.push(a=s)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}var Po=function(){function e(t,n){var r=this;M(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[];var o=this.matchedStyles=[];n.forEach(function(e){if(function(e){return null!=e.tag}(e))r.tags.push(e);else if(function(e){return null!=e.style}(e)){var t=/[^=]*/.exec(e.style)[0];o.indexOf(t)<0&&o.push(t),r.styles.push(e)}}),this.normalizeLists=!this.tags.some(function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)})}return x(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Ho(this,t,!1);return n.addAll(e,Kr.none,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Ho(this,t,!0);return n.addAll(e,Kr.none,t.from,t.to),Qr.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(Vo(e,o.tag)&&(void 0===o.namespace||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(e);if(!1===i)continue;o.attrs=i||void 0}return o}}}},{key:"matchStyle",value:function(e,t,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o],a=i.style;if(!(0!=a.indexOf(e)||i.context&&!n.matchesContext(i.context)||a.length>e.length&&(61!=a.charCodeAt(e.length)||a.slice(e.length+1)!=t))){if(i.getAttrs){var u=i.getAttrs(t);if(!1===u)continue;i.attrs=u||void 0}return i}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var o=t[r];if((null==o.priority?50:o.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Uo(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})};for(var o in e.marks)r(o);var i=function(t){var r=e.nodes[t].spec.parseDOM;r&&r.forEach(function(e){n(e=Uo(e)),e.node||e.ignore||e.mark||(e.node=t)})};for(var a in e.nodes)i(a);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),Lo={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},zo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$o={ol:!0,ul:!0};function qo(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var jo=function(){return x(function e(t,n,r,o,i,a){M(this,e),this.type=t,this.attrs=n,this.marks=r,this.solid=o,this.options=a,this.content=[],this.activeMarks=Kr.none,this.match=i||(4&a?null:t.contentMatch)},[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(Vr.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var r=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}var o=Vr.from(this.content);return!e&&this.match&&(o=o.append(this.match.fillBefore(Vr.empty,!0))),this.type?this.type.create(this.attrs,o,this.marks):o}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Lo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),Ho=function(){return x(function e(t,n,r){M(this,e),this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;var o,i=n.topNode,a=qo(null,n.preserveWhitespace,0)|(r?4:0);o=i?new jo(i.type,i.attrs,Kr.none,!0,n.topMatch||i.type.contentMatch,a):new jo(r?null:t.schema.topNodeType,null,Kr.none,!0,null,a),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1},[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}},{key:"addTextNode",value:function(e,t){var n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,i=this.parser.schema;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){for(var a=n.split(/\r?\n|\r/),u=0;u<a.length;u++)u&&this.insertNode(i.linebreakReplacement.create(),t,!0),a[u]&&this.insertNode(i.text(a[u]),t,!/\S/.test(a[u]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){var s=r.content[r.content.length-1],l=e.previousSibling;(!s||l&&"BR"==l.nodeName||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t,n){var r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);var i,a=e.nodeName.toLowerCase();$o.hasOwnProperty(a)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&$o.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(u?u.ignore:zo.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);var s,l=this.needsBlock;if(Lo.hasOwnProperty(a))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),s=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}var c=u&&u.skip?t:this.readStyles(e,t);c&&this.addAll(e,c),s&&this.sync(o),this.needsBlock=l}else{var d=this.readStyles(e,t);d&&this.addElementByRule(e,u,d,!1===u.consuming?i:void 0)}this.localPreserveWS=r}},{key:"leafFallback",value:function(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}},{key:"ignoreFallback",value:function(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}},{key:"readStyles",value:function(e,t){var n=this,r=e.style;if(r&&r.length)for(var o=0;o<this.parser.matchedStyles.length;o++){var i=this.parser.matchedStyles[o],a=r.getPropertyValue(i);if(a)for(var u,s=function(e){var r=n.parser.matchStyle(i,a,n,e);return r?r.ignore?{v:null}:(t=r.clearMark?t.filter(function(e){return!r.clearMark(e)}):t.concat(n.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming?(l=e,0):void(l=e=r)):(l=e,0)},l=void 0;0!==(u=s(l));)if(u)return u.v}return t}},{key:"addElementByRule",value:function(e,t,n,r){var o,i,a=this;if(t.node)if((i=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{var u=this.enter(i,t.attrs||null,n,t.preserveWhitespace);u&&(o=!0,n=u)}else{var s=this.parser.schema.marks[t.mark];n=n.concat(s.create(t.attrs))}var l=this.top;if(i&&i.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(function(e){return a.insertNode(e,n,!1)});else{var c=e;"string"==typeof t.contentElement?c=e.querySelector(t.contentElement):"function"==typeof t.contentElement?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,n),this.findAround(e,c,!1)}o&&this.sync(l)&&this.open--}},{key:"addAll",value:function(e,t,n,r){for(var o=n||0,i=n?e.childNodes[n]:e.firstChild,a=null==r?null:e.childNodes[r];i!=a;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}},{key:"findPlace",value:function(e,t,n){for(var r,o,i=this.open,a=0;i>=0;i--){var u=this.nodes[i],s=u.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,o=u,!s.length))break;if(u.solid){if(n)break;a+=2}}if(!r)return null;this.sync(o);for(var l=0;l<r.length;l++)t=this.enterInner(r[l],null,t,!1);return t}},{key:"insertNode",value:function(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){var r=this.textblockFromContext();r&&(t=this.enterInner(r,null,t))}var o=this.findPlace(e,t,n);if(o){this.closeExtra();var i=this.top;i.match&&(i.match=i.match.matchType(e.type));var a,u=Kr.none,s=j(o.concat(e.marks));try{for(s.s();!(a=s.n()).done;){var l=a.value;(i.type?i.type.allowsMarkType(l.type):Wo(l.type,e.type))&&(u=l.addToSet(u))}}catch(e){s.e(e)}finally{s.f()}return i.content.push(e.mark(u)),!0}return!1}},{key:"enter",value:function(e,t,n,r){var o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}},{key:"enterInner",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0;this.closeExtra();var i=this.top;i.match=i.match&&i.match.matchType(e);var a=qo(e,o,i.options);4&i.options&&0==i.content.length&&(a|=4);var u=Kr.none;return n=n.filter(function(t){return!(i.type?i.type.allowsMarkType(t.type):Wo(t.type,e))||(u=t.addToSet(u),!1)}),this.nodes.push(new jo(e,t,u,r,null,a)),this.open++,n}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],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}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}},{key:"findInText",value:function(e){if(this.find)for(var 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))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),a=function(e,u){for(;e>=0;e--){var s=n[e];if(""==s){if(e==n.length-1||0==e)continue;for(;u>=i;u--)if(a(e-1,u))return!0;return!1}var l=u>0||0==u&&o?t.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!l||l.name!=s&&!l.isInGroup(s))return!1;u--}return!0};return a(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}}}])}();function Vo(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Uo(e){var t={};for(var n in e)t[n]=e[n];return t}function Wo(e,t){var n,r=t.schema.nodes,o=function(){var n=r[i];if(!n.allowsMarkType(e))return 0;var o=[],a=function(e){o.push(e);for(var n=0;n<e.edgeCount;n++){var r=e.edge(n),i=r.type,u=r.next;if(i==t)return!0;if(o.indexOf(u)<0&&a(u))return!0}};return a(n.contentMatch)?{v:!0}:void 0};for(var i in r)if(0!==(n=o())&&n)return n.v}var _o=function(){function e(t,n){M(this,e),this.nodes=t,this.marks=n}return x(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;r||(r=Jo(n).createDocumentFragment());var o=r,i=[];return e.forEach(function(e){if(i.length||e.marks.length){for(var r=0,a=0;r<i.length&&a<e.marks.length;){var u=e.marks[a];if(t.marks[u.type.name]){if(!u.eq(i[r][0])||!1===u.type.spec.spanning)break;r++,a++}else a++}for(;r<i.length;)o=i.pop()[1];for(;a<e.marks.length;){var s=e.marks[a++],l=t.serializeMark(s,e.isInline,n);l&&(i.push([s,o]),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(t.serializeNodeInner(e,n))}),r}},{key:"serializeNodeInner",value:function(e,t){if(e.isText)return Jo(t).createTextNode(e.text);var n=Xo(Jo(t),this.nodes[e.type.name](e),null,e.attrs),r=n.dom,o=n.contentDOM;if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}},{key:"serializeMark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.marks[e.type.name];return r&&Xo(Jo(n),r(e,t),null,e.attrs)}}],[{key:"renderSpec",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3?arguments[3]:void 0;return"string"==typeof t?{dom:e.createTextNode(t)}:Xo(e,t,n,r)}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=Ko(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return Ko(e.marks)}}])}();function Ko(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Jo(e){return e.document||window.document}var Qo=new WeakMap;function Go(e){var t=Qo.get(e);return void 0===t&&Qo.set(e,t=function(e){var t=null;function n(e){if(e&&"object"==k(e))if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(var r=0;r<e.length;r++)n(e[r]);else for(var o in e)n(e[o])}return n(e),t}(e)),t}function Xo(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;var o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Go(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");var a,u=i.indexOf(" ");u>0&&(n=i.slice(0,u),i=i.slice(u+1));var s=n?e.createElementNS(n,i):e.createElement(i),l=t[1],c=1;if(l&&"object"==k(l)&&null==l.nodeType&&!Array.isArray(l))for(var d in c=2,l)if(null!=l[d]){var f=d.indexOf(" ");f>0?s.setAttributeNS(d.slice(0,f),d.slice(f+1),l[d]):"style"==d&&s.style?s.style.cssText=l[d]:s.setAttribute(d,l[d])}for(var h=c;h<t.length;h++){var p=t[h];if(0===p){if(h<t.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}if("string"==typeof p)s.appendChild(e.createTextNode(p));else{var v=Xo(e,p,n,r),m=v.dom,g=v.contentDOM;if(s.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}}return{dom:s,contentDOM:a}}var Zo=Math.pow(2,16);function Yo(e,t){return e+t*Zo}function ei(e){return 65535&e}var ti=function(){return x(function e(t,n,r){M(this,e),this.pos=t,this.delInfo=n,this.recover=r},[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}])}(),ni=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(M(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return x(e,[{key:"recover",value:function(e){var t=0,n=ei(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Zo}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var r=0,o=this.inverted?2:1,i=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var u=this.ranges[a]-(this.inverted?r:0);if(u>e)break;var s=this.ranges[a+o],l=this.ranges[a+i],c=u+s;if(e<=c){var d=u+r+((s?e==u?-1:e==c?1:t:t)<0?0:l);if(n)return d;var f=e==(t<0?u:c)?null:Yo(a/3,e-u),h=0;return s&&(h|=e==u?2:e==c?1:4,(t<0?e!=u:e!=c)&&(h|=8)),new ti(d,h,f)}r+=l-s}return n?e+r:new ti(e+r,0,null)}},{key:"touches",value:function(e,t){for(var n=0,r=ei(t),o=this.inverted?2:1,i=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var u=this.ranges[a]-(this.inverted?n:0);if(u>e)break;var s=this.ranges[a+o];if(e<=u+s&&a==3*r)return!0;n+=this.ranges[a+i]-s}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],a=i-(this.inverted?o:0),u=i+(this.inverted?0:o),s=this.ranges[r+t],l=this.ranges[r+n];e(a,a+s,u,u+l),o+=l-s}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}])}();ni.empty=new ni([]);var ri=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t?t.length:0;M(this,e),this.mirror=n,this.from=r,this.to=o,this._maps=t||[],this.ownData=!(t||n)}return x(e,[{key:"maps",get:function(){return this._maps}},{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this._maps,this.mirror,t,n)}},{key:"appendMap",value:function(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this._maps.length;t<e._maps.length;t++){var r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var r=0,o=this.from;o<this.to;o++){var i=this._maps[o].mapResult(e,t);if(null!=i.recover){var a=this.getMirror(o);if(null!=a&&a>o&&a<this.to){o=a,e=this._maps[a].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new ti(e,r,null)}}])}(),oi=Object.create(null),ii=function(){return x(function e(){M(this,e)},[{key:"getMap",value:function(){return ni.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=oi[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in oi)throw new RangeError("Duplicate use of step JSON ID "+e);return oi[e]=t,t.prototype.jsonID=e,t}}])}(),ai=function(){function e(t,n){M(this,e),this.doc=t,this.failed=n}return x(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,r,o){try{return e.ok(t.replace(n,r,o))}catch(t){if(t instanceof Jr)return e.fail(t.message);throw t}}}])}();function ui(e,t,n){for(var r=[],o=0;o<e.childCount;o++){var i=e.child(o);i.content.size&&(i=i.copy(ui(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return Vr.fromArray(r)}var si=function(){function e(t,n,r){var o;return M(this,e),(o=N(this,e)).from=t,o.to=n,o.mark=r,o}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new Qr(ui(n.content,function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},o),n.openStart,n.openEnd);return ai.fromReplace(e,this.from,this.to,i)}},{key:"invert",value:function(){return new li(this.from,this.to,this.mark)}},{key:"map",value:function(t){var 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)}},{key:"merge",value:function(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}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}}])}();ii.jsonID("addMark",si);var li=function(){function e(t,n,r){var o;return M(this,e),(o=N(this,e)).from=t,o.to=n,o.mark=r,o}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=new Qr(ui(n.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))},e),n.openStart,n.openEnd);return ai.fromReplace(e,this.from,this.to,r)}},{key:"invert",value:function(){return new si(this.from,this.to,this.mark)}},{key:"map",value:function(t){var 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)}},{key:"merge",value:function(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}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}}])}();ii.jsonID("removeMark",li);var ci=function(){function e(t,n){var r;return M(this,e),(r=N(this,e)).pos=t,r.mark=n,r}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return ai.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ai.fromReplace(e,this.pos,this.pos+1,new Qr(Vr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(t){var n=t.nodeAt(this.pos);if(n){var r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(var o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new e(this.pos,n.marks[o]);return new e(this.pos,this.mark)}}return new di(this.pos,this.mark)}},{key:"map",value:function(t){var n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}}])}();ii.jsonID("addNodeMark",ci);var di=function(){function e(t,n){var r;return M(this,e),(r=N(this,e)).pos=t,r.mark=n,r}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return ai.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ai.fromReplace(e,this.pos,this.pos+1,new Qr(Vr.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ci(this.pos,this.mark):this}},{key:"map",value:function(t){var n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}}])}();ii.jsonID("removeNodeMark",di);var fi=function(){function e(t,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return M(this,e),(o=N(this,e)).from=t,o.to=n,o.slice=r,o.structure=i,o}return A(e,ii),x(e,[{key:"apply",value:function(e){return this.structure&&pi(e,this.from,this.to)?ai.fail("Structure replace would overwrite content"):ai.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new ni([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}},{key:"map",value:function(t){var 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)}},{key:"merge",value:function(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){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var n=this.slice.size+t.slice.size==0?Qr.empty:new Qr(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?Qr.empty:new Qr(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),r,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,Qr.fromJSON(t,n.slice),!!n.structure)}}])}();fi.MAP_BIAS=1,ii.jsonID("replace",fi);var hi=function(){function e(t,n,r,o,i,a){var u,s=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return M(this,e),(u=N(this,e)).from=t,u.to=n,u.gapFrom=r,u.gapTo=o,u.slice=i,u.insert=a,u.structure=s,u}return A(e,ii),x(e,[{key:"apply",value:function(e){if(this.structure&&(pi(e,this.from,this.gapFrom)||pi(e,this.gapTo,this.to)))return ai.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ai.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?ai.fromReplace(e,this.from,this.to,n):ai.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new ni([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(t){var 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)}},{key:"map",value:function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var 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}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,Qr.fromJSON(t,n.slice),n.insert,!!n.structure)}}])}();function pi(e,t,n){for(var r=e.resolve(t),o=n-t,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var a=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,o--}return!1}function vi(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=e.doc.nodeAt(t),a=[],u=t+1,s=0;s<i.childCount;s++){var l=i.child(s),c=u+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(var f=0;f<l.marks.length;f++)n.allowsMarkType(l.marks[f].type)||e.step(new li(u,c,l.marks[f]));if(o&&l.isText&&"pre"!=n.whitespace)for(var h=void 0,p=/\r?\n|\r/g,v=void 0;h=p.exec(l.text);)v||(v=new Qr(Vr.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),a.push(new fi(u+h.index,u+h.index+h[0].length,v))}else a.push(new fi(u,c,Qr.empty));u=c}if(!r.validEnd){var m=r.fillBefore(Vr.empty,!0);e.replace(u,u,new Qr(m,0,0))}for(var g=a.length-1;g>=0;g--)e.step(a[g])}function mi(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gi(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth,r=0,o=0;;--n){var i=e.$from.node(n),a=e.$from.index(n)+r,u=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(a,u,t))return n;if(0==n||i.type.spec.isolating||!mi(i,a,u))break;a&&(r=1),u<i.childCount&&(o=1)}return null}function Di(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,o=function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;var a=i.length?i[0]:t;return n.canReplaceWith(r,o,a)?i:null}(e,t),i=o&&function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.child(r),a=t.contentMatch.findWrapping(i.type);if(!a)return null;for(var u=(a.length?a[a.length-1]:t).contentMatch,s=r;u&&s<o;s++)u=u.matchType(n.child(s).type);return u&&u.validEnd?a:null}(r,t);return i?o.map(yi).concat({type:t,attrs:n}).concat(i.map(yi)):null}function yi(e){return{type:e,attrs:null}}function ki(e,t,n,r){t.forEach(function(o,i){if(o.isText)for(var a,u=/\r?\n|\r/g;a=u.exec(o.text);){var s=e.mapping.slice(r).map(n+1+i+a.index);e.replaceWith(s,s+1,t.type.schema.linebreakReplacement.create())}})}function Ei(e,t,n,r){t.forEach(function(o,i){if(o.type==o.type.schema.linebreakReplacement){var a=e.mapping.slice(r).map(n+1+i);e.replaceWith(a,a+1,t.type.schema.text("\n"))}})}function Fi(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,o=e.resolve(t),i=o.depth-n,a=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!a.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var u=o.depth-1,s=n-2;u>i;u--,s--){var l=o.node(u),c=o.index(u);if(l.type.spec.isolating)return!1;var d=l.content.cutByIndex(c,l.childCount),f=r&&r[s+1];f&&(d=d.replaceChild(0,f.type.create(f.attrs)));var h=r&&r[s]||l;if(!l.canReplace(c+1,l.childCount)||!h.type.validContent(d))return!1}var p=o.indexAfter(i),v=r&&r[0];return o.node(i).canReplaceWith(p,p,v?v.type:o.node(i+1).type)}function bi(e,t){var n=e.resolve(t),r=n.index();return Ci(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ci(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);for(var n=e.contentMatchAt(e.childCount),r=e.type.schema.linebreakReplacement,o=0;o<t.childCount;o++){var i=t.child(o),a=i.type==r?e.type.schema.nodes.text:i.type;if(!(n=n.matchType(a)))return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function wi(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=e.resolve(t),o=r.depth;;o--){var i=void 0,a=void 0,u=r.index(o);if(o==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(o+1),u++,a=r.node(o).maybeChild(u)):(i=r.node(o).maybeChild(u-1),a=r.node(o+1)),i&&!i.isTextblock&&Ci(i,a)&&r.node(o).canReplace(u,u+1))return t;if(0==o)break;t=n<0?r.before(o):r.after(o)}}function Ai(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var u=r.depth;u>=0;u--){var s=u==r.depth?0:r.pos<=(r.start(u+1)+r.end(u+1))/2?-1:1,l=r.index(u)+(s>0?1:0),c=r.node(u),d=!1;if(1==a)d=c.canReplace(l,l,o);else{var f=c.contentMatchAt(l).findWrapping(o.firstChild.type);d=f&&c.canReplaceWith(l,l,f[0])}if(d)return 0==s?r.pos:s<0?r.before(u+1):r.after(u+1)}return null}function xi(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Qr.empty;if(t==n&&!r.size)return null;var o=e.resolve(t),i=e.resolve(n);return Si(o,i,r)?new fi(t,n,r):new Bi(o,i,r).fit()}function Si(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ii.jsonID("replaceAround",hi);var Bi=function(){return x(function e(t,n,r){M(this,e),this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Vr.empty;for(var o=0;o<=t.depth;o++){var i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(var a=t.depth;a>0;a--)this.placed=Vr.from(t.node(a).copy(this.placed))},[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(t<0?this.$to:r.doc.resolve(t));if(!o)return null;for(var i=this.placed,a=r.depth,u=o.depth;a&&u&&1==i.childCount;)i=i.firstChild.content,a--,u--;var s=new Qr(i,a,u);return t>-1?new hi(r.pos,t,this.$to.pos,this.$to.end(),s,n):s.size||r.pos!=this.$to.pos?new fi(r.pos,o.pos,s):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){var o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(var i=1;i<=2;i++)for(var a=1==i?e:this.unplaced.openStart;a>=0;a--)for(var u=null,s=(a?(u=Ni(this.unplaced.content,a-1).firstChild).content:this.unplaced.content).firstChild,l=this.depth;l>=0;l--){var c=this.frontier[l],d=c.type,f=c.match,h=void 0,p=null;if(1==i&&(s?f.matchType(s.type)||(p=f.fillBefore(Vr.from(s),!1)):u&&d.compatibleContent(u.type)))return{sliceDepth:a,frontierDepth:l,parent:u,inject:p};if(2==i&&s&&(h=f.findWrapping(s.type)))return{sliceDepth:a,frontierDepth:l,parent:u,wrap:h};if(u&&f.matchType(u.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd;return!(Pi(t,-1)<=n)&&(this.unplaced.size>1&&Pi(t,1)>r&&r++,this.unplaced=new Qr(t,n+1,r),!0)}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,o=Ni(t,n);if(o.childCount<=1&&n>0){var i=t.size-n<=n+o.size;this.unplaced=new Qr(Ti(t,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Qr(Ti(t,n,1),n,r)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,r=e.parent,o=e.inject,i=e.wrap;this.depth>n;)this.closeFrontierNode();if(i)for(var a=0;a<i.length;a++)this.openFrontierNode(i[a]);var u=this.unplaced,s=r?r.content:u.content,l=u.openStart-t,c=0,d=[],f=this.frontier[n],h=f.match,p=f.type;if(o){for(var v=0;v<o.childCount;v++)d.push(o.child(v));h=h.matchFragment(o)}for(var m=s.size+t-(u.content.size-u.openEnd);c<s.childCount;){var g=s.child(c),D=h.matchType(g.type);if(!D)break;(++c>1||0==l||g.content.size)&&(h=D,d.push(Ri(g.mark(p.allowedMarks(g.marks)),1==c?l:0,c==s.childCount?m:-1)))}var y=c==s.childCount;y||(m=-1),this.placed=Mi(this.placed,n,Vr.from(d)),this.frontier[n].match=h,y&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var k=0,E=s;k<m;k++){var F=E.lastChild;this.frontier.push({type:F.type,match:F.contentMatchAt(F.childCount)}),E=F.content}this.unplaced=y?0==t?Qr.empty:new Qr(Ti(u.content,t-1,1),t-1,m<0?u.openEnd:t-1):new Qr(Ti(u.content,t,c),u.openStart,u.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Oi(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,o=n.type,i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Oi(e,t,o,r,i);if(a){for(var u=t-1;u>=0;u--){var s=this.frontier[u],l=s.match,c=Oi(e,u,s.type,l,!0);if(!c||c.childCount)continue e}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Mi(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,o)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Mi(this.placed,this.depth,Vr.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(Vr.empty,!0);e.childCount&&(this.placed=Mi(this.placed,this.frontier.length,e))}}])}();function Ti(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Ti(e.firstChild.content,t-1,n)))}function Mi(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Mi(e.lastChild.content,t-1,n)))}function Ni(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function Ri(e,t,n){if(t<=0)return e;var r=e.content;return t>1&&(r=r.replaceChild(0,Ri(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Vr.empty,!0)))),e.copy(r)}function Oi(e,t,n,r,o){var i=e.node(t),a=o?e.indexAfter(t):e.index(t);if(a==i.childCount&&!n.compatibleContent(i.type))return null;var u=r.fillBefore(i.content,!0,a);return u&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,a)?u:null}function Ii(e){return e.spec.defining||e.spec.definingForContent}function Pi(e,t){for(var n=0;;n++){var r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function Li(e,t,n,r,o){if(t<n){var i=e.firstChild;e=e.replaceChild(0,i.copy(Li(i.content,t+1,n,r,i)))}if(t>r){var a=o.contentMatchAt(0),u=a.fillBefore(e).append(e);e=u.append(a.matchFragment(u).fillBefore(Vr.empty,!0))}return e}function zi(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}var $i=function(){function e(t,n,r){var o;return M(this,e),(o=N(this,e)).pos=t,o.attr=n,o.value=r,o}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return ai.fail("No node at attribute step's position");var n=Object.create(null);for(var r in t.attrs)n[r]=t.attrs[r];n[this.attr]=this.value;var o=t.type.create(n,null,t.marks);return ai.fromReplace(e,this.pos,this.pos+1,new Qr(Vr.from(o),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return ni.empty}},{key:"invert",value:function(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(t){var n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new e(n.pos,n.attr,n.value)}}])}();ii.jsonID("attr",$i);var qi=function(){function e(t,n){var r;return M(this,e),(r=N(this,e)).attr=t,r.value=n,r}return A(e,ii),x(e,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var r=e.type.create(t,e.content,e.marks);return ai.ok(r)}},{key:"getMap",value:function(){return ni.empty}},{key:"invert",value:function(t){return new e(this.attr,t.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(t,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new e(n.attr,n.value)}}])}();ii.jsonID("docAttr",qi);var ji=Error;((ji=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=ji,ji.prototype.name="TransformError";var Hi=function(){return x(function e(t){M(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new ri},[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new ji(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"changedRange",value:function(){for(var e=1e9,t=-1e9,n=0;n<this.mapping.maps.length;n++){var r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach(function(n,r,o,i){e=Math.min(e,o),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qr.empty,r=xi(this.doc,e,t,n);return r&&this.step(r),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new Qr(Vr.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,Qr.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);var o=e.doc.resolve(t),i=e.doc.resolve(n);if(Si(o,i,r))return e.step(new fi(t,n,r));var a=zi(o,i);0==a[a.length-1]&&a.pop();var u=-(o.depth+1);a.unshift(u);for(var s=o.depth,l=o.pos-1;s>0;s--,l--){var c=o.node(s).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;a.indexOf(s)>-1?u=s:o.before(s)==l&&a.splice(1,0,-s)}for(var d=a.indexOf(u),f=[],h=r.openStart,p=r.content,v=0;;v++){var m=p.firstChild;if(f.push(m),v==r.openStart)break;p=m.content}for(var g=h-1;g>=0;g--){var D=f[g],y=Ii(D.type);if(y&&!D.sameMarkup(o.node(Math.abs(u)-1)))h=g;else if(y||!D.type.isTextblock)break}for(var k=r.openStart;k>=0;k--){var E=(k+h+1)%(r.openStart+1),F=f[E];if(F)for(var b=0;b<a.length;b++){var C=a[(b+d)%a.length],w=!0;C<0&&(w=!1,C=-C);var A=o.node(C-1),x=o.index(C-1);if(A.canReplaceWith(x,x,F.type,F.marks))return e.replace(o.before(C),w?i.after(C):n,new Qr(Li(r.content,0,r.openStart,E),E,r.openEnd))}}for(var S=e.steps.length,B=a.length-1;B>=0&&(e.replace(t,n,r),!(e.steps.length>S));B--){var T=a[B];T<0||(t=o.before(T),n=i.after(T))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var o=function(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var a=r.depth-1;a>=0;a--){var u=r.indexAfter(a);if(r.node(a).canReplaceWith(u,u,n))return r.after(a+1);if(u<r.node(a).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Qr(Vr.from(r),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){var r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){for(var i=r.sharedDepth(n),a=!1,u=r.depth;u>i;u--)r.node(u).type.spec.isolating&&(a=!0);for(var s=o.depth;s>i;s--)o.node(s).type.spec.isolating&&(a=!0);if(!a){for(var l=r.depth;l>0&&t==r.start(l);l--)t=r.before(l);for(var c=o.depth;c>0&&n==o.start(c);c--)n=o.before(c);r=e.doc.resolve(t),o=e.doc.resolve(n)}}for(var d=zi(r,o),f=0;f<d.length;f++){var h=d[f],p=f==d.length-1;if(p&&0==h||r.node(h).type.contentMatch.validEnd)return e.delete(r.start(h),o.end(h));if(h>0&&(p||r.node(h-1).canReplace(r.index(h-1),o.indexAfter(h-1))))return e.delete(r.before(h),o.after(h))}for(var v=1;v<=r.depth&&v<=o.depth;v++)if(t-r.start(v)==r.depth-v&&n>r.end(v)&&o.end(v)-n!=o.depth-v&&r.start(v-1)==o.start(v-1)&&r.node(v-1).canReplace(r.index(v-1),o.index(v-1)))return e.delete(r.before(v),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var r=t.$from,o=t.$to,i=t.depth,a=r.before(i+1),u=o.after(i+1),s=a,l=u,c=Vr.empty,d=0,f=i,h=!1;f>n;f--)h||r.index(f)>0?(h=!0,c=Vr.from(r.node(f).copy(c)),d++):s--;for(var p=Vr.empty,v=0,m=i,g=!1;m>n;m--)g||o.after(m+1)<o.end(m)?(g=!0,p=Vr.from(o.node(m).copy(p)),v++):l++;e.step(new hi(s,l,a,u,new Qr(c.append(p),d,v),c.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var r=null,o=e.doc.type.schema.linebreakReplacement,i=e.doc.resolve(t-n),a=i.node().type;if(o&&a.inlineContent){var u="pre"==a.whitespace,s=!!a.contentMatch.matchType(o);u&&!s?r=!1:!u&&s&&(r=!0)}var l=e.steps.length;if(!1===r){var c=e.doc.resolve(t+n);Ei(e,c.node(),c.before(),l)}a.inlineContent&&vi(e,t+n-1,a,i.node().contentMatchAt(i.index()),null==r);var d=e.mapping.slice(l),f=d.map(t-n);if(e.step(new fi(f,d.map(t+n,-1),Qr.empty,!0)),!0===r){var h=e.doc.resolve(f);ki(e,h.node(),h.before(),e.steps.length)}}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var r=Vr.empty,o=n.length-1;o>=0;o--){if(r.size){var i=n[o].type.contentMatch.matchFragment(r);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Vr.from(n[o].type.create(n[o].attrs,r))}var a=t.start,u=t.end;e.step(new hi(a,u,a,u,new Qr(r,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=e.steps.length;e.doc.nodesBetween(t,n,function(t,n){var a="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,a)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){var u=null;if(r.schema.linebreakReplacement){var s="pre"==r.whitespace,l=!!r.contentMatch.matchType(r.schema.linebreakReplacement);s&&!l?u=!1:!s&&l&&(u=!0)}!1===u&&Ei(e,t,n,i),vi(e,e.mapping.slice(i).map(n,1),r,void 0,null===u);var c=e.mapping.slice(i),d=c.map(n,1),f=c.map(n+t.nodeSize,1);return e.step(new hi(d,f,d+1,f-1,new Qr(Vr.from(r.create(a,null,t.marks)),0,0),1,!0)),!0===u&&ki(e,t,n,i),!1}})}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,r,o){var i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);var a=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,a);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new hi(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Qr(Vr.from(a),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new $i(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new qi(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new ci(e,t)),this}},{key:"removeNodeMark",value:function(e,t){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Kr)t.isInSet(n.marks)&&this.step(new di(e,t));else{for(var r,o=n.marks,i=[];r=t.isInSet(o);)i.push(new di(e,r)),o=r.removeFromSet(o);for(var a=i.length-1;a>=0;a--)this.step(i[a])}return this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,o=e.doc.resolve(t),i=Vr.empty,a=Vr.empty,u=o.depth,s=o.depth-n,l=n-1;u>s;u--,l--){i=Vr.from(o.node(u).copy(i));var c=r&&r[l];a=Vr.from(c?c.type.create(c.attrs,a):o.node(u).copy(a))}e.step(new fi(t,t,new Qr(i.append(a),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,r){var o,i,a=[],u=[];e.doc.nodesBetween(t,n,function(e,s,l){if(e.isInline){var c=e.marks;if(!r.isInSet(c)&&l.type.allowsMarkType(r.type)){for(var d=Math.max(s,t),f=Math.min(s+e.nodeSize,n),h=r.addToSet(c),p=0;p<c.length;p++)c[p].isInSet(h)||(o&&o.to==d&&o.mark.eq(c[p])?o.to=f:a.push(o=new li(d,f,c[p])));i&&i.to==d?i.to=f:u.push(i=new si(d,f,r))}}}),a.forEach(function(t){return e.step(t)}),u.forEach(function(t){return e.step(t)})}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,r){var o=[],i=0;e.doc.nodesBetween(t,n,function(e,a){if(e.isInline){i++;var u=null;if(r instanceof Ro)for(var s,l=e.marks;s=r.isInSet(l);)(u||(u=[])).push(s),l=s.removeFromSet(l);else r?r.isInSet(e.marks)&&(u=[r]):u=e.marks;if(u&&u.length)for(var c=Math.min(a+e.nodeSize,n),d=0;d<u.length;d++){for(var f=u[d],h=void 0,p=0;p<o.length;p++){var v=o[p];v.step==i-1&&f.eq(o[p].style)&&(h=v)}h?(h.to=c,h.step=i):o.push({style:f,from:Math.max(a,t),to:c,step:i})}}}),o.forEach(function(t){return e.step(new li(t.from,t.to,t.style))})}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return vi(this,e,t,n),this}}])}(),Vi=Object.create(null),Ui=function(){return x(function e(t,n,r){M(this,e),this.$anchor=t,this.$head=n,this.ranges=r||[new Wi(t.min(n),t.max(n))]},[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qr.empty,n=t.content.lastChild,r=null,o=0;o<t.openEnd;o++)r=n,n=n.lastChild;for(var i=e.steps.length,a=this.ranges,u=0;u<a.length;u++){var s=a[u],l=s.$from,c=s.$to,d=e.mapping.slice(i);e.replaceRange(d.map(l.pos),d.map(c.pos),u?Qr.empty:t),0==u&&ta(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],a=i.$from,u=i.$to,s=e.mapping.slice(n),l=s.map(a.pos),c=s.map(u.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),ta(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return Ji.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.parent.inlineContent?new Ji(e):ea(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var o=e.depth-1;o>=0;o--){var i=t<0?ea(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):ea(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new Zi(e.node(0))}},{key:"atStart",value:function(e){return ea(e,e,0,0,1)||new Zi(e)}},{key:"atEnd",value:function(e){return ea(e,e,e.content.size,e.childCount,-1)||new Zi(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Vi[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Vi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vi[e]=t,t.prototype.jsonID=e,t}}])}();Ui.prototype.visible=!0;var Wi=x(function e(t,n){M(this,e),this.$from=t,this.$to=n}),_i=!1;function Ki(e){_i||e.parent.inlineContent||(_i=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var Ji=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return M(this,e),Ki(t),Ki(n),N(this,e,[t,n])}return A(e,Ui),x(e,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(t,n){var r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ui.near(r);var o=t.resolve(n.map(this.anchor));return new e(o.parent.inlineContent?o:r,r)}},{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qr.empty;if(H(e,"replace",this,3)([t,n]),n==Qr.empty){var r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}},{key:"eq",value:function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}},{key:"getBookmark",value:function(){return new Qi(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}},{key:"between",value:function(t,n,r){var o=t.pos-n.pos;if(r&&!o||(r=o>=0?1:-1),!n.parent.inlineContent){var i=Ui.findFrom(n,r,!0)||Ui.findFrom(n,-r,!0);if(!i)return Ui.near(n,r);n=i.$head}return t.parent.inlineContent||(0==o||(t=(Ui.findFrom(t,-r,!0)||Ui.findFrom(t,r,!0)).$anchor).pos<n.pos!=o<0)&&(t=n),new e(t,n)}}])}();Ui.jsonID("text",Ji);var Qi=function(){function e(t,n){M(this,e),this.anchor=t,this.head=n}return x(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return Ji.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),Gi=function(){function e(t){var n;M(this,e);var r=t.nodeAfter,o=t.node(0).resolve(t.pos+r.nodeSize);return(n=N(this,e,[t,o])).node=r,n}return A(e,Ui),x(e,[{key:"map",value:function(t,n){var r=n.mapResult(this.anchor),o=r.deleted,i=r.pos,a=t.resolve(i);return o?Ui.near(a):new e(a)}},{key:"content",value:function(){return new Qr(Vr.from(this.node),0,0)}},{key:"eq",value:function(t){return t instanceof e&&t.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new Xi(this.anchor)}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))}},{key:"create",value:function(t,n){return new e(t.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}();Gi.prototype.visible=!1,Ui.jsonID("node",Gi);var Xi=function(){function e(t){M(this,e),this.anchor=t}return x(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),r=n.deleted,o=n.pos;return r?new Qi(o,o):new e(o)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Gi.isSelectable(n)?new Gi(t):Ui.near(t)}}])}(),Zi=function(){function e(t){return M(this,e),N(this,e,[t.resolve(0),t.resolve(t.content.size)])}return A(e,Ui),x(e,[{key:"replace",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qr.empty;if(n==Qr.empty){t.delete(0,t.doc.content.size);var r=Ui.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else H(e,"replace",this,3)([t,n])}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(t){return new e(t)}},{key:"eq",value:function(t){return t instanceof e}},{key:"getBookmark",value:function(){return Yi}}],[{key:"fromJSON",value:function(t){return new e(t)}}])}();Ui.jsonID("all",Zi);var Yi={map:function(){return this},resolve:function(e){return new Zi(e)}};function ea(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return Ji.create(e,n);for(var a=r-(o>0?0:1);o>0?a<t.childCount:a>=0;a+=o){var u=t.child(a);if(u.isAtom){if(!i&&Gi.isSelectable(u))return Gi.create(e,n-(o<0?u.nodeSize:0))}else{var s=ea(e,u,n+o,o<0?u.childCount:0,o,i);if(s)return s}n+=u.nodeSize*o}return null}function ta(e,t,n){var r=e.steps.length-1;if(!(r<t)){var o,i=e.steps[r];if(i instanceof fi||i instanceof hi)e.mapping.maps[r].forEach(function(e,t,n,r){null==o&&(o=r)}),e.setSelection(Ui.near(e.doc.resolve(o),n))}}var na=function(){function e(t){var n;return M(this,e),(n=N(this,e,[t.doc])).curSelectionFor=0,n.updated=0,n.meta=Object.create(null),n.time=Date.now(),n.curSelection=t.selection,n.storedMarks=t.storedMarks,n}return A(e,Hi),x(e,[{key:"selection",get:function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}},{key:"setSelection",value:function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return Kr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(t,n){H(e,"addStep",this,3)([t,n]),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Kr.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(null==n&&(n=t),!e)return this.deleteRange(t,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(Ui.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}])}();function ra(e,t){return t&&e?e.bind(t):e}var oa=x(function e(t,n,r){M(this,e),this.name=t,this.init=ra(n.init,r),this.apply=ra(n.apply,r)}),ia=[new oa("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new oa("selection",{init:function(e,t){return e.selection||Ui.atStart(t.doc)},apply:function(e){return e.selection}}),new oa("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new oa("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],aa=x(function e(t,n){var r=this;M(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ia.slice(),n&&n.forEach(function(e){if(r.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");r.plugins.push(e),r.pluginsByKey[e.key]=e,e.spec.state&&r.fields.push(new oa(e.key,e.spec.state,e))})}),ua=function(){function e(t){M(this,e),this.config=t}return x(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var a=this.config.plugins[i];if(a.spec.appendTransaction){var u=r?r[i].n:0,s=r?r[i].state:this,l=u<t.length&&a.spec.appendTransaction.call(a,u?t.slice(u):t,s,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",e),!r){r=[];for(var c=0;c<this.config.plugins.length;c++)r.push(c<i?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),r=this.config.fields,o=0;o<r.length;o++){var i=r[o];n[i.name]=i.apply(t,this[i.name],this,n)}return n}},{key:"tr",get:function(){return new na(this)}},{key:"reconfigure",value:function(t){for(var n=new aa(this.schema,t.plugins),r=n.fields,o=new e(n),i=0;i<r.length;i++){var a=r[i].name;o[a]=this.hasOwnProperty(a)?this[a]:r[i].init(t,o)}return o}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(function(e){return e.toJSON()})),e&&"object"==k(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}}],[{key:"create",value:function(t){for(var n=new aa(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n),o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(t,r);return r}},{key:"fromJSON",value:function(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var o=new aa(t.schema,t.plugins),i=new e(o);return o.fields.forEach(function(e){if("doc"==e.name)i.doc=po.fromJSON(t.schema,n.doc);else if("selection"==e.name)i.selection=Ui.fromJSON(i.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(i.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(var o in r){var a=r[o],u=a.spec.state;if(a.key==e.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o))return void(i[e.name]=u.fromJSON.call(a,t,n[o],i))}i[e.name]=e.init(t,i)}}),i}}])}();function sa(e,t,n){for(var r in e){var o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=sa(o,t,{})),n[r]=o}return n}var la=function(){return x(function e(t){M(this,e),this.spec=t,this.props={},t.props&&sa(t.props,this,this.props),this.key=t.key?t.key.key:da("plugin")},[{key:"getState",value:function(e){return e[this.key]}}])}(),ca=Object.create(null);function da(e){return e in ca?e+"$"+ ++ca[e]:(ca[e]=0,e+"$")}var fa=function(){return x(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";M(this,e),this.key=da(t)},[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}(),ha=function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)};function pa(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var va=function(e,t,n){var r=pa(e,n);if(!r)return!1;var o=ya(r);if(!o){var i=r.blockRange(),a=i&&gi(i);return null!=a&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)}var u=o.nodeBefore;if(Ma(e,o,t,-1))return!0;if(0==r.parent.content.size&&(ga(u,"end")||Gi.isSelectable(u)))for(var s=r.depth;;s--){var l=xi(e.doc,r.before(s),r.after(s),Qr.empty);if(l&&l.slice.size<l.to-l.from){if(t){var c=e.tr.step(l);c.setSelection(ga(u,"end")?Ui.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):Gi.create(c.doc,o.pos-u.nodeSize)),t(c.scrollIntoView())}return!0}if(1==s||r.node(s-1).childCount>1)break}return!(!u.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-u.nodeSize,o.pos).scrollIntoView()),!0)};function ma(e,t,n){for(var r=t.nodeBefore,o=t.pos-1;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;var i=r.lastChild;if(!i)return!1;r=i}for(var a=t.nodeAfter,u=t.pos+1;!a.isTextblock;u++){if(a.type.spec.isolating)return!1;var s=a.firstChild;if(!s)return!1;a=s}var l=xi(e.doc,o,u,Qr.empty);if(!l||l.from!=o||l instanceof fi&&l.slice.size>=u-o)return!1;if(n){var c=e.tr.step(l);c.setSelection(Ji.create(c.doc,o)),n(c.scrollIntoView())}return!0}function ga(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}var Da=function(e,t,n){var r=e.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=ya(o)}var a=i&&i.nodeBefore;return!(!a||!Gi.isSelectable(a))&&(t&&t(e.tr.setSelection(Gi.create(e.doc,i.pos-a.nodeSize)).scrollIntoView()),!0)};function ya(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ka(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var Ea=function(e,t,n){var r=ka(e,n);if(!r)return!1;var o=ba(r);if(!o)return!1;var i=o.nodeAfter;if(Ma(e,o,t,1))return!0;if(0==r.parent.content.size&&(ga(i,"start")||Gi.isSelectable(i))){var a=xi(e.doc,r.before(),r.after(),Qr.empty);if(a&&a.slice.size<a.to-a.from){if(t){var u=e.tr.step(a);u.setSelection(ga(i,"start")?Ui.findFrom(u.doc.resolve(u.mapping.map(o.pos)),1):Gi.create(u.doc,u.mapping.map(o.pos))),t(u.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},Fa=function(e,t,n){var r=e.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=ba(o)}var a=i&&i.nodeAfter;return!(!a||!Gi.isSelectable(a))&&(t&&t(e.tr.setSelection(Gi.create(e.doc,i.pos)).scrollIntoView()),!0)};function ba(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Ca=function(e,t){var n=e.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function wa(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Aa=function(e,t){var n=e.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i=r.node(-1),a=r.indexAfter(-1),u=wa(i.contentMatchAt(a));if(!u||!i.canReplaceWith(a,a,u))return!1;if(t){var s=r.after(),l=e.tr.replaceWith(s,s,u.createAndFill());l.setSelection(Ui.near(l.doc.resolve(s),1)),t(l.scrollIntoView())}return!0},xa=function(e,t){var n=e.selection,r=n.$from,o=n.$to;if(n instanceof Zi||r.parent.inlineContent||o.parent.inlineContent)return!1;var i=wa(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){var a=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,u=e.tr.insert(a,i.createAndFill());u.setSelection(Ji.create(u.doc,a+1)),t(u.scrollIntoView())}return!0},Sa=function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(Fi(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&gi(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};var Ba,Ta=function(e,t){if(e.selection instanceof Gi&&e.selection.node.isBlock){var n=e.selection.$from;return!(!n.parentOffset||!Fi(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0))}if(!e.selection.$from.depth)return!1;var r=e.tr;!e.selection.empty&&(e.selection instanceof Ji||e.selection instanceof Zi)&&r.deleteSelection();for(var o,i,a=r.selection.$from,u=r.steps.length,s=[],l=!1,c=!1,d=a.depth;;d--){if(a.node(d).isBlock){l=a.end(d)==a.pos+(a.depth-d),c=a.start(d)==a.pos-(a.depth-d),i=wa(a.node(d-1).contentMatchAt(a.indexAfter(d-1)));var f=Ba&&Ba(a.parent,l,a);s.unshift(f||(l&&i?{type:i}:null)),o=d;break}if(1==d)return!1;s.unshift(null)}var h=a.pos,p=Fi(r.doc,h,s.length,s);if(p||(s[0]=i?{type:i}:null,p=Fi(r.doc,h,s.length,s)),!p)return!1;if(r.split(h,s.length,s),!l&&c&&a.node(o).type!=i){var v=r.mapping.slice(u),m=v.map(a.before(o)),g=r.doc.resolve(m);i&&a.node(o-1).canReplaceWith(g.index(),g.index()+1,i)&&r.setNodeMarkup(v.map(a.before(o)),i)}return t&&t(r.scrollIntoView()),!0};function Ma(e,t,n,r){var o,i,a=t.nodeBefore,u=t.nodeAfter,s=a.type.spec.isolating||u.type.spec.isolating;if(!s&&function(e,t,n){var r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!bi(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var l=!s&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(i=a.contentMatchAt(a.childCount)).findWrapping(u.type))&&i.matchType(o[0]||u.type).validEnd){if(n){for(var c=t.pos+u.nodeSize,d=Vr.empty,f=o.length-1;f>=0;f--)d=Vr.from(o[f].create(null,d));d=Vr.from(a.copy(d));var h=e.tr.step(new hi(t.pos-1,c,t.pos,c,new Qr(d,1,0),o.length,!0)),p=h.doc.resolve(c+2*o.length);p.nodeAfter&&p.nodeAfter.type==a.type&&bi(h.doc,p.pos)&&h.join(p.pos),n(h.scrollIntoView())}return!0}var v=u.type.spec.isolating||r>0&&s?null:Ui.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),g=m&&gi(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(l&&ga(u,"start",!0)&&ga(a,"end")){for(var D=a,y=[];y.push(D),!D.isTextblock;)D=D.lastChild;for(var k=u,E=1;!k.isTextblock;k=k.firstChild)E++;if(D.canReplace(D.childCount,D.childCount,k.content)){if(n){for(var F=Vr.empty,b=y.length-1;b>=0;b--)F=Vr.from(y[b].copy(F));n(e.tr.step(new hi(t.pos-y.length,t.pos+u.nodeSize,t.pos+E,t.pos+u.nodeSize-E,new Qr(F,y.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Na(e){return function(t,n){for(var r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(Ji.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}var Ra=Na(-1),Oa=Na(1);function Ia(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){for(var o=!1,i=0;i<n.selection.ranges.length&&!o;i++){var a=n.selection.ranges[i],u=a.$from.pos,s=a.$to.pos;n.doc.nodesBetween(u,s,function(r,i){if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{var a=n.doc.resolve(i),u=a.index();o=a.parent.canReplaceWith(u,u+1,e)}})}if(!o)return!1;if(r){for(var l=n.tr,c=0;c<n.selection.ranges.length;c++){var d=n.selection.ranges[c],f=d.$from.pos,h=d.$to.pos;l.setBlockType(f,h,e,t)}r(l.scrollIntoView())}return!0}}function Pa(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,n,r){for(var o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}Pa(ha,va,Da),Pa(ha,Ea,Fa);function La(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var o=n.selection,i=o.$from,a=o.$to,u=i.blockRange(a);if(!u)return!1;var s=r?n.tr:null;return!!function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=!1,i=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;var u=a.resolve(t.start-2);i=new fo(u,u,t.depth),t.endIndex<t.parent.childCount&&(t=new fo(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),o=!0}var s=Di(i,n,r,t);if(!s)return!1;e&&function(e,t,n,r,o){for(var i=Vr.empty,a=n.length-1;a>=0;a--)i=Vr.from(n[a].type.create(n[a].attrs,i));e.step(new hi(t.start-(r?2:0),t.end,t.start,t.end,new Qr(i,0,0),n.length,!0));for(var u=0,s=0;s<n.length;s++)n[s].type==o&&(u=s+1);for(var l=n.length-u,c=t.start+n.length-(r?2:0),d=t.parent,f=t.startIndex,h=t.endIndex,p=!0;f<h;f++,p=!1)!p&&Fi(e.doc,c,l)&&(e.split(c,l),c+=2*l),c+=d.child(f).nodeSize}(e,t,s,o,n);return!0}(s,u,e,t)&&(r&&r(s.scrollIntoView()),!0)}}function za(e){return function(t,n){var r=t.selection,o=r.$from,i=r.$to,a=o.blockRange(i,function(t){return t.childCount>0&&t.firstChild.type==e});return!!a&&(!n||(o.node(a.depth-1).type==e?function(e,t,n,r){var o=e.tr,i=r.end,a=r.$to.end(r.depth);i<a&&(o.step(new hi(i-1,a,i,a,new Qr(Vr.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new fo(o.doc.resolve(r.$from.pos),o.doc.resolve(a),r.depth));var u=gi(r);if(null==u)return!1;o.lift(r,u);var s=o.doc.resolve(o.mapping.map(i,-1)-1);bi(o.doc,s.pos)&&s.nodeBefore.type==s.nodeAfter.type&&o.join(s.pos);return t(o.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){for(var r=e.tr,o=n.parent,i=n.end,a=n.endIndex-1,u=n.startIndex;a>u;a--)i-=o.child(a).nodeSize,r.delete(i-1,i+1);var s=r.doc.resolve(n.start),l=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;var c=0==n.startIndex,d=n.endIndex==o.childCount,f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(c?0:1),h+1,l.content.append(d?Vr.empty:Vr.from(o))))return!1;var p=s.pos,v=p+l.nodeSize;return r.step(new hi(p-(c?1:0),v+(d?1:0),p+1,v-1,new Qr((c?Vr.empty:Vr.from(o.copy(Vr.empty))).append(d?Vr.empty:Vr.from(o.copy(Vr.empty))),c?0:1,d?0:1),c?0:1)),t(r.scrollIntoView()),!0}(t,n,a)))}}Pa(Ca,xa,Sa,Ta),"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var $a=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},qa=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},ja=null,Ha=function(e,t,n){var r=ja||(ja=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Va=function(e,t,n,r){return n&&(Wa(e,t,n,r,-1)||Wa(e,t,n,r,1))},Ua=/^(img|br|input|textarea|hr)$/i;function Wa(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:_a(e))){var a=e.parentNode;if(!a||!Ka(a)||Ga(e)||Ua.test(e.nodeName)||"false"==e.contentEditable)return!1;t=$a(e)+(o<0?0:1),e=a}else{if(!Ka(e))return!1;var u=e.childNodes[t+(o<0?-1:0)];if(Ka(u)&&"false"==u.contentEditable){if(!(null===(i=u.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=u,t=o<0?_a(e):0}}}function _a(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ka(e){return 1==e.nodeType}function Ja(e){return 3==e.nodeType}function Qa(e,t){return!!t&&e.contains(Ka(t)?t:t.parentNode)}function Ga(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Xa=function(e){return e.focusNode&&Va(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Za(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var Ya="undefined"!=typeof navigator?navigator:null,eu="undefined"!=typeof document?document:null,tu=Ya&&Ya.userAgent||"",nu=/Edge\/(\d+)/.exec(tu),ru=/MSIE \d/.exec(tu),ou=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tu),iu=!!(ru||ou||nu),au=ru?document.documentMode:ou?+ou[1]:nu?+nu[1]:0,uu=!iu&&/gecko\/(\d+)/i.test(tu);uu&&(/Firefox\/(\d+)/.exec(tu)||[0,0])[1];var su=!iu&&/Chrome\/(\d+)/.exec(tu),lu=!!su,cu=su?+su[1]:0,du=!iu&&!!Ya&&/Apple Computer/.test(Ya.vendor),fu=du&&(/Mobile\/\w+/.test(tu)||!!Ya&&Ya.maxTouchPoints>2),hu=fu||!!Ya&&/Mac/.test(Ya.platform),pu=!!Ya&&/Win/.test(Ya.platform),vu=/Android \d/.test(tu),mu=!!eu&&"webkitFontSmoothing"in eu.documentElement.style,gu=mu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Du(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function yu(e,t){return"number"==typeof e?e:e[t]}function ku(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Eu(e,t,n){if(Bu(t)||0!=t.left)for(var r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,a=n||e.dom;a;)if(Ka(a)){var u=a==i.body,s=u?Du(i):ku(a),l=0,c=0;if(t.top<s.top+yu(r,"top")?c=-(s.top-t.top+yu(o,"top")):t.bottom>s.bottom-yu(r,"bottom")&&(c=t.bottom-t.top>s.bottom-s.top?t.top+yu(o,"top")-s.top:t.bottom-s.bottom+yu(o,"bottom")),t.left<s.left+yu(r,"left")?l=-(s.left-t.left+yu(o,"left")):t.right>s.right-yu(r,"right")&&(l=t.right-s.right+yu(o,"right")),l||c)if(u)i.defaultView.scrollBy(l,c);else{var d=a.scrollLeft,f=a.scrollTop;c&&(a.scrollTop+=c),l&&(a.scrollLeft+=l);var h=a.scrollLeft-d,p=a.scrollTop-f;t={left:t.left-h,top:t.top-p,right:t.right-h,bottom:t.bottom-p}}var v=u?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(v))break;a="absolute"==v?a.offsetParent:qa(a)}else a=qa(a)}function Fu(e){for(var t=[],n=e.ownerDocument,r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=qa(r));return t}function bu(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=r.dom,i=r.top,a=r.left;o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=a&&(o.scrollLeft=a)}}var Cu=null;function wu(e,t){for(var n,r,o,i,a=2e8,u=0,s=t.top,l=t.top,c=e.firstChild,d=0;c;c=c.nextSibling,d++){var f=void 0;if(Ka(c))f=c.getClientRects();else{if(!Ja(c))continue;f=Ha(c).getClientRects()}for(var h=0;h<f.length;h++){var p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<a){n=c,a=v,r=v&&Ja(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,Ka(c)&&v&&(u=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=c,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(u=d+1)}}return!n&&o&&(n=o,r=i,a=0),n&&Ja(n)?function(e,t){for(var n,r=e.nodeValue.length,o=document.createRange(),i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);var a=Tu(o,1);if(a.top!=a.bottom&&Au(t,a)){n={node:e,offset:i+(t.left>=(a.left+a.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||a?{node:e,offset:u}:wu(n,r)}function Au(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function xu(e,t,n){var r=e.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var a=e.childNodes[i];if(Ka(a))for(var u=a.getClientRects(),s=0;s<u.length;s++){var l=u[s];if(Au(t,l))return xu(a,t,l)}if((i=(i+1)%r)==o)break}return e}function Su(e,t){var n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{var r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(_a(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){var o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(_a(o.startContainer),o.startOffset)}}}(r,t.left,t.top);i&&(n=i.node,o=i.offset);var a,u=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!u||!e.dom.contains(u)){var s=e.dom.getBoundingClientRect();if(!Au(t,s))return null;if(!(u=xu(e.dom,t,s)))return null}if(du)for(var l=u;n&&l;l=qa(l))l.draggable&&(n=void 0);if(u=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(u,t),n){if(uu&&Ka(n)&&(o=Math.min(o,n.childNodes.length))<n.childNodes.length){var c,d=n.childNodes[o];"IMG"==d.nodeName&&(c=d.getBoundingClientRect()).right<=t.left&&c.bottom>t.top&&o++}var f;mu&&o&&Ka(n)&&Ka(f=n.childNodes[o-1])&&"false"==f.contentEditable&&f.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&Ka(n.lastChild)&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=o&&Ka(n)&&"BR"==n.childNodes[o-1].nodeName||(a=function(e,t,n,r){for(var o=-1,i=t,a=!1;i!=e.dom;){var u=e.docView.nearestDesc(i,!0),s=void 0;if(!u)return null;if(Ka(u.dom)&&(u.node.isBlock&&u.parent||!u.contentDOM)&&((s=u.dom.getBoundingClientRect()).width||s.height)&&(u.node.isBlock&&u.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(u.dom.nodeName)&&(!a&&s.left>r.left||s.top>r.top?o=u.posBefore:(!a&&s.right<r.left||s.bottom<r.top)&&(o=u.posAfter),a=!0),!u.contentDOM&&o<0&&!u.node.isText))return(u.node.isBlock?r.top<(s.top+s.bottom)/2:r.left<(s.left+s.right)/2)?u.posBefore:u.posAfter;i=u.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==a&&(a=function(e,t,n){var r=wu(t,n),o=r.node,i=r.offset,a=-1;if(Ka(o)&&!o.firstChild){var u=o.getBoundingClientRect();a=u.left!=u.right&&n.left>(u.left+u.right)/2?1:-1}return e.docView.posFromDOM(o,i,a)}(e,u,t));var h=e.docView.nearestDesc(u,!0);return{pos:a,inside:h?h.posAtStart-h.border:-1}}function Bu(e){return e.top<e.bottom||e.left<e.right}function Tu(e,t){var n=e.getClientRects();if(n.length){var r=n[t<0?0:n.length-1];if(Bu(r))return r}return Array.prototype.find.call(n,Bu)||e.getBoundingClientRect()}var Mu=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Nu(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),o=r.node,i=r.offset,a=r.atom,u=mu||uu;if(Ja(o)){if(!u||!Mu.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var s=i,l=i,c=n<0?1:-1;return n<0&&!i?(l++,c=-1):n>=0&&i==o.nodeValue.length?(s--,c=1):n<0?s--:l++,Ru(Tu(Ha(o,s,l),c),c<0)}var d=Tu(Ha(o,i,i),n);if(uu&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var f=Tu(Ha(o,i-1,i-1),-1);if(f.top==d.top){var h=Tu(Ha(o,i,i+1),-1);if(h.top!=d.top)return Ru(h,h.left<f.left)}}return d}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(null==a&&i&&(n<0||i==_a(o))){var p=o.childNodes[i-1];if(Ka(p))return Ou(p.getBoundingClientRect(),!1)}if(null==a&&i<_a(o)){var v=o.childNodes[i];if(Ka(v))return Ou(v.getBoundingClientRect(),!0)}return Ou(o.getBoundingClientRect(),n>=0)}if(null==a&&i&&(n<0||i==_a(o))){var m=o.childNodes[i-1],g=Ja(m)?Ha(m,_a(m)-(u?0:1)):!Ka(m)||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return Ru(Tu(g,1),!1)}if(null==a&&i<_a(o)){for(var D=o.childNodes[i];D.pmViewDesc&&D.pmViewDesc.ignoreForCoords;)D=D.nextSibling;var y=D?Ja(D)?Ha(D,0,u?0:1):Ka(D)?D:null:null;if(y)return Ru(Tu(y,-1),!0)}return Ru(Tu(Ja(o)?Ha(o):o,-n),n>=0)}function Ru(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ou(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Iu(e,t,n){var r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}var Pu=/[\u0590-\u08ac]/;var Lu=null,zu=null,$u=!1;function qu(e,t,n){return Lu==t&&zu==n?$u:(Lu=t,zu=n,$u="up"==n||"down"==n?function(e,t,n){var r=t.selection,o="up"==n?r.$from:r.$to;return Iu(e,t,function(){for(var t=e.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.contentDOM||r.dom;break}t=r.dom.parentNode}for(var i=Nu(e,o.pos,1),a=t.firstChild;a;a=a.nextSibling){var u=void 0;if(Ka(a))u=a.getClientRects();else{if(!Ja(a))continue;u=Ha(a,0,a.nodeValue.length).getClientRects()}for(var s=0;s<u.length;s++){var l=u[s];if(l.bottom>l.top+1&&("up"==n?i.top-l.top>2*(l.bottom-i.top):l.bottom-i.bottom>2*(i.bottom-l.top)))return!1}}return!0})}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,a=o==r.parent.content.size,u=e.domSelection();return u?Pu.test(r.parent.textContent)&&u.modify?Iu(e,t,function(){var t=e.domSelectionRange(),o=t.focusNode,i=t.focusOffset,a=t.anchorNode,s=t.anchorOffset,l=u.caretBidiLevel;u.modify("move",n,"character");var c=r.depth?e.docView.domAfterPos(r.before()):e.dom,d=e.domSelectionRange(),f=d.focusNode,h=d.focusOffset,p=f&&!Qa(c,f)||o==f&&i==h;try{u.collapse(a,s),o&&(o!=a||i!=s)&&u.extend&&u.extend(o,i)}catch(e){}return null!=l&&(u.caretBidiLevel=l),p}):"left"==n||"backward"==n?i:a:r.pos==r.start()||r.pos==r.end()}(e,t,n))}var ju=function(){return x(function e(t,n,r,o){M(this,e),this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=0,r.pmViewDesc=this},[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(e){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var r=this.children[t];if(r==e)return n;n+=r.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&Qa(this.contentDOM,e)){if(n<0){var r,o;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,a;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(a=i.pmViewDesc)||a.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(a):this.posAtEnd}var u;if(e==this.dom&&this.contentDOM)u=t>$a(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))u=!!(4&e.compareDocumentPosition(this.contentDOM));else if(this.dom.firstChild){if(0==t)for(var s=e;;s=s.parentNode){if(s==this.dom){u=!1;break}if(s.previousSibling)break}if(null==u&&t==e.childNodes.length)for(var l=e;;l=l.parentNode){if(l==this.dom){u=!0;break}if(l.nextSibling)break}}return(null==u?n>0:u)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,r=e;r;r=r.parentNode){var o=this.getDesc(r),i=void 0;if(o&&(!t||o.node)){if(!n||!(i=o.nodeDOM)||(Ka(i)?Qa(i,e):i==e))return o;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(var i=0;i<r.children.length;i++){var a=r.children[i];if(a.size){r=a;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n=0,r=0,o=0;n<this.children.length;n++){var i=o+this.children[n].size;if(i>e){r=e-o;break}o=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){var a=this.children[n-1];if(a.size||!(a instanceof Ju||a instanceof Hu&&a.side>=0))break}if(t<=0){for(var u,s=!0;(u=n?this.children[n-1]:null)&&u.dom.parentNode!=this.contentDOM;n--,s=!1);return u&&t&&s&&!u.border&&!u.domAtom?u.domFromPos(u.size,t):{node:this.contentDOM,offset:u?$a(u.dom)+1:0}}for(var l,c=!0;(l=n<this.children.length?this.children[n]:null)&&l.dom.parentNode!=this.contentDOM;n++,c=!1);return l&&c&&!l.border&&!l.domAtom?l.domFromPos(0,t):{node:this.contentDOM,offset:l?$a(l.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,a=0;;a++){var u=this.children[a],s=i+u.size;if(-1==r&&e<=s){var l=i+u.border;if(e>=l&&t<=s-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,l);e=i;for(var c=a;c>0;c--){var d=this.children[c-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=$a(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(s>t||a==this.children.length-1)){t=s;for(var f=a+1;f<this.children.length;f++){var h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=$a(h.dom);break}t+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(!Ka(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}},{key:"setSelection",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=Math.min(e,t),i=Math.max(e,t),a=0,u=0;a<this.children.length;a++){var s=this.children[a],l=u+s.size;if(o>u&&i<l)return s.setSelection(e-u-s.border,t-u-s.border,n,r);u=l}var c=this.domFromPos(e,e?-1:1),d=t==e?c:this.domFromPos(t,t?-1:1),f=n.root.getSelection(),h=n.domSelectionRange(),p=!1;if((uu||du)&&e==t){var v=c,m=v.node,g=v.offset;if(Ja(m)){if((p=!(!g||"\n"!=m.nodeValue[g-1]))&&g==m.nodeValue.length)for(var D,y=m;y;y=y.parentNode){if(D=y.nextSibling){"BR"==D.nodeName&&(c=d={node:D.parentNode,offset:$a(D)+1});break}var k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{var E=m.childNodes[g-1];p=E&&("BR"==E.nodeName||"false"==E.contentEditable)}}if(uu&&h.focusNode&&h.focusNode!=d.node&&Ka(h.focusNode)){var F=h.focusNode.childNodes[h.focusOffset];F&&"false"==F.contentEditable&&(r=!0)}if(r||p&&du||!Va(c.node,c.offset,h.anchorNode,h.anchorOffset)||!Va(d.node,d.offset,h.focusNode,h.focusOffset)){var b=!1;if((f.extend||e==t)&&(!p||!uu)){f.collapse(c.node,c.offset);try{e!=t&&f.extend(d.node,d.offset),b=!0}catch(e){}}if(!b){if(e>t){var C=c;c=d,d=C}var w=document.createRange();w.setEnd(d.node,d.offset),w.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(w)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){var a=n+o.border,u=i-o.border;if(e>=a&&t<=u)return this.dirty=e==n||t==i?2:1,void(e!=a||t!=u||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-a,t-a):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}},{key:"ignoreForSelection",get:function(){return!1}},{key:"isText",value:function(e){return!1}}])}(),Hu=function(){function e(t,n,r,o){var i;M(this,e);var a,u=n.type.toDOM;if("function"==typeof u&&(u=u(r,function(){return a?a.parent?a.parent.posBeforeChild(a):void 0:o})),!n.type.spec.raw){var s=Ka(u)?u:document.createElement("span");s!=u&&s.appendChild(u),s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}return(i=N(this,e,[t,[],u,null])).widget=n,i.widget=n,a=i,i}return A(e,ju),x(e,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),H(e,"destroy",this,3)([])}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForSelection",get:function(){return!!this.widget.type.spec.relaxedSide}},{key:"side",get:function(){return this.widget.type.side}}])}(),Vu=function(){function e(t,n,r,o){var i;return M(this,e),(i=N(this,e,[t,[],n,null])).textDOM=r,i.text=o,i}return A(e,ju),x(e,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}])}(),Uu=function(){function e(t,n,r,o,i){var a;return M(this,e),(a=N(this,e,[t,[],r,o])).mark=n,a.spec=i,a}return A(e,ju),x(e,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(t,n){if(H(e,"markDirty",this,3)([t,n]),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,a=this.size;n<a&&(i=ss(i,n,a,r)),t>0&&(i=ss(i,0,t,r));for(var u=0;u<i.length;u++)i[u].parent=o;return o.children=i,o}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):H(e,"ignoreMutation",this,3)([t])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),H(e,"destroy",this,3)([])}}],[{key:"create",value:function(t,n,r,o){var i=o.nodeViews[n.type.name],a=i&&i(n,o,r);return a&&a.dom||(a=_o.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,a.dom,a.contentDOM||a.dom,a)}}])}(),Wu=function(){function e(t,n,r,o,i,a,u){var s;return M(this,e),(s=N(this,e,[t,[],i,a])).node=n,s.outerDeco=r,s.innerDeco=o,s.nodeDOM=u,s}return A(e,ju),x(e,[{key:"parseRule",value:function(e){var t=this;if(this.node.type.spec.reparseInView)return null;var n={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(n.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(var r=this.children.length-1;r>=0;r--){var o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){var i=e&&e.find(function(n){return Ka(n)&&e.indexOf(n.parentNode)<0&&t.dom.contains(n)});i?n.contentElement=i:n.getContent=function(){return Vr.empty}}}else n.contentElement=this.contentDOM;else n.getContent=function(){return t.node.content};return n}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&rs(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,u=i&&i.pos<0,s=new as(this,a&&a.node,e),l=this.node.inlineContent,c=l&&this.node.isBlock;!function(e,t,n,r){var o=t.locals(e),i=0;if(0==o.length){for(var a=0;a<e.childCount;a++){var u=e.child(a);r(u,o,t.forChild(i,u),a),i+=u.nodeSize}return}for(var s=0,l=[],c=null,d=0;;){for(var f=void 0,h=void 0;s<o.length&&o[s].to==i;){var p=o[s++];p.widget&&(f?(h||(h=[f])).push(p):f=p)}if(f)if(h){h.sort(us);for(var v=0;v<h.length;v++)n(h[v],d,!!c)}else n(f,d,!!c);var m=void 0,g=void 0;if(c)g=-1,m=c,c=null;else{if(!(d<e.childCount))break;g=d,m=e.child(d++)}for(var D=0;D<l.length;D++)l[D].to<=i&&l.splice(D--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);var y=i+m.nodeSize;if(m.isText){var k=y;s<o.length&&o[s].from<k&&(k=o[s].from);for(var E=0;E<l.length;E++)l[E].to<k&&(k=l[E].to);k<y&&(c=m.cut(k-i),m=m.cut(0,k-i),y=k,g=-1)}else for(;s<o.length&&o[s].to<y;)s++;r(m,m.isInline&&!m.isLeaf?l.filter(function(e){return!e.inline}):l.slice(),t.forChild(i,m),g),i=y}}(this.node,this.innerDeco,function(t,i,a){t.spec.marks?s.syncToMarks(t.spec.marks,r,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==n.node.childCount?Kr.none:n.node.child(i).marks,r,e,i),s.placeWidget(t,e,o)},function(t,n,a,d){var f;s.syncToMarks(t.marks,r,e,d),c&&t.isAtom&&!t.isText&&s.addHackNode("IMG",s.top),s.findNodeMatch(t,n,a,d)||u&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(f=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,n,a,f,e)||s.updateNextNode(t,n,a,e,d,o)||s.addNode(t,n,a,e,o),o+=t.nodeSize,l&&(c=t.isAtom&&!t.isText)}),s.syncToMarks([],r,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),Gu(this.contentDOM,this.children,e),fu&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,r=n.from,o=n.to;if(!(e.state.selection instanceof Ji)||r<t||o>t+this.node.content.size)return null;var i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){var a=i.nodeValue,u=function(e,t,n,r){for(var o=0,i=0;o<e.childCount&&i<=r;){var a=e.child(o++),u=i;if(i+=a.nodeSize,a.isText){for(var s=a.text;o<e.childCount;){var l=e.child(o++);if(i+=l.nodeSize,!l.isText)break;s+=l.text}if(i>=n){if(i>=r&&s.slice(r-t.length-u,r-u)==t)return r-t.length;var c=u<r?s.lastIndexOf(t,r-u-1):-1;if(c>=0&&c+t.length+u>=n)return u+c;if(n==r&&s.length>=r+t.length-u&&s.slice(r-u,r-u+t.length)==t)return r}}}return-1}(this.node.content,a,r-t,o-t);return u<0?null:{node:i,pos:u,text:a}}return{node:i,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,r=t.pos,o=t.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}var a=new Vu(this,i,n,o);e.input.compositionNodes.push(a),this.children=ss(this.children,r,r+o.length,e,a)}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}},{key:"updateInner",value:function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!rs(e,this.outerDeco)){var t=!Ka(this.nodeDOM),n=this.dom;this.dom=es(this.dom,this.nodeDOM,Yu(this.outerDeco,this.node,t),Yu(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){Ka(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}},{key:"deselectNode",value:function(){Ka(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(t,n,r,o,i,a){var u,s=i.nodeViews[n.type.name],l=s&&s(n,i,function(){return u?u.parent?u.parent.posBeforeChild(u):void 0:a},r,o),c=l&&l.dom,d=l&&l.contentDOM;if(n.isText)if(c){if(!Ja(c))throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(n.text);else if(!c){var f=_o.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);c=f.dom,d=f.contentDOM}d||n.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));var h=c;return c=ns(c,r,n),l?u=new Qu(t,n,r,o,c,d||null,h,l):n.isText?new Ku(t,n,r,o,c,h):new e(t,n,r,o,c,d||null,h)}}])}();function _u(e,t,n,r,o){ns(r,t,e);var i=new Wu(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Ku=function(){function e(t,n,r,o,i,a){return M(this,e),N(this,e,[t,n,r,o,i,null,a])}return A(e,Wu),x(e,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):H(e,"localPosFromDOM",this,3)([t,n,r])}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i)}},{key:"markDirty",value:function(t,n){H(e,"markDirty",this,3)([t,n]),this.dom==this.nodeDOM||0!=t&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(),Ju=function(){function e(){return M(this,e),N(this,e,arguments)}return A(e,ju),x(e,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}])}(),Qu=function(){function e(t,n,r,o,i,a,u,s){var l;return M(this,e),(l=N(this,e,[t,n,r,o,i,a,u])).spec=s,l}return A(e,Wu),x(e,[{key:"update",value:function(t,n,r,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){var i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}return!(!this.contentDOM&&!t.isLeaf)&&H(e,"update",this,3)([t,n,r,o])}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():H(e,"selectNode",this,3)([])}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():H(e,"deselectNode",this,3)([])}},{key:"setSelection",value:function(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r.root):H(e,"setSelection",this,3)([t,n,r,o])}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),H(e,"destroy",this,3)([])}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):H(e,"ignoreMutation",this,3)([t])}}])}();function Gu(e,t,n){for(var r=e.firstChild,o=!1,i=0;i<t.length;i++){var a=t[i],u=a.dom;if(u.parentNode==e){for(;u!=r;)r=is(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(u,r);if(a instanceof Uu){var s=r?r.previousSibling:e.lastChild;Gu(a.contentDOM,a.children,n),r=s?s.nextSibling:e.firstChild}}for(;r;)r=is(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var Xu=function(e){e&&(this.nodeName=e)};Xu.prototype=Object.create(null);var Zu=[new Xu];function Yu(e,t,n){if(0==e.length)return Zu;for(var r=n?Zu[0]:new Xu,o=[r],i=0;i<e.length;i++){var a=e[i].type.attrs;if(a)for(var u in a.nodeName&&o.push(r=new Xu(a.nodeName)),a){var s=a[u];null!=s&&(n&&1==o.length&&o.push(r=new Xu(t.isInline?"span":"div")),"class"==u?r.class=(r.class?r.class+" ":"")+s:"style"==u?r.style=(r.style?r.style+";":"")+s:"nodeName"!=u&&(r[u]=s))}}return o}function es(e,t,n,r){if(n==Zu&&r==Zu)return t;for(var o=t,i=0;i<r.length;i++){var a=r[i],u=n[i];if(i){var s=void 0;u&&u.nodeName==a.nodeName&&o!=e&&(s=o.parentNode)&&s.nodeName.toLowerCase()==a.nodeName||((s=document.createElement(a.nodeName)).pmIsDeco=!0,s.appendChild(o),u=Zu[0]),o=s}ts(o,u||Zu[0],a)}return o}function ts(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){for(var i=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[],u=0;u<i.length;u++)-1==a.indexOf(i[u])&&e.classList.remove(i[u]);for(var s=0;s<a.length;s++)-1==i.indexOf(a[s])&&e.classList.add(a[s]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var l,c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=c.exec(t.style);)e.style.removeProperty(l[1]);n.style&&(e.style.cssText+=n.style)}}function ns(e,t,n){return es(e,e,Zu,Yu(t,n,!Ka(e)))}function rs(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function is(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var as=function(){return x(function e(t,n,r){M(this,e),this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,r=n.children.length,o=e.childCount,i=new Map,a=[];e:for(;o>0;){for(var u=void 0;;)if(r){var s=n.children[r-1];if(!(s instanceof Uu)){u=s,r--;break}n=s,r=s.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var l=u.node;if(l){if(l!=e.child(o-1))break;--o,i.set(u,o),a.push(u)}}return{index:o,matched:i,matches:a.reverse()}}(t.node.content,t)},[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n,r){for(var o=0,i=this.stack.length>>1,a=Math.min(i,e.length);o<a&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);var u=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(var l=this.index;l<s;l++){var c=this.top.children[l];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){u=l;break}}if(u<0&&this.index<this.top.children.length){var d=this.top.children[this.index];d instanceof Uu&&3!=d.dirty&&d.mark.type==e[i].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[i])&&(d.mark=e[i],u=this.index,this.changed=!0)}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{var f=Uu.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,i++}}},{key:"findNodeMatch",value:function(e,t,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(var a=this.index,u=Math.min(this.top.children.length,a+5);a<u;a++){var s=this.top.children[a];if(s.matchesNode(e,t,n)&&!this.preMatch.matched.has(s)){i=a;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}},{key:"updateNodeAt",value:function(e,t,n,r,o){var i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,r,o,i){for(var a=this.index;a<this.top.children.length;a++){var u=this.top.children[a];if(u instanceof Wu){var s=this.preMatch.matched.get(u);if(null!=s&&s!=o)return!1;var l=u.dom,c=void 0,d=this.isLocked(l)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&3!=u.dirty&&rs(t,u.outerDeco));if(!d&&u.update(e,t,n,r))return this.destroyBetween(this.index,a),u.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(u,e,t,n,r,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!rs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;var a=Wu.create(this.top,t,n,r,o,i);if(a.contentDOM){a.children=e.children,e.children=[];var u,s=j(a.children);try{for(s.s();!(u=s.n()).done;){u.value.parent=a}}catch(e){s.e(e)}finally{s.f()}}return e.destroy(),a}},{key:"addNode",value:function(e,t,n,r,o){var i=Wu.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var o=new Hu(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Uu;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Ku)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((du||lu)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var r=new Ju(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||Ka(e)&&e.contains(this.lock.parentNode))}}])}();function us(e,t){return e.type.side-t.type.side}function ss(e,t,n,r,o){for(var i=[],a=0,u=0;a<e.length;a++){var s=e[a],l=u,c=u+=s.size;l>=n||c<=t?i.push(s):(l<t&&i.push(s.slice(0,t-l,r)),o&&(i.push(o),o=void 0),c>n&&i.push(s.slice(n-l,s.size,r)))}return i}function ls(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;var o=e.docView.nearestDesc(n.focusNode),a=o&&0==o.size,u=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(u<0)return null;var s,l,c=r.resolve(u);if(Xa(n)){for(s=u;o&&!o.node;)o=o.parent;if(!(o&&o.node.isAtom&&Gi.isSelectable(o.node)&&o.parent)||o.node.isInline&&function(e,t,n){for(var r=0==t,o=t==_a(e);r||o;){if(e==n)return!0;var i=$a(e);if(!(e=e.parentNode))return!1;r=r&&0==i,o=o&&i==_a(e)}}(n.focusNode,n.focusOffset,o.dom)){if(uu&&"key"==t&&u>e.state.selection.to&&Ka(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(var d=n.focusNode;;d=d.parentNode){if("visible"!=getComputedStyle(d).overflow){l=Ui.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!Ka(d.parentNode))break}}else{var f=o.posBefore;l=new Gi(u==f?c:r.resolve(f))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){for(var h=u,p=u,v=0;v<n.rangeCount;v++){var m=n.getRangeAt(v);h=Math.min(h,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;var g=p==e.state.selection.anchor?[p,h]:[h,p],D=i(g,2);s=D[0],u=D[1],c=r.resolve(u)}else s=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(s<0)return null}var y=r.resolve(s);l||(l=Ds(e,y,c,"pointer"==t||e.state.selection.head<c.pos&&!a?1:-1));return l}function cs(e){return e.editable?e.hasFocus():ks(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ds(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(ms(e,n),cs(e)){var r=e.input.mouseDown;if(!t&&lu&&r){var o=e.domSelectionRange(),i=e.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Va(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection();if(!t)return;var n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,$a(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&iu&&au<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var a,u,s=n.anchor,l=n.head;!fs||n instanceof Ji||(n.$from.parent.inlineContent||(a=hs(e,n.from)),n.empty||n.$from.parent.inlineContent||(u=hs(e,n.to))),e.docView.setSelection(s,l,e,t),fs&&(a&&vs(a),u&&vs(u)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(function(){cs(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var fs=du||lu&&cu<63;function hs(e,t){var n=e.docView.domFromPos(t,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,a=o?r.childNodes[o-1]:null;if(du&&i&&"false"==i.contentEditable)return ps(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return ps(i);if(a)return ps(a)}}function ps(e){return e.contentEditable="true",du&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function vs(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ms(e,t){if(t instanceof Gi){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(gs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else gs(e)}function gs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ds(e,t,n,r){return e.someProp("createSelectionBetween",function(r){return r(e,t,n)})||Ji.between(t,n,r)}function ys(e){return!(e.editable&&!e.hasFocus())&&ks(e)}function ks(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Qa(e.dom,t.anchorNode)&&(e.editable||Qa(e.dom,t.focusNode))}catch(e){return!1}}function Es(e,t){var n=e.selection,r=n.$anchor,o=n.$head,i=t>0?r.max(o):r.min(o),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&Ui.findFrom(a,t)}function Fs(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function bs(e,t,n){var r=e.state.selection;if(!(r instanceof Ji)){if(r instanceof Gi&&r.node.isInline)return Fs(e,new Ji(t>0?r.$to:r.$from));var o=Es(e.state,t);return!!o&&Fs(e,o)}if(n.indexOf("s")>-1){var i=r.$head,a=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;var u=e.state.doc.resolve(i.pos+a.nodeSize*(t<0?-1:1));return Fs(e,new Ji(r.$anchor,u))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var s=Es(e.state,t);return!!(s&&s instanceof Gi)&&Fs(e,s)}if(!(hu&&n.indexOf("m")>-1)){var l,c=r.$head,d=c.textOffset?null:t<0?c.nodeBefore:c.nodeAfter;if(!d||d.isText)return!1;var f=t<0?c.pos-d.nodeSize:c.pos;return!!(d.isAtom||(l=e.docView.descAt(f))&&!l.contentDOM)&&(Gi.isSelectable(d)?Fs(e,new Gi(t<0?e.state.doc.resolve(c.pos-d.nodeSize):c)):Fs(e,new Ji(e.state.doc.resolve(t<0?f:f+d.nodeSize))))}}function Cs(e,t){var n=e.pmViewDesc;return n?0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName):Ka(e)&&"false"==e.contentEditable}function ws(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;var o,i,a=!1;uu&&Ka(n)&&r<_a(n)&&Cs(n.childNodes[r],-1)&&(a=!0);for(;;)if(r>0){if(!Ka(n))break;var u=n.childNodes[r-1];if(Cs(u,-1))o=n,i=--r;else{if(!Ja(u))break;r=(n=u).nodeValue.length}}else{if(As(n))break;for(var s=n.previousSibling;s&&Cs(s,-1);)o=n.parentNode,i=$a(s),s=s.previousSibling;if(s)r=_a(n=s);else{if((n=n.parentNode)==e.dom)break;r=0}}a?xs(e,n,r):o&&xs(e,o,i)}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;for(var o,i,a=_a(n);;)if(r<a){if(!Ka(n))break;if(!Cs(n.childNodes[r],1))break;o=n,i=++r}else{if(As(n))break;for(var u=n.nextSibling;u&&Cs(u,1);)o=u.parentNode,i=$a(u)+1,u=u.nextSibling;if(u)r=0,a=_a(n=u);else{if((n=n.parentNode)==e.dom)break;r=a=0}}o&&xs(e,o,i)}(e)}function As(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function xs(e,t,n){var r,o;Ja(t)||((o=function(e,t){for(;e&&t==e.childNodes.length&&!Ga(e);)t=$a(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(Ja(n))return n;if(Ka(n)&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(r=function(e,t){for(;e&&!t&&!Ga(e);)t=$a(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(Ja(n))return n;if(Ka(n)&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=r,n=r.nodeValue.length));var i=e.domSelection();if(i){if(Xa(i)){var a=document.createRange();a.setEnd(t,n),a.setStart(t,n),i.removeAllRanges(),i.addRange(a)}else i.extend&&i.extend(t,n);e.domObserver.setCurSelection();var u=e.state;setTimeout(function(){e.state==u&&ds(e)},50)}}function Ss(e,t){var n=e.state.doc.resolve(t);if(!lu&&!pu&&n.parent.inlineContent){var r=e.coordsAtPos(t);if(t>n.start()){var o=e.coordsAtPos(t-1),i=(o.top+o.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(o.left-r.left)>1)return o.left<r.left?"ltr":"rtl"}if(t<n.end()){var a=e.coordsAtPos(t+1),u=(a.top+a.bottom)/2;if(u>r.top&&u<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Bs(e,t,n){var r=e.state.selection;if(r instanceof Ji&&!r.empty||n.indexOf("s")>-1)return!1;if(hu&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var a=Es(e.state,t);if(a&&a instanceof Gi)return Fs(e,a)}if(!o.parent.inlineContent){var u=t<0?o:i,s=r instanceof Zi?Ui.near(u,t):Ui.findFrom(u,t);return!!s&&Fs(e,s)}return!1}function Ts(e,t){if(!(e.state.selection instanceof Ji))return!0;var n=e.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(a&&!a.isText){var u=e.state.tr;return t<0?u.delete(r.pos-a.nodeSize,r.pos):u.delete(r.pos,r.pos+a.nodeSize),e.dispatch(u),!0}return!1}function Ms(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ns(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||hu&&72==n&&"c"==r)return Ts(e,-1)||ws(e,-1);if(46==n&&!t.shiftKey||hu&&68==n&&"c"==r)return Ts(e,1)||ws(e,1);if(13==n||27==n)return!0;if(37==n||hu&&66==n&&"c"==r){var o=37==n?"ltr"==Ss(e,e.state.selection.from)?-1:1:-1;return bs(e,o,r)||ws(e,o)}if(39==n||hu&&70==n&&"c"==r){var i=39==n?"ltr"==Ss(e,e.state.selection.from)?1:-1:1;return bs(e,i,r)||ws(e,i)}return 38==n||hu&&80==n&&"c"==r?Bs(e,-1,r)||ws(e,-1):40==n||hu&&78==n&&"c"==r?function(e){if(!du||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n&&Ka(n)&&0==r&&n.firstChild&&Ka(n.firstChild)&&"false"==n.firstChild.contentEditable){var o=n.firstChild;Ms(e,o,"true"),setTimeout(function(){return Ms(e,o,"false")},20)}return!1}(e)||Bs(e,1,r)||ws(e,1):r==(hu?"m":"c")&&(66==n||73==n||89==n||90==n)}function Rs(e,t){e.someProp("transformCopied",function(n){t=n(t,e)});for(var n=[],r=t,o=r.content,i=r.openStart,a=r.openEnd;i>1&&a>1&&1==o.childCount&&1==o.firstChild.childCount;){i--,a--;var u=o.firstChild;n.push(u.type.name,u.attrs!=u.type.defaultAttrs?u.attrs:null),o=u.content}var s=e.someProp("clipboardSerializer")||_o.fromSchema(e.state.schema),l=Hs(),c=l.createElement("div");c.appendChild(s.serializeFragment(o,{document:l}));for(var d,f=c.firstChild,h=0;f&&Ka(f)&&(d=js[f.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=l.createElement(d[p]);c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),h++}f=c.firstChild}return f&&Ka(f)&&f.setAttribute("data-pm-slice","".concat(i," ").concat(a).concat(h?" -".concat(h):""," ").concat(JSON.stringify(n))),{dom:c,text:e.someProp("clipboardTextSerializer",function(n){return n(t,e)})||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Os(e,t,n,r,o){var i,a,u=o.parent.type.spec.code;if(!n&&!t)return null;var s=!!t&&(r||u||!n);if(s){if(e.someProp("transformPastedText",function(n){t=n(t,u||r,e)}),u)return a=new Qr(Vr.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",function(t){a=t(a,e,!0)}),a;var l=e.someProp("clipboardTextParser",function(n){return n(t,o,r,e)});if(l)a=l;else{var c=o.marks(),d=e.state.schema,f=_o.fromSchema(d);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(function(e){var t=i.appendChild(document.createElement("p"));e&&t.appendChild(f.serializeNode(d.text(e,c)))})}}else e.someProp("transformPastedHTML",function(t){n=t(n,e)}),i=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=Hs(),o=r.body,i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&js[i[1].toLowerCase()])&&(e=n.map(function(e){return"<"+e+">"}).join("")+e+n.map(function(e){return"</"+e+">"}).reverse().join(""));if(o.innerHTML=function(e){var t=window.trustedTypes;if(!t)return e;if(!Vs){if(Vs=t.defaultPolicy)try{return Vs.createHTML(e)}catch(e){}Vs=t.createPolicy("ProseMirrorClipboard",{createHTML:function(e){return e}})}return Vs.createHTML(e)}(e),n)for(var a=0;a<n.length;a++)o=o.querySelector(n[a])||o;for(var u=0;u<r.styleSheets.length;u++)for(var s=r.styleSheets[u],l=0;l<s.rules.length;l++){var c=s.rules[l];if(c instanceof CSSStyleRule)for(var d=o.querySelectorAll(c.selectorText),f=0;f<d.length;f++)d[f].style.cssText+=c.style.cssText}return o}(n),mu&&function(e){for(var t=e.querySelectorAll(lu?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);var h=i&&i.querySelector("[data-pm-slice]"),p=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=i.firstChild;m&&!Ka(m);)m=m.nextSibling;if(!m)break;i=m}if(!a){var g=e.someProp("clipboardParser")||e.someProp("domParser")||Po.fromSchema(e.state.schema);a=g.parseSlice(i,{preserveWhitespace:!(!s&&!p),context:o,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Is.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)a=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var o=e.content,i=e.openStart,a=e.openEnd,u=n.length-2;u>=0;u-=2){var s=r.nodes[n[u]];if(!s||s.hasRequiredAttrs())break;try{o=Vr.from(s.create(n[u+1],o))}catch(e){break}i++,a++}return new Qr(o,i,a)}(qs(a,+p[1],+p[2]),p[4]);else if(a=Qr.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,r=function(){var n,r=t.node(o).contentMatchAt(t.index(o)),i=[];if(e.forEach(function(e){if(i){var t,o=r.findWrapping(e.type);if(!o)return i=null;if(t=i.length&&n.length&&Ls(o,n,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=zs(i[i.length-1],n.length));var a=Ps(e,o);i.push(a),r=r.matchType(a.type),n=o}}}),i)return{v:Vr.from(i)}},o=t.depth;o>=0;o--)if(n=r())return n.v;return e}(a.content,o),!0),a.openStart||a.openEnd){for(var D=0,y=0,k=a.content.firstChild;D<a.openStart&&!k.type.spec.isolating;D++,k=k.firstChild);for(var E=a.content.lastChild;y<a.openEnd&&!E.type.spec.isolating;y++,E=E.lastChild);a=qs(a,D,y)}return e.someProp("transformPasted",function(t){a=t(a,e,s)}),a}var Is=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ps(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length-1;r>=n;r--)e=t[r].create(null,Vr.from(e));return e}function Ls(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){var i=Ls(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(Vr.from(Ps(n,e,o+1))))}}function zs(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,zs(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Vr.empty,!0);return e.copy(n.append(r))}function $s(e,t,n,r,o,i){var a=t<0?e.firstChild:e.lastChild,u=a.content;return e.childCount>1&&(i=0),o<r-1&&(u=$s(u,t,n,r,o+1,i)),o>=n&&(u=t<0?a.contentMatchAt(0).fillBefore(u,i<=o).append(u):u.append(a.contentMatchAt(a.childCount).fillBefore(Vr.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(u))}function qs(e,t,n){return t<e.openStart&&(e=new Qr($s(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Qr($s(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var js={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Hs(){return document.implementation.createHTMLDocument("title")}var Vs=null;var Us={},Ws={},_s={touchstart:!0,touchmove:!0},Ks=x(function e(){M(this,e),this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null});function Js(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Qs(e){e.someProp("handleDOMEvents",function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return Gs(e,t)})})}function Gs(e,t){return e.someProp("handleDOMEvents",function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Xs(e){return{left:e.clientX,top:e.clientY}}function Zs(e,t,n,r,o){if(-1==r)return!1;for(var i,a=e.state.doc.resolve(r),u=function(r){if(e.someProp(t,function(t){return r>a.depth?t(e,n,a.nodeAfter,a.before(r),o,!0):t(e,n,a.node(r),a.before(r),o,!1)}))return{v:!0}},s=a.depth+1;s>0;s--)if(i=u(s))return i.v;return!1}function Ys(e,t,n){if(e.focused||e.focus(),!e.state.selection.eq(t)){var r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}}function el(e,t,n,r,o){return Zs(e,"handleClickOn",t,n,r)||e.someProp("handleClick",function(n){return n(e,t,r)})||(o?function(e,t){if(-1==t)return!1;var n,r,o=e.state.selection;o instanceof Gi&&(n=o.node);for(var i=e.state.doc.resolve(t),a=i.depth+1;a>0;a--){var u=a>i.depth?i.nodeAfter:i.node(a);if(Gi.isSelectable(u)){r=n&&o.$from.depth>0&&a>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(a);break}}return null!=r&&(Ys(e,Gi.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Gi.isSelectable(r))&&(Ys(e,new Gi(n)),!0)}(e,n))}function tl(e,t,n,r){return Zs(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",function(n){return n(e,t,r)})}function nl(e,t,n,r){return Zs(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",function(n){return n(e,t,r)})||function(e,t,n){if(0!=n.button)return!1;var r=rl(e,t,!0),o=e.state.doc;if(!r)return!1;Ys(e,r),r instanceof Ji&&o.eq(e.state.doc)&&(e.input.mouseDown=new sl(e,r));return!0}(e,n,r)}function rl(e,t,n){var r=e.state.doc;if(-1==t)return r.inlineContent?Ji.create(r,0,r.content.size):null;for(var o=r.resolve(t),i=o.depth+1;i>0;i--){var a=i>o.depth?o.nodeAfter:o.node(i),u=o.before(i);if(a.inlineContent)return Ji.create(r,u+1,u+1+a.content.size);if(n&&Gi.isSelectable(a))return Gi.create(r,u)}return null}function ol(e){return pl(e)}Ws.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!ll(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!vu||!lu||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!fu||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",function(t){return t(e,n)})||Ns(e,n)?n.preventDefault():Js(e,"key");else{var r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(function(){e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",function(t){return t(e,Za(13,"Enter"))}),e.input.lastIOSEnter=0)},200)}},Ws.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},Ws.keypress=function(e,t){var n=t;if(!(ll(e)||!n.charCode||n.ctrlKey&&!n.altKey||hu&&n.metaKey))if(e.someProp("handleKeyPress",function(t){return t(e,n)}))n.preventDefault();else{var r=e.state.selection;if(!(r instanceof Ji&&r.$from.sameParent(r.$to))){var o=String.fromCharCode(n.charCode),i=function(){return e.state.tr.insertText(o).scrollIntoView()};/[\r\n]/.test(o)||e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,o,i)})||e.dispatch(i()),n.preventDefault()}}};var il=hu?"metaKey":"ctrlKey";Us.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var r=ol(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[il]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();var a=e.posAtCoords(Xs(n));a&&("singleClick"==i?e.input.mouseDown=new ul(e,a,n,!!r):("doubleClick"==i?tl:nl)(e,a.pos,a.inside,n)?n.preventDefault():Js(e,"pointer"))};var al=function(){return x(function e(t){M(this,e),this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))},[{key:"up",value:function(e){this.done()}},{key:"move",value:function(e){0==e.buttons&&this.done()}},{key:"done",value:function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}},{key:"delaySelUpdate",value:function(){return!1}}])}(),ul=function(){function e(t,n,r,o){var i,a,u;if(M(this,e),(i=N(this,e,[t])).pos=n,i.event=r,i.flushed=o,i.delayedSelectionSync=!1,i.startDoc=t.state.doc,i.selectNode=!!r[il],i.allowDefault=r.shiftKey,n.inside>-1)a=t.state.doc.nodeAt(n.inside),u=n.inside;else{var s=t.state.doc.resolve(n.pos);a=s.parent,u=s.depth?s.before():0}var l=o?null:r.target,c=l?t.docView.nearestDesc(l,!0):null;i.target=c&&Ka(c.nodeDOM)?c.nodeDOM:null;var d=t.state.selection;return 0==r.button&&(a.type.spec.draggable&&!1!==a.type.spec.selectable||d instanceof Gi&&d.from<=u&&d.to>u)&&(i.mightDrag={node:a,pos:u,addAttr:!(!i.target||i.target.draggable),setUneditable:!(!i.target||!uu||i.target.hasAttribute("contentEditable"))}),i.target&&i.mightDrag&&(i.mightDrag.addAttr||i.mightDrag.setUneditable)&&(i.view.domObserver.stop(),i.mightDrag.addAttr&&(i.target.draggable=!0),i.mightDrag.setUneditable&&setTimeout(function(){i.view.input.mouseDown==i&&i.target.setAttribute("contentEditable","false")},20),i.view.domObserver.start()),Js(t,"pointer"),i}return A(e,al),x(e,[{key:"done",value:function(){var t=this;H(e,"done",this,3)([]),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(function(){t.view.isDestroyed||ds(t.view)})}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Xs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Js(this.view,"pointer"):el(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||du&&this.mightDrag&&!this.mightDrag.node.isAtom||lu&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ys(this.view,Ui.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Js(this.view,"pointer")}}},{key:"move",value:function(t){this.updateAllowDefault(t),Js(this.view,"pointer"),H(e,"move",this,3)([t])}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}},{key:"delaySelUpdate",value:function(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}])}(),sl=function(){function e(t,n){var r;return M(this,e),(r=N(this,e,[t])).startSelection=n,r.startDoc=t.state.doc,r}return A(e,al),x(e,[{key:"move",value:function(e){if(0!=e.buttons&&!this.view.isDestroyed&&this.view.state.doc.eq(this.startDoc)){e.preventDefault(),Js(this.view,"pointer");var t=this.view.posAtCoords(Xs(e)),n=t&&rl(this.view,t.inside,!1);if(n){var r=this.view.state.doc,o=this.startSelection,a=n.from<o.from?[o.to,n.from]:[o.from,n.to],u=i(a,2),s=u[0],l=u[1];Ys(this.view,Ji.create(r,s,l))}}else this.done()}}])}();function ll(e,t){return!!e.composing||!!(du&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Us.touchstart=function(e){e.input.lastTouch=Date.now(),ol(e),Js(e,"pointer")},Us.touchmove=function(e){e.input.lastTouch=Date.now(),Js(e,"pointer")},Us.contextmenu=function(e){return ol(e)};var cl=vu?5e3:-1;function dl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(function(){return pl(e)},t))}function fl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function hl(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(Ja(e)&&t)return e;if(Ka(e)&&t>0){if("false"==e.contentEditable)return null;t=_a(e=e.childNodes[t-1])}else{if(!e.parentNode||Ga(e))return null;t=$a(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(Ja(e)&&t<e.nodeValue.length)return e;if(Ka(e)&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ga(e))return null;t=$a(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){var o=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(e.input.compositionNode==r){var a=n.pmViewDesc;if(a&&a.isText(n.nodeValue))return r}}return n||r}function pl(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(vu&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),fl(e),t||e.docView&&e.docView.dirty){var n=ls(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Ws.compositionstart=Ws.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$to;if(t.selection instanceof Ji&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})||lu&&pu&&function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n||!Ka(n)||r>=n.childNodes.length)return!1;var o=n.childNodes[r];return Ka(o)&&"false"==o.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),pl(e,!0),e.markCursor=null;else if(pl(e,!t.selection.empty),uu&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.domSelectionRange(),o=r.focusNode,i=r.focusOffset;o&&Ka(o)&&0!=i;){var a=i<0?o.lastChild:o.childNodes[i-1];if(!a)break;if(Ja(a)){var u=e.domSelection();u&&u.collapse(a,a.nodeValue.length);break}o=a,i=-1}e.input.composing=!0}dl(e,cl)},Ws.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(function(){return e.domObserver.flush()}),e.input.compositionID++,dl(e,20))};var vl=iu&&au<15||fu&&gu<604;function ml(e,t,n,r,o){var i=Os(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,o,i||Qr.empty)}))return!0;if(!i)return!1;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),u=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(u.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gl(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Us.copy=Ws.cut=function(e,t){var n=t,r=e.state.selection,o="cut"==n.type;if(!r.empty){var i=vl?null:n.clipboardData,a=Rs(e,r.content()),u=a.dom,s=a.text;i?(n.preventDefault(),i.clearData(),i.setData("text/html",u.innerHTML),i.setData("text/plain",s)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}}(e,u),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Ws.paste=function(e,t){var n=t;if(!e.composing||vu){var r=vl?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ml(e,gl(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();var o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ml(e,r.value,null,o,t):ml(e,r.textContent,r.innerHTML,o,t)},50)}}(e,n)}};var Dl=x(function e(t,n,r){M(this,e),this.slice=t,this.move=n,this.node=r}),yl=hu?"altKey":"ctrlKey";function kl(e,t){var n;return e.someProp("dragCopies",function(e){n=n||e(t)}),null!=n?!n:!t[yl]}for(var El in Us.dragstart=function(e,t){var n=t,r=e.input.mouseDown;if(r&&r.done(),n.dataTransfer){var o,i=e.state.selection,a=i.empty?null:e.posAtCoords(Xs(n));if(a&&a.pos>=i.from&&a.pos<=(i instanceof Gi?i.to-1:i.to));else if(r&&r.mightDrag)o=Gi.create(e.state.doc,r.mightDrag.pos);else if(n.target&&Ka(n.target)){var u=e.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=e.docView&&(o=Gi.create(e.state.doc,u.posBefore))}var s=Rs(e,(o||e.state.selection).content()),l=s.dom,c=s.text,d=s.slice;(!n.dataTransfer.files.length||!lu||cu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(vl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",vl||n.dataTransfer.setData("text/plain",c),e.dragging=new Dl(d,kl(e,n),o)}},Us.dragend=function(e){var t=e.dragging;window.setTimeout(function(){e.dragging==t&&(e.dragging=null)},50)},Ws.dragover=Ws.dragenter=function(e,t){return t.preventDefault()},Ws.drop=function(e,t){try{!function(e,t,n){if(!t.dataTransfer)return;var r=e.posAtCoords(Xs(t));if(!r)return;var o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",function(t){i=t(i,e,!1)}):i=Os(e,gl(t.dataTransfer),vl?null:t.dataTransfer.getData("text/html"),!1,o);var a=!(!n||!kl(e,t));if(e.someProp("handleDrop",function(n){return n(e,t,i||Qr.empty,a)}))return void t.preventDefault();if(!i)return;t.preventDefault();var u=i?Ai(e.state.doc,o.pos,i):o.pos;null==u&&(u=o.pos);var s=e.state.tr;if(a){var l=n.node;l?l.replace(s):s.deleteSelection()}var c=s.mapping.map(u),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,f=s.doc;d?s.replaceRangeWith(c,c,i.content.firstChild):s.replaceRange(c,c,i);if(s.doc.eq(f))return;var h=s.doc.resolve(c);if(d&&Gi.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))s.setSelection(new Gi(h));else{var p=s.mapping.map(u);s.mapping.maps[s.mapping.maps.length-1].forEach(function(e,t,n,r){return p=r}),s.setSelection(Ds(e,h,s.doc.resolve(p)))}e.focus(),e.dispatch(s.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Us.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ds(e)},20))},Us.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Us.beforeinput=function(e,t){if(vu&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout(function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,Za(8,"Backspace"))}))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}},50)}},Ws)Us[El]=Ws[El];function Fl(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var bl=function(){function e(t,n){M(this,e),this.toDOM=t,this.spec=n||Sl,this.side=this.spec.side||0}return x(e,[{key:"map",value:function(e,t,n,r){var o=e.mapResult(t.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Al(i-n,i-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Fl(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),Cl=function(){function e(t,n){M(this,e),this.attrs=t,this.spec=n||Sl}return x(e,[{key:"map",value:function(e,t,n,r){var o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Al(o,i,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&Fl(this.attrs,t.attrs)&&Fl(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),wl=function(){function e(t,n){M(this,e),this.attrs=t,this.spec=n||Sl}return x(e,[{key:"map",value:function(e,t,n,r){var o=e.mapResult(t.from+r,1);if(o.deleted)return null;var i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Al(o.pos-n,i.pos-n,this)}},{key:"valid",value:function(e,t){var n,r=e.content.findIndex(t.from),o=r.index,i=r.offset;return i==t.from&&!(n=e.child(o)).isText&&i+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&Fl(this.attrs,t.attrs)&&Fl(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),Al=function(){function e(t,n,r){M(this,e),this.from=t,this.to=n,this.type=r}return x(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof Cl}},{key:"widget",get:function(){return this.type instanceof bl}}],[{key:"widget",value:function(t,n,r){return new e(t,t,new bl(n,r))}},{key:"inline",value:function(t,n,r,o){return new e(t,n,new Cl(r,o))}},{key:"node",value:function(t,n,r,o){return new e(t,n,new wl(r,o))}}])}(),xl=[],Sl={},Bl=function(){function e(t,n){M(this,e),this.local=t.length?t:xl,this.children=n.length?n:xl}return x(e,[{key:"find",value:function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}},{key:"findInner",value:function(e,t,n,r,o){for(var i=0;i<this.local.length;i++){var a=this.local[i];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&n.push(a.copy(a.from+r,a.to+r))}for(var u=0;u<this.children.length;u+=3)if(this.children[u]<t&&this.children[u+1]>e){var s=this.children[u]+1;this.children[u+2].findInner(e-s,t-s,n,r+s,o)}}},{key:"map",value:function(e,t,n){return this==Tl||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Sl)}},{key:"mapInner",value:function(t,n,r,o,i){for(var a,u=0;u<this.local.length;u++){var s=this.local[u].map(t,r,o);s&&s.type.valid(n,s)?(a||(a=[])).push(s):i.onRemove&&i.onRemove(this.local[u].spec)}return this.children.length?Nl(this.children,a||[],t,n,r,o,i):a?new e(a.sort(Ll),xl):Tl}},{key:"add",value:function(t,n){return n.length?this==Tl?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,r){var o,i=this,a=0;t.forEach(function(e,t){var u,s=t+r;if(u=Ol(n,e,s)){for(o||(o=i.children.slice());a<o.length&&o[a]<t;)a+=3;o[a]==t?o[a+2]=o[a+2].addInner(e,u,s+1):o.splice(a,0,t,t+e.nodeSize,Pl(u,e,s+1,Sl)),a+=3}});for(var u=Rl(a?Il(n):n,-r),s=0;s<u.length;s++)u[s].type.valid(t,u[s])||u.splice(s--,1);return new e(u.length?this.local.concat(u).sort(Ll):this.local,o||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==Tl?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var r=this.children,o=this.local,i=0;i<r.length;i+=3){for(var a,u=void 0,s=r[i]+n,l=r[i+1]+n,c=0;c<t.length;c++)(a=t[c])&&a.from>s&&a.to<l&&(t[c]=null,(u||(u=[])).push(a));if(u){r==this.children&&(r=this.children.slice());var d=r[i+2].removeInner(u,s+1);d!=Tl?r[i+2]=d:(r.splice(i,3),i-=3)}}if(o.length)for(var f,h=0;h<t.length;h++)if(f=t[h])for(var p=0;p<o.length;p++)o[p].eq(f,n)&&(o==this.local&&(o=this.local.slice()),o.splice(p--,1));return r==this.children&&o==this.local?this:o.length||r.length?new e(o,r):Tl}},{key:"forChild",value:function(t,n){if(this==Tl)return this;if(n.isLeaf)return e.empty;for(var r,o,i=0;i<this.children.length;i+=3)if(this.children[i]>=t){this.children[i]==t&&(r=this.children[i+2]);break}for(var a=t+1,u=a+n.content.size,s=0;s<this.local.length;s++){var l=this.local[s];if(l.from<u&&l.to>a&&l.type instanceof Cl){var c=Math.max(a,l.from)-a,d=Math.min(u,l.to)-a;c<d&&(o||(o=[])).push(l.copy(c,d))}}if(o){var f=new e(o.sort(Ll),xl);return r?new Ml([f,r]):f}return r||Tl}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var r=0;r<this.children.length;r+=3)if(this.children[r]!=t.children[r]||this.children[r+1]!=t.children[r+1]||!this.children[r+2].eq(t.children[r+2]))return!1;return!0}},{key:"locals",value:function(e){return zl(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==Tl)return xl;if(e.inlineContent||!this.local.some(Cl.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Cl||t.push(this.local[n]);return t}},{key:"forEachSet",value:function(e){e(this)}}],[{key:"create",value:function(e,t){return t.length?Pl(t,e,0,Sl):Tl}}])}();Bl.empty=new Bl([],[]),Bl.removeOverlap=zl;var Tl=Bl.empty,Ml=function(){function e(t){M(this,e),this.members=t}return x(e,[{key:"map",value:function(t,n){var r=this.members.map(function(e){return e.map(t,n,Sl)});return e.from(r)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return Bl.empty;for(var r=[],o=0;o<this.members.length;o++){var i=this.members[o].forChild(t,n);i!=Tl&&(i instanceof e?r=r.concat(i.members):r.push(i))}return e.from(r)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(var i=0;i<o.length;i++)t.push(o[i])}else t=o}return t?zl(n?t:t.sort(Ll)):xl}},{key:"forEachSet",value:function(e){for(var t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}],[{key:"from",value:function(t){switch(t.length){case 0:return Tl;case 1:return t[0];default:return new e(t.every(function(e){return e instanceof Bl})?t:t.reduce(function(e,t){return e.concat(t instanceof Bl?t:t.members)},[]))}}}])}();function Nl(e,t,n,r,o,i,a){for(var u=e.slice(),s=function(e){var t=0;n.maps[l].forEach(function(n,r,o,i){for(var a=i-o-(r-n),s=0;s<u.length;s+=3){var l=u[s+1];if(!(l<0||n>l+e-t)){var c=u[s]+e-t;r>=c?u[s+1]=n<=c?-2:-1:n>=e&&a&&(u[s]+=a,u[s+1]+=a)}}t+=a}),e=n.maps[l].map(e,-1),c=e},l=0,c=i;l<n.maps.length;l++)s(c);for(var d=!1,f=0;f<u.length;f+=3)if(u[f+1]<0){if(-2==u[f+1]){d=!0,u[f+1]=-1;continue}var h=n.map(e[f]+i),p=h-o;if(p<0||p>=r.content.size){d=!0;continue}var v=n.map(e[f+1]+i,-1)-o,m=r.content.findIndex(p),g=m.index,D=m.offset,y=r.maybeChild(g);if(y&&D==p&&D+y.nodeSize==v){var k=u[f+2].mapInner(n,y,h+1,e[f]+i+1,a);k!=Tl?(u[f]=p,u[f+1]=v,u[f+2]=k):(u[f+1]=-2,d=!0)}else d=!0}if(d){var E=function(e,t,n,r,o,i,a){function u(e,t){for(var i=0;i<e.local.length;i++){var s=e.local[i].map(r,o,t);s?n.push(s):a.onRemove&&a.onRemove(e.local[i].spec)}for(var l=0;l<e.children.length;l+=3)u(e.children[l+2],e.children[l]+t+1)}for(var s=0;s<e.length;s+=3)-1==e[s+1]&&u(e[s+2],t[s]+i+1);return n}(u,e,t,n,o,i,a),F=Pl(E,r,0,a);t=F.local;for(var b=0;b<u.length;b+=3)u[b+1]<0&&(u.splice(b,3),b-=3);for(var C=0,w=0;C<F.children.length;C+=3){for(var A=F.children[C];w<u.length&&u[w]<A;)w+=3;u.splice(w,0,F.children[C],F.children[C+1],F.children[C+2])}}return new Bl(t.sort(Ll),u)}function Rl(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var o=e[r];n.push(new Al(o.from+t,o.to+t,o.type))}return n}function Ol(e,t,n){if(t.isLeaf)return null;for(var r,o=n+t.nodeSize,i=null,a=0;a<e.length;a++)(r=e[a])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),e[a]=null);return i}function Il(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Pl(e,t,n,r){var o=[],i=!1;t.forEach(function(t,a){var u=Ol(e,t,a+n);if(u){i=!0;var s=Pl(u,t,n+a+1,r);s!=Tl&&o.push(a,a+t.nodeSize,s)}});for(var a=Rl(i?Il(e):e,-n).sort(Ll),u=0;u<a.length;u++)a[u].type.valid(t,a[u])||(r.onRemove&&r.onRemove(a[u].spec),a.splice(u--,1));return a.length||o.length?new Bl(a,o):Tl}function Ll(e,t){return e.from-t.from||e.to-t.to}function zl(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var o=n+1;o<t.length;o++){var i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),$l(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),$l(t,o+1,i.copy(r.to,i.to)))}}return t}function $l(e,t,n){for(;t<e.length&&Ll(n,e[t])>0;)t++;e.splice(t,0,n)}function ql(e){var t=[];return e.someProp("decorations",function(n){var r=n(e.state);r&&r!=Tl&&t.push(r)}),e.cursorWrapper&&t.push(Bl.create(e.state.doc,[e.cursorWrapper.deco])),Ml.from(t)}var jl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Hl=iu&&au<=11,Vl=function(){return x(function e(){M(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0},[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}])}(),Ul=function(){return x(function e(t,n){var r=this;M(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Vl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){for(var n=0;n<e.length;n++)r.queue.push(e[n]);iu&&au<=11&&e.some(function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length})?r.flushSoon():du&&t.composing&&e.some(function(e){return"childList"==e.type&&"TR"==e.target.nodeName})?(t.input.badSafariComposition=!0,r.flushSoon()):r.flush()}),Hl&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)},[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){e.flushingSoon=-1,e.flush()},20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,jl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(function(){return e.flush()},20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)}},{key:"onSelectionChange",value:function(){if(ys(this.view)){if(this.suppressingSelectionUpdates)return ds(this.view);if(iu&&au<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Va(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,r=e.focusNode;r;r=qa(r))n.add(r);for(var o=e.anchorNode;o;o=qa(o))if(n.has(o)){t=o;break}var i=t&&this.view.docView.nearestDesc(t);return i&&i.ignoreMutation({type:"selection",target:Ja(t)?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=j(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(e){t.e(e)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ys(e)&&!this.ignoreSelectionChange(n),o=-1,a=-1,u=!1,s=[];if(e.editable)for(var l=0;l<t.length;l++){var c=this.registerMutation(t[l],s);c&&(o=o<0?c.from:Math.min(c.from,o),a=a<0?c.to:Math.max(c.to,a),c.typeOver&&(u=!0))}if(s.some(function(e){return"BR"==e.nodeName})&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode||lu&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(function(e){return"childList"==e.type&&e.removedNodes.length}))){var d,f=j(s);try{for(f.s();!(d=f.n()).done;){var h=d.value;if("BR"==h.nodeName&&h.parentNode)for(var p=h.nextSibling;p&&Ka(p);){if("false"==p.contentEditable){h.parentNode.removeChild(h);break}p=p.firstChild}}}catch(e){f.e(e)}finally{f.f()}}else if(uu&&s.length){var v=s.filter(function(e){return"BR"==e.nodeName});if(2==v.length){var m=i(v,2),g=m[0],D=m[1];g.parentNode&&g.parentNode.parentNode==D.parentNode?D.remove():g.remove()}else{var y,k=this.currentSelection.focusNode,E=j(v);try{for(E.s();!(y=E.n()).done;){var F=y.value,b=F.parentNode;!b||"LI"!=b.nodeName||k&&Jl(e,k)==b||F.remove()}}catch(e){E.e(e)}finally{E.f()}}}var C=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xa(n)&&(C=ls(e))&&C.eq(Ui.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ds(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,a),function(e){if(Wl.has(e))return;if(Wl.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=uu,_l)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),_l=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n,r,o=e.domSelectionRange(),i=o.focusNode,a=o.focusOffset,u=j(t);try{for(u.s();!(r=u.n()).done;){var s=r.value;if("TR"==(null===(n=s.parentNode)||void 0===n?void 0:n.nodeName)){for(var l=s.nextSibling;l&&"TD"!=l.nodeName&&"TH"!=l.nodeName;)l=l.nextSibling;if(l){for(var c=l;;){var d=c.firstChild;if(!d||!Ka(d)||"false"==d.contentEditable||/^(BR|IMG)$/.test(d.nodeName))break;c=d}c.insertBefore(s,c.firstChild),i==s&&e.domSelection().collapse(s,a)}else s.parentNode.removeChild(s)}}}catch(e){u.e(e)}finally{u.f()}}(e,s)),this.handleDOMChange(o,a,u,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ds(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++){var o=e.addedNodes[r];t.push(o),Ja(o)&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var i=e.previousSibling,a=e.nextSibling;if(iu&&au<=11&&e.addedNodes.length)for(var u=0;u<e.addedNodes.length;u++){var s=e.addedNodes[u],l=s.previousSibling,c=s.nextSibling;(!l||Array.prototype.indexOf.call(e.addedNodes,l)<0)&&(i=l),(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(a=c)}var d=i&&i.parentNode==e.target?$a(i)+1:0,f=n.localPosFromDOM(e.target,d,-1),h=a&&a.parentNode==e.target?$a(a):e.target.childNodes.length;return{from:f,to:n.localPosFromDOM(e.target,h,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}])}(),Wl=new WeakMap,_l=!1;function Kl(e,t){var n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(Va(a.node,a.offset,o,i)){var u=[o,i,n,r];n=u[0],r=u[1],o=u[2],i=u[3]}return{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Jl(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}var Ql=function(e){return function(t){var n=t.pmViewDesc;if(n)return n.parseRule(e);if("BR"==t.nodeName&&t.parentNode){if(du&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}if(t.parentNode.lastChild==t||du&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}},Gl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Xl(e,t,n,r,o){var i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var a=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,u=ls(e,a);if(u&&!e.state.selection.eq(u)){if(lu&&vu&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",function(t){return t(e,Za(13,"Enter"))}))return;var s=e.state.tr.setSelection(u);"pointer"==a?s.setMeta("pointer",!0):"key"==a&&s.scrollIntoView(),i&&s.setMeta("composition",i),e.dispatch(s)}}else{var l=e.state.doc.resolve(t),c=l.sharedDepth(n);t=l.before(c+1),n=e.state.doc.resolve(n).after(c+1);var d,f,h=e.state.selection,p=function(e,t,n,r){var o,i=e.docView.parseRange(t,n),a=i.node,u=i.fromOffset,s=i.toOffset,l=i.from,c=i.to,d=e.domSelectionRange(),f=d.anchorNode;if(f&&Qa(e.dom,f)&&(o=[{node:f,offset:d.anchorOffset}],Xa(d)||o.push({node:d.focusNode,offset:d.focusOffset})),lu&&8===e.input.lastKeyCode)for(var h=s;h>u;h--){var p=a.childNodes[h-1],v=p.pmViewDesc;if("BR"==p.nodeName&&!v){s=h;break}if(!v||v.size)break}var m=e.state.doc,g=e.someProp("domParser")||Po.fromSchema(e.state.schema),D=m.resolve(l),y=null,k=g.parse(a,{topNode:D.parent,topMatch:D.parent.contentMatchAt(D.index()),topOpen:!0,from:u,to:s,preserveWhitespace:"pre"!=D.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Ql(r),context:D});if(o&&null!=o[0].pos){var E=o[0].pos,F=o[1]&&o[1].pos;null==F&&(F=E),y={anchor:E+l,head:F+l}}return{doc:k,sel:y,from:l,to:c}}(e,t,n,o),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,f="end"):(d=e.state.selection.from,f="start"),e.input.lastKeyCode=null;var g=function(e,t,n,r,o){var i=e.findDiffStart(t,n),a=n+e.size,u=n+t.size;if(null==i)return null;var s=e.findDiffEnd(t,a,u),l=s.a,c=s.b;if("end"==o){r-=l+Math.max(0,i-Math.min(l,c))-i}if(l<i&&a<u){c=(i-=r<=i&&r>=l?i-r:0)+(c-l),l=i}else if(c<i){l=(i-=r<=i&&r>=c?i-r:0)+(l-c),c=i}return{start:i,endA:l,endB:c}}(m.content,p.doc.content,p.from,d,f);if(g&&e.input.domChangeCount++,(fu&&e.input.lastIOSEnter>Date.now()-225||vu)&&o.some(function(e){return Ka(e)&&!Gl.test(e.nodeName)})&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",function(t){return t(e,Za(13,"Enter"))}))e.input.lastIOSEnter=0;else{if(!g){if(!(r&&h instanceof Ji&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var D=Zl(e,e.state.doc,p.sel);if(D&&!D.eq(e.state.selection)){var y=e.state.tr.setSelection(D);i&&y.setMeta("composition",i),e.dispatch(y)}}return}g={start:h.from,endA:h.to,endB:h.to}}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof Ji&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),iu&&au<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&" "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var k=p.doc.resolveNoCache(g.start-p.from),E=p.doc.resolveNoCache(g.endB-p.from),F=v.resolve(g.start),b=k.sameParent(E)&&k.parent.inlineContent&&F.end()>=g.endA;if((fu&&e.input.lastIOSEnter>Date.now()-225&&(!b||o.some(function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))||!b&&function(e,t,n){var r=0,o=0;return e.nodesBetween(t,n,function(e,i){e.isTextblock&&i>=t&&i<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-i),Math.min(e.nodeSize,n-i))):e.isLeaf)&&o++}),0==o&&1==r}(p.doc,k.pos,E.pos))&&e.someProp("handleKeyDown",function(t){return t(e,Za(13,"Enter"))}))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Yl(r,!0,!1)<o.pos)return!1;var i=e.resolve(t);if(!r.parent.isTextblock){var a=i.nodeAfter;return null!=a&&n==t+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var u=e.resolve(Yl(i,!0,!0));return!(!u.parent.isTextblock||u.pos>n||Yl(u,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(u.parent.content)}(v,g.start,g.endA,k,E)&&e.someProp("handleKeyDown",function(t){return t(e,Za(8,"Backspace"))}))vu&&lu&&e.domObserver.suppressSelectionUpdates();else{lu&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),vu&&!b&&k.start()!=E.start()&&0==E.parentOffset&&k.depth==E.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,E=p.doc.resolveNoCache(g.endB-p.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,Za(13,"Enter"))})},20));var C,w=g.start,A=g.endA,x=function(t){var n=t||e.state.tr.replace(w,A,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){var r=Zl(e,n.doc,p.sel);r&&!(lu&&e.composing&&r.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(r.head==w||r.head==n.mapping.map(A)-1)||iu&&r.empty&&r.head==w)&&n.setSelection(r)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(b)if(k.pos==E.pos){iu&&au<=11&&0==k.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return ds(e)},20));var S=x(e.state.tr.delete(w,A)),B=v.resolve(g.start).marksAcross(v.resolve(g.endA));B&&S.ensureMarks(B),e.dispatch(S)}else if(g.endA==g.endB&&(C=function(e,t){for(var n,r,o,i=e.firstChild.marks,a=t.firstChild.marks,u=i,s=a,l=0;l<a.length;l++)u=a[l].removeFromSet(u);for(var c=0;c<i.length;c++)s=i[c].removeFromSet(s);if(1==u.length&&0==s.length)r=u[0],n="add",o=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=u.length||1!=s.length)return null;r=s[0],n="remove",o=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var d=[],f=0;f<t.childCount;f++)d.push(o(t.child(f)));if(Vr.from(d).eq(e))return{mark:r,type:n}}(k.parent.content.cut(k.parentOffset,E.parentOffset),F.parent.content.cut(F.parentOffset,g.endA-F.start())))){var T=x(e.state.tr);"add"==C.type?T.addMark(w,A,C.mark):T.removeMark(w,A,C.mark),e.dispatch(T)}else if(k.parent.child(k.index()).isText&&k.index()==E.index()-(E.textOffset?0:1)){var M=k.parent.textBetween(k.parentOffset,E.parentOffset),N=function(){return x(e.state.tr.insertText(M,w,A))};e.someProp("handleTextInput",function(t){return t(e,w,A,M,N)})||e.dispatch(N())}else e.dispatch(x());else e.dispatch(x())}}}}function Zl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ds(e,t.resolve(n.anchor),t.resolve(n.head))}function Yl(e,t,n){for(var r=e.depth,o=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n)for(var i=e.node(r).maybeChild(e.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}var ec=function(){return x(function e(t,n){var r=this;M(this,e),this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ks,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(ic),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=rc(this),nc(this),this.nodeViews=oc(this),this.docView=_u(this.state.doc,tc(this),ql(this),this.dom,this),this.domObserver=new Ul(this,function(e,t,n,o){return Xl(r,e,t,n,o)}),this.domObserver.start(),function(e){var t=function(){var t=Us[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,n)||Gs(e,n)||!e.editable&&n.type in Ws||t(e,n)},_s[n]?{passive:!0}:void 0)};for(var n in Us)t();du&&e.dom.addEventListener("input",function(){return null}),Qs(e)}(this),this.updatePluginViews()},[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Qs(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ic),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n,r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(fl(this),i=!0),this.state=e;var a=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var u=oc(this);(function(e,t){var n=0,r=0;for(var o in e){if(e[o]!=t[o])return!0;n++}for(var i in t)r++;return n!=r})(u,this.nodeViews)&&(this.nodeViews=u,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Qs(this),this.editable=rc(this),nc(this);var s=ql(this),l=tc(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,s);!d&&e.selection.eq(r.selection)||(i=!0);var f,h,p,v,m,g,D,y,k,E,F,b="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,a=o+1;a<Math.min(innerHeight,r.bottom);a+=5){var u=e.root.elementFromPoint(i,a);if(u&&u!=e.dom&&e.dom.contains(u)){var s=u.getBoundingClientRect();if(s.top>=o-20){t=u,n=s.top;break}}}return{refDOM:t,refTop:n,stack:Fu(e.dom)}}(this);if(i){this.domObserver.stop();var C=d&&(iu||lu)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&(v=r.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var w=lu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hl(this)),!o&&this.docView.update(e.doc,l,s,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=_u(e.doc,l,s,this.dom,this)),!w||this.trackWrites&&this.dom.contains(this.trackWrites)||(C=!0)}var A=this.input.mouseDown;C||!(A&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(f=this,h=f.docView.domFromPos(f.state.selection.anchor,0),p=f.domSelectionRange(),Va(h.node,h.offset,p.anchorNode,p.anchorOffset))&&A.delaySelUpdate())?ds(this,C):(ms(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():b&&(y=(D=b).refDOM,k=D.refTop,E=D.stack,F=y?y.getBoundingClientRect().top:0,bu(E,0==F?0:F-k))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(t&&Qa(this.dom,t))if(this.someProp("handleScrollToSelection",function(t){return t(e)}));else if(this.state.selection instanceof Gi){var n=this.docView.domAfterPos(this.state.selection.from);Ka(n)&&Eu(this,n.getBoundingClientRect(),t)}else Eu(this,this.coordsAtPos(this.state.selection.head,1),t);else;}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var a=this.state.plugins[i];a.spec.view&&this.pluginViews.push(a.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{var o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==n.node&&(r=o)}this.dragging=new Dl(e.slice,e.move,r<0?void 0:Gi.create(this.state.doc,r))}},{key:"someProp",value:function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[e];if(null!=i&&(n=t?t(i):i))return n}var a=this.state.plugins;if(a)for(var u=0;u<a.length;u++){var s=a[u].props[e];if(null!=s&&(n=t?t(s):s))return n}}},{key:"hasFocus",value:function(){if(iu){var e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Cu)return e.focus(Cu);var t=Fu(e);e.focus(null==Cu?{get preventScroll(){return Cu={preventScroll:!0},!0}}:void 0),Cu||(Cu=!1,bu(t,0))}(this.dom),ds(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,r=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},o=this.dom.parentNode;o;o=o.parentNode)if(n=r(o))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return Su(this,e)}},{key:"coordsAtPos",value:function(e){return Nu(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}},{key:"endOfTextblock",value:function(e,t){return qu(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return ml(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return ml(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"serializeForClipboard",value:function(e){return Rs(this,e)}},{key:"destroy",value:function(){this.docView&&(!function(e){for(var t in e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ql(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ja=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){Gs(e,t)||!Us[t.type]||!e.editable&&t.type in Ws||Us[t.type](e,t)}(this,e)}},{key:"domSelectionRange",value:function(){var e=!1!==this.dom.isConnected&&this.domSelection();return e?du&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Kl(e,n)}var r;function o(e){e.preventDefault(),e.stopImmediatePropagation(),r=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),r?Kl(e,r):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function tc(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r?t.class+=" "+n[r]:"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[Al.node(0,e.state.doc.content.size,t)]}function nc(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Al.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function rc(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function oc(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function ic(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}ec.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var ac={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},uc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},sc="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),lc="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),cc=0;cc<10;cc++)ac[48+cc]=ac[96+cc]=String(cc);for(cc=1;cc<=24;cc++)ac[cc+111]="F"+cc;for(cc=65;cc<=90;cc++)ac[cc]=String.fromCharCode(cc+32),uc[cc]=String.fromCharCode(cc);for(var dc in ac)uc.hasOwnProperty(dc)||(uc[dc]=ac[dc]);var fc="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),hc="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function pc(e){var t,n,r,o,i=e.split(/-(?!$)/),a=i[i.length-1];"Space"==a&&(a=" ");for(var u=0;u<i.length-1;u++){var s=i[u];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);fc?o=!0:n=!0}}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),o&&(a="Meta-"+a),r&&(a="Shift-"+a),a}function vc(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function mc(e){var t=function(e){var t=Object.create(null);for(var n in e)t[pc(n)]=e[n];return t}(e);return function(e,n){var r,o=function(e){var t=!(sc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||lc&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?uc:ac)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[vc(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){var a=t[vc(o,n,!1)];if(a&&a(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(hc&&n.ctrlKey&&n.altKey)&&(r=ac[n.keyCode])&&r!=o){var u=t[vc(r,n)];if(u&&u(e.state,e.dispatch,e))return!0}}return!1}}var gc=200,Dc=function(){};Dc.prototype.append=function(e){return e.length?(e=Dc.from(e),!this.length&&e||e.length<gc&&this.leafAppend(e)||this.length<gc&&e.leafPrepend(this)||this.appendInner(e)):this},Dc.prototype.prepend=function(e){return e.length?Dc.from(e).append(this):this},Dc.prototype.appendInner=function(e){return new kc(this,e)},Dc.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Dc.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Dc.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Dc.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Dc.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Dc.from=function(e){return e instanceof Dc?e:e&&e.length?new yc(e):Dc.empty};var yc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=gc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=gc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Dc);Dc.empty=new yc([]);var kc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Dc),Ec=function(){function e(t,n){M(this,e),this.items=t,this.eventCount=n}return x(e,[{key:"popEvent",value:function(t,n){var r=this;if(0==this.eventCount)return null;for(var o,i,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}n&&(o=this.remapping(a,this.items.length),i=o.maps.length);var u,s,l=t.tr,c=[],d=[];return this.items.forEach(function(t,n){if(!t.step)return o||(o=r.remapping(a,n+1),i=o.maps.length),i--,void d.push(t);if(o){d.push(new Fc(t.map));var f,h=t.step.map(o.slice(i));h&&l.maybeStep(h).doc&&(f=l.mapping.maps[l.mapping.maps.length-1],c.push(new Fc(f,void 0,void 0,c.length+d.length))),i--,f&&o.appendMap(f,i)}else l.maybeStep(t.step);return t.selection?(u=o?t.selection.map(o.slice(i)):t.selection,s=new e(r.items.slice(0,a).append(d.reverse().concat(c)),r.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:u}}},{key:"addTransform",value:function(t,n,r,o){for(var i=[],a=this.eventCount,u=this.items,s=!o&&u.length?u.get(u.length-1):null,l=0;l<t.steps.length;l++){var c,d=t.steps[l].invert(t.docs[l]),f=new Fc(t.mapping.maps[l],d,n);(c=s&&s.merge(f))&&(f=c,l?i.pop():u=u.slice(0,u.length-1)),i.push(f),n&&(a++,n=void 0),o||(s=f)}var h,p,v,m=a-r.depth;return m>Cc&&(p=m,(h=u).forEach(function(e,t){if(e.selection&&0==p--)return v=t,!1}),u=h.slice(v),a-=m),new e(u.append(i),a)}},{key:"remapping",value:function(e,t){var n=new ri;return this.items.forEach(function(t,r){var o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map(function(e){return new Fc(e)})),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);var r=[],o=this.items.length-n,i=t.mapping,a=t.steps.length,u=this.eventCount;this.items.forEach(function(e){e.selection&&u--},o);var s=n;this.items.forEach(function(e){var n=i.getMirror(--s);if(null!=n){a=Math.min(a,n);var o=i.maps[n];if(e.step){var l=t.steps[n].invert(t.docs[n]),c=e.selection&&e.selection.map(i.slice(s+1,n));c&&u++,r.push(new Fc(o,l,c))}else r.push(new Fc(o))}},o);for(var l=[],c=n;c<a;c++)l.push(new Fc(i.maps[c]));var d=new e(this.items.slice(0,o).append(l).append(r),u);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-r.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),r=n.maps.length,o=[],i=0;return this.items.forEach(function(e,a){if(a>=t)o.push(e),e.selection&&i++;else if(e.step){var u=e.step.map(n.slice(r)),s=u&&u.getMap();if(r--,s&&n.appendMap(s,r),u){var l=e.selection&&e.selection.map(n.slice(r));l&&i++;var c,d=new Fc(s.invert(),u,l),f=o.length-1;(c=o.length&&o[f].merge(d))?o[f]=c:o.push(d)}}else e.map&&r--},this.items.length,0),new e(Dc.from(o.reverse()),i)}}])}();Ec.empty=new Ec(Dc.empty,0);var Fc=function(){function e(t,n,r,o){M(this,e),this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}return x(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}])}(),bc=x(function e(t,n,r,o,i){M(this,e),this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}),Cc=20;function wc(e){for(var t=[],n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(function(e,n,r,o){return t.push(r,o)});return t}function Ac(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}var xc=!1,Sc=null;function Bc(e){var t=e.plugins;if(Sc!=t){xc=!1,Sc=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){xc=!0;break}}return xc}var Tc=new fa("history"),Mc=new fa("closeHistory");function Nc(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new la({key:Tc,state:{init:function(){return new bc(Ec.empty,Ec.empty,null,0,-1)},apply:function(t,n,r){return function(e,t,n,r){var o,i=n.getMeta(Tc);if(i)return i.historyState;n.getMeta(Mc)&&(e=new bc(e.done,e.undone,null,0,-1));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(Tc))return a.getMeta(Tc).redo?new bc(e.done.addTransform(n,void 0,r,Bc(t)),e.undone,wc(n.mapping.maps),e.prevTime,e.prevComposition):new bc(e.done,e.undone.addTransform(n,void 0,r,Bc(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new bc(e.done.rebased(n,o),e.undone.rebased(n,o),Ac(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new bc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ac(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var u=n.getMeta("composition"),s=0==e.prevTime||!a&&e.prevComposition!=u&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach(function(e,r){for(var o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),l=a?Ac(e.prevRanges,n.mapping):wc(n.mapping.maps);return new bc(e.done.addTransform(n,s?t.selection.getBookmark():void 0,r,Bc(t)),Ec.empty,l,n.time,null==u?e.prevComposition:u)}(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,r="historyUndo"==n?Oc:"historyRedo"==n?Ic:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Rc(e,t){return function(n,r){var o=Tc.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){var i=function(e,t,n){var r=Bc(t),o=Tc.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;var a=i.selection.resolve(i.transform.doc),u=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),s=new bc(n?u:i.remaining,n?i.remaining:u,null,0,-1);return i.transform.setSelection(a).setMeta(Tc,{redo:n,historyState:s})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var Oc=Rc(!1,!0),Ic=Rc(!0,!0);function Pc(e){return null!=e.getMeta(Tc)}function Lc(t){var n=t.state,r=t.transaction,o=r.selection,i=r.doc,a=r.storedMarks;return e(e({},n),{},{apply:n.apply.bind(n),applyTransaction:n.applyTransaction.bind(n),plugins:n.plugins,schema:n.schema,reconfigure:n.reconfigure.bind(n),toJSON:n.toJSON.bind(n),get storedMarks(){return a},get selection(){return o},get doc(){return i},get tr(){return o=r.selection,i=r.doc,a=r.storedMarks,r}})}var zc=function(){function t(e){M(this,t),this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}return x(t,[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,r=this.state,o=n.view,a=r.tr,u=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(function(t){var n=i(t,2),r=n[0],s=n[1];return[r,function(){var t=s.apply(void 0,arguments)(u);return a.getMeta("preventDispatch")||e.hasCustomState||o.dispatch(a),t}]}))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(t){var n=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.rawCommands,a=this.editor,u=this.state,s=a.view,l=[],c=!!t,d=t||u.tr,f=e(e({},Object.fromEntries(Object.entries(o).map(function(e){var t=i(e,2),o=t[0],a=t[1];return[o,function(){var e=n.buildProps(d,r),t=a.apply(void 0,arguments)(e);return l.push(t),f}]}))),{},{run:function(){return c||!r||d.getMeta("preventDispatch")||n.hasCustomState||s.dispatch(d),l.every(function(e){return!0===e})}});return f}},{key:"createCan",value:function(t){var n=this,r=this.rawCommands,o=this.state,a=!1,u=t||o.tr,s=this.buildProps(u,a);return e(e({},Object.fromEntries(Object.entries(r).map(function(t){var n=i(t,2),r=n[0],o=n[1];return[r,function(){return o.apply(void 0,arguments)(e(e({},s),{},{dispatch:void 0}))}]}))),{},{chain:function(){return n.createChain(u,a)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,o=this.editor,a=this.state,u=o.view,s={tr:e,editor:o,view:u,state:Lc({state:a,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(r).map(function(e){var t=i(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(s)}]}))}};return s}}],[{key:"createFakeChain",value:function(){var e=new Proxy({},{get:function(t,n){if("then"!==n)return"run"===n?function(){return!1}:function(){return e}}});return e}},{key:"createFallbackCan",value:function(){var e=t.createFakeChain();return new Proxy({chain:function(){return e}},{get:function(e,t){if("then"!==t)return"chain"===t?e.chain:function(){return!1}}})}}])}(),$c=function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame(function(){var e;t.isDestroyed||(n.dom.blur(),null===(e=window)||void 0===e||null===(e=e.getSelection())||void 0===e||e.removeAllRanges())}),!0}},qc=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function(t){return t.commands.setContent("",{emitUpdate:e})}},jc=function(){return function(e){var t=e.state,n=e.tr,r=e.dispatch,o=n.selection.ranges;return!r||(o.forEach(function(e){var r=e.$from,o=e.$to;t.doc.nodesBetween(r.pos,o.pos,function(e,t){if(!e.type.isText){var r=n.doc,o=n.mapping,i=r.resolve(o.map(t)),a=r.resolve(o.map(t+e.nodeSize)),u=i.blockRange(a);if(u){var s=gi(u);if(e.type.isTextblock){var l=i.parent.contentMatchAt(i.index()).defaultType;n.setNodeMarkup(u.start,l)}(s||0===s)&&n.lift(u,s)}}})}),!0)}},Hc=function(e){return function(t){return e(t)}},Vc=function(){return function(e){var t=e.state,n=e.dispatch;return xa(t,n)}},Uc=function(e,t){return function(n){var r=n.editor,o=n.tr,i=r.state.doc.slice(e.from,e.to);o.deleteRange(e.from,e.to);var a=o.mapping.map(t);return o.insert(a,i.content),o.setSelection(new Ji(o.doc.resolve(Math.max(a-1,0)))),!0}},Wc=function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection.$anchor.node();if(r.content.size>0)return!1;for(var o=t.selection.$anchor,i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(n){var a=o.before(i),u=o.after(i);t.delete(a,u).scrollIntoView()}return!0}return!1}};function _c(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}var Kc=function(e){return function(t){for(var n=t.tr,r=t.state,o=t.dispatch,i=_c(e,r.schema),a=n.selection.$anchor,u=a.depth;u>0;u-=1)if(a.node(u).type===i){if(o){var s=a.before(u),l=a.after(u);n.delete(s,l).scrollIntoView()}return!0}return!1}},Jc=function(e){return function(t){var n=t.tr,r=t.dispatch,o=e.from,i=e.to;return r&&n.delete(o,i),!0}},Qc=function(e,t,n){if(!e.parent.isInline)return e.pos;if("left"===n&&e.pos>e.start()||"right"===n&&e.pos<e.end())return e.pos;var r,o=t.nodes[e.parent.type.name].spec;return(r=o).content&&/^text(\*|\+)/.test(r.content)?"left"===n?e.start()-1:e.end()+1:e.pos},Gc=function(){return function(e){var t=e.state,n=e.dispatch;if(t.selection.empty)return!1;if(n){var r=t.tr,o=t.selection.ranges,i=r.steps.length;o.forEach(function(e){var n=r.mapping.slice(i),o=function(e,t,n){return{from:Qc(e,n,"left"),to:Qc(t,n,"right")}}(r.doc.resolve(n.map(e.$from.pos)),r.doc.resolve(n.map(e.$to.pos)),t.schema),a=o.from,u=o.to;r.deleteRange(a,u)}),r.selection.empty||r.setSelection(Ji.near(r.doc.resolve(r.selection.from))),r.scrollIntoView(),n(r)}return!0}},Xc=function(){return function(e){return e.commands.keyboardShortcut("Enter")}},Zc=function(){return function(e){var t=e.state,n=e.dispatch;return Aa(t,n)}};function Yc(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function ed(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},r=Object.keys(t);return!r.length||r.every(function(r){return n.strict?t[r]===e[r]:Yc(t[r])?t[r].test(e[r]):t[r]===e[r]})}function td(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find(function(e){return e.type===t&&ed(Object.fromEntries(Object.keys(n).map(function(t){return[t,e.attrs[t]]})),n)})}function nd(e,t){return!!td(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function rd(e,t,n){if(e&&t){var r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(function(e){return e.type===t})||(r=e.parent.childBefore(e.parentOffset)),r.node&&r.node.marks.some(function(e){return e.type===t})){if(!n){var i=r.node.marks.find(function(e){return e.type===t});i&&(n=i.attrs)}if(td(o(r.node.marks),t,n)){for(var a=r.index,u=e.start()+r.offset,s=a+1,l=u+r.node.nodeSize;a>0&&nd(o(e.parent.child(a-1).marks),t,n);)a-=1,u-=e.parent.child(a).nodeSize;for(;s<e.parent.childCount&&nd(o(e.parent.child(s).marks),t,n);)l+=e.parent.child(s).nodeSize,s+=1;return{from:u,to:l}}}}}function od(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}var id=function(e,t){return function(n){var r=n.tr,o=n.state,i=n.dispatch,a=od(e,o.schema),u=r.doc,s=r.selection,l=s.$from,c=s.from,d=s.to;if(i){var f=rd(l,a,t);if(f&&f.from<=c&&f.to>=d){var h=Ji.create(u,f.from,f.to);r.setSelection(h)}}return!0}},ad=function(e){return function(t){for(var n="function"==typeof e?e(t):e,r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1}};function ud(e){return e instanceof Ji}function sd(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function ld(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=Ui.atStart(e),r=Ui.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;var o=n.from,i=r.to;return"all"===t?Ji.create(e,sd(0,o,i),sd(e.content.size,o,i)):Ji.create(e,sd(t,o,i),sd(t,o,i))}function cd(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function dd(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var fd=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=r.editor,i=r.view,a=r.tr,u=r.dispatch;n=e({scrollIntoView:!0},n);var s=function(){(dd()||cd())&&i.dom.focus(),"undefined"==typeof navigator||!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||dd()||cd()||i.dom.focus({preventScroll:!0}),requestAnimationFrame(function(){o.isDestroyed||(i.focus(),(null==n?void 0:n.scrollIntoView)&&o.commands.scrollIntoView())})};try{if(i.hasFocus()&&null===t||!1===t)return!0}catch(e){return!1}if(u&&null===t&&!ud(o.state.selection))return s(),!0;var l=ld(a.doc,t)||o.state.selection,c=o.state.selection.eq(l);return u&&(c||a.setSelection(l),c&&a.storedMarks&&a.setStoredMarks(a.storedMarks),s()),!0}},hd=function(t,n){return function(r){return t.every(function(t,o){return n(t,e(e({},r),{},{index:o}))})}},pd=function(e,t){return function(n){var r=n.tr;return n.commands.insertContentAt({from:r.selection.from,to:r.selection.to},e,t)}},vd=function(e){for(var t=e.childNodes,n=t.length-1;n>=0;n-=1){var r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&vd(r)}return e};function md(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return vd(n)}function gd(e){return"function"==typeof(null==e?void 0:e.nodesBetween)}function Dd(t,n,r){if(gd(t))return t;var o="object"===k(t)&&null!==t;r=e({slice:!0,parseOptions:{}},r);var i="string"==typeof t;if(o)try{if(Array.isArray(t)&&t.length>0)return Vr.fromArray(t.map(function(e){return n.nodeFromJSON(e)}));var a=n.nodeFromJSON(t);return r.errorOnInvalidContent&&a.check(),a}catch(e){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:e});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",e),Dd("",n,r)}if(i){if(r.errorOnInvalidContent){var u=!1,s="",l=new Oo({topNode:n.spec.topNode,marks:n.spec.marks,nodes:n.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:function(e){return u=!0,s="string"==typeof e?e:e.outerHTML,null}}]}})});if(r.slice?Po.fromSchema(l).parseSlice(md(t),r.parseOptions):Po.fromSchema(l).parse(md(t),r.parseOptions),r.errorOnInvalidContent&&u)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error("Invalid element found: ".concat(s))})}var c=Po.fromSchema(n);return r.slice?c.parseSlice(md(t),r.parseOptions).content:c.parse(md(t),r.parseOptions)}return Dd("",n,r)}function yd(e){return!("type"in e)}function kd(e,t,n){var r=e.steps.length-1;if(!(r<t)){var o=e.steps[r];if(o instanceof fi||o instanceof hi){var i=e.mapping.maps[r],a=0;i.forEach(function(e,t,n,r){0===a&&(a=r)}),e.setSelection(Ui.near(e.doc.resolve(a),n))}}}var Ed=function(t,n,r){return function(o){var i=o.tr,a=o.dispatch,u=o.editor;if(a){var s;r=e({parseOptions:u.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},r);var l=function(e){u.emit("contentError",{editor:u,error:e,disableCollaboration:function(){"collaboration"in u.storage&&"object"===k(u.storage.collaboration)&&u.storage.collaboration&&(u.storage.collaboration.isDisabled=!0)}})},c=e({preserveWhitespace:"full"},r.parseOptions);if(!r.errorOnInvalidContent&&!u.options.enableContentCheck&&u.options.emitContentError)try{Dd(n,u.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{var d;s=Dd(n,u.schema,{parseOptions:c,errorOnInvalidContent:null!==(d=r.errorOnInvalidContent)&&void 0!==d?d:u.options.enableContentCheck})}catch(e){return l(e),!1}var f,h="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},p=h.from,v=h.to,m=!0,g=!0,D=yd(s)?s.content:[s];if(D.forEach(function(e){e.check(),m=!!m&&(e.isText&&0===e.marks.length),g=!!g&&e.isBlock}),p===v&&g){var y=i.doc.resolve(p).parent;!y.isTextblock||y.type.spec.code||y.childCount||(p-=1,v+=1)}if(m)f=Array.isArray(n)?n.map(function(e){return e.text||""}).join(""):gd(n)?D.map(function(e){var t;return null!==(t=e.text)&&void 0!==t?t:""}).join(""):"object"===k(n)&&n&&n.text?n.text:n,i.insertText(f,p,v);else{f=Vr.from(D);var E=i.doc.resolve(p),F=E.node(),b=0===E.parentOffset,C=F.isText||F.isTextblock,w=F.content.size>0;b&&C&&w&&g&&(p=Math.max(0,p-1)),i.replaceWith(p,v,D)}r.updateSelection&&kd(i,i.steps.length-1,-1),r.applyInputRules&&i.setMeta("applyInputRules",{from:p,text:f}),r.applyPasteRules&&i.setMeta("applyPasteRules",{from:p,text:f})}return!0}};function Fd(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var bd=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n,r=t.tr,o=t.dispatch,a=t.editor,u=e.pos,s=e.attrs,l=e.content,c=e.updateSelection,d=void 0===c||c,f=Fd((n="number"==typeof u?r.doc.resolve(u):u||r.selection.$from).parent.contentMatchAt(n.index()));if(!f)return!1;var h,p=Object.keys(f.spec.attrs||{}),v=s?Object.fromEntries(Object.entries(s).filter(function(e){var t=i(e,1)[0];return p.includes(t)})):{};if(l){var m=Dd(l,a.schema);h=f.createAndFill(v,m)}else h=f.createAndFill(v);return!!h&&(o&&(r.insert(n.pos,h),d&&kd(r,r.steps.length-1,-1)),!0)}},Cd=function(){return function(e){return function(e,t){var n,r=e.selection,o=r instanceof Gi;if(o){if(r.node.isTextblock||!bi(e.doc,r.from))return!1;n=r.from}else if(null==(n=wi(e.doc,r.from,-1)))return!1;if(t){var i=e.tr.join(n);o&&i.setSelection(Gi.create(i.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0}(e.state,e.dispatch)}},wd=function(){return function(e){return function(e,t){var n,r=e.selection;if(r instanceof Gi){if(r.node.isTextblock||!bi(e.doc,r.to))return!1;n=r.to}else if(null==(n=wi(e.doc,r.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},Ad=function(){return function(e){var t=e.state,n=e.dispatch;return va(t,n)}},xd=function(){return function(e){var t=e.state,n=e.dispatch;return Ea(t,n)}},Sd=function(e,t){var n=e.resolve(t),r=n.nodeBefore,o=n.nodeAfter;return!(!r||!o)&&(!r.type.spec.isolating&&!o.type.spec.isolating)},Bd=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var o=wi(t.doc,t.selection.$from.pos,-1);return null!=o&&(!!Sd(t.doc,o)&&(r.join(o,2),n&&n(r),!0))}catch(e){return!1}}},Td=function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var o=wi(t.doc,t.selection.$from.pos,1);return null!=o&&(!!Sd(t.doc,o)&&(r.join(o,2),n&&n(r),!0))}catch(e){return!1}}},Md=function(){return function(e){return function(e,t,n){var r=pa(e,n);if(!r)return!1;var o=ya(r);return!!o&&ma(e,o,t)}(e.state,e.dispatch)}},Nd=function(){return function(e){return function(e,t,n){var r=ka(e,n);if(!r)return!1;var o=ba(r);return!!o&&ma(e,o,t)}(e.state,e.dispatch)}};function Rd(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Od=function(e){return function(t){var n=t.editor,r=t.view,o=t.tr,i=t.dispatch,a=function(e){var t,n,r,o,i=e.split(/-(?!$)/),a=i[i.length-1];"Space"===a&&(a=" ");for(var u=0;u<i.length-1;u+=1){var s=i[u];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: ".concat(s));dd()||Rd()?o=!0:n=!0}}return t&&(a="Alt-".concat(a)),n&&(a="Ctrl-".concat(a)),o&&(a="Meta-".concat(a)),r&&(a="Shift-".concat(a)),a}(e).split(/-(?!$)/),u=a.find(function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)}),s=new KeyboardEvent("keydown",{key:"Space"===u?" ":u,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=n.captureTransaction(function(){r.someProp("handleKeyDown",function(e){return e(r,s)})});return null==l||l.steps.forEach(function(e){var t=e.map(o.mapping);t&&i&&o.maybeStep(t)}),!0}};function Id(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,o=r.from,i=r.to,a=r.empty,u=t?_c(t,e.schema):null,s=[];e.doc.nodesBetween(o,i,function(e,t){if(!e.isText){var n=Math.max(o,t),r=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:r})}});var l=i-o,c=s.filter(function(e){return!u||u.name===e.node.type.name}).filter(function(e){return ed(e.node.attrs,n,{strict:!1})});return a?!!c.length:c.reduce(function(e,t){return e+t.to-t.from},0)>=l}var Pd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.dispatch;return!!Id(r,_c(e,r.schema),t)&&function(e,t){var n=e.selection,r=n.$from,o=n.$to,i=r.blockRange(o),a=i&&gi(i);return null!=a&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)}(r,o)}},Ld=function(){return function(e){var t=e.state,n=e.dispatch;return Sa(t,n)}},zd=function(e){return function(t){var n=t.state,r=t.dispatch;return za(_c(e,n.schema))(n,r)}},$d=function(){return function(e){var t=e.state,n=e.dispatch;return Ca(t,n)}};function qd(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function jd(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce(function(t,r){return n.includes(r)||(t[r]=e[r]),t},{})}var Hd=function(e,t){return function(n){var r=n.tr,o=n.state,i=n.dispatch,a=null,u=null,s=qd("string"==typeof e?e:e.name,o.schema);if(!s)return!1;"node"===s&&(a=_c(e,o.schema)),"mark"===s&&(u=od(e,o.schema));var l=!1;return r.selection.ranges.forEach(function(e){o.doc.nodesBetween(e.$from.pos,e.$to.pos,function(e,n){a&&a===e.type&&(l=!0,i&&r.setNodeMarkup(n,void 0,jd(e.attrs,t))),u&&e.marks.length&&e.marks.forEach(function(o){u===o.type&&(l=!0,i&&r.addMark(n,n+e.nodeSize,u.create(jd(o.attrs,t))))})})}),l}},Vd=function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},Ud=function(){return function(e){var t=e.tr;if(e.dispatch){var n=new Zi(t.doc);t.setSelection(n)}return!0}},Wd=function(){return function(e){var t=e.state,n=e.dispatch;return Da(t,n)}},_d=function(){return function(e){var t=e.state,n=e.dispatch;return Fa(t,n)}},Kd=function(){return function(e){return function(e,t){var n,r=e.selection,o=r.$from,i=r.to,a=o.sharedDepth(i);return 0!=a&&(n=o.before(a),t&&t(e.tr.setSelection(Gi.create(e.doc,n))),!0)}(e.state,e.dispatch)}},Jd=function(){return function(e){var t=e.state,n=e.dispatch;return Oa(t,n)}},Qd=function(){return function(e){var t=e.state,n=e.dispatch;return Ra(t,n)}};function Gd(e,t){return Dd(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},errorOnInvalidContent:(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).errorOnInvalidContent})}var Xd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errorOnInvalidContent,r=t.emitUpdate,o=void 0===r||r,i=t.parseOptions,a=void 0===i?{}:i;return function(t){var r=t.editor,i=t.tr,u=t.dispatch,s=t.commands,l=i.doc;if("full"!==a.preserveWhitespace){var c=Gd(e,r.schema,a,{errorOnInvalidContent:null!=n?n:r.options.enableContentCheck});if(u){var d=yd(c)?c.content:[c];i.replaceWith(0,l.content.size,d).setMeta("preventUpdate",!o)}return!0}return u&&i.setMeta("preventUpdate",!o),s.insertContentAt({from:0,to:l.content.size},e,{parseOptions:a,errorOnInvalidContent:null!=n?n:r.options.enableContentCheck})}};function Zd(t,n){var r=od(n,t.schema),i=t.selection,a=i.from,u=i.to,s=i.empty,l=[];s?(t.storedMarks&&l.push.apply(l,o(t.storedMarks)),l.push.apply(l,o(t.selection.$head.marks()))):t.doc.nodesBetween(a,u,function(e){l.push.apply(l,o(e.marks))});var c=l.find(function(e){return e.type.name===r.name});return c?e({},c.attrs):{}}function Yd(e,t){var n=new Hi(e);return t.forEach(function(e){e.steps.forEach(function(e){n.step(e)})}),n}function ef(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}}function tf(t,n,r){return void 0===t.config[n]&&t.parent?tf(t.parent,n,r):"function"==typeof t.config[n]?t.config[n].bind(e(e({},r),{},{parent:t.parent?tf(t.parent,n,r):null})):t.config[n]}function nf(e){return e.map(function(e){var t=tf(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e].concat(o(nf(t()))):e}).flat(10)}function rf(e,t){var n=_o.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function of(t,n){var r,a=new Map,u=j(t);try{for(u.s();!(r=u.n()).done;){var s,l=r.value,c=null!==(s=a.get(l.type))&&void 0!==s?s:new Map;c.set(l.name,l),a.set(l.type,c)}}catch(e){u.e(e)}finally{u.f()}return[].concat(o(Object.values(n.nodes)),o(Object.values(n.marks))).flatMap(function(t){var n;return Object.entries(null!==(n=t.spec.attrs)&&void 0!==n?n:{}).map(function(n){var r,o=i(n,2),u=o[0],s=o[1],l=null===(r=a.get(t.name))||void 0===r?void 0:r.get(u),c=Object.hasOwn(s,"default");return{type:t.name,name:u,attribute:e(e({rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0},null==l?void 0:l.attribute),{},{default:s.default,isRequired:!c,validate:s.validate})}})})}var af={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},uf={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function sf(t,n,r,o){return e(e(e({},Object.fromEntries(Object.entries(n).filter(function(e){var t=i(e,1)[0];return"attrs"!==t&&!Object.hasOwn(o,t)}))),function(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(function(t){var r=i(t,2),o=r[0],a=r[1],u=e[o];if(void 0===u)return[];if(!("string"==typeof a?k(u)===a:"string"==typeof u&&a.includes(u)))throw new RangeError("Invalid schemaSpec field '".concat(n,".").concat(o,"'"));return[[o,u]]}))}(r,o,t)),{},{attrs:r.attrs})}function lf(e,t,n){for(var r=0,o=Object.keys(t);r<o.length;r++){var i=o[r];if(!Object.hasOwn(e,i))throw new RangeError("schemaSpec requires a local ".concat(n," extension named '").concat(i,"'"))}for(var a=0,u=Object.keys(e);a<u.length;a++){var s=u[a];if(!Object.hasOwn(t,s))throw new RangeError("Local ".concat(n," extension '").concat(s,"' is not in schemaSpec"))}}function cf(e){var t=e.filter(function(t,n){return e.indexOf(t)!==n});return Array.from(new Set(t))}function df(e){return{baseExtensions:e.filter(function(e){return"extension"===e.type}),nodeExtensions:e.filter(function(e){return"node"===e.type}),markExtensions:e.filter(function(e){return"mark"===e.type})}}function ff(t){var n=[],r=df(t),a=r.nodeExtensions,u=r.markExtensions,s=[].concat(o(a),o(u)),l={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},c=a.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),d=u.map(function(e){return e.name}),f=[].concat(o(c),o(d));return t.forEach(function(t){var r=tf(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:s});r&&r().forEach(function(t){(Array.isArray(t.types)?t.types:"*"===t.types?f:"nodes"===t.types?c:"marks"===t.types?d:[]).forEach(function(r){Object.entries(t.attributes).forEach(function(t){var o=i(t,2),a=o[0],u=o[1];n.push({type:r,name:a,attribute:e(e({},l),u)})})})})}),s.forEach(function(t){var r=tf(t,"addAttributes",{name:t.name,options:t.options,storage:t.storage});if(r){var o=r();Object.entries(o).forEach(function(r){var o=i(r,2),a=o[0],u=o[1],s=e(e({},l),u);"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,n.push({type:t.name,name:a,attribute:s})})}}),n}function hf(e){return"function"==typeof e}function pf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(hf(e)){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return t?e.bind(t).apply(void 0,r):e.apply(void 0,r)}return e}function vf(e){for(var t=[],n=function(e){for(var t=[],n="",r=!1,o=!1,i=0,a=e.length,u=0;u<a;u+=1){var s=e[u];if("'"!==s||o)if('"'!==s||r){if(!r&&!o){if("("===s){i+=1,n+=s;continue}if(")"===s&&i>0){i-=1,n+=s;continue}if(";"===s&&0===i){t.push(n),n="";continue}}n+=s}else o=!o,n+=s;else r=!r,n+=s}return n&&t.push(n),t}(e||""),r=n.length,o=0;o<r;o+=1){var i=n[o],a=i.indexOf(":");if(-1!==a){var u=i.slice(0,a).trim(),s=i.slice(a+1).trim();u&&s&&t.push([u,s])}}return t}function mf(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.filter(function(e){return!!e}).reduce(function(t,n){var r=e({},t);return Object.entries(n).forEach(function(e){var t=i(e,2),n=t[0],a=t[1];if("__proto__"!==n)if(r[n])if("class"===n){var u=a?String(a).split(" "):[],s=r[n]?r[n].split(" "):[],l=u.filter(function(e){return!s.includes(e)});r[n]=[].concat(o(s),o(l)).join(" ")}else if("style"===n){var c=new Map([].concat(o(vf(r[n])),o(vf(a))));r[n]=Array.from(c.entries()).map(function(e){var t=i(e,2),n=t[0],r=t[1];return"".concat(n,": ").concat(r)}).join("; ")}else r[n]=a;else r[n]=a;else Object.defineProperty(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0})}),r},{})}function gf(e,t){return t.filter(function(t){return t.type===e.type.name}).filter(function(e){return e.attribute.rendered}).map(function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:S({},t.name,e.attrs[t.name])}).reduce(function(e,t){return mf(e,t)},{})}function Df(t,n){return"style"in t?t:e(e({},t),{},{getAttrs:function(r){var o=t.getAttrs?t.getAttrs(r):t.attrs;if(!1===o)return!1;var i=n.reduce(function(t,n){var o=n.attribute.parseHTML?n.attribute.parseHTML(r):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(r.getAttribute(n.name));return null==o?t:e(e({},t),{},S({},n.name,o))},{});return e(e({},o),i)}})}function yf(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=i(e,2),n=t[0],r=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(r))&&null!=r}))}function kf(e){var t,n,r={};return!(null==e||null===(t=e.attribute)||void 0===t?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),void 0!==(null==e||null===(n=e.attribute)||void 0===n?void 0:n.validate)&&(r.validate=e.attribute.validate),[e.name,r]}function Ef(t,n){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ff(t),i=df(t),a=i.nodeExtensions,u=i.markExtensions;return{topNode:null===(r=a.find(function(e){return tf(e,"topNode")}))||void 0===r?void 0:r.name,nodes:Object.fromEntries(a.map(function(r){var i=o.filter(function(e){return e.type===r.name}),a={name:r.name,options:r.options,storage:r.storage,editor:n},u=yf(e(e({},t.reduce(function(t,n){var o=tf(n,"extendNodeSchema",a);return e(e({},t),o?o(r):{})},{})),{},{content:pf(tf(r,"content",a)),marks:pf(tf(r,"marks",a)),group:pf(tf(r,"group",a)),inline:pf(tf(r,"inline",a)),atom:pf(tf(r,"atom",a)),selectable:pf(tf(r,"selectable",a)),draggable:pf(tf(r,"draggable",a)),code:pf(tf(r,"code",a)),whitespace:pf(tf(r,"whitespace",a)),linebreakReplacement:pf(tf(r,"linebreakReplacement",a)),defining:pf(tf(r,"defining",a)),isolating:pf(tf(r,"isolating",a)),attrs:Object.fromEntries(i.map(kf))})),s=pf(tf(r,"parseHTML",a));s&&(u.parseDOM=s.map(function(e){return Df(e,i)}));var l=tf(r,"renderHTML",a);l&&(u.toDOM=function(e){return l({node:e,HTMLAttributes:gf(e,i)})});var c=tf(r,"renderText",a);return c&&(u.toText=c),[r.name,u]})),marks:Object.fromEntries(u.map(function(r){var i=o.filter(function(e){return e.type===r.name}),a={name:r.name,options:r.options,storage:r.storage,editor:n},u=yf(e(e({},t.reduce(function(t,n){var o=tf(n,"extendMarkSchema",a);return e(e({},t),o?o(r):{})},{})),{},{inclusive:pf(tf(r,"inclusive",a)),excludes:pf(tf(r,"excludes",a)),group:pf(tf(r,"group",a)),spanning:pf(tf(r,"spanning",a)),code:pf(tf(r,"code",a)),attrs:Object.fromEntries(i.map(kf))})),s=pf(tf(r,"parseHTML",a));s&&(u.parseDOM=s.map(function(e){return Df(e,i)}));var l=tf(r,"renderHTML",a);return l&&(u.toDOM=function(e){return l({mark:e,HTMLAttributes:gf(e,i)})}),[r.name,u]}))}}function Ff(e,t,n){if(void 0===n)return new Oo(Ef(e,t));var r=cf(e.filter(function(e){return"extension"!==e.type}).map(function(e){return e.name}));if(r.length)throw new RangeError("Duplicate local schema types: ".concat(r.join(", ")));var o=new Oo(n),i=Ef(e,t,of(ff(e),o));return new Oo(function(e,t){lf(e.nodes,t.nodes,"node"),lf(e.marks,t.marks,"mark");var n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach(function(t,r){n=n.update(t,sf(t,e.nodes[t],r,af))}),t.spec.marks.forEach(function(t,n){r=r.update(t,sf(t,e.marks[t],n,uf))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}(i,o))}function bf(e){return e.sort(function(e,t){var n=tf(e,"priority")||100,r=tf(t,"priority")||100;return n>r?-1:n<r?1:0})}function Cf(e){var t=bf(nf(e)),n=cf(t.map(function(e){return e.name}));return n.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(n.map(function(e){return"'".concat(e,"'")}).join(", "),"]. This can lead to issues.")),t}function wf(e,t){return Ff(Cf(e),t)}function Af(e,t){var n=wf(t);return rf(po.fromJSON(n,e).content,n)}function xf(e,t,n){var r=t.from,o=t.to,i=n||{},a=i.blockSeparator,u=void 0===a?"\n\n":a,s=i.textSerializers,l=void 0===s?{}:s,c="";return e.nodesBetween(r,o,function(e,n,i,a){e.isBlock&&n>r&&(c+=u);var s,d=null==l?void 0:l[e.type.name];if(d)return i&&(c+=d({node:e,pos:n,parent:i,index:a,range:t})),!1;e.isText&&(c+=null==e||null===(s=e.text)||void 0===s?void 0:s.slice(Math.max(r,n)-n,o-n))}),c}function Sf(e){return Object.fromEntries(Object.entries(e.nodes).filter(function(e){return i(e,2)[1].spec.toText}).map(function(e){var t=i(e,2);return[t[0],t[1].spec.toText]}))}function Bf(t,n){var r=qd("string"==typeof n?n:n.name,t.schema);return"node"===r?function(t,n){var r=_c(n,t.schema),o=t.selection,i=o.from,a=o.to,u=[];t.doc.nodesBetween(i,a,function(e){u.push(e)});var s=u.reverse().find(function(e){return e.type.name===r.name});return s?e({},s.attrs):{}}(t,n):"mark"===r?Zd(t,n):{}}function Tf(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JSON.stringify,n={};return e.filter(function(e){var r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter(function(e,n){return!t.filter(function(e,t){return t!==n}).some(function(t){return e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to})})}function Mf(e){var t=e.mapping,n=e.steps,r=[];return t.maps.forEach(function(e,o){var i=[];if(e.ranges.length)e.forEach(function(e,t){i.push({from:e,to:t})});else{var a=n[o],u=a.from,s=a.to;if(void 0===u||void 0===s)return;i.push({from:u,to:s})}i.forEach(function(e){var n=e.from,i=e.to,a=t.slice(o).map(n,-1),u=t.slice(o).map(i),s=t.invert().map(a,-1),l=t.invert().map(u);r.push({oldRange:{from:s,to:l},newRange:{from:a,to:u}})})}),Tf(r)}function Nf(t,n,r){var i=[];return t===n?r.resolve(t).marks().forEach(function(n){var o=rd(r.resolve(t),n.type);o&&i.push(e({mark:n},o))}):r.nodesBetween(t,n,function(e,t){e&&void 0!==(null==e?void 0:e.nodeSize)&&i.push.apply(i,o(e.marks.map(function(n){return{from:t,to:t+e.nodeSize,mark:n}})))}),i}function Rf(e,t){return t.nodes[e]||t.marks[e]||null}function Of(e,t,n){return Object.fromEntries(Object.entries(n).filter(function(n){var r=i(n,1)[0],o=e.find(function(e){return e.type===t&&e.name===r});return!!o&&o.attribute.keepOnSplit}))}function If(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.empty,a=r.ranges,u=t?od(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter(function(e){return!u||u.name===e.type.name}).find(function(e){return ed(e.attrs,n,{strict:!1})});var s=0,l=[];if(a.forEach(function(t){var n=t.$from,r=t.$to,i=n.pos,a=r.pos;e.doc.nodesBetween(i,a,function(e,t){if(u&&e.inlineContent&&!e.type.allowsMarkType(u))return!1;if(e.isText||e.marks.length){var n=Math.max(i,t),r=Math.min(a,t+e.nodeSize);s+=r-n,l.push.apply(l,o(e.marks.map(function(e){return{mark:e,from:n,to:r}})))}})}),0===s)return!1;var c=l.filter(function(e){return!u||u.name===e.mark.type.name}).filter(function(e){return ed(e.mark.attrs,n,{strict:!1})}).reduce(function(e,t){return e+t.to-t.from},0),d=l.filter(function(e){return!u||e.mark.type!==u&&e.mark.type.excludes(u)}).reduce(function(e,t){return e+t.to-t.from},0);return(c>0?c+d:c)>=s}function Pf(e,t){return Array.isArray(t)?t.some(function(t){return("string"==typeof t?t:t.name)===e.name}):t}function Lf(e,t){var n=df(t).nodeExtensions.find(function(t){return t.name===e});if(!n)return!1;var r=pf(tf(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function zf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.checkChildren,r=void 0===n||n,o=t.ignoreWhitespace,i=void 0!==o&&o;if(i){if("hardBreak"===e.type.name)return!0;var a;if(e.isText)return!/\S/.test(null!==(a=e.text)&&void 0!==a?a:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(r){var u=!0;return e.content.forEach(function(e){!1!==u&&(zf(e,{ignoreWhitespace:i,checkChildren:r})||(u=!1))}),u}return!1}function $f(e){return e instanceof Gi}function qf(e){if(null===e||"object"!==k(e))return!1;var t=e;if(!function(e){if(null===e||"object"!==k(e))return!1;var t=e;return"function"==typeof t.apply&&"function"==typeof t.getMap&&"function"==typeof t.invert&&"function"==typeof t.map&&"function"==typeof t.merge&&"function"==typeof t.toJSON}(t))return!1;var n=t.toJSON();return null!==n&&"object"===k(n)&&"replace"===n.stepType}var jf=function(){function e(t){M(this,e),this.position=t}return x(e,[{key:"toJSON",value:function(){return{position:this.position}}}],[{key:"fromJSON",value:function(t){return new e(t.position)}}])}();function Hf(e,t){var n=t.mapping.mapResult(e.position);return{position:new jf(n.pos),mapResult:n}}function Vf(e){return new jf(e)}var Uf=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=r.tr,i=r.state,a=r.dispatch,u=o.selection,s=u.empty,l=u.ranges,c=od(t,i.schema);if(a)if(s){var d=Zd(i,c);o.addStoredMark(c.create(e(e({},d),n)))}else l.forEach(function(t){var r=t.$from.pos,a=t.$to.pos;i.doc.nodesBetween(r,a,function(t,i){var u=Math.max(i,r),s=Math.min(i+t.nodeSize,a);t.marks.find(function(e){return e.type===c})?t.marks.forEach(function(t){c===t.type&&o.addMark(u,s,c.create(e(e({},t.attrs),n)))}):o.addMark(u,s,c.create(n))})});return function(e,t,n){var r=t.selection,o=null;if(ud(r)&&(o=r.$cursor),o){var i,a=null!==(i=e.storedMarks)&&void 0!==i?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(function(e){return e.type.excludes(n)}))}return r.ranges.some(function(t){var r=t.$from,o=t.$to,i=0===r.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(r.pos,o.pos,function(e,t,r){if(i)return!1;if(e.isInline){var o=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(function(e){return e.type.excludes(n)});i=o&&a}return!i}),i})}(i,o,c)}},Wf=function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},_f=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o,i=r.state,a=r.dispatch,u=r.chain,s=_c(t,i.schema);return i.selection.$anchor.sameParent(i.selection.$head)&&(o=i.selection.$anchor.parent.attrs),s.isTextblock?u().command(function(t){var r=t.commands;return!!Ia(s,e(e({},o),n))(i)||r.clearNodes()}).command(function(t){var r=t.state;return Ia(s,e(e({},o),n))(r,a)}).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},Kf=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,o=sd(e,0,r.content.size),i=Gi.create(r,o);n.setSelection(i)}return!0}},Jf=function(t,n){return function(r){var o,i,a=r.tr,u=r.state,s=r.dispatch,l=u.selection;return"number"==typeof n?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=l.from,i=l.to),s&&a.doc.nodesBetween(o,i,function(n,r){n.isText||a.setNodeMarkup(r,void 0,e(e({},n.attrs),{},{dir:t}))}),!0}},Qf=function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,o="number"==typeof e?{from:e,to:e}:e,i=o.from,a=o.to,u=Ji.atStart(r).from,s=Ji.atEnd(r).to,l=sd(i,u,s),c=sd(a,u,s),d=Ji.create(r,l,c);n.setSelection(d)}return!0}},Gf=function(e){return function(t){var n,r=t.state,o=t.dispatch,i=_c(e,r.schema);return(n=i,function(e,t){var r=e.selection,o=r.$from,i=r.$to,a=o.blockRange(i,function(e){return e.childCount>0&&e.firstChild.type==n});if(!a)return!1;var u=a.startIndex;if(0==u)return!1;var s=a.parent,l=s.child(u-1);if(l.type!=n)return!1;if(t){var c=l.lastChild&&l.lastChild.type==s.type,d=Vr.from(c?n.create():null),f=new Qr(Vr.from(n.create(null,Vr.from(s.type.create(null,d)))),c?3:1,0),h=a.start,p=a.end;t(e.tr.step(new hi(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0})(r,o)}};function Xf(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var r=n.filter(function(e){return null==t?void 0:t.includes(e.type.name)});e.tr.ensureMarks(r)}}var Zf=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,r=e.state,o=e.dispatch,i=e.editor,a=n.selection,u=n.doc,s=a.$from,l=a.$to,c=Of(i.extensionManager.attributes,s.node().type.name,s.node().attrs);if(a instanceof Gi&&a.node.isBlock)return!(!s.parentOffset||!Fi(u,s.pos))&&(o&&(t&&Xf(r,i.extensionManager.splittableMarks),n.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;var d=l.parentOffset===l.parent.content.size,f=0===s.depth?void 0:Fd(s.node(-1).contentMatchAt(s.indexAfter(-1))),h=d&&f?[{type:f,attrs:c}]:void 0,p=a instanceof Ji&&!a.empty?ua.create({doc:n.doc,selection:a}).tr.deleteSelection():null,v=p?p.doc:n.doc,m=p?p.mapping.map(s.pos):s.pos,g=Fi(v,m,1,h);if(h||g||!Fi(v,m,1,f?[{type:f}]:void 0)||(g=!0,h=f?[{type:f,attrs:c}]:void 0),o){if(g){var D=n.steps.length;if(a instanceof Ji&&n.deleteSelection(),n.split(n.mapping.slice(D).map(s.pos),1,h),f&&!d&&!s.parentOffset&&s.parent.type!==f){var y=n.mapping.slice(D).map(s.before()),k=n.doc.resolve(y);s.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&n.setNodeMarkup(n.mapping.slice(D).map(s.before()),f)}}t&&Xf(r,i.extensionManager.splittableMarks),n.scrollIntoView()}return g}},Yf=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=r.tr,i=r.state,a=r.dispatch,u=r.editor,s=_c(t,i.schema),l=i.selection,c=l.$from,d=l.$to,f=i.selection.node;if(f&&f.isBlock||c.depth<2||!c.sameParent(d))return!1;var h=c.node(-1);if(h.type!==s)return!1;var p=u.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==s||c.index(-2)!==c.node(-2).childCount-1)return!1;if(a){for(var v,m=Vr.empty,g=c.index(-1)?1:c.index(-2)?2:3,D=c.depth-g;D>=c.depth-3;D-=1)m=Vr.from(c.node(D).copy(m));var y=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,k=e(e({},Of(p,c.node().type.name,c.node().attrs)),n),E=(null===(v=s.contentMatch.defaultType)||void 0===v?void 0:v.createAndFill(k))||void 0;m=m.append(Vr.from(s.createAndFill(null,E)||void 0));var F=c.before(c.depth-(g-1));o.replace(F,c.after(-y),new Qr(m,4-g,0));var b=-1;o.doc.nodesBetween(F,o.doc.content.size,function(e,t){if(b>-1)return!1;e.isTextblock&&0===e.content.size&&(b=t+1)}),b>-1&&o.setSelection(Ji.near(o.doc.resolve(b))),o.scrollIntoView()}return!0}var C=d.pos===c.end()?h.contentMatchAt(0).defaultType:null,w=e(e({},Of(p,h.type.name,h.attrs)),n),A=e(e({},Of(p,c.node().type.name,c.node().attrs)),n),x=0===c.parentOffset&&0===c.index(-1),S=c.before(-1);o.delete(c.pos,d.pos);var B=x?h.attrs:w,T=C?[{type:s,attrs:B},{type:C,attrs:A}]:[{type:s,attrs:B}];if(!Fi(o.doc,c.pos,2))return!1;if(a){var M=i.selection,N=i.storedMarks,R=u.extensionManager.splittableMarks,O=N||M.$to.parentOffset&&M.$from.marks();if(o.split(c.pos,2,T).scrollIntoView(),x&&o.setNodeMarkup(S,void 0,w),!O||!a)return!0;var I=O.filter(function(e){return R.includes(e.type.name)});o.ensureMarks(I)}return!0}};function eh(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch(e){return null}}function th(e,t){if(0===e.pendingContent.length)return!0;var n=eh(t,Vr.from(e.pendingContent));return!!n&&(e.items.push(n),e.pendingContent=[],!0)}function nh(e,t,n){return(n.validContent(Vr.from([].concat(o(t.pendingContent),[e])))||!(!th(t,n)||!n.validContent(Vr.from(e))))&&(t.pendingContent.push(e),!0)}function rh(e,t,n,r){var i,a=r(e,n);if(!a)return!1;var u=eh(n.listType,Vr.from(a),e.attrs);return!!u&&(n.itemType.validContent(Vr.from([].concat(o(t.pendingContent),[u])))?(t.pendingContent.push(u),!0):!!th(t,n.itemType)&&((i=t.items).push.apply(i,o(a)),!0))}function oh(e,t,n){for(var r={items:[],pendingContent:[]},o=0;o<e.childCount;o+=1){var i=e.child(o);if(!(t.isListNode(i)?rh(i,r,t,n):nh(i,r,t.itemType)))return null}return th(r,t.itemType)?r.items:null}function ih(e,t){for(var n=[],r=0;r<e.childCount;r+=1){var i=oh(e.child(r),t,ih);if(!i)return null;n.push.apply(n,o(i))}return n}function ah(e,t){var n=null;return e.descendants(function(e,r){return e!==t||(n=r,!1)}),n}function uh(e){return e&&"1"!==e?e:null}function sh(e,t){return uh(e)===uh(t)}var lh=function(e,t){var n=ef(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;var o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!bi(e.doc,n.pos)||(!sh(n.node.attrs.type,null==o?void 0:o.attrs.type)||(e.join(n.pos),!0))},ch=function(e,t){var n=ef(function(e){return e.type===t})(e.selection);if(!n)return!0;var r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;var o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!bi(e.doc,r)||(!sh(n.node.attrs.type,null==o?void 0:o.attrs.type)||(e.join(r),!0))};var dh=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(o){var i=o.editor,a=o.tr,u=o.state,s=o.dispatch,l=o.chain,c=o.commands,d=o.can,f=i.extensionManager,h=f.extensions,p=f.splittableMarks,v=_c(e,u.schema),m=_c(t,u.schema),g=u.selection,D=u.storedMarks,y=g.$from,k=g.$to,E=y.blockRange(k),F=D||g.$to.parentOffset&&g.$from.marks();if(!E)return!1;var b=ef(function(e){return Lf(e.type.name,h)})(g),C=0===g.from&&g.to===u.doc.content.size,w=u.doc.content.content,A=1===w.length?w[0]:null,x=C&&A&&Lf(A.type.name,h)?{node:A,pos:0,depth:0}:null,S=null!=b?b:x,B=!!x;if((!!b&&E.depth>=1&&E.depth-b.depth<=1||B)&&S){if(S.node.type===v)return C&&B?l().command(function(e){var t=e.tr,n=e.dispatch,r=function(e){var t=e.doc,n=t.firstChild;if(!n)return null;var r=t.resolve(1),o=t.resolve(n.nodeSize-1);return Ji.between(r,o)}(t);return!!r&&(t.setSelection(r),n&&n(t),!0)}).liftListItem(m).run():c.liftListItem(m);if(Lf(S.node.type.name,h)&&v.validContent(S.node.content))return l().command(function(){return a.setNodeMarkup(S.pos,v),!0}).command(function(){return lh(a,v)}).command(function(){return ch(a,v)}).run();if(Lf(S.node.type.name,h)){var T,M=null===(T=S.node.firstChild)||void 0===T?void 0:T.type;if(M&&M!==m){var N=ih(S.node,{listType:v,itemType:m,isListNode:function(e){return Lf(e.type.name,h)}}),R=N?Vr.from(N):null;return!(!R||!v.validContent(R))&&l().command(function(){var e,t=a.selection,n=t.$anchor,o=t.$head,i=n.parent,u=o.parent,s=n.parentOffset,l=o.parentOffset;try{e=v.create(r,R)}catch(e){return!1}if(a.replaceWith(S.pos,S.pos+S.node.nodeSize,e),i.inlineContent&&u.inlineContent){var c=ah(e,i),d=ah(e,u);if(null!==c&&null!==d){var f=S.pos+c+2+s,h=S.pos+d+2+l;a.setSelection(Ji.create(a.doc,f,h))}}return!0}).command(function(){return lh(a,v)}).command(function(){return ch(a,v)}).run()}}}return n&&F&&s?l().command(function(){var e=d().wrapInList(v,r),t=F.filter(function(e){return p.includes(e.type.name)});return a.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(v,r).command(function(){return lh(a,v)}).command(function(){return ch(a,v)}).run():l().command(function(){return!!d().wrapInList(v,r)||c.clearNodes()}).wrapInList(v,r).command(function(){return lh(a,v)}).command(function(){return ch(a,v)}).run()}},fh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var o=r.state,i=r.commands,a=n.extendEmptyMarkRange,u=void 0!==a&&a,s=od(e,o.schema);return If(o,s,t)?i.unsetMark(s,{extendEmptyMarkRange:u}):i.setMark(s,t)}},hh=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(o){var i,a=o.state,u=o.commands,s=_c(t,a.schema),l=_c(n,a.schema),c=Id(a,s,r);return a.selection.$anchor.sameParent(a.selection.$head)&&(i=a.selection.$anchor.parent.attrs),c?u.setNode(l,i):u.setNode(s,e(e({},i),r))}},ph=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.commands,i=_c(e,r.schema);return Id(r,i,t)?o.lift(i):o.wrapIn(i,t)}},vh=function(){return function(e){for(var t=e.state,n=e.dispatch,r=t.plugins,o=0;o<r.length;o+=1){var i=r[o],a=void 0;if(i.spec.isInputRules&&(a=i.getState(t))){if(n){for(var u=t.tr,s=a.transform,l=s.steps.length-1;l>=0;l-=1)u.step(s.steps[l].invert(s.docs[l]));if(a.text){var c=u.doc.resolve(a.from).marks();u.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else u.delete(a.from,a.to)}return!0}}return!1}},mh=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n=t.tr,r=t.dispatch,o=t.editor,i=e.ignoreClearable,a=void 0!==i&&i,u=n.selection,s=u.empty,l=u.ranges;if(s)return!0;var c=o.extensionManager.nonClearableMarks;if(r){var d=Object.values(o.schema.marks).filter(function(e){return a||!c.includes(e.name)});l.forEach(function(e){var t,r=j(d);try{for(r.s();!(t=r.n()).done;){var o=t.value;n.removeMark(e.$from.pos,e.$to.pos,o)}}catch(e){r.e(e)}finally{r.f()}})}return!0}},gh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,o=n.state,i=n.dispatch,a=t.extendEmptyMarkRange,u=void 0!==a&&a,s=r.selection,l=od(e,o.schema),c=s.$from,d=s.empty,f=s.ranges;if(!i)return!0;if(d&&u){var h,p=s.from,v=s.to,m=rd(c,l,null===(h=c.marks().find(function(e){return e.type===l}))||void 0===h?void 0:h.attrs);m&&(p=m.from,v=m.to),r.removeMark(p,v,l)}else f.forEach(function(e){r.removeMark(e.$from.pos,e.$to.pos,l)});return r.removeStoredMark(l),!0}},Dh=function(t){return function(n){var r,o,i=n.tr,a=n.state,u=n.dispatch,s=a.selection;return"number"==typeof t?(r=t,o=t):t&&"from"in t&&"to"in t?(r=t.from,o=t.to):(r=s.from,o=s.to),u&&i.doc.nodesBetween(r,o,function(t,n){if(!t.isText){var r=e({},t.attrs);delete r.dir,i.setNodeMarkup(n,void 0,r)}}),!0}},yh=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=r.tr,i=r.state,a=r.dispatch,u=null,s=null,l=qd("string"==typeof t?t:t.name,i.schema);if(!l)return!1;"node"===l&&(u=_c(t,i.schema)),"mark"===l&&(s=od(t,i.schema));var c=!1;return o.selection.ranges.forEach(function(t){var r,l,d,f,h=t.$from.pos,p=t.$to.pos;o.selection.empty?i.doc.nodesBetween(h,p,function(e,t){u&&u===e.type&&(c=!0,d=Math.max(t,h),f=Math.min(t+e.nodeSize,p),r=t,l=e)}):i.doc.nodesBetween(h,p,function(t,i){i<h&&u&&u===t.type&&(c=!0,d=Math.max(i,h),f=Math.min(i+t.nodeSize,p),r=i,l=t),i>=h&&i<=p&&(u&&u===t.type&&(c=!0,a&&o.setNodeMarkup(i,void 0,e(e({},t.attrs),n))),s&&t.marks.length&&t.marks.forEach(function(r){if(s===r.type&&(c=!0,a)){var u=Math.max(i,h),l=Math.min(i+t.nodeSize,p);o.addMark(u,l,s.create(e(e({},r.attrs),n)))}}))}),l&&(void 0!==r&&a&&o.setNodeMarkup(r,void 0,e(e({},l.attrs),n)),s&&l.marks.length&&l.marks.forEach(function(t){s===t.type&&a&&o.addMark(d,f,s.create(e(e({},t.attrs),n)))}))}),c}},kh=new fa("__tiptap_decorations__"),Eh=function(e){return function(t){var n=t.tr;return t.dispatch&&n.setMeta(kh,{type:"force",name:e}),!0}},Fh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var o=n.selection,i=o.$from,a=o.$to,u=i.blockRange(a),s=u&&Di(u,e,t);return!!s&&(r&&r(n.tr.wrap(u,s).scrollIntoView()),!0)}}(_c(e,r.schema),t)(r,o)}},bh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.dispatch;return La(_c(e,r.schema),t)(r,o)}},Ch=Lr({blur:function(){return $c},clearContent:function(){return qc},clearNodes:function(){return jc},command:function(){return Hc},createParagraphNear:function(){return Vc},cut:function(){return Uc},deleteCurrentNode:function(){return Wc},deleteNode:function(){return Kc},deleteRange:function(){return Jc},deleteSelection:function(){return Gc},enter:function(){return Xc},exitCode:function(){return Zc},extendMarkRange:function(){return id},first:function(){return ad},focus:function(){return fd},forEach:function(){return hd},insertContent:function(){return pd},insertContentAt:function(){return Ed},insertDefaultBlock:function(){return bd},joinBackward:function(){return Ad},joinDown:function(){return wd},joinForward:function(){return xd},joinItemBackward:function(){return Bd},joinItemForward:function(){return Td},joinTextblockBackward:function(){return Md},joinTextblockForward:function(){return Nd},joinUp:function(){return Cd},keyboardShortcut:function(){return Od},lift:function(){return Pd},liftEmptyBlock:function(){return Ld},liftListItem:function(){return zd},newlineInCode:function(){return $d},resetAttributes:function(){return Hd},scrollIntoView:function(){return Vd},selectAll:function(){return Ud},selectNodeBackward:function(){return Wd},selectNodeForward:function(){return _d},selectParentNode:function(){return Kd},selectTextblockEnd:function(){return Jd},selectTextblockStart:function(){return Qd},setContent:function(){return Xd},setMark:function(){return Uf},setMeta:function(){return Wf},setNode:function(){return _f},setNodeSelection:function(){return Kf},setTextDirection:function(){return Jf},setTextSelection:function(){return Qf},sinkListItem:function(){return Gf},splitBlock:function(){return Zf},splitListItem:function(){return Yf},toggleList:function(){return dh},toggleMark:function(){return fh},toggleNode:function(){return hh},toggleWrap:function(){return ph},undoInputRule:function(){return vh},unsetAllMarks:function(){return mh},unsetMark:function(){return gh},unsetTextDirection:function(){return Dh},updateAttributes:function(){return yh},updateDecorations:function(){return Eh},wrapIn:function(){return Fh},wrapInList:function(){return bh}}),wh=new WeakMap;var Ah=function(){return x(function e(){M(this,e),this.callbacks={}},[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=this.callbacks[e];return i&&i.forEach(function(e){return e.apply(t,r)}),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(function(e){return e!==t}):delete this.callbacks[e]),this}},{key:"once",value:function(e,t){var n=this,r=function(){n.off(e,r);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];t.apply(n,i)};return this.on(e,r)}},{key:"removeAllListeners",value:function(){this.callbacks={}}}])}(),xh="undefined"!=typeof process&&!1;function Sh(e){return"widget"===e.kind}function Bh(e,t){var n,r=[],o=new Set,i=j(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;"widget"===a.kind&&Sh(a)&&o.add(a.key),r.push(a.toPMDecoration(t))}}catch(e){i.e(e)}finally{i.f()}return{decorations:r,widgetKeys:o}}function Th(e){var t=e.position,n=e.from,r=e.to,o=e.docSize;return!(t<n)&&(t<r||t===r&&r===o)}function Mh(e){var t,n=null===(t=e.spec)||void 0===t?void 0:t.key;return"string"==typeof n?n:void 0}function Nh(e){return"attr"===e.jsonID}function Rh(e,t){for(var n=null,r=0,o=0,i=0;i<e.childCount&&!(o>t.to);i+=1){var a=o+e.child(i).nodeSize;a>=t.from&&(null===n&&(n=o),r=a),o=a}return null===n?null:{from:n,to:r}}function Oh(t,n){if(t.steps.some(function(e){return!function(e){var t=!1;if(e.getMap().forEach(function(){t=!0}),t||Nh(e))return!0;var n=e;return"number"==typeof n.from&&"number"==typeof n.to}(e)}))return{type:"full"};var r=Mf(t).map(function(e){return e.newRange});t.steps.forEach(function(e,n){if(Nh(e)){var o=t.mapping.slice(n);r.push({from:o.map(e.pos,-1),to:o.map(e.pos+1)})}});var o,i=[],a=j(r);try{for(a.s();!(o=a.n()).done;){var u=Rh(n,o.value);u&&i.push(u)}}catch(e){a.e(e)}finally{a.f()}i.sort(function(e,t){return e.from-t.from});for(var s=[],l=0,c=i;l<c.length;l++){var d=c[l],f=s[s.length-1];f&&d.from<=f.to?f.to=Math.max(f.to,d.to):s.push(e({},d))}return{type:"ranges",ranges:s}}function Ih(e,t,n,r){return e.map(t,n,{onRemove:function(e){var t=null==e?void 0:e.key;"string"==typeof t&&r.delete(t)}})}function Ph(e,t,n){var r,o,i=null!==(r=t.decorationSetsByExtension[e])&&void 0!==r?r:Bl.empty,a=new Set(null!==(o=t.widgetKeysByExtension[e])&&void 0!==o?o:[]);return{set:Ih(i,n.mapping,n.doc,a),widgetKeys:a}}function Lh(e,t){var n=Object.values(t).flatMap(function(e){return e.find()});return Bl.create(e,n)}function zh(e){for(var t=new Set,n=0,r=Object.values(e);n<r.length;n++){var o,i=r[n],a=j(i);try{for(a.s();!(o=a.n()).done;){var u=o.value;t.add(u)}}catch(e){a.e(e)}finally{a.f()}}return t}function $h(e,t,n){return!!n||"manual"!==e.update&&(e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged)}var qh=new Set,jh=function(){return x(function e(t){var n=this;M(this,e),this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=function(e){var t=e.nextState,r=kh.getState(t);r&&n.warnDuplicateWidgetKeys(r)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(function(e){return function(e,t){var n;switch(null!==(n=t.update)&&void 0!==n?n:"document"){case"document":if(t.createInRange)throw new Error('[tiptap error]: Extension "'.concat(e,'" provides createInRange() but does not use the "changedRanges" decoration update strategy.'));return;case"changedRanges":if(!t.createInRange)throw new Error('[tiptap error]: Extension "'.concat(e,'" uses the "changedRanges" decoration update strategy but does not provide createInRange().'));return;case"manual":if(t.createInRange)throw new Error('[tiptap error]: Extension "'.concat(e,'" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.'));if(t.shouldUpdate)throw new Error('[tiptap error]: Extension "'.concat(e,'" cannot combine the "manual" decoration update strategy with shouldUpdate().'));return;default:throw new Error('[tiptap error]: Extension "'.concat(e,'" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".'))}}(e.name,e.spec)}),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)},[{key:"destroy",value:function(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}},{key:"liveWidgetKeys",value:function(){var e,t;return null!==(e=null===(t=kh.getState(this.editor.state))||void 0===t?void 0:t.widgetKeys)&&void 0!==e?e:qh}},{key:"mountedView",get:function(){return this.editor.isDestroyed?null:this.editor.view}},{key:"resolveEntries",value:function(e){var t,n=[],r=j(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=o.name,a=(0,o.addDecorations)();a&&n.push({name:i,spec:a})}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"createPlugin",value:function(){var e=this,t=this.editor,n=this.entries;return new la({key:kh,state:{init:function(t,r){var o,i={},a={},u=j(n);try{for(u.s();!(o=u.n()).done;){var s=o.value,l=s.name,c=s.spec,d=e.buildFullSet(l,c,r),f=d.set,h=d.widgetKeys;i[l]=f,a[l]=h}}catch(e){u.e(e)}finally{u.f()}var p={decorationSetsByExtension:i,widgetKeysByExtension:a,mergedDecorationSet:e.buildMergedSet(r.doc,i),widgetKeys:zh(a)};return e.warnDuplicateWidgetKeys(p),p},apply:function(r,o,i,a){var u=r.getMeta(kh),s="force"===(null==u?void 0:u.type)&&!u.name,l="force"===(null==u?void 0:u.type)?u.name:void 0,c={},d={},f=new Set;return function(e,t){var n;wh.set(e,(null!==(n=wh.get(e))&&void 0!==n?n:0)+1);try{return t()}finally{var r,o=(null!==(r=wh.get(e))&&void 0!==r?r:1)-1;o>0?wh.set(e,o):wh.delete(e)}}(t,function(){var u,h=j(n);try{for(h.s();!(u=h.n()).done;){var p=u.value,v=p.name,m=p.spec,g=s||l===v;if($h(m,{editor:t,tr:r,oldState:i,newState:a},g))if("changedRanges"===m.update&&r.docChanged&&!g){var D=e.applyChangedRangesRecompute(v,m,o,r,a);c[v]=D.set,d[v]=D.widgetKeys,f.add(v)}else{var y=e.buildFullSet(v,m,a),k=y.set,E=y.widgetKeys;c[v]=k,d[v]=E,f.add(v)}else{var F=Ph(v,o,r);c[v]=F.set,d[v]=F.widgetKeys}}}catch(e){h.e(e)}finally{h.f()}}),0!==f.size||r.docChanged?{decorationSetsByExtension:c,widgetKeysByExtension:d,mergedDecorationSet:e.mergeAfterApply({entries:n,previous:o,tr:r,decorationSetsByExtension:c,recomputedNames:f}),widgetKeys:zh(d)}:o}},props:{decorations:function(e){var t,n;return null!==(t=null===(n=kh.getState(e))||void 0===n?void 0:n.mergedDecorationSet)&&void 0!==t?t:Bl.empty}}})}},{key:"applyChangedRangesRecompute",value:function(e,t,n,r,o){var i=Oh(r,o.doc);return"full"===i.type?this.buildFullSet(e,t,o):this.rebuildRanges(e,t,n,r,o,i.ranges)}},{key:"rebuildRanges",value:function(e,t,n,r,o,i){var a,u,s,l=this,c=null!==(a=n.decorationSetsByExtension[e])&&void 0!==a?a:Bl.empty,d=new Set(null!==(u=n.widgetKeysByExtension[e])&&void 0!==u?u:[]),f=Ih(c,r.mapping,r.doc,d),h=o.doc.content.size,p=j(i);try{var v=function(){var n,r=s.value,i=r.from,a=r.to,u=f.find(i,a).filter(function(e){return Th({position:e.from,from:i,to:a,docSize:h})}),c=j(u);try{for(c.s();!(n=c.n()).done;){var p=Mh(n.value);p&&d.delete(p)}}catch(e){c.e(e)}finally{c.f()}f=f.remove(u);var v=Bh(function(e){var t=e.decorations,n=e.from,r=e.to,o=e.docSize,i=e.extensionName,a=e.warnedExtensions;return t.filter(function(e){return!!Th({position:e.anchor,from:n,to:r,docSize:o})||(e.anchor===r||a.has(i)||(a.add(i),console.warn('[tiptap warn]: Extension "'.concat(i,'" returned a decoration outside the requested range [').concat(n,", ").concat(r,"). It was ignored."))),!1)})}({decorations:l.runCreate(e,"createInRange",function(){return t.createInRange({editor:l.editor,state:o,view:l.mountedView,from:i,to:a})}),from:i,to:a,docSize:h,extensionName:e,warnedExtensions:l.warnedOutOfRangeExtensions}),e),m=v.decorations,g=v.widgetKeys;f=f.add(o.doc,m);var D,y=j(g);try{for(y.s();!(D=y.n()).done;){var k=D.value;d.add(k)}}catch(e){y.e(e)}finally{y.f()}};for(p.s();!(s=p.n()).done;)v()}catch(e){p.e(e)}finally{p.f()}return{set:f,widgetKeys:d}}},{key:"buildFullSet",value:function(e,t,n){var r=this,o=this.runCreate(e,"create",function(){return t.create({editor:r.editor,state:n,view:r.mountedView})});return function(e,t,n){var r=Bh(t,n),o=r.decorations,i=r.widgetKeys;return{set:Bl.create(e,o),widgetKeys:i}}(n.doc,o,e)}},{key:"runCreate",value:function(e,t,n){try{return n()}catch(n){return console.error('[tiptap error]: Extension "'.concat(e,'" threw in `addDecorations().').concat(t,"()`. Its decorations were dropped for this update."),n),[]}}},{key:"warnDuplicateWidgetKeys",value:function(e){if(xh)if(0!==e.widgetKeys.size){var t,n=function(e){var t,n=new Map,r=new Map,o=j(e.find());try{for(o.s();!(t=o.n()).done;){var a,u,s,l=t.value,c=Mh(l);if(c){var d=null!==(a=l.spec.extensionName)&&void 0!==a?a:"unknown",f=null!==(u=n.get(c))&&void 0!==u?u:new Set;f.add(d),n.set(c,f),r.set(c,(null!==(s=r.get(c))&&void 0!==s?s:0)+1)}}}catch(e){o.e(e)}finally{o.f()}return Array.from(n,function(e){var t=i(e,2);return{key:t[0],extensions:t[1]}}).filter(function(e){var t,n=e.key;return(null!==(t=r.get(n))&&void 0!==t?t:0)>1})}(e.mergedDecorationSet),r=new Set(n.map(function(e){return e.key})),o=j(n);try{for(o.s();!(t=o.n()).done;){var a=t.value,u=a.key,s=a.extensions;if(!this.warnedWidgetKeys.has(u)){var l=Array.from(s).map(function(e){return'"'.concat(e,'"')}).join(", ");console.warn('[tiptap warn]: Duplicate widget decoration key "'.concat(u,'" in extension').concat(1===s.size?"":"s"," ").concat(l,". Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. `comment-${id}`)."))}}}catch(e){o.e(e)}finally{o.f()}this.warnedWidgetKeys=r}else this.warnedWidgetKeys.clear()}},{key:"buildMergedSet",value:function(e,t){var n=Object.keys(t);return 1===n.length?t[n[0]]:Lh(e,t)}},{key:"mergeAfterApply",value:function(e){var t=e.entries,n=e.previous,r=e.tr,o=e.decorationSetsByExtension,i=e.recomputedNames;return 1===t.length?o[t[0].name]:0===i.size?n.mergedDecorationSet.map(r.mapping,r.doc):Lh(r.doc,o)}}])}();function Hh(e,t){if(e===t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(function(n){return Object.prototype.hasOwnProperty.call(t,n)&&Object.is(e[n],t[n])})}var Vh={lt:"<",gt:">",quot:'"',amp:"&"};function Uh(e){return e.replace(/&(?:#(\d{1,7})|#[xX]([0-9a-fA-F]{1,6})|(lt|gt|quot|amp));/g,function(e,t,n,r){return void 0!==t?_h(Number(t)):void 0!==n?_h(parseInt(n,16)):Vh[r]})}var Wh=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function _h(e){var t;return 0===e||e>1114111||e>=55296&&e<=57343?"�":String.fromCodePoint(null!==(t=Wh.get(e))&&void 0!==t?t:e)}function Kh(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Jh(e,t,n){for(var r,o,i,a=e.split("\n"),u=[],s="",l=0,c=t.baseIndentSize||2,d=function(){var e=a[l],i=e.match(t.itemPattern);if(!i)return u.length>0?0:""===e.trim()?(l+=1,s="".concat(s).concat(e,"\n"),1):{v:void 0};var d=t.extractItemData(i),f=d.indentLevel,h=d.mainContent;s="".concat(s).concat(e,"\n");var p,v=[h];for(l+=1;l<a.length;){var m=a[l];if(""===m.trim()){var g=a.slice(l+1).findIndex(function(e){return""!==e.trim()});if(-1===g)break;if(((null===(o=a[l+1+g].match(/^(\s*)/))||void 0===o||null===(o=o[1])||void 0===o?void 0:o.length)||0)>f){v.push(m),s="".concat(s).concat(m,"\n"),l+=1;continue}break}if(!(((null===(r=m.match(/^(\s*)/))||void 0===r||null===(r=r[1])||void 0===r?void 0:r.length)||0)>f))break;v.push(m),s="".concat(s).concat(m,"\n"),l+=1}var D=v.slice(1);if(D.length>0){var y=D.map(function(e){return e.slice(f+c)}).join("\n");y.trim()&&(p=t.customNestedParser?t.customNestedParser(y):n.blockTokens(y))}var k=t.createToken(d,p);u.push(k)};l<a.length&&0!==(i=d());)if(1!==i&&i)return i.v;if(0!==u.length)return{items:u,raw:s}}function Qh(e){var t,n=0,r=j(e);try{for(r.s();!(t=r.n()).done;){n="\t"===t.value?n+4-n%4:n+1}}catch(e){r.e(e)}finally{r.f()}return n}function Gh(e,t,n,r,o){if(!e||!Array.isArray(e.content))return"";var i="function"==typeof n?n(r):n,a=V(e.content),u=a[0],s=U(a).slice(1),l="".concat(i).concat(t.renderChildren([u]));return s&&s.length>0&&s.forEach(function(e,n){var r,a,u=null!==(r=null===(a=t.renderChild)||void 0===a?void 0:a.call(t,e,n+1))&&void 0!==r?r:t.renderChildren([e]);if(null!=u){var s=function(e){if(!(null==o?void 0:o.alignNestedToPrefix))return t.indent(e);var n=t.indent(""),r=Qh(i);return(Qh(n)>=r?n:" ".repeat(r))+e},c=u.split("\n").map(function(e){return s(e||"")}).join("\n");l+="paragraph"===e.type?"\n\n".concat(c):"\n".concat(c)}}),l}function Xh(e){return"string"==typeof e.type?e.type:e.type.name}function Zh(e,t){if(e.length!==t.length)return!1;var n=Array.from({length:t.length},function(){return!1});return e.every(function(e){var r=Xh(e),o=t.findIndex(function(t,o){return!n[o]&&r===Xh(t)&&Hh(e.attrs,t.attrs)});return-1!==o&&(n[o]=!0,!0)})}function Yh(t,n){var r=e({},t);return Kh(t)&&Kh(n)&&Object.keys(n).forEach(function(e){Kh(n[e])&&Kh(t[e])?r[e]=Yh(t[e],n[e]):r[e]=n[e]}),r}var ep=x(function e(t){var n;M(this,e),this.find=t.find,this.handler=t.handler,this.undoable=null===(n=t.undoable)||void 0===n||n}),tp=function(e,t){if(Yc(t))return t.exec(e);var n=t(e);if(!n)return null;var r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function np(e){var t=e.editor,n=e.from,r=e.to,o=e.text,i=e.rule,a=e.match,u=e.plugin,s=e.insertText,l=t.view,c=function(e){var t=e.editor,n=e.from,r=e.to,o=e.text;if(!e.insertText)return{inputTransaction:null,tr:t.view.state.tr};var i=t.view.state.tr.insertText(o,n,r);return{inputTransaction:i,tr:ua.create({doc:i.doc,selection:i.selection,storedMarks:i.storedMarks}).tr}}({editor:t,from:n,to:r,text:o,insertText:s}),d=c.inputTransaction,f=c.tr,h=d?n+o.length:r,p=Lc({state:l.state,transaction:f}),v={from:n-(a[0].length-o.length),to:h},m=new zc({editor:t,state:p}),g=m.commands,D=m.chain,y=m.can;return!(null===i.handler({state:p,range:v,match:a,commands:g,chain:D,can:y})||!f.steps.length)&&(d&&(l.dispatch(d),!l.state.doc.eq(d.doc))||(function(e){e.setMeta(Mc,!0)}(f),f.setMeta("inputRule",!0),i.undoable&&f.setMeta(u,{transform:f,from:n,to:h,text:o}),l.dispatch(f)),!0)}function rp(e,t,n){var r=t[0].length-n.length;if(r<=0)return!0;var o=e.parentOffset-r;return o>=0&&e.parent.textBetween(o,e.parentOffset)===t[0].slice(0,r)}function op(e){var t,n=e.editor,r=e.from,o=e.to,i=e.text,a=e.rules,u=e.plugin,s=e.insertText,l=n.view;if(l.composing)return!1;var c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find(function(e){return e.type.spec.code})))return!1;var d,f=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,function(e,t,o,i){var a,u,s=(null===(a=(u=e.type.spec).toText)||void 0===a?void 0:a.call(u,{node:e,pos:t,parent:o,index:i}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n}(c)+i,h=j(a);try{for(h.s();!(d=h.n()).done;){var p=d.value,v=tp(f,p.find);if(v&&rp(c,v,i)&&np({editor:n,from:r,to:o,text:i,rule:p,match:v,plugin:u,insertText:s}))return!0}}catch(e){h.e(e)}finally{h.f()}return!1}var ip=function(){return x(function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};M(this,t),this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config=e(e({},this.config),n),this.name=this.config.name},[{key:"options",get:function(){return e({},pf(tf(this,"addOptions",{name:this.name})))}},{key:"storage",get:function(){return e({},pf(tf(this,"addStorage",{name:this.name,options:this.options})))}},{key:"configure",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this.extend(e(e({},this.config),{},{addOptions:function(){return Yh(t.options,n)}}));return r.name=this.name,r.parent=this.parent,this.child=null,r}},{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=new this.constructor(e(e({},this.config),t));return n.parent=this,this.child=n,n.name="name"in t?t.name:n.parent.name,n}}])}(),ap=function(){function e(){var t;M(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=N(this,e,[].concat(r))).type="mark",t}return A(e,ip),x(e,[{key:"configure",value:function(t){return H(e,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return H(e,"extend",this,3)([n])}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e("function"==typeof t?t():t)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,r=t.state.tr,o=t.state.selection.$from;if(o.pos===o.end()){var i=o.marks();if(!i.find(function(e){return(null==e?void 0:e.type.name)===n.name}))return!1;var a=i.find(function(e){return(null==e?void 0:e.type.name)===n.name});return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}}])}(),up=x(function e(t){M(this,e),this.find=t.find,this.handler=t.handler});function sp(e){var t=e.editor,n=e.state,r=e.from,i=e.to,a=e.rule,u=e.pasteEvent,s=e.dropEvent,l=new zc({editor:t,state:n}),c=l.commands,d=l.chain,f=l.can,h=[];return n.doc.nodesBetween(r,i,function(e,t){var l,p,v,m;if(!(null===(l=e.type)||void 0===l||null===(l=l.spec)||void 0===l?void 0:l.code)&&(e.isText||e.isTextblock||e.isInline)){var g=null!==(p=null!==(v=null===(m=e.content)||void 0===m?void 0:m.size)&&void 0!==v?v:e.nodeSize)&&void 0!==p?p:0,D=Math.max(r,t),y=Math.min(i,t+g);if(!(D>=y))(function(e,t,n){if(Yc(t))return o(e.matchAll(t));var r=t(e,n);return r?r.map(function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(D-t,y-t,void 0,""),a.find,u).forEach(function(e){if(void 0!==e.index){var t=D+e.index+1,r=t+e[0].length,o={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},i=a.handler({state:n,range:o,match:e,commands:c,chain:d,can:f,pasteEvent:u,dropEvent:s});h.push(i)}})}}),h.every(function(e){return null!==e})}var lp=null;function cp(e){var t,n=e.editor,r=e.rules,o=null,i=!1,a=!1,u="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(e){t=null}var s=function(e){var r=e.state,o=e.from,i=e.to,a=e.rule,s=e.pasteEvt,l=r.tr,c=Lc({state:r,transaction:l});if(sp({editor:n,state:c,from:Math.max(o-1,0),to:i.b-1,rule:a,pasteEvent:s,dropEvent:t})&&l.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch(e){t=null}return u="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.on("destroy",function(){lp===n&&(lp=null)}),r.map(function(e){return new la({view:function(e){var t=function(t){var r;(o=(null===(r=e.dom.parentElement)||void 0===r?void 0:r.contains(t.target))?e.dom.parentElement:null)&&(lp=n)},r=function(){lp&&(lp=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",r),{destroy:function(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:function(e,n){if(a=o===e.dom.parentElement,t=n,!a){var r=lp;(null==r?void 0:r.isEditable)&&setTimeout(function(){if(!r.isDestroyed){var e=r.state.selection;e&&r.commands.deleteRange({from:e.from,to:e.to})}},10)}return!1},paste:function(e,t){var n,r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return u=t,i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,r){var o=t[0],l="paste"===o.getMeta("uiEvent")&&!i,c="drop"===o.getMeta("uiEvent")&&!a,d=o.getMeta("applyPasteRules"),f=!!d;if(l||c||f){if(f){var h=d.text;"string"==typeof h||(h=rf(Vr.from(h),r.schema));var p=d.from,v=p+h.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(t=n.clipboardData)||void 0===t||t.setData("text/html",e),n}(h);return s({rule:e,state:r,from:p,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(r.doc.content),D=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof g&&D&&g!==D.b)return s({rule:e,state:r,from:g,to:D,pasteEvt:u})}}})})}var dp=function(){return x(function e(t,n){M(this,e),this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=n,this.baseExtensions=t,this.extensions=Cf(t),this.hasSchemaSpec=void 0!==n.options.schemaSpec,this.schema=Ff(this.extensions,n,n.options.schemaSpec),this.setupExtensions()},[{key:"commands",get:function(){var t=this;return this.extensions.reduce(function(n,r){var o=tf(r,"addCommands",{name:r.name,options:r.options,storage:t.editor.extensionStorage[r.name],editor:t.editor,type:Rf(r.name,t.schema)});return o?e(e({},n),o()):n},{})}},{key:"plugins",get:function(){var t=this,n=this.editor,r=bf(o(this.extensions).reverse()).flatMap(function(r){var a={name:r.name,options:r.options,storage:t.editor.extensionStorage[r.name],editor:n,type:Rf(r.name,t.schema)},u=[],s=tf(r,"addKeyboardShortcuts",a),l={};if("mark"===r.type&&tf(r,"exitable",a)&&(l.ArrowRight=function(){return ap.handleExit({editor:n,mark:r})}),s){var c=Object.fromEntries(Object.entries(s()).map(function(e){var t=i(e,2),r=t[0],o=t[1];return[r,function(){return o({editor:n})}]}));l=e(e({},l),c)}var d=function(e){return new la({props:{handleKeyDown:mc(e)}})}(l);u.push(d);var f=tf(r,"addInputRules",a);if(Pf(r,n.options.enableInputRules)&&f){var h=f();if(h&&h.length){var p=function(e){var t=e.editor,n=e.rules,r=new la({state:{init:function(){return null},apply:function(e,o,i){var a=e.getMeta(r);if(a)return a;var u=e.getMeta("applyInputRules");return u&&setTimeout(function(){var e=u.text;"string"==typeof e||(e=rf(Vr.from(e),i.schema));var o=u.from,a=o+e.length;op({editor:t,from:o,to:a,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:o}},props:{handleTextInput:function(e,o,i,a){return op({editor:t,from:o,to:i,text:a,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:function(e){return setTimeout(function(){var o=e.state.selection.$cursor;o&&op({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1}},handleKeyDown:function(e,o){if("Enter"!==o.key)return!1;var i=e.state.selection.$cursor;return!!i&&op({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:n,rules:h}),v=Array.isArray(p)?p:[p];u.push.apply(u,o(v))}}var m=tf(r,"addPasteRules",a);if(Pf(r,n.options.enablePasteRules)&&m){var g=m();if(g&&g.length){var D=cp({editor:n,rules:g});u.push.apply(u,o(D))}}var y=tf(r,"addProseMirrorPlugins",a);if(y){var k=y();u.push.apply(u,o(k))}return u}),a=this.createDecorationPlugin();return a&&r.push(a),r}},{key:"createDecorationPlugin",value:function(){var e,t=this,n=this.editor;null===(e=this.decorationManager)||void 0===e||e.destroy();var r=[];return this.extensions.forEach(function(e){var o=tf(e,"addDecorations",{name:e.name,options:e.options,storage:t.editor.extensionStorage[e.name],editor:n,type:Rf(e.name,t.schema)});o&&r.push({name:e.name,addDecorations:o})}),this.decorationManager=new jh({editor:n,entries:r}),this.decorationManager.plugin}},{key:"attributes",get:function(){var e=ff(this.extensions);return this.hasSchemaSpec?of(e,this.schema):e}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=df(this.extensions).nodeExtensions;return Object.fromEntries(n.filter(function(e){return!!tf(e,"addNodeView")}).map(function(n){var r=e.attributes.filter(function(e){return e.type===n.name}),o=tf(n,"addNodeView",{name:n.name,options:n.options,storage:e.editor.extensionStorage[n.name],editor:t,type:_c(n.name,e.schema)});if(!o)return[];var i=o();if(!i)return[];return[n.name,function(e,o,a,u,s){var l=gf(e,r);return i({node:e,view:o,getPos:a,decorations:u,innerDecorations:s,editor:t,extension:n,HTMLAttributes:l})}]}))}},{key:"dispatchTransaction",value:function(e){var t=this,n=this.editor;return bf(o(this.extensions).reverse()).reduceRight(function(e,r){var o={name:r.name,options:r.options,storage:t.editor.extensionStorage[r.name],editor:n,type:Rf(r.name,t.schema)},i=tf(r,"dispatchTransaction",o);return i?function(t){i.call(o,{transaction:t,next:e})}:e},e)}},{key:"transformPastedHTML",value:function(e){var t=this,n=this.editor;return bf(o(this.extensions)).reduce(function(e,r){var o={name:r.name,options:r.options,storage:t.editor.extensionStorage[r.name],editor:n,type:Rf(r.name,t.schema)},i=tf(r,"transformPastedHTML",o);return i?function(t,n){var r=e(t,n);return i.call(o,r)}:e},e||function(e){return e})}},{key:"markViews",get:function(){var t=this,n=this.editor,r=df(this.extensions).markExtensions;return Object.fromEntries(r.filter(function(e){return!!tf(e,"addMarkView")}).map(function(r){var o=t.attributes.filter(function(e){return e.type===r.name}),i=tf(r,"addMarkView",{name:r.name,options:r.options,storage:t.editor.extensionStorage[r.name],editor:n,type:od(r.name,t.schema)});if(!i)return[];return[r.name,function(t,a,u){var s=gf(t,o);return i()({mark:t,view:a,inline:u,editor:n,extension:r,HTMLAttributes:s,updateAttributes:function(r){!function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.state,i=o.doc,a=o.tr,u=t;i.descendants(function(n,o){var i=a.mapping.map(o),s=a.mapping.map(o)+n.nodeSize,l=null;if(n.marks.forEach(function(e){if(e!==u)return!1;l=e}),l){var c=!1;if(Object.keys(r).forEach(function(e){r[e]!==l.attrs[e]&&(c=!0)}),c){var d=t.type.create(e(e({},t.attrs),r));a.removeMark(i,s,t.type),a.addMark(i,s,d)}}}),a.docChanged&&n.view.dispatch(a)}(t,n,r)}})}]}))}},{key:"destroy",value:function(){var e;null===(e=this.decorationManager)||void 0===e||e.destroy(),this.extensions.forEach(function(e){for(var t=e;t.parent;){var n=t.parent;n.child===t&&(n.child=null),t=n}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}},{key:"setupExtensions",value:function(){var e=this,t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(function(e){return[e.name,e.storage]})),t.forEach(function(t){var n,r,o={name:t.name,options:t.options,storage:e.editor.extensionStorage[t.name],editor:e.editor,type:Rf(t.name,e.schema)};"mark"===t.type&&((null===(n=pf(tf(t,"keepOnSplit",o)))||void 0===n||n)&&e.splittableMarks.push(t.name),null===(r=pf(tf(t,"clearable",o)))||void 0===r||r||e.nonClearableMarks.push(t.name));var i=tf(t,"onBeforeCreate",o),a=tf(t,"onCreate",o),u=tf(t,"onUpdate",o),s=tf(t,"onSelectionUpdate",o),l=tf(t,"onTransaction",o),c=tf(t,"onFocus",o),d=tf(t,"onBlur",o),f=tf(t,"onDestroy",o);i&&e.editor.on("beforeCreate",i),a&&e.editor.on("create",a),u&&e.editor.on("update",u),s&&e.editor.on("selectionUpdate",s),l&&e.editor.on("transaction",l),c&&e.editor.on("focus",c),d&&e.editor.on("blur",d),f&&e.editor.on("destroy",f)})}}])}();dp.resolve=Cf,dp.sort=bf,dp.flatten=nf;var fp=function(){function e(){var t;M(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=N(this,e,[].concat(r))).type="extension",t}return A(e,ip),x(e,[{key:"configure",value:function(t){return H(e,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return H(e,"extend",this,3)([n])}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e("function"==typeof t?t():t)}}])}(),hp=fp.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var t=this;return[new la({key:new fa("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var n=t.editor,r=n.state,i=n.schema,a=r.doc,u=r.selection,s=Sf(i),l=t.options.blockSeparator,c=e(e({},void 0!==l?{blockSeparator:l}:{}),{},{textSerializers:s});return o(u.ranges).sort(function(e,t){return e.$from.pos-t.$from.pos}).map(function(e){var t=e.$from,n=e.$to;return xf(a,{from:t.pos,to:n.pos},c)}).join(null!=l?l:"\n\n")}}})]}}),pp=fp.create({name:"commands",addCommands:function(){return e({},Ch)}}),vp=fp.create({name:"delete",onUpdate:function(e){var t,n,r=this,i=e.transaction,a=e.appendedTransactions,u=function(){var e,t,n;if(!(null!==(e=null===(t=r.editor.options.coreExtensionOptions)||void 0===t||null===(t=t.delete)||void 0===t||null===(n=t.filterTransaction)||void 0===n?void 0:n.call(t,i))&&void 0!==e?e:i.getMeta("y-sync$"))){var u=Yd(i.before,[i].concat(o(a)));Mf(u).forEach(function(e){u.mapping.mapResult(e.oldRange.from).deletedAfter&&u.mapping.mapResult(e.oldRange.to).deletedBefore&&u.before.nodesBetween(e.oldRange.from,e.oldRange.to,function(t,n){var o=n+t.nodeSize-2,a=e.oldRange.from<=n&&o<=e.oldRange.to;r.editor.emit("delete",{type:"node",node:t,from:n,to:o,newFrom:u.mapping.map(n),newTo:u.mapping.map(o),deletedRange:e.oldRange,newRange:e.newRange,partial:!a,editor:r.editor,transaction:i,combinedTransform:u})})});var s=u.mapping;u.steps.forEach(function(e,t){if(e instanceof li){var n,o,a=s.slice(t).map(e.from,-1),l=s.slice(t).map(e.to),c=s.invert().map(a,-1),d=s.invert().map(l),f=a>0&&(null===(n=u.doc.nodeAt(a-1))||void 0===n?void 0:n.marks.some(function(t){return t.eq(e.mark)})),h=null===(o=u.doc.nodeAt(l))||void 0===o?void 0:o.marks.some(function(t){return t.eq(e.mark)});r.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:d},newRange:{from:a,to:l},partial:Boolean(h||f),editor:r.editor,transaction:i,combinedTransform:u})}})}};null===(t=null===(n=this.editor.options.coreExtensionOptions)||void 0===n||null===(n=n.delete)||void 0===n?void 0:n.async)||void 0===t||t?setTimeout(u,0):u()}}),mp=fp.create({name:"drop",addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("tiptapDrop"),props:{handleDrop:function(t,n,r,o){e.editor.emit("drop",{editor:e.editor,event:n,slice:r,moved:o})}}})]}}),gp=fp.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Dp=new fa("focusEvents"),yp=fp.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new la({key:Dp,props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:function(t,n){e.isFocused=!1;var r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),kp=fp.create({name:"keymap",addKeyboardShortcuts:function(){var t=this,n=function(){return t.editor.commands.first(function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command(function(e){var n=e.tr,r=n.selection,o=n.doc,i=r.empty,a=r.$anchor,u=a.pos,s=a.parent,l=a.parent.isTextblock&&u>0?n.doc.resolve(u-1):a,c=l.parent.type.spec.isolating,d=a.pos-a.parentOffset,f=c&&1===l.parent.childCount?d===a.pos:Ui.atStart(o).from===u;return!(!i||!s.type.isTextblock||s.textContent.length||!f||f&&"paragraph"===a.parent.type.name)&&t.clearNodes()})},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]})},r=function(){return t.editor.commands.first(function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]})},o={Enter:function(){return t.editor.commands.first(function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]})},"Mod-Enter":function(){return t.editor.commands.exitCode()},Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:r,"Mod-Delete":r,"Mod-a":function(){return t.editor.commands.selectAll()}},i=e({},o),a=e(e({},o),{},{"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":r,"Ctrl-Alt-Backspace":r,"Alt-Delete":r,"Alt-d":r,"Ctrl-a":function(){return t.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return t.editor.commands.selectTextblockEnd()}});return dd()||Rd()?a:i},addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("clearDocument"),appendTransaction:function(t,n,r){if(!t.some(function(e){return e.getMeta("composition")})){var o=t.some(function(e){return e.docChanged})&&!n.doc.eq(r.doc),i=t.some(function(e){return e.getMeta("preventClearDocument")});if(o&&!i){var a=n.selection,u=a.empty,s=a.from,l=a.to,c=Ui.atStart(n.doc).from,d=Ui.atEnd(n.doc).to;if(!u&&s===c&&l===d&&zf(r.doc)){var f=r.tr,h=Lc({state:r,transaction:f});if(new zc({editor:e.editor,state:h}).commands.clearNodes(),f.steps.length)return f}}}}})]}}),Ep=fp.create({name:"paste",addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("tiptapPaste"),props:{handlePaste:function(t,n,r){e.editor.emit("paste",{editor:e.editor,event:n,slice:r})}}})]}}),Fp=fp.create({name:"tabindex",addOptions:function(){return{value:void 0}},addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("tabindex"),props:{attributes:function(){var t;return e.editor.isEditable||void 0!==e.options.value?{tabindex:null!==(t=e.options.value)&&void 0!==t?t:"0"}:{}}}})]}}),bp=fp.create({name:"textDirection",addOptions:function(){return{direction:void 0}},addGlobalAttributes:function(){var e=this;return this.options.direction?[{types:df(this.extensions).nodeExtensions.filter(function(e){return"text"!==e.name}).map(function(e){return e.name}),attributes:{dir:{default:this.options.direction,parseHTML:function(t){var n=t.getAttribute("dir");return!n||"ltr"!==n&&"rtl"!==n&&"auto"!==n?e.options.direction:n},renderHTML:function(e){return e.dir?{dir:e.dir}:{}}}}}]:[]},addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("textDirection"),props:{attributes:function(){var t=e.options.direction;return t?{dir:t}:{}}}})]}}),Cp=!1;var wp=function(){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;M(this,t),this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}return x(t,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!==(e=this.actualDepth)&&void 0!==e?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var e=this.resolvedPos.start(this.resolvedPos.depth-1);return new t(this.resolvedPos.doc.resolve(e),this.editor)}},{key:"before",get:function(){var e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}},{key:"after",get:function(){var e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}},{key:"children",get:function(){var e=this,n=[];return this.node.content.forEach(function(r,o){var i=r.isBlock&&!r.isTextblock,a=r.isAtom&&!r.isText,u=r.isInline,s=e.pos+o+(a?0:1);if(!(s<0||s>e.resolvedPos.doc.nodeSize-2)){var l=e.resolvedPos.doc.resolve(s);if(i||u||!(l.depth<=e.depth)){var c=new t(l,e.editor,i,i||u?r:null);i&&(c.actualDepth=e.depth+1),n.push(c)}}}),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=this.parent;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0)for(var o=r.node.attrs,i=Object.keys(t),a=0;a<i.length;a+=1){var u=i[a];if(o[u]!==t[u])break}else n=r;r=r.parent}return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];if(!this.children||0===this.children.length)return r;var o=Object.keys(t);return this.children.forEach(function(i){n&&r.length>0||(i.node.type.name===e&&o.every(function(e){return t[e]===i.node.attrs[e]})&&r.push(i),n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n))))}),r}},{key:"setAttribute",value:function(t){var n=this.editor.state.tr;n.setNodeMarkup(this.from,void 0,e(e({},this.node.attrs),t)),this.editor.view.dispatch(n)}}])}(),Ap=function(){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};M(this,t),(e=N(this,t)).css=null,e.className="tiptap",e.editorView=null,e.isFocused=!1,e.destroyed=!1,e.isInitialized=!1,e.extensionStorage={},e.instanceId=Math.random().toString(36).slice(2,9),e.hasWarnedStaleDecorationRead=!1,e.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:function(){return null},onCreate:function(){return null},onMount:function(){return null},onUnmount:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null},onContentError:function(e){throw e.error},onPaste:function(){return null},onDrop:function(){return null},onDelete:function(){return null},enableExtensionDispatchTransaction:!0},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.utils={getUpdatedPosition:Hf,createMappablePosition:Vf},e.setOptions(n),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:e}),e.on("mount",e.options.onMount),e.on("unmount",e.options.onUnmount),e.on("contentError",e.options.onContentError),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),e.on("drop",function(t){var n=t.event,r=t.slice,o=t.moved;return e.options.onDrop(n,r,o)}),e.on("paste",function(t){var n=t.event,r=t.slice;return e.options.onPaste(n,r)}),e.on("delete",e.options.onDelete);var r=e.createDoc();if(!e.editorState){var o=ld(r,e.options.autofocus);e.editorState=ua.create({doc:r,schema:e.schema,selection:o||void 0})}return function(e){if(!Cp){var t;Cp=!0;try{var n=fi.fromJSON(e,{from:0,to:0});if(!qf(n))return;t=n.slice.content}catch(e){return}t instanceof Vr||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}}(e.schema),e.options.element&&e.mount(e.options.element),e}return A(t,Ah),x(t,[{key:"mount",value:function(e){var t=this;if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(function(){t.isDestroyed||(!1!==t.options.autofocus&&null!==t.options.autofocus&&t.commands.focus(t.options.autofocus),t.emit("create",{editor:t}),t.isInitialized=!0)},0)}},{key:"unmount",value:function(){if(this.editorView){this.editorState=this.editorView.state;var e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(".".concat(this.className)).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}},{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager?this.commandManager.chain():zc.createFakeChain()}},{key:"can",value:function(){return this.commandManager?this.commandManager.can():zc.createFallbackCan()}},{key:"injectCSS",value:function(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t,n){var r=document.querySelector("style[data-tiptap-style".concat(n?"-".concat(n):"","]"));if(null!==r)return r;var o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute("data-tiptap-style".concat(n?"-".concat(n):""),""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',this.options.injectNonce))}},{key:"setOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=e(e({},this.options),t),this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(e(e({},this.options.editorProps),{},{attributes:this.getEditorViewAttributes()})),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"view",get:function(){var e=this;return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:function(t){e.editorState=t},dispatch:function(t){e.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:function(t,n){if(e.editorView)return e.editorView[n];if("state"===n)return e.editorState;if(n in t)return Reflect.get(t,n);throw new Error("[tiptap error]: The editor view is not available. Cannot access view['".concat(n,"']. The editor may not be mounted yet."))}})}},{key:"state",get:function(){var e;return xh&&!this.hasWarnedStaleDecorationRead&&(e=this,wh.has(e))&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}},{key:"registerPlugin",value:function(e,t){var n=hf(t)?t(e,o(this.state.plugins)):[].concat(o(this.state.plugins),[e]),r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t=this.state.plugins,n=t;if([].concat(e).forEach(function(e){var t="string"==typeof e?"".concat(e,"$"):e.key;n=n.filter(function(e){return!e.key.startsWith(t)})}),t.length!==n.length){var r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}}}},{key:"createExtensionManager",value:function(){var e,t,n=this,r=[].concat(o(this.options.enableCoreExtensions?[gp,hp.configure({blockSeparator:null===(e=this.options.coreExtensionOptions)||void 0===e||null===(e=e.clipboardTextSerializer)||void 0===e?void 0:e.blockSeparator}),pp,yp,kp,Fp.configure({value:null===(t=this.options.coreExtensionOptions)||void 0===t||null===(t=t.tabindex)||void 0===t?void 0:t.value}),mp,Ep,vp,bp.configure({direction:this.options.textDirection})].filter(function(e){return"object"!==k(n.options.enableCoreExtensions)||!1!==n.options.enableCoreExtensions[e.name]}):[]),o(this.options.extensions)).filter(function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)});this.extensionManager=new dp(r,this)}},{key:"createCommandManager",value:function(){this.commandManager=new zc({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createDoc",value:function(){var e,t=this;try{e=Gd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;var n=Gd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=ua.create({doc:n,schema:this.schema,selection:ld(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:function(){"collaboration"in t.storage&&"object"===k(t.storage.collaboration)&&t.storage.collaboration&&(t.storage.collaboration.isDisabled=!0),t.options.extensions=t.options.extensions.filter(function(e){return"collaboration"!==e.name}),t.createExtensionManager()}}),this.editorState.doc}return e}},{key:"getEditorViewAttributes",value:function(){var t,n=null===(t=this.options.editorProps)||void 0===t?void 0:t.attributes;return hf(n)?function(t){return e({role:"textbox"},n(t))}:e({role:"textbox"},n)}},{key:"createView",value:function(t){var n=this.options,r=n.editorProps,o=n.enableExtensionDispatchTransaction,i=r.dispatchTransaction||this.dispatchTransaction.bind(this),a=o?this.extensionManager.dispatchTransaction(i):i,u=r.transformPastedHTML,s=this.extensionManager.transformPastedHTML(u);this.editorView=new ec(t,e(e({},r),{},{attributes:this.getEditorViewAttributes(),dispatchTransaction:a,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews}));var l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="".concat(this.className," ").concat(this.view.dom.className)}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(!this.view.isDestroyed){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(function(e){var n;return null===(n=t.capturedTransaction)||void 0===n?void 0:n.step(e)}):void(this.capturedTransaction=e);var n=this.state.applyTransaction(e),r=n.state,o=n.transactions,i=!this.state.selection.eq(r.selection),a=o.includes(e),u=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:r}),a){this.view.updateState(r),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:o.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:e});var s=o.findLast(function(e){return e.getMeta("focus")||e.getMeta("blur")}),l=null==s?void 0:s.getMeta("focus"),c=null==s?void 0:s.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),c&&this.emit("blur",{editor:this,event:c.event,transaction:s}),e.getMeta("preventUpdate")||!o.some(function(e){return e.docChanged})||u.doc.eq(r.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:o.slice(1)})}}}},{key:"getAttributes",value:function(e){return Bf(this.state,e)}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Id(e,null,n)||If(e,null,n);var r=qd(t,e.schema);return"node"===r?Id(e,t,n):"mark"===r&&If(e,t,n)}(this.state,n,r)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return rf(this.state.doc.content,this.schema)}},{key:"getText",value:function(t){var n=t||{},r=n.blockSeparator,o=void 0===r?"\n\n":r,i=n.textSerializers,a=void 0===i?{}:i;return function(e,t){return xf(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:o,textSerializers:e(e({},Sf(this.schema)),a)})}},{key:"isEmpty",get:function(){return zf(this.state.doc)}},{key:"destroy",value:function(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}},{key:"isDestroyed",get:function(){var e,t;return null===(e=null===(t=this.editorView)||void 0===t?void 0:t.isDestroyed)||void 0===e||e}},{key:"$node",value:function(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new wp(t,this,!1,n)}},{key:"$doc",get:function(){return this.$pos(0)}}])}();function xp(e){return new ep({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=pf(e.getAttributes,void 0,o);if(!1===i||null===i)return null;var a=n.tr,u=o[o.length-1],s=o[0];if(u){var l=s.search(/\S/),c=r.from+s.indexOf(u),d=c+u.length;if(Nf(r.from,r.to,n.doc).filter(function(t){return t.mark.type.excluded.find(function(n){return n===e.type&&n!==t.mark.type})}).filter(function(e){return e.to>c}).length)return null;d<r.to&&a.delete(d,r.to),c>r.from&&a.delete(r.from+l,c);var f=r.from+l+u.length;a.addMark(r.from+l,f,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Sp(e){return new ep({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=n.doc.resolve(r.from),a=pf(e.getAttributes,void 0,o)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;n.tr.delete(r.from,r.to).setBlockType(r.from,r.from,e.type,a)},undoable:e.undoable})}function Bp(e){return new ep({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=t.chain,a=pf(e.getAttributes,void 0,o)||{},u=n.tr.delete(r.from,r.to),s=u.doc.resolve(r.from).blockRange(),l=s&&Di(s,e.type,a);if(!l)return null;if(u.wrap(s,l),e.keepMarks&&e.editor){var c=n.selection,d=n.storedMarks,f=e.editor.extensionManager.splittableMarks,h=d||c.$to.parentOffset&&c.$from.marks();if(h){var p=h.filter(function(e){return f.includes(e.type.name)});u.ensureMarks(p)}}if(e.keepAttributes){var v="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(v,a).run()}var m=u.doc.resolve(r.from-1).nodeBefore;m&&m.type===e.type&&bi(u.doc,r.from-1)&&(!e.joinPredicate||e.joinPredicate(o,m))&&u.join(r.from-1)},undoable:e.undoable})}var Tp=function(){function e(){var t;M(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=N(this,e,[].concat(r))).type="node",t}return A(e,ip),x(e,[{key:"configure",value:function(t){return H(e,"configure",this,3)([t])}},{key:"extend",value:function(t){var n="function"==typeof t?t():t;return H(e,"extend",this,3)([n])}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e("function"==typeof t?t():t)}}])}();function Mp(e){return new up({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=t.pasteEvent,a=pf(e.getAttributes,void 0,o,i);if(!1===a||null===a)return null;var u=n.tr,s=o[o.length-1],l=o[0],c=r.to;if(s){var d=l.search(/\S/),f=r.from+l.indexOf(s),h=f+s.length;if(Nf(r.from,r.to,n.doc).filter(function(t){return t.mark.type.excluded.find(function(n){return n===e.type&&n!==t.mark.type})}).filter(function(e){return e.to>f}).length)return null;h<r.to&&u.delete(h,r.to),f>r.from&&u.delete(r.from+d,f),c=r.from+d+s.length,u.addMark(r.from+d,c,e.type.create(a||{})),void 0!==o.index&&void 0!==o.input&&o.index+o[0].length>=o.input.length||u.removeStoredMark(e.type)}}})}var Np=["children"],Rp=new WeakSet,Op=new WeakSet;function Ip(e){var t=e;return Rp.add(t),t}function Pp(e){return Array.isArray(e)&&Rp.has(e)}function Lp(e){return e.flatMap(function(e){return null==e?[]:Array.isArray(e)&&Op.has(e)&&!Pp(e)?Lp(e):[e]})}function zp(e,t){if("slot"===e)return 0;if(e instanceof Function){var n=e(t);return!Array.isArray(n)||Pp(n)||Op.has(n)?n:Ip(n)}var i=null!=t?t:{},a=i.children,u=r(i,Np);if("svg"===e)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(a)){if(Pp(a))return Ip([e,u,a]);if(0===a.length)return Ip([e,u]);var s=Lp(a);return 0===s.length?Ip([e,u]):Ip([e,u].concat(o(s)))}return Ip(null!=a?[e,u,a]:[e,u])}var $p=function(e,t){return zp(e,t)},qp=/^\s*>\s$/,jp=Tp.create({name:"blockquote",addOptions:function(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML:function(){return[{tag:"blockquote"}]},renderHTML:function(t){var n=t.HTMLAttributes;return $p("blockquote",e(e({},mf(this.options.HTMLAttributes,n)),{},{children:$p("slot",{})}))},parseMarkdown:function(e,t){var n,r=null!==(n=t.parseBlockChildren)&&void 0!==n?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:function(e,t){if(!e.content)return"";var n=[];return e.content.forEach(function(e,r){var o,i,a=(null!==(o=null===(i=t.renderChild)||void 0===i?void 0:i.call(t,e,r))&&void 0!==o?o:t.renderChildren([e])).split("\n").map(function(e){return""===e.trim()?">":"".concat(">"," ").concat(e)});n.push(a.join("\n"))}),n.join("\n".concat(">","\n"))},addCommands:function(){var e=this;return{setBlockquote:function(){return function(t){return t.commands.wrapIn(e.name)}},toggleBlockquote:function(){return function(t){return t.commands.toggleWrap(e.name)}},unsetBlockquote:function(){return function(t){return t.commands.lift(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-b":function(){return e.editor.commands.toggleBlockquote()},Backspace:function(){return function(e,t){var n,r=e.state.selection;if(!r.empty)return!1;var o=r.$from;if(0!==o.parentOffset)return!1;var i=o.depth-1;if(i<0)return!1;var a=o.node(i),u=o.index(i);if(0===u)return!1;if(a.type===t)return e.commands.lift(t.name);var s=a.child(u-1);if(s.type!==t||!(null===(n=s.lastChild)||void 0===n?void 0:n.isTextblock))return!1;var l=o.before()-1-1;return e.commands.command(function(e){var t=e.tr,n=e.dispatch;if(!n)return!0;var r=o.parent.content,i=new Qr(r,0,0);return t.replace(l,o.after(),i),t.setSelection(Ji.create(t.doc,l+r.size)),t.scrollIntoView(),n(t),!0})}(e.editor,e.type)}}},addInputRules:function(){return[Bp({find:qp,type:this.type})]}}),Hp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Vp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Up=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Wp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_p=ap.create({name:"bold",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){var e=this;return[{tag:"strong"},{tag:"b",getAttrs:function(e){return"normal"!==e.style.fontWeight&&null}},{style:"font-weight=400",clearMark:function(t){return t.type.name===e.name}},{style:"font-weight",getAttrs:function(e){return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}]},renderHTML:function(t){var n=t.HTMLAttributes;return $p("strong",e(e({},mf(this.options.HTMLAttributes,n)),{},{children:$p("slot",{})}))},markdownTokenName:"strong",parseMarkdown:function(e,t){return t.applyMark("bold",t.parseInline(e.tokens||[]))},markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:function(e,t){return"**".concat(t.renderChildren(e),"**")},addCommands:function(){var e=this;return{setBold:function(){return function(t){return t.commands.setMark(e.name)}},toggleBold:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetBold:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-b":function(){return e.editor.commands.toggleBold()},"Mod-B":function(){return e.editor.commands.toggleBold()}}},addInputRules:function(){return[xp({find:Hp,type:this.type}),xp({find:Up,type:this.type})]},addPasteRules:function(){return[Mp({find:Vp,type:this.type}),Mp({find:Wp,type:this.type})]}}),Kp=function(e){var t=/`([^`]+)`(?!`)$/.exec(e);return t?t.index>0&&"`"===e[t.index-1]?null:{index:t.index,text:t[0],replaceWith:t[1]}:null},Jp=function(e){for(var t,n=/`([^`]+)`(?!`)/g,r=[];null!==(t=n.exec(e));)t.index>0&&"`"===e[t.index-1]||r.push({index:t.index,text:t[0],replaceWith:t[1]});return r};var Qp=ap.create({name:"code",addOptions:function(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML:function(){return[{tag:"code"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["code",mf(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:function(e,t){return t.applyMark("code",[{type:"text",text:e.text||""}])},renderMarkdown:function(e,t,n){var r;if(!e.content)return"";var o="string"==typeof(null==n||null===(r=n.meta)||void 0===r?void 0:r.markText)?n.meta.markText:"",i="`".repeat(function(e){for(var t=new Set((e.match(/`+/g)||[]).map(function(e){return e.length})),n=1;t.has(n);)n+=1;return n}(o)),a=o.startsWith("`")||o.endsWith("`")?" ":"";return"".concat(i).concat(a).concat(t.renderChildren(e.content)).concat(a).concat(i)},addCommands:function(){var e=this;return{setCode:function(){return function(t){return t.commands.setMark(e.name)}},toggleCode:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetCode:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-e":function(){return e.editor.commands.toggleCode()}}},addInputRules:function(){return[xp({find:Kp,type:this.type})]},addPasteRules:function(){return[Mp({find:Jp,type:this.type})]}}),Gp=/^```([a-z]+)?[\s\n]$/,Xp=/^~~~([a-z]+)?[\s\n]$/,Zp=Tp.create({name:"codeBlock",addOptions:function(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes:function(){var e=this;return{language:{default:this.options.defaultLanguage,parseHTML:function(t){var n,r=e.options.languageClassPrefix;if(!r)return null;var i=o((null===(n=t.firstElementChild)||void 0===n?void 0:n.classList)||[]).filter(function(e){return e.startsWith(r)}).map(function(e){return e.replace(r,"")})[0];return i||null},rendered:!1}}},parseHTML:function(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML:function(e){var t=e.node,n=e.HTMLAttributes;return["pre",mf(this.options.HTMLAttributes,n),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:function(e,t){var n,r;return!1===(null===(n=e.raw)||void 0===n?void 0:n.startsWith("```"))&&!1===(null===(r=e.raw)||void 0===r?void 0:r.startsWith("~~~"))&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:function(e,t){var n,r=(null===(n=e.attrs)||void 0===n?void 0:n.language)||"";return e.content?["```".concat(r),t.renderChildren(e.content),"```"].join("\n"):"```".concat(r,"\n\n```")},addCommands:function(){var e=this;return{setCodeBlock:function(t){return function(n){return n.commands.setNode(e.name,t)}},toggleCodeBlock:function(t){return function(n){return n.commands.toggleNode(e.name,"paragraph",t)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-c":function(){return e.editor.commands.toggleCodeBlock()},Backspace:function(){var t=e.editor.state.selection,n=t.empty,r=t.$anchor,o=1===r.pos;return!(!n||r.parent.type.name!==e.name)&&(!(!o&&r.parent.textContent.length)&&e.editor.commands.clearNodes())},Tab:function(t){var n,r=t.editor;if(!e.options.enableTabIndentation)return!1;var o=null!==(n=e.options.tabSize)&&void 0!==n?n:4,i=r.state,a=i.selection,u=a.$from,s=a.empty;if(u.parent.type!==e.type)return!1;var l=" ".repeat(o);return s?r.commands.insertContent(l):r.commands.command(function(e){var t=e.tr,n=a.from,r=a.to,o=i.doc.textBetween(n,r,"\n","\n").split("\n").map(function(e){return l+e}).join("\n");return t.replaceWith(n,r,i.schema.text(o)),!0})},"Shift-Tab":function(t){var n,r=t.editor;if(!e.options.enableTabIndentation)return!1;var o=null!==(n=e.options.tabSize)&&void 0!==n?n:4,i=r.state,a=i.selection,u=a.$from,s=a.empty;return u.parent.type===e.type&&(s?r.commands.command(function(e){for(var t,n=e.tr,r=u.pos,a=u.start(),s=u.end(),l=i.doc.textBetween(a,s,"\n","\n").split("\n"),c=0,d=0,f=r-a,h=0;h<l.length;h+=1){if(d+l[h].length>=f){c=h;break}d+=l[h].length+1}var p=(null===(t=l[c].match(/^ */))||void 0===t?void 0:t[0])||"",v=Math.min(p.length,o);if(0===v)return!0;for(var m=a,g=0;g<c;g+=1)m+=l[g].length+1;return n.delete(m,m+v),r-m<=v&&n.setSelection(Ji.create(n.doc,m)),!0}):r.commands.command(function(e){var t=e.tr,n=a.from,r=a.to,u=i.doc.textBetween(n,r,"\n","\n").split("\n").map(function(e){var t,n=(null===(t=e.match(/^ */))||void 0===t?void 0:t[0])||"",r=Math.min(n.length,o);return e.slice(r)}).join("\n");return t.replaceWith(n,r,i.schema.text(u)),!0}))},Enter:function(t){var n=t.editor;if(!e.options.exitOnTripleEnter)return!1;var r=n.state.selection,o=r.$from;if(!r.empty||o.parent.type!==e.type)return!1;var i=o.parentOffset===o.parent.nodeSize-2,a=o.parent.textContent.endsWith("\n\n");return!(!i||!a)&&n.chain().command(function(e){return e.tr.delete(o.pos-2,o.pos),!0}).exitCode().run()},ArrowUp:function(t){var n=t.editor;if(!e.options.exitOnArrowUp)return!1;var r=n.state.selection,o=r.$from;if(!r.empty||o.parent.type!==e.type)return!1;if(0!==o.parentOffset)return!1;var i=o.before();return!(i>0)&&n.commands.insertDefaultBlock({pos:i})},ArrowDown:function(t){var n=t.editor;if(!e.options.exitOnArrowDown)return!1;var r=n.state,o=r.selection,i=r.doc,a=o.$from;if(!o.empty||a.parent.type!==e.type)return!1;if(a.parentOffset!==a.parent.nodeSize-2)return!1;var u=a.after();return void 0!==u&&(i.nodeAt(u)?n.commands.command(function(e){return e.tr.setSelection(Ui.near(i.resolve(u))),!0}):n.commands.exitCode())}}},addInputRules:function(){return[Sp({find:Gp,type:this.type,getAttributes:function(e){return{language:e[1]}}}),Sp({find:Xp,type:this.type,getAttributes:function(e){return{language:e[1]}}})]},addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("codeBlockVSCodeHandler"),props:{handlePaste:function(t,n){if(!n.clipboardData)return!1;if(e.editor.isActive(e.type.name))return!1;var r=n.clipboardData.getData("text/plain"),o=n.clipboardData.getData("vscode-editor-data"),i=o?JSON.parse(o):void 0,a=null==i?void 0:i.mode;if(!r||!a)return!1;var u=t.state,s=u.tr,l=u.schema.text(r.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(e.type.create({language:a},l)),s.selection.$from.parent.type!==e.type&&s.setSelection(Ji.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Yp=Tp.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n\n"):""}}),ev=Tp.create({name:"hardBreak",markdownTokenName:"br",addOptions:function(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:function(){return[{tag:"br"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["br",mf(this.options.HTMLAttributes,t)]},renderText:function(){return"\n"},renderMarkdown:function(){return" \n"},parseMarkdown:function(){return{type:"hardBreak"}},addCommands:function(){var e=this;return{setHardBreak:function(){return function(t){var n=t.commands,r=t.chain,o=t.state,i=t.editor;return n.first([function(){return n.exitCode()},function(){return n.command(function(){var t=o.selection,n=o.storedMarks;if(t.$from.parent.type.spec.isolating)return!1;var a=e.options.keepMarks,u=i.extensionManager.splittableMarks,s=n||t.$to.parentOffset&&t.$from.marks();return r().insertContent({type:e.name}).command(function(e){var t=e.tr;if(e.dispatch&&s&&a){var n=s.filter(function(e){return u.includes(e.type.name)});t.ensureMarks(n)}return!0}).scrollIntoView().run()})}])}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Enter":function(){return e.editor.commands.setHardBreak()},"Shift-Enter":function(){return e.editor.commands.setHardBreak()}}}}),tv=Tp.create({name:"heading",addOptions:function(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes:function(){return{level:{default:1,rendered:!1}}},parseHTML:function(){return this.options.levels.map(function(e){return{tag:"h".concat(e),attrs:{level:e}}})},renderHTML:function(e){var t=e.node,n=e.HTMLAttributes;return["h".concat(this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]),mf(this.options.HTMLAttributes,n),0]},parseMarkdown:function(e,t){return t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[]))},renderMarkdown:function(e,t){var n,r=(null===(n=e.attrs)||void 0===n?void 0:n.level)?parseInt(e.attrs.level,10):1,o="#".repeat(r);return e.content?"".concat(o," ").concat(t.renderChildren(e.content)):""},addCommands:function(){var e=this;return{setHeading:function(t){return function(n){var r=n.commands;return!!e.options.levels.includes(t.level)&&r.setNode(e.name,t)}},toggleHeading:function(t){return function(n){var r=n.commands;return!!e.options.levels.includes(t.level)&&r.toggleNode(e.name,"paragraph",t)}}}},addKeyboardShortcuts:function(){var t=this;return this.options.levels.reduce(function(n,r){return e(e({},n),{},S({},"Mod-Alt-".concat(r),function(){return t.editor.commands.toggleHeading({level:r})}))},{})},addInputRules:function(){var e=this;return this.options.levels.map(function(t){return Sp({find:new RegExp("^(#{".concat(Math.min.apply(Math,o(e.options.levels)),",").concat(t,"})\\s$")),type:e.type,getAttributes:{level:t}})})}}),nv=Tp.create({name:"horizontalRule",addOptions:function(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML:function(){return[{tag:"hr"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["hr",mf(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:function(e,t){return t.createNode("horizontalRule")},renderMarkdown:function(){return"---"},addCommands:function(){var e=this;return{setHorizontalRule:function(){return function(t){var n=t.chain,r=t.state;if(!function(e,t){var n=e.selection,r=n.$from;if(n instanceof Gi){var o=r.index();return r.parent.canReplaceWith(o,o+1,t)}for(var i=r.depth;i>=0;){var a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(t))return!0;i-=1}return!1}(r,r.schema.nodes[e.name]))return!1;var o=r.selection,i=o.$to,a=n();return $f(o)?a.insertContentAt(i.pos,{type:e.name}):a.insertContent({type:e.name}),a.command(function(t){var n=t.state,r=t.tr;if(t.dispatch){var o=r.selection.$to,i=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?r.setSelection(Ji.create(r.doc,o.pos+1)):o.nodeAfter.isBlock?r.setSelection(Gi.create(r.doc,o.pos)):r.setSelection(Ji.create(r.doc,o.pos));else{var a=n.schema.nodes[e.options.nextNodeType]||o.parent.type.contentMatch.defaultType,u=null==a?void 0:a.create();u&&(r.insert(i,u),r.setSelection(Ji.create(r.doc,i+1)))}r.scrollIntoView()}return!0}).run()}}}},addInputRules:function(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new ep({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=pf(e.getAttributes,void 0,o)||{},a=n.tr,u=r.from,s=r.to,l=e.type.create(i);if(o[1]){var c=u+o[0].lastIndexOf(o[1]);c>s?c=s:s=c+o[1].length;var d=o[0][o[0].length-1];a.insertText(d,u+o[0].length-1),a.replaceWith(c,s,l)}else if(o[0]){var f=e.type.isInline?u:u-1;a.insert(f,e.type.create(i)).delete(a.mapping.map(u),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable}))];var e}}),rv=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ov=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,iv=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,av=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,uv=ap.create({name:"italic",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){var e=this;return[{tag:"em"},{tag:"i",getAttrs:function(e){return"normal"!==e.style.fontStyle&&null}},{style:"font-style=normal",clearMark:function(t){return t.type.name===e.name}},{style:"font-style=italic"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["em",mf(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setItalic:function(){return function(t){return t.commands.setMark(e.name)}},toggleItalic:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetItalic:function(){return function(t){return t.commands.unsetMark(e.name)}}}},markdownTokenName:"em",parseMarkdown:function(e,t){return t.applyMark("italic",t.parseInline(e.tokens||[]))},markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:function(e,t){return"*".concat(t.renderChildren(e),"*")},addKeyboardShortcuts:function(){var e=this;return{"Mod-i":function(){return e.editor.commands.toggleItalic()},"Mod-I":function(){return e.editor.commands.toggleItalic()}}},addInputRules:function(){return[xp({find:rv,type:this.type}),xp({find:iv,type:this.type})]},addPasteRules:function(){return[Mp({find:ov,type:this.type}),Mp({find:av,type:this.type})]}}),sv="numeric",lv="ascii",cv="alpha",dv="asciinumeric",fv="alphanumeric",hv="domain",pv="emoji",vv="whitespace";function mv(e,t){return e in t||(t[e]=[]),t[e]}function gv(e,t,n){for(var r in t[sv]&&(t[dv]=!0,t[fv]=!0),t[lv]&&(t[dv]=!0,t[cv]=!0),t[dv]&&(t[fv]=!0),t[cv]&&(t[fv]=!0),t[fv]&&(t[hv]=!0),t[pv]&&(t[hv]=!0),t){var o=mv(r,n);o.indexOf(e)<0&&o.push(e)}}function Dv(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.j={},this.jr=[],this.jd=null,this.t=e}Dv.groups={},Dv.prototype={accepts:function(){return!!this.t},go:function(e){var t=this,n=t.j[e];if(n)return n;for(var r=0;r<t.jr.length;r++){var o=t.jr[r][0],i=t.jr[r][1];if(i&&o.test(e))return i}return t.jd},has:function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e in this.j:!!this.go(e)},ta:function(e,t,n,r){for(var o=0;o<e.length;o++)this.tt(e[o],t,n,r)},tr:function(e,t,n,r){var o;return r=r||Dv.groups,t&&t.j?o=t:(o=new Dv(t),n&&r&&gv(t,n,r)),this.jr.push([e,o]),o},ts:function(e,t,n,r){var o=this,i=e.length;if(!i)return o;for(var a=0;a<i-1;a++)o=o.tt(e[a]);return o.tt(e[i-1],t,n,r)},tt:function(e,t,n,r){r=r||Dv.groups;var o=this;if(t&&t.j)return o.j[e]=t,t;var i,a=t,u=o.go(e);if(u?(i=new Dv,Object.assign(i.j,u.j),i.jr.push.apply(i.jr,u.jr),i.jd=u.jd,i.t=u.t):i=new Dv,a){if(r)if(i.t&&"string"==typeof i.t){var s=Object.assign(function(e,t){var n={};for(var r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(i.t,r),n);gv(a,s,r)}else n&&gv(a,n,r);i.t=a}return o.j[e]=i,i}};var yv=function(e,t,n,r,o){return e.ta(t,n,r,o)},kv=function(e,t,n,r,o){return e.tr(t,n,r,o)},Ev=function(e,t,n,r,o){return e.ts(t,n,r,o)},Fv=function(e,t,n,r,o){return e.tt(t,n,r,o)},bv="WORD",Cv="UWORD",wv="ASCIINUMERICAL",Av="ALPHANUMERICAL",xv="LOCALHOST",Sv="TLD",Bv="UTLD",Tv="SCHEME",Mv="SLASH_SCHEME",Nv="NUM",Rv="WS",Ov="NL",Iv="OPENBRACE",Pv="CLOSEBRACE",Lv="OPENBRACKET",zv="CLOSEBRACKET",$v="OPENPAREN",qv="CLOSEPAREN",jv="OPENANGLEBRACKET",Hv="CLOSEANGLEBRACKET",Vv="FULLWIDTHLEFTPAREN",Uv="FULLWIDTHRIGHTPAREN",Wv="LEFTCORNERBRACKET",_v="RIGHTCORNERBRACKET",Kv="LEFTWHITECORNERBRACKET",Jv="RIGHTWHITECORNERBRACKET",Qv="FULLWIDTHLESSTHAN",Gv="FULLWIDTHGREATERTHAN",Xv="AMPERSAND",Zv="APOSTROPHE",Yv="ASTERISK",em="AT",tm="BACKSLASH",nm="BACKTICK",rm="CARET",om="COLON",im="COMMA",am="DOLLAR",um="DOT",sm="EQUALS",lm="EXCLAMATION",cm="HYPHEN",dm="PERCENT",fm="PIPE",hm="PLUS",pm="POUND",vm="QUERY",mm="QUOTE",gm="FULLWIDTHMIDDLEDOT",Dm="SEMI",ym="SLASH",km="TILDE",Em="UNDERSCORE",Fm="EMOJI",bm="SYM",Cm=Object.freeze({__proto__:null,ALPHANUMERICAL:Av,AMPERSAND:Xv,APOSTROPHE:Zv,ASCIINUMERICAL:wv,ASTERISK:Yv,AT:em,BACKSLASH:tm,BACKTICK:nm,CARET:rm,CLOSEANGLEBRACKET:Hv,CLOSEBRACE:Pv,CLOSEBRACKET:zv,CLOSEPAREN:qv,COLON:om,COMMA:im,DOLLAR:am,DOT:um,EMOJI:Fm,EQUALS:sm,EXCLAMATION:lm,FULLWIDTHGREATERTHAN:Gv,FULLWIDTHLEFTPAREN:Vv,FULLWIDTHLESSTHAN:Qv,FULLWIDTHMIDDLEDOT:gm,FULLWIDTHRIGHTPAREN:Uv,HYPHEN:cm,LEFTCORNERBRACKET:Wv,LEFTWHITECORNERBRACKET:Kv,LOCALHOST:xv,NL:Ov,NUM:Nv,OPENANGLEBRACKET:jv,OPENBRACE:Iv,OPENBRACKET:Lv,OPENPAREN:$v,PERCENT:dm,PIPE:fm,PLUS:hm,POUND:pm,QUERY:vm,QUOTE:mm,RIGHTCORNERBRACKET:_v,RIGHTWHITECORNERBRACKET:Jv,SCHEME:Tv,SEMI:Dm,SLASH:ym,SLASH_SCHEME:Mv,SYM:bm,TILDE:km,TLD:Sv,UNDERSCORE:Em,UTLD:Bv,UWORD:Cv,WORD:bv,WS:Rv}),wm=/[a-z]/,Am=/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])/,xm=/(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED8\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8])/,Sm=/\d/,Bm=/\s/,Tm=null,Mm=null;function Nm(e,t){for(var n=function(e){var t=[],n=e.length,r=0;for(;r<n;){var o=e.charCodeAt(r),i=void 0,a=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(a),r+=a.length}return t}(t.replace(/[A-Z]/g,function(e){return e.toLowerCase()})),r=n.length,o=[],i=0,a=0;a<r;){for(var u=e,s=null,l=0,c=null,d=-1,f=-1;a<r&&(s=u.go(n[a]));)(u=s).accepts()?(d=0,f=0,c=u):d>=0&&(d+=n[a].length,f++),l+=n[a].length,i+=n[a].length,a++;i-=d,a-=f,l-=d,o.push({t:c.t,v:t.slice(i-l,i),s:i-l,e:i})}return o}function Rm(e,t,n,r,o){for(var i,a=t.length,u=0;u<a-1;u++){var s=t[u];e.j[s]?i=e.j[s]:((i=new Dv(r)).jr=o.slice(),e.j[s]=i),e=i}return(i=new Dv(n)).jr=o.slice(),e.j[t[a-1]]=i,i}function Om(e){for(var t=[],n=[],r=0;r<e.length;){for(var o=0;"0123456789".indexOf(e[r+o])>=0;)o++;if(o>0){t.push(n.join(""));for(var i=parseInt(e.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(e[r]),r++}return t}var Im={defaultProtocol:"http",events:null,format:Lm,formatHref:Lm,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Pm(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=Object.assign({},Im);e&&(n=Object.assign(n,e instanceof Pm?e.o:e));for(var r=n.ignoreTags,o=[],i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=o}function Lm(e){return e}function zm(e,t){this.t="token",this.v=e,this.tk=t}function $m(e,t){var n=function(){function t(n,r){var o;return M(this,t),(o=N(this,t,[n,r])).t=e,o}return A(t,zm),x(t)}();for(var r in t)n.prototype[r]=t[r];return n.t=e,n}Pm.prototype={o:Im,ignoreTags:[],defaultRender:function(e){return e},check:function(e){return this.get("validate",e.toString(),e)},get:function(e,t,n){var r=null!=t,o=this.o[e];return o?("object"===k(o)?"function"==typeof(o=n.t in o?o[n.t]:Im[e])&&r&&(o=o(t,n)):"function"==typeof o&&r&&(o=o(t,n.t,n)),o):o},getObj:function(e,t,n){var r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render:function(e){var t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},zm.prototype={isLink:!1,toString:function(){return this.v},toHref:function(e){return this.toString()},toFormattedString:function(e){var t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref:function(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex:function(){return this.tk[0].s},endIndex:function(){return this.tk[this.tk.length-1].e},toObject:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Im.defaultProtocol;return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject:function(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate:function(e){return e.get("validate",this.toString(),this)},render:function(e){var t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),o=e.get("tagName",n,t),i=this.toFormattedString(e),a={},u=e.get("className",n,t),s=e.get("target",n,t),l=e.get("rel",n,t),c=e.getObj("attributes",n,t),d=e.getObj("events",n,t);return a.href=r,u&&(a.class=u),s&&(a.target=s),l&&(a.rel=l),c&&Object.assign(a,c),{tagName:o,attributes:a,content:i,eventListeners:d}}};var qm=$m("email",{isLink:!0,toHref:function(){return"mailto:"+this.toString()}}),jm=$m("text"),Hm=$m("nl"),Vm=$m("url",{isLink:!0,toHref:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Im.defaultProtocol;return this.hasProtocol()?this.v:"".concat(e,"://").concat(this.v)},hasProtocol:function(){var e=this.tk;return e.length>=2&&e[0].t!==xv&&e[1].t===om}}),Um=function(e){return new Dv(e)};function Wm(e,t,n){var r=n[0].s,o=n[n.length-1].e;return new e(t.slice(r,o),n)}var _m="undefined"!=typeof console&&console&&console.warn||function(){},Km={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Jm(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Km.initialized&&_m('linkifyjs: already initialized - will not register custom scheme "'.concat(e,'" ').concat("until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.")),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Km.customSchemes.push([e,t])}function Qm(){Km.scanner=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t={};Dv.groups=t;var n=new Dv;null==Tm&&(Tm=Om("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==Mm&&(Mm=Om("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),Fv(n,"'",Zv),Fv(n,"{",Iv),Fv(n,"}",Pv),Fv(n,"[",Lv),Fv(n,"]",zv),Fv(n,"(",$v),Fv(n,")",qv),Fv(n,"<",jv),Fv(n,">",Hv),Fv(n,"(",Vv),Fv(n,")",Uv),Fv(n,"「",Wv),Fv(n,"」",_v),Fv(n,"『",Kv),Fv(n,"』",Jv),Fv(n,"<",Qv),Fv(n,">",Gv),Fv(n,"&",Xv),Fv(n,"*",Yv),Fv(n,"@",em),Fv(n,"`",nm),Fv(n,"^",rm),Fv(n,":",om),Fv(n,",",im),Fv(n,"$",am),Fv(n,".",um),Fv(n,"=",sm),Fv(n,"!",lm),Fv(n,"-",cm),Fv(n,"%",dm),Fv(n,"|",fm),Fv(n,"+",hm),Fv(n,"#",pm),Fv(n,"?",vm),Fv(n,'"',mm),Fv(n,"/",ym),Fv(n,";",Dm),Fv(n,"~",km),Fv(n,"_",Em),Fv(n,"\\",tm),Fv(n,"・",gm);var r=kv(n,Sm,Nv,S({},sv,!0));kv(r,Sm,r);var o=kv(r,wm,wv,S({},dv,!0)),i=kv(r,Am,Av,S({},fv,!0)),a=kv(n,wm,bv,S({},lv,!0));kv(a,Sm,o),kv(a,wm,a),kv(o,Sm,o),kv(o,wm,o);var u=kv(n,Am,Cv,S({},cv,!0));kv(u,wm),kv(u,Sm,i),kv(u,Am,u),kv(i,Sm,i),kv(i,wm),kv(i,Am,i);var s=Fv(n,"\n",Ov,S({},vv,!0)),l=Fv(n,"\r",Rv,S({},vv,!0)),c=kv(n,Bm,Rv,S({},vv,!0));Fv(n,"",c),Fv(l,"\n",s),Fv(l,"",c),kv(l,Bm,c),Fv(c,"\r"),Fv(c,"\n"),kv(c,Bm,c),Fv(c,"",c);var d=kv(n,xm,Fm,S({},pv,!0));Fv(d,"#"),kv(d,xm,d),Fv(d,"️",d);var f=Fv(d,"");Fv(f,"#"),kv(f,xm,d);for(var h=[[wm,a],[Sm,o]],p=[[wm,null],[Am,u],[Sm,i]],v=0;v<Tm.length;v++)Rm(n,Tm[v],Sv,bv,h);for(var m=0;m<Mm.length;m++)Rm(n,Mm[m],Bv,Cv,p);gv(Sv,{tld:!0,ascii:!0},t),gv(Bv,{utld:!0,alpha:!0},t),Rm(n,"file",Tv,bv,h),Rm(n,"mailto",Tv,bv,h),Rm(n,"http",Mv,bv,h),Rm(n,"https",Mv,bv,h),Rm(n,"ftp",Mv,bv,h),Rm(n,"ftps",Mv,bv,h),gv(Tv,{scheme:!0,ascii:!0},t),gv(Mv,{slashscheme:!0,ascii:!0},t),e=e.sort(function(e,t){return e[0]>t[0]?1:-1});for(var g=0;g<e.length;g++){var D=e[g][0],y=e[g][1],k=S({},y?"scheme":"slashscheme",!0);D.indexOf("-")>=0?k[hv]=!0:wm.test(D)?Sm.test(D)?k[dv]=!0:k[lv]=!0:k[sv]=!0,Ev(n,D,D,k)}return Ev(n,"localhost",xv,{ascii:!0}),n.jd=new Dv(bm),{start:n,tokens:Object.assign({groups:t},Cm)}}(Km.customSchemes);for(var e=0;e<Km.tokenQueue.length;e++)Km.tokenQueue[e][1]({scanner:Km.scanner});Km.parser=function(e){var t=e.groups,n=t.domain.concat([Xv,Yv,em,tm,nm,rm,am,sm,cm,Nv,dm,fm,hm,pm,ym,bm,km,Em]),r=[Zv,om,im,um,lm,dm,vm,mm,Dm,jv,Hv,Iv,Pv,zv,Lv,$v,qv,Vv,Uv,Wv,_v,Kv,Jv,Qv,Gv],o=[Xv,Zv,Yv,tm,nm,rm,am,sm,cm,Iv,Pv,dm,fm,hm,pm,vm,ym,bm,km,Em],a=Um(),u=Fv(a,km);yv(u,o,u),yv(u,t.domain,u);var s=Um(),l=Um(),c=Um();yv(a,t.domain,s),yv(a,t.scheme,l),yv(a,t.slashscheme,c),yv(s,o,u),yv(s,t.domain,s);var d=Fv(s,em);Fv(u,em,d),Fv(l,em,d),Fv(c,em,d);var f=Fv(u,um);yv(f,o,u),yv(f,t.domain,u);var h=Um();yv(d,t.domain,h),yv(h,t.domain,h);var p=Fv(h,um);yv(p,t.domain,h);var v=Um(qm);yv(p,t.tld,v),yv(p,t.utld,v),Fv(d,xv,v);var m=Fv(h,cm);Fv(m,cm,m),yv(m,t.domain,h),yv(v,t.domain,h),Fv(v,um,p),Fv(v,cm,m);var g=Fv(s,cm),D=Fv(s,um);Fv(g,cm,g),yv(g,t.domain,s),yv(D,o,u),yv(D,t.domain,s);var y=Um(Vm);yv(D,t.tld,y),yv(D,t.utld,y),yv(y,t.domain,s),yv(y,o,u),Fv(y,um,D),Fv(y,cm,g),Fv(y,em,d);var k=Fv(y,om),E=Um(Vm);yv(k,t.numeric,E);var F=Um(Vm),b=Um();yv(F,n,F),yv(F,r,b),yv(b,n,F),yv(b,r,b),Fv(y,ym,F),Fv(E,ym,F);var C=Fv(l,om),w=Fv(c,om),A=Fv(w,ym),x=Fv(A,ym);yv(l,t.domain,s),Fv(l,um,D),Fv(l,cm,g),yv(c,t.domain,s),Fv(c,um,D),Fv(c,cm,g),yv(C,t.domain,F),Fv(C,ym,F),Fv(C,vm,F),yv(x,t.domain,F),yv(x,n,F),Fv(x,ym,F);for(var S=[[Iv,Pv],[Lv,zv],[$v,qv],[jv,Hv],[Vv,Uv],[Wv,_v],[Kv,Jv],[Qv,Gv]],B=0;B<S.length;B++){var T=i(S[B],2),M=T[0],N=T[1],R=Fv(F,M);Fv(b,M,R);var O=Um(Vm);yv(R,n,O);var I=Um();yv(R,r,I),Fv(R,N,F),yv(O,n,O),yv(O,r,I),yv(I,n,O),yv(I,r,I),Fv(O,N,F),Fv(I,N,F)}return Fv(a,xv,y),Fv(a,Ov,Hm),{start:a,tokens:Cm}}(Km.scanner.tokens);for(var t=0;t<Km.pluginQueue.length;t++)Km.pluginQueue[t][1]({scanner:Km.scanner,parser:Km.parser});return Km.initialized=!0,Km}function Gm(e){return Km.initialized||Qm(),function(e,t,n){for(var r=n.length,o=0,i=[],a=[];o<r;){for(var u=e,s=null,l=null,c=0,d=null,f=-1;o<r&&!(s=u.go(n[o].t));)a.push(n[o++]);for(;o<r&&(l=s||u.go(n[o].t));)s=null,(u=l).accepts()?(f=0,d=u):f>=0&&f++,o++,c++;if(f<0)(o-=c)<r&&(a.push(n[o]),o++);else{a.length>0&&(i.push(Wm(jm,t,a)),a=[]),o-=f,c-=f;var h=d.t,p=n.slice(o-c,o);i.push(Wm(h,t,p))}}return a.length>0&&i.push(Wm(jm,t,a)),i}(Km.parser.start,e,Nm(Km.scanner.start,e))}function Xm(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(t&&"object"===k(t)){if(n)throw Error("linkifyjs: Invalid link type ".concat(t,"; must be a string"));n=t,t=null}for(var r=new Pm(n),o=Gm(e),i=[],a=0;a<o.length;a++){var u=o[a];!u.isLink||t&&u.t!==t||!r.check(u)||i.push(u.toFormattedObject(r))}return i}Gm.scan=Nm;var Zm="[\0- -\u2029 ]",Ym=new RegExp(Zm),eg=new RegExp("".concat(Zm,"$")),tg=new RegExp("".concat(Zm,"+$")),ng=new RegExp(Zm,"g");function rg(t){return new la({key:new fa("autolink"),appendTransaction:function(n,r,i){var a=n.some(function(e){return e.docChanged})&&!r.doc.eq(i.doc),u=n.some(function(e){return e.getMeta("preventAutolink")});if(a&&!u){var s=i.tr,l=Yd(r.doc,o(n));if(!n.some(Pc)){var c=[];l.steps.forEach(function(e,t){if(e instanceof fi&&e.slice.size){var n=l.mapping.slice(t+1),r=n.map(e.from,1),o=n.map(e.from+e.slice.size,-1);r<o&&c.push({from:r,to:o})}}),c.sort(function(e,t){return t.to-e.to}),c.forEach(function(e){return function(e,t,n){var r,o,i=e.doc.resolve(t.to);if(null===(r=i.nodeBefore)||void 0===r?void 0:r.isText){var a=null===(o=e.doc.textBetween(t.from,t.to,"","").match(tg))||void 0===o?void 0:o[0];if(a){var u=t.to-a.length,s=Nf(u,t.to,e.doc).filter(function(e){return e.mark.type===n});if(s.length){var l=i.nodeAfter;if(!l||!s.some(function(e){return e.mark.isInSet(l.marks)})){var c=e.storedMarks;e.removeMark(u,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}}}}}(s,e,t.type)})}if(Mf(l).forEach(function(n){var r,o,a,u,l,c,d,f=n.newRange,h=(r=i.doc,o=f,a=function(e){return e.isTextblock},u=[],r.nodesBetween(o.from,o.to,function(e,t){a(e)&&u.push({node:e,pos:t})}),u);if(h.length>1)l=h[0],c=i.doc.textBetween(l.pos,l.pos+l.node.nodeSize,void 0," ");else if(h.length){var p=i.doc.textBetween(f.from,f.to," "," ");if(!eg.test(p))return;l=h[0],c=i.doc.textBetween(l.pos,f.to,void 0," ")}if(l&&c){var v=c.split(Ym).filter(Boolean);if(v.length<=0)return!1;var m=v[v.length-1],g=l.pos+c.lastIndexOf(m);if(!m)return!1;var D=Gm(m).map(function(e){return e.toObject(t.defaultProtocol)});if(!(1===(d=D).length?d[0].isLink:3===d.length&&d[1].isLink&&["()","[]"].includes(d[0].value+d[2].value)))return!1;D.filter(function(e){return e.isLink}).map(function(t){return e(e({},t),{},{from:g+t.start+1,to:g+t.end+1})}).filter(function(e){return!i.schema.marks.code||!i.doc.rangeHasMark(e.from,e.to,i.schema.marks.code)}).filter(function(e){return t.validate(e.value)}).filter(function(e){return t.shouldAutoLink(e.value)}).forEach(function(e){Nf(e.from,e.to,i.doc).some(function(e){return e.mark.type===t.type})||s.addMark(e.from,e.to,t.type.create({href:e.href}))})}}),s.steps.length)return s}}})}var og=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,ig=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function ag(e,t){for(var n=0,r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1}function ug(e,t,n){var r,o,a=i(t,3),u=a[1],s=a[2];return"!"!==(t.index?e[t.index-1]:void 0)&&!ag(e,null!==(r=t.index)&&void 0!==r?r:0)&&(!function(e,t){for(var n=0,r=0;r<t;)if("`"===e[r])if(0===n&&ag(e,r))r+=1;else{for(var o=0;r<t&&"`"===e[r];)o+=1,r+=1;0===n?n=o:o===n&&(n=0)}else r+=1;return n>0}(e,null!==(o=t.index)&&void 0!==o?o:0)&&(!!u.trim()&&n(s)))}function sg(e){var t,n,r=i(e,7),o=r[0],a=r[1],u=r[2],s=r[4],l=r[5],c=r[6],d=null!==(t=null!=s?s:l)&&void 0!==t?t:c;return{index:null!==(n=e.index)&&void 0!==n?n:0,text:o,replaceWith:a,data:{href:u,title:d||null,markdown:!0}}}function lg(e){var t,n,r;return{href:null===(t=e.data)||void 0===t?void 0:t.href,title:null!==(n=null===(r=e.data)||void 0===r?void 0:r.title)&&void 0!==n?n:null}}function cg(e,t){var n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(function(e){var t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(ng,"").match(new RegExp("^(?:(?:".concat(n.map(function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}).join("|"),"):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))"),"i"))}var dg,fg=ap.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate:function(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(function(e){"string"!=typeof e?Jm(e.scheme,e.optionalSlashes):Jm(e)})},onDestroy:function(){Dv.groups={},Km.scanner=null,Km.parser=null,Km.tokenQueue=[],Km.pluginQueue=[],Km.customSchemes=[],Km.initialized=!1},inclusive:function(){return this.options.autolink},addOptions:function(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:function(e,t){return!!cg(e,t.protocols)},validate:function(e){return!!e},shouldAutoLink:function(e){var t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;var r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}},addAttributes:function(){var e,t,n;return{href:{default:null,parseHTML:function(e){return e.getAttribute("href")}},target:{default:null!==(e=this.options.HTMLAttributes.target)&&void 0!==e?e:null},rel:{default:null!==(t=this.options.HTMLAttributes.rel)&&void 0!==t?t:null},class:{default:null!==(n=this.options.HTMLAttributes.class)&&void 0!==n?n:null},title:{default:null}}},parseHTML:function(){var e=this;return[{tag:"a[href]",getAttrs:function(t){var n=t.getAttribute("href");return!(!n||!e.options.isAllowedUri(n,{defaultValidate:function(t){return!!cg(t,e.options.protocols)},protocols:e.options.protocols,defaultProtocol:e.options.defaultProtocol}))&&null}}]},renderHTML:function(t){var n=this,r=t.HTMLAttributes;return this.options.isAllowedUri(r.href,{defaultValidate:function(e){return!!cg(e,n.options.protocols)},protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",mf(this.options.HTMLAttributes,r),0]:["a",mf(this.options.HTMLAttributes,e(e({},r),{},{href:""})),0]},markdownTokenName:"link",parseMarkdown:function(e,t){return t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null})},renderMarkdown:function(e,t){var n,r,o,i,a=null!==(n=null===(r=e.attrs)||void 0===r?void 0:r.href)&&void 0!==n?n:"",u=null!==(o=null===(i=e.attrs)||void 0===i?void 0:i.title)&&void 0!==o?o:"",s=t.renderChildren(e);return u?"[".concat(s,"](").concat(a,' "').concat(u,'")'):"[".concat(s,"](").concat(a,")")},addCommands:function(){var e=this;return{setLink:function(t){return function(n){var r=n.chain,o=t.href;return!!e.options.isAllowedUri(o,{defaultValidate:function(t){return!!cg(t,e.options.protocols)},protocols:e.options.protocols,defaultProtocol:e.options.defaultProtocol})&&r().setMark(e.name,t).setMeta("preventAutolink",!0).run()}},toggleLink:function(t){return function(n){var r=n.chain,o=(t||{}).href;return!(o&&!e.options.isAllowedUri(o,{defaultValidate:function(t){return!!cg(t,e.options.protocols)},protocols:e.options.protocols,defaultProtocol:e.options.defaultProtocol}))&&r().toggleMark(e.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},unsetLink:function(){return function(t){return(0,t.chain)().unsetMark(e.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}}}},addInputRules:function(){var e,t,n=this;return this.options.markdownLinks?[(e={type:this.type,isAllowedHref:function(e){return n.options.isAllowedUri(e,{defaultValidate:function(e){return!!cg(e,n.options.protocols)},protocols:n.options.protocols,defaultProtocol:n.options.defaultProtocol})}},t=xp({find:function(t){var n=og.exec(t);return n&&ug(t,n,e.isAllowedHref)?sg(n):null},type:e.type,getAttributes:lg}),new ep({find:t.find,handler:function(e){var n=t.handler(e);return null!==n&&e.state.tr.steps.length&&e.state.tr.setMeta("preventAutolink",!0),n}}))]:[]},addPasteRules:function(){var e,t,n=this,r=function(e){var t=[];if(e){var r=n.options,o=r.protocols,i=r.defaultProtocol;Xm(e).filter(function(e){return e.isLink&&n.options.isAllowedUri(e.value,{defaultValidate:function(e){return!!cg(e,o)},protocols:o,defaultProtocol:i})}).forEach(function(e){n.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[(e={type:this.type,isAllowedHref:function(e){return n.options.isAllowedUri(e,{defaultValidate:function(e){return!!cg(e,n.options.protocols)},protocols:n.options.protocols,defaultProtocol:n.options.defaultProtocol})},findPlainUrls:r},t=Mp({find:function(t){var n,r,i,a=[],u=j(t.matchAll(ig));try{for(u.s();!(i=u.n()).done;){var s=i.value;ug(t,s,e.isAllowedHref)&&a.push(sg(s))}}catch(e){u.e(e)}finally{u.f()}var l=(null!==(n=null===(r=e.findPlainUrls)||void 0===r?void 0:r.call(e,t))&&void 0!==n?n:[]).filter(function(e){return!a.some(function(t){return function(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}(t,e)})});return[].concat(a,o(l))},type:e.type,getAttributes:lg}),new up({find:t.find,handler:function(e){var n,r=t.handler(e);return null!==r&&e.state.tr.steps.length&&(null===(n=e.match.data)||void 0===n?void 0:n.markdown)&&e.state.tr.setMeta("preventAutolink",!0),r}}))]:[Mp({find:r,type:this.type,getAttributes:function(e){var t;return{href:null===(t=e.data)||void 0===t?void 0:t.href}}})]},addProseMirrorPlugins:function(){var e,t=this,n=[],r=this.options,o=r.protocols,i=r.defaultProtocol;return this.options.autolink&&n.push(rg({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:function(e){return t.options.isAllowedUri(e,{defaultValidate:function(e){return!!cg(e,o)},protocols:o,defaultProtocol:i})},shouldAutoLink:this.options.shouldAutoLink})),n.push((e={type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection},new la({key:new fa("handleClickLink"),props:{handleClick:function(t,n,r){if(0!==r.button)return!1;if(!t.editable)return!1;var o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{var i=r.target;if(!i)return!1;var a=e.editor.view.dom;(o=i.closest("a"))&&!a.contains(o)&&(o=null)}if(!o)return!1;var u=!1;if(e.enableClickSelection&&(u=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){var s,l,c=Bf(t.state,e.type.name),d=null!==(s=o.href)&&void 0!==s?s:c.href,f=null!==(l=o.target)&&void 0!==l?l:c.target;d&&(window.open(d,f),u=!0)}return u}}}))),this.options.linkOnPaste&&n.push(function(e){return new la({key:new fa("handlePasteLink"),props:{handlePaste:function(t,n,r){var o=e.shouldAutoLink;if(t.state.selection.empty)return!1;var i="";r.content.forEach(function(e){i+=e.textContent});var a=Xm(i,{defaultProtocol:e.defaultProtocol}).find(function(e){return e.isLink&&e.value===i});return!(!i||!a||void 0!==o&&!o(a.value))&&e.editor.commands.setMark(e.type,{href:a.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),hg=["start","type"],pg="textStyle",vg=/^\s*([-+*])\s$/,mg=Tp.create({name:"bulletList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},parseHTML:function(){return[{tag:"ul"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["ul",mf(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:function(e,t){return"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]}},renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n"):""},markdownOptions:{indentsContent:!0},addCommands:function(){var e=this;return{toggleBulletList:function(){return function(t){var n=t.commands,r=t.chain;return e.options.keepAttributes?r().toggleList(e.name,e.options.itemTypeName,e.options.keepMarks).updateAttributes("listItem",e.editor.getAttributes(pg)).run():n.toggleList(e.name,e.options.itemTypeName,e.options.keepMarks)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-8":function(){return e.editor.commands.toggleBulletList()}}},addInputRules:function(){var e=this,t=Bp({find:vg,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Bp({find:vg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:function(){return e.editor.getAttributes(pg)},editor:this.editor})),[t]}}),gg=function(e,t,n){return function(e,t,n,r){var o=function(e,t,n){var r=e.selection;if(!r.empty)return null;var o=r.$from;if(!o.parent.isTextblock)return null;if(o.parentOffset!==o.parent.content.size)return null;for(var i=-1,a=o.depth;a>0;a-=1)if(o.node(a).type.name===t){i=a;break}if(i<0)return null;var u=o.node(i),s=o.index(i);if(s+1>=u.childCount)return null;var l=u.child(s+1);if(!n.includes(l.type.name))return null;var c=e.schema.nodes[t],d=!1;if(l.forEach(function(e){e.type===c&&e.childCount>1&&(d=!0)}),!d)return null;var f=e.doc.resolve(o.after()).nodeAfter;if(!f||!n.includes(f.type.name))return null;var h=[];return f.forEach(function(e){h.push(e)}),0===h.length?null:{listItemDepth:i,nestedList:f,nestedListPos:o.after(),insertPos:o.after(i),items:h}}(e,n,r);if(!o)return!1;var i=e.selection,a=o.nestedList,u=o.nestedListPos,s=o.insertPos,l=o.items,c=e.tr;c.delete(u,u+a.nodeSize);var d=c.mapping.map(s);return c.insert(d,Vr.from(l)),c.setSelection(i.map(c.doc,c.mapping)),t&&t(c),!0}(e.state,e.view.dispatch,t,n)},Dg=function(e,t){return fp.create({name:"".concat(e,"BranchingDeleteKeymap"),priority:101,addKeyboardShortcuts:function(){var n=this,r=function(){return gg(n.editor,e,t)};return{Delete:r,"Mod-Delete":r}}})},yg=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],kg="abcdefghijklmnopqrstuvwxyz",Eg=String.raw(dg||(dg=W(["d+|[ivxlcdmIVXLCDM]+|",""],["\\d+|[ivxlcdmIVXLCDM]+|",""])),"[a-zA-Z]{1,2}");function Fg(e){var t,n=e,r="",o=j(yg);try{for(o.s();!(t=o.n()).done;)for(var a=i(t.value,2),u=a[0],s=a[1];n>=u;)r+=s,n-=u}catch(e){o.e(e)}finally{o.f()}return r}function bg(e){return Fg(e).toUpperCase()}function Cg(e){for(var t=e.toLowerCase(),n=0,r=0;n<t.length;){var o,a=!1,u=j(yg);try{for(u.s();!(o=u.n()).done;){var s=i(o.value,2),l=s[0],c=s[1];if(t.startsWith(c,n)){r+=l,n+=c.length,a=!0;break}}}catch(e){u.e(e)}finally{u.f()}if(!a)return 0}return r}function wg(e){if(e<=26)return kg[e-1];var t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?kg[n]:kg[t]+kg[n]}function Ag(e){if(e&&!/^\d+$/.test(e))return function(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;var t=Cg(e);return!(t<=0)&&(e===e.toLowerCase()?Fg(t):bg(t))===e}(e)?e===e.toLowerCase()?"i":"I":/^[a-z]{1,2}$/.test(e)?"a":/^[A-Z]{1,2}$/.test(e)?"A":void 0}function xg(e){if(/^\d+$/.test(e))return parseInt(e,10);var t=Ag(e);if("i"===t||"I"===t)return Cg(e);if("a"===t||"A"===t){var n=function(e){var t=e.toLowerCase();return 1===t.length?t.charCodeAt(0)-"a".charCodeAt(0)+1:2===t.length?26*(t.charCodeAt(0)-"a".charCodeAt(0)+1)+(t.charCodeAt(1)-"a".charCodeAt(0))+1:0}(e);return n>0?n:1}var r=parseInt(e,10);return Number.isNaN(r)?1:r}function Sg(e,t){if("numeric"===e)return String(t);switch(e){case"a":return wg(t);case"A":return wg(t).toUpperCase();case"i":return Fg(t);case"I":return bg(t);default:return String(t)}}function Bg(e){var t=function(e){return{type:Ag(e),start:xg(e)}}(e),n=t.type,r=t.start,o={};return n&&(o.type=n),1!==r&&(o.start=r),o}function Tg(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var Mg=Tp.create({name:"listItem",addOptions:function(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML:function(){return[{tag:"li"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["li",mf(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:function(e,t){var n;if("list_item"!==e.type)return[];var r=null!==(n=t.parseBlockChildren)&&void 0!==n?n:t.parseChildren,i=[];if(e.tokens&&e.tokens.length>0){if(function(e){var t,n,r=null===(t=e.tokens)||void 0===t?void 0:t[0];return Boolean(e.text&&1===(null===(n=e.tokens)||void 0===n?void 0:n.length)&&"list"===(null==r?void 0:r.type)&&r.ordered&&r.raw===e.text)}(e))return{type:"listItem",content:[{type:"paragraph",content:Tg(e.text||"",t)}]};if(e.tokens.some(function(e){return"paragraph"===e.type}))i=r(e.tokens);else{var a=e.tokens[0];if(a&&"text"===a.type&&a.tokens&&a.tokens.length>0){if(i=[{type:"paragraph",content:t.parseInline(a.tokens)}],e.tokens.length>1){var u,s=r(e.tokens.slice(1));(u=i).push.apply(u,o(s))}}else i=r(e.tokens)}}return 0===i.length&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:function(e,t,n){return Gh(e,t,function(e){if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){var t,n,r=(null===(t=e.meta)||void 0===t||null===(t=t.parentAttrs)||void 0===t?void 0:t.start)||1;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:". ",r=t+1;if(!e||"1"===e)return"".concat(r).concat(n);switch(e){case"a":return"".concat(wg(r)).concat(n);case"A":return"".concat(wg(r).toUpperCase()).concat(n);case"i":return"".concat(Fg(r)).concat(n);case"I":return"".concat(bg(r)).concat(n);default:return"".concat(r).concat(n)}}(null===(n=e.meta)||void 0===n||null===(n=n.parentAttrs)||void 0===n?void 0:n.type,r-1+(e.index||0),". ")}return"- "},n,{alignNestedToPrefix:"orderedList"===(null==n?void 0:n.parentType)})},addExtensions:function(){return[Dg(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts:function(){var e=this;return{Enter:function(){return e.editor.commands.splitListItem(e.name)},Tab:function(){return e.editor.commands.sinkListItem(e.name)},"Shift-Tab":function(){return e.editor.commands.liftListItem(e.name)}}}}),Ng=function(e,t){for(var n=t.selection.$from,r=_c(e,t.schema),o=n.depth,i=n.pos,a=null;o>0&&null===a;)n.node(o).type===r?a=o:(o-=1,i-=1);return null===a?null:{$pos:t.doc.resolve(i),depth:a}},Rg=function(e,t){var n=Ng(e,t);if(!n)return!1;var r=function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:20,o=e.doc.resolve(n),i=r,a=null;i>0&&null===a;){var u=o.node(i);(null==u?void 0:u.type.name)===t?a=u:i-=1}return[a,i]}(t,e,n.$pos.pos+4);return i(r,2)[1]},Og=function(e,t,n){if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Id(e.state,t)&&function(e,t,n){var r=e.selection.$anchor,o=Math.max(0,r.pos-2),i=e.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))}(e.state,0,n)){var r=e.state.selection.$anchor,o=e.state.doc.resolve(r.before()-1),i=[];o.node().descendants(function(e,n){e.type.name===t&&i.push({node:e,pos:n})});var a=i.at(-1);if(!a)return!1;var u=e.state.doc.resolve(o.start()+a.pos+1);return e.chain().cut({from:r.start()-1,to:r.end()+1},u.end()).joinForward().run()}if(!Id(e.state,t))return!1;if(!function(e){var t=e.selection,n=t.$from,r=t.$to;return!(n.parentOffset>0||n.pos!==r.pos)}(e.state))return!1;var s=e.state.selection.$from,l=s.depth-1;return s.node(l).type===e.schema.nodes[t]&&0===s.index(l)&&e.chain().liftListItem(t).run()},Ig=function(e,t){if(!Id(e.state,t))return!1;if(!function(e,t){var n=e.selection,r=n.$from,o=n.$to,i=n.$anchor;if(t){var a=ef(function(e){return e.type.name===t})(e.selection);if(!a)return!1;var u=e.doc.resolve(a.pos+1);return i.pos+1===u.end()}return!(o.parentOffset<o.parent.nodeSize-2||r.pos!==o.pos)}(e.state,t))return!1;var n,r,o,i,a=e.state.selection,u=a.$from,s=a.$to;return!(!a.empty&&u.sameParent(s))&&(n=t,r=e.state,o=Rg(n,r),(i=Ng(n,r))&&o&&o>i.depth?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():function(e,t){var n=Rg(e,t),r=Ng(e,t);return!(!r||!n)&&n<r.depth}(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},Pg=function(e,t,n){var r=e.state,o=r.selection;if(!o.empty)return!1;var i=o.$from;if(0!==i.parentOffset)return!1;if(!i.parent.isTextblock)return!1;if(Id(r,t))return!1;var a=function(e){var t=e.depth-1;if(t<0)return null;var n=e.index(t);return 0===n?null:e.node(t).child(n-1)}(i);if(!a||!n.includes(a.type.name))return!1;var u=a.lastChild;if(!u||u.type.name!==t)return!1;var s=i.parent;if(!u.canReplace(u.childCount,u.childCount,Vr.from(s)))return!1;var l=i.before(),c=i.after(),d=l-2;return e.commands.command(function(e){var t=e.tr;return e.dispatch&&(t.delete(l,c).insert(d,Vr.from(s)),t.setSelection(Ji.create(t.doc,d+1)),t.scrollIntoView()),!0})},Lg=fp.create({name:"listKeymap",addOptions:function(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts:function(){var e=this;return{Delete:function(t){var n=t.editor,r=!1;return e.options.listTypes.forEach(function(e){var t=e.itemName;void 0!==n.state.schema.nodes[t]&&Ig(n,t)&&(r=!0)}),r},"Mod-Delete":function(t){var n=t.editor,r=!1;return e.options.listTypes.forEach(function(e){var t=e.itemName;void 0!==n.state.schema.nodes[t]&&Ig(n,t)&&(r=!0)}),r},Backspace:function(t){var n=t.editor,r=!1;return e.options.listTypes.forEach(function(e){var t=e.itemName,o=e.wrapperNames;void 0!==n.state.schema.nodes[t]&&Og(n,t,o)&&(r=!0)}),r},"Mod-Backspace":function(t){var n=t.editor,r=!1;return e.options.listTypes.forEach(function(e){var t=e.itemName,o=e.wrapperNames;void 0!==n.state.schema.nodes[t]&&Og(n,t,o)&&(r=!0)}),r},Tab:function(t){var n,r=t.editor,o=j(e.options.listTypes);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=i.itemName,u=i.wrapperNames;if(void 0!==r.state.schema.nodes[a]&&Pg(r,a,u))return!0}}catch(e){o.e(e)}finally{o.f()}return!1}}}}),zg=new RegExp("^(\\s*)(".concat(Eg,")([.)])\\s+(.*)$")),$g=/^\s/,qg={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function jg(e){var t=e.trimStart();return qg.bulletItem.test(t)||function(e){return zg.test(e.trimStart())}(t)||qg.heading.test(t)||qg.thematicBreak.test(t)&&!t.startsWith("-")||/^>\s?/.test(t)||qg.codeFence.test(t)||qg.blockMath.test(t)}function Hg(e){return Object.values(qg).some(function(t){return t.test(e)})}function Vg(e){var t=[],n=[],r=!1;return e.forEach(function(e){if(!r)return""===e.trim()||t.length>0&&jg(e)?(r=!0,void n.push(e)):void t.push(e);n.push(e)}),{paragraphLines:t,blockLines:n}}function Ug(e){for(var t=[],n=0,r=0;n<e.length;){var o=e[n],a=o.match(zg);if(!a)break;var u=i(a,5),s=u[1],l=u[2];u[3];for(var c=u[4],d=s.length,f=parseInt(l,10),h=isNaN(f)?Ag(l):void 0,p=isNaN(f)?xg(l):f,v=[c],m=n+1,g=[o],D=!1;m<e.length;){var y=e[m];if(y.match(zg))break;if(""===y.trim())g.push(y),v.push(""),D=!0,m+=1;else if(y.match($g)){var k=y.length-y.trimStart().length,E=d+l.length+1;g.push(y),v.push(y.slice(Math.min(k,E))),m+=1}else{if(D||Hg(y))break;g.push(y),v.push(y),m+=1}}t.push({indent:d,number:p,type:h,content:v.join("\n").trim(),contentLines:v,raw:g.join("\n")}),r=m,n=m}return[t,r]}var Wg=new RegExp("^(".concat(Eg,")([.)])\\s+(.+)$"));function _g(e){var t=e.split("\n").filter(function(e){return e.trim().length>0});if(0===t.length)return null;var n,r=[],o=j(t);try{for(o.s();!(n=o.n()).done;){var i=n.value.trim().match(Wg);if(!i)return null;r.push({marker:i[1],content:i[3]})}}catch(e){o.e(e)}finally{o.f()}return function(e){var t;if(0===e.length)return!1;var n=null!==(t=Ag(e[0]))&&void 0!==t?t:"numeric",r=xg(e[0]);if(r<1)return!1;for(var o=0;o<e.length;o++){var i=Sg(n,r+o);if(e[o]!==i)return!1}return!0}(r.map(function(e){return e.marker}))?{type:"orderedList",attrs:Bg(r[0].marker),content:r.map(function(e){return{type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:e.content}]}]}})}:null}function Kg(e,t,n){for(var r=[],i=0;i<e.length;){var a=e[i];if(a.indent===t){var u=Vg(a.contentLines),s=u.paragraphLines,l=u.blockLines,c=s.join("\n").trim(),d=[];c&&d.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});var f=l.join("\n").trim();if(f){var h=n.blockTokens(f);d.push.apply(d,o(h))}for(var p=i+1,v=[];p<e.length&&e[p].indent>t;)v.push(e[p]),p+=1;if(v.length>0){var m=Kg(v,Math.min.apply(Math,o(v.map(function(e){return e.indent}))),n);d.push({type:"list",ordered:!0,start:v[0].number,typeMarker:v[0].type,items:m,raw:v.map(function(e){return e.raw}).join("\n")})}r.push({type:"list_item",raw:a.raw,tokens:d}),i=p}else i+=1}return r}function Jg(e,t){for(var n=[],r=0;n.length<t;){var o=e.indexOf("\n",r);if(-1===o)return n.push(e.slice(r)),n;n.push(e.slice(r,o)),r=o+1}return n}var Qg="textStyle",Gg=/^(\d+)\.\s$/;function Xg(e){var t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Zg=Tp.create({name:"orderedList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},addAttributes:function(){return{start:{default:1,parseHTML:function(e){return e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1}},type:{default:null,parseHTML:function(e){var t=e.getAttribute("type");if(t)return t;var n=e.getAttribute("style");if(n){var r=Xg(n);if(r)return r}var o=e.querySelector("li");if(o){var i=o.getAttribute("style");if(i){var a=Xg(i);if(a)return a}}return null}}}},parseHTML:function(){return[{tag:"ol"}]},renderHTML:function(e){var t=e.HTMLAttributes,n=t.start,o=t.type,i=r(t,hg),a=mf(this.options.HTMLAttributes,i);return 1!==n&&(a.start=n),o&&"1"!==o&&(a.type=o),["ol",a,0]},markdownTokenName:"list",parseMarkdown:function(e,t){if("list"!==e.type||!e.ordered)return[];var n=e.start||1,r=e.typeMarker,i=e.items?function(e,t){return e.map(function(e){if("list_item"!==e.type)return t.parseChildren([e])[0];var n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(function(e){if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push.apply(n,o(t.parseChildren([e])));else if("text"===e.type&&e.tokens){var r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{var i=t.parseChildren([e]);i.length>0&&n.push.apply(n,o(i))}}),{type:"listItem",content:n}})}(e.items,t):[],a={};return 1!==n&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:"orderedList",attrs:a,content:i}:{type:"orderedList",content:i}},renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n"):""},markdownTokenizer:{name:"orderedList",level:"block",start:function(){return-1},tokenize:function(e,t,n){var r,o,a=function(e){var t=e.indexOf("\n"),n=-1===t?e:e.slice(0,t);if(!zg.test(n))return[[],0,[]];for(var r=64,o=Jg(e,r),i=Ug(o);i[1]===o.length&&o.length===r;)i=Ug(o=Jg(e,r*=2));return[i[0],i[1],o]}(e),u=i(a,3),s=u[0],l=u[1],c=u[2];if(0!==s.length){var d=Kg(s,s[0].indent,n);if(0!==d.length)return{type:"list",ordered:!0,start:(null===(r=s[0])||void 0===r?void 0:r.number)||1,typeMarker:null===(o=s[0])||void 0===o?void 0:o.type,items:d,raw:c.slice(0,l).join("\n")}}}},markdownOptions:{indentsContent:!0},addCommands:function(){var e=this;return{toggleOrderedList:function(){return function(t){var n=t.commands,r=t.chain;return e.options.keepAttributes?r().toggleList(e.name,e.options.itemTypeName,e.options.keepMarks).updateAttributes("listItem",e.editor.getAttributes(Qg)).run():n.toggleList(e.name,e.options.itemTypeName,e.options.keepMarks)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-7":function(){return e.editor.commands.toggleOrderedList()}}},addProseMirrorPlugins:function(){return[new la({props:{handlePaste:function(e,t){var n,r,o=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");if(null==o?void 0:o.trim())return!1;var i=null===(r=t.clipboardData)||void 0===r?void 0:r.getData("text/plain");if(!i)return!1;var a=_g(i);if(!a)return!1;try{var u=e.state.schema.nodeFromJSON(a),s=e.state.tr.replaceSelectionWith(u);return e.dispatch(s),!0}catch(e){return!1}}}})]},addInputRules:function(){var t=this,n=function(e,t){return(!t.attrs.type||"1"===t.attrs.type)&&t.childCount+t.attrs.start===+e[1]},r=Bp({find:Gg,type:this.type,getAttributes:function(e){return{start:+e[1]}},joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(r=Bp({find:Gg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:function(n){return e({start:+n[1]},t.editor.getAttributes(Qg))},joinPredicate:n,editor:this.editor})),[r]}}),Yg=/^\s*(\[([( |x])?\])\s$/,eD=Tp.create({name:"taskItem",addOptions:function(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content:function(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:function(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:function(e){var t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:function(e){return{"data-checked":e.checked}}}}},parseHTML:function(){return[{tag:'li[data-type="'.concat(this.name,'"]'),priority:51,contentElement:function(e){var t;return null!==(t=e.querySelector("div"))&&void 0!==t?t:e}}]},renderHTML:function(e){var t=e.node,n=e.HTMLAttributes;return["li",mf(this.options.HTMLAttributes,n,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:function(e,t){var n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){var r=t.parseChildren(e.nestedTokens);n.push.apply(n,o(r))}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:function(e,t){var n;return Gh(e,t,"- [".concat((null===(n=e.attrs)||void 0===n?void 0:n.checked)?"x":" ","] "))},addExtensions:function(){return this.options.nested?[Dg(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts:function(){var t=this,n={Enter:function(){return t.editor.commands.splitListItem(t.name)},"Shift-Tab":function(){return t.editor.commands.liftListItem(t.name)}};return this.options.nested?e(e({},n),{},{Tab:function(){return t.editor.commands.sinkListItem(t.name)}}):n},addNodeView:function(){var t=this;return function(n){var r=n.node,o=n.HTMLAttributes,a=n.getPos,u=n.editor,s=document.createElement("li"),l=document.createElement("label"),c=document.createElement("span"),d=document.createElement("input"),f=document.createElement("div");c.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";var h=function(e){var n=function(e,t,n){var r;return(null==n||null===(r=n.checkboxLabel)||void 0===r?void 0:r.call(n,e,t))||"Task item checkbox for ".concat(e.textContent||"empty task item")}(e,e.attrs.checked,t.options.a11y);d.setAttribute("aria-label",n),c.textContent=n};h(r),l.contentEditable="false",d.type="checkbox",d.addEventListener("mousedown",function(e){return e.preventDefault()}),d.addEventListener("change",function(n){if(u.isEditable||t.options.onReadOnlyChecked){var o=n.target.checked;u.isEditable&&"function"==typeof a&&u.chain().focus(void 0,{scrollIntoView:!1}).command(function(t){var n=t.tr,r=a();if("number"!=typeof r)return!1;var i=n.doc.nodeAt(r);return n.setNodeMarkup(r,void 0,e(e({},null==i?void 0:i.attrs),{},{checked:o})),!0}).run(),!u.isEditable&&t.options.onReadOnlyChecked&&(t.options.onReadOnlyChecked(r,o)||(d.checked=!d.checked))}else d.checked=!d.checked}),Object.entries(t.options.HTMLAttributes).forEach(function(e){var t=i(e,2),n=t[0],r=t[1];s.setAttribute(n,r)}),s.dataset.checked=r.attrs.checked,d.checked=r.attrs.checked,l.append(d,c),s.append(l,f),Object.entries(o).forEach(function(e){var t=i(e,2),n=t[0],r=t[1];s.setAttribute(n,r)});var p=new Set(Object.keys(o));return{dom:s,contentDOM:f,update:function(e){if(e.type!==t.type)return!1;s.dataset.checked=e.attrs.checked,d.checked=e.attrs.checked,h(e);var n=gf(e,u.extensionManager.attributes),r=new Set(Object.keys(n)),o=t.options.HTMLAttributes;return p.forEach(function(e){r.has(e)||(e in o?s.setAttribute(e,o[e]):s.removeAttribute(e))}),Object.entries(n).forEach(function(e){var t=i(e,2),n=t[0],r=t[1];null==r?n in o?s.setAttribute(n,o[n]):s.removeAttribute(n):s.setAttribute(n,r)}),p=r,!0}}}},addInputRules:function(){return[Bp({find:Yg,type:this.type,getAttributes:function(e){return{checked:"x"===e[e.length-1]}}})]}}),tD=Tp.create({name:"taskList",addOptions:function(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},parseHTML:function(){return[{tag:'ul[data-type="'.concat(this.name,'"]'),priority:51}]},renderHTML:function(e){var t=e.HTMLAttributes;return["ul",mf(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:function(e,t){return t.createNode("taskList",{},t.parseChildren(e.items||[]))},renderMarkdown:function(e,t){return e.content?t.renderChildren(e.content,"\n"):""},markdownTokenizer:{name:"taskList",level:"block",start:function(e){var t,n=null===(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))||void 0===t?void 0:t.index;return void 0!==n?n:-1},tokenize:function(e,t,n){var r=function(e){var t=Jh(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:function(e){return{indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}},createToken:function(e,t){return{type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}},customNestedParser:r},n);if(t){var i={type:"taskList",raw:t.raw,items:t.items},a=e.slice(t.raw.length);return a.trim()?[i].concat(o(n.blockTokens(a))):[i]}return n.blockTokens(e)},i=Jh(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:function(e){return{indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}},createToken:function(e,t){return{type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}},customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands:function(){var e=this;return{toggleTaskList:function(){return function(t){return t.commands.toggleList(e.name,e.options.itemTypeName)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-9":function(){return e.editor.commands.toggleTaskList()}}}});fp.create({name:"listKit",addExtensions:function(){var e=[];return!1!==this.options.bulletList&&e.push(mg.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Mg.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(Lg.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(Zg.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(eD.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(tD.configure(this.options.taskList)),e}});var nD=" ",rD=Tp.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",mf(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){var n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);var r=t.parseInline(n);return 1!==n.length||"text"!==n[0].type||n[0].raw!==nD&&n[0].text!==nD&&" "!==n[0].raw&&" "!==n[0].text||1!==r.length||"text"!==r[0].type||r[0].text!==nD&&" "!==r[0].text?t.createNode("paragraph",void 0,r):t.createNode("paragraph",void 0,[])},renderMarkdown:function(e,t,n){if(!e)return"";var r=Array.isArray(e.content)?e.content:[];if(0===r.length){var o,i,a=Array.isArray(null==n||null===(o=n.previousNode)||void 0===o?void 0:o.content)?n.previousNode.content:[];return"paragraph"===(null==n||null===(i=n.previousNode)||void 0===i?void 0:i.type)&&0===a.length?nD:""}return t.renderChildren(r)},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),oD=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,iD=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,aD=ap.create({name:"strike",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:function(e){return!!e.includes("line-through")&&{}}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["s",mf(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:function(e,t){return t.applyMark("strike",t.parseInline(e.tokens||[]))},renderMarkdown:function(e,t){return"~~".concat(t.renderChildren(e),"~~")},addCommands:function(){var e=this;return{setStrike:function(){return function(t){return t.commands.setMark(e.name)}},toggleStrike:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetStrike:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-s":function(){return e.editor.commands.toggleStrike()}}},addInputRules:function(){return[xp({find:oD,type:this.type})]},addPasteRules:function(){return[Mp({find:iD,type:this.type})]}}),uD=Tp.create({name:"text",group:"inline",parseMarkdown:function(e){return{type:"text",text:e.text||""}},renderMarkdown:function(e){return e.text||""}}),sD=ap.create({name:"underline",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:function(e){return!!e.includes("underline")&&{}}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["u",mf(this.options.HTMLAttributes,t),0]},parseMarkdown:function(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:function(e,t){return"++".concat(t.renderChildren(e),"++")},markdownTokenizer:{name:"underline",level:"inline",start:function(e){return e.indexOf("++")},tokenize:function(e,t,n){var r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(r){var o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}}},addCommands:function(){var e=this;return{setUnderline:function(){return function(t){return t.commands.setMark(e.name)}},toggleUnderline:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetUnderline:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-u":function(){return e.editor.commands.toggleUnderline()},"Mod-U":function(){return e.editor.commands.toggleUnderline()}}}});function lD(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new la({view:function(t){return new cD(t,e)}})}var cD=function(){return x(function e(t,n){var r,o=this;M(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=null!==(r=n.width)&&void 0!==r?r:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){var n=function(t){o[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})},[{key:"destroy",value:function(){var e=this;this.setCursor(null),this.handlers.forEach(function(t){var n=t.name,r=t.handler;return e.editorView.dom.removeEventListener(n,r)})}},{key:"update",value:function(e,t){if(null!=this.cursorPos&&t.doc!=e.state.doc)if(this.lastDragEvent){var n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,o=r.getBoundingClientRect(),i=o.width/r.offsetWidth,a=o.height/r.offsetHeight;if(n){var u=t.nodeBefore,s=t.nodeAfter;if(u||s){var l=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(l){var c=l.getBoundingClientRect(),d=u?c.bottom:c.top;u&&s&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);var f=this.width/2*a;e={left:c.left,right:c.right,top:d-f,bottom:d+f}}}}if(!e){var h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*i;e={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}var v,m,g=this.editorView.dom.offsetParent;if(this.element||(this.element=g.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!g||g==document.body&&"static"==getComputedStyle(g).position)v=-pageXOffset,m=-pageYOffset;else{var D=g.getBoundingClientRect(),y=D.width/g.offsetWidth,k=D.height/g.offsetHeight;v=D.left-g.scrollLeft*y,m=D.top-g.scrollTop*k}this.element.style.left=(e.left-v)/i+"px",this.element.style.top=(e.top-m)/a+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/a+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)}},{key:"computeTarget",value:function(e){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,t,e):r;if(!t||o)return null;var i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var a=Ai(this.editorView.state.doc,i,this.editorView.dragging.slice);null!=a&&(i=a)}return i}},{key:"dragover",value:function(e){if(this.editorView.editable){this.lastDragEvent=e;var t=this.computeTarget(e);null!=t&&(this.setCursor(t),this.scheduleRemoval(5e3))}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}])}(),dD=function(){function e(t){return M(this,e),N(this,e,[t,t])}return A(e,Ui),x(e,[{key:"map",value:function(t,n){var r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Ui.near(r)}},{key:"content",value:function(){return Qr.empty}},{key:"eq",value:function(t){return t instanceof e&&t.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new fD(this.anchor)}}],[{key:"fromJSON",value:function(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.inlineContent||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),r=e.node(t);if(0!=n)for(var o=r.child(n-1);;o=o.lastChild){if(0==o.childCount&&!o.inlineContent||hD(o.type))return!0;if(o.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(var o=r.child(n);;o=o.firstChild){if(0==o.childCount&&!o.inlineContent||hD(o.type))return!0;if(o.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}},{key:"findGapCursorFrom",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!r&&e.valid(t))return t;for(var o=t.pos,i=null,a=t.depth;;a--){var u=t.node(a);if(n>0?t.indexAfter(a)<u.childCount:t.index(a)>0){i=u.child(n>0?t.indexAfter(a):t.index(a)-1);break}if(0==a)return null;o+=n;var s=t.doc.resolve(o);if(e.valid(s))return s}for(;;){var l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!Gi.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=l,o+=n;var c=t.doc.resolve(o);if(e.valid(c))return c}return null}}}])}();dD.prototype.visible=!1,dD.findFrom=dD.findGapCursorFrom,Ui.jsonID("gapcursor",dD);var fD=function(){function e(t){M(this,e),this.pos=t}return x(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return dD.valid(t)?new dD(t):Ui.near(t)}}])}();function hD(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}var pD=mc({ArrowLeft:vD("horiz",-1),ArrowRight:vD("horiz",1),ArrowUp:vD("vert",-1),ArrowDown:vD("vert",1)});function vD(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){var i=e.selection,a=t>0?i.$to:i.$from,u=i.empty;if(i instanceof Ji){if(!o.endOfTextblock(n)||0==a.depth)return!1;u=!1,a=e.doc.resolve(t>0?a.after():a.before())}var s=dD.findGapCursorFrom(a,t,u);return!!s&&(r&&r(e.tr.setSelection(new dD(s))),!0)}}function mD(e,t,n){if(!e||!e.editable)return!1;var r=e.state.doc.resolve(t);if(!dD.valid(r))return!1;var o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&Gi.isSelectable(e.state.doc.nodeAt(o.inside)))&&(e.dispatch(e.state.tr.setSelection(new dD(r))),!0)}function gD(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof dD))return!1;var n=e.state.selection.$from,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;for(var o=Vr.empty,i=r.length-1;i>=0;i--)o=Vr.from(r[i].createAndFill(null,o));var a=e.state.tr.replace(n.pos,n.pos,new Qr(o,0,0));return a.setSelection(Ji.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function DD(e){if(!(e.selection instanceof dD))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",Bl.create(e.doc,[Al.widget(e.selection.head,t,{key:"gapcursor"})])}fp.create({name:"characterCount",addOptions:function(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:function(e){return e.length},wordCounter:function(e){return e.split(" ").filter(function(e){return""!==e}).length}}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||e.options.mode)){var r=n.textBetween(0,n.content.size,void 0," ");return e.options.textCounter(r)}return n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc,r=n.textBetween(0,n.content.size," "," ");return e.options.wordCounter(r)}},addProseMirrorPlugins:function(){var e=this,t=!1;return[new la({key:new fa("characterCount"),appendTransaction:function(n,r,o){if(!t){var i=e.options.limit,a=e.options.autoTrim;if(null!=i&&0!==i&&!1!==a){var u=e.storage.characters({node:o.doc});if(u>i){var s=u-i;console.warn("[CharacterCount] Initial content exceeded limit of ".concat(i," characters. Content was automatically trimmed."));var l=o.tr.deleteRange(0,s);return t=!0,l}t=!0}else t=!0}},filterTransaction:function(t,n){var r=e.options.limit;if(!t.docChanged||0===r||null==r)return!0;var o=e.storage.characters({node:n.doc}),i=e.storage.characters({node:t.doc});if(i<=r)return!0;if(o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o)return!1;if(!t.getMeta("paste"))return!1;var a=t.selection.$head.pos,u=a-(i-r),s=a;return t.deleteRange(u,s),!(e.storage.characters({node:t.doc})>r)}})]}});var yD=fp.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[lD(this.options)]}});fp.create({name:"focus",addOptions:function(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins:function(){var e=this;return[new la({key:new fa("focus"),props:{decorations:function(t){var n=t.doc,r=t.selection,o=e.editor,i=o.isEditable,a=o.isFocused,u=r.anchor,s=[];if(!i||!a)return Bl.create(n,[]);var l=0;"deepest"===e.options.mode&&n.descendants(function(e,t){if(!e.isText)return u>=t&&u<=t+e.nodeSize-1&&void(l+=1)});var c=0;return n.descendants(function(t,n){return!t.isText&&(u>=n&&u<=n+t.nodeSize-1&&(c+=1,"deepest"===e.options.mode&&l-c>0||"shallowest"===e.options.mode&&c>1?"deepest"===e.options.mode:void s.push(Al.node(n,n+t.nodeSize,{class:e.options.className}))))}),Bl.create(n,s)}}})]}});var kD=fp.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new la({props:{decorations:DD,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&dD.valid(n)?new dD(n):null},handleClick:mD,handleKeyDown:pD,handleDOMEvents:{beforeinput:gD}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!==(t=pf(tf(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}}),ED="placeholder",FD=new fa("tiptap__placeholder");function bD(e){var t=e.editor,n=e.placeholder,r=e.dataAttribute,o=e.pos,i=e.node,a=e.isEmptyDoc,u=e.hasAnchor,s=e.classes,l=s.emptyNode,c=s.emptyEditor,d=[l];return a&&d.push(c),Al.node(o,o+i.nodeSize,S({class:d.join(" ")},r,"function"==typeof n?n({editor:t,node:i,pos:o,hasAnchor:u}):n))}function CD(e,t){return"function"==typeof e?e(t):e}function wD(e){var t=e.editor,n=e.options,r=e.dataAttribute,o=e.doc,i=e.selection,a=e.from,u=e.to,s=i.anchor,l=[],c=t.isEmpty;return o.nodesBetween(a,u,function(e,o){var i=s>=o&&s<=o+e.nodeSize,a=!e.isLeaf&&zf(e);return e.type.isTextblock?(!i&&n.showOnlyCurrent||!a||l.push(bD({editor:t,isEmptyDoc:c,dataAttribute:r,hasAnchor:i,placeholder:n.placeholder,classes:{emptyEditor:n.emptyEditorClass,emptyNode:CD(n.emptyNodeClass,{editor:t,node:e,pos:o,hasAnchor:i})},node:e,pos:o})),n.includeChildren):n.includeChildren}),l}function AD(e){var t=e.editor,n=e.options,r=e.dataAttribute,i=e.doc,a=e.selection;if(!t.isEditable&&n.showOnlyWhenEditable)return null;var u=a.anchor,s=[],l=t.isEmpty;if(n.showOnlyCurrent&&!n.includeChildren){var c=i.resolve(u),d=c.depth>0?c.node(1):c.nodeAfter,f=c.depth>0?c.before(1):u;if(d&&d.type.isTextblock&&zf(d)){var h=u>=f&&u<=f+d.nodeSize;s.push(bD({editor:t,isEmptyDoc:l,dataAttribute:r,hasAnchor:h,placeholder:n.placeholder,classes:{emptyEditor:n.emptyEditorClass,emptyNode:CD(n.emptyNodeClass,{editor:t,node:d,pos:f,hasAnchor:h})},node:d,pos:f}))}}else s.push.apply(s,o(wD({editor:t,options:n,dataAttribute:r,doc:i,selection:a,from:0,to:i.content.size})));return Bl.create(i,s)}function xD(e,t){var n=e.resolve(t);if(0===n.depth){var r,o=null!==(r=n.nodeAfter)&&void 0!==r?r:n.nodeBefore;if(!o)return{from:t,to:t};var i=n.nodeAfter?t:t-o.nodeSize;return{from:i,to:i+o.nodeSize}}var a=n.before(1);return{from:a,to:a+n.node(1).nodeSize}}function SD(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function BD(e,t){var n=function(e,t,n){var r=[];return e.forEach(function(e,o){var i=o,a=i+e.nodeSize;i+1<n&&a+1>t&&r.push({from:i,to:a})}),r}(e,t.from,t.to);return n.push(SD(e,xD(e,t.from))),t.to>t.from?n.push(SD(e,xD(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(SD(e,xD(e,Math.min(t.from+1,e.content.size)))),n}function TD(t,n,r){var i=[];if(t.docChanged){var a,u=Mf(t),s=j(u);try{for(s.s();!(a=s.n()).done;){var l=a.value;i.push.apply(i,o(BD(r.doc,l.newRange)))}}catch(e){s.e(e)}finally{s.f()}}return t.selectionSet&&(i.push(SD(r.doc,xD(r.doc,t.mapping.map(n.selection.anchor)))),i.push(SD(r.doc,xD(r.doc,r.selection.anchor)))),function(t){if(0===t.length)return[];for(var n=o(t).sort(function(e,t){return e.from-t.from}),r=[e({},n[0])],i=1;i<n.length;i+=1){var a=r[r.length-1],u=n[i];u.from<=a.to?a.to=Math.max(a.to,u.to):r.push(e({},u))}return r}(i)}function MD(e){var t,n=e.decorations,r=e.ranges,o=e.editor,i=e.options,a=e.dataAttribute,u=e.doc,s=e.selection,l=n,c=j(r);try{var d=function(){var e=t.value,n=function(e,t,n){var r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}(e.from,e.to,u),r=n.from,c=n.to,d=l.find(r,c).filter(function(e){return e.from>=r&&e.to<=c});d.length&&(l=l.remove(d));var f=wD({editor:o,options:i,dataAttribute:a,doc:u,selection:s,from:r,to:c});f.length&&(l=l.add(u,f))};for(c.s();!(t=c.n()).done;)d()}catch(e){c.e(e)}finally{c.f()}return l}function ND(e){var t=e.editor,n=e.options,r=e.dataAttribute;return{init:function(e,o){var i=AD({editor:t,options:n,dataAttribute:r,doc:o.doc,selection:o.selection});return null!=i?i:Bl.empty},apply:function(e,o,i,a){return e.docChanged||e.selectionSet?MD({decorations:o.map(e.mapping,e.doc),ranges:TD(e,i,a),editor:t,options:n,dataAttribute:r,doc:a.doc,selection:a.selection}):o}}}var RD=fp.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:ED,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){return[(t={editor:this.editor,options:this.options},n=t.editor,r=t.options,o=r.dataAttribute?"data-".concat(r.dataAttribute.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()):"data-".concat(ED),i=r.showOnlyCurrent&&!r.includeChildren,new la(e(e({key:FD},i?{}:{state:ND({editor:n,options:r,dataAttribute:o})}),{},{props:{decorations:i?function(e){var t=e.doc,i=e.selection;return AD({editor:n,options:r,dataAttribute:o,doc:t,selection:i})}:function(e){var t;return r.showOnlyWhenEditable&&!n.isEditable?Bl.empty:null!==(t=FD.getState(e))&&void 0!==t?t:Bl.empty}}})))];var t,n,r,o,i}});function OD(e,t){return!e.selection.empty&&!$f(e.selection)&&t.isEditable}function ID(e){var t=e.types,n=e.node;return n&&Array.isArray(t)&&t.includes(n.type)||(null==n?void 0:n.type)===t}fp.create({name:"selection",addOptions:function(){return{className:"selection"}},addProseMirrorPlugins:function(){var e=this.editor,t=this.options;return[new la({key:new fa("selection"),props:{decorations:function(n){return function(e,t){return OD(e,t)&&!t.isFocused&&!t.view.dragging}(n,e)?Bl.create(n.doc,[Al.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur:function(t){return!!OD(t.state,e)&&(null===(n=window.getSelection())||void 0===n||n.removeAllRanges(),!1);var n},focus:function(t){return!!OD(t.state,e)&&(requestAnimationFrame(function(){!e.isDestroyed&&t.hasFocus()&&function(e){e.focus()}(t)}),!1)}}}})]}});var PD,LD=fp.create({name:"trailingNode",addOptions:function(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins:function(){var e,t=this,n=new fa(this.name),r=this.options.node||(null===(e=this.editor.schema.topNodeType.contentMatch.defaultType)||void 0===e?void 0:e.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(function(e){return i(e,2)[1]}).filter(function(e){return(t.options.notAfter||[]).concat(r).includes(e.name)});return[new la({key:n,appendTransaction:function(e,t,o){var i=o.doc,a=o.tr,u=o.schema,s=n.getState(o),l=i.content.size,c=u.nodes[r];if(!e.some(function(e){return e.getMeta("skipTrailingNode")})&&s)return a.insert(l,c.create())},state:{init:function(e,t){return!ID({node:t.tr.doc.lastChild,types:o})},apply:function(e,t){return e.docChanged?e.getMeta("__uniqueIDTransaction")?t:!ID({node:e.doc.lastChild,types:o}):t}}})]}}),zD=fp.create({name:"undoRedo",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return Oc(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return Ic(t,n)}}}},addProseMirrorPlugins:function(){return[Nc(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),$D=fp.create({name:"starterKit",addExtensions:function(){var e,t,n,r,o=[];(!1!==this.options.bold&&o.push(_p.configure(this.options.bold)),!1!==this.options.blockquote&&o.push(jp.configure(this.options.blockquote)),!1!==this.options.bulletList&&o.push(mg.configure(this.options.bulletList)),!1!==this.options.code&&o.push(Qp.configure(this.options.code)),!1!==this.options.codeBlock&&o.push(Zp.configure(this.options.codeBlock)),!1!==this.options.document&&o.push(Yp.configure(this.options.document)),!1!==this.options.dropcursor&&o.push(yD.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&o.push(kD.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&o.push(ev.configure(this.options.hardBreak)),!1!==this.options.heading&&o.push(tv.configure(this.options.heading)),!1!==this.options.undoRedo&&o.push(zD.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&o.push(nv.configure(this.options.horizontalRule)),!1!==this.options.italic&&o.push(uv.configure(this.options.italic)),!1!==this.options.listItem&&o.push(Mg.configure(this.options.listItem)),!1!==this.options.listKeymap)&&o.push(Lg.configure(null===(e=this.options)||void 0===e?void 0:e.listKeymap));!1!==this.options.link&&o.push(fg.configure(null===(t=this.options)||void 0===t?void 0:t.link));(!1!==this.options.orderedList&&o.push(Zg.configure(this.options.orderedList)),!1!==this.options.paragraph&&o.push(rD.configure(this.options.paragraph)),!1!==this.options.strike&&o.push(aD.configure(this.options.strike)),!1!==this.options.text&&o.push(uD.configure(this.options.text)),!1!==this.options.underline)&&o.push(sD.configure(null===(n=this.options)||void 0===n?void 0:n.underline));!1!==this.options.trailingNode&&o.push(LD.configure(null===(r=this.options)||void 0===r?void 0:r.trailingNode));return o}});function qD(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jD={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function HD(e){jD=e}var VD={exec:function(){return null}};function UD(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="string"==typeof e?e:e.source,r={replace:function(e,t){var o="string"==typeof t?t:t.source;return o=o.replace(_D.caret,"$1"),n=n.replace(e,o),r},getRegex:function(){return new RegExp(n,t)}};return r}var WD=function(){try{return!!new RegExp("(?<=1)(?<!1)")}catch(e){return!1}}(),_D={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDD40-\uDD65\uDD6F-\uDD85\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDF70-\uDF81\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDDB0-\uDDDB\uDDE0-\uDDE9\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D\uDD30-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE96\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD833[\uDCF0-\uDCF9]|\uD834[\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD839[\uDCD0-\uDCEB\uDCF0-\uDCF9\uDDD0-\uDDED\uDDF0-\uDDFA\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])/,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:function(e){return new RegExp("^( {0,3}".concat(e,")((?:[\t ][^\\n]*)?(?:\\n|$))"))},nextBulletRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))"))},hrRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)"))},fencesBeginRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}(?:```|~~~)"))},headingBeginRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}#"))},htmlBeginRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}<(?:[a-z].*>|!--)"),"i")},blockquoteBeginRegex:function(e){return new RegExp("^ {0,".concat(Math.min(3,e-1),"}>"))}},KD=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,JD=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,QD=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,GD=UD(QD).replace(/bull/g,JD).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),XD=UD(QD).replace(/bull/g,JD).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ZD=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,YD=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ey=UD(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",YD).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ty=UD(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,JD).getRegex(),ny="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ry=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,oy=UD("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",ry).replace("tag",ny).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),iy=UD(ZD).replace("hr",KD).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ny).getRegex(),ay={blockquote:UD(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",iy).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:ey,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:KD,html:oy,lheading:GD,list:ty,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:iy,table:VD,text:/^[^\n]+/},uy=UD("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",KD).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ny).getRegex(),sy=e(e({},ay),{},{lheading:XD,table:uy,paragraph:UD(ZD).replace("hr",KD).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",uy).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ny).getRegex()}),ly=e(e({},ay),{},{html:UD("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ry).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:VD,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:UD(ZD).replace("hr",KD).replace("heading"," *#{1,6} *[^\n]").replace("lheading",GD).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),cy=/^( {2,}|\\)\n(?!\s*$)/,dy=/(?:[!-\/:-@\[-`\{-~\xA1-\xA9\xAB\xAC\xAE-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u066A-\u066D\u06D4\u06DE\u06E9\u06FD\u06FE\u0700-\u070D\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964\u0965\u0970\u09F2\u09F3\u09FA\u09FB\u09FD\u0A76\u0AF0\u0AF1\u0B70\u0BF3-\u0BFA\u0C77\u0C7F\u0C84\u0D4F\u0D79\u0DF4\u0E3F\u0E4F\u0E5A\u0E5B\u0F01-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u104A-\u104F\u109E\u109F\u10FB\u1360-\u1368\u1390-\u1399\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u1800-\u180A\u1940\u1944\u1945\u19DE-\u19FF\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2010-\u2027\u2030-\u205E\u207A-\u207E\u208A-\u208E\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2775\u2794-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3001-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uFB29\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD00-\uDD02\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDC77\uDC78\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEC8\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDD8E\uDD8F\uDEAD\uDED0-\uDED8\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3F]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFD5-\uDFF1\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3F\uDF44\uDF45]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F[\uDC9C\uDC9F]|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE8B]|\uD838[\uDD4F\uDEFF]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA])/,fy=/(?:[\t-\r -\/:-@\[-`\{-~\xA0-\xA9\xAB\xAC\xAE-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u066A-\u066D\u06D4\u06DE\u06E9\u06FD\u06FE\u0700-\u070D\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964\u0965\u0970\u09F2\u09F3\u09FA\u09FB\u09FD\u0A76\u0AF0\u0AF1\u0B70\u0BF3-\u0BFA\u0C77\u0C7F\u0C84\u0D4F\u0D79\u0DF4\u0E3F\u0E4F\u0E5A\u0E5B\u0F01-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u104A-\u104F\u109E\u109F\u10FB\u1360-\u1368\u1390-\u1399\u1400\u166D\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u1800-\u180A\u1940\u1944\u1945\u19DE-\u19FF\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2000-\u200A\u2010-\u2029\u202F-\u205F\u207A-\u207E\u208A-\u208E\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2775\u2794-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uFB29\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFEFF\uFF01-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD00-\uDD02\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDC77\uDC78\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEC8\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDD8E\uDD8F\uDEAD\uDED0-\uDED8\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3F]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFD5-\uDFF1\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3F\uDF44\uDF45]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F[\uDC9C\uDC9F]|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE8B]|\uD838[\uDD4F\uDEFF]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA])/,hy=/(?:[\0-\x08\x0E-\x1F0-9A-Za-z\x7F-\x9F\xAA\xAD\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376-\u037D\u037F-\u0383\u0386\u0388-\u03F5\u03F7-\u0481\u0483-\u0559\u0560-\u0588\u058B\u058C\u0590-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0605\u0610-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06DD\u06DF-\u06E8\u06EA-\u06FC\u06FF\u070E-\u07F5\u07FA-\u07FD\u0800-\u082F\u083F-\u085D\u085F-\u0887\u0889-\u0963\u0966-\u096F\u0971-\u09F1\u09F4-\u09F9\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF2-\u0B6F\u0B71-\u0BF2\u0BFB-\u0C76\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0D4E\u0D50-\u0D78\u0D7A-\u0DF3\u0DF5-\u0E3E\u0E40-\u0E4E\u0E50-\u0E59\u0E5C-\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F84\u0F86-\u0FBD\u0FC6\u0FCD\u0FDB-\u1049\u1050-\u109D\u10A0-\u10FA\u10FC-\u135F\u1369-\u138F\u139A-\u13FF\u1401-\u166C\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DC-\u17FF\u180B-\u193F\u1941-\u1943\u1946-\u19DD\u1A00-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FBC\u1FBE\u1FC2-\u1FCC\u1FD0-\u1FDC\u1FE0-\u1FEC\u1FF0-\u1FFC\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u2079\u207F-\u2089\u208F-\u209F\u20C2-\u20FF\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u218C-\u218F\u242A-\u243F\u244B-\u249B\u24EA-\u24FF\u2776-\u2793\u2B74\u2B75\u2C00-\u2CE4\u2CEB-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E5E-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3040-\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u318F\u3192-\u3195\u31A0-\u31BF\u31E6-\u31EE\u31F0-\u31FF\u321F-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48F\uA4C7-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA6FF\uA717-\uA71F\uA722-\uA788\uA78B-\uA827\uA82C-\uA835\uA83A-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAA76\uAA7A-\uAADD\uAAE0-\uAAEF\uAAF2-\uAB5A\uAB5C-\uAB69\uAB6C-\uABEA\uABEC-\uD7FF\uE000-\uFB28\uFB2A-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDD0-\uFDFB\uFE00-\uFE0F\uFE1A-\uFE2F\uFE53\uFE67\uFE6C-\uFEFE\uFF00\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]|\uD800[\uDC00-\uDCFF\uDD03-\uDD36\uDD40-\uDD78\uDD8A\uDD8B\uDD8F\uDD9D-\uDD9F\uDDA1-\uDDCF\uDDFD-\uDF9E\uDFA0-\uDFCF\uDFD1-\uDFFF]|\uD801[\uDC00-\uDD6E\uDD70-\uDFFF]|\uD802[\uDC00-\uDC56\uDC58-\uDC76\uDC79-\uDD1E\uDD20-\uDD3E\uDD40-\uDE4F\uDE59-\uDE7E\uDE80-\uDEC7\uDEC9-\uDEEF\uDEF7-\uDF38\uDF40-\uDF98\uDF9D-\uDFFF]|\uD803[\uDC00-\uDD6D\uDD6F-\uDD8D\uDD90-\uDEAC\uDEAE-\uDECF\uDED9-\uDF54\uDF5A-\uDF85\uDF8A-\uDFFF]|\uD804[\uDC00-\uDC46\uDC4E-\uDCBA\uDCBD\uDCC2-\uDD3F\uDD44-\uDD73\uDD76-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE0-\uDE37\uDE3E-\uDEA8\uDEAA-\uDFD3\uDFD6\uDFD9-\uDFFF]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5C\uDC5E-\uDCC5\uDCC7-\uDDC0\uDDD8-\uDE40\uDE44-\uDE5F\uDE6D-\uDEB8\uDEBA-\uDF3B\uDF40-\uDFFF]|\uD806[\uDC00-\uDC3A\uDC3C-\uDD43\uDD47-\uDDE1\uDDE3-\uDE3E\uDE47-\uDE99\uDE9D\uDEA3-\uDEFF\uDF0A-\uDFE0\uDFE2-\uDFFF]|\uD807[\uDC00-\uDC40\uDC46-\uDC6F\uDC72-\uDEF6\uDEF9-\uDF42\uDF50-\uDFD4\uDFF2-\uDFFE]|[\uD808\uD80A\uD80C-\uD819\uD81C-\uD82E\uD830-\uD832\uD837\uD83F-\uDBFF][\uDC00-\uDFFF]|\uD809[\uDC00-\uDC6F\uDC75-\uDFFF]|\uD80B[\uDC00-\uDFF0\uDFF3-\uDFFF]|\uD81A[\uDC00-\uDE6D\uDE70-\uDEF4\uDEF6-\uDF36\uDF40-\uDF43\uDF46-\uDFFF]|\uD81B[\uDC00-\uDD6C\uDD70-\uDE96\uDE9B-\uDFE1\uDFE3-\uDFFF]|\uD82F[\uDC00-\uDC9B\uDC9D\uDC9E\uDCA0-\uDFFF]|\uD833[\uDCF0-\uDCF9\uDCFD-\uDCFF\uDEB4-\uDEB9\uDED1-\uDEDF\uDEF1-\uDF4F\uDFC4-\uDFFF]|\uD834[\uDCF6-\uDCFF\uDD27\uDD28\uDD65-\uDD69\uDD6D-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDDEB-\uDDFF\uDE42-\uDE44\uDE46-\uDEFF\uDF57-\uDFFF]|\uD835[\uDC00-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE8C-\uDFFF]|\uD838[\uDC00-\uDD4E\uDD50-\uDEFE\uDF00-\uDFFF]|\uD839[\uDC00-\uDDFE\uDE00-\uDFFF]|\uD83A[\uDC00-\uDD5D\uDD60-\uDFFF]|\uD83B[\uDC00-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDD2D\uDD2F-\uDEEF\uDEF2-\uDFFF]|\uD83C[\uDC2C-\uDC2F\uDC94-\uDC9F\uDCAF\uDCB0\uDCC0\uDCD0\uDCF6-\uDD0C\uDDAE-\uDDE5\uDE03-\uDE0F\uDE3C-\uDE3F\uDE49-\uDE4F\uDE52-\uDE5F\uDE66-\uDEFF]|\uD83D[\uDED9-\uDEDB\uDEED-\uDEEF\uDEFD-\uDEFF\uDFDA-\uDFDF\uDFEC-\uDFEF\uDFF1-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE\uDCAF\uDCBC-\uDCBF\uDCC2-\uDCCF\uDCD9-\uDCFF\uDE58-\uDE5F\uDE6E\uDE6F\uDE7D-\uDE7F\uDE8B-\uDE8D\uDEC7\uDEC9-\uDECC\uDEDD\uDEDE\uDEEB-\uDEEE\uDEF9-\uDEFF\uDF93\uDFF0-\uDFF9\uDFFB-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,py=UD(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,fy).getRegex(),vy=/(?!~)(?:[!-\/:-@\[-`\{-~\xA1-\xA9\xAB\xAC\xAE-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u066A-\u066D\u06D4\u06DE\u06E9\u06FD\u06FE\u0700-\u070D\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964\u0965\u0970\u09F2\u09F3\u09FA\u09FB\u09FD\u0A76\u0AF0\u0AF1\u0B70\u0BF3-\u0BFA\u0C77\u0C7F\u0C84\u0D4F\u0D79\u0DF4\u0E3F\u0E4F\u0E5A\u0E5B\u0F01-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u104A-\u104F\u109E\u109F\u10FB\u1360-\u1368\u1390-\u1399\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u1800-\u180A\u1940\u1944\u1945\u19DE-\u19FF\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2010-\u2027\u2030-\u205E\u207A-\u207E\u208A-\u208E\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2775\u2794-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3001-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uFB29\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD00-\uDD02\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDC77\uDC78\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEC8\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDD8E\uDD8F\uDEAD\uDED0-\uDED8\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3F]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFD5-\uDFF1\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3F\uDF44\uDF45]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F[\uDC9C\uDC9F]|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE8B]|\uD838[\uDD4F\uDEFF]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA])/,my=UD(/link|precode-code|html/,"g").replace("link",_(/\[(?:[^\[\]`]|(`+)[^`]+\1(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/,{a:1})).replace("precode-",WD?"(?<!`)()":"(^^|[^`])").replace("code",_(/(`+)[^`]+\1(?!`)/,{b:1})).replace("html",/<(?! )[^<>]*?>/).getRegex(),gy=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Dy=UD(gy,"u").replace(/punct/g,dy).getRegex(),yy=UD(gy,"u").replace(/punct/g,vy).getRegex(),ky="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ey=UD(ky,"gu").replace(/notPunctSpace/g,hy).replace(/punctSpace/g,fy).replace(/punct/g,dy).getRegex(),Fy=UD(ky,"gu").replace(/notPunctSpace/g,/(?:(?:[\0-\x08\x0E-\x1F0-9A-Za-z\x7F-\x9F\xAA\xAD\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376-\u037D\u037F-\u0383\u0386\u0388-\u03F5\u03F7-\u0481\u0483-\u0559\u0560-\u0588\u058B\u058C\u0590-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0605\u0610-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06DD\u06DF-\u06E8\u06EA-\u06FC\u06FF\u070E-\u07F5\u07FA-\u07FD\u0800-\u082F\u083F-\u085D\u085F-\u0887\u0889-\u0963\u0966-\u096F\u0971-\u09F1\u09F4-\u09F9\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF2-\u0B6F\u0B71-\u0BF2\u0BFB-\u0C76\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0D4E\u0D50-\u0D78\u0D7A-\u0DF3\u0DF5-\u0E3E\u0E40-\u0E4E\u0E50-\u0E59\u0E5C-\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F84\u0F86-\u0FBD\u0FC6\u0FCD\u0FDB-\u1049\u1050-\u109D\u10A0-\u10FA\u10FC-\u135F\u1369-\u138F\u139A-\u13FF\u1401-\u166C\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DC-\u17FF\u180B-\u193F\u1941-\u1943\u1946-\u19DD\u1A00-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FBC\u1FBE\u1FC2-\u1FCC\u1FD0-\u1FDC\u1FE0-\u1FEC\u1FF0-\u1FFC\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u2079\u207F-\u2089\u208F-\u209F\u20C2-\u20FF\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u218C-\u218F\u242A-\u243F\u244B-\u249B\u24EA-\u24FF\u2776-\u2793\u2B74\u2B75\u2C00-\u2CE4\u2CEB-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E5E-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3040-\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u318F\u3192-\u3195\u31A0-\u31BF\u31E6-\u31EE\u31F0-\u31FF\u321F-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48F\uA4C7-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA6FF\uA717-\uA71F\uA722-\uA788\uA78B-\uA827\uA82C-\uA835\uA83A-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAA76\uAA7A-\uAADD\uAAE0-\uAAEF\uAAF2-\uAB5A\uAB5C-\uAB69\uAB6C-\uABEA\uABEC-\uD7FF\uE000-\uFB28\uFB2A-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDD0-\uFDFB\uFE00-\uFE0F\uFE1A-\uFE2F\uFE53\uFE67\uFE6C-\uFEFE\uFF00\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]|\uD800[\uDC00-\uDCFF\uDD03-\uDD36\uDD40-\uDD78\uDD8A\uDD8B\uDD8F\uDD9D-\uDD9F\uDDA1-\uDDCF\uDDFD-\uDF9E\uDFA0-\uDFCF\uDFD1-\uDFFF]|\uD801[\uDC00-\uDD6E\uDD70-\uDFFF]|\uD802[\uDC00-\uDC56\uDC58-\uDC76\uDC79-\uDD1E\uDD20-\uDD3E\uDD40-\uDE4F\uDE59-\uDE7E\uDE80-\uDEC7\uDEC9-\uDEEF\uDEF7-\uDF38\uDF40-\uDF98\uDF9D-\uDFFF]|\uD803[\uDC00-\uDD6D\uDD6F-\uDD8D\uDD90-\uDEAC\uDEAE-\uDECF\uDED9-\uDF54\uDF5A-\uDF85\uDF8A-\uDFFF]|\uD804[\uDC00-\uDC46\uDC4E-\uDCBA\uDCBD\uDCC2-\uDD3F\uDD44-\uDD73\uDD76-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE0-\uDE37\uDE3E-\uDEA8\uDEAA-\uDFD3\uDFD6\uDFD9-\uDFFF]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5C\uDC5E-\uDCC5\uDCC7-\uDDC0\uDDD8-\uDE40\uDE44-\uDE5F\uDE6D-\uDEB8\uDEBA-\uDF3B\uDF40-\uDFFF]|\uD806[\uDC00-\uDC3A\uDC3C-\uDD43\uDD47-\uDDE1\uDDE3-\uDE3E\uDE47-\uDE99\uDE9D\uDEA3-\uDEFF\uDF0A-\uDFE0\uDFE2-\uDFFF]|\uD807[\uDC00-\uDC40\uDC46-\uDC6F\uDC72-\uDEF6\uDEF9-\uDF42\uDF50-\uDFD4\uDFF2-\uDFFE]|[\uD808\uD80A\uD80C-\uD819\uD81C-\uD82E\uD830-\uD832\uD837\uD83F-\uDBFF][\uDC00-\uDFFF]|\uD809[\uDC00-\uDC6F\uDC75-\uDFFF]|\uD80B[\uDC00-\uDFF0\uDFF3-\uDFFF]|\uD81A[\uDC00-\uDE6D\uDE70-\uDEF4\uDEF6-\uDF36\uDF40-\uDF43\uDF46-\uDFFF]|\uD81B[\uDC00-\uDD6C\uDD70-\uDE96\uDE9B-\uDFE1\uDFE3-\uDFFF]|\uD82F[\uDC00-\uDC9B\uDC9D\uDC9E\uDCA0-\uDFFF]|\uD833[\uDCF0-\uDCF9\uDCFD-\uDCFF\uDEB4-\uDEB9\uDED1-\uDEDF\uDEF1-\uDF4F\uDFC4-\uDFFF]|\uD834[\uDCF6-\uDCFF\uDD27\uDD28\uDD65-\uDD69\uDD6D-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDDEB-\uDDFF\uDE42-\uDE44\uDE46-\uDEFF\uDF57-\uDFFF]|\uD835[\uDC00-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE8C-\uDFFF]|\uD838[\uDC00-\uDD4E\uDD50-\uDEFE\uDF00-\uDFFF]|\uD839[\uDC00-\uDDFE\uDE00-\uDFFF]|\uD83A[\uDC00-\uDD5D\uDD60-\uDFFF]|\uD83B[\uDC00-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDD2D\uDD2F-\uDEEF\uDEF2-\uDFFF]|\uD83C[\uDC2C-\uDC2F\uDC94-\uDC9F\uDCAF\uDCB0\uDCC0\uDCD0\uDCF6-\uDD0C\uDDAE-\uDDE5\uDE03-\uDE0F\uDE3C-\uDE3F\uDE49-\uDE4F\uDE52-\uDE5F\uDE66-\uDEFF]|\uD83D[\uDED9-\uDEDB\uDEED-\uDEEF\uDEFD-\uDEFF\uDFDA-\uDFDF\uDFEC-\uDFEF\uDFF1-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE\uDCAF\uDCBC-\uDCBF\uDCC2-\uDCCF\uDCD9-\uDCFF\uDE58-\uDE5F\uDE6E\uDE6F\uDE7D-\uDE7F\uDE8B-\uDE8D\uDEC7\uDEC9-\uDECC\uDEDD\uDEDE\uDEEB-\uDEEE\uDEF9-\uDEFF\uDF93\uDFF0-\uDFF9\uDFFB-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])|~)/).replace(/punctSpace/g,/(?!~)(?:[\t-\r -\/:-@\[-`\{-~\xA0-\xA9\xAB\xAC\xAE-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u066A-\u066D\u06D4\u06DE\u06E9\u06FD\u06FE\u0700-\u070D\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964\u0965\u0970\u09F2\u09F3\u09FA\u09FB\u09FD\u0A76\u0AF0\u0AF1\u0B70\u0BF3-\u0BFA\u0C77\u0C7F\u0C84\u0D4F\u0D79\u0DF4\u0E3F\u0E4F\u0E5A\u0E5B\u0F01-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u104A-\u104F\u109E\u109F\u10FB\u1360-\u1368\u1390-\u1399\u1400\u166D\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u1800-\u180A\u1940\u1944\u1945\u19DE-\u19FF\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2000-\u200A\u2010-\u2029\u202F-\u205F\u207A-\u207E\u208A-\u208E\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2775\u2794-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uFB29\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFEFF\uFF01-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD00-\uDD02\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDC77\uDC78\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEC8\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDD8E\uDD8F\uDEAD\uDED0-\uDED8\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3F]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFD5-\uDFF1\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3F\uDF44\uDF45]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F[\uDC9C\uDC9F]|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE8B]|\uD838[\uDD4F\uDEFF]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA])/).replace(/punct/g,vy).getRegex(),by=UD("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,hy).replace(/punctSpace/g,fy).replace(/punct/g,dy).getRegex(),Cy=UD(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,dy).getRegex(),wy=UD("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,hy).replace(/punctSpace/g,fy).replace(/punct/g,dy).getRegex(),Ay=UD(/\\(punct)/,"gu").replace(/punct/g,dy).getRegex(),xy=UD(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Sy=UD(ry).replace("(?:--\x3e|$)","--\x3e").getRegex(),By=UD("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Sy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ty=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,My=UD(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ty).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ny=UD(/^!?\[(label)\]\[(ref)\]/).replace("label",Ty).replace("ref",YD).getRegex(),Ry=UD(/^!?\[(ref)\](?:\[\])?/).replace("ref",YD).getRegex(),Oy=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Iy={_backpedal:VD,anyPunctuation:Ay,autolink:xy,blockSkip:my,br:cy,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:VD,delLDelim:VD,delRDelim:VD,emStrongLDelim:Dy,emStrongRDelimAst:Ey,emStrongRDelimUnd:by,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:My,nolink:Ry,punctuation:py,reflink:Ny,reflinkSearch:UD("reflink|nolink(?!\\()","g").replace("reflink",Ny).replace("nolink",Ry).getRegex(),tag:By,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:VD},Py=e(e({},Iy),{},{link:UD(/^!?\[(label)\]\((.*?)\)/).replace("label",Ty).getRegex(),reflink:UD(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ty).getRegex()}),Ly=e(e({},Iy),{},{emStrongRDelimAst:Fy,emStrongLDelim:yy,delLDelim:Cy,delRDelim:wy,url:UD(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Oy).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:UD(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Oy).getRegex()}),zy=e(e({},Ly),{},{br:UD(cy).replace("{2,}","*").getRegex(),text:UD(Ly.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),$y={normal:ay,gfm:sy,pedantic:ly},qy={normal:Iy,gfm:Ly,breaks:zy,pedantic:Py},jy={"&":"&","<":"<",">":">",'"':""","'":"'"},Hy=function(e){return jy[e]};function Vy(e,t){if(t){if(_D.escapeTest.test(e))return e.replace(_D.escapeReplace,Hy)}else if(_D.escapeTestNoEncode.test(e))return e.replace(_D.escapeReplaceNoEncode,Hy);return e}function Uy(e){try{e=encodeURI(e).replace(_D.percentDecode,"%")}catch(e){return null}return e}function Wy(e,t){var n,r=e.replace(_D.findPipe,function(e,t,n){for(var r=!1,o=t;--o>=0&&"\\"===n[o];)r=!r;return r?"|":" |"}).split(_D.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!(null!==(n=r.at(-1))&&void 0!==n&&n.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(_D.slashPipe,"|");return r}function _y(e,t,n){var r=e.length;if(0===r)return"";for(var o=0;o<r;){var i=e.charAt(r-o-1);if(i!==t||n){if(i===t||!n)break;o++}else o++}return e.slice(0,r-o)}function Ky(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="",o=j(e);try{for(o.s();!(t=o.n()).done;){var i=t.value;if("\t"===i){var a=4-n%4;r+=" ".repeat(a),n+=a}else r+=i,n++}}catch(e){o.e(e)}finally{o.f()}return r}function Jy(e,t,n,r,o){var i=t.href,a=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;var s={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:i,title:a,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,s}var Qy=function(){return x(function e(t){M(this,e),S(this,"options",void 0),S(this,"rules",void 0),S(this,"lexer",void 0),this.options=t||jD},[{key:"space",value:function(e){var t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}},{key:"code",value:function(e){var t=this.rules.block.code.exec(e);if(t){var n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:_y(n,"\n")}}}},{key:"fences",value:function(e){var t=this.rules.block.fences.exec(e);if(t){var n=t[0],r=function(e,t,n){var r=e.match(n.other.indentCodeCompensation);if(null===r)return t;var o=r[1];return t.split("\n").map(function(e){var t=e.match(n.other.beginningSpace);return null===t?e:i(t,1)[0].length>=o.length?e.slice(o.length):e}).join("\n")}(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}},{key:"heading",value:function(e){var t=this.rules.block.heading.exec(e);if(t){var n=t[2].trim();if(this.rules.other.endingHash.test(n)){var r=_y(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}},{key:"hr",value:function(e){var t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:_y(t[0],"\n")}}},{key:"blockquote",value:function(e){var t=this.rules.block.blockquote.exec(e);if(t){for(var n=_y(t[0],"\n").split("\n"),r="",o="",i=[];n.length>0;){var a=!1,u=[],s=void 0;for(s=0;s<n.length;s++)if(this.rules.other.blockquoteStart.test(n[s]))u.push(n[s]),a=!0;else{if(a)break;u.push(n[s])}n=n.slice(s);var l=u.join("\n"),c=l.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");r=r?"".concat(r,"\n").concat(l):l,o=o?"".concat(o,"\n").concat(c):c;var d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=d,0===n.length)break;var f=i.at(-1);if("code"===(null==f?void 0:f.type))break;if("blockquote"===(null==f?void 0:f.type)){var h=f,p=h.raw+"\n"+n.join("\n"),v=this.blockquote(p);i[i.length-1]=v,r=r.substring(0,r.length-h.raw.length)+v.raw,o=o.substring(0,o.length-h.text.length)+v.text;break}if("list"!==(null==f?void 0:f.type));else{var m=f,g=m.raw+"\n"+n.join("\n"),D=this.list(g);i[i.length-1]=D,r=r.substring(0,r.length-f.raw.length)+D.raw,o=o.substring(0,o.length-m.raw.length)+D.raw,n=g.substring(i.at(-1).raw.length).split("\n")}}return{type:"blockquote",raw:r,tokens:i,text:o}}}},{key:"list",value:function(e){var t=this,n=this.rules.block.list.exec(e);if(n){var r=n[1].trim(),o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?"\\d{1,9}\\".concat(r.slice(-1)):"\\".concat(r),this.options.pedantic&&(r=o?r:"[*+-]");for(var a=this.rules.other.listItemRegex(r),u=!1;e;){var s=!1,l="",c="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;l=n[0],e=e.substring(l.length);var d=Ky(n[2].split("\n",1)[0],n[1].length),f=e.split("\n",1)[0],h=!d.trim(),p=0;if(this.options.pedantic?(p=2,c=d.trimStart()):h?p=n[1].length+1:(p=(p=d.search(this.rules.other.nonSpaceChar))>4?1:p,c=d.slice(p),p+=n[1].length),h&&this.rules.other.blankLine.test(f)&&(l+=f+"\n",e=e.substring(f.length+1),s=!0),!s)for(var v=this.rules.other.nextBulletRegex(p),m=this.rules.other.hrRegex(p),g=this.rules.other.fencesBeginRegex(p),D=this.rules.other.headingBeginRegex(p),y=this.rules.other.htmlBeginRegex(p),k=this.rules.other.blockquoteBeginRegex(p);e;){var E=e.split("\n",1)[0],F=void 0;if(f=E,this.options.pedantic?F=f=f.replace(this.rules.other.listReplaceNesting," "):F=f.replace(this.rules.other.tabCharGlobal," "),g.test(f)||D.test(f)||y.test(f)||k.test(f)||v.test(f)||m.test(f))break;if(F.search(this.rules.other.nonSpaceChar)>=p||!f.trim())c+="\n"+F.slice(p);else{if(h||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||g.test(d)||D.test(d)||m.test(d))break;c+="\n"+f}h=!f.trim(),l+=E+"\n",e=e.substring(E.length+1),d=F.slice(p)}i.loose||(u?i.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(u=!0)),i.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=l}var b=i.items.at(-1);if(!b)return;b.raw=b.raw.trimEnd(),b.text=b.text.trimEnd(),i.raw=i.raw.trimEnd();var C,w=j(i.items);try{for(w.s();!(C=w.n()).done;){var A=C.value;if(this.lexer.state.top=!1,A.tokens=this.lexer.blockTokens(A.text,[]),A.task){var x,S;if(A.text=A.text.replace(this.rules.other.listReplaceTask,""),"text"===(null===(x=A.tokens[0])||void 0===x?void 0:x.type)||"paragraph"===(null===(S=A.tokens[0])||void 0===S?void 0:S.type)){A.tokens[0].raw=A.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),A.tokens[0].text=A.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(var B=this.lexer.inlineQueue.length-1;B>=0;B--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[B].src)){this.lexer.inlineQueue[B].src=this.lexer.inlineQueue[B].src.replace(this.rules.other.listReplaceTask,"");break}}var T=this.rules.other.listTaskCheckbox.exec(A.raw);if(T){var M={type:"checkbox",raw:T[0]+" ",checked:"[ ]"!==T[0]};A.checked=M.checked,i.loose?A.tokens[0]&&["paragraph","text"].includes(A.tokens[0].type)&&"tokens"in A.tokens[0]&&A.tokens[0].tokens?(A.tokens[0].raw=M.raw+A.tokens[0].raw,A.tokens[0].text=M.raw+A.tokens[0].text,A.tokens[0].tokens.unshift(M)):A.tokens.unshift({type:"paragraph",raw:M.raw,text:M.raw,tokens:[M]}):A.tokens.unshift(M)}}if(!i.loose){var N=A.tokens.filter(function(e){return"space"===e.type}),R=N.length>0&&N.some(function(e){return t.rules.other.anyLine.test(e.raw)});i.loose=R}}}catch(e){w.e(e)}finally{w.f()}if(i.loose){var O,I=j(i.items);try{for(I.s();!(O=I.n()).done;){var P=O.value;P.loose=!0;var L,z=j(P.tokens);try{for(z.s();!(L=z.n()).done;){var $=L.value;"text"===$.type&&($.type="paragraph")}}catch(e){z.e(e)}finally{z.f()}}}catch(e){I.e(e)}finally{I.f()}}return i}}},{key:"html",value:function(e){var t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}},{key:"def",value:function(e){var t=this.rules.block.def.exec(e);if(t){var n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:o}}}},{key:"table",value:function(e){var t,n=this,r=this.rules.block.table.exec(e);if(r&&this.rules.other.tableDelimiter.test(r[2])){var o=Wy(r[1]),i=r[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=null!==(t=r[3])&&void 0!==t&&t.trim()?r[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],u={type:"table",raw:r[0],header:[],align:[],rows:[]};if(o.length===i.length){var s,l=j(i);try{for(l.s();!(s=l.n()).done;){var c=s.value;this.rules.other.tableAlignRight.test(c)?u.align.push("right"):this.rules.other.tableAlignCenter.test(c)?u.align.push("center"):this.rules.other.tableAlignLeft.test(c)?u.align.push("left"):u.align.push(null)}}catch(e){l.e(e)}finally{l.f()}for(var d=0;d<o.length;d++)u.header.push({text:o[d],tokens:this.lexer.inline(o[d]),header:!0,align:u.align[d]});var f,h=j(a);try{for(h.s();!(f=h.n()).done;){var p=f.value;u.rows.push(Wy(p,u.header.length).map(function(e,t){return{text:e,tokens:n.lexer.inline(e),header:!1,align:u.align[t]}}))}}catch(e){h.e(e)}finally{h.f()}return u}}}},{key:"lheading",value:function(e){var t=this.rules.block.lheading.exec(e);if(t){var n=t[1].trim();return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:n,tokens:this.lexer.inline(n)}}}},{key:"paragraph",value:function(e){var t=this.rules.block.paragraph.exec(e);if(t){var n="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}},{key:"text",value:function(e){var t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}},{key:"escape",value:function(e){var t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}},{key:"tag",value:function(e){var t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}},{key:"link",value:function(e){var t=this.rules.inline.link.exec(e);if(t){var n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;var r=_y(n.slice(0,-1),"\\");if((n.length-r.length)%2==0)return}else{var o=function(e,t){if(-1===e.indexOf(t[1]))return-1;for(var n=0,r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&--n<0)return r;return n>0?-2:-1}(t[2],"()");if(-2===o)return;if(o>-1){var i=(0===t[0].indexOf("!")?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,i).trim(),t[3]=""}}var a=t[2],u="";if(this.options.pedantic){var s=this.rules.other.pedanticHrefTitle.exec(a);s&&(a=s[1],u=s[3])}else u=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(a=this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?a.slice(1):a.slice(1,-1)),Jy(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:u&&u.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}},{key:"reflink",value:function(e,t){var n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){var r=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!r){var o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Jy(n,r,n[0],this.lexer,this.rules)}}},{key:"emStrong",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(r[1]||r[2]||r[3]||r[4])&&(!r[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[3]||!n||this.rules.inline.punctuation.exec(n))){var i,a,u=o(r[0]).length-1,s=u,l=0,c="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+u);null!==(r=c.exec(t));)if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6])if(a=o(i).length,r[3]||r[4])s+=a;else if(!((r[5]||r[6])&&u%3)||(u+a)%3){if(!((s-=a)>0)){a=Math.min(a,a+s+l);var d=o(r[0])[0].length,f=e.slice(0,u+r.index+d+a);if(Math.min(u,a)%2){var h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}var p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}else l+=a}}},{key:"codespan",value:function(e){var t=this.rules.inline.code.exec(e);if(t){var n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}},{key:"br",value:function(e){var t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}},{key:"del",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){var i,a,u=o(r[0]).length-1,s=u,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+u);null!==(r=l.exec(t));)if((i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6])&&(a=o(i).length)===u)if(r[3]||r[4])s+=a;else if(!((s-=a)>0)){a=Math.min(a,a+s);var c=o(r[0])[0].length,d=e.slice(0,u+r.index+c+a),f=d.slice(u,-u);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}},{key:"autolink",value:function(e){var t,n,r=this.rules.inline.autolink.exec(e);if(r)return"@"===r[2]?n="mailto:"+(t=r[1]):n=t=r[1],{type:"link",raw:r[0],text:t,href:n,tokens:[{type:"text",raw:t,text:t}]}}},{key:"url",value:function(e){var t;if(t=this.rules.inline.url.exec(e)){var n,r;if("@"===t[2])r="mailto:"+(n=t[0]);else{var o;do{var i,a;o=t[0],t[0]=null!==(i=null===(a=this.rules.inline._backpedal.exec(t[0]))||void 0===a?void 0:a[0])&&void 0!==i?i:""}while(o!==t[0]);n=t[0],r="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}},{key:"inlineText",value:function(e){var t=this.rules.inline.text.exec(e);if(t){var n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}}])}(),Gy=function(){function e(t){M(this,e),S(this,"tokens",void 0),S(this,"options",void 0),S(this,"state",void 0),S(this,"inlineQueue",void 0),S(this,"tokenizer",void 0),this.tokens=[],this.tokens.links=Object.create(null),this.options=t||jD,this.options.tokenizer=this.options.tokenizer||new Qy,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};var n={other:_D,block:$y.normal,inline:qy.normal};this.options.pedantic?(n.block=$y.pedantic,n.inline=qy.pedantic):this.options.gfm&&(n.block=$y.gfm,this.options.breaks?n.inline=qy.breaks:n.inline=qy.gfm),this.tokenizer.rules=n}return x(e,[{key:"lex",value:function(e){e=e.replace(_D.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(var t=0;t<this.inlineQueue.length;t++){var n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}},{key:"blockTokens",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=function(){var t,i,a;if(null!==(t=n.options.extensions)&&void 0!==t&&null!==(t=t.block)&&void 0!==t&&t.some(function(t){return!!(a=t.call({lexer:n},e,r))&&(e=e.substring(a.raw.length),r.push(a),!0)}))return 0;if(a=n.tokenizer.space(e)){e=e.substring(a.raw.length);var u=r.at(-1);return 1===a.raw.length&&void 0!==u?u.raw+="\n":r.push(a),0}if(a=n.tokenizer.code(e)){e=e.substring(a.raw.length);var s=r.at(-1);return"paragraph"===(null==s?void 0:s.type)||"text"===(null==s?void 0:s.type)?(s.raw+=(s.raw.endsWith("\n")?"":"\n")+a.raw,s.text+="\n"+a.text,n.inlineQueue.at(-1).src=s.text):r.push(a),0}if(a=n.tokenizer.fences(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.heading(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.hr(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.blockquote(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.list(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.html(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.def(e)){e=e.substring(a.raw.length);var l=r.at(-1);return"paragraph"===(null==l?void 0:l.type)||"text"===(null==l?void 0:l.type)?(l.raw+=(l.raw.endsWith("\n")?"":"\n")+a.raw,l.text+="\n"+a.raw,n.inlineQueue.at(-1).src=l.text):n.tokens.links[a.tag]||(n.tokens.links[a.tag]={href:a.href,title:a.title},r.push(a)),0}if(a=n.tokenizer.table(e))return e=e.substring(a.raw.length),r.push(a),0;if(a=n.tokenizer.lheading(e))return e=e.substring(a.raw.length),r.push(a),0;var c=e;if(null!==(i=n.options.extensions)&&void 0!==i&&i.startBlock){var d,f=1/0,h=e.slice(1);n.options.extensions.startBlock.forEach(function(e){"number"==typeof(d=e.call({lexer:n},h))&&d>=0&&(f=Math.min(f,d))}),f<1/0&&f>=0&&(c=e.substring(0,f+1))}if(n.state.top&&(a=n.tokenizer.paragraph(c))){var p=r.at(-1);return o&&"paragraph"===(null==p?void 0:p.type)?(p.raw+=(p.raw.endsWith("\n")?"":"\n")+a.raw,p.text+="\n"+a.text,n.inlineQueue.pop(),n.inlineQueue.at(-1).src=p.text):r.push(a),o=c.length!==e.length,e=e.substring(a.raw.length),0}if(a=n.tokenizer.text(e)){e=e.substring(a.raw.length);var v=r.at(-1);return"text"===(null==v?void 0:v.type)?(v.raw+=(v.raw.endsWith("\n")?"":"\n")+a.raw,v.text+="\n"+a.text,n.inlineQueue.pop(),n.inlineQueue.at(-1).src=v.text):r.push(a),0}if(e){var m="Infinite loop on byte: "+e.charCodeAt(0);if(n.options.silent)return console.error(m),1;throw new Error(m)}};for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(_D.tabCharGlobal," ").replace(_D.spaceLine,""));e&&(0===(t=i())||1!==t););return this.state.top=!0,r}},{key:"inline",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.inlineQueue.push({src:e,tokens:t}),t}},{key:"inlineTokens",value:function(e){var t,n,r=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.tokenizer.lexer=this;var i,a=e,u=null;if(this.tokens.links){var s=Object.keys(this.tokens.links);if(s.length>0)for(;null!==(u=this.tokenizer.rules.inline.reflinkSearch.exec(a));)s.includes(u[0].slice(u[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,u.index)+"["+"a".repeat(u[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!==(u=this.tokenizer.rules.inline.anyPunctuation.exec(a));)a=a.slice(0,u.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!==(u=this.tokenizer.rules.inline.blockSkip.exec(a));)i=u[2]?u[2].length:0,a=a.slice(0,u.index+i)+"["+"a".repeat(u[0].length-i-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);a=null!==(t=null===(n=this.options.hooks)||void 0===n||null===(n=n.emStrongMask)||void 0===n?void 0:n.call({lexer:this},a))&&void 0!==t?t:a;for(var l,c=!1,d="",f=function(){var t,n,i;if(c||(d=""),c=!1,null!==(t=r.options.extensions)&&void 0!==t&&null!==(t=t.inline)&&void 0!==t&&t.some(function(t){return!!(i=t.call({lexer:r},e,o))&&(e=e.substring(i.raw.length),o.push(i),!0)}))return 0;if(i=r.tokenizer.escape(e))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.tag(e))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.link(e))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.reflink(e,r.tokens.links)){e=e.substring(i.raw.length);var u=o.at(-1);return"text"===i.type&&"text"===(null==u?void 0:u.type)?(u.raw+=i.raw,u.text+=i.text):o.push(i),0}if(i=r.tokenizer.emStrong(e,a,d))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.codespan(e))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.br(e))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.del(e,a,d))return e=e.substring(i.raw.length),o.push(i),0;if(i=r.tokenizer.autolink(e))return e=e.substring(i.raw.length),o.push(i),0;if(!r.state.inLink&&(i=r.tokenizer.url(e)))return e=e.substring(i.raw.length),o.push(i),0;var s=e;if(null!==(n=r.options.extensions)&&void 0!==n&&n.startInline){var l,f=1/0,h=e.slice(1);r.options.extensions.startInline.forEach(function(e){"number"==typeof(l=e.call({lexer:r},h))&&l>=0&&(f=Math.min(f,l))}),f<1/0&&f>=0&&(s=e.substring(0,f+1))}if(i=r.tokenizer.inlineText(s)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(d=i.raw.slice(-1)),c=!0;var p=o.at(-1);return"text"===(null==p?void 0:p.type)?(p.raw+=i.raw,p.text+=i.text):o.push(i),0}if(e){var v="Infinite loop on byte: "+e.charCodeAt(0);if(r.options.silent)return console.error(v),1;throw new Error(v)}};e&&(0===(l=f())||1!==l););return o}}],[{key:"rules",get:function(){return{block:$y,inline:qy}}},{key:"lex",value:function(t,n){return new e(n).lex(t)}},{key:"lexInline",value:function(t,n){return new e(n).inlineTokens(t)}}])}(),Xy=function(){return x(function e(t){M(this,e),S(this,"options",void 0),S(this,"parser",void 0),this.options=t||jD},[{key:"space",value:function(e){return""}},{key:"code",value:function(e){var t,n=e.text,r=e.lang,o=e.escaped,i=null===(t=(r||"").match(_D.notSpaceStart))||void 0===t?void 0:t[0],a=n.replace(_D.endingNewline,"")+"\n";return i?'<pre><code class="language-'+Vy(i)+'">'+(o?a:Vy(a,!0))+"</code></pre>\n":"<pre><code>"+(o?a:Vy(a,!0))+"</code></pre>\n"}},{key:"blockquote",value:function(e){var t=e.tokens;return"<blockquote>\n".concat(this.parser.parse(t),"</blockquote>\n")}},{key:"html",value:function(e){return e.text}},{key:"def",value:function(e){return""}},{key:"heading",value:function(e){var t=e.tokens,n=e.depth;return"<h".concat(n,">").concat(this.parser.parseInline(t),"</h").concat(n,">\n")}},{key:"hr",value:function(e){return"<hr>\n"}},{key:"list",value:function(e){for(var t=e.ordered,n=e.start,r="",o=0;o<e.items.length;o++){var i=e.items[o];r+=this.listitem(i)}var a=t?"ol":"ul";return"<"+a+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+a+">\n"}},{key:"listitem",value:function(e){return"<li>".concat(this.parser.parse(e.tokens),"</li>\n")}},{key:"checkbox",value:function(e){return"<input "+(e.checked?'checked="" ':"")+'disabled="" type="checkbox"> '}},{key:"paragraph",value:function(e){var t=e.tokens;return"<p>".concat(this.parser.parseInline(t),"</p>\n")}},{key:"table",value:function(e){for(var t="",n="",r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});for(var o="",i=0;i<e.rows.length;i++){var a=e.rows[i];n="";for(var u=0;u<a.length;u++)n+=this.tablecell(a[u]);o+=this.tablerow({text:n})}return o&&(o="<tbody>".concat(o,"</tbody>")),"<table>\n<thead>\n"+t+"</thead>\n"+o+"</table>\n"}},{key:"tablerow",value:function(e){var t=e.text;return"<tr>\n".concat(t,"</tr>\n")}},{key:"tablecell",value:function(e){var t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?"<".concat(n,' align="').concat(e.align,'">'):"<".concat(n,">"))+t+"</".concat(n,">\n")}},{key:"strong",value:function(e){var t=e.tokens;return"<strong>".concat(this.parser.parseInline(t),"</strong>")}},{key:"em",value:function(e){var t=e.tokens;return"<em>".concat(this.parser.parseInline(t),"</em>")}},{key:"codespan",value:function(e){var t=e.text;return"<code>".concat(Vy(t,!0),"</code>")}},{key:"br",value:function(e){return"<br>"}},{key:"del",value:function(e){var t=e.tokens;return"<del>".concat(this.parser.parseInline(t),"</del>")}},{key:"link",value:function(e){var t=e.href,n=e.title,r=e.tokens,o=this.parser.parseInline(r),i=Uy(t);if(null===i)return o;var a='<a href="'+(t=i)+'"';return n&&(a+=' title="'+Vy(n)+'"'),a+=">"+o+"</a>"}},{key:"image",value:function(e){var t=e.href,n=e.title,r=e.text,o=e.tokens;o&&(r=this.parser.parseInline(o,this.parser.textRenderer));var i=Uy(t);if(null===i)return Vy(r);var a='<img src="'.concat(t=i,'" alt="').concat(Vy(r),'"');return n&&(a+=' title="'.concat(Vy(n),'"')),a+=">"}},{key:"text",value:function(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Vy(e.text)}}])}(),Zy=function(){return x(function e(){M(this,e)},[{key:"strong",value:function(e){return e.text}},{key:"em",value:function(e){return e.text}},{key:"codespan",value:function(e){return e.text}},{key:"del",value:function(e){return e.text}},{key:"html",value:function(e){return e.text}},{key:"text",value:function(e){return e.text}},{key:"link",value:function(e){return""+e.text}},{key:"image",value:function(e){return""+e.text}},{key:"br",value:function(){return""}},{key:"checkbox",value:function(e){return e.raw}}])}(),Yy=function(){function e(t){M(this,e),S(this,"options",void 0),S(this,"renderer",void 0),S(this,"textRenderer",void 0),this.options=t||jD,this.options.renderer=this.options.renderer||new Xy,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zy}return x(e,[{key:"parse",value:function(e){this.renderer.parser=this;for(var t="",n=0;n<e.length;n++){var r,o=e[n];if(null!==(r=this.options.extensions)&&void 0!==r&&null!==(r=r.renderers)&&void 0!==r&&r[o.type]){var i=o,a=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==a||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){t+=a||"";continue}}var u=o;switch(u.type){case"space":t+=this.renderer.space(u);break;case"hr":t+=this.renderer.hr(u);break;case"heading":t+=this.renderer.heading(u);break;case"code":t+=this.renderer.code(u);break;case"table":t+=this.renderer.table(u);break;case"blockquote":t+=this.renderer.blockquote(u);break;case"list":t+=this.renderer.list(u);break;case"checkbox":t+=this.renderer.checkbox(u);break;case"html":t+=this.renderer.html(u);break;case"def":t+=this.renderer.def(u);break;case"paragraph":t+=this.renderer.paragraph(u);break;case"text":t+=this.renderer.text(u);break;default:var s='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}return t}},{key:"parseInline",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.renderer;this.renderer.parser=this;for(var n="",r=0;r<e.length;r++){var o,i=e[r];if(null!==(o=this.options.extensions)&&void 0!==o&&null!==(o=o.renderers)&&void 0!==o&&o[i.type]){var a=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==a||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=a||"";continue}}var u=i;switch(u.type){case"escape":case"text":n+=t.text(u);break;case"html":n+=t.html(u);break;case"link":n+=t.link(u);break;case"image":n+=t.image(u);break;case"checkbox":n+=t.checkbox(u);break;case"strong":n+=t.strong(u);break;case"em":n+=t.em(u);break;case"codespan":n+=t.codespan(u);break;case"br":n+=t.br(u);break;case"del":n+=t.del(u);break;default:var s='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}return n}}],[{key:"parse",value:function(t,n){return new e(n).parse(t)}},{key:"parseInline",value:function(t,n){return new e(n).parseInline(t)}}])}(),ek=(PD=function(){return x(function e(t){M(this,e),S(this,"options",void 0),S(this,"block",void 0),this.options=t||jD},[{key:"preprocess",value:function(e){return e}},{key:"postprocess",value:function(e){return e}},{key:"processAllTokens",value:function(e){return e}},{key:"emStrongMask",value:function(e){return e}},{key:"provideLexer",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.block)?Gy.lex:Gy.lexInline}},{key:"provideParser",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.block)?Yy.parse:Yy.parseInline}}])}(),S(PD,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),S(PD,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),PD),tk=function(){return x(function e(){M(this,e),S(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),S(this,"options",this.setOptions),S(this,"parse",this.parseMarkdown(!0)),S(this,"parseInline",this.parseMarkdown(!1)),S(this,"Parser",Yy),S(this,"Renderer",Xy),S(this,"TextRenderer",Zy),S(this,"Lexer",Gy),S(this,"Tokenizer",Qy),S(this,"Hooks",ek),this.use.apply(this,arguments)},[{key:"walkTokens",value:function(e,t){var n,r=this,o=[],i=j(e);try{var a=function(){var e=n.value;switch(o=o.concat(t.call(r,e)),e.type){case"table":var i,a=e,u=j(a.header);try{for(u.s();!(i=u.n()).done;){var s=i.value;o=o.concat(r.walkTokens(s.tokens,t))}}catch(e){u.e(e)}finally{u.f()}var l,c=j(a.rows);try{for(c.s();!(l=c.n()).done;){var d,f=l.value,h=j(f);try{for(h.s();!(d=h.n()).done;){var p=d.value;o=o.concat(r.walkTokens(p.tokens,t))}}catch(e){h.e(e)}finally{h.f()}}}catch(e){c.e(e)}finally{c.f()}break;case"list":var v=e;o=o.concat(r.walkTokens(v.items,t));break;default:var m,g=e;null!==(m=r.defaults.extensions)&&void 0!==m&&null!==(m=m.childTokens)&&void 0!==m&&m[g.type]?r.defaults.extensions.childTokens[g.type].forEach(function(e){var n=g[e].flat(1/0);o=o.concat(r.walkTokens(n,t))}):g.tokens&&(o=o.concat(r.walkTokens(g.tokens,t)))}};for(i.s();!(n=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}return o}},{key:"use",value:function(){for(var t=this,n=this.defaults.extensions||{renderers:{},childTokens:{}},r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.forEach(function(r){var o=e({},r);if(o.async=t.defaults.async||o.async||!1,r.extensions&&(r.extensions.forEach(function(e){if(!e.name)throw new Error("extension name required");if("renderer"in e){var t=n.renderers[e.name];n.renderers[e.name]=t?function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];var i=e.renderer.apply(this,r);return!1===i&&(i=t.apply(this,r)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");var r=n[e.level];r?r.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),o.extensions=n),r.renderer){var i=t.defaults.renderer||new Xy(t.defaults),a=function(){if(!(u in i))throw new Error("renderer '".concat(u,"' does not exist"));if(["options","parser"].includes(u))return 1;var e=u,t=r.renderer[e],n=i[e];i[e]=function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var a=t.apply(i,r);return!1===a&&(a=n.apply(i,r)),a||""}};for(var u in r.renderer)a();o.renderer=i}if(r.tokenizer){var s=t.defaults.tokenizer||new Qy(t.defaults),l=function(){if(!(c in s))throw new Error("tokenizer '".concat(c,"' does not exist"));if(["options","rules","lexer"].includes(c))return 1;var e=c,t=r.tokenizer[e],n=s[e];s[e]=function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=t.apply(s,r);return!1===i&&(i=n.apply(s,r)),i}};for(var c in r.tokenizer)l();o.tokenizer=s}if(r.hooks){var d=t.defaults.hooks||new ek,f=function(e){if(!(e in d))throw new Error("hook '".concat(e,"' does not exist"));if(["options","block"].includes(e))return 1;var n=e,o=r.hooks[n],i=d[n];ek.passThroughHooks.has(e)?d[n]=function(n){if(t.defaults.async&&ek.passThroughHooksRespectAsync.has(e))return z($().m(function e(){var t;return $().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.call(d,n);case 1:return t=e.v,e.a(2,i.call(d,t))}},e)}))();var r=o.call(d,n);return i.call(d,r)}:d[n]=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(t.defaults.async)return z($().m(function e(){var t;return $().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.apply(d,n);case 1:if(t=e.v,!(!1===t)){e.n=3;break}return e.n=2,i.apply(d,n);case 2:t=e.v;case 3:return e.a(2,t)}},e)}))();var a=o.apply(d,n);return!1===a&&(a=i.apply(d,n)),a}};for(var h in r.hooks)f(h);o.hooks=d}if(r.walkTokens){var p=t.defaults.walkTokens,v=r.walkTokens;o.walkTokens=function(e){var t=[];return t.push(v.call(this,e)),p&&(t=t.concat(p.call(this,e))),t}}t.defaults=e(e({},t.defaults),o)}),this}},{key:"setOptions",value:function(t){return this.defaults=e(e({},this.defaults),t),this}},{key:"lexer",value:function(e,t){return Gy.lex(e,null!=t?t:this.defaults)}},{key:"parser",value:function(e,t){return Yy.parse(e,null!=t?t:this.defaults)}},{key:"parseMarkdown",value:function(t){var n=this;return function(r,o){var i=e({},o),a=e(e({},n.defaults),i),u=n.onError(!!a.silent,!!a.async);if(!0===n.defaults.async&&!1===i.async)return u(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(k(r)>"u"||null===r)return u(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof r)return u(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=t),a.async)return z($().m(function e(){var o,i,u,s,l,c,d,f,h,p,v;return $().w(function(e){for(;;)switch(e.n){case 0:if(!a.hooks){e.n=2;break}return e.n=1,a.hooks.preprocess(r);case 1:l=e.v,e.n=3;break;case 2:l=r;case 3:if(o=l,!a.hooks){e.n=5;break}return e.n=4,a.hooks.provideLexer(t);case 4:c=e.v,e.n=6;break;case 5:c=t?Gy.lex:Gy.lexInline;case 6:return d=c,e.n=7,d(o,a);case 7:if(i=e.v,!a.hooks){e.n=9;break}return e.n=8,a.hooks.processAllTokens(i);case 8:f=e.v,e.n=10;break;case 9:f=i;case 10:if(u=f,!a.walkTokens){e.n=11;break}return e.n=11,Promise.all(n.walkTokens(u,a.walkTokens));case 11:if(!a.hooks){e.n=13;break}return e.n=12,a.hooks.provideParser(t);case 12:h=e.v,e.n=14;break;case 13:h=t?Yy.parse:Yy.parseInline;case 14:return p=h,e.n=15,p(u,a);case 15:if(s=e.v,!a.hooks){e.n=17;break}return e.n=16,a.hooks.postprocess(s);case 16:v=e.v,e.n=18;break;case 17:v=s;case 18:return e.a(2,v)}},e)}))().catch(u);try{a.hooks&&(r=a.hooks.preprocess(r));var s=(a.hooks?a.hooks.provideLexer(t):t?Gy.lex:Gy.lexInline)(r,a);a.hooks&&(s=a.hooks.processAllTokens(s)),a.walkTokens&&n.walkTokens(s,a.walkTokens);var l=(a.hooks?a.hooks.provideParser(t):t?Yy.parse:Yy.parseInline)(s,a);return a.hooks&&(l=a.hooks.postprocess(l)),l}catch(e){return u(e)}}}},{key:"onError",value:function(e,t){return function(n){if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){var r="<p>An error occurred:</p><pre>"+Vy(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}}])}(),nk=new tk;function rk(e,t){return nk.parse(e,t)}rk.options=rk.setOptions=function(e){return nk.setOptions(e),rk.defaults=nk.defaults,HD(rk.defaults),rk},rk.getDefaults=qD,rk.defaults=jD,rk.use=function(){return nk.use.apply(nk,arguments),rk.defaults=nk.defaults,HD(rk.defaults),rk},rk.walkTokens=function(e,t){return nk.walkTokens(e,t)},rk.parseInline=nk.parseInline,rk.Parser=Yy,rk.parser=Yy.parse,rk.Renderer=Xy,rk.TextRenderer=Zy,rk.Lexer=Gy,rk.lexer=Gy.lex,rk.Tokenizer=Qy,rk.Hooks=ek,rk.parse=rk,rk.options,rk.setOptions,rk.use,rk.walkTokens,rk.parseInline,Yy.parse,Gy.lex;var ok=/\n[^\S\n]*(?:\n[^\S\n]*)+$/;function ik(e,t){var n=t.split("\n").flatMap(function(e){return[e,""]}).map(function(t){return"".concat(e).concat(t)}).join("\n");return n.slice(0,n.length-1)}function ak(e,t){var n=[];return Array.from(e.entries()).forEach(function(e){var r=i(e,2),o=r[0],a=r[1];t&&(t.marks||[]).find(function(e){return e.type===o&&Hh(e.attrs,a.attrs)})||n.push(o)}),n}function uk(e){var t=(e.raw||e.text||"").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return t?{isTask:!0,checked:"x"===t[2].toLowerCase(),indentLevel:t[1].length}:{isTask:!1,indentLevel:0}}function sk(e,t){return"string"!=typeof e?"json":t}var lk=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","mask","path","polygon","polyline","radialgradient","rect","stop","switch","symbol","textpath","tspan","use","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),ck=/<\/?([a-zA-Z][\w-]*)/g;function dk(e,t){return function(e){for(var t,n=[];null!==(t=ck.exec(e));)n.push(t[1].toLowerCase());return n}(e).some(function(e){return!!function(e){var t=e.toLowerCase();return!t.includes("-")&&!lk.has(t)}(e)&&!t.has(e)})}var fk=function(){return x(function e(t){var n,r,o,i,a,u=this;M(this,e),this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.schemaParseDomTagsCache=null,this.inlineNodeTypesCache=null,this.lastParseResult=null,this.markedInstance=null!==(n=null==t?void 0:t.marked)&&void 0!==n?n:rk,this.indentStyle=null!==(r=null==t||null===(o=t.indentation)||void 0===o?void 0:o.style)&&void 0!==r?r:"space",this.indentSize=null!==(i=null==t||null===(a=t.indentation)||void 0===a?void 0:a.size)&&void 0!==i?i:2,this.baseExtensions=(null==t?void 0:t.extensions)||[],(null==t?void 0:t.markedOptions)&&"function"==typeof this.markedInstance.setOptions&&this.markedInstance.setOptions(t.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,(null==t?void 0:t.extensions)&&(this.baseExtensions=t.extensions,bf(nf(t.extensions)).forEach(function(e){return u.registerExtension(e)}))},[{key:"instance",get:function(){return this.markedInstance}},{key:"indentCharacter",get:function(){return"space"===this.indentStyle?" ":"\t"}},{key:"indentString",get:function(){return this.indentCharacter.repeat(this.indentSize)}},{key:"hasMarked",value:function(){return!!this.markedInstance}},{key:"registerExtension",value:function(e){var t,n;this.extensions.push(e);var r=pf(tf(e,"code")),o=e.name,i={name:o,options:e.options,storage:e.storage};r&&this.codeTypes.add(o),this.extensionRanks.has(o)||this.extensionRanks.set(o,this.extensionRanks.size);var a=tf(e,"markdownTokenName",i)||o,u=tf(e,"parseMarkdown",i),s=tf(e,"renderMarkdown",i),l=tf(e,"markdownTokenizer",i),c=null!==(t=tf(e,"markdownOptions",i))&&void 0!==t?t:null,d={tokenName:a,nodeName:o,parseMarkdown:u,renderMarkdown:s,isIndenting:null!==(n=null==c?void 0:c.indentsContent)&&void 0!==n&&n,htmlReopen:null==c?void 0:c.htmlReopen,tokenizer:l};if(a&&u){var f=this.registry.get(a)||[];f.push(d),this.registry.set(a,f)}if(s){var h=this.nodeTypeRegistry.get(o)||[];h.push(d),this.nodeTypeRegistry.set(o,h)}l&&this.hasMarked()&&this.registerTokenizer(l)}},{key:"createLexer",value:function(){return new this.markedInstance.Lexer(this.markedInstance.defaults)}},{key:"createTokenizerHelpers",value:function(e){return{inlineTokens:function(t){return e.inlineTokens(t)},blockTokens:function(t){return e.blockTokens(t)}}}},{key:"tokenizeInline",value:function(e){var t;return(null!==(t=this.activeParseLexer)&&void 0!==t?t:this.createLexer()).inlineTokens(e)}},{key:"registerTokenizer",value:function(t){var n=this;if(this.hasMarked()){var r=t.name,o=t.start,i=t.level,a=void 0===i?"inline":i,u=t.tokenize,s=this.createTokenizerHelpers.bind(this),l=this.createLexer.bind(this),c={name:r,level:a,start:o?"function"==typeof o?o:function(e){return e.indexOf(o)}:function(e){var t=u(e,[],n.createTokenizerHelpers(n.createLexer()));return t&&t.raw?e.indexOf(t.raw):-1},tokenizer:function(t,n){var o=this.lexer?s(this.lexer):s(l()),i=u(t,n,o);if(i&&i.type)return e(e({},i),{},{type:i.type||r,raw:i.raw||"",tokens:i.tokens||[]})},childTokens:[]};this.markedInstance.use({extensions:[c]})}}},{key:"getHandlersForToken",value:function(e){try{return this.registry.get(e)||[]}catch(e){return[]}}},{key:"getHandlerForToken",value:function(e){var t=this.getHandlersForToken(e);if(t.length>0)return t[0];var n=this.getHandlersForNodeType(e);return n.length>0?n[0]:void 0}},{key:"getHandlersForNodeType",value:function(e){try{return this.nodeTypeRegistry.get(e)||[]}catch(e){return[]}}},{key:"serialize",value:function(e){if(!e)return"";var t=this.renderNodes(e,e);return this.isEmptyOutput(t)?"":t}},{key:"isEmptyOutput",value:function(e){return!e||""===e.trim()||""===e.replace(/ /g,"").replace(/\u00A0/g,"").trim()}},{key:"parse",value:function(e){if(!this.hasMarked())throw new Error("No marked instance available for parsing");var t=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{var r=n.lex(e);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=t}}},{key:"parseTokens",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=r?function(t){return t.flatMap(function(n,r){var o;if("space"===n.type||"space"===(null===(o=t[r+1])||void 0===o?void 0:o.type))return[n];var i=(n.raw||"").match(ok);return i?[e(e({},n),{},{raw:(n.raw||"").slice(0,-i[0].length)}),{type:"space",raw:i[0]}]:[n]})}(t):t,i=o.reduce(function(e,t,n){return"space"!==t.type&&e.push(n),e},[]),a=-1,u=0;return o.flatMap(function(e,t){for(;u<i.length&&i[u]<t;)a=i[u],u+=1;if(r&&"space"===e.type){var o,s=null!==(o=i[u])&&void 0!==o?o:-1;return n.createImplicitEmptyParagraphsFromSpace(e,a,s)}var l=n.parseToken(e,r);return null===l?[]:Array.isArray(l)?l:[l]})}},{key:"createImplicitEmptyParagraphsFromSpace",value:function(e,t,n){var r=this.countParagraphSeparators(e.raw||"");if(0===r)return[];var o=Math.max(r-(-1===t||-1===n?0:1),0);return Array.from({length:o},function(){return{type:"paragraph",content:[]}})}},{key:"countParagraphSeparators",value:function(e){return(e.replace(/\r\n/g,"\n").match(/\n\n/g)||[]).length}},{key:"parseToken",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.type)return null;if("list"===e.type)return this.parseListToken(e);var r=this.getHandlersForToken(e.type),o=this.createParseHelpers();if(r.find(function(n){if(!n.parseMarkdown)return!1;var r=n.parseMarkdown(e,o),i=t.normalizeParseResult(r);return!(!i||Array.isArray(i)&&!(i.length>0))&&(t.lastParseResult=i,!0)})&&this.lastParseResult){var i=this.lastParseResult;return this.lastParseResult=null,i}return this.parseFallbackToken(e,n)}},{key:"parseListToken",value:function(t){var n=this;if(!t.items||0===t.items.length)return this.parseTokenWithHandlers(t);var r=t.items.some(function(e){return uk(e).isTask}),i=t.items.some(function(e){return!uk(e).isTask});if(!r||!i||0===this.getHandlersForToken("taskList").length)return this.parseTokenWithHandlers(t);for(var a=[],u=[],s=null,l=function(){var e=t.items[c],r=uk(e),i=r.isTask,l=r.checked,d=r.indentLevel,f=e;if(i){var h=(e.raw||e.text||"").split("\n"),p=h[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),v=p?p[2]:"",m=[];if(h.length>1&&h.slice(1).join("\n").trim()){var g=h.slice(1),D=g.filter(function(e){return e.trim()});if(D.length>0){var y=Math.min.apply(Math,o(D.map(function(e){return e.length-e.trimStart().length}))),k=g.map(function(e){return e.trim()?e.slice(y):""}).join("\n").trim();k&&(m=n.markedInstance.lexer("".concat(k,"\n")))}}f={type:"taskItem",raw:"",mainContent:v,indentLevel:d,checked:null!=l&&l,text:v,tokens:n.tokenizeInline(v),nestedTokens:m}}var E=i?"taskList":"list";s!==E?(u.length>0&&a.push({type:s,items:u}),u=[f],s=E):u.push(f)},c=0;c<t.items.length;c+=1)l();u.length>0&&a.push({type:s,items:u});for(var d=[],f=0;f<a.length;f+=1){var h=a[f],p=e(e({},t),{},{type:h.type,items:h.items}),v=this.parseToken(p);v&&(Array.isArray(v)?d.push.apply(d,o(v)):d.push(v))}return d.length>0?d:null}},{key:"parseTokenWithHandlers",value:function(e){var t=this;if(!e.type)return null;var n=this.getHandlersForToken(e.type),r=this.createParseHelpers();if(n.find(function(n){if(!n.parseMarkdown)return!1;var o=n.parseMarkdown(e,r),i=t.normalizeParseResult(o);return!(!i||Array.isArray(i)&&!(i.length>0))&&(t.lastParseResult=i,!0)})&&this.lastParseResult){var o=this.lastParseResult;return this.lastParseResult=null,o}return this.parseFallbackToken(e)}},{key:"createParseHelpers",value:function(){var e=this;return{parseInline:function(t){return e.parseInlineTokens(t)},tokenizeInline:function(t){return e.tokenizeInline(t)},parseChildren:function(t){return e.parseTokens(t)},parseBlockChildren:function(t){return e.parseTokens(t,!0)},createTextNode:function(e,t){return{type:"text",text:e,marks:t||void 0}},createNode:function(e,t,n){var r={type:e,attrs:t||void 0,content:n||void 0};return t&&0!==Object.keys(t).length||delete r.attrs,r},applyMark:function(e,t,n){return{mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0}}}}},{key:"escapeRegex",value:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},{key:"parseInlineTokens",value:function(e){for(var t=[],n=0;n<e.length;n+=1){var r=e[n];if("text"===r.type)t.push({type:"text",text:Uh(r.text||"")});else if("escape"===r.type)t.push({type:"text",text:r.text||""});else if("html"===r.type){var i,a,u=(null!==(i=null!==(a=r.raw)&&void 0!==a?a:r.text)&&void 0!==i?i:"").toString(),s=/^<\/[\s]*[\w-]+/i.test(u),l=u.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!s&&l&&!/\/>$/.test(u)){for(var c=l[1],d=this.escapeRegex(c),f=new RegExp("^<\\/\\s*".concat(d,"\\b"),"i"),h=-1,p=[u],v=n+1;v<e.length;v+=1){var m,g,D=e[v],y=(null!==(m=null!==(g=D.raw)&&void 0!==g?g:D.text)&&void 0!==m?m:"").toString();if(p.push(y),"html"===D.type&&f.test(y)){h=v;break}}if(-1!==h){var k=p.join(""),E={type:"html",raw:k,text:k,block:!1},F=this.parseHTMLToken(E);if(F){var b=this.normalizeParseResult(F);Array.isArray(b)?t.push.apply(t,o(b)):b&&t.push(b)}n=h;continue}}var C=this.parseHTMLToken(r);if(C){var w=this.normalizeParseResult(C);Array.isArray(w)?t.push.apply(t,o(w)):w&&t.push(w)}}else if(r.type){var A=this.getHandlerForToken(r.type);if(A&&A.parseMarkdown){var x=this.createParseHelpers(),S=A.parseMarkdown(r,x);if(this.isMarkResult(S)){var B=this.applyMarkToContent(S.mark,S.content,S.attrs);t.push.apply(t,o(B))}else{var T=this.normalizeParseResult(S);Array.isArray(T)?t.push.apply(t,o(T)):T&&t.push(T)}}else r.tokens&&t.push.apply(t,o(this.parseInlineTokens(r.tokens)))}}for(var M=t.length-1;M>0;M-=1){var N=t[M],R=t[M-1];if("text"===N.type&&"text"===R.type)Zh(N.marks||[],R.marks||[])&&(R.text=(R.text||"")+(N.text||""),t.splice(M,1))}return t}},{key:"applyMarkToContent",value:function(t,n,r){var i=this;return n.map(function(n){if("text"===n.type){var a=n.marks||[],u=r?{type:t,attrs:r}:{type:t};return e(e({},n),{},{marks:[].concat(o(a),[u])})}return e(e({},n),{},{content:n.content?i.applyMarkToContent(t,n.content,r):void 0})})}},{key:"isMarkResult",value:function(e){return e&&"object"===k(e)&&"mark"in e}},{key:"normalizeParseResult",value:function(e){return e?this.isMarkResult(e)?e.content:e:null}},{key:"parseFallbackToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];switch(e.type){case"paragraph":return{type:"paragraph",content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"heading":return{type:"heading",attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"text":return{type:"text",text:Uh(e.text||"")};case"html":return this.parseHTMLToken(e);case"escape":return{type:"text",text:e.text||""};case"space":return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}},{key:"parseHTMLToken",value:function(e){var t=e.text||e.raw||"";if(!t.trim())return null;if(this.isUnrecognizedHtml(t))return this.htmlAsLiteralText(t,!!e.block);if("undefined"==typeof window||void 0===window.DOMParser)return this.htmlAsLiteralText(t,!!e.block);try{var n=function(e,t){var n=wf(t),r=md(e);return Po.fromSchema(n).parse(r).toJSON()}(t,this.baseExtensions);if("doc"===n.type&&n.content){if(e.block)return n.content;var r=this.toInlineContent(n.content);return r.length>0?r:null}return n}catch(e){throw new Error("Failed to parse HTML in markdown: ".concat(e))}}},{key:"toInlineContent",value:function(e){var t=this,n=this.getInlineNodeTypes();return e.flatMap(function(e){return e.type&&n.has(e.type)?[e]:e.content?t.toInlineContent(e.content):[]})}},{key:"getInlineNodeTypes",value:function(){if(this.inlineNodeTypesCache)return this.inlineNodeTypesCache;var e=new Set(["text"]);try{var t=wf(this.baseExtensions);Object.values(t.nodes).forEach(function(t){t.isInline&&e.add(t.name)})}catch(e){}return this.inlineNodeTypesCache=e,e}},{key:"isUnrecognizedHtml",value:function(e){return dk(e,this.getSchemaParseDomTags())}},{key:"getSchemaParseDomTags",value:function(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;var e=new Set;try{var t=wf(this.baseExtensions),n=function(t){var n=null==t?void 0:t.parseDOM;Array.isArray(n)&&n.forEach(function(t){if("string"==typeof(null==t?void 0:t.tag)){var n=t.tag.match(/^[a-zA-Z][\w-]*/);n&&e.add(n[0].toLowerCase())}})};Object.values(t.nodes).forEach(function(e){return n(e.spec)}),Object.values(t.marks).forEach(function(e){return n(e.spec)})}catch(e){}return this.schemaParseDomTagsCache=e,e}},{key:"htmlAsLiteralText",value:function(e,t){var n=e.replace(/\s+$/,"");return n?t?{type:"paragraph",content:[{type:"text",text:n}]}:{type:"text",text:n}:null}},{key:"encodeTextForMarkdown",value:function(e,t,n){var r=this;return null!=(null==n?void 0:n.type)&&this.codeTypes.has(n.type)||(t.marks||[]).some(function(e){return r.codeTypes.has("string"==typeof e?e:e.type)})?e:this.escapeMarkdownSyntax(function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}(e))}},{key:"escapeMarkdownSyntax",value:function(e){return e.replace(/([\\`*_[\]~])/g,"\\$1")}},{key:"renderNodeToMarkdown",value:function(t,n){var r,o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if("text"===t.type)return this.encodeTextForMarkdown(t.text||"",t,n);if(!t.type)return"";var s=this.getHandlerForToken(t.type);if(!s)return"";var l=Array.isArray(null==n?void 0:n.content)&&i>0?n.content[i-1]:void 0,c={renderChildren:function(e,n){var r=s.isIndenting?a+1:a;return!Array.isArray(e)&&e.content?o.renderNodes(e.content,t,n||"",i,r):o.renderNodes(e,t,n||"",i,r)},renderChild:function(e,n){var r=s.isIndenting?a+1:a;return o.renderNodeToMarkdown(e,t,n,r)},indent:function(e){return o.indentString+e},wrapInBlock:ik},d={index:i,level:a,parentType:null==n?void 0:n.type,previousNode:l,meta:e({parentAttrs:null==n?void 0:n.attrs},u)};return(null===(r=s.renderMarkdown)||void 0===r?void 0:r.call(s,t,c,d))||""}},{key:"renderNodes",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,o):e.type?this.renderNodeToMarkdown(e,t,r,o):""}},{key:"renderNodesWithMarkBoundaries",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=[],s=new Map,l=new Set,c=new Map,d=function(e){var t=e.map(function(){return new Map}),n=new Map,r=function(e){var r=n.get(e);r&&(r.indexes.forEach(function(n){return t[n].set(e,r.text)}),n.delete(e))};return e.forEach(function(e,t){if("text"===e.type){var o=new Set((e.marks||[]).map(function(e){return e.type}));Array.from(n.keys()).filter(function(e){return!o.has(e)}).forEach(r),o.forEach(function(r){var o=n.get(r)||{indexes:[],text:""};o.indexes.push(t),o.text+=e.text||"",n.set(r,o)})}else Array.from(n.keys()).forEach(r)}),Array.from(n.keys()).forEach(r),t}(e);if(e.forEach(function(r,f){var h=f<e.length-1?e[f+1]:null;if(r.type)if("text"===r.type){var p=n.encodeTextForMarkdown(r.text||"",r,t),v=new Map((r.marks||[]).map(function(e){return[e.type,e]})),m=n.getMarksToOpenForSerialization(s,v,h),g=ak(v,h);if(p.length>0&&0===p.trim().length&&v.size>0){var D=new Set(g.filter(function(e){return!s.has(e)}));D.size>0&&(v=new Map(Array.from(v).filter(function(e){var t=i(e,1)[0];return!D.has(t)})),m=n.getMarksToOpenForSerialization(s,v,h),g=ak(v,h))}var y=g.filter(function(e){return s.has(e)}),k=y.length>0&&m.length>0,E="";if(g.length>0&&!k){var F=p.match(/(\s+)$/);F&&(E=F[1],p=p.slice(0,-E.length))}k||g.slice().reverse().forEach(function(e){var t;if(s.has(e)){var r=v.get(e),o=n.getMarkClosing(e,r,c.get(e),null===(t=d[f])||void 0===t?void 0:t.get(e));o&&(p+=o),s.has(e)&&(s.delete(e),c.delete(e))}});var b,C="";if(m.length>0){var w=p.match(/^(\s+)/);w&&(C=w[1],p=p.slice(C.length))}if(m.forEach(function(e){var t,r=e.type,o=e.mark,i=l.has(r)?"html":"markdown",a=n.getMarkOpening(r,o,i,null===(t=d[f])||void 0===t?void 0:t.get(r));a&&(p=a+p),c.set(r,i),l.delete(r)}),k||m.slice().reverse().forEach(function(e){var t=e.type,n=e.mark;s.set(t,n)}),p=C+p,k){var A=new Set(((null==h?void 0:h.marks)||[]).map(function(e){return e.type}));m.forEach(function(e){var t=e.type;A.has(t)&&n.getHtmlReopenTags(t)&&l.add(t)});var x=Array.from(s.keys()),S=y.slice().sort(function(e,t){return x.indexOf(t)-x.indexOf(e)});b=[].concat(o(m.map(function(e){return e.type})),o(S))}else b=function(e,t,n,r){var a=!n,u=n&&(!n.marks||0===n.marks.length),s=n&&n.marks&&!r(t,new Map(n.marks.map(function(e){return[e.type,e]}))),l=[];return(a||u||s)&&(n&&n.marks?Array.from(e.entries()).reverse().forEach(function(e){var t=i(e,2),r=t[0],o=t[1];n.marks.find(function(e){return e.type===r&&Hh(e.attrs,o.attrs)})||l.push(r)}):(a||u)&&l.push.apply(l,o(Array.from(e.keys()).reverse()))),l}(s,v,h,n.markSetsEqual.bind(n));var B="";if(b.length>0){var T=p.match(/(\s+)$/);T&&(B=T[1],p=p.slice(0,-B.length))}b.forEach(function(e){var t,r,o=null!==(t=s.get(e))&&void 0!==t?t:v.get(e),i=n.getMarkClosing(e,o,c.get(e),null===(r=d[f])||void 0===r?void 0:r.get(e));i&&(p+=i),s.delete(e),c.delete(e)}),p+=B,p+=E,u.push(p)}else{var M=new Set((r.marks||[]).map(function(e){return e.type})),N=new Map,R=new Map;s.forEach(function(e,t){var n;M.has(t)&&(N.set(t,e),R.set(t,null!==(n=c.get(t))&&void 0!==n?n:"markdown"))});var O=function(e,t){var n="";return Array.from(e.keys()).reverse().forEach(function(r){var o=t(r,e.get(r));o&&(n=o+n)}),e.clear(),n}(s,function(e,t){var r;return n.getMarkClosing(e,t,c.get(e),null===(r=d[f-1])||void 0===r?void 0:r.get(e))});c.clear();var I=n.renderNodeToMarkdown(r,t,f,a),P="hardBreak"===r.type?"":function(e,t,n){var r="";return Array.from(e.entries()).forEach(function(e){var o=i(e,2),a=o[0],u=o[1],s=n(a,u);s&&(r+=s),t.set(a,u)}),r}(N,s,function(e,t){var r,o,i=null!==(r=R.get(e))&&void 0!==r?r:"markdown";return c.set(e,i),n.getMarkOpening(e,t,i,null===(o=d[f+1])||void 0===o?void 0:o.get(e))});u.push(O+I+P)}}),""===r){var f=-1;u.forEach(function(e,t){if(e){if(f>=0&&e.startsWith("[")){var n=/(\\*)!$/.exec(u[f]);n&&n[1].length%2==0&&(u[f]="".concat(u[f].slice(0,-1),"\\!"))}f=t}})}return u.join(r)}},{key:"getMarkOpening",value:function(e,t){var n,r=arguments.length>3?arguments[3]:void 0;if("html"===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"markdown"))return(null===(n=this.getHtmlReopenTags(e))||void 0===n?void 0:n.open)||"";var o=this.getHandlersForNodeType(e),i=o.length>0?o[0]:void 0;if(!i||!i.renderMarkdown)return"";var a="__TIPTAP_MARKDOWN_PLACEHOLDER__",u={type:e,attrs:t.attrs||{},content:[{type:"text",text:a}]};try{var s=i.renderMarkdown(u,{renderChildren:function(){return a},renderChild:function(){return a},indent:function(e){return e},wrapInBlock:function(e,t){return e+t}},{index:0,level:0,parentType:"text",meta:{markText:r}}),l=s.indexOf(a);return l>=0?s.substring(0,l):""}catch(t){throw new Error("Failed to get mark opening for ".concat(e,": ").concat(t))}}},{key:"getMarkClosing",value:function(e,t){var n,r=arguments.length>3?arguments[3]:void 0;if("html"===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"markdown"))return(null===(n=this.getHtmlReopenTags(e))||void 0===n?void 0:n.close)||"";var o=this.getHandlersForNodeType(e),i=o.length>0?o[0]:void 0;if(!i||!i.renderMarkdown)return"";var a="__TIPTAP_MARKDOWN_PLACEHOLDER__",u={type:e,attrs:t.attrs||{},content:[{type:"text",text:a}]};try{var s=i.renderMarkdown(u,{renderChildren:function(){return a},renderChild:function(){return a},indent:function(e){return e},wrapInBlock:function(e,t){return e+t}},{index:0,level:0,parentType:"text",meta:{markText:r}}),l=s.indexOf(a),c=l+33;return l>=0?s.substring(c):""}catch(t){throw new Error("Failed to get mark closing for ".concat(e,": ").concat(t))}}},{key:"getHtmlReopenTags",value:function(e){var t=this.getHandlersForNodeType(e),n=t.length>0?t[0]:void 0;return null==n?void 0:n.htmlReopen}},{key:"markSetsEqual",value:function(e,t){return e.size===t.size&&Array.from(e.entries()).every(function(e){var n=i(e,2),r=n[0],o=n[1],a=t.get(r);return a&&Hh(o.attrs,a.attrs)})}},{key:"getMarksToOpenForSerialization",value:function(e,t,n){var r=this,a=function(e,t){var n=[];return Array.from(t.entries()).forEach(function(t){var r=i(t,2),o=r[0],a=r[1],u=e.get(o);u&&Hh(u.attrs,a.attrs)||n.push({type:o,mark:a})}),n}(e,t);if(a.length<=1)return a;var u=(null==n?void 0:n.marks)||[],s=function(e,t){return u.some(function(n){return n.type===e&&Hh(n.attrs,t)})},l=function(e,t){var n,o,i=null!==(n=r.extensionRanks.get(e.type))&&void 0!==n?n:Number.MAX_SAFE_INTEGER,a=null!==(o=r.extensionRanks.get(t.type))&&void 0!==o?o:Number.MAX_SAFE_INTEGER;return i!==a?a-i:e.type.localeCompare(t.type)},c=a.filter(function(e){return!s(e.type,e.mark.attrs)}).sort(l),d=a.filter(function(e){return s(e.type,e.mark.attrs)}).sort(l);return[].concat(o(c),o(d))}}])}(),hk=fp.create({name:"markdown",addOptions:function(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands:function(){var e=this;return{setContent:function(t,n){if(!(null==n?void 0:n.contentType))return Ch.setContent(t,n);if("markdown"!==sk(t,null==n?void 0:n.contentType)||!e.editor.markdown)return Ch.setContent(t,n);var r=e.editor.markdown.parse(t);return Ch.setContent(r,n)},insertContent:function(t,n){if(!(null==n?void 0:n.contentType))return Ch.insertContent(t,n);if("markdown"!==sk(t,null==n?void 0:n.contentType)||!e.editor.markdown)return Ch.insertContent(t,n);var r=e.editor.markdown.parse(t);return Ch.insertContent(r,n)},insertContentAt:function(t,n,r){if(!(null==r?void 0:r.contentType))return Ch.insertContentAt(t,n,r);if("markdown"!==sk(n,null==r?void 0:r.contentType)||!e.editor.markdown)return Ch.insertContentAt(t,n,r);var o=e.editor.markdown.parse(n);return Ch.insertContentAt(t,o,r)}}},addStorage:function(){return{manager:new fk({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate:function(){var e,t=this;if(this.editor.markdown)console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");else if(this.storage.manager=new fk({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=function(){return t.storage.manager.serialize(t.editor.getJSON())},this.editor.options.contentType&&"markdown"===sk(this.editor.options.content,this.editor.options.contentType)){if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(void 0===this.editor.options.content||"string"!=typeof this.editor.options.content)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');var n=this.editor.markdown.parse(this.editor.options.content);(null===(e=n.content)||void 0===e?void 0:e.length)&&(this.editor.options.content=n)}}}),pk=function(e){return Math.min(Math.max(Math.trunc(Number(e.length))||0,0),Number.MAX_SAFE_INTEGER)},vk={at:function(e){var t=Object(this),n=pk(t),r=Math.trunc(Number(e))||0,o=r<0?n+r:r;return o<0||o>=n?void 0:t[o]},findLast:function(e,t){for(var n=Object(this),r=pk(n)-1;r>=0;r-=1)if(e.call(t,n[r],r,n))return n[r]},findLastIndex:function(e,t){for(var n=Object(this),r=pk(n)-1;r>=0;r-=1)if(e.call(t,n[r],r,n))return r;return-1}},mk={hasOwn:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(e),t)}},gk=function(e,t){Object.keys(t).forEach(function(n){"function"!=typeof e[n]&&Object.defineProperty(e,n,{value:t[n],writable:!0,configurable:!0})})},Dk=!1,yk={breaks:!0,gfm:!0},kk=["http","https","mailto"],Ek="react-autoql-link-request",Fk=fp.create({name:"reactAutoqlLinkShortcut",addKeyboardShortcuts:function(){var e=this;return{"Mod-k":function(){return e.editor.emit(Ek),!0}}}}),bk={underline:102,strike:99},Ck=$D.extend({addExtensions:function(){return this.parent().map(function(e){return bk[e.name]?e.extend({priority:bk[e.name]}):e})}}),wk=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).placeholder;return Dk||(Dk=!0,gk(Array.prototype,vk),gk(Object,mk)),[Ck.configure({link:{openOnClick:!1,autolink:!0,linkOnPaste:!0,defaultProtocol:"https",protocols:kk}}),hk.configure({markedOptions:yk}),Fk].concat(o(e?[RD.configure({placeholder:e})]:[]))},Ak=null,xk=function(){return Ak||(Ak=wk()),Ak},Sk=null,Bk=function(){return Sk||(Sk=new fk({extensions:xk(),markedOptions:yk})),Sk},Tk=function(e){return"string"==typeof e?e:""},Mk=new Map,Nk=["bulletList","orderedList"],Rk=new Map,Ok=function(e){var t=Rk.get(e);return void 0===t&&(t=[],(Bk().parse(e).content||[]).forEach(function(e){Nk.includes(e.type)?(e.content||[]).forEach(function(n,r){return t.push({list:e,node:n,index:r})}):t.push({node:e})}),Rk.size>=300&&Rk.clear(),Rk.set(e,t)),t},Ik=function(e){return"text"===e.type?e.text||"":(e.content||[]).map(Ik).join("paragraph"===e.type?"":"\n")},Pk=new Map,Lk=/^[^\s@/:]+@[^\s@/:]+\.[^\s@/:]+$/,zk=/^[a-z][a-z0-9+.-]*:(?!\d)/i,$k=/^[^\s.]+(\.[^\s.]+)+$/,qk=function(e){return e.reduce(function(e,t){return e+t},0)},jk=function(e){return"heading"===e.type||"text"===e.type||"analysis"===e.type?!!(e.text||"").trim():"data"===e.type?!!e.source:"pagebreak"===e.type},Hk=function(e){for(var t=[],n=0;n<e.length;){var r=e[n],o=e[n+1],i=function(e){return e&&"pagebreak"!==e.type&&"half"===e.width};i(r)&&i(o)?(t.push([r,o]),n+=2):(t.push([r]),n+=1)}return t},Vk=function(t){var n=t.blocks,r=t.views,a=t.measurements;return Hk(n.filter(jk)).map(function(t){var n,u,s,l,c=i(t,1)[0];return 1===t.length&&"pagebreak"===c.type?{type:"break"}:1===t.length&&null!=r&&null!==(n=r[c.id])&&void 0!==n&&n.split&&null!==(u=a.tables)&&void 0!==u&&u[c.id]?e({type:"table",id:c.id},a.tables[c.id]):1===t.length&&null!==(s=a.flows)&&void 0!==s&&null!==(s=s[c.id])&&void 0!==s&&null!==(s=s.chunks)&&void 0!==s&&s.length?e({type:"flow",id:c.id,height:(null===(l=a.blocks)||void 0===l?void 0:l[c.id])||0},a.flows[c.id]):{type:"atomic",ids:t.map(function(e){return e.id}),height:Math.max.apply(Math,o(t.map(function(e){var t;return(null===(t=a.blocks)||void 0===t?void 0:t[e.id])||0}))),keepWithNext:1===t.length&&"heading"===c.type}})},Uk=function(e,t,n,r){for(var o=e.chrome+r,i=0;t+i<e.rows.length;){var a=o+e.rows[t+i];if(a+(t+i+1===e.rows.length?e.tail:e.continued)>n)break;o=a,i+=1}return i},Wk=function(e,t,n){for(var r=e.head,o=0;t+o<e.chunks.length;){var i=r+e.chunks[t+o];if(i+(t+o+1===e.chunks.length?e.tail:e.end)>n)break;r=i,o+=1}for(;o>1&&t+o<e.chunks.length&&null!==(a=e.keep)&&void 0!==a&&a[t+o-1];){var a;o-=1}return o},_k=function(e,t){var n=t.contentHeight,r=t.repeatTableHeaders,o=void 0===r||r,i=t.minRows,a=void 0===i?3:i,u=t.minChunks,s=void 0===u?2:u,l=t.safety,c=void 0===l?4:l,d=Math.max(1,n-c),f=[],h={cells:[],overflow:!1},p=0,v=function(){h.cells.length&&(f.push(h),h={cells:[],overflow:!1},p=0)};return e.forEach(function(t,n){if("break"!==t.type)if("flow"===t.type&&t.height>d)for(var r=t.chunks.length,i=0;i<r;){var u=Wk(t,i,d-p);if(u<Math.min(s,r-i)&&p>0)v();else{0===u&&(u=1,h.overflow=!0);var l=i+u,c=l>=r;h.cells.push({kind:"flow",id:t.id,from:i,to:l,isLast:c}),p+=t.head+qk(t.chunks.slice(i,l))+(c?t.tail:t.end),i=l,c||v()}}else{if("atomic"===t.type||"flow"===t.type){var f="flow"===t.type?[t.id]:t.ids,m=t.height+(t.keepWithNext?function(e){return e&&"break"!==e.type?"table"===e.type?e.chrome+e.header+qk(e.rows.slice(0,a)):"flow"===e.type&&e.height>d?e.head+qk(e.chunks.slice(0,s)):e.height:0}(e[n+1]):0);return p>0&&m>d-p&&v(),h.cells.push({kind:"blocks",ids:f}),p+=t.height,void(t.height>d&&(h.overflow=!0))}var g=t.rows.length;if(0===g){var D=t.chrome+t.header+t.tail;return p>0&&D>d-p&&v(),h.cells.push({kind:"table",id:t.id,from:0,to:0,showHeader:!0,isLast:!0}),void(p+=D)}for(var y=0;y<g;){var k=0===y||o,E=k?t.header:0,F=g-y,b=Uk(t,y,d-p,E);if(b<Math.min(a,F)&&p>0)v();else{0===b&&(b=1,h.overflow=!0);var C=F-b;C>0&&C<a&&b>a&&(b=Math.max(a,b-(a-C)));var w=y+b,A=w>=g;h.cells.push({kind:"table",id:t.id,from:y,to:w,showHeader:k,isLast:A}),p+=t.chrome+E+qk(t.rows.slice(y,w))+(A?t.tail:t.continued),y=w,A||v()}}}else v()}),!h.cells.length&&f.length||f.push(h),f},Kk=function(e){var t={};return e.forEach(function(e,n){e.cells.forEach(function(e){("table"===e.kind||"flow"===e.kind?0===e.from?[e.id]:[]:e.ids||[]).forEach(function(e){null==t[e]&&(t[e]=n)})})}),t},Jk={1:34,2:28,3:22},Qk={chrome:30,header:26,row:22,tail:40,continued:20},Gk=function(t){var n=t.blocks,r=t.views,o=t.contentWidthPx,i=Math.max(20,Math.floor(o/7)),a={blocks:{},tables:{},flows:{}},u=function(e,t){var n=t.head,r=t.tail,o=function(e){var t=Tk(e);return t?Ok(t).map(function(e){return{text:Ik(e.node),heading:"heading"===e.node.type}}):[]}(e),a=o.map(function(e){return 18*e.text.split("\n").reduce(function(e,t){return e+Math.max(1,Math.ceil(t.length/i))},0)+6});return a.length?{head:n,chunks:a,tail:r,end:n,keep:o.map(function(e){return e.heading})}:null};return n.forEach(function(t){var n=null==r?void 0:r[t.id],o="half"===t.width,s=function(){return(t.text||"").split("\n").reduce(function(e,t){return e+Math.max(1,Math.ceil(t.length/(o?i/2:i)))},0)};switch(t.type){case"heading":a.blocks[t.id]=(Jk[t.level]||Jk[2])*(t.text||"").trim().split("\n").length;break;case"text":a.blocks[t.id]=18*s()+12;var l=o?null:u(t.text,{head:6,tail:6});l&&(a.flows[t.id]=l);break;case"analysis":a.blocks[t.id]=18*s()+34;var c=o?null:u(Kt(t.text),{head:6,tail:28});c&&(a.flows[t.id]=c);break;case"data":if("table"===(null==n?void 0:n.kind)&&"ready"===n.state){var d=new Array(n.rows.length).fill(Qk.row);a.tables[t.id]=e(e({},Qk),{},{rows:d}),a.blocks[t.id]=Qk.chrome+Qk.header+qk(d)+Qk.tail}else"chart"===(null==n?void 0:n.kind)&&"ready"===n.state?a.blocks[t.id]=(o?y.half:y.full)+60:a.blocks[t.id]=96;break;default:a.blocks[t.id]=0}}),a},Xk=function(e,t,n){if(null==e||""===e)return"";var r=Ct({element:e,column:t,config:n});return null==r?"":r},Zk=pt.memo(function(e){var t=e.columns,n=e.rows,r=e.from,o=void 0===r?0:r,i=e.dataFormatting,a=e.showHeader,u=void 0===a||a,s=e.total,l=void 0===s?null:s,c=e.measure,d=void 0!==c&&c,f=Ft(i);return pt.createElement("table",{className:"".concat(w,"-table"),"data-measure-table":d||void 0},u?pt.createElement("thead",null,pt.createElement("tr",null,t.map(function(e){var t;return pt.createElement("th",{key:null!==(t=e.name)&&void 0!==t?t:e.index,scope:"col","data-numeric":bt(e)||void 0},e.display_name||e.name)}))):null,pt.createElement("tbody",null,n.map(function(e,n){return pt.createElement("tr",{key:o+n,"data-row":""},t.map(function(t){var n;return pt.createElement("td",{key:null!==(n=t.name)&&void 0!==n?n:t.index,"data-numeric":bt(t)||void 0},Xk(null==e?void 0:e[t.index],t,f))}))}),l?pt.createElement("tr",{"data-total":""},t.map(function(e){var t,n=e.index===l.labelIndex,r=l.sums[e.index];return pt.createElement("td",{key:null!==(t=e.name)&&void 0!==t?t:e.index,"data-numeric":!n&&bt(e)||void 0},n?Rt.data.total:void 0!==r?Xk(r,e,f):"")})):null))}),Yk=["pivotTableConfig"],eE={allowDisplayTypeChange:!1,enableDynamicCharting:!1,enableChartControls:!1,enableTableSorting:!1,enableTableContextMenu:!1,enableCustomColumns:!1,allowColumnAddition:!1,useInfiniteScroll:!1,showQueryInterpretation:!1,autoSelectQueryValidationSuggestion:!1,showSuggestionPrefix:!1,mutable:!1,isResizing:!1,autoHeight:!1,height:"100%",width:"100%"},tE=new WeakMap,nE=0,rE=function(e){return e&&"object"===k(e)?(tE.has(e)||(nE+=1,tE.set(e,nE)),String(tE.get(e))):"none"},oE=function(t){function n(){var t;M(this,n);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return t=N(this,n,[].concat(i)),S(t,"used",!1),S(t,"reported",{}),S(t,"onUse",function(){t.used=!0}),S(t,"report",function(e,n){var r,o=t.reported[e];t.reported[e]=n,t.used&&t.props.onConfigChange&&n&&(wt(n,o)||wt(n,null===(r=t.props.view.tile)||void 0===r?void 0:r[e])||t.props.onConfigChange(S({},e,JSON.parse(JSON.stringify(n)))))}),S(t,"onTableConfigChange",function(n){return t.report("dataConfig",n&&(u=(o=n).pivotTableConfig,s=r(o,Yk),null!=u&&null!==(i=u.numberColumnIndices)&&void 0!==i&&i.length||null!=u&&null!==(a=u.stringColumnIndices)&&void 0!==a&&a.length?e(e({},s),{},{pivotTableConfig:u}):s));var o,i,a,u,s}),S(t,"onAggConfigChange",function(e){return t.report("aggConfig",e)}),t}return A(n,t),x(n,[{key:"shouldComponentUpdate",value:function(e){var t=this.props,n=t.view,r=t.dataFormatting,o=t.autoQLConfig;return e.view.response!==n.response||e.view.displayType!==n.displayType||e.view.height!==n.height||e.view.tile!==n.tile||!e.onConfigChange!=!this.props.onConfigChange||!wt(e.dataFormatting,r)||!wt(e.autoQLConfig,o)}},{key:"render",value:function(){var t=this.props,n=t.view,r=t.authentication,o=t.autoQLConfig,i=t.dataFormatting,a=t.onConfigChange,u=n.tile,s=n.response,l=n.displayType,c=n.height,d=u?K(u,{queryResponse:s}):{queryResponse:s},f=u?J(o,u):At(o),h="function"==typeof a;return pt.createElement("div",T({className:"".concat(w,"-chart")},S({},tn,""),{style:{height:c},"data-editable":h||void 0,onMouseDownCapture:h?this.onUse:void 0,onKeyDownCapture:h?this.onUse:void 0}),pt.createElement(Q,T({key:"".concat(rE(s),":").concat(l)},d,eE,h?{enableDynamicCharting:!0,onTableConfigChange:this.onTableConfigChange,onAggConfigChange:this.onAggConfigChange}:{},{initialDisplayType:l,authentication:r,autoQLConfig:e(e({},f),{},{enableDrilldowns:!1}),dataFormatting:i})))}}])}(pt.Component),iE=["singleLine","onChange","onKeyDown","value"],aE=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"ref",pt.createRef()),S(e,"onResize",function(t){var n,r=null===(n=t[0])||void 0===n||null===(n=n.contentRect)||void 0===n?void 0:n.width;r!==e.lastWidth&&(e.lastWidth=r,e.resize())}),S(e,"resize",function(){var t=e.ref.current;t&&(t.style.height="auto",t.scrollHeight&&(t.style.height="".concat(t.scrollHeight+(t.offsetHeight-t.clientHeight),"px")))}),S(e,"onChange",function(t){var n=e.props,r=n.singleLine,o=n.onChange,i=r?t.target.value.replace(/\s*\n\s*/g," "):t.target.value;null==o||o(i)}),S(e,"onKeyDown",function(t){var n,r;e.props.singleLine&&"Enter"===t.key&&(t.preventDefault(),t.currentTarget.blur()),null===(n=(r=e.props).onKeyDown)||void 0===n||n.call(r,t)}),e}return A(t,e),x(t,[{key:"componentDidMount",value:function(){var e,t;this.resize(),"undefined"!=typeof ResizeObserver&&this.ref.current&&(this.observer=new ResizeObserver(this.onResize),this.observer.observe(this.ref.current)),null===(e=document.fonts)||void 0===e||null===(t=e.addEventListener)||void 0===t||t.call(e,"loadingdone",this.resize)}},{key:"componentDidUpdate",value:function(e){e.value===this.props.value&&e.style===this.props.style||this.resize()}},{key:"componentWillUnmount",value:function(){var e,t,n;null===(e=this.observer)||void 0===e||e.disconnect(),null===(t=document.fonts)||void 0===t||null===(n=t.removeEventListener)||void 0===n||n.call(t,"loadingdone",this.resize)}},{key:"render",value:function(){var e=this.props;e.singleLine,e.onChange,e.onKeyDown;var t=e.value,n=r(e,iE);return pt.createElement("textarea",T({},n,{ref:this.ref,rows:1,value:t||"",onChange:this.onChange,onKeyDown:this.onKeyDown}))}}])}(pt.Component),uE=pt.createContext(null),sE=pt.memo(function(t){var n=t.markdown,r=t.className,o=t.style,i=t.testId,a=t.from,u=t.to,s=null==a?function(e){var t=Tk(e);if(!t)return"";var n=Mk.get(t);return void 0===n&&(n=Af(Bk().parse(t),xk()),Mk.size>=300&&Mk.clear(),Mk.set(t,n)),n}(n):function(t,n,r){var o=Tk(t);if(!o)return"";var i="".concat(n,":").concat(r,"\0").concat(o),a=Pk.get(i);if(void 0===a){var u=[],s=null;Ok(o).slice(n,r).forEach(function(t){if(!t.list)return s=null,void u.push(t.node);if(!s||s.list!==t.list){var n,r,o="orderedList"===t.list.type?e(e({},t.list.attrs),{},{start:(null!==(n=null===(r=t.list.attrs)||void 0===r?void 0:r.start)&&void 0!==n?n:1)+t.index}):t.list.attrs;s={list:t.list,node:e(e({},t.list),{},{attrs:o,content:[]})},u.push(s.node)}s.node.content.push(t.node)}),a=u.length?Af({type:"doc",content:u},xk()):"",Pk.size>=300&&Pk.clear(),Pk.set(i,a)}return a}(n,a,u);return pt.createElement("div",{className:"".concat(w,"-rich").concat(r?" ".concat(r):""),style:o,"data-test":i,dangerouslySetInnerHTML:{__html:s}})}),lE=function(t){function n(){var e;M(this,n);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e=N(this,n,[].concat(r)),S(e,"host",pt.createRef()),S(e,"onUpdate",function(t){var n,r,o=t.editor.getMarkdown().replace(/\s+$/,"");o!==e.markdown&&(e.markdown=o,null===(n=(r=e.props).onChange)||void 0===n||n.call(r,o))}),S(e,"blockElement",function(){var t,n;return(null===(t=e.host.current)||void 0===t||null===(n=t.closest)||void 0===n?void 0:n.call(t,"[data-block-id]"))||null}),S(e,"blockId",function(){var t;return(null===(t=e.blockElement())||void 0===t?void 0:t.getAttribute("data-block-id"))||null}),S(e,"onKeyDown",function(t){if("Escape"!==t.key)return!1;var n,r=e.blockElement();r?r.focus():null===(n=e.editor)||void 0===n||n.commands.blur();return!0}),e}return A(n,t),x(n,[{key:"componentDidMount",value:function(){var t=this,n=this.props,r=n.value,o=n.placeholder,i=n.label,a=n.testId,u=n.editable;this.markdown=r||"",this.editor=new Ap({element:this.host.current,extensions:wk({placeholder:o}),content:this.markdown,contentType:"markdown",editable:u,editorProps:{attributes:e(e({class:"".concat(w,"-rich ").concat(w,"-rich-editor"),role:"textbox","aria-multiline":"true"},i?{"aria-label":i}:{}),a?{"data-test":a}:{}),handleKeyDown:function(e,n){return t.onKeyDown(n)}},onUpdate:this.onUpdate,onFocus:function(){var e,n,r;null===(e=t.context)||void 0===e||e.activate(t.editor,t.blockId()),null===(n=(r=t.props).onFocus)||void 0===n||n.call(r)},onBlur:function(e){var n,r,o,i=e.event;null===(n=t.context)||void 0===n||n.deactivate(t.editor,(null==i?void 0:i.relatedTarget)||null),null===(r=(o=t.props).onBlur)||void 0===r||r.call(o)}})}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.value,r=t.editable;this.editor&&(n!==e.value&&(n||"")!==this.markdown&&(this.markdown=n||"",this.editor.commands.setContent(this.markdown,{contentType:"markdown",emitUpdate:!1})),r!==e.editable&&this.editor.setEditable(r,!1))}},{key:"componentWillUnmount",value:function(){var e;this.editor&&(null===(e=this.context)||void 0===e||e.deactivate(this.editor,null),this.editor.destroy(),this.editor=null)}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.style;return pt.createElement("div",{ref:this.host,className:t,style:n})}}])}(pt.Component);S(lE,"contextType",uE),S(lE,"defaultProps",{value:"",editable:!0});var cE=function(){return"undefined"!=typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||"")},dE=["block","mode","onTextChange"],fE=function(e){var t;if(e){var n={};return e.font&&null!==(t=L[e.font])&&void 0!==t&&t.stack&&(n.fontFamily=L[e.font].stack),e.size&&G[e.size]&&(n.fontSize="".concat(G[e.size].pt,"pt")),e.weight&&X[e.weight]&&(n.fontWeight=X[e.weight].value),e.color&&(n.color=e.color),Object.keys(n).length?n:void 0}},hE=function(e){if(e){var t={};return e.background&&(t.background=e.background),e.align&&(t.textAlign=e.align),Object.keys(t).length?t:void 0}},pE=function(e){var t;"Enter"!==e.key||e.shiftKey||null!==(t=e.nativeEvent)&&void 0!==t&&t.isComposing||(e.preventDefault(),e.currentTarget.blur())},vE=function(e){var t=e.block,n=e.mode,r=e.onTextChange,o=fE(t.style);if("edit"===n){var i="".concat(w,"-heading-hint-").concat(t.id);return pt.createElement("div",{className:"".concat(w,"-heading-edit")},pt.createElement(aE,{className:"".concat(w,"-heading"),"data-level":t.level,style:o,value:t.text,placeholder:Rt.headingPlaceholder,"aria-label":Rt.headingPlaceholder,"aria-describedby":i,onChange:r,onKeyDown:pE}),pt.createElement("div",{id:i,className:"".concat(w,"-heading-hint"),"aria-hidden":"true","data-test":"report-builder-heading-hint"},Rt.headingNewLine(cE())))}return pt.createElement("div",{className:"".concat(w,"-heading"),"data-level":t.level,style:o,role:"heading","aria-level":t.level+1},t.text)},mE=function(e){var t=e.block,n=e.mode,r=e.onTextChange,o=e.piece,i=fE(t.style);return"edit"===n?pt.createElement(lE,{className:"".concat(w,"-text"),style:i,value:t.text,placeholder:Rt.textPlaceholder,label:Rt.textPlaceholder,testId:"report-builder-text-input",onChange:r}):pt.createElement(sE,{className:"".concat(w,"-text"),style:i,markdown:t.text,from:null==o?void 0:o.from,to:null==o?void 0:o.to})},gE=function(e){var t=e.title,n=e.children,r=e.tone;return pt.createElement("div",{className:"".concat(w,"-placeholder"),"data-tone":r||void 0},t?pt.createElement("div",{className:"".concat(w,"-placeholder-title")},t):null,n?pt.createElement("div",{className:"".concat(w,"-placeholder-body")},n):null)},DE=function(e){var t=e.mode,n=e.onAsk,r=e.canRun,o=e.canCapture,i=e.onPickTiles,a=e.pending;if("edit"!==t)return null;if(!r&&o){var u="question"===(null==a?void 0:a.kind)?a:null,s=!!u&&!u.error;return pt.createElement(gE,{title:Rt.data.emptyTitle},s?pt.createElement("div",{className:"".concat(w,"-asking"),role:"status","data-test":"report-builder-asking"},pt.createElement(Z,null),pt.createElement("span",{className:"".concat(w,"-sr-only")},Rt.data.asking(u.query))):pt.createElement("input",{key:u?"asked-".concat(u.seq):"ask",type:"text",className:"".concat(w,"-ask"),defaultValue:u?u.query:"",placeholder:Rt.data.askPlaceholder,"aria-label":Rt.data.askPlaceholder,"data-test":"report-builder-ask",disabled:"tiles"===(null==a?void 0:a.kind),onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.value.trim()&&(e.preventDefault(),null==n||n(e.currentTarget.value.trim()))}}),null!=u&&u.error?pt.createElement("span",{className:"".concat(w,"-ask-error"),role:"alert"},u.error):null,pt.createElement("span",null,Rt.data.askBody),i?pt.createElement(pt.Fragment,null,pt.createElement("span",null,Rt.data.or),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-variant":"primary","data-test":"report-builder-pick-tiles",disabled:!!a&&!a.error,onClick:i},"tiles"===(null==a?void 0:a.kind)?Rt.data.picking:Rt.data.pickTiles),pt.createElement("span",null,Rt.data.pickBody)):null)}return r?pt.createElement(gE,{title:Rt.data.emptyTitle},pt.createElement("input",{type:"text",className:"".concat(w,"-ask"),placeholder:Rt.data.askPlaceholder,"aria-label":Rt.data.askPlaceholder,onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.value.trim()&&(e.preventDefault(),null==n||n(e.currentTarget.value.trim()))}}),pt.createElement("span",null,Rt.data.emptyBody)):pt.createElement(gE,{title:Rt.data.emptyTitle},Rt.panel.noCaptureNote)},yE=function(e){var t=e.caption,n=e.interpretation;return pt.createElement("div",{className:"".concat(w,"-flow"),"data-measure-tail":""},t?pt.createElement("div",{className:"".concat(w,"-caption")},t):null,n?pt.createElement("div",{className:"".concat(w,"-interpretation")},pt.createElement("b",null,Rt.data.interpretedAs)," ",n):null)},kE=function(e){return[e.caption,e.filterLabel?Rt.data.filteredBy(e.filterLabel):null,e.capturedAt?Rt.data.asOf(Y(e.capturedAt,{time:!0})):null].filter(Boolean).join(" · ")||null},EE=function(){return pt.createElement("div",{className:"".concat(w,"-flow")},pt.createElement("div",{className:"".concat(w,"-continued")},Rt.data.continued))},FE=function(e){var t=e.view,n=e.mode,r=e.piece,o=e.showInterpretation,i=e.dataFormatting,a=e.authentication,u=e.autoQLConfig,s=e.onAsk,l=e.canRun,c=void 0===l||l,d=e.canCapture,f=void 0!==d&&d,h=e.onPickTiles,p=e.pending,v=e.onChartChange;if(!t||"empty"===t.state)return pt.createElement(DE,{mode:n,onAsk:s,canRun:c,canCapture:f,onPickTiles:h,pending:p});var m=!!r&&r.from>0,g=pt.createElement("div",{className:"".concat(w,"-data-title"),"data-continuation":m||void 0},"query"===t.sourceType?"“".concat(t.title,"”"):t.title,m?" ".concat(Rt.data.continuedTitle):"");if("ready"!==t.state)return pt.createElement("div",{className:"".concat(w,"-data"),"data-state":t.state},g,pt.createElement(gE,{tone:"error"===t.state||"missing"===t.state?"warning":void 0},function(e,t){var n;switch(e.state){case"not-run":return t?Rt.data.notRun:Rt.data.noCapture;case"loading":return Rt.data.loading;case"stale":return Rt.data.stale;case"missing":return Rt.data.missing;case"unsupported":return Rt.data.unsupported[e.reason]||Rt.data.unsupported.unsupported;case"error":return(null===(n=e.error)||void 0===n?void 0:n.message)||Rt.data.error;default:return null}}(t,c)));var D=o?t.interpretation:"";if("table"===t.kind){var y=r?r.from:0,k=r?r.to:t.rows.length,E=!r||r.isLast;return pt.createElement("div",{className:"".concat(w,"-data"),"data-kind":"table"},g,pt.createElement(Zk,{columns:t.columns,rows:t.rows.slice(y,k),from:y,dataFormatting:i,showHeader:!r||r.showHeader,total:E?t.total:null,measure:"measure"===n}),E?pt.createElement(yE,{caption:kE(t),interpretation:D}):pt.createElement(EE,null))}return"single-value"===t.kind?pt.createElement("div",{className:"".concat(w,"-data"),"data-kind":"single-value"},g,pt.createElement("div",{className:"".concat(w,"-single-value")},null==t.value?"—":Ct({element:t.value,column:t.column,config:Ft(i)})),pt.createElement(yE,{caption:kE(t),interpretation:D})):pt.createElement("div",{className:"".concat(w,"-data"),"data-kind":"chart"},g,"measure"===n?pt.createElement("div",{className:"".concat(w,"-chart"),style:{height:t.height}}):pt.createElement(oE,{view:t,authentication:a,autoQLConfig:u,dataFormatting:i,onConfigChange:"edit"===n?v:void 0}),pt.createElement(yE,{caption:kE(t),interpretation:D}))},bE=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"state",{editing:!1}),S(e,"isWriting",function(){var t;return"analysis"===(null===(t=e.props.pending)||void 0===t?void 0:t.kind)&&!e.props.pending.error}),S(e,"canEdit",function(){return"edit"===e.props.mode&&"function"==typeof e.props.onTextChange&&!e.isWriting()}),e}return A(t,e),x(t,[{key:"render",value:function(){var e=this,t=this.props,n=t.block,r=t.view,o=t.mode,i=t.piece,a=this.isWriting(),u="written"===(null==r?void 0:r.state),s=this.canEdit()&&(u||this.state.editing);if(!s&&!u)return"edit"!==o?null:pt.createElement(gE,{title:Rt.analysis.emptyTitle},a?Rt.analysis.writing:null!=r&&r.canAnalyze?Rt.analysis.emptyReady:"too-little"===(null==r?void 0:r.blocker)||"no-query-id"===(null==r?void 0:r.blocker)?Rt.analysis.emptyBlocked:Rt.analysis.emptyBody);var l=[Rt.analysis.source,null!=r&&r.fromTitle?Rt.analysis.from(r.fromTitle):null,null!=r&&r.focusUsed?Rt.analysis.focus(r.focusUsed):null].filter(Boolean).join(" · ");return pt.createElement("div",{className:"".concat(w,"-analysis"),style:fE(n.style),"data-writing":a||void 0,"data-editing":s&&this.state.editing||void 0},s?pt.createElement(lE,{className:"".concat(w,"-analysis-text"),value:Kt(n.text),label:Rt.panel.wording,testId:"report-builder-analysis-edit",onChange:this.props.onTextChange,onFocus:function(){return e.setState({editing:!0})},onBlur:function(){return e.setState({editing:!1})}}):pt.createElement(sE,{className:"".concat(w,"-analysis-text"),markdown:Kt(r.text),from:null==i?void 0:i.from,to:null==i?void 0:i.to}),!i||i.isLast?pt.createElement("div",{className:"".concat(w,"-analysis-meta")},"✦ ",l):null,"edit"===o&&r&&(r.targetGone||r.targetChanged)?pt.createElement("div",{className:"".concat(w,"-analysis-note")},r.targetGone?Rt.analysis.targetGone:Rt.analysis.targetChanged):null)}}])}(pt.Component),CE=function(e){return"edit"===e.mode?pt.createElement("div",{className:"".concat(w,"-page-break"),role:"separator"},pt.createElement("span",null,Rt.pageBreak)):null},wE=function(e){var t=e.block,n=e.mode,o=void 0===n?"page":n,i=e.onTextChange,a=r(e,dE);switch(t.type){case"heading":return pt.createElement(vE,{block:t,mode:o,onTextChange:i});case"text":return pt.createElement(mE,{block:t,mode:o,onTextChange:i,piece:a.piece});case"data":return pt.createElement(FE,T({mode:o},a));case"analysis":return pt.createElement(bE,{block:t,view:a.view,mode:o,pending:a.pending,onTextChange:i,piece:a.piece});case"pagebreak":return pt.createElement(CE,{mode:o});default:return"edit"===o?pt.createElement(gE,null,Rt.panel.unknownNote):null}},AE=Rt.formatting,xE=function(e){return cE()?e.replace(/Mod-/g,"⌘").replace(/Shift-/g,"⇧"):e.replace(/Mod-/g,"Ctrl+").replace(/Shift-/g,"Shift+")},SE=[{name:"bold",label:AE.bold,keys:"Mod-B",glyph:"B",toggle:function(e){return e.toggleBold()}},{name:"italic",label:AE.italic,keys:"Mod-I",glyph:"I",toggle:function(e){return e.toggleItalic()}},{name:"underline",label:AE.underline,keys:"Mod-U",glyph:"U",toggle:function(e){return e.toggleUnderline()}},{name:"strike",label:AE.strike,keys:"Mod-Shift-S",glyph:"S",toggle:function(e){return e.toggleStrike()}}],BE=[{name:"bulletList",label:AE.bulletList,keys:"Mod-Shift-8",icon:"list-bulleted",toggle:function(e){return e.toggleBulletList()}},{name:"orderedList",label:AE.orderedList,keys:"Mod-Shift-7",icon:"list-numbered",toggle:function(e){return e.toggleOrderedList()}}],TE="--react-autoql-report-builder-bar-shift",ME=function(e){if(!e)return"paragraph";for(var t=0,n=[1,2,3];t<n.length;t++){var r=n[t];if(e.isActive("heading",{level:r}))return"heading"}for(var o=0,i=[4,5,6];o<i.length;o++){var a=i[o];if(e.isActive("heading",{level:a}))return"subheading"}return"paragraph"},NE=function(t){function n(){var t;M(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return t=N(this,n,[].concat(o)),S(t,"state",{tick:0,link:null}),S(t,"linkInput",pt.createRef()),S(t,"bar",pt.createRef()),S(t,"place",function(){t.scroller&&"function"==typeof window.requestAnimationFrame&&(t.frame&&window.cancelAnimationFrame(t.frame),t.frame=window.requestAnimationFrame(t.position))}),S(t,"position",function(){t.frame=null;var e=t.bar.current,n=null==e?void 0:e.parentElement;if(e&&n&&t.scroller){var r=ee(n),o=parseFloat(e.style.getPropertyValue(TE))||0,i=e.getBoundingClientRect(),a=function(e){var t=e.naturalTop,n=e.viewTop,r=e.blockBottom,o=e.barHeight,i=e.zoom,a=void 0===i?1:i;if(!(t<n))return 0;var u=Math.min(n,r-o);return Math.max(0,u-t)/(a>0?a:1)}({naturalTop:i.top-o*r,viewTop:t.scroller.getBoundingClientRect().top+6,blockBottom:n.getBoundingClientRect().bottom,barHeight:i.height,zoom:r});Math.abs(a-o)>=.5&&e.style.setProperty(TE,"".concat(Math.round(10*a)/10,"px"))}}),S(t,"refresh",function(){return t.setState(function(e){return{tick:e.tick+1}})}),S(t,"usable",function(){return!!t.props.editor&&t.props.editor.isEditable&&!t.props.editor.isDestroyed}),S(t,"keepSelection",function(e){return e.preventDefault()}),S(t,"run",function(e){t.usable()&&e(t.props.editor.chain().focus()).run()}),S(t,"setStyle",function(e){return t.run(function(t){return"paragraph"===e?t.setParagraph():t.setHeading({level:"heading"===e?3:4})})}),S(t,"clearFormatting",function(){return t.run(function(e){return e.unsetAllMarks().clearNodes()})}),S(t,"openLink",function(){if(t.usable()){var e=t.props.editor.getAttributes("link").href||"";t.setState({link:{text:e,error:null,editing:!!e}},function(){var e,n;null===(e=t.linkInput.current)||void 0===e||e.focus(),null===(n=t.linkInput.current)||void 0===n||n.select()})}}),S(t,"closeLink",function(){t.setState({link:null}),t.usable()&&t.props.editor.commands.focus()}),S(t,"applyLink",function(n){var r;n.preventDefault();var o,i,a=t.props.editor,u=(null===(r=t.state.link)||void 0===r?void 0:r.text)||"",s=(o=u,(i=String(null!=o?o:"").trim())?/^(https?:\/\/[^\s]+|mailto:[^\s]+)$/i.test(i)?i:Lk.test(i)?"mailto:".concat(i):zk.test(i)?null:$k.test(i)?"https://".concat(i):null:null);if(s){if(t.usable()){var l=a.chain().focus();a.state.selection.empty&&!a.isActive("link")?l.insertContent({type:"text",text:u.trim(),marks:[{type:"link",attrs:{href:s}}]}):l.extendMarkRange("link").setLink({href:s}),l.run(),t.setState({link:null})}}else t.setState(function(t){var n=t.link;return{link:e(e({},n),{},{error:AE.linkInvalid})}})}),S(t,"removeLink",function(){t.run(function(e){return e.extendMarkRange("link").unsetLink()}),t.setState({link:null})}),S(t,"onBarBlur",function(e){var n,r,o,i=e.relatedTarget;i&&(e.currentTarget.contains(i)||null!==(n=i.closest)&&void 0!==n&&n.call(i,".ProseMirror"))||(t.state.link&&t.setState({link:null}),null===(r=(o=t.props).onLeave)||void 0===r||r.call(o))}),S(t,"onLinkKeyDown",function(e){"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),t.closeLink())}),t}return A(n,t),x(n,[{key:"componentDidMount",value:function(){this.listen(this.props.editor),this.follow()}},{key:"componentDidUpdate",value:function(e){e.editor!==this.props.editor&&(this.unlisten(e.editor),this.listen(this.props.editor),this.state.link&&this.setState({link:null})),this.place()}},{key:"componentWillUnmount",value:function(){this.unlisten(this.props.editor),this.unfollow()}},{key:"follow",value:function(){var e,t=this.bar.current;if(this.scroller=(null==t||null===(e=t.closest)||void 0===e?void 0:e.call(t,".".concat(w,"-canvas")))||null,t&&this.scroller){if(this.scroller.addEventListener("scroll",this.place,{passive:!0}),window.addEventListener("resize",this.place),"undefined"!=typeof ResizeObserver){this.observer=new ResizeObserver(this.place),t.parentElement&&this.observer.observe(t.parentElement);var n=t.closest(".".concat(w,"-zoom-frame"));n&&this.observer.observe(n)}this.place()}}},{key:"unfollow",value:function(){var e,t;null===(e=this.scroller)||void 0===e||e.removeEventListener("scroll",this.place),window.removeEventListener("resize",this.place),null===(t=this.observer)||void 0===t||t.disconnect(),this.frame&&window.cancelAnimationFrame(this.frame),this.scroller=null}},{key:"listen",value:function(e){null==e||e.on("transaction",this.refresh),null==e||e.on(Ek,this.openLink)}},{key:"unlisten",value:function(e){null==e||e.off("transaction",this.refresh),null==e||e.off(Ek,this.openLink)}},{key:"renderLink",value:function(){var t=this,n=this.state.link;return pt.createElement("form",{className:"".concat(w,"-format-link"),onSubmit:this.applyLink,"data-test":"report-builder-format-link"},pt.createElement("input",{ref:this.linkInput,type:"text",className:"".concat(w,"-input"),value:n.text,placeholder:AE.linkPlaceholder,"aria-label":AE.linkAddress,"aria-invalid":n.error?"true":void 0,onChange:function(r){return t.setState({link:e(e({},n),{},{text:r.target.value,error:null})})},onKeyDown:this.onLinkKeyDown}),pt.createElement("button",{type:"submit",className:"".concat(w,"-button"),"data-variant":"primary"},AE.linkApply),n.editing?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),onClick:this.removeLink},AE.linkRemove):null,pt.createElement("button",{type:"button",className:"".concat(w,"-button"),onClick:this.closeLink},AE.linkCancel),n.error?pt.createElement("span",{className:"".concat(w,"-format-error"),role:"alert"},n.error):null)}},{key:"render",value:function(){var t=this,n=this.props.editor,r=this.usable(),o=function(e){return r&&n.isActive(e)},i=function(e){var n=e.name,o=e.label,i=e.keys,a=e.glyph,u=e.icon,s=e.onPress,l=e.pressed;return pt.createElement("button",{key:n,type:"button",className:"".concat(w,"-format-button"),"data-format":n,"aria-label":o,"aria-pressed":void 0===l?void 0:!!l,title:i?"".concat(o," (").concat(xE(i),")"):o,disabled:!r,onMouseDown:t.keepSelection,onClick:s},u?pt.createElement(R,{name:u}):pt.createElement("span",{className:"".concat(w,"-format-glyph")},a))};return pt.createElement("div",{ref:this.bar,className:"".concat(w,"-format-bar"),role:"toolbar","aria-label":AE.toolbar,"data-formatting-bar":"","data-test":"report-builder-format-bar","data-active":r||void 0,onBlur:this.onBarBlur},pt.createElement(Rn,{inline:!0},pt.createElement("select",{className:"".concat(w,"-format-style"),"aria-label":AE.style,value:ME(r?n:null),disabled:!r,onChange:function(e){return t.setStyle(e.target.value)}},pt.createElement("option",{value:"paragraph"},AE.paragraph),pt.createElement("option",{value:"heading"},AE.heading),pt.createElement("option",{value:"subheading"},AE.subheading))),pt.createElement("span",{className:"".concat(w,"-format-sep"),"aria-hidden":"true"}),SE.map(function(n){return i(e(e({},n),{},{pressed:o(n.name),onPress:function(){return t.run(n.toggle)}}))}),pt.createElement("span",{className:"".concat(w,"-format-sep"),"aria-hidden":"true"}),BE.map(function(n){return i(e(e({},n),{},{pressed:o(n.name),onPress:function(){return t.run(n.toggle)}}))}),pt.createElement("span",{className:"".concat(w,"-format-sep"),"aria-hidden":"true"}),i({name:"link",label:AE.link,keys:"Mod-K",icon:"link",pressed:o("link"),onPress:this.openLink}),i({name:"clear",label:AE.clear,icon:"clear-format",onPress:this.clearFormatting}),this.state.link&&r?this.renderLink():r?null:pt.createElement("span",{className:"".concat(w,"-format-hint")},AE.hint))}}])}(pt.Component),RE=["block","view","selected","isFirst","isLast","onSelect","onAction","onText","onAsk","onPickTiles","onAnalyzeResult","onChartChange","formattingEditor","onFormattingLeave"],OE=function(e){var t=e.id,n=e.isFirst,r=e.isLast,o=e.onAction,i=e.onAnalyze;return pt.createElement("div",{className:"".concat(w,"-block-tools"),role:"toolbar","aria-label":Rt.panel.block},i?pt.createElement(pt.Fragment,null,pt.createElement("button",{type:"button",title:Rt.analyzeResult,"aria-label":Rt.analyzeResult,"data-accent":"","data-test":"report-builder-analyze-result",onClick:i},pt.createElement(R,{name:"analysis"})),pt.createElement("span",{className:"".concat(w,"-block-tools-sep")})):null,pt.createElement("button",{type:"button",title:Rt.moveUp,"aria-label":Rt.moveUp,disabled:n,onClick:function(){return o(t,"up")}},pt.createElement(R,{name:"up"})),pt.createElement("button",{type:"button",title:Rt.moveDown,"aria-label":Rt.moveDown,disabled:r,onClick:function(){return o(t,"down")}},pt.createElement(R,{name:"down"})),pt.createElement("button",{type:"button",title:Rt.duplicate,"aria-label":Rt.duplicate,onClick:function(){return o(t,"duplicate")}},pt.createElement(R,{name:"duplicate"})),pt.createElement("button",{type:"button",title:Rt.remove,"aria-label":Rt.remove,"data-danger":"",onClick:function(){return o(t,"remove")}},pt.createElement(R,{name:"remove"})))},IE=pt.memo(function(e){var t,n=e.block,o=e.view,i=e.selected,a=e.isFirst,u=e.isLast,s=e.onSelect,l=e.onAction,c=e.onText,d=e.onAsk,f=e.onPickTiles,h=e.onAnalyzeResult,p=e.onChartChange,v=e.formattingEditor,m=e.onFormattingLeave,g=r(e,RE),D=(null===(t=O[n.type])||void 0===t?void 0:t.label)||n.type,y=function(){i||s(n.id)},k=!!h&&"data"===n.type&&!Jt({target:n,targetView:o});return pt.createElement("div",{className:"".concat(w,"-block"),"data-block-id":n.id,"data-type":n.type,"data-width":"pagebreak"===n.type?"full":n.width,"data-selected":i||void 0,style:hE(n.style),role:"group","aria-label":D,tabIndex:["data","analysis","pagebreak"].includes(n.type)?0:void 0,onMouseDown:y,onFocus:y},i?pt.createElement("span",{className:"".concat(w,"-block-tag")},D):null,i?pt.createElement(OE,{id:n.id,isFirst:a,isLast:u,onAction:l,onAnalyze:k?function(){return h(n.id)}:void 0}):null,v?pt.createElement(NE,{editor:v,onLeave:m}):null,pt.createElement(wE,T({block:n,view:o,mode:"edit",onTextChange:function(e){return c(n.id,e)},onAsk:function(e){return d(n.id,e)},onPickTiles:f?function(){return f(n.id)}:void 0,onChartChange:p?function(e){return p(n.id,e)}:void 0},g)))}),PE=function(e,t){for(var n=0,r=e;r&&r!==t;r=r.offsetParent)n+=r.offsetTop;return n},LE=function(e){var t=e.fill,n=e.footer,r=e.header,o=e.marginIn;return pt.createElement("div",{className:"".concat(w,"-page-gap"),"aria-hidden":"true","data-test":"report-builder-page-gap"},pt.createElement("div",{className:"".concat(w,"-page-fill"),"data-page-fill":"",style:{height:t||0}}),n,pt.createElement("div",{className:"".concat(w,"-page-gap-band"),"data-page-gap-band":"",style:{margin:"".concat(o,"in 0")}}),r,pt.createElement("div",{"data-page-start":""}))},zE=function(t){function n(){var t;M(this,n);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return t=N(this,n,[].concat(i)),S(t,"sheetRef",pt.createRef()),S(t,"blocksRef",pt.createRef()),S(t,"state",{fills:[],plates:[]}),S(t,"measureFills",function(){var n=t.sheetRef.current,r=t.blocksRef.current;if(n&&r&&t.props.startPages){var i=function(e){var t=e.starts,n=e.ends,r=e.contentHeight;return n.map(function(e,n){var o;return Math.max(0,Math.floor(r-(e-(null!==(o=t[n])&&void 0!==o?o:0))))})}({starts:[PE(r,n)].concat(o(Array.from(r.querySelectorAll("[data-page-start]"),function(e){return PE(e,n)}))),ends:Array.from(r.querySelectorAll("[data-page-fill]"),function(e){return PE(e,n)}),contentHeight:t.props.geometry.contentHeightPx}),a=Array.from(r.querySelectorAll("[data-page-gap-band]"),function(e){return{top:PE(e,n),height:e.offsetHeight}}),u=n.offsetHeight>0?function(e){var t=e.gaps,n=e.sheetHeight;if(!t.length)return[];var r=[],o=0;return t.forEach(function(e){r.push({top:o,height:Math.max(0,e.top-o)}),o=e.top+e.height}),r.push({top:o,height:Math.max(0,n-o)}),r}({gaps:a,sheetHeight:n.offsetHeight}):[],s=t.state.fills,l=i.length!==s.length||i.some(function(e,t){return e!==s[t]}),c=!function(e,t){return e.length===t.length&&e.every(function(e,n){return e.top===t[n].top&&e.height===t[n].height})}(u,t.state.plates);(l||c)&&t.setState(e(e({},l?{fills:i}:null),c?{plates:u}:null))}}),t}return A(n,t),x(n,[{key:"componentDidMount",value:function(){var e=this;this.measureFills(),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver(function(){return e.measureFills()}),this.blocksRef.current&&(this.observer.observe(this.blocksRef.current),this.observed=this.blocksRef.current))}},{key:"componentDidUpdate",value:function(){var e,t;this.blocksRef.current&&this.observed!==this.blocksRef.current&&(null===(e=this.observer)||void 0===e||e.disconnect(),null===(t=this.observer)||void 0===t||t.observe(this.blocksRef.current),this.observed=this.blocksRef.current);this.measureFills()}},{key:"componentWillUnmount",value:function(){var e;null===(e=this.observer)||void 0===e||e.disconnect()}},{key:"render",value:function(){var t,n=this.props,r=n.report,i=n.views,a=n.selectedId,u=n.geometry,s=n.branding,l=n.footerLeft,c=n.startPages,d=n.pageCount,f=n.frontPages,h=n.onSelect,p=n.onAction,v=n.onText,m=n.onAsk,g=n.dataFormatting,D=n.authentication,y=n.autoQLConfig,k=n.canRun,E=n.canCapture,F=n.onPickTiles,b=n.onAnalyzeResult,C=n.onChartChange,A=n.pending,x=n.richEditor,S=n.richBlockId,B=n.onFormattingLeave,T=this.state,M=T.fills,N=T.plates,R=r.page,O=r.blocks,I=lr(R,s),P=function(e){return e.coverPage&&e.tableOfContents?Rt.frontMatter.both:e.coverPage?Rt.frontMatter.cover:e.tableOfContents?Rt.frontMatter.toc:null}(R),L=Hk(O),z=O.length-1,$=!!c&&L.length>0,q=$&&N.length>0,j=$?function(e,t){var n=0;return e.map(function(e){var r=e.map(function(e){return t[e.id]}).filter(function(e){return null!=e});return r.length&&(n=Math.max(n,Math.min.apply(Math,o(r)))),n})}(L,c):L.map(function(){return 0}),H=f+Math.max(1,d),V=u.headerIn>0?pt.createElement("div",{className:"".concat(w,"-page-header"),style:{height:"".concat(u.headerIn,"in")}},pt.createElement(pr,{branding:s,title:r.title})):null,U=function(e){return u.footerIn>0?pt.createElement("div",{className:"".concat(w,"-page-footer"),style:{height:"".concat(u.footerIn,"in")}},pt.createElement(mr,{left:R.footer?l:"",right:R.pageNumbers&&$?Rt.preview.page(f+e+1,H):""})):null},W=0;return pt.createElement("div",{ref:this.sheetRef,className:"".concat(w,"-paper ").concat(w,"-sheet"),"data-orientation":u.orientation,"data-paged":$||void 0,"data-plated":q||void 0,style:e({width:"".concat(u.widthIn,"in"),padding:"".concat(u.marginIn,"in")},I)},q?N.map(function(e,t){return pt.createElement("div",{key:t,className:"".concat(w,"-page-plate"),"aria-hidden":"true","data-test":"report-builder-page-plate",style:{top:e.top,height:e.height}})}):null,P?pt.createElement("div",{className:"".concat(w,"-front-matter-note"),style:{top:"".concat(u.marginIn/2,"in"),left:"".concat(u.marginIn,"in"),right:"".concat(u.marginIn,"in")}},P):null,V,O.length?pt.createElement("div",{ref:this.blocksRef,className:"".concat(w,"-sheet-blocks")},L.map(function(e,t){var n=$&&t>0&&j[t]>j[t-1],r=n?W++:null;return pt.createElement(pt.Fragment,{key:e[0].id},n?pt.createElement(LE,{fill:M[r],footer:U(j[t-1]),header:V,marginIn:u.marginIn}):null,pt.createElement("div",{className:"".concat(w,"-row"),"data-count":e.length},e.map(function(e){var t=O.indexOf(e);return pt.createElement(IE,{key:e.id,block:e,view:i[e.id],selected:e.id===a,isFirst:0===t,isLast:t===z,onSelect:h,onAction:p,onText:v,onAsk:m,showInterpretation:R.showInterpretation,dataFormatting:g,authentication:D,autoQLConfig:y,canRun:k,canCapture:E,onPickTiles:F,onAnalyzeResult:b,onChartChange:C,pending:null==A?void 0:A[e.id],formattingEditor:x&&e.id===S?x:null,onFormattingLeave:B})})))}),$?pt.createElement("div",{className:"".concat(w,"-page-fill"),"data-page-fill":"",style:{height:M[W]||0}}):null):pt.createElement("div",{className:"".concat(w,"-empty-report")},pt.createElement("div",{className:"".concat(w,"-empty-report-title")},Rt.emptyReportTitle),pt.createElement("p",null,Rt.emptyReportBody)),U(null!==(t=j[j.length-1])&&void 0!==t?t:0))}}])}(pt.Component);S(zE,"defaultProps",{startPages:null,pageCount:1,frontPages:0});var $E=function(e){return e?e.getBoundingClientRect().height:0},qE=function(e){if(!function(e){return!!e&&e.getBoundingClientRect().width>0}(e))return null;var t=$E(e.querySelector("[data-measure-continued]")),n={blocks:{},tables:{},flows:{}};return e.querySelectorAll("[data-measure-id]").forEach(function(e){var r=e.getAttribute("data-measure-id"),i=e.getBoundingClientRect();if(n.blocks[r]=i.height,e.hasAttribute("data-measure-split")){var a=function(e,t,n){var r=e.querySelector("[data-measure-table]");if(!r)return null;var o=r.getBoundingClientRect(),i=r.querySelector("thead"),a=e.querySelector("[data-measure-tail]"),u=i?i.getBoundingClientRect().top:o.top,s=a?a.getBoundingClientRect().bottom:o.bottom;return{chrome:u-t.top+(t.bottom-s),header:$E(i),rows:Array.from(r.querySelectorAll("tbody tr[data-row]")).map($E),tail:$E(r.querySelector("tr[data-total]"))+$E(a),continued:n}}(e,i,t);a&&(n.tables[r]=a)}if(e.hasAttribute("data-measure-flow")){var u=function(e,t){var n=e.querySelector(".".concat(w,"-rich"));if(!n)return null;var r=[];if(Array.from(n.children).forEach(function(e){"UL"===e.tagName||"OL"===e.tagName?r.push.apply(r,o(Array.from(e.children).filter(function(e){return"LI"===e.tagName}))):r.push(e)}),!r.length)return null;var i=r.map(function(e){return e.getBoundingClientRect().top}),a=r[r.length-1].getBoundingClientRect(),u=i[0]-t.top;return{head:u,chunks:r.map(function(e,t){return t<r.length-1?i[t+1]-i[t]:a.height}),tail:t.bottom-a.bottom,end:u,keep:r.map(function(e){return/^H[1-6]$/.test(e.tagName)})}}(e,i);u&&(n.flows[r]=u)}}),n},jE=function(e){var t=e.title,n=e.branding,r=e.generated,o=e.dataAsOf,i=e.hasData;return pt.createElement("div",{className:"".concat(w,"-cover"),"data-brand-position":(null==n?void 0:n.position)||void 0},pt.createElement(hr,{branding:n,size:"large"}),pt.createElement("div",{className:"".concat(w,"-cover-middle")},pt.createElement("div",{className:"".concat(w,"-cover-title"),role:"heading","aria-level":1},t||Rt.untitled),pt.createElement("div",{className:"".concat(w,"-cover-sub")},gr({dataAsOf:o,hasData:i}))),pt.createElement("div",{className:"".concat(w,"-cover-foot")},pt.createElement("span",null,r?"".concat(Rt.preview.generated," ").concat(r):""),pt.createElement("span",null,(null==n?void 0:n.name)||"")))},HE=function(e){var t=e.entries;return pt.createElement("nav",{className:"".concat(w,"-toc"),"aria-label":Rt.preview.contents},pt.createElement("div",{className:"".concat(w,"-toc-title")},Rt.preview.contents),t.map(function(e){return pt.createElement("div",{key:e.id,className:"".concat(w,"-toc-entry"),"data-level":e.level},pt.createElement("span",null,(e.text||"").replace(/\s*\n\s*/g," ")),pt.createElement("i",{"aria-hidden":"true"}),pt.createElement("b",null,e.page))}))},VE=["text","analysis"],UE=function(){return new Promise(function(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(function(){return e()}):setTimeout(e,0)})},WE=function(e){var t=e.block,n=e.children,r=e.measureId,o=e.split,i=e.flow;return pt.createElement("div",{className:"".concat(w,"-cell"),"data-width":"pagebreak"===t.type?"full":t.width,"data-measure-id":r,"data-measure-split":o?"":void 0,"data-measure-flow":i?"":void 0},pt.createElement("div",{className:"".concat(w,"-block-box"),"data-type":t.type,style:hE(t.style)},n))},_E=pt.forwardRef(function(t,n){var r=t.blocks,o=t.views,i=t.geometry,a=t.fontStyle,u=t.paperProps,s=Hk(r.filter(jk));return pt.createElement("div",{className:"".concat(w,"-measurer-clip"),"aria-hidden":"true"},pt.createElement("div",{ref:n,className:"".concat(w,"-paper ").concat(w,"-measurer"),style:e({width:i.contentWidthPx},a)},s.map(function(e){return pt.createElement("div",{key:e[0].id,className:"".concat(w,"-row"),"data-count":e.length},e.map(function(t){var n;return pt.createElement(WE,{key:t.id,block:t,measureId:t.id,split:1===e.length&&!(null===(n=o[t.id])||void 0===n||!n.split),flow:1===e.length&&VE.includes(t.type)},pt.createElement(wE,T({block:t,view:o[t.id],mode:"measure"},u)))}))}),pt.createElement("div",{className:"".concat(w,"-flow"),"data-measure-continued":""},pt.createElement(EE,null))))}),KE=function(){var e=z($().m(function e(t){var n,r,o,i,a,u,s,l,c,d,f,h;return $().w(function(e){for(;;)switch(e.n){case 0:return n=t.report,r=t.views,o=t.branding,i=t.measurer,a=t.isCurrent,u=void 0===a?function(){return!0}:a,s=t.estimate,l=void 0===s||s,c=en(n.page),e.n=1,Promise.all(dr(n.page,o).map(function(e){return an(e)}));case 1:return e.n=2,on();case 2:return e.n=3,UE();case 3:if(u()){e.n=4;break}return e.a(2,null);case 4:if((d=qE(i()))||l){e.n=5;break}return e.a(2,null);case 5:return f=d||Gk({blocks:n.blocks,views:r,contentWidthPx:c.contentWidthPx}),h=Vk({blocks:n.blocks,views:r,measurements:f}),e.a(2,_k(h,{contentHeight:c.contentHeightPx,repeatTableHeaders:n.page.repeatTableHeaders}))}},e)}));return function(t){return e.apply(this,arguments)}}(),JE=function(t){function n(){var t;M(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return t=N(this,n,[].concat(o)),S(t,"measurerRef",pt.createRef()),S(t,"pagesRef",pt.createRef()),S(t,"layoutToken",0),S(t,"state",{measuring:!0,contentPages:null}),S(t,"getGeometry",function(){return en(t.props.report.page)}),S(t,"getFontStyle",function(){return lr(t.props.report.page,t.props.branding)}),S(t,"whenReady",function(){return t.readyPromise}),S(t,"getPagesElement",function(){return t.pagesRef.current}),S(t,"getPageElements",function(){var e;return Array.from((null===(e=t.pagesRef.current)||void 0===e?void 0:e.querySelectorAll(".".concat(un)))||[])}),S(t,"layout",function(){var e=++t.layoutToken;t.state.measuring||(t.readyPromise=new Promise(function(e){return t.resolveReady=e})),t.setState({measuring:!0},z($().m(function n(){var r;return $().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,KE({report:t.props.report,views:t.props.views,branding:t.props.branding,measurer:function(){return t.measurerRef.current},isCurrent:function(){return t.mounted&&e===t.layoutToken}});case 1:if(r=n.v){n.n=2;break}return n.a(2);case 2:t.setState({measuring:!1,contentPages:r},function(){t.mounted&&e===t.layoutToken&&(t.props.onLayout(t.getLayoutInfo()),t.resolveReady())});case 3:return n.a(2)}},n)})))}),S(t,"getFrontMatter",function(){var e=t.props.report,n=e.blocks.filter(function(e){return"heading"===e.type&&jk(e)});return{cover:!!e.page.coverPage,toc:!!e.page.tableOfContents&&n.length>0,headings:n}}),S(t,"getLayoutInfo",function(){var e=t.getFrontMatter(),n=e.cover,r=e.toc,o=t.state.contentPages||[];return{pageCount:o.length+(n?1:0)+(r?1:0),overflowCount:o.filter(function(e){return e.overflow}).length}}),S(t,"renderPage",function(n){var r=n.key,o=n.number,i=n.total,a=n.header,u=void 0===a||a,s=n.footer,l=void 0===s||s,c=n.overflow,d=void 0!==c&&c,f=n.children,h=t.props,p=h.report,v=h.branding,m=h.runAt,g=h.generatedAt,D=t.getGeometry(),y=function(e){return"".concat(e,"in")},k=u&&D.headerIn>0,E=l&&D.footerIn>0,F=p.page.footer?Dr({generated:Y(g),dataAsOf:m?Y(m,{time:!0}):null,hasData:t.props.canRun&&yr(p)}):"",b=p.page.pageNumbers?Rt.preview.page(o,i):"";return pt.createElement("div",{key:r,className:"".concat(w,"-page-frame")},pt.createElement("span",{className:"".concat(w,"-page-label"),"aria-hidden":"true"},o),pt.createElement("div",{className:"".concat(un," ").concat(w,"-paper"),"data-orientation":D.orientation,style:e({width:y(D.widthIn),height:y(D.heightIn),padding:y(D.marginIn)},t.getFontStyle())},k?pt.createElement("div",{className:"".concat(w,"-page-header"),style:{height:y(D.headerIn)}},pt.createElement(pr,{branding:v,title:p.title})):null,pt.createElement("div",{className:"".concat(w,"-page-content"),style:{height:y(D.contentHeightIn+(u?0:D.headerIn)+(l?0:D.footerIn))}},f),E?pt.createElement("div",{className:"".concat(w,"-page-footer"),style:{height:y(D.footerIn)}},pt.createElement(mr,{left:F,right:b})):null),d?pt.createElement("span",{className:"".concat(w,"-page-overflow"),role:"note"},Rt.preview.overflow):null)}),S(t,"renderCells",function(e){var n=t.props,r=n.report,o=n.views,i=n.dataFormatting,a=n.authentication,u=n.autoQLConfig,s={};r.blocks.forEach(function(e){s[e.id]=e});var l={showInterpretation:r.page.showInterpretation,dataFormatting:i,authentication:a,autoQLConfig:u,canRun:t.props.canRun};return e.cells.map(function(e){if("table"===e.kind||"flow"===e.kind){var t=s[e.id];return t?pt.createElement("div",{key:"".concat(e.id,":").concat(e.from),className:"".concat(w,"-row"),"data-count":1},pt.createElement(WE,{block:t},pt.createElement(wE,T({block:t,view:o[t.id],mode:"page",piece:e},l)))):null}var n=e.ids.map(function(e){return s[e]}).filter(Boolean);return pt.createElement("div",{key:e.ids.join("+"),className:"".concat(w,"-row"),"data-count":n.length},n.map(function(e){return pt.createElement(WE,{key:e.id,block:e},pt.createElement(wE,T({block:e,view:o[e.id],mode:"page"},l)))}))})}),S(t,"renderPages",function(){var e=t.props,n=e.report,r=e.branding,o=e.runAt,i=e.generatedAt,a=t.state.contentPages||[],u=t.getFrontMatter(),s=u.cover,l=u.toc,c=u.headings,d=(s?1:0)+(l?1:0),f=d+a.length,h=[];if(s&&h.push(t.renderPage({key:"cover",number:1,total:f,header:!1,footer:!1,children:pt.createElement(jE,{title:n.title,branding:r,generated:Y(i),dataAsOf:o?Y(o,{time:!0}):"",hasData:t.props.canRun&&yr(n)})})),l){var p=function(e,t){var n=new Set(t.filter(function(e){return"heading"===e.type}).map(function(e){return e.id})),r={};return e.forEach(function(e,t){e.cells.forEach(function(e){(e.ids||[]).forEach(function(e){n.has(e)&&null==r[e]&&(r[e]=t+1)})})}),r}(a,c),v=c.map(function(e){return{id:e.id,text:e.text,level:e.level,page:null!=p[e.id]?p[e.id]+d:""}});h.push(t.renderPage({key:"toc",number:s?2:1,total:f,children:pt.createElement(HE,{entries:v})}))}return a.forEach(function(e,n){h.push(t.renderPage({key:"page-".concat(n),number:d+n+1,total:f,overflow:e.overflow,children:t.renderCells(e)}))}),h}),t}return A(n,t),x(n,[{key:"componentDidMount",value:function(){var e=this;this.mounted=!0,this.readyPromise=new Promise(function(t){return e.resolveReady=t}),this.layout()}},{key:"componentDidUpdate",value:function(e){e.report===this.props.report&&e.views===this.props.views&&cr(e.branding,this.props.branding)&&wt(e.dataFormatting,this.props.dataFormatting)||this.layout()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.layoutToken+=1}},{key:"render",value:function(){var e=this.props,t=e.report,n=e.views,r=e.dataFormatting,o=e.authentication,i=e.autoQLConfig,a=this.getGeometry(),u=this.state,s=u.measuring,l=u.contentPages;return pt.createElement("div",{className:"".concat(w,"-preview"),"data-test":"report-builder-preview"},s?pt.createElement(_E,{ref:this.measurerRef,blocks:t.blocks,views:n,geometry:a,fontStyle:this.getFontStyle(),paperProps:{showInterpretation:t.page.showInterpretation,dataFormatting:r,authentication:o,autoQLConfig:i,canRun:this.props.canRun}}):null,pt.createElement(Fn,{zoom:this.props.zoom,onFit:this.props.onFit},pt.createElement("div",{className:"".concat(w,"-preview-pages"),ref:this.pagesRef,"data-measuring":s||void 0},l?this.renderPages():pt.createElement("div",{className:"".concat(w,"-preview-status")},Rt.preview.measuring))))}}])}(pt.Component);S(JE,"defaultProps",{onLayout:function(){},zoom:gn,onFit:void 0});var QE=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"anchorRef",pt.createRef()),S(e,"measurerRef",pt.createRef()),S(e,"token",0),S(e,"state",{active:!1}),S(e,"activateIfLaidOut",function(){var t,n,r=null===(t=e.anchorRef.current)||void 0===t?void 0:t.parentElement;return!e.state.active&&r&&r.getBoundingClientRect().width>0?(null===(n=e.spaceObserver)||void 0===n||n.disconnect(),e.setState({active:!0},function(){return e.schedule(0)}),!0):e.state.active}),S(e,"schedule",function(t){clearTimeout(e.timer),e.timer=setTimeout(e.layout,t)}),S(e,"layout",z($().m(function t(){var n,r;return $().w(function(t){for(;;)switch(t.n){case 0:return n=++e.token,t.n=1,KE({report:e.props.report,views:e.props.views,branding:e.props.branding,measurer:function(){return e.measurerRef.current},isCurrent:function(){return e.mounted&&n===e.token},estimate:!1});case 1:(r=t.v)&&e.mounted&&n===e.token&&e.props.onPages(r);case 2:return t.a(2)}},t)}))),e}return A(t,e),x(t,[{key:"componentDidMount",value:function(){var e=this;if(this.mounted=!0,!this.activateIfLaidOut()&&"undefined"!=typeof ResizeObserver){var t,n=null===(t=this.anchorRef.current)||void 0===t?void 0:t.parentElement;n&&(this.spaceObserver=new ResizeObserver(function(){return e.activateIfLaidOut()}),this.spaceObserver.observe(n))}}},{key:"shouldComponentUpdate",value:function(e,t){return t.active!==this.state.active||e.report!==this.props.report||e.views!==this.props.views||e.canRun!==this.props.canRun||!cr(e.branding,this.props.branding)||!wt(e.dataFormatting,this.props.dataFormatting)}},{key:"componentDidUpdate",value:function(e){this.state.active&&(e.report===this.props.report&&e.views===this.props.views&&cr(e.branding,this.props.branding)&&wt(e.dataFormatting,this.props.dataFormatting)||this.schedule(this.props.debounceMs))}},{key:"componentWillUnmount",value:function(){var e;this.mounted=!1,this.token+=1,clearTimeout(this.timer),null===(e=this.spaceObserver)||void 0===e||e.disconnect()}},{key:"render",value:function(){var e=this.props,t=e.report,n=e.views,r=e.branding,o=e.dataFormatting,i=e.authentication,a=e.autoQLConfig,u=e.canRun;return this.state.active?pt.createElement(_E,{ref:this.measurerRef,blocks:t.blocks,views:n,geometry:en(t.page),fontStyle:lr(t.page,r),paperProps:{showInterpretation:t.page.showInterpretation,dataFormatting:o,authentication:i,autoQLConfig:a,canRun:u}}):pt.createElement("span",{ref:this.anchorRef,hidden:!0})}}])}(pt.Component);S(QE,"defaultProps",{onPages:function(){},debounceMs:250});var GE=Rt.panel,XE=Object.keys(L).map(function(e){return[e,L[e].label]}),ZE=XE.map(function(e){var t=i(e,2),n=t[0],r=t[1];return[n,"theme"===n?GE.themeBrandFonts:r]}),YE=[["",GE.default]].concat(o(Object.keys(G).map(function(e){return[e,G[e].label]}))),eF=[["",GE.default]].concat(o(Object.keys(X).map(function(e){return[e,X[e].label]}))),tF=function(e,t){var n=((null==t?void 0:t.colors)||[]).map(function(e,t){return[e,GE.brandSwatch(t+1,e)]}),r=new Set(n.map(function(e){return i(e,1)[0].toLowerCase()}));return[].concat(o(n),o(e.filter(function(e){var t=i(e,1)[0];return!r.has(t.toLowerCase())})))},nF=function(e){var t=e.page,n=e.onPageChange,r=e.brandFonts;return pt.createElement(pt.Fragment,null,pt.createElement(Bn,null,GE.pageSetup),pt.createElement(In,{label:GE.orientation,value:t.orientation,options:ue,onChange:function(e){return n({orientation:e})}}),pt.createElement(On,{label:GE.margins,value:t.margins,options:se,onChange:function(e){return n({margins:e})}}),pt.createElement(On,{label:GE.typeface,value:t.typeface,options:r?ZE:XE,onChange:function(e){return n({typeface:e})}}),pt.createElement(Tn,null,GE.typefaceNote),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.headerFooter),pt.createElement(Pn,{label:GE.header,checked:t.header,onChange:function(e){return n({header:e})}}),pt.createElement(Pn,{label:GE.footer,checked:t.footer,onChange:function(e){return n({footer:e})}}),pt.createElement(Pn,{label:GE.pageNumbers,checked:t.pageNumbers,onChange:function(e){return n({pageNumbers:e})}}),pt.createElement(Pn,{label:GE.repeatTableHeaders,checked:t.repeatTableHeaders,onChange:function(e){return n({repeatTableHeaders:e})}}),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.results),pt.createElement(Pn,{label:GE.showInterpretation,checked:t.showInterpretation,onChange:function(e){return n({showInterpretation:e})}}),pt.createElement(Tn,null,GE.showInterpretationNote),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.frontMatter),pt.createElement(Pn,{label:GE.coverPage,checked:t.coverPage,onChange:function(e){return n({coverPage:e})}}),pt.createElement(Pn,{label:GE.tableOfContents,checked:t.tableOfContents,onChange:function(e){return n({tableOfContents:e})}}),pt.createElement(Mn,null),pt.createElement("p",{className:"".concat(w,"-empty-props")},GE.nothingSelected))},rF=function(e){var t=e.block,n=e.onBlockChange;return pt.createElement(In,{label:GE.width,value:t.width,options:te,onChange:function(e){return n(t.id,{width:e})}})},oF=function(e){var t=e.block,n=e.branding,r=e.onBlockChange,o=e.onStyleChange,i=e.onStyleReset,a=t.style||{},u=function(e){return o(t.id,e)};return pt.createElement(pt.Fragment,null,pt.createElement(Mn,null),pt.createElement(Bn,null,GE.text),pt.createElement(On,{label:GE.font,value:a.font||"theme",options:XE,onChange:function(e){return u({font:"theme"===e?"":e})}}),pt.createElement("div",{className:"".concat(w,"-two")},pt.createElement(On,{label:GE.size,value:a.size||"",options:YE,onChange:function(e){return u({size:e})}}),pt.createElement(On,{label:GE.weight,value:a.weight||"",options:eF,onChange:function(e){return u({weight:e})}})),pt.createElement(Ln,{label:GE.textColour,value:a.color,swatches:tF(ce,n),onChange:function(e){return u({color:e})}}),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.block),pt.createElement(rF,{block:t,onBlockChange:r}),pt.createElement(In,{label:GE.align,value:a.align||"left",options:le,onChange:function(e){return u({align:"left"===e?"":e})}}),pt.createElement(Ln,{label:GE.background,value:a.background,swatches:tF(de,n),noneLabel:GE.none,onChange:function(e){return u({background:e})}}),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"",disabled:!t.style,onClick:function(){return i(t.id)}},GE.resetToTheme),pt.createElement(Tn,null,GE.themeNote))},iF=function(e){var t=e.initial,n=e.onAsk,r=e.note,o=void 0===r?GE.askNote:r,i=e.disabled,a=void 0!==i&&i,u=Sn("question");return pt.createElement(pt.Fragment,null,pt.createElement(Nn,{label:GE.askQuestion,htmlFor:u},pt.createElement("input",{id:u,type:"text",className:"".concat(w,"-input"),defaultValue:t||"",placeholder:Rt.data.askPlaceholder,"data-test":"report-builder-question",disabled:a,onKeyDown:function(e){"Enter"===e.key&&e.currentTarget.value.trim()&&(e.preventDefault(),n(e.currentTarget.value.trim()))}})),pt.createElement(Tn,null,o))},aF={table:"table",column:"column-chart",bar:"bar-chart",line:"line-chart",pie:"pie-chart",heatmap:"heatmap",bubble:"bubble-chart",stacked_bar:"stacked-bar-chart",stacked_column:"stacked-column-chart",stacked_line:"stacked-line-chart",column_line:"column-line-chart",histogram:"histogram-chart",scatterplot:"scatterplot"},uF=function(e){var t=e.block,n=e.view,r=e.onBlockChange;return pt.createElement(pt.Fragment,null,pt.createElement(Nn,{label:GE.showAs},pt.createElement("div",{className:"".concat(w,"-display-types"),role:"group","aria-label":GE.showAs,"data-test":"report-builder-show-as"},n.displayOptions.map(function(e){var o=GE.displayTypes[e]||e,i=n.displayType===e;return pt.createElement("button",{key:e,type:"button",className:"".concat(w,"-display-type"),"aria-label":o,title:o,"aria-pressed":i,"data-selected":i||void 0,onClick:function(){return r(t.id,{displayType:e})}},pt.createElement(ne,{type:aF[e]}))}))),"chart"!==n.kind||n.complete||null==n.countRows?null:pt.createElement(Tn,null,GE.chartOfSlice(n.rowCount,n.countRows)),"chart"===n.kind?pt.createElement(Tn,null,GE.axesNote):null)},sF=function(e){var t,n,r,o=e.block,a=e.view,u=e.onBlockChange,s="ready"===(null==a?void 0:a.state),l=re(s?a.countRows:null),c=(l.find(function(e){return i(e,1)[0]>=o.rows})||l[l.length-1])[0],d=((null==a||null===(t=a.tile)||void 0===t?void 0:t.orders)||[]).some(function(e){return null==e?void 0:e.name}),f=s?a.orderLabel:null;return r=null!=a&&a.capturedAt?f?GE.rowsCaptured(f):d?GE.rowsCapturedUnnamed:GE.rowsCapturedUnsorted(o.rows):"query"===(null===(n=o.source)||void 0===n?void 0:n.type)?GE.rowsQuestion(o.rows):f?GE.rowsRanked(f):d?GE.rowsRankedUnnamed:GE.rowsUnranked(o.rows),pt.createElement(pt.Fragment,null,pt.createElement(On,{label:GE.rows,value:c,options:l,testId:"report-builder-rows",onChange:function(e){return u(o.id,{rows:e})}}),pt.createElement(Tn,null,GE.rowsCap(oe),r,s&&!a.complete?GE.rowsNoTotal:""))},lF=function(e){var t,n,r=e.block,o=e.view;return pt.createElement("div",{className:"".concat(w,"-source-card"),"data-test":"report-builder-source"},"query"===(null===(t=r.source)||void 0===t?void 0:t.type)?pt.createElement("div",{className:"".concat(w,"-source-row")},pt.createElement("span",null,GE.question),pt.createElement("b",null,"“",r.source.query,"”")):null,"tile"===(null===(n=r.source)||void 0===n?void 0:n.type)?pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-source-row")},pt.createElement("span",null,GE.dashboard),pt.createElement("b",null,(null==o?void 0:o.dashboardName)||"—")),pt.createElement("div",{className:"".concat(w,"-source-row")},pt.createElement("span",null,GE.tile),pt.createElement("b",null,(null==o?void 0:o.tileTitle)||"—"))):null,null!=o&&o.capturedAt?pt.createElement("div",{className:"".concat(w,"-source-row")},pt.createElement("span",null,GE.captured),pt.createElement("b",null,Y(o.capturedAt,{time:!0}))):null)},cF=function(e){var t=e.dashboards,n=e.dashboardId,r=e.tileKey,i=e.onDashboard,a=e.onTile,u=Array.isArray(t)?t:[];if(!u.length)return pt.createElement(Tn,null,GE.noDashboards);var c=u.find(function(e){return String(e.id)===String(n)}),d=Array.isArray(null==c?void 0:c.tiles)?c.tiles:[],f=d.filter(function(e){return null!=ie(e)&&s(e).supported}),h=d.length-f.length;return pt.createElement(pt.Fragment,null,pt.createElement(On,{label:GE.dashboard,value:c?String(c.id):"",options:[["",GE.chooseDashboard]].concat(o(u.map(function(e){return[String(e.id),e.name||String(e.id)]}))),testId:"report-builder-dashboard",onChange:function(e){return i(e||null)}}),pt.createElement(On,{label:GE.tile,value:r||"",disabled:!c,options:[["",GE.chooseTile]].concat(o(f.map(function(e){return[ie(e),l(e)]}))),testId:"report-builder-tile",onChange:function(e){var t=f.find(function(t){return ie(t)===e});t&&a(ae({dashboard:c,tile:t}))}}),c&&h>0?pt.createElement(Tn,null,GE.hiddenTiles(h)):null)},dF=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"state",{editing:!1,dashboardId:null}),S(e,"setSource",function(t){e.setState({editing:!1,dashboardId:null}),e.props.onSourceChange(e.props.block.id,t)}),e}return A(t,e),x(t,[{key:"render",value:function(){var e,t,n=this,r=this.props,o=r.block,i=r.view,a=r.dashboards,u=r.onBlockChange,s=r.canRun,l=void 0===s||s,c=r.canCapture,d=void 0!==c&&c,f=r.onPickTiles,h=r.onAskCapture,p=r.onRerun,v=r.pending,m=o.source,g=!(null==i||!i.capturedAt),D=l&&(!m||this.state.editing),y=null!==(e=this.state.dashboardId)&&void 0!==e?e:"tile"===(null==m?void 0:m.type)?m.dashboardId:null,k="question"===(null==v?void 0:v.kind)?v:null,E=!!k&&!k.error,F=!l&&d&&!!p&&!!o.askedHere&&"query"===(null==m?void 0:m.type);return pt.createElement(pt.Fragment,null,D?pt.createElement(pt.Fragment,null,pt.createElement(iF,{initial:"query"===(null==m?void 0:m.type)?m.query:"",onAsk:function(e){return n.setSource({type:"query",query:e})}}),pt.createElement("div",{className:"".concat(w,"-or")},pt.createElement("span",null,GE.orExisting)),pt.createElement(cF,{dashboards:a,dashboardId:y,tileKey:"tile"===(null==m?void 0:m.type)&&y===m.dashboardId?m.tileKey:"",onDashboard:function(e){return n.setState({dashboardId:e})},onTile:this.setSource}),this.state.editing?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"",onClick:function(){return n.setState({editing:!1,dashboardId:null})}},GE.cancel):null):m||g?pt.createElement(pt.Fragment,null,pt.createElement(Bn,null,GE.source),pt.createElement(lF,{block:o,view:i}),pt.createElement(Tn,null,F?GE.askedNote:g?GE.capturedNote:"query"===m.type?GE.questionNote:GE.sourceNote),l||g?null:pt.createElement(Tn,null,GE.noCaptureNote),F?pt.createElement(pt.Fragment,null,pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"","data-test":"report-builder-rerun",disabled:E,onClick:function(){return p(o.id)}},E?GE.rerunning:GE.rerun),null!=k&&k.error?pt.createElement(Tn,{tone:"warning"},k.error):pt.createElement(Tn,null,GE.rerunNote)):null,l?pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"","data-test":"report-builder-change-source",onClick:function(){return n.setState({editing:!0})}},GE.changeSource):null,"ready"===(null==i?void 0:i.state)&&(null===(t=i.displayOptions)||void 0===t?void 0:t.length)>1?pt.createElement(pt.Fragment,null,pt.createElement(Mn,null),pt.createElement(uF,{block:o,view:i,onBlockChange:u})):null,function(e,t){var n,r;if("ready"===(null==t?void 0:t.state))return"table"===t.kind;var o=null==t||null===(n=t.tile)||void 0===n?void 0:n.displayType;return"tile"===(null===(r=e.source)||void 0===r?void 0:r.type)&&!(null==t||!t.tile)&&!xt(o)&&"single-value"!==o}(o,i)?pt.createElement(pt.Fragment,null,pt.createElement(Mn,null),pt.createElement(sF,{block:o,view:i,onBlockChange:u})):null):!l&&d?pt.createElement(pt.Fragment,null,pt.createElement(iF,{key:k?"asked-".concat(k.seq):"ask",initial:k?k.query:"",onAsk:function(e){return null==h?void 0:h(o.id,e)},note:E?Rt.data.asking(k.query):GE.askCaptureNote,disabled:E||"tiles"===(null==v?void 0:v.kind)}),null!=k&&k.error?pt.createElement(Tn,{tone:"warning"},k.error):null,f?pt.createElement(pt.Fragment,null,pt.createElement("div",{className:"".concat(w,"-or")},pt.createElement("span",null,GE.orTiles)),pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"","data-test":"report-builder-panel-pick-tiles",disabled:!!v&&!v.error,onClick:function(){return f(o.id)}},"tiles"===(null==v?void 0:v.kind)?Rt.data.picking:Rt.data.pickTiles),pt.createElement(Tn,null,GE.pickTilesNote)):null):pt.createElement(Tn,null,GE.noCaptureNote),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.block),pt.createElement(rF,{block:o,onBlockChange:u}))}}])}(pt.Component),fF=function(e){var t=e.block,n=e.view,r=e.targets,i=void 0===r?[]:r,a=e.onBlockChange,u=e.onAnalyze,s=e.pending,l=Sn("focus"),c="analysis"===(null==s?void 0:s.kind)&&!s.error,d="written"===(null==n?void 0:n.state),f=[["",GE.chooseResult]].concat(o(i.map(function(e){return e.blocker?[e.id,GE.cantAnalyzeOption(e.label,e.blocker),!0]:[e.id,e.label]}))),h={"no-query-id":GE.cantAnalyze,"too-little":GE.cantAnalyzeTooLittle}[null==n?void 0:n.blocker];return t.target&&!i.some(function(e){return e.id===t.target})&&f.push([t.target,null!=n&&n.targetGone?GE.removedResult:(null==n?void 0:n.fromTitle)||GE.thisResult]),pt.createElement(pt.Fragment,null,pt.createElement(On,{label:GE.analysisResult,value:t.target||"",options:f,testId:"report-builder-analysis-target",onChange:function(e){return a(t.id,{target:e||null})}}),null!=n&&n.targetGone?pt.createElement(Tn,{tone:"warning"},Rt.analysis.targetGone):null,i.length?null:pt.createElement(Tn,null,GE.noResults),pt.createElement(Nn,{label:GE.focus,htmlFor:l},pt.createElement(aE,{id:l,className:"".concat(w,"-input"),value:t.focus||"",placeholder:GE.focusPlaceholder,singleLine:!0,"data-test":"report-builder-analysis-focus",onChange:function(e){return a(t.id,{focus:e})}})),u?pt.createElement(pt.Fragment,null,pt.createElement("button",{type:"button",className:"".concat(w,"-button"),"data-block":"","data-variant":"primary","data-test":"report-builder-analyze",disabled:!(null!=n&&n.canAnalyze)||c,onClick:function(){return u(t.id)}},c?GE.analyzing:d?GE.analyzeAgain:GE.analyze),null!=s&&s.error?pt.createElement(Tn,{tone:"warning"},s.error):pt.createElement(Tn,null,d?GE.analyzeAgainNote:GE.analyzeNote),!t.target||null!=n&&n.targetGone||!h?null:pt.createElement(Tn,null,h)):null,null!=n&&n.targetChanged?pt.createElement(Tn,{tone:"warning"},Rt.analysis.targetChanged):null,pt.createElement(Tn,null,GE.wordingNote),pt.createElement(Mn,null),pt.createElement(Bn,null,GE.block),pt.createElement(rF,{block:t,onBlockChange:a}))},hF="react-autoql-report-builder-panel-open",pF=function(){try{return"false"!==window.localStorage.getItem(hF)}catch(e){return!0}},vF=function(e){try{e?window.localStorage.removeItem(hF):window.localStorage.setItem(hF,"false")}catch(e){}},mF=function(e){var t,n=e.report,r=e.block,o=e.view,i=e.onPageChange;if(r){var a=O[r.type];t=pt.createElement(pt.Fragment,null,pt.createElement(Bn,null,a?a.label:r.type),"heading"===r.type?pt.createElement(pt.Fragment,null,pt.createElement(On,{label:GE.level,value:r.level,options:P,testId:"report-builder-level",onChange:function(t){return e.onBlockChange(r.id,{level:t})}}),pt.createElement(Tn,null,GE.headingNote(cE())),pt.createElement(oF,e)):null,"text"===r.type?pt.createElement(pt.Fragment,null,pt.createElement(Tn,null,GE.textNote),pt.createElement(oF,e)):null,"data"===r.type?pt.createElement(dF,T({key:r.id},e,{view:o})):null,"analysis"===r.type?pt.createElement(fF,T({key:r.id},e,{view:o})):null,"pagebreak"===r.type?pt.createElement(Tn,null,GE.pageBreakNote):null,a?null:pt.createElement(Tn,null,GE.unknownNote))}else{var u,s;t=pt.createElement(nF,{page:n.page,onPageChange:i,brandFonts:!!(null!==(u=e.branding)&&void 0!==u&&u.headingFont||null!==(s=e.branding)&&void 0!==s&&s.bodyFont)})}return pt.createElement("aside",{id:e.id,className:"".concat(w,"-panel"),style:e.width?{width:"".concat(e.width,"px")}:void 0,"aria-label":r?Rt.properties:GE.pageSetup,"data-test":"report-builder-panel"},t)},gF=function(e,t,n){return Math.min(Math.max(e,t),n)},DF="react-autoql-report-builder-panel-width",yF=function(){try{var e=Number(window.localStorage.getItem(DF));return Number.isFinite(e)&&e>=100&&e<=4e3?e:null}catch(e){return null}},kF=function(e){try{null==e?window.localStorage.removeItem(DF):window.localStorage.setItem(DF,String(Math.round(e)))}catch(e){}},EF=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"ref",pt.createRef()),S(e,"drag",null),S(e,"state",{dragging:!1}),S(e,"getBounds",function(){var t,n,r,o=e.ref.current,i=e.props.controls?document.getElementById(e.props.controls):null,a=null==o?void 0:o.previousElementSibling,u=null===(t=window.getComputedStyle)||void 0===t?void 0:t.bind(window),s=parseFloat(null==u||null===(n=u(document.documentElement))||void 0===n?void 0:n.fontSize)||16,l=i&&parseFloat(null==u||null===(r=u(i))||void 0===r?void 0:r.minWidth)||240,c=(null==i?void 0:i.getBoundingClientRect().width)||0,d=(null==a?void 0:a.getBoundingClientRect().width)||0,f=40*s;return c&&d&&(f=Math.min(f,c+d-25*s)),{min:l,max:f=Math.max(l,f),width:gF(c||e.props.width||l,l,f)}}),S(e,"resize",function(t,n){var r,o;(e.props.onResize(t),n)&&(null===(r=(o=e.props).onResizeEnd)||void 0===r||r.call(o,t))}),S(e,"onMouseDown",function(t){var n;if(0===t.button){t.preventDefault(),null===(n=e.ref.current)||void 0===n||n.focus();var r=e.getBounds(),o=r.min,i=r.max,a=r.width;e.drag={startX:t.clientX,startWidth:a,width:a,min:o,max:i},document.addEventListener("mousemove",e.onMouseMove),document.addEventListener("mouseup",e.onMouseUp)}}),S(e,"onMouseMove",function(t){var n=e.drag;if(n)if(0!==t.buttons){var r=gF(n.startWidth+n.startX-t.clientX,n.min,n.max);r!==n.width&&(n.width=r,e.state.dragging||e.setState({dragging:!0}),e.resize(r,!1))}else e.onMouseUp()}),S(e,"onMouseUp",function(){var t,n,r=e.drag;(e.drag=null,e.stopListening(),e.state.dragging&&e.setState({dragging:!1}),r&&r.width!==r.startWidth)&&(null===(t=(n=e.props).onResizeEnd)||void 0===t||t.call(n,r.width))}),S(e,"stopListening",function(){document.removeEventListener("mousemove",e.onMouseMove),document.removeEventListener("mouseup",e.onMouseUp)}),S(e,"onKeyDown",function(t){var n,r=e.getBounds(),o=r.min,i=r.max,a=r.width,u=t.shiftKey?64:16;if("ArrowLeft"===t.key)n=a+u;else if("ArrowRight"===t.key)n=a-u;else if("Home"===t.key)n=o;else{if("End"!==t.key)return;n=i}t.preventDefault(),(n=gF(n,o,i))!==a&&e.resize(n,!0)}),e}return A(t,e),x(t,[{key:"componentWillUnmount",value:function(){this.stopListening()}},{key:"render",value:function(){var e=this.props,t=e.width,n=e.controls,r=this.state.dragging;return pt.createElement("div",{ref:this.ref,className:"".concat(w,"-panel-resizer"),role:"separator","aria-orientation":"vertical","aria-label":Rt.resizePanel,"aria-controls":n,"aria-valuenow":Math.round(t||240),"aria-valuemin":240,"aria-valuemax":640,title:Rt.resizePanelHint,tabIndex:0,"data-dragging":r||void 0,"data-test":"report-builder-panel-resizer",onMouseDown:this.onMouseDown,onKeyDown:this.onKeyDown,onDoubleClick:this.props.onReset},r?pt.createElement("div",{className:"".concat(w,"-panel-resize-overlay")}):null)}}])}(pt.Component),FF=new Map,bF=function(e){try{var t,n=null===(t=St(e))||void 0===t?void 0:t.project_id;return null==n||""===n?e:String(n)}catch(t){return e}},CF=function(e,t){var n=kt(e),r=n.domain,o=n.apiKey,i=n.token;if(!r||!i)return null;var a="".concat(r,"|").concat(o,"|");return{url:"".concat(r).concat(t).concat(o?"?key=".concat(encodeURIComponent(o)):""),config:{headers:{Authorization:"Bearer ".concat(i)}},scope:a,key:"".concat(a).concat(bF(i))}},wF=function(e,t){FF.delete(e),FF.set(e,t),FF.size>4&&FF.delete(FF.keys().next().value)},AF=function(){return new Error("No AutoQL authentication to read the branding with")},xF=function(){var e=z($().m(function e(t){var n,r,i,a,u,s,l,c,d;return $().w(function(e){for(;;)switch(e.n){case 0:if(r=t.authentication,i=t.branding,a=CF(r,"/autoql/management/api/v1/reports/branding")){e.n=1;break}throw AF();case 1:return e.n=2,gt.put(a.url,ar(i),a.config);case 2:for(u=e.v,s=ir(null==u||null===(n=u.data)||void 0===n?void 0:n.data),l=0,c=o(FF.keys());l<c.length;l++)(d=c[l]).startsWith(a.scope)&&FF.delete(d);return wF(a.key,Promise.resolve(s)),e.a(2,s)}},e)}));return function(t){return e.apply(this,arguments)}}(),SF=0,BF=function(e){var t,n=null;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return n&&o.length===n.length&&o.every(function(e,t){return e===n[t]})?t:(n=o,t=e.apply(void 0,o))}},TF=function(u){function s(u){var l;return M(this,s),l=N(this,s,[u]),S(l,"normalizeBlockCached",function(e){if(!e||"object"!==k(e))return null;var t=l.blockCache.get(e);if(t)return t;var n=ge(e);return n&&(l.blockCache.set(e,n),l.blockCache.set(n,n)),n}),S(l,"getReport",function(){var t=l.props.report;if(t===l.lastRawReport&&l.lastReport)return l.lastReport;var n=Array.isArray(null==t?void 0:t.blocks)?t.blocks:[],r=De(t&&"object"===k(t)?e(e({},t),{},{blocks:[]}):t);return l.lastRawReport=t,l.lastReport=e(e({},r),{},{blocks:n.map(l.normalizeBlockCached).filter(Boolean)}),l.lastReport}),S(l,"getTileIndex",BF(function(e){return Ce(e)})),S(l,"getPlan",BF(function(e,t,n,r,o){return we({report:e,tileIndex:t,authentication:n,autoQLConfig:r,getAuthenticationForProject:o})})),S(l,"getRequestKeys",function(e){var t={};return e.jobs.forEach(function(e){t[e.blockId]=e.key}),l.lastRequestKeys&&function(e,t){var n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(function(n){return e[n]===t[n]})}(l.lastRequestKeys,t)?l.lastRequestKeys:(l.lastRequestKeys=t,t)}),S(l,"getViews",BF(function(e,t,n,r,o){var i=l.viewEntries||{},u={},s={};return e.blocks.forEach(function(e){var l;if("data"===e.type){var c=r[e.id],d=null!=c&&(null==o?void 0:o[e.id])===c,f="tile"===(null===(l=e.source)||void 0===l?void 0:l.type)?a(t,e.source):null,h=[e,null==f?void 0:f.tile,null==f?void 0:f.dashboard,n[e.id],c,d],p=i[e.id],v=p&&p.inputs.every(function(e,t){return e===h[t]})?p:{inputs:h,view:Wt({block:e,tileIndex:t,result:n[e.id],requestKey:c,running:d})};u[e.id]=v,s[e.id]=v.view}}),e.blocks.forEach(function(t){if("analysis"===t.type){var n=t.target?e.blocks.find(function(e){return e.id===t.target&&"data"===e.type}):void 0,r=[t,n,n?s[n.id]:void 0],o=i[t.id],a=o&&o.inputs.length===r.length&&o.inputs.every(function(e,t){return e===r[t]})?o:{inputs:r,view:Gt({block:t,target:n,targetView:r[2]})};u[t.id]=a,s[t.id]=a.view}}),l.viewEntries=u,s})),S(l,"derive",function(){var e=l.getReport(),t=l.getTileIndex(l.props.dashboards),n=l.getPlan(e,t,l.props.authentication,l.props.autoQLConfig,l.props.getAuthenticationForProject),r=l.getRequestKeys(n),o=l.state,i=o.run,a=o.results,u="running"===(null==i?void 0:i.status)?i.keys:null;return{report:e,tileIndex:t,plan:n,requestKeys:r,views:l.getViews(e,t,a,r,u)}}),S(l,"isStale",function(e){var t=l.state.run;return!(!t||"running"===t.status)&&Object.keys(e).some(function(n){return t.keys[n]!==e[n]})}),S(l,"change",function(e){l.lastEmitted={base:l.props.report,report:e},l.props.onChange(e)}),S(l,"getLatestReport",function(){var e=l.lastEmitted;return e&&e.base===l.props.report?e.report:l.getReport()}),S(l,"onTitleChange",function(t){return l.change(function(t,n){return e(e({},t),{},{title:n})}(l.getLatestReport(),t))}),S(l,"onPageChange",function(t){return l.change(function(t,n){return e(e({},t),{},{page:e(e({},t.page),n)})}(l.getLatestReport(),t))}),S(l,"onBlockChange",function(e,t){return l.change(qt(l.getLatestReport(),e,t))}),S(l,"onStyleChange",function(t,o){return l.change(function(t,o,i){return zt(t,t.blocks.map(function(t){if(t.id!==o)return t;var a=n(e(e({},t.style||{}),i));t.style;var u=r(t,Ot);return a?e(e({},u),{},{style:a}):u}))}(l.getLatestReport(),t,o))}),S(l,"onStyleReset",function(e){return l.change(function(e,t){return zt(e,e.blocks.map(function(e){return e.id!==t?e:(e.style,r(e,It))}))}(l.getLatestReport(),e))}),S(l,"onSourceChange",function(e,t){return l.change(function(e,t,n){return qt(e,t,{source:n})}(l.getLatestReport(),e,t))}),S(l,"onText",function(e,t){return l.change(qt(l.getLatestReport(),e,{text:t}))}),S(l,"onChartChange",function(e,t){return l.change(qt(l.getLatestReport(),e,t))}),S(l,"onAsk",function(e,t){return l.onSourceChange(e,{type:"query",query:t})}),S(l,"onBlockAction",function(t,n){var r=l.getLatestReport();if("up"===n||"down"===n)l.change(function(e,t,n){var r=Lt(e,t),o=r+n;if(r<0||o<0||o>=e.blocks.length)return e;var a=e.blocks.slice(),u=a.splice(r,1),s=i(u,1)[0];return a.splice(o,0,s),zt(e,a)}(r,t,"up"===n?-1:1));else if("duplicate"===n){var o=function(t,n){var r=t.blocks.find(function(e){return e.id===n});if(!r)return{report:t,id:null};var o=e(e({},JSON.parse(JSON.stringify(r))),{},{id:Dt()});return{report:$t(t,o,n),id:o.id}}(r,t),a=o.report,u=o.id;l.change(a),u&&l.setState({selectedId:u})}else if("remove"===n){var s=r.blocks.findIndex(function(e){return e.id===t});if(s<0)return;l.change(function(e,t){return zt(e,e.blocks.filter(function(e){return e.id!==t}))}(r,t)),l.offerUndoRemove(r.blocks[s],s),l.state.selectedId===t&&l.setState({selectedId:null})}}),S(l,"offerUndoRemove",function(e,t){clearTimeout(l.removedTimer),l.setState({removed:{block:e,index:t}}),l.removedTimer=setTimeout(function(){l.mounted&&l.setState({removed:null})},1e4)}),S(l,"undoRemove",function(){var e=l.state.removed;if(clearTimeout(l.removedTimer),e){var t=l.getLatestReport();t.blocks.some(function(t){return t.id===e.block.id})?l.setState({removed:null}):(l.change(function(e,t,n){var r=e.blocks.slice();return r.splice(Math.max(0,Math.min(n,r.length)),0,t),zt(e,r)}(t,e.block,e.index)),l.setState({removed:null,selectedId:e.block.id},function(){return l.scrollToBlock(e.block.id)}))}}),S(l,"onSelect",function(e){return l.setState({selectedId:e})}),S(l,"onFormattingBarLeave",function(){return l.setState({richEditor:null,richBlockId:null})}),S(l,"onCanvasMouseDown",function(e){var t,n;null!==(t=(n=e.target).closest)&&void 0!==t&&t.call(n,".".concat(w,"-block"))||l.setState({selectedId:null})}),S(l,"onKeyDown",function(e){"Escape"===e.key&&(l.state.details?l.closeDetails():!l.state.selectedId||/^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName)||e.target.isContentEditable||l.setState({selectedId:null}))}),S(l,"onPanelResize",function(e){return l.setState({panelWidth:e})}),S(l,"onPanelResizeEnd",function(e){return kF(e)}),S(l,"onTogglePanel",function(){var e=!l.state.panelOpen;l.setState({panelOpen:e}),vF(e)}),S(l,"onPageSetup",function(){l.state.panelOpen||vF(!0),l.setState({selectedId:null,details:null,panelOpen:!0},function(){var e,t=null===(e=l.rootRef.current)||void 0===e?void 0:e.querySelector("#".concat(l.panelId));t&&(t.scrollTop=0)})}),S(l,"loadBranding",function(){var e=++l.brandingSeq;l.props.enableBranding?function(e){var t=e.authentication,n=CF(t,"/autoql/api/v1/reports/branding");if(!n)return Promise.reject(AF());var r=FF.get(n.key);if(r)return wF(n.key,r),r;var o=gt.get(n.url,n.config).then(function(e){var t;return ir(null==e||null===(t=e.data)||void 0===t?void 0:t.data)});return o.catch(function(){FF.get(n.key)===o&&FF.delete(n.key)}),wF(n.key,o),o}({authentication:l.props.authentication}).then(function(t){l.mounted&&e===l.brandingSeq&&l.setState({orgBranding:t,brandingReady:!0})},function(){l.mounted&&e===l.brandingSeq&&l.setState({orgBranding:null,brandingReady:!1})}):(l.state.orgBranding||l.state.brandingReady)&&l.setState({orgBranding:null,brandingReady:!1})}),S(l,"getBranding",BF(function(e,t){return rr(e,t)})),S(l,"canEditBranding",function(){return!!(l.props.enableBranding&&l.props.canEditBranding&&l.state.brandingReady)}),S(l,"openBranding",function(){return l.setState({brandingOpen:!0,details:null})}),S(l,"closeBranding",function(){return l.setState({brandingOpen:!1},function(){var e,t;return null===(e=l.optionsRef.current)||void 0===e||null===(t=e.focusButton)||void 0===t?void 0:t.call(e)})}),S(l,"saveBranding",function(){var e=z($().m(function e(t){var n;return $().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,xF({authentication:l.props.authentication,branding:t});case 1:n=e.v,l.mounted&&l.setState({orgBranding:n,brandingReady:!0});case 2:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}()),S(l,"onZoomChange",function(e){l.setState({zoom:e}),function(e){try{window.localStorage.setItem(yn,String(e))}catch(e){}}(e)}),S(l,"onFit",function(e){l.setState(function(t){return t.fitScale===e?null:{fitScale:e}})}),S(l,"onEditorPages",function(e){var t={startPages:Kk(e),count:e.length};l.setState(function(e){return wt(e.editorPages,t)?null:{editorPages:t}})}),S(l,"onPanelResizeReset",function(){l.setState({panelWidth:null}),kF(null)}),S(l,"scrollToBlock",function(e){setTimeout(function(){var t,n,r=null===(t=l.rootRef.current)||void 0===t?void 0:t.querySelector('[data-block-id="'.concat(e,'"]'));null==r||null===(n=r.scrollIntoView)||void 0===n||n.call(r,{block:"nearest"})},0)}),S(l,"setPending",function(t,n){return l.setState(function(r){var o=e({},r.pending);return n?o[t]=n:delete o[t],{pending:o}})}),S(l,"onPickTiles",function(t){var n=l.props.pickDashboardTiles;if("function"==typeof n&&!l.pendingSeqs[t]){l.pendingSeq+=1;var r=l.pendingSeq;l.pendingSeqs[t]=r,l.setPending(t,{kind:"tiles",seq:r});var i,a=function(){return!(!l.mounted||l.pendingSeqs[t]!==r)&&(delete l.pendingSeqs[t],l.setPending(t,null),!0)};try{i=n()}catch(e){i=Promise.reject(e)}Promise.resolve(i).then(function(n){if(a()){var r=l.getLatestReport(),i=r.blocks.find(function(e){return e.id===t});if(i&&"data"===i.type&&!i.source&&!i.capture){var u=new Set(r.blocks.map(function(e){return e.id})),s=(Array.isArray(n)?n:[]).map(ge).filter(Boolean).map(function(t){var n=u.has(t.id)?e(e({},t),{},{id:Dt()}):t;return u.add(n.id),n});s.length&&(l.change(function(e,t,n){var r=Lt(e,t);if(r<0)return e;var i=e.blocks.slice();return i.splice.apply(i,[r,1].concat(o(n))),zt(e,i)}(r,t,s)),l.setState({selectedId:s[0].id},function(){return l.scrollToBlock(s[0].id)}))}}}).catch(function(e){a()&&l.props.onErrorCallback(e)})}}),S(l,"askQuestion",function(n,o){var i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).rerun,a=void 0!==i&&i;if(!l.pendingSeqs[n]){l.pendingSeq+=1;var u=l.pendingSeq;l.pendingSeqs[n]=u;var s="function"==typeof AbortController?new AbortController:null;l.pendingAborts[n]=s,l.setPending(n,{kind:"question",seq:u,query:o,rerun:a}),ye({query:o,authentication:l.props.authentication,autoQLConfig:l.props.autoQLConfig,signal:null==s?void 0:s.signal}).then(function(i){if(l.mounted&&l.pendingSeqs[n]===u)if(delete l.pendingSeqs[n],delete l.pendingAborts[n],i.ok){l.setPending(n,null);var s=l.getLatestReport(),c=s.blocks.find(function(e){return e.id===n});if(c&&"data"===c.type)if(a){var d;if(!c.askedHere||"query"!==(null===(d=c.source)||void 0===d?void 0:d.type)||c.source.query!==o)return;l.change(qt(s,n,{capture:i.capture}))}else c.source||c.capture||l.change(function(n,o,i){var a=i.source,u=i.capture,s=i.rows,l=i.askedHere,c=void 0!==l&&l;return zt(n,n.blocks.map(function(n){if(n.id!==o)return n;n.displayType,n.askedHere;var i=r(n,Pt);return e(e({},i),{},{source:a,capture:u,rows:t(s)},c?{askedHere:!0}:{})}))}(s,n,{source:{type:"query",query:o},capture:i.capture,rows:i.rows,askedHere:!0}))}else{var f,h=Rt.data.askFailed[i.reason]||Rt.data.askFailed.error,p=null!==(f=i.error)&&void 0!==f&&f.message?"".concat(h," ").concat(i.error.message):h;l.setPending(n,"cancelled"===i.reason?null:{kind:"question",seq:u,query:o,rerun:a,error:p})}})}}),S(l,"onAskCapture",function(e,t){return l.askQuestion(e,t)}),S(l,"onRerun",function(e){var t,n=l.getLatestReport().blocks.find(function(t){return t.id===e});null!=n&&n.askedHere&&"query"===(null===(t=n.source)||void 0===t?void 0:t.type)&&l.askQuestion(e,n.source.query,{rerun:!0})}),S(l,"onAnalyze",function(e){if(l.props.enableAnalysis&&!l.pendingSeqs[e]){var t=l.getLatestReport(),n=t.blocks.find(function(t){return t.id===e&&"analysis"===t.type}),r=(null==n?void 0:n.target)&&t.blocks.find(function(e){return e.id===n.target&&"data"===e.type}),o=r?Qt({target:r,targetView:l.derive().views[r.id]}):null;if(o){l.pendingSeq+=1;var i=l.pendingSeq;l.pendingSeqs[e]=i,l.setPending(e,{kind:"analysis",seq:i});var a=(n.focus||"").trim();(function(e){var t,n=e.input,r=e.focus,o=void 0===r?"":r,i=e.authentication,a=e.fetchSummary,u=void 0===a?Et:a,s=kt(i);try{t=u({queryID:n.queryId,data:{additional_context:{text:n.text,interpretation:n.interpretation,focus_prompt:(o||"").trim()},rows:n.rows,columns:n.columns},apiKey:s.apiKey,token:s.token,domain:s.domain})}catch(e){t=Promise.reject(e)}return Promise.resolve(t).then(function(e){var t,n=null==e||null===(t=e.data)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.summary;return"string"==typeof n&&n.trim()?{ok:!0,text:n}:{ok:!1,message:Rt.analysis.failed}},function(e){var t=F(e);if(t)return{ok:!1,billing:t,message:b[t]};var n="string"==typeof(null==e?void 0:e.message)?e.message:"";return{ok:!1,message:n?"".concat(Rt.analysis.failed," ").concat(n):Rt.analysis.failed}})})({input:o,focus:a,authentication:l.props.authentication}).then(function(t){if(l.mounted&&l.pendingSeqs[e]===i)if(delete l.pendingSeqs[e],t.ok){l.setPending(e,null);var n=l.getLatestReport();n.blocks.some(function(t){return t.id===e&&"analysis"===t.type})&&l.change(qt(n,e,{text:Kt(t.text),writtenAt:(new Date).toISOString(),targetAsOf:o.asOf,targetTitle:o.title,focusUsed:a,rowsAnalyzed:o.rows.length}))}else l.setPending(e,{kind:"analysis",seq:i,error:t.message})})}}}),S(l,"onAnalyzeResult",function(e){if(l.props.enableAnalysis){var t=l.getLatestReport(),n=t.blocks.find(function(t){return t.id===e&&"data"===t.type});if(!Jt({target:n,targetView:l.derive().views[e]})){var r=ke("analysis",{target:e});l.change($t(t,r,e)),l.setState({selectedId:r.id},function(){return l.scrollToBlock(r.id)}),l.onAnalyze(r.id)}}}),S(l,"openDetails",function(e,t){var n;if((null===(n=l.state.details)||void 0===n?void 0:n.type)!==e){var r,o=l.bodyRef.current;if(o&&t){var i=o.getBoundingClientRect(),a=t.getBoundingClientRect(),u=a.top-i.top-6,s=i.height-460;s>8&&u>s&&(u=s),u>8||(u=8),r={top:u,left:a.right-i.left+10}}l.setState({details:{type:e,draft:jn(e),position:r}})}else l.closeDetails()}),S(l,"closeDetails",function(){return l.setState({details:null})}),S(l,"onDraftChange",function(t){return l.setState(function(n){return n.details?{details:e(e({},n.details),{},{draft:t})}:null})}),S(l,"insertFromDetails",function(){var t,n=l.state,r=n.details,o=n.selectedId;if(r){var i=l.getLatestReport(),a=i.blocks.some(function(e){return e.id===o})?o:void 0,u="analysis"!==r.type||null!==(t=r.draft)&&void 0!==t&&t.target?r.draft:e(e({},r.draft),{},{target:l.analysisTargetFor(i,a)}),s=ke(r.type,u);s&&(l.change($t(i,s,a)),l.setState({details:null,selectedId:s.id},function(){return l.scrollToBlock(s.id)}))}}),S(l,"analysisTargetFor",function(e,t){for(var n=new Set(Xt(e.blocks,l.derive().views).filter(function(e){return!e.blocker}).map(function(e){return e.id})),r=t?e.blocks.findIndex(function(e){return e.id===t}):e.blocks.length-1,i=r;i>=0;i-=1)if(n.has(e.blocks[i].id))return e.blocks[i].id;return 1===n.size?o(n)[0]:void 0}),S(l,"cancelRequests",function(){l.cancelSource&&(l.cancelSource.cancel(Nt),l.cancelSource=null)}),S(l,"runReport",function(){if(!l.props.enableRunReport)return Promise.resolve(null);l.cancelRequests();var t=l.derive(),n=t.plan,r=t.requestKeys;l.runId+=1;var o=l.runId,i=gt.CancelToken.source();l.cancelSource=i;var a=(new Date).toISOString(),u=function(){return l.mounted&&l.runId===o};return l.setState({results:{},run:{id:o,status:"running",runAt:a,done:0,total:n.jobs.length,keys:r}}),Ee({jobs:n.jobs,cancelToken:i.token,onSettled:function(t,n){u()&&l.setState(function(r){return{results:e(e({},r.results),{},S({},t,n)),run:r.run?e(e({},r.run),{},{done:r.run.done+1}):r.run}})}}).then(function(t){if(!u())return null;l.cancelSource===i&&(l.cancelSource=null);var r=e(e({},Fe(t,n.skipped)),{},{runAt:a});return l.setState(function(t){return{run:e(e({},t.run),{},{status:"cancelled"===r.status?"cancelled":"done"})}}),l.props.onRunComplete(r),r}).catch(function(t){return u()?(l.setState(function(t){return{run:e(e({},t.run),{},{status:"done"})}}),l.props.onErrorCallback(t),null):null})}),S(l,"cancelRun",function(){var t;"running"===(null===(t=l.state.run)||void 0===t?void 0:t.status)&&(l.cancelRequests(),l.runId+=1,l.setState(function(t){return{run:e(e({},t.run),{},{status:"cancelled"})}}))}),S(l,"openPrintPreview",function(){return new Promise(function(e){l.state.previewOpen?e():l.setState({previewOpen:!0,details:null,layoutInfo:null,notice:null},e)})}),S(l,"closePrintPreview",function(){return new Promise(function(e){var t;null===(t=l.printJob)||void 0===t||t.remove(),l.setState({previewOpen:!1,layoutInfo:null,notice:null},e)})}),S(l,"onLayout",function(e){return l.setState({layoutInfo:e})}),S(l,"print",z($().m(function e(){var t,n,r,o,i;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!l.printInFlight){e.n=1;break}return e.a(2,!1);case 1:return l.printInFlight=!0,l.setState({printing:!0,notice:null}),e.p=2,e.n=3,l.openPrintPreview();case 3:if(n=l.previewRef.current){e.n=4;break}return e.a(2,!1);case 4:return e.n=5,n.whenReady();case 5:return e.n=6,rn(n.getPagesElement(),{timeout:15e3});case 6:if(r=e.v,l.mounted&&l.state.previewOpen&&l.previewRef.current===n){e.n=7;break}return e.a(2,!1);case 7:return r.timedOut&&l.setState({notice:Rt.preview.chartsTimedOut(r.pending)}),o=l.getReport(),null===(t=l.printJob)||void 0===t||t.remove(),l.printJob=mn({pages:n.getPageElements(),title:o.title||Rt.untitled,orientation:o.page.orientation}),e.n=8,l.printJob.printed;case 8:return e.a(2,e.v);case 9:return e.p=9,i=e.v,l.props.onErrorCallback(i),e.a(2,!1);case 10:return e.p=10,l.printInFlight=!1,l.mounted&&l.setState({printing:!1}),e.f(10);case 11:return e.a(2)}},e,null,[[2,9,10,11]])}))),S(l,"runLabelFor",function(e){var t=e.report,n=e.isStale;return be({run:l.state.run,dataBlockCount:t.blocks.filter(function(e){return"data"===e.type&&e.source}).length,isStale:n})}),S(l,"getPreviewMeta",function(e){var t=l.state.layoutInfo,n=ue.find(function(t){return i(t,1)[0]===e.page.orientation}),r=[Rt.preview.letter,(n||ue[0])[1]];return t&&r.push(Rt.preview.pages(t.pageCount)),r.join(" · ")}),S(l,"renderEditor",function(e){var t=e.report,n=e.views,r=e.geometry,o=e.branding,i=l.state,a=i.selectedId,u=i.details,s=i.run,c=i.pending,d=i.panelWidth,f=l.props.enableRunReport,h=!f&&!!l.props.enableDataBlocks,p=h&&"function"==typeof l.props.pickDashboardTiles?l.onPickTiles:void 0,v=p?"tiles":"ask",m=!!l.props.enableAnalysis,g=t.blocks.find(function(e){return e.id===a})||null,D=s&&"running"!==s.status?s.runAt:null,y=l.state.editorPages,k=(t.page.coverPage?1:0)+(t.page.tableOfContents&&t.blocks.some(function(e){return"heading"===e.type&&jk(e)})?1:0);return pt.createElement(pt.Fragment,null,pt.createElement(An,{openType:null==u?void 0:u.type,onOpen:l.openDetails,onGetStarted:l.props.onGetStarted,types:I.filter(function(e){return"data"===e?f||h:"analysis"!==e||m}),note:f?Rt.paletteNote:h?Rt.paletteNoteDataBlocks[v]:Rt.paletteNoteCaptures}),pt.createElement("main",{className:"".concat(w,"-canvas"),onMouseDown:l.onCanvasMouseDown},pt.createElement(QE,{report:t,views:n,branding:o,dataFormatting:l.props.dataFormatting,authentication:l.props.authentication,autoQLConfig:l.props.autoQLConfig,canRun:f,onPages:l.onEditorPages}),pt.createElement(Fn,{zoom:l.state.zoom,onFit:l.onFit},pt.createElement(zE,{report:t,views:n,selectedId:null==g?void 0:g.id,geometry:r,branding:o,footerLeft:Dr({dataAsOf:D?Y(D,{time:!0}):null,hasData:f&&yr(t)}),onSelect:l.onSelect,onAction:l.onBlockAction,onText:l.onText,onAsk:h?l.onAskCapture:l.onAsk,dataFormatting:l.props.dataFormatting,authentication:l.props.authentication,autoQLConfig:l.props.autoQLConfig,canRun:f,canCapture:h,onPickTiles:p,onAnalyzeResult:m?l.onAnalyzeResult:void 0,onChartChange:l.onChartChange,pending:c,richEditor:l.state.richEditor,richBlockId:l.state.richBlockId,onFormattingLeave:l.onFormattingBarLeave,startPages:null==y?void 0:y.startPages,pageCount:null==y?void 0:y.count,frontPages:k}))),l.state.panelOpen?pt.createElement(pt.Fragment,null,pt.createElement(EF,{width:d,controls:l.panelId,onResize:l.onPanelResize,onResizeEnd:l.onPanelResizeEnd,onReset:l.onPanelResizeReset}),pt.createElement(mF,{id:l.panelId,width:d,report:t,branding:o,block:g,view:g?n[g.id]:null,dashboards:l.props.dashboards,onPageChange:l.onPageChange,onBlockChange:l.onBlockChange,onStyleChange:l.onStyleChange,onStyleReset:l.onStyleReset,onSourceChange:l.onSourceChange,canRun:f,canCapture:h,onPickTiles:p,onAskCapture:h?l.onAskCapture:void 0,onRerun:h?l.onRerun:void 0,targets:"analysis"===(null==g?void 0:g.type)?Xt(t.blocks,n):void 0,onAnalyze:m?l.onAnalyze:void 0,pending:g?c[g.id]:void 0})):null,u?pt.createElement(Hn,{type:u.type,draft:u.draft,position:u.position,copy:"data"===u.type&&h?Rt.dataDetails[v]:void 0,onDraftChange:l.onDraftChange,onInsert:l.insertFromDetails,onClose:l.closeDetails}):null)}),l.rootRef=pt.createRef(),l.bodyRef=pt.createRef(),l.previewRef=pt.createRef(),l.optionsRef=pt.createRef(),l.blockCache=new WeakMap,l.runId=0,SF+=1,l.panelId="".concat(w,"-panel-").concat(SF),l.richText={activate:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return l.setState(function(n){return n.richEditor===e&&n.richBlockId===t?null:{richEditor:e,richBlockId:t}})},deactivate:function(e,t){var n;null!=t&&null!==(n=t.closest)&&void 0!==n&&n.call(t,"[data-formatting-bar]")||l.setState(function(t){return t.richEditor===e?{richEditor:null,richBlockId:null}:null})}},l.state={selectedId:null,details:null,previewOpen:!1,layoutInfo:null,run:null,results:{},printing:!1,notice:null,removed:null,richEditor:null,richBlockId:null,pending:{},panelWidth:yF(),panelOpen:pF(),zoom:kn(),fitScale:1,editorPages:null,orgBranding:null,brandingReady:!1,brandingOpen:!1},l.pendingSeq=0,l.pendingSeqs={},l.pendingAborts={},l.brandingSeq=0,l}return A(s,u),x(s,[{key:"componentDidMount",value:function(){this.mounted=!0,this.loadBranding()}},{key:"componentDidUpdate",value:function(e){var t=e.authentication||{},n=this.props.authentication||{};e.enableBranding===this.props.enableBranding&&t.token===n.token&&t.domain===n.domain&&t.apiKey===n.apiKey||this.loadBranding()}},{key:"componentWillUnmount",value:function(){var e;this.mounted=!1,clearTimeout(this.removedTimer),this.cancelRequests(),Object.values(this.pendingAborts).forEach(function(e){return null==e?void 0:e.abort()}),null===(e=this.printJob)||void 0===e||e.remove()}},{key:"render",value:function(){var e=this.derive(),t=e.report,n=e.plan,r=e.requestKeys,o=e.views,i=this.getBranding(this.props.branding,this.state.orgBranding),a=en(t.page),u=this.state,s=u.run,l=u.previewOpen,c=u.printing,d=u.notice,f=u.layoutInfo,h=this.isStale(r),p="running"===(null==s?void 0:s.status),v=n.jobs.length>0;return pt.createElement(fe,null,pt.createElement(uE.Provider,{value:this.richText},pt.createElement("div",{ref:this.rootRef,className:"".concat(w).concat(this.props.className?" ".concat(this.props.className):""),"data-mode":l?"preview":"edit",onKeyDown:this.onKeyDown,"data-test":"report-builder"},this.props.fontStylesheetUrl?pt.createElement("link",{rel:"stylesheet",href:this.props.fontStylesheetUrl}):null,pt.createElement(vr,{branding:i}),pt.createElement(wn,{title:t.title,onTitleChange:this.onTitleChange,runLabel:this.runLabelFor({report:t,isStale:h}),running:p,highlightRun:v&&!p&&(!s||h||"cancelled"===s.status),hasRun:!!s&&!p,canRun:v,onRun:this.runReport,onCancelRun:this.cancelRun,showRun:this.props.enableRunReport,previewOpen:l,previewMeta:l?this.getPreviewMeta(t):null,onOpenPreview:this.openPrintPreview,onClosePreview:this.closePrintPreview,printing:c,onPrint:this.print,status:this.props.toolbarStatus,zoom:this.state.zoom,fitScale:this.state.fitScale,onZoomChange:this.onZoomChange,panelOpen:this.state.panelOpen,panelId:this.panelId,onTogglePanel:this.onTogglePanel,optionsRef:this.optionsRef,onPageSetup:this.onPageSetup,onBranding:this.canEditBranding()?this.openBranding:void 0}),d||l&&null!=f&&f.overflowCount?pt.createElement("div",{className:"".concat(w,"-notice"),role:"status"},d||Rt.preview.overflowNotice(f.overflowCount)):null,this.state.removed&&!l?pt.createElement("div",{className:"".concat(w,"-notice"),"data-tone":"info",role:"status","data-test":"report-builder-removed"},pt.createElement("span",null,Rt.blockRemoved),pt.createElement("button",{type:"button",className:"".concat(w,"-notice-action"),"data-test":"report-builder-undo-remove",onClick:this.undoRemove},Rt.undoRemove)):null,pt.createElement("div",{className:"".concat(w,"-body"),ref:this.bodyRef},l?pt.createElement(JE,{ref:this.previewRef,report:t,views:o,branding:i,runAt:s&&"running"!==s.status?s.runAt:null,generatedAt:(new Date).toISOString(),dataFormatting:this.props.dataFormatting,authentication:this.props.authentication,autoQLConfig:this.props.autoQLConfig,onLayout:this.onLayout,canRun:this.props.enableRunReport,zoom:this.state.zoom,onFit:this.onFit}):this.renderEditor({report:t,views:o,geometry:a,branding:i})),this.state.brandingOpen&&this.canEditBranding()?pt.createElement(Ir,{branding:i,reportTitle:t.title,onSave:this.saveBranding,onClose:this.closeBranding}):null)))}}])}(pt.Component);S(TF,"propTypes",{authentication:he,autoQLConfig:pe,dataFormatting:ve,dashboards:mt.arrayOf(mt.shape({id:mt.oneOfType([mt.string,mt.number]).isRequired,name:mt.string,tiles:mt.arrayOf(mt.object),slicers:mt.arrayOf(mt.object)})),report:mt.shape({schemaVersion:mt.number,title:mt.string,page:mt.object,blocks:mt.arrayOf(mt.object)}),onChange:mt.func,branding:mt.shape({name:mt.string,logoUrl:mt.string,wordmarkUrl:mt.string,position:mt.oneOf(["left","center","right"]),colors:mt.arrayOf(mt.string),headingFont:mt.shape({name:mt.string,url:mt.string}),bodyFont:mt.shape({name:mt.string,url:mt.string})}),enableBranding:mt.bool,canEditBranding:mt.bool,onRunComplete:mt.func,onErrorCallback:mt.func,getAuthenticationForProject:mt.func,fontStylesheetUrl:mt.string,enableRunReport:mt.bool,enableDataBlocks:mt.bool,pickDashboardTiles:mt.func,enableAnalysis:mt.bool,onGetStarted:mt.func,toolbarStatus:mt.node,className:mt.string}),S(TF,"defaultProps",{authentication:Bt,autoQLConfig:Tt,dataFormatting:Mt,dashboards:[],report:void 0,onChange:function(){},branding:void 0,enableBranding:!1,canEditBranding:!1,onRunComplete:function(){},onErrorCallback:function(){},getAuthenticationForProject:void 0,fontStylesheetUrl:null,enableRunReport:!1,enableDataBlocks:!1,pickDashboardTiles:void 0,enableAnalysis:!1,onGetStarted:void 0,toolbarStatus:null,className:void 0});var MF=me(TF);MF.displayName="ReportBuilder";var NF=xe.save.conflict,RF="".concat(xe.errors.lead.save,": ").concat(xe.errors.titleTooLong(ze),"."),OF=[5e3,15e3,3e4,6e4],IF={createReport:Te,saveReport:Me,fetchReport:Ne},PF=function(e){return e instanceof $e&&409===e.status&&"REPORT_VERSION_CONFLICT"===e.code},LF=function(e){return e instanceof $e&&(0===e.status||e.status>=500)},zF=function(){return x(function e(t){var n;M(this,e);var r=t.id,o=t.stored,i=t.report,a=t.delayMs,u=t.api;this.options=t,this.id=r,this.delayMs=null!=a?a:Se,this.api=u||IF,this.local=i,this.base=o?Be(o.report):null,this.unconfirmed=null,this.version=o?o.version:null,this.edits=0,this.savedEdits=o?0:-1,this.inflight=null,this.sending=[],this.timer=null,this.retries=0,this.disposed=!1,this.state={status:o?"saved":"saving",error:null,savedAt:null!==(n=null==o?void 0:o.updatedAt)&&void 0!==n?n:null}},[{key:"report",get:function(){return this.local}},{key:"current",get:function(){return this.state}},{key:"created",get:function(){return null!==this.version}},{key:"hasUnsaved",get:function(){return this.dirty||null!==this.inflight}},{key:"dirty",get:function(){return this.edits!==this.savedEdits}},{key:"edit",value:function(e){this.disposed||(this.local=e,this.edits+=1,"conflict"!==this.state.status&&(this.setState({status:"saving",error:null}),this.schedule(this.delayMs)))}},{key:"flush",value:(r=z($().m(function e(){var t,n,r=arguments;return $().w(function(e){for(;;)switch(e.n){case 0:t=(r.length>0&&void 0!==r[0]?r[0]:{}).keepalive,n=void 0!==t&&t,this.clearTimer();case 1:if(!this.inflight){e.n=3;break}return e.n=2,this.inflight;case 2:return e.a(3,7);case 3:if(!this.disposed&&"conflict"!==this.state.status){e.n=4;break}return e.a(2,!1);case 4:if(this.dirty){e.n=5;break}return e.a(2,!0);case 5:return e.n=6,this.send(n);case 6:if(e.v){e.n=7;break}return e.a(2,!1);case 7:e.n=1;break;case 8:return e.a(2)}},e,this)})),function(){return r.apply(this,arguments)})},{key:"leave",value:function(){if(this.clearTimer(),!this.disposed&&"conflict"!==this.state.status&&this.dirty){var e=this.sending[this.sending.length-1];e&&e.keepalive&&e.edits===this.edits||this.send(!0)}}},{key:"retry",value:function(){return"failed"===this.state.status&&this.hasUnsaved?this.flush():Promise.resolve(!this.hasUnsaved)}},{key:"settle",value:(n=z($().m(function e(){return $().w(function(e){for(;;)switch(e.n){case 0:if(!this.inflight){e.n=2;break}return e.n=1,this.inflight;case 1:e.n=0;break;case 2:this.clearTimer();case 3:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"dispose",value:function(){this.disposed=!0,this.clearTimer()}},{key:"schedule",value:function(e){var t=this;this.clearTimer(),this.disposed||(this.timer=setTimeout(function(){t.timer=null,t.inflight||t.disposed||"conflict"===t.state.status||!t.dirty||t.send()},e))}},{key:"clearTimer",value:function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}},{key:"setState",value:function(t){var n,r;(this.state=e(e({},this.state),t),this.disposed)||(null===(n=(r=this.options).onState)||void 0===n||n.call(r,this.state))}},{key:"authentication",value:function(){var e,t;return null===(e=(t=this.options).getAuthentication)||void 0===e?void 0:e.call(t)}},{key:"send",value:function(e){var t=this,n=this.write(e).finally(function(){t.inflight===n&&(t.inflight=null)});return this.inflight=n,n}},{key:"write",value:(t=z($().m(function t(n){var r,o,i,a,u,s,l,c,d,f,h,p,v,m,g=this;return $().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=this.edits,!Le(this.local)){t.n=1;break}return this.fail(RF,!1,r),t.a(2,!1);case 1:if(o=Be(this.local),i={body:o,edits:r,keepalive:!!n},this.sending.push(i),a=n?{keepalive:!0}:{},this.setState({status:"saving",error:null}),t.p=2,null!==this.version){t.n=4;break}return t.n=3,this.api.createReport(e(e({authentication:this.authentication(),id:this.id,report:o},this.options.folderId?{folderId:this.options.folderId}:{}),a));case 3:return u=t.v,this.version=u.version,this.base=u.report,Pe(u.report,o)&&(this.savedEdits=r),this.succeed(u.updatedAt),t.a(2,!0);case 4:s=$().m(function t(){var n,u,s,l,d,f;return $().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,g.api.saveReport(e({authentication:g.authentication(),id:g.id,report:o,version:g.version},a));case 1:return n=t.v,g.version=n.version,g.base=o,g.unconfirmed=null,g.savedEdits=r,g.succeed(n.updatedAt),t.a(2,{v:!0});case 2:if(t.p=2,f=t.v,PF(f)&&!(c>=3)){t.n=3;break}throw f;case 3:if(!(g.savedEdits>=r)){t.n=4;break}return t.a(2,{v:!0});case 4:return t.n=5,g.api.fetchReport({authentication:g.authentication(),id:g.id});case 5:if(u=t.v,!g.sending.some(function(e){return e.edits>r&&null!==Ae(e.body,u.report)})){t.n=6;break}return t.a(2,{v:!0});case 6:if(null!==(s=g.addedSince(u.report))){t.n=7;break}return g.conflict(),t.a(2,{v:!1});case 7:if(g.version=u.version,g.base=u.report,g.unconfirmed=null,s.length>0&&(o=qe(o,s),i.body=o,g.local=qe(g.local,s),g.disposed||null===(l=(d=g.options).onMerged)||void 0===l||l.call(d,g.local,s)),!Pe(o,u.report)){t.n=8;break}return g.savedEdits=r,g.succeed(u.updatedAt),t.a(2,{v:!0});case 8:return t.a(2)}},t,null,[[0,2]])}),c=0;case 5:return t.d(Ie(s()),6);case 6:if(!(l=t.v)){t.n=7;break}return t.a(2,l.v);case 7:c+=1,t.n=5;break;case 8:t.n=10;break;case 9:return t.p=9,m=t.v,LF(m)&&(this.unconfirmed=o),d=Re(m,"save"),f=d.message,h=d.retry,this.fail(f,h,r),Oe(m)&&!this.disposed&&(null===(p=(v=this.options).onUnauthorized)||void 0===p||p.call(v)),t.a(2,!1);case 10:return t.p=10,this.sending=this.sending.filter(function(e){return e!==i}),t.f(10);case 11:return t.a(2)}},t,this,[[2,9,10,11]])})),function(e){return t.apply(this,arguments)})},{key:"addedSince",value:function(e){for(var t=0,n=[this.base,this.unconfirmed].concat(o(this.sending.map(function(e){return e.body})));t<n.length;t++){var r=n[t],i=Ae(r,e);if(null!==i)return i}return null}},{key:"succeed",value:function(e){this.retries=0,this.setState({status:this.dirty?"saving":"saved",error:null,savedAt:e||this.state.savedAt}),this.dirty&&this.schedule(this.delayMs)}},{key:"fail",value:function(e,t,n){var r=OF[Math.min(this.retries,OF.length-1)];this.setState({status:"failed",error:t?"".concat(e," ").concat(xe.save.retrying):e}),t?(this.retries+=1,this.schedule(r)):this.edits!==n&&this.schedule(this.delayMs)}},{key:"conflict",value:function(){this.clearTimer(),this.setState({status:"conflict",error:NF})}}]);var t,n,r}(),$F=function(e){return!!e&&"object"===k(e)&&!Array.isArray(e)},qF=function(e,t){return"string"==typeof e?"".concat(e).concat(t):null},jF=function(e){return null==e?"":String(e)},HF=function(e){if(!e)return{};try{var t=window.localStorage.getItem(e),n=t?JSON.parse(t):null;return $F(n)?n:{}}catch(e){return{}}},VF=function(e,t){Object.keys(t).length>0?window.localStorage.setItem(e,JSON.stringify(t)):window.localStorage.removeItem(e)},UF=function(e,t){var n=HF(qF(e,He))[jF(t)];if(!$F(n))return{};var r={};return Object.entries(n).forEach(function(e){var t=i(e,2),n=t[0],o=t[1];"number"==typeof o&&o>=96&&o<=4e3&&(r[n]=Math.round(o))}),r},WF=function(e,t){var n={};return t.forEach(function(t){void 0!==e[t]&&(n[t]=e[t])}),Object.keys(n).length===Object.keys(e).length?e:n},_F=function(e,t){return e.includes(t)?e:[].concat(o(e),[t])},KF=xe.tabs,JF=function(e,t){return Math.min(e.max,Math.max(96,Math.round(e.startWidth+t-e.startX)))},QF=function(e){var t=e.querySelector("[data-tab-title]"),n=null==t?void 0:t.parentElement;if(!t||!n)return 96;var r=e.getBoundingClientRect(),o=t.getBoundingClientRect().left-r.left,i=r.right-n.getBoundingClientRect().right;return Math.max(96,Math.ceil(o+t.scrollWidth+i)+1)},GF=function(e){function t(){var e;M(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=N(this,t,[].concat(r)),S(e,"scrollerRef",pt.createRef()),S(e,"drag",null),S(e,"state",{dragged:null}),S(e,"showShownTab",function(){var t,n=e.props.shownId,r=e.scrollerRef.current;if(null!==n&&r){var o=Array.from(r.children).find(function(e){return e.getAttribute("data-tab")===n});null==o||null===(t=o.scrollIntoView)||void 0===t||t.call(o,{block:"nearest",inline:"nearest"})}}),S(e,"onTabMouseDown",function(e){1===e.button&&e.preventDefault()}),S(e,"onTabAuxClick",function(t,n){var r,o;1===t.button&&(t.preventDefault(),null===(r=(o=e.props).onClose)||void 0===r||r.call(o,n))}),S(e,"startResize",function(t,n){var r,o,i=t.currentTarget.parentElement;0===t.button&&e.props.onResize&&i&&(t.preventDefault(),e.drag={id:n,pointerId:t.pointerId,startX:t.clientX,startWidth:i.getBoundingClientRect().width,max:QF(i),moved:!1},null===(r=(o=t.currentTarget).setPointerCapture)||void 0===r||r.call(o,t.pointerId))}),S(e,"moveResize",function(t){var n=e.drag;n&&t.pointerId===n.pointerId&&(!n.moved&&Math.abs(t.clientX-n.startX)<3||(n.moved=!0,e.setState({dragged:{id:n.id,width:JF(n,t.clientX)}})))}),S(e,"endResize",function(t){var n=e.drag;if(n&&t.pointerId===n.pointerId){var r,o;if(e.drag=null,n.moved)null===(r=(o=e.props).onResize)||void 0===r||r.call(o,n.id,JF(n,t.clientX));e.clearDragged()}}),S(e,"cancelResize",function(){e.drag=null,e.clearDragged()}),S(e,"clearDragged",function(){return e.setState(function(e){return e.dragged?{dragged:null}:null})}),S(e,"fitTitle",function(t,n){var r,o,i=t.currentTarget.parentElement;i&&(null===(r=(o=e.props).onResize)||void 0===r||r.call(o,n,QF(i)))}),S(e,"renderTab",function(t){var n=e.props,r=n.shownId,o=n.widths,i=n.onSelect,a=n.onClose,u=n.onResize,s=e.state.dragged,l=t.id===r,c=(null==s?void 0:s.id)===t.id,d=c?s.width:null==o?void 0:o[t.id],f="number"==typeof d;return pt.createElement("div",{key:t.id,className:"".concat(Ve,"-tab"),"data-tab":t.id,"data-shown":l?"":void 0,style:f?{flex:"0 0 auto",width:d,maxWidth:"none"}:void 0,onMouseDown:e.onTabMouseDown,onAuxClick:function(n){return e.onTabAuxClick(n,t.id)}},pt.createElement("button",{type:"button",className:"".concat(Ve,"-tab-select"),title:t.title,"aria-current":l?"page":void 0,onClick:function(){return null==i?void 0:i(t.id)}},pt.createElement(R,{name:"file",size:14}),pt.createElement("span",{className:"".concat(Ve,"-tab-title"),"data-tab-title":"","data-capped":f?void 0:""},t.title),t.notSaved?pt.createElement("span",{className:"".concat(Ve,"-sr-only")},KF.notSaved):null),pt.createElement("span",{className:"".concat(Ve,"-tab-end")},pt.createElement("button",{type:"button",className:"".concat(Ve,"-tab-close"),"aria-label":KF.close(t.title),title:KF.closeTitle,onClick:function(){return null==a?void 0:a(t.id)}},pt.createElement(R,{name:"close",size:14})),t.notSaved&&!l?pt.createElement("span",{className:"".concat(Ve,"-tab-dot"),"aria-hidden":"true","data-test":"reports-tab-not-saved"}):null),u?pt.createElement("span",{className:"".concat(Ve,"-tab-resize"),"aria-hidden":"true",title:KF.resize,"data-dragging":c?"":void 0,"data-test":"reports-tab-resize",onPointerDown:function(n){return e.startResize(n,t.id)},onPointerMove:e.moveResize,onPointerUp:e.endResize,onPointerCancel:e.cancelResize,onDoubleClick:function(n){return e.fitTitle(n,t.id)}}):null)}),e}return A(t,e),x(t,[{key:"componentDidMount",value:function(){this.showShownTab()}},{key:"componentDidUpdate",value:function(e){e.shownId===this.props.shownId&&e.tabs.length===this.props.tabs.length||this.showShownTab()}},{key:"render",value:function(){var e=this.props,t=e.tabs,n=e.shownId,r=e.onHome,o=e.onNew,i=e.newDisabled;return pt.createElement("nav",{className:"".concat(Ve,"-tabs"),"aria-label":KF.label,"data-test":"reports-tabs"},pt.createElement("button",{type:"button",className:"".concat(Ve,"-tabs-home"),"aria-label":KF.home,title:KF.home,"aria-current":null===n?"page":void 0,onClick:function(){return null==r?void 0:r()}},pt.createElement(R,{name:"home",size:16})),pt.createElement("div",{ref:this.scrollerRef,className:"".concat(Ve,"-tabs-scroller")},t.map(this.renderTab)),pt.createElement("button",{type:"button",className:"".concat(Ve,"-tabs-new"),disabled:!!i,onClick:function(){return null==o?void 0:o()}},pt.createElement(R,{name:"plus",size:15}),KF.newReport))}}])}(pt.Component);S(GF,"defaultProps",{tabs:[],shownId:null,newDisabled:!1});var XF=xe.saveStatus,ZF=["saved","saving","failed","conflict"],YF=function(e){var t=e.state,n=e.savedAt,r=e.onSave,o=e.onReload,i=ZF.includes(t)?t:"saved",a=function(e,t){switch(e){case"saving":return{icon:pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:14})),label:XF.saving,title:XF.saveNow};case"failed":return{icon:pt.createElement(R,{name:"alert",size:14}),label:XF.failed,title:XF.tryAgain};case"conflict":return{icon:pt.createElement(R,{name:"refresh",size:14}),label:XF.conflict,title:XF.reload};default:return{icon:pt.createElement(R,{name:"check",size:14}),label:XF.saved,title:t?XF.savedAt(t):XF.allSaved}}}(i,function(e){if(!e)return null;var t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}(n)),u=a.icon,s=a.label,l=a.title;return pt.createElement("span",{className:"".concat(Ve,"-save-status"),role:"status","aria-live":"polite"},pt.createElement("button",{type:"button",className:"".concat(Ve,"-save-button"),title:l,"data-state":i,"data-test":"reports-save-status",onClick:function(){return"conflict"===i?null==o?void 0:o():null==r?void 0:r()}},u,s))},eb=xe,tb=eb.tilePicker,nb=[],rb=function(e){return"string"==typeof(null==e?void 0:e.query)&&!!e.query.trim()},ob=function(e,t){var n,r,o,i;return(null!==(n=e.y)&&void 0!==n?n:0)-(null!==(r=t.y)&&void 0!==r?r:0)||(null!==(o=e.x)&&void 0!==o?o:0)-(null!==(i=t.x)&&void 0!==i?i:0)},ib=function(e){var t;return rb(e)?e.displayType&&_e.includes(e.displayType)?{kind:"unavailable",reason:tb.unsupported}:e.queryResponse?Array.isArray(null===(t=e.queryResponse)||void 0===t||null===(t=t.data)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.rows)?{kind:"ready"}:{kind:"unavailable",reason:tb.noData}:{kind:"loading"}:{kind:"unavailable",reason:tb.noQuestion}},ab=function(t){function n(t){var r,i;return M(this,n),i=N(this,n,[t]),S(i,"attachDashboard",function(e){i.dashboardRef=e}),S(i,"onDashboardChange",function(t,n){var r,o;!i.unmounted&&Array.isArray(n)&&(i.setState(function(r){var o=r.tilesById;return{tilesById:e(e({},o),{},S({},String(t.id),n))}}),null===(r=(o=i.props).onTilesChange)||void 0===r||r.call(o,t.id,n))}),S(i,"choose",function(e){return i.setState({chosenId:e,ticked:new Set,touched:!1,error:null})}),S(i,"toggle",function(e){return i.setState(function(t,n){var r=new Set(i.view(n,t).ticked);return r.has(e)?r.delete(e):r.add(e),{ticked:r,touched:!0,error:null}})}),S(i,"add",function(){var t=i.props,n=t.report,r=t.onAdd,a=i.view(),u=a.dashboard,s=a.chosenKeys,l=i.dashboardRef;if(l&&u&&s.length){var c=Ke(l,s,u),d=c.filter(function(e){return!e.result.ok});if(d.length)i.setState({error:d.map(function(e){return tb.tileFailed(e.title||tb.untitledTile,e.result.message)}).join(" ")});else{var f,h=c.map(function(e){return Be(e.result.block)}),p=Array.isArray(null==n?void 0:n.blocks)?n.blocks:[],v=Je(e(e({},n),{},{blocks:[].concat(o(p),o(h))}));if(v>Qe)i.setState({error:tb.tooLarge((f=v,(f/1048576).toFixed(1)))});else r(h,u)}}}),i.selectRef=pt.createRef(),i.dashboardRef=null,i.state={chosenId:null!==(r=t.initialDashboardId)&&void 0!==r?r:null,tilesById:{},ticked:new Set,touched:!1,error:null},i}return A(n,t),x(n,[{key:"componentDidMount",value:function(){this.runAnswers()}},{key:"componentDidUpdate",value:function(){this.runAnswers()}},{key:"componentWillUnmount",value:function(){this.unmounted=!0}},{key:"view",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state,o=(e=n.dashboards,t=r.chosenId,Array.isArray(e)&&(null!=t&&e.find(function(e){return e&&String(e.id)===String(t)})||e[0])||null),i=(o?r.tilesById[String(o.id)]:void 0)||(Array.isArray(null==o?void 0:o.tiles)?o.tiles:nb),a=i.filter(function(e){return!!e&&"object"===k(e)}).sort(ob).map(function(e){return{tile:e,key:ie(e),status:ib(e)}}),u=a.filter(function(e){return"ready"===e.status.kind}).map(function(e){return e.key}),s="start"!==n.mode||r.touched?r.ticked:new Set(u);return{dashboard:o,tiles:i,listed:a,ticked:s,chosenKeys:u.filter(function(e){return s.has(e)}),loadingCount:a.filter(function(e){return"loading"===e.status.kind}).length}}},{key:"runAnswers",value:function(){var e=this.dashboardRef;if(e&&e!==this.answeredBy&&(this.answeredBy=e,this.view().tiles.some(function(e){return rb(e)&&!e.queryResponse})))try{var t,n;null===(t=e.executeCachedDashboard)||void 0===t||null===(t=t.call(e))||void 0===t||null===(n=t.catch)||void 0===n||n.call(t,function(){})}catch(e){}}},{key:"renderPicker",value:function(e){var t=this,n=this.props.dashboards;return!Array.isArray(n)||n.length<2?null:pt.createElement("label",{className:"".concat(Ve,"-tile-picker-dashboard")},tb.dashboard,pt.createElement(Rn,{prefix:Ve,inline:!0},pt.createElement("select",{ref:this.selectRef,className:"".concat(Ve,"-select"),value:e?String(e.id):"","data-test":"reports-tile-picker-dashboard",onChange:function(e){return t.choose(e.target.value)}},n.filter(Boolean).map(function(e){return pt.createElement("option",{key:e.id,value:String(e.id)},e.name||eb.untitledDashboard)}))))}},{key:"renderDashboard",value:function(e,t){var n,r=this,o=this.props,i=o.authentication,a=o.autoQLConfig,u=o.dataFormatting,s=o.dashboards;return Array.isArray(s)?e?pt.createElement("div",{className:"".concat(Ve,"-tile-picker-board")},pt.createElement(Ue,{key:String(e.id),ref:this.attachDashboard,authentication:i,autoQLConfig:a,dataFormatting:u,dashboardId:String(e.id),title:null!==(n=e.name)&&void 0!==n?n:"",tiles:t,enableSlicers:!1,enableAutoRefresh:!0,executeOnMount:!1,executeOnStopEditing:!1,isEditable:!1,isEditing:!1,isProjectDashboard:"PROJECT"===e.type,showToolbar:!1,enableDynamicCharting:!0,preferRegularTableInitialDisplayType:!0,enableMagicWand:!1,onChange:function(t){return r.onDashboardChange(e,t)}})):pt.createElement("div",{className:"".concat(Ve,"-message")},pt.createElement("p",null,eb.noDashboards)):pt.createElement("div",{className:"".concat(Ve,"-message")},pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:20})),pt.createElement("p",null,eb.loadingDashboards))}},{key:"renderTiles",value:function(e,t,n){var r=this;return t.length?pt.createElement("ul",{className:"".concat(Ve,"-tile-picker-tiles")},t.map(function(e,t){var o=e.tile,i=e.key,a=e.status,u="ready"!==a.kind,s=function(e){return e.title||e.query||tb.untitledTile}(o);return pt.createElement("li",{key:null!=i?i:"tile-".concat(t)},pt.createElement("label",{className:"".concat(Ve,"-tile-picker-tile"),"data-disabled":u||void 0},pt.createElement("input",{type:"checkbox",checked:!u&&n.has(i),disabled:u,"data-test":"reports-tile-picker-tile-".concat(i),onChange:function(){return r.toggle(i)}}),pt.createElement("span",{className:"".concat(Ve,"-tile-picker-text")},pt.createElement("span",{className:"".concat(Ve,"-tile-picker-name"),title:s},s),u?pt.createElement("span",{className:"".concat(Ve,"-tile-picker-why")},"loading"===a.kind?tb.loading:a.reason):null)))})):e?pt.createElement("p",{className:"".concat(Ve,"-tile-picker-empty")},tb.noTiles):null}},{key:"render",value:function(){var e=this.props,t=e.mode,n=e.onClose,r=this.state.error,o=this.view(),i=o.dashboard,a=o.tiles,u=o.listed,s=o.ticked,l=o.chosenKeys,c=o.loadingCount,d="start"===t,f=this.renderPicker(i),h=null;return r?h=pt.createElement("span",{className:"".concat(Ve,"-error")},pt.createElement(R,{name:"alert",size:14}),r):c&&(h=tb.stillLoading(c)),pt.createElement(We,{title:d?tb.titleStart:tb.titleAdd,description:d?tb.whatStart:tb.whatAdd,size:"large",headerExtra:f,status:h,statusTone:r?"error":void 0,initialFocus:f?this.selectRef:void 0,testId:"reports-tile-picker",onClose:n,actions:pt.createElement(pt.Fragment,null,pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),"data-test":"reports-tile-picker-cancel",onClick:n},eb.cancel),pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),"data-variant":"primary","data-test":"reports-tile-picker-add",disabled:!l.length,onClick:this.add},tb.add(l.length)))},pt.createElement("div",{className:"".concat(Ve,"-tile-picker-main")},this.renderDashboard(i,a)),pt.createElement("aside",{className:"".concat(Ve,"-tile-picker-aside")},pt.createElement("h3",{className:"".concat(Ve,"-label ").concat(Ve,"-tile-picker-heading")},tb.tiles),this.renderTiles(i,u,s)))}}])}(pt.Component);S(ab,"defaultProps",{dashboards:null,mode:"add",initialDashboardId:null});var ub=xe,sb=ub.newReport,lb=function(e){return Array.from(e).slice(0,ze).join("")},cb=0,db=function(e){function t(e){var n;return M(this,t),n=N(this,t,[e]),S(n,"choose",function(e){return n.setState({mode:e,error:null})}),S(n,"create",z($().m(function e(){var t,r,o,i,a,u,s,l;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n.canCreate()){e.n=1;break}return e.a(2);case 1:if(t=n.state.mode,n.setState({error:null}),"blank"!==t){e.n=2;break}return n.props.onStart({title:"",blocks:[]}),e.a(2);case 2:if("dashboard"!==t){e.n=3;break}return n.setState({pickingTiles:!0}),e.a(2);case 3:return r=n.state.question.trim(),o="function"==typeof AbortController?new AbortController:null,n.inFlight=o,n.setState({asking:!0}),e.p=4,e.n=5,ye({query:r,authentication:n.props.authentication,autoQLConfig:n.props.autoQLConfig,signal:null==o?void 0:o.signal});case 5:i=e.v,e.n=7;break;case 6:e.p=6,l=e.v,i={ok:!1,reason:"error",error:l};case 7:if(n.mounted&&(null==o||!o.signal.aborted)){e.n=8;break}return e.a(2);case 8:if(n.inFlight=null,i.ok){e.n=9;break}return a=null,"cancelled"!==i.reason&&(s=sb.failed[i.reason]||sb.failed.error,a=null!==(u=i.error)&&void 0!==u&&u.message?"".concat(s," ").concat(i.error.message):s),n.setState({asking:!1,error:a}),e.a(2);case 9:n.setState({asking:!1}),n.props.onStart({title:lb(r),blocks:[{id:Ge(),type:"data",width:"full",rows:i.rows,source:{type:"query",query:r},capture:i.capture,askedHere:!0}]});case 10:return e.a(2)}},e,null,[[4,6]])}))),S(n,"onQuestionKeyDown",function(e){var t;"Enter"!==e.key||null!==(t=e.nativeEvent)&&void 0!==t&&t.isComposing||(e.preventDefault(),n.create())}),S(n,"closeTiles",function(){return n.setState({pickingTiles:!1})}),S(n,"startFromTiles",function(e,t){var r;return n.props.onStart({title:lb(String(null!==(r=null==t?void 0:t.name)&&void 0!==r?r:"")),blocks:e})}),cb+=1,n.radioName="".concat(Ve,"-new-report-").concat(cb),n.questionRef=pt.createRef(),n.dashboardSelectRef=pt.createRef(),n.inFlight=null,n.emptyReport=Xe(),n.state={mode:"question",question:"",dashboardId:null,asking:!1,error:null,pickingTiles:!1},n}return A(t,e),x(t,[{key:"componentDidMount",value:function(){this.mounted=!0}},{key:"componentDidUpdate",value:function(e,t){var n;"question"===this.state.mode&&"question"!==t.mode&&(null===(n=this.questionRef.current)||void 0===n||n.focus())}},{key:"componentWillUnmount",value:function(){var e;this.mounted=!1,null===(e=this.inFlight)||void 0===e||e.abort(),this.inFlight=null}},{key:"dashboard",value:function(){var e=this.props.dashboards;if(!Array.isArray(e))return null;var t=this.state.dashboardId;return null!=t&&e.find(function(e){return e&&String(e.id)===String(t)})||e[0]||null}},{key:"canCreate",value:function(){var e=this.state,t=e.mode,n=e.question;return!e.asking&&("blank"===t||("question"===t?!!n.trim():!!this.dashboard()))}},{key:"renderChoice",value:function(e,t,n,r){var o=this,i=this.state.mode===e;return pt.createElement("li",{className:"".concat(Ve,"-choice"),"data-checked":i||void 0},pt.createElement("label",{className:"".concat(Ve,"-choice-row")},pt.createElement("input",{type:"radio",name:this.radioName,value:e,checked:i,"data-test":"reports-new-report-".concat(e),onChange:function(){return o.choose(e)}}),pt.createElement(R,{name:t}),pt.createElement("span",{className:"".concat(Ve,"-choice-name")},n)),i&&r?pt.createElement("div",{className:"".concat(Ve,"-choice-more")},r):null)}},{key:"renderQuestion",value:function(){var e=this,t=this.state,n=t.question,r=t.asking;return pt.createElement(pt.Fragment,null,pt.createElement("input",{ref:this.questionRef,type:"text",className:"".concat(Ve,"-input"),value:n,disabled:r,placeholder:sb.questionPlaceholder,"aria-label":sb.questionLabel,"data-test":"reports-new-report-question-input",onChange:function(t){return e.setState({question:t.target.value,error:null})},onKeyDown:this.onQuestionKeyDown}),pt.createElement("p",{className:"".concat(Ve,"-note")},sb.questionNote))}},{key:"renderDashboards",value:function(){var e=this,t=this.props.dashboards;if(!Array.isArray(t))return pt.createElement("p",{className:"".concat(Ve,"-new-report-wait")},pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:14})),ub.loadingDashboards);if(!t.length)return pt.createElement("p",{className:"".concat(Ve,"-new-report-wait")},ub.noDashboards);var n=this.dashboard();return pt.createElement(Rn,{prefix:Ve},pt.createElement("select",{ref:this.dashboardSelectRef,className:"".concat(Ve,"-select"),value:n?String(n.id):"","aria-label":sb.dashboardLabel,"data-test":"reports-new-report-dashboard-select",onChange:function(t){return e.setState({dashboardId:t.target.value})}},t.filter(Boolean).map(function(e){return pt.createElement("option",{key:e.id,value:String(e.id)},sb.dashboardOption(e.name||ub.untitledDashboard,function(e){return Array.isArray(null==e?void 0:e.tiles)?e.tiles.length:0}(e)))})))}},{key:"render",value:function(){var e=this.props,t=e.authentication,n=e.autoQLConfig,r=e.dataFormatting,o=e.dashboards,i=e.onClose,a=e.onTilesChange,u=this.state,s=u.mode,l=u.asking,c=u.error,d=u.pickingTiles,f=this.dashboard();if(d&&f)return pt.createElement(ab,{authentication:t,autoQLConfig:n,dataFormatting:r,dashboards:o,initialDashboardId:f.id,mode:"start",report:this.emptyReport,onClose:this.closeTiles,onAdd:this.startFromTiles,onTilesChange:a});var h="dashboard"===s?sb.chooseTiles:sb.create;return l&&(h=pt.createElement(pt.Fragment,null,pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:14})),sb.asking)),pt.createElement(We,{title:sb.title,description:void 0===o?sb.whatWithoutDashboards:sb.what,size:"small",initialFocus:"dashboard"===s?this.dashboardSelectRef:this.questionRef,testId:"reports-new-report",onClose:i,actions:pt.createElement(pt.Fragment,null,pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),"data-test":"reports-new-report-cancel",onClick:i},ub.cancel),pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),"data-variant":"primary","data-test":"reports-new-report-create",disabled:!this.canCreate(),onClick:this.create},h))},pt.createElement("ul",{className:"".concat(Ve,"-choices"),role:"radiogroup","aria-label":sb.startFrom},this.renderChoice("question","question",sb.question,this.renderQuestion()),void 0!==o?this.renderChoice("dashboard","dashboard",sb.dashboard,this.renderDashboards()):null,this.renderChoice("blank","file",sb.blank)),c?pt.createElement("p",{className:"".concat(Ve,"-error ").concat(Ve,"-new-report-error"),role:"alert"},pt.createElement(R,{name:"alert",size:14}),c):null)}}])}(pt.Component),fb=["created"],hb=xe,pb=[],vb=new Set,mb=function(e,t){if(null!=t&&""!==t)return String(t);try{var n,r=null!=e&&e.token?null===(n=St(e.token))||void 0===n?void 0:n.project_id:void 0;return null==r?"":String(r)}catch(e){return""}},gb=function(e,t){var n=new Set(e);return n.delete(t),n},Db=function(){var e=z($().m(function e(t){var n,r,i,a,u,s,l,c;return $().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ft({authentication:t,pageSize:ht});case 1:for(r=e.v,i=[],a=2;a<=Math.min(r.totalPages||1,25);a+=1)i.push(ft({authentication:t,page:a,pageSize:ht}).catch(function(e){return{error:e}}));return l=[r],c=o,e.n=2,Promise.all(i);case 2:return u=l.concat.call(l,c(e.v)),s=new Set,e.a(2,{reports:u.flatMap(function(e){return e.reports||[]}).filter(function(e){return!s.has(e.id)&&s.add(e.id)}),missing:(null===(n=u.find(function(e){return e.error}))||void 0===n?void 0:n.error)||null})}},e)}));return function(t){return e.apply(this,arguments)}}(),yb=function(t,n){var r=n.id,i=n.title,a=n.sizeBytes,u=n.version,s=n.folderId,l=n.tagIds,c=n.createdAt,d=n.updatedAt;return t.some(function(e){return e.id===r})?t.map(function(t){return t.id===r?e(e({},t),{},{title:i}):t}):[].concat(o(t),[{id:r,title:i,sizeBytes:a,version:u,folderId:s,tagIds:l,createdAt:c,updatedAt:d}])},kb=function(e){return o(e).sort(function(e,t){return e.name.localeCompare(t.name,void 0,{sensitivity:"base",numeric:!0})})},Eb=function(e,t){return(e||[]).find(function(e){return e.name.toLowerCase()===t.toLowerCase()})||null},Fb=function(e){return e.created,r(e,fb)},bb=function(e,t){var n=new Error(Re(e,t).message);return n.code=null==e?void 0:e.code,n.status=null==e?void 0:e.status,n},Cb=function(e){return"string"==typeof e?e.trim():""},wb=function(){return new $e({status:422,code:"REPORT_NAME_INVALID"})},Ab=function(e){return!e||Array.from(e).length>80},xb=function(e){var t,n=e.reports,r=e.listError,o=e.retryList,i=e.openReport,a=e.notices;return t=null===n?pt.createElement("div",{className:"".concat(Ve,"-message")},pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:20})),pt.createElement("p",null,hb.loadingReports)):r&&!n.length?pt.createElement("div",{className:"".concat(Ve,"-message"),"data-tone":"error"},pt.createElement(R,{name:"alert",size:20}),pt.createElement("p",{role:"alert"},r),pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),onClick:o},hb.tryAgain)):n.length?pt.createElement("ul",{className:"".concat(Ve,"-home-items")},n.map(function(e){return pt.createElement("li",{key:e.id},pt.createElement("button",{type:"button",className:"".concat(Ve,"-home-item"),onClick:function(){return i(e.id)}},pt.createElement(R,{name:"file"}),pt.createElement("span",{className:"".concat(Ve,"-home-name")},nt(e)),pt.createElement("span",{className:"".concat(Ve,"-home-edited")},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date,n=new Date(e);if(Number.isNaN(n.getTime()))return"";var r=Math.floor((t.getTime()-n.getTime())/6e4);return r<60?r<1?hb.workspace.justNow:hb.workspace.minutesAgo(r):n.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"})}(e.updatedAt))))})):pt.createElement("div",{className:"".concat(Ve,"-message")},pt.createElement("p",null,hb.workspace.noReports)),pt.createElement("div",{className:"".concat(Ve,"-home-list"),"data-test":"reports-home"},pt.createElement("h2",{className:"".concat(Ve,"-home-title")},hb.workspace.homeLabel),a.map(function(e){return pt.createElement("p",{key:e.text,className:"error"===e.tone?"".concat(Ve,"-error"):"".concat(Ve,"-note"),role:"status"},e.text)}),t)},Sb=function(t){function n(t){var r;return M(this,n),r=N(this,n,[t]),S(r,"flushAll",function(e){return Promise.all(o(r.savers.values()).map(function(t){return t.flush(e)}))}),S(r,"hasUnsavedChanges",function(){return o(r.savers.values()).some(function(e){return e.hasUnsaved})}),S(r,"saveNow",function(){var e,t=r.shownId;t&&(null===(e=r.savers.get(t))||void 0===e||e.flush())}),S(r,"reload",function(){return r.resetList()}),S(r,"storagePrefix",function(){return void 0===r.props.storageKeyPrefix?Ze:r.props.storageKeyPrefix}),S(r,"credentialsFor",function(e){return r.credentials.get(e)}),S(r,"switchSource",function(e){r.flushAll(),r.sourceId=e,r.resetList()}),S(r,"resetList",function(){r.tabsSource=null,r.tabs=[],r.setState({reports:null,listError:null,listMissing:null,notice:null,actionError:null,tabs:[],tabWidths:{},folders:null,tags:null,organizersError:null}),r.select(null),r.loadList(),r.loadOrganizers()}),S(r,"loadList",function(){var e=r.sourceId;r.listRequest+=1;var t=r.listRequest;Db(r.credentialsFor(e)).then(function(n){var o=n.reports,i=n.missing;if(r.mounted&&t===r.listRequest){r.unauthorizedSaid=!1,i&&r.unauthorized(i);var a=r.storagePrefix(),u=new Set(o.map(function(e){return e.id})),s=function(e){return!!i||u.has(e)},l=function(e,t){var n=HF(qF(e,je))[jF(t)];if(!Array.isArray(n))return[];var r=n.filter(function(e){return"string"==typeof e&&e.length>0});return Array.from(new Set(r)).slice(-30)}(a,e).filter(s),c=r.props.shownReportId,d=c&&s(c)?c:null,f=d?_F(l,d):l;r.tabsSource=e,r.tabs=f,r.shownId=d,r.setState({reports:o,listError:null,listMissing:i?Re(i,"loadSome").message:null,tabs:f,tabWidths:WF(UF(a,e),f),shownId:d}),r.loadShown()}},function(e){r.mounted&&t===r.listRequest&&(r.unauthorized(e),r.setState({reports:[],listError:Re(e,"load").message}))})}),S(r,"loadOrganizers",function(){var e=r.sourceId,t=r.credentialsFor(e);r.organizersRequest+=1;var n=r.organizersRequest,o=function(){return r.mounted&&n===r.organizersRequest};r.setState({organizersError:null}),Promise.all([Ye({authentication:t}),et({authentication:t})]).then(function(e){var t=i(e,2),n=t[0],a=t[1];o()&&r.setState({folders:kb(n),tags:kb(a),organizersError:null})},function(e){o()&&(r.unauthorized(e),r.setState({folders:[],tags:[],organizersError:Re(e,"organizers").message}))})}),S(r,"stillOn",function(e){return r.mounted&&e===r.sourceId}),S(r,"placeReports",function(e){return r.setState(function(t){var n=t.reports;return n?{reports:n.map(function(t){return e(t)||t})}:null})}),S(r,"createFolder",function(){var e=z($().m(function e(t){return $().w(function(e){for(;;)if(0===e.n)return e.a(2,r.makeOrganizer("folder",t))},e)}));return function(t){return e.apply(this,arguments)}}()),S(r,"createTag",function(){var e=z($().m(function e(t,n){return $().w(function(e){for(;;)if(0===e.n)return e.a(2,r.makeOrganizer("tag",t,n))},e)}));return function(t,n){return e.apply(this,arguments)}}()),S(r,"makeOrganizer",function(){var e=z($().m(function e(t,n,i){var a,u,s,l,c,d,f,h,p,v,m,g,D;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a="folder"===t?"folders":"tags",u=Cb(n),!Ab(u)){e.n=1;break}throw bb(wb(),t);case 1:if(!(s=Eb(r.state[a],u))){e.n=2;break}return e.a(2,s);case 2:if(l=r.sourceId,c=r.credentialsFor(l),d=function(e){return r.stillOn(l)&&r.setState(function(t){return S({},a,kb([].concat(o((t[a]||[]).filter(function(t){return t.id!==e.id})),[e])))}),e},e.p=3,"folder"!==t){e.n=5;break}return e.n=4,it({authentication:c,id:Ge(),name:u});case 4:g=e.v,e.n=7;break;case 5:return e.n=6,ot({authentication:c,id:Ge(),name:u,color:i});case 6:g=e.v;case 7:return f=g,e.a(2,d(Fb(f)));case 8:if(e.p=8,D=e.v,p="folder"===t?"REPORT_FOLDER_NAME_TAKEN":"REPORT_TAG_NAME_TAKEN",(null==D?void 0:D.code)!==p||null===(h=D.details)||void 0===h||!h.id){e.n=10;break}return e.n=9,("folder"===t?Ye:et)({authentication:c}).catch(function(){return[]});case 9:if(v=e.v,!(m=v.find(function(e){return e.id===D.details.id}))){e.n=10;break}return e.a(2,d(m));case 10:throw r.unauthorized(D),bb(D,t);case 11:return e.a(2)}},e,null,[[3,8]])}));return function(t,n,r){return e.apply(this,arguments)}}()),S(r,"renameFolder",function(){var e=z($().m(function e(t,n){var o,i,a,u;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=Cb(n),!Ab(o)){e.n=1;break}throw bb(wb(),"folder");case 1:return i=r.sourceId,e.p=2,e.n=3,at({authentication:r.credentialsFor(i),id:t,name:o});case 3:return a=e.v,r.stillOn(i)&&r.setState(function(e){var n=e.folders;return{folders:kb((n||[]).map(function(e){return e.id===t?a:e}))}}),e.a(2,a);case 4:throw e.p=4,u=e.v,r.unauthorized(u),bb(u,"folder");case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t,n){return e.apply(this,arguments)}}()),S(r,"updateTag",function(){var e=z($().m(function e(t){var n,o,i,a,u,s,l,c=arguments;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=(n=c.length>1&&void 0!==c[1]?c[1]:{}).name,i=n.color,void 0===(a=void 0===o?void 0:Cb(o))||!Ab(a)){e.n=1;break}throw bb(wb(),"tag");case 1:return u=r.sourceId,e.p=2,e.n=3,ut({authentication:r.credentialsFor(u),id:t,name:a,color:i});case 3:return s=e.v,r.stillOn(u)&&r.setState(function(e){var n=e.tags;return{tags:kb((n||[]).map(function(e){return e.id===t?s:e}))}}),e.a(2,s);case 4:throw e.p=4,l=e.v,r.unauthorized(l),bb(l,"tag");case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}()),S(r,"deleteFolder",function(){var t=z($().m(function t(n){var o,i;return $().w(function(t){for(;;)switch(t.p=t.n){case 0:return o=r.sourceId,t.p=1,t.n=2,st({authentication:r.credentialsFor(o),id:n});case 2:t.n=4;break;case 3:if(t.p=3,"REPORT_FOLDER_NOT_FOUND"===(null==(i=t.v)?void 0:i.code)){t.n=4;break}throw r.unauthorized(i),bb(i,"deleteFolder");case 4:r.stillOn(o)&&(r.setState(function(e){return{folders:(e.folders||[]).filter(function(e){return e.id!==n})}}),r.placeReports(function(t){return t.folderId===n?e(e({},t),{},{folderId:null}):null}));case 5:return t.a(2)}},t,null,[[1,3]])}));return function(e){return t.apply(this,arguments)}}()),S(r,"deleteTag",function(){var t=z($().m(function t(n){var o,i;return $().w(function(t){for(;;)switch(t.p=t.n){case 0:return o=r.sourceId,t.p=1,t.n=2,lt({authentication:r.credentialsFor(o),id:n});case 2:t.n=4;break;case 3:if(t.p=3,"REPORT_TAG_NOT_FOUND"===(null==(i=t.v)?void 0:i.code)){t.n=4;break}throw r.unauthorized(i),bb(i,"deleteTag");case 4:r.stillOn(o)&&(r.setState(function(e){return{tags:(e.tags||[]).filter(function(e){return e.id!==n})}}),r.placeReports(function(t){var r;return null!==(r=t.tagIds)&&void 0!==r&&r.includes(n)?e(e({},t),{},{tagIds:t.tagIds.filter(function(e){return e!==n})}):null}));case 5:return t.a(2)}},t,null,[[1,3]])}));return function(e){return t.apply(this,arguments)}}()),S(r,"organizeReports",function(){var t=z($().m(function t(n){var o,i,a,u,s,l,c,d;return $().w(function(t){for(;;)switch(t.p=t.n){case 0:return o=n.reportIds,i=n.folderId,a=n.addTagIds,u=n.removeTagIds,s=r.sourceId,t.p=1,t.n=2,ct({authentication:r.credentialsFor(s),reportIds:o,folderId:i,addTagIds:a,removeTagIds:u});case 2:return l=t.v,r.stillOn(s)&&(c=new Map(l.map(function(e){return[e.id,e]})),r.placeReports(function(t){var n=c.get(t.id);return n?e(e({},t),{},{folderId:n.folderId,tagIds:n.tagIds}):null})),t.a(2,l);case 3:throw t.p=3,d=t.v,r.unauthorized(d),bb(d,"organize");case 4:return t.a(2)}},t,null,[[1,3]])}));return function(e){return t.apply(this,arguments)}}()),S(r,"credentialsRenewed",function(e){r.savers.forEach(function(t,n){r.saverSources.get(n)===e&&t.retry()}),r.state.listError||r.state.listMissing?r.resetList():(r.state.openError&&r.loadShown(),r.state.organizersError&&r.loadOrganizers())}),S(r,"askForCredentials",function(){var e,t;r.unauthorizedSaid||(r.unauthorizedSaid=!0,null===(e=(t=r.props).onUnauthorized)||void 0===e||e.call(t))}),S(r,"unauthorized",function(e){Oe(e)&&r.askForCredentials()}),S(r,"makeSaver",function(e,t,n,i){var a,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;null===(a=r.savers.get(e))||void 0===a||a.dispose();var s=new zF({id:e,folderId:u,stored:i,report:n,delayMs:r.props.saveDelay,getAuthentication:function(){return r.credentialsFor(t)},onState:function(t){return r.onSaverState(e,t)},onMerged:function(t,n){if(r.mounted&&r.shownId===e){var i,a=(null===(i=r.unshownMerge)||void 0===i?void 0:i.id)===e?r.unshownMerge.blocks:[];r.unshownMerge={id:e,blocks:[].concat(o(a),o(n))},r.setState({opened:{id:e,report:t}})}},onUnauthorized:r.askForCredentials});return r.savers.set(e,s),r.saverSources.set(e,t),r.onSaverState(e,s.current),s}),S(r,"onSaverState",function(t,n){if(r.mounted){"saved"===n.status&&(r.unauthorizedSaid=!1);var o="failed"===n.status||"conflict"===n.status,i=n.savedAt;r.setState(function(a){var u=a.notSaved,s=a.reports,l={};r.shownId===t&&(l.saveState=n),u.has(t)!==o&&(l.notSaved=o?new Set(u).add(t):gb(u,t));var c,d,f,h=i&&s?s.find(function(e){return e.id===t}):null;return h&&(c=i,d=h.updatedAt,f=Date.parse(c),!Number.isNaN(f)&&f>(Date.parse(d)||0))&&(l.reports=s.map(function(n){return n.id===t?e(e({},n),{},{updatedAt:i}):n})),Object.keys(l).length?l:null})}}),S(r,"onPageHide",function(){r.savers.forEach(function(e){return e.leave()})}),S(r,"onVisibilityChange",function(){"hidden"===document.visibilityState&&r.flushAll()}),S(r,"onBeforeUnload",function(e){var t=o(r.savers.values()).filter(function(e){return e.hasUnsaved});t.length&&(t.forEach(function(e){return e.flush({keepalive:!0})}),e.preventDefault(),e.returnValue="")}),S(r,"onKeyDown",function(e){var t,n;if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&"s"===String(e.key).toLowerCase()&&!e.defaultPrevented&&r.shownId){var o=e.target;(o===window||o===document.body||o===document.documentElement||!(null===(t=r.root.current)||void 0===t||!t.contains(o))||!(null==o||null===(n=o.closest)||void 0===n||!n.call(o,".".concat(Ve,"-layer"))))&&(e.preventDefault(),r.saveNow())}}),S(r,"setTabs",function(e){var t=e(r.tabs);t!==r.tabs&&(r.tabs=t,r.setState(function(e){var n=e.tabWidths;return{tabs:t,tabWidths:WF(n,t)}}))}),S(r,"select",function(e){r.shownId=e,r.setState({shownId:e}),r.loadShown()}),S(r,"loadShown",function(){var t=r.shownId;r.openRequest+=1;var n=r.openRequest,o={openError:null,actionError:null};if(t){var i=r.savers.get(t);if(null!=i&&i.hasUnsaved)r.setState(e(e({},o),{},{opened:{id:t,report:i.report},saveState:i.current}));else{r.setState(e(e({},o),{},{opened:null,saveState:null}));var a=r.sourceId;Ne({authentication:r.credentialsFor(a),id:t}).then(function(e){if(r.mounted&&n===r.openRequest){r.unauthorizedSaid=!1;var o={report:e.report,version:e.version,updatedAt:e.updatedAt},i=r.makeSaver(t,a,e.report,o);r.setState(function(n){var r=n.reports;return{opened:{id:t,report:e.report},saveState:i.current,reports:r&&yb(r,e)}})}},function(e){if(r.mounted&&n===r.openRequest){if(tt(e)){var o,i=nt(null===(o=r.state.reports)||void 0===o?void 0:o.find(function(e){return e.id===t}));return r.forget(t),r.setState({notice:hb.workspace.deletedElsewhere(i)}),void r.select(null)}r.unauthorized(e),r.setState({openError:Re(e,"open").message})}})}}else r.setState(e(e({},o),{},{opened:null,saveState:null}))}),S(r,"openReport",function(e){r.setTabs(function(t){return _F(t,e)}),r.shownId!==e&&(r.saveNow(),r.setState({notice:null}),r.select(e))}),S(r,"goHome",function(){null!==r.shownId&&(r.saveNow(),r.select(null))}),S(r,"closeTab",function(e){var t;null===(t=r.savers.get(e))||void 0===t||t.flush();var n=function(e,t,n){var r,o,i=e.indexOf(t);if(-1===i)return{tabs:e,shown:n};var a=e.filter(function(e){return e!==t});return n!==t?{tabs:a,shown:n}:{tabs:a,shown:null!==(r=null!==(o=a[i])&&void 0!==o?o:a[i-1])&&void 0!==r?r:null}}(r.tabs,e,r.shownId),o=n.tabs,i=n.shown;r.setTabs(function(){return o}),i!==r.shownId&&r.select(i)}),S(r,"resizeTab",function(t,n){r.setState(function(r){var o=r.tabWidths;return o[t]===n?null:{tabWidths:e(e({},o),{},S({},t,n))}})}),S(r,"forget",function(e){var t;null===(t=r.savers.get(e))||void 0===t||t.dispose(),r.savers.delete(e),r.saverSources.delete(e),r.setTabs(function(t){return t.includes(e)?t.filter(function(t){return t!==e}):t}),r.setState(function(t){var n=t.reports,r=t.notSaved;return{reports:n?n.filter(function(t){return t.id!==e}):n,notSaved:r.has(e)?gb(r,e):r}})}),S(r,"activeReport",function(){var e=r.state,t=e.opened,n=e.shownId;return t&&t.id===n?t:null}),S(r,"handleChange",function(t){var n,o=r.shownId;if(o){var i,a=(null===(n=r.unshownMerge)||void 0===n?void 0:n.id)===o?r.unshownMerge.blocks:null,u=a?qe(t,a):t,s="string"==typeof(null==u?void 0:u.title)?u.title:"";if(r.setState(function(t){var n=t.opened,r=t.reports;return{opened:(null==n?void 0:n.id)===o?{id:o,report:u}:n,reports:r?r.map(function(t){return t.id===o?e(e({},t),{},{title:s}):t}):r}}),!rt(u))null===(i=r.savers.get(o))||void 0===i||i.edit(u)}}),S(r,"newReportFolder",function(){var e,t=r.props.newReportFolderId;return t&&null!==(e=r.state.folders)&&void 0!==e&&e.some(function(e){return e.id===t})?t:null}),S(r,"startReport",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.title,n=void 0===t?"":t,i=e.blocks,a=void 0===i?[]:i;if(null!==r.state.reports){r.saveNow();var u=Ge(),s=Xe({title:n,blocks:Be(a)}),l=r.newReportFolder(),c=r.makeSaver(u,r.sourceId,s,null,l),d=(new Date).toISOString(),f={id:u,title:n,sizeBytes:0,version:0,folderId:l,tagIds:[],createdAt:d,updatedAt:d};r.setState(function(e){var t=e.reports;return{newReportOpen:!1,notice:null,reports:[f].concat(o(t||[]))}}),c.flush(),r.setTabs(function(e){return _F(e,u)}),r.select(u)}}),S(r,"deleteReport",function(){var e=z($().m(function e(t){var n,o,i,a;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:return r.setState({deletingId:t,actionError:null,notice:null}),n=r.savers.get(t),e.p=1,e.n=2,null==n?void 0:n.settle();case 2:if(n&&!n.created){e.n=3;break}return i=null!==(o=r.saverSources.get(t))&&void 0!==o?o:r.sourceId,e.n=3,dt({authentication:r.credentialsFor(i),id:t});case 3:if(r.mounted){e.n=4;break}return e.a(2,!0);case 4:return r.forget(t),r.shownId===t&&r.select(null),e.a(2,!0);case 5:return e.p=5,a=e.v,r.mounted&&(r.unauthorized(a),r.setState({actionError:Re(a,"delete").message})),null==n||n.flush(),e.a(2,!1);case 6:return e.p=6,r.mounted&&r.setState({deletingId:null}),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])}));return function(t){return e.apply(this,arguments)}}()),S(r,"deleteReports",function(){var e=z($().m(function e(t){var n,o,i,a,u,s;return $().w(function(e){for(;;)switch(e.p=e.n){case 0:n=!0,o=j(t),e.p=1,o.s();case 2:if((i=o.n()).done){e.n=6;break}return a=i.value,e.n=3,r.deleteReport(a);case 3:if(!(u=e.v)){e.n=4;break}u=n;case 4:n=u;case 5:e.n=2;break;case 6:e.n=8;break;case 7:e.p=7,s=e.v,o.e(s);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,n)}},e,null,[[1,7,8,9]])}));return function(t){return e.apply(this,arguments)}}()),S(r,"reloadShown",function(){var e,t=r.shownId;t&&(null===(e=r.savers.get(t))||void 0===e||e.dispose(),r.savers.delete(t),r.saverSources.delete(t),r.setState({notice:null}),r.loadShown())}),S(r,"pickDashboardTiles",function(){return new Promise(function(e){var t,n=r.shownId;n?(null===(t=r.state.tilePicker)||void 0===t||t.resolve(null),r.setState({tilePicker:{reportId:n,resolve:e}})):e(null)})}),S(r,"closeTilePicker",function(e){var t;null===(t=r.state.tilePicker)||void 0===t||t.resolve(e),r.setState({tilePicker:null})}),S(r,"openNewReport",function(){return r.setState({newReportOpen:!0})}),S(r,"closeNewReport",function(){return r.setState({newReportOpen:!1})}),S(r,"retryOpen",function(){return r.loadShown()}),S(r,"renderHome",function(){var e=r.state,t=e.reports,n=e.listError,i=e.listMissing,a=e.deletingId,u=e.actionError,s=e.notice,l=e.folders,c=e.tags,d=e.organizersError,f={reports:t,listError:n,retryList:r.resetList,openReport:r.openReport,deleteReport:r.deleteReport,deleteReports:r.deleteReports,deletingId:a,folders:l,tags:c,organizersError:d,retryOrganizers:r.loadOrganizers,createFolder:r.createFolder,renameFolder:r.renameFolder,deleteFolder:r.deleteFolder,createTag:r.createTag,updateTag:r.updateTag,deleteTag:r.deleteTag,organizeReports:r.organizeReports,notices:[].concat(o(u?[{tone:"error",text:u}]:[]),o(i?[{tone:"error",text:i}]:[]),o(s?[{tone:"info",text:s}]:[])),newReport:r.openNewReport};return r.props.renderHome?r.props.renderHome(f):pt.createElement(xb,f)}),S(r,"renderEditor",function(){var e,t=r.props,n=t.authentication,o=t.autoQLConfig,i=t.dataFormatting,a=t.dashboards,u=t.dashboardsError,s=r.state,l=s.openError,c=s.saveState,d=r.activeReport(),f=!!d&&rt(d.report),h=(d?null==c?void 0:c.error:null)||(f?hb.workspace.readOnly:null)||(u?hb.workspace.dashboardsFailed(u):null);return e=d?pt.createElement(MF,{key:"".concat(r.sourceId,":").concat(d.id),authentication:n,autoQLConfig:o,dataFormatting:i,dashboards:a||pb,report:d.report,onChange:r.handleChange,branding:r.props.branding,enableBranding:r.props.enableBranding,canEditBranding:r.props.canEditBranding,enableDataBlocks:r.props.enableDataBlocks,pickDashboardTiles:void 0===a?void 0:r.pickDashboardTiles,enableAnalysis:r.props.enableAnalysis,enableRunReport:r.props.enableRunReport,fontStylesheetUrl:r.props.fontStylesheetUrl,getAuthenticationForProject:r.props.getAuthenticationForProject,onRunComplete:r.props.onRunComplete,onErrorCallback:r.props.onErrorCallback,toolbarStatus:!f&&c?pt.createElement(YF,{state:c.status,savedAt:c.savedAt,onSave:r.saveNow,onReload:r.reloadShown}):void 0}):l?pt.createElement("div",{className:"".concat(Ve,"-message"),"data-tone":"error"},pt.createElement(R,{name:"alert",size:20}),pt.createElement("p",{role:"alert"},l),pt.createElement("button",{type:"button",className:"".concat(Ve,"-button"),onClick:r.retryOpen},hb.tryAgain)):pt.createElement("div",{className:"".concat(Ve,"-message")},pt.createElement("span",{className:"".concat(Ve,"-spin")},pt.createElement(R,{name:"spinner",size:20})),pt.createElement("p",null,hb.workspace.opening)),pt.createElement("div",{className:"".concat(Ve,"-editor")},h?pt.createElement("p",{className:"".concat(Ve,"-editor-notice"),role:"status","data-test":"reports-editor-notice"},pt.createElement(R,{name:"alert",size:14}),h):null,pt.createElement("div",{className:"".concat(Ve,"-editor-body")},e))}),r.savers=new Map,r.saverSources=new Map,r.credentials=new Map,r.sourceId=mb(t.authentication,t.dataSourceId),r.credentials.set(r.sourceId,t.authentication),r.shownId=null,r.tabs=[],r.tabsSource=null,r.reported=t.shownReportId,r.listRequest=0,r.organizersRequest=0,r.openRequest=0,r.unauthorizedSaid=!1,r.unshownMerge=null,r.root=pt.createRef(),r.state={reports:null,listError:null,listMissing:null,tabs:[],tabWidths:{},shownId:null,opened:null,openError:null,saveState:null,notSaved:vb,actionError:null,notice:null,deletingId:null,tilePicker:null,newReportOpen:!1,folders:null,tags:null,organizersError:null},r}return A(n,t),x(n,[{key:"componentDidMount",value:function(){this.mounted=!0,window.addEventListener("pagehide",this.onPageHide),window.addEventListener("beforeunload",this.onBeforeUnload),window.addEventListener("keydown",this.onKeyDown),document.addEventListener("visibilitychange",this.onVisibilityChange),this.loadList(),this.loadOrganizers()}},{key:"componentDidUpdate",value:function(e,t){var n,r,o,i=this.props,a=i.authentication,u=i.dataSourceId,s=i.shownReportId;if(!function(e,t){return(null==e?void 0:e.token)===(null==t?void 0:t.token)&&(null==e?void 0:e.apiKey)===(null==t?void 0:t.apiKey)&&(null==e?void 0:e.domain)===(null==t?void 0:t.domain)}(a,e.authentication)||u!==e.dataSourceId){var l=mb(a,u);this.credentials.set(l,a),l!==this.sourceId?this.switchSource(l):this.credentialsRenewed(l)}if(s!==e.shownReportId&&s!==this.reported){this.reported=s;var c=this.state.reports;c&&void 0!==s&&(s&&(this.state.listMissing||c.some(function(e){return e.id===s}))?this.openReport(s):this.goHome())}null!==this.state.reports&&this.state.shownId!==this.reported&&(this.reported=this.state.shownId,null===(r=(o=this.props).onShowReport)||void 0===r||r.call(o,this.state.shownId));if((t.tabs!==this.state.tabs||t.tabWidths!==this.state.tabWidths)&&null!==this.tabsSource&&this.tabsSource===this.sourceId){var d=this.storagePrefix();!function(e,t,n){var r=qF(e,je);if(r)try{var o=HF(r);n.length>0?o[jF(t)]=n.slice(-30):delete o[jF(t)],VF(r,o)}catch(e){}}(d,this.sourceId,this.state.tabs),function(e,t,n){var r=qF(e,He);if(r)try{var o=HF(r);Object.keys(n).length>0?o[jF(t)]=n:delete o[jF(t)],VF(r,o)}catch(e){}}(d,this.sourceId,WF(this.state.tabWidths,this.state.tabs))}var f=this.state.tilePicker;f&&f.reportId!==(null===(n=this.activeReport())||void 0===n?void 0:n.id)&&(f.resolve(null),this.setState({tilePicker:null}));var h=this.unshownMerge;if(h){var p,v=this.activeReport(),m=(null==v?void 0:v.id)===h.id&&Array.isArray(null===(p=v.report)||void 0===p?void 0:p.blocks)?v.report.blocks:null;m&&!h.blocks.every(function(e){return m.some(function(t){return(null==t?void 0:t.id)===(null==e?void 0:e.id)})})||(this.unshownMerge=null)}}},{key:"componentWillUnmount",value:function(){var e;this.mounted=!1,window.removeEventListener("pagehide",this.onPageHide),window.removeEventListener("beforeunload",this.onBeforeUnload),window.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("visibilitychange",this.onVisibilityChange),null===(e=this.state.tilePicker)||void 0===e||e.resolve(null),this.savers.forEach(function(e){e.flush().finally(function(){return e.dispose()})})}},{key:"render",value:function(){var e=this,t=this.props,n=t.authentication,r=t.autoQLConfig,o=t.dataFormatting,i=t.dashboards,a=t.onDashboardTilesChange,u=t.className,s=this.state,l=s.reports,c=s.tabs,d=s.tabWidths,f=s.shownId,h=s.notSaved,p=s.tilePicker,v=s.newReportOpen,m=this.activeReport(),g=function(e){return nt(null==l?void 0:l.find(function(t){return t.id===e}))};return pt.createElement("div",{ref:this.root,className:"".concat(Ve).concat(u?" ".concat(u):""),"data-test":"reports"},pt.createElement(GF,{tabs:c.map(function(e){return{id:e,title:g(e),notSaved:h.has(e)}}),shownId:f,onHome:this.goHome,onSelect:this.openReport,onClose:this.closeTab,onNew:this.openNewReport,newDisabled:null===l,widths:d,onResize:this.resizeTab}),null===f?pt.createElement("div",{className:"".concat(Ve,"-home")},this.renderHome()):this.renderEditor(),v?pt.createElement(db,{authentication:n,autoQLConfig:r,dataFormatting:o,dashboards:i,onClose:this.closeNewReport,onStart:this.startReport,onTilesChange:a}):null,p&&m&&p.reportId===m.id?pt.createElement(ab,{authentication:n,autoQLConfig:r,dataFormatting:o,dashboards:null!=i?i:null,report:m.report,mode:"add",onClose:function(){return e.closeTilePicker(null)},onAdd:function(t){return e.closeTilePicker(t)},onTilesChange:a}):null)}}])}(pt.Component);S(Sb,"propTypes",{authentication:he,autoQLConfig:pe,dataFormatting:ve,dataSourceId:mt.oneOfType([mt.string,mt.number]),dashboards:mt.arrayOf(mt.object),dashboardsError:mt.string,onDashboardTilesChange:mt.func,shownReportId:mt.string,onShowReport:mt.func,renderHome:mt.func,storageKeyPrefix:mt.string,onUnauthorized:mt.func,saveDelay:mt.number,newReportFolderId:mt.string,branding:mt.object,enableBranding:mt.bool,canEditBranding:mt.bool,enableDataBlocks:mt.bool,enableAnalysis:mt.bool,enableRunReport:mt.bool,fontStylesheetUrl:mt.string,getAuthenticationForProject:mt.func,onRunComplete:mt.func,onErrorCallback:mt.func,className:mt.string}),S(Sb,"defaultProps",{authentication:void 0,autoQLConfig:Tt,dataFormatting:Mt,dataSourceId:void 0,dashboards:void 0,dashboardsError:void 0,onDashboardTilesChange:void 0,shownReportId:void 0,onShowReport:void 0,renderHome:void 0,storageKeyPrefix:Ze,onUnauthorized:void 0,saveDelay:Se,newReportFolderId:null,branding:void 0,enableBranding:!1,canEditBranding:!1,enableDataBlocks:!1,enableAnalysis:!1,enableRunReport:!1,fontStylesheetUrl:null,getAuthenticationForProject:void 0,onRunComplete:void 0,onErrorCallback:void 0,className:void 0});var Bb=me(Sb);export{MF as ReportBuilder,Bb as Reports};
|