1import{aa as vf,ab as Sf,al as kg,bL as vg,bM as Sg,aC as Cg,bN as Mg,bg as Eg,r as x,j as p,bO as qi,bj as Cf,bP as Tg,ac as Ag,E as K,ad as Dg,ak as Rg,H as pe,ag as Ce,ah as vs,bT as Ng,aF as qa,aH as Mf,G as Ee,T as re,a7 as Nn,aG as Og,bU as Ig,o as xn,A as we,a6 as Kn,aw as Ef,S as Mt,V as jg,C as ar,B as We,a9 as Xo,e as Ja,c as ui,g as Ks,a2 as B,i as Tf,f as Ga,a0 as Af,w as As,a4 as Lg,b0 as zg,bV as Pg,aZ as bs,x as ge,av as Zo,h as Df,D as Bg,u as $g,b as nd,p as _g,aI as Fg,k as Hg,q as Vg,M as rd,aJ as Wg,L as Ug,v as Kg,a3 as qg,d as sd,R as Jg}from"./index-CB1LRsvg.js";import{I as Qo}from"./IconDots-B1aCp1zV.js";import{I as ss}from"./IconTrash-B56plgcD.js";import{I as Ya}from"./IconPencil-oMykwAVz.js";import{I as Ss}from"./IconChartBar-BP2caZyo.js";import{I as Gg}from"./IconFileTypePdf-lbhnpUEb.js";import{C as Xa,V as Yg,S as Xg,a as Zg,I as Qg}from"./VisualizationWrapper-B_gdPpCh.js";import{I as vl}from"./IconPresentation-C3fRhwcl.js";import{I as ey}from"./IconStar-9-CEEvth.js";import{V as ty,b as Rf,n as ny,f as ry,d as sy,u as iy,I as oy,a as ly}from"./useEnsureAnalysis-Yl5RysKE.js";import{I as Za}from"./IconPhoto-DUZWNaK7.js";import{E as ay}from"./EditorHeader-e9HD8M3q.js";import{C as cy}from"./IconChartDots-DkoRXFwt.js";import{I as Nf,S as Of,r as Ds,a as dy,l as uy,M as Sl,b as Rs,n as fy}from"./ShapeContent-JjQWWkhc.js";import{k as hy,b as py}from"./index-Vcq4gwWv.js";import{s as Hr,e as fi,i as my,r as gy,A as If,h as Qa,b as jf,m as yy}from"./richText-CBRloJre.js";import{a as Lf,b as by,g as xy}from"./vizTitle-DtATiW7_.js";import{u as wy}from"./usePrompt-pQsCHLvP.js";import{a as zf,u as ky}from"./IconTable-uuuZ8vFo.js";import{S as so}from"./SegmentedControl-B2vw4mHc.js";import{N as Ns,P as vy}from"./Progress-Bis4sOii.js";import{I as Sy}from"./IconAlertTriangle-oE-1p8q2.js";import{I as Cy}from"./IconLink-B5LPxjxf.js";import{S as My}from"./SimpleGrid-C5deGO61.js";import{f as Ey,r as Ty,e as Ay,g as id,h as Dy,i as Ry,s as Cl,j as Ny,d as Oy,c as Iy,k as sn,l as jy,m as qr,n as od,o as ld,p as Ly,q as ad,t as cd}from"./useDecks-Re5MFzij.js";import{a as zy,s as Py}from"./useVisualization-C3neUNqV.js";import{V as By}from"./VisualizationLibrary-BKs2u01E.js";import{a as $y}from"./layout-2mrj5SBU.js";import{u as _y}from"./useConfirm-B_NA31aX.js";import{V as Fy}from"./VisualizationImage-9QCisdbA.js";import{E as Pf}from"./EmptyState-DqWHbZL6.js";import{I as Hy}from"./IconArrowLeft-Ds_130vQ.js";import{u as Vy}from"./usePageTitle-PP7G01cs.js";import{B as dd}from"./Badge-CvorhVBt.js";import{S as ud}from"./Switch-BZSEpu01.js";import"./IconCode-0PJYF6Gd.js";import"./IconEye-CL2S3lqC.js";import"./use-clipboard-Dyb8n21I.js";import"./IconFilter-HeDMfmcN.js";import"./StatusText-gwUfW1V-.js";import"./Table-D4aHVX52.js";import"./IconDownload-BpW96cSR.js";import"./Skeleton-DixNWO5N.js";import"./papaparse.min-BAKOmby7.js";import"./Alert-Dvpb9ICu.js";import"./Accordion-CYFEfRNi.js";import"./Collapse-DQjkuvle.js";import"./IconFileText-Bkeiywzv.js";import"./IconDatabase-BZlekyNS.js";import"./formatAbbreviate-BjreiDFX.js";import"./IconCopy-Coo_r-4m.js";import"./SectionTitle-DUWdJHXc.js";import"./IconSearch-CqQSV7iv.js";import"./libraryView-De30Gts8.js";import"./pressable-tRM_bxh-.js";import"./Card-DwzWyE8m.js";import"./AspectRatio-CMHm-VhU.js";import"./ThemeIcon-DUJfKgY0.js";const ec=vf((n,e)=>{const t=Sf("Autocomplete",null,n),{classNames:r,styles:s,unstyled:i,vars:o,dropdownOpened:l,defaultDropdownOpened:a,onDropdownClose:c,onDropdownOpen:d,onFocus:u,onBlur:f,onClick:h,onChange:m,data:g,value:y,defaultValue:b,selectFirstOptionOnChange:S,selectFirstOptionOnDropdownOpen:C,onOptionSubmit:T,comboboxProps:M,readOnly:D,disabled:k,filter:A,limit:P,withScrollArea:U,maxDropdownHeight:G,size:V,id:ue,renderOption:ae,autoComplete:se,scrollAreaProps:de,onClear:ye,clearButtonProps:Qe,error:be,clearable:De,rightSection:Ue,autoSelectOnBlur:ve,openOnFocus:lt=!0,attributes:Me,...at}=t,$e=kg(ue),ct=vg(g),ie=Sg(ct),[me,Q]=Cg({value:y,defaultValue:b,finalValue:"",onChange:m}),Te=Mg({opened:l,defaultOpened:a,onDropdownOpen:()=>{d==null||d(),C&&Te.selectFirstOption()},onDropdownClose:()=>{c==null||c(),setTimeout(Te.resetSelectedOption,0)}}),Ie=Se=>{Q(Se),Te.resetSelectedOption()},{resolvedClassNames:dt,resolvedStyles:le}=Eg({props:t,styles:s,classNames:r});x.useEffect(()=>{S&&Te.selectFirstOption()},[S,me]);const xe=p.jsx(qi.ClearButton,{...Qe,onClear:()=>{Ie(""),ye==null||ye()}});return p.jsxs(qi,{store:Te,__staticSelector:"Autocomplete",classNames:dt,styles:le,unstyled:i,readOnly:D,size:V,attributes:Me,keepMounted:ve,onOptionSubmit:Se=>{T==null||T(Se),Ie(ie[Se].label),Te.closeDropdown()},...M,children:[p.jsx(qi.Target,{autoComplete:se,children:p.jsx(Cf,{ref:e,...at,size:V,__staticSelector:"Autocomplete",__clearSection:xe,__clearable:De&&!!me&&!k&&!D,rightSection:Ue,disabled:k,readOnly:D,value:me,error:be,onChange:Se=>
1{Ie(Se.currentTarget.value),Te.openDropdown(),S&&Te.selectFirstOption()},onFocus:Se=>{lt&&Te.openDropdown(),u==null||u(Se)},onBlur:Se=>{ve&&Te.clickSelectedOption(),Te.closeDropdown(),f==null||f(Se)},onClick:Se=>{Te.openDropdown(),h==null||h(Se)},classNames:dt,styles:le,unstyled:i,attributes:Me,id:$e})}),p.jsx(Tg,{data:ct,hidden:D||k,filter:A,search:me,limit:P,hiddenWhenEmpty:!0,withScrollArea:U,maxDropdownHeight:G,unstyled:i,labelId:at.label?`${$e}-label`:void 0,"aria-label":at.label?void 0:at["aria-label"],renderOption:ae,scrollAreaProps:de})]})});ec.classes={...Cf.classes,...qi.classes};ec.displayName="@mantine/core/Autocomplete";var Bf={root:"m_dc6f14e2"};const Wy=Dg((n,{size:e})=>({root:{"--kbd-fz":Rg(e,"kbd-fz")}})),io=vf((n,e)=>{const t=Sf("Kbd",null,n),{classNames:r,className:s,style:i,styles:o,unstyled:l,vars:a,attributes:c,...d}=t,u=Ag({name:"Kbd",classes:Bf,props:t,className:s,style:i,classNames:r,styles:o,unstyled:l,attributes:c,vars:a,varsResolver:Wy});return p.jsx(K,{component:"kbd",ref:e,...u("root"),...d})});io.classes=Bf;io.displayName="@mantine/core/Kbd";/** 2 * @license @tabler/icons-react v3.41.1 - MIT 3 * 4 * This source code is licensed under the MIT license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Uy=[["path",{d:"M7 5.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666",key:"svg-0"}],["path",{d:"M4.012 7.26a2.005 2.005 0 0 0 -1.012 1.737v10c0 1.1 .9 2 2 2h10c.75 0 1.158 -.385 1.5 -1",key:"svg-1"}],["path",{d:"M11 10h6",key:"svg-2"}],["path",{d:"M14 7v6",key:"svg-3"}]],Ji=pe("outline","library-plus","LibraryPlus",Uy);/** 7 * @license @tabler/icons-react v3.41.1 - MIT 8 * 9 * This source code is licensed under the MIT license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ky=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-1"}],["path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6",key:"svg-2"}],["path",{d:"M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6",key:"svg-3"}],["path",{d:"M16.5 15h3",key:"svg-4"}],["path",{d:"M18 15v6",key:"svg-5"}],["path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4",key:"svg-6"}]],qy=pe("outline","file-type-ppt","FileTypePpt",Ky);/** 12 * @license @tabler/icons-react v3.41.1 - MIT 13 * 14 * This source code is licensed under the MIT license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Jy=[["path",{d:"M5 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -14",key:"svg-0"}],["path",{d:"M9 7l6 0",key:"svg-1"}],["path",{d:"M9 11l6 0",key:"svg-2"}],["path",{d:"M9 15l4 0",key:"svg-3"}]],tc=pe("outline","notes","Notes",Jy);/** 17 * @license @tabler/icons-react v3.41.1 - MIT 18 * 19 * This source code is licensed under the MIT license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Gy=[["path",{d:"M19 18v-8l-2 2",key:"svg-0"}],["path",{d:"M4 6v12",key:"svg-1"}],["path",{d:"M12 6v12",key:"svg-2"}],["path",{d:"M11 18h2",key:"svg-3"}],["path",{d:"M3 18h2",key:"svg-4"}],["path",{d:"M4 12h8",key:"svg-5"}],["path",{d:"M3 6h2",key:"svg-6"}],["path",{d:"M11 6h2",key:"svg-7"}]],Yy=pe("outline","h-1","H1",Gy);/** 22 * @license @tabler/icons-react v3.41.1 - MIT 23 * 24 * This source code is licensed under the MIT license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Xy=[["path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0",key:"svg-0"}],["path",{d:"M4 6v12",key:"svg-1"}],["path",{d:"M12 6v12",key:"svg-2"}],["path",{d:"M11 18h2",key:"svg-3"}],["path",{d:"M3 18h2",key:"svg-4"}],["path",{d:"M4 12h8",key:"svg-5"}],["path",{d:"M3 6h2",key:"svg-6"}],["path",{d:"M11 6h2",key:"svg-7"}]],Zy=pe("outline","h-2","H2",Xy);/** 27 * @license @tabler/icons-react v3.41.1 - MIT 28 * 29 * This source code is licensed under the MIT license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const Qy=[["path",{d:"M19 14a2 2 0 1 0 -2 -2",key:"svg-0"}],["path",{d:"M17 16a2 2 0 1 0 2 -2",key:"svg-1"}],["path",{d:"M4 6v12",key:"svg-2"}],["path",{d:"M12 6v12",key:"svg-3"}],["path",{d:"M11 18h2",key:"svg-4"}],["path",{d:"M3 18h2",key:"svg-5"}],["path",{d:"M4 12h8",key:"svg-6"}],["path",{d:"M3 6h2",key:"svg-7"}],["path",{d:"M11 6h2",key:"svg-8"}]],e0=pe("outline","h-3","H3",Qy);/**
32 * @license @tabler/icons-react v3.41.1 - MIT 33 * 34 * This source code is licensed under the MIT license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const t0=[["path",{d:"M7 12h10",key:"svg-0"}],["path",{d:"M7 5v14",key:"svg-1"}],["path",{d:"M17 5v14",key:"svg-2"}],["path",{d:"M15 19h4",key:"svg-3"}],["path",{d:"M15 5h4",key:"svg-4"}],["path",{d:"M5 19h4",key:"svg-5"}],["path",{d:"M5 5h4",key:"svg-6"}]],n0=pe("outline","heading","Heading",t0);/** 37 * @license @tabler/icons-react v3.41.1 - MIT 38 * 39 * This source code is licensed under the MIT license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const r0=[["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14",key:"svg-0"}]],sa=pe("outline","square","Square",r0);/** 42 * @license @tabler/icons-react v3.41.1 - MIT 43 * 44 * This source code is licensed under the MIT license. 45 * See the LICENSE file in the root directory of this source tree. 46 */const s0=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}]],$f=pe("outline","circle","Circle",s0);/** 47 * @license @tabler/icons-react v3.41.1 - MIT 48 * 49 * This source code is licensed under the MIT license. 50 * See the LICENSE file in the root directory of this source tree. 51 */const i0=[["path",{d:"M4 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M16 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M7.5 16.5l9 -9",key:"svg-2"}]],nc=pe("outline","line","Line",i0);/** 52 * @license @tabler/icons-react v3.41.1 - MIT 53 * 54 * This source code is licensed under the MIT license. 55 * See the LICENSE file in the root directory of this source tree. 56 */const o0=[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M15 16l4 -4",key:"svg-1"}],["path",{d:"M15 8l4 4",key:"svg-2"}]],l0=pe("outline","arrow-narrow-right","ArrowNarrowRight",o0);/** 57 * @license @tabler/icons-react v3.41.1 - MIT 58 * 59 * This source code is licensed under the MIT license. 60 * See the LICENSE file in the root directory of this source tree. 61 */const a0=[["path",{d:"M4 20l3 0",key:"svg-0"}],["path",{d:"M14 20l7 0",key:"svg-1"}],["path",{d:"M6.9 15l6.9 0",key:"svg-2"}],["path",{d:"M10.2 6.3l5.8 13.7",key:"svg-3"}],["path",{d:"M5 20l6 -16l2 0l7 16",key:"svg-4"}]],c0=pe("outline","typography","Typography",a0);function d0(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return x.useMemo(()=>r=>{e.forEach(s=>s(r))},e)}const el=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ds(n){const e=Object.prototype.toString.call(n);return e==="[object Window]"||e==="[object global]"}function rc(n){return"nodeType"in n}function Jt(n){var e,t;return n?ds(n)?n:rc(n)&&(e=(t=n.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function sc(n){const{Document:e}=Jt(n);return n instanceof e}function hi(n){return ds(n)?!1:n instanceof Jt(n).HTMLElement}function _f(n){return n instanceof Jt(n).SVGElement}function us(n){return n?ds(n)?n.document:rc(n)?sc(n)?n:hi(n)||_f(n)?n.ownerDocument:document:document:document}const jn=el?x.useLayoutEffect:x.useEffect;function ic(n){const e=x.useRef(n);return jn(()=>{e.current=n}),x.useCallback(function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}function u0(){const n=x.useRef(null),e=x.useCallback((r,s)=>{n.current=setInterval(r,s)},[]),t=x.useCallback(()=>{n.current!==null&&(clearInterval(n.current),n.current=null)},[]);return[e,t]}function qs(n,e){e===void 0&&(e=[n]);const t=x.useRef(n);return jn(()=>{t.current!==n&&(t.current=n)},e),t}function pi(n,e){const t=x.useRef();return x.useMemo(()=>{const r=n(t.current);return t.current=r,r},[...e])}function oo(n){const e=ic(n),t=x.useRef(null),r=x.useCallback(s=>{s!==t.current&&(e==null||e(s,t.current)),t.current=s},[]);return[t,r]}function ia(n){const e=x.useRef();return x.useEffect(()=>{e.current=n},[n]),e.current}let Ml={};function mi(n,e){return x.useMemo(()=>{if(e)return e;const t=Ml[n]==null?0:Ml[n]+1;return Ml[n]=t,n+"-"+t},[n,e])}function Ff(n){return function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];return r.reduce((i,o)=>{const l=Object.entries(o);for(const[a,c]of l){const d=i[a];d!=null&&(i[a]=d+n*c)}return i},{...e})}}const ts=Ff(1),Js=Ff(-1);function f0(n){return"clientX"in n&&"clientY"in n}function oc(n){if(!n)return!1;const{KeyboardEvent:e}=Jt(n.target);return e&&n instanceof e}function h0(n){if(!n)return!1;const{TouchEvent:e}=Jt(n.target);return e&&n instanceof e}function oa(n){if(h0(n)){if(n.touches&&n.touches.length){const{clientX:e,clientY:t}=n.touches[0];return{x:e,y:t}}else if(n.changedTouches&&n.changedTouches.length){const{clientX:e,clientY:t}=n.changedTouches[0];return{x:e,y:t}}}return f0(n)?{x:n.clientX,y:n.clientY}:null}const Gs=Object.freeze({Translate:{toString(n){if(!n)return;const{x:e,y:t}=n;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(n){if(!n)return;const{scaleX:e,scaleY:t}=n;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(n){if(n)return[Gs.Translate.toString(n),Gs.Scale.toString(n)].join(" ")}},Transition:{toString(n){let{property:e,duration:t,easing:r}=n;return e+" "+t+"ms "+r}}}),fd="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function p0(n){return n.matches(fd)?n:n.querySelector(fd)}
61const m0={display:"none"};function g0(n){let{id:e,value:t}=n;return Ce.createElement("div",{id:e,style:m0},t)}function y0(n){let{id:e,announcement:t,ariaLiveType:r="assertive"}=n;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ce.createElement("div",{id:e,style:s,role:"status","aria-live":r,"aria-atomic":!0},t)}function b0(){const[n,e]=x.useState("");return{announce:x.useCallback(r=>{r!=null&&e(r)},[]),announcement:n}}const Hf=x.createContext(null);function x0(n){const e=x.useContext(Hf);x.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(n)},[n,e])}function w0(){const[n]=x.useState(()=>new Set),e=x.useCallback(r=>(n.add(r),()=>n.delete(r)),[n]);return[x.useCallback(r=>{let{type:s,event:i}=r;n.forEach(o=>{var l;return(l=o[s])==null?void 0:l.call(o,i)})},[n]),e]}const k0={draggable:` 62 To pick up a draggable item, press the space bar. 63 While dragging, use the arrow keys to move the item. 64 Press space again to drop the item in its new position, or press escape to cancel. 65 `},v0={onDragStart(n){let{active:e}=n;return"Picked up draggable item "+e.id+"."},onDragOver(n){let{active:e,over:t}=n;return t?"Draggable item "+e.id+" was moved over droppable area "+t.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(n){let{active:e,over:t}=n;return t?"Draggable item "+e.id+" was dropped over droppable area "+t.id:"Draggable item "+e.id+" was dropped."},onDragCancel(n){let{active:e}=n;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function S0(n){let{announcements:e=v0,container:t,hiddenTextDescribedById:r,screenReaderInstructions:s=k0}=n;const{announce:i,announcement:o}=b0(),l=mi("DndLiveRegion"),[a,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),x0(x.useMemo(()=>({onDragStart(u){let{active:f}=u;i(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:h}=u;e.onDragMove&&i(e.onDragMove({active:f,over:h}))},onDragOver(u){let{active:f,over:h}=u;i(e.onDragOver({active:f,over:h}))},onDragEnd(u){let{active:f,over:h}=u;i(e.onDragEnd({active:f,over:h}))},onDragCancel(u){let{active:f,over:h}=u;i(e.onDragCancel({active:f,over:h}))}}),[i,e])),!a)return null;const d=Ce.createElement(Ce.Fragment,null,Ce.createElement(g0,{id:r,value:s.draggable}),Ce.createElement(y0,{id:l,announcement:o}));return t?vs.createPortal(d,t):d}var ot;(function(n){n.DragStart="dragStart",n.DragMove="dragMove",n.DragEnd="dragEnd",n.DragCancel="dragCancel",n.DragOver="dragOver",n.RegisterDroppable="registerDroppable",n.SetDroppableDisabled="setDroppableDisabled",n.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function lo(){}function ao(n,e){return x.useMemo(()=>({sensor:n,options:e??{}}),[n,e])}function Vf(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return x.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const vn=Object.freeze({x:0,y:0});function Wf(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function Uf(n,e){let{data:{value:t}}=n,{data:{value:r}}=e;return t-r}function C0(n,e){let{data:{value:t}}=n,{data:{value:r}}=e;return r-t}function hd(n){let{left:e,top:t,height:r,width:s}=n;return[{x:e,y:t},{x:e+s,y:t},{x:e,y:t+r},{x:e+s,y:t+r}]}function Kf(n,e){if(!n||n.length===0)return null;const[t]=n;return t[e]}function pd(n,e,t){return e===void 0&&(e=n.left),t===void 0&&(t=n.top),{x:e+n.width*.5,y:t+n.height*.5}}const qf=n=>{let{collisionRect:e,droppableRects:t,droppableContainers:r}=n;const s=pd(e,e.left,e.top),i=[];for(const o of r){const{id:l}=o,a=t.get(l);if(a){const c=Wf(pd(a),s);i.push({id:l,data:{droppableContainer:o,value:c}})}}return i.sort(Uf)},M0=n=>{let{collisionRect:e,droppableRects:t,droppableContainers:r}=n;const s=hd(e),i=[];for(const o of r){const{id:l}=o,a=t.get(l);if(a){const c=hd(a),d=s.reduce((f,h,m)=>f+Wf(c[m],h),0),u=Number((d/4).toFixed(4));i.push({id:l,data:{droppableContainer:o,value:u}})}}return i.sort(Uf)};function E0(n,e){const t=Math.max(e.top,n.top),r=Math.max(e.left,n.left),s=Math.min(e.left+e.width,n.left+n.width),i=Math.min(e.top+e.height,n.top+n.height),o=s-r,l=i-t;if(r<s&&t<i){const a=e.width*e.height,c=n.width*n.height,d=o*l,u=d/(a+c-d);return Number(u.toFixed(4))}return 0}const T0=n=>{let{collisionRect:e,droppableRects:t,droppableContainers:r}=n;const s=[];for(const i of r){const{id:o}=i,l=t.get(o);if(l){const a=E0(l,e);a>0&&s.push({id:o,data:{droppableContainer:i,value:a}})}}return s.sort(C0)};function A0(n,e,t){return{...n,scaleX:e&&t?e.width/t.width:1,scaleY:e&&t?e.height/t.height:1}}function Jf(n,e){return n&&e?{x:n.left-e.left,y:n.top-e.top}:vn}function D0(n){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((o,l)=>
65({...o,top:o.top+n*l.y,bottom:o.bottom+n*l.y,left:o.left+n*l.x,right:o.right+n*l.x}),{...t})}}const R0=D0(1);function N0(n){if(n.startsWith("matrix3d(")){const e=n.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(n.startsWith("matrix(")){const e=n.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function O0(n,e,t){const r=N0(e);if(!r)return n;const{scaleX:s,scaleY:i,x:o,y:l}=r,a=n.left-o-(1-s)*parseFloat(t),c=n.top-l-(1-i)*parseFloat(t.slice(t.indexOf(" ")+1)),d=s?n.width/s:n.width,u=i?n.height/i:n.height;return{width:d,height:u,top:c,right:a+d,bottom:c+u,left:a}}const I0={ignoreTransform:!1};function fs(n,e){e===void 0&&(e=I0);let t=n.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:d}=Jt(n).getComputedStyle(n);c&&(t=O0(t,c,d))}const{top:r,left:s,width:i,height:o,bottom:l,right:a}=t;return{top:r,left:s,width:i,height:o,bottom:l,right:a}}function md(n){return fs(n,{ignoreTransform:!0})}function j0(n){const e=n.innerWidth,t=n.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}function L0(n,e){return e===void 0&&(e=Jt(n).getComputedStyle(n)),e.position==="fixed"}function z0(n,e){e===void 0&&(e=Jt(n).getComputedStyle(n));const t=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=e[s];return typeof i=="string"?t.test(i):!1})}function tl(n,e){const t=[];function r(s){if(e!=null&&t.length>=e||!s)return t;if(sc(s)&&s.scrollingElement!=null&&!t.includes(s.scrollingElement))return t.push(s.scrollingElement),t;if(!hi(s)||_f(s)||t.includes(s))return t;const i=Jt(n).getComputedStyle(s);return s!==n&&z0(s,i)&&t.push(s),L0(s,i)?t:r(s.parentNode)}return n?r(n):t}function Gf(n){const[e]=tl(n,1);return e??null}function El(n){return!el||!n?null:ds(n)?n:rc(n)?sc(n)||n===us(n).scrollingElement?window:hi(n)?n:null:null}function Yf(n){return ds(n)?n.scrollX:n.scrollLeft}function Xf(n){return ds(n)?n.scrollY:n.scrollTop}function la(n){return{x:Yf(n),y:Xf(n)}}var mt;(function(n){n[n.Forward=1]="Forward",n[n.Backward=-1]="Backward"})(mt||(mt={}));function Zf(n){return!el||!n?!1:n===document.scrollingElement}function Qf(n){const e={x:0,y:0},t=Zf(n)?{height:window.innerHeight,width:window.innerWidth}:{height:n.clientHeight,width:n.clientWidth},r={x:n.scrollWidth-t.width,y:n.scrollHeight-t.height},s=n.scrollTop<=e.y,i=n.scrollLeft<=e.x,o=n.scrollTop>=r.y,l=n.scrollLeft>=r.x;return{isTop:s,isLeft:i,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const P0={x:.2,y:.2};function B0(n,e,t,r,s){let{top:i,left:o,right:l,bottom:a}=t;r===void 0&&(r=10),s===void 0&&(s=P0);const{isTop:c,isBottom:d,isLeft:u,isRight:f}=Qf(n),h={x:0,y:0},m={x:0,y:0},g={height:e.height*s.y,width:e.width*s.x};return!c&&i<=e.top+g.height?(h.y=mt.Backward,m.y=r*Math.abs((e.top+g.height-i)/g.height)):!d&&a>=e.bottom-g.height&&(h.y=mt.Forward,m.y=r*Math.abs((e.bottom-g.height-a)/g.height)),!f&&l>=e.right-g.width?(h.x=mt.Forward,m.x=r*Math.abs((e.right-g.width-l)/g.width)):!u&&o<=e.left+g.width&&(h.x=mt.Backward,m.x=r*Math.abs((e.left+g.width-o)/g.width)),{direction:h,speed:m}}function $0(n){if(n===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:e,left:t,right:r,bottom:s}=n.getBoundingClientRect();return{top:e,left:t,right:r,bottom:s,width:n.clientWidth,height:n.clientHeight}}function eh(n){return n.reduce((e,t)=>ts(e,la(t)),vn)}function _0(n){return n.reduce((e,t)=>e+Yf(t),0)}function F0(n){return n.reduce((e,t)=>e+Xf(t),0)}function H0(n,e){if(e===void 0&&(e=fs),!n)return;const{top:t,left:r,bottom:s,right:i}=e(n);Gf(n)&&(s<=0||i<=0||t>=window.innerHeight||r>=window.innerWidth)&&n.scrollIntoView({block:"center",inline:"center"})}const V0=[["x",["left","right"],_0],["y",["top","bottom"],F0]];class lc{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=tl(t),s=eh(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,o,l]of V0)for(const a of o)Object.defineProperty(this,a,{get:()=>{const c=l(r),d=s[i]-c;return this.rect[a]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Os{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>
65{this.listeners.forEach(t=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...t)})},this.target=e}add(e,t,r){var s;(s=this.target)==null||s.addEventListener(e,t,r),this.listeners.push([e,t,r])}}function W0(n){const{EventTarget:e}=Jt(n);return n instanceof e?n:us(n)}function Tl(n,e){const t=Math.abs(n.x),r=Math.abs(n.y);return typeof e=="number"?Math.sqrt(t**2+r**2)>e:"x"in e&&"y"in e?t>e.x&&r>e.y:"x"in e?t>e.x:"y"in e?r>e.y:!1}var an;(function(n){n.Click="click",n.DragStart="dragstart",n.Keydown="keydown",n.ContextMenu="contextmenu",n.Resize="resize",n.SelectionChange="selectionchange",n.VisibilityChange="visibilitychange"})(an||(an={}));function gd(n){n.preventDefault()}function U0(n){n.stopPropagation()}var he;(function(n){n.Space="Space",n.Down="ArrowDown",n.Right="ArrowRight",n.Left="ArrowLeft",n.Up="ArrowUp",n.Esc="Escape",n.Enter="Enter",n.Tab="Tab"})(he||(he={}));const th={start:[he.Space,he.Enter],cancel:[he.Esc],end:[he.Space,he.Enter,he.Tab]},K0=(n,e)=>{let{currentCoordinates:t}=e;switch(n.code){case he.Right:return{...t,x:t.x+25};case he.Left:return{...t,x:t.x-25};case he.Down:return{...t,y:t.y+25};case he.Up:return{...t,y:t.y-25}}};class nl{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Os(us(t)),this.windowListeners=new Os(Jt(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(an.Resize,this.handleCancel),this.windowListeners.add(an.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(an.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,r=e.node.current;r&&H0(r),t(vn)}handleKeyDown(e){if(oc(e)){const{active:t,context:r,options:s}=this.props,{keyboardCodes:i=th,coordinateGetter:o=K0,scrollBehavior:l="smooth"}=s,{code:a}=e;if(i.end.includes(a)){this.handleEnd(e);return}if(i.cancel.includes(a)){this.handleCancel(e);return}const{collisionRect:c}=r.current,d=c?{x:c.left,y:c.top}:vn;this.referenceCoordinates||(this.referenceCoordinates=d);const u=o(e,{active:t,context:r.current,currentCoordinates:d});if(u){const f=Js(u,d),h={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const y=e.code,{isTop:b,isRight:S,isLeft:C,isBottom:T,maxScroll:M,minScroll:D}=Qf(g),k=$0(g),A={x:Math.min(y===he.Right?k.right-k.width/2:k.right,Math.max(y===he.Right?k.left:k.left+k.width/2,u.x)),y:Math.min(y===he.Down?k.bottom-k.height/2:k.bottom,Math.max(y===he.Down?k.top:k.top+k.height/2,u.y))},P=y===he.Right&&!S||y===he.Left&&!C,U=y===he.Down&&!T||y===he.Up&&!b;if(P&&A.x!==u.x){const G=g.scrollLeft+f.x,V=y===he.Right&&G<=M.x||y===he.Left&&G>=D.x;if(V&&!f.y){g.scrollTo({left:G,behavior:l});return}V?h.x=g.scrollLeft-G:h.x=y===he.Right?g.scrollLeft-M.x:g.scrollLeft-D.x,h.x&&g.scrollBy({left:-h.x,behavior:l});break}else if(U&&A.y!==u.y){const G=g.scrollTop+f.y,V=y===he.Down&&G<=M.y||y===he.Up&&G>=D.y;if(V&&!f.x){g.scrollTo({top:G,behavior:l});return}V?h.y=g.scrollTop-G:h.y=y===he.Down?g.scrollTop-M.y:g.scrollTop-D.y,h.y&&g.scrollBy({top:-h.y,behavior:l});break}}this.handleMove(e,ts(Js(u,this.referenceCoordinates),h))}}}handleMove(e,t){const{onMove:r}=this.props;e.preventDefault(),r(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}nl.activators=[{eventName:"onKeyDown",handler:(n,e,t)=>{let{keyboardCodes:r=th,onActivation:s}=e,{active:i}=t;const{code:o}=n.nativeEvent;if(r.start.includes(o)){const l=i.activatorNode.current;return l&&n.target!==l?!1:(n.preventDefault(),s==null||s({event:n.nativeEvent}),!0)}return!1}}];function yd(n){return!!(n&&"distance"in n)}function bd(n){return!!(n&&"delay"in n)}class ac{constructor(e,t,r){var s;r===void 0&&(r=W0(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:i}=e,{target:o}=i;this.props=e,this.events=t,this.document=us(o),this.documentListeners=new Os(this.document),this.listeners=new Os(r),this.windowListeners=new Os(Jt(o)),this.initialCoordinates=(s=oa(i))!=null?s:vn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(an.Resize,this.handleCancel),this.windowListeners.add(an.DragStart,gd),this.windowListeners.add(an.VisibilityChange,this.handleCancel),this.windowListeners.add(an.ContextMenu,gd),this.documentListeners.add(an.Keydown,this.handleKeydown),t){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(bd(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(yd(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:r,onPending:s}=this.props;s(r,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(an.Click,U0,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(an.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:r,initialCoordinates:s,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!s)return;const a=(t=oa(e))!=null?t:vn,c=Js(s,a);if(!r&&l){if(yd(l)){if(l.tolerance!=null&&Tl(c,l.tolerance))return this.handleCancel();if(Tl(c,l.distance))return this.handleStart()}if(bd(l)&&Tl(c,l.tolerance))return this.handleCancel();this.handlePending(l,c);return}e.cancelable&&e.preventDefault(),o(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===he.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const q0={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rl extends ac{constructor(e){const{event:t}=e,r=us(t.target);super(e,q0,r)}}rl.activators=[{eventName:"onPointerDown",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:r}=e;return!t.isPrimary||t.button!==0?!1:(r==null||r({event:t}),!0)}}];const J0={move:{name:"mousemove"},end:{name:"mouseup"}};var aa;(function(n){n[n.RightClick=2]="RightClick"})(aa||(aa={}));class G0 extends ac{constructor(e){super(e,J0,us(e.event.target))}}G0.activators=[{eventName:"onMouseDown",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:r}=e;return t.button===aa.RightClick?!1:(r==null||r({event:t}),!0)}}];const Al={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Y0 extends ac{constructor(e){super(e,Al)}static setup(){return window.addEventListener(Al.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Al.move.name,e)};function e(){}}}Y0.activators=[{eventName:"onTouchStart",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:r}=e;const{touches:s}=t;return s.length>1?!1:(r==null||r({event:t}),!0)}}];var Is;(function(n){n[n.Pointer=0]="Pointer",n[n.DraggableRect=1]="DraggableRect"})(Is||(Is={}));var co;
65(function(n){n[n.TreeOrder=0]="TreeOrder",n[n.ReversedTreeOrder=1]="ReversedTreeOrder"})(co||(co={}));function X0(n){let{acceleration:e,activator:t=Is.Pointer,canScroll:r,draggingRect:s,enabled:i,interval:o=5,order:l=co.TreeOrder,pointerCoordinates:a,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:f}=n;const h=Q0({delta:u,disabled:!i}),[m,g]=u0(),y=x.useRef({x:0,y:0}),b=x.useRef({x:0,y:0}),S=x.useMemo(()=>{switch(t){case Is.Pointer:return a?{top:a.y,bottom:a.y,left:a.x,right:a.x}:null;case Is.DraggableRect:return s}},[t,s,a]),C=x.useRef(null),T=x.useCallback(()=>{const D=C.current;if(!D)return;const k=y.current.x*b.current.x,A=y.current.y*b.current.y;D.scrollBy(k,A)},[]),M=x.useMemo(()=>l===co.TreeOrder?[...c].reverse():c,[l,c]);x.useEffect(()=>{if(!i||!c.length||!S){g();return}for(const D of M){if((r==null?void 0:r(D))===!1)continue;const k=c.indexOf(D),A=d[k];if(!A)continue;const{direction:P,speed:U}=B0(D,A,S,e,f);for(const G of["x","y"])h[G][P[G]]||(U[G]=0,P[G]=0);if(U.x>0||U.y>0){g(),C.current=D,m(T,o),y.current=U,b.current=P;return}}y.current={x:0,y:0},b.current={x:0,y:0},g()},[e,T,r,g,i,o,JSON.stringify(S),JSON.stringify(h),m,c,M,d,JSON.stringify(f)])}const Z0={x:{[mt.Backward]:!1,[mt.Forward]:!1},y:{[mt.Backward]:!1,[mt.Forward]:!1}};function Q0(n){let{delta:e,disabled:t}=n;const r=ia(e);return pi(s=>{if(t||!r||!s)return Z0;const i={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[mt.Backward]:s.x[mt.Backward]||i.x===-1,[mt.Forward]:s.x[mt.Forward]||i.x===1},y:{[mt.Backward]:s.y[mt.Backward]||i.y===-1,[mt.Forward]:s.y[mt.Forward]||i.y===1}}},[t,e,r])}function eb(n,e){const t=e!=null?n.get(e):void 0,r=t?t.node.current:null;return pi(s=>{var i;return e==null?null:(i=r??s)!=null?i:null},[r,e])}function tb(n,e){return x.useMemo(()=>n.reduce((t,r)=>{const{sensor:s}=r,i=s.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...t,...i]},[]),[n,e])}var Ys;(function(n){n[n.Always=0]="Always",n[n.BeforeDragging=1]="BeforeDragging",n[n.WhileDragging=2]="WhileDragging"})(Ys||(Ys={}));var ca;(function(n){n.Optimized="optimized"})(ca||(ca={}));const xd=new Map;function nb(n,e){let{dragging:t,dependencies:r,config:s}=e;const[i,o]=x.useState(null),{frequency:l,measure:a,strategy:c}=s,d=x.useRef(n),u=y(),f=qs(u),h=x.useCallback(function(b){b===void 0&&(b=[]),!f.current&&o(S=>S===null?b:S.concat(b.filter(C=>!S.includes(C))))},[f]),m=x.useRef(null),g=pi(b=>{if(u&&!t)return xd;if(!b||b===xd||d.current!==n||i!=null){const S=new Map;for(let C of n){if(!C)continue;if(i&&i.length>0&&!i.includes(C.id)&&C.rect.current){S.set(C.id,C.rect.current);continue}const T=C.node.current,M=T?new lc(a(T),T):null;C.rect.current=M,M&&S.set(C.id,M)}return S}return b},[n,i,t,u,a]);return x.useEffect(()=>{d.current=n},[n]),x.useEffect(()=>{u||h()},[t,u]),x.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),x.useEffect(()=>{u||typeof l!="number"||m.current!==null||(m.current=setTimeout(()=>{h(),m.current=null},l))},[l,u,h,...r]),{droppableRects:g,measureDroppableContainers:h,measuringScheduled:i!=null};function y(){switch(c){case Ys.Always:return!1;case Ys.BeforeDragging:return t;default:return!t}}}function nh(n,e){return pi(t=>n?t||(typeof e=="function"?e(n):n):null,[e,n])}function rb(n,e){return nh(n,e)}function sb(n){let{callback:e,disabled:t}=n;const r=ic(e),s=x.useMemo(()=>{if(t||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,t]);return x.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function sl(n){let{callback:e,disabled:t}=n;const r=ic(e),s=x.useMemo(()=>{if(t||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[t]);return x.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function ib(n){return new lc(fs(n),n)}function wd(n,e,t){e===void 0&&(e=ib);const[r,s]=x.useState(null);function i(){s(a=>{if(!n)return null;if(n.isConnected===!1){var c;return(c=a??t)!=null?c:null}const d=e(n);return JSON.stringify(a)===JSON.stringify(d)?a:d})}const o=sb({callback(a){if(n)for(const c of a){const{type:d,target:u}=c;if(d==="childList"&&u instanceof HTMLElement&&u.contains(n)){i();break}}}}),l=sl({callback:i});return jn(()=>{i(),n?(l==null||l.observe(n),o==null||o.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),o==null||o.disconnect())},[n]),r}function ob(n){const e=nh(n);return Jf(n,e)}const kd=[];function lb(n){const e=x.useRef(n),t=pi(r=>n?r&&r!==kd&&n&&e.current&&n.parentNode===e.current.parentNode?r:tl(n):kd,[n]);return x.useEffect(()=>{e.current=n},[n]),t}
65function ab(n){const[e,t]=x.useState(null),r=x.useRef(n),s=x.useCallback(i=>{const o=El(i.target);o&&t(l=>l?(l.set(o,la(o)),new Map(l)):null)},[]);return x.useEffect(()=>{const i=r.current;if(n!==i){o(i);const l=n.map(a=>{const c=El(a);return c?(c.addEventListener("scroll",s,{passive:!0}),[c,la(c)]):null}).filter(a=>a!=null);t(l.length?new Map(l):null),r.current=n}return()=>{o(n),o(i)};function o(l){l.forEach(a=>{const c=El(a);c==null||c.removeEventListener("scroll",s)})}},[s,n]),x.useMemo(()=>n.length?e?Array.from(e.values()).reduce((i,o)=>ts(i,o),vn):eh(n):vn,[n,e])}function vd(n,e){e===void 0&&(e=[]);const t=x.useRef(null);return x.useEffect(()=>{t.current=null},e),x.useEffect(()=>{const r=n!==vn;r&&!t.current&&(t.current=n),!r&&t.current&&(t.current=null)},[n]),t.current?Js(n,t.current):vn}function cb(n){x.useEffect(()=>{if(!el)return;const e=n.map(t=>{let{sensor:r}=t;return r.setup==null?void 0:r.setup()});return()=>{for(const t of e)t==null||t()}},n.map(e=>{let{sensor:t}=e;return t}))}function db(n,e){return x.useMemo(()=>n.reduce((t,r)=>{let{eventName:s,handler:i}=r;return t[s]=o=>{i(o,e)},t},{}),[n,e])}function rh(n){return x.useMemo(()=>n?j0(n):null,[n])}const Sd=[];function ub(n,e){e===void 0&&(e=fs);const[t]=n,r=rh(t?Jt(t):null),[s,i]=x.useState(Sd);function o(){i(()=>n.length?n.map(a=>Zf(a)?r:new lc(e(a),a)):Sd)}const l=sl({callback:o});return jn(()=>{l==null||l.disconnect(),o(),n.forEach(a=>l==null?void 0:l.observe(a))},[n]),s}function fb(n){if(!n)return null;if(n.children.length>1)return n;const e=n.children[0];return hi(e)?e:n}function hb(n){let{measure:e}=n;
65const[t,r]=x.useState(null),s=x.useCallback(c=>{for(const{target:d}of c)if(hi(d)){r(u=>{const f=e(d);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),i=sl({callback:s}),o=x.useCallback(c=>{const d=fb(c);i==null||i.disconnect(),d&&(i==null||i.observe(d)),r(d?e(d):null)},[e,i]),[l,a]=oo(o);return x.useMemo(()=>({nodeRef:l,rect:t,setRef:a}),[t,l,a])}const pb=[{sensor:rl,options:{}},{sensor:nl,options:{}}],mb={current:{}},Gi={draggable:{measure:md},droppable:{measure:md,strategy:Ys.WhileDragging,frequency:ca.Optimized},dragOverlay:{measure:fs}};class js extends Map{get(e){var t;return e!=null&&(t=super.get(e))!=null?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,r;return(t=(r=this.get(e))==null?void 0:r.node.current)!=null?t:void 0}}const gb={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new js,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:lo},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gi,measureDroppableContainers:lo,windowRect:null,measuringScheduled:!1},yb={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:lo,draggableNodes:new Map,over:null,measureDroppableContainers:lo},il=x.createContext(yb),sh=x.createContext(gb);function bb(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new js}}}function xb(n,e){switch(e.type){case ot.DragStart:return{...n,draggable:{...n.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ot.DragMove:return n.draggable.active==null?n:{...n,draggable:{...n.draggable,translate:{x:e.coordinates.x-n.draggable.initialCoordinates.x,y:e.coordinates.y-n.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...n,draggable:{...n.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:t}=e,{id:r}=t,s=new js(n.droppable.containers);return s.set(r,t),{...n,droppable:{...n.droppable,containers:s}}}case ot.SetDroppableDisabled:{const{id:t,key:r,disabled:s}=e,i=n.droppable.containers.get(t);if(!i||r!==i.key)return n;const o=new js(n.droppable.containers);return o.set(t,{...i,disabled:s}),{...n,droppable:{...n.droppable,containers:o}}}case ot.UnregisterDroppable:{const{id:t,key:r}=e,s=n.droppable.containers.get(t);if(!s||r!==s.key)return n;const i=new js(n.droppable.containers);return i.delete(t),{...n,droppable:{...n.droppable,containers:i}}}default:return n}}function wb(n){let{disabled:e}=n;const{active:t,activatorEvent:r,draggableNodes:s}=x.useContext(il),i=ia(r),o=ia(t==null?void 0:t.id);return x.useEffect(()=>{if(!e&&!r&&i&&o!=null){if(!oc(i)||document.activeElement===i.target)return;const l=s.get(o);if(!l)return;const{activatorNode:a,node:c}=l;if(!a.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[a.current,c.current]){if(!d)continue;const u=p0(d);if(u){u.focus();break}}})}},[r,e,s,o,i]),null}function kb(n,e){let{transform:t,...r}=e;return n!=null&&n.length?n.reduce((s,i)=>i({transform:s,...r}),t):t}function vb(n){return x.useMemo(()=>({draggable:{...Gi.draggable,...n==null?void 0:n.draggable},droppable:{...Gi.droppable,...n==null?void 0:n.droppable},dragOverlay:{...Gi.dragOverlay,...n==null?void 0:n.dragOverlay}}),[n==null?void 0:n.draggable,n==null?void 0:n.droppable,n==null?void 0:n.dragOverlay])}function Sb(n){let{activeNode:e,measure:t,initialRect:r,config:s=!0}=n;const i=x.useRef(!1),{x:o,y:l}=typeof s=="boolean"?{x:s,y:s}:s;jn(()=>{if(!o&&!l||!e){i.current=!1;return}if(i.current||!r)return;const c=e==null?void 0:e.node.current;if(!c||c.isConnected===!1)return;const d=t(c),u=Jf(d,r);if(o||(u.x=0),l||(u.y=0),i.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const f=Gf(c);f&&f.scrollBy({top:u.y,left:u.x})}},[e,o,l,r,t])}const ih=x.createContext({...vn,scaleX:1,scaleY:1});var Qn;(function(n){n[n.Uninitialized=0]="Uninitialized",n[n.Initializing=1]="Initializing",n[n.Initialized=2]="Initialized"})(Qn||(Qn={}));const oh=x.memo(function(e){var t,r,s,i;let{id:o,accessibility:l,autoScroll:a=!0,children:c,sensors:d=pb,collisionDetection:u=T0,measuring:f,modifiers:h,...m}=e;const g=x.useReducer(xb,void 0,bb),[y,b]=g,[S,C]=w0(),[T,M]=x.useState(Qn.Uninitialized),D=T===Qn.Initialized,{draggable:{active:k,nodes:A,translate:P},droppable:{containers:U}}=y,G=k!=null?A.get(k):null,V=x.useRef({initial:null,translated:null}),ue=x.useMemo(()=>{var _;return k!=null?{id:k,data:(_=G==null?void 0:G.data)!=null?_:mb,rect:V}:null}
65,[k,G]),ae=x.useRef(null),[se,de]=x.useState(null),[ye,Qe]=x.useState(null),be=qs(m,Object.values(m)),De=mi("DndDescribedBy",o),Ue=x.useMemo(()=>U.getEnabled(),[U]),ve=vb(f),{droppableRects:lt,measureDroppableContainers:Me,measuringScheduled:at}=nb(Ue,{dragging:D,dependencies:[P.x,P.y],config:ve.droppable}),$e=eb(A,k),ct=x.useMemo(()=>ye?oa(ye):null,[ye]),ie=Bt(),me=rb($e,ve.draggable.measure);Sb({activeNode:k!=null?A.get(k):null,config:ie.layoutShiftCompensation,initialRect:me,measure:ve.draggable.measure});const Q=wd($e,ve.draggable.measure,me),Te=wd($e?$e.parentElement:null),Ie=x.useRef({activatorEvent:null,active:null,activeNode:$e,collisionRect:null,collisions:null,droppableRects:lt,draggableNodes:A,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),dt=U.getNodeFor((t=Ie.current.over)==null?void 0:t.id),le=hb({measure:ve.dragOverlay.measure}),xe=(r=le.nodeRef.current)!=null?r:$e,Se=D?(s=le.rect)!=null?s:Q:null,Pn=!!(le.nodeRef.current&&le.rect),Gt=ob(Pn?null:Q),pn=rh(xe?Jt(xe):null),Re=lb(D?dt??$e:null),At=ub(Re),Lt=kb(h,{transform:{x:P.x-Gt.x,y:P.y-Gt.y,scaleX:1,scaleY:1},activatorEvent:ye,active:ue,activeNodeRect:Q,containerNodeRect:Te,draggingNodeRect:Se,over:Ie.current.over,overlayNodeRect:le.rect,scrollableAncestors:Re,scrollableAncestorRects:At,windowRect:pn}),ut=ct?ts(ct,P):null,Cn=ab(Re),en=vd(Cn),He=vd(Cn,[Q]),ft=ts(Lt,en),Dt=Se?R0(Se,Lt):null,Rt=ue&&Dt?u({active:ue,collisionRect:Dt,droppableRects:lt,droppableContainers:Ue,pointerCoordinates:ut}):null,zt=Kf(Rt,"id"),[Ye,F]=x.useState(null),Xe=Pn?Lt:ts(Lt,He),kt=A0(Xe,(i=Ye==null?void 0:Ye.re
65ct)!=null?i:null,Q),Pt=x.useRef(null),Mn=x.useCallback((_,Ve)=>{let{sensor:ht,options:Yt}=Ve;if(ae.current==null)return;const pt=A.get(ae.current);if(!pt)return;const vt=_.nativeEvent,$t=new ht({active:ae.current,activeNode:pt,event:vt,options:Yt,context:Ie,onAbort(Ze){if(!A.get(Ze))return;const{onDragAbort:Ft}=be.current,v={id:Ze};Ft==null||Ft(v),S({type:"onDragAbort",event:v})},onPending(Ze,_t,Ft,v){if(!A.get(Ze))return;const{onDragPending:W}=be.current,Y={id:Ze,constraint:_t,initialCoordinates:Ft,offset:v};W==null||W(Y),S({type:"onDragPending",event:Y})},onStart(Ze){const _t=ae.current;if(_t==null)return;const Ft=A.get(_t);if(!Ft)return;const{onDragStart:v}=be.current,O={activatorEvent:vt,active:{id:_t,data:Ft.data,rect:V}};vs.unstable_batchedUpdates(()=>{v==null||v(O),M(Qn.Initializing),b({type:ot.DragStart,initialCoordinates:Ze,active:_t}),S({type:"onDragStart",event:O}),de(Pt.current),Qe(vt)})},onMove(Ze){b({type:ot.DragMove,coordinates:Ze})},onEnd:tn(ot.DragEnd),onCancel:tn(ot.DragCancel)});Pt.current=$t;function tn(Ze){return async function(){const{active:Ft,collisions:v,over:O,scrollAdjustedTranslate:W}=Ie.current;let Y=null;if(Ft&&W){const{cancelDrop:ee}=be.current;Y={activatorEvent:vt,active:Ft,collisions:v,delta:W,over:O},Ze===ot.DragEnd&&typeof ee=="function"&&await Promise.resolve(ee(Y))&&(Ze=ot.DragCancel)}ae.current=null,vs.unstable_batchedUpdates(()=>{b({type:Ze}),M(Qn.Uninitialized),F(null),de(null),Qe(null),Pt.current=null;const ee=Ze===ot.DragEnd?"onDragEnd":"onDragCancel";if(Y){const H=be.current[ee];H==null||H(Y),S({type:ee,event:Y})}})}}},[A]),ps=x.useCallback((_,Ve)=>(ht,Yt)=>{const pt=ht.nativeEvent,vt=A.get(Yt);if(ae.current!==null||!vt||pt.dndKit||pt.defaultPrevented)return;const $t={active:vt};_(ht,Ve.options,$t)===!0&&(pt.dndKit={capturedBy:Ve.sensor},ae.current=Yt,Mn(ht,Ve))},[A,Mn]),mn=tb(d,ps);cb(d),jn(()=>{Q&&T===Qn.Initializing&&M(Qn.Initialized)},[Q,T]),x.useEffect(()=>{const{onDragMove:_}=be.current,{active:Ve,activatorEvent:ht,collisions:Yt,over:pt}=Ie.current;if(!Ve||!ht)return;const vt={active:Ve,activatorEvent:ht,collisions:Yt,delta:{x:ft.x,y:ft.y},over:pt};vs.unstable_batchedUpdates(()=>{_==null||_(vt),S({type:"onDragMove",event:vt})})},[ft.x,ft.y]),x.useEffect(()=>{const{active:_,activatorEvent:Ve,collisions:ht,droppableContainers:Yt,scrollAdjustedTranslate:pt}=Ie.current;if(!_||ae.current==null||!Ve||!pt)return;const{onDragOver:vt}=be.current,$t=Yt.get(zt),tn=$t&&$t.rect.current?{id:$t.id,rect:$t.rect.current,data:$t.data,disabled:$t.disabled}:null,Ze={active:_,activatorEvent:Ve,collisions:ht,delta:{x:pt.x,y:pt.y},over:tn};vs.unstable_batchedUpdates(()=>{F(tn),vt==null||vt(Ze),S({type:"onDragOver",event:Ze})})},[zt]),jn(()=>{Ie.current={activatorEvent:ye,active:ue,activeNode:$e,collisionRect:Dt,collisions:Rt,droppableRects:lt,draggableNodes:A,draggingNode:xe,draggingNodeRect:Se,droppableContainers:U,over:Ye,scrollableAncestors:Re,scrollAdjustedTranslate:ft},V.current={initial:Se,translated:Dt}},[ue,$e,Rt,Dt,A,xe,Se,lt,U,Ye,Re,ft]),X0({...ie,delta:P,draggingRect:Dt,pointerCoordinates:ut,scrollableAncestors:Re,scrollableAncestorRects:At});const fe=x.useMemo(()=>({active:ue,activeNode:$e,activeNodeRect:Q,activatorEvent:ye,collisions:Rt,containerNodeRect:Te,dragOverlay:le,draggableNodes:A,droppableContainers:U,droppableRects:lt,over:Ye,measureDroppableContainers:Me,scrollableAncestors:Re,scrollableAncestorRects:At,measuringConfiguration:ve,measuringScheduled:at,windowRect:pn}),[ue,$e,Q,ye,Rt,Te,le,A,U,lt,Ye,Me,Re,At,ve,at,pn]),_e=x.useMemo(()=>({activatorEvent:ye,activators:mn,active:ue,activeNodeRect:Q,ariaDescribedById:{draggable:De},dispatch:b,draggableNodes:A,over:Ye,measureDroppableContainers:Me}),[ye,mn,ue,Q,b,De,A,Ye,Me]);return Ce.createElement(Hf.Provider,{value:C},Ce.createElement(il.Provider,{value:_e},Ce.createElement(sh.Provider,{value:fe},Ce.createElement(ih.Provider,{value:kt},c)),Ce.createElement(wb,{disabled:(l==null?void 0:l.restoreFocus)===!1})),Ce.createElement(S0,{...l,hiddenTextDescribedById:De}));function Bt(){const _=(se==null?void 0:se.autoScrollEnabled)===!1,Ve=typeof a=="object"?a.enabled===!1:a===!1,ht=D&&!_&&!Ve;return typeof a=="object"?{...a,enabled:ht}:{enabled:ht}}}),Cb=x.createContext(null),Cd="button",Mb="Draggable";function Eb(n){let{id:e,data:t,disabled:r=!1,attributes:s}=n;const i=mi(Mb),{activators:o,activatorEvent:l,active:a,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:f}=x.useContext(il),{role:h=Cd,roleDescription:m="draggable",tabIndex:g=0}=s??{}
65,y=(a==null?void 0:a.id)===e,b=x.useContext(y?ih:Cb),[S,C]=oo(),[T,M]=oo(),D=db(o,e),k=qs(t);jn(()=>(u.set(e,{id:e,key:i,node:S,activatorNode:T,data:k}),()=>{const P=u.get(e);P&&P.key===i&&u.delete(e)}),[u,e]);const A=x.useMemo(()=>({role:h,tabIndex:g,"aria-disabled":r,"aria-pressed":y&&h===Cd?!0:void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[r,h,g,y,m,d.draggable]);return{active:a,activatorEvent:l,activeNodeRect:c,attributes:A,isDragging:y,listeners:r?void 0:D,node:S,over:f,setNodeRef:C,setActivatorNodeRef:M,transform:b}}function Tb(){return x.useContext(sh)}const Ab="Droppable",Db={timeout:25};function Rb(n){let{data:e,disabled:t=!1,id:r,resizeObserverConfig:s}=n;const i=mi(Ab),{active:o,dispatch:l,over:a,measureDroppableContainers:c}=x.useContext(il),d=x.useRef({disabled:t}),u=x.useRef(!1),f=x.useRef(null),h=x.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:y}={...Db,...s},b=qs(g??r),S=x.useCallback(()=>{if(!u.current){u.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{c(Array.isArray(b.current)?b.current:[b.current]),h.current=null},y)},[y]),C=sl({callback:S,disabled:m||!o}),T=x.useCallback((A,P)=>{C&&(P&&(C.unobserve(P),u.current=!1),A&&C.observe(A))},[C]),[M,D]=oo(T),k=qs(e);return x.useEffect(()=>{!C||!M.current||(C.disconnect(),u.current=!1,C.observe(M.current))},[M,C]),x.useEffect(()=>(l({type:ot.RegisterDroppable,element:{id:r,key:i,disabled:t,node:M,rect:f,data:k}}),()=>l({type:ot.UnregisterDroppable,key:i,id:r})),[r]),x.useEffect(()=>{t!==d.current.disabled&&(l({type:ot.SetDroppableDisabled,id:r,key:i,disabled:t}),d.current.disabled=t)},[r,i,t,l]),{active:o,rect:f,isOver:(a==null?void 0:a.id)===r,node:M,over:a,setNodeRef:D}}function cc(n,e,t){const r=n.slice();return r.splice(t<0?r.length+t:t,0,r.splice(e,1)[0]),r}function Nb(n,e){return n.reduce((t,r,s)=>{const i=e.get(r);return i&&(t[s]=i),t},Array(n.length))}function Ei(n){return n!==null&&n>=0}function Ob(n,e){if(n===e)return!0;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Ib(n){return typeof n=="boolean"?{draggable:n,droppable:n}:n}const Ti={scaleX:1,scaleY:1},jb=n=>{var e;let{rects:t,activeNodeRect:r,activeIndex:s,overIndex:i,index:o}=n;const l=(e=t[s])!=null?e:r;if(!l)return null;const a=Lb(t,o,s);if(o===s){const c=t[i];return c?{x:s<i?c.left+c.width-(l.left+l.width):c.left-l.left,y:0,...Ti}:null}return o>s&&o<=i?{x:-l.width-a,y:0,...Ti}:o<s&&o>=i?{x:l.width+a,y:0,...Ti}:{x:0,y:0,...Ti}};
65function Lb(n,e,t){const r=n[e],s=n[e-1],i=n[e+1];return!r||!s&&!i?0:t<e?s?r.left-(s.left+s.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(s.left+s.width)}const lh=n=>{let{rects:e,activeIndex:t,overIndex:r,index:s}=n;const i=cc(e,r,t),o=e[s],l=i[s];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},Ai={scaleX:1,scaleY:1},zb=n=>{var e;let{activeIndex:t,activeNodeRect:r,index:s,rects:i,overIndex:o}=n;const l=(e=i[t])!=null?e:r;if(!l)return null;if(s===t){const c=i[o];return c?{x:0,y:t<o?c.top+c.height-(l.top+l.height):c.top-l.top,...Ai}:null}const a=Pb(i,s,t);return s>t&&s<=o?{x:0,y:-l.height-a,...Ai}:s<t&&s>=o?{x:0,y:l.height+a,...Ai}:{x:0,y:0,...Ai}};function Pb(n,e,t){const r=n[e],s=n[e-1],i=n[e+1];return r?t<e?s?r.top-(s.top+s.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const ah="Sortable",ch=Ce.createContext({activeIndex:-1,containerId:ah,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lh,disabled:{draggable:!1,droppable:!1}});function dh(n){let{children:e,id:t,items:r,strategy:s=lh,disabled:i=!1}=n;const{active:o,dragOverlay:l,droppableRects:a,over:c,measureDroppableContainers:d}=Tb(),u=mi(ah,t),f=l.rect!==null,h=x.useMemo(()=>r.map(D=>typeof D=="object"&&"id"in D?D.id:D),[r]),m=o!=null,g=o?h.indexOf(o.id):-1,y=c?h.indexOf(c.id):-1,b=x.useRef(h),S=!Ob(h,b.current),C=y!==-1&&g===-1||S,T=Ib(i);jn(()=>{S&&m&&d(h)},[S,h,m,d]),x.useEffect(()=>{b.current=h},[h]);const M=x.useMemo(()=>({activeIndex:g,containerId:u,disabled:T,disableTransforms:C,items:h,overIndex:y,useDragOverlay:f,sortedRects:Nb(h,a),strategy:s}),[g,u,T.draggable,T.droppable,C,h,y,a,f,s]);return Ce.createElement(ch.Provider,{value:M},e)}const Bb=n=>{let{id:e,items:t,activeIndex:r,overIndex:s}=n;return cc(t,r,s).indexOf(e)},$b=n=>{let{containerId:e,isSorting:t,wasDragging:r,index:s,items:i,newIndex:o,previousItems:l,previousContainerId:a,transition:c}=n;return!c||!r||l!==i&&s===o?!1:t?!0:o!==s&&e===a},_b={duration:200,easing:"ease"},uh="transform",Fb=Gs.Transition.toString({property:uh,duration:0,easing:"linear"}),Hb={roleDescription:"sortable"};function Vb(n){let{disabled:e,index:t,node:r,rect:s}=n;const[i,o]=x.useState(null),l=x.useRef(t);return jn(()=>{if(!e&&t!==l.current&&r.current){const a=s.current;if(a){const c=fs(r.current,{ignoreTransform:!0}),d={x:a.left-c.left,y:a.top-c.top,scaleX:a.width/c.width,scaleY:a.height/c.height};(d.x||d.y)&&o(d)}}t!==l.current&&(l.current=t)},[e,t,r,s]),x.useEffect(()=>{i&&o(null)},[i]),i}function Wb(n){let{animateLayoutChanges:e=$b,attributes:t,disabled:r,data:s,getNewIndex:i=Bb,id:o,strategy:l,resizeObserverConfig:a,transition:c=_b}=n;const{items:d,containerId:u,activeIndex:f,disabled:h,disableTransforms:m,sortedRects:g,overIndex:y,useDragOverlay:b,strategy:S}=x.useContext(ch),C=Ub(r,h),T=d.indexOf(o),M=x.useMemo(()=>({sortable:{containerId:u,index:T,items:d},...s}),[u,s,T,d]),D=x.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:A,isOver:P,setNodeRef:U}=Rb({id:o,data:M,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...a}}),{active:G,activatorEvent:V,activeNodeRect:ue,attributes:ae,setNodeRef:se,listeners:de,isDragging:ye,over:Qe,setActivatorNodeRef:be,transform:De}=Eb({id:o,data:M,attributes:{...Hb,...t},disabled:C.draggable}),Ue=d0(U,se),ve=!!G,lt=ve&&!m&&Ei(f)&&Ei(y),Me=!b&&ye,at=Me&<?De:null,ct=lt?at??(l??S)({rects:g,activeNodeRect:ue,activeIndex:f,overIndex:y,index:T}):null,ie=Ei(f)&&Ei(y)?i({id:o,items:d,activeIndex:f,overIndex:y}):T,me=G==null?void 0:G.id,Q=x.useRef({activeId:me,items:d,newIndex:ie,containerId:u}),Te=d!==Q.current.items,Ie=e({active:G,containerId:u,isDragging:ye,isSorting:ve,id:o,index:T,items:d,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:Q.current.activeId!=null}),dt=Vb({disabled:!Ie,index:T,node:A,rect:k});return x.useEffect(()=>{ve&&Q.current.newIndex!==ie&&(Q.current.newIndex=ie),u!==Q.current.containerId&&(Q.current.containerId=u),d!==Q.current.items&&(Q.current.items=d)},[ve,ie,u,d]),x.useEffect(()=>{if(me===Q.current.activeId)return;if(me!=null&&Q.current.activeId==null){Q.current.activeId=me;return}const xe=setTimeout(()=>{Q.current.activeId=me},50);return()=>clearTimeout(xe)},[me]),{active:G,activeIndex:f,attributes:ae,data:M,rect:k,index:T,newIndex:ie,items:d,isOver:P,isSorting:ve,isDragging:ye,listeners:de,node:A,overIndex:y,over:Qe,setNodeRef:Ue,setActivatorNodeRef:be,
65setDroppableNodeRef:U,setDraggableNodeRef:se,transform:dt??ct,transition:le()};function le(){if(dt||Te&&Q.current.newIndex===T)return Fb;if(!(Me&&!oc(V)||!c)&&(ve||Ie))return Gs.Transition.toString({...c,property:uh})}}function Ub(n,e){var t,r;return typeof n=="boolean"?{draggable:n,droppable:!1}:{draggable:(t=n==null?void 0:n.draggable)!=null?t:e.draggable,droppable:(r=n==null?void 0:n.droppable)!=null?r:e.droppable}}function uo(n){if(!n)return!1;const e=n.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const Kb=[he.Down,he.Right,he.Up,he.Left],fh=(n,e)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:i,over:o,scrollableAncestors:l}}=e;if(Kb.includes(n.code)){if(n.preventDefault(),!t||!r)return;const a=[];i.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const f=s.get(u.id);if(f)switch(n.code){case he.Down:r.top<f.top&&a.push(u);break;case he.Up:r.top>f.top&&a.push(u);break;case he.Left:r.left>f.left&&a.push(u);break;case he.Right:r.left<f.left&&a.push(u);break}});const c=M0({collisionRect:r,droppableRects:s,droppableContainers:a});let d=Kf(c,"id");if(d===(o==null?void 0:o.id)&&c.length>1&&(d=c[1].id),d!=null){const u=i.get(t.id),f=i.get(d),h=f?s.get(f.id):null,m=f==null?void 0:f.node.current;if(m&&h&&u&&f){const y=tl(m).some((D,k)=>l[k]!==D),b=hh(u,f),S=qb(u,f),C=y||!b?{x:0,y:0}:{x:S?r.width-h.width:0,y:S?r.height-h.height:0},T={x:h.left,y:h.top};return C.x&&C.y?T:Js(T,C)}}}};function hh(n,e){return!uo(n)||!uo(e)?!1:n.data.current.sortable.containerId===e.data.current.sortable.containerId}function qb(n,e){return!uo(n)||!uo(e)||!hh(n,e)?!1:n.data.current.sortable.index<e.data.current.sortable.index}const Md=24,Ed=14,Jb=[{id:"blank",name:"Blank",blocks:[]},{id:"title-slide",name:"Title slide",blocks:[{block_type:"title",heading_level:1,x:3,y:4,w:18,h:3},{block_type:"paragraph",x:3,y:7,w:18,h:2}]},{id:"title-and-body",name:"Title and body",blocks:[{block_type:"title",heading_level:1,x:1,y:1,w:22,h:2},{block_type:"paragraph",x:1,y:3,w:22,h:10}]},{id:"title-only",name:"Title only",blocks:[{block_type:"title",heading_level:1,x:1,y:1,w:22,h:2}]},{id:"section-header",name:"Section header",blocks:[{block_type:"paragraph",x:2,y:8,w:8,h:1},{block_type:"title",heading_level:1,x:2,y:9,w:20,h:3}]},{id:"section-title-description",name:"Section title and description",blocks:[{block_type:"title",heading_level:1,x:1,y:3,w:10,h:5},{block_type:"paragraph",x:12,y:3,w:11,h:8}]},{id:"one-column-text",name:"One column text",blocks:[{block_type:"title",heading_level:1,x:1,y:1,w:22,h:2},{block_type:"paragraph",x:6,y:3,w:12,h:10}]},{id:"picture-caption",name:"Picture with caption",blocks:[{block_type:"image",x:3,y:1,w:18,h:10},{block_type:"paragraph",x:3,y:11,w:18,h:2}]},{id:"two-content",name:"Two content",blocks:[{block_type:"title",heading_level:1,x:1,y:1,w:22,h:2},{block_type:"paragraph",x:1,y:3,w:11,h:10},{block_type:"paragraph",x:12,y:3,w:11,h:10}]}],Gb=Jb.map(n=>({...n,blocks:n.blocks.map(e=>({...e,x:e.x/Md*100,y:e.y/Ed*100,w:e.w/Md*100,h:e.h/Ed*100}))})),Di=1e-6;function Yb(n){for(const e of n.blocks)if(e.x<-Di||e.y<-Di||e.x+e.w>100+Di||e.y+e.h>100+Di)return console.error(`Slide layout "${n.id}" has an out-of-bounds block (x=${e.x} y=${e.y} w=${e.w} h=${e.h}); must fit within 0â100% of the slide. Dropping this preset.`),!1;return!0}const Xb=Gb.filter(Yb);async function Zb(n,e,t,r){const s=await n.createPage(e,r);try{for(const i of t.blocks)await n.addBlock(e,{block_type:i.block_type,page_id:s.id,heading_level:i.heading_level,text_content:"",x:i.x,y:i.y,w:i.w,h:i.h,...i.block_type!=="image"&&{auto_height:!1}})}catch(i){try{await n.deletePage(e,s.id,!0)}catch{}throw i}return s}const ph=.5,mh=3,da=1.1;function Yi(n){return Math.min(mh,Math.max(ph,n))}function Qb(n,e){if(e===0)return n;const t=Math.min(Math.abs(e)/50,1),r=Math.pow(da,t);return Yi(e<0?n*r:n/r)}function ex(n){return n.ctrlKey||n.metaKey}/** 66 * @license @tabler/icons-react v3.41.1 - MIT 67 * 68 * This source code is licensed under the MIT license. 69 * See the LICENSE file in the root directory of this source tree. 70 */const tx=[["path",{d:"M5 12l14 0",key:"svg-0"}]],gh=pe("outline","minus","Minus",tx);/**
vendor: 9,944 bytes, lines 71-75
71 * @license @tabler/icons-react v3.41.1 - MIT 72 * 73 * This source code is licensed under the MIT license. 74 * See the LICENSE file in the root directory of this source tree. 75 */const nx=[["path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6l0 -7",key:"svg-0"}],["path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7",key:"svg-1"}]],yh=pe("outline","bold","Bold",nx);function Ct(n){this.content=n}Ct.prototype={constructor:Ct,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Ct(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ct(t)},addToStart:function(n,e){return new Ct([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ct(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Ct(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ct.from(n),n.size?new Ct(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ct.from(n),n.size?new Ct(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ct.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Ct.from=function(n){if(n instanceof Ct)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ct(e)};function bh(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&kh(o.charCodeAt(a-1))&&wh(o.charCodeAt(a))&&t--,t}if(s.content.size||i.content.size){let o=bh(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function xh(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,d=l.text,u=c.length,f=d.length;for(;u>0&&f>0&&c[u-1]==d[f-1];)u--,f--,t--,r--;return u&&f&&u<c.length&&kh(c.charCodeAt(u-1))&&wh(c.charCodeAt(u))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=xh(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function wh(n){return n>=56320&&n<57344}function kh(n){return n>=55296&&n<56320}class N{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new N(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new N(r,s)}cutByIndex(e,t){return e==t?N.empty:e==0&&t==this.content.length?this:new N(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new N(s,i)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return bh(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return xh(this,e,t,r)}findIndex(e){if(e==0)return Ri(0,e);if(e==this.size)return Ri(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?Ri(t+1,i):Ri(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return N.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return N.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new N(t||e,r)}static from(e){if(!e)return N.empty;if(e instanceof N)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new N([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}N.empty=new N([],0);const Dl={index:0,offset:0};function Ri(n,e){return Dl.index=n,Dl.offset=e,Dl}function fo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!fo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!fo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ae=class ua{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&fo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ua.none;if(e instanceof ua)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Ae.none=[];class Xs extends Error{}class z{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Sh(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new z(r,this.openStart,this.openEnd)}removeBetween(e,t){return new z(vh(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return z.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z(N.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new z(e,r,s)}}z.empty=new z(N.empty,0,0);function vh(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(vh(i.content,e-s-1,t-s-1)))}function Sh(n,e,t,r,s,i){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Sh(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?s-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function rx(n,e,t){if(t.openStart>
vendor: 4,752 bytes, line 75
75n.depth)throw new Xs("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xs("Inconsistent open depths");return Ch(n,e,t,0)}function Ch(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Ch(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Rr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=sx(t,n);return Rr(i,Eh(n,o,l,e,r))}else return Rr(i,ho(n,e,r))}function Mh(n,e){if(!e.type.compatibleContent(n.type))throw new Xs("Cannot join "+e.type.name+" onto "+n.type.name)}function fa(n,e,t){let r=n.node(t);return Mh(r,e.node(t)),r}function Dr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ls(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Dr(n.nodeAfter,r),i++));for(let l=i;l<o;l++)Dr(s.child(l),r);e&&e.depth==t&&e.textOffset&&Dr(e.nodeBefore,r)}function Rr(n,e){if(!n.type.validContent(e))throw new Xs("Invalid content for node "+n.type.name);return n.copy(e)}function Eh(n,e,t,r,s){let i=n.depth>s&&fa(n,e,s+1),o=r.depth>s&&fa(t,r,s+1),l=[];return Ls(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Mh(i,o),Dr(Rr(i,Eh(n,e,t,r,s+1)),l)):(i&&Dr(Rr(i,ho(n,e,s+1)),l),Ls(e,t,s,l),o&&Dr(Rr(o,ho(t,r,s+1)),l)),Ls(r,null,s,l),new N(l)}function ho(n,e,t){let r=[];if(Ls(null,n,t,r),n.depth>t){let s=fa(n,e,t+1);Dr(Rr(s,ho(n,e,t+1)),r)}return Ls(e,null,t,r),new N(r)}function sx(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(N.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Zs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ae.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new po(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new Zs(t,r,i)}
vendor: 4,381 bytes, line 75
75static resolveCached(e,t){let r=Td.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else Td.set(e,r=new ix);let s=r.elts[r.i]=Zs.resolve(e,t);return r.i=(r.i+1)%ox,s}}class ix{constructor(){this.elts=[],this.i=0}}const ox=12,Td=new WeakMap;class po{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const lx=Object.create(null);let cr=class ha{constructor(e,t,r,s=Ae.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&fo(this.attrs,t||e.defaultAttrs||lx)&&Ae.sameSet(this.marks,r||Ae.none)}copy(e=null){return e==this.content?this:new ha(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ha(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return z.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new z(c,s.depth-o,i.depth-o)}replace(e,t,r){return rx(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return Zs.resolveCached(this,e)}resolveNoCache(e){return Zs.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Th(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=N.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ae.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ae.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}
75`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=N.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};cr.prototype.text=void 0;class mo extends cr{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Th(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mo(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Th(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Lr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ax(e,t);if(r.next==null)return Lr.empty;let s=Ah(r);r.next&&r.err("Unexpected trailing text");let i=mx(px(s));return gx(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return N.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(` 76`)}}Lr.empty=new Lr(!0);class ax{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ah(n){let e=[];do e.push(cx(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cx(n){let e=[];do e.push(dx(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dx(n){let e=hx(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ux(n,e);else break;return e}function Ad(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ux(n,e){let t=Ad(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ad(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function fx(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function hx(n){if(n.eat("(")){let e=Ah(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=fx(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function px(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=t();s(i(o.expr,a),d),a=d}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=t();r(a,d),s(i(o.expr,a),d),a=d}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Dh(n,e){return e-n}function Dd(n,e){let t=[];return r(e),t.sort(Dh);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function mx(n){let e=Object.create(null);return t(Dd(n,0));function t(r){let s=[];r.forEach(o=>
vendor: 6,108 bytes, line 76
76{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Dd(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Lr(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Dh);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function gx(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Rh(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Nh(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Oh(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${r}`);for(let s in n)n[s].validate&&n[s].validate(e[s])}function Ih(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new bx(n,r,e[r]);return t}let Rd=class jh{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ih(e,r.attrs),this.defaultAttrs=Rh(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Lr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Nh(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new cr(this,this.computeAttrs(e),N.from(t),Ae.setFrom(r))}createChecked(e=null,t,r){return t=N.from(t),this.checkContent(t),new cr(this,this.computeAttrs(e),t,Ae.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=N.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(N.empty,!0);return i?new cr(this,e,t.append(i),Ae.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Oh(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ae.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new jh(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function yx(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class bx{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?yx(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ol{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Ih(e,s.attrs),this.excluded=null;let i=Rh(this.attrs);this.instance=i?new Ae(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ae(this,Nh(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new ol(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Oh(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Lh{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Ct.from(e.nodes),t.marks=Ct.from(e.marks||{}),this.nodes=Rd.compile(this.spec.nodes,this),this.marks=ol.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Lr.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Nd(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Nd(this,o.split(" "))}this.nodeFromJSON=s=>cr.fromJSON(this,s),this.markFromJSON=s=>Ae.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);
vendor: 2,896 bytes, line 76
76else if(e instanceof Rd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new mo(r,r.defaultAttrs,e,Ae.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Nd(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function xx(n){return n.tag!=null}function wx(n){return n.style!=null}class dr{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(xx(s))this.tags.push(s);else if(wx(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Id(this,t,!1);return r.addAll(e,Ae.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Id(this,t,!0);return r.addAll(e,Ae.none,t.from,t.to),z.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Sx(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=jd(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=jd(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new dr(e,dr.schemaRules(e)))}}const zh={address:!0,article:!0,aside:!0,blockquote:!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},kx={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ph={ol:!0,ul:!0}
vendor: 4,248 bytes, lines 76-78
76,Qs=1,pa=2,zs=4;function Od(n,e,t){return e!=null?(e?Qs:0)|(e==="full"?pa:0):n&&n.whitespace=="pre"?Qs|pa:t&~zs}class Ni{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ae.none,this.match=i||(o&zs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(N.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qs)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=N.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!zh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Id{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=Od(null,t.preserveWhitespace,0)|(r?zs:0);s?i=new Ni(s.type,s.attrs,Ae.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new Ni(null,null,Ae.none,!0,null,o):i=new Ni(e.schema.topNodeType,null,Ae.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&pa?"full":this.localPreserveWS||(s.options&Qs)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` 77`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Ph.hasOwnProperty(o)&&this.parser.normalizeLists&&vx(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:kx.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(zh.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 78`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;
vendor: 4,119 bytes, line 78
78if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ae.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Ld(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Od(e,i,o.options);o.options&zs&&o.content.length==0&&(l|=zs);let a=Ae.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Ld(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ni(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Qs)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];
vendor: 4,471 bytes, line 78
78if(r.isTextblock&&r.defaultAttrs)return r}}}function vx(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ph.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Sx(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function jd(n){let e={};for(let t in n)e[t]=n[t];return e}function Ld(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class Vr{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Oi(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){if(e.isText)return Oi(t).createTextNode(e.text);let{dom:r,contentDOM:s}=Xi(Oi(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Xi(Oi(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return typeof t=="string"?{dom:e.createTextNode(t)}:Xi(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=zd(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return zd(e.marks)}}function zd(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Oi(n){return n.document||window.document}const Pd=new WeakMap;function Cx(n){let e=Pd.get(n);return e===void 0&&Pd.set(n,e=Mx(n)),e}function Mx(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Xi(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Cx(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:m}=Xi(n,f,t,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const Bh=65535,$h=Math.pow(2,16);function Ex(n,e){return n+e*$h}function Bd(n){return n&Bh}function Tx(n){return(n-(n&Bh))/$h}const _h=1,Fh=2,Zi=4,Hh=8;class ma{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Hh)>0}get deletedBefore(){return(this.delInfo&(_h|Zi))>0}get deletedAfter(){return(this.delInfo&(Fh|Zi))>0}get deletedAcross(){return(this.delInfo&Zi)>0}}class Xt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Xt.empty)return Xt.empty}recover(e){let t=0,r=Bd(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Tx(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;
vendor: 6,633 bytes, line 78
78for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let m=e==(t<0?a:u)?null:Ex(l/3,e-a),g=e==a?Fh:e==u?_h:Zi;return(t<0?e!=a:e!=u)&&(g|=Hh),new ma(h,g,m)}s+=d-c}return r?e+s:new ma(e+s,0,null)}touches(e,t){let r=0,s=Bd(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new Xt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Xt.empty:new Xt(e<0?[0,-e,0]:[0,0,e])}}Xt.empty=new Xt([]);class ei{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ei(this._maps,this.mirror,e,t)}appendMap(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),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new ei;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new ma(e,s,null)}}const Rl=Object.create(null);class jt{getMap(){return Xt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Rl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Rl)throw new RangeError("Duplicate use of step JSON ID "+e);return Rl[e]=t,t.prototype.jsonID=e,t}}class nt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new nt(e,null)}static fail(e){return new nt(null,e)}static fromReplace(e,t,r,s){try{return nt.ok(e.replace(t,r,s))}catch(i){if(i instanceof Xs)return nt.fail(i.message);throw i}}}function dc(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(dc(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return N.fromArray(r)}class ir extends jt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new z(dc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return nt.fromReplace(e,this.from,this.to,i)}invert(){return new On(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ir(t.pos,r.pos,this.mark)}merge(e){return e instanceof ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ir(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ir(t.from,t.to,e.markFromJSON(t.mark))}}jt.jsonID("addMark",ir);class On extends jt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new z(dc(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return nt.fromReplace(e,this.from,this.to,r)}invert(){return new ir(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new On(t.pos,r.pos,this.mark)}merge(e){return e instanceof On&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new On(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new On(t.from,t.to,e.markFromJSON(t.mark))}}jt.jsonID("removeMark",On);class or extends jt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return nt.fromReplace(e,this.pos,this.pos+1,new z(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new or(this.pos,t.marks[s]);return new or(this.pos,this.mark)}}return new zr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new or(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new or(t.pos,e.markFromJSON(t.mark))}}jt.jsonID("addNodeMark",or);class zr extends jt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return nt.fromReplace(e,this.pos,this.pos+1,new z(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new or(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zr(t.pos,this.mark)}
vendor: 10,168 bytes, lines 78-79
78toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new zr(t.pos,e.markFromJSON(t.mark))}}jt.jsonID("removeNodeMark",zr);class tt extends jt{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&ga(e,this.from,this.to)?nt.fail("Structure replace would overwrite content"):nt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Xt([this.from,this.to-this.from,this.slice.size])}invert(e){return new tt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&tt.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new tt(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof tt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?z.empty:new z(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new tt(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?z.empty:new z(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new tt(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new tt(t.from,t.to,z.fromJSON(e,t.slice),!!t.structure)}}tt.MAP_BIAS=1;jt.jsonID("replace",tt);class yt extends jt{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ga(e,this.from,this.gapFrom)||ga(e,this.gapTo,this.to)))return nt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return nt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?nt.fromReplace(e,this.from,this.to,r):nt.fail("Content does not fit in gap")}getMap(){return new Xt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new yt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new yt(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yt(t.from,t.to,t.gapFrom,t.gapTo,z.fromJSON(e,t.slice),t.insert,!!t.structure)}}jt.jsonID("replaceAround",yt);function ga(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function Ax(n,e,t,r){let s=[],i=[],o,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),m=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(m)||(o&&o.to==f&&o.mark.eq(u[g])?o.to=h:s.push(o=new On(f,h,u[g])));l&&l.to==f?l.to=h:i.push(l=new ir(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Dx(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof ol){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==i-1&&u.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new On(o.from,o.to,o.style)))}function uc(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new tt(l,d,z.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new On(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new z(N.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new tt(l+f.index,l+f.index+f[0].length,m))}}l=d}if(!r.validEnd){let a=r.fillBefore(N.empty,!0);n.replace(l,l,new z(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Rx(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function hs(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,i=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-i;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!Rx(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function Nx(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,d=N.empty,u=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,d=N.from(r.node(m).copy(d)),u++):a--;let f=N.empty,h=0;for(let m=i,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=N.from(s.node(m).copy(f)),h++):c++;n.step(new yt(a,c,o,l,new z(d.append(f),u,h),d.size-u,!0))}function fc(n,e,t=null,r=n){let s=Ox(n,e),i=s&&Ix(r,e);return i?s.map($d).concat({type:e,attrs:t}).concat(i.map($d)):null}function $d(n){return{type:n,attrs:null}}function Ox(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function Ix(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function jx(n,e,t){let r=N.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=N.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new yt(s,i,s,i,new z(r,0,0),t.length,!0))}function Lx(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&zx(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&Wh(n,o,l,i),uc(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return n.step(new yt(u,f,u+1,f-1,new z(N.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Vh(n,o,l,i),!1}})}function Vh(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Wh(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(` 79`))}})}function zx(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Px(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new yt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new z(N.from(o),0,0),1,!0))}function qn(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),m=r&&r[d+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Bx(n,e,t=1,r){let s=n.doc.resolve(e),i=N.empty,o=N.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=N.from(s.node(l).copy(i));let d=r&&r[c];o=N.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}n.step(new tt(e,e,new z(i.append(o),t,t),!0))}function yr(n,e){let t=n.resolve(e),r=t.index();return Uh(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function $x(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Uh(n,e){return!!(n&&e&&!n.isLeaf&&$x(n,e))}function ll(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;
vendor: 6,913 bytes, line 79
79s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Uh(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function _x(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Wh(n,d.node(),d.before(),l)}o.inlineContent&&uc(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new tt(c,a.map(e+t,-1),z.empty,!0)),r===!0){let d=n.doc.resolve(c);Vh(n,d.node(),d.before(),n.steps.length)}return n}function Fx(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Kh(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function al(n,e,t=e,r=z.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return qh(s,i,r)?new tt(e,t,r):new Hx(s,i,r).fit()}function qh(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Hx{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=N.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=N.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new z(i,o,l);return e>-1?new yt(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new tt(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Nl(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(N.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Nl(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new z(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Nl(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new z(Cs(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new z(Cs(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(Jh(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let m=c==l.childCount;m||(h=-1),this.placed=Ms(this.placed,t,N.from(d)),this.frontier[t].match=u,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=m?e==0?z.empty:new z(Cs(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new z(Cs(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ol(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Ol(e,t,s,r,i);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Ol(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ms(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Ms(this.placed,this.depth,N.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(N.empty,!0);t.childCount&&(this.placed=Ms(this.placed,this.frontier.length,t))}}function Cs(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Cs(n.firstChild.content,e-1,t)))}function Ms(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ms(n.lastChild.content,e-1,t)))}function Nl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Jh(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Jh(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.t
vendor: 14,696 bytes, line 79
79ype.contentMatch.matchFragment(r).fillBefore(N.empty,!0)))),n.copy(r)}function Ol(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Vx(t,i.content,o)?l:null}function Vx(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Wx(n){return n.spec.defining||n.spec.definingForContent}function Ux(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(qh(s,i,r))return n.step(new tt(e,t,r));let o=Yh(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let m=f.firstChild;if(c.push(m),h==r.openStart)break;f=m.content}for(let f=d-1;f>=0;f--){let h=c[f],m=Wx(h.type);if(m&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(m||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let S=s.node(y-1),C=s.index(y-1);if(S.canReplaceWith(C,C,m.type,m.marks))return n.replace(s.before(y),b?i.after(y):t,new z(Gh(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function Gh(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Gh(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(N.empty,!0))}return n}function Kx(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Fx(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new z(N.from(r),0,0))}function qx(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&t==s.start(a);a--)t=s.before(a);r=n.doc.resolve(e),s=n.doc.resolve(t)}}let i=Yh(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Yh(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class ns extends jt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return nt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return nt.fromReplace(e,this.pos,this.pos+1,new z(N.from(s),0,t.isLeaf?0:1))}getMap(){return Xt.empty}invert(e){return new ns(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ns(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ns(t.pos,t.attr,t.value)}}jt.jsonID("attr",ns);class ti extends jt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return nt.ok(r)}getMap(){return Xt.empty}invert(e){return new ti(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ti(t.attr,t.value)}}jt.jsonID("docAttr",ti);let is=class extends Error{};is=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};is.prototype=Object.create(Error.prototype);is.prototype.constructor=is;is.prototype.name="TransformError";class hc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ei}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new is(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),t=s.map(t,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=z.empty){let s=al(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new z(N.from(r),0,0))}delete(e,t){return this.replace(e,t,z.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ux(this,e,t,r),this}replaceRangeWith(e,t,r){return Kx(this,e,t,r),this}deleteRange(e,t){return qx(this,e,t),this}lift(e,t){return Nx(this,e,t),this}join(e,t=1){return _x(this,e,t),this}wrap(e,t){return jx(this,e,t),this}setBlockType(e,t=e,r,s=null){return Lx(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Px(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new ns(e,t,r)),this}setDocAttribute(e,t){return this.step(new ti(e,t)),this}addNodeMark(e,t){return this.step(new or(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Ae)t.isInSet(r.marks)&&this.step(new zr(e,t));else{let s=r.marks,i,o=[];for(;i=t.isInSet(s);)o.push(new zr(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Bx(this,e,t,r),this}addMark(e,t,r){return Ax(this,e,t,r),this}removeMark(e,t,r){return Dx(this,e,t,r),this}clearIncompatible(e,t,r){return uc(this,e,t,r),this}}const Il=Object.create(null);class X{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Xh(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=z.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?z.empty:t),l==0&&Hd(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Hd(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new q(e):Yr(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?Yr(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Yr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Qt(e.node(0))}static atStart(e){return Yr(e,e,0,0,1)||new Qt(e)}static atEnd(e){return Yr(e,e,e.content.size,e.childCount,-1)||new Qt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Il[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Il)throw new RangeError("Duplicate use of selection JSON ID "+e);return Il[e]=t,t.prototype.jsonID=e,t}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Xh{constructor(e,t){this.$from=e,this.$to=t}}let _d=!1;function Fd(n){!_d&&!n.parent.inlineContent&&(_d=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class q extends X{constructor(e,t=e){Fd(e),Fd(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return X.near(r);let s=e.resolve(t.map(this.anchor));return new q(s.parent.inlineContent?s:r,r)}replace(e,t=z.empty){if(super.replace(e,t),t==z.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=X.findFrom(t,r,!0)||X.findFrom(t,-r,!0);if(i)t=i.$head;else return X.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new q(e,t)}}X.jsonID("text",q);class cl{constructor(e,t){this.anchor=e,this.head=t}map(e){return new cl(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class J extends X{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?X.near(i):new J(i)}content(){return new z(N.from(this.node),0,0)}eq(e){return e instanceof J&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new pc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new J(e.resolve(t.anchor))}static create(e,t){return new J(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}J.prototype.visible=!1;X.jsonID("node",J);class pc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new cl(r,r):new pc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&J.isSelectable(r)?new J(t):X.near(t)}}class Qt extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=z.empty){if(t==z.empty){e.delete(0,e.doc.content.size);let r=X.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Qt(e)}map(e){return new Qt(e)}eq(e){return e instanceof Qt}getBookmark(){return Jx}}X.jsonID("all",Qt);const Jx={map(){return this},resolve(n){return new Qt(n)}};function Yr(n,e,t,r,s,i=!1){if(e.inlineContent)return q.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&J.isSelectable(l))return J.create(n,t-(s<0?l.nodeSize:0))}else{let a=Yr(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Hd(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof tt||s instanceof yt))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),n.setSelection(X.near(n.doc.resolve(o),t))}const Vd=1,Ii=2,Wd=4;class Gx extends hc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){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}setSelection(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=(this.updated|Vd)&~Ii,this.storedMarks=null,this}get selectionSet(){return(this.updated&Vd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ii,this}ensureMarks(e){return Ae.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ii)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ii,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ae.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(X.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Wd,this}get scrolledIntoView(){return(this.updated&Wd)>0}}function Ud(n,e){return!e||!n?n:n.bind(e)}class Es{constructor(e,t,r){this.name=e,this.init=Ud(t.init,r),this.apply=Ud(t.a
vendor: 4,403 bytes, line 79
79pply,r)}}const Yx=[new Es("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Es("selection",{init(n,e){return n.selection||X.atStart(e.doc)},apply(n){return n.selection}}),new Es("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Es("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class jl{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Yx.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Es(r.key,r.spec.state,r))})}}class Qr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Qr(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Gx(this)}static create(e){let t=new jl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Qr(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new jl(this.schema,e.plugins),r=t.fields,s=new Qr(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new jl(e.schema,e.plugins),i=new Qr(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=cr.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=X.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Zh(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Zh(s,e,{})),t[r]=s}return t}class st{constructor(e){this.spec=e,this.props={},e.props&&Zh(e.props,this,this.props),this.key=e.key?e.key.key:Qh("plugin")}getState(e){return e[this.key]}}const Ll=Object.create(null);function Qh(n){return n in Ll?n+"$"+ ++Ll[n]:(Ll[n]=0,n+"$")}class Tt{constructor(e="key"){this.key=Qh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Et=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},ls=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ya=null;const Vn=function(n,e,t){let r=ya||(ya=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Xx=function(){ya=null},Pr=function(n,e,t,r){return t&&(Kd(n,e,t,r,-1)||Kd(n,e,t,r,1))},Zx=/^(img|br|input|textarea|hr)$/i;function Kd(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;
vendor: 10,986 bytes, line 79
79if(e==(s<0?0:dn(n))){let o=n.parentNode;if(!o||o.nodeType!=1||gi(n)||Zx.test(n.nodeName)||n.contentEditable=="false")return!1;e=Et(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else n=o,e=s<0?dn(n):0}else return!1}}function dn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qx(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=dn(n)}else if(n.parentNode&&!gi(n))e=Et(n),n=n.parentNode;else return null}}function e1(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!gi(n))e=Et(n)+1,n=n.parentNode;else return null}}function t1(n,e,t){for(let r=e==0,s=e==dn(n);r||s;){if(n==t)return!0;let i=Et(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==dn(n)}}function gi(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const dl=function(n){return n.focusNode&&Pr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function vr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function n1(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function r1(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(dn(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(dn(r.startContainer),r.startOffset)}}}const Ln=typeof navigator<"u"?navigator:null,qd=typeof document<"u"?document:null,br=Ln&&Ln.userAgent||"",ba=/Edge\/(\d+)/.exec(br),ep=/MSIE \d/.exec(br),xa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(br),qt=!!(ep||xa||ba),ur=ep?document.documentMode:xa?+xa[1]:ba?+ba[1]:0,un=!qt&&/gecko\/(\d+)/i.test(br);un&&+(/Firefox\/(\d+)/.exec(br)||[0,0])[1];const wa=!qt&&/Chrome\/(\d+)/.exec(br),gt=!!wa,tp=wa?+wa[1]:0,Ot=!qt&&!!Ln&&/Apple Computer/.test(Ln.vendor),as=Ot&&(/Mobile\/\w+/.test(br)||!!Ln&&Ln.maxTouchPoints>2),cn=as||(Ln?/Mac/.test(Ln.platform):!1),np=Ln?/Win/.test(Ln.platform):!1,Wn=/Android \d/.test(br),yi=!!qd&&"webkitFontSmoothing"in qd.documentElement.style,s1=yi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function i1(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Bn(n,e){return typeof n=="number"?n:n[e]}function o1(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Jd(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=ls(o);continue}let l=o,a=l==i.body,c=a?i1(i):o1(l),d=0,u=0;if(e.top<c.top+Bn(r,"top")?u=-(c.top-e.top+Bn(s,"top")):e.bottom>c.bottom-Bn(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Bn(s,"top")-c.top:e.bottom-c.bottom+Bn(s,"bottom")),e.left<c.left+Bn(r,"left")?d=-(c.left-e.left+Bn(s,"left")):e.right>c.right-Bn(r,"right")&&(d=e.right-c.right+Bn(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,m=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let g=l.scrollLeft-h,y=l.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:ls(o)}}function l1(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(i,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:rp(n.dom)}}function rp(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=ls(r));return e}function a1({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;sp(t,r==0?0:r-e)}function sp(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Jr=null;function c1(n){if(n.setActive)return n.setActive();if(Jr)return n.focus(Jr);let e=rp(n);n.focus(Jr==null?{get preventScroll(){return Jr={preventScroll:!0},!0}}:void 0),Jr||(Jr=!1,sp(e,0))}function ip(n,e){let t,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Vn(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let m=f[h];if(m.top<=o&&m.bottom>=l){o=Math.max(m.bottom,o),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=d,r=g,s=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&g&&(i=u+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?d1(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:ip(t,s)}function d1(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let o=Zn(r,1);if(o.top!=o.bottom&&mc(e,o)){s={node:n,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function mc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function u1(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function f1(n,e,t){let{node:r,offset:s}=ip(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function h1(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function op(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(mc(e,c))return op(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function p1(n,e){let t=n.dom.ownerDocument,r,s=0,i=r1(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!mc(e,c)||(o=op(n.dom,e,c),!o))return null}if(Ot)for(let c=o;r&&c;c=ls(c))c.draggable&&(r=void 0);if(o=u1(o,e),r){if(un&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;yi&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=h1(n,r,s,e))}l==null&&(l=f1(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Gd(n){return n.top<n.bottom||n.left<n.right}function Zn(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Gd(r))return r}return Array.prototype.find.call(t,Gd)||n.getBoundingClientRect()}const m1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function lp(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=yi||un;if(r.nodeType==3)if(o&&(m1.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=Zn(Vn(r,s,s),t);if(un&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Zn(Vn(r,s-1,s-1),-1);if(c.top==a.top){let d=Zn(Vn(r,s,s+1),-1);if(d.top!=a.top)return xs(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,xs(Zn(Vn(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==dn(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return zl(a.getBoundingClientRect(),!1)}if(i==null&&s<dn(r)){let a=r.childNodes[s];if(a.nodeType==1)return zl(a.getBoundingClientRect(),!0)}return zl(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==dn(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Vn(a,dn(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return xs(Zn(c,1),!1)}if(i==null&&s<dn(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Vn(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return xs(Zn(c,-1),!0)}return xs(Zn(r.nodeType==3?Vn(r):r,-t),t>=0)}function xs(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function zl(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function ap(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function g1(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return ap(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=lp(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Vn(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const y1=/[\u0590-\u08ac]/;function b1(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return l?!y1.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:ap(n,e,()=>
vendor: 5,068 bytes, line 79
79{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||a==m&&c==g;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let Yd=null,Xd=null,Zd=!1;function x1(n,e,t){return Yd==e&&Xd==t?Zd:(Yd=e,Xd=t,Zd=t=="up"||t=="down"?g1(n,e,t):b1(n,e,t))}const fn=0,Qd=1,Cr=2,kn=3;class bi{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=fn,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>Et(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof dp){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof cp&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Et(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Et(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let d=o+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=Et(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Et(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);
vendor: 24,650 bytes, lines 79-80
79if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(i>m&&o<y)return g.setSelection(e-m-g.border,t-m-g.border,r,s);m=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((un||Ot)&&e==t){let{node:h,offset:m}=l;if(h.nodeType==3){if(u=!!(m&&h.nodeValue[m-1]==` 80`),u&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Et(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=h.childNodes[m-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(un&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&Ot)&&Pr(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Pr(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&un)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let m=l;l=a,a=m}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?Cr:Qd,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=kn:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Cr:kn}r=o}this.dirty=Cr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Cr:Qd;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class cp extends bi{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==fn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class w1 extends bi{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class fr extends bi{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=Vr.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new fr(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&kn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=kn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=fn){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=fn}}slice(e,t,r){let s=fr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=va(i,t,o,r)),e>0&&(i=va(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class hr extends bi{constructor(e,t,r,s,i,o,l){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,i,o){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Vr.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=hp(d,r,t),c?a=new k1(e,t,r,s,d,u||null,f,c):t.isText?new ul(e,t,r,s,d,f):new hr(e,t,r,s,d,u||null,f)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>N.empty)}return e}matchesNode(e,t,r){return this.dirty==fn&&e.eq(this.node)&&go(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new S1(this,o&&o.node,e);E1(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Ae.none:this.node.child(d).marks,r,e,d),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Cr)&&(o&&this.protectLocalComposition(e,o),up(this.contentDOM,this.children,e),as&&T1(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof q)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=A1(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;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)}let o=new w1(this,i,t,s);e.input.compositionNodes.push(o),this.children=va(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==kn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=fn}updateOuterDeco(e){if(go(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=fp(this.dom,this.nodeDOM,ka(this.outerDeco,this.node,t),ka(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function eu(n,e,t,r,s){hp(r,e,n);let i=new hr(void 0,n,e,t,r,r,r);return i.contentDOM&&i.updateChildren(s,0),i}class ul extends hr{constructor(e,t,r,s,i,o){super(e,t,r,s,i,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==kn||this.dirty!=fn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=fn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=fn,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new ul(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=kn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class dp extends bi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==fn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class k1 extends hr{constructor(e,t,r,s,i,o,l,a){super(e,t,r,s,i,o,l),this.spec=a}update(e,t,r,s){if(this.dirty==kn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function up(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=tu(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(o instanceof fr){let a=r?r.previousSibling:n.lastChild;up(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=tu(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Ps=function(n){n&&(this.nodeName=n)};Ps.prototype=Object.create(null);const Mr=[new Ps];function ka(n,e,t){if(n.length==0)return Mr;let r=t?Mr[0]:new Ps,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ps(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&s.length==1&&s.push(r=new Ps(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function fp(n,e,t,r){if(t==Mr&&r==Mr)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=t[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Mr[0]),s=a}v1(s,l||Mr[0],o)}return s}function v1(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function hp(n,e,t){return fp(n,n,Mr,ka(e,t,n.nodeType!=1))}function go(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function tu(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class S1{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=C1(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=fn,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){a=d;break}}if(a<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof fr&&d.dirty!=kn&&d.mark.type==e[o].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[o])&&(d.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=fr.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==kn&&o.dom==o.contentDOM&&(o.dirty=Cr),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof hr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=kn&&go(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Cr,u.updateChildren(s,o+1),u.dirty=fn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!go(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=hr.create(this.top,t,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,i){let o=hr.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new cp(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof fr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ul)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ot||gt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new dp(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function C1(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof fr)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function M1(n,e){return n.type.side-e.type.side}function E1(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(d?(u||(u=[d])).push(y):d=y)}if(d)if(u){u.sort(M1);for(let y=0;y<u.length;y++)t(u[y],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let m=i+f.nodeSize;if(f.isText){let y=m;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<m&&(a=f.cut(y-i),f=f.cut(0,y-i),m=y,h=-1)}else for(;o<s.length&&s[o].to<m;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(i,f),h),i=m}}function T1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function A1(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function va(n,e,t,r,s){let i=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,r)))}return i}function gc(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(dl(t)){for(a=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&J.isSelectable(u)&&s.parent&&!(u.isInline&&t1(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new J(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(u<0)return null;[a,o]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=yc(n,d,l,u)}return c}function pp(n){return n.editable?n.hasFocus():gp(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Jn(n,e=!1){let t=n.state.selection;if(mp(n,t),!pp(n))return;let r=n.input.mouseDown;if(!e&>&&r){let s=n.domSelectionRange(),i=n.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&Pr(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)R1(n);else{let{anchor:s,head:i}=t,o,l;nu&&!(t instanceof q)&&(t.$from.parent.inlineContent||(o=ru(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=ru(n,t.to))),n.docView.setSelection(s,i,n,e),nu&&(o&&su(o),l&&su(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&D1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const nu=Ot||gt&&tp<63;function ru(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Ot&&s&&s.contentEditable=="false")return Pl(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Pl(s);if(i)return Pl(i)}}function Pl(n){return n.contentEditable="true",Ot&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function su(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function D1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!pp(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function R1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Et(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&qt&&ur<=11&&(t.disabled=!0,t.disabled=!1)}function mp(n,e){if(e instanceof J){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(iu(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else iu(n)}function iu(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function yc(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||q.between(e,t,r)}function ou(n){return n.editable&&!n.hasFocus()?!1:gp(n)}function gp(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function N1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Pr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Sa(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&X.findFrom(i,e)}function er(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function lu(n,e,t){let r=n.state.selection;if(r instanceof q)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return er(n,new q(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Sa(n.state,e);return s&&s instanceof J?er(n,s):!1}else if(!(cn&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?J.isSelectable(i)?er(n,new J(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):yi?er(n,new q(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof J&&r.node.isInline)return er(n,new q(e>0?r.$to:r.$from));{let s=Sa(n.state,e);return s?er(n,s):!1}}}function yo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bs(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Gr(n,e){return e<0?O1(n):I1(n)}function O1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(un&&t.nodeType==1&&r<yo(t)&&Bs(t.childNodes[r],-1)&&(o=!0);;)if(r>
vendor: 4,604 bytes, line 80
800){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bs(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(yp(t))break;{let l=t.previousSibling;for(;l&&Bs(l,-1);)s=t.parentNode,i=Et(l),l=l.previousSibling;if(l)t=l,r=yo(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Ca(n,t,r):s&&Ca(n,s,i)}function I1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=yo(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bs(l,1))i=t,o=++r;else break}else{if(yp(t))break;{let l=t.nextSibling;for(;l&&Bs(l,1);)i=l.parentNode,o=Et(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=yo(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Ca(n,i,o)}function yp(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function j1(n,e){for(;n&&e==n.childNodes.length&&!gi(n);)e=Et(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function L1(n,e){for(;n&&!e&&!gi(n);)e=Et(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ca(n,e,t){if(e.nodeType!=3){let i,o;(o=j1(e,t))?(e=o,t=0):(i=L1(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(dl(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Jn(n)},50)}function au(n,e){let t=n.state.doc.resolve(e);if(!(gt||np)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function cu(n,e,t){let r=n.state.selection;if(r instanceof q&&!r.empty||t.indexOf("s")>-1||cn&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Sa(n.state,e);if(o&&o instanceof J)return er(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Qt?X.near(o,e):X.findFrom(o,e);return l?er(n,l):!1}return!1}function du(n,e){if(!(n.state.selection instanceof q))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function uu(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function z1(n){if(!Ot||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;uu(n,r,"true"),setTimeout(()=>uu(n,r,"false"),20)}return!1}function P1(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function B1(n,e){let t=e.keyCode,r=P1(e);if(t==8||cn&&t==72&&r=="c")return du(n,-1)||Gr(n,-1);if(t==46&&!e.shiftKey||cn&&t==68&&r=="c")return du(n,1)||Gr(n,1);if(t==13||t==27)return!0;if(t==37||cn&&t==66&&r=="c"){let s=t==37?au(n,n.state.selection.from)=="ltr"?-1:1:-1;return lu(n,s,r)||Gr(n,s)}else if(t==39||cn&&t==70&&r=="c"){let s=t==39?au(n,n.state.selection.from)=="ltr"?1:-1:1;return lu(n,s,r)||Gr(n,s)}else{if(t==38||cn&&t==80&&r=="c")return cu(n,-1,r)||Gr(n,-1);if(t==40||cn&&t==78&&r=="c")return z1(n)||cu(n,1,r)||Gr(n,1);if(r==(cn?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function bc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Vr.fromSchema(n.state.schema),l=Sp(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=vp[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let m=l.createElement(d[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);
vendor: 4,268 bytes, lines 80-83
80let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` 81 82`);return{dom:a,text:f,slice:e}}function bp(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return l=new z(N.from(n.state.schema.text(e.replace(/\r\n?/g,` 83`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,m=Vr.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=H1(t),yi&&V1(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||dr.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!$1.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=W1(fu(l,+d[1],+d[2]),d[4]);else if(l=z.maxOpen(_1(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=fu(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}const $1=/^(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 _1(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&wp(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=kp(o[o.length-1],i.length));let d=xp(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return N.from(o)}return n}function xp(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,N.from(n));return n}function wp(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=wp(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(N.from(xp(t,n,s+1))))}}function kp(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,kp(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(N.empty,!0);return n.copy(t.append(r))}function Ma(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=Ma(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(N.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function fu(n,e,t){return e<n.openStart&&(n=new z(Ma(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new z(Ma(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const vp={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 Sp(){return document.implementation.createHTMLDocument("title")}let Bl=null;function F1(n){let e=window.trustedTypes;return e?(Bl||(Bl=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Bl.createHTML(n)):n}function H1(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sp(),r=t.body,s=/<([a-z][^>\s]+)/i.exec(n),i;if((i=s&&vp[s[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=F1(n),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[o])||r;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let d=r.querySelectorAll(c.selectorText);for(let u=0;u<d.length;u++)d[u].style.cssText+=c.style.cssText}}}return r}function V1(n){let e=n.querySelectorAll(gt?"span:not([class]):not
83([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function W1(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=N.from(a.create(r[l+1],s)),i++,o++}return new z(s,i,o)}const Vt={},Wt={},U1={touchstart:!0,touchmove:!0};class K1{constructor(){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 q1(n){for(let e in Vt){let t=Vt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{G1(n,r)&&!xc(n,r)&&(n.editable||!(r.type in Wt))&&t(n,r)},U1[e]?{passive:!0}:void 0)}Ot&&n.dom.addEventListener("input",()=>null),Ea(n)}function Un(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function J1(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ea(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>xc(n,r))})}function xc(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function G1(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Y1(n,e){!xc(n,e)&&Vt[e.type]&&(n.editable||!(e.type in Wt))&&Vt[e.type](n,e)}Wt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Tp(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Wn&>&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),as&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,vr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||B1(n,t)?t.preventDefault():Un(n,"key")};Wt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Wt.keypress=(n,e)=>{let t=e;if(Tp(n)||!t.charCode||t.ctrlKey&&!t.altKey||cn&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function xi(n){return{left:n.clientX,top:n.clientY}}function X1(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function wc(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function wi(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Z1(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(wi(n,new J(t)),!0):!1}function Q1(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof J&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(J.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(wi(n,J.create(n.state.doc,s)),!0):!1}function ew(n,e,t,r,s){return wc(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Q1(n,t):Z1(n,t))}function tw(n,e,t,r){return wc(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",
vendor: 13,841 bytes, line 83
83s=>s(n,e,r))}function nw(n,e,t,r){return wc(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||rw(n,t,r)}function rw(n,e,t){if(t.button!=0)return!1;let r=Cp(n,e,!0),s=n.state.doc;return r?(wi(n,r),r instanceof q&&s.eq(n.state.doc)&&(n.input.mouseDown=new iw(n,r)),!0):!1}function Cp(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?q.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return q.create(r,l+1,l+1+o.content.size);if(t&&J.isSelectable(o))return J.create(r,l)}return null}function kc(n){return bo(n)}const Mp=cn?"metaKey":"ctrlKey";Vt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=kc(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&X1(t,n.input.lastClick)&&!t[Mp]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(xi(t));o&&(i=="singleClick"?n.input.mouseDown=new sw(n,o,t,!!r):(i=="doubleClick"?tw:nw)(n,o.pos,o.inside,t)?t.preventDefault():Un(n,"pointer"))};class Ep{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class sw extends Ep{constructor(e,t,r,s){super(e),this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Mp],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof J&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&un&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Un(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Jn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(xi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Un(this.view,"pointer"):ew(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ot&&this.mightDrag&&!this.mightDrag.node.isAtom||gt&&!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)?(wi(this.view,X.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Un(this.view,"pointer")}move(e){this.updateAllowDefault(e),Un(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class iw extends Ep{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Un(this.view,"pointer");let t=this.view.posAtCoords(xi(e)),r=t&&Cp(this.view,t.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];wi(this.view,q.create(s,o,l))}}Vt.touchstart=n=>{n.input.lastTouch=Date.now(),kc(n),Un(n,"pointer")};Vt.touchmove=n=>{n.input.lastTouch=Date.now(),Un(n,"pointer")};Vt.contextmenu=n=>kc(n);function Tp(n,e){return n.composing?!0:Ot&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ow=Wn?5e3:-1;Wt.compositionstart=Wt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||gt&&np&&lw(n)))n.markCursor=n.state.storedMarks||t.marks(),bo(n,!0),n.markCursor=null;else if(bo(n,!e.selection.empty),un&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}Ap(n,ow)};function lw(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Wt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ap(n,20))};function Ap(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>bo(n),e))}function Dp(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function aw(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Qx(e.focusNode,e.focusOffset),r=e1(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function bo(n,e=!1){if(!(Wn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Dp(n),e||n.docView&&n.docView.dirty){let t=gc(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function cw(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ni=qt&&ur<15||as&&s1<604;Vt.copy=Wt.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=ni?null:t.clipboardData,o=r.content(),{dom:l,text:a}=bc(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):cw(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dw(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function uw(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ri(n,r.value,null,s,e):ri(n,r.textContent,r.innerHTML,s,e)},50)}function ri(n,e,t,r,s){let i=bp(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||z.empty)))return!0;if(!i)return!1;let o=dw(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Rp(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Wt.paste=(n,e)=>{let t=e;if(n.composing&&!Wn)return;let r=ni?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ri(n,Rp(r),r.getData("text/html"),s,t)?t.preventDefault():uw(n,t)};class Np{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const fw=cn?"altKey":"ctrlKey";function Op(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[fw]}Vt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(xi(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof J?s.to-1:s.to))){if(r&&r.mightDrag)o=J.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=J.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:d}=bc(n,l);(!t.dataTransfer.files.length||!gt||tp>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ni?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ni||t.dataTransfer.setData("text/plain",c),n.dragging=new Np(d,Op(n,t),o)};Vt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Wt.dragover=Wt.dragenter=(n,e)=>e.preventDefault();Wt.drop=(n,e)=>{try{hw(n,e,n.dragging)}finally{n.dragging=null}};function hw(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(xi(e));if(!r)return;let s=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",h=>{i=h(i,n,!1)}):i=bp(n,Rp(e.dataTransfer),ni?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(t&&Op(n,e));if(n.someProp("handleDrop",h=>h(n,e,i||z.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Kh(n.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&J.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new J(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((m,g,y,b)=>h=b),a.setSelection(yc(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Vt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Jn(n)},20))};Vt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Vt.beforeinput=(n,e)=>{if(gt&&Wn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,vr(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Wt)Vt[n]=Wt[n];function si(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class xo{constructor(e,t){this.toDOM=e,this.spec=t||Nr,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new Ht(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&si(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class pr{constructor(e,t){this.attrs=e,this.spec=t||Nr}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Ht(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof pr&&si(this.attrs,e.attrs)&&si(this.spec,e.spec)}static is(e){return e.type instanceof pr}destroy(){}}class vc{constructor(e,t){this.attrs=e,this.spec=t||Nr}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Ht(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof vc&&si(this.attrs,e.attrs)&&si(this.spec,e.spec)}destroy(){}}class Ht{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ht(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ht(e,e,new xo(t,r))}static inline(e,t,r,s){return new Ht(e,t,new pr(r,s))}
vendor: 6,387 bytes, line 83
83static node(e,t,r,s){return new Ht(e,t,new vc(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof pr}get widget(){return this.type instanceof xo}}const Xr=[],Nr={};class qe{constructor(e,t){this.local=e.length?e:Xr,this.children=t.length?t:Xr}static create(e,t){return t.length?wo(t,e,0,Nr):Nt}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==Nt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Nr)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?pw(this.children,o||[],e,t,r,s,i):o?new qe(o.sort(Or),Xr):Nt}add(e,t){return t.length?this==Nt?qe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=jp(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,wo(d,l,c+1,Nr)),i+=3}});let o=Ip(i?Lp(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new qe(o.length?this.local.concat(o).sort(Or):this.local,s||this.children)}remove(e){return e.length==0||this==Nt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=Nt?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new qe(s,r):Nt}forChild(e,t){if(this==Nt)return this;if(t.isLeaf)return qe.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof pr){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new qe(s.sort(Or),Xr);return r?new rr([l,r]):l}return r||Nt}eq(e){if(this==e)return!0;if(!(e instanceof qe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Sc(this.localsInner(e))}localsInner(e){if(this==Nt)return Xr;if(e.inlineContent||!this.local.some(pr.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof pr||t.push(this.local[r]);return t}forEachSet(e){e(this)}}qe.empty=new qe([],[]);qe.removeOverlap=Sc;const Nt=qe.empty;class rr{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Nr));return rr.from(r)}forChild(e,t){if(t.isLeaf)return qe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=Nt&&(i instanceof rr?r=r.concat(i.members):r.push(i))}return rr.from(r)}eq(e){if(!(e instanceof rr)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?Sc(r?t:t.sort(Or)):Xr}static from(e){switch(e.length){case 0:return Nt;case 1:return e[0];default:return new rr(e.every(t=>t instanceof qe)?e:e.reduce((t,r)=>t.concat(r instanceof qe?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function pw(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,m,g)=>{let y=g-m-(h-f);for(let b=0;b<l.length;b+=3){let S=l[b+1];if(S<0||f>S+d-u)continue;let C=l[b]+d-u;h>=C?l[b+1]=f<=C?-2:-1:f>=d&&y&&(l[b]+=y,l[b+1]+=y)}u+=y}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:m,offset:g}=r.content.findIndex(u),y=r.maybeChild(m);if(y&&g==u&&g+y.nodeSize==h){let b=l[c+2].mapInner(t,y,d+1,n[c]+i+1,o);b!=Nt?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=mw(l,n,e,t,s,i,o),d=wo(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new qe(e.sort(Or),l)}function Ip(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Ht(s.from+e,s.to+e,s.type))}return t}function mw(n,e,t,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function jp(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Lp(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function wo(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=jp(n,l,a+t);if(c){i=!0;let d=wo(c,l,t+a+1,r);d!=Nt&&s.push(a,a+l.nodeSize,d)}});let o=Ip(i?Lp(n):n,-t).sort(Or);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new qe(o,s):Nt}function Or(n,e){return n.from-e.from||n.to-e.to}function Sc(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;
vendor: 23,434 bytes, line 83
83s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),hu(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),hu(e,s,r.copy(i.from,r.to)));break}}}return e}function hu(n,e,t){for(;e<n.length&&Or(t,n[e])>0;)e++;n.splice(e,0,t)}function $l(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Nt&&e.push(r)}),n.cursorWrapper&&e.push(qe.create(n.state.doc,[n.cursorWrapper.deco])),rr.from(e)}const gw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yw=qt&&ur<=11;class bw{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class xw{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bw,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);qt&&ur<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Ot&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),yw&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,gw)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ou(this.view)){if(this.suppressingSelectionUpdates)return Jn(this.view);if(qt&&ur<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=ls(i))t.add(i);for(let i=e.anchorNode;i;i=ls(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ou(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||gt&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(un&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||vw(e,u)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&dl(r)&&(c=gc(e))&&c.eq(X.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Jn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),ww(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Sw(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Jn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(qt&&ur<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?Et(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?Et(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let pu=new WeakMap,mu=!1;function ww(n){if(!pu.has(n)&&(pu.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=un,mu)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."),mu=!0}}function gu(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Pr(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function kw(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return gu(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?gu(n,t):null}function vw(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Sw(n,e){var t;let{focusNode:r,focusOffset:s}=n.domSelectionRange();for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function Cw(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],dl(a)||c.push({node:a.focusNode,offset:a.focusOffset})),gt&&n.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){i=y;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||dr.fromSchema(n.state.schema),h=u.resolve(o),m=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Mw,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),m={anchor:y+o,head:b+o}}return{doc:g,sel:m,from:o,to:l}}function Mw(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ot&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Ot&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ew=/^(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 Tw(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=gc(n,k);if(A&&!n.state.selection.eq(A)){if(gt&&Wn&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",U=>U(n,vr(13,"Enter"))))return;let P=n.state.tr.setSelection(A);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Cw(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=Rw(u.content,c.doc.content,c.from,f,h);if(m&&n.input.domChangeCount++,(as&&n.input.lastIOSEnter>Date.now()-225||Wn)&&s.some(k=>k.nodeType==1&&!Ew.test(k.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",k=>k(n,vr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=yu(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let A=n.state.tr.setSelection(k);i&&A.setMeta("composition",i),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof q&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),qt&&ur<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" Â "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),y=c.doc.resolveNoCache(m.endB-c.from),b=d.resolve(m.start),S=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=m.endA;if((as&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!S&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",k=>k(n,vr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&Dw(d,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",k=>k(n,vr(8,"Backspace")))){Wn&>&&n.domObserver.suppressSelectionUpdates();return}gt&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Wn&&!S&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,y=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,vr(13,"Enter"))})},20));let C=m.start,T=m.endA,M=k=>{let A=k||n.state.tr.replace(C,T,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let P=yu(n,A.doc,c.sel);P&&!(gt&&n.composing&&P.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(P.head==C||P.head==A.mapping.map(T)-1)||qt&&P.empty&&P.head==C)&&A.setSelection(P)}return i&&A.setMeta("composition",i),A.scrollIntoView()},D;if(S)if(g.pos==y.pos){qt&&ur<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Jn(n),20));let k=M(n.state.tr.delete(C,T)),A=d.resolve(m.start).marksAcross(d.resolve(m.endA));A&&k.ensureMarks(A),n.dispatch(k)}else if(m.endA==m.endB&&(D=Aw(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let k=M(n.state.tr);D.type=="add"?k.addMark(C,T,D.mark):k.removeMark(C,T,D.mark),n.dispatch(k)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let k=g.parent.textBetween(g.parentOffset,y.parentOffset),A=()=>M(n.state.tr.insertText(k,C,T));n.someProp("handleTextInput",P=>P(n,C,T,k,A))||n.dispatch(A())}else n.dispatch(M());else n.dispatch(M())}function yu(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:yc(n,e.resolve(t.anchor),e.resolve(t.head))}function Aw(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(N.from(c).eq(n))return{mark:l,type:o}}function Dw(n,e,t,r,s){if(t-e<=s.pos-r.pos||_l(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(_l(i,!0,!0));return!o.parent.isTextblock||o.pos>t||_l(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function _l(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function Rw(n,e,t,r,s){let i=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,o,l);if(s=="end"){let d=Math.max(0,i-Math.min(a,c));r-=a+d-i}if(a<i&&o<l){let d=r<=i&&r>=a?i-r:0;i-=d,c=i+(c-a),a=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}class zp{constructor(e,t){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 K1,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=wu(this),xu(this),this.nodeViews=ku(this),this.docView=eu(this.state.doc,bu(this),$l(this),this.dom,this),this.domObserver=new xw(this,(r,s,i,o)=>Tw(this,r,s,i,o)),this.domObserver.start(),q1(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ea(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Dp(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ku(this);Ow(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ea(this),this.editable=wu(this),xu(this);let a=$l(this),c=bu(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&l1(this);if(o){this.domObserver.stop();let h=u&&(qt||gt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Nw(s.selection,e.selection);if(u){let g=gt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=aw(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=eu(e.doc,c,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let m=this.input.mouseDown;h||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&N1(this)&&m.delaySelUpdate())?Jn(this,h):(mp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&a1(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof J){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Jd(this,t.getBoundingClientRect(),e)}else Jd(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Np(e.slice,e.move,s<0?void 0:J.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(qt){let 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(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&c1(this.dom),Jn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return p1(this,e)}coordsAtPos(e,t=1){return lp(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return x1(this,t||this.state,e)}pasteHTML(e,t){return ri(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ri(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return bc(this,e)}destroy(){this.docView&&(J1(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$l(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Y1(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ot&&this.root.nodeType===11&&n1(this.dom.ownerDocument)==this.dom&&kw(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}zp.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function bu(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ht.node(0,n.state.doc.content.size,e)]}function xu(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ht.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function wu(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Nw(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function ku(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ow(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function vu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Iw=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),jw=typeof navigator<"u"&&/Win/.test(navigator.platform);function Lw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];
vendor: 49,687 bytes, lines 83-87
83if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Iw?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function zw(n){let e=Object.create(null);for(let t in n)e[Lw(t)]=n[t];return e}function Fl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Pw(n){return new st({props:{handleKeyDown:Cc(n)}})}function Cc(n){let e=zw(n);return function(t,r){let s=hy(r),i,o=e[Fl(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Fl(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(jw&&r.ctrlKey&&r.altKey)&&(i=py[r.keyCode])&&i!=s){let l=e[Fl(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Mc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Pp(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Bp=(n,e,t)=>{let r=Pp(n,t);if(!r)return!1;let s=Ec(r);if(!s){let o=r.blockRange(),l=o&&hs(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(qp(n,s,e,-1))return!0;if(r.parent.content.size==0&&(cs(i,"end")||J.isSelectable(i)))for(let o=r.depth;;o--){let l=al(n.doc,r.before(o),r.after(o),z.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(cs(i,"end")?X.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):J.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Bw=(n,e,t)=>{let r=Pp(n,t);if(!r)return!1;let s=Ec(r);return s?$p(n,s,e):!1},$w=(n,e,t)=>{let r=Fp(n,t);if(!r)return!1;let s=Tc(r);return s?$p(n,s,e):!1};function $p(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=al(n.doc,i,a,z.empty);if(!c||c.from!=i||c instanceof tt&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(q.create(d.doc,i)),t(d.scrollIntoView())}return!0}function cs(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const _p=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Ec(r)}let o=i&&i.nodeBefore;return!o||!J.isSelectable(o)?!1:(e&&e(n.tr.setSelection(J.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Ec(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Fp(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Hp=(n,e,t)=>{let r=Fp(n,t);if(!r)return!1;let s=Tc(r);if(!s)return!1;let i=s.nodeAfter;if(qp(n,s,e,1))return!0;if(r.parent.content.size==0&&(cs(i,"start")||J.isSelectable(i))){let o=al(n.doc,r.before(),r.after(),z.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(cs(i,"start")?X.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):J.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Vp=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Tc(r)}let o=i&&i.nodeAfter;return!o||!J.isSelectable(o)?!1:(e&&e(n.tr.setSelection(J.create(n.doc,i.pos)).scrollIntoView()),!0)};function Tc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const _w=(n,e)=>{let t=n.selection,r=t instanceof J,s;if(r){if(t.node.isTextblock||!yr(n.doc,t.from))return!1;s=t.from}else if(s=ll(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(J.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Fw=(n,e)=>{let t=n.selection,r;if(t instanceof J){if(t.node.isTextblock||!yr(n.doc,t.to))return!1;r=t.to}else if(r=ll(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Hw=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&hs(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},Wp=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` 84`).scrollIntoView()),!0)};function Ac(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Vw=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=Ac(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(X.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Up=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Qt||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Ac(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(o,i.createAndFill());l.setSelection(q.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Kp=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(qn(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&hs(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Ww(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof J&&e.selection.node.isBlock)return!r.parentOffset||!qn(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Ac(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof q||e.selection instanceof Qt)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=qn(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=qn(d.doc,u,i.length,i)),!f)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(o).type!=l){let h=d.mapping.map(r.before(o)),m=d.doc.resolve(h);l&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const Uw=Ww(),Kw=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(J.create(n.doc,s))),!0)};function qw(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||yr(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function qp(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&qw(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,m=N.empty;for(let b=o.length-1;b>=0;b--)m=N.from(o[b].create(null,m));m=N.from(s.copy(m));let g=n.tr.step(new yt(e.pos-1,h,e.pos,h,new z(m,1,0),o.length,!0)),y=g.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&yr(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:X.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&hs(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&cs(i,"start",!0)&&cs(s,"end")){let h=s,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let b=N.empty;for(let C=m.length-1;C>=0;C--)b=N.from(m[C].copy(b));let S=n.tr.step(new yt(e.pos-m.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new z(b,m.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Jp(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(q.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Jw=Jp(-1),Gw=Jp(1);function Yw(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&fc(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Su(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function Dc(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}Dc(Mc,Bp,_p);Dc(Mc,Hp,Vp);Dc(Wp,Up,Kp,Uw);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Xw(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i);if(!o)return!1;let l=r?t.tr:null;return Zw(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Zw(n,e,t,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new po(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new po(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=fc(i,t,r,e);return l?(n&&Qw(n,e,l,s,t),!0):!1}function Qw(n,e,t,r,s){let i=N.empty;for(let d=t.length-1;d>=0;d--)i=N.from(t[d].type.create(t[d].attrs,i));n.step(new yt(e.start-(r?2:0),e.end,e.start,e.end,new z(i,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==s&&(o=d+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&qn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function ek(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?tk(e,t,n,i):nk(e,t,i):!0:!1}}function tk(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new yt(i-1,o,i,o,new z(N.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new po(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=hs(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return yr(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function nk(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?N.empty:N.from(s))))return!1;let u=i.pos,f=u+o.nodeSize;return r.step(new yt(u-(l?1:0),f+(a?1:0),u+1,f-1,new z((l?N.empty:N.from(s.copy(N.empty))).append(a?N.empty:N.from(s.copy(N.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rk(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=N.from(c?n.create():null),u=new z(N.from(n.create(null,N.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new yt(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function fl(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class hl{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...g)=>{const y=this.buildProps(c,t),b=h(...g)(y);return l.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:fl({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class sk{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function $(n,e,t){return n.config[e]===void 0&&n.parent?$(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?$(n.parent,e,t):null}):n.config[e]}function pl(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Gp(n){const e=[],{nodeExtensions:t,markExtensions:r}=pl(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=$(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=$(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...i,...u};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function xt(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Fe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function Ta(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Fe(t,r),{})}function Yp(n){return typeof n=="function"}function ne(n,e=void 0,...t){return Yp(n)?e?n.bind(e)(...t):n(...t):n}function ik(n={}){return Object.keys(n).length===0&&n.constructor===Object}function ok(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Cu(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):ok(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Mu(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&ik(t)?!1:t!=null))}function lk(n,e){var t;const r=Gp(n),{nodeExtensions:s,markExtensions:i}=pl(n),o=(t=s.find(c=>$(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,S)=>{const C=$(S,"extendNodeSchema",u);return{...b,...C?C(c):{}}},{}),h=Mu({...f,content:ne($(c,"content",u)),marks:ne($(c,"marks",u)),group:ne($(c,"group",u)),inline:ne($(c,"inline",u)),atom:ne($(c,"atom",u)),selectable:ne($(c,"selectable",u)),draggable:ne($(c,"draggable",u)),code:ne($(c,"code",u)),whitespace:ne($(c,"whitespace",u)),linebreakReplacement:ne($(c,"linebreakReplacement",u)),defining:ne($(c,"defining",u)),isolating:ne($(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var S;return[b.name,{default:(S=b==null?void 0:b.attribute)===null||S===void 0?void 0:S.default}]}))}),m=ne($(c,"parseHTML",u));m&&(h.parseDOM=m.map(b=>Cu(b,d)));const g=$(c,"renderHTML",u);g&&(h.toDOM=b=>g({node:b,HTMLAttributes:Ta(b,d)}));const y=$(c,"renderText",u);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,b)=>{const S=$(b,"extendMarkSchema",u);return{...y,...S?S(c):{}}},{}),h=Mu({...f,inclusive:ne($(c,"inclusive",u)),excludes:ne($(c,"excludes",u)),group:ne($(c,"group",u)),spanning:ne($(c,"spanning",u)),code:ne($(c,"code",u)),attrs:Object.fromEntries(d.map(y=>{var b;return[y.name,{default:(b=y==null?void 0:y.attribute)===null||b===void 0?void 0:b.default}]}))}),m=ne($(c,"parseHTML",u));m&&(h.parseDOM=m.map(y=>Cu(y,d)));const g=$(c,"renderHTML",u);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Ta(y,d)})),[c.name,h]}));return new Lh({topNode:o,nodes:l,marks:a})}function Hl(n,e){return e.nodes[n]||e.marks[n]||null}function Eu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Rc(n,e){const t=Vr.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const ak=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),t};function Nc(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class ml{constructor(e){this.find=e.find,this.handler=e.handler}}const ck=(n,e)=>{if(Nc(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ji(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=ak(c)+i;return o.forEach(f=>{if(d)return;const h=ck(u,f.find);if(!h)return;const m=a.state.tr,g=fl({state:a.state,transaction:m}),y={from:r-(h[0].length-i.length),to:s},{commands:b,chain:S,can:C}=new hl({editor:t,state:g});f.handler({state:g,range:y,match:h,commands:b,chain:S,can:C})===null||!m.steps.length||(m.setMeta(l,{transform:m,from:r,to:s,text:i}),a.dispatch(m),d=!0)}),d}function dk(n){const{editor:e,rules:t}=n,r=new st({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Rc(N.from(d),o.schema);const{from:u}=a,f=u+d.length;ji({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ji({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ji({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ji({editor:e,from:o.pos,to:o.pos,text:` 85`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function uk(n){return Object.prototype.toString.call(n).slice(8,-1)}function Li(n){return uk(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function gl(n,e){const t={...n};return Li(n)&&Li(e)&&Object.keys(e).forEach(r=>{Li(e[r])&&Li(n[r])?t[r]=gl(n[r],e[r]):t[r]=e[r]}),t}class hn{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ne($(this,"addOptions",{name:this.name}))),this.storage=ne($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new hn(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>gl(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new hn(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ne($(t,"addOptions",{name:t.name})),t.storage=ne($(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function fk(n){return typeof n=="number"}class hk{constructor(e){this.find=e.find,this.handler=e.handler}}const pk=(n,e,t)=>{if(Nc(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function mk(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:d}=new hl({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,m)=>{if(!h.isTextblock||h.type.spec.code)return;const g=Math.max(r,m),y=Math.min(s,m+h.content.size),b=h.textBetween(g-m,y-m,void 0,"");pk(b,i.find,o).forEach(C=>{if(C.index===void 0)return;const T=g+C.index+1,M=T+C[0].length,D={from:t.tr.mapping.map(T),to:t.tr.mapping.map(M)},k=i.handler({state:t,range:D,match:C,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(k)})}),u.every(h=>h!==null)}let zi=null;const gk=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function yk(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:m})=>{const g=d.tr,y=fl({state:d,transaction:g});if(!(!mk({editor:e,state:y,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(d=>new st({view(u){const f=m=>{var g;r=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(m.target)?u.dom.parentElement:null,r&&(zi=e)},h=()=>{zi&&(zi=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){const h=zi;h!=null&&h.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(u,f)=>{var h;const m=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const m=u[0],g=m.getMeta("uiEvent")==="paste"&&!s,y=m.getMeta("uiEvent")==="drop"&&!i,b=m.getMeta("applyPasteRules"),S=!!b;if(!g&&!y&&!S)return;if(S){let{text:M}=b;typeof M=="string"?M=M:M=Rc(N.from(M),h.schema);const{from:D}=b,k=D+M.length,A=gk(M);return a({rule:d,state:h,from:D,to:{b:k},pasteEvt:A})}const C=f.doc.content.findDiffStart(h.doc.content),T=f.doc.content.findDiffEnd(h.doc.content);if(!(!fk(C)||!T||C===T.b))return a({rule:d,state:h,from:C,to:T,pasteEvt:o})}}))}function bk(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class es{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=es.resolve(e),this.schema=lk(this.extensions,t),this.setupExtensions()}static resolve(e){const t=es.sort(es.flatten(e)),r=bk(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=$(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=$(r,"priority")||100,o=$(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Hl(t.name,this.schema)},s=$(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=es.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Hl(o.name,this.schema)},a=[],c=$(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&$(o,"exitable",l)&&(d.ArrowRight=()=>hn.handleExit({editor:e,mark:o})),c){const g=Object.fromEntries(Object.entries(c()).map(([y,b])=>[y,()=>b({editor:e})]));d={...d,...g}}const u=Pw(d);a.push(u);const f=$(o,"addInputRules",l);Eu(o,e.options.enableInputRules)&&f&&r.push(...f());const h=$(o,"addPasteRules",l);Eu(o,e.options.enablePasteRules)&&h&&s.push(...h());const m=$(o,"addProseMirrorPlugins",l);if(m){const g=m();a.push(...g)}return a}).flat();return[dk({editor:e,rules:r}),...yk({editor:e,rules:s}),...i]}get attributes(){return Gp(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=pl(this.extensions);return Object.fromEntries(t.filter(r=>!!$(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:xt(r.name,this.schema)},o=$(r,"addNodeView",i);if(!o)return[];const l=(a,c,d,u,f)=>{const h=Ta(a,s);return o()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:r,HTMLAttributes:h})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Hl(e.name,this.schema)};e.type==="mark"&&(!((t=ne($(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=$(e,"onBeforeCreate",r),i=$(e,"onCreate",r),o=$(e,"onUpdate",r),l=$(e,"onSelectionUpdate",r),a=$(e,"onTransaction",r),c=$(e,"onFocus",r),d=$(e,"onBlur",r),u=$(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class rt{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ne($(this,"addOptions",{name:this.name}))),this.storage=ne($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new rt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>gl(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new rt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ne($(t,"addOptions",{name:t.name})),t.storage=ne($(t,"addStorage",{name:t.name,options:t.options})),t}}function Xp(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=` 86 87`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);const h=o==null?void 0:o[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function Zp(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const xk=rt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new st({key:new Tt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Zp(t);return Xp(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),wk=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),kk=(n=!1)=>({commands:e})=>e.setContent("",n),vk=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const m=hs(h);if(l.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},Sk=n=>e=>n(e),Ck=()=>({state:n,dispatch:e})=>Up(n,e),Mk=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new q(r.doc.resolve(Math.max(o-1,0)))),!0},Ek=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},Tk=n=>({tr:e,state:t,dispatch:r})=>{const s=xt(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Ak=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Dk=()=>({state:n,dispatch:e})=>Mc(n,e),Rk=()=>({commands:n})=>n.keyboardShortcut("Enter"),Nk=()=>({state:n,dispatch:e})=>Vw(n,e);function ko(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:Nc(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function Qp(n,e,t={}){return n.find(r=>r.type===e&&ko(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Tu(n,e,t={}){return!!Qp(n,e,t)}function Oc(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!Qp([...s.node.marks],e,t)))return;let o=s.index,l=n.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&Tu([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&Tu([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function xr(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const Ok=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=xr(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=Oc(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=q.create(o,u.from,u.to);t.setSelection(f)}}return!0},Ik=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function em(n){return n instanceof q}function Er(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function tm(n,e=null){if(!e)return null;const t=X.atStart(n),r=X.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?q.create(n,Er(0,s,i),Er(n.content.size,s,i)):q.create(n,Er(e,s,i),Er(e,s,i))}function Au(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function vo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function jk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Lk=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(vo()||Au())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),jk()&&!vo()&&!Au()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!em(t.state.selection))return o(),!0;const l=tm(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},zk=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Pk=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),nm=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&nm(r)}return n};function Pi(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return nm(t)}function ii(n,e,t){if(n instanceof cr||n instanceof N)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return N.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),ii("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Lh({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?dr.fromSchema(a).parseSlice(Pi(n),t.parseOptions):dr.fromSchema(a).parse(Pi(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=dr.fromSchema(e);return t.slice?i.parseSlice(Pi(n),t.parseOptions).content:i.parse(Pi(n),t.parseOptions)}return ii("",e,t)}function Bk(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof tt||s instanceof yt))return;const i=n.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),n.setSelection(X.near(n.doc.resolve(o),t))}const $k=n=>!("type"in n),_k=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ii(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=ii(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if(($k(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),d===u&&h){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,u+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof N){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,d,u)}else g=l,r.replaceWith(d,u,g);t.updateSelection&&Bk(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},Fk=()=>({state:n,dispatch:e})=>_w(n,e),Hk=()=>({state:n,dispatch:e})=>Fw(n,e),Vk=()=>({state:n,dispatch:e})=>Bp(n,e),Wk=()=>({state:n,dispatch:e})=>Hp(n,e),Uk=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ll(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Kk=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ll(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},qk=()=>({state:n,dispatch:e})=>Bw(n,e),Jk=()=>({state:n,dispatch:e})=>$w(n,e);function rm(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Gk(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))vo()||rm()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const Yk=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=Gk(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function oi(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?xt(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),m=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:m})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ko(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Xk=(n,e={})=>({state:t,dispatch:r})=>{const s=xt(n,t.schema);return oi(t,s,e)?Hw(t,r):!1},Zk=()=>({state:n,dispatch:e})=>Kp(n,e),Qk=n=>({state:e,dispatch:t})=>{const r=xt(n,e.schema);return ek(r)(e,t)},ev=()=>({state:n,dispatch:e})=>Wp(n,e);function yl(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Du(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const tv=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=yl(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=xt(n,r.schema)),l==="mark"&&(o=xr(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,Du(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(Du(u.attrs,e)))})})}),!0):!1},nv=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),rv=()=>({tr:n,dispatch:e})=>{if(e){const t=new Qt(n.doc);n.setSelection(t)}return!0},sv=()=>({state:n,dispatch:e})=>_p(n,e),iv=()=>({state:n,dispatch:e})=>Vp(n,e),ov=()=>({state:n,dispatch:e})=>Kw(n,e),lv=()=>({state:n,dispatch:e})=>Gw(n,e),av=()=>({state:n,dispatch:e})=>Jw(n,e);function Aa(n,e,t={},r={}){return ii(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const cv=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{var a,c;const{doc:d}=i;if(t.preserveWhitespace!=="full"){const u=Aa(n,s.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function sm(n,e){const t=xr(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function dv(n,e){const t=new hc(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function uv(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function fv(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function im(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Ic(n){return e=>im(e.$from,n)}function hv(n,e){const t={from:0,to:n.content.size};return Xp(n,t,e)}function pv(n,e){const t=xt(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function om(n,e){const t=yl(typeof e=="string"?e:e.name,n.schema);return t==="node"?pv(n,e):t==="mark"?sm(n,e):{}}function mv(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function gv(n){const e=mv(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function yv(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),gv(r)}function jc(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=Oc(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Qi(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function Da(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?xr(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>ko(u.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,m=f.pos;n.doc.nodesBetween(h,m,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(h,y),S=Math.min(m,y+g.nodeSize),C=S-b;o+=C,l.push(...g.marks.map(T=>({mark:T,from:b,to:S})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>ko(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function bv(n,e,t={}){if(!e)return oi(n,null,t)||Da(n,null,t);const r=yl(e,n.schema);return r==="node"?oi(n,e,t):r==="mark"?Da(n,e,t):!1}function Ru(n,e){const{nodeExtensions:t}=pl(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=ne($(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Lc(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(Lc(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function xv(n){return n instanceof J}function wv(n,e,t){var r;const{selection:s}=e;let i=null;if(em(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),m=!!t.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(t));c=h&&m}return!c}),c})}const kv=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=xr(n,r.schema);if(s)if(o){const c=sm(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const m=Math.max(h,d),g=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(m,g,a.create({...b.attrs,...e}))}):t.addMark(m,g,a.create(e))})});return wv(r,t,a)},vv=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Sv=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=xt(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>Su(i,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Su(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Cv=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Er(n,0,r.content.size),i=J.create(r,s);e.setSelection(i)}return!0},Mv=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=q.atStart(r).from,l=q.atEnd(r).to,a=Er(s,o,l),c=Er(i,o,l),d=q.create(r,a,c);e.setSelection(d)}return!0},Ev=n=>({state:e,dispatch:t})=>{const r=xt(n,e.schema);return rk(r)(e,t)};function Nu(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e==null?void 0:e.includes(s.type.name));n.tr.ensureMarks(r)}}const Tv=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Qi(c,l.node().type.name,l.node().attrs);if(i instanceof J&&i.node.isBlock)return!l.parentOffset||!qn(o,l.pos)?!1:(r&&(n&&Nu(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;
vendor: 4,242 bytes, line 87
87const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:uv(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,m=qn(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&qn(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(m&&(i instanceof q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Nu(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Av=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const l=xt(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=N.empty;const S=a.index(-1)?1:a.index(-2)?2:3;for(let A=a.depth-S;A>=a.depth-3;A-=1)b=N.from(a.node(A).copy(b));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,T={...Qi(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(T))||void 0;b=b.append(N.from(l.createAndFill(null,M)||void 0));const D=a.before(a.depth-(S-1));t.replace(D,a.after(-C),new z(b,4-S,0));let k=-1;t.doc.nodesBetween(D,t.doc.content.size,(A,P)=>{if(k>-1)return!1;A.isTextblock&&A.content.size===0&&(k=P+1)}),k>-1&&t.setSelection(q.near(t.doc.resolve(k))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,m={...Qi(f,u.type.name,u.attrs),...e},g={...Qi(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!qn(t.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:S}=r,{splittableMarks:C}=i.extensionManager,T=S||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!T||!s)return!0;const M=T.filter(D=>C.includes(D.type.name));t.ensureMarks(M)}return!0},Vl=(n,e)=>{const t=Ic(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&yr(n.doc,t.pos)&&n.join(t.pos),!0},Wl=(n,e)=>{const t=Ic(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&yr(n.doc,r)&&n.join(r),!0},Dv=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=xt(n,o.schema),m=xt(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:S}=g,C=b.blockRange(S),T=y||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const M=Ic(D=>Ru(D.type.name,u))(g);if(C.depth>=1&&M&&C.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(m);if(Ru(M.node.type.name,u)&&h.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>Vl(i,h)).command(()=>Wl(i,h)).run()}return!t||!T||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Vl(i,h)).command(()=>Wl(i,h)).run():a().command(()=>{const D=d().wrapInList(h,r),k=T.filter(A=>f.includes(A.type.name));return i.ensureMarks(k),D?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Vl(i,h)).command(()=>Wl(i,h)).run()},Rv=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=xr(n,r.schema);return Da(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Nv=(n,e,t={})=>({state:r,commands:s})=>{const i=xt(n,r.schema),o=xt(e,r.schema),l=oi(r,i,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...t})},Ov=(n,e={})=>({state:t,commands:r})=>{const s=xt(n,t.schema);return oi(t,s,e)?r.lift(s):r.wrapIn(s,e)},Iv=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;
vendor: 9,487 bytes, lines 87-127
87if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},jv=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Lv=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=xr(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:f,to:h}=l;const m=(i=c.marks().find(y=>y.type===a))===null||i===void 0?void 0:i.attrs,g=Oc(c,a,m);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},zv=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=yl(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=xt(n,r.schema)),l==="mark"&&(o=xr(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,f,h,m;t.selection.empty?r.doc.nodesBetween(c,d,(g,y)=>{i&&i===g.type&&(h=Math.max(y,c),m=Math.min(y+g.nodeSize,d),u=y,f=g)}):r.doc.nodesBetween(c,d,(g,y)=>{y<c&&i&&i===g.type&&(h=Math.max(y,c),m=Math.min(y+g.nodeSize,d),u=y,f=g),y>=c&&y<=d&&(i&&i===g.type&&t.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const S=Math.max(y,c),C=Math.min(y+g.nodeSize,d);t.addMark(S,C,o.create({...b.attrs,...e}))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&t.addMark(h,m,o.create({...g.attrs,...e}))}))}),!0):!1},Pv=(n,e={})=>({state:t,dispatch:r})=>{const s=xt(n,t.schema);return Yw(s,e)(t,r)},Bv=(n,e={})=>({state:t,dispatch:r})=>{const s=xt(n,t.schema);return Xw(s,e)(t,r)};var $v=Object.freeze({__proto__:null,blur:wk,clearContent:kk,clearNodes:vk,command:Sk,createParagraphNear:Ck,cut:Mk,deleteCurrentNode:Ek,deleteNode:Tk,deleteRange:Ak,deleteSelection:Dk,enter:Rk,exitCode:Nk,extendMarkRange:Ok,first:Ik,focus:Lk,forEach:zk,insertContent:Pk,insertContentAt:_k,joinBackward:Vk,joinDown:Hk,joinForward:Wk,joinItemBackward:Uk,joinItemForward:Kk,joinTextblockBackward:qk,joinTextblockForward:Jk,joinUp:Fk,keyboardShortcut:Yk,lift:Xk,liftEmptyBlock:Zk,liftListItem:Qk,newlineInCode:ev,resetAttributes:tv,scrollIntoView:nv,selectAll:rv,selectNodeBackward:sv,selectNodeForward:iv,selectParentNode:ov,selectTextblockEnd:lv,selectTextblockStart:av,setContent:cv,setMark:kv,setMeta:vv,setNode:Sv,setNodeSelection:Cv,setTextSelection:Mv,sinkListItem:Ev,splitBlock:Tv,splitListItem:Av,toggleList:Dv,toggleMark:Rv,toggleNode:Nv,toggleWrap:Ov,undoInputRule:Iv,unsetAllMarks:jv,unsetMark:Lv,updateAttributes:zv,wrapIn:Pv,wrapInList:Bv});const _v=rt.create({name:"commands",addCommands(){return{...$v}}}),Fv=rt.create({name:"drop",addProseMirrorPlugins(){return[new st({key:new Tt("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Hv=rt.create({name:"editable",addProseMirrorPlugins(){return[new st({key:new Tt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Vv=new Tt("focusEvents"),Wv=rt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new st({key:Vv,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Uv=rt.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,m=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,g=m.parent.type.spec.isolating,y=u.pos-u.parentOffset,b=g&&m.parent.childCount===1?y===u.pos:X.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return vo()||rm()?i:s},addProseMirrorPlugins(){return[new st({key:new Tt("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=X.atStart(e.doc).from,c=X.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Lc(t.doc))return;const f=t.tr,h=fl({state:t,transaction:f}),{commands:m}=new hl({editor:this.editor,state:h});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Kv=rt.create({name:"paste",addProseMirrorPlugins(){return[new st({key:new Tt("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),qv=rt.create({name:"tabindex",addProseMirrorPlugins(){return[new st({key:new Tt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Sr{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You canât set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Sr(t,this.editor)}get before(){let 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 Sr(e,this.editor)}get after(){let 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 Sr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new Sr(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new Sr(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>t[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const Jv=`.ProseMirror { 88 position: relative; 89} 90 91.ProseMirror { 92 word-wrap: break-word; 93 white-space: pre-wrap; 94 white-space: break-spaces; 95 -webkit-font-variant-ligatures: none; 96 font-variant-ligatures: none; 97 font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ 98} 99 100.ProseMirror [contenteditable="false"] { 101 white-space: normal; 102} 103 104.ProseMirror [contenteditable="false"] [contenteditable="true"] { 105 white-space: pre-wrap; 106} 107 108.ProseMirror pre { 109 white-space: pre-wrap; 110} 111 112img.ProseMirror-separator { 113 display: inline !important; 114 border: none !important; 115 margin: 0 !important; 116 width: 0 !important; 117 height: 0 !important; 118} 119 120.ProseMirror-gapcursor { 121 display: none; 122 pointer-events: none; 123 position: absolute; 124 margin: 0; 125} 126 127.ProseMirror-gapcursor:after {
128 content: ""; 129 display: block; 130 position: absolute; 131 top: -2px; 132 width: 20px; 133 border-top: 1px solid black; 134 animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; 135} 136 137@keyframes ProseMirror-cursor-blink { 138 to { 139 visibility: hidden; 140 } 141} 142 143.ProseMirror-hideselection *::selection { 144 background: transparent; 145} 146 147.ProseMirror-hideselection *::-moz-selection { 148 background: transparent; 149} 150 151.ProseMirror-hideselection * { 152 caret-color: transparent; 153} 154 155.ProseMirror-focused .ProseMirror-gapcursor { 156 display: block; 157} 158 159.tippy-box[data-animation=fade][data-state=hidden] { 160 opacity: 0 161}`;function Gv(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}class Yv extends sk{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Gv(Jv,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Yp(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(l=>!l.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Hv,xk.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),_v,Wv,Uv,qv,Fv,Kv].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new es(s,this)}createCommandManager(){this.commandManager=new hl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Aa(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;
vendor: 6,686 bytes, lines 161-163
161this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=Aa(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=tm(t,this.options.autofocus);this.view=new zp(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Qr.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return om(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return bv(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Rc(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` 162 163`,textSerializers:r={}}=e||{};return hv(this.state.doc,{blockSeparator:t,textSerializers:{...Zp(this.schema),...r}})}get isEmpty(){return Lc(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Sr(t,this)}get $doc(){return this.$pos(0)}}function Br(n){return new ml({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ne(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(jc(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&i.delete(d,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Xv(n){return new ml({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ne(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()}})}function Ra(n){return new ml({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=ne(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function li(n){return new ml({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=ne(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&fc(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||u.$to.parentOffset&&u.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&yr(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class wt{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ne($(this,"addOptions",{name:this.name}))),this.storage=ne($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new wt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>gl(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new wt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ne($(t,"addOptions",{name:t.name})),t.storage=ne($(t,"addStorage",{name:t.name,options:t.options})),t}}function gr(n){return new hk({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=ne(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(jc(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>
163y===n.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;f<t.to&&o.delete(f,t.to),u>t.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function Zv(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof J){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function Qv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var lm={exports:{}},Ul={};/** 164 * @license React 165 * use-sync-external-store-shim.production.min.js 166 * 167 * Copyright (c) Facebook, Inc. and its affiliates. 168 * 169 * This source code is licensed under the MIT license found in the 170 * LICENSE file in the root directory of this source tree. 171 */var Ou;function eS(){if(Ou)return Ul;Ou=1;var n=Ce;function e(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,i=n.useLayoutEffect,o=n.useDebugValue;function l(u,f){var h=f(),m=r({inst:{value:h,getSnapshot:f}}),g=m[0].inst,y=m[1];return i(function(){g.value=h,g.getSnapshot=f,a(g)&&y({inst:g})},[u,h,f]),s(function(){return a(g)&&y({inst:g}),u(function(){a(g)&&y({inst:g})})},[u]),o(h),h}function a(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!t(u,h)}catch{return!0}}function c(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return Ul.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,Ul}lm.exports=eS();var zc=lm.exports;const tS=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},nS=({contentComponent:n})=>{const e=zc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return Ce.createElement(Ce.Fragment,null,Object.values(e))};function rS(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Ng.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}class sS extends Ce.Component{constructor(e){var t;super(e),this.editorContentRef=Ce.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((t=e.editor)===null||t===void 0)&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=rS(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return Ce.createElement(Ce.Fragment,null,Ce.createElement("div",{ref:tS(t,this.editorContentRef),...r}),(e==null?void 0:e.contentComponent)&&Ce.createElement(nS,{contentComponent:e.contentComponent}))}}const iS=x.forwardRef((n,e)=>{const t=Ce.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return Ce.createElement(sS,{key:t,innerRef:e,...n})}),am=Ce.memo(iS);var oS=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(!n(e[s],t[s]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;for(s of e.entries())if(!n(s[1],t.get(s[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(e[s]!==t[s])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!n(e[o],t[o]))return!1}return!0}return e!==e&&t!==t},lS=Qv(oS),cm={exports:{}},Kl={};/** 172 * @license React 173 * use-sync-external-store-shim/with-selector.production.min.js 174 * 175 * Copyright (c) Facebook, Inc. and its affiliates. 176 * 177 * This source code is licensed under the MIT license found in the 178 * LICENSE file in the root directory of this source tree. 179 */var Iu;function aS(){if(Iu)return Kl;Iu=1;var n=Ce,e=zc;
179function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,l=n.useMemo,a=n.useDebugValue;return Kl.useSyncExternalStoreWithSelector=function(c,d,u,f,h){var m=i(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=l(function(){function b(D){if(!S){if(S=!0,C=D,D=f(D),h!==void 0&&g.hasValue){var k=g.value;if(h(k,D))return T=k}return T=D}if(k=T,r(C,D))return k;var A=f(D);return h!==void 0&&h(k,A)?k:(C=D,T=A)}var S=!1,C,T,M=u===void 0?null:u;return[function(){return b(d())},M===null?void 0:function(){return b(M())}]},[d,u,f,h]);var y=s(c,m[0],m[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},Kl}cm.exports=aS();var cS=cm.exports;const dS=typeof window<"u"?x.useLayoutEffect:x.useEffect;class uS{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function fS(n){var e;const[t]=x.useState(()=>new uS(n.editor)),r=cS.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:lS);return dS(()=>t.watch(n.editor),[n.editor,t]),x.useDebugValue(r),r}const hS=!1,Na=typeof window>"u",pS=Na||!!(typeof window<"u"&&window.next);class Pc{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Na||pS?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)===null||i===void 0?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)===null||i===void 0?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)===null||i===void 0?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)===null||i===void 0?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)===null||i===void 0?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)===null||i===void 0?void 0:i.call(s,...r)}};return new Yv(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=t.extensions)===null||o===void 0?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Pc.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}
179):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function dm(n={},e=[]){const t=x.useRef(n);t.current=n;const[r]=x.useState(()=>new Pc(t)),s=zc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return x.useDebugValue(s),x.useEffect(r.onRender(e)),fS({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&i===0?0:i+1}),s}const mS=x.createContext({editor:null});mS.Consumer;const gS=x.createContext({onDragStart:void 0}),yS=()=>x.useContext(gS);Ce.forwardRef((n,e)=>{const{onDragStart:t}=yS(),r=n.as||"div";return Ce.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const bS=/^\s*>\s$/,xS=wt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}}
vendor: 1,036 bytes, line 179
179,addInputRules(){return[li({find:bS,type:this.type})]}}),wS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,kS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,vS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,SS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,CS=hn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Br({find:wS,type:this.type}),Br({find:vS,type:this.t
vendor: 3,702 bytes, lines 179-181
179ype})]},addPasteRules(){return[gr({find:kS,type:this.type}),gr({find:SS,type:this.type})]}}),MS="listItem",ju="textStyle",Lu=/^\s*([-+*])\s$/,ES=wt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(MS,this.editor.getAttributes(ju)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=li({find:Lu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=li({find:Lu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ju),editor:this.editor})),[n]}}),TS=/(^|[^`])`([^`]+)`(?!`)/,AS=/(^|[^`])`([^`]+)`(?!`)/g,DS=hn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Br({find:TS,type:this.type})]},addPasteRules(){return[gr({find:AS,type:this.type})]}}),RS=/^```([a-z]+)?[\s\n]$/,NS=/^~~~([a-z]+)?[\s\n]$/,OS=wt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Fe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` 180 181`);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(X.near(r.resolve(l))),!0)):n.commands.exitCode()}}}
181,addInputRules(){return[Ra({find:RS,type:this.type,getAttributes:n=>({language:n[1]})}),Ra({find:NS,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new st({key:new Tt("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` 182`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(q.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),IS=wt.create({name:"doc",topNode:!0,content:"block+"});function jS(n={}){return new st({view(e){return new LS(e,n)}})}class LS{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=u?m.bottom:m.top;u&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(!t||i)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Kh(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const zS=rt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[jS(this.options)]}});class Je extends X{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));
vendor: 2,033 bytes, line 182
182return Je.valid(r)?new Je(r):X.near(r)}content(){return z.empty}eq(e){return e instanceof Je&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Je(e.resolve(t.pos))}getBookmark(){return new Bc(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!PS(e)||!BS(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Je.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(Je.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!J.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(Je.valid(l))return l}return null}}}Je.prototype.visible=!1;Je.findFrom=Je.findGapCursorFrom;X.jsonID("gapcursor",Je);class Bc{constructor(e){this.pos=e}map(e){return new Bc(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Je.valid(t)?new Je(t):X.near(t)}}function um(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function PS(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||um(s.type))return!0;if(s.inlineContent)return!1}}return!0}function BS(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||um(s.type))return!0;if(s.inlineContent)return!1}}return!0}function $S(){return new st({props:{decorations:VS,createSelectionBetween(n,e,t){return e.pos==t.pos&&Je.valid(t)?new Je(t):null}
vendor: 3,509 bytes, lines 182-183
182,handleClick:FS,handleKeyDown:_S,handleDOMEvents:{beforeinput:HS}}})}const _S=Cc({ArrowLeft:Bi("horiz",-1),ArrowRight:Bi("horiz",1),ArrowUp:Bi("vert",-1),ArrowDown:Bi("vert",1)});function Bi(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof q){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Je.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new Je(c))),!0):!1}}function FS(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Je.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&J.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Je(r))),!0)}function HS(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Je))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=N.empty;for(let o=r.length-1;o>=0;o--)s=N.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new z(s,0,0));return i.setSelection(q.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function VS(n){if(!(n.selection instanceof Je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",qe.create(n.doc,[Ht.widget(n.selection.head,e,{key:"gapcursor"})])}const WS=rt.create({name:"gapCursor",addProseMirrorPlugins(){return[$S()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ne($(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),US=wt.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Fe(this.options.HTMLAttributes,n)]},renderText(){return` 183`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),KS=wt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Fe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Ra({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}}
183)\\s$`),type:this.type,getAttributes:{level:n}}))}});var So=200,bt=function(){};bt.prototype.append=function(e){return e.length?(e=bt.from(e),!this.length&&e||e.length<So&&this.leafAppend(e)||this.length<So&&e.leafPrepend(this)||this.appendInner(e)):this};bt.prototype.prepend=function(e){return e.length?bt.from(e).append(this):this};bt.prototype.appendInner=function(e){return new qS(this,e)};bt.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?bt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};bt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};bt.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};bt.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};bt.from=function(e){return e instanceof bt?e:e&&e.length?new fm(e):bt.empty};var fm=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=So)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=So)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(bt);bt.empty=new fm([]);var qS=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(bt);const JS=500;class wn{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new An(u.map));let h=u.step.map(s.slice(i)),m;h&&o.maybeStep(h).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],c.push(new An(m,void 0,void 0,c.length+d.length))),i--,m&&s.appendMap(m,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new wn(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new An(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>YS&&(l=GS(l,c),o-=c),new wn(l.append(i),o)}remapping(e,t){let r=new ei;
vendor: 3,886 bytes, line 183
183return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new wn(this.items.append(e.map(t=>new An(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let m=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(i.slice(a+1,h));y&&l++,r.push(new An(m,g,y))}else r.push(new An(m))},s);let c=[];for(let f=t;f<o;f++)c.push(new An(i.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new wn(d,l);return u.emptyItemCount()>JS&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=o.selection&&o.selection.map(t.slice(r));d&&i++;let u=new An(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else o.map&&r--},this.items.length,0),new wn(bt.from(s.reverse()),i)}}wn.empty=new wn(bt.empty,0);function GS(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class An{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new An(t.getMap().invert(),t,this.selection)}}}class tr{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const YS=20;function XS(n,e,t,r){let s=t.getMeta(Ir),i;if(s)return s.historyState;t.getMeta(eC)&&(n=new tr(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Ir))return o.getMeta(Ir).redo?new tr(n.done.addTransform(t,void 0,r,eo(e)),n.undone,zu(t.mapping.maps),n.prevTime,n.prevComposition):new tr(n.done,n.undone.addTransform(t,void 0,r,eo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ZS(t,n.prevRanges)),c=o?ql(n.prevRanges,t.mapping):zu(t.mapping.maps);return new tr(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,eo(e)),wn.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new tr(n.done.rebased(t,i),n.undone.rebased(t,i),ql(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new tr(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ql(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ZS(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function zu(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function ql(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function QS(n,e,t){let r=eo(e),s=Ir.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new tr(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Ir,{redo:t,historyState:a})}let Jl=!1,Pu=null;function eo(n){let e=n.plugins;if(Pu!=e){Jl=!1,Pu=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Jl=!0;break}}return Jl}
vendor: 6,175 bytes, line 183
183const Ir=new Tt("history"),eC=new Tt("closeHistory");function tC(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new st({key:Ir,state:{init(){return new tr(wn.empty,wn.empty,null,0,-1)},apply(e,t,r){return XS(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?pm:r=="historyRedo"?mm:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function hm(n,e){return(t,r)=>{let s=Ir.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=QS(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const pm=hm(!1,!0),mm=hm(!0,!0),nC=rt.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>pm(n,e),redo:()=>({state:n,dispatch:e})=>mm(n,e)}},addProseMirrorPlugins(){return[tC(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Ñ":()=>this.editor.commands.undo(),"Shift-Mod-Ñ":()=>this.editor.commands.redo()}}}),rC=wt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Fe(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Zv(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):xv(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(q.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(J.create(o.doc,c.pos)):o.setSelection(q.create(o.doc,c.pos));else{const u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(o.insert(d,u),o.setSelection(q.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Xv({find:/^(?:---|â-|___\s|\*\*\*\s)$/,type:this.type})]}}),sC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,iC=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,oC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,lC=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,aC=hn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Br({find:sC,type:this.type}),Br({find:oC,type:this.type})]},addPasteRules(){return[gr({find:iC,type:this.type}),gr({find:lC,type:this.type})]}}),cC=wt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Fe(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),dC="listItem",Bu="textStyle",$u=/^(\d+)\.\s$/,uC=wt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Fe(this.options.HTMLAttributes,t),0]:["ol",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dC,this.editor.getAttributes(Bu)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=li({find:$u,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=li({find:$u,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Bu)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),fC=wt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),hC=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pC=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,mC=hn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}}
183,addInputRules(){return[Br({find:hC,type:this.type})]},addPasteRules(){return[gr({find:pC,type:this.type})]}}),gC=wt.create({name:"text",group:"inline"}),gm=rt.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(CS.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(xS.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(ES.configure(this.options.bulletList)),this.options.code!==!1&&n.push(DS.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(OS.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(IS.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(zS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(WS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(US.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(KS.configure(this.options.heading)),this.options.history!==!1&&n.push(nC.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(rC.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(aC.configure(this.options.italic)),this.options.listItem!==!1&&n.push(cC.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(uC.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(fC.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(mC.configure(this.options.strike)),this.options.text!==!1&&n.push(gC.configure(this.options.text)),n}}),_u=200,yC=600,Oa="slide-notes-panel";function bC({initialHtml:n,onSave:e}){const t=x.useRef(n),r=x.useRef(e);r.current=e;const s=dm({extensions:[gm.configure({heading:!1})],content:n||"<p></p>",editorProps:{attributes:{"aria-label":"Speaker notes"}}}),i=()=>
183{if(!s)return;const a=Hr(s.getHTML());a!==t.current&&(t.current=a,r.current(a))},o=x.useRef(i);o.current=i;const l=Ig(()=>o.current(),{delay:yC});return x.useEffect(()=>{if(s)return s.on("update",l),s.on("blur",()=>o.current()),()=>{s.off("update",l)}},[s,l]),x.useEffect(()=>()=>{l.cancel(),o.current()},[l]),s?p.jsxs(K,{children:[p.jsxs(Ee,{gap:4,mb:"xs",role:"toolbar","aria-label":"Notes formatting",children:[p.jsx(xn,{label:"Bold (Ctrl+B)",withArrow:!0,children:p.jsx(we,{variant:s.isActive("bold")?"filled":"subtle",color:"gray",size:"sm","aria-label":"Bold","aria-pressed":s.isActive("bold"),onClick:()=>s.chain().focus().toggleBold().run(),children:p.jsx(yh,{size:16,"aria-hidden":!0})})}),p.jsx(xn,{label:"Bulleted list",withArrow:!0,children:p.jsx(we,{variant:s.isActive("bulletList")?"filled":"subtle",color:"gray",size:"sm","aria-label":"Bulleted list","aria-pressed":s.isActive("bulletList"),onClick:()=>s.chain().focus().toggleBulletList().run(),children:p.jsx(Nf,{size:16,"aria-hidden":!0})})})]}),p.jsx(am,{editor:s,className:"deck-notes-rte"})]}):null}function xC({notes:n}){const e=Hr(fi(n));return my(e)?p.jsx(re,{size:"sm",c:"dimmed",children:"No notes for this slide."}):p.jsx(K,{className:"deck-notes-rte",dangerouslySetInnerHTML:{__html:e}})}
183function Fu({page:n,canWrite:e,onSave:t}){return n?e?p.jsx(bC,{initialHtml:Hr(fi(n.notes)),onSave:r=>t(n.id,r)},n.id):p.jsx(xC,{notes:n.notes}):p.jsx(re,{size:"sm",c:"dimmed",children:"Select a slide to add notes."})}function wC({page:n,canWrite:e,open:t,onToggle:r,onSave:s}){return qa("(max-width: 47.99em)",!1,{getInitialValueInEffect:!1})?p.jsx(Mf,{id:Oa,opened:t,onClose:r,position:"bottom",size:"60%",padding:"sm",title:p.jsxs(Ee,{gap:6,wrap:"nowrap",children:[p.jsx(tc,{size:16,"aria-hidden":!0}),p.jsx(re,{size:"sm",fw:600,children:"Speaker notes"})]}),children:p.jsx(Fu,{page:n,canWrite:e,onSave:s})}):t?p.jsx(Nn,{id:Oa,direction:"column",flex:`0 0 ${_u}px`,h:_u,mih:0,style:{borderTop:"1px solid var(--mantine-color-default-border)"},children:p.jsx(Og,{style:{flex:"1 1 auto"},px:"sm",py:"sm",children:p.jsx(Fu,{page:n,canWrite:e,onSave:s})})}):null}const kC=["title","paragraph","image","shape"],ym="application/x-slate-deck-block";function vC(n){if(!n||typeof n!="object")return!1;const e=n;return kC.includes(e.block_type)&&t
183ypeof e.x=="number"&&typeof e.y=="number"&&typeof e.w=="number"&&typeof e.h=="number"}function SC(n,e){n==null||n.setData(ym,JSON.stringify(e))}function CC(n){try{const e=n.getData(ym);if(!e)return null;const t=JSON.parse(e);return vC(t)?t:null}catch{return null}}const MC={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp"};function EC(n){return MC[n]??null}function TC(n){for(let e=0;e<n.length;e++){const t=n[e];if(!t.type.startsWith("image/"))continue;const r=EC(t.type);if(!r)return{kind:"unsupported",mime:t.type};const s=t.getAsFile();return s?{kind:"found",file:s,ext:r}:{kind:"unsupported",mime:t.type}}return{kind:"none"}}function AC(n,e){return n.name.toLowerCase().endsWith(`.${e}`)?n:new File([n],`clipboard-image.${e}`,{type:n.type})}function DC(n){const e=n("text/html");if(e.trim())return{html:e};const t=n("text/plain");return t.trim()?{plain:t}:null}const In=100,lr=1e-6,RC=["start","center","end"];function Hu(n,e,t,r){const s={start:n,center:n+e/2,end:n+e};let i=null;for(const a of RC){const c=s[a];let d=null;for(const u of t){const f=Math.abs(c-u);f<=r&&(d===null||f<d.dist)&&(d={pos:u,dist:f})}d&&(i===null||d.dist<i.dist)&&(i={kind:a,pos:d.pos,dist:d.dist})}if(!i)return null;const o=i.kind==="start"?0:i.kind==="center"?e/2:e,l=Math.max(0,Math.min(In-e,i.pos-o));return Math.abs(l+o-i.pos)>lr?null:{coord:l,kind:i.kind,pos:i.pos}}function Vu(n,e,t,r){const s=[{kind:"start",pos:e},{kind:"center",pos:e+t/2},{kind:"end",pos:e+t}],i=[],o=new Set;for(const{kind:l,pos:a}of s)o.has(a)||r.some(c=>Math.abs(c-a)<=lr)&&(o.add(a),i.push({axis:n,kind:l,pos:a}));return i}function Wu(n,e,t,r){const s=t==="x",i=k=>s?k.x:k.y,o=k=>s?k.w:k.h,l=k=>i(k)+o(k),a=k=>s?k.y:k.x,c=k=>a(k)+(s?k.h:k.w),d=e.filter(k=>a(k)<c(n)&&c(k)>a(n));if(d.length===0)return null;const u=i(n),f=o(n),h=u+f,m=a(n)+(s?n.h:n.w)/2,g=s?"horizontal":"vertical",y=(k,A)=>({axis:g,from:k,to:A,cross:m,role:"spacing"}),b=d.filter(k=>l(k)<=u),S=d.filter(k=>i(k)>=h),C=b.length?b.reduce((k,A)=>l(A)>l(k)?A:k):null,T=S.length?S.reduce((k,A)=>i(A)<i(k)?A:k):null,M=[];if(C&&T){const k=i(T)-l(C)-f;if(k>=0){const A=l(C)+k/2;M.push({coord:A,segments:[y(l(C),A),y(A+f,i(T))]})}}else if(T&&S.length>=2){const[k,A]=[...S].sort((U,G)=>i(U)-i(G)),P=i(A)-l(k);if(P>0){const U=i(k)-P-f;M.push({coord:U,segments:[y(U+f,i(k))]})}}else if(C&&b.length>=2){const[k,A]=[...b].sort((U,G)=>l(G)-l(U)),P=i(k)-l(A);if(P>0){const U=l(k)+P;M.push({coord:U,segments:[y(l(k),U)]})}}let D=null;for(const k of M){if(k.coord<-lr||k.coord>In-f+lr)continue;const A=Math.abs(k.coord-u);A<=r&&(D===null||A<D.dist)&&(D={...k,dist:A})}return D?{coord:D.coord,segments:D.segments}:null}function Uu(n,e,t){if(e&&t){const r=Math.abs(n-e.coord),s=Math.abs(n-t.coord);return r<=s?{coord:e.coord,mode:"edge",segments:[]}:{coord:t.coord,mode:"spacing",segments:t.segments}}return e?{coord:e.coord,mode:"edge",segments:[]}:t?{coord:t.coord,mode:"spacing",segments:t.segments}:{coord:n,mode:"none",segments:[]}}function NC(n,e,t){const r=(t==null?void 0:t.thresholdX)??1,s=(t==null?void 0:t.thresholdY)??1,i=[...e.flatMap(m=>[m.x,m.x+m.w/2,m.x+m.w]),0,In/2,In],o=[...e.flatMap(m=>[m.y,m.y+m.h/2,m.y+m.h]),0,In/2,In],l=[],a=[],c=Uu(n.x,Hu(n.x,n.w,i,r),Wu(n,e,"x",r)),d=c.coord;c.mode==="edge"?l.push(...Vu("vertical",d,n.w,i)):c.mode==="spacing"&&a.push(...c.segments);const u=Uu(n.y,Hu(n.y,n.h,o,s),Wu(n,e,"y",s)),f=u.coord;u.mode==="edge"?l.push(...Vu("horizontal",f,n.h,o)):u.mode==="spacing"&&a.push(...u.segments);const h=a.map(m=>m.axis==="horizontal"?{...m,cross:f+n.h/2}:{...m,cross:d+n.w/2});return{x:d,y:f,guides:l,segments:h}}function Ku(n,e,t,r,s,i){const o=i?n.x:n.y,l=i?n.w:n.h,a=[],c=[];if(e===null)return{lo:o,size:l,guides:a,segments:c};const d=M=>i?M.x:M.y,u=M=>i?M.w:M.h,f=i?"vertical":"horizontal",h=i?"horizontal":"vertical",m=i?n.y+n.h/2:n.x+n.w/2,g=M=>i?M.y+M.h/2:M.x+M.w/2,y=o+l,b=[...t.flatMap(M=>[d(M),d(M)+u(M)/2,d(M)+u(M)]),0,In/2,In],S=e==="end"?y:o;let C=null;for(const M of b){const D=Math.abs(S-M);D<=r&&(C===null||D<C.dist)&&(C={pos:M,dist:D})}if(C){const M=e==="end"?C.pos-o:y-C.pos,D=e==="end"?o:C.pos;if(M>=s&&D>=-lr&&D+M<=In+lr)return a.push({axis:f,kind:e,pos:C.pos}),{lo:D,size:M,guides:a,segments:c}}let T=null;for(const M of t){const D=Math.abs(l-u(M));D<=r&&(T===null||D<T.dist)&&(T={o:M,dist:D})}if(T){const M=u(T.o),D=e==="end"?o:y-M;if(M>=s&&D>=-lr&&D+M<=In+lr)return c.push({axis:h,from:D,to:D+M,cross:m,role:"size"}),c.push({axis:h,from:d(T.o),to:d(T.o)+M,cross:g(T.o),role:"size"}),{lo:D,size:M,guides:a,segments:c}}return{lo:o,size:l,guides:a,segments:c}}function OC(n,e,t,r){const s=(r==null?void 0:r.thresholdX)??1,i=(r==null?void 0:r.thresholdY)??1,o=r==null?void 0:r.minW,l=r==null?void 0:r.minH,a=e.right?"end":e.left?"start":null,c=e.bottom?"end":e.top?"start":null,d=Ku(n,a,t,s,o,!0),u=Ku(n,c,t,i,l,!1);return{x:d.lo,y:u.lo,w:d.size,h:u.size,guides:[...d.guides,...u.guides],segments:[...d.segments,...u.segments]}}/**
184 * @license @tabler/icons-react v3.41.1 - MIT 185 * 186 * This source code is licensed under the MIT license. 187 * See the LICENSE file in the root directory of this source tree. 188 */const IC=[["path",{d:"M4 18v.01",key:"svg-0"}],["path",{d:"M8 18v.01",key:"svg-1"}],["path",{d:"M12 18v.01",key:"svg-2"}],["path",{d:"M16 18v.01",key:"svg-3"}],["path",{d:"M20 18v.01",key:"svg-4"}],["path",{d:"M18 12h2",key:"svg-5"}],["path",{d:"M11 12h2",key:"svg-6"}],["path",{d:"M4 12h2",key:"svg-7"}],["path",{d:"M4 6h16",key:"svg-8"}]],jC=pe("outline","border-style-2","BorderStyle2",IC);/** 189 * @license @tabler/icons-react v3.41.1 - MIT 190 * 191 * This source code is licensed under the MIT license. 192 * See the LICENSE file in the root directory of this source tree. 193 */const LC=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M9 4l0 16",key:"svg-1"}]],zC=pe("outline","layout-sidebar","LayoutSidebar",LC);/** 194 * @license @tabler/icons-react v3.41.1 - MIT 195 * 196 * This source code is licensed under the MIT license. 197 * See the LICENSE file in the root directory of this source tree. 198 */const PC=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 16.5l2 -3l2 3m-2 -3v-2l3 -1m-6 0l3 1",key:"svg-1"}],["path",{d:"M11.5 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0 -1 0",fill:"currentColor",key:"svg-2"}]],BC=pe("outline","accessible","Accessible",PC);/** 199 * @license @tabler/icons-react v3.41.1 - MIT 200 * 201 * This source code is licensed under the MIT license. 202 * See the LICENSE file in the root directory of this source tree. 203 */const $C=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M12 8l0 .01",key:"svg-1"}],["path",{d:"M8 12l0 .01",key:"svg-2"}],["path",{d:"M12 12l0 .01",key:"svg-3"}],["path",{d:"M16 12l0 .01",key:"svg-4"}],["path",{d:"M12 16l0 .01",key:"svg-5"}]],bm=pe("outline","border-outer","BorderOuter",$C),qu={color:"#1c1c1c",width:1,style:"solid",radius:0},_C=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"];function xm({props:n,onChange:e}){const t=n==null?void 0:n.border,r=!!t,s=t??qu,i=o=>{e({border:o??null})};return p.jsxs(Mt,{gap:"sm",w:220,children:[p.jsx(so,{size:"xs",fullWidth:!0,"aria-label":"Border on or off",value:r?"on":"off",onChange:o=>i(o==="on"?qu:void 0),data:[{label:"No border",value:"off"},{label:"Border",value:"on"}]}),r&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(re,{size:"xs",fw:500,mb:4,children:"Color"}),p.jsx(Xa,{fullWidth:!0,format:"hex",value:s.color,onChange:o=>i({...s,color:o}),swatches:_C})]}),p.jsx(Ns,{size:"xs",label:"Width (px)",min:0,max:20,value:s.width,onChange:o=>i({...s,width:Number(o)||0})}),p.jsxs("div",{children:[p.jsx(re,{size:"xs",fw:500,mb:2,children:"Style"}),p.jsx(so,{size:"xs",fullWidth:!0,"aria-label":"Border style",value:s.style,onChange:o=>i({...s,style:o}),data:[{label:"Solid",value:"solid"},{label:"Dashed",value:"dashed"}]})]}),p.jsx(Ns,{size:"xs",label:"Corner radius (px)",min:0,max:40,value:s.radius,onChange:o=>i({...s,radius:Number(o)||0})})]})]})}function FC({props:n,onChange:e}
203){const[t,r]=x.useState(!1),s=!!(n!=null&&n.border);return p.jsxs(Kn,{opened:t,onChange:r,position:"bottom",shadow:"md",withinPortal:!0,closeOnClickOutside:!0,closeOnEscape:!0,returnFocus:!0,children:[p.jsx(Kn.Target,{children:p.jsxs(we,{variant:s?"filled":"default",size:"sm",w:34,"aria-label":"Block border","aria-pressed":s,"aria-expanded":t,onClick:()=>r(i=>!i),children:[p.jsx(bm,{size:16,"aria-hidden":!0}),p.jsx(Ef,{size:12,style:{marginLeft:1},"aria-hidden":!0})]})}),p.jsx(Kn.Dropdown,{p:"sm",children:p.jsx(xm,{props:n,onChange:e})})]})}const HC=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},VC=hn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&HC(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),WC=rt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),UC=rt.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),KC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,qC=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,JC=hn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}}
203,addInputRules(){return[Br({find:KC,type:this.type})]},addPasteRules(){return[gr({find:qC,type:this.type})]}}),GC=wt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Fe(this.options.HTMLAttributes,n),0]}}),YC=wt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Fe(this.options.HTMLAttributes,n),0]}}),XC=wt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Fe(this.options.HTMLAttributes,n),0]}}),ZC=rt.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),QC=hn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),eM={markerColor:null,markerWeight:null,markerFont:null};function wm(n){const e=n.find(t=>t.type.name==="textStyle");return{markerColor:(e==null?void 0:e.attrs.color)||null,markerFont:(e==null?void 0:e.attrs.fontFamily)||null,markerWeight:n.some(t=>t.type.name==="bold")?"bold":null}}function tM(n){let e=eM,t=!1;return n.descendants(r=>t?!1:r.isText?(t=!0,e=wm(r.marks),!1):!0),e}const nM=rt.create({name:"fontSize",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize||null,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}},{types:["paragraph","listItem"],attributes:{fontScale:{default:null,parseHTML:n=>{const e=n.style.getPropertyValue("--fs-scale");return e?parseFloat(e):null},renderHTML:n=>n.fontScale?{style:`--fs-scale: ${n.fontScale}`}:{}}}},{types:["listItem"],attributes:{markerColor:{default:null,parseHTML:n=>n.style.getPropertyValue("--marker-color")||null,renderHTML:n=>n.markerColor?{style:`--marker-color: ${n.markerColor}`}:{}},markerWeight:{default:null,parseHTML:n=>n.style.getPropertyValue("--marker-weight")||null,renderHTML:n=>n.markerWeight?{style:`--marker-weight: ${n.markerWeight}`}:{}},markerFont:{default:null,parseHTML:n=>n.style.getPropertyValue("--marker-font")||null,renderHTML:n=>n.markerFont?{style:`--marker-font: ${n.markerFont}`}:{}}}}]},addProseMirrorPlugins(){return[new st({key:new Tt("listMarkerStyleSync"),appendTransaction:(n,e,t)=>{const r=n.some(d=>d.docChanged),s=!e.selection.eq(t.selection),i=e.storedMarks!==t.storedMarks;if(!r&&!s&&!i)return null;const{selection:o,storedMarks:l}=t,a=[];if(t.doc.descendants((d,u)=>{if(d.type.name!=="listItem")return;let f=tM(d);const h=o.from>=u&&o.to<=u+d.nodeSize;d.textContent.length===0&&h&&(f=wm(l??o.$from.marks())),!(d.attrs.markerColor===f.markerColor&&d.attrs.markerWeight===f.markerWeight&&d.attrs.markerFont===f.markerFont)&&a.push({pos:u,attrs:{...d.attrs,...f}})}),a.length===0)return null;const c=t.tr;for(const d of a)c.setNodeMarkup(d.pos,void 0,d.attrs);return c.setStoredMarks(l?l.slice():null),c}})]},addCommands(){return{setFontSize:n=>({chain:e})=>{const t=parseFloat(n),r=Number.isFinite(t)?t:null;return e().setMark("textStyle",{fontSize:n}).updateAttributes("paragraph",{fontScale:r}).updateAttributes("listItem",{fontScale:r}).run()},unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().updateAttributes("paragraph",{fontScale:null}).updateAttributes("listItem",{fontScale:null}).run()}}}),rM=[null,1,1.15,1.5,2];function sM(n){return rM.find(e=>n.isActive("paragraph",{lineHeight:e}))}const iM=rt.create({name:"lineHeight",addGlobalAttributes(){return[{types:["paragraph"],attributes:{lineHeight:{default:null,parseHTML:n=>{const e=parseFloat(n.style.lineHeight);return Number.isFinite(e)?e:null},renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({commands:e})=>e.updateAttributes("paragraph",{lineHeight:n}),unsetLineHeight:()=>({commands:n})=>n.updateAttributes("paragraph",{lineHeight:null})}}}),km=x.createContext(null);function vm(){return x.useContext(km)}const oM="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2
203ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",lM="ελ1Ï
2бг1ел3деÑи4еÑ2каÑолик6ом3мÐ
203ºÐ´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",Ia="numeric",ja="ascii",La="alpha",$s="asciinumeric",Ts="alphanumeric",za="domain",Sm="emoji",aM="scheme",cM="slashscheme",Gl="whitespace";function dM(n,e){return n in e||(e[n]=[]),e[n]}function Tr(n,e,t){e[Ia]&&(e[$s]=!0,e[Ts]=!0),e[ja]&&(e[$s]=!0,e[La]=!0),e[$s]&&(e[Ts]=!0),e[La]&&(e[Ts]=!0),e[Ts]&&(e[za]=!0),e[Sm]&&(e[za]=!0);for(const r in e){const s=dM(r,t);s.indexOf(n)<0&&s.push(n)}}function uM(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Kt(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Kt.groups={};Kt.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Kt.groups;let s;return e&&e.j?s=e:(s=new Kt(e),t&&r&&Tr(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||Kt.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,l=s.go(n);if(l?(o=new Kt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Kt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(uM(o.t,r),t);Tr(i,a,r)}else t&&Tr(i,t,r);o.t=i}return s.j[n]=o,o}};const oe=(n,e,t,r,s)=>n.ta(e,t,r,s),Ke=(n,e,t,r,s)=>n.tr(e,t,r,s),Ju=(n,e,t,r,s)=>n.ts(e,t,r,s),j=(n,e,t,r,s)=>n.tt(e,t,r,s),Fn="WORD",Pa="UWORD",Cm="ASCIINUMERICAL",Mm="ALPHANUMERICAL",ai="LOCALHOST",Ba="TLD",$a="UTLD",to="SCHEME",Zr="SLASH_SCHEME",$c="NUM",_a="WS",_c="NL",_s="OPENBRACE",Fs="CLOSEBRACE",Co="OPENBRACKET",Mo="CLOSEBRACKET",Eo="OPENPAREN",To="CLOSEPAREN",Ao="OPENANGLEBRACKET",Do="CLOSEANGLEBRACKET",Ro="FULLWIDTHLEFTPAREN",No="FULLWIDTHRIGHTPAREN",Oo="LEFTCORNERBRACKET",Io="RIGHTCORNERBRACKET",jo="LEFTWHITECORNERBRACKET",Lo="RIGHTWHITECORNERBRACKET",zo="FULLWIDTHLESSTHAN",Po="FULLWIDTHGREATERTHAN",Bo="AMPERSAND",$o="APOSTROPHE",_o="ASTERISK",nr="AT",Fo="BACKSLASH",Ho="BACKTICK",Vo="CARET",Ar="COLON",Fc="COMMA",Wo="DOLLAR",Dn="DOT",Uo="EQUALS",Hc="EXCLAMATION",ln="HYPHEN",Hs="PERCENT",Ko="PIPE",qo="PLUS",Jo="POUND",Vs="QUERY",Vc="QUOTE",Em="FULLWIDTHMIDDLEDOT",Wc="SEMI",Rn="SLASH",Ws="TILDE",Go="UNDERSCORE",Tm="EMOJI",Yo="SYM";var Am=Object.freeze({__proto__:null,ALPHANUMERICAL:Mm,AMPERSAND:Bo,APOSTROPHE:$o,ASCIINUMERICAL:Cm,ASTERISK:_o,AT:nr,BACKSLASH:Fo,BACKTICK:Ho,CARET:Vo,CLOSEANGLEBRACKET:Do,CLOSEBRACE:Fs,CLOSEBRACKET:Mo,CLOSEPAREN:To,COLON:Ar,COMMA:Fc,DOLLAR:Wo,DOT:Dn,EMOJI:Tm,EQUALS:Uo,EXCLAMATION:Hc,FULLWIDTHGREATERTHAN:Po,FULLWIDTHLEFTPAREN:Ro,FULLWIDTHLESSTHAN:zo,FULLWIDTHMIDDLEDOT:Em,FULLWIDTHRIGHTPAREN:No,HYPHEN:ln,LEFTCORNERBRACKET:Oo,LEFTWHITECORNERBRACKET:jo,LOCALHOST:ai,NL:_c,NUM:$c,OPENANGLEBRACKET:Ao,OPENBRACE:_s,OPENBRACKET:Co,OPENPAREN:Eo,PERCENT:Hs,PIPE:Ko,PLUS:qo,POUND:Jo,QUERY:Vs,QUOTE:Vc,RIGHTCORNERBRACKET:Io,RIGHTWHITECORNERBRACKET:Lo,SCHEME:to,SEMI:Wc,SLASH:Rn,SLASH_SCHEME:Zr,SYM:Yo,TILDE:Ws,TLD:Ba,UNDERSCORE:Go,UTLD:$a,UWORD:Pa,WORD:Fn,WS:_a});const $n=/[a-z]/,ws=new RegExp("\\p{L}","u"),Yl=new RegExp("\\p{Emoji}","u"),_n=/\d/,Xl=/\s/,Gu="\r",Zl=` 204`,fM="ï¸",hM="â",Ql="";let $i=null,_i=null;function pM(n=[]){const e={};Kt.groups=e;const t=new Kt;$i==null&&($i=Yu(oM)),_i==null&&(_i=Yu(lM)),j(t,"'",$o),j(t,"{",_s),j(t,"}",Fs),j(t,"[",Co),j(t,"]",Mo),j(t,"(",Eo),j(t,")",To),j(t,"<",Ao),j(t,">",Do),j(t,"ï¼",Ro),j(t,"ï¼",No),j(t,"ã",Oo),j(t,"ã",Io),j(t,"ã",jo),j(t,"ã",Lo),j(t,"ï¼",zo),j(t,"ï¼",Po),j(t,"&",Bo),j(t,"*",_o),j(t,"@",nr),j(t,"`",Ho),j(t,"^",Vo),j(t,":",Ar),j(t,",",Fc),j(t,"$",Wo),j(t,".",Dn),j(t,"=",Uo),j(t,"!",Hc),j(t,"-",ln),j(t,"%",Hs),j(t,"|",Ko),j(t,"+",qo),j(t,"#",Jo),j(t,"?",Vs),j(t,'"',Vc),j(t,"/",Rn),j(t,";",Wc),j(t,"~",Ws),j(t,"_",Go),j(t,"\\",Fo),j(t,"ã»",Em);const r=Ke(t,_n,$c,{[Ia]:!0});Ke(r,_n,r);const s=Ke(r,$n,Cm,{[$s]:!0}),i=Ke(r,ws,Mm,{[Ts]:!0}),o=Ke(t,$n,Fn,{[ja]:!0});Ke(o,_n,s),Ke(o,$n,o),Ke(s,_n,s),Ke(s,$n,s);const l=Ke(t,ws,Pa,{[La]:!0});Ke(l,$n),Ke(l,_n,i),Ke(l,ws,l),Ke(i,_n,i),Ke(i,$n),Ke(i,ws,i);const a=j(t,Zl,_c,{[Gl]:!0}),c=j(t,Gu,_a,{[Gl]:!0}),d=Ke(t,Xl,_a,{[Gl]:!0});j(t,Ql,d),j(c,Zl,a),j(c,Ql,d),Ke(c,Xl,d),j(d,Gu),j(d,Zl),Ke(d,Xl,d),j(d,Ql,d);const u=Ke(t,Yl,Tm,{[Sm]:!0});j(u,"#"),Ke(u,Yl,u),j(u,fM,u);const f=j(u,hM);j(f,"#"),Ke(f,Yl,u);const h=[[$n,o],[_n,s]],m=[[$n,null],[ws,l],[_n,i]];for(let g=0;g<$i.length;g++)Xn(t,$i[g],Ba,Fn,h);for(let g=0;g<_i.length;g++)Xn(t,_i[g],$a,Pa,m);Tr(Ba,{tld:!0,ascii:!0},e),Tr($a,{utld:!0,alpha:!0},e),Xn(t,"file",to,Fn,h),Xn(t,"mailto",to,Fn,h),Xn(t,"http",Zr,Fn,h),Xn(t,"https",Zr,Fn,h),Xn(t,"ftp",Zr,Fn,h),Xn(t,"ftps",Zr,Fn,h),Tr(to,{scheme:!0,ascii:!0},e),Tr(Zr,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],S=n[g][1]?{[aM]:!0}:{[cM]:!0};y.indexOf("-")>=0?S[za]=!0:$n.test(y)?_n.test(y)?S[$s]=!0:S[ja]=!0:S[Ia]=!0,Ju(t,y,y,S)}return Ju(t,"localhost",ai,{ascii:!0}),t.jd=new Kt(Yo),{start:t,tokens:Object.assign({groups:e},Am)}}function Dm(n,e){const t=mM(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[o].length,f++),c+=t[o].length,i+=t[o].length,o++;i-=u,o-=f,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function mM(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function Xn(n,e,t,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?i=n.j[a]:(i=new Kt(r),i.jr=s.slice(),n.j[a]=i),n=i}return i=new Kt(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function Yu(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const ci={defaultProtocol:"http",events:null,format:Xu,formatHref:Xu,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Uc(n,e=null){let t=Object.assign({},ci);n&&(t=Object.assign(t,n instanceof Uc?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Uc.prototype={o:ci,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:ci[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Xu(n){return n}function Rm(n,e){this.t="token",this.v=n,this.tk=e}Rm.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"â¦":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=ci.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function bl(n,e){class t extends Rm{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const gM=bl("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Zu=bl("text"),yM=bl("nl"),Fi=bl("url",{isLink:!0,toHref(n=ci.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ai&&n[1].t===Ar}}),on=n=>new Kt(n);function bM({groups:n}){const e=n.domain.concat([Bo,_o,nr,Fo,Ho,Vo,Wo,Uo,ln,$c,Hs,Ko,qo,Jo,Rn,Yo,Ws,Go
vendor: 4,092 bytes, lines 204-207
204]),t=[$o,Ar,Fc,Dn,Hc,Hs,Vs,Vc,Wc,Ao,Do,_s,Fs,Mo,Co,Eo,To,Ro,No,Oo,Io,jo,Lo,zo,Po],r=[Bo,$o,_o,Fo,Ho,Vo,Wo,Uo,ln,_s,Fs,Hs,Ko,qo,Jo,Vs,Rn,Yo,Ws,Go],s=on(),i=j(s,Ws);oe(i,r,i),oe(i,n.domain,i);const o=on(),l=on(),a=on();oe(s,n.domain,o),oe(s,n.scheme,l),oe(s,n.slashscheme,a),oe(o,r,i),oe(o,n.domain,o);const c=j(o,nr);j(i,nr,c),j(l,nr,c),j(a,nr,c);const d=j(i,Dn);oe(d,r,i),oe(d,n.domain,i);const u=on();oe(c,n.domain,u),oe(u,n.domain,u);const f=j(u,Dn);oe(f,n.domain,u);const h=on(gM);oe(f,n.tld,h),oe(f,n.utld,h),j(c,ai,h);const m=j(u,ln);j(m,ln,m),oe(m,n.domain,u),oe(h,n.domain,u),j(h,Dn,f),j(h,ln,m);const g=j(o,ln),y=j(o,Dn);j(g,ln,g),oe(g,n.domain,o),oe(y,r,i),oe(y,n.domain,o);const b=on(Fi);oe(y,n.tld,b),oe(y,n.utld,b),oe(b,n.domain,o),oe(b,r,i),j(b,Dn,y),j(b,ln,g),j(b,nr,c);const S=j(b,Ar),C=on(Fi);oe(S,n.numeric,C);const T=on(Fi),M=on();oe(T,e,T),oe(T,t,M),oe(M,e,T),oe(M,t,M),j(b,Rn,T),j(C,Rn,T);const D=j(l,Ar),k=j(a,Ar),A=j(k,Rn),P=j(A,Rn);oe(l,n.domain,o),j(l,Dn,y),j(l,ln,g),oe(a,n.domain,o),j(a,Dn,y),j(a,ln,g),oe(D,n.domain,T),j(D,Rn,T),j(D,Vs,T),oe(P,n.domain,T),oe(P,e,T),j(P,Rn,T);const U=[[_s,Fs],[Co,Mo],[Eo,To],[Ao,Do],[Ro,No],[Oo,Io],[jo,Lo],[zo,Po]];for(let G=0;G<U.length;G++){const[V,ue]=U[G],ae=j(T,V);j(M,V,ae);const se=on(Fi);oe(ae,e,se);const de=on();oe(ae,t,de),j(ae,ue,T),oe(se,e,se),oe(se,t,de),oe(de,e,se),oe(de,t,de),j(se,ue,T),j(de,ue,T)}return j(s,ai,b),j(s,_c,yM),{start:s,tokens:Am}}function xM(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(ea(Zu,e,o)),o=[]),s-=f,d-=f;const h=u.t,m=t.slice(s-d,s);i.push(ea(h,e,m))}}return o.length>0&&i.push(ea(Zu,e,o)),i}function ea(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const wM=typeof console<"u"&&console&&console.warn||(()=>{}),kM="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Be={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function vM(){return Kt.groups={},Be.scanner=null,Be.parser=null,Be.tokenQueue=[],Be.pluginQueue=[],Be.customSchemes=[],Be.initialized=!1,Be}function Qu(n,e=!1){if(Be.initialized&&wM(`linkifyjs: already initialized - will not register custom scheme "${n}" ${kM}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 2051. Must only contain digits, lowercase ASCII letters or "-" 2062. Cannot start or end with "-" 2073. "-" cannot repeat`);Be.customSchemes.push([n,e])}function SM(){Be.scanner=pM(Be.customSchemes);for(let n=0;n<Be.tokenQueue.length;n++)Be.tokenQueue[n][1]({scanner:Be.scanner});Be.parser=bM(Be.scanner.tokens);for(let n=0;n<Be.pluginQueue.length;n++)Be.pluginQueue[n][1]({scanner:Be.scanner,parser:Be.parser});return Be.initialized=!0,Be}function Kc(n){return Be.initialized||SM(),xM(Be.parser.start,n,Dm(Be.scanner.start,n))}Kc.scan=Dm;function Nm(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Uc(t),s=Kc(n),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}const qc="[\0- Â áá â-\u2029âã]",CM=new RegExp(qc),MM=new RegExp(`${qc}$`),EM=new RegExp(qc,"g");function TM(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function AM(n){return new st({key:new Tt("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=dv(t.doc,[...e]);if(yv(l).forEach(({newRange:c})=>{const d=fv(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!MM.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}
vendor: 4,106 bytes, line 207
207if(u&&f){const h=f.split(CM).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=u.pos+f.lastIndexOf(m);if(!m)return!1;const y=Kc(m).map(b=>b.toObject(n.defaultProtocol));if(!TM(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{jc(b.from,b.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function DM(n){return new st({key:new Tt("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=om(e.state,n.type.name),c=r.target,d=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:a.href,u=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:a.target;return c&&d?(window.open(d,u),!0):!1}}})}function RM(n){return new st({key:new Tt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Nm(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function wr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(EM,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const NM=hn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){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(n=>{if(typeof n=="string"){Qu(n);return}Qu(n.scheme,n.optionalSlashes)})},onDestroy(){vM()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!wr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!wr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!wr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Fe(this.options.HTMLAttributes,n),0]:["a",Fe(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!wr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!wr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[gr({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Nm(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!wr(o,t),protocols:t,defaultProtocol:r}));
207s.length&&s.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(AM({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!wr(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(DM({type:this.type})),this.options.linkOnPaste&&n.push(RM({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),OM=NM.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),"data-slide-id":{default:null,parseHTML:e=>e.getAttribute("data-slide-id"),renderHTML:e=>{const t=e["data-slide-id"];return t?{"data-slide-id":t}:{}}}}}});let Fa,Ha;if(typeof WeakMap<"u"){let n=new WeakMap;Fa=e=>n.get(e),Ha=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Fa=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},Ha=(r,s)=>(t==10&&(t=0),n[t++]=r,n[t++]=s)}var Ge=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:s,top:i,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:s==this.width)?null:this.map[i*this.width+(t<0?r-1:s)]:(t<0?i==0:o==this.height)?null:this.map[r+this.width*(t<0?i-1:o)]}rectBetween(n,e){const{left:t,right:r,top:s,bottom:i}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let s=n.left;s<n.right;s++){const i=r*this.width+s,o=this.map[i];t[o]||(t[o]=!0,!(s==n.left&&s&&this.map[i-1]==o||r==n.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,s=0;;r++){const i=s+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(n){return Fa(n)||Ha(n,IM(n))}};function IM(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=jM(n),t=n.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let m=0;;m++){for(;s<r.length&&r[s]!=0;)s++;if(m==u.childCount)break;const g=u.child(m),{colspan:y,rowspan:b,colwidth:S}=g.attrs;for(let C=0;C<b;C++){if(C+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-C});break}const T=s+C*e;for(let M=0;M<y;M++){r[T+M]==0?r[T+M]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:y-M});const D=S&&S[M];if(D){const k=(T+M)%e*2,A=o[k];A==null||A!=D&&o[k+1]==1?(o[k]=D,o[k+1]=1):A==D&&o[k+1]++}}}s+=y,d+=g.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Ge(e,t,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&LM(l,o,n),l}function jM(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const s=n.child(r);let i=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function LM(n,e,t){n.problems||(n.problems=[]);const r={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(r[i])continue;
207r[i]=!0;const o=t.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=e[(s+c)%n.width*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=zM(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function zM(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function It(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const sr=new Tt("selectingCells");function $r(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function PM(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Sn(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function xl(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=$r(e.$head)||BM(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function BM(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Va(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function $M(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Jc(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Om(n,e,t){const r=n.node(-1),s=Ge.get(r),i=n.start(-1),o=s.nextCell(n.pos-i,e,t);return o==null?null:n.node(0).resolve(i+o)}function _r(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function Im(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function _M(n,e,t){const r=It(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}var Oe=class Hn extends X{constructor(e,t=e){const r=e.node(-1),s=Ge.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=i+d+1;return new Xh(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Va(r)&&Va(s)&&Jc(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Hn.rowSelection(r,s):i&&this.isColSelection()?Hn.colSelection(r,s):new Hn(r,s)}return q.between(r,s)}content(){const e=this.$anchorCell.node(-1),t=Ge.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const f=t.map[d];if(i[f])continue;i[f]=!0;const h=t.findCell(f);let m=e.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=s.left-h.left,y=h.right-s.right;if(g>0||y>0){let b=m.attrs;if(g>0&&(b=_r(b,0,g)),y>0&&(b=_r(b,b.colspan-y,y)),h.left<s.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...m.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}o.push(e.child(a).copy(N.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new z(N.from(l),1,1)}replace(e,t=z.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?z.empty:t)}const i=X.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new z(N.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Ge.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;
207const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),s=Ge.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Hn(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Ge.get(e),r=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Hn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),s=Ge.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Hn(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Hn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Hn(e.resolve(t),e.resolve(r))}getBookmark(){return new FM(this.$anchorCell.pos,this.$headCell.pos)}};Oe.prototype.visible=!1;X.jsonID("cell",Oe);var FM=class jm{constructor(e,t){this.anchor=e,this.head=t}map(e){return new jm(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Jc(t,r)?new Oe(t,r):X.near(r,1)}};function HM(n){if(!(n.selection instanceof Oe))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Ht.node(r,r+t.nodeSize,{class:"selectedCell"}))}),qe.create(n.doc,e)}function VM({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function WM({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function UM(n,e,t){const r=(e||n).selection,s=(e||n).doc;let i,o;if(r instanceof J&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Oe.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Oe.rowSelection(l,l)}else if(!t){const l=Ge.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Oe.create(s,a+1,c)}}else r instanceof q&&VM(r)?i=q.create(s,r.from):r instanceof q&&WM(r)&&(i=q.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}const KM=new Tt("fix-tables");function Lm(n,e,t,r){const s=n.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<s&&n.child(l).sameMarkup(a)?Lm(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function zm(n,e){let t;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=qM(n,s,i,t))};return e?e.doc!=n.doc&&Lm(e.doc,n.doc,0,r):n.doc.descendants(r),t}function qM(n,e,t,r){const s=Ge.get(e);if(!s.problems)return r;r||(r=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;
207r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,_r(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<f;y++){const b=It(n.schema)[h].createAndFill();b&&m.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),m)}c=u}return r.setMeta(KM,{fixTables:!0})}function zn(n){const e=n.selection,t=xl(n),r=t.node(-1),s=t.start(-1),i=Ge.get(r);return{...e instanceof Oe?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:r}}function Pm(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;_M(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Im(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?It(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function JM(n,e){if(!Sn(n))return!1;if(e){const t=zn(n);e(Pm(n.tr,t,t.left))}return!0}function GM(n,e){if(!Sn(n))return!1;if(e){const t=zn(n);e(Pm(n.tr,t,t.right))}return!0}function YM(n,{map:e,table:t,tableStart:r},s){const i=n.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=t.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,_r(d,s-e.colCount(a)));else{const u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}o+=d.rowspan}}function XM(n,e){if(!Sn(n))return!1;if(e){const t=zn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;YM(r,t,s),s!=t.left;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=Ge.get(i)}e(r)}return!0}function ZM(n,e,t){var r;const s=It(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function Bm(n,{map:e,tableStart:t,table:r},s){let i=t;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let l=s>0?-1:0;ZM(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;const u=l==null?It(r.type.schema).cell:(a=r.nodeAt(e.map[d+l*e.width]))===null||a===void 0?void 0:a.type,f=u==null?void 0:u.createAndFill();f&&o.push(f)}return n.insert(i,It(r.type.schema).row.create(null,o)),n}function QM(n,e){if(!Sn(n))return!1;if(e){const t=zn(n);e(Bm(n.tr,t,t.top))}return!0}function eE(n,e){if(!Sn(n))return!1;if(e){const t=zn(n);e(Bm(n.tr,t,t.bottom))}return!0}function tE(n,{map:e,table:t,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=t.child(c).nodeSize;const o=i+t.child(s).nodeSize,l=n.mapping.maps.length;n.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const f=t.nodeAt(u),h=f.attrs,m=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(s+1,c,t);n.insert(n.mapping.slice(l).map(r+g),m),c+=h.colspan-1}}}}function nE(n,e){if(!Sn(n))return!1;if(e){const t=zn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;tE(r,t,s),s!=t.top;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=Ge.get(t.table)}e(r)}return!0}function ef(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function rE({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;
207i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function tf(n,e){const t=n.selection;if(!(t instanceof Oe)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=zn(n),{map:s}=r;if(rE(s,r))return!1;if(e){const i=n.tr,o={};let l=N.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=s.map[d*s.width+u],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{ef(h)||(l=l.append(h.content));const m=i.mapping.map(f+r.tableStart);i.delete(m,m+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Im(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const d=a+1+c.content.size,u=ef(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Oe(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function nf(n,e){const t=It(n.schema);return sE(({node:r})=>t[r.type.spec.tableRole])(n,e)}function sE(n){return(e,t)=>{const r=e.selection;let s,i;if(r instanceof Oe){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=PM(r.$from),!s)return!1;i=(o=$r(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=zn(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let m=d.map.positionAt(h,d.left,d.table);h==d.top&&(m+=s.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&h==d.top||u.insert(f=u.mapping.map(m+d.tableStart,1),n({node:s,row:h,col:g}).createAndFill(a[y]))}u.setNodeMarkup(i,n({node:s,row:d.top,col:d.left}),a[0]),r instanceof Oe&&u.setSelection(new Oe(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),t(u)}return!0}}function iE(n,e){return function(t,r){if(!Sn(t))return!1;const s=xl(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof Oe?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function oE(n){return function(e,t){if(!Sn(e))return!1;if(t){const r=It(e.schema),s=zn(e),i=e.tr,o=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);t(i)}return!0}}function rf(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function di(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?oE(n):function(t,r){if(!Sn(t))return!1;if(r){const s=It(t.schema),i=zn(t),o=t.tr,l=rf("row",i,s),a=rf("column",i,s),c=(n==="column"?l:n==="row"&&a)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:i.map.height}:n=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,u=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(d).forEach(f=>{const h=f+i.tableStart,m=o.doc.nodeAt(h);m&&o.setNodeMarkup(h,u,m.attrs)}),r(o)}return!0}}di("row",{useDeprecatedLogic:!0});di("column",{useDeprecatedLogic:!0});const lE=di("cell",{useDeprecatedLogic:!0});function aE(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){const i=n.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function sf(n){return function(e,t){if(!Sn(e))return!1;const r=aE(xl(e),n);if(r==null)return!1;if(t){const s=e.doc.resolve(r);t(e.tr.setSelection(q.between(s,$M(s))).scrollIntoView())}return!0}}function cE(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Hi(n,e){const t=n.selection;if(!(t instanceof Oe))return!1;if(e){const r=n.tr,s=It(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new z(s,0,0))}),r.docChanged&&e(r)}return!0}function dE(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;
207const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Wa(It(o).row,new z(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?Wa(It(o).row,new z(e,t,r)).content:e);else return null;return uE(o,l)}function uE(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(N.empty),t[s]<r){const i=It(n).cell.createAndFill(),o=[];for(let l=t[s];l<r;l++)o.push(i);e[s]=e[s].append(N.from(o))}return{height:e.length,width:r,rows:e}}function Wa(n,e){const t=n.createAndFill();return new hc(t).replace(0,t.content.size,e).doc}function fE({width:n,height:e,rows:t},r,s){if(n!=r){const i=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(_r(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(N.from(c))}t=o,n=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(N.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function hE(n,e,t,r,s,i,o){const l=n.doc.type.schema,a=It(l);let c,d;if(s>e.width)for(let u=0,f=0;u<e.height;u++){const h=t.child(u);f+=h.nodeSize;const m=[];let g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)m.push(g);n.insert(n.mapping.slice(o).map(f-1+r),m)}if(i>e.height){const u=[];for(let m=0,g=(e.height-1)*e.width;m<Math.max(e.width,s);m++){const y=m>=e.width?!1:t.nodeAt(e.map[g+m]).type==a.header_cell;u.push(y?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,N.from(u)),h=[];for(let m=e.height;m<i;m++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||d)}function of(n,e,t,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const f=t.nodeAt(u),{top:h,left:m}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:o-h}),n.insert(n.mapping.slice(l).map(e.positionAt(o,m,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function lf(n,e,t,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const f=t.nodeAt(u),h=e.colCount(u),m=n.mapping.slice(l).map(u+r);n.setNodeMarkup(m,null,_r(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(m+f.nodeSize,f.type.createAndFill(_r(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function af(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let o=Ge.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=n.tr;let f=0;function h(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");o=Ge.get(i),f=u.mapping.maps.length}hE(u,o,i,t,c,d,f)&&h(),of(u,o,i,t,a,c,l,f)&&h(),of(u,o,i,t,a,c,d,f)&&h(),lf(u,o,i,t,l,d,a,f)&&h(),lf(u,o,i,t,l,d,c,f)&&h();for(let m=l;m<d;m++){const g=o.positionAt(m,a,i),y=o.positionAt(m,c,i);u.replace(u.mapping.slice(f).map(g+t),u.mapping.slice(f).map(y+t),new z(s.rows[m-l],0,0))}h(),u.setSelection(new Oe(u.doc.resolve(t+o.positionAt(l,a,i)),u.doc.resolve(t+o.positionAt(d-1,c-1,i)))),e(u)}const pE=Cc({ArrowLeft:Vi("horiz",-1),ArrowRight:Vi("horiz",1),ArrowUp:Vi("vert",-1),ArrowDown:Vi("vert",1),"Shift-ArrowLeft":Wi("horiz",-1),"Shift-ArrowRight":Wi("horiz",1),"Shift-ArrowUp":Wi("vert",-1),"Shift-ArrowDown":Wi("vert",1),Backspace:Hi,"Mod-Backspace":Hi,Delete:Hi,"Mod-Delete":Hi});function no(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Vi(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Oe)return no(t,r,X.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const o=$m(s,n,e);if(o==null)return!1;if(n=="horiz")return no(t,r,X.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(o),a=Om(l,n,e);let c;return a?c=X.near(a,1):e<0?c=X.near(t.doc.resolve(l.before(-1)),-1):c=X.near
207(t.doc.resolve(l.after(-1)),1),no(t,r,c)}}}function Wi(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;let o;if(i instanceof Oe)o=i;else{const a=$m(s,n,e);if(a==null)return!1;o=new Oe(t.doc.resolve(a))}const l=Om(o.$headCell,n,e);return l?no(t,r,new Oe(o.$anchorCell,l)):!1}}function mE(n,e){const t=n.state.doc,r=$r(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Oe(r))),!0):!1}function gE(n,e,t){if(!Sn(n.state))return!1;let r=dE(t);const s=n.state.selection;if(s instanceof Oe){r||(r={width:1,height:1,rows:[N.from(Wa(It(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Ge.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=fE(r,l.right-l.left,l.bottom-l.top),af(n.state,n.dispatch,o,l,r),!0}else if(r){const i=xl(n.state),o=i.start(-1);return af(n.state,n.dispatch,o,Ge.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function yE(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=cf(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Oe)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=$r(n.state.selection.$anchor))!=null&&((t=ta(n,e))===null||t===void 0?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=ta(n,c);const u=sr.getState(n.state)==null;
207if(!d||!Jc(a,d))if(u)d=a;else return;const f=new Oe(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(sr,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),sr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(sr,-1))}function l(a){const c=a,d=sr.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(cf(n,c.target)!=r&&(u=ta(n,e),!u))return o();u&&i(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function $m(n,e,t){if(!(n.state.selection instanceof q))return null;const{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?o:null}}return null}function cf(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ta(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:s}=t;return r>=0&&$r(n.state.doc.resolve(r))||$r(n.state.doc.resolve(s))}var bE=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ua(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Ua(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ua(n,e,t,r,s,i){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){const{colspan:h,colwidth:m}=c.child(u).attrs;for(let g=0;g<h;g++,f++){const y=s==f?i:m&&m[g],b=y?y+"px":"";if(o+=y||r,y||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const S=document.createElement("col");S.style.width=b,e.appendChild(S)}}}for(;a;){var d;const u=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}}const Zt=new Tt("tableColumnResizing");function xE({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=bE,lastColumnResizable:s=!0}={}){const i=new st({key:Zt,state:{init(o,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,d=It(l.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,t,f)),new wE(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Zt.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{kE(o,l,n,s)},mouseleave:o=>{vE(o)},mousedown:(o,l)=>{SE(o,l,e,t)}},decorations:o=>{const l=Zt.getState(o);if(l&&l.activeHandle>-1)return AE(o,l.activeHandle)},nodeViews:{}}});return i}var wE=class ro{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Zt);if(r&&r.setHandle!=null)return new ro(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ro(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Va(e.doc.resolve(s))||(s=-1),new ro(s,t.dragging)}return t}};function kE(n,e,t,r){if(!n.editable)return;const s=Zt.getState(n.state);if(s&&!s.dragging){const i=ME(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?o=df(n,e,"left",t):a-e.clientX<=t&&(o=df(n,e,"right",t))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=Ge.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}_m(n,o)}}}function vE(n){if(!n.editable)return;const e=Zt.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&_m(n,-1)}function SE(n,e,t,r){var s;if(!n.editable)return!1;const i=(s=n.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Zt.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=CE(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Zt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const f=Zt.getState(n.state);f!=null&&f.dragging&&(EE(n,f.activeHandle,uf(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(Zt,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=Zt.getState(n.state);if(f&&f.dragging){const h=uf(f.dragging,u,t);ff(n,f.activeHandle,h,r)}}return ff(n,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function CE(n,e,{colspan:t,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=n.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let a=0;a<t;a++)r[a]&&(o-=r[a],l--);return o/l}function ME(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function df(n,e,t,r){const s=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=$r(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=Ge.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function uf(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function _m(n,e){n.dispatch(n.state.tr.setMeta(Zt,{setHandle:e}))}
207function EE(n,e,t){const r=n.state.doc.resolve(e),s=r.node(-1),i=Ge.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],f=s.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==t)continue;const m=f.colwidth?f.colwidth.slice():TE(f.colspan);m[h]=t,a.setNodeMarkup(o+u,null,{...f,colwidth:m})}a.docChanged&&n.dispatch(a)}function ff(n,e,t,r){const s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Ge.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ua(i,a.firstChild,a,r,l,t)}function TE(n){return Array(n).fill(0)}function AE(n,e){const t=[],r=n.doc.resolve(e),s=r.node(-1);if(!s)return qe.empty;const i=Ge.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){var a;const u=i.map[d],f=o+u+s.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Zt.getState(n))===null||a===void 0)&&a.dragging&&t.push(Ht.no
207de(o+u,o+u+s.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(Ht.widget(f,h))}}return qe.create(n.doc,t)}function DE({allowTableNodeSelection:n=!1}={}){return new st({key:sr,state:{init(){return null},apply(e,t){const r=e.getMeta(sr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:HM,handleDOMEvents:{mousedown:yE},createSelectionBetween(e){return sr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:mE,handleKeyDown:pE,handlePaste:gE},appendTransaction(e,t,r){return UM(r,zm(r,t),n)}})}function Ka(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function hf(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let u=0,f=0;u<d.childCount;u+=1){const{colspan:h,colwidth:m}=d.child(u).attrs;for(let g=0;g<h;g+=1,f+=1){const y=s===f?i:m&&m[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[S,C]=Ka(r,y);c.style.setProperty(S,C)}c=c.nextSibling}else{const S=document.createElement("col"),[C,T]=Ka(r,y);S.style.setProperty(C,T),e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)===null||o===void 0||o.removeChild(c),c=u}a?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}class RE{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),hf(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,hf(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function NE(n,e,t,r){let s=0,i=!0;const o=[],l=n.firstChild;if(!l)return{};for(let u=0,f=0;u<l.childCount;u+=1){const{colspan:h,colwidth:m}=l.child(u).attrs;for(let g=0;g<h;g+=1,f+=1){const y=t===f?r:m&&m[g];s+=y||e,y||(i=!1);const[b,S]=Ka(e,y);o.push(["col",{style:`${b}: ${S}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function pf(n,e){return n.createAndFill()}function OE(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function IE(n,e,t,r,s){const i=OE(n),o=[],l=[];for(let c=0;c<t;c+=1){const d=pf(i.cell);if(d&&l.push(d),r){const u=pf(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function jE(n){return n instanceof Oe}const Ui=({editor:n})=>{const{selection:e}=n.state;if(!jE(e))return!1;let t=0;const r=im(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},LE=wt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:RE,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:s}=NE(n,this.options.cellMinWidth),i=["table",Fe(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=IE(i.schema,n,e,t);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(q.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>JM(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>GM(n,e),deleteColumn:()=>({state:n,dispatch:e})=>XM(n,e),addRowBefore:()=>({state:n,dispatch:e})=>QM(n,e),addRowAfter:()=>({state:n,dispatch:e})=>eE(n,e),deleteRow:()=>({state:n,dispatch:e})=>nE(n,e),deleteTable:()=>({state:n,dispatch:e})=>cE(n,e),mergeCells:()=>({state:n,dispatch:e})=>tf(n,e),splitCell:()=>({state:n,dispatch:e})=>nf(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>di("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>di("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>lE(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>tf(n,e)?!0:nf(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>iE(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>sf(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>sf(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&zm(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Oe.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ui,"Mod-Backspace":Ui,Delete:Ui,"Mod-Delete":Ui}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[xE({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],DE({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ne($(n,"tableRole",e))}}}),zE=LE.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),"data-toc":{default:null,parseHTML:e=>e.getAttribute("data-toc")==="true"?!0:null,renderHTML:e=>e["data-toc"]===!0?{"data-toc":"true"}:{}}}}}),mf='[data-rte-toolbar],.mantine-Popover-dropdown,.mantine-Select-dropdown,.mantine-ColorInput-dropdown,.mantine-Menu-
207dropdown,[role="listbox"]';function PE({initialHtml:n,baseFontPx:e,slides:t,onSave:r,onExit:s,onContentChange:i}){const o=x.useRef(null),l=vm(),a=x.useId(),c=x.useRef(()=>{}),d=dm({extensions:[gm.configure({heading:!1}),QC,VC,WC,UC,nM,iM,JC.configure({multicolor:!0}),ZC.configure({types:["paragraph","listItem"]}),OM.configure({openOnClick:!1,autolink:!1,protocols:["http","https","mailto"]}),zE.configure({resizable:!1}),XC,YC,GC],content:n||"<p></p>",autofocus:"end",editorProps:{attributes:{"aria-label":"Block text","aria-describedby":a},handleKeyDown:(h,m)=>m.key==="Escape"?(m.preventDefault(),c.current(!0),!0):!1}});x.useEffect(()=>{if(!(!d||!l))return l.setActive({editor:d,baseFontPx:e,slides:t}),()=>l.setActive(null)},[d,e,t]),x.useEffect(()=>{if(!d)return;const h=()=>i==null?void 0:i();return d.on("update",h),()=>{d.off("update",h)}},[d,i]);const u=h=>{var g;const m=h?(g=o.current)==null?void 0:g.closest(".slide-grid-item"):null;if(d){const y=Hr(d.getHTML());y!==n&&r(y)}s(),m==null||m.focus({preventScroll:!0})};c.current=u,x.useEffect(()=>{const h=m=>{var y;const g=m.target;g&&((y=o.current)!=null&&y.contains(g)||g.closest(mf)||u(!1))};return document.addEventListener("pointerdown",h,!0),()=>document.removeEventListener("pointerdown",h,!0)},[d]);const f=h=>{var y,b;const m=h.relatedTarget;if(!m||(y=o.current)!=null&&y.contains(m))return;const g=(b=o.current)==null?void 0:b.closest(".slide-grid-item");g&&g.contains(m)||m.closest(mf)||u(!1)};return d?p.jsxs("div",{ref:o,onBlur:f,children:[p.jsx(am,{editor:d,className:"deck-rte"}),p.jsx(jg,{id:a,children:"Press Escape to finish editing"})]}):null}function BE(n){return n===1?28:n===2?22:18}const $E=14,_E=8,FE=new Map;function HE({deckViz:n,canWrite:e,slides:t,onSaveContent:r,selected:s,onEditingChange:i,onMeasureHeight:o,requestEdit:l}){const a=n.block_type;return a==="title"?p.jsx(gf,{deckViz:n,canWrite:e,slides:t,onSave:r,selected:s,onEditingChange:i,onMeasureHeight:o,requestEdit:l,variant:"title"}):a==="paragraph"?p.jsx(gf,{deckViz:n,canWrite:e,slides:t,onSave:r,selected:s,onEditingChange:i,onMeasureHeight:o,requestEdit:l,variant:"paragraph"}):a==="image"?p.jsx(WE,{deckViz:n}):a==="shape"?p.jsx(VE,{deckViz:n}):null}function VE({deckViz:n}){return p.jsx(K,{w:"100%",h:"100%","data-pptx-role":"shape",children:p.jsx(Of,{props:n.props})})}function gf({deckViz:n,canWrite:e,slides:t,onSave:r,onEditingChange:s,onMeasureHeight:i,requestEdit:o,variant:l}){const[a,c]=x.useState(!1);x.useEffect(()=>{o&&e&&c(!0)},[o,e]);const d=fi(n.text_content),u=l==="title",f=n.heading_level??1,h=u?BE(f):$E,m=n.text_scale??1,g=n.auto_height!==!1,y=x.useRef(null),b=x.useRef(i);b.current=i;const S=x.useCallback(()=>{requestAnimationFrame(()=>{const M=y.current;M&&g&&b.current&&b.current(M.offsetHeight)})},[g]);x.useEffect(()=>{const M=y.current;if(!M||!g)return;S();const D=new ResizeObserver(()=>S());return D.observe(M),()=>D.disconnect()},[g,S]),x.useEffect(()=>{s==null||s(a)},[a,s]);const C={"--text-scale":m,fontSize:`calc(${h}px * var(--text-scale, 1))`,lineHeight:1.2,padding:_E},T=u?"Click to add titleâ¦":"Click to add textâ¦";return p.jsx(K,{h:"100%",style:{overflow:g?"hidden":"visible",cursor:e?a?"text":"move":"default"},onClick:()=>{!a&&e&&!d&&c(!0)},onDoubleClick:()=>{!a&&e&&c(!0)},children:p.jsx("div",{ref:y,"data-pptx-role":"text",style:C,children:a&&e?p.jsx(PE,{initialHtml:d,baseFontPx:h*m,slides:t,onSave:M=>r({text_content:M}),onExit:()=>c(!1),onContentChange:S}):d?p.jsx("div",{className:"deck-rte-content",dangerouslySetInnerHTML:{__html:gy(Hr(d),FE)}}):p.jsx(re,{span:!0,c:"dimmed",fw:400,fs:"italic",style:{fontSize:"inherit"},children:e?T:""})})})}function WE({deckViz:n}){var e;return n.image_url?p.jsx(K,{w:"100%",h:"100%",style:{overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},children:p.jsx(If,{src:n.image_url,alt:((e=n.props)==null?void 0:e.image_alt)??"Slide image",style:n.image_stretch?{width:"100%",height:"100%",objectFit:"fill"}:{width:"100%",height:"100%",objectFit:"contain"}})}):p.jsx(ar,{h:"100%",children:p.jsx(re,{size:"xs",c:"dimmed",fs:"italic",children:"Upload an image via the 3-dot menu"})})}/**
208 * @license @tabler/icons-react v3.41.1 - MIT 209 * 210 * This source code is licensed under the MIT license. 211 * See the LICENSE file in the root directory of this source tree. 212 */const UE=[["path",{d:"M3 13a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -6",key:"svg-0"}],["path",{d:"M12 8h2a1 1 0 0 1 1 1v2m0 4v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-10",key:"svg-1"}],["path",{d:"M15 11v-6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v12m-1 3h-4a1 1 0 0 1 -1 -1v-4",key:"svg-2"}],["path",{d:"M4 20h14",key:"svg-3"}],["path",{d:"M3 3l18 18",key:"svg-4"}]],Fm=pe("outline","chart-bar-off","ChartBarOff",UE);/** 213 * @license @tabler/icons-react v3.41.1 - MIT 214 * 215 * This source code is licensed under the MIT license. 216 * See the LICENSE file in the root directory of this source tree. 217 */const KE=[["path",{d:"M3 4a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-0"}],["path",{d:"M15 16a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4",key:"svg-1"}],["path",{d:"M21 11v-3a2 2 0 0 0 -2 -2h-6l3 3m0 -6l-3 3",key:"svg-2"}],["path",{d:"M3 13v3a2 2 0 0 0 2 2h6l-3 -3m0 6l3 -3",key:"svg-3"}]],qE=pe("outline","replace","Replace",KE);function JE({visualization:n,setVisualization:e,onOpen:t,minimal:r=!1,analyzing:s=!1,onTypeChange:i,contentScale:o=1,missing:l=!1,loadError:a=null,onRetryLoad:c,canEdit:d=!1,onRemove:u,onReplace:f,editing:h=!1}){const m=a?"Visualization couldn't load":l?"Visualization unavailable":n?Lf(n):"Untitled",g=!l&&!a&&n?by(n):void 0,y=t?b=>{b.currentTarget.contains(b.target)&&(b.target.closest("[data-no-open], button, a, input, select, textarea, label, [role='button'], [role='menuitem'], [role='option'], [role='combobox'], [role='slider'], [role='switch'], [role='tab'], [contenteditable='true']")||t())}:void 0;return p.jsxs(Nn,{direction:"column",h:"100%",mih:0,w:"100%",miw:0,children:[p.jsxs(K,{px:"lg",pt:5,pb:4,miw:0,mih:0,onDoubleClick:y,title:t?"Double-click to open":void 0,style:{overflow:"hidden",...t&&!h?{cursor:"pointer"}:void 0},children:[p.jsx(re,{fw:600,size:"sm",lineClamp:2,style:{wordBreak:"break-word"},children:m}),g&&p.jsx(re,{size:"xs",c:"dimmed",lineClamp:2,style:{wordBreak:"break-word"},children:g})]}),p.jsx(K,{px:"sm",pb:"sm",onDoubleClick:h?y:void 0,style:{flex:"1 1 auto",minHeight:0,position:"relative"},children:a?p.jsx(ar,{h:"100%",p:"md",children:p.jsxs(Mt,{align:"center",gap:6,maw:280,children:[p.jsx(Sy,{size:24,color:"var(--mantine-color-dimmed)","aria-hidden":!0}),p.jsx(re,{c:"dimmed",size:"sm",ta:"center",fw:500,children:a}),p.jsx(re,{c:"dimmed",size:"xs",ta:"center",children:"The chart may still exist â this slide couldnât check."}),c&&p.jsx(Ee,{gap:"xs",mt:"xs",justify:"center",onMouseDown:b=>b.stopPropagation(),children:p.jsx(We,{size:"xs",variant:"default",leftSection:p.jsx(zf,{size:14,"aria-hidden":!0}),onClick:c,children:"Try again"})})]})}):l?p.jsx(ar,{h:"100%",p:"md",children:p.jsxs(Mt,{align:"center",gap:6,maw:280,children:[p.jsx(Fm,{size:24,color:"var(--mantine-color-dimmed)","aria-hidden":!0}),p.jsx(re,{c:"dimmed",size:"sm",ta:"center",fw:500,children:"This visualization is no longer available"}),p.jsx(re,{c:"dimmed",size:"xs",ta:"center",children:"It may have been deleted from its source dashboard."}),d&&(u||f)&&p.jsxs(Ee,{gap:"xs",mt:"xs",justify:"center",onMouseDown:b=>b.stopPropagation(),children:[f&&p.jsx(We,{size:"xs",variant:"default",leftSection:p.jsx(qE,{size:14,"aria-hidden":!0}),onClick:f,children:"Replace"}),u&&p.jsx(We,{size:"xs",color:"red",variant:"light",leftSection:p.jsx(ss,{size:14,"aria-hidden":!0}),onClick:u,children:"Remove visualization"})]})]})}):n?p.jsx(Yg,{minimal:r,allowAdmin:!1,configOverrides:Xg,visualization:n,setVisualization:e,analyzing:s,onTypeChange:i&&n.id?b=>i(n.id,b):void 0,contentScale:o,interactive:!h}):p.jsx(ar,{p:"md",children:p.jsx(re,{c:"dimmed",size:"sm",children:"Loading visualization..."})})})]})}/** 218 * @license @tabler/icons-react v3.41.1 - MIT 219 * 220 * This source code is licensed under the MIT license. 221 * See the LICENSE file in the root directory of this source tree. 222 */const GE=[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M8 12l8 0",key:"svg-1"}],["path",{d:"M6 18l12 0",key:"svg-2"}]],YE=pe("outline","align-center","AlignCenter",GE);/**
223 * @license @tabler/icons-react v3.41.1 - MIT 224 * 225 * This source code is licensed under the MIT license. 226 * See the LICENSE file in the root directory of this source tree. 227 */const XE=[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 12l10 0",key:"svg-1"}],["path",{d:"M4 18l14 0",key:"svg-2"}]],ZE=pe("outline","align-left","AlignLeft",XE);/** 228 * @license @tabler/icons-react v3.41.1 - MIT 229 * 230 * This source code is licensed under the MIT license. 231 * See the LICENSE file in the root directory of this source tree. 232 */const QE=[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M10 12l10 0",key:"svg-1"}],["path",{d:"M6 18l14 0",key:"svg-2"}]],eT=pe("outline","align-right","AlignRight",QE);/** 233 * @license @tabler/icons-react v3.41.1 - MIT 234 * 235 * This source code is licensed under the MIT license. 236 * See the LICENSE file in the root directory of this source tree. 237 */const tT=[["path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M12.5 5.5l4 4",key:"svg-1"}],["path",{d:"M4.5 13.5l4 4",key:"svg-2"}],["path",{d:"M21 15v4h-8l4 -4l4 0",key:"svg-3"}]],nT=pe("outline","highlight","Highlight",tT);/** 238 * @license @tabler/icons-react v3.41.1 - MIT 239 * 240 * This source code is licensed under the MIT license. 241 * See the LICENSE file in the root directory of this source tree. 242 */const rT=[["path",{d:"M11 5l6 0",key:"svg-0"}],["path",{d:"M7 19l6 0",key:"svg-1"}],["path",{d:"M14 5l-4 14",key:"svg-2"}]],sT=pe("outline","italic","Italic",rT);/** 243 * @license @tabler/icons-react v3.41.1 - MIT 244 * 245 * This source code is licensed under the MIT license. 246 * See the LICENSE file in the root directory of this source tree. 247 */const iT=[["path",{d:"M7 20v-12a4 4 0 0 1 4 -4h2a4 4 0 0 1 4 4v12",key:"svg-0"}],["path",{d:"M7 13l10 0",key:"svg-1"}]],oT=pe("outline","letter-a","LetterA",iT);/** 248 * @license @tabler/icons-react v3.41.1 - MIT 249 * 250 * This source code is licensed under the MIT license. 251 * See the LICENSE file in the root directory of this source tree. 252 */const lT=[["path",{d:"M3 8l3 -3l3 3",key:"svg-0"}],["path",{d:"M3 16l3 3l3 -3",key:"svg-1"}],["path",{d:"M6 5l0 14",key:"svg-2"}],["path",{d:"M13 6l7 0",key:"svg-3"}],["path",{d:"M13 12l7 0",key:"svg-4"}],["path",{d:"M13 18l7 0",key:"svg-5"}]],aT=pe("outline","line-height","LineHeight",lT);/** 253 * @license @tabler/icons-react v3.41.1 - MIT 254 * 255 * This source code is licensed under the MIT license. 256 * See the LICENSE file in the root directory of this source tree. 257 */const cT=[["path",{d:"M11 6h9",key:"svg-0"}],["path",{d:"M11 12h9",key:"svg-1"}],["path",{d:"M12 18h8",key:"svg-2"}],["path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4",key:"svg-3"}],["path",{d:"M6 10v-6l-2 2",key:"svg-4"}]],dT=pe("outline","list-numbers","ListNumbers",cT);/** 258 * @license @tabler/icons-react v3.41.1 - MIT 259 * 260 * This source code is licensed under the MIT license. 261 * See the LICENSE file in the root directory of this source tree. 262 */const uT=[["path",{d:"M7 5v5a5 5 0 0 0 10 0v-5",key:"svg-0"}],["path",{d:"M5 19h14",key:"svg-1"}]],fT=pe("outline","underline","Underline",uT);function hT(n){const e=x.useRef(null),t=x.useCallback(()=>{const o=n.current;return o?Array.from(o.querySelectorAll("button, input, [tabindex]")).filter(l=>{if(l.hasAttribute("disabled")||l.getAttribute("aria-disabled")==="true"||l.getAttribute("data-disabled")==="true"||l.getAttribute("tabindex")==="-1"&&l!==e.current&&!(l instanceof HTMLButtonElement||l instanceof HTMLInputElement))return!1;if(l instanceof HTMLInputElement&&l.type==="radio"){const a=o.querySelectorAll(`input[type="radio"][name="${l.name}"]`),c=Array.from(a).find(d=>d.checked)??a[0];return l===c}return!0}):[]},[n]),r=x.useCallback(()=>{const o=t();if(o.length===0)return;let l=e.current;(!l||!o.includes(l))&&(l=o[0]),e.current=l;for(const a of o)a.tabIndex=a===l?0:-1},[t]);return x.useEffect(()=>{r()}),{onFocus:o=>{const l=o.target;t().includes(l)&&(e.current=l,r())},onKeyDown:o=>{const{key:l}=o;if(l!=="ArrowLeft"&&l!=="ArrowRight"&&l!=="Home"&&l!=="End")return;const a=o.target;if(a instanceof HTMLInputElement){if(a.type==="radio")return;if(!a.readOnly){if(l==="Home"||l==="End")return;const f=a.selectionStart===0&&a.selectionEnd===0,h=a.selectionStart===a.value.length;if(l==="ArrowLeft"&&!f||l==="ArrowRight"&&!h)return}}const c=t(),d=c.indexOf(a);if(d<0)return;let u=d;l==="ArrowLeft"?u=(d-1+c.length)%c.length:l==="ArrowRight"?u=(d+1)%c.length:l==="Home"?u=0:u=c.length-1,o.preventDefault(),e.current=c[u],r(),c[u].focus()}}}const pT=[{value:"",label:"IBM Plex Sans"},{value:"Arial, sans-serif",label:"Arial"},{value:"Georgia, serif",label:"Georgia"},{value:'"Times New Roman", serif',label:"Times New Roman"},{value:'"Courier New", monospace',label:"Courier New"},{value:"Verdana, sans-serif",label:"Verdana"}],Hm=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],mT=[6,8,9,10,11,12,14,16,18,20,24,28,32,36,40,48,56,64,72,80,88,96].map(String);function gT({editor:n,baseFontPx:e,chain:t}){const r=n.getAttributes("textStyle").fontSize,s=Math.round(r?parseFloat(r)*e:e),[i,o]=x.useState(null),l=i??String(s),a=d=>{const u=Math.max(1,Math.min(400,Math.round(d)));let f=t();n.state.selection.empty&&(f=f.selectAll()),f.setFontSize(`${u/e}em`).run()},c=d=>{const u=parseInt(d,10);Number.isNaN(u)||a(u),o(null)};return p.jsxs(Ee,{gap:2,wrap:"nowrap",children:[p.jsx(we,{variant:"default",size:"sm",onClick:()=>a(s-1),"aria-label":"Decrease font size",children:p.jsx(gh,{size:14,"aria-hidden":!0})}),p.jsx(ec,{size:"xs",w:42,value:l,data:mT,"aria-label":"Font size",selectFirstOptionOnChange:!1,filter:({options:d})=>d,comboboxProps:{withinPortal:!0},onMouseDown:d=>d.stopPropagation(),onChange:d=>o(d.replace(/[^0-9]/g,"")),onOptionSubmit:d=>c(d),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),c(l)),d.key==="Escape"&&o(null)},onBlur:()=>{i!==null&&c(i)},styles:{input:{textAlign:"center",padding:"0 4px",height:"26px",minHeight:"26px",lineHeight:"26px"}}}),p.jsx(we,{variant:"default",size:"sm",onClick:()=>a(s+1),"aria-label":"Increase font size",children:p.jsx(ui,{size:14,"aria-hidden":!0})})]})}function Us({icon:n,label:e,value:t,onPick:r,onClear:s}){const[i,o]=x.useState(!1);return p.jsxs(Kn,{opened:i,onChange:o,position:"bottom",shadow:"md",withinPortal:!0,closeOnClickOutside:!0,closeOnEscape:!0,returnFocus:!0,children:[p.jsx(Kn.Target,{children:p.jsxs(we,{variant:"default",size:"sm","aria-label":e,"aria-expanded":i,onClick:()=>o(l=>!l),style:{position:"relative"},children:[n,p.jsx("span",{style:{position:"absolute",left:4,right:4,bottom:2,height:3,borderRadius:1,background:t||"transparent"}})]})}),p.jsx(Kn.Dropdown,{p:"xs",children:p.jsxs(Mt,{gap:"xs",children:[p.jsx(Xa,{format:"hex",value:t||"#000000",onChange:r,swatches:Hm}),p.jsxs(Ee,{justify:s?"space-between":"flex-end",children:[s&&p.jsx(We,{variant:"subtle",size:"compact-xs",onClick:()=>{s(),o(!1)},children:"Clear"}),p.jsx(We,{variant:"light",size:"compact-xs",onClick:()=>o(!1),children:"Done"})]})]})})]})}function yT({editor:n,slides:e,chain:t}){const[r,s]=x.useState(!1),[i,o]=x.useState("url"),[l,a]=x.useState(""),[c,d]=x.useState(null),u=n.getAttributes("link"),f=n.isActive("link"),h=u["data-sli
262de-id"]??null,m=u.href??"",g=!n.state.selection.empty,y=A=>/^(https?:|mailto:)/i.test(A),b=g||f,S=b&&y(l.trim()),C=b&&!!c,T=()=>{h?(o("slide"),d(h),a("")):(o("url"),a(m),d(null)),s(!0)},M=()=>{const A=l.trim();if(!b||!y(A))return;let P=t();f&&(P=P.extendMarkRange("link")),P.setLink({href:A,"data-slide-id":null}).setUnderline().run(),s(!1)},D=()=>{if(!b||!c)return;let A=t();f&&(A=A.extendMarkRange("link")),A.setLink({href:"#","data-slide-id":c}).setUnderline().run(),s(!1)},k=()=>{t().extendMarkRange("link").unsetLink().run(),s(!1)};return p.jsxs(Kn,{opened:r,onChange:s,position:"bottom",shadow:"md",withinPortal:!0,closeOnClickOutside:!0,closeOnEscape:!0,returnFocus:!0,children:[p.jsx(Kn.Target,{children:p.jsx(we,{variant:f?"filled":"default",size:"sm","aria-label":"Link","aria-pressed":f,"aria-expanded":r,onClick:()=>r?s(!1):T(),children:p.jsx(Cy,{size:16,"aria-hidden":!0})})}),p.jsx(Kn.Dropdown,{p:"xs",onMouseDown:A=>A.stopPropagation(),children:p.jsxs(Mt,{gap:"xs",w:260,children:[p.jsx(so,{size:"xs",fullWidth:!0,"aria-label":"Link type",value:i,onChange:A=>o(A),data:[{value:"url",label:"Web URL"},{value:"slide",label:"Slide"}]}),i==="url"?p.jsx(Ks,{size:"xs",placeholder:"https://example.com","aria-label":"Link URL",value:l,onChange:A=>a(A.currentTarget.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),M())}}):p.jsx(Ja,{size:"xs",placeholder:"Choose a slide","aria-label":"Link to slide",searchable:!0,data:e.map(A=>({value:A.id,label:A.label})),value:c,onChange:d,comboboxProps:{withinPortal:!1},nothingFoundMessage:"No other slides"}),p.jsxs(Ee,{justify:"space-between",children:[p.jsx(We,{variant:"subtle",size:"compact-xs",disabled:!f,onClick:k,children:"Remove"}),p.jsx(We,{variant:"light",size:"compact-xs",disabled:i==="url"?!S:!C,onClick:i==="url"?M:D,children:"Apply"})]})]})})]})}const bT=[{value:null,label:"Default"},{value:1,label:"Single"},{value:1.15,label:"1.15"},{value:1.5,label:"1.5"},{value:2,label:"Double"}];function xT({editor:n,chain:e}){const t=sM(n);return p.jsxs(B,{position:"bottom",shadow:"md",withinPortal:!0,children:[p.jsx(B.Target,{children:p.jsx(we,{variant:"default",size:"sm","aria-label":"Line spacing",children:p.jsx(aT,{size:16,"aria-hidden":!0})})}),p.jsx(B.Dropdown,{children:bT.map(({value:r,label:s})=>p.jsx(B.Item,{rightSection:t===r?p.jsx(Tf,{size:14,"aria-hidden":!0}):void 0,onClick:()=>{const i=e();r===null?i.unsetLineHeight().run():i.setLineHeight(r).run()},children:s},s))})]})}function wT({leadingControl:n}){const e=vm(),t=(e==null?void 0:e.active)??null,r=(t==null?void 0:t.editor)??null,s=x.useRef(null),i=hT(s),o=x.useRef(!1),[,l]=x.useReducer(y=>y+1,0);if(x.useEffect(()=>{if(!r)return;const y=()=>l();return r.on("transaction",y),()=>{r.off("transaction",y)}},[r]),!t||!r)return null;const{baseFontPx:a,slides:c}=t,d=r.getAttributes("textStyle").fontFamily??"",u=r.isActive({textAlign:"center"})?"center":r.isActive({textAlign:"right"})?"right":"left",f=r.getAttributes("textStyle").color??"",h=r.getAttributes("highlight").color??"",m=y=>y.preventDefault(),g=()=>o.current?r.chain().focus():r.chain();return p.jsx(Xo,{ref:s,withBorder:!0,p:4,"data-rte-toolbar":!0,role:"toolbar","aria-label":"Text formatting",onMouseDown:m,onPointerDownCapture:()=>{o.current=!0},onKeyDownCapture:()=>{o.current=!1},onKeyDown:i.onKeyDown,onFocus:i.onFocus,style:{display:"inline-block"},children:p.jsxs(Ee,{gap:6,wrap:"wrap",align:"center",children:[n,p.jsx(Ja,{size:"xs",w:130,"aria-label":"Font family",data:pT,value:d,onChange:y=>{y?g().setFontFamily(y).run():g().unsetFontFamily().run()},comboboxProps:{withinPortal:!0}}),p.jsx(gT,{editor:r,baseFontPx:a,chain:g}),p.jsxs(Ee,{gap:2,wrap:"nowrap",children:[p.jsxs(we.Group,{children:[p.jsx(we,{variant:r.isActive("bold")?"filled":"default",size:"sm",onClick:()=>g().toggleBold().run(),"aria-label":"Bold","aria-pressed":r.isActive("bold"),children:p.jsx(yh,{size:16,"aria-hidden":!0})}),p.jsx(we,{variant:r.isActive("italic")?"filled":"default",size:"sm",onClick:()=>g().toggleItalic().run(),"aria-label":"Italic","aria-pressed":r.isActive("italic"),children:p.jsx(sT,{size:16,"aria-hidden":!0})}),p.jsx(we,{variant:r.isActive("underline")?"filled":"default",size:"sm",onClick:()=>g().toggleUnderline().run(),"aria-label":"Underline","aria-pressed":r.isActive("underline"),children:p.jsx(fT,{size:16,"aria-hidden":!0})})]}),p.jsx(Us,{icon:p.jsx(oT,{size:16,"aria-hidden":!0}),label:"Text color",value:f,onPick:y=>r.chain().setColor(y).run(),onClear:()=>g().unsetColor().run()}),p.jsx(Us,{icon:p.jsx(nT,{size:16,"aria-hidden":!0}),label:"Highlight color",value:h,onPick:y=>r.chain().setHighlight({color:y}).run(),onClear:()=>g().unsetHighlight().run()})]}),p.jsx(so,{size:"xs","aria-label":"Text alignment",value:u,onChange:y=>g().setTextAlign(y).run(),data:[{value:"left",label:p.jsx(ZE,{size:14,"aria-hidden":!0})},{value:"center",label:p.jsx(YE,{size:14,"aria-hidden":!0})},{value:"right",label:p.jsx(eT,{size:14,"aria-hidden":!0})}]}),p.jsx(yT,{editor:r,slides:c,chain:g}),p.jsx(xT,{editor:r,chain:g}),p.jsxs(we.Group,{children:[p.jsx(we,{variant:r.isActive("bulletList")?"filled":"default",size:"sm",onClick:()=>g().toggleBulletList().run(),"aria-label":"Bullet list","aria-pressed":r.isActive("bulletList"),children:p.jsx(Nf,{size:16,"aria-hidden":!0})}),p.jsx(we,{variant:r.isActive("orderedList")?"filled":"default",size:"sm",onClick:()=>g().toggleOrderedList().run(),"aria-label":"Numbered list","aria-pressed":r.isActive("orderedList"),children:p.jsx(dT,{size:16,"aria-hidden":!0})})]})]})})}const kT=x.forwardRef(function({deckViz:e,visualization:t,vizLoaded:r=!0,vizError:s=null,onRetryViz:i,analyzing:o,workspaceId:l,canWrite:a,contentScale:c=1,otherPages:d,canExpand:u,onRemove:f,onReplace:h,onRefresh:m,onMove:g,onExpand:y,onMinimalModeChange:b,onBackgroun
262dColorChange:S,onTypeChange:C,onVisualizationUpdate:T,onSaveBlockContent:M,onSaveBlockProps:D,selected:k=!1,onSelect:A,onMeasureBlockHeight:P,onUploadImage:U,style:G,className:V,onPointerDown:ue,blockLabel:ae,tabIndex:se,ariaCurrent:de,ariaDescribedBy:ye,onFocus:Qe,onKeyDown:be,onKeyUp:De,children:Ue},ve){var zt,Ye;const[lt,Me]=x.useState(!1),[at,$e]=x.useState(0),[ct,ie]=x.useState(!1),[me,Q]=x.useState(!1),{prompt:Te,promptDialog:Ie}=wy(),dt=async()=>{var kt;const F=((kt=e.props)==null?void 0:kt.image_alt)??"",Xe=await Te({title:"Image description",label:"Describe this image for screen readers",description:"Say what the picture shows. Leave empty if it is purely decorative.",initialValue:F,confirmLabel:"Save",allowEmpty:!0});Xe===null||Xe===F||D==null||D(e.id,{image_alt:Xe||null})},le=e.block_type??"visualization",xe=le==="visualization",Se=le==="shape",Pn=le==="title"||le==="paragraph",Gt=xe&&!t?s:null,pn=xe&&r&&!t&&!Gt,Re=pn||!!Gt,At=!xe&&!Se&&(le==="image"?!e.image_url:!Qa(e.text_content)),Lt=e.minimal_mode??"auto",ut=Lt==="on"?!0:Lt==="off"?!1:e.w<50,Cn=Ga(),en=Re?void 0:()=>Cn(`/${l}/visualization/${e.visualization_id}`),He=[];xe&&en&&He.push({key:"open",label:"Open",Icon:Lg,onClick:en}),xe&&a&&(t!=null&&t.content.datasource_id)&&He.push({key:"refresh",label:"Refresh data",Icon:zf,onClick:()=>e.visualization_id&&m(e.visualization_id)}),xe&&!Re&&a&&u&&He.push({key:"expand",label:"Expand to slide",Icon:zg,onClick:()=>y(e.id)}),xe&&!Re&&a&&b&&He.push({key:"minimal",sub:p.jsxs(B.Sub,{children:[p.jsx(B.Sub.Target,{children:p.jsx(B.Sub.Item,{leftSection:p.jsx(zC,{size:16,"aria-hidden":!0}),children:"Minimal mode"})}),p.jsx(B.Sub.Dropdown,{children:["auto","on","off"].map(F=>p.jsx(B.Item,{leftSection:Lt===F?p.jsx(Tf,{size:16,"aria-hidden":!0}):p.jsx(K,{w:14}),onClick:()=>b(e.id,F),children:F==="auto"?"Auto (default)":F==="on"?"Always minimal":"Never minimal"},F))})]})}),a&&S&&He.push({key:"background",sub:p.jsxs(B.Sub,{children:[p.jsx(B.Sub.Target,{children:p.jsx(B.Sub.Item,{leftSection:p.jsx(Zg,{size:14,"aria-hidden":!0}
262),children:"Background color"})}),p.jsx(B.Sub.Dropdown,{children:p.jsxs(K,{p:"xs",children:[p.jsx(Xa,{format:"hex",value:e.background_color||"#ffffff",onChangeEnd:F=>S(e.id,F),swatches:Hm}),p.jsx(We,{fullWidth:!0,variant:"subtle",size:"compact-xs",mt:"xs",disabled:!e.background_color,onClick:()=>S(e.id,""),children:"Clear"})]})})]})}),le==="image"&&a&&He.push({key:"upload",label:"Upload image",Icon:Za,onClick:()=>U==null?void 0:U(e.id)}),le==="image"&&a&&D&&He.push({key:"alt",label:(zt=e.props)!=null&&zt.image_alt?"Edit image descriptionâ¦":"Add image descriptionâ¦",Icon:BC,onClick:dt}),!Pn&&a&&D&&He.push({key:"border",label:"Borderâ¦",Icon:jC,onClick:()=>ie(!0)}),a&&d.length>0&&He.push({key:"move",sub:p.jsxs(B.Sub,{children:[p.jsx(B.Sub.Target,{children:p.jsx(B.Sub.Item,{leftSection:p.jsx(Af,{size:16,"aria-hidden":!0}),children:"Move to"})}),p.jsx(B.Sub.Dropdown,{children:d.map(F=>p.jsx(B.Item,{onClick:()=>g(e.id,F.id),children:F.label},F.id))})]})}),a&&He.push({key:"remove",label:"Remove",Icon:ss,color:"red",onClick:()=>f(e.id)});const ft=He.length===1&&"onClick"in He[0]?He[0]:null,Dt={className:["slide-grid-item-menu",me?"slide-grid-item-menu-open":""].filter(Boolean).join(" "),pos:"absolute",top:2,right:2,style:{zIndex:3,transform:`scale(${c})`,transformOrigin:"top right",gap:2}};x.useEffect(()=>Me(!1),[e.id]);const Rt=F=>{if(F.target===F.currentTarget&&(F.key==="Enter"||F.key==="F2")){if(xe){en&&(F.preventDefault(),en());return}if(Pn&&a){F.preventDefault(),$e(Xe=>Xe+1);return}}be==null||be(F)};return p.jsxs(Xo,{ref:ve,role:"group","aria-label":ae,"aria-current":de,"aria-describedby":ye,tabIndex:se,onFocus:Qe,onKeyDown:Rt,onKeyUp:De,className:[V,"slide-grid-item",a?"slide-grid-item-editable":"",a&&At?"slide-grid-item-empty":"",k?"slide-grid-item-selected":"",lt?"slide-grid-item-editing":""].filter(Boolean).join(" "),style:{...G,background:e.background_color||void 0,...jf((Ye=e.props)==null?void 0:Ye.border)},onPointerDown:ue,p:0,children:[p.jsxs(K,{display:"flex",pos:"absolute",mih:0,inset:0,style:{flexDirection:"column",overflow:Se||!xe&&le!=="image"&&e.auto_height===!1?"visible":"hidden"},children:[ft?p.jsx(K,{...Dt,children:p.jsx(xn,{label:ft.label,withArrow:!0,openDelay:150,children:p.jsx(we,{"aria-label":ae?`${ft.label.replace(/â¦$/,"")} ${ae}`:ft.label,variant:"subtle",color:ft.color??"blue",size:"sm",onMouseDown:F=>{F.stopPropagation(),A==null||A()},onClick:ft.onClick,children:p.jsx(ft.Icon,{size:14,"aria-hidden":!0})})})}):He.length>0?p.jsx(K,{...Dt,children:p.jsxs(B,{shadow:"md",position:"bottom-end",opened:me,onChange:Q,children:[p.jsx(B.Target,{children:p.jsx(we,{"aria-label":ae?`Options for ${ae}`:"Block options",variant:"subtle",color:"blue",size:"sm",onMouseDown:F=>{F.stopPropagation(),A==null||A()},children:p.jsx(Qo,{size:14,"aria-hidden":!0})})}),p.jsx(B.Dropdown,{children:He.map(F=>"onClick"in F?p.jsx(B.Item,{color:F.color,leftSection:p.jsx(F.Icon,{size:16,"aria-hidden":!0}),onClick:F.onClick,children:F.label},F.key):p.jsx(x.Fragment,{children:F.sub},F.key))})]})}):null,xe?p.jsx(JE,{visualization:t,setVisualization:T,analyzing:o,onOpen:en,minimal:ut,contentScale:c,onTypeChange:C,missing:pn,loadError:Gt,onRetryLoad:i,canEdit:a,onRemove:()=>f(e.id),onReplace:()=>h(e.id),editing:a}):p.jsx(HE,{deckViz:e,canWrite:a,slides:d,onSaveContent:F=>M==null?void 0:M(e.id,F),selected:k,onEditingChange:Me,onMeasureHeight:F=>P==null?void 0:P(e.id,F),requestEdit:at})]}),Ue,p.jsx("div",{onPointerDown:F=>F.stopPropagation(),children:Ie}),D&&p.jsx(As,{opened:ct,onClose:()=>ie(!1),title:"Border",size:"auto",onPointerDown:F=>F.stopPropagation(),children:p.jsx(xm,{props:e.props,onChange:F=>D(e.id,F)})})]})}),Vm=x.createContext(null);function Wm(){return x.useContext(Vm)}const Fr=2/48*100,mr=1/28*100,vT=".ProseMirror, .slide-grid-item-menu, .slide-resize-handle, .slide-endpoint-handle, [data-menu-dropdown]";function ST(n){return n.closest(vT)!==null}const CT=["nw","n","ne","e","se","s","sw","w"];function MT(n){return n==="nw"||n==="ne"||n==="se"||n==="sw"}function ET(n,e,t,r){const s=Math.min(100,Math.max(Fr,t)),i=Math.min(100,Math.max(mr,r));return{x:Math.min(100-s,Math.max(0,n)),y:Math.min(100-i,Math.max(0,e)),w:s,h:i}}function Um(n,e,t,r){let{x:s,y:i,w:o,h:l}=n;const a=s+o,c=i+l;return e.includes("e")&&(o=Math.max(Fr,Math.min(o+t,100-s))),e.includes("s")&&(l=Math.max(mr,Math.min(l+r,100-i))),e.includes("w")&&(o=Math.max(Fr,Math.min(o-t,a)),s=a-o),e.includes("n")&&(l=Math.max(mr,Math.min(l-r,c)),i=c-l),{x:s,y:i,w:o,h:l}}function TT(n,e,t,r,s,i,o){const l=Um(n,e,t,r),c=n.w*i/(n.h*o)*(o/i),d=e==="e"||e==="w"?!0:e==="n"||e==="s"?!1:l.w>=l.h*c,u=d?l.w:l.h*c,f=d?l.w/c:l.h,h=n.x+n.w,m=n.y+n.h,g=n.x+n.w/2,y=n.y+n.h/2;let b=n.x,S=n.y,C=n.x,T=n.y;switch(e){case"se":b=n.x,S=n.y,C=n.x,T=n.y;break;case"nw":b=h,S=m,C=h-u,T=m-f;break;case"ne":b=n.x,S=m,C=n.x,T=m-f;break;case"sw":b=h,S=n.y,C=h-u,T=n.y;break;case"e":b=n.x,S=y,C=n.x,T=y-f/2;break;case"w":b=h,S=y,C=h-u,T=y-f/2;break;case"s":b=g,S=n.y,C=g-u/2,T=n.y;break;case"n":b=g,S=m,C=g-u/2,T=m-f;break}const M=C,D=C+u,k=T,A=T+f,P=M<b?b/(b-M):1/0,U=D>b?(100-b)/(D-b):1/0,G=k<S?S/(S-k):1/0,V=A>S?(100-S)/(A-S):1/0,ue=Math.min(P,U,G,V),ae=Math.max(Fr/u,mr/f),se=ae<=ue?Math.min(Math.max(1,ae),ue):ue;
262return{w:u*se,h:f*se,x:b+(C-b)*se,y:S+(T-S)*se}}function AT(n,e,t){if(!Number.isFinite(e)||e<=0||n.h<=0)return n;const r=e/t;let s=n.w,i=n.h;return n.w/n.h>r?s=n.h*r:i=n.w/r,{x:n.x,y:n.y,w:Math.min(100,Math.max(Fr,s)),h:Math.min(100,Math.max(mr,i))}}function DT(n,e){return Math.abs(n.x-e.x)>1e-6||Math.abs(n.y-e.y)>1e-6||Math.abs(n.w-e.w)>1e-6||Math.abs(n.h-e.h)>1e-6}function RT({dv:n,type:e,dir:t,event:r,width:s,canvasHeight:i,blocks:o,setDraft:l,onLayoutChange:a,onResizeBlockHeight:c,onImageStretch:d,snapDraft:u,snapResize:f,setOverlay:h}){const m=r.clientX,g=r.clientY,y={x:n.x,y:n.y,w:n.w,h:n.h},b=r.currentTarget,S=r.pointerId;let C=y,T=!1,M=!1,D=!1,k=!1;const A=se=>{if(se.pointerId!==S)return;const de=se.clientX-m,ye=se.clientY-g;if((Math.abs(de)>1||Math.abs(ye)>1)&&(T=!0,!M))try{b.setPointerCapture(S),M=!0}catch{}const Qe=de/s*100,be=ye/i*100;if(e==="drag"){let De=ET(y.x+Qe,y.y+be,y.w,y.h);if(u){const Ue=u(De);De=Ue.rect,h==null||h({guides:Ue.guides,segments:Ue.segments})}C=De}else if(n.block_type==="image"&&MT(t)&&!se.shiftKey)C=TT(y,t,Qe,be,void 0,s,i),k=!1,h==null||h({guides:[],segments:[]});else{let De=Um(y,t,Qe,be);if(f){const Ue=f(De,t);De=Ue.rect,h==null||h({guides:Ue.guides,segments:Ue.segments})}C=De,e==="resize"&&n.block_type==="image"&&(k=!0)}l({id:n.id,...C})},P=()=>{h==null||h({guides:[],segments:[]}),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",V),window.removeEventListener("blur",ae),b.removeEventListener("lostpointercapture",ue),M&&b.hasPointerCapture(S)&&b.releasePointerCapture(S)},U=()=>{D||(D=!0,P(),l(null))},G=se=>{se.pointerId!==S||D||(D=!0,P(),l(null),T&&(a==null||a(o.map(de=>de.id===n.id?{id:de.id,...C}:{id:de.id,x:de.x,y:de.y,w:de.w,h:de.h})),e==="resize"&&(n.block_type==="title"||n.block_type==="paragraph")&&Math.abs(C.h-y.h)>1e-6&&(c==null||c(n.id)),e==="resize"&&n.block_type==="image"&&k&&DT(y,C)&&(d==null||d(n.id,!0))))},V=se=>{se.pointerId===S&&U()},ue=se=>{se.pointerId!==S||D||(M=!1)},ae=()=>U();window.addEventListener("pointermove",A),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",V),window.addEventListener("blur",ae),b.addEventListener("lostpointercapture",ue)}const jr=16/9,NT=6,OT=24,IT=14,yf=4;function jT(n,e,t,r){const s=yf/t*100,i=yf/r*100,o={};return n.includes("w")&&e.x<=s&&(o.left=0),n.includes("e")&&e.x+e.w>=100-s&&(o.right=0),n.includes("n")&&e.y<=i&&(o.top=0),n.includes("s")&&e.y+e.h>=100-i&&(o.bottom=0),o}const LT=1,zT=5,PT=300,bf={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function xf(n,e,t){var s,i;const r=e+1;switch(n.block_type){case"title":case"paragraph":{const o=Qa(n.text_content).replace(/\s+/g," ").trim(),l=o.length>40?`${o.slice(0,40)}â¦`:o,a=n.block_type==="title"?"Title":"Text";return l?`${a} block ${r}: ${l}`:`${a} block ${r}`}case"image":{const o=(i=(s=n.props)==null?void 0:s.image_alt)==null?void 0:i.trim();return o?`Image block ${r}: ${o}`:`Image block ${r}`}case"shape":{const o=Ds(n.props).shape_kind;return`${o?`${o[0].toUpperCase()}${o.slice(1)} shape`:"Shape"} ${r}`}default:{const o=t?Lf(t):void 0;return o?`Chart block ${r}: ${o}`:`Chart block ${r}`}}}const Ki=6,wf=6;function BT({seg:n,color:e}){const t=n.role==="size"?"dashed":"solid";return n.axis==="horizontal"?p.jsxs(p.Fragment,{children:[p.jsx(K,{style:{position:"absolute",left:`${n.from}%`,width:`${n.to-n.from}%`,top:`${n.cross}%`,borderTop:`1px ${t} ${e}`}}),[n.from,n.to].map((r,s)=>p.jsx(K,{style:{position:"absolute",left:`${r}%`,top:`${n.cross}%`,height:wf,borderLeft:`1px solid ${e}`,transform:"translateY(-50%)"}},s))]}):p.jsxs(p.Fragment,{children:[p.jsx(K,{style:{position:"absolute",top:`${n.from}%`,height:`${n.to-n.from}%`,left:`${n.cross}%`,borderLeft:`1px ${t} ${e}`}}),[n.from,n.to].map((r,s)=>p.jsx(K,{style:{position:"absolute",top:`${r}%`,left:`${n.cross}%`,width:wf,borderTop:`1px solid ${e}`,transform:"translateX(-50%)"}},s))]})}function $T({guides:n,segments:e}){const t="var(--sd-color-accent)";return p.jsxs(K,{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:5},children:[n.map(r=>r.axis==="vertical"?p.jsx(K,{style:{position:"absolute",top:0,bottom:0,left:`${r.pos}%`,width:1,background:t}},`v-${r.kind}-${r.pos}`):p.jsx(K,{style:{position:"absolute",left:0,right:0,top:`${r.pos}%`,height:1,background:t}},`h-${r.kind}-${r.pos}`)),e.map((r,s)=>p.jsx(BT,{seg:r,color:t},`s-${r.role}-${r.axis}-${s}`))]})}function _T({page:n,pages:e,vizMap:t,vizLoaded:r=!0,vizError:s=null,onRetryViz:i,analyzingVizIds:o,workspaceId:l,canWrite:a,readOnly:c=!1,notesOpen:d,onToggleNotes:u,onLayoutChange:f,onRemoveViz:h,onReplaceViz:m,onRefreshViz:g,onMoveViz:y,onExpandViz:b,onMinimalModeChange:S,onSelectBlock:C,onSaveBlockProps:T,onBackgroun
262dColorChange:M,onTypeChange:D,onVisualizationUpdate:k,onSaveBlockContent:A,onResizeBlockHeight:P,onAutoHeight:U,onImageStretch:G,onUploadImage:V,onUpdateBlockProps:ue,onAddVisualization:ae,onNewVisualization:se,onDuplicateElement:de,onPasteImage:ye,onPasteText:Qe}){const be=x.useRef(null),De=x.useRef(null),Ue=x.useRef(null),[ve,lt]=x.useState({width:1200,height:1200/jr}),[Me,at]=x.useState(1),$e=x.useRef(1);$e.current=Me;const ct=x.useRef(null),[ie,me]=x.useState(null);x.useEffect(()=>{C==null||C(ie)},[ie,C]),x.useEffect(()=>{if(!ie)return;const v=Dt(ie);v&&Re(`Selected ${v}`)},[ie]);const[Q,Te]=x.useState(null),[Ie,dt]=x.useState(null),le=x.useRef(null),[xe,Se]=x.useState({guides:[],segments:[]}),[Pn,Gt]=x.useState(""),pn=x.useRef(0),Re=x.useCallback(v=>{pn.current+=1,Gt(pn.current%2?v:`${v}Â `)},[]),At=x.useRef(null),Lt=x.useCallback(()=>{const v=At.current;v&&(clearTimeout(v.timer),At.current=null,Re(v.message))},[Re]),ut=x.useCallback(v=>{At.current&&clearTimeout(At.current.timer),At.current={message:v,timer:setTimeout(Lt,PT)}},[Lt]);x.useEffect(()=>()=>{At.current&&clearTimeout(At.current.timer)},[]);const Cn=x.useId(),en=`${Cn}-block`,He=`${Cn}-viz`,[ft]=x.useState(()=>{var v,O;return typeof window<"u"&&(((O=(v=window.matchMedia)==null?void 0:v.call(window,"(pointer: coarse)"))==null?void 0:O.matches)??!1)}),Dt=x.useCallback(v=>{const O=n.visualizations.findIndex(Y=>Y.id===v);if(O<0)return null;const W=n.visualizations[O];return xf(W,O,W.visualization_id?t[W.visualization_id]:void 0)},[n.visualizations,t]);x.useEffect(()=>{const v=De.current??be.current;if(!v)return;const O=(ee,H)=>{ee>0&&H>0&<({width:ee,height:H})},W=new ResizeObserver(ee=>{var ke;const H=(ke=ee[0])==null?void 0:ke.contentRect;O((H==null?void 0:H.width)??v.clientWidth,(H==null?void 0:H.height)??v.clientHeight)});W.observe(v),O(v.clientWidth,v.clientHeight);const Y=requestAnimationFrame(()=>O(v.clientWidth,v.clientHeight));return()=>{W.disconnect(),cancelAnimationFrame(Y)}},[]);const zt=Math.max(1,Math.min(ve.width,1600,ve.height*jr)),Ye=zt/jr,F=zt*Me,Xe=Ye*Me,kt=Math.round(ve.width/2),Pt=Math.round(ve.height/2),Mn=x.useCallback((v,O,W)=>{const Y=be.current,ee=$e.current,H=Yi(v(ee));if(H!==ee){if(Y){const ke=Y.getBoundingClientRect(),Ne=O===void 0?Y.clientWidth/2:O-ke.left,it=W===void 0?Y.clientHeight/2:W-ke.top;ct.current=H===1&&O===void 0?{kind:"center"}:{kind:"point",cx:(Y.scrollLeft+Ne-kt)/ee,cy:(Y.scrollTop+it-Pt)/ee,vx:Ne,vy:it}}at(H)}},[kt,Pt]);x.useLayoutEffect(()=>{const v=be.current,O=ct.current;!v||!O||(ct.current=null,O.kind==="center"?(v.scrollLeft=kt+F/2-v.clientWidth/2,v.scrollTop=Pt+Xe/2-v.clientHeight/2):(v.scrollLeft=kt+O.cx*Me-O.vx,v.scrollTop=Pt+O.cy*Me-O.vy))},[Me,kt,Pt,F,Xe]),x.useLayoutEffect(()=>{const v=be.current;!v||$e.current!==1||(v.scrollLeft=kt+F/2-v.clientWidth/2,v.scrollTop=Pt+Xe/2-v.clientHeight/2)},[ve.width,ve.height,kt,Pt,F,Xe]),x.useEffect(()=>{const v=be.current;if(!v)return;const O=W=>{ex(W)&&(W.preventDefault(),Mn(Y=>Qb(Y,W.deltaY),W.clientX,W.clientY))};return v.addEventListener("wheel",O,{passive:!1}),()=>v.removeEventListener("wheel",O)},[Mn]);const ps=Math.max(.5,Math.min(1,zt/1100)),mn=1,fe=x.useMemo(()=>{if(!ie)return null;const v=n.visualizations.find(O=>O.id===ie);return!v||v.block_type!=="title"&&v.block_type!=="paragraph"&&v.block_type!=="image"&&v.block_type!=="shape"?null:{block_type:v.block_type,text_content:v.text_content,heading_level:v.heading_level,image_url:v.image_url,x:v.x,y:v.y,w:v.w,h:v.h,text_scale:v.text_scale,auto_height:v.auto_height,props:v.props}},[n.visualizations,ie]);x.useEffect(()=>{le.current=null,me(null)},[n.id]),x.useEffect(()=>{ie&&!n.visualizations.some(v=>v.id===ie)&&(le.current=null,me(null))},[n.visualizations,ie]);const _e=Wm(),Bt=_e==null?void 0:_e.setActive;x.useEffect(()=>{if(!Bt)return;const v=ie?n.visualizations.find(O=>O.id===ie):void 0;(v==null?void 0:v.block_type)==="shape"&&a&&!c&&ue?Bt({deckViz:v,onChange:O=>ue(v.id,O)}):Bt(null)},[Bt,ie,n.visualizations,a,c,ue]),x.useEffect(()=>()=>Bt==null?void 0:Bt(null),[Bt]);const[,_]=x.useState(0);Pg(!c&&a&&(!!ie||!!le.current),()=>{le.current=null,me(null),_(v=>v+1)}),x.useEffect(()=>{if(c||!a||!ie&&!le.current)return;const v=O=>{const W=O.target;
262if(!bs(W)){if(ie&&(O.key==="Backspace"||O.key==="Delete")){O.preventDefault();const Y=Dt(ie);h==null||h(ie),le.current=null,me(null),Y&&Re(`Deleted ${Y}`);return}(O.metaKey||O.ctrlKey)&&!O.shiftKey&&!O.altKey&&O.key.toLowerCase()==="c"&&fe&&!bs(W)&&(le.current=fe)}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Re,a,Dt,h,c,ie,fe]),x.useEffect(()=>{if(c||!a||!fe)return;const v=O=>{const W=O.target;bs(W)||(O.preventDefault(),le.current=fe,SC(O.clipboardData,fe))};return window.addEventListener("copy",v),()=>window.removeEventListener("copy",v)},[a,c,fe]),x.useEffect(()=>{if(c||!a)return;const v=O=>{const W=O.target;if(bs(W))return;const Y=O.clipboardData;if(!Y)return;const ee=CC(Y);if(ee){O.preventDefault(),le.current=null,de==null||de(ee),Re("Pasted 1 block");return}const H=TC(Y.items);if(H.kind==="found"){O.preventDefault(),le.current=null,ye==null||ye(AC(H.file,H.ext)),Re("Pasted 1 block");return}if(H.kind==="unsupported"){O.preventDefault(),ge.show({color:"red",message:`Unsupported image format (${H.mime}). Allowed: PNG, JPEG, GIF, WEBP.`});return}const ke=DC(it=>Y.getData(it));if(ke){O.preventDefault(),le.current=null,Qe==null||Qe(ke),Re("Pasted 1 block");return}const Ne=le.current;Ne&&(O.preventDefault(),le.current=null,de==null||de(Ne),Re("Pasted 1 block"))};return window.addEventListener("paste",v),()=>window.removeEventListener("paste",v)},[Re,a,de,ye,Qe,c]);const Ve=(v,O,W,Y)=>{RT({dv:v,type:O,dir:W,event:Y,width:F,canvasHeight:Xe,blocks:n.visualizations,setDraft:Te,onLayoutChange:f,onResizeBlockHeight:P,onImageStretch:G,setOverlay:Se,snapDraft:ee=>{const H=n.visualizations.filter(Le=>Le.id!==v.id).map(Le=>({x:Le.x,y:Le.y,w:Le.w,h:Le.h})),{x:ke,y:Ne,guides:it,segments:je}=NC(ee,H,{thresholdX:Ki/F*100,thresholdY:Ki/Xe*100});return{rect:{...ee,x:ke,y:Ne},guides:it,segments:je}},snapResize:(ee,H)=>{const ke=n.visualizations.filter(et=>et.id!==v.id).map(et=>({x:et.x,y:et.y,w:et.w,h:et.h})),Ne={top:H.includes("n"),right:H.includes("e"),bottom:H.includes("s"),left:H.includes("w")},{x:it,y:je,w:Le,h:gn,guides:En,segments:Tn}=OC(ee,Ne,ke,{thresholdX:Ki/F*100,thresholdY:Ki/Xe*100,minW:Fr,minH:mr});return{rect:{x:it,y:je,w:Le,h:gn},guides:En,segments:Tn}}})},ht=(v,O)=>{var Y,ee;if(c||!a)return;me(v.id);const W=O.target;ST(W)||(O.preventDefault(),(ee=(Y=O.currentTarget)==null?void 0:Y.focus)==null||ee.call(Y,{preventScroll:!0}),Ve(v,"drag",null,O))},Yt=(v,O,W,Y,ee)=>{const H={x:v.x,y:v.y,w:v.w,h:v.h},ke=(je,Le,gn)=>Math.min(Math.max(je,Le),Math.max(Le,gn)),Ne=ee?{...H,w:ke(H.w+O*Y,Fr,100-H.x),h:ke(H.h+W*Y,mr,100-H.y)}:{...H,x:ke(H.x+O*Y,0,100-H.w),y:ke(H.y+W*Y,0,100-H.h)};if(Ne.x===H.x&&Ne.y===H.y&&Ne.w===H.w&&Ne.h===H.h)return;f==null||f(n.visualizations.map(je=>je.id===v.id?{id:je.id,...Ne}:{id:je.id,x:je.x,y:je.y,w:je.w,h:je.h}));const it=je=>`${Math.round(je)}%`;ee?((v.block_type==="title"||v.block_type==="paragraph")&&Ne.h!==H.h&&(P==null||P(v.id)),v.block_type==="image"&&(G==null||G(v.id,!0)),ut(`Resized to ${it(Ne.w)} by ${it(Ne.h)}`)):ut(`Moved to ${it(Ne.x)}, ${it(Ne.y)}`)},pt=(v,O)=>{if(c||!a||O.target!==O.currentTarget||bs(O.target)||ie!==v.id)return;const W=bf[O.key];W&&(O.preventDefault(),Yt(v,W[0],W[1],O.shiftKey?zT:LT,O.ctrlKey||O.metaKey))},vt=v=>{v.key in bf&&Lt()},$t=(v,O)=>{c||!a||O.currentTarget.contains(O.target)&&me(v.id)},tn=(v,O,W)=>{if(c||!a)return;W.preventDefault(),W.stopPropagation(),me(v.id);const Y=Ue.current;if(!Y)return;const ee=Y.getBoundingClientRect(),H=W.currentTarget;try{H.setPointerCapture(W.pointerId)}catch{}const ke=Ds(v.props),Ne={x:v.x+(ke.x1??0)/100*v.w,y:v.y+(ke.y1??0)/100*v.h},it={x:v.x+(ke.x2??100)/100*v.w,y:v.y+(ke.y2??100)/100*v.h},je=O==="start"?it:Ne,Le=2,gn=Math.min(22,64/ee.width*100),En=Math.min(22,36/ee.height*100);let Tn=null;const et=ze=>{const yn=Math.max(0,Math.min(100,(ze.clientX-ee.left)/ee.width*100)),Gn=Math.max(0,Math.min(100,(ze.clientY-ee.top)/ee.height*100)),bn=O==="start"?{x:yn,y:Gn}:je,Yn=O==="start"?je:{x:yn,y:Gn},Wr=Math.max(0,Math.min(bn.x,Yn.x)-Le),Ur=Math.max(0,Math.min(bn.y,Yn.y)-En),wl=Math.min(100,Math.max(bn.x,Yn.x)+gn),kl=Math.min(100,Math.max(bn.y,Yn.y)+Le),ms=Math.max(1,wl-Wr),Kr=Math.max(1,kl-Ur),ki=Ci=>({x:(Ci.x-Wr)/ms*100,y:(Ci.y-Ur)/Kr*100}),vi=ki(bn),gs=ki(Yn),Si={x1:vi.x,y1:vi.y,x2:gs.x,y2:gs.y};Te({id:v.id,x:Wr,y:Ur,w:ms,h:Kr}),dt({id:v.id,props:{...ke,...Si}}),Tn={layout:{x:Wr,y:Ur,w:ms,h:Kr},props:Si}},ce=()=>{window.removeEventListener("pointermove",et),window.removeEventListener("pointerup",ce),Tn&&(f==null||f(n.visualizations.map(ze=>
262ze.id===v.id?{id:ze.id,...Tn.layout}:{id:ze.id,x:ze.x,y:ze.y,w:ze.w,h:ze.h})),ue==null||ue(v.id,Tn.props)),Te(null),dt(null)};window.addEventListener("pointermove",et),window.addEventListener("pointerup",ce)},Ze=(v,O,W)=>{c||!a||(W.preventDefault(),W.stopPropagation(),me(v.id),Ve(v,"resize",O,W))},_t=x.useMemo(()=>e.map((v,O)=>({id:v.id,label:v.title||`Slide ${O+1}`})).filter(v=>v.id!==n.id),[e,n.id]),Ft=n.visualizations.length===0;return p.jsxs(Nn,{direction:"column",w:"100%",h:"100%",mih:0,children:[p.jsxs(K,{ref:De,flex:"1 1 auto",mih:0,p:{base:"xs",md:"sm"},bg:"var(--sd-color-canvas-surround)",style:{overflow:"hidden"},onMouseDown:v=>{v.target.closest(".slide-grid-item")||me(null)},children:[p.jsx(K,{ref:be,className:"slide-canvas","data-zoom":Me.toFixed(2),style:{width:"100%",height:"100%",overflow:"auto"},children:p.jsx(K,{style:{position:"relative",width:F+2*kt,height:Xe+2*Pt},children:p.jsxs(K,{ref:Ue,style:{position:"absolute",left:kt,top:Pt,width:zt,height:Ye,transform:`scale(${Me})`,transformOrigin:"top left",background:"var(--sd-color-surface)",border:"1px solid var(--sd-color-canvas-edge)",borderRadius:"var(--sd-radius-xs)",overflow:"hidden",backgroundImage:"linear-gradient(to right, var(--sd-color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, var(--sd-color-border-subtle) 1px, transparent 1px)",backgroundPosition:"0 0",backgroundSize:`${zt/OT}px ${Ye/IT}px`,backgroundRepeat:"repeat"},onMouseDown:v=>{v.target.closest(".slide-grid-item")||me(null)},children:[Ft&&!c&&p.jsx(K,{style:{position:"absolute",top:"50%",left:"50%",transform:`translate(-50%, -50%) scale(${ps})`,transformOrigin:"center"},children:p.jsxs(Mt,{align:"center",gap:"md",style:{textAlign:"center"},children:[p.jsx(re,{c:"dimmed",style:{whiteSpace:"nowrap"},children:"No visualizations on this slide yet."}),a&&p.jsxs(Ee,{gap:"sm",wrap:"nowrap",justify:"center",children:[se&&p.jsx(We,{variant:"filled",color:"blue",size:"sm",leftSection:p.jsx(Ss,{size:16,"aria-hidden":!0}),onClick:se,children:"New visualization"}),ae&&p.jsx(We,{size:"sm",leftSection:p.jsx(Ji,{size:16,"aria-hidden":!0}),onClick:ae,children:"Import visualization"})]})]})}),n.visualizations.map((v,O)=>{const W=Q&&Q.id===v.id?Q:v,Y=ie===v.id&&!c,ee=Y&&a,H=v.visualization_id?t[v.visualization_id]:void 0,ke=(v.block_type??"visualization")==="visualization",Ne=xf(v,O,H),it=a&&!c?ke?He:en:ke&&!c?He:void 0,je=(Ie==null?void 0:Ie.id)===v.id?Ie.props:void 0,Le=v.block_type==="shape"&&Ds(je??v.props).shape_kind==="line",gn=je?{...v,props:je}:v,En=Ds(je??v.props),Tn=Math.abs(W.x)<.01&&Math.abs(W.y)<.01&&Math.abs(W.w-100)<.01&&Math.abs(W.h-100)<.01,et=n.visualizations.length===1&&!Tn;return p.jsxs(kT,{deckViz:gn,style:{position:"absolute",left:`${W.x}%`,top:`${W.y}%`,width:`${W.w}%`,height:`${W.h}%`,boxSizing:"border-box",touchAction:a&&!c&&(!ft||(Q==null?void 0:Q.id)===v.id)?"none":"auto"},onPointerDown:ce=>ht(v,ce),tabIndex:c?-1:0,blockLabel:Ne,ariaCurrent:Y?"true":void 0,ariaDescribedBy:it,onFocus:ce=>$t(v,ce),onKeyDown:ce=>pt(v,ce),onKeyUp:vt,visualization:H,vizLoaded:r,vizError:s,onRetryViz:i,analyzing:v.visualization_id?(o==null?void 0:o.has(v.visualization_id))??!1:!1,workspaceId:l,contentScale:mn,canWrite:a&&!c,otherPages:_t,canExpand:et,onRemove:ce=>h==null?void 0:h(ce),onReplace:ce=>m==null?void 0:m(ce),onRefresh:ce=>g==null?void 0:g(ce),onMove:(ce,ze)=>y==null?void 0:y(ce,ze),onExpand:ce=>b==null?void 0:b(ce),onMinimalModeChange:S?(ce,ze)=>S(ce,ze):void 0,onSaveBlockProps:T,onBackgroundColorChange:M?(ce,ze)=>M(ce,ze):void 0,onTypeChange:D,onVisualizationUpdate:k,onSaveBlockContent:A,selected:Y,onSelect:()=>{!c&&a&&me(v.id)},onMeasureBlockHeight:(ce,ze)=>{if(v.auto_height===!1)return;const yn=Math.max(mr,Math.min(100,(ze-NT)/Ye*100));Math.abs(yn-v.h)>.01&&(U==null||U(ce,yn))},onUploadImage:V,children:[ee&&Le&&["start","end"].map(ce=>{const ze=ce==="start"?En.x1:En.x2,yn=ce==="start"?En.y1:En.y2;return p.jsx("div",{className:"slide-endpoint-handle","aria-hidden":!0,onPointerDown:Gn=>tn(v,ce,Gn),style:{position:"absolute",left:`${ze??0}%`,top:`${yn??0}%`,width:12,height:12,transform:"translate(-50%, -50%)",borderRadius:"50%",background:"#fff",border:"2px s
262olid var(--mantine-primary-color-filled)",cursor:"grab",zIndex:4,touchAction:"none"}},ce)}),ee&&!Le&&CT.map(ce=>p.jsx("div",{className:`slide-resize-handle slide-resize-handle-${ce}`,"aria-hidden":!0,style:jT(ce,W,zt,Ye),onPointerDown:ze=>Ze(v,ce,ze)},ce))]},v.id)}),(xe.guides.length>0||xe.segments.length>0)&&p.jsx($T,{guides:xe.guides,segments:xe.segments})]})})}),p.jsx("div",{className:"sr-only",role:"status","aria-live":"polite",children:Pn}),p.jsx("div",{className:"sr-only",id:en,children:"Arrow keys move the block, Shift for larger steps, Control and arrow keys resize. Enter edits text. Delete removes the block. Escape deselects."}),p.jsxs("div",{className:"sr-only",id:He,children:["Press Enter to open.",a&&!c?" Arrow keys move the block, Shift for larger steps, Control and arrow keys resize. Delete removes the block. Escape deselects.":""]})]}),p.jsxs(Ee,{justify:"space-between",wrap:"nowrap",px:"sm",py:4,bg:"var(--sd-color-surface)",style:{borderTop:"1px solid var(--sd-color-border)"},children:[u?p.jsx(We,{variant:d?"light":"subtle",color:"gray",size:"compact-sm",style:{color:"var(--sd-color-text)"},leftSection:p.jsx(tc,{size:16,"aria-hidden":!0}),"aria-label":d?"Hide speaker notes":"Show speaker notes","aria-expanded":d,"aria-controls":Oa,onClick:u,children:"Speaker Notes"}):p.jsx("span",{}),p.jsxs(Ee,{role:"toolbar",gap:2,"aria-label":"Slide zoom",onPointerDown:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),children:[p.jsx(we,{variant:"subtle",color:"gray",size:"sm","aria-label":"Zoom out",disabled:Me<=ph,onClick:()=>Mn(v=>Yi(v/da)),children:p.jsx(gh,{size:14,"aria-hidden":!0})}),p.jsxs(We,{variant:"subtle",color:"gray",size:"compact-xs",w:48,onClick:()=>Mn(()=>1),title:"Reset to fit (â/Ctrl + scroll to zoom)","aria-label":"Reset zoom to fit",children:[Math.round(Me*100),"%"]}),p.jsx(we,{variant:"subtle",color:"gray",size:"sm","aria-label":"Zoom in",disabled:Me>=mh,onClick:()=>Mn(v=>Yi(v*da)),children:p.jsx(ui,{size:14,"aria-hidden":!0})})]})]})]})}function FT({blocks:n}){return p.jsx(K,{"aria-hidden":!0,pos:"relative",w:"100%",bg:"var(--mantine-color-body)",style:{aspectRatio:jr,border:"1px solid var(--mantine-color-default-border)",borderRadius:"var(--sd-radius-xs)",overflow:"hidden"},children:n.map((e,t)=>p.jsx(HT,{block:e},t))})}function HT({block:n}){const e={position:"absolute",left:`${n.x}%`,top:`${n.y}%`,width:`${n.w}%`,height:`${n.h}%`,padding:2,boxSizing:"border-box"};return n.block_type==="image"?p.jsx(K,{style:e,children:p.jsx(K,{h:"100%",bg:"var(--mantine-color-default-hover)",style:{border:"1px solid var(--mantine-color-default-border)",borderRadius:2,display:"flex",alignItems:"center",justifyContent:"center"},children:p.jsx(Za,{size:14,color:"var(--mantine-color-dimmed)","aria-hidden":!0})})}):n.block_type==="title"?p.jsx(K,{style:e,children:p.jsx(K,{h:"100%",bg:"var(--sd-color-accent)",style:{borderRadius:2,opacity:.85}})}):p.jsx(K,{style:e,children:p.jsx(K,{h:"100%",style:{display:"flex",flexDirection:"column",gap:3,paddingTop:1,overflow:"hidden"},children:[100,92,96,70].map((t,r)=>p.jsx(K,{h:3,w:`${t}%`,bg:"var(--mantine-color-dimmed)",style:{borderRadius:1,opacity:.5,flex:"0 0 auto"}},r))})})}function VT({opened:n,onClose:e,onSelect:t}){return p.jsx(As,{opened:n,onClose:e,title:"Choose a layout",size:"lg",children:p.jsx(My,{cols:{base:2,sm:3},spacing:"md",children:Xb.map(r=>p.jsxs(Zo,{onClick:()=>t(r),className:"link-card",p:"xs",style:{borderRadius:"var(--sd-radius-md)",border:"1px solid var(--mantine-color-default-border)"},"aria-label":`Add ${r.name} slide`,children:[p.jsx(FT,{blocks:r.blocks}),p.jsx(re,{size:"sm",mt:"xs",ta:"center",children:r.name})]},r.id))})})}/** 263 * @license @tabler/icons-react v3.41.1 - MIT 264 * 265 * This source code is licensed under the MIT license. 266 * See the LICENSE file in the root directory of this source tree. 267 */const WT=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 13l-6 6",key:"svg-1"}],["path",{d:"M6 13l6 6",key:"svg-2"}]],UT=pe("outline","arrow-down","ArrowDown",WT);/** 268 * @license @tabler/icons-react v3.41.1 - MIT 269 * 270 * This source code is licensed under the MIT license. 271 * See the LICENSE file in the root directory of this source tree. 272 */const KT=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 11l-6 -6",key:"svg-1"}],["path",{d:"M6 11l6 -6",key:"svg-2"}]],qT=pe("outline","arrow-up","ArrowUp",KT);/**
273 * @license @tabler/icons-react v3.41.1 - MIT 274 * 275 * This source code is licensed under the MIT license. 276 * See the LICENSE file in the root directory of this source tree. 277 */const JT=[["path",{d:"M8 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M8 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M8 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M14 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}],["path",{d:"M14 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-4"}],["path",{d:"M14 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-5"}]],Km=pe("outline","grip-vertical","GripVertical",JT),GT=8,na=1100;function YT(n,e){return n!=="title"?14:e===1?28:e===2?22:18}function qm({page:n,vizMap:e,vizLoaded:t=!0,width:r,selected:s=!1,framed:i=!0}){const o=r/jr,l=r/100,a=o/100;return p.jsx(Xo,{withBorder:i,radius:"xs",w:r,h:o,pos:"relative",bg:"var(--sd-color-surface)",flex:"none","aria-hidden":!0,style:{borderColor:s?"var(--sd-color-accent)":"var(--sd-color-border)",borderWidth:i?s?2:1:0,overflow:"hidden"},children:n.visualizations.map(c=>p.jsx(XT,{deckViz:c,viz:c.visualization_id?e[c.visualization_id]:void 0,vizLoaded:t,pxPerPctW:l,pxPerPctH:a},c.id))})}function XT({deckViz:n,viz:e,vizLoaded:t,pxPerPctW:r,pxPerPctH:s}){var d;const i=n.block_type??"visualization",o=n.w*r,l=n.h*s,a=jf((d=n.props)==null?void 0:d.border,r*100/na);if(i==="visualization"&&t&&!e)return p.jsx(ar,{pos:"absolute",left:n.x*r,top:n.y*s,w:o,h:l,style:{overflow:"hidden"},children:p.jsx(Fm,{size:Math.max(12,Math.min(o,l)*.35),color:"var(--mantine-color-dimmed)","aria-hidden":!0})});if(i!=="visualization"||!n.visualization_id){if(i==="shape")return p.jsx(K,{pos:"absolute",left:n.x*r,top:n.y*s,w:o,h:l,children:p.jsx(Of,{props:n.props,scale:r*100/na})});if(i==="image")return n.image_url?p.jsx(ZT,{imageUrl:n.image_url,stretch:n.image_stretch,left:n.x*r,top:n.y*s,w:o,h:l,borderStyle:a,background:n.background_color||void 0}):p.jsx(K,{pos:"absolute",left:n.x*r,top:n.y*s,w:o,h:l,style:{background:n.background_color||"var(--sd-color-surface-subtle)",overflow:"hidden",...a}});const u=fi(n.text_content);if(!u&&!n.background_color)return null;const f=r*100/na,h=n.heading_level??1,m=YT(i,h)*(n.text_scale??1)*f;return p.jsx(K,{pos:"absolute",left:n.x*r,top:n.y*s,w:o,h:l,style:{overflow:n.auto_height===!1?"visible":"hidden",background:n.background_color||void 0,...a},children:p.jsx("div",{className:"deck-rte-content",style:{fontSize:`${m}px`,lineHeight:1.2,padding:GT*f},dangerouslySetInnerHTML:{__html:Hr(u)}})})}const c=e?xy(e):"Untitled";return p.jsx(K,{pos:"absolute",left:n.x*r,top:n.y*s,w:o,h:l,title:c,style:{overflow:"hidden",background:n.background_color||void 0,...a},children:p.jsx(Fy,{visualizationId:n.visualization_id,width:o,height:l,alt:c,contentVersion:e==null?void 0:e.current_version_seq},`${n.visualization_id}-${(e==null?void 0:e.data_fetched_at)??(e==null?void 0:e.updatedAt)??""}`)})}function ZT({imageUrl:n,stretch:e,left:t,top:r,w:s,h:i,borderStyle:o,background:l}){return p.jsx(K,{pos:"absolute",left:t,top:r,w:s,h:i,style:{background:l,overflow:"hidden",...o},children:p.jsx(If,{src:n,alt:"Slide image",style:{width:"100%",height:"100%",objectFit:e?"fill":"contain"}})})}function Gc(n,e){return n.title||`Slide ${e+1}`}function Jm(n,e){return n.title?`Slide ${e+1}: ${n.title}`:`Slide ${e+1}`}const Gm={draggable:"To reorder, press Space or Enter to pick up the slide. While holding it, use the arrow keys to move it, press Space or Enter again to drop it in its new position, or press Escape to cancel."};function Ym(n,e){const t=n.length,r=o=>n.findIndex(l=>l.id===o),s=o=>{const l=r(o);return l<0?"slide":`slide ${l+1} of ${t}: ${Gc(n[l],l)}`},i=o=>e&&r(o)===0;return{onDragStart:({active:o})=>`Picked up ${s(o.id)}.`,onDragOver:({over:o})=>o?i(o.id)?"Cannot move above the cover slide.":`Slide moved to position ${r(o.id)+1} of ${t}.`:"Slide is no longer over a drop position.",onDragEnd:({active:o,over:l})=>{if(!l)return"Slide dropped. The order is unchanged.";if(i(l.id))return"Cannot move above the cover slide. The order is unchanged.";const a=r(l.id)+1;return o.id===l.id?`Slide dropped in its original position, ${a} of ${t}.`:`Slide moved to position ${a} of ${t}.`},onDragCancel:({active:o})=>`Reordering cancelled. ${s(o.id)} returned to its original position.`}}function Xm(n,{orientation:e,pages:t,onSelect:r}){var u;const s=n.target;if(s.getAttribute("role")!=="option")return;const i=t.findIndex(f=>f.id===s.dataset.slideId);if(i<0||t.length===0)return;const o=e==="vertical"?"ArrowUp":"ArrowLeft",l=e==="vertical"?"ArrowDown":"ArrowRight";let a=null;if(n.key===o)a=Math.max(0,i-1);else if(n.key===l)a=Math.min(t.length-1,i+1);else if(n.key==="Home")a=0;else if(n.key==="End")a=t.length-1;else if(n.key==="Enter"||n.key===" "){n.preventDefault(),r(t[i].id);return}if(a===null)return;n.preventDefault();const c=t[a].id;r(c);const d=n.currentTarget.querySelectorAll('[role="option"]');(u=Array.from(d).find(f=>f.dataset.slideId===c))==null||u.focus()}function Zm(n,e,t){const r=n.findIndex(s=>s.id===e);return(r<0?0:r)===t?0:-1}const QT=190;function eA({page:n,index:e,selected:t,tabIndex:r,canWrite:s,canMoveUp:i,canMoveDown:o,vizMap:l,vizLoaded:a=!0,onSelect:c,onMoveUp:d,onMoveDown:u,onDelete:f,onRename:h,sortableHandleProps:m}){const[g,y]=x.useState(!1),[b,S]=x.useState(n.title??""),C=x.useRef(null),[T,M]=x.useState(!1);x.useEffect(()=>{g&&(S(n.title??""),requestAnimationFrame(()=>{var V;return(V=C.current)==null?void 0:V.select()}
277))},[g,n.title]);const D=()=>{y(!1);const V=b.trim();(V||null)!==(n.title??null)&&h(V)},k=Gc(n,e),A=s&&((m==null?void 0:m.canDrag)??!1),P=(m==null?void 0:m.isDragging)??!1,U={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--mantine-font-size-xs)",color:t?void 0:"var(--mantine-color-dimmed)",fontWeight:t?600:400},G=s&&p.jsxs(B,{shadow:"md",position:"bottom-end",returnFocus:!1,children:[p.jsx(B.Target,{children:p.jsx(we,{"aria-label":`Options for slide ${e+1}`,variant:"subtle",color:"gray",size:"sm",onClick:V=>V.stopPropagation(),children:p.jsx(Qo,{size:14,"aria-hidden":!0})})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Item,{leftSection:p.jsx(Ya,{size:16,"aria-hidden":!0}),onClick:()=>y(!0),children:"Rename"}),p.jsx(B.Item,{leftSection:p.jsx(qT,{size:16,"aria-hidden":!0}),disabled:!i,onClick:d,children:"Move up"}),p.jsx(B.Item,{leftSection:p.jsx(UT,{size:16,"aria-hidden":!0}),disabled:!o,onClick:u,children:"Move down"}),p.jsx(B.Divider,{}),p.jsx(B.Item,{color:"red",leftSection:p.jsx(ss,{size:16,"aria-hidden":!0}),onClick:f,children:"Delete"})]})]});return p.jsxs(K,{w:"100%",p:"xs",onPointerEnter:()=>M(!0),onPointerLeave:()=>M(!1),onFocus:()=>M(!0),onBlur:V=>{V.currentTarget.contains(V.relatedTarget)||M(!1)},onClick:c,style:{cursor:"pointer",background:t?"var(--sd-color-accent-subtle)":"var(--sd-color-surface)",border:`1px solid ${t?"var(--sd-color-accent)":"var(--sd-color-border)"}`,borderRadius:"var(--sd-radius-md)",boxShadow:P?"var(--sd-shadow-md)":void 0,transition:"border-color 150ms ease, background-color 150ms ease"},children:[p.jsxs(Ee,{gap:4,align:"center",wrap:"nowrap",mb:6,mih:22,children:[g?p.jsx(Ks,{ref:C,"aria-label":`Rename ${k}`,size:"xs",flex:"1 1 auto",value:b,onChange:V=>S(V.currentTarget.value),onBlur:D,onKeyDown:V=>{V.key==="Enter"?(V.preventDefault(),D()):V.key==="Escape"&&(V.preventDefault(),S(n.title??""),y(!1))},placeholder:`Slide ${e+1}`,onClick:V=>V.stopPropagation()}):s?p.jsx(Zo,{flex:"1 1 auto","aria-label":n.title?`Rename slide ${e+1}: ${n.title}`:`Rename slide ${e+1}`,style:{...U,cursor:"text"},onClick:V=>{V.stopPropagation(),y(!0)},children:k}):p.jsx(re,{flex:"1 1 auto",size:"xs",truncate:!0,miw:0,c:t?void 0:"dimmed",fw:t?600:400,children:k}),A&&m&&p.jsx(we,{ref:m.setActivatorNodeRef,...m.attributes,...m.listeners,"aria-label":`Reorder slide ${e+1}`,variant:"subtle",color:"gray",size:"sm","data-hover-reveal":!0,onClick:V=>V.stopPropagation(),style:{cursor:P?"grabbing":"grab",touchAction:"none",opacity:T||P?1:0,transition:"opacity 120ms"},children:p.jsx(Km,{size:14,"aria-hidden":!0})}),G]}),p.jsx("div",{role:"option","aria-selected":t,"aria-label":Jm(n,e),"data-slide-id":n.id,tabIndex:r,className:"focus-ring",style:{borderRadius:"var(--sd-radius-xs)"},onClick:V=>{V.stopPropagation(),c()},onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),V.stopPropagation(),c())},children:p.jsx(qm,{page:n,vizMap:l,vizLoaded:a,width:QT,framed:!1})})]})}const tA=n=>{let{transform:e}=n;return{...e,y:0}};function nA(n,e,t){const r={...n};return e.top+n.y<=t.top?r.y=t.top-e.top:e.bottom+n.y>=t.top+t.height&&(r.y=t.top+t.height-e.bottom),e.left+n.x<=t.left?r.x=t.left-e.left:e.right+n.x>=t.left+t.width&&(r.x=t.left+t.width-e.right),r}const Qm=n=>{let{containerNodeRect:e,draggingNodeRect:t,transform:r}=n;return!t||!e?r:nA(r,t,e)},rA=n=>{let{transform:e}=n;return{...e,x:0}};function eg({id:n,disabled:e,children:t}){const{attributes:r,listeners:s,setActivatorNodeRef:i,setNodeRef:o,transform:l,transition:a,isDragging:c}=Wb({id:n,disabled:e});return p.jsx("div",{ref:o,role:"presentation",style:{transform:Gs.Transform.toString(l),transition:a,opacity:c?.72:1,position:"relative",zIndex:c?2:"auto"},children:t({attributes:r,listeners:s,setActivatorNodeRef:i,isDragging:c,canDrag:!e})})}function sA({pages:n,selectedPageId:e,canWrite:t,vizMap:r,vizLoaded:s=!0,onSelectPage:i,onMoveUp:o,onMoveDown:l,onDelete:a,onRename:c,onAdd:d,onReorder:u}){var g;const f=((g=n[0])==null?void 0:g.is_cover)===!0,h=Vf(ao(rl,{activationConstraint:{distance:6}}),ao(nl,{coordinateGetter:fh})),m=({active:y,over:b})=>{!b||y.id===b.id||f&&b.id===n[0].id||u(String(y.id),String(b.id))};return p.jsxs(Mt,{h:"100%",gap:0,w:232,flex:"none",bg:"var(--sd-color-surface)",style:{borderRight:"1px solid var(--sd-color-border)"},children:[p.jsx(K,{p:"sm",flex:"1 1 auto",style:{overflowY:"auto"},children:p.jsx(oh,{sensors:h,collisionDetection:qf,modifiers:[rA,Qm],onDragEnd:m,accessibility:{announcements:Ym(n,f),screenReaderInstructions:Gm},children:p.jsx(dh,{items:n.map(y=>y.id),strategy:zb,children:p.jsx(Mt,{gap:"xs",role:"listbox","aria-label":"Slides","aria-orientation":"vertical",onKeyDown:y=>Xm(y,{orientation:"vertical",pages:n,onSelect:i}),children:n.map((y,b)=>p.jsx(eg,{id:y.id,disabled:!t||f&&b===0,children:S=>p.jsx(eA,{page:y,index:b,selected:y.id===e,tabIndex:Zm(n,e,b),canWrite:t,canMoveUp:f?b>1:b>0,canMoveDown:f?b>0&&b<n.length-1:b<n.length-1,vizMap:r,vizLoaded:s,sortableHandleProps:S,onSelect:()=>i(y.id),onMoveUp:()=>o(y.id),onMoveDown:()=>l(y.id),onDelete:()=>a(y.id),onRename:C=>c(y.id,C)})},y.id))})})})}),t&&p.jsx(K,{p:"sm",pt:0,children:p.jsx(We,{fullWidth:!0,variant:"default",size:"xs",leftSection:p.jsx(ui,{size:14,"aria-hidden":!0}),onClick:d,children:"Add slide"})})]})}const rs=112,tg=rs/jr;function iA({pages:n,selectedPageId:e,canWrite:t,vizMap:r,vizLoaded:s=!0,onSelectPage:i,onRename:o,onDelete:l,onAdd:a,onReorder:c}){var h;const d=((h=n[0])==null?void 0:h.is_cover)===!0,u=Vf(ao(rl,{activationConstraint:{distance:6}}
277),ao(nl,{coordinateGetter:fh})),f=({active:m,over:g})=>{!g||m.id===g.id||d&&g.id===n[0].id||c(String(m.id),String(g.id))};return p.jsx(K,{px:"sm",py:"xs",style:{overflowX:"auto",borderTop:"1px solid var(--sd-color-border)"},children:p.jsxs(Ee,{gap:"sm",wrap:"nowrap",align:"flex-start",children:[p.jsx(oh,{sensors:u,collisionDetection:qf,modifiers:[tA,Qm],onDragEnd:f,accessibility:{announcements:Ym(n,d),screenReaderInstructions:Gm},children:p.jsx(dh,{items:n.map(m=>m.id),strategy:jb,children:p.jsx(Ee,{gap:"sm",wrap:"nowrap",align:"flex-start",role:"listbox","aria-label":"Slides","aria-orientation":"horizontal",onKeyDown:m=>Xm(m,{orientation:"horizontal",pages:n,onSelect:i}),children:n.map((m,g)=>p.jsx(eg,{id:m.id,disabled:!t||d&&g===0,children:y=>p.jsx(oA,{page:m,index:g,selected:m.id===e,tabIndex:Zm(n,e,g),canWrite:t,vizMap:r,vizLoaded:s,sortableHandleProps:y,onSelect:()=>i(m.id),onRename:b=>o(m.id,b),onDelete:()=>l(m.id)})},m.id))})})}),t&&p.jsx(Zo,{onClick:a,flex:"none",children:p.jsxs(Mt,{gap:4,w:rs,children:[p.jsx(ar,{w:rs,h:tg,style:{border:"1px dashed var(--sd-color-border-strong)",borderRadius:"var(--mantine-radius-sm)",color:"var(--sd-color-accent-text)"},children:p.jsx(ui,{size:20,"aria-hidden":!0})}),p.jsx(re,{size:"xs",ta:"center",c:"var(--sd-color-accent-text)",children:"Add slide"})]})})]})})}function oA({page:n,index:e,selected:t,tabIndex:r,canWrite:s,vizMap:i,vizLoaded:o,onSelect:l,onRename:a,onDelete:c,sortableHandleProps:d}){const[u,f]=x.useState(!1),[h,m]=x.useState(n.title??""),g=x.useRef(null),[y,b]=x.useState(!1);x.useEffect(()=>{u&&(m(n.title??""),requestAnimationFrame(()=>{var k;return(k=g.current)==null?void 0:k.select()}
277))},[u,n.title]);const S=()=>{f(!1);const k=h.trim();(k||null)!==(n.title??null)&&a(k)},C=Gc(n,e),T=s&&((d==null?void 0:d.canDrag)??!1),M=(d==null?void 0:d.isDragging)??!1,D={width:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center",fontSize:"var(--mantine-font-size-xs)",color:t?void 0:"var(--mantine-color-dimmed)",fontWeight:t?600:400};return p.jsxs(Mt,{gap:4,w:rs,flex:"none",pos:"relative",onPointerEnter:()=>b(!0),onPointerLeave:()=>b(!1),onFocus:()=>b(!0),onBlur:k=>{k.currentTarget.contains(k.relatedTarget)||b(!1)},children:[p.jsx(K,{role:"option","aria-selected":t,"aria-label":Jm(n,e),"data-slide-id":n.id,tabIndex:r,className:"focus-ring",w:rs,h:tg,onClick:l,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.stopPropagation(),l())},style:{cursor:"pointer",boxShadow:M?"var(--sd-shadow-md)":void 0,borderRadius:"var(--mantine-radius-sm)"},children:p.jsx(qm,{page:n,vizMap:i,vizLoaded:o,width:rs,selected:t})}),s&&p.jsxs(Ee,{gap:2,wrap:"nowrap",pos:"absolute",top:2,right:2,children:[T&&d&&p.jsx(we,{ref:d.setActivatorNodeRef,...d.attributes,...d.listeners,"aria-label":`Reorder slide ${e+1}`,variant:"default",size:"sm","data-hover-reveal":!0,style:{cursor:M?"grabbing":"grab",touchAction:"none",opacity:y||M?1:0,transition:"opacity 120ms"},children:p.jsx(Km,{size:14,"aria-hidden":!0})}),t&&p.jsxs(B,{shadow:"md",position:"bottom-end",returnFocus:!1,children:[p.jsx(B.Target,{children:p.jsx(we,{variant:"default",size:"sm","aria-label":`Options for slide ${e+1}`,onClick:k=>k.stopPropagation(),children:p.jsx(Qo,{size:14,"aria-hidden":!0})})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Item,{leftSection:p.jsx(Ya,{size:16,"aria-hidden":!0}),onClick:()=>f(!0),children:"Rename"}),p.jsx(B.Item,{color:"red",leftSection:p.jsx(ss,{size:16,"aria-hidden":!0}),onClick:c,children:"Delete"})]})]})]}),u?p.jsx(Ks,{ref:g,"aria-label":`Rename ${C}`,size:"xs",value:h,onChange:k=>m(k.currentTarget.value),onBlur:S,onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),S()):k.key==="Escape"&&(k.preventDefault(),m(n.title??""),f(!1))},placeholder:`Slide ${e+1}`}):s?p.jsx(Zo,{"aria-label":n.title?`Rename slide ${e+1}: ${n.title}`:`Rename slide ${e+1}`,style:{...D,cursor:"text"},onClick:()=>f(!0),children:C}):p.jsx(re,{size:"xs",ta:"center",truncate:!0,c:t?void 0:"dimmed",fw:t?600:400,children:C})]})}const kr=x.forwardRef(function({label:e,icon:t,disabled:r,onClick:s,onKeyDown:i,style:o,...l},a){return p.jsx(xn,{label:e,withArrow:!0,openDelay:150,position:"bottom",children:p.jsx(we,{ref:a,size:"md",variant:"default","aria-label":e,"aria-disabled":r||void 0,"data-disabled":r||void 0,style:{...r?{pointerEvents:"auto"}:{},...o},onClick:r?c=>c.preventDefault():s,onKeyDown:r?void 0:i,...l,children:t})})});function lA(n){const e=[`v${n.seq}`];return n.created_by_display_name&&e.push(n.created_by_display_name),e.push(ry(n.created_at)),e.join(" · ")}function aA({deck:n,opened:e,onClose:t,onRestored:r}){const[s,i]=x.useState([]),[o,l]=x.useState(!1),[a,c]=x.useState(null),d=qa("(max-width: 47.99em)",!1,{getInitialValueInEffect:!1}),u=x.useCallback(async()=>{if(n!=null&&n.id){l(!0);try{const h=await Ey(n.id);i(h)}catch{}finally{l(!1)}}},[n==null?void 0:n.id]);x.useEffect(()=>
277{e&&u()},[e,u]);const f=async h=>{c(h);try{const m=await Ty(n.id,h);r(m),await u()}catch{ny("Failed to restore version.")}finally{c(null)}};return p.jsx(Mf,{opened:e,onClose:t,title:p.jsxs(Ee,{gap:"xs",children:[p.jsx(Rf,{size:16,"aria-hidden":!0}),p.jsx(re,{fw:600,children:"Version history"})]}),position:"right",size:d?"100%":"sm",padding:"md",children:o?p.jsx(K,{ta:"center",py:"xl",role:"status","aria-label":"Loading versions",children:p.jsx(Df,{size:"sm"})}):s.length===0?p.jsx(Pf,{title:"No versions yet",description:"Start editing to create one."}):p.jsx(ty,{versions:s.map(h=>({id:h.id,seq:h.seq,title:h.label||`Version ${h.seq}`,meta:lA(h),createdAt:h.created_at,isCurrent:h.is_current})),restoringSeq:a,onRestore:f})})}function cA(n){return n!==null&&(n.status==="forbidden"||n.status==="notFound"||n.status==="error")}async function dA(n,e=fetch){let t;try{t=await e(`/v2/decks/${n}/visualizations`,{credentials:"include"})}catch{return{status:"error",message:"Couldn't reach the server to load this deck's visualizations."}}if(t.status===401||t.status===403)return{status:"forbidden",message:"You don't have access to this deck's visualizations."};if(t.status===404)return{status:"notFound",message:"This deck's visualizations could not be found."};if(!t.ok)return{status:"error",message:`Failed to load this deck's visualizations (${t.status}).`};let r;try{r=await t.json()}catch{return{status:"error",message:"The server returned an unreadable response."}}if(!Array.isArray(r))return{status:"error",message:"The server returned an unexpected response."};const s=r;return s.forEach(i=>{if(typeof i.content=="string")try{i.content=JSON.parse(i.content)}catch{}}),{status:"loaded",visualizations:s}}function uA({children:n}){const[e,t]=x.useState(null);return p.jsx(km.Provider,{value:{active:e,setActive:t},children:n})}/** 278 * @license @tabler/icons-react v3.41.1 - MIT 279 * 280 * This source code is licensed under the MIT license. 281 * See the LICENSE file in the root directory of this source tree. 282 */const fA=[["path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737",key:"svg-0"}],["path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081",key:"svg-1"}],["path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208",key:"svg-2"}]],hA=pe("outline","bucket-droplet","BucketDroplet",fA);/** 283 * @license @tabler/icons-react v3.41.1 - MIT 284 * 285 * This source code is licensed under the MIT license. 286 * See the LICENSE file in the root directory of this source tree. 287 */const pA=[["path",{d:"M5 19v-6a8 8 0 0 1 8 -8h6",key:"svg-0"}]],mA=pe("outline","radius-top-left","RadiusTopLeft",pA),gA=[{kind:"rect",label:"Rectangle",icon:sa},{kind:"ellipse",label:"Ellipse",icon:$f},{kind:"line",label:"Line",icon:nc}];function yA(){const n=Wm(),e=(n==null?void 0:n.active)??null;if(!e)return null;const{deckViz:t,onChange:r}=e,s=Ds(t.props),i=s.shape_kind==="ellipse",o=s.shape_kind==="line",l=!!s.stroke&&(s.stroke_width??0)>0;return p.jsx(Xo,{withBorder:!0,p:4,role:"toolbar","aria-label":"Shape style",style:{display:"inline-block"},children:p.jsxs(Ee,{gap:6,wrap:"wrap",align:"center",children:[p.jsx(we.Group,{children:gA.map(({kind:a,label:c,icon:d})=>p.jsx(xn,{label:c,withArrow:!0,children:p.jsx(we,{variant:s.shape_kind===a?"filled":"default",size:"sm","aria-label":c,"aria-pressed":s.shape_kind===a,onClick:()=>s.shape_kind!==a&&r(dy(s,a)),children:p.jsx(d,{size:16,"aria-hidden":!0})})},a))}),p.jsx(Bg,{orientation:"vertical"}),o?p.jsxs(p.Fragment,{children:[p.jsx(Us,{icon:p.jsx(nc,{size:16,"aria-hidden":!0}),label:"Line color",value:uy(s),onPick:a=>r({stroke:a})}),p.jsx(xn,{label:"Line width",withArrow:!0,children:p.jsx(Ns,{size:"xs",w:64,"aria-label":"Line width",min:Sl,max:40,value:s.stroke_width??Sl,onChange:a=>r({stroke_width:Number(a)||Sl})})}),p.jsxs(we.Group,{children:[p.jsx(xn,{label:"Arrow at start",withArrow:!0,children:p.jsx(we,{variant:s.arrow_start?"filled":"default",size:"sm","aria-label":"Arrow at start","aria-pressed":!!s.arrow_start,onClick:()=>r({arrow_start:!s.arrow_start}),children:p.jsx(Hy,{size:16,"aria-hidden":!0})})}),p.jsx(xn,{label:"Arrow at end",withArrow:!0,children:p.jsx(we,{variant:s.arrow_end?"filled":"default",size:"sm","aria-label":"Arrow at end","aria-pressed":!!s.arrow_end,onClick:()=>r({arrow_end:!s.arrow_end}),children:p.jsx(Af,{size:16,"aria-hidden":!0})})})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(Us,{icon:p.jsx(hA,{size:16,"aria-hidden":!0}),label:"Fill",value:s.fill??"",onPick:a=>r({fill:a}),onClear:()=>r({fill:null})}),p.jsx(Us,{icon:p.jsx(bm,{size:16,"aria-hidden":!0}),label:"Border color",value:l?s.stroke??"":"",onPick:a=>r({stroke:a,...l?{}:{stroke_width:Rs.stroke_width}}),onClear:()=>r({stroke_width:0})}),p.jsx(xn,{label:"Border width",withArrow:!0,children:p.jsx(Ns,{size:"xs",w:64,"aria-label":"Border width",min:0,max:40,value:s.stroke_width??0,onChange:a=>{const c=Number(a)||0;r({stroke_width:c,...c>
2870&&!s.stroke?{stroke:Rs.stroke}:{}})}})}),!i&&p.jsx(xn,{label:"Corner rounding",withArrow:!0,children:p.jsx(Ns,{size:"xs",w:64,"aria-label":"Corner rounding",leftSection:p.jsx(mA,{size:14,"aria-hidden":!0}),min:0,max:200,value:s.radius??0,onChange:a=>r({radius:Number(a)||0})})})]})]})})}function bA({children:n}){const[e,t]=x.useState(null);return p.jsx(Vm.Provider,{value:{active:e,setActive:t},children:n})}function xA({currentWorkspaceId:n}){var i;const e=Ga(),{workspaces:t}=$g(),r=(i=t==null?void 0:t.find(o=>o.id===n))==null?void 0:i.name,s=(t??[]).filter(o=>o.id!==n);return!n&&s.length===0?p.jsx(re,{size:"sm",children:p.jsx(nd,{to:"/workspaces",children:"View all workspaces"})}):p.jsxs(Mt,{align:"center",gap:"sm",children:[n&&p.jsx(We,{component:nd,to:`/${n}`,children:r?`Back to ${r}`:"Back to workspace"}),s.length>0&&p.jsxs(Ee,{gap:"xs",justify:"center",wrap:"nowrap",children:[p.jsx(re,{size:"sm",c:"dimmed",children:"Go to a different workspace:"}),p.jsx(Ja,{w:200,placeholder:"Select a workspace","aria-label":"Go to a different workspace",data:s.map(o=>({value:o.id,label:o.name})),onChange:o=>{o&&e(`/${o}`)}})]})]})}const ks={title:{w:100,h:4/28*100},paragraph:{w:100,h:8/28*100},image:{w:50,h:50}},ra=4;function kf(n,e){return Math.max(0,100-e)===0?0:n+e+ra<=100?n+ra:Math.max(0,n-ra)}function wA(n){return new Promise(e=>{const t=URL.createObjectURL(n),r=new Image;r.onload=()=>{URL.revokeObjectURL(t),e(r.naturalHeight>0?r.naturalWidth/r.naturalHeight:0)},r.onerror=()=>{URL.revokeObjectURL(t),e(0)},r.src=t})}const kA=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function TD(){var td;const{workspace:n,deck:e}=_g(),t=Ga(),{open:r,setOpen:s,setDockEl:i}=Fg(),[o]=Hg(),l=x.useRef(o.get("page")),{loading:a,deck:c,refetch:d}=Ay(e);Vy((c==null?void 0:c.title)||void 0);const{capability:u}=Vg(n),f=u!=null&&u!=="read",h=ky(n),m=qa("(max-width: 768px)"),{visualizations:g,loading:y,refetch:b}=zy(n),[S,C]=x.useState(!1),[T,M]=x.useState(!1),[D,k]=x.useState(!1),[A,P]=x.useState(!1),[U,G]=x.useState(null),[V,ue]=x.useState(null),[ae,se]=x.useState(null),[de,ye]=x.useState(!1),Qe=x.useRef(null),be=x.useRef(!1),De=()=>{var w;be.current&&(be.current=!1,(w=Qe.current)==null||w.focus())},[Ue,ve]=x.useState(""),[lt,Me]=x.useState(""),[at,$e]=x.useState(!1),[ct,ie]=x.useState(!1),[me,Q]=x.useState(!1),[Te,Ie]=x.useState([]),[dt,le]=x.useState(""),[xe,Se]=x.useState(null),[Pn,Gt]=x.useState(null),[pn,Re]=x.useState(!1),[At,Lt]=x.useState(!1),[ut,Cn]=x.useState(null),[en,He]=x.useState(0),[ft,Dt]=x.useState(!1),[Rt,zt]=x.useState(!1),[Ye,F]=x.useState(0),[Xe,kt]=x.useState(null),[Pt,Mn]=x.useState(!1);x.useEffect(()=>{if(!n)return;let w=!1;return fetch(`/v2/workspaces/${n}/public-status`,{credentials:"include"}).then(E=>E.ok?E.json():null).then(E=>{!w&&E&&Mn(!!E.public)}).catch(()=>{}),()=>{w=!0}},[n]);const[ps,mn]=x.useState(""),[fe,_e]=x.useState((c==null?void 0:c.pages)??[]),Bt=x.useRef(fe);x.useEffect(()=>{Bt.current=fe},[fe]);
287const[_,Ve]=x.useState(null),[ht,Yt]=x.useState(!1),{confirm:pt,confirmDialog:vt}=_y(),$t=x.useRef(async()=>{}),tn=fe.some(w=>w.is_cover),Ze=x.useMemo(()=>{if(!f||!h)return null;const w=_?`&page=${_}`:"";return[{id:"cover",label:tn?"Regenerate the cover slide":"Generate a cover slide",description:tn?"Replaces this deck's cover with a fresh AI-drafted overview and contents. Asks first.":"Adds a cover slide: title, an AI-drafted overview, and linked contents.",icon:p.jsx(rd,{size:16,"aria-hidden":!0}),run:()=>$t.current(),disabled:at},{id:"chart",label:"Add a chart from a question",description:_?"Opens the editor; the finished chart lands on the selected slide.":"Opens the editor; the finished chart lands on a new slide.",icon:p.jsx(Ss,{size:16,"aria-hidden":!0}),run:()=>t(`/${n}/visualization/new?deck=${e}${w}`)}]},[f,h,at,tn,_,n,e,t]);Wg(Ze,c==null?void 0:c.title),x.useEffect(()=>{c!=null&&c.pages&&(_e(c.pages),Ve(w=>{var R;if(w&&c.pages.some(I=>I.id===w))return w;const E=l.current;return E&&c.pages.some(I=>I.id===E)?E:((R=c.pages[0])==null?void 0:R.id)??null}))},[c==null?void 0:c.pages]);const _t=x.useMemo(()=>(g??[]).find(w=>w.id===U)??null,[g,U]),[Ft,v]=x.useState({}),O=x.useCallback(w=>{w.id&&v(E=>({...E,[w.id]:w}))},[]);x.useEffect(()=>{if(y||g!==null||!e)return;let w=!1;return Cn({status:"loading"}),dA(e).then(E=>{w||Cn(E)}),()=>{w=!0}},[y,g,e,en]);const W=x.useCallback(()=>He(w=>w+1),[]),[Y,ee]=x.useState({}),H=x.useMemo(()=>{const w={},E=(ut==null?void 0:ut.status)==="loaded"?ut.visualizations:[];for(const R of g??E)w[R.id||""]=R;for(const[R,I]of Object.entries(Ft))w[R]=I;return w},[g,ut,Ft]),ke=g!==null||(ut==null?void 0:ut.status)==="loaded",Ne=cA(ut)?ut.message:null,it=x.useCallback((w,E)=>{var Z;if(ee(te=>({...te,[w]:E})),!f)return;const R=H[w],I=(Z=R==null?void 0:R.content.builds)==null?void 0:Z.find(te=>{var Pe;return((Pe=te.config)==null?void 0:Pe.type)===E});if(!R||!I)return;const L={...R,content:{...R.content,build:I}};O(L),Py(L).then(te=>{te!=null&&te.id&&(typeof te.content=="string"&&(te.content=JSON.parse(te.content)),O(te))}).catch(te=>console.error("Failed to persist chart type",te))},[f,H,O]),je=x.useMemo(()=>{if(Object.keys(Y).length===0)return H;const w={...H};for(const[E,R]of Object.entries(Y)){const I=H[E];if(!(I!=null&&I.content.builds))continue;const L=I.content.builds.find(Z=>{var te;return((te=Z.config)==null?void 0:te.type)===R});L&&(w[E]={...I,content:{...I.content,build:L}})}return w},[H,Y]),Le=x.useMemo(()=>fe.find(w=>w.id===_)??null,[fe,_]),gn=x.useMemo(()=>(Le==null?void 0:Le.visualizations.find(w=>w.id===V))??null,[Le,V]),En=x.useMemo(()=>{const w=new Set;for(const E of fe)for(const R of E.visualizations)R.visualization_id&&(!R.block_type||R.block_type==="visualization")&&w.add(R.visualization_id);return[...w].map(E=>H[E]).filter(E=>!!E)},[fe,H]),{analyzingIds:Tn}=sy(En,{enabled:f,onAnalyzed:O}),et=x.useRef(null),ce=x.useRef(Promise.resolve()),ze=x.useCallback((w,E,R)=>{const I=ce.current.then(()=>id(w,E,R),()=>id(w,E,R));return ce.current=I.catch(()=>{}),I},[]),yn=x.useRef(new Map);x.useEffect(()=>()=>{et.current&&clearTimeout(et.current)},[]);const Gn=x.useCallback(async()=>{if(!(!c||T||!f)){M(!0);try{await Dy(c.id),await d()}catch(w){w.message!=="nothing_to_undo"&&ge.show({color:"red",message:"Undo failed: "+w.message})}finally{M(!1)}}},[c,T,f,d]),bn=x.useCallback(async()=>{if(!(!c||T||!f)){M(!0);try{await Ry(c.id),await d()}catch(w){w.message!=="nothing_to_redo"&&ge.show({color:"red",message:"Redo failed: "+w.message})}finally{M(!1)}}},[c,T,f,d]),Yn=[["mod+Z",()=>Gn()],["mod+shift+Z",()=>bn()],["mod+Y",()=>bn()]];if(kA&&Yn.push(["ctrl+Z",()=>Gn()],["ctrl+shift+Z",()=>bn()],["ctrl+Y",()=>bn()]),iy(Yn),x.useEffect(()=>{!me||!(c!=null&&c.id)||!f||fetch(`/v2/decks/${c.id}/shares`,{credentials:"include"}).then(w=>w.ok?w.json():[]).then(Ie).catch(()=>{})},[me,c==null?void 0:c.id,f]),a&&!c||y&&!g)return p.jsx(Ug,{visible:!0});if(!c)return p.jsx(ar,{h:"var(--app-vh)",w:"100%",children:p.jsxs(Mt,{align:"center",justify:"center",ta:"center",gap:0,children:[p.jsx(Kg,{children:"404"}),p.jsx(re,{fw:"bold",mb:"xs",size:"lg",children:"Deck Not Found"}),p.jsx(re,{size:"sm",mb:"md",children:"This deck doesn't exist or you don't have access to it."}),p.jsx(xA,{currentWorkspaceId:n})]})});const Wr=()=>{be.current=!0,ve(c.title),Me(c.description||""),ye(!0)},Ur=async()=>{try{ie(!0),await Cl({id:c.id,title:Ue,description:lt,private:c.private,workspace_id:c.workspace_id}),ye(!1),De(),d()}catch(w){ge.show({color:"red",message:"Failed to save: "+w.message})}finally{ie(!1)}},wl=async()=>
287{if(!(fe.some(E=>E.is_cover)&&!await pt({title:"Replace cover slide",message:"This replaces the current cover slide and any edits on it.",confirmLabel:"Replace cover"})))try{$e(!0);const{cover_page_id:E}=await Ny(c.id);await d(),Ve(E)}catch(E){ge.show({color:"red",message:"Failed to generate cover slide: "+E.message})}finally{$e(!1)}};$t.current=wl;const kl=async w=>{try{await Cl({id:c.id,title:c.title,description:c.description??void 0,private:w,workspace_id:c.workspace_id}),d()}catch(E){ge.show({color:"red",message:"Failed to update: "+E.message})}},ms=async w=>{try{await Cl({id:c.id,title:c.title,description:c.description??void 0,private:c.private,discoverable:w,workspace_id:c.workspace_id}),d()}catch(E){ge.show({color:"red",message:"Failed to update: "+E.message})}},Kr=async()=>{if(dt.trim()){Re(!0),Se(null),Gt(null);try{const w=await fetch(`/v2/users/lookup?email=${encodeURIComponent(dt.trim())}`,{credentials:"include"});w.ok?Se(await w.json()):Gt("No account found for that email.")}catch{Gt("Lookup failed.")}finally{Re(!1)}}},ki=async()=>{if(!(!xe||!(c!=null&&c.id))){Lt(!0);try{const w=await fetch(`/v2/decks/${c.id}/shares`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_id:xe.id})});if(w.ok){const E=await w.json();Ie(R=>[...R,E]),le(""),Se(null)}else{const E=await w.json().catch(()=>({}));ge.show({color:"red",message:E.detail??"Failed to add share."})}}finally{Lt(!1)}}},vi=async w=>{if(!(c!=null&&c.id))return;(await fetch(`/v2/decks/${c.id}/shares/${w}`,{method:"DELETE",credentials:"include"})).ok&&Ie(R=>R.filter(I=>I.user_id!==w))},gs=async w=>{const E=w==="pdf"?"PDF":"PowerPoint",R=fe.reduce((Pe,nn)=>Pe+nn.visualizations.length,0),I=4e3+R*3e3+4e3,L=Date.now(),Z=()=>{const Pe=Date.now()-L,nn=1-Math.exp(-Pe/(I*.45));if(F(Math.min(95,nn*95)),Pe<4e3)mn("Launching headless browser...");else if(Pe<I-3e3){const Ut=Pe-4e3,rn=I-7e3,St=Math.min(R,Math.max(1,Math.ceil(Ut/rn*R)));mn(`Rendering page ${St} of ${R}...`)}else mn(`Finalizing ${E}...`)};let te=null;try{zt(!0),kt(w),F(0),mn("Starting..."),Z(),te=setInterval(Z,250);const Pe=await fetch(`/v2/decks/${e}/${w}`,{credentials:"include"});if(!Pe.ok)throw new Error(`Server returned ${Pe.status}`);const nn=await Pe.blob();F(100),mn("Downloading...");const Ut=URL.createObjectURL(nn),rn=document.createElement("a");rn.href=Ut,rn.download=`${c.title}.${w}`,rn.click(),URL.revokeObjectURL(Ut)}catch(Pe){ge.show({color:"red",message:`Failed to export ${E}: `+Pe.message})}finally{te&&clearInterval(te),setTimeout(()=>{zt(!1),kt(null),F(0),mn("")},600)}},Si=async()=>{if(be.current=!0,!await pt({title:"Delete deck",message:`Delete "${c.title}"? This removes the deck and all of its slides.`,confirmLabel:"Delete deck"})){De();return}try{Dt(!0),await Oy(c.id),t(`/${n}`)}catch(E){ge.show({color:"red",message:"Failed to delete: "+E.message})}finally{Dt(!1)}},Ci=async w=>{try{await Iy(c.id,w,{pageId:_??void 0}),k(!1),G(null),d(),b()}catch(E){ge.show({color:"red",message:"Failed to add: "+E.message})}},ng=async(w,E)=>{try{await sn(c.id,w,{visualization_id:E}),k(!1),se(null),G(null),d(),b()}catch(R){ge.show({color:"red",message:"Failed to replace: "+R.message})}},rg=async w=>{_e(E=>E.map(R=>R.id===_?{...R,visualizations:R.visualizations.filter(I=>I.id!==w)}:R));try{await jy(c.id,w),d(),b()}catch(E){ge.show({color:"red",message:"Failed to remove: "+E.message}),d()}},sg=async(w,E)=>{if(!(!_||E===_)){_e(R=>{const I=R.find(Z=>Z.id===_),L=I==null?void 0:I.visualizations.find(Z=>Z.id===w);return L?R.map(Z=>Z.id===_?{...Z,visualizations:Z.visualizations.filter(te=>te.id!==w)}:Z.id===E?{...Z,visualizations:[...Z.visualizations,{...L,page_id:E}]}:Z):R});try{await sn(c.id,w,{page_id:E}),await d()}catch(R){ge.show({color:"red",message:"Failed to move: "+R.message}),d()}}},ig=async(w,E)=>{_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,minimal_mode:E}:L)})));try{await sn(c.id,w,{minimal_mode:E}),await d()}catch(R){ge.show({color:"red",message:"Failed to update minimal mode: "+R.message}),d()}},Yc=async(w,E)=>{_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,props:yy(L.props,E)}:L)})));try{await sn(c.id,w,{props:E}),await d()}catch(R){ge.show({color:"red",message:"Failed to update block: "+R.message}),d()}},og=async(w,E)=>{_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,background_color:E||null}:L)})));try{await sn(c.id,w,{background_color:E}),await d()}catch(R){ge.show({color:"red",message:"Failed to update background color: "+R.message}),d()}},lg=async w=>{if(!_)return;const E={x:0,y:0,w:100,h:100};_e(R=>R.map(I=>I.id===_?{...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,...E}:L)}:I));try{await sn(c.id,w,E),d()}catch(R){ge.show({color:"red",message:"Failed to expand: "+R.message}),d()}},ag=async w=>{try{const E=await fetch(`/v2/visualizations/${w}/refresh`,{method:"POST",credentials:"include"});if(E.ok){const R=await E.json();R!=null&&R.id&&(typeof R.content=="string"&&(R.content=JSON.parse(R.content)),O(R)),d()}}catch(E){console.error("Failed to refresh visualization:",E)}},cg=w=>{_&&(_e(E=>E.map(R=>R.id===_?{...R,visualizations:R.visualizations.map(I=>{const L=w.find(Z=>Z.id===I.id);return L?{...I,x:L.x,y:L.y,w:L.w,h:L.h}:I})}:R)),et.current&&clearTimeout(et.current),et.current=setTimeout(()=>
287{ze(c.id,_,w).catch(E=>{ge.show({color:"red",message:"Failed to save layout: "+E.message}),d()})},400))},ys=async(w,E)=>{if(!_)return;const{w:R,h:I}=ks[w];try{await qr(c.id,{block_type:w,page_id:_,heading_level:E,text_content:"",w:R,h:I}),d()}catch(L){ge.show({color:"red",message:"Failed to add block: "+L.message})}},Mi=async(w,E)=>{if(!_)return;const R=w==="line",{w:I,h:L}=fy(w,E);try{await qr(c.id,{block_type:"shape",page_id:_,w:I,h:L,props:R?{shape_kind:"line",stroke:Rs.stroke,stroke_width:Rs.stroke_width,fill:null,x1:8,y1:66,x2:70,y2:66,arrow_start:!1,arrow_end:!!(E!=null&&E.arrow)}:{...Rs,shape_kind:w}}),d()}catch(Z){ge.show({color:"red",message:"Failed to add shape: "+Z.message})}},dg=(w,E)=>{const R=fe.flatMap(L=>L.visualizations).find(L=>L.id===w);if(!R)return;const I={...R.props??{},...E};_e(L=>L.map(Z=>({...Z,visualizations:Z.visualizations.map(te=>te.id===w?{...te,props:I}:te)}))),sn(c.id,w,{props:E}).catch(()=>d())},ug=async w=>{if(!_)return;const E=kf(w.x,w.w),R=kf(w.y,w.h);try{await qr(c.id,{block_type:w.block_type,page_id:_,text_content:w.text_content??void 0,heading_level:w.heading_level??void 0,image_url:w.image_url??void 0,x:E,y:R,w:w.w,h:w.h,text_scale:w.text_scale,auto_height:w.auto_height,props:w.props}),d()}catch(I){ge.show({color:"red",message:"Failed to paste element: "+I.message})}},fg=async w=>{if(_)try{const{image_key:E}=await od(c.id,w),R=`/v2/decks/${c.id}/images/${E}`;await qr(c.id,{block_type:"image",page_id:_,image_url:R,x:0,y:0,w:ks.image.w,h:ks.image.h}),d()}catch(E){ge.show({color:"red",message:"Failed to paste image: "+E.message})}},hg=async w=>{if(!_)return;const E="html"in w?Hr(w.html):fi(w.plain);if(Qa(E))try{await qr(c.id,{block_type:"paragraph",page_id:_,text_content:E,x:0,y:0,w:ks.paragraph.w,h:ks.paragraph.h,auto_height:!1}),d()}catch(R){ge.show({color:"red",message:"Failed to paste text: "+R.message})}},pg=w=>{const E=yn.current.get(w);E&&(clearTimeout(E),yn.current.delete(w)),_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id!==w?L:{...L,auto_height:!1})}))),sn(c.id,w,{auto_height:!1}).catch(R=>{ge.show({color:"red",message:"Failed to save text box height: "+R.message}),d()})},mg=(w,E)=>{if(!f)return;const R=Bt.current.flatMap(Z=>Z.visualizations).find(Z=>Z.id===w);if(!R||R.auto_height===!1||R.h===E)return;_e(Z=>Z.map(te=>({...te,visualizations:te.visualizations.map(Pe=>Pe.id===w?{...Pe,h:E}:Pe)})));const I=yn.current,L=I.get(w);L&&clearTimeout(L),I.set(w,setTimeout(()=>{I.delete(w),sn(c.id,w,{h:E}).catch(()=>d())},400))},gg=async(w,E)=>{_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,...E}:L)})));try{await sn(c.id,w,E)}catch(R){ge.show({color:"red",message:"Failed to save block: "+R.message}),d()}},yg=async(w,E)=>{if(f){_e(R=>R.map(I=>({...I,visualizations:I.visualizations.map(L=>L.id===w?{...L,image_stretch:E}:L)})));try{await sn(c.id,w,{image_stretch:E})}catch(R){ge.show({color:"red",message:"Failed to save image: "+R.message}),d()}}},bg=async w=>{const E=document.createElement("input");E.type="file",E.accept="image/*",E.onchange=async()=>{var I;const R=(I=E.files)==null?void 0:I[0];if(R)try{const{image_key:L}=await od(c.id,R),Z=`/v2/decks/${c.id}/images/${L}`,te=await wA(R),Pe=Bt.current.flatMap(Ut=>Ut.visualizations).find(Ut=>Ut.id===w),nn=Pe&&te>0?AT({x:Pe.x,y:Pe.y,w:Pe.w,h:Pe.h},te,jr):null;if(_e(Ut=>Ut.map(rn=>({...rn,visualizations:rn.visualizations.map(St=>St.id===w?{...St,image_url:Z,image_stretch:!1,...nn?{w:nn.w,h:nn.h}:{}}:St)}))),await sn(c.id,w,{image_url:Z,image_stretch:!1}),nn){const Ut=Bt.current.find(rn=>rn.visualizations.some(St=>St.id===w));if(Ut){et.current&&(clearTimeout(et.current),et.current=null);const rn=Ut.visualizations.map(St=>St.id===w?{id:St.id,x:St.x,y:St.y,w:nn.w,h:nn.h}:{id:St.id,x:St.x,y:St.y,w:St.w,h:St.h});await ze(c.id,Ut.id,rn)}}d()}catch(L){ge.show({color:"red",message:"Image upload failed: "+L.message})}},E.click()},xg=async w=>{const E=_?fe.findIndex(I=>I.id===_):-1,R=E>=0?E+1:void 0;try{const I=await Zb({createPage:Ly,addBlock:qr,deletePage:ld},c.id,w,R);await d(),Ve(I.id)}catch(I){try{await d()}catch{}ge.show({color:"red",message:"Failed to add slide: "+I.message})}},Xc=async w=>{const E=fe.find(I=>I.id===w);if(await pt({title:"Delete slide",message:E!=null&&E.title?`Delete the slide "${E.title}" and everything on it?`:"Delete this slide and everything on it?",confirmLabel:"Delete slide"}))try{await ld(c.id,w),_===w&&Ve(null),d()}catch(I){ge.show({color:"red",message:"Failed to delete slide: "+I.message})}},Zc=async(w,E)=>{const R=E.trim()||null;_e(I=>I.map(L=>L.id===w?{...L,title:R}:L));try{await ad(c.id,w,{title:R}),d()}catch(I){ge.show({color:"red",message:"Failed to rename slide: "+I.message}),d()}},wg=async(w,E)=>{const R=E||null;_e(I=>I.map(L=>L.id===w?{...L,notes:R}:L));try{await ad(c.id,w,{notes:R})}catch(I){console.error("Failed to save speaker notes",I)}},Qc=async(w,E)=>{const R=fe.findIndex(Z=>Z.id===w),I=R+E;if(R<0||I<0||I>=fe.length)return;const L=[...fe];[L[R],L[I]]=[L[I],L[R]],_e(L);try{await cd(c.id,L.map(Z=>Z.id)),d()}catch(Z){ge.show({color:"red",message:"Failed to reorder: "+Z.message}),d()}},ed=async(w,E)=>{var Z;if(w===E)return;const R=fe.findIndex(te=>te.id===w),I=fe.findIndex(te=>te.id===E);if(R<0||I<0||(Z=fe[0])!=null&&Z.is_cover&&(R===0||I===0))return;const L=cc(fe,R,I);_e(L);try{await cd(c.id,L.map(te=>te.id)),d()}catch(te){ge.show({color:"red",message:"Failed to reorder: "+te.message}),d()}};return p.jsxs(Nn,{align:"stretch",style:{height:"calc(var(--app-vh) - var(--app-shell-header-offset, 60px))"},children:[vt,p.jsx(uA,{children:p.jsxs(bA,{children:[p.jsxs(Nn,{direction:"column",flex:"1 1 auto",miw:0,mih:0,children:[p.jsx(ay,{backTo:u==null?"/shared":`/${n}`,title:c.title,badge:c.private&&Pt?p.jsx(dd,{variant:"light",color:"blue",leftSection:p.jsx(ey,{size:12,"aria-hidden":!0}),title:"Visible because the workspace is featured as an Example",children:"Via Example"}):c.private?null:p.jsx(dd,{variant:"light",color:"gray",leftSection:p.jsx(sd,{size:12,"aria-hidden":!0}),children:"Shared"}),description:c.description||void 0,actions:p.jsx(p.Fragment,{children:p.jsxs(Ee,{gap:"sm",wrap:"nowrap",flex:"none",maw:"100%",children:[f&&h&&p.jsx(kr,{label:"Open the assistant: cover slide, chart from a question",icon:p.jsx(rd,{size:16,"aria-hidden":!0}),"aria-expanded":r,onClick:()=>s(!0),loading:at}
287),f&&p.jsx(K,{visibleFrom:"sm",role:"toolbar","aria-label":"Slide actions",children:p.jsxs(we.Group,{children:[p.jsxs(B,{shadow:"md",position:"bottom-end",children:[p.jsx(B.Target,{children:p.jsx(kr,{label:"Add a chart",icon:p.jsx(Ss,{size:16,"aria-hidden":!0})})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Label,{children:"Add a chart"}),p.jsx(B.Item,{leftSection:p.jsx(Ss,{size:16,"aria-hidden":!0}),onClick:()=>t(`/${n}/visualization/new?deck=${e}`+(_?`&page=${_}`:"")),children:"New chart from a question"}),p.jsx(B.Item,{leftSection:p.jsx(Ji,{size:16,"aria-hidden":!0}),onClick:()=>k(!0),disabled:!_,children:"Import a saved chart"})]})]}),p.jsx(kr,{label:"Add text",icon:p.jsx(c0,{size:16,"aria-hidden":!0}),onClick:()=>ys("paragraph"),disabled:!_}),p.jsxs(B,{shadow:"md",position:"bottom-end",children:[p.jsx(B.Target,{children:p.jsx(kr,{label:"Add a heading",icon:p.jsx(n0,{size:16,"aria-hidden":!0}),disabled:!_})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Label,{children:"Headings"}),p.jsx(B.Item,{leftSection:p.jsx(Yy,{size:16,"aria-hidden":!0}),onClick:()=>ys("title",1),children:"Heading 1"}),p.jsx(B.Item,{leftSection:p.jsx(Zy,{size:16,"aria-hidden":!0}),onClick:()=>ys("title",2),children:"Heading 2"}),p.jsx(B.Item,{leftSection:p.jsx(e0,{size:16,"aria-hidden":!0}),onClick:()=>ys("title",3),children:"Heading 3"})]})]}),p.jsx(kr,{label:"Add an image",icon:p.jsx(Za,{size:16,"aria-hidden":!0}),onClick:()=>ys("image"),disabled:!_}),p.jsxs(B,{shadow:"md",position:"bottom-end",children:[p.jsx(B.Target,{children:p.jsx(kr,{label:"Add a shape",icon:p.jsx(sa,{size:16,"aria-hidden":!0}),disabled:!_})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Label,{children:"Shapes"}),p.jsx(B.Item,{leftSection:p.jsx(sa,{size:16,"aria-hidden":!0}),onClick:()=>Mi("rect"),children:"Rectangle"}),p.jsx(B.Item,{leftSection:p.jsx($f,{size:16,"aria-hidden":!0}),onClick:()=>Mi("ellipse"),children:"Ellipse"}),p.jsx(B.Item,{leftSection:p.jsx(nc,{size:16,"aria-hidden":!0}),onClick:()=>Mi("line"),children:"Line"}),p.jsx(B.Item,{leftSection:p.jsx(l0,{size:16,"aria-hidden":!0}),onClick:()=>Mi("line",{arrow:!0}),children:"Arrow"})]})]})]})}),p.jsxs(Ee,{gap:"xs",wrap:"nowrap",role:"toolbar","aria-label":"Deck actions",children:[p.jsx(kr,{label:"Share or download this deck",icon:p.jsx(qg,{size:16,"aria-hidden":!0}),onClick:()=>Q(!0)}),p.jsxs(B,{shadow:"md",position:"bottom-end",withArrow:!0,children:[p.jsx(B.Target,{children:p.jsx(We,{variant:"primary",size:"xs",leftSection:p.jsx(vl,{size:14,"aria-hidden":!0}),rightSection:p.jsx(Ef,{size:14,"aria-hidden":!0}),disabled:fe.length===0,children:"Present"})}),p.jsxs(B.Dropdown,{children:[p.jsx(B.Item,{leftSection:p.jsx(vl,{size:16,"aria-hidden":!0}),onClick:()=>window.open(`/embed/deck/${e}?present=1`,"_blank"),children:"Present (audience)"}),p.jsx(B.Item,{leftSection:p.jsx(tc,{size:16,"aria-hidden":!0}),onClick:()=>window.open(`/embed/deck/${e}?present=1&presenter=1`,"_blank"),children:"Presenter view (with notes)"})]})]})]}),f&&p.jsxs(B,{shadow:"md",position:"bottom-end",returnFocus:!1,children:[p.jsx(B.Target,{children:p.jsx(xn,{label:"More",withArrow:!0,children:p.jsx(we,{ref:Qe,variant:"subtle",color:"gray",size:"md","aria-label":"More actions",children:p.jsx(Qo,{size:16,"aria-hidden":!0})})})}),p.jsxs(B.Dropdown,{children:[m&&p.jsxs(p.Fragment,{children:[p.jsx(B.Item,{leftSection:p.jsx(Ss,{size:16,"aria-hidden":!0}),onClick:()=>t(`/${n}/visualization/new?deck=${e}`+(_?`&page=${_}`:"")),children:"New chart from a question"}),p.jsx(B.Item,{leftSection:p.jsx(Ji,{size:16,"aria-hidden":!0}),onClick:()=>{be.current=!0,k(!0)},disabled:!_,children:"Import a saved chart"}),p.jsx(B.Divider,{})]}),p.jsx(B.Item,{leftSection:p.jsx(oy,{size:16,"aria-hidden":!0}),rightSection:p.jsx(io,{size:"xs",children:"âZ"}),onClick:Gn,disabled:T,children:"Undo"}),p.jsx(B.Item,{leftSection:p.jsx(ly,{size:16,"aria-hidden":!0}),rightSection:p.jsx(io,{size:"xs",children:"ââ§Z"}),onClick:bn,disabled:T,children:"Redo"}),p.jsx(B.Item,{leftSection:p.jsx(Rf,{size:16,"aria-hidden":!0}),onClick:()=>C(!0),children:"Version history"}),p.jsx(B.Divider,{}),p.jsx(B.Item,{leftSection:p.jsx(Ya,{size:16,"aria-hidden":!0}),onClick:Wr,children:"Edit title and description"}),p.jsx(B.Item,{color:"red",leftSection:p.jsx(ss,{size:16,"aria-hidden":!0}),onClick:Si,disabled:ft,children:"Delete deck"})]})]})]})}),children:p.jsxs(K,{className:"deck-header-rte",children:[p.jsx(wT,{leadingControl:f&&gn?p.jsx(FC,{props:gn.props,onChange:w=>Yc(gn.id,w)}):void 0}),p.jsx(yA,{})]})}),p.jsxs(Nn,{flex:"1 1 100%",mih:0,align:"stretch",children:[p.jsx(Nn,{visibleFrom
287:"sm",h:"100%",children:p.jsx(sA,{pages:fe,selectedPageId:_,canWrite:f,vizMap:H,vizLoaded:ke,onSelectPage:Ve,onMoveUp:w=>Qc(w,-1),onMoveDown:w=>Qc(w,1),onDelete:Xc,onRename:Zc,onAdd:()=>P(!0),onReorder:ed})}),p.jsxs(Nn,{direction:"column",flex:"1 1 auto",mih:0,miw:0,bg:"var(--sd-color-page)",children:[p.jsx(Nn,{flex:"1 1 auto",miw:0,mih:0,style:{overflow:"hidden"},children:Le?p.jsx(_T,{page:Le,pages:fe,vizMap:je,vizLoaded:ke,vizError:Ne,onRetryViz:W,analyzingVizIds:Tn,workspaceId:n,canWrite:f,notesOpen:ht,onToggleNotes:()=>Yt(w=>!w),onLayoutChange:cg,onRemoveViz:rg,onReplaceViz:w=>{se(w),G(null),k(!0)},onRefreshViz:ag,onMoveViz:sg,onExpandViz:lg,onMinimalModeChange:ig,onSelectBlock:ue,onSaveBlockProps:Yc,onUpdateBlockProps:dg,onBackgroundColorChange:og,onTypeChange:it,onVisualizationUpdate:O,onSaveBlockContent:gg,onResizeBlockHeight:pg,onAutoHeight:mg,onImageStretch:yg,onUploadImage:bg,onAddVisualization:()=>k(!0),onNewVisualization:()=>t(`/${n}/visualization/new?deck=${e}`+(_?`&page=${_}`:"")),onDuplicateElement:ug,onPasteImage:fg,onPasteText:hg}):p.jsx(ar,{flex:1,children:p.jsx(Pf,{icon:p.jsx(vl,{size:20,"aria-hidden":!0}),title:"No slides in this deck yet",description:"Add a slide, then fill it with charts, text, and shapes.",action:f?p.jsx(We,{variant:"default",leftSection:p.jsx(ui,{size:16,"aria-hidden":!0}),onClick:()=>P(!0),children:"Add slide"}):void 0})})}),p.jsx(wC,{page:Le,canWrite:f,open:ht,onToggle:()=>Yt(w=>!w),onSave:wg}),fe.length>0&&p.jsx(K,{hiddenFrom:"sm",flex:"0 0 auto",children:p.jsx(iA,{pages:fe,selectedPageId:_,canWrite:f,vizMap:H,vizLoaded:ke,onSelectPage:Ve,onRename:Zc,onDelete:Xc,onAdd:()=>P(!0),onReorder:ed})})]})]})]}),p.jsx(Nn,{ref:i,visibleFrom:"sm",flex:"0 0 auto",h:"100%",mih:0})]})}),p.jsx(VT,{opened:A,onClose:()=>P(!1),onSelect:w=>{P(!1),xg(w)}}),p.jsx(As,{size:"auto",opened:D,onClose:()=>{k(!1),se(null),G(null),De()},title:ae?"Replace a chart":"Import a saved chart",children:p.jsxs(Mt,{gap:"md",style:{width:760,maxWidth:"92vw"},children:[y&&!g?p.jsx(K,{p:"md",ta:"center",children:p.jsx(Df,{size:"sm"})}):p.jsx(K,{style:{maxHeight:"60vh",overflowY:"auto"},children:p.jsx(By,{visualizations:g??[],workspaceId:n,mode:"select",selectedId:U,onSelect:G,emptyText:"No visualizations available",columns:$y.columns.cards})}),(_t==null?void 0:_t.in_deck)&&p.jsxs(re,{size:"sm",c:"dimmed",children:["Used in ",((td=_t.deck_names)==null?void 0:td[0])??"another deck"," â a copy will be added."]}),p.jsx(Ee,{justify:"flex-end",gap:"sm",children:p.jsx(We,{variant:"primary",leftSection:p.jsx(Ji,{size:16,"aria-hidden":!0}),disabled:!U,onClick:()=>{U&&(ae?ng(ae,U):Ci(U))},children:ae?"Replace chart":"Import chart"})})]})}),p.jsx(As,{size:"auto",opened:de,onClose:()=>{ye(!1),De()},title:"Edit deck",children:p.jsxs(Mt,{gap:"md",style:{width:680,maxWidth:"90vw"},children:[p.jsx(Ks,{label:"Title","data-autofocus":!0,value:Ue,onChange:w=>ve(w.currentTarget.value),disabled:ct}),p.jsx(Jg,{label:"Description",description:"Short tagline shown in deck lists and galleries.",value:lt,onChange:w=>Me(w.currentTarget.value),disabled:ct,rows:2}),p.jsxs(Ee,{justify:"flex-end",children:[p.jsx(We,{variant:"default",onClick:()=>{ye(!1),De()},disabled:ct,children:"Cancel"}),p.jsx(We,{variant:"primary",onClick:Ur,loading:ct,children:"Save"})]})]})}),p.jsx(As,{size:"auto",opened:me,onClose:()=>Q(!1),title:"Share and download",children:p.jsxs(Mt,{maw:600,w:"calc(100vw - var(--mantine-spacing-xl) * 2)",gap:"lg",children:[f&&p.jsx(K,{p:"md",style:{background:"var(--sd-color-surface-subtle)",borderRadius:"var(--sd-radius-md)"},children:p.jsx(ud,{checked:!c.private,onChange:w=>kl(!w.currentTarget.checked),label:p.jsxs(K,{children:[p.jsx(re,{size:"sm",fw:500,children:c.private?"Private deck":"Shared deck"}),p.jsx(re,{size:"xs",c:"dimmed",children:c.private?"Only workspace members can view this deck":"Anyone with the link can view this deck"})]}),thumbIcon:c.private?p.jsx(Qg,{size:12,"aria-hidden":!0}):p.jsx(sd,{size:12,"aria-hidden":!0})})}),!c.private&&f&&p.jsx(K,{p:"md",style:{background:"var(--sd-color-surface-subtle)",borderRadius:"var(--sd-radius-md)"},children:p.jsx(ud,{checked:!!c.discoverable,onChange:w=>ms(w.currentTarget.checked),label:p.jsxs(K,{children:[p.jsx(re,{size:"sm",fw:500,children:"List on Explore"}),p.jsx(re,{size:"xs",c:"dimmed",children:"Show this deck on the Explore page so other users can discover it. When off, only people with the direct link can find it."})]})})}),!c.private&&p.jsxs(K,{children:[p.jsx(re,{size:"sm",fw:600,mb:"xs",children:"Share URL"}),p.jsx(cy,{url:`${window.location.origin}/embed/deck/${e}`}),p.jsx(re,{size:"xs",c:"dimmed",mt:"xs",children:"Share this link with anyone. No login required."})]}),c.private&&f&&p.jsxs(K,{p:"md",style:{background:"var(--sd-color-surface-subtle)",borderRadius:"var(--sd-radius-md)"},children:[p.jsx(re,{size:"sm",fw:600,mb:"xs",children:"Share with specific people"}),p.jsx(re,{size:"xs",c:"dimmed",mb:"sm",children:"Grant access to individual users by email. They must have an account."}),p.jsxs(Ee,{gap:"xs",align:"flex-end",mb:"sm",children:[p.jsx(Ks,{"aria-label":"Recipient email",placeholder:"[email protected]",value:dt,onChange:w=>{le(w.currentTarget.value),Se(null),Gt(null)},onKeyDown:w=>w.key==="Enter"&&Kr(),size:"xs",style:{flex:1},error:Pn}),p.jsx(We,{size:"xs",variant:"default",loading:pn,onClick:Kr,children:"Find"})]}),xe&&p.jsxs(Ee,{justify:"space-between",mb:"sm",p:"xs",style:{background:"var(--sd-color-accent-subtle)",borderRadius:"var(--mantine-radius-sm)"},children:[p.jsx(re,{size:"xs",children:xe.display_name?`${xe.display_name} (@${xe.username})`:`@${xe.username}`}),p.jsx(We,{size:"xs",loading:At,onClick:ki,children:"Add"})]}),Te.length>0&&p.jsxs(Mt,{gap:4,children:[p.jsx(re,{size:"xs",c:"dimmed",fw:500,children:"Currently shared with"}),Te.map(w=>p.jsxs(Ee,{justify:"space-between",children:[p.jsx(re,{size:"xs",children:w.display_name?`${w.display_name} (@${w.username})`:`@${w.username}`}),p.jsx(we,{"aria-label":`Remove access for @${w.username}`,size:"sm",variant:"subtle",color:"red",onClick:()=>
287vi(w.user_id),title:"Remove access",children:p.jsx(ss,{size:12,"aria-hidden":!0})})]},w.user_id))]})]}),p.jsxs(K,{children:[p.jsx(re,{size:"sm",fw:600,mb:"xs",children:"Export"}),p.jsxs(Ee,{gap:"xs",wrap:"nowrap",children:[p.jsx(We,{leftSection:p.jsx(Gg,{size:16,"aria-hidden":!0}),variant:"default",loading:Rt&&Xe==="pdf",onClick:()=>gs("pdf"),fullWidth:!0,disabled:Rt,children:Rt&&Xe==="pdf"?"Generating PDF...":"Download PDF"}),p.jsx(We,{leftSection:p.jsx(qy,{size:16,"aria-hidden":!0}),variant:"default",loading:Rt&&Xe==="pptx",onClick:()=>gs("pptx"),fullWidth:!0,disabled:Rt,children:Rt&&Xe==="pptx"?"Generating PowerPoint...":"Download PowerPoint"})]}),Rt?p.jsxs(Mt,{gap:4,mt:"xs",children:[p.jsx(vy,{value:Ye,animated:Ye<100,transitionDuration:250,size:"sm"}),p.jsxs(Ee,{justify:"space-between",children:[p.jsx(re,{size:"xs",c:"dimmed",children:ps}),p.jsxs(re,{size:"xs",c:"dimmed",children:[Math.round(Ye),"%"]})]})]}):p.jsx(re,{size:"xs",c:"dimmed",mt:"xs",children:"Download all visualizations in this deck as a PDF report or an editable PowerPoint."})]})]})}),p.jsx(aA,{deck:c,opened:S,onClose:()=>C(!1),onRestored:()=>{d(),C(!1)}})]})}export{TD as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.