/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@platejs/utils@52.3.21/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{n as NODES,r as STYLE_KEYS,t as KEYS}from"./plate-keys-C2YNmTqZ.js";import{createSlatePlugin,createTSlatePlugin}from"@platejs/core";import{ElementApi,NodeApi,PathApi,TextApi,queryNode}from"@platejs/slate";const ExitBreakPlugin=createSlatePlugin({key:KEYS.exitBreak,editOnly:!0}).extendTransforms((({editor:e})=>({insert:t=>e.tf.insertExitBreak(t),insertBefore:t=>e.tf.insertExitBreak({...t,reverse:!0})}))),withNormalizeTypes=({editor:e,getOptions:t,tf:{normalizeNode:i}})=>({transforms:{normalizeNode([r,n]){const{rules:o,onError:l}=t();if(0!==n.length||!o.some((({path:t,strictType:i,type:r})=>{const n=NodeApi.get(e,t);if(n){if(i&&ElementApi.isElement(n)&&n.type!==i){const{children:r,...n}=e.api.create.block({type:i});return e.tf.setNodes(n,{at:t}),!0}}else try{return e.tf.insertNodes(e.api.create.block({type:i??r}),{at:t}),!0}catch(e){l?.(e)}return!1})))return i([r,n])}}}),NormalizeTypesPlugin=createTSlatePlugin({key:KEYS.normalizeTypes,options:{rules:[]}}).overrideEditor(withNormalizeTypes),SingleBlockPlugin=createSlatePlugin({key:KEYS.singleBlock,override:{enabled:{[KEYS.trailingBlock]:!1}}}).overrideEditor((({editor:e,tf:{normalizeNode:t}})=>({transforms:{insertBreak(){e.tf.insertSoftBreak()},normalizeNode(i){const[r,n]=i;0===n.length&&e.children.length>1?e.tf.withoutNormalizing((()=>{for(;e.children.length>1;)e.tf.insertText("\n",{at:e.api.start([1])}),e.tf.mergeNodes({at:[1],match:(e,t)=>1===t.length})})):t(i)}}}))),SingleLinePlugin=createSlatePlugin({key:KEYS.singleLine,override:{enabled:{[KEYS.trailingBlock]:!1}}}).overrideEditor((({editor:e,tf:{normalizeNode:t}})=>({transforms:{insertBreak(){},insertSoftBreak(){},normalizeNode(i){const[r,n]=i;if(TextApi.isText(r)){const t=r.text.replace(/[\r\n\u2028\u2029]/g,"");if(t!==r.text)return void e.tf.insertText(t,{at:n})}0===n.length&&e.children.length>1?e.tf.withoutNormalizing((()=>{for(;e.children.length>1;)e.tf.mergeNodes({at:[1],match:(e,t)=>1===t.length})})):t(i)}}}))),withTrailingBlock=({editor:e,getOptions:t,tf:{normalizeNode:i}})=>({transforms:{normalizeNode([r,n]){const{level:o,type:l,...a}=t();if(0===n.length){const t=e.api.last([],{level:o}),i=t?.[0];if(!i||i.type!==l&&queryNode(t,a)){const i=t?PathApi.next(t[1]):[0];return void e.tf.insertNodes(e.api.create.block({type:l},i),{at:i})}}return i([r,n])}}}),TrailingBlockPlugin=createTSlatePlugin({key:KEYS.trailingBlock,options:{level:0}}).overrideEditor(withTrailingBlock).extend((({editor:e})=>({options:{type:e.getType(KEYS.p)}})));export{ExitBreakPlugin,KEYS,NODES,NormalizeTypesPlugin,STYLE_KEYS,SingleBlockPlugin,SingleLinePlugin,TrailingBlockPlugin,withNormalizeTypes,withTrailingBlock};
//# sourceMappingURL=/sm/aa4e65b662c919f0fcc974d201df41ae768adedfca503b86bf19d76bbadc4831.map