@velora-cms/server 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/admin/sync-admin-bundle.d.ts +9 -0
  2. package/dist/admin/sync-admin-bundle.js +120 -0
  3. package/dist/admin-bundle/.velora-version +1 -0
  4. package/dist/admin-bundle/assets/{_virtual_mf-localSharedImportMap___mfe_internal__velora_admin__mf_owner__1-DOKdWYyj.js → _virtual_mf-localSharedImportMap___mfe_internal__velora_admin__mf_owner__1-DlIgIuFP.js} +1 -1
  5. package/dist/admin-bundle/assets/{_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare___mf_0_velora_mf_2_cms_mf_1_plugin_mf_2_sdk__loadShare__.js-C1-ZAxwO.js → _virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare___mf_0_velora_mf_2_cms_mf_1_plugin_mf_2_sdk__loadShare__.js-Bm9EahCG.js} +2 -2
  6. package/dist/admin-bundle/assets/{content-trash.schema-DfXHkC-w.js → content-trash.schema-tvJ4Lbos.js} +5 -5
  7. package/dist/admin-bundle/assets/{hostInit--C4xK6nj.js → hostInit-B-6-34XY.js} +1 -1
  8. package/dist/admin-bundle/assets/{index-DhMY-0sC.js → index-CHCGuSbb.js} +1 -1
  9. package/dist/admin-bundle/assets/{index-BIAF0ShP.js → index-DYO7-IK8.js} +33 -33
  10. package/dist/admin-bundle/assets/{mf-entry-bootstrap-0-aef015cd.js → mf-entry-bootstrap-0-7b0ce2fe.js} +2 -2
  11. package/dist/admin-bundle/assets/{remoteEntry-CNyN68bc.js → remoteEntry-J2yJXsGB.js} +2 -2
  12. package/dist/admin-bundle/index.html +4 -4
  13. package/dist/app.d.ts +16 -1
  14. package/dist/app.js +63 -4
  15. package/dist/auth/api-keys.d.ts +1 -0
  16. package/dist/auth/api-keys.js +5 -1
  17. package/dist/auth/route-rate-limits.d.ts +4 -0
  18. package/dist/auth/route-rate-limits.js +13 -0
  19. package/dist/bin-sync-admin.d.ts +2 -0
  20. package/dist/bin-sync-admin.js +39 -0
  21. package/dist/bundled-templates/com.velora.blog/package.tar.gz +0 -0
  22. package/dist/config/public-url.d.ts +3 -0
  23. package/dist/config/public-url.js +45 -0
  24. package/dist/db/core-migrations/steps.js +95 -16
  25. package/dist/docs-bundle/pagefind/fragment/en_42f5356.pf_fragment +0 -0
  26. package/dist/docs-bundle/pagefind/fragment/en_67dccf8.pf_fragment +0 -0
  27. package/dist/docs-bundle/pagefind/fragment/en_80941b8.pf_fragment +0 -0
  28. package/dist/docs-bundle/pagefind/fragment/en_a64440b.pf_fragment +0 -0
  29. package/dist/docs-bundle/pagefind/fragment/en_eb168aa.pf_fragment +0 -0
  30. package/dist/docs-bundle/pagefind/index/en_8450ec7.pf_index +0 -0
  31. package/dist/docs-bundle/pagefind/index/en_c285f7b.pf_index +0 -0
  32. package/dist/docs-bundle/pagefind/index/en_e8cada7.pf_index +0 -0
  33. package/dist/docs-bundle/pagefind/pagefind-entry.json +1 -1
  34. package/dist/docs-bundle/pagefind/pagefind.en_57d2f8922f.pf_meta +0 -0
  35. package/dist/docs-bundle/v1/using-velora/getting-started/index.html +5 -3
  36. package/dist/docs-bundle/v1/using-velora/headless-api/index.html +10 -4
  37. package/dist/docs-bundle/v1/using-velora/index.html +6 -4
  38. package/dist/docs-bundle/v1/using-velora/installation/index.html +73 -15
  39. package/dist/docs-bundle/v1/using-velora/media/index.html +118 -34
  40. package/dist/graphql/schema.d.ts +1 -0
  41. package/dist/graphql/schema.js +5 -2
  42. package/dist/lib.d.ts +1 -0
  43. package/dist/lib.js +45 -11
  44. package/dist/media/media-service.d.ts +14 -15
  45. package/dist/media/media-service.js +121 -59
  46. package/dist/media/media-tokens.d.ts +6 -0
  47. package/dist/media/media-tokens.js +88 -0
  48. package/dist/media/storage/local.d.ts +16 -0
  49. package/dist/media/storage/local.js +99 -0
  50. package/dist/media/storage/s3.d.ts +25 -0
  51. package/dist/media/storage/s3.js +134 -0
  52. package/dist/media/storage/types.d.ts +21 -0
  53. package/dist/media/storage/types.js +44 -0
  54. package/dist/routes/admin-static.d.ts +2 -0
  55. package/dist/routes/admin-static.js +42 -4
  56. package/dist/routes/media-public.d.ts +6 -0
  57. package/dist/routes/media-public.js +265 -0
  58. package/dist/routes/media.d.ts +2 -1
  59. package/dist/routes/media.js +95 -5
  60. package/dist/routes/plugin-storage.js +5 -1
  61. package/dist/routes/public-api.js +5 -3
  62. package/dist/routes/published-item.d.ts +2 -1
  63. package/dist/routes/published-item.js +28 -5
  64. package/dist/scripts/copy-admin-bundle.js +9 -1
  65. package/package.json +7 -6
  66. package/prisma/schema.prisma +16 -3
  67. package/dist/docs-bundle/pagefind/fragment/en_1d9eb24.pf_fragment +0 -0
  68. package/dist/docs-bundle/pagefind/fragment/en_3099406.pf_fragment +0 -0
  69. package/dist/docs-bundle/pagefind/fragment/en_9aa652e.pf_fragment +0 -0
  70. package/dist/docs-bundle/pagefind/fragment/en_d855550.pf_fragment +0 -0
  71. package/dist/docs-bundle/pagefind/fragment/en_e6d88d8.pf_fragment +0 -0
  72. package/dist/docs-bundle/pagefind/index/en_5feeed7.pf_index +0 -0
  73. package/dist/docs-bundle/pagefind/index/en_c6981f9.pf_index +0 -0
  74. package/dist/docs-bundle/pagefind/index/en_ce4f6bf.pf_index +0 -0
  75. package/dist/docs-bundle/pagefind/pagefind.en_1e94abd852.pf_meta +0 -0
