| 88 |
`,yr={mode:"browse"},br={mode:"upload"},vr=M(()=>{const{value:n,setValue:r}=b(t.imageSrcPropTypeUtil),{id:s,url:l}=n??{},{data:a,isFetching:c}=(0,$.useWpMediaAttachment)(s?.value||null),u=a?.url??l?.value??null,{data:d}=_(),[p,h]=(0,e.useState)(!1),{canUser:f}=(0,ir.useCurrentUserCapabilities)(),m=f("manage_options"),{open:g}=(0,$.useWpMediaFrame)({mediaTypes:["svg"],multiple:!1,selected:s?.value||null,onSelect:e=>{r({id:{$$type:"image-attachment-id",value:e.id},url:null})}}),y=e=>{d||e!==br?g(e):h(!0)},v={title:(0,i.__)("Sorry, you can't upload that file yet.","elementor"),description:e.createElement(e.Fragment,null,(0,i.__)("To upload them anyway, ask the site administrator to enable unfiltered","elementor"),e.createElement("br",null),(0,i.__)("file uploads.","elementor")),isEnabled:!m};return e.createElement(o.Stack,{gap:1},e.createElement(ur,{open:p,onClose:e=>{h(!1),e&&g(br)}}),e.createElement(G,null,e.createElement(mr,{variant:"outlined"},e.createElement(gr,null,c?e.createElement(o.CircularProgress,{role:"progressbar"}):e.createElement(o.CardMedia,{component:"img",image:u,alt:(0,i.__)("Preview SVG","elementor"),sx:{maxHeight:"140px",width:"50px"}})),e.createElement(o.CardOverlay,{sx:{"&:hover":{backgroundColor:"rgba( 0, 0, 0, 0.75 )"}}},e.createElement(o.Stack,{gap:1},e.createElement(o.Button,{size:"tiny",color:"inherit",variant:"outlined",onClick:()=>y(yr)},(0,i.__)("Select SVG","elementor")),e.createElement(Kn,v,e.createElement("span",null,e.createElement(o.ThemeProvider,{colorScheme:m?"light":"dark"},e.createElement(o.Button,{size:"tiny",variant:"text",color:"inherit",startIcon:e.createElement(R.UploadIcon,null),disabled:!m,onClick:()=>m&&y(br)},(0,i.__)("Upload","elementor"))))))))))});var wr=window.elementorV2.env;const{env:xr}=(0,wr.parseEnv)("@elementor/editor-controls"),Er=M(()=>{const{value:n,setValue:r}=b(t.backgroundGradientOverlayPropTypeUtil);return e.createElement(o.UnstableGradientBox,{sx:{width:"auto",padding:1.5},value:(()=>{if(!n)return;const{type:e,angle:t,stops:r,positions:o}=n;return{type:e.value,angle:t.value,stops:r.value.map(({value:{color:e,offset:t}})=>({color:e.value,offset:t.value})),positions:o?.value.split(" ")}})(),onChange:e=>{const n=(e=>({...e,type:t.stringPropTypeUtil.create(e.type),angle:t.numberPropTypeUtil.create(e.angle),stops:t.gradientColorStopPropTypeUtil.create(e.stops.map(({color:e,offset:n})=>t.colorStopPropTypeUtil.create({color:t.colorPropTypeUtil.create(e),offset:t.numberPropTypeUtil.create(n)})))}))(e);n.positions&&(n.positions=t.stringPropTypeUtil.create(e.positions.join(" "))),r(n)}})}),kr=t.backgroundGradientOverlayPropTypeUtil.create({type:t.stringPropTypeUtil.create("linear"),angle:t.numberPropTypeUtil.create(180),stops:t.gradientColorStopPropTypeUtil.create([t.colorStopPropTypeUtil.create({color:t.colorPropTypeUtil.create("rgb(0,0,0)"),offset:t.numberPropTypeUtil.create(0)}),t.colorStopPropTypeUtil.create({color:t.colorPropTypeUtil.create("rgb(255,255,255)"),offset:t.numberPropTypeUtil.create(100)})])}),Sr=[{value:"fixed",label:(0,i.__)("Fixed","elementor"),renderContent:({size:t})=>e.createElement(R.PinIcon,{fontSize:t}),showTooltip:!0},{value:"scroll",label:(0,i.__)("Scroll","elementor"),renderContent:({size:t})=>e.createElement(R.PinnedOffIcon,{fontSize:t}),showTooltip:!0}],Cr=()=>e.createElement(wt,null,e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,(0,i.__)("Attachment","elementor"))),e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",justifyContent:"flex-end",overflow:"hidden"}},e.createElement(pn,{options:Sr}))),Tr=[{label:(0,i.__)("Center center","elementor"),value:"center center"},{label:(0,i.__)("Center left","elementor"),value:"center left"},{label:(0,i.__)("Center right","elementor"),value:"center right"},{label:(0,i.__)("Top center","elementor"),value:"top center"},{label:(0,i.__)("Top left","elementor"),value:"top left"},{label:(0,i.__)("Top right","elementor"),value:"top right"},{label:(0,i.__)("Bottom center","elementor"),value:"bottom center"},{label:(0,i.__)("Bottom left","elementor"),value:"bottom left"},{label:(0,i.__)("Bottom right","elementor"),value:"bottom right"},{label:(0,i.__)("Custom","elementor"),value:"custom"}],Mr=()=>{const n=b(t.backgroundImagePositionOffsetPropTypeUtil),r=b(t.stringPropTypeUtil),s=!!n.value,l=(0,e.useRef)(null);return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(o.Grid,{item:!0,xs:12},e.createElement(wt,null,e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,(0,i.__)("Position","elementor"))),e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",justifyContent:"flex-end",overflow:"hidden"}},e.createElement(G,null,e.createElement(o.Select,{fullWidth:!0,size:"tiny",onChange:e=>{const t=e.target.value||null;"custom"===t?n.setValue({x:null,y:null}):r.setValue(t)},disabled:r.disabled,value:(n.value?"custom":r.value)??""},Tr.map(({label:t,value:n})=>e.createElement(q.MenuListItem,{key:n,value:n??""},t))))))),s?e.createElement(d,n,e.createElement(o.Grid,{item:!0,xs:12},e.createElement(o.Grid,{container:!0,spacing:1.5,ref:l},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"x"},e.createElement(xe,{startIcon:e.createElement(R.LetterXIcon,{fontSize:"tiny"}),anchorRef:l,min:-Number.MAX_SAFE_INTEGER}))),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"y"},e.createElement(xe,{startIcon:e.createElement(R.LetterYIcon,{fontSize:"tiny"}),anchorRef:l,min:-Number.MAX_SAFE_INTEGER})))))):null)},Or=[{value:"repeat",label:(0,i.__)("Repeat","elementor"),renderContent:({size:t})=>e.createElement(R.GridDotsIcon,{fontSize:t}),showTooltip:!0},{value:"repeat-x",label:(0,i.__)("Repeat-x","elementor"),renderContent:({size:t})=>e.createElement(R.DotsHorizontalIcon,{fontSize:t}),showTooltip:!0},{value:"repeat-y",label:(0,i.__)("Repeat-y","elementor"),renderContent:({size:t})=>e.createElement(R.DotsVerticalIcon,{fontSize:t}),showTooltip:!0},{value:"no-repeat",label:(0,i.__)("No-repeat","elementor"),renderContent:({size:t})=>e.createElement(R.XIcon,{fontSize:t}),showTooltip:!0}],Ir=()=>e.createElement(wt,null,e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,(0,i.__)("Repeat","elementor"))),e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",justifyContent:"flex-end"}},e.createElement(pn,{options:Or}))),Pr=[{value:"auto",label:(0,i.__)("Auto","elementor"),renderContent:({size:t})=>e.createElement(R.LetterAIcon,{fontSize:t}),showTooltip:!0},{value:"cover",label:(0,i.__)("Cover","elementor"),renderContent:({size:t})=>e.createElement(R.ArrowsMaximizeIcon,{fontSize:t}),showTooltip:!0},{value:"contain",label:(0,i.__)("Contain","elementor"),renderContent:({size:t})=>e.createElement(R.ArrowBarBothIcon,{fontSize:t}),showTooltip:!0},{value:"custom",label:(0,i.__)("Custom","elementor"),renderContent:({size:t})=>e.createElement(R.PencilIcon,{fontSize:t}),showTooltip:!0}],Nr=()=>{const n=b(t.backgroundImageSizeScalePropTypeUtil),r=b(t.stringPropTypeUtil),s=!!n.value,l=(0,e.useRef)(null);return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(o.Grid,{item:!0,xs:12},e.createElement(wt,null,e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,(0,i.__)("Size","elementor"))),e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",justifyContent:"flex-end"}},e.createElement(an,{exclusive:!0,items:Pr,onChange:e=>{"custom"===e?n.setValue({width:null,height:null}):r.setValue(e)},disabled:r.disabled,value:n.value?"custom":r.value})))),s?e.createElement(d,n,e.createElement(o.Grid,{item:!0,xs:12,ref:l},e.createElement(wt,null,e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"width"},e.createElement(xe,{startIcon:e.createElement(R.ArrowsMoveHorizontalIcon,{fontSize:"tiny"}),extendedOptions:["auto"],anchorRef:l}))),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"height"},e.createElement(xe,{startIcon:e.createElement(R.ArrowsMoveVerticalIcon,{fontSize:"tiny"}),extendedOptions:["auto"],anchorRef:l})))))):null)};function Dr(){return Dr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dr.apply(null,arguments)}const Ar=t.backgroundColorOverlayPropTypeUtil.create({color:t.colorPropTypeUtil.create("#00000033")}),_r=()=>({$$type:"background-image-overlay",value:{image:{$$type:"image",value:{src:{$$type:"image-src",value:{url:{$$type:"url",value:xr.background_placeholder_image},id:null}},size:{$$type:"string",value:"large"}}}}}),zr=[{label:(0,i.__)("Thumbnail - 150 x 150","elementor"),value:"thumbnail"},{label:(0,i.__)("Medium - 300 x 300","elementor"),value:"medium"},{label:(0,i.__)("Large 1024 x 1024","elementor"),value:"large"},{label:(0,i.__)("Full","elementor"),value:"full"}],Rr=M(()=>{const{propType:n,value:r,setValue:o}=b(t.backgroundOverlayPropTypeUtil);return e.createElement(d,{propType:n,value:r,setValue:o},e.createElement(lt,{initial:_r(),propTypeUtil:t.backgroundOverlayPropTypeUtil},e.createElement(Ct,{label:(0,i.__)("Overlay","elementor")},e.createElement(Ve,{newItemIndex:0})),e.createElement(qe,null,e.createElement(st,{Icon:Br,Label:Ur,actions:e.createElement(e.Fragment,null,e.createElement(dt,null),e.createElement(ct,null),e.createElement(ht,null))})),e.createElement(yt,null,e.createElement($r,null))))}),$r=()=>{const{getTabsProps:n,getTabProps:r,getTabPanelProps:s}=(({color:n,image:r,gradient:i})=>{const{value:s,setValue:l}=b(t.backgroundImageOverlayPropTypeUtil),{value:a,setValue:c}=b(t.backgroundColorOverlayPropTypeUtil),{value:u,setValue:d}=b(t.backgroundGradientOverlayPropTypeUtil),{getTabsProps:p,getTabProps:h,getTabPanelProps:f}=(0,o.useTabs)(a?"color":u?"gradient":"image"),m=(0,e.useRef)({image:r,color:n,gradient:i}),g=(e,t)=>{t&&(m.current[e]=t)},y=(e,t)=>{switch(t){case"image":l(m.current.image),g("color",a),g("gradient",u);break;case"gradient":d(m.current.gradient),g("color",a),g("image",s);break;case"color":c(m.current.color),g("image",s),g("gradient",u)}return p().onChange(e,t)};return{getTabProps:h,getTabPanelProps:f,getTabsProps:()=>({...p(),onChange:y})}})({image:_r().value,color:Ar.value,gradient:kr.value}),{rowRef:l}=ze();return e.createElement(o.Box,{sx:{width:"100%"}},e.createElement(o.Box,{sx:{borderBottom:1,borderColor:"divider"}},e.createElement(o.Tabs,Dr({size:"small",variant:"fullWidth"},n(),{"aria-label":(0,i.__)("Background Overlay","elementor")}),e.createElement(o.Tab,Dr({label:(0,i.__)("Image","elementor")},r("image"))),e.createElement(o.Tab,Dr({label:(0,i.__)("Gradient","elementor")},r("gradient"))),e.createElement(o.Tab,Dr({label:(0,i.__)("Color","elementor")},r("color"))))),e.createElement(o.TabPanel,Dr({sx:{p:1.5}},s("image")),e.createElement(vt,null,e.createElement(Jr,null))),e.createElement(o.TabPanel,Dr({sx:{p:1.5}},s("gradient")),e.createElement(Er,null)),e.createElement(o.TabPanel,Dr({sx:{p:1.5}},s("color")),e.createElement(vt,null,e.createElement(qr,{anchorEl:l}))))},Br=({value:t})=>{switch(t.$$type){case"background-image-overlay":return e.createElement(Fr,{value:t});case"background-color-overlay":return e.createElement(Lr,{value:t});case"background-gradient-overlay":return e.createElement(jr,{value:t});default:return null}},Vr=e=>e?.value?.color?.value?e.value.color.value:"",Lr=({value:t})=>{const n=Vr(t);return e.createElement(Kr,{size:"inherit",component:"span",value:n})},Fr=({value:t})=>{const{imageUrl:n}=Yr(t);return e.createElement(o.CardMedia,{image:n,sx:e=>({height:"1rem",width:"1rem",borderRadius:e.shape.borderRadius/2+"px",outline:`1px solid ${e.palette.action.disabled}`})})},jr=({value:t})=>{const n=Zr(t);return e.createElement(Kr,{size:"inherit",component:"span",value:n})},Ur=({value:t})=>{switch(t.$$type){case"background-image-overlay":return e.createElement(Gr,{value:t});case"background-color-overlay":return e.createElement(Wr,{value:t});case"background-gradient-overlay":return e.createElement(Hr,{value:t});default:return null}},Wr=({value:t})=>{const n=Vr(t);return e.createElement("span",null,n)},Gr=({value:t})=>{const{imageTitle:n}=Yr(t);return e.createElement("span",null,n)},Hr=({value:t})=>"linear"===t.value.type.value?e.createElement("span",null,(0,i.__)("Linear Gradient","elementor")):e.createElement("span",null,(0,i.__)("Radial Gradient","elementor")),qr=({anchorEl:n})=>{const r=b(t.backgroundColorOverlayPropTypeUtil);return e.createElement(d,r,e.createElement(f,{bind:"color"},e.createElement(Oe,{anchorEl:n})))},Jr=()=>{const n=b(t.backgroundImageOverlayPropTypeUtil);return e.createElement(d,n,e.createElement(f,{bind:"image"},e.createElement(Y,{sizes:zr})),e.createElement(f,{bind:"position"},e.createElement(Mr,null)),e.createElement(f,{bind:"repeat"},e.createElement(Ir,null)),e.createElement(f,{bind:"size"},e.createElement(Nr,null)),e.createElement(f,{bind:"attachment"},e.createElement(Cr,null)))},Kr=(0,o.styled)(o.UnstableColorIndicator)(({theme:e})=>({height:"1rem",width:"1rem",borderRadius:e.shape.borderRadius/2+"px"})),Yr=e=>{let t,n=null;const r=e?.value.image.value?.src.value,{data:o}=(0,$.useWpMediaAttachment)(r.id?.value||null);if(r.id){const e=Xr(o?.filename);t=`${o?.title}${e}`||null,n=o?.url||null}else r.url&&(n=r.url.value,t=n?.substring(n.lastIndexOf("/")+1)||null);return{imageTitle:t,imageUrl:n}},Xr=e=>e?`.${e.substring(e.lastIndexOf(".")+1)}`:"",Zr=e=>{const t=e.value,n=t.stops.value?.map(({value:{color:e,offset:t}})=>`${e.value} ${t.value??0}%`)?.join(",");return"linear"===t.type.value?`linear-gradient(${t.angle.value}deg, ${n})`:`radial-gradient(circle at ${t.positions.value}, ${n})`},Qr=[{label:(0,i.__)("Full element","elementor"),value:"border-box"},{label:(0,i.__)("Padding edges","elementor"),value:"padding-box"},{label:(0,i.__)("Content edges","elementor"),value:"content-box"},{label:(0,i.__)("Text","elementor"),value:"text"}],eo=(0,i.__)("Color","elementor"),to=(0,i.__)("Clipping","elementor"),no=M(()=>{const n=b(t.backgroundPropTypeUtil);return e.createElement(d,n,e.createElement(f,{bind:"background-overlay"},e.createElement(Rr,null)),e.createElement(ro,null),e.createElement(oo,null))}),ro=()=>e.createElement(f,{bind:"color"},e.createElement(o.Grid,{container:!0,gap:2,alignItems:"center",flexWrap:"nowrap"},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(mn,null,eo)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(Oe,null)))),oo=()=>e.createElement(f,{bind:"clip"},e.createElement(o.Grid,{container:!0,gap:2,alignItems:"center",flexWrap:"nowrap"},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(mn,null,to)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(K,{options:Qr}))));function io(){return io=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},io.apply(null,arguments)}const so=/\$\{([^}]+)\}/g,lo=M(({repeaterLabel:n,childControlConfig:r,showDuplicate:o,showToggle:i,initialValues:s,patternLabel:l,placeholder:a,propKey:c,addItemTooltipProps:u})=>{const{propTypeUtil:p,isItemDisabled:h}=r;if(!p)return null;const f=(0,e.useMemo)(()=>(0,t.createArrayPropUtils)(p.key,p.schema,c),[p.key,p.schema,c]),m=(0,e.useMemo)(()=>({...r,placeholder:a||"",patternLabel:l||""}),[r,a,l]),{propType:g,value:y,setValue:v}=b(f);return e.createElement(d,{propType:g,value:y,setValue:v},e.createElement(Je.Provider,{value:m},e.createElement(lt,{initial:p.create(s||null),propTypeUtil:f,isItemDisabled:h},e.createElement(Ct,{label:n},e.createElement(Ve,io({},u,{newItemIndex:0,ariaLabel:n}))),e.createElement(qe,{isSortable:!1},e.createElement(st,{Icon:ao,Label:ho,actions:e.createElement(e.Fragment,null,o&&e.createElement(dt,null),i&&e.createElement(ct,null),e.createElement(ht,null))})),e.createElement(yt,null,e.createElement(co,null)))))}),ao=()=>e.createElement(e.Fragment,null),co=()=>{const{component:t,props:n={}}=Ke();return e.createElement(vt,{p:1.5},e.createElement(wt,null,e.createElement(t,n)))},uo=(e,t)=>{let n={};const r=t.split("."),o=r.slice(-1)[0];let i=r.reduce((e,t,o)=>(o===r.length-2&&(n=e),e&&"object"==typeof e?e[t]:{}),e);i=i||"";const s=n?.$$type,l=n?.value;return"unit"===o&&"size"===s&&"custom"===l?.unit?l?.size?"":we:i},po=e=>"string"==typeof e?""===e.trim():!!Number.isNaN(e)||(Array.isArray(e)?0===e.length:"object"==typeof e&&null!==e&&0===Object.keys(e).length),ho=({value:t})=>{const{placeholder:n,patternLabel:r,props:i}=Ke(),s=((e,t)=>{const n=fo(e).map(e=>uo(t,e));return!(0===n.length||!n.some(e=>null==e)&&!n.every(po))})(r,t),l=s?n:(a=r,(c=t)?a.replace(so,(e,t)=>{const n=uo(c,t);return"object"!=typeof n||null===n||Array.isArray(n)?Array.isArray(n)?n.join(", "):String(n??""):"name"in n&&n.name?n.name:JSON.stringify(n)}):a);var a,c;const u=((e,t)=>e?"text.disabled":t?"text.tertiary":"text.primary")(!!i?.readOnly,s);return e.createElement(o.Box,{component:"span",color:u},l)},fo=e=>e.match(so)?.map(e=>e.slice(2,-1))||[],mo=e=>{const t={"&":"&","<":"<",">":">","'":"'",'"':"""};return e.replace(/[&<>'"]/g,e=>t[e]||e)};function go(){return go=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},go.apply(null,arguments)}const yo=M((n={})=>{const{value:r,setValue:s,...l}=b(t.keyValuePropTypeUtil),[a,c]=(0,e.useState)(""),[u,p]=(0,e.useState)(""),[h,m]=(0,e.useState)({key:r?.key?.value||"",value:r?.value?.value||""}),g=n.keyName||(0,i.__)("Key","elementor"),y=n.valueName||(0,i.__)("Value","elementor"),{keyHelper:v,valueHelper:w}=n.getHelperText?.(h.key,h.value)||{keyHelper:void 0,valueHelper:void 0},[x,E,k]=(0,e.useMemo)(()=>[n.regexKey?new RegExp(n.regexKey):void 0,n.regexValue?new RegExp(n.regexValue):void 0,n.validationErrorMessage||(0,i.__)("Invalid Format","elementor")],[n.regexKey,n.regexValue,n.validationErrorMessage]);return e.createElement(d,go({},l,{value:r,setValue:(e,n,o)=>{const i=o?.bind;if(!i)return;const l=e[i];if((0,t.isTransformable)(l)&&"dynamic"===l.$$type)return void s({...r,[i]:l});const a=t.stringPropTypeUtil.extract(l);m(e=>({...e,[i]:a})),a&&((e,t)=>{if("key"===t&&x){const t=x.test(e);return c(t?"":k),t}if("value"===t&&E){const t=E.test(e);return p(t?"":k),t}return!0})(a,i)?s({...r,[i]:l}):s({...r,[i]:{value:"",$$type:"string"}})}}),e.createElement(o.Grid,{container:!0,gap:1.5},e.createElement(o.Grid,{item:!0,xs:12,display:"flex",flexDirection:"column"},e.createElement(o.FormLabel,{size:"tiny",sx:{pb:1}},g),e.createElement(f,{bind:"key"},e.createElement(Q,{inputValue:n.escapeHtml?mo(h.key):h.key,error:!!a,helperText:v})),!!a&&e.createElement(o.FormHelperText,{error:!0},a)),e.createElement(o.Grid,{item:!0,xs:12,display:"flex",flexDirection:"column"},e.createElement(o.FormLabel,{size:"tiny",sx:{pb:1}},y),e.createElement(f,{bind:"value"},e.createElement(Q,{inputValue:n.escapeHtml?mo(h.value):h.value,error:!!u,inputDisabled:!!a,helperText:w})),!!u&&e.createElement(o.FormHelperText,{error:!0},u))))}),bo=[{label:(0,i.__)("Center center","elementor"),value:"center center"},{label:(0,i.__)("Center left","elementor"),value:"center left"},{label:(0,i.__)("Center right","elementor"),value:"center right"},{label:(0,i.__)("Top center","elementor"),value:"top center"},{label:(0,i.__)("Top left","elementor"),value:"top left"},{label:(0,i.__)("Top right","elementor"),value:"top right"},{label:(0,i.__)("Bottom center","elementor"),value:"bottom center"},{label:(0,i.__)("Bottom left","elementor"),value:"bottom left"},{label:(0,i.__)("Bottom right","elementor"),value:"bottom right"},{label:(0,i.__)("Custom","elementor"),value:"custom"}],vo=()=>{const n=b(t.positionPropTypeUtil),r=b(t.stringPropTypeUtil),s=!!n.value;return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(o.Grid,{item:!0,xs:12},e.createElement(o.Grid,{container:!0,gap:2,alignItems:"center",flexWrap:"nowrap"},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,(0,i.__)("Object position","elementor"))),e.createElement(o.Grid,{item:!0,xs:6,sx:{overflow:"hidden"}},e.createElement(o.Select,{size:"tiny",disabled:r.disabled,value:(n.value?"custom":r.value)??"",onChange:e=>{const t=e.target.value||null;"custom"===t?n.setValue({x:null,y:null}):r.setValue(t)},fullWidth:!0},bo.map(({label:t,value:n})=>e.createElement(q.MenuListItem,{key:n,value:n??""},t)))))),s&&e.createElement(d,n,e.createElement(o.Grid,{item:!0,xs:12},e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"x"},e.createElement(xe,{startIcon:e.createElement(R.LetterXIcon,{fontSize:"tiny"}),min:-Number.MAX_SAFE_INTEGER}))),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"y"},e.createElement(xe,{startIcon:e.createElement(R.LetterYIcon,{fontSize:"tiny"}),min:-Number.MAX_SAFE_INTEGER})))))))},wo="transform-move",xo="transform-scale",Eo="transform-rotate",ko="transform-skew",So={move:{size:0,unit:"px"},scale:1,rotate:{size:0,unit:"deg"},skew:{size:0,unit:"deg"}},Co={$$type:wo,value:{x:{$$type:"size",value:{size:So.move.size,unit:So.move.unit}},y:{$$type:"size",value:{size:So.move.size,unit:So.move.unit}},z:{$$type:"size",value:{size:So.move.size,unit:So.move.unit}}}},To=t.scaleTransformPropTypeUtil.create({x:t.numberPropTypeUtil.create(So.scale),y:t.numberPropTypeUtil.create(So.scale),z:t.numberPropTypeUtil.create(So.scale)}),Mo=t.rotateTransformPropTypeUtil.create({x:{$$type:"size",value:{size:So.rotate.size,unit:So.rotate.unit}},y:{$$type:"size",value:{size:So.rotate.size,unit:So.rotate.unit}},z:{$$type:"size",value:{size:So.rotate.size,unit:So.rotate.unit}}}),Oo=t.skewTransformPropTypeUtil.create({x:{$$type:"size",value:{size:So.skew.size,unit:So.skew.unit}},y:{$$type:"size",value:{size:So.skew.size,unit:So.skew.unit}}}),Io=({label:t,bind:n,startIcon:r,anchorRef:i,units:s,variant:l="angle"})=>{const a=t.replace(/\s+/g,"-").toLowerCase();return e.createElement(o.Grid,{item:!0,xs:12},e.createElement(wt,{ref:i},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(mn,{htmlFor:a},t)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:n},e.createElement(xe,{anchorRef:i,startIcon:r,units:s,variant:l,min:-Number.MAX_SAFE_INTEGER,isRepeaterControl:!0,id:a})))))};function Po(){return Po=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Po.apply(null,arguments)}const No=[{label:(0,i.__)("Move X","elementor"),bind:"x",startIcon:e.createElement(R.ArrowRightIcon,{fontSize:"tiny"}),units:["px","%","em","rem","vw"]},{label:(0,i.__)("Move Y","elementor"),bind:"y",startIcon:e.createElement(R.ArrowDownSmallIcon,{fontSize:"tiny"}),units:["px","%","em","rem","vh"]},{label:(0,i.__)("Move Z","elementor"),bind:"z",startIcon:e.createElement(R.ArrowDownLeftIcon,{fontSize:"tiny"}),units:["px","%","em","rem","vw","vh"]}],Do=()=>{const n=b(t.moveTransformPropTypeUtil),r=[(0,e.useRef)(null),(0,e.useRef)(null),(0,e.useRef)(null)];return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(d,n,e.createElement(f,{bind:wo},No.map((t,n)=>e.createElement(Io,Po({key:t.bind},t,{anchorRef:r[n],units:t.units,variant:"length"}))))))};function Ao(){return Ao=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ao.apply(null,arguments)}const _o=[{label:(0,i.__)("Rotate X","elementor"),bind:"x",startIcon:e.createElement(R.Arrow360Icon,{fontSize:"tiny"})},{label:(0,i.__)("Rotate Y","elementor"),bind:"y",startIcon:e.createElement(R.Arrow360Icon,{fontSize:"tiny",style:{transform:"scaleX(-1) rotate(-90deg)"}})},{label:(0,i.__)("Rotate Z","elementor"),bind:"z",startIcon:e.createElement(R.RotateClockwiseIcon,{fontSize:"tiny"})}],zo=["deg","rad","grad","turn"],Ro=()=>{const n=b(t.rotateTransformPropTypeUtil),r=[(0,e.useRef)(null),(0,e.useRef)(null),(0,e.useRef)(null)];return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(d,n,e.createElement(f,{bind:Eo},_o.map((t,n)=>e.createElement(Io,Ao({key:t.bind},t,{anchorRef:r[n],units:zo}))))))},$o=({label:t,bind:n,startIcon:r,anchorRef:i})=>e.createElement(o.Grid,{item:!0,xs:12},e.createElement(wt,{ref:i},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(mn,null,t)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:n},e.createElement(fn,{step:.1,placeholder:"1",startIcon:r})))));function Bo(){return Bo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bo.apply(null,arguments)}const Vo=[{label:(0,i.__)("Scale X","elementor"),bind:"x",startIcon:e.createElement(R.ArrowRightIcon,{fontSize:"tiny"})},{label:(0,i.__)("Scale Y","elementor"),bind:"y",startIcon:e.createElement(R.ArrowDownSmallIcon,{fontSize:"tiny"})},{label:(0,i.__)("Scale Z","elementor"),bind:"z",startIcon:e.createElement(R.ArrowDownLeftIcon,{fontSize:"tiny"})}],Lo=()=>{const n=b(t.scaleTransformPropTypeUtil),r=[(0,e.useRef)(null),(0,e.useRef)(null),(0,e.useRef)(null)];return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(d,n,e.createElement(f,{bind:xo},Vo.map((t,n)=>e.createElement($o,Bo({key:t.bind},t,{anchorRef:r[n]}))))))};function Fo(){return Fo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fo.apply(null,arguments)}const jo=[{label:(0,i.__)("Skew X","elementor"),bind:"x",startIcon:e.createElement(R.ArrowRightIcon,{fontSize:"tiny"})},{label:(0,i.__)("Skew Y","elementor"),bind:"y",startIcon:e.createElement(R.ArrowLeftIcon,{fontSize:"tiny",style:{transform:"scaleX(-1) rotate(-90deg)"}})}],Uo=["deg","rad","grad","turn"],Wo=()=>{const n=b(t.skewTransformPropTypeUtil),r=[(0,e.useRef)(null),(0,e.useRef)(null),(0,e.useRef)(null)];return e.createElement(o.Grid,{container:!0,spacing:1.5},e.createElement(d,n,e.createElement(f,{bind:ko},jo.map((t,n)=>e.createElement(Io,Fo({key:t.bind},t,{anchorRef:r[n],units:Uo}))))))};function Go(){return Go=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Go.apply(null,arguments)}const Ho=()=>{const{getTabsProps:n,getTabProps:r,getTabPanelProps:s}=(({move:n,scale:r,rotate:i,skew:s})=>{const{value:l,setValue:a}=b(t.moveTransformPropTypeUtil),{value:c,setValue:u}=b(t.scaleTransformPropTypeUtil),{value:d,setValue:p}=b(t.rotateTransformPropTypeUtil),{value:h,setValue:f}=b(t.skewTransformPropTypeUtil),{openItemIndex:m,items:g}=ze(),{getTabsProps:y,getTabProps:v,getTabPanelProps:w}=(0,o.useTabs)((()=>{switch(!0){case!!c:return xo;case!!d:return Eo;case!!h:return ko;default:return wo}})()),x=(0,e.useRef)({move:n,scale:r,rotate:i,skew:s}),E=(e,t)=>{t&&(x.current[e]=t)},k=(e,t)=>{switch(t){case wo:a(x.current.move),E("scale",c),E("rotate",d),E("skew",h);break;case xo:u(x.current.scale),E("move",l),E("rotate",d),E("skew",h);break;case Eo:p(x.current.rotate),E("move",l),E("scale",c),E("skew",h);break;case ko:f(x.current.skew),E("move",l),E("scale",c),E("rotate",d)}return y().onChange(e,t)};return{getTabProps:e=>{return{...v(e),disabled:(t=e,!!g.find(({item:{$$type:e}},n)=>t===e&&n!==m))};var t},getTabPanelProps:w,getTabsProps:()=>({...y(),onChange:k})}})({move:Co.value,scale:To.value,rotate:Mo.value,skew:Oo.value});return e.createElement(vt,null,e.createElement(o.Box,{sx:{width:"100%"}},e.createElement(o.Box,{sx:{borderBottom:1,borderColor:"divider"}},e.createElement(o.Tabs,Go({size:"small",variant:"fullWidth",sx:{"& .MuiTab-root":{minWidth:"62px"}}},n(),{"aria-label":(0,i.__)("Transform","elementor")}),e.createElement(o.Tab,Go({label:(0,i.__)("Move","elementor")},r(wo))),e.createElement(o.Tab,Go({label:(0,i.__)("Scale","elementor")},r(xo))),e.createElement(o.Tab,Go({label:(0,i.__)("Rotate","elementor")},r(Eo))),e.createElement(o.Tab,Go({label:(0,i.__)("Skew","elementor")},r(ko))))),e.createElement(o.TabPanel,Go({sx:{p:1.5}},s(wo)),e.createElement(Do,null)),e.createElement(o.TabPanel,Go({sx:{p:1.5}},s(xo)),e.createElement(Lo,null)),e.createElement(o.TabPanel,Go({sx:{p:1.5}},s(Eo)),e.createElement(Ro,null)),e.createElement(o.TabPanel,Go({sx:{p:1.5}},s(ko)),e.createElement(Wo,null))))},qo=({value:t})=>{switch(t.$$type){case wo:return e.createElement(R.ArrowsMaximizeIcon,{fontSize:"tiny"});case xo:return e.createElement(R.ArrowAutofitHeightIcon,{fontSize:"tiny"});case Eo:return e.createElement(R.RotateClockwise2Icon,{fontSize:"tiny"});case ko:return e.createElement(R.SkewXIcon,{fontSize:"tiny"});default:return null}},Jo=(e,t)=>Object.values(e).map(e=>{if("scale"===t)return e?.value||So[t];const n=So[t],r=e?.value?.size??n.size,o=e?.value?.unit??n.unit;return"custom"===o?r||we:`${r}${o}`}).join(", "),Ko=t=>{const{$$type:n,value:r}=t.value;switch(n){case wo:return e.createElement(Yo,{label:(0,i.__)("Move","elementor"),value:Jo(r,"move")});case xo:return e.createElement(Yo,{label:(0,i.__)("Scale","elementor"),value:Jo(r,"scale")});case Eo:return e.createElement(Yo,{label:(0,i.__)("Rotate","elementor"),value:Jo(r,"rotate")});case ko:return e.createElement(Yo,{label:(0,i.__)("Skew","elementor"),value:Jo(r,"skew")});default:return""}},Yo=({label:t,value:n})=>e.createElement(o.Box,{component:"span"},t,": ",n),Xo=["px","%","em","rem"],Zo={label:(0,i.__)("Perspective","elementor"),bind:"perspective",units:["px","em","rem","vw","vh"]},Qo=[{label:(0,i.__)("Origin X","elementor"),bind:"x",units:Xo},{label:(0,i.__)("Origin Y","elementor"),bind:"y",units:Xo}],ei=()=>e.createElement(o.Stack,{direction:"column",spacing:1.5},e.createElement(E,null,(0,i.__)("Children perspective","elementor")),e.createElement(ti,null),e.createElement(ni,null)),ti=()=>e.createElement(f,{bind:"perspective"},e.createElement(oi,{control:Zo,key:Zo.bind})),ni=()=>e.createElement(f,{bind:"perspective-origin"},e.createElement(ri,null)),ri=()=>{const n=b(t.perspectiveOriginPropTypeUtil);return e.createElement(d,n,Qo.map(t=>e.createElement(f,{bind:t.bind,key:t.bind},e.createElement(oi,{control:t}))))},oi=({control:t})=>{const n=e.useRef(null);return e.createElement(wt,{ref:n},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,t.label)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(xe,{variant:"length",units:t.units,anchorRef:n,disableCustom:!0})))},ii=["px","%","em","rem"],si=ii.filter(e=>"%"!==e),li=[{label:(0,i.__)("Origin X","elementor"),bind:"x",units:ii},{label:(0,i.__)("Origin Y","elementor"),bind:"y",units:ii},{label:(0,i.__)("Origin Z","elementor"),bind:"z",units:si}],ai=()=>e.createElement(o.Stack,{direction:"column",spacing:1.5},e.createElement(E,null,(0,i.__)("Transform","elementor")),li.map(t=>e.createElement(ci,{control:t,key:t.bind}))),ci=({control:n})=>{const r=b(t.transformOriginPropTypeUtil),i=e.useRef(null);return e.createElement(d,r,e.createElement(f,{bind:n.bind},e.createElement(wt,{ref:i},e.createElement(o.Grid,{item:!0,xs:6},e.createElement(E,null,n.label)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(xe,{variant:"length",units:n.units,anchorRef:i,disableCustom:!0})))))};function ui(){return ui=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ui.apply(null,arguments)}const di=({popupState:t,anchorRef:n})=>{const r=(0,o.bindPopover)({...t,anchorEl:n.current??void 0});return e.createElement(o.Popover,ui({disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"left"},slotProps:{paper:{sx:{width:(n.current?.offsetWidth||0)-6+"px",mt:.5}}}},r),e.createElement(q.PopoverHeader,{title:(0,i.__)("Transform settings","elementor"),onClose:t.close,icon:e.createElement(R.AdjustmentsIcon,{fontSize:"tiny"})}),e.createElement(o.Divider,null),e.createElement(vt,{sx:{px:2,py:1.5}},e.createElement(f,{bind:"transform-origin"},e.createElement(ai,null)),e.createElement(o.Box,{sx:{my:.5}},e.createElement(o.Divider,null)),e.createElement(ei,null)))};function pi(){return pi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pi.apply(null,arguments)}const hi="tiny",fi=M(()=>{const n=b(t.transformPropTypeUtil),r=(0,e.useRef)(null),i=(0,o.usePopupState)({variant:"popover"});return e.createElement(d,n,e.createElement(di,{popupState:i,anchorRef:r}),e.createElement(f,{bind:"transform-functions"},e.createElement(gi,{headerRef:r,propType:n.propType,popupState:i})))}),mi=e.createElement(o.Box,{component:"span","aria-label":void 0,sx:{display:"flex",gap:.5,p:2,width:320,borderRadius:1}},e.createElement(R.InfoCircleFilledIcon,{sx:{color:"secondary.main"}}),e.createElement(o.Typography,{variant:"body2",color:"text.secondary",fontSize:"14px"},(0,i.__)("You can use each kind of transform only once per element.","elementor"))),gi=({headerRef:n,propType:r,popupState:o})=>{const s=b(t.transformFunctionsPropTypeUtil),l=[Co,To,Mo,Oo],{value:a,bind:c}=s,u=()=>l.find(e=>!a?.some(t=>t.$$type===e.$$type)),p=!u();return e.createElement(d,s,e.createElement(lt,{initial:u()??Co,propTypeUtil:t.transformFunctionsPropTypeUtil},e.createElement(Ct,{label:(0,i.__)("Transform","elementor"),adornment:()=>e.createElement(St,{customContext:{path:["transform"],propType:r}}),ref:n},e.createElement(yi,{popupState:o,repeaterBindKey:c}),e.createElement(Ve,{disabled:p,tooltipContent:mi,enableTooltip:p,ariaLabel:"transform"})),e.createElement(qe,null,e.createElement(st,{Icon:qo,Label:Ko,actions:e.createElement(e.Fragment,null,e.createElement(ct,null),e.createElement(ht,null))})),e.createElement(yt,null,e.createElement(Ho,null))))},yi=({popupState:t,repeaterBindKey:n})=>{const{bind:r}=b(),s=(0,i.__)("Transform settings","elementor");return r!==n?null:e.createElement(o.Tooltip,{title:s,placement:"top"},e.createElement(o.IconButton,pi({size:hi,"aria-label":s},(0,o.bindTrigger)(t)),e.createElement(R.AdjustmentsIcon,{fontSize:hi})))},bi=M(({selectionLabel:n,sizeLabel:r,selectionConfig:i,sizeConfigMap:s,isRepeaterControl:l=!1})=>{const{value:a,setValue:c,propType:u}=b(t.selectionSizePropTypeUtil),p=(0,e.useRef)(null),h=r.replace(/\s+/g,"-").toLowerCase(),m=(0,e.useMemo)(()=>{switch(a.selection.$$type){case"key-value":return s[a?.selection?.value.value.value||""];case"string":return s[a?.selection?.value||""];default:return null}},[a,s]),g=i.component;return e.createElement(d,{value:a,setValue:c,propType:u},e.createElement(o.Grid,{container:!0,spacing:1.5,ref:p},e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",alignItems:"center"}},e.createElement(E,null,n)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"selection"},e.createElement(g,i.props))),m&&e.createElement(e.Fragment,null,e.createElement(o.Grid,{item:!0,xs:6,sx:{display:"flex",alignItems:"center"}},e.createElement(E,{htmlFor:h},r)),e.createElement(o.Grid,{item:!0,xs:6},e.createElement(f,{bind:"size"},e.createElement(xe,{anchorRef:p,variant:m.variant,units:m.units,defaultUnit:m.defaultUnit,id:h,isRepeaterControl:l}))))))}),vi={selection:{$$type:"key-value",value:{key:{value:(0,i.__)("All properties","elementor"),$$type:"string"},value:{value:"all",$$type:"string"}}},size:{$$type:"size",value:{size:200,unit:"ms"}}},wi=[{label:(0,i.__)("Default","elementor"),type:"category",properties:[{label:(0,i.__)("All properties","elementor"),value:"all"}]}],xi=wi.map(e=>({label:e.label,items:e.properties.map(e=>e.label)}));var Ei=window.elementorV2.mixpanel;const ki={eventName:"click_added_transition",location:"V4 Style Tab",secondaryLocation:"Transition control",trigger:"click"};function Si(){return Si=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Si.apply(null,arguments)}function Ci(e){if(!e?.value)return null;for(const t of wi)for(const n of t.properties)if(n.value===e.value)return n;return null}const Ti=(e,t)=>t.filter(t=>t!==e.key.value),Mi=({recentlyUsedList:n=[],disabledItems:r=[]})=>{const{value:s,setValue:l}=b(t.keyValuePropTypeUtil),{key:{value:a}}=s,c=(0,e.useRef)(null),u=(0,o.usePopupState)({variant:"popover"});return e.createElement(o.Box,{ref:c},e.createElement(G,null,e.createElement(o.UnstableTag,Si({variant:"outlined",label:a,endIcon:e.createElement(R.ChevronDownIcon,{fontSize:"tiny"})},(0,o.bindTrigger)(u),{fullWidth:!0}))),e.createElement(o.Popover,Si({disablePortal:!0,disableScrollLock:!0},(0,o.bindPopover)(u),{anchorReference:"anchorPosition",anchorPosition:(()=>{if(!c.current)return;const e=c.current.getBoundingClientRect();return{top:e.top,left:e.right+36}})(),anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}}),e.createElement(kn,{itemsList:(()=>{const e=n.map(e=>Ci({value:e,$$type:"string"})?.label).filter(e=>!!e),t=xi.map(t=>({...t,items:t.items.filter(t=>!e.includes(t))}));if(0===e.length)return t;const[r,...o]=t;return[r,{label:(0,i.__)("Recently Used","elementor"),items:e},...o]})(),selectedItem:a,onItemChange:e=>{const t=(e=>{for(const t of wi){const n=t.properties.find(t=>t.label===e);if(n)return{key:{value:n.label,$$type:"string"},value:{value:n.value,$$type:"string"}}}return null})(e);t&&(l(t),u.close())},onClose:u.close,sectionWidth:268,title:(0,i.__)("Transition Property","elementor"),icon:R.VariationsIcon,disabledItems:Ti(s,r)})))},Oi={variant:"time",units:["s","ms"],defaultUnit:"ms"},Ii=(0,t.createArrayPropUtils)(t.selectionSizePropTypeUtil.key,t.selectionSizePropTypeUtil.schema,"transition");De.subscribe("transition-item-added",e=>{const t=e,n=t?.itemValue?.selection?.value?.value?.value,r=(0,Pn.getSelectedElements)(),o=r[0]?.type??null;(0,Ei.trackEvent)({transition_type:n??"unknown",...ki,widget_type:o})});const Pi=(e,t)=>({selectionLabel:(0,i.__)("Type","elementor"),sizeLabel:(0,i.__)("Duration","elementor"),selectionConfig:{component:Mi,props:{recentlyUsedList:e,disabledItems:t}},isRepeaterControl:!0,sizeConfigMap:{...wi.reduce((e,t)=>(t.properties.forEach(t=>{e[t.value]=Oi}),e),{})}}),Ni=e=>{const t=Ci(e.value.selection.value?.value);return!!t&&!!t.isDisabled},Di=(e,n)=>({propTypeUtil:t.selectionSizePropTypeUtil,component:bi,props:Pi(e,n),isItemDisabled:Ni}),Ai=(e,t)=>(e??[]).some(e=>e?.value?.selection?.value?.value?.value===t.value),_i=(e=[])=>{if(!e?.length)return vi;for(const t of wi)for(const n of t.properties)if(!Ai(e,n))return{...vi,selection:{$$type:"key-value",value:{key:{value:n.label,$$type:"string"},value:{value:n.value,$$type:"string"}}}};return vi},zi=e.createElement(o.Alert,{sx:{width:280,gap:.5},color:"secondary",icon:e.createElement(R.InfoCircleFilledIcon,null)},e.createElement(o.AlertTitle,null,(0,i.__)("Transitions","elementor")),e.createElement(o.Box,{component:"span"},e.createElement(o.Typography,{variant:"body2"},(0,i.__)("Switch to 'Normal' state to add a transition.","elementor")))),Ri=M(({recentlyUsedListGetter:t,currentStyleState:n})=>{const r=null===n,[o,s]=(0,e.useState)([]),{value:l,setValue:a}=b(Ii),c=(0,e.useMemo)(()=>((e=[])=>{const t=(e||[]).map(e=>e.value?.selection?.value?.key?.value);return wi.forEach(e=>{const n=e.properties.filter(e=>e.isDisabled&&!t.includes(e.label)).map(e=>e.label);t.push(...n)}),t})(l),[l]),u=(0,e.useMemo)(()=>{const e=new Set;return wi.forEach(t=>{t.properties.forEach(t=>e.add(t.value))}),e},[]);(0,e.useEffect)(()=>{if(!l||0===l.length)return;const e=l.filter(e=>{const t=e?.value?.selection?.value?.value?.value??"";return u.has(t)});e.length!==l.length&&a(e)},[u]),(0,e.useEffect)(()=>{t().then(s)},[t]);const d=(0,e.useMemo)(()=>((e=[])=>!!e?.length&&wi.every(t=>t.properties.every(t=>t.isDisabled||!!e?.find(e=>e.value?.selection?.value?.value?.value===t.value))))(l),[l]),p=!r||d;return e.createElement(lo,{label:(0,i.__)("Transitions","elementor"),repeaterLabel:(0,i.__)("Transitions","elementor"),patternLabel:"${value.selection.value.key.value}: ${value.size.value.size}${value.size.value.unit}",placeholder:(0,i.__)("Empty Transition","elementor"),showDuplicate:!1,showToggle:!0,initialValues:_i(l),childControlConfig:Di(o,c),propKey:"transition",addItemTooltipProps:{disabled:p,enableTooltip:!r,tooltipContent:zi}})});var $i=n(9091),Bi=n.n($i);function Vi(){return Vi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vi.apply(null,arguments)}const Li=M(({inputDisabled:n})=>{const{value:r,setValue:i,...s}=b(t.DateTimePropTypeUtil),l=(e,n)=>{const o=n.bind,s=e[o];if((0,t.isTransformable)(s))return i({...r,[o]:s});let l="";if(s){const e=s;l="date"===o?e.format("YYYY-MM-DD"):e.format("HH:mm")}i({...r,[o]:{$$type:"string",value:l}})};return e.createElement(d,Vi({},s,{value:r,setValue:i}),e.createElement(G,null,e.createElement(o.LocalizationProvider,null,e.createElement(o.Box,{display:"flex",gap:1,alignItems:"center"},e.createElement(f,{bind:"date"},e.createElement(o.DatePicker,{value:(e=>{if(!e)return null;const t=Bi()(e);return t&&"function"==typeof t.isValid&&t.isValid()?t:null})(t.stringPropTypeUtil.extract(r?.date)),onChange:e=>l({date:e},{bind:"date"}),disabled:n,slotProps:{textField:{size:"tiny"},openPickerButton:{size:"tiny"},openPickerIcon:{fontSize:"tiny"}}})),e.createElement(f,{bind:"time"},e.createElement(o.TimePicker,{value:(e=>{if(!e)return null;const[t,n]=e.split(":"),r=Number.parseInt(t??"",10),o=Number.parseInt(n??"",10);return Number.isNaN(r)||Number.isNaN(o)?null:Bi()().hour(r).minute(o).second(0).millisecond(0)})(t.stringPropTypeUtil.extract(r?.time)),onChange:e=>l({time:e},{bind:"time"}),disabled:n,slotProps:{textField:{size:"tiny"},openPickerButton:{size:"tiny"},openPickerIcon:{fontSize:"tiny"}}}))))))});function Fi(e){this.content=e}Fi.prototype={constructor:Fi,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new Fi(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Fi(n)},addToStart:function(e,t){return new Fi([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Fi(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new Fi(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Fi.from(e)).size?new Fi(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Fi.from(e)).size?new Fi(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Fi.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Fi.from=function(e){if(e instanceof Fi)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Fi(t)};var ji=Fi;function Ui(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=Ui(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Wi(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),l=t.child(--i),a=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let e=0,t=Math.min(s.text.length,l.text.length);for(;e<t&&s.text[s.text.length-e-1]==l.text[l.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let e=Wi(s.content,l.content,n-1,r-1);if(e)return e}n-=a,r-=a}else n-=a,r-=a}}class Gi{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=a},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new Gi(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=l}return new Gi(n,r)}cutByIndex(e,t){return e==t?Gi.empty:0==e&&t==this.content.length?this:new Gi(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new Gi(r,o)}addToStart(e){return new Gi([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Gi(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,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ui(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Wi(this,e,t,n)}findIndex(e){if(0==e)return qi(0,e);if(e==this.size)return qi(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?qi(t+1,r):qi(t,n);n=r}}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 Gi.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Gi(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Gi.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new Gi(t||e,n)}static from(e){if(!e)return Gi.empty;if(e instanceof Gi)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Gi([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Gi.empty=new Gi([],0);const Hi={index:0,offset:0};function qi(e,t){return Hi.index=e,Hi.offset=t,Hi}function Ji(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Ji(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ji(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Ki{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}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&&Ji(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 n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Ki.none;if(e instanceof Ki)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Ki.none=[];class Yi extends Error{}class Xi{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Qi(this.content,e+this.openStart,t);return n&&new Xi(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Xi(Zi(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 Xi.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Xi(Gi.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Xi(e,n,r)}}function Zi(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(o==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Zi(i.content,t-o-1,n-o-1)))}function Qi(e,t,n,r){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Qi(s.content,t-i-1,n,s);return l&&e.replaceChild(o,s.copy(l))}function es(e,t,n){if(n.openStart>e.depth)throw new Yi("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Yi("Inconsistent open depths");return ts(e,t,n,0)}function ts(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=ts(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Gi.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return ls(i,as(e,o,s,t,r))}{let r=e.parent,o=r.content;return ls(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return ls(i,cs(e,t,r))}function ns(e,t){if(!t.type.compatibleContent(e.type))throw new Yi("Cannot join "+t.type.name+" onto "+e.type.name)}function rs(e,t,n){let r=e.node(n);return ns(r,t.node(n)),r}function is(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function ss(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(is(e.nodeAfter,r),i++));for(let e=i;e<s;e++)is(o.child(e),r);t&&t.depth==n&&t.textOffset&&is(t.nodeBefore,r)}function ls(e,t){return e.type.checkContent(t),e.copy(t)}function as(e,t,n,r,o){let i=e.depth>o&&rs(e,t,o+1),s=r.depth>o&&rs(n,r,o+1),l=[];return ss(null,e,o,l),i&&s&&t.index(o)==n.index(o)?(ns(i,s),is(ls(i,as(e,t,n,r,o+1)),l)):(i&&is(ls(i,cs(e,t,o+1)),l),ss(t,n,o,l),s&&is(ls(s,cs(n,r,o+1)),l)),ss(r,null,o,l),new Gi(l)}function cs(e,t,n){let r=[];return ss(null,e,n,r),e.depth>n&&is(ls(rs(e,t,n+1),cs(e,t,n+1)),r),ss(t,null,n,r),new Gi(r)}Xi.empty=new Xi(Gi.empty,0,0);class us{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Ki.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new fs(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new us(t,n,o)}static resolveCached(e,t){let n=hs.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else hs.set(e,n=new ds);let r=n.elts[n.i]=us.resolve(e,t);return n.i=(n.i+1)%ps,r}}class ds{constructor(){this.elts=[],this.i=0}}const ps=12,hs=new WeakMap;class fs{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ms=Object.create(null);class gs{constructor(e,t,n,r=Ki.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Gi.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Ji(this.attrs,t||e.defaultAttrs||ms)&&Ki.sameSet(this.marks,n||Ki.none)}copy(e=null){return e==this.content?this:new gs(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new gs(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Xi.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new Xi(l,r.depth-i,o.depth-i)}replace(e,t,n){return es(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return us.resolveCached(this,e)}resolveNoCache(e){return us.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),bs(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,n=Gi.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}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=Ki.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Ki.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=Gi.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}gs.prototype.text=void 0;class ys extends gs{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):bs(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 ys(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ys(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&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 bs(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class vs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new ws(e,t);if(null==n.next)return vs.empty;let r=xs(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);Ms(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new vs(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(Ts);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(Ms(e,0))}(function(e){let t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,i)),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(e(t.expr,i),s),o(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let r=0;r<t.min;r++){let r=n();o(e(t.expr,s),r),s=r}if(-1==t.max)o(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();r(s,i),o(e(t.expr,s),i),s=i}return[r(s)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],i);if(r==t.exprs.length-1)return s;o(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(i,s){let l=i.matchFragment(e,n);if(l&&(!t||l.validEnd))return Gi.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.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=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}vs.empty=new vs(!0);class ws{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 xs(e){let t=[];do{t.push(Es(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Es(e){let t=[];do{t.push(ks(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function ks(e){let t=function(e){if(e.eat("(")){let t=xs(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}return 0==o.length&&e.err("No node type or group '"+t+"' found"),o}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Cs(e,t)}return t}function Ss(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Cs(e,t){let n=Ss(e),r=n;return e.eat(",")&&(r="}"!=e.next?Ss(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Ts(e,t){return t-e}function Ms(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Ts)}function Os(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Is(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function Ps(e,t,n,r){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Ns(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new As(e,r,t[r]);return n}class Ds{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Ns(e,n.attrs),this.defaultAttrs=Os(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==vs.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:Is(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new gs(this,this.computeAttrs(e),Gi.from(t),Ki.setFrom(n))}createChecked(e=null,t,n){return t=Gi.from(t),this.checkContent(t),new gs(this,this.computeAttrs(e),t,Ki.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Gi.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(Gi.empty,!0);return o?new gs(this,e,t.append(o),Ki.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ps(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Ki.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new Ds(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class As{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class _s{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ns(e,r.attrs),this.excluded=null;let o=Os(this.attrs);this.instance=o?new Ki(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ki(this,Is(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new _s(e,r++,t,o)),n}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){Ps(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zs{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=ji.from(e.nodes),t.marks=ji.from(e.marks||{}),this.nodes=Ds.compile(this.spec.nodes,this),this.marks=_s.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=vs.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?Rs(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Rs(this,n.split(" "))}this.nodeFromJSON=e=>gs.fromJSON(this,e),this.markFromJSON=e=>Ki.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Ds))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ys(n,n.defaultAttrs,e,Ki.setFrom(t))}mark(e,t){return"string"==typeof e&&(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 Rs(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class $s{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Us(this,t,!1);return n.addAll(e,Ki.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Us(this,t,!0);return n.addAll(e,Ki.none,t.from,t.to),Xi.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ws(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Gs(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Gs(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $s(e,$s.schemaRules(e)))}}const Bs={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},Vs={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ls={ol:!0,ul:!0};function Fs(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class js{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Ki.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Gi.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Gi.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Gi.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&&!Bs.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Us{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=Fs(null,t.preserveWhitespace,0)|(n?4:0);r=o?new js(o.type,o.attrs,Ki.none,!0,t.topMatch||o.type.contentMatch,i):new js(n?null:e.schema.topNodeType,null,Ki.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Ls.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Ls.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Vs.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(Bs.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],l=s.findWrapping(e);if(l&&(!r||r.length>l.length+i)&&(r=l,o=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Ki.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):Hs(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Fs(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=Ki.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):Hs(t.type,e))||(l=t.addToSet(l),!1)),this.nodes.push(new js(e,t,l,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Ws(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Gs(e){let t={};for(let n in e)t[n]=e[n];return t}function Hs(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class qs{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Ks(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Xs(Ks(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Xs(Ks(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Xs(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new qs(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Js(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Js(e.marks)}}function Js(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Ks(e){return e.document||window.document}const Ys=new WeakMap;function Xs(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=function(e){let t=Ys.get(e);return void 0===t&&Ys.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],u=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){u=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let o=u;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:o}=Xs(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}const Zs=Math.pow(2,16);function Qs(e,t){return e+t*Zs}function el(e){return 65535&e}class tl{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class nl{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&nl.empty)return nl.empty}recover(e){let t=0,n=el(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Zs}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[s+o],c=this.ranges[s+i],u=l+a;if(e<=u){let o=l+r+((a?e==l?-1:e==u?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?l:u)?null:Qs(s/3,e-l),d=e==l?2:e==u?1:4;return(t<0?e!=l:e!=u)&&(d|=8),new tl(o,d,i)}r+=c-a}return n?e+r:new tl(e+r,0,null)}touches(e,t){let n=0,r=el(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+o];if(e<=s+l&&t==3*r)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new nl(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?nl.empty:new nl(e<0?[0,-e,0]:[0,0,e])}}nl.empty=new nl([]);class rl{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new rl(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),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new rl;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new tl(e,r,null)}}const ol=Object.create(null);class il{getMap(){return nl.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ol[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ol)throw new RangeError("Duplicate use of step JSON ID "+e);return ol[e]=t,t.prototype.jsonID=e,t}}class sl{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new sl(e,null)}static fail(e){return new sl(null,e)}static fromReplace(e,t,n,r){try{return sl.ok(e.replace(t,n,r))}catch(e){if(e instanceof Yi)return sl.fail(e.message);throw e}}}function ll(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(ll(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return Gi.fromArray(r)}class al extends il{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Xi(ll(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return sl.fromReplace(e,this.from,this.to,o)}invert(){return new cl(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new al(t.pos,n.pos,this.mark)}merge(e){return e instanceof al&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new al(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new al(t.from,t.to,e.markFromJSON(t.mark))}}il.jsonID("addMark",al);class cl extends il{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Xi(ll(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return sl.fromReplace(e,this.from,this.to,n)}invert(){return new al(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new cl(t.pos,n.pos,this.mark)}merge(e){return e instanceof cl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cl(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new cl(t.from,t.to,e.markFromJSON(t.mark))}}il.jsonID("removeMark",cl);class ul extends il{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sl.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return sl.fromReplace(e,this.pos,this.pos+1,new Xi(Gi.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new ul(this.pos,t.marks[n]);return new ul(this.pos,this.mark)}}return new dl(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ul(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ul(t.pos,e.markFromJSON(t.mark))}}il.jsonID("addNodeMark",ul);class dl extends il{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sl.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return sl.fromReplace(e,this.pos,this.pos+1,new Xi(Gi.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ul(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dl(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new dl(t.pos,e.markFromJSON(t.mark))}}il.jsonID("removeNodeMark",dl);class pl extends il{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&fl(e,this.from,this.to)?sl.fail("Structure replace would overwrite content"):sl.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new nl([this.from,this.to-this.from,this.slice.size])}invert(e){return new pl(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new pl(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof pl)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Xi.empty:new Xi(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new pl(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Xi.empty:new Xi(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new pl(this.from,this.to+(e.to-e.from),t,this.structure)}}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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new pl(t.from,t.to,Xi.fromJSON(e,t.slice),!!t.structure)}}il.jsonID("replace",pl);class hl extends il{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(fl(e,this.from,this.gapFrom)||fl(e,this.gapTo,this.to)))return sl.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return sl.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?sl.fromReplace(e,this.from,this.to,n):sl.fail("Content does not fit in gap")}getMap(){return new nl([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 hl(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),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new hl(t.pos,n.pos,r,o,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("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new hl(t.from,t.to,t.gapFrom,t.gapTo,Xi.fromJSON(e,t.slice),t.insert,!!t.structure)}}function fl(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function ml(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],l=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),c=l+a.nodeSize,u=r.matchType(a.type);if(u){r=u;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new cl(l,c,a.marks[t]));if(o&&a.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(a.text);)t||(t=new Xi(Gi.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new pl(l+e.index,l+e.index+e[0].length,t))}}else s.push(new pl(l,c,Xi.empty));l=c}if(!r.validEnd){let t=r.fillBefore(Gi.empty,!0);e.replace(l,l,new Xi(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function gl(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function yl(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,l=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,l,t))return n;if(0==n||i.type.spec.isolating||!gl(i,s,l))break;s&&(r=1),l<i.childCount&&(o=1)}return null}function bl(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(vl).concat({type:t,attrs:n}).concat(i.map(vl)):null}function vl(e){return{type:e,attrs:null}}function wl(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function xl(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function El(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function kl(e,t){let n=e.resolve(t),r=n.index();return Sl(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Sl(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Cl(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&Sl(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function Tl(e,t,n=t,r=Xi.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Ml(o,i,r)?new pl(t,n,r):new Ol(o,i,r).fit()}function Ml(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}il.jsonID("replaceAround",hl);class Ol{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Gi.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Gi.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let l=new Xi(o,i,s);return e>-1?new hl(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new pl(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Nl(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:l}=this.frontier[e],a=null;if(1==t&&(o?l.matchType(o.type)||(a=l.fillBefore(Gi.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:a};if(2==t&&o&&(i=l.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&l.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Nl(e,t);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new Xi(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Nl(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Xi(Il(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Xi(Il(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-e,a=0,c=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));u=u.matchFragment(r)}let p=s.size+e-(i.content.size-i.openEnd);for(;a<s.childCount;){let e=s.child(a),t=u.matchType(e.type);if(!t)break;a++,(a>1||0==l||e.content.size)&&(u=t,c.push(Dl(e.mark(d.allowedMarks(e.marks)),1==a?l:0,a==s.childCount?p:-1)))}let h=a==s.childCount;h||(p=-1),this.placed=Pl(this.placed,t,Gi.from(c)),this.frontier[t].match=u,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Xi.empty:new Xi(Il(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new Xi(Il(i.content,e,a),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Al(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Al(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Al(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?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=Pl(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Pl(this.placed,this.depth,Gi.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Gi.empty,!0);e.childCount&&(this.placed=Pl(this.placed,this.frontier.length,e))}}function Il(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Il(e.firstChild.content,t-1,n)))}function Pl(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Pl(e.lastChild.content,t-1,n)))}function Nl(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Dl(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Dl(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Gi.empty,!0)))),e.copy(r)}function Al(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function _l(e){return e.spec.defining||e.spec.definingForContent}function zl(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(zl(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Gi.empty,!0))}return e}function Rl(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class $l extends il{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return sl.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return sl.fromReplace(e,this.pos,this.pos+1,new Xi(Gi.from(r),0,t.isLeaf?0:1))}getMap(){return nl.empty}invert(e){return new $l(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 $l(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new $l(t.pos,t.attr,t.value)}}il.jsonID("attr",$l);class Bl extends il{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return sl.ok(n)}getMap(){return nl.empty}invert(e){return new Bl(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("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Bl(t.attr,t.value)}}il.jsonID("docAttr",Bl);let Vl=class extends Error{};Vl=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Vl.prototype=Object.create(Error.prototype)).constructor=Vl,Vl.prototype.name="TransformError";class Ll{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new rl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vl(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Xi.empty){let r=Tl(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Xi(Gi.from(n),0,0))}delete(e,t){return this.replace(e,t,Xi.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Ml(o,i,r))return e.step(new pl(t,n,r));let s=Rl(o,i);0==s[s.length-1]&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:o.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e],n=_l(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let l=(t+u+1)%(r.openStart+1),d=c[l];if(d)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],u=!0;c<0&&(u=!1,c=-c);let p=o.node(c-1),h=o.index(c-1);if(p.canReplaceWith(h,h,d.type,d.marks))return e.replace(o.before(c),u?i.after(c):n,new Xi(zl(r.content,0,r.openStart,l),l,r.openEnd))}}let d=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,r),!(e.steps.length>d));l--){let e=s[l];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Xi(Gi.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=Rl(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=Gi.empty,d=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Gi.from(r.node(e).copy(u)),d++):a--;let p=Gi.empty,h=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,p=Gi.from(o.node(e).copy(p)),h++):c++;e.step(new hl(a,c,s,l,new Xi(u.append(p),d,h),u.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let l=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);xl(e,r.node(),r.before(),l)}s.inlineContent&&ml(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new pl(c,a.map(t+n,-1),Xi.empty,!0)),!0===r){let t=e.doc.resolve(c);wl(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=Gi.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Gi.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new hl(o,i,o,i,new Xi(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&xl(e,t,n,i),ml(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let l=e.mapping.slice(i),a=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new hl(a,c,a+1,c-1,new Xi(Gi.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&wl(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new hl(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Xi(Gi.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new $l(e,t,n)),this}setDocAttribute(e,t){return this.step(new Bl(e,t)),this}addNodeMark(e,t){return this.step(new ul(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Ki)t.isInSet(n.marks)&&this.step(new dl(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new dl(e,r)),o=r.removeFromSet(o);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=Gi.empty,s=Gi.empty;for(let e=o.depth,t=o.depth-n,l=n-1;e>t;e--,l--){i=Gi.from(o.node(e).copy(i));let t=r&&r[l];s=Gi.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new pl(t,t,new Xi(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,c)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),d=Math.min(a+e.nodeSize,n),p=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(p)||(o&&o.to==c&&o.mark.eq(u[e])?o.to=d:s.push(o=new cl(c,d,u[e])));i&&i.to==c?i.to=d:l.push(i=new al(c,d,r))}}),s.forEach(t=>e.step(t)),l.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let l=null;if(r instanceof _s){let t,n=e.marks;for(;t=r.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(l=[r]):l=e.marks;if(l&&l.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&a.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:a,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new cl(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return ml(this,e,t,n),this}}const Fl=Object.create(null);class jl{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ul(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=Xi.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(a.pos),s?Xi.empty:t),0==s&&Ql(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),Ql(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Hl(e):Zl(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Zl(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Zl(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Yl(e.node(0))}static atStart(e){return Zl(e,e,0,0,1)||new Yl(e)}static atEnd(e){return Zl(e,e,e.content.size,e.childCount,-1)||new Yl(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Fl[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Fl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Hl.between(this.$anchor,this.$head).getBookmark()}}jl.prototype.visible=!0;class Ul{constructor(e,t){this.$from=e,this.$to=t}}let Wl=!1;function Gl(e){Wl||e.parent.inlineContent||(Wl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Hl extends jl{constructor(e,t=e){Gl(e),Gl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return jl.near(n);let r=e.resolve(t.map(this.anchor));return new Hl(r.parent.inlineContent?r:n,n)}replace(e,t=Xi.empty){if(super.replace(e,t),t==Xi.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Hl&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ql(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Hl(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=jl.findFrom(t,n,!0)||jl.findFrom(t,-n,!0);if(!e)return jl.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(jl.findFrom(e,-n,!0)||jl.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Hl(e,t)}}jl.jsonID("text",Hl);class ql{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ql(e.map(this.anchor),e.map(this.head))}resolve(e){return Hl.between(e.resolve(this.anchor),e.resolve(this.head))}}class Jl extends jl{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?jl.near(o):new Jl(o)}content(){return new Xi(Gi.from(this.node),0,0)}eq(e){return e instanceof Jl&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Kl(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Jl(e.resolve(t.anchor))}static create(e,t){return new Jl(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Jl.prototype.visible=!1,jl.jsonID("node",Jl);class Kl{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new ql(n,n):new Kl(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Jl.isSelectable(n)?new Jl(t):jl.near(t)}}class Yl extends jl{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Xi.empty){if(t==Xi.empty){e.delete(0,e.doc.content.size);let t=jl.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Yl(e)}map(e){return new Yl(e)}eq(e){return e instanceof Yl}getBookmark(){return Xl}}jl.jsonID("all",Yl);const Xl={map(){return this},resolve(e){return new Yl(e)}};function Zl(e,t,n,r,o,i=!1){if(t.inlineContent)return Hl.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Jl.isSelectable(r))return Jl.create(e,n-(o<0?r.nodeSize:0))}else{let t=Zl(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Ql(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof pl||i instanceof hl)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(jl.near(e.doc.resolve(o),n)))}class ea extends Ll{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=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Ki.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ki.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(jl.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ta(e,t){return t&&e?e.bind(t):e}class na{constructor(e,t,n){this.name=e,this.init=ta(t.init,n),this.apply=ta(t.apply,n)}}const ra=[new na("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new na("selection",{init(e,t){return e.selection||jl.atStart(t.doc)},apply(e){return e.selection}}),new na("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new na("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class oa{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ra.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new na(e.key,e.spec.state,e))})}}class ia{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 n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ia(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new ea(this)}static create(e){let t=new oa(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new ia(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new oa(this.schema,e.plugins),n=t.fields,r=new ia(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new oa(e.schema,e.plugins),o=new ia(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=gs.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=jl.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=l.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function sa(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=sa(o,t,{})),n[r]=o}return n}class la{constructor(e){this.spec=e,this.props={},e.props&&sa(e.props,this,this.props),this.key=e.key?e.key.key:ca("plugin")}getState(e){return e[this.key]}}const aa=Object.create(null);function ca(e){return e in aa?e+"$"+ ++aa[e]:(aa[e]=0,e+"$")}class ua{constructor(e="key"){this.key=ca(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const da=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function pa(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const ha=(e,t,n)=>{let r=pa(e,n);if(!r)return!1;let o=ya(r);if(!o){let n=r.blockRange(),o=n&&yl(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(Oa(e,o,t,-1))return!0;if(0==r.parent.content.size&&(ma(i,"end")||Jl.isSelectable(i)))for(let n=r.depth;;n--){let s=Tl(e.doc,r.before(n),r.after(n),Xi.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ma(i,"end")?jl.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Jl.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))};function fa(e,t,n){let r=t.nodeBefore,o=t.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=Tl(e.doc,o,s,Xi.empty);if(!l||l.from!=o||l instanceof pl&&l.slice.size>=s-o)return!1;if(n){let t=e.tr.step(l);t.setSelection(Hl.create(t.doc,o)),n(t.scrollIntoView())}return!0}function ma(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const ga=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=ya(r)}let s=i&&i.nodeBefore;return!(!s||!Jl.isSelectable(s)||(t&&t(e.tr.setSelection(Jl.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function ya(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ba(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const va=(e,t,n)=>{let r=ba(e,n);if(!r)return!1;let o=xa(r);if(!o)return!1;let i=o.nodeAfter;if(Oa(e,o,t,1))return!0;if(0==r.parent.content.size&&(ma(i,"start")||Jl.isSelectable(i))){let n=Tl(e.doc,r.before(),r.after(),Xi.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ma(i,"start")?jl.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Jl.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))},wa=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=xa(r)}let s=i&&i.nodeAfter;return!(!s||!Jl.isSelectable(s)||(t&&t(e.tr.setSelection(Jl.create(e.doc,i.pos)).scrollIntoView()),0))};function xa(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const Ea=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function ka(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Sa=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=ka(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(jl.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},Ca=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Yl||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=ka(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(Hl.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},Ta=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(El(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&yl(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};var Ma;function Oa(e,t,n,r){let o,i,s=t.nodeBefore,l=t.nodeAfter,a=s.type.spec.isolating||l.type.spec.isolating;if(!a&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!kl(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!a&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(o[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=Gi.empty;for(let e=o.length-1;e>=0;e--)i=Gi.from(o[e].create(null,i));i=Gi.from(s.copy(i));let a=e.tr.step(new hl(t.pos-1,r,t.pos,r,new Xi(i,1,0),o.length,!0)),c=a.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&kl(a.doc,c.pos)&&a.join(c.pos),n(a.scrollIntoView())}return!0}let u=l.type.spec.isolating||r>0&&a?null:jl.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),p=d&&yl(d);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(c&&ma(l,"start",!0)&&ma(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=l,a=1;for(;!i.isTextblock;i=i.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=Gi.empty;for(let e=o.length-1;e>=0;e--)r=Gi.from(o[e].copy(r));n(e.tr.step(new hl(t.pos-o.length,t.pos+l.nodeSize,t.pos+a,t.pos+l.nodeSize-a,new Xi(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ia(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(Hl.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const Pa=Ia(-1),Na=Ia(1);function Da(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Aa(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let _a=Aa(da,ha,ga),za=Aa(da,va,wa);const Ra={Enter:Aa(Ea,Ca,Ta,(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Jl&&e.selection.node.isBlock)return!(!n.parentOffset||!El(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,i,s=[],l=!1,a=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){l=n.end(e)==n.pos+(n.depth-e),a=n.start(e)==n.pos-(n.depth-e),i=ka(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let t=Ma;s.unshift(t||(l&&i?{type:i}:null)),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof Hl||e.selection instanceof Yl)&&c.deleteSelection();let u=c.mapping.map(n.pos),d=El(c.doc,u,s.length,s);if(d||(s[0]=i?{type:i}:null,d=El(c.doc,u,s.length,s)),!d)return!1;if(c.split(u,s.length,s),!l&&a&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0}),"Mod-Enter":Sa,Backspace:_a,"Mod-Backspace":_a,"Shift-Backspace":_a,Delete:za,"Mod-Delete":za,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Yl(e.doc))),!0)},$a={"Ctrl-h":Ra.Backspace,"Alt-Backspace":Ra["Mod-Backspace"],"Ctrl-d":Ra.Delete,"Ctrl-Alt-Backspace":Ra["Mod-Delete"],"Alt-Delete":Ra["Mod-Delete"],"Alt-d":Ra["Mod-Delete"],"Ctrl-a":Pa,"Ctrl-e":Na};for(let e in Ra)$a[e]=Ra[e];"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();const Ba=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Va=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let La=null;const Fa=function(e,t,n){let r=La||(La=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},ja=function(e,t,n,r){return n&&(Wa(e,t,n,r,-1)||Wa(e,t,n,r,1))},Ua=/^(img|br|input|textarea|hr)$/i;function Wa(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ga(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Ha(e)||Ua.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ba(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?Ga(e):0}}}}function Ga(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ha(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const qa=function(e){return e.focusNode&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ja(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Ka="undefined"!=typeof navigator?navigator:null,Ya="undefined"!=typeof document?document:null,Xa=Ka&&Ka.userAgent||"",Za=/Edge\/(\d+)/.exec(Xa),Qa=/MSIE \d/.exec(Xa),ec=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xa),tc=!!(Qa||ec||Za),nc=Qa?document.documentMode:ec?+ec[1]:Za?+Za[1]:0,rc=!tc&&/gecko\/(\d+)/i.test(Xa);rc&&(/Firefox\/(\d+)/.exec(Xa)||[0,0])[1];const oc=!tc&&/Chrome\/(\d+)/.exec(Xa),ic=!!oc,sc=oc?+oc[1]:0,lc=!tc&&!!Ka&&/Apple Computer/.test(Ka.vendor),ac=lc&&(/Mobile\/\w+/.test(Xa)||!!Ka&&Ka.maxTouchPoints>2),cc=ac||!!Ka&&/Mac/.test(Ka.platform),uc=!!Ka&&/Win/.test(Ka.platform),dc=/Android \d/.test(Xa),pc=!!Ya&&"webkitFontSmoothing"in Ya.documentElement.style,hc=pc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fc(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function mc(e,t){return"number"==typeof e?e:e[t]}function gc(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function yc(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Va(s);continue}let e=s,n=e==i.body,l=n?fc(i):gc(e),a=0,c=0;if(t.top<l.top+mc(r,"top")?c=-(l.top-t.top+mc(o,"top")):t.bottom>l.bottom-mc(r,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+mc(o,"top")-l.top:t.bottom-l.bottom+mc(o,"bottom")),t.left<l.left+mc(r,"left")?a=-(l.left-t.left+mc(o,"left")):t.right>l.right-mc(r,"right")&&(a=t.right-l.right+mc(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}let u=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(u))break;s="absolute"==u?s.offsetParent:Va(s)}}function bc(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Va(r));return t}function vc(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let wc=null;function xc(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,c=t.top;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=Fa(u).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=a&&h.bottom>=c){a=Math.max(h.bottom,a),c=Math.min(h.top,c);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==u.nodeType&&e&&(l=d+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!o&&h.left<=t.left&&h.right>=t.left&&(o=u,i={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(l=d+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=Tc(r,1);if(n.top!=n.bottom&&Ec(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:xc(n,r)}function Ec(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function kc(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(Ec(t,o))return kc(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function Sc(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ga(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ga(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,l=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Ec(t,n))return null;if(l=kc(e.dom,t,n),!l)return null}if(lc)for(let e=l;n&&e;e=Va(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(rc&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;pc&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=xc(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Cc(e){return e.top<e.bottom||e.left<e.right}function Tc(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Cc(e))return e}return Array.prototype.find.call(n,Cc)||e.getBoundingClientRect()}const Mc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Oc(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=pc||rc;if(3==r.nodeType){if(!s||!Mc.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Ic(Tc(Fa(r,e,t),i),i<0)}{let e=Tc(Fa(r,o,o),n);if(rc&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Tc(Fa(r,o-1,o-1),-1);if(t.top==e.top){let n=Tc(Fa(r,o,o+1),-1);if(n.top!=e.top)return Ic(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Ga(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Pc(e.getBoundingClientRect(),!1)}if(null==i&&o<Ga(r)){let e=r.childNodes[o];if(1==e.nodeType)return Pc(e.getBoundingClientRect(),!0)}return Pc(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Ga(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Fa(e,Ga(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ic(Tc(t,1),!1)}if(null==i&&o<Ga(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Fa(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ic(Tc(t,-1),!0)}return Ic(Tc(3==r.nodeType?Fa(r):r,-n),n>=0)}function Ic(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Pc(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Nc(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Dc=/[\u0590-\u08ac]/;let Ac=null,_c=null,zc=!1;class Rc{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){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,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Ba(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof Uc){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof $c&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Ba(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Ba(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==r&&e<=l){let o=i+n.border;if(e>=o&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Ba(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Ba(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((rc||lc)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:Ba(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(rc&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&lc)&&ja(s.node,s.offset,c.anchorNode,c.anchorOffset)&&ja(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||e==t)&&(!u||!rc)){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class $c extends Rc{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||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 Bc extends Rc{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Vc extends Rc{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=qs.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Vc(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Vc.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=nu(o,t,i,n)),e>0&&(o=nu(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Lc extends Rc{constructor(e,t,n,r,o,i,s,l,a){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,l=o.nodeViews[t.type.name],a=l&&l(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=a&&a.dom,u=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=qs.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:u}=e)}u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Xc(c,n,t),a?s=new Wc(e,t,n,r,c,u||null,d,a,o,i+1):t.isText?new jc(e,t,n,r,c,d,o):new Lc(e,t,n,r,c,u||null,d,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Gi.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Zc(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,l=new eu(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d,p,h;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(u?(d||(d=[u])).push(e):u=e)}if(u)if(d){d.sort(tu);for(let e=0;e<d.length;e++)n(d[e],c,!!a)}else n(u,c,!!a);if(a)h=-1,p=a,a=null;else{if(!(c<e.childCount))break;h=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,h=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(p,p.isInline&&!p.isLeaf?l.filter(e=>!e.inline):l.slice(),t.forChild(i,p),h),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(o==this.node.childCount?Ki.none:this.node.child(o).marks,n,e),l.placeWidget(t,e,r)},(t,i,a,c)=>{let u;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(t,i,a,u,e)||l.updateNextNode(t,i,a,e,c,r)||l.addNode(t,i,a,e,r),r+=t.nodeSize}),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Gc(this.contentDOM,this.children,e),ac&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Hl)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Bc(this,o,t,r);e.input.compositionNodes.push(i),this.children=nu(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Zc(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Kc(this.dom,this.nodeDOM,Jc(this.outerDeco,this.node,t),Jc(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Fc(e,t,n,r,o){Xc(r,t,e);let i=new Lc(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class jc extends Lc{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,0))}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,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new jc(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Uc extends Rc{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Wc extends Lc{constructor(e,t,n,r,o,i,s,l,a,c){super(e,t,n,r,o,i,s,a,c),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Gc(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=Qc(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Vc){let t=r?r.previousSibling:e.lastChild;Gc(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Qc(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Hc=function(e){e&&(this.nodeName=e)};Hc.prototype=Object.create(null);const qc=[new Hc];function Jc(e,t,n){if(0==e.length)return qc;let r=n?qc[0]:new Hc,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Hc(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Hc(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Kc(e,t,n,r){if(n==qc&&r==qc)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=qc[0]),o=t}Yc(o,s||qc[0],i)}return o}function Yc(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Xc(e,t,n){return Kc(e,e,qc,Jc(t,n,1!=e.nodeType))}function Zc(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Qc(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class eu{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Vc)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Vc.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Lc){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,u=l.dom,d=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&Zc(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zc(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=Lc.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=Lc.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new $c(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Vc;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((lc||ic)&&e&&"false"==e.dom.contentEditable&&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 n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Uc(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function tu(e,t){return e.type.side-t.type.side}function nu(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,u=l+=a.size;c>=n||u<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function ru(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=r.resolve(s);if(qa(n)){for(l=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Jl.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Ga(e);r||o;){if(e==n)return!0;let t=Ba(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Ga(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;a=new Jl(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);return a||(a=pu(e,u,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}function ou(e){return e.editable?e.hasFocus():fu(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function iu(e,t=!1){let n=e.state.selection;if(uu(e,n),ou(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&ic){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&ja(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Ba(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&tc&&nc<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!su||n instanceof Hl||(n.$from.parent.inlineContent||(r=lu(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=lu(e,n.to))),e.docView.setSelection(i,s,e,t),su&&(r&&cu(r),o&&cu(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{ou(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const su=lc||ic&&sc<63;function lu(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(lc&&o&&"false"==o.contentEditable)return au(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return au(o);if(i)return au(i)}}function au(e){return e.contentEditable="true",lc&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function cu(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function uu(e,t){if(t instanceof Jl){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(du(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else du(e)}function du(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function pu(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||Hl.between(t,n,r)}function hu(e){return!(e.editable&&!e.hasFocus())&&fu(e)}function fu(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function mu(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&jl.findFrom(i,t)}function gu(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function yu(e,t,n){let r=e.state.selection;if(!(r instanceof Hl)){if(r instanceof Jl&&r.node.isInline)return gu(e,new Hl(t>0?r.$to:r.$from));{let n=mu(e.state,t);return!!n&&gu(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return gu(e,new Hl(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=mu(e.state,t);return!!(n&&n instanceof Jl)&&gu(e,n)}if(!(cc&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Jl.isSelectable(i)?gu(e,new Jl(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!pc&&gu(e,new Hl(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function bu(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function vu(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function wu(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;for(rc&&1==n.nodeType&&r<bu(n)&&vu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(vu(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(xu(n))break;{let t=n.previousSibling;for(;t&&vu(t,-1);)o=n.parentNode,i=Ba(t),t=t.previousSibling;if(t)n=t,r=bu(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Eu(e,n,r):o&&Eu(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=bu(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!vu(n.childNodes[r],1))break;o=n,i=++r}else{if(xu(n))break;{let t=n.nextSibling;for(;t&&vu(t,1);)o=t.parentNode,i=Ba(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=bu(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Eu(e,o,i)}(e)}function xu(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Eu(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Ha(e);)t=Ba(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Ha(e);)t=Ba(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(qa(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&iu(e)},50)}function ku(e,t){let n=e.state.doc.resolve(t);if(!ic&&!uc&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Su(e,t,n){let r=e.state.selection;if(r instanceof Hl&&!r.empty||n.indexOf("s")>-1)return!1;if(cc&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=mu(e.state,t);if(n&&n instanceof Jl)return gu(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Yl?jl.near(n,t):jl.findFrom(n,t);return!!s&&gu(e,s)}return!1}function Cu(e,t){if(!(e.state.selection instanceof Hl))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Tu(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Mu(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||qs.fromSchema(e.state.schema),l=$u(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c,u=a.firstChild,d=0;for(;u&&1==u.nodeType&&(c=zu[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}u=a.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Ou(e,t,n,r,o){let i,s,l=o.parent.type.spec.code;if(!n&&!t)return null;let a=!!t&&(r||l||!n);if(a){if(e.someProp("transformPastedText",n=>{t=n(t,l||r,e)}),l)return s=new Xi(Gi.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,o,r,e));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=qs.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=$u().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);if((n=o&&zu[o[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join("")),r.innerHTML=function(e){let t=window.trustedTypes;return t?(Bu||(Bu=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),Bu.createHTML(e)):e}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),pc&&function(e){let t=e.querySelectorAll(ic?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||$s.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!a&&!u),context:o,ruleFromNode(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Iu.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(u)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=Gi.from(t.create(n[e+1],o)),i++,s++}return new Xi(o,i,s)}(_u(s,+u[1],+u[2]),u[4]);else if(s=Xi.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Nu(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Du(i[i.length-1],r.length));let t=Pu(e,n);i.push(t),o=o.matchType(t.type),r=n}}),i)return Gi.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=_u(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,a)}),s}const Iu=/^(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 Pu(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Gi.from(e));return e}function Nu(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Nu(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(Gi.from(Pu(n,e,o+1))))}}function Du(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Du(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Gi.empty,!0);return e.copy(n.append(r))}function Au(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(i=0),o<r-1&&(l=Au(l,t,n,r,o+1,i)),o>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(Gi.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}function _u(e,t,n){return t<e.openStart&&(e=new Xi(Au(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Xi(Au(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const zu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ru=null;function $u(){return Ru||(Ru=document.implementation.createHTMLDocument("title"))}let Bu=null;const Vu={},Lu={},Fu={touchstart:!0,touchmove:!0};class ju{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Uu(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Wu(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Gu(e,t))})}function Gu(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Hu(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function qu(e){return{left:e.clientX,top:e.clientY}}function Ju(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Ku(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Yu(e,t,n,r){return Ju(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Xu(e,t,n,r){return Ju(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Ku(e,Hl.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)Ku(e,Hl.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Jl.isSelectable(n))continue;Ku(e,Jl.create(r,i),"pointer")}return!0}}(e,n,r)}function Zu(e){return id(e)}Lu.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!td(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!dc||!ic||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ac||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||function(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||cc&&72==n&&"c"==r)return Cu(e,-1)||wu(e,-1);if(46==n&&!t.shiftKey||cc&&68==n&&"c"==r)return Cu(e,1)||wu(e,1);if(13==n||27==n)return!0;if(37==n||cc&&66==n&&"c"==r){let t=37==n?"ltr"==ku(e,e.state.selection.from)?-1:1:-1;return yu(e,t,r)||wu(e,t)}if(39==n||cc&&70==n&&"c"==r){let t=39==n?"ltr"==ku(e,e.state.selection.from)?1:-1:1;return yu(e,t,r)||wu(e,t)}return 38==n||cc&&80==n&&"c"==r?Su(e,-1,r)||wu(e,-1):40==n||cc&&78==n&&"c"==r?function(e){if(!lc||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Tu(e,n,"true"),setTimeout(()=>Tu(e,n,"false"),20)}return!1}(e)||Su(e,1,r)||wu(e,1):r==(cc?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Uu(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Ja(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},Lu.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Lu.keypress=(e,t)=>{let n=t;if(td(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||cc&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Hl&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const Qu=cc?"metaKey":"ctrlKey";Vu.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Zu(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Qu]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(qu(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ed(e,s,n,!!r)):("doubleClick"==i?Yu:Xu)(e,s.pos,s.inside,n)?n.preventDefault():Uu(e,"pointer"))};class ed{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Qu],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||a instanceof Jl&&a.from<=i&&a.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!rc||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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Uu(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>iu(this.view)),this.view.input.mouseDown=null}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(qu(e))),this.updateAllowDefault(e),this.allowDefault||!t?Uu(this.view,"pointer"):function(e,t,n,r,o){return Ju(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Jl&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Jl.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Ku(e,Jl.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Jl.isSelectable(r))&&(Ku(e,new Jl(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||lc&&this.mightDrag&&!this.mightDrag.node.isAtom||ic&&!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)?(Ku(this.view,jl.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Uu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Uu(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function td(e,t){return!!e.composing||!!(lc&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Vu.touchstart=e=>{e.input.lastTouch=Date.now(),Zu(e),Uu(e,"pointer")},Vu.touchmove=e=>{e.input.lastTouch=Date.now(),Uu(e,"pointer")},Vu.contextmenu=e=>Zu(e);const nd=dc?5e3:-1;function rd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>id(e),t))}function od(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function id(e,t=!1){if(!(dc&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),od(e),t||e.docView&&e.docView.dirty){let n=ru(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Lu.compositionstart=Lu.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Hl&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),id(e,!0),e.markCursor=null;else if(id(e,!t.selection.empty),rc&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}rd(e,nd)},Lu.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,rd(e,20))};const sd=tc&&nc<15||ac&&hc<604;function ld(e,t,n,r,o){let i=Ou(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||Xi.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ad(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Vu.copy=Lu.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=sd?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Mu(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Lu.paste=(e,t)=>{let n=t;if(e.composing&&!dc)return;let r=sd?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ld(e,ad(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ld(e,r.value,null,o,t):ld(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class cd{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const ud=cc?"altKey":"ctrlKey";function dd(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[ud]}Vu.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(qu(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Jl?i.to-1:i.to));else if(r&&r.mightDrag)o=Jl.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Jl.create(e.state.doc,t.posBefore))}let l=(o||e.state.selection).content(),{dom:a,text:c,slice:u}=Mu(e,l);(!n.dataTransfer.files.length||!ic||sc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(sd?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",sd||n.dataTransfer.setData("text/plain",c),e.dragging=new cd(u,dd(e,n),o)},Vu.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Lu.dragover=Lu.dragenter=(e,t)=>t.preventDefault(),Lu.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let o=e.posAtCoords(qu(n));if(!o)return;let i=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",t=>{s=t(s,e,!1)}):s=Ou(e,ad(n.dataTransfer),sd?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!r||!dd(e,n));if(e.someProp("handleDrop",t=>t(e,n,s||Xi.empty,l)))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=r;e?e.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(p))return;let h=c.doc.resolve(u);if(d&&Jl.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Jl(h));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),c.setSelection(pu(e,h,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Vu.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&iu(e)},20))},Vu.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Vu.beforeinput=(e,t)=>{if(ic&&dc&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Ja(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Lu)Vu[e]=Lu[e];function pd(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class hd{constructor(e,t){this.toDOM=e,this.spec=t||bd,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new gd(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof hd&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fd{constructor(e,t){this.attrs=e,this.spec=t||bd}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new gd(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fd&&pd(this.attrs,e.attrs)&&pd(this.spec,e.spec)}static is(e){return e.type instanceof fd}destroy(){}}class md{constructor(e,t){this.attrs=e,this.spec=t||bd}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new gd(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof md&&pd(this.attrs,e.attrs)&&pd(this.spec,e.spec)}destroy(){}}class gd{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new gd(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,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new gd(e,e,new hd(t,n))}static inline(e,t,n,r){return new gd(e,t,new fd(n,r))}static node(e,t,n,r){return new gd(e,t,new md(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof fd}get widget(){return this.type instanceof hd}}const yd=[],bd={};class vd{constructor(e,t){this.local=e.length?e:yd,this.children=t.length?t:yd}static create(e,t){return t.length?Cd(t,e,0,bd):wd}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==wd||0==e.maps.length?this:this.mapInner(e,t,0,0,n||bd)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<l.length;o+=3){let i=l[o+1];if(i<0||e>i+t-r)continue;let a=l[o]+t-r;n>=a?l[o+1]=e<=a?-2:-1:e>=t&&s&&(l[o]+=s,l[o+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),u=c-o;if(u<0||u>=r.content.size){a=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:p,offset:h}=r.content.findIndex(u),f=r.maybeChild(p);if(f&&h==u&&h+f.nodeSize==d){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=wd?(l[t]=u,l[t+1]=d,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,o,i,s),c=Cd(a,r,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new vd(t.sort(Td),l)}(this.children,i||[],e,t,n,r,o):i?new vd(i.sort(Td),yd):wd}add(e,t){return t.length?this==wd?vd.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,l=i+n;if(s=kd(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,Cd(s,e,l+1,bd)),o+=3}});let i=Ed(o?Sd(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new vd(i.length?this.local.concat(i).sort(Td):this.local,r||this.children)}remove(e){return 0==e.length||this==wd?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=wd?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new vd(r,n):wd}forChild(e,t){if(this==wd)return this;if(t.isLeaf)return vd.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof fd){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new vd(r.sort(Td),yd);return n?new xd([e,n]):e}return n||wd}eq(e){if(this==e)return!0;if(!(e instanceof vd)||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 Md(this.localsInner(e))}localsInner(e){if(this==wd)return yd;if(e.inlineContent||!this.local.some(fd.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof fd||t.push(this.local[e]);return t}forEachSet(e){e(this)}}vd.empty=new vd([],[]),vd.removeOverlap=Md;const wd=vd.empty;class xd{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,bd));return xd.from(n)}forChild(e,t){if(t.isLeaf)return vd.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=wd&&(o instanceof xd?n=n.concat(o.members):n.push(o))}return xd.from(n)}eq(e){if(!(e instanceof xd)||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,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Md(n?t:t.sort(Td)):yd}static from(e){switch(e.length){case 0:return wd;case 1:return e[0];default:return new xd(e.every(e=>e instanceof vd)?e:e.reduce((e,t)=>e.concat(t instanceof vd?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ed(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new gd(o.from+t,o.to+t,o.type))}return n}function kd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Sd(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Cd(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let l=kd(e,t,s+n);if(l){i=!0;let e=Cd(l,t,n+s+1,r);e!=wd&&o.push(s,s+t.nodeSize,e)}});let s=Ed(i?Sd(e):e,-n).sort(Td);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new vd(s,o):wd}function Td(e,t){return e.from-t.from||e.to-t.to}function Md(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Od(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Od(t,o+1,i.copy(r.to,i.to)))}}return t}function Od(e,t,n){for(;t<e.length&&Td(n,e[t])>0;)t++;e.splice(t,0,n)}function Id(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=wd&&t.push(r)}),e.cursorWrapper&&t.push(vd.create(e.state.doc,[e.cursorWrapper.deco])),xd.from(t)}const Pd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Nd=tc&&nc<=11;class Dd{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 Ad{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Dd,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);tc&&nc<=11&&e.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),Nd&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Pd)),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(hu(this.view)){if(this.suppressingSelectionUpdates)return iu(this.view);if(tc&&nc<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ja(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,n=new Set;for(let t=e.focusNode;t;t=Va(t))n.add(t);for(let r=e.anchorNode;r;r=Va(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 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 n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&hu(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(rc&&l.length){let t=l.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&$d(e,n)==t||r.remove()}}}let a=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qa(n)&&(a=ru(e))&&a.eq(jl.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,iu(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(!_d.has(e)&&(_d.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=rc,zd)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."),zd=!0}}(e)),this.handleDOMChange(o,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||iu(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(tc&&nc<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Ba(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=o&&o.parentNode==e.target?Ba(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let _d=new WeakMap,zd=!1;function Rd(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return ja(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function $d(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Bd(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(lc&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||lc&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Vd=/^(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 Ld(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:pu(e,t.resolve(n.anchor),t.resolve(n.head))}function Fd(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function jd(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class Ud{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 ju,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Jd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Hd(this),Gd(this),this.nodeViews=qd(this),this.docView=Fc(this.state.doc,Wd(this),Id(this),this.dom,this),this.domObserver=new Ad(this,(e,t,n,r)=>function(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ru(e,t);if(n&&!e.state.selection.eq(n)){if(ic&&dc&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,Ja(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a,c,u=e.state.selection,d=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:c.anchorOffset}],qa(c)||r.push({node:c.focusNode,offset:c.focusOffset})),ic&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,p=e.someProp("domParser")||$s.fromSchema(e.state.schema),h=d.resolve(l),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Bd,context:h});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),p=e.state.doc,h=p.slice(d.from,d.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,c="end"):(a=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o&&(r-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&jd(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=r<=i&&r>=l?i-r:0;i-=t,i&&i<e.size&&jd(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(h.content,d.doc.content,d.from,a,c);if(f&&e.input.domChangeCount++,(ac&&e.input.lastIOSEnter>Date.now()-225||dc)&&o.some(e=>1==e.nodeType&&!Vd.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,Ja(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&u instanceof Hl&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){let t=Ld(e,e.state.doc,d.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:u.from,endA:u.to,endB:u.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Hl&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=d.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=d.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),tc&&nc<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>d.from&&" "==d.doc.textBetween(f.start-d.from-1,f.start-d.from+1)&&(f.start--,f.endA--,f.endB--);let m=d.doc.resolveNoCache(f.start-d.from),g=d.doc.resolveNoCache(f.endB-d.from),y=p.resolve(f.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=f.endA;if((ac&&e.input.lastIOSEnter>Date.now()-225&&(!b||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&m.pos<d.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(d.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,Ja(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Fd(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Fd(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Fd(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,Ja(8,"Backspace"))))return void(dc&&ic&&e.domObserver.suppressSelectionUpdates());ic&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),dc&&!b&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==f.endA&&(f.endB-=2,g=d.doc.resolveNoCache(f.endB-d.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,Ja(13,"Enter"))})},20));let v,w=f.start,x=f.endA,E=t=>{let n=t||e.state.tr.replace(w,x,d.doc.slice(f.start-d.from,f.endB-d.from));if(d.sel){let t=Ld(e,n.doc,d.sel);t&&!(ic&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==w||t.head==n.mapping.map(x)-1)||tc&&t.empty&&t.head==w)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(b)if(m.pos==g.pos){tc&&nc<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>iu(e),20));let t=E(e.state.tr.delete(w,x)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(v=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,l=i,a=s;for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);for(let e=0;e<i.length;e++)a=i[e].removeFromSet(a);if(1==l.length&&0==a.length)r=l[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=l.length||1!=a.length)return null;r=a[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(Gi.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,f.endA-y.start())))){let t=E(e.state.tr);"add"==v.type?t.addMark(w,x,v.mark):t.removeMark(w,x,v.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>E(e.state.tr.insertText(t,w,x));e.someProp("handleTextInput",r=>r(e,w,x,t,n))||e.dispatch(n())}else e.dispatch(E());else e.dispatch(E())}(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in Vu){let n=Vu[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Hu(e,t)||Gu(e,t)||!e.editable&&t.type in Lu||n(e,t)},Fu[t]?{passive:!0}:void 0)}lc&&e.dom.addEventListener("input",()=>null),Wu(e)}(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&&Wu(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Jd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(od(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=qd(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Wu(this),this.editable=Hd(this),Gd(this);let l=Id(this),a=Wd(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",u=o||!this.docView.matchesNode(e.doc,a,l);!u&&e.selection.eq(r.selection)||(i=!0);let d="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:bc(e.dom)}}(this);if(i){this.domObserver.stop();let t=u&&(tc||ic)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(u){let n=ic?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Ga(e=e.childNodes[t-1])}else{if(!e.parentNode||Ha(e))return null;t=Ba(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ha(e))return null;t=Ba(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}(this)),!o&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Fc(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return ja(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?iu(this,t):(uu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;vc(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Jl){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&yc(this,t.getBoundingClientRect(),e)}else yc(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new cd(e.slice,e.move,r<0?void 0:Jl.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(tc){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(wc)return e.focus(wc);let t=bc(e);e.focus(null==wc?{get preventScroll(){return wc={preventScroll:!0},!0}}:void 0),wc||(wc=!1,vc(t,0))}(this.dom),iu(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Sc(this,e)}coordsAtPos(e,t=1){return Oc(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,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){return Ac==t&&_c==n?zc:(Ac=t,_c=n,zc="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Nc(e,t,()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Oc(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Fa(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?Dc.test(r.parent.textContent)&&l.modify?Nc(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),p=u&&!c.contains(1==u.nodeType?u:u.parentNode)||t==u&&o==d;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return ld(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ld(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Mu(this,e)}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Id(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,La=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Gu(e,t)||!Vu[t.type]||!e.editable&&t.type in Lu||Vu[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?lc&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Rd(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Rd(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Wd(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[gd.node(0,e.state.doc.content.size,t)]}function Gd(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:gd.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Hd(e){return!e.someProp("editable",t=>!1===t(e.state))}function qd(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Jd(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ud.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var Kd={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Yd={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Xd="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zd="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Qd=0;Qd<10;Qd++)Kd[48+Qd]=Kd[96+Qd]=String(Qd);for(Qd=1;Qd<=24;Qd++)Kd[Qd+111]="F"+Qd;for(Qd=65;Qd<=90;Qd++)Kd[Qd]=String.fromCharCode(Qd+32),Yd[Qd]=String.fromCharCode(Qd);for(var ep in Kd)Yd.hasOwnProperty(ep)||(Yd[ep]=Kd[ep]);const tp="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),np="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function rp(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);tp?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function op(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ip(e){let t=function(e){let t=Object.create(null);for(let n in e)t[rp(n)]=e[n];return t}(e);return function(e,n){let r,o=function(e){var t=!(Xd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Zd&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Yd:Kd)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[op(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[op(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(np&&n.ctrlKey&&n.altKey)&&(r=Kd[n.keyCode])&&r!=o){let o=t[op(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}var sp=Object.defineProperty,lp=(e,t)=>{for(var n in t)sp(e,n,{get:t[n],enumerable:!0})};function ap(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var cp=class{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:n}=this,{view:r}=t,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(i);return o.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(o),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!e,a=e||o.tr,c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(a,t),o=n(...e)(r);return s.push(o),c}])),run:()=>(l||!t||a.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(a),s.every(e=>!0===e))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,o=e||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:e,editor:r,view:i,state:ap({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(s)]))}};return s}},up={};lp(up,{blur:()=>dp,clearContent:()=>pp,clearNodes:()=>hp,command:()=>fp,createParagraphNear:()=>mp,cut:()=>gp,deleteCurrentNode:()=>yp,deleteNode:()=>vp,deleteRange:()=>wp,deleteSelection:()=>xp,enter:()=>Ep,exitCode:()=>kp,extendMarkRange:()=>Pp,first:()=>Np,focus:()=>Rp,forEach:()=>$p,insertContent:()=>Bp,insertContentAt:()=>jp,joinBackward:()=>Gp,joinDown:()=>Wp,joinForward:()=>Hp,joinItemBackward:()=>qp,joinItemForward:()=>Jp,joinTextblockBackward:()=>Kp,joinTextblockForward:()=>Yp,joinUp:()=>Up,keyboardShortcut:()=>Zp,lift:()=>eh,liftEmptyBlock:()=>th,liftListItem:()=>nh,newlineInCode:()=>rh,resetAttributes:()=>sh,scrollIntoView:()=>lh,selectAll:()=>ah,selectNodeBackward:()=>ch,selectNodeForward:()=>uh,selectParentNode:()=>dh,selectTextblockEnd:()=>ph,selectTextblockStart:()=>hh,setContent:()=>mh,setMark:()=>Fh,setMeta:()=>jh,setNode:()=>Uh,setNodeSelection:()=>Wh,setTextDirection:()=>Gh,setTextSelection:()=>Hh,sinkListItem:()=>qh,splitBlock:()=>Kh,splitListItem:()=>Yh,toggleList:()=>Qh,toggleMark:()=>ef,toggleNode:()=>tf,toggleWrap:()=>nf,undoInputRule:()=>rf,unsetAllMarks:()=>of,unsetMark:()=>sf,unsetTextDirection:()=>lf,updateAttributes:()=>af,wrapIn:()=>cf,wrapInList:()=>uf});var dp=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),pp=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),hp=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:o}=r;return!n||(o.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:o}=t,i=r.resolve(o.map(n)),s=r.resolve(o.map(n+e.nodeSize)),l=i.blockRange(s);if(!l)return;const a=yl(l);if(e.type.isTextblock){const{defaultType:e}=i.parent.contentMatchAt(i.index());t.setNodeMarkup(l.start,e)}(a||0===a)&&t.lift(l,a)})}),!0)},fp=e=>t=>e(t),mp=()=>({state:e,dispatch:t})=>Ca(e,t),gp=(e,t)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const s=r.mapping.map(t);return r.insert(s,i.content),r.setSelection(new Hl(r.doc.resolve(Math.max(s-1,0)))),!0},yp=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const o=e.selection.$anchor;for(let n=o.depth;n>0;n-=1)if(o.node(n).type===r.type){if(t){const t=o.before(n),r=o.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function bp(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var vp=e=>({tr:t,state:n,dispatch:r})=>{const o=bp(e,n.schema),i=t.selection.$anchor;for(let e=i.depth;e>0;e-=1)if(i.node(e).type===o){if(r){const n=i.before(e),r=i.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},wp=e=>({tr:t,dispatch:n})=>{const{from:r,to:o}=e;return n&&t.delete(r,o),!0},xp=()=>({state:e,dispatch:t})=>da(e,t),Ep=()=>({commands:e})=>e.keyboardShortcut("Enter"),kp=()=>({state:e,dispatch:t})=>Sa(e,t);function Sp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Cp(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Sp(t[r])?t[r].test(e[r]):t[r]===e[r])}function Tp(e,t,n={}){return e.find(e=>e.type===t&&Cp(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function Mp(e,t,n={}){return!!Tp(e,t,n)}function Op(e,t,n){var r;if(!e||!t)return;let o=e.parent.childAfter(e.parentOffset);if(o.node&&o.node.marks.some(e=>e.type===t)||(o=e.parent.childBefore(e.parentOffset)),!o.node||!o.node.marks.some(e=>e.type===t))return;if(n=n||(null==(r=o.node.marks[0])?void 0:r.attrs),!Tp([...o.node.marks],t,n))return;let i=o.index,s=e.start()+o.offset,l=i+1,a=s+o.node.nodeSize;for(;i>0&&Mp([...e.parent.child(i-1).marks],t,n);)i-=1,s-=e.parent.child(i).nodeSize;for(;l<e.parent.childCount&&Mp([...e.parent.child(l).marks],t,n);)a+=e.parent.child(l).nodeSize,l+=1;return{from:s,to:a}}function Ip(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var Pp=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const i=Ip(e,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){const e=Op(a,i,t);if(e&&e.from<=c&&e.to>=u){const t=Hl.create(s,e.from,e.to);n.setSelection(t)}}return!0},Np=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function Dp(e){return e instanceof Hl}function Ap(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function _p(e,t=null){if(!t)return null;const n=jl.atStart(e),r=jl.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const o=n.from,i=r.to;return"all"===t?Hl.create(e,Ap(0,o,i),Ap(e.content.size,o,i)):Hl.create(e,Ap(t,o,i),Ap(t,o,i))}function zp(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Rp=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:i})=>{t={scrollIntoView:!0,...t};const s=()=>{(zp()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(i&&null===e&&!Dp(n.state.selection))return s(),!0;const l=_p(o.doc,e)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},$p=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Bp=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Vp=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Vp(r)}return e};function Lp(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return Vp(n)}function Fp(e,t,n){if(e instanceof gs||e instanceof Gi)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return Gi.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),Fp("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,o="";const i=new zs({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,o="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?$s.fromSchema(i).parseSlice(Lp(e),n.parseOptions):$s.fromSchema(i).parse(Lp(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const r=$s.fromSchema(t);return n.slice?r.parseSlice(Lp(e),n.parseOptions).content:r.parse(Lp(e),n.parseOptions)}return Fp("",t,n)}var jp=(e,t,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){let o;const l=e=>{i.emit("contentError",{editor:i,error:e,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},a={preserveWhitespace:"full",...(n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Fp(t,i.schema,{parseOptions:a,errorOnInvalidContent:!0})}catch(e){l(e)}try{o=Fp(t,i.schema,{parseOptions:a,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:i.options.enableContentCheck})}catch(e){return l(e),!1}let c,{from:u,to:d}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,h=!0;if(("type"in o?[o]:o).forEach(e=>{e.check(),p=!!p&&e.isText&&0===e.marks.length,h=!!h&&e.isBlock}),u===d&&h){const{parent:e}=r.doc.resolve(u);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(u-=1,d+=1)}if(p){if(Array.isArray(t))c=t.map(e=>e.text||"").join("");else if(t instanceof Gi){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),c=e}else c="object"==typeof t&&t&&t.text?t.text:t;r.insertText(c,u,d)}else{c=o;const e=r.doc.resolve(u),t=e.node(),n=0===e.parentOffset,i=t.isText||t.isTextblock,s=t.content.size>0;n&&i&&s&&(u=Math.max(0,u-1)),r.replaceWith(u,d,c)}n.updateSelection&&function(e,t){const n=e.steps.length-1;if(n<t)return;const r=e.steps[n];if(!(r instanceof pl||r instanceof hl))return;const o=e.mapping.maps[n];let i=0;o.forEach((e,t,n,r)=>{0===i&&(i=r)}),e.setSelection(jl.near(e.doc.resolve(i),-1))}(r,r.steps.length-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:c}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:c})}return!0},Up=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection,o=r instanceof Jl;if(o){if(r.node.isTextblock||!kl(e.doc,r.from))return!1;n=r.from}else if(n=Cl(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);o&&r.setSelection(Jl.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0})(e,t),Wp=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection;if(r instanceof Jl){if(r.node.isTextblock||!kl(e.doc,r.to))return!1;n=r.to}else if(n=Cl(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0})(e,t),Gp=()=>({state:e,dispatch:t})=>ha(e,t),Hp=()=>({state:e,dispatch:t})=>va(e,t),qp=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Cl(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},Jp=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Cl(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},Kp=()=>({state:e,dispatch:t})=>((e,t)=>{let n=pa(e,void 0);if(!n)return!1;let r=ya(n);return!!r&&fa(e,r,t)})(e,t),Yp=()=>({state:e,dispatch:t})=>((e,t)=>{let n=ba(e,void 0);if(!n)return!1;let r=xa(n);return!!r&&fa(e,r,t)})(e,t);function Xp(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Zp=e=>({editor:t,view:n,tr:r,dispatch:o})=>{const i=function(e){const t=e.split(/-(?!$)/);let n,r,o,i,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);zp()||Xp()?i=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),o&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=i.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),l=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,l))});return null==a||a.steps.forEach(e=>{const t=e.map(r.mapping);t&&o&&r.maybeStep(t)}),!0};function Qp(e,t,n={}){const{from:r,to:o,empty:i}=e.selection,s=t?bp(t,e.schema):null,l=[];e.doc.nodesBetween(r,o,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);l.push({node:e,from:n,to:i})});const a=o-r,c=l.filter(e=>!s||s.name===e.node.type.name).filter(e=>Cp(e.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((e,t)=>e+t.to-t.from,0)>=a}var eh=(e,t={})=>({state:n,dispatch:r})=>!!Qp(n,bp(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&yl(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)})(n,r),th=()=>({state:e,dispatch:t})=>Ta(e,t),nh=e=>({state:t,dispatch:n})=>{return(r=bp(e,t.schema),function(e,t){let{$from:n,$to:o}=e.selection,i=n.blockRange(o,e=>e.childCount>0&&e.firstChild.type==r);return!!i&&(!t||(n.node(i.depth-1).type==r?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new hl(i-1,s,i,s,new Xi(Gi.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new fs(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=yl(r);if(null==l)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return kl(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),t(o.scrollIntoView()),!0}(e,t,r,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?Gi.empty:Gi.from(o))))return!1;let d=i.pos,p=d+s.nodeSize;return r.step(new hl(d-(l?1:0),p+(a?1:0),d+1,p-1,new Xi((l?Gi.empty:Gi.from(o.copy(Gi.empty))).append(a?Gi.empty:Gi.from(o.copy(Gi.empty))),l?0:1,a?0:1),l?0:1)),t(r.scrollIntoView()),!0}(e,t,i)))})(t,n);var r},rh=()=>({state:e,dispatch:t})=>Ea(e,t);function oh(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function ih(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var sh=(e,t)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=oh("string"==typeof e?e:e.name,r.schema);if(!l)return!1;"node"===l&&(i=bp(e,r.schema)),"mark"===l&&(s=Ip(e,r.schema));let a=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{i&&i===e.type&&(a=!0,o&&n.setNodeMarkup(r,void 0,ih(e.attrs,t))),s&&e.marks.length&&e.marks.forEach(i=>{s===i.type&&(a=!0,o&&n.addMark(r,r+e.nodeSize,s.create(ih(i.attrs,t))))})})}),a},lh=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),ah=()=>({tr:e,dispatch:t})=>{if(t){const t=new Yl(e.doc);e.setSelection(t)}return!0},ch=()=>({state:e,dispatch:t})=>ga(e,t),uh=()=>({state:e,dispatch:t})=>wa(e,t),dh=()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:o}=e.selection,i=r.sharedDepth(o);return 0!=i&&(n=r.before(i),t&&t(e.tr.setSelection(Jl.create(e.doc,n))),!0)})(e,t),ph=()=>({state:e,dispatch:t})=>Na(e,t),hh=()=>({state:e,dispatch:t})=>Pa(e,t);function fh(e,t,n={},r={}){return Fp(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var mh=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{const{doc:a}=i;if("full"!==r.preserveWhitespace){const l=fh(e,o.schema,r,{errorOnInvalidContent:null!=t?t:o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,l).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:o.options.enableContentCheck})};function gh(e,t){const n=Ip(t,e.schema),{from:r,to:o,empty:i}=e.selection,s=[];i?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,e=>{s.push(...e.marks)});const l=s.find(e=>e.type.name===n.name);return l?{...l.attrs}:{}}function yh(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function bh(e,t,n){return void 0===e.config[t]&&e.parent?bh(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?bh(e.parent,t,n):null}):e.config[t]}function vh(e){return e.map(e=>{const t=bh(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...vh(t())]:e}).flat(10)}function wh(e,t){const n=qs.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function xh(e){return"function"==typeof e}function Eh(e,t=void 0,...n){return xh(e)?t?e.bind(t)(...n):e(...n):e}function kh(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function Sh(e){const t=[],{nodeExtensions:n,markExtensions:r}=kh(e),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{const n=bh(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:o});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...i,...r}})})})})}),o.forEach(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=bh(e,"addAttributes",n);if(!r)return;const o=r();Object.entries(o).forEach(([n,r])=>{const o={...i,...r};"function"==typeof(null==o?void 0:o.default)&&(o.default=o.default()),(null==o?void 0:o.isRequired)&&void 0===(null==o?void 0:o.default)&&delete o.default,t.push({type:e.name,name:n,attribute:o})})}),t}function Ch(...e){return e.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],o=n[e]?n[e].split(" "):[],i=r.filter(e=>!o.includes(e));n[e]=[...o,...i].join(" ")}else if("style"===e){const r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],o=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],i=new Map;o.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),r.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),n[e]=Array.from(i.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function Th(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>Ch(e,t),{})}function Mh(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const o=t.reduce((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}},{});return{...r,...o}}}}function Oh(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function Ih(e){var t,n;const r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(r.validate=e.attribute.validate),[e.name,r]}function Ph(e){return e.sort((e,t)=>{const n=bh(e,"priority")||100,r=bh(t,"priority")||100;return n>r?-1:n<r?1:0})}function Nh(e){const t=Ph(vh(e)),n=function(e){const t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),t}function Dh(e,t,n){const{from:r,to:o}=t,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let l="";return e.nodesBetween(r,o,(e,n,a,c)=>{var u;e.isBlock&&n>r&&(l+=i);const d=null==s?void 0:s[e.type.name];if(d)return a&&(l+=d({node:e,pos:n,parent:a,index:c,range:t})),!1;e.isText&&(l+=null==(u=null==e?void 0:e.text)?void 0:u.slice(Math.max(r,n)-n,o-n))}),l}function Ah(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function _h(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(t=>{const o=Op(n.resolve(e),t.type);o&&r.push({mark:t,...o})}):n.nodesBetween(e,t,(e,t)=>{e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function zh(e,t){return t.nodes[e]||t.marks[e]||null}function Rh(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function $h(e,t,n={}){const{empty:r,ranges:o}=e.selection,i=t?Ip(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!i||i.name===e.type.name).find(e=>Cp(e.attrs,n,{strict:!1}));let s=0;const l=[];if(o.forEach(({$from:t,$to:n})=>{const r=t.pos,o=n.pos;e.doc.nodesBetween(r,o,(e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),i=Math.min(o,t+e.nodeSize);s+=i-n,l.push(...e.marks.map(e=>({mark:e,from:n,to:i})))})}),0===s)return!1;const a=l.filter(e=>!i||i.name===e.mark.type.name).filter(e=>Cp(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=l.filter(e=>!i||e.mark.type!==i&&e.mark.type.excludes(i)).reduce((e,t)=>e+t.to-t.from,0);return(a>0?a+c:a)>=s}function Bh(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function Vh(e,t){const{nodeExtensions:n}=kh(t),r=n.find(t=>t.name===e);if(!r)return!1;const o=Eh(bh(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof o&&o.split(" ").includes("list")}function Lh(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(Lh(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}var Fh=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=Ip(e,r.schema);if(o)if(s){const e=gh(r,a);n.addStoredMark(a.create({...e,...t}))}else l.forEach(e=>{const o=e.$from.pos,i=e.$to.pos;r.doc.nodesBetween(o,i,(e,r)=>{const s=Math.max(r,o),l=Math.min(r+e.nodeSize,i);e.marks.find(e=>e.type===a)?e.marks.forEach(e=>{a===e.type&&n.addMark(s,l,a.create({...e.attrs,...t}))}):n.addMark(s,l,a.create(t))})});return function(e,t,n){var r;const{selection:o}=t;let i=null;if(Dp(o)&&(i=o.$cursor),i){const t=null!=(r=e.storedMarks)?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}const{ranges:s}=o;return s.some(({$from:t,$to:r})=>{let o=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(o)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),i=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));o=t&&i}return!o}),o})}(r,n,a)},jh=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Uh=(e,t={})=>({state:n,dispatch:r,chain:o})=>{const i=bp(e,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:e})=>!!Da(i,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>Da(i,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Wh=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=Ap(e,0,n.content.size),o=Jl.create(n,r);t.setSelection(o)}return!0},Gh=(e,t)=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=r;let s,l;return"number"==typeof t?(s=t,l=t):t&&"from"in t&&"to"in t?(s=t.from,l=t.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},Hh=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:o}="number"==typeof e?{from:e,to:e}:e,i=Hl.atStart(n).from,s=Hl.atEnd(n).to,l=Ap(r,i,s),a=Ap(o,i,s),c=Hl.create(n,l,a);t.setSelection(c)}return!0},qh=e=>({state:t,dispatch:n})=>{const r=bp(e,t.schema);return(o=r,function(e,t){let{$from:n,$to:r}=e.selection,i=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==o);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=o)return!1;if(t){let n=a.lastChild&&a.lastChild.type==l.type,r=Gi.from(n?o.create():null),s=new Xi(Gi.from(o.create(null,Gi.from(l.type.create(null,r)))),n?3:1,0),c=i.start,u=i.end;t(e.tr.step(new hl(c-(n?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0})(t,n);var o};function Jh(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var Kh=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=t,{$from:l,$to:a}=i,c=Rh(o.extensionManager.attributes,l.node().type.name,l.node().attrs);if(i instanceof Jl&&i.node.isBlock)return!(!l.parentOffset||!El(s,l.pos)||(r&&(e&&Jh(n,o.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),0));if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,d=0===l.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=u&&d?[{type:d,attrs:c}]:void 0,h=El(t.doc,t.mapping.map(l.pos),1,p);if(p||h||!El(t.doc,t.mapping.map(l.pos),1,d?[{type:d}]:void 0)||(h=!0,p=d?[{type:d,attrs:c}]:void 0),r){if(h&&(i instanceof Hl&&t.deleteSelection(),t.split(t.mapping.map(l.pos),1,p),d&&!u&&!l.parentOffset&&l.parent.type!==d)){const e=t.mapping.map(l.before()),n=t.doc.resolve(e);l.node(-1).canReplaceWith(n.index(),n.index()+1,d)&&t.setNodeMarkup(t.mapping.map(l.before()),d)}e&&Jh(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return h},Yh=(e,t={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const l=bp(e,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const p=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let e=Gi.empty;const r=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-r;t>=a.depth-3;t-=1)e=Gi.from(a.node(t).copy(e));const o=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i={...Rh(p,a.node().type.name,a.node().attrs),...t},c=(null==(s=l.contentMatch.defaultType)?void 0:s.createAndFill(i))||void 0;e=e.append(Gi.from(l.createAndFill(null,c)||void 0));const u=a.before(a.depth-(r-1));n.replace(u,a.after(-o),new Xi(e,4-r,0));let d=-1;n.doc.nodesBetween(u,n.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0===e.content.size&&(d=t+1)}),d>-1&&n.setSelection(Hl.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,f={...Rh(p,d.type.name,d.attrs),...t},m={...Rh(p,a.node().type.name,a.node().attrs),...t};n.delete(a.pos,c.pos);const g=h?[{type:l,attrs:f},{type:h,attrs:m}]:[{type:l,attrs:f}];if(!El(n.doc,a.pos,2))return!1;if(o){const{selection:e,storedMarks:t}=r,{splittableMarks:s}=i.extensionManager,l=t||e.$to.parentOffset&&e.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!l||!o)return!0;const c=l.filter(e=>s.includes(e.type.name));n.ensureMarks(c)}return!0},Xh=(e,t)=>{const n=yh(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!kl(e.doc,n.pos)||(e.join(n.pos),!0)},Zh=(e,t)=>{const n=yh(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!kl(e.doc,r)||(e.join(r),!0)},Qh=(e,t,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=o.extensionManager,h=bp(e,s.schema),f=bp(t,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const x=yh(e=>Vh(e.type.name,d))(m);if(v.depth>=1&&x&&v.depth-x.depth<=1){if(x.node.type===h)return c.liftListItem(f);if(Vh(x.node.type.name,d)&&h.validContent(x.node.content)&&l)return a().command(()=>(i.setNodeMarkup(x.pos,h),!0)).command(()=>Xh(i,h)).command(()=>Zh(i,h)).run()}return n&&w&&l?a().command(()=>{const e=u().wrapInList(h,r),t=w.filter(e=>p.includes(e.type.name));return i.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>Xh(i,h)).command(()=>Zh(i,h)).run():a().command(()=>!!u().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>Xh(i,h)).command(()=>Zh(i,h)).run()},ef=(e,t={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=Ip(e,r.schema);return $h(r,s,t)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,t)},tf=(e,t,n={})=>({state:r,commands:o})=>{const i=bp(e,r.schema),s=bp(t,r.schema),l=Qp(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},nf=(e,t={})=>({state:n,commands:r})=>{const o=bp(e,n.schema);return Qp(n,o,t)?r.lift(o):r.wrapIn(o,t)},rf=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(e))){if(t){const t=e.tr,n=i.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(i.text){const n=t.doc.resolve(i.from).marks();t.replaceWith(i.from,i.to,e.schema.text(i.text,n))}else t.delete(i.from,i.to)}return!0}}return!1},of=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:o}=n;return r||t&&o.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},sf=(e,t={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=t,{selection:l}=n,a=Ip(e,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&s){let{from:e,to:t}=l;const r=null==(i=c.marks().find(e=>e.type===a))?void 0:i.attrs,o=Op(c,a,r);o&&(e=o.from,t=o.to),n.removeMark(e,t,a)}else d.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,a)});return n.removeStoredMark(a),!0},lf=e=>({tr:t,state:n,dispatch:r})=>{const{selection:o}=n;let i,s;return"number"==typeof e?(i=e,s=e):e&&"from"in e&&"to"in e?(i=e.from,s=e.to):(i=o.from,s=o.to),r&&t.doc.nodesBetween(i,s,(e,n)=>{if(e.isText)return;const r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},af=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=oh("string"==typeof e?e:e.name,r.schema);if(!l)return!1;"node"===l&&(i=bp(e,r.schema)),"mark"===l&&(s=Ip(e,r.schema));let a=!1;return n.selection.ranges.forEach(e=>{const l=e.$from.pos,c=e.$to.pos;let u,d,p,h;n.selection.empty?r.doc.nodesBetween(l,c,(e,t)=>{i&&i===e.type&&(a=!0,p=Math.max(t,l),h=Math.min(t+e.nodeSize,c),u=t,d=e)}):r.doc.nodesBetween(l,c,(e,r)=>{r<l&&i&&i===e.type&&(a=!0,p=Math.max(r,l),h=Math.min(r+e.nodeSize,c),u=r,d=e),r>=l&&r<=c&&(i&&i===e.type&&(a=!0,o&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),s&&e.marks.length&&e.marks.forEach(i=>{if(s===i.type&&(a=!0,o)){const o=Math.max(r,l),a=Math.min(r+e.nodeSize,c);n.addMark(o,a,s.create({...i.attrs,...t}))}}))}),d&&(void 0!==u&&o&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),s&&d.marks.length&&d.marks.forEach(e=>{s===e.type&&o&&n.addMark(p,h,s.create({...e.attrs,...t}))}))}),a},cf=(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&bl(s,e,t);return!!l&&(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0)}}(bp(e,n.schema),t)(n,r),uf=(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return!!function(e,t,n,r=null){let o=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=s.resolve(t.start-2);i=new fs(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new fs(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let l=bl(i,n,r,t);return!!l&&(e&&function(e,t,n,r,o){let i=Gi.empty;for(let e=n.length-1;e>=0;e--)i=Gi.from(n[e].type.create(n[e].attrs,i));e.step(new hl(t.start-(r?2:0),t.end,t.start,t.end,new Xi(i,0,0),n.length,!0));let s=0;for(let e=0;e<n.length;e++)n[e].type==o&&(s=e+1);let l=n.length-s,a=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,o=!0;n<r;n++,o=!1)!o&&El(e.doc,a,l)&&(e.split(a,l),a+=2*l),a+=c.child(n).nodeSize}(e,t,l,o,n),!0)}(l,s,e,t)&&(r&&r(l.scrollIntoView()),!0)}}(bp(e,n.schema),t)(n,r),df=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},pf=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function hf(e){var t;const{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=e,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(null==(t=c.nodeBefore||c.nodeAfter)?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let u=!1;const d=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,o,i)=>{var s,l;const a=(null==(l=(s=e.type.spec).toText)?void 0:l.call(s,{node:e,pos:t,parent:o,index:i}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?a:a.slice(0,Math.max(0,r-t))}),n})(c)+i;return s.forEach(e=>{if(u)return;const t=((e,t)=>{if(Sp(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,e.find);if(!t)return;const s=a.state.tr,c=ap({state:a.state,transaction:s}),p={from:r-(t[0].length-i.length),to:o},{commands:h,chain:f,can:m}=new cp({editor:n,state:c});null!==e.handler({state:c,range:p,match:t,commands:h,chain:f,can:m})&&s.steps.length&&(e.undoable&&s.setMeta(l,{transform:s,from:r,to:o,text:i}),a.dispatch(s),u=!0)}),u}function ff(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function mf(e,t){const n={...e};return ff(e)&&ff(t)&&Object.keys(t).forEach(r=>{ff(t[r])&&ff(e[r])?n[r]=mf(e[r],t[r]):n[r]=t[r]}),n}var gf=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Eh(bh(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Eh(bh(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>mf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},yf=class e extends gf{constructor(){super(...arguments),this.type="mark"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const o=r.marks();if(!o.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;const i=o.find(e=>(null==e?void 0:e.type.name)===t.name);return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},bf=class{constructor(e){this.find=e.find,this.handler=e.handler}};var vf=null;function wf(e){const{editor:t,rules:n}=e;let r,o=null,i=!1,s=!1,l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}const a=({state:e,from:n,to:o,rule:i,pasteEvt:s})=>{const a=e.tr,c=ap({state:e,transaction:a});if(function(e){const{editor:t,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=e,{commands:a,chain:c,can:u}=new cp({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,o,(e,t)=>{var p,h,f,m,g;if((null==(h=null==(p=e.type)?void 0:p.spec)?void 0:h.code)||!(e.isText||e.isTextblock||e.isInline))return;const y=null!=(g=null!=(m=null==(f=e.content)?void 0:f.size)?m:e.nodeSize)?g:0,b=Math.max(r,t),v=Math.min(o,t+y);b>=v||((e,t,n)=>{if(Sp(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(t=>{const n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(b-t,v-t,void 0,""),i.find,s).forEach(e=>{if(void 0===e.index)return;const t=b+e.index+1,r=t+e[0].length,o={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=i.handler({state:n,range:o,match:e,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(p)})}),d.every(e=>null!==e)}({editor:t,state:c,from:Math.max(n-1,0),to:o.b-1,rule:i,pasteEvent:s,dropEvent:r})&&a.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}return l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return n.map(e=>new la({view(e){const n=n=>{var r;o=(null==(r=e.dom.parentElement)?void 0:r.contains(n.target))?e.dom.parentElement:null,o&&(vf=t)},r=()=>{vf&&(vf=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(s=o===e.dom.parentElement,r=t,!s){const e=vf;(null==e?void 0:e.isEditable)&&setTimeout(()=>{const t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;const r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return l=t,i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{const o=t[0],c="paste"===o.getMeta("uiEvent")&&!i,u="drop"===o.getMeta("uiEvent")&&!s,d=o.getMeta("applyPasteRules"),p=!!d;if(!c&&!u&&!p)return;if(p){let{text:t}=d;"string"==typeof t||(t=wh(Gi.from(t),r.schema));const{from:n}=d,o=n+t.length,i=(e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n})(t);return a({rule:e,state:r,from:n,to:{b:o},pasteEvt:i})}const h=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return"number"==typeof h&&f&&h!==f.b?a({rule:e,state:r,from:h,to:f,pasteEvt:l}):void 0}}))}var xf=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=Nh(e),this.schema=function(e,t){var n;const r=Sh(e),{nodeExtensions:o,markExtensions:i}=kh(e),s=null==(n=o.find(e=>bh(e,"topNode")))?void 0:n.name,l=Object.fromEntries(o.map(n=>{const o=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=Oh({...e.reduce((e,t)=>{const r=bh(t,"extendNodeSchema",i);return{...e,...r?r(n):{}}},{}),content:Eh(bh(n,"content",i)),marks:Eh(bh(n,"marks",i)),group:Eh(bh(n,"group",i)),inline:Eh(bh(n,"inline",i)),atom:Eh(bh(n,"atom",i)),selectable:Eh(bh(n,"selectable",i)),draggable:Eh(bh(n,"draggable",i)),code:Eh(bh(n,"code",i)),whitespace:Eh(bh(n,"whitespace",i)),linebreakReplacement:Eh(bh(n,"linebreakReplacement",i)),defining:Eh(bh(n,"defining",i)),isolating:Eh(bh(n,"isolating",i)),attrs:Object.fromEntries(o.map(Ih))}),l=Eh(bh(n,"parseHTML",i));l&&(s.parseDOM=l.map(e=>Mh(e,o)));const a=bh(n,"renderHTML",i);a&&(s.toDOM=e=>a({node:e,HTMLAttributes:Th(e,o)}));const c=bh(n,"renderText",i);return c&&(s.toText=c),[n.name,s]})),a=Object.fromEntries(i.map(n=>{const o=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=Oh({...e.reduce((e,t)=>{const r=bh(t,"extendMarkSchema",i);return{...e,...r?r(n):{}}},{}),inclusive:Eh(bh(n,"inclusive",i)),excludes:Eh(bh(n,"excludes",i)),group:Eh(bh(n,"group",i)),spanning:Eh(bh(n,"spanning",i)),code:Eh(bh(n,"code",i)),attrs:Object.fromEntries(o.map(Ih))}),l=Eh(bh(n,"parseHTML",i));l&&(s.parseDOM=l.map(e=>Mh(e,o)));const a=bh(n,"renderHTML",i);return a&&(s.toDOM=e=>a({mark:e,HTMLAttributes:Th(e,o)})),[n.name,s]}));return new zs({topNode:s,nodes:l,marks:a})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{const n=bh(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:zh(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){const{editor:e}=this;return Ph([...this.extensions].reverse()).flatMap(t=>{const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:zh(t.name,this.schema)},r=[],o=bh(t,"addKeyboardShortcuts",n);let i={};if("mark"===t.type&&bh(t,"exitable",n)&&(i.ArrowRight=()=>yf.handleExit({editor:e,mark:t})),o){const t=Object.fromEntries(Object.entries(o()).map(([t,n])=>[t,()=>n({editor:e})]));i={...i,...t}}const s=new la({props:{handleKeyDown:ip(i)}});r.push(s);const l=bh(t,"addInputRules",n);if(Bh(t,e.options.enableInputRules)&&l){const t=l();if(t&&t.length){const n=function(e){const{editor:t,rules:n}=e,r=new la({state:{init(){return null},apply(e,o,i){const s=e.getMeta(r);if(s)return s;const l=e.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:e}=l;"string"==typeof e||(e=wh(Gi.from(e),i.schema));const{from:o}=l,s=o+e.length;hf({editor:t,from:o,to:s,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:o}},props:{handleTextInput(e,o,i,s){return hf({editor:t,from:o,to:i,text:s,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{const{$cursor:o}=e.state.selection;o&&hf({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,o){if("Enter"!==o.key)return!1;const{$cursor:i}=e.state.selection;return!!i&&hf({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:t}),o=Array.isArray(n)?n:[n];r.push(...o)}}const a=bh(t,"addPasteRules",n);if(Bh(t,e.options.enablePasteRules)&&a){const t=a();if(t&&t.length){const n=wf({editor:e,rules:t});r.push(...n)}}const c=bh(t,"addProseMirrorPlugins",n);if(c){const e=c();r.push(...e)}return r})}get attributes(){return Sh(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=kh(this.extensions);return Object.fromEntries(t.filter(e=>!!bh(e,"addNodeView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:bp(t.name,this.schema)},o=bh(t,"addNodeView",r);if(!o)return[];const i=o();return i?[t.name,(r,o,s,l,a)=>{const c=Th(r,n);return i({node:r,view:o,getPos:s,decorations:l,innerDecorations:a,editor:e,extension:t,HTMLAttributes:c})}]:[]}))}get markViews(){const{editor:e}=this,{markExtensions:t}=kh(this.extensions);return Object.fromEntries(t.filter(e=>!!bh(e,"addMarkView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Ip(t.name,this.schema)},o=bh(t,"addMarkView",r);return o?[t.name,(r,i,s)=>{const l=Th(r,n);return o()({mark:r,view:i,inline:s,editor:e,extension:t,HTMLAttributes:l,updateAttributes:t=>{!function(e,t,n={}){const{state:r}=t,{doc:o,tr:i}=r,s=e;o.descendants((t,r)=>{const o=i.mapping.map(r),l=i.mapping.map(r)+t.nodeSize;let a=null;if(t.marks.forEach(e=>{if(e!==s)return!1;a=e}),!a)return;let c=!1;if(Object.keys(n).forEach(e=>{n[e]!==a.attrs[e]&&(c=!0)}),c){const t=e.type.create({...e.attrs,...n});i.removeMark(o,l,e.type),i.addMark(o,l,t)}}),i.docChanged&&t.view.dispatch(i)}(r,e,t)}})}]:[]}))}setupExtensions(){const e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zh(e.name,this.schema)};"mark"===e.type&&(null==(t=Eh(bh(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name);const r=bh(e,"onBeforeCreate",n),o=bh(e,"onCreate",n),i=bh(e,"onUpdate",n),s=bh(e,"onSelectionUpdate",n),l=bh(e,"onTransaction",n),a=bh(e,"onFocus",n),c=bh(e,"onBlur",n),u=bh(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),l&&this.editor.on("transaction",l),a&&this.editor.on("focus",a),c&&this.editor.on("blur",c),u&&this.editor.on("destroy",u)})}};xf.resolve=Nh,xf.sort=Ph,xf.flatten=vh,lp({},{ClipboardTextSerializer:()=>kf,Commands:()=>Sf,Delete:()=>Cf,Drop:()=>Tf,Editable:()=>Mf,FocusEvents:()=>If,Keymap:()=>Pf,Paste:()=>Nf,Tabindex:()=>Df,TextDirection:()=>Af,focusEventsPluginKey:()=>Of});var Ef=class e extends gf{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},kf=Ef.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new la({key:new ua("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,{ranges:i}=o,s=Math.min(...i.map(e=>e.$from.pos)),l=Math.max(...i.map(e=>e.$to.pos)),a=Ah(n);return Dh(r,{from:s,to:l},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Sf=Ef.create({name:"commands",addCommands(){return{...up}}}),Cf=Ef.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,o;const i=()=>{var n,r,o,i;if(null!=(i=null==(o=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:o.call(r,e))?i:e.getMeta("y-sync$"))return;const s=function(e,t){const n=new Ll(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}(e.before,[e,...t]),l=function(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,o)=>{const i=[];if(e.ranges.length)e.forEach((e,t)=>{i.push({from:e,to:t})});else{const{from:e,to:t}=n[o];if(void 0===e||void 0===t)return;i.push({from:e,to:t})}i.forEach(({from:e,to:n})=>{const i=t.slice(o).map(e,-1),s=t.slice(o).map(n),l=t.invert().map(i,-1),a=t.invert().map(s);r.push({oldRange:{from:l,to:a},newRange:{from:i,to:s}})})}),function(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to)})}(r)}(s);l.forEach(t=>{s.mapping.mapResult(t.oldRange.from).deletedAfter&&s.mapping.mapResult(t.oldRange.to).deletedBefore&&s.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{const o=r+n.nodeSize-2,i=t.oldRange.from<=r&&o<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:o,newFrom:s.mapping.map(r),newTo:s.mapping.map(o),deletedRange:t.oldRange,newRange:t.newRange,partial:!i,editor:this.editor,transaction:e,combinedTransform:s})})});const a=s.mapping;s.steps.forEach((t,n)=>{var r,o;if(t instanceof cl){const i=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),c=a.invert().map(i,-1),u=a.invert().map(l),d=null==(r=s.doc.nodeAt(i-1))?void 0:r.marks.some(e=>e.eq(t.mark)),p=null==(o=s.doc.nodeAt(l))?void 0:o.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:c,to:u},newRange:{from:i,to:l},partial:Boolean(p||d),editor:this.editor,transaction:e,combinedTransform:s})}})};null==(o=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||o?setTimeout(i,0):i()}}),Tf=Ef.create({name:"drop",addProseMirrorPlugins(){return[new la({key:new ua("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Mf=Ef.create({name:"editable",addProseMirrorPlugins(){return[new la({key:new ua("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Of=new ua("focusEvents"),If=Ef.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new la({key:Of,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Pf=Ef.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:o,$anchor:i}=n,{pos:s,parent:l}=i,a=i.parent.isTextblock&&s>0?t.doc.resolve(s-1):i,c=a.parent.type.spec.isolating,u=i.pos-i.parentOffset,d=c&&1===a.parent.childCount?u===i.pos:jl.atStart(r).from===s;return!(!o||!l.type.isTextblock||l.textContent.length||!d||d&&"paragraph"===i.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},o={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return zp()||Xp()?o:r},addProseMirrorPlugins(){return[new la({key:new ua("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),o=e.some(e=>e.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:s,to:l}=t.selection,a=jl.atStart(t.doc).from,c=jl.atEnd(t.doc).to;if(i||s!==a||l!==c)return;if(!Lh(n.doc))return;const u=n.tr,d=ap({state:n,transaction:u}),{commands:p}=new cp({editor:this.editor,state:d});return p.clearNodes(),u.steps.length?u:void 0}})]}}),Nf=Ef.create({name:"paste",addProseMirrorPlugins(){return[new la({key:new ua("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Df=Ef.create({name:"tabindex",addProseMirrorPlugins(){return[new la({key:new ua("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Af=Ef.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:e}=kh(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return!t||"ltr"!==t&&"rtl"!==t&&"auto"!==t?this.options.direction:t},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new la({key:new ua("textDirection"),props:{attributes:()=>{const e=this.options.direction;return e?{dir:e}:{}}}})]}}),_f=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},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(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=this.pos+r+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;const a=new e(l,this.editor,o,o?n:null);o&&(a.actualDepth=this.depth+1),t.push(new e(l,this.editor,o,o?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){const e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){const o=n[r];if(e[o]!==t[o])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const o=Object.keys(t);return this.children.forEach(i=>{n&&r.length>0||(i.node.type.name===e&&o.every(e=>t[e]===i.node.attrs[e])&&r.push(i),n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n))))}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},zf=class extends df{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>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("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),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:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),this.on("delete",this.options.onDelete);const t=this.createDoc(),n=_p(t,this.options.autofocus);this.editorState=ia.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}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&&"undefined"!=typeof document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',document.getElementsByTagName("head")[0].appendChild(r),r}(0,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&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,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if("state"===t)return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const n=xh(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let n=t;if([].concat(e).forEach(e=>{const t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;const n=[...this.options.enableCoreExtensions?[Mf,kf.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),Sf,If,Pf,Df,Tf,Nf,Cf,Af.configure({direction:this.options.textDirection})].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new xf(n,this)}createCommandManager(){this.commandManager=new cp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=fh(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message)))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=fh(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var t;this.editorView=new Ud(e,{...this.options.editorProps,attributes:{role:"textbox",...null==(t=this.options.editorProps)?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${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)return this.capturedTransaction?void e.steps.forEach(e=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)}):void(this.capturedTransaction=e);const{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),o=n.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!o)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),l=null==s?void 0:s.getMeta("focus"),a=null==s?void 0:s.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||i.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return function(e,t){const n=oh("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=bp(t,e.schema),{from:r,to:o}=e.selection,i=[];e.doc.nodesBetween(r,o,e=>{i.push(e)});const s=i.reverse().find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}(e,t):"mark"===n?gh(e,t):{}}(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return Qp(e,null,n)||$h(e,null,n);const r=oh(t,e.schema);return"node"===r?Qp(e,t,n):"mark"===r&&$h(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wh(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return Dh(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...Ah(this.schema),...n}})}get isEmpty(){return Lh(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}$node(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new _f(t,this)}get $doc(){return this.$pos(0)}};function Rf(e){return new pf({find:e.find,handler:({state:t,range:n,match:r})=>{const o=Eh(e.getAttributes,void 0,r);if(!1===o||null===o)return null;const{tr:i}=t,s=r[r.length-1],l=r[0];if(s){const r=l.search(/\S/),a=n.from+l.indexOf(s),c=a+s.length;if(_h(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>a).length)return null;c<n.to&&i.delete(c,n.to),a>n.from&&i.delete(n.from+r,a);const u=n.from+r+s.length;i.addMark(n.from+r,u,e.type.create(o||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function $f(e){if(!(null==e?void 0:e.trim()))return{};const t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const e=o.map(e=>e.trim().slice(1));t.class=e.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(t.id=i[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var o;const i=parseInt((null==(o=r.match(/__QUOTED_(\d+)__/))?void 0:o[1])||"0",10),s=n[i];s&&(t[e]=s.slice(1,-1))});const s=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return s&&s.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function Bf(e){if(!e||0===Object.keys(e).length)return"";const t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?t.push(e):!1!==n&&null!=n&&t.push(`${e}="${String(n)}"`))}),t.join(" ")}function Vf(e){const{nodeName:t,name:n,parseAttributes:r=$f,serializeAttributes:o=Bf,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=e,a=n||t;return{parseMarkdown:(e,n)=>{const r={...i,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${a}(?:\\s|$)`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,o){const i=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),l=e.match(i);if(!l)return;const c=l[1]||"",u=r(c);return s.find(e=>!(e in u))?void 0:{type:t,raw:l[0],attributes:u}}},renderMarkdown:e=>{const t=(e=>{if(!l)return e;const t={};return l.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),n=o(t);return`:::${a}${n?` {${n}}`:""} :::`}}}function Lf(e){const{nodeName:t,name:n,getContent:r,parseAttributes:o=$f,serializeAttributes:i=Bf,defaultAttributes:s={},content:l="block",allowedAttributes:a}=e,c=n||t;return{parseMarkdown:(e,n)=>{let o;if(r){const t=r(e);o="string"==typeof t?[{type:"text",text:t}]:t}else o="block"===l?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);const i={...s,...e.attributes};return n.createNode(t,i,o)},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${c}`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,r){var i;const s=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),a=e.match(s);if(!a)return;const[u,d=""]=a,p=o(d);let h=1;const f=u.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm,y=e.slice(f);for(g.lastIndex=0;;){const n=g.exec(y);if(null===n)break;const o=n.index,s=n[1];if(!(null==(i=n[2])?void 0:i.endsWith(":::")))if(s)h+=1;else if(h-=1,0===h){const i=y.slice(0,o);m=i.trim();const s=e.slice(0,f+o+n[0].length);let a=[];if(m)if("block"===l)for(a=r.blockTokens(i),a.forEach(e=>{!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=r.inlineTokens(e.text))});a.length>0;){const e=a[a.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;a.pop()}else a=r.inlineTokens(m);return{type:t,raw:s,attributes:p,content:m,tokens:a}}}}},renderMarkdown:(e,t)=>{const n=(e=>{if(!a)return e;const t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),r=i(n),o=r?` {${r}}`:"",s=t.renderChildren(e.content||[],"\n\n");return`:::${c}${o}\n\n${s}\n\n:::`}}}function Ff(e){if(!e.trim())return{};const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;null!==r;){const[,o,i,s]=r;t[o]=i||s,r=n.exec(e)}return t}function jf(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function Uf(e){const{nodeName:t,name:n,getContent:r,parseAttributes:o=Ff,serializeAttributes:i=jf,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=e,c=n||t,u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{const o={...s,...e.attributes};if(l)return n.createNode(t,o);const i=r?r(e):e.content||"";return i?n.createNode(t,o,[n.createTextNode(i)]):n.createNode(t,o,[])},markdownTokenizer:{name:t,level:"inline",start(e){const t=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){const i=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),s=e.match(i);if(!s)return;let a="",c="";if(l){const[,e]=s;c=e}else{const[,e,t]=s;c=e,a=t||""}const d=o(c.trim());return{type:t,raw:s[0],content:a.trim(),attributes:d}}},renderMarkdown:e=>{let t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));const n=(e=>{if(!a)return e;const t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),o=i(n),s=o?` ${o}`:"";return l?`[${c}${s}]`:`[${c}${s}]${t}[/${c}]`}}}function Wf(e,t,n){var r,o,i,s;const l=e.split("\n"),a=[];let c="",u=0;const d=t.baseIndentSize||2;for(;u<l.length;){const e=l[u],p=e.match(t.itemPattern);if(!p){if(a.length>0)break;if(""===e.trim()){u+=1,c=`${c}${e}\n`;continue}return}const h=t.extractItemData(p),{indentLevel:f,mainContent:m}=h;c=`${c}${e}\n`;const g=[m];for(u+=1;u<l.length;){const e=l[u];if(""===e.trim()){const t=l.slice(u+1).findIndex(e=>""!==e.trim());if(-1===t)break;if(((null==(o=null==(r=l[u+1+t].match(/^(\s*)/))?void 0:r[1])?void 0:o.length)||0)>f){g.push(e),c=`${c}${e}\n`,u+=1;continue}break}if(!(((null==(s=null==(i=e.match(/^(\s*)/))?void 0:i[1])?void 0:s.length)||0)>f))break;g.push(e),c=`${c}${e}\n`,u+=1}let y;const b=g.slice(1);if(b.length>0){const e=b.map(e=>e.slice(f+d)).join("\n");e.trim()&&(y=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}const v=t.createToken(h,y);a.push(v)}if(0!==a.length)return{items:a,raw:c}}function Gf(e,t,n,r){if(!e||!Array.isArray(e.content))return"";const o="function"==typeof n?n(r):n,[i,...s]=e.content,l=[`${o}${t.renderChildren([i])}`];return s&&s.length>0&&s.forEach(e=>{const n=t.renderChildren([e]);if(n){const e=n.split("\n").map(e=>e?t.indent(e):"").join("\n");l.push(e)}}),l.join("\n")}lp({},{createAtomBlockMarkdownSpec:()=>Vf,createBlockMarkdownSpec:()=>Lf,createInlineMarkdownSpec:()=>Uf,parseAttributes:()=>$f,parseIndentedBlocks:()=>Wf,renderNestedMarkdownContent:()=>Gf,serializeAttributes:()=>Bf});var Hf=class e extends gf{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};function qf(e){return new bf({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{const i=Eh(e.getAttributes,void 0,r,o);if(!1===i||null===i)return null;const{tr:s}=t,l=r[r.length-1],a=r[0];let c=n.to;if(l){const r=a.search(/\S/),o=n.from+a.indexOf(l),u=o+l.length;if(_h(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>o).length)return null;u<n.to&&s.delete(u,n.to),o>n.from&&s.delete(n.from+r,o),c=n.from+r+l.length,s.addMark(n.from+r,c,e.type.create(i||{})),s.removeStoredMark(e.type)}}})}var Jf=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);const{children:n,...r}=null!=t?t:{};if("svg"===e)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Kf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Yf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Xf=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Zf=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Qf=yf.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Jf("strong",{...Ch(this.options.HTMLAttributes,e),children:Jf("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Rf({find:Kf,type:this.type}),Rf({find:Xf,type:this.type})]},addPasteRules(){return[qf({find:Yf,type:this.type}),qf({find:Zf,type:this.type})]}}),em=Hf.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),tm=Hf.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",Ch(this.options.HTMLAttributes,e)]},renderText(){return"\n"},renderMarkdown:()=>" \n",parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:e,storedMarks:o}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=r.extensionManager,l=o||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&l&&i){const t=l.filter(e=>s.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),nm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,rm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,om=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,im=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sm=yf.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Ch(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Rf({find:nm,type:this.type}),Rf({find:om,type:this.type})]},addPasteRules(){return[qf({find:rm,type:this.type}),qf({find:im,type:this.type})]}}),lm=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,am=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,cm=yf.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}]},renderHTML({HTMLAttributes:e}){return["s",Ch(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Rf({find:lm,type:this.type})]},addPasteRules(){return[qf({find:am,type:this.type})]}}),um=yf.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return"sub"===e&&null}}]},renderHTML({HTMLAttributes:e}){return["sub",Ch(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),dm=yf.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return"super"===e&&null}}]},renderHTML({HTMLAttributes:e}){return["sup",Ch(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),pm=Hf.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),hm=yf.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}]},renderHTML({HTMLAttributes:e}){return["u",Ch(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;const o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),fm=window.ReactDOM,mm=n(6886),gm=n(9370),ym=n(8061),bm=n(5544),vm=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},wm=({contentComponent:e})=>{const t=(0,mm.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,gm.jsx)(gm.Fragment,{children:Object.values(t)})},xm=class extends e.Component{constructor(t){var n;super(t),this.editorContentRef=e.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null==(n=t.editor)?void 0:n.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.view.dom),e.setOptions({element:t}),e.contentComponent=function(){const e=new Set;let t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:fm.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(e=>e())}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var e;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.firstChild))return;const n=document.createElement("div");n.append(t.view.dom),t.setOptions({element:n})}catch{}}}render(){const{editor:e,innerRef:t,...n}=this.props;return(0,gm.jsxs)(gm.Fragment,{children:[(0,gm.jsx)("div",{ref:vm(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&(0,gm.jsx)(wm,{contentComponent:e.contentComponent})]})}},Em=(0,e.forwardRef)((t,n)=>{const r=e.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[t.editor]);return e.createElement(xm,{key:r,innerRef:n,...t})}),km=e.memo(Em),Sm="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Cm=class{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.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 e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Tm(t){var n;const[r]=(0,e.useState)(()=>new Cm(t.editor)),o=(0,bm.useSyncExternalStoreWithSelector)(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,null!=(n=t.equalityFn)?n:ym);return Sm(()=>r.watch(t.editor),[t.editor,r]),(0,e.useDebugValue)(o),o}var Mm="undefined"==typeof window,Om=Mm||Boolean("undefined"!=typeof window&&window.next),Im=class e{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(e=>e())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?Mm||Om?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}};return new zf(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(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))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(()=>{this.isComponentMounted&&this.instanceId===e?t&&t.setOptions(this.options.current):t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};(0,e.createContext)({editor:null}).Consumer;var Pm=(0,e.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});e.forwardRef((t,n)=>{const{onDragStart:r}=(0,e.useContext)(Pm),o=t.as||"div";return(0,gm.jsx)(o,{...t,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})}),e.createContext({markViewContentRef:()=>{}});const Nm={clear:{label:(0,i.__)("Clear","elementor"),icon:e.createElement(R.MinusIcon,{fontSize:"tiny"}),action:"clear",method:e=>{e.chain().focus().clearNodes().unsetAllMarks().run()}},bold:{label:(0,i.__)("Bold","elementor"),icon:e.createElement(R.BoldIcon,{fontSize:"tiny"}),action:"bold",method:e=>{e.chain().focus().toggleBold().run()}},italic:{label:(0,i.__)("Italic","elementor"),icon:e.createElement(R.ItalicIcon,{fontSize:"tiny"}),action:"italic",method:e=>{e.chain().focus().toggleItalic().run()}},underline:{label:(0,i.__)("Underline","elementor"),icon:e.createElement(R.UnderlineIcon,{fontSize:"tiny"}),action:"underline",method:e=>{e.chain().focus().toggleUnderline().run()}},strike:{label:(0,i.__)("Strikethrough","elementor"),icon:e.createElement(R.StrikethroughIcon,{fontSize:"tiny"}),action:"strike",method:e=>{e.chain().focus().toggleStrike().run()}},superscript:{label:(0,i.__)("Superscript","elementor"),icon:e.createElement(R.SuperscriptIcon,{fontSize:"tiny"}),action:"superscript",method:e=>{e.chain().focus().toggleSuperscript().run()}},subscript:{label:(0,i.__)("Subscript","elementor"),icon:e.createElement(R.SubscriptIcon,{fontSize:"tiny"}),action:"subscript",method:e=>{e.chain().focus().toggleSubscript().run()}}},{clear:Dm,...Am}=Nm,_m=Object.keys(Am),zm=({editor:t})=>{const n=Tm({editor:t,selector:e=>_m.filter(t=>e.editor.isActive(t))}),r=(0,e.useMemo)(()=>Object.values(Am),[]);return e.createElement(o.Box,{sx:{position:"absolute",top:-40,display:"inline-flex",gap:.5,padding:.5,borderRadius:1,backgroundColor:"background.paper",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)",alignItems:"center"}},e.createElement(o.Tooltip,{title:Dm.label,placement:"top"},e.createElement(o.IconButton,{"aria-label":Dm.label,onClick:()=>Dm.method(t),size:"tiny"},Dm.icon)),e.createElement(o.ToggleButtonGroup,{value:n,size:"tiny",sx:{display:"flex",gap:.5}},r.map(n=>e.createElement(o.Tooltip,{title:n.label,key:n.action,placement:"top"},e.createElement(o.ToggleButton,{value:n.action,"aria-label":n.label,size:"tiny",onClick:()=>n.method(t)},n.icon)))))};function Rm(){return Rm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Rm.apply(null,arguments)}const $m=e.forwardRef(({value:t,setValue:n,attributes:r={},showToolbar:i=!1,sx:s},l)=>{const a=function(t={},n=[]){const r=(0,e.useRef)(t);r.current=t;const[o]=(0,e.useState)(()=>new Im(r)),i=(0,mm.useSyncExternalStore)(o.subscribe,o.getEditor,o.getServerSnapshot);return(0,e.useDebugValue)(i),(0,e.useEffect)(o.onRender(n)),Tm({editor:i,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction||void 0===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),i}({extensions:[em.extend({content:"inline*"}),pm,Qf,sm,cm,hm,dm,um,tm.extend({addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.setHardBreak()}}})],content:t,onUpdate:({editor:e})=>n(e.getHTML())});return((n,r)=>{const o=(0,e.useRef)(!1);(0,e.useEffect)(()=>{o.current?(()=>{if(!a)return;a.getHTML()!==t&&a.commands.setContent(t,{emitUpdate:!1})})():o.current=!0},r)})(0,[a,t]),e.createElement(o.Box,Rm({ref:l,sx:{p:.8,border:"1px solid",borderColor:"grey.200",borderRadius:"8px",transition:"border-color .2s ease, box-shadow .2s ease","&:hover":{borderColor:"black"},"&:focus-within":{borderColor:"black",boxShadow:"0 0 0 1px black"},"& .ProseMirror:focus":{outline:"none"},"& .ProseMirror":{minHeight:"70px",fontSize:"12px"},...s}},r),i&&e.createElement(zm,{editor:a}),e.createElement(km,{editor:a}))}),Bm=M(()=>{const{value:n,setValue:r}=b(t.htmlPropTypeUtil);return e.createElement(G,null,e.createElement($m,{value:n||"",setValue:e=>r(e)}))}),Vm=(0,o.styled)(o.IconButton)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Lm=({tooltipText:t,onClick:n,disabled:r,size:i="tiny"})=>e.createElement(o.Tooltip,{title:t,placement:"top",disableInteractive:!0},e.createElement(Vm,{"aria-label":t,size:i,onClick:n,disabled:r},e.createElement(R.BrushBigIcon,{fontSize:i})));function Fm(){return Fm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fm.apply(null,arguments)}const jm="tiny",Um=({label:t,itemSettings:n,disabled:r=!1,openOnAdd:s=!1,values:l=[],setValues:a,showDuplicate:c=!0,showToggle:u=!0,showRemove:d=!0,disableAddItemButton:p=!1,addButtonInfotipContent:h,openItem:f=-1,isSortable:m=!0})=>{const[g,y]=(0,e.useState)(f),b=l.map((e,t)=>m&&"getId"in n?n.getId({item:e,index:t}):String(t)),v=r||p,w=v&&h,x=e.createElement(o.IconButton,{size:jm,sx:{ml:"auto"},disabled:v,onClick:()=>{const e=structuredClone(n.initialValues),t=l.length;a([...l,e],{},{action:{type:"add",payload:[{index:t,item:e}]}}),s&&y(t)},"aria-label":(0,i.__)("Add item","elementor")},e.createElement(R.PlusIcon,{fontSize:jm}));return e.createElement(Te,{gap:2},e.createElement(Ct,{label:t,adornment:St},w?e.createElement(o.Infotip,{placement:"right",content:h,color:"secondary",slotProps:{popper:{sx:{width:300}}}},e.createElement(o.Box,{sx:{...v?{cursor:"not-allowed"}:{}}},x)):x),0<b.length&&e.createElement(je,{value:b,onChange:(e,t)=>{a(e.map(e=>l[b.indexOf(e)]),{},{action:{type:"reorder",payload:{...t}}})}},b.map(t=>{const o=b.indexOf(t),i=l[o];return i?e.createElement(Ue,{id:t,key:`sortable-${t}`,disabled:!m},e.createElement(Wm,{disabled:r,propDisabled:i?.disabled,label:e.createElement(tt,{value:i},e.createElement(n.Label,{value:i,index:o})),startIcon:e.createElement(Qe,{value:i},e.createElement(n.Icon,{value:i})),removeItem:()=>(e=>{const t=l[e];a(l.filter((t,n)=>n!==e),{},{action:{type:"remove",payload:[{index:e,item:t}]}})})(o),duplicateItem:()=>(e=>{const t=structuredClone(l[e]),n=1+e;a([...l.slice(0,n),t,...l.slice(n)],{},{action:{type:"duplicate",payload:[{index:e,item:t}]}})})(o),toggleDisableItem:()=>(e=>{a(l.map((t,n)=>{if(n===e){const{disabled:e,...n}=t;return{...n,...e?{}:{disabled:!0}}}return t}),{},{action:{type:"toggle-disable"}})})(o),openOnMount:s&&g===o,onOpen:()=>y(-1),showDuplicate:c,showToggle:u,showRemove:d,actions:n.actions,value:i},t=>e.createElement(n.Content,Fm({},t,{value:i,bind:String(o),index:o})))):null})))},Wm=({label:t,propDisabled:n,startIcon:r,children:s,removeItem:l,duplicateItem:a,toggleDisableItem:c,openOnMount:u,onOpen:d,showDuplicate:p,showToggle:h,showRemove:f,disabled:m,actions:g,value:y})=>{const{popoverState:b,popoverProps:v,ref:w,setRef:x}=Gm(u,d),E=(0,i.__)("Duplicate","elementor"),k=n?(0,i.__)("Show","elementor"):(0,i.__)("Hide","elementor"),S=(0,i.__)("Remove","elementor");return e.createElement(e.Fragment,null,e.createElement(Xe,Fm({disabled:m,label:t,ref:x,"aria-label":(0,i.__)("Open item","elementor")},(0,o.bindTrigger)(b),{startIcon:r,actions:e.createElement(e.Fragment,null,p&&e.createElement(o.Tooltip,{title:E,placement:"top"},e.createElement(o.IconButton,{size:jm,onClick:a,"aria-label":E},e.createElement(R.CopyIcon,{fontSize:jm}))),h&&e.createElement(o.Tooltip,{title:k,placement:"top"},e.createElement(o.IconButton,{size:jm,onClick:c,"aria-label":k},n?e.createElement(R.EyeOffIcon,{fontSize:jm}):e.createElement(R.EyeIcon,{fontSize:jm}))),g?.(y),f&&e.createElement(o.Tooltip,{title:S,placement:"top"},e.createElement(o.IconButton,{size:jm,onClick:l,"aria-label":S},e.createElement(R.XIcon,{fontSize:jm}))))})),e.createElement(mt,Fm({width:w?.getBoundingClientRect().width},v,{anchorEl:w}),e.createElement(o.Box,null,s({anchorEl:w}))))},Gm=(t,n)=>{const[r,i]=(0,e.useState)(null),s=(0,o.usePopupState)({variant:"popover"}),l=(0,o.bindPopover)(s);return(0,e.useEffect)(()=>{t&&r&&(s.open(r),n?.())},[r]),{popoverState:s,ref:r,setRef:i,popoverProps:l}}}(),(window.elementorV2=window.elementorV2||{}).editorControls=r}(),window.elementorV2.editorControls?.init?.(); |