/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{Node as e,nodeInputRule as t,canInsertNode as o,isNodeSelection as r,mergeAttributes as n}from"../../core/dist/index.js";import{TextSelection as s,NodeSelection as a}from"../../../prosemirror-state/dist/index.js";var i=e.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",n(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!o(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$to:i}=n,d=e();return r(n)?d.insertContentAt(i.pos,{type:this.name}):d.insertContent({type:this.name}),d.command(({state:e,tr:t,dispatch:o})=>{if(o){const{$to:o}=t.selection,r=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?t.setSelection(s.create(t.doc,o.pos+1)):o.nodeAfter.isBlock?t.setSelection(a.create(t.doc,o.pos)):t.setSelection(s.create(t.doc,o.pos));else{const n=e.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,a=null==n?void 0:n.create();a&&(t.insert(r,a),t.setSelection(s.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[t({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});export{i as HorizontalRule};