@mrakomor/core 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockChrome.mjs +2 -2
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-2C6UDFD4.mjs +1 -0
- package/dist/chunk-5HWTMPF4.mjs +2 -0
- package/dist/chunk-6CG6EGQM.mjs +2 -0
- package/dist/{chunk-K2DMHAUD.mjs → chunk-7CJLTNHZ.mjs} +1 -1
- package/dist/chunk-ERNLRJPB.mjs +1 -0
- package/dist/chunk-EXDY5TZH.mjs +1 -0
- package/dist/chunk-FAXIFXQK.mjs +4 -0
- package/dist/chunk-GDDVUIEH.mjs +1 -0
- package/dist/{chunk-GDID5DFL.mjs → chunk-JVQ2YGII.mjs} +1 -1
- package/dist/chunk-P7TUN2KD.mjs +1 -0
- package/dist/chunk-S2W6LYHT.mjs +1 -0
- package/dist/chunk-TL5BHWDU.mjs +2 -0
- package/dist/chunk-ZHOZPQZH.mjs +1 -0
- package/dist/clipboard.cjs +4 -4
- package/dist/clipboard.mjs +3 -3
- package/dist/footer.cjs +4 -1
- package/dist/footer.mjs +2 -2
- package/dist/headline.cjs +3 -2
- package/dist/headline.mjs +1 -1
- package/dist/help.mjs +2 -2
- package/dist/index.cjs +6 -5
- package/dist/index.mjs +4 -4
- package/dist/link.cjs +3 -3
- package/dist/link.mjs +2 -2
- package/dist/list.cjs +3 -3
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +3 -2
- package/dist/paragraph.mjs +1 -1
- package/dist/slashCommand.cjs +2 -2
- package/dist/slashCommand.mjs +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.mjs +2 -2
- package/dist/tts.cjs +8 -8
- package/dist/tts.mjs +3 -3
- package/dist/types/Mrakomor.d.mts +230 -0
- package/dist/types/component/AbstractComponent.d.mts +69 -0
- package/dist/types/component/Editor.d.mts +8 -0
- package/dist/types/component/block/BlockComponent.d.mts +105 -0
- package/dist/types/component/block/BlockRegister.d.mts +29 -0
- package/dist/types/component/block/ExternalComponent.d.mts +42 -0
- package/dist/types/component/block/UnknownComponent.d.mts +3 -0
- package/dist/types/component/block/blockItemEquals.d.mts +6 -0
- package/dist/types/component/block/helpers.d.mts +319 -0
- package/dist/types/component/editorContext.d.mts +4 -0
- package/dist/types/component/entityRange/EntityRangeElement.d.mts +15 -0
- package/dist/types/component/inlineStyle/Bold.d.mts +4 -0
- package/dist/types/component/inlineStyle/InlineElement.d.mts +10 -0
- package/dist/types/component/inlineStyle/Italic.d.mts +4 -0
- package/dist/types/component/inlineStyle/Subscript.d.mts +4 -0
- package/dist/types/component/inlineStyle/Superscript.d.mts +4 -0
- package/dist/types/component/inlineStyle/Underline.d.mts +4 -0
- package/dist/types/component/inlineStyle/index.d.mts +5 -0
- package/dist/types/component/overlayMount.d.mts +46 -0
- package/dist/types/dom.d.mts +161 -0
- package/dist/types/emitter.d.mts +38 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/namespaces.d.mts +17 -0
- package/dist/types/plugin/blockChrome/BlockChrome.d.mts +11 -0
- package/dist/types/plugin/blockChrome/index.d.mts +1 -0
- package/dist/types/plugin/blockInsertMenu/BlockInsertMenu.d.mts +6 -0
- package/dist/types/plugin/blockInsertMenu/index.d.mts +1 -0
- package/dist/types/plugin/clipboard/clipboardHelpers.d.mts +151 -0
- package/dist/types/plugin/clipboard/clipboardPlugin.d.mts +6 -0
- package/dist/types/plugin/clipboard/index.d.mts +1 -0
- package/dist/types/plugin/default/defaultMrakomorPlugin.d.mts +21 -0
- package/dist/types/plugin/dialog/Dialog.d.mts +23 -0
- package/dist/types/plugin/footer/footerPlugin.d.mts +7 -0
- package/dist/types/plugin/footer/index.d.mts +1 -0
- package/dist/types/plugin/headline/Headline.d.mts +29 -0
- package/dist/types/plugin/headline/index.d.mts +1 -0
- package/dist/types/plugin/help/HelpRegister.d.mts +15 -0
- package/dist/types/plugin/help/helpPlugin.d.mts +26 -0
- package/dist/types/plugin/help/helpSchema.d.mts +11 -0
- package/dist/types/plugin/help/index.d.mts +1 -0
- package/dist/types/plugin/linkEntity/LinkEntity.d.mts +37 -0
- package/dist/types/plugin/linkEntity/index.d.mts +1 -0
- package/dist/types/plugin/list/List.d.mts +61 -0
- package/dist/types/plugin/list/index.d.mts +1 -0
- package/dist/types/plugin/list/listHelpers.d.mts +166 -0
- package/dist/types/plugin/menu/Menu.d.mts +22 -0
- package/dist/types/plugin/menu/menuPlugin.d.mts +6 -0
- package/dist/types/plugin/paragraph/Paragraph.d.mts +16 -0
- package/dist/types/plugin/paragraph/index.d.mts +1 -0
- package/dist/types/plugin/slashCommand/SlashActionRegister.d.mts +12 -0
- package/dist/types/plugin/slashCommand/index.d.mts +1 -0
- package/dist/types/plugin/slashCommand/slashActionSchema.d.mts +29 -0
- package/dist/types/plugin/slashCommand/slashCommandHelpers.d.mts +77 -0
- package/dist/types/plugin/slashCommand/slashCommandPlugin.d.mts +11 -0
- package/dist/types/plugin/slashCommand/slashHelp.d.mts +12 -0
- package/dist/types/plugin/tooltip/Tooltip.d.mts +16 -0
- package/dist/types/plugin/tooltip/index.d.mts +1 -0
- package/dist/types/plugin/tts/TtsHeadline.d.mts +27 -0
- package/dist/types/plugin/tts/TtsList.d.mts +19 -0
- package/dist/types/plugin/tts/TtsParagraph.d.mts +9 -0
- package/dist/types/plugin/tts/TtsVoice.d.mts +52 -0
- package/dist/types/plugin/tts/index.d.mts +4 -0
- package/dist/types/register/Register.d.mts +50 -0
- package/dist/types/register/sortRegisterEntries.d.mts +7 -0
- package/dist/types/schema/blockContent.d.mts +34 -0
- package/dist/types/schema/blockRegister.d.mts +14 -0
- package/dist/types/schema/config.d.mts +6 -0
- package/dist/types/types.d.mts +636 -0
- package/package.json +35 -23
- package/dist/chunk-5VPYPKGA.mjs +0 -1
- package/dist/chunk-G2QV4GOO.mjs +0 -1
- package/dist/chunk-N4I2WZWF.mjs +0 -1
- package/dist/chunk-Q7RMVYZR.mjs +0 -1
- package/dist/chunk-T7OO472O.mjs +0 -1
- package/dist/chunk-TX4RCFPO.mjs +0 -3
- package/dist/chunk-U3MSKB3R.mjs +0 -2
- package/dist/chunk-UC7W4JIH.mjs +0 -2
- package/dist/chunk-WBTDWVEC.mjs +0 -3
- package/dist/chunk-WQWE5UCN.mjs +0 -1
- package/dist/chunk-YHWQV2DB.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$
|
|
2
|
-
`,document.head.appendChild(e);}}})();var N=class extends p{static get nodeName(){return "span"}static get style(){return "SPAN"}static match(t){return t.nodeName===this.nodeName.toUpperCase()||t.style===this.style}getState(){return {style:this.constructor.style}}render(){return o(this.constructor.nodeName,{},this.props.children)}};var T=class extends N{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return o("b",{},"B")}static match(t){return t.nodeName==="strong"?true:super.match(t)}};var w=class extends N{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return o("i",{},"I")}};var P=class extends N{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return o("sub",{},"Sub")}};var U=class extends N{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return o("sup",{},"Sup")}};var K=class extends N{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return o("u",{},"U")}};var jt=a.object({component:a.function(),id:a.string(),label:a.string(),keywords:a.array(a.string()),group:a.string(),order:a.number().default(({context:n})=>n?.index??0),settings:a.any().optional()});function Wt(n,t){let e=`block:${n}`;return t?.style==="UNORDERED"?`${e}:ul`:t?.style==="ORDERED"?`${e}:ol`:e}function Pt(n,t=0){let e=typeof n=="function",o=e?n:n?.component,r=e?{}:n,s=o.NAMESPACE??"",i=s.split(".").pop()||s,a=r.label||o.LABEL||i||s,l=Array.isArray(o.KEYWORDS)?o.KEYWORDS:[],p=r.keywords?.length?r.keywords.map(String):l.length?l.map(String):[a,i].filter(Boolean).map(String),g=r.settings;return jt.parse({component:o,id:r.id||Wt(s,g),label:String(a),keywords:p,group:String(r.group||o.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...g?{settings:g}:{}},{context:{index:t}})}var Q=class n extends a$6{#o=null;constructor(t){super(t),this.subscribe(()=>{this.#o=null;});}normalize(t,e){if(t==null)return null;try{return Pt(t,e)}catch{return null}}getByNamespace(t){return this.#n().get(t)}#n(){return this.#o??=n.buildNamespaceMap(this.list()),this.#o}static buildNamespaceMap(t){let e=new Map;for(let o of t){let r=o.component?.NAMESPACE;r&&!e.has(r)&&e.set(r,o.component);}return e}};var v=class n extends a$4{static get NAMESPACE(){return c$1}static getStateSchema(t){return a.object({component:a.string().default(n.NAMESPACE),componentId:a.string().default(t?.getAttribute("data-componentid")||a$3()),properties:a.object({}).default({}),settings:a.object({}).default({})}).default({})}constructor(t){super(t),this.root=null;}getState(){return this.state.peek()}isAtomic(){return true}static appendExchangeState(){return null}onMount(){}onUnmount(){}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return o("div",{className:t,contentEditable:false,style:"position: relative;",$ref:o=>{this.element=o;},"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[o("div",{$ref:o=>{this.root=o;},style:"display: block;",contentEditable:false}),o("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:true,[d$1]:true},document.createTextNode("\xA0"))])}onKeydown(t){t.key!=="Backspace"&&t.key!=="ArrowUp"&&t.key!=="ArrowDown"&&t.preventDefault(),u(this,t);}};var z=class extends v{static get NAMESPACE(){return d$2}onMount(){let t=o("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);r(this.root,t);}onUnmount(){this.root.innerHTML="";}};function qt(n,t){let e=n._getBlockElementByComponentId(t);return t$1(e)?.isStale?.()??false}function Ut(n){return (t,e)=>{if(!h(t,e))return false;let o=e?.componentId??t?.componentId;return !(o&&qt(n,o))}}function Kt({mrakomor:n}){let t=n.get(),e=Ut(t);return j$2(a$7,t),l$1(()=>{t._onMount();}),m$1(()=>{t._onUnmount();}),o("div",{id:t._id,className:"mrakomor-editor"},[o("div",{className:"mrakomor-editor-surface"},[o("div",{className:"mrakomor-tools-container"}),o("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"}},[q(()=>t._getContentState(),o=>o.componentId,(o$1,r)=>o(()=>{let s;l$1(()=>{s.getNodeComponent=()=>{let l=s$1(s);return l?g(l):null},t._setBlockElement(s,r);}),m$1(()=>{t._removeBlockElement(s);});let i=t.resolveComponent(o$1.get().component,o$1),a=t.wrapBlockElement(i);return o("div",{className:"mrakomor-block-element",[b$2]:true,$ref:l=>{s=l;}},a)}),{equals:e})])])])}function Z(n,t,e){let o=n._getBlockElementIndex(t);if(o===-1)return false;let r=n.getContent();return r.splice(o,1,n.normalizeComponentState(e)),n._setContentState(r),true}function zt(n,{customHook:t,applyFn:e$1,applyArgs:o,resolveRange:r=true}){let{mrakomor:s}=n,{blockElement:i$1,range:a}=n;r&&(a=a??i(),i$1=i$1??e(a));let l=t$1(i$1),p=l?.[t]?.(n);if(n.defaultPrevented){p&&Z(s,i$1,p);return}let g=l?.getFormattingTarget?.(a);if(!g)return;let f=s._getBlockElementState(i$1);if(!f)return;let h=e$1(structuredClone(f),g,{...o,range:a});h&&Z(s,i$1,h);}function Vt(n$1){let{mrakomor:t}=n$1,{blockElement:e$1,range:o,newLineState:r,originalLineState:s,namespace:i,position:a,cursor:l}=n$1,p,g;if(a||(e$1?p=t._getBlockElementIndex(e$1):o&&(p=t._getBlockElementIndex(e(o))),p===void 0||p===-1))return;g=p+1;let f=t.getContent();s&&f.splice(p,1,t.normalizeComponentState(s)),r&&(r.component=i,f.splice(g,0,t.normalizeComponentState(r))),t._setContentState(f),n(()=>{typeof l=="number"&&t$1(t._getBlockElements()[g])?.setCursor?.(l);});}function Xt(n$1){let{mrakomor:t}=n$1,{blockElement:e$1,range:o,blocks:r,cursor:s,cursorBlockIndex:i=0}=n$1;if(!Array.isArray(r)||r.length===0)return;let a=e$1??(o?e(o):null),l=t._getBlockElementIndex(a);if(l===-1)return;let p=[...t._getContentState()];p.splice(l,1,...r.map(g=>t.normalizeComponentState(g))),t._setContentState(p),n(()=>{if(typeof s!="number")return;t._syncBlockElementsFromDom();let g=s$1(t._getBlockElements()[l+i]);g?.isConnected&&r$2(g,s);});}function Jt(n){let{mrakomor:t,blockElement:e,namespace:o}=n,r=t._getBlockElementState(e);if(!r)return;let s=t.register.blocks.getByNamespace(r.component),i=t.register.blocks.getByNamespace(o),a=n.exchangeState??s?.toExchangeState?.(r)??k({properties:r.properties,settings:r.settings}),l=i?.fromExchangeState?.(a)??a;Z(t,e,{...l,component:o,componentId:a$3()});}function Qt(n){let{mrakomor:t,blockElement:e,targetIndex:o}=n,r=t._getBlockElementIndex(e);if(r===-1||typeof o!="number")return;let s=o>r?o-1:o;if(s===r)return;let i=[...t._getContentState()],[a]=i.splice(r,1);i.splice(s,0,a),t._setContentState(i);}function Zt(n$1){let{mrakomor:t,blockElement:e$1,range:o}=n$1,r=t._getBlockElementIndex(e$1);if(r!==-1){let s=t.getContent();s.splice(r,1),t._setContentState(s);}n(()=>{let s=e(o);r$2(s$1(s),0);});}function te(n){let{mrakomor:t,state:e,blockElement:o}=n,r=t._getBlockElementState(o);if(!r)return;let s=structuredClone(r),i=e?.offset,a=e?.length,l=e?.entity?.type;s.properties.entityRanges=(s.properties.entityRanges??[]).filter(p=>!(p?.offset===i&&p?.length===a&&p?.entity?.type===l)),Z(t,o,s),t.command.closeDialog?.();}function ee(n){zt(n,{customHook:"insertEntityRange",applyFn:z$1,applyArgs:{state:n.state,namespace:n.namespace}});}function ne(n){zt(n,{customHook:"insertInlineStyleRange",applyFn:y,applyArgs:{style:n.style}});}function oe(n$1){let{mrakomor:t,blockElement:e,previousBlockElement:o}=n$1,r=t._getBlockElementIndex(o),s=t._getBlockElementIndex(e);if(r===-1||s===-1)return;let i=t.getContent(),a=i[s],l=i[r],p=t.register.blocks.getByNamespace(l.component),g=t.register.blocks.getByNamespace(a.component),f=n$1.exchangeState??g?.toExchangeState?.(a)??k({properties:a.properties,settings:a.settings}),h=p?.appendExchangeState?.(l,f);if(!h)return;i.splice(s,1),i.splice(r,1,t.normalizeComponentState(h.state)),t._setContentState(i);let C=()=>{if(typeof h.cursor!="number")return;let y=t._getBlockElements()[r]??o,B=s$1(y);B?.isConnected&&r$2(B,h.cursor);};C(),n(C);}function re(n){let{mrakomor:t}=n,e=t.getRoot();if(n.relatedTarget instanceof Node&&e.contains(n.relatedTarget))return;let[r,s]=a$5(()=>[t.getContent(),t._getContentState()]);r.length===s.length&&r.every((a,l)=>a===s[l])||t.setContent(r);}function se(n){let t=i();return e(t)?.getNodeComponent?.()?.classInstance?.onKeydown?.(n)}function ie(n){t$1(n)?.setCursor?.();}function ce(n$1){if(n$1.key!=="Backspace")return;let{mrakomor:t}=n$1,e$1=i();if(!e$1)return;let o=e(e$1);if(!o)return;let r=u$1(o),s=o?.previousSibling,a=u$1(s)?.childNodes?.[0]?.contentEditable==="true",l$1=r?.childNodes?.[0]?.contentEditable==="true",p=s$1(o),g=!j(p?.textContent),f=e$1.collapsed&&(e$1.startOffset===0||j$1()===0||g);if(!e$1.collapsed){let u=p$1(e$1);if(u&&u.startBlock!==u.endBlock){let E=t._getBlockElementIndex(u.startBlock),S=t._getBlockElementIndex(u.endBlock),b=t.getContent(),O=E>=0?b[E]:void 0,R=S>=0?b[S]:void 0;if(E>=0&&S>E&&typeof O?.properties?.text=="string"&&typeof R?.properties?.text=="string"){n$1.preventDefault();let{content:$t,cursor:pt,resultIndex:Yt}=r$1(b,{startIndex:E,endIndex:S,startOffset:u.startOffset,endOffset:u.endOffset});t._setContentState($t.map(Y=>t.normalizeComponentState(Y))),n(()=>{let Y=t._getBlockElements()[Yt];Y&&typeof pt=="number"&&r$2(s$1(Y),pt);});}}return}if(!f)return;let h=t._getBlockElementIndex(o),C=s?t._getBlockElementIndex(s):-1,y=t._getBlockElementState(o),B=t._getBlockElementState(s),A=s?t$1(s):null;if(!s||C<0){n$1.preventDefault();return}if(B&&y&&l(y)&&A&&!A.isAtomic?.()){if(g&&!l(B)){n$1.preventDefault();let u=t.getContent();u.splice(h,1),t._setContentState(u),ie(s);return}n$1.preventDefault(),t.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:e$1});return}A?.isAtomic?.()&&(!a&&e$1.startOffset===0||o?.textContent==="\xA0"&&!l$1)&&(n$1.preventDefault(),t.command.removeBlockElement({blockElement:s,range:e$1})),y&&!l(y)&&n$1.preventDefault();}function tt(n){return {resolveComponent:t=>t===v.NAMESPACE?v:z,registerCommands(t){t.emitter.on(a$1.INSERT_BLOCK_ELEMENT,b(Vt)),t.emitter.on(a$1.REPLACE_BLOCK_ELEMENT,b(Xt)),t.emitter.on(a$1.TRANSFORM_BLOCK_ELEMENT,b(Jt)),t.emitter.on(a$1.MOVE_BLOCK_ELEMENT,b(Qt)),t.emitter.on(a$1.REMOVE_BLOCK_ELEMENT,b(Zt)),t.emitter.on(a$1.REMOVE_ENTITY_RANGE,b(te)),t.emitter.on(a$1.INSERT_ENTITY_RANGE,b(ee)),t.emitter.on(a$1.INSERT_INLINE_STYLE_RANGE,b(ne)),t.emitter.on(a$1.MERGE_BLOCK_ELEMENT,b(oe));},registerHandlers(t){t.emitter.on(a$1.FOCUSOUT,re),t.emitter.on(a$1.KEYDOWN,b(se)),t.emitter.on(a$1.KEYDOWN,b(ce));},registerListeners(t){let e=t.getRoot(),{signal:o}=t.listenerAbortController;e.addEventListener("keydown",r=>t.emitDomEvent(a$1.KEYDOWN,r),{signal:o}),e.addEventListener("beforeinput",r=>t.emitDomEvent(a$1.BEFORE_INPUT,r),{signal:o}),e.addEventListener("input",r=>t.emitDomEvent(a$1.INPUT,r),{signal:o}),e.addEventListener("focusin",r=>t.emitDomEvent(a$1.FOCUSIN,r),{signal:o}),e.addEventListener("focusout",r=>t.emitDomEvent(a$1.FOCUSOUT,r),{signal:o}),e.addEventListener("click",r=>t.emitDomEvent(a$1.CLICK,r),{signal:o}),document.addEventListener("selectionchange",r=>t.emitDomEvent(a$1.SELECTION_CHANGE,r),{signal:o});}}}(function(){if(!(typeof document>"u")){var n="mrakomor/core/plugin/dialog/Dialog.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===n});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",n),e.textContent=`.mrakomor-dialog-container,.mrakomor-dialog-backdrop{pointer-events:all}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between}.dialog[open] .dialog-controls{text-align:right;width:100%}.dialog[open] .dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}.dialog[open] .dialog-container{width:100%}
|
|
3
|
-
`,document.head.appendChild(e);}}})();var
|
|
4
|
-
`,document.head.appendChild(e);}}})();function
|
|
1
|
+
import {a as a$5,c as c$3}from'./chunk-EXDY5TZH.mjs';import {a as a$4,c as c$2}from'./chunk-S2W6LYHT.mjs';export{c as defaultMrakomorPlugin}from'./chunk-S2W6LYHT.mjs';import'./chunk-GDDVUIEH.mjs';import {a as a$6}from'./chunk-ZHOZPQZH.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {a as a$1}from'./chunk-ERNLRJPB.mjs';import'./chunk-FAXIFXQK.mjs';import {a as a$2,c as c$1}from'./chunk-B6JJAATK.mjs';export{a as EVENT}from'./chunk-B6JJAATK.mjs';import {y,x,a as a$3,v,o as o$1,u as u$1,b}from'./chunk-P7TUN2KD.mjs';import {p,c,u,e,g,o,s,t,q as q$1,k,m,n,r,h,i}from'./chunk-7CJLTNHZ.mjs';(function(){if(!(typeof document>"u")){var o="mrakomor/core/style/core.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===o});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",o),e.textContent=`.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.mrakomor-editor:focus-visible{outline:none}.mrakomor-editor{display:flex;flex-direction:column;height:100%;min-height:0}.mrakomor-editor-surface{position:relative;flex:1 1 auto;min-height:0}.mrakomor-tools-container{position:absolute;inset:0;pointer-events:none;z-index:4}.mrakomor-content{position:relative;height:100%;min-height:0;overflow-y:auto}.mrakomor-content:focus-visible{outline:none}
|
|
2
|
+
`,document.head.appendChild(e);}}})();var E=class extends q$1{static get nodeName(){return "span"}static get style(){return "SPAN"}static match(t){return t.nodeName===this.nodeName.toUpperCase()||t.style===this.style}getState(){return {style:this.constructor.style}}render(){return p(this.constructor.nodeName,{},this.props.children)}};var B=class extends E{static get nodeName(){return "b"}static get style(){return "BOLD"}static get LABEL(){return p("b",{},"B")}static match(t){return t.nodeName==="strong"?true:super.match(t)}};var w=class extends E{static get nodeName(){return "i"}static get style(){return "ITALIC"}static get LABEL(){return p("i",{},"I")}};var L=class extends E{static get nodeName(){return "sub"}static get style(){return "SUBSCRIPT"}static get LABEL(){return p("sub",{},"Sub")}};var R=class extends E{static get nodeName(){return "sup"}static get style(){return "SUPERSCRIPT"}static get LABEL(){return p("sup",{},"Sup")}};var O=class extends E{static get nodeName(){return "u"}static get style(){return "UNDERLINE"}static get LABEL(){return p("u",{},"U")}};var xt=a.object({component:a.function(),id:a.string(),label:a.string(),keywords:a.array(a.string()),group:a.string(),order:a.number().default(({context:o})=>o?.index??0),settings:a.any().optional()});function yt(o,t){let e=`block:${o}`;return t?.style==="UNORDERED"?`${e}:ul`:t?.style==="ORDERED"?`${e}:ol`:e}function dt(o,t=0){let e=typeof o=="function",n=e?o:o?.component,r=e?{}:o,c=n.NAMESPACE??"",l=c.split(".").pop()||c,h=r.label||n.LABEL||l||c,d=Array.isArray(n.KEYWORDS)?n.KEYWORDS:[],p=r.keywords?.length?r.keywords.map(String):d.length?d.map(String):[h,l].filter(Boolean).map(String),b=r.settings;return xt.parse({component:n,id:r.id||yt(c,b),label:String(h),keywords:p,group:String(r.group||n.GROUP||"blocks"),...typeof r.order=="number"?{order:r.order}:{},...b?{settings:b}:{}},{context:{index:t}})}var G=class o extends a$5{#o=null;constructor(t){super(t),this.subscribe(()=>{this.#o=null;});}normalize(t,e){if(t==null)return null;try{return dt(t,e)}catch{return null}}getByNamespace(t){return this.#n().get(t)}#n(){return this.#o??=o.buildNamespaceMap(this.list()),this.#o}static buildNamespaceMap(t){let e=new Map;for(let n of t){let r=n.component?.NAMESPACE;r&&!e.has(r)&&e.set(r,n.component);}return e}};function Ct(o,t){let e=o._getBlockElementByComponentId(t);return v(e)?.isStale?.()??false}function ft(o){return (t,e)=>{if(!i(t,e))return false;let n=e?.componentId??t?.componentId;return !(n&&Ct(o,n))}}function gt({mrakomor:o}){let t=o.get(),e=ft(t);k(a$6,t);let n$1=g(r=>{t._setContentRoot(r??null);});return m(()=>{t._onMount();}),n(()=>{t._onUnmount();}),p("div",{id:t._id,className:"mrakomor-editor"},[p("div",{className:"mrakomor-editor-surface"},[p("div",{className:"mrakomor-tools-container"}),p("div",{className:"mrakomor-content",contentEditable:true,style:{spellcheck:true,outline:"none"},$ref:n$1},[r(()=>t._getContentState(),r=>r.componentId,(r,c)=>p(()=>{let l;m(()=>{l.getNodeComponent=()=>{let p=u$1(l);return p?h(p):null},t._setBlockElement(l,c);}),n(()=>{t._removeBlockElement(l);});let h$1=t.resolveComponent(r.get().component,r),d=t.wrapBlockElement(h$1);return p("div",{className:"mrakomor-block-element",[b]:true,$ref:p=>{l=p;}},d)}),{equals:e})])])])}(function(){if(!(typeof document>"u")){var o="mrakomor/core/plugin/dialog/Dialog.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===o});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",o),e.textContent=`.mrakomor-dialog-container,.mrakomor-dialog-backdrop{pointer-events:all}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between}.dialog[open] .dialog-controls{text-align:right;width:100%}.dialog[open] .dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}.dialog[open] .dialog-container{width:100%}
|
|
3
|
+
`,document.head.appendChild(e);}}})();var ht="mrakomor.dialog.Dialog";function H({open:o,placement:t,positionX:e,positionY:n,block:r,dialogRef:c$1}){let l=c(()=>{let d=t.get()==="center";return {position:"absolute",zIndex:d?"9100":"9000",top:`${n.get()}px`,left:`${e.get()}px`,...d?{padding:0,background:"transparent",border:"none",boxShadow:"none",minWidth:0}:{background:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px 10px",boxShadow:"0 2px 8px rgba(0,0,0,.15)",minWidth:"220px"}}}),h=c(()=>({position:"absolute",inset:"0",zIndex:"9050",background:"rgba(15, 23, 42, 0.28)",pointerEvents:"all"}));return p("span",{style:{display:"contents"}},[u(()=>o.get()&&t.get()==="center",p("div",{className:"mrakomor-dialog-backdrop",contentEditable:false,style:h})),u(()=>o.get(),p("div",{className:"mrakomor-dialog-container",contenteditable:false,style:l,$ref:c$1},()=>r.get()))])}H.NAMESPACE=ht;function q({mrakomor:o$2}){let t=null,e$1=e(false),n=e(false),r=e("anchor"),c=e(0),l=e(0),h=e(null),d=g(null),p$1=g(null);function b(){n.set(false),r.set("anchor"),o$1(),d.set(null),o(()=>{e$1.set(false);});}return {resolveComponent(f){if(f===ht)return H},registerEvents(){a$2.OPEN_DIALOG="mrakomor:open-dialog",a$2.CLOSE_DIALOG="mrakomor:close-dialog";},registerCommands(f){f.command.openDialog=(x,k)=>{f.emit(a$2.OPEN_DIALOG,{...x,options:k});},f.command.closeDialog=()=>{f.emit(a$2.CLOSE_DIALOG);};},registerHandlers(){o$2.emitter.on(a$2.OPEN_DIALOG,({children:f,element:x$1,options:k={}})=>{h.set(f??p("div",{},"Empty dialog")),n.set(true),d.set(x$1??null),r.set(k.placement??"anchor"),o(()=>{let N=o$2.getRoot(),{x:I,y:v}=k.placement==="center"?y(N,p$1):x(N,x$1??{left:0,top:0},p$1);c.set(I),l.set(v),e$1.set(true);});}),o$2.emitter.on(a$2.CLOSE_DIALOG,b),o$2.emitter.on(a$2.KEYDOWN,f=>{f.key==="Escape"&&n.peek()===true&&o$2.command.closeDialog();}),o$2.emitter.on(a$2.CLICK,f=>{if(n.peek()!==true||e$1.peek()!==true)return;let x=f.target,k=p$1&&typeof p$1.contains=="function"&&p$1.contains(x),N=d&&typeof d.contains=="function"&&d.contains(x);!k&&!N&&o$2.command.closeDialog();});},onMount(){let{dispose:f}=a$1(o$2,"mrakomor-dialog-plugin-container",p(H,{open:n,placement:r,positionX:c,positionY:l,block:h,dialogRef:p$1}));t=f;},onUnmount(){t?.(),t=null;}}}var Y=class extends a$5{constructor(t){super(t,{sort:e=>e});}normalize(t){return c$3(t)}};(function(){if(!(typeof document>"u")){var o="mrakomor/core/plugin/menu/Menu.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===o});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",o),e.textContent=`.mrakomor-menu{position:absolute;z-index:9300;display:flex;flex-direction:column;gap:2px;min-width:160px;max-height:240px;overflow-y:auto;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-menu__item:hover,.mrakomor-menu__item--active{background:#ffffff26}.mrakomor-menu__empty{padding:6px 10px;font-size:13px;font-weight:600;color:#ffffff80}
|
|
4
|
+
`,document.head.appendChild(e);}}})();function St(o,t=-1){if(!o.length)return p("div",{className:"mrakomor-menu__empty",role:"presentation"},"No results");let e=o.map((n,r)=>p("button",{type:"button",role:"option",id:`mrakomor-menu-option-${n.id}`,className:["mrakomor-menu__item",r===t?"mrakomor-menu__item--active":""].filter(Boolean).join(" "),title:n.label,"data-id":n.id,"aria-selected":r===t?"true":"false",onMouseDown:c=>{c.preventDefault();}},n.label));return p("span",{style:"display: contents"},e)}function X({open:o,positionX:t,positionY:e,entries:n,highlightIndex:r,ariaLabel:c$1,menuRef:l}){let h=c(()=>({left:`${t.get()}px`,top:`${e.get()}px`}));return u(()=>o.get(),p("div",{className:"mrakomor-menu",role:"listbox","aria-label":()=>c$1.get(),contenteditable:false,style:h,$ref:l},()=>St(n.get(),r.get())))}function j({mrakomor:o$1}){let t=null,e$1=null,n=g(null),r=null,c=e(false),l=e(false),h=e(0),d=e(0),p$1=e([]),b=e(-1),f=e("Menu");function x$1(s){o(()=>{let u=o$1.getRoot();if(!u||!s)return;let C=n?.offsetHeight??200,y=u.getBoundingClientRect();if(s.top-y.top>C+8){let{x:_,y:bt}=x(u,s,{offsetHeight:C},4);h.set(_),d.set(bt);}else h.set(s.left-y.left),d.set(s.bottom-y.top+4);c.set(true);});}function k(){l.set(false),r=null,b.set(-1),p$1.set([]),o(()=>{c.set(false);});}function N(s){!s||!r||r(s);}function I(s){if(l.peek()!==true)return;let u=s.target?.closest?.(".mrakomor-menu__item");if(!u||!e$1?.contains(u))return;s.preventDefault(),s.stopPropagation();let C=u.getAttribute("data-id"),y=p$1.peek().find(D=>D.id===C);y&&N(y);}function v(s={}){let{entries:u=[],anchorRect:C,highlightIndex:y=-1,ariaLabel:D="Menu",onSelect:_=null}=s;p$1.set(u),b.set(y),f.set(D),_!==void 0&&(r=_),l.set(true),C?x$1(C):c.set(true);}return {registerEvents(){a$2.OPEN_MENU="mrakomor:open-menu",a$2.CLOSE_MENU="mrakomor:close-menu",a$2.UPDATE_MENU="mrakomor:update-menu";},registerCommands(s){s.command.openMenu=u=>{s.emit(a$2.OPEN_MENU,u);},s.command.updateMenu=u=>{s.emit(a$2.UPDATE_MENU,u);},s.command.closeMenu=()=>{s.emit(a$2.CLOSE_MENU);};},registerHandlers(){o$1.emitter.on(a$2.OPEN_MENU,v),o$1.emitter.on(a$2.UPDATE_MENU,v),o$1.emitter.on(a$2.CLOSE_MENU,k),o$1.emitter.on(a$2.CLICK,s=>{let u=n?.current??n;l.peek()===true&&c.peek()===true&&u&&typeof u.contains=="function"&&!u.contains(s.target)&&k();}),o$1.emitter.on(a$2.KEYDOWN,s=>{s.key==="Escape"&&l.peek()===true&&k();});},onMount(){let{container:s,dispose:u}=a$1(o$1,"mrakomor-menu-plugin-container",p(X,{open:l,positionX:h,positionY:d,entries:p$1,highlightIndex:b,ariaLabel:f,menuRef:n}));e$1=s,e$1?.addEventListener("click",I),t=u;},onUnmount(){e$1?.removeEventListener("click",I),t?.(),t=null,e$1=null,n.current=null,r=null;}}}function Nt(o){return o!=null&&typeof o=="object"&&(typeof Element>"u"?o.nodeType===1:o instanceof Element)}function kt(){return a.object({root:a.any().refine(Nt,{message:"root must be a DOM Element"}),id:a.string().optional(),debug:a.boolean().optional(),content:a.array(a.any()).optional(),plugins:a.array(a.function()).optional(),blockComponents:a.array(a.any().refine(o=>typeof o=="function"||o!=null&&typeof o=="object"&&typeof o.component=="function",{message:"blockComponents entry must be a constructor or registration"})).optional(),slashActions:a.array(a.any().refine(o=>o!=null&&typeof o=="object"&&typeof o.handler=="function",{message:"slashActions entry must include a handler function"})).optional(),inlineStyles:a.array(a.function()).optional(),entityRanges:a.array(a.function()).optional(),tooltip:a.any().optional()})}function Et(o){return [...o.filter(t=>t!==q&&t!==j&&t!==c$2),q,j,c$2]}function _t(o){kt().parse(o);let t={debug:false,content:[],plugins:[],blockComponents:[],slashActions:[],inlineStyles:[B,w,O,L,R],entityRanges:[],tooltip:{}},e={...t,...o,plugins:Et(o.plugins??t.plugins)},n=new W(e);return n._init(),n}var W=class{#o=a$3();#n;#i=null;#e=[];#t=[];#r;#s=false;listenerAbortController=new AbortController;#a=e([],{debug:"content"});#l=[];command;emitter;register;constructor(t){let{root:e,id:n,content:r}=t;this.#o=n||this.#o,this.#n=e,this.#l=r,this.#t=[],this.#r={...t,plugins:Et(t.plugins??[])},this.register={blocks:new G(this),help:new Y(this)};let{emitter:c,command:l}=c$1({mrakomor:this});this.command=l,this.emitter=c;}_init(){this.#u(),this.#a=e(this._normalizeContentState(this.#l),{debug:"content"});}#u(){this.#e=this.#r.plugins.map(t=>t?.({config:this.#r,root:this.#n,mrakomor:this}))??[],this.#r=this.#e.reduce((t,e)=>e?.resolveConfig?.(t)??t,this.#r),this.register.blocks.add(this.#r.blockComponents??[]),this.#e.forEach(t=>{t?.registerEvents?.(this);}),this.#e.forEach(t=>{t?.registerCommands?.(this);}),this.#e.forEach(t=>{this.emitter.on(a$2.KEYDOWN,e=>t?.onKeyDown?.(e));}),this.#e.forEach(t=>{t?.registerHandlers?.(this);}),this.#e.forEach(t=>{t?.registerListeners?.(this);});}emit(t,e={}){return this.emitter.emit(t,{...e,mrakomor:this})}on(t,e){return this.emitter.on(t,e)}onChangeContent(t){return this.on(a$2.CONTENT_CHANGE,t)}emitDomEvent(t,e){let{clipboardData:n,metaKey:r,altKey:c,code:l,ctrlKey:h,key:d,isComposing:p,repeat:b,button:f,shiftKey:x,which:k,detail:N,isTrusted:I,target:v,relatedTarget:s,data:u,inputType:C,clientX:y,clientY:D}=e??{},{defaultPrevented:_}=this.emit(t,{clipboardData:n,metaKey:r,altKey:c,code:l,ctrlKey:h,key:d,isComposing:p,repeat:b,button:f,shiftKey:x,which:k,detail:N,isTrusted:I,target:v,relatedTarget:s,data:u,inputType:C,clientX:y,clientY:D});return _&&e?.preventDefault?.(),_}getConfig(){return {...this.#r,blockComponents:this.register.blocks.list(),slashActions:this.register.slashActions?.list()??[]}}wrapBlockElement(t){for(let e of this.#e){let n=e.wrapBlockElement?.(t);if(n)return n}return t}getRoot(){return this.#n}_getContentRoot(){return this.#i}_setContentRoot(t){this.#i=t;}get _id(){return this.#o}getContent(){return this.#t.map(e=>v(e)?.getState())}setContent(t=[]){this._setContentState(this._normalizeContentState(t));}_syncBlockElementsFromDom(){let t=this.#i;t&&(this.#t=[...t.querySelectorAll(".mrakomor-block-element")]);}_getBlockElements(){return this.#t}_getContentState(){return this.#a.get()}_setContentState(t=[]){this.#a.set(t),this.emit(a$2.CONTENT_CHANGE,{content:t}),o(()=>{this._syncBlockElementsFromDom();});}_normalizeContentState(t=[]){return t.map(e=>{let n=this.normalizeComponentState(e);return n===void 0?void 0:structuredClone(n)}).filter(e=>e!==void 0)??[]}_setBlockElement(t,e=this.#t.length){this.#t.splice(e,0,t);}_removeBlockElement(t){this.#t=this.#t.filter(e=>e!==t);}#m(t){return v(t)?.state?.peek()?.componentId}#c(t){return t?this.#t.findIndex(e=>this.#m(e)===t):-1}_getBlockElementIndex(t){if(!t)return -1;let e=this.#t.indexOf(t);return e!==-1?e:this.#c(this.#m(t))}_getBlockElementByComponentId(t){let e=this.#c(t);return e===-1?null:this.#t[e]}_getBlockElementState(t){let e=this._getBlockElementIndex(t);if(e!==-1)return v(this.#t[e])?.getState()}mount(){let t=s(this.#n,p(gt,{mrakomor:this}));return this.#s=true,t}unmount(){this.#s&&(this.#s=false,t(this.#n));}_onUnmount(){this.listenerAbortController.abort(),this.#e.forEach(t=>{t?.onUnmount?.(this);}),this.emitter.removeAllListeners();}_onMount(){this.#e.forEach(t=>{t?.onMount?.(this);}),o(()=>{this._syncBlockElementsFromDom();});}resolveComponent(t,e){let n=this.resolveComponentConstructor(t);return n?p(n,{state:e}):p(a$4,{state:e})}resolveComponentConstructor(t){let e=this.register.blocks.getByNamespace(t);if(!e){for(let n of this.#e)if(e=n?.resolveComponent?.(t),e)break}return e}normalizeComponentState(t){if(t==null){console.warn("normalizeComponentState() received a nullish state; dropping it.");return}let e="component"in t?t.component:t.entity.type;return this.resolveComponentConstructor(e)?.getStateSchema()?.parse(t)}};export{B as Bold,H as Dialog,w as Italic,X as Menu,W as Mrakomor,L as Subscript,R as Superscript,O as Underline,_t as createMrakomor,q as dialogPlugin,j as menuPlugin};
|
package/dist/link.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var Le=class{next(...e){}error(...e){}complete(...e){}},ue=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var G=Symbol("@esmj/signals:type"),K=Symbol("@esmj/signals:name");var k=null,ce=false,fe=[];function D(e){let t=k;k=null;let n=e();return k=t,n}function Bt(){ce=false;let e=He();for(let n of e)n.get();let t=fe;fe=[];for(let n of t)n();}function Pe(){ce||(ce=true,queueMicrotask(Bt));}function de(e){fe.push(e),Pe();}var qe=Symbol("@esmj/signals:internal observable"),_=Symbol("@esmj/signals:original function"),Lt=class extends ue{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>D(()=>{this.#e.add(e),this.#r();}),e.next[_]=void 0),e instanceof ze&&e.next[_]===void 0){let t=e.next.bind(e);e.next=()=>D(()=>{this.#e.add(e),t(),this.#r();}),e.next[_]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[_]){let n=t.get,r=n.bind(t);t.get=()=>D(()=>(this.#e.delete(t),r())),t.get[_]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[_]?e.next[_]:e.next,e.get=e.get[_]?e.get[_]:e.get,this.#e.delete(e),this.unsubscribe(e)}},X=null;function Fe(e){X=new Lt(e);}Fe(()=>{Pe();});function He(){return X.getPending()}function Ke(e){return X.watch(e)}function Ve(e){return X.unwatch(e)}var R=Symbol("@esmj/signals:no error"),ze=class Ue extends Le{#e=true;#r=false;#n=null;#o=this.#d();#u=null;#l=null;#i=0;#s=new Map;#t=R;constructor(t,n){super(),this.#u=t,this.#l=n,this.debug=n?.debug,this[G]="computed",this[K]=n?.debug??null,this.get=this.get.bind(this);}#c(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#d(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[K],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Ue&&D(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[qe].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=T(this.#a(),this.#l)),(this.#e||this.#t!==R)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),k&&k.sourceRevisions.set(this,this.#i),this.#t!==R)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=T(this.#a(),this.#l)),(this.#e||this.#t!==R)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==R)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=R,this.#c(),this.#o.sourceRevisions.clear();let t=k;k=this.#o;let n;try{n=this.#u();}catch(r){this.#t=r;}return k=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=R,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===R&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=R;}};function O(e,t){return new ze(e,t)}function v(e,t){let n,{debug:r,...o}={},i=O(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),Ke(i);let s=()=>{n?.(),i.destroy(),Ve(i);};return s[Symbol.dispose]=s,s[G]="effect",s[K]=r??null,s.__RX_COMPUTED__=i,s}function T(e,t={}){let n=t?.equals??Object.is,r=0,o=new ue;function i(){return k&&(k.dependencies.set(o,o.subscribe(k.observer)),k.sourceRevisions.set(c,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let c={get:i,set:a,peek:s,getRevision:l,[qe]:o,[G]:"signal",[K]:t?.debug??null};return c}function Y(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var tt=Symbol("node-component"),Q=Symbol("node-internal"),Pt=Symbol("keep-literal"),ne=Symbol("raw-props");function U(e){let t=null,n=()=>t,r=i=>(t=i??null,typeof e=="function"&&e(t),t),o={get:n,set:r,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(o,"current",{get(){return t},set(i){r(i);},enumerable:true,configurable:false}),new Proxy(o,{get(i,s,a){if(Reflect.has(i,s))return Reflect.get(i,s,a);if(!t)return;let l=t[s];return typeof l=="function"?l.bind(t):l},set(i,s,a,l){return Reflect.has(i,s)||!t?Reflect.set(i,s,a,l):(t[s]=a,true)},has(i,s){return Reflect.has(i,s)||!!t&&s in t}})}var nt=null;function I(){return nt}function Z(e){nt=e;}function ke(e){return e?.[tt]||null}function Je(e,t){e[tt]=t;}function ee(e,t={disposers:[],id:Y()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function Ht(e){return e[Q]}function $(e,t){let n=Ht(e);n||(n=ee(e)),n.disposers.push(t);}function he(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function A(e,t){let n=I();Z(e);try{return t()}finally{Z(n);}}var ge=new Map,te=new Map,We=new Map;function rt(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[Pt]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=O(i):r[o]=T(i);}return r}function we(e){return {id:Symbol("context-id"),defaultValue:e}}function Se(e){let t=I();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function oe(e){de(()=>{setTimeout(e,0);});}function J(e){let t=e.componentId,n=ge.get(t);if(n){ge.delete(t);for(let r of n){let o=r();typeof o=="function"&&he(te,t,o);}}}function Kt(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function Vt(e){let t=We.get(e);if(t){We.delete(e);for(let n of t)n();}}function Ce(e){if(!e)return;let t=ee(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=ke(e);if(n&&(Kt(n.componentId),Vt(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Ce(r),r=o;}}}function P(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ge(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function zt(e,t,n){let r=Y(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=Ge(e)?void 0:e[ne],s={...rt(t??{},i),children:n},a=I(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(l);let c;if(Ge(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&he(ge,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&he(te,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(s);Z(a);let u=Ut(c);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ee(f,l),Je(f,o);else ee(u,l),u instanceof Node&&Je(u,o);return u}};return o}function ot(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{J(t);});}function Ut(e){return e instanceof Node?e:P(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Xe={className:"class",htmlFor:"for"},Ye=new Set(["value","defaultValue","checked","selected","indeterminate"]),Jt=new Set(["srcdoc"]),Wt=new Set(["href","src","action","formaction","xlink:href"]),Gt=new Set(["securitypolicyviolation"]),Xt=new Set(["contenteditable","draggable","spellcheck"]);function z(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var st=Symbol("Fragment");function m(e,t,n){if(e===st){let o=document.createDocumentFragment();return me(o,Ze(n)),o}if(typeof e=="function")return zt(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),se(r,t),me(r,Ze(n)),r}function pe(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Yt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Qt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Jt.has(n)?true:Wt.has(n)&&t!==null&&t!==void 0&&Yt(String(t))}function it(e){return typeof e!="string"?e:Xe[e]?Xe[e]:e}function Zt(e,t){let n=it(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Xt.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Qe(e,t,n){let r=Zt(t,n);if(r===null){e.removeAttribute(t);return}if(Qt(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function se(e,t){let n=I();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=it(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(z(o)){let i=v(()=>{A(n,()=>{pe(e,o.get());});});$(e,i);}else if(typeof o=="function"){let i=v(()=>{A(n,()=>{pe(e,o());});});$(e,i);}else pe(e,o);continue}if(r==="style"){if(z(o)){let i=v(()=>{A(n,()=>{Object.assign(e.style,o.get());});});$(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Gt.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(z(o)||typeof o=="function"){let i=r,s=v(()=>{A(n,()=>{let a=typeof o=="function"?o():o.get();Ye.has(i)?e[i]=a??"":Qe(e,i,a);});});$(e,s);continue}Ye.has(r)||typeof r=="symbol"?e[r]=o??"":Qe(e,r,o);}}function Ze(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function me(e,t){for(let n of t)at(e,n);}function at(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){et(e,t);return}if(P(t)){ot(e,t);return}if(z(t)){et(e,()=>t.get());return}if(Array.isArray(t)){me(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function q(e){let t=null,n=e;return P(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function ie(e,t=true){for(let n of e)t&&Ce(n),n.remove();}function et(e,t){let n=I(),r=document.createComment("");e.appendChild(r);let o=[],i=v(()=>{A(n,()=>{let s=t(),{nodes:a,instance:l}=q(s);ie(o),a.length&&r.after(...a),l&&queueMicrotask(()=>J(l)),o=a;});});$(e,i);}var ct=class{constructor(e){this.props=e;}};var nn={abortEarly:true};function Re(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function rn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Re(e.errors[r],n));}function pt(e,t,n,r){if(n!==false){let o=Re(e.error,t);return {success:false,error:o,errors:[o]}}rn(e,r,t);}function ae(e){return e?.abortEarly!==void 0?e:nn}function ve(e,t){y(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Ne=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ee=e=>e===true||e===false,on=e=>e instanceof Date&&!Number.isNaN(e.getTime()),sn=e=>typeof e=="function",an=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ht(e,t){let n=w(_e,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return y(this,"_parse",(s,a,l)=>{let c=s(a,l);if(!c.success)return c;let u=o(c.data,{context:l?.context});if(!_e(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...c.data};for(let d in u)f[d]===void 0&&(f[d]=u[d]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},y(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:l}=ae(s);if(a.success===false)return a;let c={},u=[];for(let f in e){let d=e[f]._parse(a.data[f],s);if(d.success)c[f]=d.data;else {let p=pt(d,f,l,u);if(p)return p}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function je(e){return w(W,{...e,type:"string"})}function $e(e){return w(Ne,{...e,type:"number"})}function Ae(e){return w(Ee,{...e,type:"boolean"})}function Me(e){return w(on,{...e,type:"date"})}function gt(e){return w(sn,{...e,type:"function"})}function mt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=w(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function yt(e,t){let n=w(an,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,y(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=ae(i);if(s.success===false)return s;let l=[],c=[],u=i;for(let f=0;f<s.data.length;f++){let d={...u,context:{...u?.context,index:f}},p=e._parse(s.data[f],d);if(p.success)l.push(p.data);else {let b=pt(p,f,a,c);if(b)return b}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function bt(){return w(()=>true)}function F(e,t){return y(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function xt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${_e(o)?JSON.stringify(o):`"${o}"`}`,r=w(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,y(r,"_parse",(o,i,s)=>{let a=s,l=[];for(let d=0;d<e.length;d++){let p=e[d]._parse(i,a);if(p.success)return p;l.push(p);}let{abortEarly:c}=ae(a),u={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let d=0;d<l.length;d++){let p=l[d].errors;if(p?.length)for(let b=0;b<p.length;b++)p[b].cause?.key&&f.push(Re(p[b],`branch ${d}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function kt(e,t){let n=w(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function wt(e){let t=w(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,y(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function St(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Ct={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return F(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},Ae({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return F(n=>{if(Ee(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},$e({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ee(n)||Ne(n)&&Number.isFinite(n)?String(n):n,je({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return W(n)&&(r=n.trim()),Ne(n)&&Number.isFinite(n)||r?new Date(r??n):n},Me({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return y(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},vt={},g={object:ht,string:je,number:$e,boolean:Ae,date:Me,function:gt,enum:mt,array:yt,any:bt,preprocess:F,union:xt,literal:kt,contextRef:wt,withContext:St,coerce:vt,cast:Ct};function ft(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function y(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function w(e,{type:t="any",name:n,message:r}={}){r=r||ft(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let l=e(s);if(l===true)return {success:true,data:s};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,a){let l=this._parse(s,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(s,a){return this._parse(s,a)},transform(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=s(u.data)),u}),this},optional(){return ve(this,s=>s===void 0),this},nullable(){return ve(this,s=>s===null),this},nullish(){return ve(this,s=>s==null),this},default(s){return y(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof s=="function"?s({context:c?.context}):s),a(l,c))),this},catch(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof s=="function"?s({input:l,error:u.error}):s}}),this},pipe(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?s._parse(u.data,c):u}),this},refine(s,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||ft(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return y(this,"_parse",(u,f,d)=>{let p=u(f,d),{abortEarly:b}=ae(d);if(!p.success)return p;let N=s(p.data);if(N===true||typeof N=="object"&&N?.success===true)return p;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return dt.length>0?dt.reduce((s,a)=>a(s,e,o)??s,i):i}var dt=[];Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var Et=Symbol("block-element"),ln=Symbol("block-element-body"),un=Symbol("selectable-element");function Te(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function cn(e){return e?Te(e.startContainer,Et):null}function _t(e){return Te(e,Et)}function fn(e){return e?Te(e.startContainer,un):null}function dn(){return window.getSelection()}function pn(){let e=dn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Rt(){mn();}function gn(e,t){let n=fn(t);return n||(yn(e)??e?.childNodes?.[0]??null)}function Nt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)s+=a[c].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function mn(){let e=pn();if(!e)return null;let t=cn(e),n=gn(t,e);return {start:Nt(n,e.startContainer,e.startOffset),end:Nt(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function yn(e){if(!e)return null;let t=bn(e);return t?.firstElementChild??t?.firstChild}function bn(e){if(!e)return null;for(let t of e.children)if(t[ln])return t;return null}function jt({type:e,data:t=g.any(),length:n,offset:r}={}){let o=e!=null,i=g.object({type:o?g.string().default(e):g.string(),data:t}),s=n??(o?0:void 0),a=r??(o?0:void 0);return g.object({entity:o?i.default({}):i,length:s==null?g.number():g.number().default(s),offset:a==null?g.number():g.number().default(a)})}var $t=we();var le=class extends ct{static get nodeName(){return "span"}static get NAMESPACE(){return "namespace.EntityRangeElement"}static match(t){return t?.nodeName===this.nodeName.toUpperCase()||t?.entity?.type===this.NAMESPACE}static getStateSchema(t){return g.any()}constructor(t){super(t),this.mrakomor=Se($t),this.element=U(null);}render(){return m(this.constructor.nodeName,{},this.props.children)}};(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/linkEntity/LinkEntity.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.link-toolbar{display:flex;flex-direction:column;gap:6px}.link-toolbar__row{display:flex;align-items:center;gap:4px;min-width:0}.link-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.link-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.link-toolbar__btn:hover{background:#f0f0f0;color:#222}.link-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
|
|
2
|
-
`,document.head.appendChild(n);}}})();var xn=g.preprocess(e=>String(e??"").trim(),g.string().refine(e=>e===""||/^(?:https?:|mailto:)/i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e),{message:"Invalid link href"}).catch(""));function At(e){return xn.parse(e)}var kn='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';var
|
|
3
|
-
exports.LinkEntity=B;exports.linkEntityPlugin=
|
|
1
|
+
'use strict';var Le=class{next(...e){}error(...e){}complete(...e){}},ue=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var G=Symbol("@esmj/signals:type"),K=Symbol("@esmj/signals:name");var k=null,ce=false,fe=[];function D(e){let t=k;k=null;let n=e();return k=t,n}function Bt(){ce=false;let e=He();for(let n of e)n.get();let t=fe;fe=[];for(let n of t)n();}function Pe(){ce||(ce=true,queueMicrotask(Bt));}function de(e){fe.push(e),Pe();}var qe=Symbol("@esmj/signals:internal observable"),_=Symbol("@esmj/signals:original function"),Lt=class extends ue{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>D(()=>{this.#e.add(e),this.#r();}),e.next[_]=void 0),e instanceof ze&&e.next[_]===void 0){let t=e.next.bind(e);e.next=()=>D(()=>{this.#e.add(e),t(),this.#r();}),e.next[_]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[_]){let n=t.get,r=n.bind(t);t.get=()=>D(()=>(this.#e.delete(t),r())),t.get[_]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[_]?e.next[_]:e.next,e.get=e.get[_]?e.get[_]:e.get,this.#e.delete(e),this.unsubscribe(e)}},X=null;function Fe(e){X=new Lt(e);}Fe(()=>{Pe();});function He(){return X.getPending()}function Ke(e){return X.watch(e)}function Ve(e){return X.unwatch(e)}var R=Symbol("@esmj/signals:no error"),ze=class Ue extends Le{#e=true;#r=false;#n=null;#o=this.#d();#u=null;#l=null;#i=0;#s=new Map;#t=R;constructor(t,n){super(),this.#u=t,this.#l=n,this.debug=n?.debug,this[G]="computed",this[K]=n?.debug??null,this.get=this.get.bind(this);}#c(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#d(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[K],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Ue&&D(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[qe].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=O(this.#a(),this.#l)),(this.#e||this.#t!==R)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),k&&k.sourceRevisions.set(this,this.#i),this.#t!==R)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=O(this.#a(),this.#l)),(this.#e||this.#t!==R)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==R)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=R,this.#c(),this.#o.sourceRevisions.clear();let t=k;k=this.#o;let n;try{n=this.#u();}catch(r){this.#t=r;}return k=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=R,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===R&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=R;}};function T(e,t){return new ze(e,t)}function v(e,t){let n,{debug:r,...o}={},i=T(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),Ke(i);let s=()=>{n?.(),i.destroy(),Ve(i);};return s[Symbol.dispose]=s,s[G]="effect",s[K]=r??null,s.__RX_COMPUTED__=i,s}function O(e,t={}){let n=t?.equals??Object.is,r=0,o=new ue;function i(){return k&&(k.dependencies.set(o,o.subscribe(k.observer)),k.sourceRevisions.set(c,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let c={get:i,set:a,peek:s,getRevision:l,[qe]:o,[G]:"signal",[K]:t?.debug??null};return c}function Y(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var tt=Symbol("node-component"),Q=Symbol("node-internal"),Pt=Symbol("keep-literal"),ne=Symbol("raw-props");function U(e){let t=null,n=()=>t,r=i=>(t=i??null,typeof e=="function"&&e(t),t),o={get:n,set:r,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(o,"current",{get(){return t},set(i){r(i);},enumerable:true,configurable:false}),new Proxy(o,{get(i,s,a){if(Reflect.has(i,s))return Reflect.get(i,s,a);if(!t)return;let l=t[s];return typeof l=="function"?l.bind(t):l},set(i,s,a,l){return Reflect.has(i,s)||!t?Reflect.set(i,s,a,l):(t[s]=a,true)},has(i,s){return Reflect.has(i,s)||!!t&&s in t}})}var nt=null;function I(){return nt}function Z(e){nt=e;}function ke(e){return e?.[tt]||null}function Je(e,t){e[tt]=t;}function ee(e,t={disposers:[],id:Y()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function Ht(e){return e[Q]}function $(e,t){let n=Ht(e);n||(n=ee(e)),n.disposers.push(t);}function he(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function A(e,t){let n=I();Z(e);try{return t()}finally{Z(n);}}var ge=new Map,te=new Map,We=new Map;function rt(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[Pt]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=T(i):r[o]=O(i);}return r}function Se(e){return {id:Symbol("context-id"),defaultValue:e}}function we(e){let t=I();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function oe(e){de(()=>{setTimeout(e,0);});}function J(e){let t=e.componentId,n=ge.get(t);if(n){ge.delete(t);for(let r of n){let o=r();typeof o=="function"&&he(te,t,o);}}}function Kt(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function Vt(e){let t=We.get(e);if(t){We.delete(e);for(let n of t)n();}}function Ce(e){if(!e)return;let t=ee(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=ke(e);if(n&&(Kt(n.componentId),Vt(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Ce(r),r=o;}}}function P(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ge(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function zt(e,t,n){let r=Y(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=Ge(e)?void 0:e[ne],s={...rt(t??{},i),children:n},a=I(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(l);let c;if(Ge(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&he(ge,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&he(te,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(s);Z(a);let u=Ut(c);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ee(f,l),Je(f,o);else ee(u,l),u instanceof Node&&Je(u,o);return u}};return o}function ot(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{J(t);});}function Ut(e){return e instanceof Node?e:P(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Xe={className:"class",htmlFor:"for"},Ye=new Set(["value","defaultValue","checked","selected","indeterminate"]),Jt=new Set(["srcdoc"]),Wt=new Set(["href","src","action","formaction","xlink:href"]),Gt=new Set(["securitypolicyviolation"]),Xt=new Set(["contenteditable","draggable","spellcheck"]);function z(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var st=Symbol("Fragment");function m(e,t,n){if(e===st){let o=document.createDocumentFragment();return me(o,Ze(n)),o}if(typeof e=="function")return zt(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),se(r,t),me(r,Ze(n)),r}function pe(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Yt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Qt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Jt.has(n)?true:Wt.has(n)&&t!==null&&t!==void 0&&Yt(String(t))}function it(e){return typeof e!="string"?e:Xe[e]?Xe[e]:e}function Zt(e,t){let n=it(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Xt.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Qe(e,t,n){let r=Zt(t,n);if(r===null){e.removeAttribute(t);return}if(Qt(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function se(e,t){let n=I();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=it(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(z(o)){let i=v(()=>{A(n,()=>{pe(e,o.get());});});$(e,i);}else if(typeof o=="function"){let i=v(()=>{A(n,()=>{pe(e,o());});});$(e,i);}else pe(e,o);continue}if(r==="style"){if(z(o)){let i=v(()=>{A(n,()=>{Object.assign(e.style,o.get());});});$(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Gt.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(z(o)||typeof o=="function"){let i=r,s=v(()=>{A(n,()=>{let a=typeof o=="function"?o():o.get();Ye.has(i)?e[i]=a??"":Qe(e,i,a);});});$(e,s);continue}Ye.has(r)||typeof r=="symbol"?e[r]=o??"":Qe(e,r,o);}}function Ze(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function me(e,t){for(let n of t)at(e,n);}function at(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){et(e,t);return}if(P(t)){ot(e,t);return}if(z(t)){et(e,()=>t.get());return}if(Array.isArray(t)){me(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function q(e){let t=null,n=e;return P(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function ie(e,t=true){for(let n of e)t&&Ce(n),n.remove();}function et(e,t){let n=I(),r=document.createComment("");e.appendChild(r);let o=[],i=v(()=>{A(n,()=>{let s=t(),{nodes:a,instance:l}=q(s);ie(o),a.length&&r.after(...a),l&&queueMicrotask(()=>J(l)),o=a;});});$(e,i);}var ct=class{constructor(e){this.props=e;}};var nn={abortEarly:true};function Re(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function rn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Re(e.errors[r],n));}function pt(e,t,n,r){if(n!==false){let o=Re(e.error,t);return {success:false,error:o,errors:[o]}}rn(e,r,t);}function ae(e){return e?.abortEarly!==void 0?e:nn}function ve(e,t){y(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Ee=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ne=e=>e===true||e===false,on=e=>e instanceof Date&&!Number.isNaN(e.getTime()),sn=e=>typeof e=="function",an=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ht(e,t){let n=S(_e,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return y(this,"_parse",(s,a,l)=>{let c=s(a,l);if(!c.success)return c;let u=o(c.data,{context:l?.context});if(!_e(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...c.data};for(let d in u)f[d]===void 0&&(f[d]=u[d]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},y(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:l}=ae(s);if(a.success===false)return a;let c={},u=[];for(let f in e){let d=e[f]._parse(a.data[f],s);if(d.success)c[f]=d.data;else {let p=pt(d,f,l,u);if(p)return p}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function je(e){return S(W,{...e,type:"string"})}function $e(e){return S(Ee,{...e,type:"number"})}function Ae(e){return S(Ne,{...e,type:"boolean"})}function Me(e){return S(on,{...e,type:"date"})}function gt(e){return S(sn,{...e,type:"function"})}function mt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=S(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function yt(e,t){let n=S(an,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,y(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=ae(i);if(s.success===false)return s;let l=[],c=[],u=i;for(let f=0;f<s.data.length;f++){let d={...u,context:{...u?.context,index:f}},p=e._parse(s.data[f],d);if(p.success)l.push(p.data);else {let b=pt(p,f,a,c);if(b)return b}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function bt(){return S(()=>true)}function F(e,t){return y(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function xt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${_e(o)?JSON.stringify(o):`"${o}"`}`,r=S(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,y(r,"_parse",(o,i,s)=>{let a=s,l=[];for(let d=0;d<e.length;d++){let p=e[d]._parse(i,a);if(p.success)return p;l.push(p);}let{abortEarly:c}=ae(a),u={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let d=0;d<l.length;d++){let p=l[d].errors;if(p?.length)for(let b=0;b<p.length;b++)p[b].cause?.key&&f.push(Re(p[b],`branch ${d}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function kt(e,t){let n=S(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function St(e){let t=S(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,y(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function wt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Ct={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return F(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},Ae({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return F(n=>{if(Ne(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},$e({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ne(n)||Ee(n)&&Number.isFinite(n)?String(n):n,je({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return W(n)&&(r=n.trim()),Ee(n)&&Number.isFinite(n)||r?new Date(r??n):n},Me({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return y(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},vt={},g={object:ht,string:je,number:$e,boolean:Ae,date:Me,function:gt,enum:mt,array:yt,any:bt,preprocess:F,union:xt,literal:kt,contextRef:St,withContext:wt,coerce:vt,cast:Ct};function ft(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function y(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function S(e,{type:t="any",name:n,message:r}={}){r=r||ft(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let l=e(s);if(l===true)return {success:true,data:s};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,a){let l=this._parse(s,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(s,a){return this._parse(s,a)},transform(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=s(u.data)),u}),this},optional(){return ve(this,s=>s===void 0),this},nullable(){return ve(this,s=>s===null),this},nullish(){return ve(this,s=>s==null),this},default(s){return y(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof s=="function"?s({context:c?.context}):s),a(l,c))),this},catch(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof s=="function"?s({input:l,error:u.error}):s}}),this},pipe(s){return y(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?s._parse(u.data,c):u}),this},refine(s,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||ft(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return y(this,"_parse",(u,f,d)=>{let p=u(f,d),{abortEarly:b}=ae(d);if(!p.success)return p;let E=s(p.data);if(E===true||typeof E=="object"&&E?.success===true)return p;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return dt.length>0?dt.reduce((s,a)=>a(s,e,o)??s,i):i}var dt=[];Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var Nt=Symbol("block-element"),ln=Symbol("block-element-body"),un=Symbol("selectable-element");function Oe(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function cn(e){return e?Oe(e.startContainer,Nt):null}function _t(e){return Oe(e,Nt)}function fn(e){return e?Oe(e.startContainer,un):null}function dn(){return window.getSelection()}function pn(){let e=dn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Rt(){mn();}function gn(e,t){let n=fn(t);return n||(yn(e)??e?.childNodes?.[0]??null)}function Et(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)s+=a[c].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function mn(){let e=pn();if(!e)return null;let t=cn(e),n=gn(t,e);return {start:Et(n,e.startContainer,e.startOffset),end:Et(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function yn(e){if(!e)return null;let t=bn(e);return t?.firstElementChild??t?.firstChild}function bn(e){if(!e)return null;for(let t of e.children)if(t[ln])return t;return null}function jt({type:e,data:t=g.any(),length:n,offset:r}={}){let o=e!=null,i=g.object({type:o?g.string().default(e):g.string(),data:t}),s=n??(o?0:void 0),a=r??(o?0:void 0);return g.object({entity:o?i.default({}):i,length:s==null?g.number():g.number().default(s),offset:a==null?g.number():g.number().default(a)})}var $t=Se();var le=class extends ct{static get nodeName(){return "span"}static get NAMESPACE(){return "namespace.EntityRangeElement"}static match(t){return t?.nodeName===this.nodeName.toUpperCase()||t?.entity?.type===this.NAMESPACE}static getStateSchema(t){return g.any()}constructor(t){super(t),this.mrakomor=we($t),this.element=U(null);}render(){return m(this.constructor.nodeName,{},this.props.children)}};(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/linkEntity/LinkEntity.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.link-toolbar{display:flex;flex-direction:column;gap:6px}.link-toolbar__row{display:flex;align-items:center;gap:4px;min-width:0}.link-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.link-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.link-toolbar__btn:hover{background:#f0f0f0;color:#222}.link-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
|
|
2
|
+
`,document.head.appendChild(n);}}})();var xn=g.preprocess(e=>String(e??"").trim(),g.string().refine(e=>e===""||/^(?:https?:|mailto:)/i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e),{message:"Invalid link href"}).catch(""));function At(e){return xn.parse(e)}var kn='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';var Sn='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';var B=class e extends le{static get nodeName(){return "a"}static get NAMESPACE(){return "atom.link.Link"}static getStateSchema(t){let n;if(t?.getAttribute("data-state"))try{n=JSON.parse(t.getAttribute("data-state"));}catch{}return jt({type:e.NAMESPACE,data:g.object({href:g.string().default(n?.entity?.data?.href??t?.href??"").transform(r=>At(r)),target:g.string().default(n?.entity?.data?.target??t?.target??"")}).default({}),length:n?.length??0,offset:n?.offset??0}).default({})}constructor(t){super(t),this.input=U(n=>oe(()=>{n.focus();}));}#e({entity:t,length:n,offset:r}){return m("div",{className:"link-toolbar"},[m("div",{className:"link-toolbar__row",style:{display:"flex"}},[m("button",{className:"link-toolbar__btn",title:"Copy URL",$dangerouslySetInnerHTML:kn,onClick:()=>navigator.clipboard?.writeText(t.peek()?.data?.href??"")}),m("input",{type:"text",$ref:this.input,value:t.peek()?.data?.href??"",defaultValue:t.peek()?.data?.href??"",onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.mrakomor.command.closeDialog());},onInput:o=>{let i=o.currentTarget.value;t.set({...t.peek(),data:{...t.peek()?.data,href:i}});}}),m("select",{value:t.peek()?.data?.target??"",onChange:o=>{t.set({...t.peek(),data:{...t.peek()?.data,target:o.currentTarget.value}});}},[m("option",{value:"",selected:t.peek()?.data?.target===""},""),m("option",{value:"_self",selected:t.peek()?.data?.target==="_self"},"_self"),m("option",{value:"_blank",selected:t.peek()?.data?.target==="_blank"},"_blank"),m("option",{value:"_parent",selected:t.peek()?.data?.target==="_parent"},"_parent"),m("option",{value:"_top",selected:t.peek()?.data?.target==="_top"},"_top")]),m("span",{className:"link-toolbar__sep"}),m("button",{className:"link-toolbar__btn link-toolbar__btn--danger",title:"Remove link",$dangerouslySetInnerHTML:Sn,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:t.peek(),length:n.peek(),offset:r.peek()},blockElement:_t(this.element)});}})])])}onMount(){let{entity:t}=this.props;t.peek()?.data?.href||this.mrakomor.command.openDialog({element:this.element,children:this.#e(this.props)});}render(){let{entity:t,length:n,offset:r,children:o}=this.props;return m("a",{href:()=>At(t.get()?.data?.href),target:()=>t.get()?.data?.target||null,rel:()=>t.get()?.data?.target==="_blank"?"noopener noreferrer":null,$ref:this.element,onClick:i=>{i.ctrlKey||i.metaKey||oe(()=>{Rt(),this.mrakomor.command.openDialog({element:this.element,children:this.#e({entity:t,length:n,offset:r})});});},"data-state":()=>JSON.stringify({entity:t.get(),length:n.get(),offset:r.get()})},o)}};function wn({mrakomor:e}){return {resolveConfig:t=>(t.entityRanges.push(B),t),resolveComponent:t=>{if(t===B.NAMESPACE)return B},registerHandlers(){e.register.help.add({id:"link.insert",group:"formatting",description:"Insert or edit a link on the selection",commands:[],shortcuts:["Mod+K"]});},onKeyDown(t){t.key==="k"&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.command.insertEntityRange({namespace:B.NAMESPACE}));}}}
|
|
3
|
+
exports.LinkEntity=B;exports.linkEntityPlugin=wn;
|
package/dist/link.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
2
|
-
`,document.head.appendChild(t);}}})();var k=a.preprocess(r=>String(r??"").trim(),a.string().refine(r=>r===""||/^(?:https?:|mailto:)/i.test(r)||!/^[a-z][a-z0-9+.-]*:/i.test(r),{message:"Invalid link href"}).catch(""));function u(r){return k.parse(r)}var f='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';var b='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';var i=class r extends a$1{static get nodeName(){return "a"}static get NAMESPACE(){return "atom.link.Link"}static getStateSchema(e){let t;if(e?.getAttribute("data-state"))try{t=JSON.parse(e.getAttribute("data-state"));}catch{}return b$1({type:r.NAMESPACE,data:a.object({href:a.string().default(t?.entity?.data?.href??e?.href??"").transform(a=>u(a)),target:a.string().default(t?.entity?.data?.target??e?.target??"")}).default({}),length:t?.length??0,offset:t?.offset??0}).default({})}constructor(e){super(e),this.input=
|
|
1
|
+
import {a as a$1}from'./chunk-2C6UDFD4.mjs';import {b as b$1}from'./chunk-JVQ2YGII.mjs';import'./chunk-ZHOZPQZH.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {f as f$1,m}from'./chunk-P7TUN2KD.mjs';import {g,o,p}from'./chunk-7CJLTNHZ.mjs';(function(){if(!(typeof document>"u")){var r="mrakomor/core/plugin/linkEntity/LinkEntity.css",e=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(a){return a.getAttribute("data-mrakomor-css-path")===r});if(!e){var t=document.createElement("style");t.setAttribute("data-mrakomor-css",""),t.setAttribute("data-mrakomor-css-path",r),t.textContent=`.link-toolbar{display:flex;flex-direction:column;gap:6px}.link-toolbar__row{display:flex;align-items:center;gap:4px;min-width:0}.link-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.link-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.link-toolbar__btn:hover{background:#f0f0f0;color:#222}.link-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
|
|
2
|
+
`,document.head.appendChild(t);}}})();var k=a.preprocess(r=>String(r??"").trim(),a.string().refine(r=>r===""||/^(?:https?:|mailto:)/i.test(r)||!/^[a-z][a-z0-9+.-]*:/i.test(r),{message:"Invalid link href"}).catch(""));function u(r){return k.parse(r)}var f='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';var b='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';var i=class r extends a$1{static get nodeName(){return "a"}static get NAMESPACE(){return "atom.link.Link"}static getStateSchema(e){let t;if(e?.getAttribute("data-state"))try{t=JSON.parse(e.getAttribute("data-state"));}catch{}return b$1({type:r.NAMESPACE,data:a.object({href:a.string().default(t?.entity?.data?.href??e?.href??"").transform(a=>u(a)),target:a.string().default(t?.entity?.data?.target??e?.target??"")}).default({}),length:t?.length??0,offset:t?.offset??0}).default({})}constructor(e){super(e),this.input=g(t=>o(()=>{t.focus();}));}#e({entity:e,length:t,offset:a}){return p("div",{className:"link-toolbar"},[p("div",{className:"link-toolbar__row",style:{display:"flex"}},[p("button",{className:"link-toolbar__btn",title:"Copy URL",$dangerouslySetInnerHTML:f,onClick:()=>navigator.clipboard?.writeText(e.peek()?.data?.href??"")}),p("input",{type:"text",$ref:this.input,value:e.peek()?.data?.href??"",defaultValue:e.peek()?.data?.href??"",onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.mrakomor.command.closeDialog());},onInput:o=>{let s=o.currentTarget.value;e.set({...e.peek(),data:{...e.peek()?.data,href:s}});}}),p("select",{value:e.peek()?.data?.target??"",onChange:o=>{e.set({...e.peek(),data:{...e.peek()?.data,target:o.currentTarget.value}});}},[p("option",{value:"",selected:e.peek()?.data?.target===""},""),p("option",{value:"_self",selected:e.peek()?.data?.target==="_self"},"_self"),p("option",{value:"_blank",selected:e.peek()?.data?.target==="_blank"},"_blank"),p("option",{value:"_parent",selected:e.peek()?.data?.target==="_parent"},"_parent"),p("option",{value:"_top",selected:e.peek()?.data?.target==="_top"},"_top")]),p("span",{className:"link-toolbar__sep"}),p("button",{className:"link-toolbar__btn link-toolbar__btn--danger",title:"Remove link",$dangerouslySetInnerHTML:b,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:e.peek(),length:t.peek(),offset:a.peek()},blockElement:f$1(this.element)});}})])])}onMount(){let{entity:e}=this.props;e.peek()?.data?.href||this.mrakomor.command.openDialog({element:this.element,children:this.#e(this.props)});}render(){let{entity:e,length:t,offset:a,children:o$1}=this.props;return p("a",{href:()=>u(e.get()?.data?.href),target:()=>e.get()?.data?.target||null,rel:()=>e.get()?.data?.target==="_blank"?"noopener noreferrer":null,$ref:this.element,onClick:s=>{s.ctrlKey||s.metaKey||o(()=>{m(),this.mrakomor.command.openDialog({element:this.element,children:this.#e({entity:e,length:t,offset:a})});});},"data-state":()=>JSON.stringify({entity:e.get(),length:t.get(),offset:a.get()})},o$1)}};function v({mrakomor:r}){return {resolveConfig:e=>(e.entityRanges.push(i),e),resolveComponent:e=>{if(e===i.NAMESPACE)return i},registerHandlers(){r.register.help.add({id:"link.insert",group:"formatting",description:"Insert or edit a link on the selection",commands:[],shortcuts:["Mod+K"]});},onKeyDown(e){e.key==="k"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r.command.insertEntityRange({namespace:i.NAMESPACE}));}}}
|
|
3
3
|
export{i as LinkEntity,v as linkEntityPlugin};
|
package/dist/list.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth="1"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth="2"]{margin-inline-start:3em}.molecule-list-list li[data-depth="3"]{margin-inline-start:4.5em}
|
|
2
|
-
`,document.head.appendChild(n);}}})();var lt=class{next(...e){}error(...e){}complete(...e){}},ke=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var se=Symbol("@esmj/signals:type"),X=Symbol("@esmj/signals:name");var R=null,Ie=false,Ae=[];function w(e){let t=R;R=null;let n=e();return R=t,n}function Cn(){Ie=false;let e=pt();for(let n of e)n.get();let t=Ae;Ae=[];for(let n of t)n();}function ct(){Ie||(Ie=true,queueMicrotask(Cn));}function Le(e){Ae.push(e),ct();}var ut=Symbol("@esmj/signals:internal observable"),L=Symbol("@esmj/signals:original function"),Nn=class extends ke{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=s=>{n(s),this.#e.add(s);},t.unsubscribe=s=>{r(s),this.#e.delete(s);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[L]=void 0),e instanceof gt&&e.next[L]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{this.#e.add(e),t(),this.#r();}),e.next[L]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[L]){let n=t.get,r=n.bind(t);t.get=()=>w(()=>(this.#e.delete(t),r())),t.get[L]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[L]?e.next[L]:e.next,e.get=e.get[L]?e.get[L]:e.get,this.#e.delete(e),this.unsubscribe(e)}},oe=null;function ft(e){oe=new Nn(e);}ft(()=>{ct();});function pt(){return oe.getPending()}function mt(e){return oe.watch(e)}function dt(e){return oe.unwatch(e)}var T=Symbol("@esmj/signals:no error"),gt=class ht extends lt{#e=true;#r=false;#t=null;#s=this.#p();#c=null;#l=null;#i=0;#o=new Map;#n=T;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[se]="computed",this[X]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#s.dependencies.values())t();this.#s.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[X],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#o.keys()]}}#f(){for(let[t,n]of this.#o)if(t instanceof ht&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[ut].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=P(this.#a(),this.#l)),(this.#e||this.#n!==T)&&(this.#o.size===0||this.#f()?this.#a():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==T)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=P(this.#a(),this.#l)),(this.#e||this.#n!==T)&&(this.#o.size===0||this.#f()?this.#a():this.#e=false),this.#n!==T)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=T,this.#u(),this.#s.sourceRevisions.clear();let t=R;R=this.#s;let n;try{n=this.#c();}catch(r){this.#n=r;}return R=t,this.#o=this.#s.sourceRevisions,this.#s.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=T,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===T&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#o.clear(),this.#e=true,this.#n=T;}};function j(e,t){return new gt(e,t)}function I(e,t){let n,{debug:r,...s}={},o=j(()=>{n?.(),n=e();},{equals:()=>false,...s});o.get(),mt(o);let i=()=>{n?.(),o.destroy(),dt(o);};return i[Symbol.dispose]=i,i[se]="effect",i[X]=r??null,i.__RX_COMPUTED__=o,i}function P(e,t={}){let n=t?.equals??Object.is,r=0,s=new ke;function o(){return R&&(R.dependencies.set(s,s.subscribe(R.observer)),R.sourceRevisions.set(c,r)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,r++,s.next();}return e}function l(){return r}let c={get:o,set:a,peek:i,getRevision:l,[ut]:s,[se]:"signal",[X]:t?.debug??null};return c}function ie(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var _t=Symbol("node-component"),ae=Symbol("node-internal"),_n=Symbol("keep-literal"),fe=Symbol("raw-props");function Oe(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function De(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var kn=new Set(["template","script"]);function In(e,t){let n=(e==null?"span":String(e)).trim(),r=n;kn.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${e}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),r="span");let s=document.createElement(r);return r==="span"&&(s.style.display="contents"),s.setAttribute(t,ie()),s}function Be(e,t,n){let r=In(e,t);return n?.id&&r.setAttribute("id",n.id),r}var kt=null;function $(){return kt}function le(e){kt=e;}function pe(e){return e?.[_t]||null}function yt(e,t){e[_t]=t;}function ce(e,t={disposers:[],id:ie()}){return e?.[ae]?e[ae]:(e&&(e[ae]=t),t)}function An(e){return e[ae]}function v(e,t){let n=An(e);n||(n=ce(e)),n.disposers.push(t);}function we(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function O(e,t){let n=$();le(e);try{return t()}finally{le(n);}}var Me=new Map,ue=new Map,Et=new Map;function It(e,t){let n=typeof t=="function"?t:s=>!!t?.includes(s),r=Object.create(null);for(let s of Object.keys(e)){let o=e[s];s==="children"||n(s)?r[s]=o:o?.[_n]?r[s]=o():o!=null&&typeof o.get=="function"?r[s]=o:typeof o=="function"?r[s]=j(o):r[s]=P(o);}return r}function me(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(s=>{let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!o||!i)return false;let a="value"in o?o.value:o.get?.call(e),l="value"in i?i.value:i.get?.call(t);return me(a,l)})}function Pe(e){return {id:Symbol("context-id"),defaultValue:e}}function je(e){let t=$();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function F(e){Le(()=>{setTimeout(e,0);});}function Q(e){let t=e.componentId,n=Me.get(t);if(n){Me.delete(t);for(let r of n){let s=r();typeof s=="function"&&we(ue,t,s);}}}function Ln(e){let t=ue.get(e);if(t){ue.delete(e);for(let n of t)n();}}function Tn(e){let t=Et.get(e);if(t){Et.delete(e);for(let n of t)n();}}function de(e){if(!e)return;let t=ce(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(s){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",s);}t.disposers=[];}let n=pe(e);if(n&&(Ln(n.componentId),Tn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let s=r.nextSibling;de(r),r=s;}}}function H(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function St(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function wn(e,t,n){let r=ie(),s={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let o=St(e)?void 0:e[fe],i={...It(t??{},o),children:n},a=$(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};le(l);let c;if(St(e)){s.ClassConstructor=e;let f=new e(i);s.classInstance=f,typeof f.onMount=="function"&&we(Me,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&we(ue,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(i);le(a);let u=Mn(c);if(s.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ce(f,l),yt(f,s);else ce(u,l),u instanceof Node&&yt(u,s);return u}};return s}function $e(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Q(t);});}function Mn(e){return e instanceof Node?e:H(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var xt={className:"class",htmlFor:"for"},bt=new Set(["value","defaultValue","checked","selected","indeterminate"]),vn=new Set(["srcdoc"]),On=new Set(["href","src","action","formaction","xlink:href"]),Dn=new Set(["securitypolicyviolation"]),Bn=new Set(["contenteditable","draggable","spellcheck"]);function J(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var At=Symbol("Fragment");function q(e,t,n){if(e===At){let s=document.createDocumentFragment();return ve(s,Ct(n)),s}if(typeof e=="function")return wn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),ge(r,t),ve(r,Ct(n)),r}function Te(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Pn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function jn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return vn.has(n)?true:On.has(n)&&t!==null&&t!==void 0&&Pn(String(t))}function Lt(e){return typeof e!="string"?e:xt[e]?xt[e]:e}function $n(e,t){let n=Lt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Bn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Rt(e,t,n){let r=$n(t,n);if(r===null){e.removeAttribute(t);return}if(jn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function ge(e,t){let n=$();for(let[r,s]of Reflect.ownKeys(t).map(o=>[o,t[o]]))if(r!=="id"){if(r=Lt(r),r==="$ref"){typeof s=="function"?s(e):typeof s=="object"&&s!==null&&(s.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(J(s)){let o=I(()=>{O(n,()=>{Te(e,s.get());});});v(e,o);}else if(typeof s=="function"){let o=I(()=>{O(n,()=>{Te(e,s());});});v(e,o);}else Te(e,s);continue}if(r==="style"){if(J(s)){let o=I(()=>{O(n,()=>{Object.assign(e.style,s.get());});});v(e,o);}else typeof s=="object"&&s!==null?Object.assign(e.style,s):e.setAttribute("style",s);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof s=="function"){let o=r.slice(2).toLowerCase();if(Dn.has(o)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(o,s);continue}if(J(s)||typeof s=="function"){let o=r,i=I(()=>{O(n,()=>{let a=typeof s=="function"?s():s.get();bt.has(o)?e[o]=a??"":Rt(e,o,a);});});v(e,i);continue}bt.has(r)||typeof r=="symbol"?e[r]=s??"":Rt(e,r,s);}}function Ct(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ve(e,t){for(let n of t)Tt(e,n);}function Tt(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){Nt(e,t);return}if(H(t)){$e(e,t);return}if(J(t)){Nt(e,()=>t.get());return}if(Array.isArray(t)){ve(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function K(e){let t=null,n=e;return H(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function he(e,t=true){for(let n of e)t&&de(n),n.remove();}function Nt(e,t){let n=$(),r=document.createComment("");e.appendChild(r);let s=[],o=I(()=>{O(n,()=>{let i=t(),{nodes:a,instance:l}=K(i);he(s),a.length&&r.after(...a),l&&queueMicrotask(()=>Q(l)),s=a;});});v(e,o);}var vt=class{constructor(e){this.props=e;}};function wt(e,t,n,r){let{equals:s=me,tagName:o="span",...i}=r??{},a=Be(o,"data-for",i);ge(a,i);let l=$(),c=[],u=new Map,f=j(()=>e()),p=I(()=>{let m=f.get(),y=Array.isArray(m)?m:[],N=[],E=[],D=new Set;for(let g=0;g<y.length;g++){let x=y[g],_=t(x,g);if(D.has(_)){console.error(`For: duplicate key "${String(_)}" detected; ignoring later item at index ${g}`);continue}D.add(_),N.push(x),E.push(_);}let U=new Map(c.map(g=>[g.key,g])),M=[];for(let g=0;g<N.length;g++){let x=E[g],_=N[g],B=U.get(x);if(B)u.get(x).set(_),M.push(B),U.delete(x);else {let ot=P(_,{equals:s});u.set(x,ot);let En={...ot,set(){}},it={key:x,nodes:[]};O(l,()=>{let Sn=n(En,g),{nodes:xn,instance:at}=K(Sn);it.nodes=xn,at&&queueMicrotask(()=>Q(at));}),M.push(it);}}for(let[g,x]of U)he(x.nodes),u.delete(g);let A=null;for(let g=M.length-1;g>=0;g--){let x=M[g].nodes;for(let _=x.length-1;_>=0;_--){let B=x[_];(B.parentNode!==a||B.nextSibling!==A)&&a.insertBefore(B,A),A=B;}}c=M;});return v(a,p),a}function Fe(e,t,n,r){if(typeof e=="function")return wt(e,t,n,r);let{each:s,keyFn:o,equals:i,tagName:a,children:l,...c}=e??{};if(typeof o!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=Oe(s),f=De(e??{},t);return wt(u,o,f,{...c,equals:i,tagName:a})}Fe[fe]=e=>e!=="each";function Ot(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(de(e),e.innerHTML=""),H(t)?$e(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Hn={abortEarly:true};function Ge(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function Un(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Ge(e.errors[r],n));}function Pt(e,t,n,r){if(n!==false){let s=Ge(e.error,t);return {success:false,error:s,errors:[s]}}Un(e,r,t);}function ye(e){return e?.abortEarly!==void 0?e:Hn}function He(e,t){S(e,"_parse",(n,r,s)=>{let o=n(r,s);return !o.success&&t(r)?{success:true,data:r}:o});}var Z=e=>typeof e=="string"||e instanceof String,Ue=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),qe=e=>e===true||e===false,qn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Kn=e=>typeof e=="function",Gn=e=>Array.isArray(e),Ke=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function jt(e,t){let n=C(Ke,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([s,o])=>`${s}: ${o._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(s,{when:o="always"}={}){return S(this,"_parse",(i,a,l)=>{let c=i(a,l);if(!c.success)return c;let u=s(c.data,{context:l?.context});if(!Ke(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(o==="missing"){let f={...c.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},S(n,"_parse",(s,o,i)=>{let a=s(o,i),{abortEarly:l}=ye(i);if(a.success===false)return a;let c={},u=[];for(let f in e){let p=e[f]._parse(a.data[f],i);if(p.success)c[f]=p.data;else {let m=Pt(p,f,l,u);if(m)return m}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function Ve(e){return C(Z,{...e,type:"string"})}function Ye(e){return C(Ue,{...e,type:"number"})}function We(e){return C(qe,{...e,type:"boolean"})}function Xe(e){return C(qn,{...e,type:"date"})}function $t(e){return C(Kn,{...e,type:"function"})}function Ft(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${s} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,s="enum",o=C(n,{message:r,...t,type:s});return o._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,o._getDefinition=()=>e,o}function Ht(e,t){let n=C(Gn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,S(n,"_parse",(r,s,o)=>{let i=r(s,o),{abortEarly:a}=ye(o);if(i.success===false)return i;let l=[],c=[],u=o;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},m=e._parse(i.data[f],p);if(m.success)l.push(m.data);else {let y=Pt(m,f,a,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function Ut(){return C(()=>true)}function G(e,t){return S(t,"_parse",(n,r,s)=>(r=e(r),n(r,s))),t}function qt(e,t){let n=s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((o,i)=>` ${i+1}. ${o._getDescription()}`).join(",")} but received "${typeof s}" with value: ${Ke(s)?JSON.stringify(s):`"${s}"`}`,r=C(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,S(r,"_parse",(s,o,i)=>{let a=i,l=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(o,a);if(m.success)return m;l.push(m);}let{abortEarly:c}=ye(a),u={message:typeof n=="function"?n(o):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<l.length;p++){let m=l[p].errors;if(m?.length)for(let y=0;y<m.length;y++)m[y].cause?.key&&f.push(Ge(m[y],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Kt(e,t){let n=C(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function Gt(e){let t=C(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,S(t,"_parse",(n,r,s)=>({success:true,data:s?.context?.[e]})),t}function Vt(e,t){return {parse(n,r){let s=e.parse(r?.context??{},r);return t(s).parse(n,r)},safeParse(n,r){let s=e.safeParse(r?.context??{},r);return s.success?t(s.data).safeParse(n,r):s}}}var Yt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return G(n=>{let r;return Z(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},We({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return G(n=>{if(qe(n))return Number(n);if(Z(n)){let r=n.trim();if(r==="")return n;let s=Number(r);if(Number.isFinite(s))return s}return n},Ye({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return G(n=>qe(n)||Ue(n)&&Number.isFinite(n)?String(n):n,Ve({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return G(n=>{let r;return Z(n)&&(r=n.trim()),Ue(n)&&Number.isFinite(n)||r?new Date(r??n):n},Xe({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return S(e,"_parse",(r,s,o)=>{if(Z(s))try{s=JSON.parse(s);}catch{let i={message:typeof n=="function"?n(s):n};return {success:false,error:i,errors:[i]}}return r(s,o)}),e}},Wt={},d={object:jt,string:Ve,number:Ye,boolean:We,date:Xe,function:$t,enum:Ft,array:Ht,any:Ut,preprocess:G,union:qt,literal:Kt,contextRef:Gt,withContext:Vt,coerce:Wt,cast:Yt};function Dt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function S(e,t,n){let r=e[t];e[t]=(...s)=>n(r,...s);}function C(e,{type:t="any",name:n,message:r}={}){r=r||Dt(t);let s={name:n,message:r,type:t},o={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let l=e(i);if(l===true)return {success:true,data:i};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(i):r};return {success:false,error:c,errors:[c]}},parse(i,a){let l=this._parse(i,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(i,a){return this._parse(i,a)},transform(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=i(u.data)),u}),this},optional(){return He(this,i=>i===void 0),this},nullable(){return He(this,i=>i===null),this},nullish(){return He(this,i=>i==null),this},default(i){return S(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof i=="function"?i({context:c?.context}):i),a(l,c))),this},catch(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof i=="function"?i({input:l,error:u.error}):i}}),this},pipe(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?i._parse(u.data,c):u}),this},refine(i,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||Dt(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return S(this,"_parse",(u,f,p)=>{let m=u(f,p),{abortEarly:y}=ye(p);if(!m.success)return m;let N=i(m.data);if(N===true||typeof N=="object"&&N?.success===true)return m;let E={message:typeof a=="function"?a(f):a};return {success:false,error:E,errors:[E]}}),this},clone(){return {...this}}};return Bt.length>0?Bt.reduce((i,a)=>a(i,e,s)??i,o):o}var Bt=[];var ze=Qe(),Je=Qe(),Xt=Qe(),Vn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Qe(){return Math.floor(Math.random()*16777215)}function Yn(){return Je=(Je+1)%16777215,Je}function b(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Yn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,ze>>16&255,ze>>8&255,ze&255,Xt>>8&255,Xt&255,t>>16&255,t>>8&255,t&255),r="";for(let s=0;s<n.length;s++)r+=Vn[n.charCodeAt(s)];return r}var zt=Symbol("block-element"),Wn=Symbol("block-element-body"),Jt=Symbol("selectable-element");function Xn(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function Ee(e){return Xn(e,zt)}function Qt(){return window.getSelection()}function V(){let e=Qt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Ze(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)i+=a[c].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=s.nextNode();for(;o;){if(o===t)return r+n;r+=o.textContent.length,o=s.nextNode();}return r}function zn(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,s=[e];for(;s.length>0;){let o=s.pop();if(o.nodeType===Node.TEXT_NODE){let i=o.textContent.length;if(r+i>=t)return n.setEnd(o,t-r),n.setStart(o,t-r),n;r+=i;}else if(o.childNodes&&o.childNodes.length>0)for(let i=o.childNodes.length-1;i>=0;i--)s.push(o.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function Y(e,t){let n=zn(e,t),r=Qt();r.removeAllRanges(),r.addRange(n);}function Jn(e){if(!e)return null;let t=Qn(e);return t?.firstElementChild??t?.firstChild}function et(e){if(!e?.[zt])return null;let t=Jn(e);return t?pe(t)?.classInstance:null}function Qn(e){if(!e)return null;for(let t of e.children)if(t[Wn])return t;return null}var Se={INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var Zt=Pe();var xe=class extends vt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=je(Zt),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(Se.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var W="molecule.paragraph.Paragraph",be="molecule.list.List";var en="molecule.headline.";function h(e){return e===`
|
|
2
|
+
`,document.head.appendChild(n);}}})();var dt=class{next(...e){}error(...e){}complete(...e){}},ve=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var ue=Symbol("@esmj/signals:type"),J=Symbol("@esmj/signals:name");var R=null,Te=false,Oe=[];function v(e){let t=R;R=null;let n=e();return R=t,n}function Tn(){Te=false;let e=St();for(let n of e)n.get();let t=Oe;Oe=[];for(let n of t)n();}function ht(){Te||(Te=true,queueMicrotask(Tn));}function Me(e){Oe.push(e),ht();}var Et=Symbol("@esmj/signals:internal observable"),L=Symbol("@esmj/signals:original function"),On=class extends ve{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>v(()=>{this.#e.add(e),this.#r();}),e.next[L]=void 0),e instanceof bt&&e.next[L]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#r();}),e.next[L]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[L]){let n=t.get,r=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),r())),t.get[L]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[L]?e.next[L]:e.next,e.get=e.get[L]?e.get[L]:e.get,this.#e.delete(e),this.unsubscribe(e)}},fe=null;function yt(e){fe=new On(e);}yt(()=>{ht();});function St(){return fe.getPending()}function xt(e){return fe.watch(e)}function Ct(e){return fe.unwatch(e)}var A=Symbol("@esmj/signals:no error"),bt=class Rt extends dt{#e=true;#r=false;#t=null;#o=this.#p();#a=null;#l=null;#i=0;#s=new Map;#n=A;constructor(t,n){super(),this.#a=t,this.#l=n,this.debug=n?.debug,this[ue]="computed",this[J]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[J],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Rt&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[Et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==A)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==A)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==A)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),this.#n!==A)throw this.#n;return this.#t.peek()}#c(){this.#r=true,this.#e=false,this.#n=A,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#a();}catch(r){this.#n=r;}return R=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=A,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===A&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=A;}};function F(e,t){return new bt(e,t)}function I(e,t){let n,{debug:r,...o}={},s=F(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),xt(s);let i=()=>{n?.(),s.destroy(),Ct(s);};return i[Symbol.dispose]=i,i[ue]="effect",i[J]=r??null,i.__RX_COMPUTED__=s,i}function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new ve;function s(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(a,r)),e}function i(){return e}function c(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let a={get:s,set:c,peek:i,getRevision:l,[Et]:o,[ue]:"signal",[J]:t?.debug??null};return a}function pe(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Tt=Symbol("node-component"),me=Symbol("node-internal"),Mn=Symbol("keep-literal"),Ee=Symbol("raw-props");function $e(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function Fe(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var wn=new Set(["template","script"]);function Dn(e,t){let n=(e==null?"span":String(e)).trim(),r=n;wn.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${e}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),r="span");let o=document.createElement(r);return r==="span"&&(o.style.display="contents"),o.setAttribute(t,pe()),o}function He(e,t,n){let r=Dn(e,t);return n?.id&&r.setAttribute("id",n.id),r}var Ot=null;function H(){return Ot}function ge(e){Ot=e;}function ye(e){return e?.[Tt]||null}function kt(e,t){e[Tt]=t;}function de(e,t={disposers:[],id:pe()}){return e?.[me]?e[me]:(e&&(e[me]=t),t)}function Pn(e){return e[me]}function M(e,t){let n=Pn(e);n||(n=de(e)),n.disposers.push(t);}function De(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function w(e,t){let n=H();ge(e);try{return t()}finally{ge(n);}}var Pe=new Map,he=new Map,_t=new Map;function Mt(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let s=e[o];o==="children"||n(o)?r[o]=s:s?.[Mn]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=F(s):r[o]=$(s);}return r}function Se(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let c="value"in s?s.value:s.get?.call(e),l="value"in i?i.value:i.get?.call(t);return Se(c,l)})}function Ke(e){return {id:Symbol("context-id"),defaultValue:e}}function Ue(e){let t=H();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function N(e){Me(()=>{setTimeout(e,0);});}function ee(e){let t=e.componentId,n=Pe.get(t);if(n){Pe.delete(t);for(let r of n){let o=r();typeof o=="function"&&De(he,t,o);}}}function jn(e){let t=he.get(e);if(t){he.delete(e);for(let n of t)n();}}function $n(e){let t=_t.get(e);if(t){_t.delete(e);for(let n of t)n();}}function xe(e){if(!e)return;let t=de(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=ye(e);if(n&&(jn(n.componentId),$n(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;xe(r),r=o;}}}function K(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function It(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Fn(e,t,n){let r=pe(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=It(e)?void 0:e[Ee],i={...Mt(t??{},s),children:n},c=H(),l={disposers:[],id:r,contexts:new Map(c?.contexts)};ge(l);let a;if(It(e)){o.ClassConstructor=e;let f=new e(i);o.classInstance=f,typeof f.onMount=="function"&&De(Pe,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&De(he,r,()=>{f.onUnmount?.();}),a=f.render();}else a=e(i);ge(c);let u=Hn(a);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)de(f,l),kt(f,o);else de(u,l),u instanceof Node&&kt(u,o);return u}};return o}function qe(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{ee(t);});}function Hn(e){return e instanceof Node?e:K(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Nt={className:"class",htmlFor:"for"},Bt=new Set(["value","defaultValue","checked","selected","indeterminate"]),Kn=new Set(["srcdoc"]),Un=new Set(["href","src","action","formaction","xlink:href"]),qn=new Set(["securitypolicyviolation"]),Gn=new Set(["contenteditable","draggable","spellcheck"]);function Z(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var wt=Symbol("Fragment");function V(e,t,n){if(e===wt){let o=document.createDocumentFragment();return je(o,At(n)),o}if(typeof e=="function")return Fn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),Ce(r,t),je(r,At(n)),r}function we(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Vn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Yn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Kn.has(n)?true:Un.has(n)&&t!==null&&t!==void 0&&Vn(String(t))}function Dt(e){return typeof e!="string"?e:Nt[e]?Nt[e]:e}function zn(e,t){let n=Dt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Gn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Lt(e,t,n){let r=zn(t,n);if(r===null){e.removeAttribute(t);return}if(Yn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function Ce(e,t){let n=H();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=Dt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(Z(o)){let s=I(()=>{w(n,()=>{we(e,o.get());});});M(e,s);}else if(typeof o=="function"){let s=I(()=>{w(n,()=>{we(e,o());});});M(e,s);}else we(e,o);continue}if(r==="style"){if(Z(o)){let s=I(()=>{w(n,()=>{Object.assign(e.style,o.get());});});M(e,s);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let s=r.slice(2).toLowerCase();if(qn.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(Z(o)||typeof o=="function"){let s=r,i=I(()=>{w(n,()=>{let c=typeof o=="function"?o():o.get();Bt.has(s)?e[s]=c??"":Lt(e,s,c);});});M(e,i);continue}Bt.has(r)||typeof r=="symbol"?e[r]=o??"":Lt(e,r,o);}}function At(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function je(e,t){for(let n of t)Pt(e,n);}function Pt(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){vt(e,t);return}if(K(t)){qe(e,t);return}if(Z(t)){vt(e,()=>t.get());return}if(Array.isArray(t)){je(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function Y(e){let t=null,n=e;return K(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function be(e,t=true){for(let n of e)t&&xe(n),n.remove();}function vt(e,t){let n=H(),r=document.createComment("");e.appendChild(r);let o=[],s=I(()=>{w(n,()=>{let i=t(),{nodes:c,instance:l}=Y(i);be(o),c.length&&r.after(...c),l&&queueMicrotask(()=>ee(l)),o=c;});});M(e,s);}var Ft=class{constructor(e){this.props=e;}};function jt(e,t,n,r){let{equals:o=Se,tagName:s="span",...i}=r??{},c=He(s,"data-for",i);Ce(c,i);let l=H(),a=[],u=new Map,f=F(()=>e()),p=I(()=>{let m=f.get(),h=Array.isArray(m)?m:[],S=[],y=[],P=new Set;for(let d=0;d<h.length;d++){let b=h[d],_=t(b,d);if(P.has(_)){console.error(`For: duplicate key "${String(_)}" detected; ignoring later item at index ${d}`);continue}P.add(_),S.push(b),y.push(_);}let G=new Map(a.map(d=>[d.key,d])),O=[];for(let d=0;d<S.length;d++){let b=y[d],_=S[d],j=G.get(b);if(j)u.get(b).set(_),O.push(j),G.delete(b);else {let pt=$(_,{equals:o});u.set(b,pt);let Nn={...pt,set(){}},mt={key:b,nodes:[]};w(l,()=>{let Bn=n(Nn,d),{nodes:Ln,instance:gt}=Y(Bn);mt.nodes=Ln,gt&&queueMicrotask(()=>ee(gt));}),O.push(mt);}}for(let[d,b]of G)be(b.nodes),u.delete(d);let B=null;for(let d=O.length-1;d>=0;d--){let b=O[d].nodes;for(let _=b.length-1;_>=0;_--){let j=b[_];(j.parentNode!==c||j.nextSibling!==B)&&c.insertBefore(j,B),B=j;}}a=O;});return M(c,p),c}function Ge(e,t,n,r){if(typeof e=="function")return jt(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:c,children:l,...a}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=$e(o),f=Fe(e??{},t);return jt(u,s,f,{...a,equals:i,tagName:c})}Ge[Ee]=e=>e!=="each";function Ht(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(xe(e),e.innerHTML=""),K(t)?qe(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Xn={abortEarly:true};function Xe(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function Jn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Xe(e.errors[r],n));}function qt(e,t,n,r){if(n!==false){let o=Xe(e.error,t);return {success:false,error:o,errors:[o]}}Jn(e,r,t);}function Re(e){return e?.abortEarly!==void 0?e:Xn}function Ve(e,t){x(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var te=e=>typeof e=="string"||e instanceof String,Ye=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),ze=e=>e===true||e===false,Qn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Zn=e=>typeof e=="function",er=e=>Array.isArray(e),We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Gt(e,t){let n=k(We,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,s])=>`${o}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:s="always"}={}){return x(this,"_parse",(i,c,l)=>{let a=i(c,l);if(!a.success)return a;let u=o(a.data,{context:l?.context});if(!We(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(s==="missing"){let f={...a.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...a.data,...u}}}),this},x(n,"_parse",(o,s,i)=>{let c=o(s,i),{abortEarly:l}=Re(i);if(c.success===false)return c;let a={},u=[];for(let f in e){let p=e[f]._parse(c.data[f],i);if(p.success)a[f]=p.data;else {let m=qt(p,f,l,u);if(m)return m}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:a}}),r}function Je(e){return k(te,{...e,type:"string"})}function Qe(e){return k(Ye,{...e,type:"number"})}function Ze(e){return k(ze,{...e,type:"boolean"})}function et(e){return k(Qn,{...e,type:"date"})}function Vt(e){return k(Zn,{...e,type:"function"})}function Yt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,o="enum",s=k(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function zt(e,t){let n=k(er,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,x(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:c}=Re(s);if(i.success===false)return i;let l=[],a=[],u=s;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},m=e._parse(i.data[f],p);if(m.success)l.push(m.data);else {let h=qt(m,f,c,a);if(h)return h}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:l}}),n}function Wt(){return k(()=>true)}function z(e,t){return x(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Xt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof o}" with value: ${We(o)?JSON.stringify(o):`"${o}"`}`,r=k(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,x(r,"_parse",(o,s,i)=>{let c=i,l=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(s,c);if(m.success)return m;l.push(m);}let{abortEarly:a}=Re(c),u={message:typeof n=="function"?n(s):n};if(a!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<l.length;p++){let m=l[p].errors;if(m?.length)for(let h=0;h<m.length;h++)m[h].cause?.key&&f.push(Xe(m[h],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Jt(e,t){let n=k(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function Qt(e){let t=k(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,x(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Zt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var en={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return z(n=>{let r;return te(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},Ze({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return z(n=>{if(ze(n))return Number(n);if(te(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Qe({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return z(n=>ze(n)||Ye(n)&&Number.isFinite(n)?String(n):n,Je({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return z(n=>{let r;return te(n)&&(r=n.trim()),Ye(n)&&Number.isFinite(n)||r?new Date(r??n):n},et({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return x(e,"_parse",(r,o,s)=>{if(te(o))try{o=JSON.parse(o);}catch{let i={message:typeof n=="function"?n(o):n};return {success:false,error:i,errors:[i]}}return r(o,s)}),e}},tn={},g={object:Gt,string:Je,number:Qe,boolean:Ze,date:et,function:Vt,enum:Yt,array:zt,any:Wt,preprocess:z,union:Xt,literal:Jt,contextRef:Qt,withContext:Zt,coerce:tn,cast:en};function Kt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function x(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function k(e,{type:t="any",name:n,message:r}={}){r=r||Kt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let l=e(i);if(l===true)return {success:true,data:i};if(typeof l=="object"&&l?.success===true)return l;let a={message:typeof r=="function"?r(i):r};return {success:false,error:a,errors:[a]}},parse(i,c){let l=this._parse(i,c);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(i,c){return this._parse(i,c)},transform(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success&&(u.data=i(u.data)),u}),this},optional(){return Ve(this,i=>i===void 0),this},nullable(){return Ve(this,i=>i===null),this},nullish(){return Ve(this,i=>i==null),this},default(i){return x(this,"_parse",(c,l,a)=>(l===void 0&&(l=typeof i=="function"?i({context:a?.context}):i),c(l,a))),this},catch(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?u:{success:true,data:typeof i=="function"?i({input:l,error:u.error}):i}}),this},pipe(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?i._parse(u.data,a):u}),this},refine(i,{message:c,type:l,jsonSchema:a}={}){if(l&&(c=c||Kt(l),t=l),a){let u=[...this._getJsonSchemaHints?.()??[],a];this._getJsonSchemaHints=()=>u;}return x(this,"_parse",(u,f,p)=>{let m=u(f,p),{abortEarly:h}=Re(p);if(!m.success)return m;let S=i(m.data);if(S===true||typeof S=="object"&&S?.success===true)return m;let y={message:typeof c=="function"?c(f):c};return {success:false,error:y,errors:[y]}}),this},clone(){return {...this}}};return Ut.length>0?Ut.reduce((i,c)=>c(i,e,o)??i,s):s}var Ut=[];var tt=rt(),nt=rt(),nn=rt(),tr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function rt(){return Math.floor(Math.random()*16777215)}function nr(){return nt=(nt+1)%16777215,nt}function C(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=nr(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,tt>>16&255,tt>>8&255,tt&255,nn>>8&255,nn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=tr[n.charCodeAt(o)];return r}var ot=Symbol("block-element"),rr=Symbol("block-element-body"),ne=Symbol("selectable-element");function st(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function it(e){return e?st(e.startContainer,ot):null}function ke(e){return st(e,ot)}function rn(e){return e?st(e.startContainer,ne):null}function or(e){return e?e[ne]!==void 0?[e]:[...e.children].filter(t=>t[ne]!==void 0):[]}function sr(e,t){return t?or(e).indexOf(t):-1}function re(e,t){let n=rn(t);return !n||!e?.contains(n)?null:{element:n,index:sr(e,n)}}function on(){return window.getSelection()}function U(){let e=on();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function ct(){let e=U();if(!e)return 0;e.collapse(true);let t=rn(e),n=it(e),r=t??W(n);return _e(r,e.startContainer,e.startOffset)}function _e(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,c=e.childNodes,l=Math.min(n,c.length);for(let a=0;a<l;a++)i+=c[a].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=o.nextNode();for(;s;){if(s===t)return r+n;r+=s.textContent.length,s=o.nextNode();}return r}function ir(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(r+i>=t)return n.setEnd(s,t-r),n.setStart(s,t-r),n;r+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)o.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function D(e,t){let n=ir(e,t),r=on();r.removeAllRanges(),r.addRange(n);}function W(e){if(!e)return null;let t=cr(e);return t?.firstElementChild??t?.firstChild}function oe(e){if(!e?.[ot])return null;let t=W(e);return t?ye(t)?.classInstance:null}function cr(e){if(!e)return null;for(let t of e.children)if(t[rr])return t;return null}var se={KEYDOWN:"mrakomor:keydown",INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var sn=Ke();var Ie=class extends Ft{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Ue(sn),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return g.object({component:g.string().default(this.NAMESPACE),properties:g.object().default({}),settings:g.object().default({})}).default({})}static getPropsSchema(){return g.object({state:this.getStateSchema(),observeDOMChanges:g.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(se.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var X="molecule.paragraph.Paragraph",ie="molecule.list.List";var cn="molecule.headline.";function E(e){return e===`
|
|
3
3
|
`||e===`\r
|
|
4
|
-
`?"":e??""}function
|
|
5
|
-
`),s=n.map(o=>({text:h(o?.text),inlineStyleRanges:o?.inlineStyleRanges??[],entityRanges:o?.entityRanges??[],depth:o?.depth??0}));return k({originComponent:this.NAMESPACE,properties:{text:r,items:s},settings:t?.settings})}static fromExchangeState(t){return mn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return gn(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},s=nt(t);if(s.length)n.properties.items=s.map(o=>Ne(o).parse(yn(o,r)));else {let o=this.state?.peek?.()?.properties?.items;n.properties.items=o?.length?structuredClone(o):[Ne().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}getFormattingTarget(t){let n=t??V(),r=ne(this.element,n);if(!r)return null;let s=re(this.element,r);return s<0?null:{element:r,read(o){let i=o.properties?.items?.[s];return {inlineStyleRanges:i?.inlineStyleRanges,entityRanges:i?.entityRanges}},write(o,{inlineStyleRanges:i,entityRanges:a}){let l=o.properties?.items?.[s];l&&(i!==void 0&&(l.inlineStyleRanges=i),a!==void 0&&(l.entityRanges=a));}}}_commitState(t){let n=Ee(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(n);if(r===-1)return;let s=this.mrakomor.getContent();s.splice(r,1,t),this.mrakomor.setContent(s);}_buildItemContent(t){return hn(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",s=Fe(()=>this.state.get().properties?.items??[],(o,i)=>o.componentId??String(i),(o,i)=>q("li",{contentEditable:true,[Jt]:true,"data-componentid":()=>o.get().componentId,"data-item-index":()=>{let a=o.get()?.componentId,c=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===a);return String(c>=0?c:i)},"data-depth":()=>String(o.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let a=o.get(),l=a?.text??"";return h(l)?w(()=>this._buildItemContent(a)):"<br>"}}),{tagName:r});return s.className=t,n.componentId&&s.setAttribute("data-componentid",n.componentId),this.element=s,s}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor(t){let n=this.getState()?.properties?.items??[],r=n.length-1;if(r<0)return;let s=typeof t=="number"?t:h(n[r]?.text).length,o=()=>{let i=this.element?.querySelector(`li[data-item-index="${r}"]`);i?.isConnected&&Y(i,s);};o(),F(o);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],s=r[t];if(!s)return;if((s.depth??0)>0){r[t]={...s,depth:s.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&Y(p,0);};f(),F(f);return}let o=Ee(this.element),i=this.mrakomor._getBlockElementIndex(o),a=o?.previousElementSibling??null,l=a?this.mrakomor._getBlockElementIndex(a):-1;if(t===0&&l>=0&&i===l+1){let f=this.mrakomor.getContent(),p=dn(f,l,i);if(p){this.mrakomor._setContentState(p.content.map(m=>this.mrakomor.normalizeComponentState(m))),et(a)?.setCursor?.(p.cursor);return}}let{blocks:c,paragraphIndex:u}=st(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(W)});this.mrakomor.command.replaceBlockElement({blockElement:Ee(this.element),blocks:c,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=V(),r=ne(this.element,n);if(!r)return;let s=re(this.element,r),o=rt(r,n),i=this.getState(),a=[...i.properties.items??[]],l=a[s];if(!l)return;if(!h(l.text)){this.#e(s);return}let{before:c,after:u}=pn(l,o);a.splice(s,1,c,u),this._commitState({...i,properties:{...i.properties,items:a}}),F(()=>{let f=this.element?.querySelector(`li[data-item-index="${s+1}"]`);f&&Y(f,0);});}#t(t){let n=V();if(!n?.collapsed)return;let r=ne(this.element,n);if(!r){let i=n.startContainer;if(!(i===this.element||this.element?.contains?.(i)))return;t.preventDefault(),this.#e(0);return}let s=re(this.element,r);rt(r,n)===0&&(t.preventDefault(),this.#e(s));}};function nr(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let s=t._getBlockElementState(n);if(!s||!sn({component:r})||!Re(s))return;e.preventDefault();let i=et(n)?.element,a=e.range??V(),l=i?ne(i,a):null,c=re(i,l);if(c<0)return;let{blocks:u,paragraphIndex:f}=st(s,c,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function rr(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(Se.TRANSFORM_BLOCK_ELEMENT,nr);}}}function sr(){return rr(_e)}exports.List=_e;exports.listPlugin=sr;
|
|
4
|
+
`?"":e??""}function q({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},s=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:s},...r?{settings:r}:{}}}function fn(e){let t="",n=[],r=[];return (e??[]).forEach((o,s)=>{s>0&&(t+=`
|
|
5
|
+
`);let i=t.length;t+=E(o?.text);for(let c of o?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of o?.entityRanges??[])r.push({...c,offset:c.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function T(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function pn({mrakomor:e,resultIndex:t,cursor:n,fallbackBlockElement:r,itemIndex:o}){let s=()=>{if(typeof n!="number")return;let i=e._getBlockElements()[t]??r,c=oe(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:o});return}let l=W(i);l?.isConnected&&D(l,n);};s(),N(s);}function lt(e){let t=e?.component??"";return t===X||t.startsWith(cn)}function Ne(e){return Array.isArray(e?.properties?.items)}function lr(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function ln(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function ar(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let c=r.find(l=>l.match(i));c&&(s=V(c,{},s));}for(let i of n){let c=o.find(l=>l.match(i));c&&(s=V(c,i,s));}return s}function mn(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=E(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let c=lr([...s,...i],o.length);for(let l=0;l<c.length-1;l+=1){let a=c[l],u=c[l+1];if(a>=u)continue;let f=o.slice(a,u),p=ar(f,ln(s,a,u),ln(i,a,u),{inlineStyleComponents:t,entityRangeComponents:n});Ht(r,p);}return r}function ce(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=r.find(a=>a.match(i));if(c){let a=i.textContent.length;t.properties.inlineStyleRanges.push({style:c.style,offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(a=>a.match(i));if(l){let a=i.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(i).parse(),offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function le(e,t){let n=E(e.properties.text),r=E(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function an(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function un(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function gn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=an(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=un(e.properties.inlineStyleRanges,t),n.properties.entityRanges=an(e.properties.entityRanges,t),r.properties.entityRanges=un(e.properties.entityRanges,t),r.componentId=C(),{originalLineState:n,newLineState:r}}var Be=class extends Ie{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:E(this.getState()?.properties?.text).length;D(this.element,r);};n(),N(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:E(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),q({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=fn(n?.properties?.items);return le(t,T(r))}};function dn(e,t,n){let r=e._getBlockElementIndex(t);if(r===-1)return false;let o=e.getContent();return o.splice(r,1,e.normalizeComponentState(n)),e._setContentState(o),true}function hn(){return g.object({length:g.number(),offset:g.number(),style:g.string()})}function En({type:e,data:t=g.any(),length:n,offset:r}={}){let o=e!=null,s=g.object({type:o?g.string().default(e):g.string(),data:t}),i=n??(o?0:void 0),c=r??(o?0:void 0);return g.object({entity:o?s.default({}):s,length:i==null?g.number():g.number().default(i),offset:c==null?g.number():g.number().default(c)})}function Sn(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function Le(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=C();return t.add(r),{...n,componentId:r}})}function xn(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function at(e,t){return !e||!t?0:_e(e,t.startContainer,t.startOffset)}function Cn(e,t){let n=T(e),{originalLineState:r,newLineState:o}=gn(n,t);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:C(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function bn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??C(),depth:o?.depth??0,text:E(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:C(),depth:0,text:E(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:ie,componentId:C(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function ut(e,t,{namespace:n=X,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),c=o.slice(t+1),l=q({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),a={component:n,componentId:C(),settings:{},...r?.fromExchangeState(l)??T(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(a),c.length&&u.push({...e,componentId:i.length?C():e.componentId,properties:{...e.properties,items:c}}),{blocks:u,paragraphIndex:i.length?1:0}}function yn(e){return Ne(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function ft(e,t){let n=yn(e),r=yn(t);return n!=null&&n===r}function Rn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!ft(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let p=[...e];p.splice(n,1);let m=s.length-1,h=m>=0?E(s[m]?.text).length:0;return {content:p,listIndex:t,cursor:h}}let[c,...l]=i,a=0;if(s.length===0)s.push(c,...l),a=0;else {let p=s.length-1,m=s[p],h=T(m),S=T(c),{state:y,cursor:P}=le(h,S);s[p]={...m,text:y.properties.text,inlineStyleRanges:y.properties.inlineStyleRanges,entityRanges:y.properties.entityRanges},l.length&&s.push(...l),a=P;}let u={...r,properties:{...r.properties,items:Le(s)}},f=[...e];return f[t]=u,f.splice(n,1),{content:f,listIndex:t,cursor:a}}function kn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=q({properties:t?.properties}).properties.items,[s,...i]=o,c=n[r],l=T(c),a=T(s),{state:u,cursor:f}=le(l,a),p=n.map((m,h)=>h===r?{...m,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges}:m);return i.length&&p.push(...i.map(m=>({componentId:m?.componentId??C(),depth:m?.depth??0,text:E(m?.text??""),inlineStyleRanges:m?.inlineStyleRanges??[],entityRanges:m?.entityRanges??[]}))),{state:{...e,properties:{...e.properties,items:Le(p)}},cursor:f,itemIndex:r}}function _n(e,t){return mn({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function In(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:E(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return ce(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:E(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Ae=e=>g.object({componentId:g.string().default(()=>e?.getAttribute?.("data-componentid")||C()),depth:g.number().default(0),text:g.string().default(""),inlineStyleRanges:g.array(hn()).default([]),entityRanges:g.array(En()).default([])}).default({}),ae=class e extends Be{static get NAMESPACE(){return ie}static get LABEL(){return "List"}static get GROUP(){return "lists"}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){let n=Sn(t);return g.object({component:g.string().default(e.NAMESPACE),componentId:g.string().default(t?.getAttribute("data-componentid")||C()),properties:g.object({items:g.array(Ae()).default([Ae().parse()]).transform(Le)}).default({}),settings:g.object({style:g.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:E(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return q({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return bn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return kn(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},o=xn(t);if(o.length)n.properties.items=o.map(s=>Ae(s).parse(In(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Ae().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=ke(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId);dn(this.mrakomor,n,t);}_buildItemContent(t){return _n(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",o=Ge(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>V("li",{contentEditable:true,[ne]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let c=s.get()?.componentId,a=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===c);return String(a>=0?a:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let c=s.get(),l=c?.text??"";return E(l)?v(()=>this._buildItemContent(c)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor({cursor:t,itemIndex:n}={}){let r=this.getState()?.properties?.items??[],o=r.length-1;if(o<0)return;let s=typeof n=="number"&&n>=0&&n<=o?n:o,i=typeof t=="number"?t:E(r[s]?.text).length,c=()=>{let l=this.element?.querySelector(`li[data-item-index="${s}"]`);l?.isConnected&&D(l,i);};c(),N(c);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&D(p,0);};f(),N(f);return}let s=ke(this.element),i=this.mrakomor._getBlockElementIndex(s),c=s?.previousElementSibling??null,l=c?this.mrakomor._getBlockElementIndex(c):-1;if(t===0&&l>=0&&i===l+1){let f=this.mrakomor.getContent(),p=Rn(f,l,i);if(p){let m=p.content.map((h,S)=>S===p.listIndex?this.mrakomor.normalizeComponentState(h):h);this.mrakomor._setContentState(m),oe(c)?.setCursor?.({cursor:p.cursor});return}}let{blocks:a,paragraphIndex:u}=ut(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(X)});this.mrakomor.command.replaceBlockElement({blockElement:ke(this.element),blocks:a,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=U(),r=re(this.element,n);if(!r)return;let{element:o,index:s}=r,i=at(o,n),c=this.getState(),l=[...c.properties.items??[]],a=l[s];if(!a)return;if(!E(a.text)){this.#e(s);return}let{before:u,after:f}=Cn(a,i);l.splice(s,1,u,f),this._commitState({...c,properties:{...c.properties,items:l}}),N(()=>{let p=this.element?.querySelector(`li[data-item-index="${s+1}"]`);p&&D(p,0);});}#t(t){let n=U();if(!n?.collapsed)return;let r=re(this.element,n);if(!r){let c=n.startContainer;if(!(c===this.element||this.element?.contains?.(c)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;at(o,n)===0&&(t.preventDefault(),this.#e(s));}};function ur(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!lt({component:r})||!Ne(o))return;e.preventDefault();let i=oe(n)?.element,c=e.range??U(),l=re(i,c);if(!l)return;let{index:a}=l,{blocks:u,paragraphIndex:f}=ut(o,a,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function fr(e){if(e.key!=="Backspace")return;let t=U();if(!t?.collapsed)return;let n=it(t);if(!n)return;let r=W(n),o=!E(r?.textContent),s=t.startOffset===0||ct()===0||o;if(!o||!s)return;let i=n.previousSibling;if(!i)return;let{mrakomor:c}=e,l=c._getBlockElementIndex(n),a=c._getBlockElementIndex(i);if(l<0||a<0)return;let u=c._getBlockElementState(n),f=c._getBlockElementState(i);if(!u||!lt(u)||!f||f.component!==ie)return;let p=c.getContent(),m=p[l+1];if(!ft(f,m))return;let S=c.register.blocks.getByNamespace(m.component)?.toExchangeState?.(m),y=S&&ae.appendExchangeState(f,S);y&&(e.preventDefault(),p.splice(l,1),p.splice(a,2,c.normalizeComponentState(y.state)),c._setContentState(p),pn({mrakomor:c,resultIndex:a,cursor:y.cursor,fallbackBlockElement:i,itemIndex:y.itemIndex}));}function pr(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(se.TRANSFORM_BLOCK_ELEMENT,ur),t.emitter.on(se.KEYDOWN,fr);}}}function mr(){return pr(ae)}exports.List=ae;exports.listPlugin=mr;
|
package/dist/list.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{c as List,e as listPlugin}from'./chunk-5HWTMPF4.mjs';import'./chunk-S2W6LYHT.mjs';import'./chunk-GDDVUIEH.mjs';import'./chunk-JVQ2YGII.mjs';import'./chunk-ZHOZPQZH.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-FAXIFXQK.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-P7TUN2KD.mjs';import'./chunk-7CJLTNHZ.mjs';
|