@lexical/extension 0.43.0 → 0.43.1-nightly.20260410.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.
@@ -825,7 +825,7 @@ function maybeWithBuilder(editor) {
825
825
  function normalizeExtensionArgument(arg) {
826
826
  return Array.isArray(arg) ? arg : [arg];
827
827
  }
828
- const PACKAGE_VERSION = "0.43.0+dev.cjs";
828
+ const PACKAGE_VERSION = "0.43.1-nightly.20260410.0+dev.cjs";
829
829
 
830
830
  /** @internal */
831
831
  class LexicalBuilder {
@@ -824,7 +824,7 @@ function maybeWithBuilder(editor) {
824
824
  function normalizeExtensionArgument(arg) {
825
825
  return Array.isArray(arg) ? arg : [arg];
826
826
  }
827
- const PACKAGE_VERSION = "0.43.0+dev.esm";
827
+ const PACKAGE_VERSION = "0.43.1-nightly.20260410.0+dev.esm";
828
828
 
829
829
  /** @internal */
830
830
  class LexicalBuilder {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(!function(){let t=c;for(c=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==r;){let n=r;for(r=void 0,l++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&x(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(l=0,d--,e)throw t}function o(t){if(d>0)return t();f=++u,d++;try{return t()}finally{i()}}let s,r;function a(t){const e=s;s=void 0;try{return t()}finally{s=e}}let c,d=0,l=0,u=0,f=0,h=0;function g(t){if(void 0===s)return;let e=t.n;return void 0===e||e.t!==s?(e={i:0,S:t,p:s.s,n:void 0,t:s,e:void 0,x:void 0,r:e},void 0!==s.s&&(s.s.n=e),s.s=e,t.n=e,32&s.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=s.s,e.n=void 0,s.s.n=e,s.s=e),e):void 0}function p(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function m(t,e){return new p(t,e)}function x(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function E(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function v(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function S(t,e){p.call(this,void 0),this.x=t,this.s=void 0,this.g=h-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function y(t,e){return new S(t,e)}function N(t){const e=t.m;if(t.m=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{s=n,i()}}}function b(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,N(t)}function O(t){if(s!==this)throw new Error("Out-of-order effect");v(this),s=t,this.f&=-2,8&this.f&&b(this),i()}function R(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function C(t,e){const n=new R(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function D(t,e={}){const n={};for(const i in t){const o=e[i],s=m(void 0===o?t[i]:o);n[i]=s}return n}p.prototype.brand=n,p.prototype.h=function(){return!0},p.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:a(()=>{var t;null==(t=this.W)||t.call(this)}))},p.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&a(()=>{var t;null==(t=this.Z)||t.call(this)}))}},p.prototype.subscribe=function(t){return C(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},p.prototype.valueOf=function(){return this.value},p.prototype.toString=function(){return this.value+""},p.prototype.toJSON=function(){return this.value},p.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(p.prototype,"value",{get(){const t=g(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(l>100)throw new Error("Cycle detected");!function(t){0!==d&&0===l&&t.l!==f&&(t.l=f,c={S:t,v:t.v,i:t.i,o:c})}(this),this.v=t,this.i++,h++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),S.prototype=new p,S.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===h)return!0;if(this.g=h,this.f|=1,this.i>0&&!x(this))return this.f&=-2,!0;const t=s;try{E(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,v(this),this.f&=-2,!0},S.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}p.prototype.S.call(this,t)},S.prototype.U=function(t){if(void 0!==this.t&&(p.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},S.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(S.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=g(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),R.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.m=t)}finally{t()}},R.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,N(this),E(this),d++;const t=s;return s=this,O.bind(this,t)},R.prototype.N=function(){2&this.f||(this.f|=2,this.u=r,r=this)},R.prototype.d=function(){this.f|=8,1&this.f||b(this)},R.prototype.dispose=function(){this.d()};const M=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return C(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function _(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const T=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return C(()=>_(t,i.value))}});function I(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const $=t.createState("format",{parse:t=>"number"==typeof t?t:0});class A extends t.DecoratorNode{$config(){return this.config("decorator-text",{extends:t.DecoratorNode,stateConfigs:[{flat:!0,stateConfig:$}]})}getFormat(){return t.$getState(this,$)}getFormatFlags(e,n){return t.toggleTextFormatType(this.getFormat(),e,n)}hasFormat(e){const n=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(this.getFormat()&n)}setFormat(e){return t.$setState(this,$,e)}toggleFormat(e){const n=this.getFormat(),i=t.toggleTextFormatType(n,e,null);return this.setFormat(i)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function F(t){return t instanceof A}function P(t,e){const n=document.createElement(e);return n.appendChild(t),n}const k={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},j=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[A],register:(e,n,i)=>e.registerCommand(t.FORMAT_TEXT_COMMAND,e=>{const n=t.$getSelection();if(t.$isNodeSelection(n)||t.$isRangeSelection(n))for(const t of n.getNodes())F(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function L(t,e){let n;return m(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const K=t.defineExtension({build:t=>L(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function z(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function B(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=B(n[t],i[t]);return t}return e}const U=0,Y=1,H=2,W=3,G=4,Z=5,V=6,J=7;function X(t){return t.id===U}function q(t){return t.id===H}function Q(t){return function(t){return t.id===Y}(t)||z(305,String(t.id),String(Y)),Object.assign(t,{id:H})}const tt=new Set;class et{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:U}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t.shallowMergeConfig;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;q(e)||z(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:W,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:G,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==G&&z(307,String(e.id),String(Z)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Z,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Z&&z(308,String(n.id),String(Z));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:V})}(n),()=>{const t=this.state;t.id!==J&&z(309,String(n.id),String(J)),this.state=function(t){return Object.assign(t,{id:Z})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==V&&z(310,String(e.id),String(V)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:J})}(e),n}getSignal(){return void 0===this._signal&&z(311),this._signal}getInitResult(){void 0===this.extension.init&&z(312,this.extension.name);const t=this.state;return function(t){return t.id>=G}(t)||z(313,String(t.id),String(G)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=W}(t)||z(314,String(t.id),String(W)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=J}(t)||z(316,String(t.id),String(J)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||tt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=Z})(t)||z(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const nt={tag:t.HISTORY_MERGE_TAG};function it(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const ot=t.defineExtension({config:t.safeCast({setOptions:nt,updateOptions:nt}),init:({$initialEditorState:t=it})=>({$initialEditorState:t,initialized:!1}),afterRegistration(e,{updateOptions:n,setOptions:i},o){const s=o.getInitResult();if(!s.initialized){s.initialized=!0;const{$initialEditorState:o}=s;if(t.$isEditorState(o))e.setEditorState(o,i);else if("function"==typeof o)e.update(()=>{o(e)},n);else if(o&&("string"==typeof o||"object"==typeof o)){const t=e.parseEditorState(o);e.setEditorState(t,i)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[t.RootNode,t.TextNode,t.LineBreakNode,t.TabNode,t.ParagraphNode]}),st=Symbol.for("@lexical/extension/LexicalBuilder");function rt(){}function at(t){throw t}function ct(t){return Array.isArray(t)?t:[t]}const dt="0.43.0+prod.cjs";class lt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=dt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ct(ot)];for(const n of t)e.push(ct(n));return new lt(e)}static maybeFromEditor(t){const e=t[st];return e&&(e.PACKAGE_VERSION!==dt&&z(292,e.PACKAGE_VERSION,dt),e instanceof lt||z(293)),e}static fromEditor(t){const e=lt.maybeFromEditor(t);return void 0===e&&z(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[st]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=rt;function n(){try{e()}finally{e=rt}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return e=t.mergeRegister(this.registerEditor(i),()=>i.setRootElement(null)),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&z(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&z(296);const e=ct(t),[n]=e;"string"!=typeof n.name&&z(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&z(298,n.name),!i){i=new et(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&z(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&z(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ct(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(q(o))return;const s=n.extension.name;var r;X(o)||z(300,s,i||"[unknown]"),X(r=o)||z(304,String(r.id),String(U)),o=Object.assign(r,{id:Y}),n.state=o;const a=this.outgoingConfigEdges.get(s);if(a)for(const t of a.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=Q(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())X(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&z(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(e){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const t of n){const n=t.register(e,s);n&&o.push(n)}for(const t of n){const n=t.afterRegistration(e);n&&o.push(n)}return t.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const a of r){const{extension:r}=a;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of I(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&z(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,a)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&B(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,c=i.size>0;(a||c)&&(t.html={},a&&(t.html.import=o),c&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=at),t}}function ut(t,e){const n=lt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const ft=new Set,ht=t.defineExtension({build(e,n,i){const o=i.getDependency(K).output,s=m({watchedNodeKeys:new Map}),r=L(()=>{},()=>C(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),c=r&&r.isSelected()||!1;a=a||c!==(!!e&&e.has(o)),c&&(i=i||new Set,i.add(o))}}),!a&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=y(()=>(r.value||ft).has(t)),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[K],name:"@lexical/extension/NodeSelection"}),gt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class pt extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new pt(t.__key)}static importJSON(t){return xt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:mt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const n=document.createElement("hr");return t.addClassNamesToElement(n,e.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function mt(){return{node:xt()}}function xt(){return t.$create(pt)}function Et(t){return t instanceof pt}const vt=t.defineExtension({dependencies:[K,ht],name:"@lexical/extension/HorizontalRule",nodes:()=>[pt],register(n,i,s){const{watchNodeKey:r}=s.getDependency(ht).output,a=m({nodeSelections:new Map}),c=n._config.theme.hrSelected??"selected";return t.mergeRegister(n.registerCommand(gt,n=>{const i=t.$getSelection();if(!t.$isRangeSelection(i))return!1;if(null!==i.focus.getNode()){const t=xt();e.$insertNodeToNearestRoot(t)}return!0},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(Et(n))return function(e,n=!1){const i=t.$getSelection(),o=e.isSelected(),s=e.getKey();let r;n&&t.$isNodeSelection(i)?r=i:(r=t.$createNodeSelection(),t.$setSelection(r)),o?r.delete(s):r.add(s)}(n,e.shiftKey),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerMutationListener(pt,(t,e)=>{o(()=>{let e=!1;const{nodeSelections:i}=a.peek();for(const[o,s]of t.entries())if("destroyed"===s)i.delete(o),e=!0;else{const t=i.get(o),s=n.getElementByKey(o);t?t.domNode.value=s:(e=!0,i.set(o,{domNode:m(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})})}),C(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())e.push(C(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,c):t.removeClassNamesFromElement(e,c)}}));return t.mergeRegister(...e)}))}});const St=t.defineExtension({build:(t,e)=>D({inheritEditableFromParent:e.inheritEditableFromParent}),config:t.safeCast({$getParentEditor:function(){const e=t.$getEditor();return lt.fromEditor(e),e},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>C(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),yt=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,n,i)=>{const o=i.getOutput();return C(()=>{if(!o.disabled.value)return e.selectionAlwaysOnDisplay(t,o.onReposition.value)})}});function Nt(t){return t.canBeEmpty()}function bt(n,i,o=Nt){return t.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){if(n.getNodes().filter(e=>t.$isBlockElementNode(e)&&e.canIndent()).length>0)return!0;const i=n.anchor,o=n.focus,s=o.isBefore(i)?o:i,r=s.getNode(),a=e.$getNearestBlockElementAncestorOrThrow(r);if(a.canIndent()){const e=a.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(s))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,()=>{const n="number"==typeof i?i:i?i.peek():null,s=t.$getSelection();if(!t.$isRangeSelection(s))return!1;const r="function"==typeof o?o:o.peek();return e.$handleIndentAndOutdent(t=>{if(r(t)){const e=t.getIndent()+1;(!n||e<n)&&t.setIndent(e)}})},t.COMMAND_PRIORITY_CRITICAL))}const Ot=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$canIndent:Nt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return C(()=>{if(!i.value)return bt(t,o,s)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=xt,exports.$isDecoratorTextNode=F,exports.$isHorizontalRuleNode=Et,exports.AutoFocusExtension=M,exports.ClearEditorExtension=T,exports.DecoratorTextExtension=j,exports.DecoratorTextNode=A,exports.EditorStateExtension=K,exports.HorizontalRuleExtension=vt,exports.HorizontalRuleNode=pt,exports.INSERT_HORIZONTAL_RULE_COMMAND=gt,exports.InitialStateExtension=ot,exports.LexicalBuilder=lt,exports.NestedEditorExtension=St,exports.NodeSelectionExtension=ht,exports.SelectionAlwaysOnDisplayExtension=yt,exports.TabIndentationExtension=Ot,exports.applyFormatFromStyle=function(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),a="italic"===e.fontStyle,c=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),a&&!t.hasFormat("italic")&&t.toggleFormat("italic"),c&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t},exports.applyFormatToDom=function(t,e,n=k){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=P(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return lt.fromExtensions(t).buildEditor()},exports.computed=y,exports.effect=C,exports.getExtensionDependencyFromEditor=function(t,e){const n=lt.fromEditor(t).getExtensionRep(e);return void 0===n&&z(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of I(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=ut,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ut(t,e);return void 0===n&&z(291,e),n},exports.namedSignals=D,exports.registerClearEditor=_,exports.registerTabIndentation=bt,exports.signal=m,exports.untracked=a,exports.watchedSignal=L;
9
+ "use strict";var t=require("lexical"),e=require("@lexical/utils");const n=Symbol.for("preact-signals");function i(){if(d>1)return void d--;let t,e=!1;for(!function(){let t=c;for(c=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==r;){let n=r;for(r=void 0,l++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&x(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(l=0,d--,e)throw t}function o(t){if(d>0)return t();f=++u,d++;try{return t()}finally{i()}}let s,r;function a(t){const e=s;s=void 0;try{return t()}finally{s=e}}let c,d=0,l=0,u=0,f=0,h=0;function g(t){if(void 0===s)return;let e=t.n;return void 0===e||e.t!==s?(e={i:0,S:t,p:s.s,n:void 0,t:s,e:void 0,x:void 0,r:e},void 0!==s.s&&(s.s.n=e),s.s=e,t.n=e,32&s.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=s.s,e.n=void 0,s.s.n=e,s.s=e),e):void 0}function p(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function m(t,e){return new p(t,e)}function x(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function E(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function v(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function S(t,e){p.call(this,void 0),this.x=t,this.s=void 0,this.g=h-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function y(t,e){return new S(t,e)}function N(t){const e=t.m;if(t.m=void 0,"function"==typeof e){d++;const n=s;s=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{s=n,i()}}}function b(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,N(t)}function O(t){if(s!==this)throw new Error("Out-of-order effect");v(this),s=t,this.f&=-2,8&this.f&&b(this),i()}function R(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function C(t,e){const n=new R(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function D(t,e={}){const n={};for(const i in t){const o=e[i],s=m(void 0===o?t[i]:o);n[i]=s}return n}p.prototype.brand=n,p.prototype.h=function(){return!0},p.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:a(()=>{var t;null==(t=this.W)||t.call(this)}))},p.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&a(()=>{var t;null==(t=this.Z)||t.call(this)}))}},p.prototype.subscribe=function(t){return C(()=>{const e=this.value,n=s;s=void 0;try{t(e)}finally{s=n}},{name:"sub"})},p.prototype.valueOf=function(){return this.value},p.prototype.toString=function(){return this.value+""},p.prototype.toJSON=function(){return this.value},p.prototype.peek=function(){const t=s;s=void 0;try{return this.value}finally{s=t}},Object.defineProperty(p.prototype,"value",{get(){const t=g(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(l>100)throw new Error("Cycle detected");!function(t){0!==d&&0===l&&t.l!==f&&(t.l=f,c={S:t,v:t.v,i:t.i,o:c})}(this),this.v=t,this.i++,h++,d++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{i()}}}}),S.prototype=new p,S.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===h)return!0;if(this.g=h,this.f|=1,this.i>0&&!x(this))return this.f&=-2,!0;const t=s;try{E(this),s=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return s=t,v(this),this.f&=-2,!0},S.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}p.prototype.S.call(this,t)},S.prototype.U=function(t){if(void 0!==this.t&&(p.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},S.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(S.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=g(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),R.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.m=t)}finally{t()}},R.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,N(this),E(this),d++;const t=s;return s=this,O.bind(this,t)},R.prototype.N=function(){2&this.f||(this.f|=2,this.u=r,r=this)},R.prototype.d=function(){this.f|=8,1&this.f||b(this)},R.prototype.dispose=function(){this.d()};const M=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return C(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function w(){const e=t.$getRoot(),n=t.$getSelection(),i=t.$createParagraphNode();e.clear(),e.append(i),null!==n&&i.select(),t.$isRangeSelection(n)&&(n.format=0)}function _(e,n=w){return e.registerCommand(t.CLEAR_EDITOR_COMMAND,t=>(e.update(n),!0),t.COMMAND_PRIORITY_EDITOR)}const T=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$onClear:w}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return C(()=>_(t,i.value))}});function I(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const $=t.createState("format",{parse:t=>"number"==typeof t?t:0});class A extends t.DecoratorNode{$config(){return this.config("decorator-text",{extends:t.DecoratorNode,stateConfigs:[{flat:!0,stateConfig:$}]})}getFormat(){return t.$getState(this,$)}getFormatFlags(e,n){return t.toggleTextFormatType(this.getFormat(),e,n)}hasFormat(e){const n=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(this.getFormat()&n)}setFormat(e){return t.$setState(this,$,e)}toggleFormat(e){const n=this.getFormat(),i=t.toggleTextFormatType(n,e,null);return this.setFormat(i)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function F(t){return t instanceof A}function P(t,e){const n=document.createElement(e);return n.appendChild(t),n}const k={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},j=t.defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[A],register:(e,n,i)=>e.registerCommand(t.FORMAT_TEXT_COMMAND,e=>{const n=t.$getSelection();if(t.$isNodeSelection(n)||t.$isRangeSelection(n))for(const t of n.getNodes())F(t)&&t.toggleFormat(e);return!1},t.COMMAND_PRIORITY_LOW)});function L(t,e){let n;return m(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const K=t.defineExtension({build:t=>L(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function z(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function B(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=B(n[t],i[t]);return t}return e}const U=0,Y=1,H=2,W=3,G=4,Z=5,V=6,J=7;function X(t){return t.id===U}function q(t){return t.id===H}function Q(t){return function(t){return t.id===Y}(t)||z(305,String(t.id),String(Y)),Object.assign(t,{id:H})}const tt=new Set;class et{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:U}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t.shallowMergeConfig;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;q(e)||z(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:W,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:G,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==G&&z(307,String(e.id),String(Z)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Z,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Z&&z(308,String(n.id),String(Z));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:V})}(n),()=>{const t=this.state;t.id!==J&&z(309,String(n.id),String(J)),this.state=function(t){return Object.assign(t,{id:Z})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==V&&z(310,String(e.id),String(V)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:J})}(e),n}getSignal(){return void 0===this._signal&&z(311),this._signal}getInitResult(){void 0===this.extension.init&&z(312,this.extension.name);const t=this.state;return function(t){return t.id>=G}(t)||z(313,String(t.id),String(G)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=W}(t)||z(314,String(t.id),String(W)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&z(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=J}(t)||z(316,String(t.id),String(J)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||tt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=Z})(t)||z(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const nt={tag:t.HISTORY_MERGE_TAG};function it(){const e=t.$getRoot();e.isEmpty()&&e.append(t.$createParagraphNode())}const ot=t.defineExtension({config:t.safeCast({setOptions:nt,updateOptions:nt}),init:({$initialEditorState:t=it})=>({$initialEditorState:t,initialized:!1}),afterRegistration(e,{updateOptions:n,setOptions:i},o){const s=o.getInitResult();if(!s.initialized){s.initialized=!0;const{$initialEditorState:o}=s;if(t.$isEditorState(o))e.setEditorState(o,i);else if("function"==typeof o)e.update(()=>{o(e)},n);else if(o&&("string"==typeof o||"object"==typeof o)){const t=e.parseEditorState(o);e.setEditorState(t,i)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[t.RootNode,t.TextNode,t.LineBreakNode,t.TabNode,t.ParagraphNode]}),st=Symbol.for("@lexical/extension/LexicalBuilder");function rt(){}function at(t){throw t}function ct(t){return Array.isArray(t)?t:[t]}const dt="0.43.1-nightly.20260410.0+prod.cjs";class lt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=dt,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[ct(ot)];for(const n of t)e.push(ct(n));return new lt(e)}static maybeFromEditor(t){const e=t[st];return e&&(e.PACKAGE_VERSION!==dt&&z(292,e.PACKAGE_VERSION,dt),e instanceof lt||z(293)),e}static fromEditor(t){const e=lt.maybeFromEditor(t);return void 0===e&&z(294),e}constructEditor(){const{$initialEditorState:e,onError:n,...i}=this.buildCreateEditorArgs(),o=Object.assign(t.createEditor({...i,...n?{onError:t=>{n(t,o)}}:{}}),{[st]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let e=rt;function n(){try{e()}finally{e=rt}}const i=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return e=t.mergeRegister(this.registerEditor(i),()=>i.setRootElement(null)),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&z(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&z(296);const e=ct(t),[n]=e;"string"!=typeof n.name&&z(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&z(298,n.name),!i){i=new et(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&z(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&z(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ct(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(q(o))return;const s=n.extension.name;var r;X(o)||z(300,s,i||"[unknown]"),X(r=o)||z(304,String(r.id),String(U)),o=Object.assign(r,{id:Y}),n.state=o;const a=this.outgoingConfigEdges.get(s);if(a)for(const t of a.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=Q(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())X(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&z(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(e){const n=this.sortedExtensionReps(),i=new AbortController,o=[()=>i.abort()],s=i.signal;for(const t of n){const n=t.register(e,s);n&&o.push(n)}for(const t of n){const n=t.afterRegistration(e);n&&o.push(n)}return t.mergeRegister(...o)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const a of r){const{extension:r}=a;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of I(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&z(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,a)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&B(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const a=Object.keys(o).length>0,c=i.size>0;(a||c)&&(t.html={},a&&(t.html.import=o),c&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=at),t}}function ut(t,e){const n=lt.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}const ft=new Set,ht=t.defineExtension({build(e,n,i){const o=i.getDependency(K).output,s=m({watchedNodeKeys:new Map}),r=L(()=>{},()=>C(()=>{const e=r.peek(),{watchedNodeKeys:n}=s.value;let i,a=!1;o.value.read(()=>{if(t.$getSelection())for(const[o,s]of n.entries()){if(0===s.size){n.delete(o);continue}const r=t.$getNodeByKey(o),c=r&&r.isSelected()||!1;a=a||c!==(!!e&&e.has(o)),c&&(i=i||new Set,i.add(o))}}),!a&&i&&e&&i.size===e.size||(r.value=i)}));return{watchNodeKey:function(t){const e=y(()=>(r.value||ft).has(t)),{watchedNodeKeys:n}=s.peek();let i=n.get(t);const o=void 0!==i;return i=i||new Set,i.add(e),o||(n.set(t,i),s.value={watchedNodeKeys:n}),e}}},dependencies:[K],name:"@lexical/extension/NodeSelection"}),gt=t.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class pt extends t.DecoratorNode{static getType(){return"horizontalrule"}static clone(t){return new pt(t.__key)}static importJSON(t){return xt().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:mt,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const n=document.createElement("hr");return t.addClassNamesToElement(n,e.theme.hr),n}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function mt(){return{node:xt()}}function xt(){return t.$create(pt)}function Et(t){return t instanceof pt}const vt=t.defineExtension({dependencies:[K,ht],name:"@lexical/extension/HorizontalRule",nodes:()=>[pt],register(n,i,s){const{watchNodeKey:r}=s.getDependency(ht).output,a=m({nodeSelections:new Map}),c=n._config.theme.hrSelected??"selected";return t.mergeRegister(n.registerCommand(gt,n=>{const i=t.$getSelection();if(!t.$isRangeSelection(i))return!1;if(null!==i.focus.getNode()){const t=xt();e.$insertNodeToNearestRoot(t)}return!0},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,e=>{if(t.isDOMNode(e.target)){const n=t.$getNodeFromDOMNode(e.target);if(Et(n))return function(e,n=!1){const i=t.$getSelection(),o=e.isSelected(),s=e.getKey();let r;n&&t.$isNodeSelection(i)?r=i:(r=t.$createNodeSelection(),t.$setSelection(r)),o?r.delete(s):r.add(s)}(n,e.shiftKey),!0}return!1},t.COMMAND_PRIORITY_LOW),n.registerMutationListener(pt,(t,e)=>{o(()=>{let e=!1;const{nodeSelections:i}=a.peek();for(const[o,s]of t.entries())if("destroyed"===s)i.delete(o),e=!0;else{const t=i.get(o),s=n.getElementByKey(o);t?t.domNode.value=s:(e=!0,i.set(o,{domNode:m(s),selectedSignal:r(o)}))}e&&(a.value={nodeSelections:i})})}),C(()=>{const e=[];for(const{domNode:n,selectedSignal:i}of a.value.nodeSelections.values())e.push(C(()=>{const e=n.value;if(e){i.value?t.addClassNamesToElement(e,c):t.removeClassNamesFromElement(e,c)}}));return t.mergeRegister(...e)}))}});const St=t.defineExtension({build:(t,e)=>D({inheritEditableFromParent:e.inheritEditableFromParent}),config:t.safeCast({$getParentEditor:function(){const e=t.$getEditor();return lt.fromEditor(e),e},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>C(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),yt=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,n,i)=>{const o=i.getOutput();return C(()=>{if(!o.disabled.value)return e.selectionAlwaysOnDisplay(t,o.onReposition.value)})}});function Nt(t){return t.canBeEmpty()}function bt(n,i,o=Nt){return t.mergeRegister(n.registerCommand(t.KEY_TAB_COMMAND,i=>{const o=t.$getSelection();if(!t.$isRangeSelection(o))return!1;i.preventDefault();const s=function(n){if(n.getNodes().filter(e=>t.$isBlockElementNode(e)&&e.canIndent()).length>0)return!0;const i=n.anchor,o=n.focus,s=o.isBefore(i)?o:i,r=s.getNode(),a=e.$getNearestBlockElementAncestorOrThrow(r);if(a.canIndent()){const e=a.getKey();let n=t.$createRangeSelection();if(n.anchor.set(e,0,"element"),n.focus.set(e,0,"element"),n=t.$normalizeSelection__EXPERIMENTAL(n),n.anchor.is(s))return!0}return!1}(o)?i.shiftKey?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND;return n.dispatchCommand(s,void 0)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.INDENT_CONTENT_COMMAND,()=>{const n="number"==typeof i?i:i?i.peek():null,s=t.$getSelection();if(!t.$isRangeSelection(s))return!1;const r="function"==typeof o?o:o.peek();return e.$handleIndentAndOutdent(t=>{if(r(t)){const e=t.getIndent()+1;(!n||e<n)&&t.setIndent(e)}})},t.COMMAND_PRIORITY_CRITICAL))}const Ot=t.defineExtension({build:(t,e,n)=>D(e),config:t.safeCast({$canIndent:Nt,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return C(()=>{if(!i.value)return bt(t,o,s)})}});exports.configExtension=t.configExtension,exports.declarePeerDependency=t.declarePeerDependency,exports.defineExtension=t.defineExtension,exports.safeCast=t.safeCast,exports.shallowMergeConfig=t.shallowMergeConfig,exports.$createHorizontalRuleNode=xt,exports.$isDecoratorTextNode=F,exports.$isHorizontalRuleNode=Et,exports.AutoFocusExtension=M,exports.ClearEditorExtension=T,exports.DecoratorTextExtension=j,exports.DecoratorTextNode=A,exports.EditorStateExtension=K,exports.HorizontalRuleExtension=vt,exports.HorizontalRuleNode=pt,exports.INSERT_HORIZONTAL_RULE_COMMAND=gt,exports.InitialStateExtension=ot,exports.LexicalBuilder=lt,exports.NestedEditorExtension=St,exports.NodeSelectionExtension=ht,exports.SelectionAlwaysOnDisplayExtension=yt,exports.TabIndentationExtension=Ot,exports.applyFormatFromStyle=function(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),a="italic"===e.fontStyle,c=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),a&&!t.hasFormat("italic")&&t.toggleFormat("italic"),c&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t},exports.applyFormatToDom=function(t,e,n=k){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=P(e,i));return e},exports.batch=o,exports.buildEditorFromExtensions=function(...t){return lt.fromExtensions(t).buildEditor()},exports.computed=y,exports.effect=C,exports.getExtensionDependencyFromEditor=function(t,e){const n=lt.fromEditor(t).getExtensionRep(e);return void 0===n&&z(303,e.name),n.getExtensionDependency()},exports.getKnownTypesAndNodes=function(t){const e=new Set,n=new Set;for(const i of I(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}},exports.getPeerDependencyFromEditor=ut,exports.getPeerDependencyFromEditorOrThrow=function(t,e){const n=ut(t,e);return void 0===n&&z(291,e),n},exports.namedSignals=D,exports.registerClearEditor=_,exports.registerTabIndentation=bt,exports.signal=m,exports.untracked=a,exports.watchedSignal=L;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,FORMAT_TEXT_COMMAND as a,$isNodeSelection as d,COMMAND_PRIORITY_LOW as u,DecoratorNode as f,$getState as l,toggleTextFormatType as h,$setState as g,TEXT_TYPE_TO_FORMAT as p,createState as m,shallowMergeConfig as v,RootNode as x,TextNode as E,LineBreakNode as y,TabNode as S,ParagraphNode as b,$isEditorState as w,HISTORY_MERGE_TAG as N,createEditor as O,mergeRegister as R,$getNodeByKey as C,$create as D,CLICK_COMMAND as F,isDOMNode as M,$getNodeFromDOMNode as I,addClassNamesToElement as _,createCommand as P,$createNodeSelection as A,$setSelection as j,removeClassNamesFromElement as k,$getEditor as $,KEY_TAB_COMMAND as K,OUTDENT_CONTENT_COMMAND as z,INDENT_CONTENT_COMMAND as L,INSERT_TAB_COMMAND as U,COMMAND_PRIORITY_CRITICAL as T,$isBlockElementNode as B,$createRangeSelection as W,$normalizeSelection__EXPERIMENTAL as G}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$insertNodeToNearestRoot as V,selectionAlwaysOnDisplay as Z,$handleIndentAndOutdent as J,$getNearestBlockElementAncestorOrThrow as H}from"@lexical/utils";const q=Symbol.for("preact-signals");function Q(){if(it>1)return void it--;let t,e=!1;for(!function(){let t=nt;for(nt=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==tt;){let n=tt;for(tt=void 0,ot++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ft(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(ot=0,it--,e)throw t}function X(t){if(it>0)return t();rt=++st,it++;try{return t()}finally{Q()}}let Y,tt;function et(t){const e=Y;Y=void 0;try{return t()}finally{Y=e}}let nt,it=0,ot=0,st=0,rt=0,ct=0;function at(t){if(void 0===Y)return;let e=t.n;return void 0===e||e.t!==Y?(e={i:0,S:t,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:e},void 0!==Y.s&&(Y.s.n=e),Y.s=e,t.n=e,32&Y.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=Y.s,e.n=void 0,Y.s.n=e,Y.s=e),e):void 0}function dt(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function ut(t,e){return new dt(t,e)}function ft(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function lt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function ht(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function gt(t,e){dt.call(this,void 0),this.x=t,this.s=void 0,this.g=ct-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function pt(t,e){return new gt(t,e)}function mt(t){const e=t.m;if(t.m=void 0,"function"==typeof e){it++;const n=Y;Y=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,vt(t),e}finally{Y=n,Q()}}}function vt(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,mt(t)}function xt(t){if(Y!==this)throw new Error("Out-of-order effect");ht(this),Y=t,this.f&=-2,8&this.f&&vt(this),Q()}function Et(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function yt(t,e){const n=new Et(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function St(t,e={}){const n={};for(const i in t){const o=e[i],s=ut(void 0===o?t[i]:o);n[i]=s}return n}dt.prototype.brand=q,dt.prototype.h=function(){return!0},dt.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:et(()=>{var t;null==(t=this.W)||t.call(this)}))},dt.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&et(()=>{var t;null==(t=this.Z)||t.call(this)}))}},dt.prototype.subscribe=function(t){return yt(()=>{const e=this.value,n=Y;Y=void 0;try{t(e)}finally{Y=n}},{name:"sub"})},dt.prototype.valueOf=function(){return this.value},dt.prototype.toString=function(){return this.value+""},dt.prototype.toJSON=function(){return this.value},dt.prototype.peek=function(){const t=Y;Y=void 0;try{return this.value}finally{Y=t}},Object.defineProperty(dt.prototype,"value",{get(){const t=at(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(ot>100)throw new Error("Cycle detected");!function(t){0!==it&&0===ot&&t.l!==rt&&(t.l=rt,nt={S:t,v:t.v,i:t.i,o:nt})}(this),this.v=t,this.i++,ct++,it++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{Q()}}}}),gt.prototype=new dt,gt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ct)return!0;if(this.g=ct,this.f|=1,this.i>0&&!ft(this))return this.f&=-2,!0;const t=Y;try{lt(this),Y=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Y=t,ht(this),this.f&=-2,!0},gt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}dt.prototype.S.call(this,t)},gt.prototype.U=function(t){if(void 0!==this.t&&(dt.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},gt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(gt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=at(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Et.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.m=t)}finally{t()}},Et.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,mt(this),lt(this),it++;const t=Y;return Y=this,xt.bind(this,t)},Et.prototype.N=function(){2&this.f||(this.f|=2,this.u=tt,tt=this)},Et.prototype.d=function(){this.f|=8,1&this.f||vt(this)},Et.prototype.dispose=function(){this.d()};const bt=t({build:(t,e,n)=>St(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return yt(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function wt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function Nt(t,e=wt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const Ot=t({build:(t,e,n)=>St(e),config:e({$onClear:wt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return yt(()=>Nt(t,i.value))}});function Rt(t){const e=new Set,n=new Set;for(const i of Ct(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Ct(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const Dt=m("format",{parse:t=>"number"==typeof t?t:0});class Ft extends f{$config(){return this.config("decorator-text",{extends:f,stateConfigs:[{flat:!0,stateConfig:Dt}]})}getFormat(){return l(this,Dt)}getFormatFlags(t,e){return h(this.getFormat(),t,e)}hasFormat(t){const e=p[t];return 0!==(this.getFormat()&e)}setFormat(t){return g(this,Dt,t)}toggleFormat(t){const e=this.getFormat(),n=h(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function Mt(t){return t instanceof Ft}function It(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),c="italic"===e.fontStyle,a=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),c&&!t.hasFormat("italic")&&t.toggleFormat("italic"),a&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t}function _t(t,e,n=At){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=Pt(e,i));return e}function Pt(t,e){const n=document.createElement(e);return n.appendChild(t),n}const At={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},jt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[Ft],register:(t,e,n)=>t.registerCommand(a,t=>{const e=s();if(d(e)||c(e))for(const n of e.getNodes())Mt(n)&&n.toggleFormat(t);return!1},u)});function kt(t,e){let n;return ut(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const $t=t({build:t=>kt(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function Kt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function zt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=zt(n[t],i[t]);return t}return e}const Lt=0,Ut=1,Tt=2,Bt=3,Wt=4,Gt=5,Vt=6,Zt=7;function Jt(t){return t.id===Lt}function Ht(t){return t.id===Tt}function qt(t){return function(t){return t.id===Ut}(t)||Kt(305,String(t.id),String(Ut)),Object.assign(t,{id:Tt})}const Qt=new Set;class Xt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Lt}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):v;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Ht(e)||Kt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:Bt,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:Wt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==Wt&&Kt(307,String(e.id),String(Gt)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Gt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Gt&&Kt(308,String(n.id),String(Gt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Vt})}(n),()=>{const t=this.state;t.id!==Zt&&Kt(309,String(n.id),String(Zt)),this.state=function(t){return Object.assign(t,{id:Gt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Vt&&Kt(310,String(e.id),String(Vt)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Zt})}(e),n}getSignal(){return void 0===this._signal&&Kt(311),this._signal}getInitResult(){void 0===this.extension.init&&Kt(312,this.extension.name);const t=this.state;return function(t){return t.id>=Wt}(t)||Kt(313,String(t.id),String(Wt)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=Bt}(t)||Kt(314,String(t.id),String(Bt)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&Kt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&Kt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Zt}(t)||Kt(316,String(t.id),String(Zt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Qt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=Gt})(t)||Kt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Yt={tag:N};function te(){const t=o();t.isEmpty()&&t.append(r())}const ee=t({config:e({setOptions:Yt,updateOptions:Yt}),init:({$initialEditorState:t=te})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(w(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t)},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[x,E,y,S,b]}),ne=Symbol.for("@lexical/extension/LexicalBuilder");function ie(...t){return ae.fromExtensions(t).buildEditor()}function oe(){}function se(t){throw t}function re(t){return Array.isArray(t)?t:[t]}const ce="0.43.0+prod.esm";class ae{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ce,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[re(ee)];for(const n of t)e.push(re(n));return new ae(e)}static maybeFromEditor(t){const e=t[ne];return e&&(e.PACKAGE_VERSION!==ce&&Kt(292,e.PACKAGE_VERSION,ce),e instanceof ae||Kt(293)),e}static fromEditor(t){const e=ae.maybeFromEditor(t);return void 0===e&&Kt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(O({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[ne]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=oe;function e(){try{t()}finally{t=oe}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=R(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&Kt(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&Kt(296);const e=re(t),[n]=e;"string"!=typeof n.name&&Kt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&Kt(298,n.name),!i){i=new Xt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&Kt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&Kt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=re(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Ht(o))return;const s=n.extension.name;var r;Jt(o)||Kt(300,s,i||"[unknown]"),Jt(r=o)||Kt(304,String(r.id),String(Lt)),o=Object.assign(r,{id:Ut}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=qt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Jt(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&Kt(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return R(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of Ct(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&Kt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&zt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=se),t}}function de(t,e){const n=ae.fromEditor(t).getExtensionRep(e);return void 0===n&&Kt(303,e.name),n.getExtensionDependency()}function ue(t,e){const n=ae.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function fe(t,e){const n=ue(t,e);return void 0===n&&Kt(291,e),n}const le=new Set,he=t({build(t,e,n){const i=n.getDependency($t).output,o=ut({watchedNodeKeys:new Map}),r=kt(()=>{},()=>yt(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read(()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=C(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}}),!c&&n&&t&&n.size===t.size||(r.value=n)}));return{watchNodeKey:function(t){const e=pt(()=>(r.value||le).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[$t],name:"@lexical/extension/NodeSelection"}),ge=P("INSERT_HORIZONTAL_RULE_COMMAND");class pe extends f{static getType(){return"horizontalrule"}static clone(t){return new pe(t.__key)}static importJSON(t){return ve().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:me,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return _(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function me(){return{node:ve()}}function ve(){return D(pe)}function xe(t){return t instanceof pe}const Ee=t({dependencies:[$t,he],name:"@lexical/extension/HorizontalRule",nodes:()=>[pe],register(t,e,n){const{watchNodeKey:o}=n.getDependency(he).output,r=ut({nodeSelections:new Map}),a=t._config.theme.hrSelected??"selected";return R(t.registerCommand(ge,t=>{const e=s();if(!c(e))return!1;if(null!==e.focus.getNode()){const t=ve();V(t)}return!0},i),t.registerCommand(F,t=>{if(M(t.target)){const e=I(t.target);if(xe(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&d(n)?r=n:(r=A(),j(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},u),t.registerMutationListener(pe,(e,n)=>{X(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[s,r]of e.entries())if("destroyed"===r)i.delete(s),n=!0;else{const e=i.get(s),r=t.getElementByKey(s);e?e.domNode.value=r:(n=!0,i.set(s,{domNode:ut(r),selectedSignal:o(s)}))}n&&(r.value={nodeSelections:i})})}),yt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of r.value.nodeSelections.values())t.push(yt(()=>{const t=e.value;if(t){n.value?_(t,a):k(t,a)}}));return R(...t)}))}});const ye=t({build:(t,e)=>St({inheritEditableFromParent:e.inheritEditableFromParent}),config:e({$getParentEditor:function(){const t=$();return ae.fromEditor(t),t},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>yt(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),Se=t({build:(t,e,n)=>St(e),config:e({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,e,n)=>{const i=n.getOutput();return yt(()=>{if(!i.disabled.value)return Z(t,i.onReposition.value)})}});function be(t){return t.canBeEmpty()}function we(t,e,n=be){return R(t.registerCommand(K,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>B(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=H(o);if(s.canIndent()){const t=s.getKey();let e=W();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=G(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?z:L:U;return t.dispatchCommand(i,void 0)},i),t.registerCommand(L,()=>{const t="number"==typeof e?e:e?e.peek():null,i=s();if(!c(i))return!1;const o="function"==typeof n?n:n.peek();return J(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},T))}const Ne=t({build:(t,e,n)=>St(e),config:e({$canIndent:be,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return yt(()=>{if(!i.value)return we(t,o,s)})}});export{ve as $createHorizontalRuleNode,Mt as $isDecoratorTextNode,xe as $isHorizontalRuleNode,bt as AutoFocusExtension,Ot as ClearEditorExtension,jt as DecoratorTextExtension,Ft as DecoratorTextNode,$t as EditorStateExtension,Ee as HorizontalRuleExtension,pe as HorizontalRuleNode,ge as INSERT_HORIZONTAL_RULE_COMMAND,ee as InitialStateExtension,ae as LexicalBuilder,ye as NestedEditorExtension,he as NodeSelectionExtension,Se as SelectionAlwaysOnDisplayExtension,Ne as TabIndentationExtension,It as applyFormatFromStyle,_t as applyFormatToDom,X as batch,ie as buildEditorFromExtensions,pt as computed,yt as effect,de as getExtensionDependencyFromEditor,Rt as getKnownTypesAndNodes,ue as getPeerDependencyFromEditor,fe as getPeerDependencyFromEditorOrThrow,St as namedSignals,Nt as registerClearEditor,we as registerTabIndentation,ut as signal,et as untracked,kt as watchedSignal};
9
+ import{defineExtension as t,safeCast as e,CLEAR_EDITOR_COMMAND as n,COMMAND_PRIORITY_EDITOR as i,$getRoot as o,$getSelection as s,$createParagraphNode as r,$isRangeSelection as c,FORMAT_TEXT_COMMAND as a,$isNodeSelection as d,COMMAND_PRIORITY_LOW as u,DecoratorNode as f,$getState as l,toggleTextFormatType as h,$setState as g,TEXT_TYPE_TO_FORMAT as p,createState as m,shallowMergeConfig as v,RootNode as x,TextNode as y,LineBreakNode as E,TabNode as S,ParagraphNode as b,$isEditorState as w,HISTORY_MERGE_TAG as N,createEditor as O,mergeRegister as R,$getNodeByKey as C,$create as D,CLICK_COMMAND as F,isDOMNode as M,$getNodeFromDOMNode as I,addClassNamesToElement as _,createCommand as P,$createNodeSelection as A,$setSelection as j,removeClassNamesFromElement as k,$getEditor as $,KEY_TAB_COMMAND as K,OUTDENT_CONTENT_COMMAND as z,INDENT_CONTENT_COMMAND as L,INSERT_TAB_COMMAND as U,COMMAND_PRIORITY_CRITICAL as T,$isBlockElementNode as B,$createRangeSelection as W,$normalizeSelection__EXPERIMENTAL as G}from"lexical";export{configExtension,declarePeerDependency,defineExtension,safeCast,shallowMergeConfig}from"lexical";import{$insertNodeToNearestRoot as V,selectionAlwaysOnDisplay as Z,$handleIndentAndOutdent as J,$getNearestBlockElementAncestorOrThrow as H}from"@lexical/utils";const q=Symbol.for("preact-signals");function Q(){if(it>1)return void it--;let t,e=!1;for(!function(){let t=nt;for(nt=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==tt;){let n=tt;for(tt=void 0,ot++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ft(n))try{n.c()}catch(n){e||(t=n,e=!0)}n=i}}if(ot=0,it--,e)throw t}function X(t){if(it>0)return t();rt=++st,it++;try{return t()}finally{Q()}}let Y,tt;function et(t){const e=Y;Y=void 0;try{return t()}finally{Y=e}}let nt,it=0,ot=0,st=0,rt=0,ct=0;function at(t){if(void 0===Y)return;let e=t.n;return void 0===e||e.t!==Y?(e={i:0,S:t,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:e},void 0!==Y.s&&(Y.s.n=e),Y.s=e,t.n=e,32&Y.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=Y.s,e.n=void 0,Y.s.n=e,Y.s=e),e):void 0}function dt(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function ut(t,e){return new dt(t,e)}function ft(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function lt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function ht(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t}t.s=e}function gt(t,e){dt.call(this,void 0),this.x=t,this.s=void 0,this.g=ct-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function pt(t,e){return new gt(t,e)}function mt(t){const e=t.m;if(t.m=void 0,"function"==typeof e){it++;const n=Y;Y=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,vt(t),e}finally{Y=n,Q()}}}function vt(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,mt(t)}function xt(t){if(Y!==this)throw new Error("Out-of-order effect");ht(this),Y=t,this.f&=-2,8&this.f&&vt(this),Q()}function yt(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function Et(t,e){const n=new yt(t,e);try{n.c()}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function St(t,e={}){const n={};for(const i in t){const o=e[i],s=ut(void 0===o?t[i]:o);n[i]=s}return n}dt.prototype.brand=q,dt.prototype.h=function(){return!0},dt.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:et(()=>{var t;null==(t=this.W)||t.call(this)}))},dt.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&et(()=>{var t;null==(t=this.Z)||t.call(this)}))}},dt.prototype.subscribe=function(t){return Et(()=>{const e=this.value,n=Y;Y=void 0;try{t(e)}finally{Y=n}},{name:"sub"})},dt.prototype.valueOf=function(){return this.value},dt.prototype.toString=function(){return this.value+""},dt.prototype.toJSON=function(){return this.value},dt.prototype.peek=function(){const t=Y;Y=void 0;try{return this.value}finally{Y=t}},Object.defineProperty(dt.prototype,"value",{get(){const t=at(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(ot>100)throw new Error("Cycle detected");!function(t){0!==it&&0===ot&&t.l!==rt&&(t.l=rt,nt={S:t,v:t.v,i:t.i,o:nt})}(this),this.v=t,this.i++,ct++,it++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{Q()}}}}),gt.prototype=new dt,gt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ct)return!0;if(this.g=ct,this.f|=1,this.i>0&&!ft(this))return this.f&=-2,!0;const t=Y;try{lt(this),Y=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Y=t,ht(this),this.f&=-2,!0},gt.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}dt.prototype.S.call(this,t)},gt.prototype.U=function(t){if(void 0!==this.t&&(dt.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}},gt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(gt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=at(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),yt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.m=t)}finally{t()}},yt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,mt(this),lt(this),it++;const t=Y;return Y=this,xt.bind(this,t)},yt.prototype.N=function(){2&this.f||(this.f|=2,this.u=tt,tt=this)},yt.prototype.d=function(){this.f|=8,1&this.f||vt(this)},yt.prototype.dispose=function(){this.d()};const bt=t({build:(t,e,n)=>St(e),config:e({defaultSelection:"rootEnd",disabled:!1}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return Et(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:!0})},{defaultSelection:i.defaultSelection.peek()})}))}});function wt(){const t=o(),e=s(),n=r();t.clear(),t.append(n),null!==e&&n.select(),c(e)&&(e.format=0)}function Nt(t,e=wt){return t.registerCommand(n,n=>(t.update(e),!0),i)}const Ot=t({build:(t,e,n)=>St(e),config:e({$onClear:wt}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return Et(()=>Nt(t,i.value))}});function Rt(t){const e=new Set,n=new Set;for(const i of Ct(t)){const t="function"==typeof i?i:i.replace;e.add(t.getType()),n.add(t)}return{nodes:n,types:e}}function Ct(t){return("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const Dt=m("format",{parse:t=>"number"==typeof t?t:0});class Ft extends f{$config(){return this.config("decorator-text",{extends:f,stateConfigs:[{flat:!0,stateConfig:Dt}]})}getFormat(){return l(this,Dt)}getFormatFlags(t,e){return h(this.getFormat(),t,e)}hasFormat(t){const e=p[t];return 0!==(this.getFormat()&e)}setFormat(t){return g(this,Dt,t)}toggleFormat(t){const e=this.getFormat(),n=h(e,t,null);return this.setFormat(n)}isInline(){return!0}createDOM(){return document.createElement("span")}updateDOM(){return!1}}function Mt(t){return t instanceof Ft}function It(t,e,n){const i=e.fontWeight,o=e.textDecoration.split(" "),s="700"===i||"bold"===i,r=o.includes("line-through"),c="italic"===e.fontStyle,a=o.includes("underline"),d=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),r&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),c&&!t.hasFormat("italic")&&t.toggleFormat("italic"),a&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==d||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==d||t.hasFormat("superscript")||t.toggleFormat("superscript"),n&&!t.hasFormat(n)&&t.toggleFormat(n),t}function _t(t,e,n=At){for(const[i,o]of Object.entries(n))t.hasFormat(o)&&(e=Pt(e,i));return e}function Pt(t,e){const n=document.createElement(e);return n.appendChild(t),n}const At={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},jt=t({name:"@lexical/extension/DecoratorText",nodes:()=>[Ft],register:(t,e,n)=>t.registerCommand(a,t=>{const e=s();if(d(e)||c(e))for(const n of e.getNodes())Mt(n)&&n.toggleFormat(t);return!1},u)});function kt(t,e){let n;return ut(t(),{unwatched(){n&&(n(),n=void 0)},watched(){this.value=t(),n=e(this)}})}const $t=t({build:t=>kt(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState})),name:"@lexical/extension/EditorState"});function Kt(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function zt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=zt(n[t],i[t]);return t}return e}const Lt=0,Ut=1,Tt=2,Bt=3,Wt=4,Gt=5,Vt=6,Zt=7;function Jt(t){return t.id===Lt}function Ht(t){return t.id===Tt}function qt(t){return function(t){return t.id===Ut}(t)||Kt(305,String(t.id),String(Ut)),Object.assign(t,{id:Tt})}const Qt=new Set;class Xt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Lt}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):v;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Ht(e)||Kt(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:Bt,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:Wt,initResult:e,registerState:n})}(o,s,i)}build(t){const e=this.state;let n;e.id!==Wt&&Kt(307,String(e.id),String(Gt)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Gt,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==Gt&&Kt(308,String(n.id),String(Gt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Vt})}(n),()=>{const t=this.state;t.id!==Zt&&Kt(309,String(n.id),String(Zt)),this.state=function(t){return Object.assign(t,{id:Gt})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==Vt&&Kt(310,String(e.id),String(Vt)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Zt})}(e),n}getSignal(){return void 0===this._signal&&Kt(311),this._signal}getInitResult(){void 0===this.extension.init&&Kt(312,this.extension.name);const t=this.state;return function(t){return t.id>=Wt}(t)||Kt(313,String(t.id),String(Wt)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=Bt}(t)||Kt(314,String(t.id),String(Bt)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&Kt(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&Kt(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Zt}(t)||Kt(316,String(t.id),String(Zt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Qt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=Gt})(t)||Kt(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Yt={tag:N};function te(){const t=o();t.isEmpty()&&t.append(r())}const ee=t({config:e({setOptions:Yt,updateOptions:Yt}),init:({$initialEditorState:t=te})=>({$initialEditorState:t,initialized:!1}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(w(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t)},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[x,y,E,S,b]}),ne=Symbol.for("@lexical/extension/LexicalBuilder");function ie(...t){return ae.fromExtensions(t).buildEditor()}function oe(){}function se(t){throw t}function re(t){return Array.isArray(t)?t:[t]}const ce="0.43.1-nightly.20260410.0+prod.esm";class ae{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ce,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[re(ee)];for(const n of t)e.push(re(n));return new ae(e)}static maybeFromEditor(t){const e=t[ne];return e&&(e.PACKAGE_VERSION!==ce&&Kt(292,e.PACKAGE_VERSION,ce),e instanceof ae||Kt(293)),e}static fromEditor(t){const e=ae.maybeFromEditor(t);return void 0===e&&Kt(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(O({...n,...e?{onError:t=>{e(t,i)}}:{}}),{[ne]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=oe;function e(){try{t()}finally{t=oe}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=R(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&Kt(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&Kt(296);const e=re(t),[n]=e;"string"!=typeof n.name&&Kt(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&Kt(298,n.name),!i){i=new Xt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&Kt(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&Kt(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=re(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Ht(o))return;const s=n.extension.name;var r;Jt(o)||Kt(300,s,i||"[unknown]"),Jt(r=o)||Kt(304,String(r.id),String(Lt)),o=Object.assign(r,{id:Ut}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s)}o=qt(o),n.state=o,t.push(n)};for(const t of this.extensionNameMap.values())Jt(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&Kt(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e)}return R(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of Ct(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&Kt(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c)}e.add(t)}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import)}r.theme&&zt(s,r.theme)}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=se),t}}function de(t,e){const n=ae.fromEditor(t).getExtensionRep(e);return void 0===n&&Kt(303,e.name),n.getExtensionDependency()}function ue(t,e){const n=ae.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function fe(t,e){const n=ue(t,e);return void 0===n&&Kt(291,e),n}const le=new Set,he=t({build(t,e,n){const i=n.getDependency($t).output,o=ut({watchedNodeKeys:new Map}),r=kt(()=>{},()=>Et(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=!1;i.value.read(()=>{if(s())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=C(i),r=s&&s.isSelected()||!1;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i))}}),!c&&n&&t&&n.size===t.size||(r.value=n)}));return{watchNodeKey:function(t){const e=pt(()=>(r.value||le).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[$t],name:"@lexical/extension/NodeSelection"}),ge=P("INSERT_HORIZONTAL_RULE_COMMAND");class pe extends f{static getType(){return"horizontalrule"}static clone(t){return new pe(t.__key)}static importJSON(t){return ve().updateFromJSON(t)}static importDOM(){return{hr:()=>({conversion:me,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return _(e,t.theme.hr),e}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function me(){return{node:ve()}}function ve(){return D(pe)}function xe(t){return t instanceof pe}const ye=t({dependencies:[$t,he],name:"@lexical/extension/HorizontalRule",nodes:()=>[pe],register(t,e,n){const{watchNodeKey:o}=n.getDependency(he).output,r=ut({nodeSelections:new Map}),a=t._config.theme.hrSelected??"selected";return R(t.registerCommand(ge,t=>{const e=s();if(!c(e))return!1;if(null!==e.focus.getNode()){const t=ve();V(t)}return!0},i),t.registerCommand(F,t=>{if(M(t.target)){const e=I(t.target);if(xe(e))return function(t,e=!1){const n=s(),i=t.isSelected(),o=t.getKey();let r;e&&d(n)?r=n:(r=A(),j(r)),i?r.delete(o):r.add(o)}(e,t.shiftKey),!0}return!1},u),t.registerMutationListener(pe,(e,n)=>{X(()=>{let n=!1;const{nodeSelections:i}=r.peek();for(const[s,r]of e.entries())if("destroyed"===r)i.delete(s),n=!0;else{const e=i.get(s),r=t.getElementByKey(s);e?e.domNode.value=r:(n=!0,i.set(s,{domNode:ut(r),selectedSignal:o(s)}))}n&&(r.value={nodeSelections:i})})}),Et(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of r.value.nodeSelections.values())t.push(Et(()=>{const t=e.value;if(t){n.value?_(t,a):k(t,a)}}));return R(...t)}))}});const Ee=t({build:(t,e)=>St({inheritEditableFromParent:e.inheritEditableFromParent}),config:e({$getParentEditor:function(){const t=$();return ae.fromEditor(t),t},inheritEditableFromParent:!1}),init:(t,e,n)=>{const i=e.$getParentEditor();t.parentEditor=i,t.theme=t.theme||i._config.theme},name:"@lexical/extension/NestedEditor",register:(t,e,n)=>Et(()=>{const e=t._parentEditor;if(e&&n.getOutput().inheritEditableFromParent.value)return t.setEditable(e.isEditable()),e.registerEditableListener(t.setEditable.bind(t))})}),Se=t({build:(t,e,n)=>St(e),config:e({disabled:!1,onReposition:void 0}),name:"@lexical/utils/SelectionAlwaysOnDisplay",register:(t,e,n)=>{const i=n.getOutput();return Et(()=>{if(!i.disabled.value)return Z(t,i.onReposition.value)})}});function be(t){return t.canBeEmpty()}function we(t,e,n=be){return R(t.registerCommand(K,e=>{const n=s();if(!c(n))return!1;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>B(t)&&t.canIndent()).length>0)return!0;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=H(o);if(s.canIndent()){const t=s.getKey();let e=W();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=G(e),e.anchor.is(i))return!0}return!1}(n)?e.shiftKey?z:L:U;return t.dispatchCommand(i,void 0)},i),t.registerCommand(L,()=>{const t="number"==typeof e?e:e?e.peek():null,i=s();if(!c(i))return!1;const o="function"==typeof n?n:n.peek();return J(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n)}})},T))}const Ne=t({build:(t,e,n)=>St(e),config:e({$canIndent:be,disabled:!1,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return Et(()=>{if(!i.value)return we(t,o,s)})}});export{ve as $createHorizontalRuleNode,Mt as $isDecoratorTextNode,xe as $isHorizontalRuleNode,bt as AutoFocusExtension,Ot as ClearEditorExtension,jt as DecoratorTextExtension,Ft as DecoratorTextNode,$t as EditorStateExtension,ye as HorizontalRuleExtension,pe as HorizontalRuleNode,ge as INSERT_HORIZONTAL_RULE_COMMAND,ee as InitialStateExtension,ae as LexicalBuilder,Ee as NestedEditorExtension,he as NodeSelectionExtension,Se as SelectionAlwaysOnDisplayExtension,Ne as TabIndentationExtension,It as applyFormatFromStyle,_t as applyFormatToDom,X as batch,ie as buildEditorFromExtensions,pt as computed,Et as effect,de as getExtensionDependencyFromEditor,Rt as getKnownTypesAndNodes,ue as getPeerDependencyFromEditor,fe as getPeerDependencyFromEditorOrThrow,St as namedSignals,Nt as registerClearEditor,we as registerTabIndentation,ut as signal,et as untracked,kt as watchedSignal};
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "extension",
7
7
  "plugin"
8
8
  ],
9
- "version": "0.43.0",
9
+ "version": "0.43.1-nightly.20260410.0",
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",
@@ -23,9 +23,9 @@
23
23
  "sideEffects": false,
24
24
  "module": "LexicalExtension.mjs",
25
25
  "dependencies": {
26
- "@lexical/utils": "0.43.0",
26
+ "@lexical/utils": "0.43.1-nightly.20260410.0",
27
27
  "@preact/signals-core": "^1.14.1",
28
- "lexical": "0.43.0"
28
+ "lexical": "0.43.1-nightly.20260410.0"
29
29
  },
30
30
  "exports": {
31
31
  ".": {