/*!
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
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../prosemirror-transform/dist/index.js"),t=require("../../prosemirror-model/dist/index.js");function n(n,r,o,l=null){let d=!1,i=r,p=r.$from.doc;if(r.depth>=2&&r.$from.node(r.depth-1).type.compatibleContent(o)&&0==r.startIndex){if(0==r.$from.index(r.depth-1))return!1;let e=p.resolve(r.start-2);i=new t.NodeRange(e,e,r.depth),r.endIndex<r.parent.childCount&&(r=new t.NodeRange(r.$from,p.resolve(r.$to.end(r.depth)),r.depth)),d=!0}let a=e.findWrapping(i,o,l,r);return!!a&&(n&&function(n,r,o,l,d){let i=t.Fragment.empty;for(let e=o.length-1;e>=0;e--)i=t.Fragment.from(o[e].type.create(o[e].attrs,i));n.step(new e.ReplaceAroundStep(r.start-(l?2:0),r.end,r.start,r.end,new t.Slice(i,0,0),o.length,!0));let p=0;for(let e=0;e<o.length;e++)o[e].type==d&&(p=e+1);let a=o.length-p,c=r.start+o.length-(l?2:0),s=r.parent;for(let t=r.startIndex,f=r.endIndex,m=!0;t<f;t++,m=!1)!m&&e.canSplit(n.doc,c,a)&&(n.split(c,a),c+=2*a),c+=s.child(t).nodeSize}(n,r,a,d,o),!0)}exports.liftListItem=function(n){return function(r,o){let{$from:l,$to:d}=r.selection,i=l.blockRange(d,e=>e.childCount>0&&e.firstChild.type==n);return!!i&&(!o||(l.node(i.depth-1).type==n?function(n,r,o,l){let d=n.tr,i=l.end,p=l.$to.end(l.depth);i<p&&(d.step(new e.ReplaceAroundStep(i-1,p,i,p,new t.Slice(t.Fragment.from(o.create(null,l.parent.copy())),1,0),1,!0)),l=new t.NodeRange(d.doc.resolve(l.$from.pos),d.doc.resolve(p),l.depth));const a=e.liftTarget(l);if(null==a)return!1;d.lift(l,a);let c=d.doc.resolve(d.mapping.map(i,-1)-1);e.canJoin(d.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&d.join(c.pos);return r(d.scrollIntoView()),!0}(r,o,n,i):function(n,r,o){let l=n.tr,d=o.parent;for(let e=o.end,t=o.endIndex-1,g=o.startIndex;t>g;t--)e-=d.child(t).nodeSize,l.delete(e-1,e+1);let i=l.doc.resolve(o.start),p=i.nodeAfter;if(l.mapping.map(o.end)!=o.start+i.nodeAfter.nodeSize)return!1;let a=0==o.startIndex,c=o.endIndex==d.childCount,s=i.node(-1),f=i.index(-1);if(!s.canReplace(f+(a?0:1),f+1,p.content.append(c?t.Fragment.empty:t.Fragment.from(d))))return!1;let m=i.pos,u=m+p.nodeSize;return l.step(new e.ReplaceAroundStep(m-(a?1:0),u+(c?1:0),m+1,u-1,new t.Slice((a?t.Fragment.empty:t.Fragment.from(d.copy(t.Fragment.empty))).append(c?t.Fragment.empty:t.Fragment.from(d.copy(t.Fragment.empty))),a?0:1,c?0:1),a?0:1)),r(l.scrollIntoView()),!0}(r,o,i)))}},exports.sinkListItem=function(n){return function(r,o){let{$from:l,$to:d}=r.selection,i=l.blockRange(d,e=>e.childCount>0&&e.firstChild.type==n);if(!i)return!1;let p=i.startIndex;if(0==p)return!1;let a=i.parent,c=a.child(p-1);if(c.type!=n)return!1;if(o){let l=c.lastChild&&c.lastChild.type==a.type,d=t.Fragment.from(l?n.create():null),p=new t.Slice(t.Fragment.from(n.create(null,t.Fragment.from(a.type.create(null,d)))),l?3:1,0),s=i.start,f=i.end;o(r.tr.step(new e.ReplaceAroundStep(s-(l?3:1),f,s,f,p,1,!0)).scrollIntoView())}return!0}},exports.wrapInList=function(e,t=null){return function(r,o){let{$from:l,$to:d}=r.selection,i=l.blockRange(d);if(!i)return!1;let p=o?r.tr:null;return!!n(p,i,e,t)&&(o&&o(p.scrollIntoView()),!0)}},exports.wrapRangeInList=n;