/*!
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 t,nodeInputRule as e,ResizableNodeView as i,mergeAttributes as n}from"../../core/dist/index.js";var s=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,r=t.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",n(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,i,n,s,r,o;const l=null!=(i=null==(e=t.attrs)?void 0:e.src)?i:"",a=null!=(s=null==(n=t.attrs)?void 0:n.alt)?s:"",d=null!=(o=null==(r=t.attrs)?void 0:r.title)?o:"";return d?`![${a}](${l} "${d}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:s}=this.options.resize;return({node:r,getPos:o,HTMLAttributes:l,editor:a})=>{const d=document.createElement("img");Object.entries(l).forEach(([t,e])=>{if(null!=e)switch(t){case"width":case"height":break;default:d.setAttribute(t,e)}}),d.src=l.src;const u=new i({element:d,editor:a,node:r,getPos:o,onResize:(t,e)=>{d.style.width=`${t}px`,d.style.height=`${e}px`},onCommit:(t,e)=>{const i=o();void 0!==i&&this.editor.chain().setNodeSelection(i).updateAttributes(this.name,{width:t,height:e}).run()},onUpdate:(t,e,i)=>t.type===r.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:!0===s}}),c=u.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",d.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[e({find:s,type:this.type,getAttributes:t=>{const[,,e,i,n]=t;return{src:i,alt:e,title:n}}})]}}),o=r;export{r as Image,o as default,s as inputRegex};