@steedos-labs/plugin-workflow 3.0.104 → 3.0.106
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/designer/dist/amis-renderer/amis-renderer.js +1 -1
- package/designer/dist/assets/{index-CTmOPK1Y.js → index-B2ycAzXC.js} +1 -1
- package/designer/dist/index.html +1 -1
- package/main/default/client/flow2_render.client.js +1 -1
- package/main/default/objects/instances/buttons/instance_delete.button.yml +1 -1
- package/main/default/objects/instances/buttons/instance_retrieve.button.yml +31 -4
- package/main/default/objects/instances/buttons/instance_save.button.yml +1 -1
- package/main/default/objects/instances/buttons/instance_submit.button.yml +1 -1
- package/main/default/routes/api_workflow_remove.router.js +6 -1
- package/main/default/routes/api_workflow_retrieve.router.js +9 -2
- package/main/default/routes/api_workflow_v2_remove.router.js +6 -1
- package/main/default/test/test_remove_guards.js +231 -0
- package/main/default/test/test_retrieve_guards.js +308 -0
- package/package.json +3 -1
- package/public/amis-renderer/amis-renderer.js +1 -1
|
@@ -750,7 +750,7 @@ ${g.slice(c+2)}`,h+=1;else break}t.push({indent:c,number:parseInt(s,10),content:
|
|
|
750
750
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{const t=e.match(/^(\s*)(\d+)\.\s+/),n=t?.index;return n!==void 0?n:-1},tokenize:(e,t,n)=>{var r;const o=e.split(`
|
|
751
751
|
`),[a,i]=O4e(o);if(a.length===0)return;const s=VG(a,0,n);return s.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:s,raw:o.slice(0,i).join(`
|
|
752
752
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(R4e,this.editor.getAttributes(CF)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=f0({find:SF,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=f0({find:SF,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(CF)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),j4e=/^\s*(\[([( |x])?\])\s$/,T4e=rl.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",ea(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{const n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){const r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;const o=`- [${(n=e.attrs)!=null&&n.checked?"x":" "}] `;return c3(e,t,o)},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const o=document.createElement("li"),a=document.createElement("label"),i=document.createElement("span"),s=document.createElement("input"),l=document.createElement("div"),c=h=>{var v,g;s.ariaLabel=((g=(v=this.options.a11y)==null?void 0:v.checkboxLabel)==null?void 0:g.call(v,h,s.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};c(e),a.contentEditable="false",s.type="checkbox",s.addEventListener("mousedown",h=>h.preventDefault()),s.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}const{checked:v}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const b=n();if(typeof b!="number")return!1;const x=g.doc.nodeAt(b);return g.setNodeMarkup(b,void 0,{...x?.attrs,checked:v}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,v)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,v])=>{o.setAttribute(h,v)}),o.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,i),o.append(a,l),Object.entries(t).forEach(([h,v])=>{o.setAttribute(h,v)});let u=new Set(Object.keys(t));return{dom:o,contentDOM:l,update:h=>{if(h.type!==this.type)return!1;o.dataset.checked=h.attrs.checked,s.checked=h.attrs.checked,c(h);const v=r.extensionManager.attributes,g=w1(h,v),b=new Set(Object.keys(g)),x=this.options.HTMLAttributes;return u.forEach(y=>{b.has(y)||(y in x?o.setAttribute(y,x[y]):o.removeAttribute(y))}),Object.entries(g).forEach(([y,N])=>{N==null?y in x?o.setAttribute(y,x[y]):o.removeAttribute(y):o.setAttribute(y,N)}),u=b,!0}}}},addInputRules(){return[f0({find:j4e,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),I4e=rl.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",ea(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
753
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){const r=a=>{const i=pT(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,l)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:l}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(a)},o=pT(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,i)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});po.create({name:"listKit",addExtensions(){const e=[];return this.options.bulletList!==!1&&e.push(DG.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(AG.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(HG.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(UG.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(T4e.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(I4e.configure(this.options.taskList)),e}});var NF=" ",D4e=" ",A4e=rl.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",ea(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);const r=t.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===NF||r[0].text===D4e)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t)=>{if(!e)return"";const n=Array.isArray(e.content)?e.content:[];return n.length===0?NF:t.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),P4e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,L4e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z4e=md.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",ea(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[fm({find:P4e,type:this.type})]},addPasteRules(){return[Zf({find:L4e,type:this.type})]}}),F4e=rl.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),WG=md.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",ea(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!o)return;const a=o[2].trim();return{type:"underline",raw:o[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),B4e=WG;function H4e(e={}){return new Wo({view(t){return new V4e(t,e)}})}class V4e{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let a=i=>{this[o](i)};return t.dom.addEventListener(o,a),{name:o,handler:a}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,o=this.editorView.dom,a=o.getBoundingClientRect(),i=a.width/o.offsetWidth,s=a.height/o.offsetHeight;if(n){let h=t.nodeBefore,v=t.nodeAfter;if(h||v){let g=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(g){let b=g.getBoundingClientRect(),x=h?b.bottom:b.top;h&&v&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*s;r={left:b.left,right:b.right,top:x-y,bottom:x+y}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),v=this.width/2*i;r={left:h.left-v,right:h.left+v,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),v=h.width/l.offsetWidth,g=h.height/l.offsetHeight;c=h.left-l.scrollLeft*v,u=h.top-l.scrollTop*g}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/s+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/s+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,a=typeof o=="function"?o(this.editorView,n,t):o;if(n&&!a){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let s=LK(this.editorView.state.doc,i,this.editorView.dragging.slice);s!=null&&(i=s)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Zo extends vr{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return Zo.valid(r)?new Zo(r):vr.near(r)}content(){return xn.empty}eq(t){return t instanceof Zo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zo(t.resolve(n.pos))}getBookmark(){return new w3(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!U4e(t)||!W4e(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&Zo.valid(t))return t;let o=t.pos,a=null;for(let i=t.depth;;i--){let s=t.node(i);if(n>0?t.indexAfter(i)<s.childCount:t.index(i)>0){a=s.child(n>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0)return null;o+=n;let l=t.doc.resolve(o);if(Zo.valid(l))return l}for(;;){let i=n>0?a.firstChild:a.lastChild;if(!i){if(a.isAtom&&!a.isText&&!An.isSelectable(a)){t=t.doc.resolve(o+a.nodeSize*n),r=!1;continue e}break}a=i,o+=n;let s=t.doc.resolve(o);if(Zo.valid(s))return s}return null}}}Zo.prototype.visible=!1;Zo.findFrom=Zo.findGapCursorFrom;vr.jsonID("gapcursor",Zo);class w3{constructor(t){this.pos=t}map(t){return new w3(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Zo.valid(n)?new Zo(n):vr.near(n)}}function qG(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function U4e(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||qG(o.type))return!0;if(o.inlineContent)return!1}}return!0}function W4e(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||qG(o.type))return!0;if(o.inlineContent)return!1}}return!0}function q4e(){return new Wo({props:{decorations:X4e,createSelectionBetween(e,t,n){return t.pos==n.pos&&Zo.valid(n)?new Zo(n):null},handleClick:Y4e,handleKeyDown:K4e,handleDOMEvents:{beforeinput:G4e}}})}const K4e=zY({ArrowLeft:u2("horiz",-1),ArrowRight:u2("horiz",1),ArrowUp:u2("vert",-1),ArrowDown:u2("vert",1)});function u2(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,a){let i=r.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof nr){if(!a.endOfTextblock(n)||s.depth==0)return!1;l=!1,s=r.doc.resolve(t>0?s.after():s.before())}let c=Zo.findGapCursorFrom(s,t,l);return c?(o&&o(r.tr.setSelection(new Zo(c))),!0):!1}}function Y4e(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Zo.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&An.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Zo(r))),!0)}function G4e(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Zo))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=Zt.empty;for(let i=r.length-1;i>=0;i--)o=Zt.from(r[i].createAndFill(null,o));let a=e.state.tr.replace(n.pos,n.pos,new xn(o,0,0));return a.setSelection(nr.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function X4e(e){if(!(e.selection instanceof Zo))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ho.create(e.doc,[Wi.widget(e.selection.head,t,{key:"gapcursor"})])}var BE=200,Aa=function(){};Aa.prototype.append=function(t){return t.length?(t=Aa.from(t),!this.length&&t||t.length<BE&&this.leafAppend(t)||this.length<BE&&t.leafPrepend(this)||this.appendInner(t)):this};Aa.prototype.prepend=function(t){return t.length?Aa.from(t).append(this):this};Aa.prototype.appendInner=function(t){return new J4e(this,t)};Aa.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Aa.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};Aa.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Aa.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};Aa.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(a,i){return o.push(t(a,i))},n,r),o};Aa.from=function(t){return t instanceof Aa?t:t&&t.length?new KG(t):Aa.empty};var KG=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,a){return o==0&&a==this.length?this:new t(this.values.slice(o,a))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,a,i,s){for(var l=a;l<i;l++)if(o(this.values[l],s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(o,a,i,s){for(var l=a-1;l>=i;l--)if(o(this.values[l],s+l)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=BE)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=BE)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(Aa);Aa.empty=new KG([]);var J4e=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,a,i){var s=this.left.length;if(o<s&&this.left.forEachInner(r,o,Math.min(a,s),i)===!1||a>s&&this.right.forEachInner(r,Math.max(o-s,0),Math.min(this.length,a)-s,i+s)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,a,i){var s=this.left.length;if(o>s&&this.right.forEachInvertedInner(r,o-s,Math.max(a,s)-s,i+s)===!1||a<s&&this.left.forEachInvertedInner(r,Math.min(o,s),a,i)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var a=this.left.length;return o<=a?this.left.slice(r,o):r>=a?this.right.slice(r-a,o-a):this.left.slice(r,a).append(this.right.slice(0,o-a))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(Aa);const Z4e=500;class nc{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,a;n&&(o=this.remapping(r,this.items.length),a=o.maps.length);let i=t.tr,s,l,c=[],u=[];return this.items.forEach((h,v)=>{if(!h.step){o||(o=this.remapping(r,v+1),a=o.maps.length),a--,u.push(h);return}if(o){u.push(new Qc(h.map));let g=h.step.map(o.slice(a)),b;g&&i.maybeStep(g).doc&&(b=i.mapping.maps[i.mapping.maps.length-1],c.push(new Qc(b,void 0,void 0,c.length+u.length))),a--,b&&o.appendMap(b,a)}else i.maybeStep(h.step);if(h.selection)return s=o?h.selection.map(o.slice(a)):h.selection,l=new nc(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:s}}addTransform(t,n,r,o){let a=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let u=0;u<t.steps.length;u++){let h=t.steps[u].invert(t.docs[u]),v=new Qc(t.mapping.maps[u],h,n),g;(g=l&&l.merge(v))&&(v=g,u?a.pop():s=s.slice(0,s.length-1)),a.push(v),n&&(i++,n=void 0),o||(l=v)}let c=i-r.depth;return c>ePe&&(s=Q4e(s,c),i-=c),new nc(s.append(a),i)}remapping(t,n){let r=new m1;return this.items.forEach((o,a)=>{let i=o.mirrorOffset!=null&&a-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},t,n),r}addMaps(t){return this.eventCount==0?this:new nc(this.items.append(t.map(n=>new Qc(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),a=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach(v=>{v.selection&&s--},o);let l=n;this.items.forEach(v=>{let g=a.getMirror(--l);if(g==null)return;i=Math.min(i,g);let b=a.maps[g];if(v.step){let x=t.steps[g].invert(t.docs[g]),y=v.selection&&v.selection.map(a.slice(l+1,g));y&&s++,r.push(new Qc(b,x,y))}else r.push(new Qc(b))},o);let c=[];for(let v=n;v<i;v++)c.push(new Qc(a.maps[v]));let u=this.items.slice(0,o).append(c).append(r),h=new nc(u,s);return h.emptyItemCount()>Z4e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,o=[],a=0;return this.items.forEach((i,s)=>{if(s>=t)o.push(i),i.selection&&a++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&a++;let h=new Qc(c.invert(),l,u),v,g=o.length-1;(v=o.length&&o[g].merge(h))?o[g]=v:o.push(h)}}else i.map&&r--},this.items.length,0),new nc(Aa.from(o.reverse()),a)}}nc.empty=new nc(Aa.empty,0);function Q4e(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}class Qc{constructor(t,n,r,o){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Qc(n.getMap().invert(),n,this.selection)}}}class _f{constructor(t,n,r,o,a){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=a}}const ePe=20;function tPe(e,t,n,r){let o=n.getMeta(qp),a;if(o)return o.historyState;n.getMeta(oPe)&&(e=new _f(e.done,e.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(i&&i.getMeta(qp))return i.getMeta(qp).redo?new _f(e.done.addTransform(n,void 0,r,J2(t)),e.undone,EF(n.mapping.maps),e.prevTime,e.prevComposition):new _f(e.done,e.undone.addTransform(n,void 0,r,J2(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let s=n.getMeta("composition"),l=e.prevTime==0||!i&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!nPe(n,e.prevRanges)),c=i?TM(e.prevRanges,n.mapping):EF(n.mapping.maps);return new _f(e.done.addTransform(n,l?t.selection.getBookmark():void 0,r,J2(t)),nc.empty,c,n.time,s??e.prevComposition)}else return(a=n.getMeta("rebased"))?new _f(e.done.rebased(n,a),e.undone.rebased(n,a),TM(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new _f(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),TM(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function nPe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,o)=>{for(let a=0;a<t.length;a+=2)r<=t[a+1]&&o>=t[a]&&(n=!0)}),n}function EF(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,o,a,i)=>t.push(a,i));return t}function TM(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),a=t.map(e[r+1],-1);o<=a&&n.push(o,a)}return n}function rPe(e,t,n){let r=J2(t),o=qp.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let i=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),o,r),l=new _f(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(i).setMeta(qp,{redo:n,historyState:l})}let IM=!1,$F=null;function J2(e){let t=e.plugins;if($F!=t){IM=!1,$F=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){IM=!0;break}}return IM}const qp=new _a("history"),oPe=new _a("closeHistory");function aPe(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Wo({key:qp,state:{init(){return new _f(nc.empty,nc.empty,null,0,-1)},apply(t,n,r){return tPe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?GG:r=="historyRedo"?XG:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function YG(e,t){return(n,r)=>{let o=qp.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(r){let a=rPe(o,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}const GG=YG(!1,!0),XG=YG(!0,!0);po.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){const r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=e=>{const t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Wo({key:new _a("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const o=this.options.limit;if(o==null||o===0){e=!0;return}const a=this.storage.characters({node:r.doc});if(a>o){const i=a-o,s=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(s,l);return e=!0,c}e=!0},filterTransaction:(t,n)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),a=this.storage.characters({node:t.doc});if(a<=r||o>r&&a>r&&a<=o)return!0;if(o>r&&a>r&&a>o||!t.getMeta("paste"))return!1;const s=t.selection.$head.pos,l=a-r,c=s-l,u=s;return t.deleteRange(c,u),!(this.storage.characters({node:t.doc})>r)}})]}});var iPe=po.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[H4e(this.options)]}});po.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Wo({key:new _a("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,a=[];if(!n||!r)return Ho.create(e,[]);let i=0;this.options.mode==="deepest"&&e.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let s=0;return e.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(s+=1,this.options.mode==="deepest"&&i-s>0||this.options.mode==="shallowest"&&s>1)return this.options.mode==="deepest";a.push(Wi.node(c,c+l.nodeSize,{class:this.options.className}))}),Ho.create(e,a)}}})]}});var sPe=po.create({name:"gapCursor",addProseMirrorPlugins(){return[q4e()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=so(Mn(e,"allowGapCursor",n)))!=null?t:null}}}),_F="placeholder";function lPe(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var cPe=po.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:_F,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const e=this.options.dataAttribute?`data-${lPe(this.options.dataAttribute)}`:`data-${_F}`;return[new Wo({key:new _a("placeholder"),props:{decorations:({doc:t,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,a=[];if(!r)return null;const i=this.editor.isEmpty;return t.descendants((s,l)=>{const c=o>=l&&o<=l+s.nodeSize,u=!s.isLeaf&&m_(s);if((c||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];i&&h.push(this.options.emptyEditorClass);const v=Wi.node(l,l+s.nodeSize,{class:h.join(" "),[e]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:c}):this.options.placeholder});a.push(v)}return this.options.includeChildren}),Ho.create(t,a)}}})]}});po.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new Wo({key:new _a("selection"),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||tG(n.selection)||e.view.dragging?null:Ho.create(n.doc,[Wi.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function kF({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var uPe=po.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;const t=new _a(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new Wo({key:t,appendTransaction:(o,a,i)=>{const{doc:s,tr:l,schema:c}=i,u=t.getState(i),h=s.content.size,v=c.nodes[n];if(u)return l.insert(h,v.create())},state:{init:(o,a)=>{const i=a.tr.doc.lastChild;return!kF({node:i,types:r})},apply:(o,a)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return a;const i=o.doc.lastChild;return!kF({node:i,types:r})}}})]}}),dPe=po.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>GG(e,t),redo:()=>({state:e,dispatch:t})=>XG(e,t)}},addProseMirrorPlugins(){return[aPe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),fPe=po.create({name:"starterKit",addExtensions(){var e,t,n,r;const o=[];return this.options.bold!==!1&&o.push(AAe.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(RAe.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(DG.configure(this.options.bulletList)),this.options.code!==!1&&o.push(zAe.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(HAe.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(VAe.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(iPe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(sPe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(UAe.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(WAe.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(dPe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(qAe.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(JAe.configure(this.options.italic)),this.options.listItem!==!1&&o.push(AG.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(HG.configure((e=this.options)==null?void 0:e.listKeymap)),this.options.link!==!1&&o.push(IG.configure((t=this.options)==null?void 0:t.link)),this.options.orderedList!==!1&&o.push(UG.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(A4e.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(z4e.configure(this.options.strike)),this.options.text!==!1&&o.push(F4e.configure(this.options.text)),this.options.underline!==!1&&o.push(WG.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(uPe.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),hPe=fPe,pPe=po.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),mPe=pPe,gPe=cPe,vPe=20,JG=(e,t=0)=>{const n=[];return!e.children.length||t>vPe||Array.from(e.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...JG(r,t+1))}),n},bPe=e=>{if(!e.children.length)return;const t=JG(e);t&&t.forEach(n=>{var r,o;const a=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${a}`)})},ZG=md.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&bPe(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",ea(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(a=>!!a))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),yPe=po.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const a=r[o].split(":");if(a.length>=2){const i=a[0].trim().toLowerCase(),s=a.slice(1).join(":").trim();if(i==="background-color")return s.replace(/['"]+/g,"")}}}return(t=e.style.backgroundColor)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),QG=po.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const a=r[o].split(":");if(a.length>=2){const i=a[0].trim().toLowerCase(),s=a.slice(1).join(":").trim();if(i==="color")return s.replace(/['"]+/g,"")}}}return(t=e.style.color)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),xPe=po.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),wPe=po.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),CPe=po.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});po.create({name:"textStyleKit",addExtensions(){const e=[];return this.options.backgroundColor!==!1&&e.push(yPe.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(QG.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(xPe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(wPe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(CPe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(ZG.configure(this.options.textStyle)),e}});var SPe=QG,NPe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,EPe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,$Pe=md.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",ea(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){const o=/^(==)([^=]+)(==)/.exec(e);if(o){const a=o[2].trim(),i=n.inlineTokens(a);return{type:"highlight",raw:o[0],text:a,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[fm({find:NPe,type:this.type})]},addPasteRules(){return[Zf({find:EPe,type:this.type})]}}),_Pe=$Pe;function Hi({onClick:e,active:t,disabled:n,title:r,children:o}){return p.jsx("button",{type:"button",onMouseDown:a=>{a.preventDefault(),e()},disabled:n,title:r,className:`p-1 rounded hover:bg-gray-200 smooth-transition ${n?"text-gray-300 cursor-not-allowed":t?"bg-gray-200 text-indigo-600":"text-gray-500"}`,children:o})}const kPe=["#000000","#434343","#666666","#999999","#cccccc","#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#3b82f6","#6366f1","#8b5cf6","#ec4899","#f43f5e","#991b1b","#9a3412","#854d0e","#166534","#115e59","#1e40af","#3730a3","#5b21b6","#9d174d","#be123c"];function OF({currentColor:e,onSelect:t,icon:n,title:r}){const[o,a]=f.useState(!1),[i,s]=f.useState({top:0,left:0}),l=f.useRef(null),c=f.useRef(null);f.useEffect(()=>{if(!o)return;const h=v=>{l.current&&!l.current.contains(v.target)&&c.current&&!c.current.contains(v.target)&&a(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]);const u=f.useCallback(h=>{if(h.preventDefault(),!o&&l.current){const v=l.current.getBoundingClientRect();s({top:v.bottom+4,left:v.left})}a(v=>!v)},[o]);return p.jsxs("div",{className:"relative",children:[p.jsxs("button",{ref:l,type:"button",title:r,className:"flex items-center p-1 rounded hover:bg-gray-200 smooth-transition text-gray-500",onMouseDown:u,children:[p.jsxs("span",{className:"relative",children:[n,e&&p.jsx("span",{className:"absolute -bottom-0.5 left-0 right-0 h-[3px] rounded-sm",style:{backgroundColor:e}})]}),p.jsx(qi,{className:"w-2.5 h-2.5 ml-0.5"})]}),o&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsxs("div",{ref:c,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg p-2.5",style:{top:i.top,left:i.left},children:[p.jsx("div",{className:"flex flex-wrap gap-1.5",style:{width:164},children:kPe.map(h=>p.jsx("button",{type:"button",title:h,className:`w-7 h-7 rounded-md border-2 smooth-transition flex items-center justify-center ${h===e?"border-gray-800 shadow-sm scale-110":"border-transparent hover:border-gray-300"}`,style:{backgroundColor:h},onMouseDown:v=>{v.preventDefault(),t(h),a(!1)}},h))}),p.jsx("button",{type:"button",className:"w-full mt-2 text-[11px] text-gray-500 hover:text-gray-700 py-1 rounded-md hover:bg-gray-100 smooth-transition",onMouseDown:h=>{h.preventDefault(),t(null),a(!1)},children:"清除颜色"})]})}),document.body)]})}function OPe({editor:e}){const[t,n]=f.useState(!1),[r,o]=f.useState({top:0,left:0}),a=f.useRef(null),i=f.useRef(null);f.useEffect(()=>{if(!t)return;const u=h=>{a.current&&!a.current.contains(h.target)&&i.current&&!i.current.contains(h.target)&&n(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[t]);const s=f.useCallback(u=>{if(u.preventDefault(),!t&&a.current){const h=a.current.getBoundingClientRect();o({top:h.bottom+4,left:h.left})}n(h=>!h)},[t]),l=[{label:"正文",active:!e.isActive("heading"),action:()=>e.chain().focus().setParagraph().run()},{label:"标题 1",active:e.isActive("heading",{level:1}),action:()=>e.chain().focus().toggleHeading({level:1}).run(),className:"text-[16px] font-bold"},{label:"标题 2",active:e.isActive("heading",{level:2}),action:()=>e.chain().focus().toggleHeading({level:2}).run(),className:"text-[15px] font-bold"},{label:"标题 3",active:e.isActive("heading",{level:3}),action:()=>e.chain().focus().toggleHeading({level:3}).run(),className:"text-[14px] font-semibold"}],c=l.find(u=>u.active)?.label||"正文";return p.jsxs("div",{className:"relative",children:[p.jsxs("button",{ref:a,type:"button",className:"flex items-center gap-0.5 px-1.5 py-1 rounded hover:bg-gray-200 smooth-transition text-gray-600 text-[12px] font-medium min-w-[56px]",onMouseDown:s,children:[c,p.jsx(qi,{className:"w-3 h-3"})]}),t&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsx("div",{ref:i,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg py-1 min-w-[120px]",style:{top:r.top,left:r.left},children:l.map(u=>p.jsx("button",{type:"button",className:`w-full text-left px-3 py-1.5 hover:bg-gray-100 smooth-transition ${u.active?"bg-indigo-50 text-indigo-600":"text-gray-700"} ${u.className||"text-[13px]"}`,onMouseDown:h=>{h.preventDefault(),u.action(),n(!1)},children:u.label},u.label))})}),document.body)]})}function MPe({editor:e,iconSize:t}){const[n,r]=f.useState(!1),[o,a]=f.useState(""),[i,s]=f.useState({top:0,left:0}),l=f.useRef(null),c=f.useRef(null),u=f.useRef(null);f.useEffect(()=>{if(!n)return;const g=b=>{l.current&&!l.current.contains(b.target)&&c.current&&!c.current.contains(b.target)&&r(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n]);const h=()=>{const g=e.getAttributes("link").href||"";if(a(g||"https://"),l.current){const b=l.current.getBoundingClientRect();s({top:b.bottom+4,left:Math.max(8,b.right-320)})}r(!n),setTimeout(()=>u.current?.focus(),50)},v=()=>{if(r(!1),!o||o==="https://"){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:o}).run()};return p.jsxs("div",{className:"relative",children:[p.jsx("button",{ref:l,type:"button",title:"插入链接",className:`p-1 rounded hover:bg-gray-200 smooth-transition ${e.isActive("link")?"bg-gray-200 text-indigo-600":"text-gray-500"}`,onMouseDown:g=>{g.preventDefault(),h()},children:p.jsx(eH,{className:t})}),n&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsxs("div",{ref:c,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg p-3 w-[320px]",style:{top:i.top,left:i.left},onMouseDown:g=>g.stopPropagation(),children:[p.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"链接地址"}),p.jsx(_s,{ref:u,value:o,onChange:g=>a(g.target.value),placeholder:"https://",size:"small",onPressEnter:v}),p.jsxs("div",{className:"flex justify-end gap-1.5 mt-2",children:[p.jsx("button",{type:"button",className:"px-2.5 py-1 text-[12px] text-gray-500 hover:text-gray-700 rounded hover:bg-gray-100 smooth-transition",onMouseDown:g=>{g.preventDefault(),r(!1)},children:"取消"}),p.jsx("button",{type:"button",className:"px-2.5 py-1 text-[12px] text-white bg-indigo-500 hover:bg-indigo-600 rounded smooth-transition",onMouseDown:g=>{g.preventDefault(),v()},children:"确定"})]})]})}),document.body)]})}function RPe({editor:e}){const t="w-3.5 h-3.5",[,n]=f.useState(0);f.useEffect(()=>{const a=()=>n(i=>i+1);return e.on("transaction",a),()=>{e.off("transaction",a)}},[e]);const r=e.getAttributes("textStyle").color,o=e.getAttributes("highlight").color;return p.jsx(p.Fragment,{children:p.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-gray-50/80",children:[p.jsx(OPe,{editor:e}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleBold().run(),active:e.isActive("bold"),title:"加粗",children:p.jsx(WB,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleItalic().run(),active:e.isActive("italic"),title:"斜体",children:p.jsx(Cae,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleUnderline().run(),active:e.isActive("underline"),title:"下划线",children:p.jsx(Uie,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleStrike().run(),active:e.isActive("strike"),title:"删除线",children:p.jsx(Oie,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(OF,{currentColor:r,onSelect:a=>{a?e.chain().focus().setColor(a).run():e.chain().focus().unsetColor().run()},icon:p.jsx(nie,{className:t}),title:"字体颜色"}),p.jsx(OF,{currentColor:o,onSelect:a=>{a?e.chain().focus().setHighlight({color:a}).run():e.chain().focus().unsetHighlight().run()},icon:p.jsx(vae,{className:t}),title:"背景色"}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleBulletList().run(),active:e.isActive("bulletList"),title:"无序列表",children:p.jsx(fN,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleOrderedList().run(),active:e.isActive("orderedList"),title:"有序列表",children:p.jsx(tH,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().sinkListItem("listItem").run(),disabled:!e.can().sinkListItem("listItem"),title:"增加缩进",children:p.jsx(Tae,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().liftListItem("listItem").run(),disabled:!e.can().liftListItem("listItem"),title:"减少缩进",children:p.jsx(Rae,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("left").run(),active:e.isActive({textAlign:"left"}),title:"左对齐",children:p.jsx(iI,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("center").run(),active:e.isActive({textAlign:"center"}),title:"居中",children:p.jsx(cR,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("right").run(),active:e.isActive({textAlign:"right"}),title:"右对齐",children:p.jsx(nH,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(MPe,{editor:e,iconSize:t}),p.jsx(Hi,{onClick:()=>e.chain().focus().unsetLink().run(),disabled:!e.isActive("link"),title:"取消链接",children:p.jsx(Kie,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().unsetAllMarks().clearNodes().run(),title:"清除格式",children:p.jsx(hie,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().undo(),title:"撤销",children:p.jsx(sI,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().redo(),title:"重做",children:p.jsx(rI,{className:t})})]})})}function C3({value:e,onChange:t,readonly:n=!1,placeholder:r="请输入内容...",isTableMode:o=!1,hasError:a=!1,minHeight:i=120}){const s=$Ae({extensions:[hPe,B4e,ZG,SPe,_Pe.configure({multicolor:!0}),C4e.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),mPe.configure({types:["heading","paragraph"]}),gPe.configure({placeholder:r})],content:e||"",editable:!n,onUpdate:({editor:c})=>{t(c.getHTML())}});if(f.useEffect(()=>{s?.setEditable(!n)},[s,n]),f.useEffect(()=>{if(!s||s.isFocused)return;const c=s.getHTML(),u=c==="<p></p>"?"":c,h=e||"";u!==h&&s.commands.setContent(h,{emitUpdate:!1})},[s,e]),n){const c=o?"w-full h-full px-2.5 py-2 text-[13px] text-gray-700 min-h-[34px]":"w-full border border-gray-200 rounded-md px-3 py-2 text-[13px] text-gray-700 min-h-[38px]";return p.jsx("div",{className:`${c} rich-text-content`,dangerouslySetInnerHTML:{__html:e||""}})}const l=o?`w-full ${a?"bg-red-100/90":"bg-white"}`:`w-full border rounded-md ${a?"border-red-200 bg-red-50":"border-gray-300 bg-amber-50/80 focus-within:border-indigo-400 focus-within:ring-2 focus-within:ring-indigo-100"}`;return p.jsxs("div",{className:l,children:[s&&p.jsx(RPe,{editor:s}),p.jsx(xG,{editor:s,className:"tiptap-editor rich-text-content overflow-hidden rounded-b-md",style:{minHeight:`${i}px`}})]})}function jPe(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:!0}function TPe(e,t){if(!e)return;const n=typeof e=="string"?e:JSON.stringify(e);function r(a){const i=a.indexOf(".");if(i!==-1){const l=a.slice(0,i),c=a.slice(i+1),u=t[l];if(!u)return{value:"",isArray:!1};try{const h=typeof u=="string"?JSON.parse(u):u;if(!Array.isArray(h))return{value:"",isArray:!1};const v=h.map(g=>g[c]).filter(g=>g!=null&&g!=="");return{value:JSON.stringify(v),isArray:!0}}catch{return{value:"",isArray:!1}}}const s=t[a]??"";return Array.isArray(s)?{value:JSON.stringify(s),isArray:!0}:{value:String(s),isArray:!1}}let o=n.replace(/"\{([^{}]+)\}"/g,(a,i)=>{const s=r(i);return s.isArray?s.value:`"${s.value}"`});return o=o.replace(/\{([^{}]+)\}/g,(a,i)=>{const s=r(i);return s.isArray,s.value}),o}function IPe(e,t,n,r){const o={};for(const a of t)!a.sourceField||!a.targetField||r?.skipExistingTargets&&jPe(n?.[a.targetField])||e[a.sourceField]!=null&&(o[a.targetField]=_x(e[a.sourceField]));return o}function DPe(e){return typeof e=="string"?e:e&&typeof e=="object"&&"field"in e?String(e.field):String(e)}function APe({field:e,value:t,onChange:n,onFillFields:r,isTableMode:o=!1,subTableCellMode:a=!1,hasError:i=!1,formValues:s}){const[l,c]=f.useState(!1),u=e.reference_to||"",h=!!e.pickerMultiple,v=(e.lookupDisplayFields||["name"]).map(DPe),g=v[0]||"name",b=e.lookupSortField||"",x=e.lookupSortOrder||"asc",y=f.useMemo(()=>!h&&e.lookupFillRules||[],[h,e.lookupFillRules]),N=f.useMemo(()=>TPe(e.lookupFilters,s||{}),[e.lookupFilters,s]),E=f.useMemo(()=>bN(t),[t]),C=f.useCallback((A,P,z)=>{if(!u||h||y.length===0||!r||!A)return;const V=B=>{const U=IPe(B,y,s,z);Object.keys(U).length>0&&r(U)},T=y.map(B=>B.sourceField).filter(Boolean);if(P&&T.every(B=>B in P)){V(P);return}const F=JSON.stringify(["_id","in",[A]]),I=["_id",...T].join(",");sc(u,{filters:F,fields:I,top:1}).then(({data:B})=>{B.length>0&&V(B[0])})},[u,h,y,r,s]),_=f.useRef(N);f.useEffect(()=>{const A=_.current;if(_.current=N,o||A===void 0||A===N||E.length===0||!u)return;const P=JSON.stringify(["_id","in",E]),z=N?JSON.stringify([JSON.parse(P),"and",JSON.parse(N)]):P;sc(u,{filters:z,fields:"_id",top:E.length}).then(({data:V})=>{const T=new Set(V.map(I=>I._id)),F=E.filter(I=>T.has(I));F.length!==E.length&&n($v(F,h))})},[N]);const[$,M]=f.useState(new Map);f.useEffect(()=>{if(!u||E.length===0)return;const A=E.filter(z=>!$.has(z));if(A.length===0)return;const P=JSON.stringify(["_id","in",A]);sc(u,{filters:P,fields:`_id,${g}`,top:A.length}).then(({data:z})=>{M(V=>{const T=new Map(V);for(const F of z)T.set(F._id,F[g]||F._id);return T})})},[u,E.join(","),g]);const j=f.useRef("");f.useEffect(()=>{if(h||E.length!==1||y.length===0||!r)return;const A=JSON.stringify({objectName:u,id:E[0],rules:y});j.current!==A&&(j.current=A,C(E[0],void 0,{skipExistingTargets:!0}))},[u,h,E.join(","),y,r,C]);const D=f.useCallback(A=>{const P=E.filter(z=>z!==A);if(n($v(P,h)),!h&&P.length===0&&y.length>0&&r){const z={};for(const V of y)V.targetField&&(z[V.targetField]="");Object.keys(z).length>0&&r(z)}},[E,n,h,y,r]),R=f.useCallback((A,P,z)=>{n($v(A,h)),M(V=>{const T=new Map(V);for(const[F,I]of P)T.set(F,I);return T}),c(!1),!h&&A.length===1&&C(A[0],z)},[n,h,C]);return e.readonly?p.jsx("div",{className:`${o?a?"px-1.5 py-1.5":"px-2.5 py-2":"border border-gray-200 rounded-md px-3 py-2"} bg-gray-50/60 min-h-[30px]`,children:E.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1.5",children:E.map(A=>p.jsx("span",{className:"inline-flex items-center gap-1 text-[13px] text-slate-700 rounded pr-2 py-0.5",children:$.get(A)||A},A))})}):p.jsxs(p.Fragment,{children:[p.jsx("div",{onClick:()=>u&&c(!0),className:`cursor-pointer smooth-transition ${o?a?`w-full px-1.5 py-1.5 min-h-[30px] border-0 rounded-none shadow-none ${i?"bg-red-100/90":"bg-transparent hover:bg-blue-50/40"}`:`w-full px-2.5 py-1.5 min-h-[34px] ${i?"bg-red-100/90":"bg-amber-50/80 hover:bg-amber-50"}`:`border rounded-md px-3 py-2 min-h-[38px] ${i?"border-red-200 bg-red-50":"border-gray-300 bg-amber-50/80 hover:border-indigo-300"}`}`,children:E.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5 items-center",children:E.map(A=>p.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] bg-indigo-50 text-indigo-700 border border-indigo-200 rounded-md px-2 py-0.5 max-w-[200px]",children:[p.jsx("span",{className:"truncate",children:$.get(A)||A}),p.jsx(Zr,{className:"w-3 h-3 text-indigo-300 hover:text-red-500 shrink-0 cursor-pointer",onClick:P=>{P.stopPropagation(),D(A)}})]},A))}):p.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[p.jsx(XB,{className:"w-4 h-4 shrink-0"}),p.jsx("span",{className:"text-[13px]",children:u?"选择数据":"请先配置关联对象"}),p.jsx(qi,{className:"w-3.5 h-3.5 ml-auto shrink-0"})]})}),l&&p.jsx(eX,{objectName:u,displayFields:v,multiple:h,selectedIds:E,filters:N,sortField:b,sortOrder:x,onConfirm:R,onClose:()=>c(!1)})]})}function eX({objectName:e,displayFields:t,multiple:n,selectedIds:r,filters:o,sortField:a,sortOrder:i,onConfirm:s,onClose:l}){const[c,u]=f.useState([]),[h,v]=f.useState(0),[g,b]=f.useState(!1),[x,y]=f.useState(1),[N,E]=f.useState(""),[C,_]=f.useState(new Set(r)),[$,M]=f.useState([]),j=10,D=f.useRef(void 0),R=t[0]||"name";f.useEffect(()=>{Kv(e).then(M)},[e]);const A=f.useMemo(()=>{const I=new Map;for(const B of $)I.set(B.value,B.label);return I},[$]),P=f.useCallback(async(I,B)=>{b(!0);try{const U=[];o&&U.push(o),B&&U.push(JSON.stringify([R,"contains",B]));let Q;U.length===2?Q=JSON.stringify([JSON.parse(U[0]),"and",JSON.parse(U[1])]):U.length===1&&(Q=U[0]);const J=["_id",...t].join(","),L=await sc(e,{filters:Q,fields:J,top:j,skip:(I-1)*j,sort:`${a||R} ${i||"asc"}`});u(L.data),v(L.total)}finally{b(!1)}},[e,t,R,o,a,i]);f.useEffect(()=>{P(x,N)},[x]);const z=f.useCallback(I=>{E(I),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{y(1),P(1,I)},300)},[P]),V=f.useMemo(()=>t.map(I=>{const B=typeof I=="string"?I:I&&typeof I=="object"&&"field"in I?String(I.field):String(I);return{title:A.get(B)||B,dataIndex:B,key:B,ellipsis:!0,render:U=>U!=null?String(U):"-"}}),[t,A]),T=f.useMemo(()=>({type:n?"checkbox":"radio",selectedRowKeys:[...C],onChange:I=>{if(_(new Set(I)),!n&&I.length>0){const B=I[0],U=c.find(J=>J._id===B),Q=new Map;U&&Q.set(B,U[R]||B),s([B],Q,U)}}}),[n,C,c,R,s]),F=()=>{const I=new Map;for(const B of c){const U=B._id;C.has(U)&&I.set(U,B[R]||U)}s([...C],I)};return p.jsx(uo,{locale:Ta,children:p.jsxs(Ao,{open:!0,title:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(XB,{className:"w-4 h-4 text-indigo-500"}),p.jsx("span",{children:"选择数据"})]}),width:Math.min(960,window.innerWidth-32),onCancel:l,onOk:n?F:void 0,okText:n?`确定${C.size>0?` (${C.size})`:""}`:void 0,cancelText:"取消",footer:n?void 0:null,destroyOnClose:!0,styles:{body:{padding:"12px 0"}},children:[p.jsx("div",{style:{padding:"0 0 12px"},children:p.jsx(_s.Search,{placeholder:`搜索 ${A.get(R)||R}...`,allowClear:!0,onChange:I=>z(I.target.value),style:{width:"100%"}})}),p.jsx(hd,{rowKey:"_id",columns:V,dataSource:c,loading:g,rowSelection:T,pagination:{current:x,pageSize:j,total:h,size:"small",showSizeChanger:!1,showTotal:I=>`共 ${I} 条`,onChange:I=>y(I)},size:"small",scroll:{x:"max-content"},style:{fontSize:13},onRow:I=>({onClick:()=>{const B=I._id;if(n)_(U=>{const Q=new Set(U);return Q.has(B)?Q.delete(B):Q.add(B),Q});else{const U=new Map;U.set(B,I[R]||B),s([B],U,I)}},style:{cursor:"pointer"}})})]})})}const PPe=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/;function $T(e,t){return!e||!e.trim()?!1:t?!/[{}]/.test(e):PPe.test(e)}function tX(e,t){if(t)return e.replace(/[{}]/g,"");let n=e.replace(/[^a-zA-Z0-9_$]/g,"_");return n&&/^[0-9]/.test(n)&&(n="_"+n),n}const LPe=[{id:"basic",label:"基础"},{id:"fields",label:"字段"},{id:"validation",label:"验证"}];function zPe(){const e=Vt(C=>C.selectedFieldId),t=Vt(C=>C.fields),n=Vt(C=>C.updateField),r=Vt(C=>C.selectField),o=Vt(C=>C.removeChildField),a=Vt(C=>C.updateChildField),i=Vt(C=>C.reorderChildFields),s=Vt(C=>C.viewMode),l=Vt(C=>C.tableColumns),c=Vt(C=>C.flowSteps),u=Vt(C=>C.chineseFieldNames),[h,v]=f.useState("basic");f.useEffect(()=>{v("basic")},[e]);let g=t.find(C=>C._id===e),b=null;if(!g){for(const C of t)if(C.children){const _=C.children.find($=>$._id===e);if(_){g=_,b=C._id;break}}}const x=b?t.find(C=>C._id===b)?.type==="grid":!1,y=b?t.find(C=>C._id===b)?.type==="table":!1,N=y?t.find(C=>C._id===b)?.children||[]:[];if(!g)return p.jsx(BPe,{});const E=C=>{b?a(b,e,C):n(e,C)};return p.jsxs("aside",{className:"flex-shrink-0 w-[365px] border-l border-gray-200 bg-white flex flex-col",children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100",children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[p.jsx("h2",{className:"text-xs font-semibold text-gray-600 truncate",children:g.label||"字段属性"}),p.jsx("span",{className:"text-[10px] text-gray-400 bg-gray-100 rounded px-1.5 py-0.5 shrink-0",children:wm[g.type]})]}),p.jsx("button",{onClick:()=>r(null),className:"rounded p-1 text-gray-400 hover:text-gray-600 hover:bg-gray-100 smooth-transition shrink-0",children:p.jsx(Zr,{className:"w-3.5 h-3.5"})})]}),p.jsx("div",{className:"flex border-b border-gray-100 bg-gray-50/60",children:LPe.filter(C=>!(C.id==="validation"&&g.type==="section"||C.id==="fields"&&g.type!=="table")).map(C=>p.jsx("button",{onClick:()=>v(C.id),className:`flex-1 py-2 text-[12px] font-medium smooth-transition border-b-2 -mb-px ${h===C.id?"border-indigo-500 text-indigo-600 bg-white":"border-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`,children:C.label},C.id))}),p.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[h==="basic"&&p.jsxs("div",{className:"px-3 py-3 space-y-4",children:[p.jsx(Bn,{label:"字段标签",required:!0,children:p.jsx("input",{value:g.label,onChange:C=>E({label:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"输入标签"})}),!["section","grid"].includes(g.type)&&p.jsxs(Bn,{label:"字段名称",required:!0,hint:g.name==="__applicant"?"系统内置字段,名称不可修改":u?"支持中文、英文、特殊符号,不能包含 { }":"字母/下划线开头,仅含字母、数字、下划线",children:[p.jsx("input",{value:g.name==="__applicant"?"applicant":g.name,onChange:C=>E({name:tX(C.target.value,u)}),readOnly:g.name==="__applicant",className:`w-full border rounded-md px-2.5 py-1.5 text-[13px] font-mono outline-none focus:ring-1 smooth-transition ${g.name==="__applicant"?"border-gray-200 bg-gray-50 text-gray-500 cursor-not-allowed":g.name&&!$T(g.name,u)?"border-red-300 focus:border-red-400 focus:ring-red-200":"border-gray-200 focus:border-indigo-400 focus:ring-indigo-200"}`,placeholder:u?"字段名称":"field_name"}),g.name&&!$T(g.name,u)&&p.jsx("p",{className:"text-[10px] text-red-500 mt-0.5",children:u?"字段名称不能为空,且不能包含 { }":"字段名必须以字母或下划线开头,仅包含字母、数字、下划线"})]}),g.type==="formula"&&p.jsx(Bn,{label:"值类型",hint:"字段值的数据类型",children:p.jsx("select",{value:g.valueType||Kj[g.type],onChange:C=>E({valueType:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:Object.entries(tRe).map(([C,_])=>p.jsx("option",{value:C,children:_},C))})}),g.type==="formula"&&(g.valueType||Kj[g.type])==="number"&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"数值格式"}),p.jsx("div",{className:"grid grid-cols-1 gap-2",children:p.jsx(Bn,{label:"精度",children:p.jsx("input",{type:"number",value:g.precision??"",onChange:C=>E({precision:C.target.value?Number(C.target.value):void 0}),className:"w-full border border-gray-200 rounded-md px-2 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition"})})}),p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:!!g.thousandSeparator,onChange:C=>E({thousandSeparator:C.target.checked}),className:"w-3.5 h-3.5 accent-indigo-500"}),p.jsx("span",{className:"text-[13px] text-gray-600",children:"显示千位分隔符"})]})]}),p.jsx(Bn,{label:"描述",children:p.jsx("textarea",{value:g.description||"",onChange:C=>E({description:C.target.value}),rows:2,className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition resize-none",placeholder:"字段描述"})}),["text","textarea","number","email","url","password","richtext"].includes(g.type)&&p.jsx(Bn,{label:"占位符",children:p.jsx("input",{value:g.placeholder||"",onChange:C=>E({placeholder:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"请输入..."})}),!["section","table","approvalComments","grid","autoNumber"].includes(g.type)&&p.jsx(Bn,{label:"默认值",children:g.type==="richtext"?p.jsx(ZPe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):["date","datetime","time"].includes(g.type)?p.jsx(QPe,{fieldType:g.type,value:g.defaultValue||"",onChange:C=>E({defaultValue:C}),defaultHour:g.defaultHour,defaultMinute:g.defaultMinute,onChangeTime:(C,_)=>E({defaultHour:C,defaultMinute:_})}):g.type==="member"&&!g.pickerMultiple?p.jsx(eLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):g.type==="org"&&!g.pickerMultiple?p.jsx(tLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):g.type==="number"?p.jsx("input",{type:"number",value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"输入数值"}):g.type==="checkbox"?p.jsxs("select",{value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"",children:"(无)"}),p.jsx("option",{value:"false",children:"否"}),p.jsx("option",{value:"true",children:"是"})]}):g.type==="radio"?p.jsxs("select",{value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"",children:"(无)"}),(g.options||[]).map(C=>p.jsx("option",{value:C.value,children:C.label},C.value))]}):g.type==="checkboxGroup"?p.jsx(uo,{locale:Ta,children:p.jsx(la,{mode:"multiple",allowClear:!0,placeholder:"选择默认值",value:g.defaultValue?String(g.defaultValue).split(",").map(C=>C.trim()).filter(Boolean):[],onChange:C=>E({defaultValue:C.length>0?C.join(","):""}),options:(g.options||[]).map(C=>({label:C.label,value:C.value})),className:"w-full",size:"small"})}):g.type==="lookup"?p.jsx(nLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C}),field:g}):p.jsx("input",{value:g.defaultValue||"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"默认值"})}),["select","multiSelect","checkbox","checkboxGroup","radio"].includes(g.type)&&p.jsx(rLe,{fieldId:g._id,options:g.options||[],onChange:C=>E({options:C})}),g.type==="formula"&&p.jsx(Bn,{label:"公式表达式",hint:"用 ${} 包裹公式,内部直接用字段名",children:p.jsx(Sje,{value:g.formula||"",onChange:C=>E({formula:C}),fieldId:g._id})}),g.type==="autoNumber"&&p.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-3",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"自动编号设置"}),p.jsx(Bn,{label:"规则名称",hint:"可选。留空时按表单和字段自动生成",children:p.jsx("input",{value:g.auto_number_name||"",onChange:C=>E({auto_number_name:C.target.value||void 0}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"如 合同编号、档案借用"})}),p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx(Bn,{label:"前缀",children:p.jsx("input",{value:g.autoNumberPrefix||"",onChange:C=>E({autoNumberPrefix:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"如 SN-"})}),p.jsx(Bn,{label:"后缀",children:p.jsx("input",{value:g.autoNumberSuffix||"",onChange:C=>E({autoNumberSuffix:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"可留空"})})]}),p.jsx(Bn,{label:"日期格式",hint:"在编号中插入日期片段",children:p.jsxs("select",{value:g.autoNumberDateFormat??"YYYYMM",onChange:C=>E({autoNumberDateFormat:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"none",children:"不用日期"}),p.jsx("option",{value:"YYYY",children:"年份(YYYY)"}),p.jsx("option",{value:"YYYYMM",children:"年月(YYYYMM)"}),p.jsx("option",{value:"YYYYMMDD",children:"年月日(YYYYMMDD)"})]})}),p.jsx(Bn,{label:"序号位数",hint:"序号补零位数,如 4 → 0001",children:p.jsx("input",{type:"number",min:1,max:10,value:g.autoNumberPadding??4,onChange:C=>E({autoNumberPadding:C.target.value?Number(C.target.value):4}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition"})}),p.jsx(Bn,{label:"重置周期",hint:"计数器何时归零重新从 1 计起",children:p.jsxs("select",{value:g.autoNumberResetCycle??"monthly",onChange:C=>E({autoNumberResetCycle:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"none",children:"不重置"}),p.jsx("option",{value:"yearly",children:"每年"}),p.jsx("option",{value:"monthly",children:"每月"}),p.jsx("option",{value:"daily",children:"每天"})]})}),p.jsxs("div",{className:"rounded-md bg-sky-50 border border-sky-200 px-3 py-2 text-[12px] text-sky-700",children:[p.jsx("span",{className:"font-semibold mr-1",children:"预览:"}),(()=>{const C=g.autoNumberPrefix||"",_=g.autoNumberSuffix||"",$=g.autoNumberPadding??4,M=g.autoNumberDateFormat??"YYYYMM",j=new Date;let D="";M==="YYYY"?D=`${j.getFullYear()}`:M==="YYYYMM"?D=`${j.getFullYear()}${String(j.getMonth()+1).padStart(2,"0")}`:M==="YYYYMMDD"&&(D=`${j.getFullYear()}${String(j.getMonth()+1).padStart(2,"0")}${String(j.getDate()).padStart(2,"0")}`);const R="1".padStart($,"0");return D?`${C}${D}-${R}${_}`:`${C}${R}${_}`})()]})]}),g.type==="apiSelect"&&p.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-4",children:[p.jsxs("div",{className:"space-y-2.5",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"接口请求"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("select",{value:g.optionsMethod||"GET",onChange:C=>E({optionsMethod:C.target.value}),className:"w-[88px] shrink-0 border border-gray-200 rounded-md px-2 py-1.5 text-[13px] font-medium outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"GET",children:"GET"}),p.jsx("option",{value:"POST",children:"POST"}),p.jsx("option",{value:"PUT",children:"PUT"}),p.jsx("option",{value:"PATCH",children:"PATCH"}),p.jsx("option",{value:"DELETE",children:"DELETE"})]}),p.jsx("input",{value:g.optionsUrl||"",onChange:C=>E({optionsUrl:C.target.value}),className:"flex-1 min-w-0 border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"",required:!0})]})]}),p.jsxs("div",{className:"space-y-2.5",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"字段映射"}),p.jsx(ys,{label:"允许多选",checked:!!g.optionsMultiple,onChange:C=>E({optionsMultiple:C})}),p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx(Bn,{label:"显示字段",hint:"用于显示的字段名",children:p.jsx("input",{value:g.optionsLabelField||"",onChange:C=>E({optionsLabelField:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"name"})}),p.jsx(Bn,{label:"值字段",hint:"用于存值的字段名",children:p.jsx("input",{value:g.optionsValueField||"",onChange:C=>E({optionsValueField:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"_id"})})]})]}),p.jsxs("details",{className:"group",children:[p.jsxs("summary",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold cursor-pointer hover:text-gray-600 select-none flex items-center gap-1",children:[p.jsx(Ip,{className:"h-3 w-3 group-open:rotate-90 smooth-transition"}),"脚本"]}),p.jsxs("div",{className:"mt-2.5 space-y-2.5",children:[p.jsx(Bn,{label:"数据转换",hint:"参数 data(数组),返回 [{label, value}]",children:p.jsx("textarea",{value:g.optionsMapScript||"",onChange:C=>E({optionsMapScript:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition font-mono",placeholder:`return data.map(item => ({
|
|
753
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){const r=a=>{const i=pT(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,l)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:l}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(a)},o=pT(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,i)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});po.create({name:"listKit",addExtensions(){const e=[];return this.options.bulletList!==!1&&e.push(DG.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(AG.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(HG.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(UG.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(T4e.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(I4e.configure(this.options.taskList)),e}});var NF=" ",D4e=" ",A4e=rl.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",ea(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);const r=t.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===NF||r[0].text===D4e)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t)=>{if(!e)return"";const n=Array.isArray(e.content)?e.content:[];return n.length===0?NF:t.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),P4e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,L4e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z4e=md.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",ea(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[fm({find:P4e,type:this.type})]},addPasteRules(){return[Zf({find:L4e,type:this.type})]}}),F4e=rl.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),WG=md.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",ea(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,t,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!o)return;const a=o[2].trim();return{type:"underline",raw:o[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),B4e=WG;function H4e(e={}){return new Wo({view(t){return new V4e(t,e)}})}class V4e{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let a=i=>{this[o](i)};return t.dom.addEventListener(o,a),{name:o,handler:a}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,o=this.editorView.dom,a=o.getBoundingClientRect(),i=a.width/o.offsetWidth,s=a.height/o.offsetHeight;if(n){let h=t.nodeBefore,v=t.nodeAfter;if(h||v){let g=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(g){let b=g.getBoundingClientRect(),x=h?b.bottom:b.top;h&&v&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*s;r={left:b.left,right:b.right,top:x-y,bottom:x+y}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),v=this.width/2*i;r={left:h.left-v,right:h.left+v,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),v=h.width/l.offsetWidth,g=h.height/l.offsetHeight;c=h.left-l.scrollLeft*v,u=h.top-l.scrollTop*g}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/s+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/s+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,a=typeof o=="function"?o(this.editorView,n,t):o;if(n&&!a){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let s=LK(this.editorView.state.doc,i,this.editorView.dragging.slice);s!=null&&(i=s)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Zo extends vr{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return Zo.valid(r)?new Zo(r):vr.near(r)}content(){return xn.empty}eq(t){return t instanceof Zo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zo(t.resolve(n.pos))}getBookmark(){return new w3(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!U4e(t)||!W4e(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&Zo.valid(t))return t;let o=t.pos,a=null;for(let i=t.depth;;i--){let s=t.node(i);if(n>0?t.indexAfter(i)<s.childCount:t.index(i)>0){a=s.child(n>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0)return null;o+=n;let l=t.doc.resolve(o);if(Zo.valid(l))return l}for(;;){let i=n>0?a.firstChild:a.lastChild;if(!i){if(a.isAtom&&!a.isText&&!An.isSelectable(a)){t=t.doc.resolve(o+a.nodeSize*n),r=!1;continue e}break}a=i,o+=n;let s=t.doc.resolve(o);if(Zo.valid(s))return s}return null}}}Zo.prototype.visible=!1;Zo.findFrom=Zo.findGapCursorFrom;vr.jsonID("gapcursor",Zo);class w3{constructor(t){this.pos=t}map(t){return new w3(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Zo.valid(n)?new Zo(n):vr.near(n)}}function qG(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function U4e(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||qG(o.type))return!0;if(o.inlineContent)return!1}}return!0}function W4e(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||qG(o.type))return!0;if(o.inlineContent)return!1}}return!0}function q4e(){return new Wo({props:{decorations:X4e,createSelectionBetween(e,t,n){return t.pos==n.pos&&Zo.valid(n)?new Zo(n):null},handleClick:Y4e,handleKeyDown:K4e,handleDOMEvents:{beforeinput:G4e}}})}const K4e=zY({ArrowLeft:u2("horiz",-1),ArrowRight:u2("horiz",1),ArrowUp:u2("vert",-1),ArrowDown:u2("vert",1)});function u2(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,o,a){let i=r.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof nr){if(!a.endOfTextblock(n)||s.depth==0)return!1;l=!1,s=r.doc.resolve(t>0?s.after():s.before())}let c=Zo.findGapCursorFrom(s,t,l);return c?(o&&o(r.tr.setSelection(new Zo(c))),!0):!1}}function Y4e(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Zo.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&An.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Zo(r))),!0)}function G4e(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Zo))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=Zt.empty;for(let i=r.length-1;i>=0;i--)o=Zt.from(r[i].createAndFill(null,o));let a=e.state.tr.replace(n.pos,n.pos,new xn(o,0,0));return a.setSelection(nr.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function X4e(e){if(!(e.selection instanceof Zo))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ho.create(e.doc,[Wi.widget(e.selection.head,t,{key:"gapcursor"})])}var BE=200,Aa=function(){};Aa.prototype.append=function(t){return t.length?(t=Aa.from(t),!this.length&&t||t.length<BE&&this.leafAppend(t)||this.length<BE&&t.leafPrepend(this)||this.appendInner(t)):this};Aa.prototype.prepend=function(t){return t.length?Aa.from(t).append(this):this};Aa.prototype.appendInner=function(t){return new J4e(this,t)};Aa.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Aa.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};Aa.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Aa.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};Aa.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(a,i){return o.push(t(a,i))},n,r),o};Aa.from=function(t){return t instanceof Aa?t:t&&t.length?new KG(t):Aa.empty};var KG=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(o,a){return o==0&&a==this.length?this:new t(this.values.slice(o,a))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,a,i,s){for(var l=a;l<i;l++)if(o(this.values[l],s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(o,a,i,s){for(var l=a-1;l>=i;l--)if(o(this.values[l],s+l)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=BE)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=BE)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(Aa);Aa.empty=new KG([]);var J4e=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,o,a,i){var s=this.left.length;if(o<s&&this.left.forEachInner(r,o,Math.min(a,s),i)===!1||a>s&&this.right.forEachInner(r,Math.max(o-s,0),Math.min(this.length,a)-s,i+s)===!1)return!1},t.prototype.forEachInvertedInner=function(r,o,a,i){var s=this.left.length;if(o>s&&this.right.forEachInvertedInner(r,o-s,Math.max(a,s)-s,i+s)===!1||a<s&&this.left.forEachInvertedInner(r,Math.min(o,s),a,i)===!1)return!1},t.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var a=this.left.length;return o<=a?this.left.slice(r,o):r>=a?this.right.slice(r-a,o-a):this.left.slice(r,a).append(this.right.slice(0,o-a))},t.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new t(o,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(Aa);const Z4e=500;class nc{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,a;n&&(o=this.remapping(r,this.items.length),a=o.maps.length);let i=t.tr,s,l,c=[],u=[];return this.items.forEach((h,v)=>{if(!h.step){o||(o=this.remapping(r,v+1),a=o.maps.length),a--,u.push(h);return}if(o){u.push(new Qc(h.map));let g=h.step.map(o.slice(a)),b;g&&i.maybeStep(g).doc&&(b=i.mapping.maps[i.mapping.maps.length-1],c.push(new Qc(b,void 0,void 0,c.length+u.length))),a--,b&&o.appendMap(b,a)}else i.maybeStep(h.step);if(h.selection)return s=o?h.selection.map(o.slice(a)):h.selection,l=new nc(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:s}}addTransform(t,n,r,o){let a=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let u=0;u<t.steps.length;u++){let h=t.steps[u].invert(t.docs[u]),v=new Qc(t.mapping.maps[u],h,n),g;(g=l&&l.merge(v))&&(v=g,u?a.pop():s=s.slice(0,s.length-1)),a.push(v),n&&(i++,n=void 0),o||(l=v)}let c=i-r.depth;return c>ePe&&(s=Q4e(s,c),i-=c),new nc(s.append(a),i)}remapping(t,n){let r=new m1;return this.items.forEach((o,a)=>{let i=o.mirrorOffset!=null&&a-o.mirrorOffset>=t?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},t,n),r}addMaps(t){return this.eventCount==0?this:new nc(this.items.append(t.map(n=>new Qc(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),a=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach(v=>{v.selection&&s--},o);let l=n;this.items.forEach(v=>{let g=a.getMirror(--l);if(g==null)return;i=Math.min(i,g);let b=a.maps[g];if(v.step){let x=t.steps[g].invert(t.docs[g]),y=v.selection&&v.selection.map(a.slice(l+1,g));y&&s++,r.push(new Qc(b,x,y))}else r.push(new Qc(b))},o);let c=[];for(let v=n;v<i;v++)c.push(new Qc(a.maps[v]));let u=this.items.slice(0,o).append(c).append(r),h=new nc(u,s);return h.emptyItemCount()>Z4e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,o=[],a=0;return this.items.forEach((i,s)=>{if(s>=t)o.push(i),i.selection&&a++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&a++;let h=new Qc(c.invert(),l,u),v,g=o.length-1;(v=o.length&&o[g].merge(h))?o[g]=v:o.push(h)}}else i.map&&r--},this.items.length,0),new nc(Aa.from(o.reverse()),a)}}nc.empty=new nc(Aa.empty,0);function Q4e(e,t){let n;return e.forEach((r,o)=>{if(r.selection&&t--==0)return n=o,!1}),e.slice(n)}class Qc{constructor(t,n,r,o){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Qc(n.getMap().invert(),n,this.selection)}}}class _f{constructor(t,n,r,o,a){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=a}}const ePe=20;function tPe(e,t,n,r){let o=n.getMeta(qp),a;if(o)return o.historyState;n.getMeta(oPe)&&(e=new _f(e.done,e.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(i&&i.getMeta(qp))return i.getMeta(qp).redo?new _f(e.done.addTransform(n,void 0,r,J2(t)),e.undone,EF(n.mapping.maps),e.prevTime,e.prevComposition):new _f(e.done,e.undone.addTransform(n,void 0,r,J2(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let s=n.getMeta("composition"),l=e.prevTime==0||!i&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!nPe(n,e.prevRanges)),c=i?TM(e.prevRanges,n.mapping):EF(n.mapping.maps);return new _f(e.done.addTransform(n,l?t.selection.getBookmark():void 0,r,J2(t)),nc.empty,c,n.time,s??e.prevComposition)}else return(a=n.getMeta("rebased"))?new _f(e.done.rebased(n,a),e.undone.rebased(n,a),TM(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new _f(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),TM(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function nPe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,o)=>{for(let a=0;a<t.length;a+=2)r<=t[a+1]&&o>=t[a]&&(n=!0)}),n}function EF(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,o,a,i)=>t.push(a,i));return t}function TM(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),a=t.map(e[r+1],-1);o<=a&&n.push(o,a)}return n}function rPe(e,t,n){let r=J2(t),o=qp.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let i=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),o,r),l=new _f(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(i).setMeta(qp,{redo:n,historyState:l})}let IM=!1,$F=null;function J2(e){let t=e.plugins;if($F!=t){IM=!1,$F=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){IM=!0;break}}return IM}const qp=new _a("history"),oPe=new _a("closeHistory");function aPe(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Wo({key:qp,state:{init(){return new _f(nc.empty,nc.empty,null,0,-1)},apply(t,n,r){return tPe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,o=r=="historyUndo"?GG:r=="historyRedo"?XG:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function YG(e,t){return(n,r)=>{let o=qp.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(r){let a=rPe(o,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}const GG=YG(!1,!0),XG=YG(!0,!0);po.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){const r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=e=>{const t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Wo({key:new _a("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const o=this.options.limit;if(o==null||o===0){e=!0;return}const a=this.storage.characters({node:r.doc});if(a>o){const i=a-o,s=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(s,l);return e=!0,c}e=!0},filterTransaction:(t,n)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),a=this.storage.characters({node:t.doc});if(a<=r||o>r&&a>r&&a<=o)return!0;if(o>r&&a>r&&a>o||!t.getMeta("paste"))return!1;const s=t.selection.$head.pos,l=a-r,c=s-l,u=s;return t.deleteRange(c,u),!(this.storage.characters({node:t.doc})>r)}})]}});var iPe=po.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[H4e(this.options)]}});po.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Wo({key:new _a("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,a=[];if(!n||!r)return Ho.create(e,[]);let i=0;this.options.mode==="deepest"&&e.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let s=0;return e.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(s+=1,this.options.mode==="deepest"&&i-s>0||this.options.mode==="shallowest"&&s>1)return this.options.mode==="deepest";a.push(Wi.node(c,c+l.nodeSize,{class:this.options.className}))}),Ho.create(e,a)}}})]}});var sPe=po.create({name:"gapCursor",addProseMirrorPlugins(){return[q4e()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=so(Mn(e,"allowGapCursor",n)))!=null?t:null}}}),_F="placeholder";function lPe(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var cPe=po.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:_F,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const e=this.options.dataAttribute?`data-${lPe(this.options.dataAttribute)}`:`data-${_F}`;return[new Wo({key:new _a("placeholder"),props:{decorations:({doc:t,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,a=[];if(!r)return null;const i=this.editor.isEmpty;return t.descendants((s,l)=>{const c=o>=l&&o<=l+s.nodeSize,u=!s.isLeaf&&m_(s);if((c||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];i&&h.push(this.options.emptyEditorClass);const v=Wi.node(l,l+s.nodeSize,{class:h.join(" "),[e]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:c}):this.options.placeholder});a.push(v)}return this.options.includeChildren}),Ho.create(t,a)}}})]}});po.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new Wo({key:new _a("selection"),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||tG(n.selection)||e.view.dragging?null:Ho.create(n.doc,[Wi.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function kF({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var uPe=po.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;const t=new _a(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new Wo({key:t,appendTransaction:(o,a,i)=>{const{doc:s,tr:l,schema:c}=i,u=t.getState(i),h=s.content.size,v=c.nodes[n];if(u)return l.insert(h,v.create())},state:{init:(o,a)=>{const i=a.tr.doc.lastChild;return!kF({node:i,types:r})},apply:(o,a)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return a;const i=o.doc.lastChild;return!kF({node:i,types:r})}}})]}}),dPe=po.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>GG(e,t),redo:()=>({state:e,dispatch:t})=>XG(e,t)}},addProseMirrorPlugins(){return[aPe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),fPe=po.create({name:"starterKit",addExtensions(){var e,t,n,r;const o=[];return this.options.bold!==!1&&o.push(AAe.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(RAe.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(DG.configure(this.options.bulletList)),this.options.code!==!1&&o.push(zAe.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(HAe.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(VAe.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(iPe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(sPe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(UAe.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(WAe.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(dPe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(qAe.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(JAe.configure(this.options.italic)),this.options.listItem!==!1&&o.push(AG.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(HG.configure((e=this.options)==null?void 0:e.listKeymap)),this.options.link!==!1&&o.push(IG.configure((t=this.options)==null?void 0:t.link)),this.options.orderedList!==!1&&o.push(UG.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(A4e.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(z4e.configure(this.options.strike)),this.options.text!==!1&&o.push(F4e.configure(this.options.text)),this.options.underline!==!1&&o.push(WG.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(uPe.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),hPe=fPe,pPe=po.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),mPe=pPe,gPe=cPe,vPe=20,JG=(e,t=0)=>{const n=[];return!e.children.length||t>vPe||Array.from(e.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...JG(r,t+1))}),n},bPe=e=>{if(!e.children.length)return;const t=JG(e);t&&t.forEach(n=>{var r,o;const a=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${a}`)})},ZG=md.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&bPe(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",ea(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(a=>!!a))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),yPe=po.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const a=r[o].split(":");if(a.length>=2){const i=a[0].trim().toLowerCase(),s=a.slice(1).join(":").trim();if(i==="background-color")return s.replace(/['"]+/g,"")}}}return(t=e.style.backgroundColor)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),QG=po.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const a=r[o].split(":");if(a.length>=2){const i=a[0].trim().toLowerCase(),s=a.slice(1).join(":").trim();if(i==="color")return s.replace(/['"]+/g,"")}}}return(t=e.style.color)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),xPe=po.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),wPe=po.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),CPe=po.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});po.create({name:"textStyleKit",addExtensions(){const e=[];return this.options.backgroundColor!==!1&&e.push(yPe.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(QG.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(xPe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(wPe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(CPe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(ZG.configure(this.options.textStyle)),e}});var SPe=QG,NPe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,EPe=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,$Pe=md.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",ea(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){const o=/^(==)([^=]+)(==)/.exec(e);if(o){const a=o[2].trim(),i=n.inlineTokens(a);return{type:"highlight",raw:o[0],text:a,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[fm({find:NPe,type:this.type})]},addPasteRules(){return[Zf({find:EPe,type:this.type})]}}),_Pe=$Pe;function Hi({onClick:e,active:t,disabled:n,title:r,children:o}){return p.jsx("button",{type:"button",onMouseDown:a=>{a.preventDefault(),e()},disabled:n,title:r,className:`p-1 rounded hover:bg-gray-200 smooth-transition ${n?"text-gray-300 cursor-not-allowed":t?"bg-gray-200 text-indigo-600":"text-gray-500"}`,children:o})}const kPe=["#000000","#434343","#666666","#999999","#cccccc","#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#3b82f6","#6366f1","#8b5cf6","#ec4899","#f43f5e","#991b1b","#9a3412","#854d0e","#166534","#115e59","#1e40af","#3730a3","#5b21b6","#9d174d","#be123c"];function OF({currentColor:e,onSelect:t,icon:n,title:r}){const[o,a]=f.useState(!1),[i,s]=f.useState({top:0,left:0}),l=f.useRef(null),c=f.useRef(null);f.useEffect(()=>{if(!o)return;const h=v=>{l.current&&!l.current.contains(v.target)&&c.current&&!c.current.contains(v.target)&&a(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]);const u=f.useCallback(h=>{if(h.preventDefault(),!o&&l.current){const v=l.current.getBoundingClientRect();s({top:v.bottom+4,left:v.left})}a(v=>!v)},[o]);return p.jsxs("div",{className:"relative",children:[p.jsxs("button",{ref:l,type:"button",title:r,className:"flex items-center p-1 rounded hover:bg-gray-200 smooth-transition text-gray-500",onMouseDown:u,children:[p.jsxs("span",{className:"relative",children:[n,e&&p.jsx("span",{className:"absolute -bottom-0.5 left-0 right-0 h-[3px] rounded-sm",style:{backgroundColor:e}})]}),p.jsx(qi,{className:"w-2.5 h-2.5 ml-0.5"})]}),o&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsxs("div",{ref:c,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg p-2.5",style:{top:i.top,left:i.left},children:[p.jsx("div",{className:"flex flex-wrap gap-1.5",style:{width:164},children:kPe.map(h=>p.jsx("button",{type:"button",title:h,className:`w-7 h-7 rounded-md border-2 smooth-transition flex items-center justify-center ${h===e?"border-gray-800 shadow-sm scale-110":"border-transparent hover:border-gray-300"}`,style:{backgroundColor:h},onMouseDown:v=>{v.preventDefault(),t(h),a(!1)}},h))}),p.jsx("button",{type:"button",className:"w-full mt-2 text-[11px] text-gray-500 hover:text-gray-700 py-1 rounded-md hover:bg-gray-100 smooth-transition",onMouseDown:h=>{h.preventDefault(),t(null),a(!1)},children:"清除颜色"})]})}),document.body)]})}function OPe({editor:e}){const[t,n]=f.useState(!1),[r,o]=f.useState({top:0,left:0}),a=f.useRef(null),i=f.useRef(null);f.useEffect(()=>{if(!t)return;const u=h=>{a.current&&!a.current.contains(h.target)&&i.current&&!i.current.contains(h.target)&&n(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[t]);const s=f.useCallback(u=>{if(u.preventDefault(),!t&&a.current){const h=a.current.getBoundingClientRect();o({top:h.bottom+4,left:h.left})}n(h=>!h)},[t]),l=[{label:"正文",active:!e.isActive("heading"),action:()=>e.chain().focus().setParagraph().run()},{label:"标题 1",active:e.isActive("heading",{level:1}),action:()=>e.chain().focus().toggleHeading({level:1}).run(),className:"text-[16px] font-bold"},{label:"标题 2",active:e.isActive("heading",{level:2}),action:()=>e.chain().focus().toggleHeading({level:2}).run(),className:"text-[15px] font-bold"},{label:"标题 3",active:e.isActive("heading",{level:3}),action:()=>e.chain().focus().toggleHeading({level:3}).run(),className:"text-[14px] font-semibold"}],c=l.find(u=>u.active)?.label||"正文";return p.jsxs("div",{className:"relative",children:[p.jsxs("button",{ref:a,type:"button",className:"flex items-center gap-0.5 px-1.5 py-1 rounded hover:bg-gray-200 smooth-transition text-gray-600 text-[12px] font-medium min-w-[56px]",onMouseDown:s,children:[c,p.jsx(qi,{className:"w-3 h-3"})]}),t&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsx("div",{ref:i,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg py-1 min-w-[120px]",style:{top:r.top,left:r.left},children:l.map(u=>p.jsx("button",{type:"button",className:`w-full text-left px-3 py-1.5 hover:bg-gray-100 smooth-transition ${u.active?"bg-indigo-50 text-indigo-600":"text-gray-700"} ${u.className||"text-[13px]"}`,onMouseDown:h=>{h.preventDefault(),u.action(),n(!1)},children:u.label},u.label))})}),document.body)]})}function MPe({editor:e,iconSize:t}){const[n,r]=f.useState(!1),[o,a]=f.useState(""),[i,s]=f.useState({top:0,left:0}),l=f.useRef(null),c=f.useRef(null),u=f.useRef(null);f.useEffect(()=>{if(!n)return;const g=b=>{l.current&&!l.current.contains(b.target)&&c.current&&!c.current.contains(b.target)&&r(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n]);const h=()=>{const g=e.getAttributes("link").href||"";if(a(g||"https://"),l.current){const b=l.current.getBoundingClientRect();s({top:b.bottom+4,left:Math.max(8,b.right-320)})}r(!n),setTimeout(()=>u.current?.focus(),50)},v=()=>{if(r(!1),!o||o==="https://"){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:o}).run()};return p.jsxs("div",{className:"relative",children:[p.jsx("button",{ref:l,type:"button",title:"插入链接",className:`p-1 rounded hover:bg-gray-200 smooth-transition ${e.isActive("link")?"bg-gray-200 text-indigo-600":"text-gray-500"}`,onMouseDown:g=>{g.preventDefault(),h()},children:p.jsx(eH,{className:t})}),n&&Ki.createPortal(p.jsx("div",{className:"workflow-form-v2",style:{display:"contents"},children:p.jsxs("div",{ref:c,className:"fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg p-3 w-[320px]",style:{top:i.top,left:i.left},onMouseDown:g=>g.stopPropagation(),children:[p.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"链接地址"}),p.jsx(_s,{ref:u,value:o,onChange:g=>a(g.target.value),placeholder:"https://",size:"small",onPressEnter:v}),p.jsxs("div",{className:"flex justify-end gap-1.5 mt-2",children:[p.jsx("button",{type:"button",className:"px-2.5 py-1 text-[12px] text-gray-500 hover:text-gray-700 rounded hover:bg-gray-100 smooth-transition",onMouseDown:g=>{g.preventDefault(),r(!1)},children:"取消"}),p.jsx("button",{type:"button",className:"px-2.5 py-1 text-[12px] text-white bg-indigo-500 hover:bg-indigo-600 rounded smooth-transition",onMouseDown:g=>{g.preventDefault(),v()},children:"确定"})]})]})}),document.body)]})}function RPe({editor:e}){const t="w-3.5 h-3.5",[,n]=f.useState(0);f.useEffect(()=>{const a=()=>n(i=>i+1);return e.on("transaction",a),()=>{e.off("transaction",a)}},[e]);const r=e.getAttributes("textStyle").color,o=e.getAttributes("highlight").color;return p.jsx(p.Fragment,{children:p.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-gray-50/80",children:[p.jsx(OPe,{editor:e}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleBold().run(),active:e.isActive("bold"),title:"加粗",children:p.jsx(WB,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleItalic().run(),active:e.isActive("italic"),title:"斜体",children:p.jsx(Cae,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleUnderline().run(),active:e.isActive("underline"),title:"下划线",children:p.jsx(Uie,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleStrike().run(),active:e.isActive("strike"),title:"删除线",children:p.jsx(Oie,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(OF,{currentColor:r,onSelect:a=>{a?e.chain().focus().setColor(a).run():e.chain().focus().unsetColor().run()},icon:p.jsx(nie,{className:t}),title:"字体颜色"}),p.jsx(OF,{currentColor:o,onSelect:a=>{a?e.chain().focus().setHighlight({color:a}).run():e.chain().focus().unsetHighlight().run()},icon:p.jsx(vae,{className:t}),title:"背景色"}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleBulletList().run(),active:e.isActive("bulletList"),title:"无序列表",children:p.jsx(fN,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().toggleOrderedList().run(),active:e.isActive("orderedList"),title:"有序列表",children:p.jsx(tH,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().sinkListItem("listItem").run(),disabled:!e.can().sinkListItem("listItem"),title:"增加缩进",children:p.jsx(Tae,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().liftListItem("listItem").run(),disabled:!e.can().liftListItem("listItem"),title:"减少缩进",children:p.jsx(Rae,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("left").run(),active:e.isActive({textAlign:"left"}),title:"左对齐",children:p.jsx(iI,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("center").run(),active:e.isActive({textAlign:"center"}),title:"居中",children:p.jsx(cR,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().setTextAlign("right").run(),active:e.isActive({textAlign:"right"}),title:"右对齐",children:p.jsx(nH,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(MPe,{editor:e,iconSize:t}),p.jsx(Hi,{onClick:()=>e.chain().focus().unsetLink().run(),disabled:!e.isActive("link"),title:"取消链接",children:p.jsx(Kie,{className:t})}),p.jsx("div",{className:"w-px h-4 bg-gray-300 mx-0.5"}),p.jsx(Hi,{onClick:()=>e.chain().focus().unsetAllMarks().clearNodes().run(),title:"清除格式",children:p.jsx(hie,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().undo(),title:"撤销",children:p.jsx(sI,{className:t})}),p.jsx(Hi,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().redo(),title:"重做",children:p.jsx(rI,{className:t})})]})})}function C3({value:e,onChange:t,readonly:n=!1,placeholder:r="请输入内容...",isTableMode:o=!1,hasError:a=!1,minHeight:i=120}){const s=$Ae({extensions:[hPe,B4e,ZG,SPe,_Pe.configure({multicolor:!0}),C4e.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),mPe.configure({types:["heading","paragraph"]}),gPe.configure({placeholder:r})],content:e||"",editable:!n,onUpdate:({editor:c})=>{t(c.getHTML())}});if(f.useEffect(()=>{s?.setEditable(!n)},[s,n]),f.useEffect(()=>{if(!s||s.isFocused)return;const c=s.getHTML(),u=c==="<p></p>"?"":c,h=e||"";u!==h&&s.commands.setContent(h,{emitUpdate:!1})},[s,e]),n){const c=o?"w-full h-full px-2.5 py-2 text-[13px] text-gray-700 min-h-[34px]":"w-full border border-gray-200 rounded-md px-3 py-2 text-[13px] text-gray-700 min-h-[38px]";return p.jsx("div",{className:`${c} rich-text-content`,dangerouslySetInnerHTML:{__html:e||""}})}const l=o?`w-full ${a?"bg-red-100/90":"bg-white"}`:`w-full border rounded-md ${a?"border-red-200 bg-red-50":"border-gray-300 bg-amber-50/80 focus-within:border-indigo-400 focus-within:ring-2 focus-within:ring-indigo-100"}`;return p.jsxs("div",{className:l,children:[s&&p.jsx(RPe,{editor:s}),p.jsx(xG,{editor:s,className:"tiptap-editor rich-text-content overflow-hidden rounded-b-md",style:{minHeight:`${i}px`}})]})}function jPe(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:!0}function TPe(e,t){if(!e)return;const n=typeof e=="string"?e:JSON.stringify(e);function r(a){const i=a.indexOf(".");if(i!==-1){const l=a.slice(0,i),c=a.slice(i+1),u=t[l];if(!u)return{value:"",isArray:!1};try{const h=typeof u=="string"?JSON.parse(u):u;if(!Array.isArray(h))return{value:"",isArray:!1};const v=h.map(g=>g[c]).filter(g=>g!=null&&g!=="");return{value:JSON.stringify(v),isArray:!0}}catch{return{value:"",isArray:!1}}}const s=t[a]??"";return Array.isArray(s)?{value:JSON.stringify(s),isArray:!0}:{value:String(s),isArray:!1}}let o=n.replace(/"\{([^{}]+)\}"/g,(a,i)=>{const s=r(i);return s.isArray?s.value:`"${s.value}"`});return o=o.replace(/\{([^{}]+)\}/g,(a,i)=>{const s=r(i);return s.isArray,s.value}),o}function IPe(e,t,n,r){const o={};for(const a of t)!a.sourceField||!a.targetField||r?.skipExistingTargets&&jPe(n?.[a.targetField])||e[a.sourceField]!=null&&(o[a.targetField]=_x(e[a.sourceField]));return o}function DPe(e){return typeof e=="string"?e:e&&typeof e=="object"&&"field"in e?String(e.field):String(e)}function APe({field:e,value:t,onChange:n,onFillFields:r,isTableMode:o=!1,subTableCellMode:a=!1,hasError:i=!1,formValues:s}){const[l,c]=f.useState(!1),u=e.reference_to||"",h=!!e.pickerMultiple,v=(e.lookupDisplayFields||["name"]).map(DPe),g=v[0]||"name",b=e.lookupSortField||"",x=e.lookupSortOrder||"asc",y=f.useMemo(()=>!h&&e.lookupFillRules||[],[h,e.lookupFillRules]),N=f.useMemo(()=>TPe(e.lookupFilters,s||{}),[e.lookupFilters,s]),E=f.useMemo(()=>bN(t),[t]),C=f.useCallback((A,P,z)=>{if(!u||h||y.length===0||!r||!A)return;const V=B=>{const U=IPe(B,y,s,z);Object.keys(U).length>0&&r(U)},T=y.map(B=>B.sourceField).filter(Boolean);if(P&&T.every(B=>B in P)){V(P);return}const F=JSON.stringify(["_id","in",[A]]),I=["_id",...T].join(",");sc(u,{filters:F,fields:I,top:1}).then(({data:B})=>{B.length>0&&V(B[0])})},[u,h,y,r,s]),_=f.useRef(N);f.useEffect(()=>{const A=_.current;if(_.current=N,a||A===void 0||A===N||E.length===0||!u)return;const P=JSON.stringify(["_id","in",E]),z=N?JSON.stringify([JSON.parse(P),"and",JSON.parse(N)]):P;sc(u,{filters:z,fields:"_id",top:E.length}).then(({data:V})=>{const T=new Set(V.map(I=>I._id)),F=E.filter(I=>T.has(I));F.length!==E.length&&n($v(F,h))})},[N]);const[$,M]=f.useState(new Map);f.useEffect(()=>{if(!u||E.length===0)return;const A=E.filter(z=>!$.has(z));if(A.length===0)return;const P=JSON.stringify(["_id","in",A]);sc(u,{filters:P,fields:`_id,${g}`,top:A.length}).then(({data:z})=>{M(V=>{const T=new Map(V);for(const F of z)T.set(F._id,F[g]||F._id);return T})})},[u,E.join(","),g]);const j=f.useRef("");f.useEffect(()=>{if(h||E.length!==1||y.length===0||!r)return;const A=JSON.stringify({objectName:u,id:E[0],rules:y});j.current!==A&&(j.current=A,C(E[0],void 0,{skipExistingTargets:!0}))},[u,h,E.join(","),y,r,C]);const D=f.useCallback(A=>{const P=E.filter(z=>z!==A);if(n($v(P,h)),!h&&P.length===0&&y.length>0&&r){const z={};for(const V of y)V.targetField&&(z[V.targetField]="");Object.keys(z).length>0&&r(z)}},[E,n,h,y,r]),R=f.useCallback((A,P,z)=>{n($v(A,h)),M(V=>{const T=new Map(V);for(const[F,I]of P)T.set(F,I);return T}),c(!1),!h&&A.length===1&&C(A[0],z)},[n,h,C]);return e.readonly?p.jsx("div",{className:`${o?a?"px-1.5 py-1.5":"px-2.5 py-2":"border border-gray-200 rounded-md px-3 py-2"} bg-gray-50/60 min-h-[30px]`,children:E.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1.5",children:E.map(A=>p.jsx("span",{className:"inline-flex items-center gap-1 text-[13px] text-slate-700 rounded pr-2 py-0.5",children:$.get(A)||A},A))})}):p.jsxs(p.Fragment,{children:[p.jsx("div",{onClick:()=>u&&c(!0),className:`cursor-pointer smooth-transition ${o?a?`w-full px-1.5 py-1.5 min-h-[30px] border-0 rounded-none shadow-none ${i?"bg-red-100/90":"bg-transparent hover:bg-blue-50/40"}`:`w-full px-2.5 py-1.5 min-h-[34px] ${i?"bg-red-100/90":"bg-amber-50/80 hover:bg-amber-50"}`:`border rounded-md px-3 py-2 min-h-[38px] ${i?"border-red-200 bg-red-50":"border-gray-300 bg-amber-50/80 hover:border-indigo-300"}`}`,children:E.length>0?p.jsx("div",{className:"flex flex-wrap gap-1.5 items-center",children:E.map(A=>p.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] bg-indigo-50 text-indigo-700 border border-indigo-200 rounded-md px-2 py-0.5 max-w-[200px]",children:[p.jsx("span",{className:"truncate",children:$.get(A)||A}),p.jsx(Zr,{className:"w-3 h-3 text-indigo-300 hover:text-red-500 shrink-0 cursor-pointer",onClick:P=>{P.stopPropagation(),D(A)}})]},A))}):p.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[p.jsx(XB,{className:"w-4 h-4 shrink-0"}),p.jsx("span",{className:"text-[13px]",children:u?"选择数据":"请先配置关联对象"}),p.jsx(qi,{className:"w-3.5 h-3.5 ml-auto shrink-0"})]})}),l&&p.jsx(eX,{objectName:u,displayFields:v,multiple:h,selectedIds:E,filters:N,sortField:b,sortOrder:x,onConfirm:R,onClose:()=>c(!1)})]})}function eX({objectName:e,displayFields:t,multiple:n,selectedIds:r,filters:o,sortField:a,sortOrder:i,onConfirm:s,onClose:l}){const[c,u]=f.useState([]),[h,v]=f.useState(0),[g,b]=f.useState(!1),[x,y]=f.useState(1),[N,E]=f.useState(""),[C,_]=f.useState(new Set(r)),[$,M]=f.useState([]),j=10,D=f.useRef(void 0),R=t[0]||"name";f.useEffect(()=>{Kv(e).then(M)},[e]);const A=f.useMemo(()=>{const I=new Map;for(const B of $)I.set(B.value,B.label);return I},[$]),P=f.useCallback(async(I,B)=>{b(!0);try{const U=[];o&&U.push(o),B&&U.push(JSON.stringify([R,"contains",B]));let Q;U.length===2?Q=JSON.stringify([JSON.parse(U[0]),"and",JSON.parse(U[1])]):U.length===1&&(Q=U[0]);const J=["_id",...t].join(","),L=await sc(e,{filters:Q,fields:J,top:j,skip:(I-1)*j,sort:`${a||R} ${i||"asc"}`});u(L.data),v(L.total)}finally{b(!1)}},[e,t,R,o,a,i]);f.useEffect(()=>{P(x,N)},[x]);const z=f.useCallback(I=>{E(I),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{y(1),P(1,I)},300)},[P]),V=f.useMemo(()=>t.map(I=>{const B=typeof I=="string"?I:I&&typeof I=="object"&&"field"in I?String(I.field):String(I);return{title:A.get(B)||B,dataIndex:B,key:B,ellipsis:!0,render:U=>U!=null?String(U):"-"}}),[t,A]),T=f.useMemo(()=>({type:n?"checkbox":"radio",selectedRowKeys:[...C],onChange:I=>{if(_(new Set(I)),!n&&I.length>0){const B=I[0],U=c.find(J=>J._id===B),Q=new Map;U&&Q.set(B,U[R]||B),s([B],Q,U)}}}),[n,C,c,R,s]),F=()=>{const I=new Map;for(const B of c){const U=B._id;C.has(U)&&I.set(U,B[R]||U)}s([...C],I)};return p.jsx(uo,{locale:Ta,children:p.jsxs(Ao,{open:!0,title:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(XB,{className:"w-4 h-4 text-indigo-500"}),p.jsx("span",{children:"选择数据"})]}),width:Math.min(960,window.innerWidth-32),onCancel:l,onOk:n?F:void 0,okText:n?`确定${C.size>0?` (${C.size})`:""}`:void 0,cancelText:"取消",footer:n?void 0:null,destroyOnClose:!0,styles:{body:{padding:"12px 0"}},children:[p.jsx("div",{style:{padding:"0 0 12px"},children:p.jsx(_s.Search,{placeholder:`搜索 ${A.get(R)||R}...`,allowClear:!0,onChange:I=>z(I.target.value),style:{width:"100%"}})}),p.jsx(hd,{rowKey:"_id",columns:V,dataSource:c,loading:g,rowSelection:T,pagination:{current:x,pageSize:j,total:h,size:"small",showSizeChanger:!1,showTotal:I=>`共 ${I} 条`,onChange:I=>y(I)},size:"small",scroll:{x:"max-content"},style:{fontSize:13},onRow:I=>({onClick:()=>{const B=I._id;if(n)_(U=>{const Q=new Set(U);return Q.has(B)?Q.delete(B):Q.add(B),Q});else{const U=new Map;U.set(B,I[R]||B),s([B],U,I)}},style:{cursor:"pointer"}})})]})})}const PPe=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/;function $T(e,t){return!e||!e.trim()?!1:t?!/[{}]/.test(e):PPe.test(e)}function tX(e,t){if(t)return e.replace(/[{}]/g,"");let n=e.replace(/[^a-zA-Z0-9_$]/g,"_");return n&&/^[0-9]/.test(n)&&(n="_"+n),n}const LPe=[{id:"basic",label:"基础"},{id:"fields",label:"字段"},{id:"validation",label:"验证"}];function zPe(){const e=Vt(C=>C.selectedFieldId),t=Vt(C=>C.fields),n=Vt(C=>C.updateField),r=Vt(C=>C.selectField),o=Vt(C=>C.removeChildField),a=Vt(C=>C.updateChildField),i=Vt(C=>C.reorderChildFields),s=Vt(C=>C.viewMode),l=Vt(C=>C.tableColumns),c=Vt(C=>C.flowSteps),u=Vt(C=>C.chineseFieldNames),[h,v]=f.useState("basic");f.useEffect(()=>{v("basic")},[e]);let g=t.find(C=>C._id===e),b=null;if(!g){for(const C of t)if(C.children){const _=C.children.find($=>$._id===e);if(_){g=_,b=C._id;break}}}const x=b?t.find(C=>C._id===b)?.type==="grid":!1,y=b?t.find(C=>C._id===b)?.type==="table":!1,N=y?t.find(C=>C._id===b)?.children||[]:[];if(!g)return p.jsx(BPe,{});const E=C=>{b?a(b,e,C):n(e,C)};return p.jsxs("aside",{className:"flex-shrink-0 w-[365px] border-l border-gray-200 bg-white flex flex-col",children:[p.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-100",children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[p.jsx("h2",{className:"text-xs font-semibold text-gray-600 truncate",children:g.label||"字段属性"}),p.jsx("span",{className:"text-[10px] text-gray-400 bg-gray-100 rounded px-1.5 py-0.5 shrink-0",children:wm[g.type]})]}),p.jsx("button",{onClick:()=>r(null),className:"rounded p-1 text-gray-400 hover:text-gray-600 hover:bg-gray-100 smooth-transition shrink-0",children:p.jsx(Zr,{className:"w-3.5 h-3.5"})})]}),p.jsx("div",{className:"flex border-b border-gray-100 bg-gray-50/60",children:LPe.filter(C=>!(C.id==="validation"&&g.type==="section"||C.id==="fields"&&g.type!=="table")).map(C=>p.jsx("button",{onClick:()=>v(C.id),className:`flex-1 py-2 text-[12px] font-medium smooth-transition border-b-2 -mb-px ${h===C.id?"border-indigo-500 text-indigo-600 bg-white":"border-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`,children:C.label},C.id))}),p.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[h==="basic"&&p.jsxs("div",{className:"px-3 py-3 space-y-4",children:[p.jsx(Bn,{label:"字段标签",required:!0,children:p.jsx("input",{value:g.label,onChange:C=>E({label:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"输入标签"})}),!["section","grid"].includes(g.type)&&p.jsxs(Bn,{label:"字段名称",required:!0,hint:g.name==="__applicant"?"系统内置字段,名称不可修改":u?"支持中文、英文、特殊符号,不能包含 { }":"字母/下划线开头,仅含字母、数字、下划线",children:[p.jsx("input",{value:g.name==="__applicant"?"applicant":g.name,onChange:C=>E({name:tX(C.target.value,u)}),readOnly:g.name==="__applicant",className:`w-full border rounded-md px-2.5 py-1.5 text-[13px] font-mono outline-none focus:ring-1 smooth-transition ${g.name==="__applicant"?"border-gray-200 bg-gray-50 text-gray-500 cursor-not-allowed":g.name&&!$T(g.name,u)?"border-red-300 focus:border-red-400 focus:ring-red-200":"border-gray-200 focus:border-indigo-400 focus:ring-indigo-200"}`,placeholder:u?"字段名称":"field_name"}),g.name&&!$T(g.name,u)&&p.jsx("p",{className:"text-[10px] text-red-500 mt-0.5",children:u?"字段名称不能为空,且不能包含 { }":"字段名必须以字母或下划线开头,仅包含字母、数字、下划线"})]}),g.type==="formula"&&p.jsx(Bn,{label:"值类型",hint:"字段值的数据类型",children:p.jsx("select",{value:g.valueType||Kj[g.type],onChange:C=>E({valueType:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:Object.entries(tRe).map(([C,_])=>p.jsx("option",{value:C,children:_},C))})}),g.type==="formula"&&(g.valueType||Kj[g.type])==="number"&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"数值格式"}),p.jsx("div",{className:"grid grid-cols-1 gap-2",children:p.jsx(Bn,{label:"精度",children:p.jsx("input",{type:"number",value:g.precision??"",onChange:C=>E({precision:C.target.value?Number(C.target.value):void 0}),className:"w-full border border-gray-200 rounded-md px-2 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition"})})}),p.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:!!g.thousandSeparator,onChange:C=>E({thousandSeparator:C.target.checked}),className:"w-3.5 h-3.5 accent-indigo-500"}),p.jsx("span",{className:"text-[13px] text-gray-600",children:"显示千位分隔符"})]})]}),p.jsx(Bn,{label:"描述",children:p.jsx("textarea",{value:g.description||"",onChange:C=>E({description:C.target.value}),rows:2,className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition resize-none",placeholder:"字段描述"})}),["text","textarea","number","email","url","password","richtext"].includes(g.type)&&p.jsx(Bn,{label:"占位符",children:p.jsx("input",{value:g.placeholder||"",onChange:C=>E({placeholder:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"请输入..."})}),!["section","table","approvalComments","grid","autoNumber"].includes(g.type)&&p.jsx(Bn,{label:"默认值",children:g.type==="richtext"?p.jsx(ZPe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):["date","datetime","time"].includes(g.type)?p.jsx(QPe,{fieldType:g.type,value:g.defaultValue||"",onChange:C=>E({defaultValue:C}),defaultHour:g.defaultHour,defaultMinute:g.defaultMinute,onChangeTime:(C,_)=>E({defaultHour:C,defaultMinute:_})}):g.type==="member"&&!g.pickerMultiple?p.jsx(eLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):g.type==="org"&&!g.pickerMultiple?p.jsx(tLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C})}):g.type==="number"?p.jsx("input",{type:"number",value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"输入数值"}):g.type==="checkbox"?p.jsxs("select",{value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"",children:"(无)"}),p.jsx("option",{value:"false",children:"否"}),p.jsx("option",{value:"true",children:"是"})]}):g.type==="radio"?p.jsxs("select",{value:g.defaultValue??"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"",children:"(无)"}),(g.options||[]).map(C=>p.jsx("option",{value:C.value,children:C.label},C.value))]}):g.type==="checkboxGroup"?p.jsx(uo,{locale:Ta,children:p.jsx(la,{mode:"multiple",allowClear:!0,placeholder:"选择默认值",value:g.defaultValue?String(g.defaultValue).split(",").map(C=>C.trim()).filter(Boolean):[],onChange:C=>E({defaultValue:C.length>0?C.join(","):""}),options:(g.options||[]).map(C=>({label:C.label,value:C.value})),className:"w-full",size:"small"})}):g.type==="lookup"?p.jsx(nLe,{value:g.defaultValue||"",onChange:C=>E({defaultValue:C}),field:g}):p.jsx("input",{value:g.defaultValue||"",onChange:C=>E({defaultValue:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"默认值"})}),["select","multiSelect","checkbox","checkboxGroup","radio"].includes(g.type)&&p.jsx(rLe,{fieldId:g._id,options:g.options||[],onChange:C=>E({options:C})}),g.type==="formula"&&p.jsx(Bn,{label:"公式表达式",hint:"用 ${} 包裹公式,内部直接用字段名",children:p.jsx(Sje,{value:g.formula||"",onChange:C=>E({formula:C}),fieldId:g._id})}),g.type==="autoNumber"&&p.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-3",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"自动编号设置"}),p.jsx(Bn,{label:"规则名称",hint:"可选。留空时按表单和字段自动生成",children:p.jsx("input",{value:g.auto_number_name||"",onChange:C=>E({auto_number_name:C.target.value||void 0}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"如 合同编号、档案借用"})}),p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx(Bn,{label:"前缀",children:p.jsx("input",{value:g.autoNumberPrefix||"",onChange:C=>E({autoNumberPrefix:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"如 SN-"})}),p.jsx(Bn,{label:"后缀",children:p.jsx("input",{value:g.autoNumberSuffix||"",onChange:C=>E({autoNumberSuffix:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"可留空"})})]}),p.jsx(Bn,{label:"日期格式",hint:"在编号中插入日期片段",children:p.jsxs("select",{value:g.autoNumberDateFormat??"YYYYMM",onChange:C=>E({autoNumberDateFormat:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"none",children:"不用日期"}),p.jsx("option",{value:"YYYY",children:"年份(YYYY)"}),p.jsx("option",{value:"YYYYMM",children:"年月(YYYYMM)"}),p.jsx("option",{value:"YYYYMMDD",children:"年月日(YYYYMMDD)"})]})}),p.jsx(Bn,{label:"序号位数",hint:"序号补零位数,如 4 → 0001",children:p.jsx("input",{type:"number",min:1,max:10,value:g.autoNumberPadding??4,onChange:C=>E({autoNumberPadding:C.target.value?Number(C.target.value):4}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition"})}),p.jsx(Bn,{label:"重置周期",hint:"计数器何时归零重新从 1 计起",children:p.jsxs("select",{value:g.autoNumberResetCycle??"monthly",onChange:C=>E({autoNumberResetCycle:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"none",children:"不重置"}),p.jsx("option",{value:"yearly",children:"每年"}),p.jsx("option",{value:"monthly",children:"每月"}),p.jsx("option",{value:"daily",children:"每天"})]})}),p.jsxs("div",{className:"rounded-md bg-sky-50 border border-sky-200 px-3 py-2 text-[12px] text-sky-700",children:[p.jsx("span",{className:"font-semibold mr-1",children:"预览:"}),(()=>{const C=g.autoNumberPrefix||"",_=g.autoNumberSuffix||"",$=g.autoNumberPadding??4,M=g.autoNumberDateFormat??"YYYYMM",j=new Date;let D="";M==="YYYY"?D=`${j.getFullYear()}`:M==="YYYYMM"?D=`${j.getFullYear()}${String(j.getMonth()+1).padStart(2,"0")}`:M==="YYYYMMDD"&&(D=`${j.getFullYear()}${String(j.getMonth()+1).padStart(2,"0")}${String(j.getDate()).padStart(2,"0")}`);const R="1".padStart($,"0");return D?`${C}${D}-${R}${_}`:`${C}${R}${_}`})()]})]}),g.type==="apiSelect"&&p.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-4",children:[p.jsxs("div",{className:"space-y-2.5",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"接口请求"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("select",{value:g.optionsMethod||"GET",onChange:C=>E({optionsMethod:C.target.value}),className:"w-[88px] shrink-0 border border-gray-200 rounded-md px-2 py-1.5 text-[13px] font-medium outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition bg-white",children:[p.jsx("option",{value:"GET",children:"GET"}),p.jsx("option",{value:"POST",children:"POST"}),p.jsx("option",{value:"PUT",children:"PUT"}),p.jsx("option",{value:"PATCH",children:"PATCH"}),p.jsx("option",{value:"DELETE",children:"DELETE"})]}),p.jsx("input",{value:g.optionsUrl||"",onChange:C=>E({optionsUrl:C.target.value}),className:"flex-1 min-w-0 border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"",required:!0})]})]}),p.jsxs("div",{className:"space-y-2.5",children:[p.jsx("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold",children:"字段映射"}),p.jsx(ys,{label:"允许多选",checked:!!g.optionsMultiple,onChange:C=>E({optionsMultiple:C})}),p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx(Bn,{label:"显示字段",hint:"用于显示的字段名",children:p.jsx("input",{value:g.optionsLabelField||"",onChange:C=>E({optionsLabelField:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"name"})}),p.jsx(Bn,{label:"值字段",hint:"用于存值的字段名",children:p.jsx("input",{value:g.optionsValueField||"",onChange:C=>E({optionsValueField:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition",placeholder:"_id"})})]})]}),p.jsxs("details",{className:"group",children:[p.jsxs("summary",{className:"text-[10px] text-gray-400 uppercase tracking-wider font-semibold cursor-pointer hover:text-gray-600 select-none flex items-center gap-1",children:[p.jsx(Ip,{className:"h-3 w-3 group-open:rotate-90 smooth-transition"}),"脚本"]}),p.jsxs("div",{className:"mt-2.5 space-y-2.5",children:[p.jsx(Bn,{label:"数据转换",hint:"参数 data(数组),返回 [{label, value}]",children:p.jsx("textarea",{value:g.optionsMapScript||"",onChange:C=>E({optionsMapScript:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition font-mono",placeholder:`return data.map(item => ({
|
|
754
754
|
label: item.name,
|
|
755
755
|
value: item.id
|
|
756
756
|
}))`,rows:4})}),p.jsx(Bn,{label:"请求前脚本",hint:"参数 (url, options, values),返回 {url, options}",children:p.jsx("textarea",{value:g.optionsBeforeScript||"",onChange:C=>E({optionsBeforeScript:C.target.value}),className:"w-full border border-gray-200 rounded-md px-2.5 py-1.5 text-[13px] outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200 smooth-transition font-mono",placeholder:`url += '?dept=' + values.department;
|
package/designer/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="shortcut icon" type="image/svg+xml" href="/images/logo.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>designer</title>
|
|
8
|
-
<script type="module" crossorigin src="/api/workflow/designer-v2/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/api/workflow/designer-v2/assets/index-B2ycAzXC.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/api/workflow/designer-v2/assets/index-CWhD6d5C.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -128,7 +128,7 @@ amis_schema: |-
|
|
|
128
128
|
]
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
-
"hiddenOn": "(window.Builder && window.Builder.settings && window.Builder.settings.STEEDOS_PUBLIC_WORKFLOW_READONLY === 'true') || !(record.box == 'draft' || (record.box == 'monitor' && context.user.is_space_admin) \n || (_.includes(record.flow.perms.users_can_admin, context.user.userId) \n || _.intersection(record.flow.perms.orgs_can_admin, context.user.organizations_parents) > 0)\n || (record.box == 'inbox' && record.state == 'draft' && record.forward_from_instance))"
|
|
131
|
+
"hiddenOn": "(window.Builder && window.Builder.settings && window.Builder.settings.STEEDOS_PUBLIC_WORKFLOW_READONLY === 'true') || !((record.box == 'draft' && record.state == 'draft') || (record.box == 'monitor' && context.user.is_space_admin) \n || (_.includes(record.flow.perms.users_can_admin, context.user.userId) \n || _.intersection(record.flow.perms.orgs_can_admin, context.user.organizations_parents) > 0)\n || (record.box == 'inbox' && record.state == 'draft' && record.forward_from_instance))"
|
|
132
132
|
}
|
|
133
133
|
],
|
|
134
134
|
"regions": [
|
|
@@ -39,11 +39,11 @@ amis_schema: |-
|
|
|
39
39
|
"api": {
|
|
40
40
|
"url": "${context.rootUrl}/api/workflow/retrieve",
|
|
41
41
|
"method": "post",
|
|
42
|
+
"silent": true,
|
|
42
43
|
"requestAdaptor": "api.data = {\n \"_id\": api.body.record._id,\n \"retrieve_comment\": api.body.retrieve_comment\n};\nreturn api;",
|
|
43
44
|
"adaptor": "if (payload && payload.status === -1) {\n return {...payload, status: 1, msg: payload.msg || '取回失败'};\n}\nreturn {...payload, status: 0, msg: payload && payload.msg ? payload.msg : '取回成功'};",
|
|
44
45
|
"messages": {
|
|
45
|
-
"success": "取回成功"
|
|
46
|
-
"failed": "${msg}"
|
|
46
|
+
"success": "取回成功"
|
|
47
47
|
},
|
|
48
48
|
"headers": {
|
|
49
49
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -56,7 +56,34 @@ amis_schema: |-
|
|
|
56
56
|
"onEvent": {
|
|
57
57
|
"submitFail": {
|
|
58
58
|
"weight": 0,
|
|
59
|
-
"actions": [
|
|
59
|
+
"actions": [
|
|
60
|
+
{
|
|
61
|
+
"actionType": "dialog",
|
|
62
|
+
"dialog": {
|
|
63
|
+
"type": "dialog",
|
|
64
|
+
"title": "无法取回",
|
|
65
|
+
"data": {
|
|
66
|
+
"__errorMsg": "${event.data.error.msg || event.data.error.message || event.data.error.response.msg || '取回失败,请稍后重试'}"
|
|
67
|
+
},
|
|
68
|
+
"body": [
|
|
69
|
+
{
|
|
70
|
+
"type": "tpl",
|
|
71
|
+
"tpl": "${__errorMsg}"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"actions": [
|
|
75
|
+
{
|
|
76
|
+
"type": "button",
|
|
77
|
+
"actionType": "cancel",
|
|
78
|
+
"label": "确定",
|
|
79
|
+
"primary": true
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"showCloseButton": true,
|
|
83
|
+
"closeOnEsc": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
60
87
|
},
|
|
61
88
|
"submitSucc": {
|
|
62
89
|
"weight": 0,
|
|
@@ -127,7 +154,7 @@ amis_schema: |-
|
|
|
127
154
|
]
|
|
128
155
|
}
|
|
129
156
|
},
|
|
130
|
-
"hiddenOn": "(window.Builder && window.Builder.settings && window.Builder.settings.STEEDOS_PUBLIC_WORKFLOW_READONLY === 'true') || !( (record.box === 'outbox' || record.box === 'pending') && record.state === 'pending')"
|
|
157
|
+
"hiddenOn": "(window.Builder && window.Builder.settings && window.Builder.settings.STEEDOS_PUBLIC_WORKFLOW_READONLY === 'true') || !( (record.box === 'outbox' || record.box === 'pending') && record.state === 'pending') || (function(){ try { var ts = record.traces || []; if (!ts.length) { return false; } var last = ts[ts.length - 1]; var isRead = false; (last.approves || []).forEach(function(a){ if (a.is_read === true) { isRead = true; } }); if (!isRead) { return false; } var pid = (last.previous_trace_ids || [])[0]; var prev = null; var guard = 0; while (pid && guard < ts.length) { guard++; prev = null; for (var j = 0; j < ts.length; j++) { if (ts[j]._id === pid) { prev = ts[j]; break; } } if (!prev || prev.judge !== 'skipped' || !prev.previous_trace_ids || !prev.previous_trace_ids.length) { break; } pid = prev.previous_trace_ids[0]; } var prevIsStart = !!prev && (!prev.previous_trace_ids || prev.previous_trace_ids.length === 0); return !prevIsStart; } catch (e) { return false; } })()"
|
|
131
158
|
}
|
|
132
159
|
],
|
|
133
160
|
"regions": [
|
|
@@ -7,7 +7,7 @@ amis_schema: |-
|
|
|
7
7
|
"label": "${'CustomAction.instances.instance_submit' | t}",
|
|
8
8
|
"level": "primary",
|
|
9
9
|
"id": "u:instance_submit",
|
|
10
|
-
"hiddenOn": "!(this.record.box === 'inbox' || this.record.box === 'draft')",
|
|
10
|
+
"hiddenOn": "!(this.record.box === 'inbox' || (this.record.box === 'draft' && this.record.state === 'draft'))",
|
|
11
11
|
"onEvent": {
|
|
12
12
|
"click": {
|
|
13
13
|
"weight": 0,
|
|
@@ -62,9 +62,14 @@ router.post('/api/workflow/remove', requireAuthentication, async function (req,
|
|
|
62
62
|
$in: space_user.organizations
|
|
63
63
|
}
|
|
64
64
|
}).fetch();
|
|
65
|
-
|
|
65
|
+
const isAdmin = space.admins.includes(current_user) || WorkflowManager.canAdmin(flow, space_user, spaceUserOrganizations);
|
|
66
|
+
if ((instance.submitter !== current_user) && !isAdmin) {
|
|
66
67
|
throw new Error("您不能删除此申请单。");
|
|
67
68
|
}
|
|
69
|
+
// 非草稿状态仅管理员可删(监控箱删单):防止申请人绕过「取回/取消申请」直接删掉审批中的单子
|
|
70
|
+
if (instance.state !== "draft" && !isAdmin) {
|
|
71
|
+
throw new Error(instance.state === "pending" ? "申请单正在审批中,不能删除,请先取回或取消申请。" : "申请单已结束,不能删除。");
|
|
72
|
+
}
|
|
68
73
|
delete_obj = db.instances.findOne(insId);
|
|
69
74
|
delete_obj.deleted = new Date;
|
|
70
75
|
delete_obj.deleted_by = current_user;
|
|
@@ -55,8 +55,11 @@ router.post('/api/workflow/retrieve', requireAuthentication, async function (req
|
|
|
55
55
|
var cc_users, flow, handler_info, i, ins, instance, instance_id, last_trace, last_trace_id, newApprove, newTrace, now, old_inbox_users, org_info, previous_step, previous_trace, previous_trace_approves, previous_trace_id, previous_trace_name, previous_trace_step_id, r, retrieve_approve, retrieve_comment, retrieve_type, setObj, space_id, space_user, the_trace, traces;
|
|
56
56
|
instance = await UUFlowManager.getInstance(hashData["_id"]);
|
|
57
57
|
retrieve_comment = hashData['retrieve_comment'];
|
|
58
|
-
// 验证instance
|
|
59
|
-
//
|
|
58
|
+
// 验证instance为审核中状态:已结束/已终止的申请单不允许取回(含传阅取回),
|
|
59
|
+
// 否则取回会把 state 重置为 pending,导致已结束的申请单被重新打开
|
|
60
|
+
if (instance.state !== 'pending') {
|
|
61
|
+
throw new Error(instance.state === 'draft' ? '草稿状态的申请单不能取回' : '申请单已结束,不能取回');
|
|
62
|
+
}
|
|
60
63
|
// 校验申请单是当前用户已审核过的单子或者当前用户是提交人或申请人
|
|
61
64
|
if ((!instance.outbox_users.includes(current_user)) && (instance.submitter !== current_user && instance.applicant !== current_user)) {
|
|
62
65
|
throw new Error('当前用户不符合取回条件');
|
|
@@ -328,6 +331,10 @@ router.post('/api/workflow/retrieve', requireAuthentication, async function (req
|
|
|
328
331
|
ins = UUFlowManager.getInstance(instance_id);
|
|
329
332
|
// 如果已经配置webhook并已激活则触发
|
|
330
333
|
await pushManager.triggerWebhook(ins.flow, ins, {}, 'retrieve', current_user, [current_user]);
|
|
334
|
+
} else {
|
|
335
|
+
// 既不满足正常取回条件(上一步唯一处理人是当前用户),也没有可取回的传阅记录,
|
|
336
|
+
// 不能静默返回成功,否则前端只会刷新页面、用户误以为取回成功
|
|
337
|
+
throw new Error('仅上一步唯一处理人可以取回,当前用户不符合取回条件');
|
|
331
338
|
}
|
|
332
339
|
|
|
333
340
|
res.status(200).send({
|
|
@@ -48,9 +48,14 @@ router.post('/api/workflow/v2/remove', requireAuthentication, async function (re
|
|
|
48
48
|
$in: space_user.organizations
|
|
49
49
|
}
|
|
50
50
|
}).toArray();
|
|
51
|
-
|
|
51
|
+
const isAdmin = space.admins.includes(current_user) || WorkflowManager.canAdmin(flow, space_user, spaceUserOrganizations);
|
|
52
|
+
if ((instance.submitter !== current_user) && !isAdmin) {
|
|
52
53
|
throw new Error("您不能删除此申请单。");
|
|
53
54
|
}
|
|
55
|
+
// 非草稿状态仅管理员可删(监控箱删单):防止申请人借「草稿」视图参数绕过「取回/取消申请」直接删掉审批中的单子
|
|
56
|
+
if (instance.state !== "draft" && !isAdmin) {
|
|
57
|
+
throw new Error(instance.state === "pending" ? "申请单正在审批中,不能删除,请先取回或取消申请。" : "申请单已结束,不能删除。");
|
|
58
|
+
}
|
|
54
59
|
delete_obj = await db.instances.findOne({_id: data._id});
|
|
55
60
|
delete_obj.deleted = new Date;
|
|
56
61
|
delete_obj.deleted_by = current_user;
|