@@ -1 +1 @@
1
- import{_}from"./vite-preload-helper-Cgledu0r.js";const u="__mf_module_cache__";globalThis[u]||={share:{},remote:{}};globalThis[u].share||={};globalThis[u].remote||={};const s=globalThis[u];for(const i of Object.keys(s.share))if(i.startsWith("default:")){const f=i.slice(8);s.share[f]===void 0&&(s.share[f]=s.share[i])}else if(!i.includes(":")){const f="default:"+i;s.share[f]===void 0&&(s.share[f]=s.share[i])}let h;async function C(){return h||(h=(async()=>{const i=(a,e,t,r)=>{const n=(Array.isArray(r)?r[0]:r)||"default",c=e||!t?a:a+"@"+t,l={canonical:n+":"+c};return n==="default"&&(l.aliases=[c]),l},f=(a,e)=>{const t=a[e.canonical];if(t!==void 0)return t;const r=e.aliases||[];for(const o of r){if(!Object.prototype.hasOwnProperty.call(a,o))continue;const n=a[o];if(n!==void 0)return a[e.canonical]=n,n}},y=Symbol.for("module-federation.shared-cache-listeners"),d=Symbol.for("module-federation.shared-cache-owners"),b=a=>{let e=a[d];return e===void 0&&(e=Object.create(null),Object.defineProperty(a,d,{value:e,enumerable:!1,configurable:!1,writable:!1})),e},S=(a,e)=>{var t;return(t=a[d])==null?void 0:t[e.canonical]},w=(a,e,t,r)=>{var c;a[e.canonical]=t;const o=e.aliases||[];for(const l of o)Object.defineProperty(a,l,{value:t,enumerable:!0,configurable:!0,writable:!0});a[d],b(a)[e.canonical]=r;const n=(c=a[y])==null?void 0:c[e.canonical];if(n)for(const l of n)l(t);return t},m=await(await _(()=>import("./remoteEntry-CNyN68bc.js"),[])).init(),{usedShared:g}=await _(async()=>{const{usedShared:a}=await import("./_virtual_mf-localSharedImportMap___mfe_internal__velora_admin__mf_owner__1-DOKdWYyj.js");return{usedShared:a}},[]),O=a=>{let e=a;for(let t=0;t<5;t++){const r=e==null?void 0:e.default;if(!r||typeof r!="object"||Object.keys(r).length===0)break;const o=Object.keys(e).filter(n=>n!=="default").map(n=>e[n]);if(o.length>0&&o.some(n=>n!==void 0))break;e=r}return e},p=[["react"],["react-dom","@velora-cms/plugin-sdk"]];for(const a of p)await Promise.all(a.map(async e=>{var o;const t=g[e];if(!t||t.materialize===!1||t.treeShaking)return;const r=i(e,(o=t.shareConfig)==null?void 0:o.singleton,t.version,t.scope);f(s.share,r)!==void 0&&S(s.share,r)==="velora_admin"||await m.loadShare(e,{customShareInfo:{shareConfig:t.shareConfig}}).then(async n=>{const c=typeof n=="function"?n():n;let l=O(await Promise.resolve(c));w(s.share,r,l,"velora_admin")})}));return m})()),h}h=C();export{h as hostInitPromise,C as initHost};
1
+ import{_}from"./vite-preload-helper-Cgledu0r.js";const u="__mf_module_cache__";globalThis[u]||={share:{},remote:{}};globalThis[u].share||={};globalThis[u].remote||={};const s=globalThis[u];for(const i of Object.keys(s.share))if(i.startsWith("default:")){const f=i.slice(8);s.share[f]===void 0&&(s.share[f]=s.share[i])}else if(!i.includes(":")){const f="default:"+i;s.share[f]===void 0&&(s.share[f]=s.share[i])}let h;async function C(){return h||(h=(async()=>{const i=(a,e,t,r)=>{const n=(Array.isArray(r)?r[0]:r)||"default",c=e||!t?a:a+"@"+t,l={canonical:n+":"+c};return n==="default"&&(l.aliases=[c]),l},f=(a,e)=>{const t=a[e.canonical];if(t!==void 0)return t;const r=e.aliases||[];for(const o of r){if(!Object.prototype.hasOwnProperty.call(a,o))continue;const n=a[o];if(n!==void 0)return a[e.canonical]=n,n}},y=Symbol.for("module-federation.shared-cache-listeners"),d=Symbol.for("module-federation.shared-cache-owners"),b=a=>{let e=a[d];return e===void 0&&(e=Object.create(null),Object.defineProperty(a,d,{value:e,enumerable:!1,configurable:!1,writable:!1})),e},S=(a,e)=>{var t;return(t=a[d])==null?void 0:t[e.canonical]},w=(a,e,t,r)=>{var c;a[e.canonical]=t;const o=e.aliases||[];for(const l of o)Object.defineProperty(a,l,{value:t,enumerable:!0,configurable:!0,writable:!0});a[d],b(a)[e.canonical]=r;const n=(c=a[y])==null?void 0:c[e.canonical];if(n)for(const l of n)l(t);return t},m=await(await _(()=>import("./remoteEntry-J2yJXsGB.js"),[])).init(),{usedShared:g}=await _(async()=>{const{usedShared:a}=await import("./_virtual_mf-localSharedImportMap___mfe_internal__velora_admin__mf_owner__1-DlIgIuFP.js");return{usedShared:a}},[]),O=a=>{let e=a;for(let t=0;t<5;t++){const r=e==null?void 0:e.default;if(!r||typeof r!="object"||Object.keys(r).length===0)break;const o=Object.keys(e).filter(n=>n!=="default").map(n=>e[n]);if(o.length>0&&o.some(n=>n!==void 0))break;e=r}return e},p=[["react"],["react-dom","@velora-cms/plugin-sdk"]];for(const a of p)await Promise.all(a.map(async e=>{var o;const t=g[e];if(!t||t.materialize===!1||t.treeShaking)return;const r=i(e,(o=t.shareConfig)==null?void 0:o.singleton,t.version,t.scope);f(s.share,r)!==void 0&&S(s.share,r)==="velora_admin"||await m.loadShare(e,{customShareInfo:{shareConfig:t.shareConfig}}).then(async n=>{const c=typeof n=="function"?n():n;let l=O(await Promise.resolve(c));w(s.share,r,l,"velora_admin")})}));return m})()),h}h=C();export{h as hostInitPromise,C as initHost};
@@ -1,4 +1,4 @@
1
- import{h as Ca,y as Hd,z as I,A as qe,D as yr,E as O,F as Vs,_ as jd,G as $n,H as va,J as H,K as br,L as Ta,M as Wd,Z as Ud,N as Ea,v as vr,I as Ot,w as sn,B as Kd,s as _s,C as qd}from"./content-trash.schema-DfXHkC-w.js";import{x as lS,S as aS}from"./content-trash.schema-DfXHkC-w.js";import{_ as D,b as Gt,a as Hs}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DMaku-HC.js";import{b as on,a as ln,f as _e,g as Yt,d as Ma,w as Aa,t as Nt,p as Jd,h as Gd,c as Do}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react__loadShare__.js-BuUBskgj.js";import{c as Yd}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_2_dom__loadShare__.js-DYfqn12F.js";import{_ as Xd}from"./__virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react__loadShare__.js_commonjs-proxy-Ng0fOpdU.js";import"./__virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_2_dom__loadShare__.js_commonjs-proxy-oc1i_iBU.js";function G1({className:n,...e}){return D("div",{"data-slot":"panel",className:Ca("rounded-lg border border-border-default bg-background-elevated p-6 shadow-sm",n),...e})}const q=n=>Vs(e=>typeof e=="function",{message:`${n} must be a function`}),mt=Vs(n=>typeof n=="function"||typeof n=="object"&&n!==null,{message:"must be a React component"}),Ro=Vs(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),{message:"must be a JSON Schema object"}),Ii=jd(Ud),Tr=O().regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/i,"must be a reverse-domain id like com.vendor.plugin"),Io=$n(["postgresql","mysql","sqlite","mssql","mongodb"]),Qd=I({storageType:$n(["simple","structured"]),supported:H(Io).min(1),unsupportedReason:va(Io,O()).optional()}).strict(),Zd=I({needsStructuredData:br(),needsExternalNetwork:br(),needsFileSystemAccess:br()}).strict(),ef=I({id:O().min(1),name:O().min(1),up:q("up"),down:q("down")}).strict(),tf=I({beforeMigration:q("beforeMigration").optional(),transformRow:q("transformRow").optional(),afterMigration:q("afterMigration").optional(),validateMigration:q("validateMigration").optional()}).strict(),nf=["content:beforeSave","content:afterSave","content:beforePublish","content:afterPublish","content:afterTrash","content:afterRestore","content:beforeDelete","media:afterUpload","user:afterLogin","api:beforeResponse"],js=va($n(nf),q("hook handler")),Ws=I({id:Tr,name:O().min(1),icon:O().min(1),version:O().min(1),type:qe("datatype"),schema:Ro,settingsSchema:Ro,defaultSettings:yr(O(),Ta()),views:I({input:mt,readOnly:mt,settings:mt,preview:mt.optional()}).strict(),serialize:q("serialize"),deserialize:q("deserialize")}).strict(),rf=I({id:O().min(1),name:O().min(1),icon:O().min(1),view:mt,adminOnly:br().optional()}).strict(),Oa=I({id:O().min(1),name:O().min(1),view:mt}).strict(),sf=I({method:$n(["GET","POST","PUT","PATCH","DELETE"]),path:O().min(1).refine(n=>n.startsWith("/"),{message:'path must start with "/"'}),access:$n(["admin","apiKey","public"]).optional(),schema:I({body:Ii.optional(),querystring:Ii.optional(),params:Ii.optional()}).strict().optional(),handler:q("handler")}).strict(),of=I({name:O().regex(/^[a-z0-9-]+$/),build:q("build")}).strict(),Na=I({extendContentResponse:q("extendContentResponse").optional(),customFormats:H(of).optional()}).strict().superRefine((n,e)=>{const t=(n.customFormats??[]).map(r=>r.name);new Set(t).size!==t.length&&e.addIssue({code:"custom",message:"customFormats names must be unique within a manifest"})}),Da=I({id:O().min(1),name:O().min(1),cron:O().min(1),run:q("run")}).strict(),Ra=I({id:O().min(1),name:O().min(1),process:q("process")}).strict(),yi=I({id:O().min(1),name:O().min(1),view:mt}).strict(),lf=I({id:O().min(1),label:O().min(1),onSelect:q("onSelect")}).strict(),af=I({id:O().min(1),label:O().min(1),icon:O().min(1),onClick:q("onClick")}).strict(),cf=I({id:O().min(1),name:O().min(1),service:Ta()}).strict(),Ia=I({name:O().min(1),description:O().optional(),repository:O().optional()}).strict(),hn=O().max(200).regex(new RegExp("^[^{};\\u0000-\\u001f\\u007f]+$"),"must not contain CSS-escaping characters"),uf=I({color:yr(hn,yr(hn,hn)).optional(),radius:yr(hn,hn).optional()}).strict(),df=I({dataTypes:H(Ws).optional(),mediaProcessors:H(Ra).optional(),settingsPages:H(yi).optional()}).strict(),ff=I({dataTypes:H(Ws).optional(),adminSections:H(rf).optional(),dashboardWidgets:H(Oa).optional(),apiRoutes:H(sf).optional(),hooks:js.optional(),scheduledTasks:H(Da).optional(),settingsPages:H(yi).optional(),documentTypes:H(Ea).optional(),bundledTemplate:Ia.optional()}).strict().superRefine((n,e)=>{const t=new Set;(n.apiRoutes??[]).forEach((r,i)=>{const s=`${r.method} ${r.path}`;t.has(s)&&e.addIssue({code:"custom",message:`Duplicate apiRoute "${s}" — method+path pairs must be unique within a manifest`,path:["apiRoutes",i]}),t.add(s)})}),hf=I({documentTypes:H(Ea).optional()}).strict(),pf=I({themeTokens:uf.optional()}).strict(),mf=I({hooks:js.optional(),settingsPages:H(yi).optional(),exposedServices:H(cf).optional(),serializers:Na.optional()}).strict(),gf=I({dashboardWidgets:H(Oa).optional(),hooks:js.optional(),scheduledTasks:H(Da).optional(),mediaProcessors:H(Ra).optional(),settingsPages:H(yi).optional(),contentTreeActions:H(lf).optional(),editorToolbar:H(af).optional(),serializers:Na.optional()}).strict(),yf=I({bundledPlugins:H(Tr).optional(),bundledTemplate:Ia.optional()}).strict(),ft={id:Tr,name:O().min(1),version:O().min(1),description:O().min(1),author:O().min(1),license:O().min(1),price:Wd().nonnegative().optional(),signature:O().optional(),cmsVersion:O().min(1),pluginDependencies:H(Tr).optional(),databaseCompatibility:Qd,permissions:Zd,migrations:H(ef).optional(),onInstall:q("onInstall").optional(),onUninstall:q("onUninstall").optional(),onActivate:q("onActivate").optional(),onDeactivate:q("onDeactivate").optional(),onUpdate:q("onUpdate").optional(),migrationHooks:tf.optional()},bf=Hd("type",[I({...ft,type:qe("datatype"),contributions:df}).strict(),I({...ft,type:qe("section"),contributions:ff}).strict(),I({...ft,type:qe("template"),contributions:hf}).strict(),I({...ft,type:qe("theme"),contributions:pf}).strict(),I({...ft,type:qe("integration"),contributions:mf}).strict(),I({...ft,type:qe("utility"),contributions:gf}).strict(),I({...ft,type:qe("bundle"),contributions:yf}).strict()]);function Pa(n){return n.map(e=>{const t=e.path.join(".");return t?`${t}: ${e.message}`:e.message})}function Y1(n){const e=bf.safeParse(n);return e.success?{ok:!0,manifest:e.data}:{ok:!1,errors:Pa(e.error.issues)}}class Po extends Error{constructor(e){super(e),this.name="PluginDefinitionError"}}const kf=["input","readOnly","settings"];function Sf(n){const e=typeof n=="object"&&n!==null&&typeof n.id=="string"?n.id:"(unknown id)",t=typeof n=="object"&&n!==null?n.views:void 0;for(const i of kf)if(!t||t[i]==null)throw new Po(`definePlugin: datatype plugin "${e}" is missing required view "${i}" (input, readOnly and settings are required; preview is optional)`);const r=Ws.safeParse(n);if(!r.success)throw new Po(`definePlugin: datatype plugin "${e}" is invalid:
1
+ import{h as Ca,y as Hd,z as I,A as qe,D as yr,E as O,F as Vs,_ as jd,G as $n,H as va,J as H,K as br,L as Ta,M as Wd,Z as Ud,N as Ea,v as vr,I as Ot,w as sn,B as Kd,s as _s,C as qd}from"./content-trash.schema-tvJ4Lbos.js";import{x as lS,S as aS}from"./content-trash.schema-tvJ4Lbos.js";import{_ as D,b as Gt,a as Hs}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DMaku-HC.js";import{b as on,a as ln,f as _e,g as Yt,d as Ma,w as Aa,t as Nt,p as Jd,h as Gd,c as Do}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react__loadShare__.js-BuUBskgj.js";import{c as Yd}from"./_virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_2_dom__loadShare__.js-DYfqn12F.js";import{_ as Xd}from"./__virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react__loadShare__.js_commonjs-proxy-Ng0fOpdU.js";import"./__virtual_mf___mfe_internal__velora_admin__mf_owner__1__loadShare__react_mf_2_dom__loadShare__.js_commonjs-proxy-oc1i_iBU.js";function G1({className:n,...e}){return D("div",{"data-slot":"panel",className:Ca("rounded-lg border border-border-default bg-background-elevated p-6 shadow-sm",n),...e})}const q=n=>Vs(e=>typeof e=="function",{message:`${n} must be a function`}),mt=Vs(n=>typeof n=="function"||typeof n=="object"&&n!==null,{message:"must be a React component"}),Ro=Vs(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),{message:"must be a JSON Schema object"}),Ii=jd(Ud),Tr=O().regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/i,"must be a reverse-domain id like com.vendor.plugin"),Io=$n(["postgresql","mysql","sqlite","mssql","mongodb"]),Qd=I({storageType:$n(["simple","structured"]),supported:H(Io).min(1),unsupportedReason:va(Io,O()).optional()}).strict(),Zd=I({needsStructuredData:br(),needsExternalNetwork:br(),needsFileSystemAccess:br()}).strict(),ef=I({id:O().min(1),name:O().min(1),up:q("up"),down:q("down")}).strict(),tf=I({beforeMigration:q("beforeMigration").optional(),transformRow:q("transformRow").optional(),afterMigration:q("afterMigration").optional(),validateMigration:q("validateMigration").optional()}).strict(),nf=["content:beforeSave","content:afterSave","content:beforePublish","content:afterPublish","content:afterTrash","content:afterRestore","content:beforeDelete","media:afterUpload","user:afterLogin","api:beforeResponse"],js=va($n(nf),q("hook handler")),Ws=I({id:Tr,name:O().min(1),icon:O().min(1),version:O().min(1),type:qe("datatype"),schema:Ro,settingsSchema:Ro,defaultSettings:yr(O(),Ta()),views:I({input:mt,readOnly:mt,settings:mt,preview:mt.optional()}).strict(),serialize:q("serialize"),deserialize:q("deserialize")}).strict(),rf=I({id:O().min(1),name:O().min(1),icon:O().min(1),view:mt,adminOnly:br().optional()}).strict(),Oa=I({id:O().min(1),name:O().min(1),view:mt}).strict(),sf=I({method:$n(["GET","POST","PUT","PATCH","DELETE"]),path:O().min(1).refine(n=>n.startsWith("/"),{message:'path must start with "/"'}),access:$n(["admin","apiKey","public"]).optional(),schema:I({body:Ii.optional(),querystring:Ii.optional(),params:Ii.optional()}).strict().optional(),handler:q("handler")}).strict(),of=I({name:O().regex(/^[a-z0-9-]+$/),build:q("build")}).strict(),Na=I({extendContentResponse:q("extendContentResponse").optional(),customFormats:H(of).optional()}).strict().superRefine((n,e)=>{const t=(n.customFormats??[]).map(r=>r.name);new Set(t).size!==t.length&&e.addIssue({code:"custom",message:"customFormats names must be unique within a manifest"})}),Da=I({id:O().min(1),name:O().min(1),cron:O().min(1),run:q("run")}).strict(),Ra=I({id:O().min(1),name:O().min(1),process:q("process")}).strict(),yi=I({id:O().min(1),name:O().min(1),view:mt}).strict(),lf=I({id:O().min(1),label:O().min(1),onSelect:q("onSelect")}).strict(),af=I({id:O().min(1),label:O().min(1),icon:O().min(1),onClick:q("onClick")}).strict(),cf=I({id:O().min(1),name:O().min(1),service:Ta()}).strict(),Ia=I({name:O().min(1),description:O().optional(),repository:O().optional()}).strict(),hn=O().max(200).regex(new RegExp("^[^{};\\u0000-\\u001f\\u007f]+$"),"must not contain CSS-escaping characters"),uf=I({color:yr(hn,yr(hn,hn)).optional(),radius:yr(hn,hn).optional()}).strict(),df=I({dataTypes:H(Ws).optional(),mediaProcessors:H(Ra).optional(),settingsPages:H(yi).optional()}).strict(),ff=I({dataTypes:H(Ws).optional(),adminSections:H(rf).optional(),dashboardWidgets:H(Oa).optional(),apiRoutes:H(sf).optional(),hooks:js.optional(),scheduledTasks:H(Da).optional(),settingsPages:H(yi).optional(),documentTypes:H(Ea).optional(),bundledTemplate:Ia.optional()}).strict().superRefine((n,e)=>{const t=new Set;(n.apiRoutes??[]).forEach((r,i)=>{const s=`${r.method} ${r.path}`;t.has(s)&&e.addIssue({code:"custom",message:`Duplicate apiRoute "${s}" — method+path pairs must be unique within a manifest`,path:["apiRoutes",i]}),t.add(s)})}),hf=I({documentTypes:H(Ea).optional()}).strict(),pf=I({themeTokens:uf.optional()}).strict(),mf=I({hooks:js.optional(),settingsPages:H(yi).optional(),exposedServices:H(cf).optional(),serializers:Na.optional()}).strict(),gf=I({dashboardWidgets:H(Oa).optional(),hooks:js.optional(),scheduledTasks:H(Da).optional(),mediaProcessors:H(Ra).optional(),settingsPages:H(yi).optional(),contentTreeActions:H(lf).optional(),editorToolbar:H(af).optional(),serializers:Na.optional()}).strict(),yf=I({bundledPlugins:H(Tr).optional(),bundledTemplate:Ia.optional()}).strict(),ft={id:Tr,name:O().min(1),version:O().min(1),description:O().min(1),author:O().min(1),license:O().min(1),price:Wd().nonnegative().optional(),signature:O().optional(),cmsVersion:O().min(1),pluginDependencies:H(Tr).optional(),databaseCompatibility:Qd,permissions:Zd,migrations:H(ef).optional(),onInstall:q("onInstall").optional(),onUninstall:q("onUninstall").optional(),onActivate:q("onActivate").optional(),onDeactivate:q("onDeactivate").optional(),onUpdate:q("onUpdate").optional(),migrationHooks:tf.optional()},bf=Hd("type",[I({...ft,type:qe("datatype"),contributions:df}).strict(),I({...ft,type:qe("section"),contributions:ff}).strict(),I({...ft,type:qe("template"),contributions:hf}).strict(),I({...ft,type:qe("theme"),contributions:pf}).strict(),I({...ft,type:qe("integration"),contributions:mf}).strict(),I({...ft,type:qe("utility"),contributions:gf}).strict(),I({...ft,type:qe("bundle"),contributions:yf}).strict()]);function Pa(n){return n.map(e=>{const t=e.path.join(".");return t?`${t}: ${e.message}`:e.message})}function Y1(n){const e=bf.safeParse(n);return e.success?{ok:!0,manifest:e.data}:{ok:!1,errors:Pa(e.error.issues)}}class Po extends Error{constructor(e){super(e),this.name="PluginDefinitionError"}}const kf=["input","readOnly","settings"];function Sf(n){const e=typeof n=="object"&&n!==null&&typeof n.id=="string"?n.id:"(unknown id)",t=typeof n=="object"&&n!==null?n.views:void 0;for(const i of kf)if(!t||t[i]==null)throw new Po(`definePlugin: datatype plugin "${e}" is missing required view "${i}" (input, readOnly and settings are required; preview is optional)`);const r=Ws.safeParse(n);if(!r.success)throw new Po(`definePlugin: datatype plugin "${e}" is invalid:
2
2
  `+Pa(r.error.issues).map(i=>` - ${i}`).join(`
3
3
  `));return n}const Er=new Map;function an(n){if(Er.has(n.id))throw new Error(`A datatype with id "${n.id}" is already registered`);Er.set(n.id,n)}function X1(n){return Er.get(n)}function Q1(){return[...Er.values()]}const Mr=new Map;function Z1(n){if(Mr.has(n.id))throw new Error(`An admin section with id "${n.id}" is already registered`);Mr.set(n.id,n)}function eS(n){return Mr.get(n)}function tS(){return[...Mr.values()]}const La=ln(null);function xf({value:n,onChange:e,children:t}){return D(La.Provider,{value:{value:n,onChange:e},children:t})}function Me(){const n=on(La);if(!n)throw new Error("usePluginValue must be called from a view rendered inside a PluginValueProvider");return n}const Us=ln(null);function nS({settings:n,onSettingsChange:e,children:t}){return D(Us.Provider,{value:{settings:n,onSettingsChange:e},children:t})}function Ba(){const n=on(Us);if(!n)throw new Error("usePluginSettings must be called from a view rendered inside a PluginSettingsProvider");return n.settings}function $a(){const n=on(Us);if(!n)throw new Error("usePluginSettingsValue must be called from a view rendered inside a PluginSettingsProvider");if(!n.onSettingsChange)throw new Error("usePluginSettingsValue must be called from a settings view rendered inside a PluginSettingsProvider that supplies onSettingsChange (read-only contexts should use usePluginSettings() instead)");return{value:n.settings,onChange:n.onSettingsChange}}const za=ln(null);function rS({fetch:n,children:e}){return D(za.Provider,{value:n,children:e})}function Ks(){const n=on(za);if(!n)throw new Error("usePluginApi must be called from a view rendered inside a PluginApiProvider");return n}function iS({contentId:n,fieldId:e,pluginId:t,children:r}){const i=Ks(),[s,o]=_e(null),[l,a]=_e(null),c=`/api/plugins/${t}/storage/${n}/${e}`;Yt(()=>{let d=!1;return a(null),i(c).then(async f=>{if(!f.ok)throw new Error(`Failed to load plugin value (${f.status})`);const h=await f.json();d||o(h.value)}).catch(f=>{d||a(f instanceof Error?f.message:String(f))}),()=>{d=!0}},[i,c]);function u(d){o(d),i(c,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:d})}).then(f=>{if(!f.ok)throw new Error(`Failed to save plugin value (${f.status})`);a(null)}).catch(f=>{a(f instanceof Error?f.message:String(f))})}return Gt(Hs,{children:[l&&D("p",{role:"alert",className:"text-xs text-danger-600",children:l}),D(xf,{value:s,onChange:u,children:r})]})}const wf={type:"object",properties:{placeholder:{type:"string"},maxLength:{type:"integer",minimum:1}},additionalProperties:!1},Cf={},vf={type:"object",properties:{acceptedTypes:{type:"array",items:{type:"string"}},maxSizeBytes:{type:"integer",minimum:1}},additionalProperties:!1},Tf={},Ge=n=>n,Ef={"com.velora.text":Ge,"com.velora.number":Ge,"com.velora.boolean":Ge,"com.velora.date":Ge,"com.velora.image":Ge,"com.velora.richtext":Ge};function Mf(n){const e=Ks(),[t,r]=_e(null),[i,s]=_e(!1),[o,l]=_e(null);return Yt(()=>{if(!n){r(null),l(null);return}let a=!1;return s(!0),l(null),e(`/api/media/${n}`).then(async c=>{if(!c.ok)throw new Error(`Failed to load media (${c.status})`);const u=await c.json();a||r({filename:u.filename,downloadUrl:u.downloadUrl})}).catch(c=>{a||l(c instanceof Error?c.message:String(c))}).finally(()=>{a||s(!1)}),()=>{a=!0}},[n,e]),{preview:t,loading:i,error:o}}function Fa({mediaId:n}){const{preview:e,loading:t,error:r}=Mf(n);return n?t?D("p",{className:"text-xs text-text-secondary",children:"Loading…"}):r?D("p",{className:"text-xs text-danger-600",children:r}):e?D("img",{src:e.downloadUrl,alt:e.filename,className:"h-24 w-24 rounded-md border border-border-default object-cover"}):null:null}function Af(){const{value:n,onChange:e}=Me(),t=Ba(),r=sn(),i=Ks(),[s,o]=_e(!1),[l,a]=_e(null);async function c(u){var f;const d=(f=u.target.files)==null?void 0:f[0];if(u.target.value="",!!d){if(a(null),t.maxSizeBytes!=null&&d.size>t.maxSizeBytes){a(`File is too large (${d.size} bytes) — the configured limit is ${t.maxSizeBytes} bytes.`);return}o(!0);try{const h=new FormData;h.append("file",d);const p=await i("/api/media",{method:"POST",body:h});if(!p.ok)throw new Error(`Upload failed (${p.status})`);const g=await p.json();e(g.id)}catch(h){a(h instanceof Error?h.message:String(h))}finally{o(!1)}}}return Gt("div",{className:"flex flex-col gap-2",children:[D(Fa,{mediaId:n}),Gt("div",{className:"flex items-center gap-2",children:[D("input",{...r,type:"file",accept:t.acceptedTypes&&t.acceptedTypes.length>0?t.acceptedTypes.join(","):"image/*",disabled:s,onChange:u=>void c(u),className:"text-sm text-text-primary"}),n&&D(Kd,{type:"button",variant:"ghost",size:"sm",disabled:s,onClick:()=>e(null),children:"Remove"})]}),l&&D("p",{className:"text-xs text-danger-600",children:l})]})}function Of(){var t;const{value:n,onChange:e}=$a();return Gt("div",{className:"flex flex-col gap-4",children:[D(vr,{label:"Accepted file types",htmlFor:"image-settings-accepted-types",helpText:"Comma-separated MIME types, e.g. image/png,image/jpeg. Leave blank to accept any image.",children:D(Ot,{id:"image-settings-accepted-types",value:((t=n.acceptedTypes)==null?void 0:t.join(","))??"",onChange:r=>{const i=r.target.value.split(",").map(s=>s.trim()).filter(s=>s.length>0);e({...n,acceptedTypes:i.length>0?i:void 0})}})}),D(vr,{label:"Max file size (bytes)",htmlFor:"image-settings-max-size",helpText:"e.g. 5000000 for ~5MB. Leave blank for no limit.",children:D(Ot,{id:"image-settings-max-size",type:"number",min:1,value:n.maxSizeBytes??"",onChange:r=>e({...n,maxSizeBytes:r.target.value===""?void 0:Number(r.target.value)})})})]})}function Lo(){const{value:n}=Me();return D(Fa,{mediaId:n})}var Bo=Object.defineProperty,Nf=(n,e)=>{let t={};for(var r in n)Bo(t,r,{get:n[r],enumerable:!0});return Bo(t,Symbol.toStringTag,{value:"Module"}),t};function ee(n){this.content=n}ee.prototype={constructor:ee,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ee(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ee(t)},addToStart:function(n,e){return new ee([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ee(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ee(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ee.from(n),n.size?new ee(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ee.from(n),n.size?new ee(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ee.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ee.from=function(n){if(n instanceof ee)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ee(e)};function Va(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&ja(o.charCodeAt(a-1))&&Ha(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=Va(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function _a(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d<c.length&&ja(c.charCodeAt(d-1))&&Ha(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=_a(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Ha(n){return n>=56320&&n<57344}function ja(n){return n>=55296&&n<56320}class b{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new b(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new b(r,i)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new b(i,s)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Va(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return _a(this,e,t,r)}findIndex(e){if(e==0)return nr(0,e);if(e==this.size)return nr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?nr(t+1,s):nr(t,r);r=s}}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 b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return b.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new b(t||e,r)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const Pi={index:0,offset:0};function nr(n,e){return Pi.index=n,Pi.offset=e,Pi}function Ar(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Ar(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Ar(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let z=class as{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ar(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return as.none;if(e instanceof as)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};z.none=[];class zn extends Error{}class w{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ua(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new w(r,this.openStart,this.openEnd)}removeBetween(e,t){return new w(Wa(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 w.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(b.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new w(e,r,i)}}w.empty=new w(b.empty,0,0);function Wa(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Wa(s.content,e-i-1,t-i-1)))}function Ua(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Ua(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Df(n,e,t){if(t.openStart>n.depth)throw new zn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new zn("Inconsistent open depths");return Ka(n,e,t,0)}function Ka(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Ka(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Ct(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Rf(t,n);return Ct(s,Ja(n,o,l,e,r))}else return Ct(s,Or(n,e,r))}function qa(n,e){if(!e.type.compatibleContent(n.type))throw new zn("Cannot join "+e.type.name+" onto "+n.type.name)}function cs(n,e,t){let r=n.node(t);return qa(r,e.node(t)),r}function wt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function vn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(wt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)wt(i.child(l),r);e&&e.depth==t&&e.textOffset&&wt(e.nodeBefore,r)}function Ct(n,e){if(!n.type.validContent(e))throw new zn("Invalid content for node "+n.type.name);return n.copy(e)}function Ja(n,e,t,r,i){let s=n.depth>i&&cs(n,e,i+1),o=r.depth>i&&cs(t,r,i+1),l=[];return vn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(qa(s,o),wt(Ct(s,Ja(n,e,t,r,i+1)),l)):(s&&wt(Ct(s,Or(n,e,i+1)),l),vn(e,t,i,l),o&&wt(Ct(o,Or(t,r,i+1)),l)),vn(r,null,i,l),new b(l)}function Or(n,e,t){let r=[];if(vn(null,n,t,r),n.depth>t){let i=cs(n,e,t+1);wt(Ct(i,Or(n,e,t+1)),r)}return vn(e,null,t,r),new b(r)}function Rf(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(b.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Fn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Nr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Fn(t,r,s)}static resolveCached(e,t){let r=$o.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else $o.set(e,r=new If);let i=r.elts[r.i]=Fn.resolve(e,t);return r.i=(r.i+1)%Pf,i}}class If{constructor(){this.elts=[],this.i=0}}const Pf=12,$o=new WeakMap;class Nr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Lf=Object.create(null);let vt=class us{constructor(e,t,r,i=z.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Ar(this.attrs,t||e.defaultAttrs||Lf)&&z.sameSet(this.marks,r||z.none)}copy(e=null){return e==this.content?this:new us(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new us(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return w.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new w(c,i.depth-o,s.depth-o)}replace(e,t,r){return Df(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Fn.resolveCached(this,e)}resolveNoCache(e){return Fn.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),Ga(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=z.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=b.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};vt.prototype.text=void 0;class Dr extends vt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ga(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 Dr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Dr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ga(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Dt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Bf(e,t);if(r.next==null)return Dt.empty;let i=Ya(r);r.next&&r.err("Unexpected trailing text");let s=jf(Hf(i));return Wf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
4
4
  `)}}Dt.empty=new Dt(!0);class Bf{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 Ya(n){let e=[];do e.push($f(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function $f(n){let e=[];do e.push(zf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zf(n){let e=_f(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Ff(n,e);else break;return e}function zo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Ff(n,e){let t=zo(n),r=t;return n.eat(",")&&(n.next!="}"?r=zo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Vf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function _f(n){if(n.eat("(")){let e=Ya(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Vf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Hf(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Xa(n,e){return e-n}function Fo(n,e){let t=[];return r(e),t.sort(Xa);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function jf(n){let e=Object.create(null);return t(Fo(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Fo(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Dt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Xa);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Wf(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Qa(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Za(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function ec(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function tc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Kf(n,r,e[r]);return t}let Vo=class nc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=tc(e,r.attrs),this.defaultAttrs=Qa(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Dt.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:Za(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new vt(this,this.computeAttrs(e),b.from(t),z.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new vt(this,this.computeAttrs(e),t,z.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(b.empty,!0);return s?new vt(this,e,t.append(s),z.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ec(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:z.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new nc(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Uf(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Kf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Uf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class bi{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=tc(e,i.attrs),this.excluded=null;let s=Qa(this.attrs);this.instance=s?new z(this,s):null}create(e=null){return!e&&this.instance?this.instance:new z(this,Za(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new bi(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){ec(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class rc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ee.from(e.nodes),t.marks=ee.from(e.marks||{}),this.nodes=Vo.compile(this.spec.nodes,this),this.marks=bi.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Dt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?_o(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:_o(this,o.split(" "))}this.nodeFromJSON=i=>vt.fromJSON(this,i),this.markFromJSON=i=>z.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Dr(r,r.defaultAttrs,e,z.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function _o(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function qf(n){return n.tag!=null}function Jf(n){return n.style!=null}class nt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(qf(i))this.tags.push(i);else if(Jf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new jo(this,t,!1);return r.addAll(e,z.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new jo(this,t,!0);return r.addAll(e,z.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Xf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Wo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Wo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nt(e,nt.schemaRules(e)))}}const ic={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Gf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sc={ol:!0,ul:!0},Vn=1,ds=2,Tn=4;function Ho(n,e,t){return e!=null?(e?Vn:0)|(e==="full"?ds:0):n&&n.whitespace=="pre"?Vn|ds:t&~Tn}class rr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=z.none,this.match=s||(o&Tn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!ic.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class jo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Ho(null,t.preserveWhitespace,0)|(r?Tn:0);i?s=new rr(i.type,i.attrs,z.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new rr(null,null,z.none,!0,null,o):s=new rr(e.schema.topNodeType,null,z.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&ds?"full":this.localPreserveWS||(i.options&Vn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`