@akairos/myno 0.2.0 → 0.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"article-menu.d.ts","sourceRoot":"","sources":["../../src/editor/article-menu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAc9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CActD;AAKD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;IA+BvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,eAAO,MAAM,WAAW,UAAgC,CAAC;AAEzD,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,UAAQ,QA6DpE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,QAanC;AAED,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAe/E,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,CA6BlF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,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,9 @@ export function applyInline(ctx, item, slash = false) {
114
114
  tr.removeMark(from, to, markType);
115
115
  }
116
116
  else {
117
- // 切换徽章类型时,先清除已存在的旧徽章/行内标记
118
- if (item.mark === "badge") {
119
- const badgeMark = state.schema.marks.badge;
120
- if (badgeMark)
121
- tr.removeMark(from, to, badgeMark);
122
- }
123
- else if (item.mark === "kbd") {
124
- const kbdMark = state.schema.marks.kbd;
125
- if (kbdMark)
126
- tr.removeMark(from, to, kbdMark);
117
+ // 徽章和按键使用纯文字,避免保存成解析器不支持的嵌套 Markdown(如 **[[kbd:…]]** 往返丢失)。
118
+ if (item.mark === "badge" || item.mark === "kbd") {
119
+ tr.removeMark(from, to);
127
120
  }
128
121
  else if (item.mark === "highlight") {
129
122
  for (const name of inlineMarks) {
@@ -1 +1 @@
1
- {"version":3,"file":"article-menu.js","sourceRoot":"","sources":["../../src/editor/article-menu.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACpC,IAAI,IAAI,IAAK,IAAY,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;IACb,CAAC;IACD,IAAI,CAAC;QACH,MAAM,IAAI,GAAI,GAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC5C,IAAI,IAAI,IAAK,IAAY,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,SAAS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G,SAAS,CAAC,GAAG,CAAC,CAAC;gBAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;oBAAE,OAAO;gBAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAClC,IAAI,CAAC,QAAQ;oBAAE,OAAO;gBACtB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;gBACvC,IAAI,CAAC,QAAQ,CACX,IAAI,CAAC,KAAK,CAAC,EAAE;qBACV,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;qBACzE,cAAc,EAAE,CACpB,CAAC;gBACF,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
package/dist/studio.js CHANGED
@@ -1916,7 +1916,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1916
1916
  d="m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z"
1917
1917
  />
1918
1918
  </svg>
1919
- `,$ke={[Et.CodeMirror]:{theme:r0e,languages:Upe,expandIcon:E9,searchIcon:jU,clearSearchIcon:T9,searchPlaceholder:"Search language",noResultText:"No result",previewToggleIcon:t=>t?hg:JU}},jke=Ct([],"FeaturesCtx"),Uke=Ct({},"CrepeCtx");function Kke(t){return t.get("CrepeCtx")}function rp(t){return t.use("FeaturesCtx")}function Ws(t){return e=>{rp(e).update(n=>n.includes(t)?n:[...n,t])}}function Gke(t,e){var n;const r=t.get(bt),i=t.get(Zu),{state:s}=r,o=i(s.doc);let a="";if(!s.selection.empty){const{from:l,to:c}=s.selection,u=s.doc.slice(l,c),{schema:h}=s.doc.type;let f=h.topNodeType.createAndFill(null,u.content);if(!f){const d=(n=h.nodes.paragraph)==null?void 0:n.createAndFill(null,u.content);d&&(f=h.topNodeType.createAndFill(null,d))}a=f?i(f):s.doc.textBetween(l,c)}return{document:o,selection:a,instruction:e}}const Od=St({provider:void 0,buildContext:void 0,diffReviewOnEnd:!0,onError:t=>{console.error(`[milkdown/ai] [${t.code}]`,t)},aiIcon:void 0},"aiProviderConfig"),sr=St({abortController:null,label:"",lastInstruction:"",lastLabel:void 0,lastFrom:-1,lastTo:-1,diffOwnedByAI:!1},"aiSession");function YU(t,e){const n=t.get(Od.key);try{n.onError(e)}catch(r){console.error("[milkdown/ai] onError handler failed:",r)}}function HA(t){const e=t.get(sr.key);t.set(sr.key,{...e,abortController:null,label:""})}async function Jke(t,e,n,r){try{const i=e(n,r.signal),s=t.get(Ce);for await(const l of i){if(r.signal.aborted)break;s.call(i8.key,l)}if(r.signal.aborted)return;const o=t.get(Od.key);if(o.diffReviewOnEnd){const l=t.get(sr.key);t.set(sr.key,{...l,diffOwnedByAI:!0})}const a=s.call(s8.key,{diffReview:o.diffReviewOnEnd});if(o.diffReviewOnEnd&&!a){const l=t.get(sr.key);t.set(sr.key,{...l,diffOwnedByAI:!1})}}catch(i){if(r.signal.aborted)return;const s=DJ(i);YU(t,s),t.get(Ce).call(jd.key,{keep:!1})}finally{t.get(sr.key).abortController===r&&HA(t)}}const _9=je("RunAI",t=>e=>(n,r)=>{var i,s,o,a;if(!e?.instruction)return!1;const l=t.get(Od.key);if(!l.provider||t.get(sr.key).abortController||(i=Yn.getState(n))!=null&&i.active||(s=Rn.getState(n))!=null&&s.active)return!1;if(!r)return!0;const u=new AbortController,{from:h,to:f}=n.selection;t.set(sr.key,{abortController:u,label:(o=e.label)!=null?o:"",lastInstruction:e.instruction,lastLabel:e.label,lastFrom:h,lastTo:f,diffOwnedByAI:!1});const d=t.get(Ce),p=n.selection.empty?"cursor":"selection";if(!d.call(r8.key,{insertAt:p}))return HA(t),!1;let m;try{m=((a=l.buildContext)!=null?a:Gke)(t,e.instruction)}catch(g){const y=BJ(g);return YU(t,y),d.call(jd.key,{keep:!1}),HA(t),!1}return Jke(t,l.provider,m,u),!0}),QU=je("AbortAI",t=>e=>(n,r)=>{var i;const s=t.get(sr.key);return r?s.abortController?(s.abortController.abort(),HA(t),(i=Yn.getState(n))!=null&&i.active&&t.get(Ce).call(jd.key,e),!0):!1:!!s.abortController});var ZU=t=>{throw TypeError(t)},R9=(t,e,n)=>e.has(t)||ZU("Cannot "+n),dr=(t,e,n)=>(R9(t,e,"read from private field"),n?n.call(t):e.get(t)),gs=(t,e,n)=>e.has(t)?ZU("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),So=(t,e,n,r)=>(R9(t,e,"write to private field"),e.set(t,n),n),ff=(t,e,n)=>(R9(t,e,"access private method"),n),b0,rv,v0,fg,iv,sv,uc,_f,Yl,XU,ov,eK,n6,tK,r6,i6;const Dd="milkdown-ai-diff-actions";function nK(t,e){t.innerHTML=zs.sanitize(e.trim())}function Yke(t){const e=document.createElement("span");return e.className=`${Dd}-icon`,nK(e,t),e}class Qke{constructor(e,n,r){this.ctx=e,gs(this,Yl),gs(this,b0),gs(this,rv),gs(this,v0),gs(this,fg),gs(this,iv,!1),gs(this,sv,!1),gs(this,uc,null),gs(this,_f,!1),gs(this,n6,()=>{const o=this.ctx.get(sr.key);if(!o.lastInstruction||!dr(this,_f)||!ff(this,Yl,tK).call(this))return;const a=this.ctx.get(Ce);a.call(uA.key);const l=this.ctx.get(bt),{doc:c}=l.state,u=Math.min(Math.max(o.lastFrom,0),c.content.size),h=Math.min(Math.max(o.lastTo,0),c.content.size);l.dispatch(l.state.tr.setSelection(qe.create(l.state.doc,u,h))),a.call(_9.key,{instruction:o.lastInstruction,label:o.lastLabel})}),gs(this,r6,()=>{this.ctx.get(Ce).call(uA.key)}),gs(this,i6,()=>{this.ctx.get(Ce).call(jw.key)}),So(this,fg,r),So(this,rv,ff(this,Yl,XU).call(this,n));const i=document.createElement("div");i.className=Dd,i.dataset.show="false",So(this,v0,ff(this,Yl,ov).call(this,"retry",r.retryIcon,r.retryLabel,dr(this,n6))),i.appendChild(dr(this,v0)),i.appendChild(ff(this,Yl,ov).call(this,"reject",r.rejectIcon,r.rejectAllLabel,dr(this,r6)));const s=ff(this,Yl,ov).call(this,"accept",r.acceptIcon,r.acceptAllLabel,dr(this,i6));s.appendChild(ff(this,Yl,eK).call(this)),i.appendChild(s),So(this,b0,i),dr(this,rv).appendChild(i),this.update(n)}update(e){var n;const r=!!((n=Rn.getState(e.state))!=null&&n.active);if(r!==dr(this,sv))if(So(this,sv,r),r){const s=this.ctx.get(sr.key);So(this,_f,s.diffOwnedByAI),So(this,uc,e.state.doc)}else{So(this,_f,!1),So(this,uc,null);const s=this.ctx.get(sr.key);s.diffOwnedByAI&&this.ctx.set(sr.key,{...s,diffOwnedByAI:!1})}const i=r&&dr(this,_f);if(i!==dr(this,iv)&&(So(this,iv,i),dr(this,b0).dataset.show=i?"true":"false"),i){const s=this.ctx.get(sr.key),o=!!dr(this,uc)&&e.state.doc.eq(dr(this,uc));dr(this,v0).disabled=!s.lastInstruction||!o}}destroy(){dr(this,b0).remove()}}b0=new WeakMap;rv=new WeakMap;v0=new WeakMap;fg=new WeakMap;iv=new WeakMap;sv=new WeakMap;uc=new WeakMap;_f=new WeakMap;Yl=new WeakSet;XU=function(t){var e;return(e=t.dom.closest(".milkdown"))!=null?e:document.body};ov=function(t,e,n,r){const i=document.createElement("button");i.type="button",i.className=`${Dd}-btn ${Dd}-btn-${t}`,i.appendChild(Yke(e));const s=document.createElement("span");return s.textContent=n,i.appendChild(s),i.addEventListener("mousedown",o=>o.preventDefault()),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r()}),i};eK=function(){const t=document.createElement("span");t.className=`${Dd}-shortcut`;const e=document.createElement("span");e.textContent=dr(this,fg).modSymbol;const n=document.createElement("span");return n.className=`${Dd}-shortcut-icon`,nK(n,dr(this,fg).enterKeyIcon),t.append(e,n),t};n6=new WeakMap;tK=function(){return dr(this,uc)?this.ctx.get(bt).state.doc.eq(dr(this,uc)):!1};r6=new WeakMap;i6=new WeakMap;const Zke=new Vt("CREPE_AI_DIFF_ACTIONS_PANEL"),Xke="Retry",e3e="Reject all",t3e="Accept all";function n3e(){var t,e,n,r;if(typeof navigator>"u")return"⌘";const i=navigator,s=(r=(n=(e=(t=i.userAgentData)==null?void 0:t.platform)!=null?e:i.platform)!=null?n:i.userAgent)!=null?r:"";return/mac|iphone|ipad|ipod/i.test(s)?"⌘":"Ctrl"}const r3e=n3e();function i3e(t){var e,n,r,i,s,o,a;const{config:l,enterKeyIcon:c}=t;return{retryLabel:(e=l?.retryLabel)!=null?e:Xke,rejectAllLabel:(n=l?.rejectAllLabel)!=null?n:e3e,acceptAllLabel:(r=l?.acceptAllLabel)!=null?r:t3e,retryIcon:(i=l?.retryIcon)!=null?i:zke,rejectIcon:(s=l?.rejectIcon)!=null?s:T9,acceptIcon:(o=l?.acceptIcon)!=null?o:z2,enterKeyIcon:c??HU,modSymbol:(a=l?.modSymbol)!=null?a:r3e}}function s3e(t={}){const e=i3e(t);return Qt(n=>new Bt({key:Zke,view(r){return new Qke(n,r,e)},props:{handleKeyDown(r,i){var s;return i.key!=="Enter"||!(i.metaKey||i.ctrlKey)||!((s=Rn.getState(r.state))!=null&&s.active)||!n.get(sr.key).diffOwnedByAI?!1:(i.preventDefault(),n.get(Ce).call(jw.key),!0)}}}))}var rK=t=>{throw TypeError(t)},iK=(t,e,n)=>e.has(t)||rK("Cannot "+n),Ma=(t,e,n)=>(iK(t,e,"read from private field"),n?n.call(t):e.get(t)),CD=(t,e,n)=>e.has(t)?rK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),SD=(t,e,n,r)=>(iK(t,e,"write to private field"),e.set(t,n),n),Mo,A0;function ED(t){const e={addItem:(n,r)=>(t.items.set(n,r),e),removeItem:n=>(t.items.delete(n),e),getItem:n=>t.items.get(n),clear:()=>(t.items.clear(),e)};return e}class o3e{constructor(){CD(this,Mo,[]),this.addItem=(e,n)=>(Ma(this,A0).call(this,e),Ma(this,Mo).push({kind:"item",id:e,item:n}),this),this.addSubmenu=(e,n,r)=>{Ma(this,A0).call(this,e);const i={def:n,items:new Map};return r&&r(ED(i)),Ma(this,Mo).push({kind:"submenu",id:e,node:i}),this},this.removeItem=e=>(Ma(this,A0).call(this,e),this),this.getItem=e=>{const n=Ma(this,Mo).find(r=>r.kind==="item"&&r.id===e);return n?.kind==="item"?n.item:void 0},this.getSubmenu=e=>{const n=Ma(this,Mo).find(r=>r.kind==="submenu"&&r.id===e);return n?.kind==="submenu"?ED(n.node):void 0},this.clear=()=>(SD(this,Mo,[]),this),this.build=()=>{const e=[],n={};for(const r of Ma(this,Mo))r.kind==="item"?e.push({kind:"item",id:r.id,item:r.item}):(e.push({kind:"submenu",id:r.id,def:r.node.def}),n[r.id]={def:r.node.def,items:Array.from(r.node.items.entries()).map(([i,s])=>({id:i,item:s}))});return{main:e,submenus:n}},CD(this,A0,e=>{SD(this,Mo,Ma(this,Mo).filter(n=>n.id!==e))})}}Mo=new WeakMap;A0=new WeakMap;function a3e(t){t.addItem("improve",{icon:S9,label:"Improve writing",streamingLabel:"Improving writing",prompt:"Improve the writing while preserving the original meaning."}).addItem("grammar",{icon:_ke,label:"Fix grammar & spelling",streamingLabel:"Fixing grammar & spelling",prompt:"Fix any grammar and spelling errors without changing the meaning."}).addItem("shorter",{icon:qke,label:"Make shorter",streamingLabel:"Making shorter",prompt:"Make this shorter while preserving the key information."}).addItem("longer",{icon:Lke,label:"Make longer",streamingLabel:"Expanding",prompt:"Expand this with more detail and examples."}),t.addSubmenu("tone",{icon:hg,label:"Change tone…",title:"Change tone",searchPlaceholder:"Search tones…"},e=>{const n=[["professional","Professional"],["casual","Casual"],["confident","Confident"],["friendly","Friendly"],["direct","Direct"],["formal","Formal"]];for(const[r,i]of n)e.addItem(r,{icon:hg,label:i,streamingLabel:"Adjusting tone",prompt:`Rewrite this in a ${i.toLowerCase()} tone.`})}),t.addSubmenu("translate",{icon:kD,label:"Translate…",title:"Translate",searchPlaceholder:"Search languages…"},e=>{const n=[["english","English","English"],["chinese","Chinese","Chinese (Simplified)"],["japanese","Japanese","Japanese"],["korean","Korean","Korean"],["spanish","Spanish","Spanish"],["french","French","French"],["german","German","German"]];for(const[r,i,s]of n)e.addItem(r,{icon:kD,label:i,streamingLabel:`Translating to ${i}`,prompt:`Translate this to ${s}.`})})}function Xc(...t){}Xc(W);function l3e(t,e){const n=e.trim();if(!n)return[t];const r=t.toLowerCase(),i=n.toLowerCase(),s=r.indexOf(i);return s===-1?[t]:[t.slice(0,s),W("mark",null,t.slice(s,s+n.length)),t.slice(s+n.length)]}const c3e=cr({props:{placeholder:{type:Object,required:!0},resetSignal:{type:Object,required:!0},suggestions:{type:Object,required:!0},chrome:{type:Object,required:!0},onConfirm:{type:Function,required:!0},onCancel:{type:Function,required:!0}},setup({placeholder:t,resetSignal:e,suggestions:n,chrome:r,onConfirm:i,onCancel:s}){const o=He(""),a=He({kind:"main"}),l=He(0),c=He(null),u=He(null),h=`ai-instruction-list-${Math.random().toString(36).slice(2,9)}`,f=B=>`${h}-opt-${B}`,d=`ai-instruction-input-${Math.random().toString(36).slice(2,9)}`;nl(e,()=>{o.value="",a.value={kind:"main"},l.value=0});const p=rs(()=>{if(a.value.kind==="submenu"){const B=n.submenus[a.value.id];return B?B.items.map(({id:K,item:U})=>({id:K,icon:U.icon,label:U.label,hasSubmenu:!1,prompt:{text:U.prompt,streamingLabel:U.streamingLabel}})):[]}return n.main.map(B=>B.kind==="item"?{id:B.id,icon:B.item.icon,label:B.item.label,hasSubmenu:!1,prompt:{text:B.item.prompt,streamingLabel:B.item.streamingLabel}}:{id:B.id,icon:B.def.icon,label:B.def.label,hasSubmenu:!0})}),m=rs(()=>{var B,K;return a.value.kind!=="submenu"?null:(K=(B=n.submenus[a.value.id])==null?void 0:B.def)!=null?K:null}),g=rs(()=>{const B=o.value.trim().toLowerCase();return B?p.value.filter(K=>K.label.toLowerCase().includes(B)):p.value}),y=rs(()=>o.value.trim().length>0),b=rs(()=>g.value.length+(y.value?1:0));nl([g,a,y],()=>{l.value=y.value?g.value.length:0});const v=()=>{fC(()=>{var B;return(B=c.value)==null?void 0:B.focus()})},A=B=>{a.value={kind:"submenu",id:B},o.value="",l.value=0,v()},k=()=>{a.value={kind:"main"},o.value="",l.value=0,v()},w=B=>{B.hasSubmenu?A(B.id):B.prompt&&(i(B.prompt.text,B.prompt.streamingLabel),o.value="")},S=()=>{const B=o.value.trim();B&&(i(B),o.value="")},_=()=>{const B=l.value,K=g.value;B<K.length?w(K[B]):y.value&&S()},I=()=>{fC(()=>{const B=u.value;if(!B)return;const K=B.querySelector(`[data-index="${l.value}"]`);K?.scrollIntoView({block:"nearest"})})},M=B=>{if(B.stopPropagation(),B.key==="ArrowDown"){if(B.preventDefault(),b.value===0)return;l.value=(l.value+1)%b.value,I();return}if(B.key==="ArrowUp"){if(B.preventDefault(),b.value===0)return;l.value=(l.value-1+b.value)%b.value,I();return}if(B.key==="Enter"){B.preventDefault(),_();return}if(B.key==="Escape"){B.preventDefault(),a.value.kind==="submenu"?k():s();return}B.key==="Backspace"&&o.value===""&&a.value.kind==="submenu"&&(B.preventDefault(),k())},F=B=>{B.preventDefault()};return()=>{const B=g.value,K=y.value,U=m.value;return W("div",{class:"ai-instruction"},W("div",{class:"ai-instruction-input"},W("span",{class:"ai-instruction-input-prefix"},W(ai,{icon:r.aiIcon})),W("input",{ref:c,id:d,class:"ai-instruction-input-field",role:"combobox","aria-expanded":"true","aria-autocomplete":"list","aria-controls":h,"aria-activedescendant":b.value>0?f(l.value):void 0,placeholder:U?U.searchPlaceholder:t.value,value:o.value,onInput:$=>{o.value=$.target.value},onKeydown:M}),W("button",{type:"button",class:"ai-instruction-submit","aria-label":r.submitButtonLabel,disabled:!K,onMousedown:F,onClick:S},W(ai,{icon:r.sendIcon}))),W("div",{class:"ai-instruction-list",ref:u,id:h,role:"listbox","aria-label":r.listboxLabel},U&&W("button",{type:"button",class:"ai-instruction-back",onMousedown:F,onClick:k},W("span",{class:"ai-instruction-back-icon","aria-hidden":"true"},W(ai,{icon:r.chevronLeftIcon})),W("span",null,U.title)),B.length>0&&W("div",{class:"ai-instruction-section"},W("div",{class:"ai-instruction-section-header"},r.suggestionsHeaderLabel),B.map(($,he)=>W("div",{key:$.id,id:f(he),"data-index":he,role:"option","aria-selected":he===l.value,class:["ai-instruction-item",he===l.value?"active":""],onMousedown:F,onClick:()=>w($),onPointerenter:()=>{l.value=he}},W("span",{class:"ai-instruction-item-icon"},W(ai,{icon:$.icon})),W("span",{class:"ai-instruction-item-label"},l3e($.label,o.value)),$.hasSubmenu&&W("span",{class:"ai-instruction-item-arrow"},W(ai,{icon:r.chevronRightIcon}))))),K&&W("div",{class:"ai-instruction-section"},W("div",{class:"ai-instruction-section-header"},r.sendAsPromptHeaderLabel),W("div",{id:f(B.length),"data-index":B.length,role:"option","aria-selected":l.value===B.length,class:["ai-instruction-item","ai-instruction-item-prompt",l.value===B.length?"active":""],onMousedown:F,onClick:S,onPointerenter:()=>{l.value=B.length}},W("span",{class:"ai-instruction-item-icon"},W(ai,{icon:r.sendPromptIcon})),W("span",{class:"ai-instruction-item-label"},r.sendAsPromptLabel," ",W("span",{class:"ai-instruction-item-quote"},'"',o.value,'"')),W("span",{class:"ai-instruction-item-shortcut"},W(ai,{icon:r.enterKeyIcon}))))))}}});var sK=t=>{throw TypeError(t)},oK=(t,e,n)=>e.has(t)||sK("Cannot "+n),zn=(t,e,n)=>(oK(t,e,"read from private field"),n?n.call(t):e.get(t)),Eo=(t,e,n)=>e.has(t)?sK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),ys=(t,e,n,r)=>(oK(t,e,"write to private field"),e.set(t,n),n),Su,Gs,av,lv,w0,cv,uv,Ql,s6,o6;class u3e{constructor(e,n,r){this.ctx=e,Eo(this,Su),Eo(this,Gs),Eo(this,av),Eo(this,lv),Eo(this,w0),Eo(this,cv,-1),Eo(this,uv,-1),Eo(this,Ql,!1),Eo(this,s6,(o,a)=>{!o.trim()||!this.ctx.get(Ce).call(_9.key,{instruction:o,label:a})||(ys(this,Ql,!1),zn(this,Gs).hide())}),Eo(this,o6,()=>{ys(this,Ql,!1),zn(this,Gs).hide()}),this.show=(o,a)=>{ys(this,cv,o),ys(this,uv,a),zn(this,w0).value++,ys(this,Ql,!0);const l=this.ctx.get(bt);zn(this,Gs).show({getBoundingClientRect:()=>Lg(l,o,a)},l),requestAnimationFrame(()=>{var c;(c=zn(this,Su).querySelector("input"))==null||c.focus()})},this.update=(o,a)=>{const{selection:l}=o.state,c=l instanceof qe,u=l.from!==zn(this,cv)||l.to!==zn(this,uv);if(!c||u){ys(this,Ql,!1),zn(this,Gs).hide();return}zn(this,Gs).update(o,a)},this.destroy=()=>{zn(this,av).unmount(),zn(this,Gs).destroy(),zn(this,Su).remove()},ys(this,lv,He(r.placeholder)),ys(this,w0,He(0));const i=document.createElement("div");i.className="milkdown-ai-instruction";const s=fs(c3e,{placeholder:zn(this,lv),resetSignal:zn(this,w0),suggestions:r.suggestions,chrome:r.chrome,onConfirm:zn(this,s6),onCancel:zn(this,o6)});s.mount(i),ys(this,av,s),ys(this,Su,i),ys(this,Gs,new r1({content:i,debounce:0,offset:10,shouldShow:()=>zn(this,Ql),floatingUIOptions:{placement:"bottom"}})),zn(this,Gs).onHide=()=>{ys(this,Ql,!1),requestAnimationFrame(()=>{try{const a=zn(this,Su).getRootNode().activeElement;if(!a||!zn(this,Su).contains(a))return;this.ctx.get(bt).dom.focus({preventScroll:!0})}catch{}})},zn(this,Gs).update(n)}}Su=new WeakMap;Gs=new WeakMap;av=new WeakMap;lv=new WeakMap;w0=new WeakMap;cv=new WeakMap;uv=new WeakMap;Ql=new WeakMap;s6=new WeakMap;o6=new WeakMap;const h3e={show:()=>{}},O9=St({...h3e},"aiInstructionTooltipAPI"),aK=i1("CREPE_AI_INSTRUCTION"),f3e="SUGGESTIONS",d3e="SEND AS PROMPT",p3e="Ask AI:",m3e="Send prompt",g3e="AI suggestions",y3e="Tell AI what to do with the selection…";function b3e(t){var e,n,r,i,s,o,a,l,c,u,h;return{aiIcon:(e=t?.aiIcon)!=null?e:S9,sendIcon:(n=t?.sendIcon)!=null?n:Hke,sendPromptIcon:(r=t?.sendPromptIcon)!=null?r:Wke,enterKeyIcon:(i=t?.enterKeyIcon)!=null?i:HU,chevronLeftIcon:(s=t?.chevronLeftIcon)!=null?s:Tke,chevronRightIcon:(o=t?.chevronRightIcon)!=null?o:Ike,suggestionsHeaderLabel:(a=t?.suggestionsHeaderLabel)!=null?a:f3e,sendAsPromptHeaderLabel:(l=t?.sendAsPromptHeaderLabel)!=null?l:d3e,sendAsPromptLabel:(c=t?.sendAsPromptLabel)!=null?c:p3e,submitButtonLabel:(u=t?.submitButtonLabel)!=null?u:m3e,listboxLabel:(h=t?.listboxLabel)!=null?h:g3e}}function v3e(t){var e,n;const r=new o3e;return a3e(r),(e=t?.buildAISuggestions)==null||e.call(t,r),{placeholder:(n=t?.instructionPlaceholder)!=null?n:y3e,chrome:b3e(t),suggestions:r.build()}}function A3e(t){return e=>{const n=v3e(t);let r=null;e.update(O9.key,i=>({...i,show:(s,o)=>{r?.show(s,o)}})),e.set(aK.key,{view:i=>(r=new u3e(e,i,n),r)})}}var lK=t=>{throw TypeError(t)},cK=(t,e,n)=>e.has(t)||lK("Cannot "+n),_a=(t,e,n)=>(cK(t,e,"read from private field"),n?n.call(t):e.get(t)),mu=(t,e,n)=>e.has(t)?lK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),df=(t,e,n,r)=>(cK(t,e,"write to private field"),e.set(t,n),n),hv,fv,dv,a6,pv,Rf,mv;const Gy="milkdown-ai-streaming",w3e=800,x3e="Generating",k3e="Esc to cancel",TD=new Vt("CREPE_AI_STREAMING_INDICATOR");class C3e{constructor(e,n,r){mu(this,hv),mu(this,fv),mu(this,dv),mu(this,a6,performance.now()),mu(this,pv,""),mu(this,Rf,0),mu(this,mv,()=>{const c=(performance.now()-_a(this,a6))/w3e*360;_a(this,hv).style.transform=`rotate(${c}deg)`,df(this,Rf,requestAnimationFrame(_a(this,mv)))}),df(this,dv,n);const i=document.createElement("span");i.className=`${Gy}-indicator`,i.contentEditable="false",i.setAttribute("role","status"),i.setAttribute("aria-live","polite");const s=document.createElement("span");s.className=`${Gy}-spinner`,s.setAttribute("aria-hidden","true"),i.appendChild(s);const o=document.createElement("span");o.className=`${Gy}-label`,i.appendChild(o);const a=document.createElement("span");a.className=`${Gy}-esc`,a.textContent=r,i.appendChild(a),this.dom=i,df(this,hv,s),df(this,fv,o),this.setLabel(e),_a(this,mv).call(this)}setLabel(e){const r=`${e.get(sr.key).label||_a(this,dv)}…`;r!==_a(this,pv)&&(df(this,pv,r),_a(this,fv).textContent=r)}destroy(){_a(this,Rf)&&cancelAnimationFrame(_a(this,Rf)),df(this,Rf,0)}}hv=new WeakMap;fv=new WeakMap;dv=new WeakMap;a6=new WeakMap;pv=new WeakMap;Rf=new WeakMap;mv=new WeakMap;function S3e(t={}){var e,n;const{config:r}=t,i=(e=r?.fallbackLabel)!=null?e:x3e,s=(n=r?.cancelHint)!=null?n:k3e;return Qt(o=>{let a=null;function l(){return a?a.setLabel(o):a=new C3e(o,i,s),a}function c(){a&&(a.destroy(),a=null)}function u(h,f){const d=Math.min(f,h.content.size),p=Cn.widget(d,l().dom,{side:1,key:"ai-streaming-indicator"});return It.create(h,[p])}return new Bt({key:TD,state:{init:()=>It.empty,apply(h,f,d,p){const m=Yn.getState(p);return!m?.active||m.insertEndPos==null?(c(),It.empty):h.getMeta(Yn)||h.docChanged?u(p.doc,m.insertEndPos):f.map(h.mapping,h.doc)}},view(){return{destroy(){c()}}},props:{decorations(h){var f;return(f=TD.getState(h))!=null?f:It.empty},handleKeyDown(h,f){var d;if(f.key!=="Escape")return!1;const p=o.get(Ce);return o.get(sr.key).abortController?(f.preventDefault(),p.call(QU.key,{keep:!0}),!0):(d=Yn.getState(h.state))!=null&&d.active?(f.preventDefault(),p.call(jd.key,{keep:!0}),!0):!1}}})})}const E3e=["table","image-block","code_block"],ID={heading:["id"]},T3e=(t,e)=>{var n,r;const i=(n=e?.diff)!=null?n:{},s=(r=e?.streaming)!=null?r:{};t.config(Ws(Et.AI)).config(o=>{o.update($w.key,c=>{var u;return{...c,ignoreAttrs:(u=i.ignoreAttrs)!=null?u:ID}});const{ignoreAttrs:a,...l}=i;o.update(Uw.key,c=>{var u;return{...c,customBlockTypes:(u=l.customBlockTypes)!=null?u:E3e,...l}})}).use(C0e).use(H0e).config(o=>{o.update(Vh.key,a=>{var l;return{...a,...s,ignoreAttrs:(l=s.ignoreAttrs)!=null?l:ID,...e?.diffReviewOnEnd!==void 0?{diffReviewOnEnd:e.diffReviewOnEnd}:{}}})}).use(X0e).config(o=>{o.update(Od.key,a=>{var l;return{...a,...e?.provider!==void 0?{provider:e.provider}:{},...e?.buildContext!==void 0?{buildContext:e.buildContext}:{},diffReviewOnEnd:(l=e?.diffReviewOnEnd)!=null?l:a.diffReviewOnEnd,...e?.onError!==void 0?{onError:e.onError}:{},...e?.aiIcon!==void 0?{aiIcon:e.aiIcon}:{}}})}).use(Od).use(sr).use(_9).use(QU).config(A3e(e)).use(O9).use(aK).use(S3e({config:e?.streamingIndicator})).use(s3e({config:e?.diffActions,enterKeyIcon:e?.enterKeyIcon}))};function uK(t){return t.$from.parent.type.name==="code_block"}function hK(t){var e;const n=(e=t.$from.node(t.$from.depth-1))==null?void 0:e.type;return n?.name==="list_item"}var fK=t=>{throw TypeError(t)},dK=(t,e,n)=>e.has(t)||fK("Cannot "+n),Vp=(t,e,n)=>(dK(t,e,"read from private field"),n?n.call(t):e.get(t)),MD=(t,e,n)=>e.has(t)?fK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),I3e=(t,e,n,r)=>(dK(t,e,"write to private field"),e.set(t,n),n),Of,gv;class D9{constructor(){MD(this,Of,[]),this.clear=()=>(I3e(this,Of,[]),this),MD(this,gv,e=>{const n={group:e,addItem:(r,i)=>{const s={...i,key:r};return e.items.push(s),n},clear:()=>(e.items=[],n)};return n}),this.addGroup=(e,n)=>{const i={key:e,label:n,items:[]};return Vp(this,Of).push(i),Vp(this,gv).call(this,i)},this.getGroup=e=>{const n=Vp(this,Of).find(r=>r.key===e);if(!n)throw new Error(`Group with key ${e} not found`);return Vp(this,gv).call(this,n)},this.build=()=>Vp(this,Of)}}Of=new WeakMap;gv=new WeakMap;function M3e(t,e,n){var r,i,s,o,a,l,c,u,h,f,d,p,m,g,y,b,v,A,k,w,S,_,I,M,F,B,K,U,$,he,ie,pe,Le,P,Q,z,E,X,V,se,_e,Re,Se,Ke,D,N,G,ae,re,Y,me,ne,ye,ee,Be,Te,Ne,Ue,it,pt,J,le,Oe,$e,Ht,gt,vn,$t,hn,Lr,Fr,xl,ba,tr,Ui,zr,bo,va,vo,fp,dp,pp,mp,gp,ru,iu,Ki,Aa,Yh,Qh,L1,yp,Zh,bp,Xh,F1,kl,z1,H1,wn,wa,W1,vp,ef,Ap,wp,q1,V1,$1,j1,qs,xp,tf,xa,kp,nf,rf,sf,U1;const ka=n&&rp(n).get(),t4=ka?.includes(Et.Latex),n4=ka?.includes(Et.ImageBlock),r4=ka?.includes(Et.Table),su=new D9;if(e?.textGroup!==null){const Nt=su.addGroup("text",(i=(r=e?.textGroup)==null?void 0:r.label)!=null?i:"Text");((s=e?.textGroup)==null?void 0:s.text)!==null&&Nt.addItem("text",{label:(l=(a=(o=e?.textGroup)==null?void 0:o.text)==null?void 0:a.label)!=null?l:"Text",icon:(h=(u=(c=e?.textGroup)==null?void 0:c.text)==null?void 0:u.icon)!=null?h:Vke,onRun:Ge=>{const Je=Ge.get(Ce),_t=cs.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t})}}),((f=e?.textGroup)==null?void 0:f.h1)!==null&&Nt.addItem("h1",{label:(m=(p=(d=e?.textGroup)==null?void 0:d.h1)==null?void 0:p.label)!=null?m:"Heading 1",icon:(b=(y=(g=e?.textGroup)==null?void 0:g.h1)==null?void 0:y.icon)!=null?b:Rke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:1}})}}),((v=e?.textGroup)==null?void 0:v.h2)!==null&&Nt.addItem("h2",{label:(w=(k=(A=e?.textGroup)==null?void 0:A.h2)==null?void 0:k.label)!=null?w:"Heading 2",icon:(I=(_=(S=e?.textGroup)==null?void 0:S.h2)==null?void 0:_.icon)!=null?I:Oke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:2}})}}),((M=e?.textGroup)==null?void 0:M.h3)!==null&&Nt.addItem("h3",{label:(K=(B=(F=e?.textGroup)==null?void 0:F.h3)==null?void 0:B.label)!=null?K:"Heading 3",icon:(he=($=(U=e?.textGroup)==null?void 0:U.h3)==null?void 0:$.icon)!=null?he:Dke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:3}})}}),((ie=e?.textGroup)==null?void 0:ie.h4)!==null&&Nt.addItem("h4",{label:(P=(Le=(pe=e?.textGroup)==null?void 0:pe.h4)==null?void 0:Le.label)!=null?P:"Heading 4",icon:(E=(z=(Q=e?.textGroup)==null?void 0:Q.h4)==null?void 0:z.icon)!=null?E:Bke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:4}})}}),((X=e?.textGroup)==null?void 0:X.h5)!==null&&Nt.addItem("h5",{label:(_e=(se=(V=e?.textGroup)==null?void 0:V.h5)==null?void 0:se.label)!=null?_e:"Heading 5",icon:(Ke=(Se=(Re=e?.textGroup)==null?void 0:Re.h5)==null?void 0:Se.icon)!=null?Ke:Nke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:5}})}}),((D=e?.textGroup)==null?void 0:D.h6)!==null&&Nt.addItem("h6",{label:(ae=(G=(N=e?.textGroup)==null?void 0:N.h6)==null?void 0:G.label)!=null?ae:"Heading 6",icon:(me=(Y=(re=e?.textGroup)==null?void 0:re.h6)==null?void 0:Y.icon)!=null?me:Pke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:6}})}}),((ne=e?.textGroup)==null?void 0:ne.quote)!==null&&Nt.addItem("quote",{label:(Be=(ee=(ye=e?.textGroup)==null?void 0:ye.quote)==null?void 0:ee.label)!=null?Be:"Quote",icon:(Ue=(Ne=(Te=e?.textGroup)==null?void 0:Te.quote)==null?void 0:Ne.icon)!=null?Ue:$U,onRun:Ge=>{const Je=Ge.get(Ce),_t=Fh.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((it=e?.textGroup)==null?void 0:it.divider)!==null&&Nt.addItem("divider",{label:(le=(J=(pt=e?.textGroup)==null?void 0:pt.divider)==null?void 0:J.label)!=null?le:"Divider",icon:(Ht=($e=(Oe=e?.textGroup)==null?void 0:Oe.divider)==null?void 0:$e.icon)!=null?Ht:zU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Hh.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t})}})}if(e?.listGroup!==null){const Nt=su.addGroup("list",(vn=(gt=e?.listGroup)==null?void 0:gt.label)!=null?vn:"List");(($t=e?.listGroup)==null?void 0:$t.bulletList)!==null&&Nt.addItem("bullet-list",{label:(Fr=(Lr=(hn=e?.listGroup)==null?void 0:hn.bulletList)==null?void 0:Lr.label)!=null?Fr:"Bullet List",icon:(tr=(ba=(xl=e?.listGroup)==null?void 0:xl.bulletList)==null?void 0:ba.icon)!=null?tr:LU,onRun:Ge=>{const Je=Ge.get(Ce),_t=jc.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((Ui=e?.listGroup)==null?void 0:Ui.orderedList)!==null&&Nt.addItem("ordered-list",{label:(va=(bo=(zr=e?.listGroup)==null?void 0:zr.orderedList)==null?void 0:bo.label)!=null?va:"Ordered List",icon:(dp=(fp=(vo=e?.listGroup)==null?void 0:vo.orderedList)==null?void 0:fp.icon)!=null?dp:VU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Uc.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((pp=e?.listGroup)==null?void 0:pp.taskList)!==null&&Nt.addItem("task-list",{label:(ru=(gp=(mp=e?.listGroup)==null?void 0:mp.taskList)==null?void 0:gp.label)!=null?ru:"Task List",icon:(Aa=(Ki=(iu=e?.listGroup)==null?void 0:iu.taskList)==null?void 0:Ki.icon)!=null?Aa:GU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Ls.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t,attrs:{checked:!1}})}})}if(e?.advancedGroup!==null){const Nt=su.addGroup("advanced",(Qh=(Yh=e?.advancedGroup)==null?void 0:Yh.label)!=null?Qh:"Advanced");((L1=e?.advancedGroup)==null?void 0:L1.image)!==null&&n4&&Nt.addItem("image",{label:(bp=(Zh=(yp=e?.advancedGroup)==null?void 0:yp.image)==null?void 0:Zh.label)!=null?bp:"Image",icon:(kl=(F1=(Xh=e?.advancedGroup)==null?void 0:Xh.image)==null?void 0:F1.icon)!=null?kl:zA,onRun:Ge=>{const Je=Ge.get(Ce),_t=f1.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t})}}),((z1=e?.advancedGroup)==null?void 0:z1.codeBlock)!==null&&Nt.addItem("code",{label:(wa=(wn=(H1=e?.advancedGroup)==null?void 0:H1.codeBlock)==null?void 0:wn.label)!=null?wa:"Code",icon:(ef=(vp=(W1=e?.advancedGroup)==null?void 0:W1.codeBlock)==null?void 0:vp.icon)!=null?ef:I9,onRun:Ge=>{const Je=Ge.get(Ce),_t=Bs.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t})}}),((Ap=e?.advancedGroup)==null?void 0:Ap.table)!==null&&r4&&Nt.addItem("table",{label:(V1=(q1=(wp=e?.advancedGroup)==null?void 0:wp.table)==null?void 0:q1.label)!=null?V1:"Table",icon:(qs=(j1=($1=e?.advancedGroup)==null?void 0:$1.table)==null?void 0:j1.icon)!=null?qs:KU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Ge.get(bt);Je.call(wr.key);const{from:G1}=_t.state.selection;Je.call(Ga.key,{nodeType:Iw(Ge,3,3)}),Je.call($7.key,{pos:G1})}}),((xp=e?.advancedGroup)==null?void 0:xp.math)!==null&&t4&&Nt.addItem("math",{label:(kp=(xa=(tf=e?.advancedGroup)==null?void 0:tf.math)==null?void 0:xa.label)!=null?kp:"Math",icon:(sf=(rf=(nf=e?.advancedGroup)==null?void 0:nf.math)==null?void 0:rf.icon)!=null?sf:M9,onRun:Ge=>{const Je=Ge.get(Ce),_t=Bs.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t,attrs:{language:"LaTeX"}})}})}(U1=e?.buildMenu)==null||U1.call(e,su);let Cl=su.build();t&&(Cl=Cl.map(Nt=>{const Ge=Nt.items.filter(Je=>Je.label.toLowerCase().includes(t.toLowerCase()));return{...Nt,items:Ge}}).filter(Nt=>Nt.items.length>0));const K1=Cl.flatMap(Nt=>Nt.items);return K1.forEach((Nt,Ge)=>{Object.assign(Nt,{index:Ge})}),Cl.reduce((Nt,Ge)=>{const Je=Nt+Ge.items.length;return Object.assign(Ge,{range:[Nt,Je]}),Je},0),{groups:Cl,size:K1.length}}Xc(W);const _3e=cr({props:{ctx:{type:Object,required:!0},show:{type:Object,required:!0},filter:{type:Object,required:!0},hide:{type:Function,required:!0},config:{type:Object,required:!1}},setup({ctx:t,show:e,filter:n,hide:r,config:i}){const s=He(),o=rs(()=>M3e(n.value,i,t)),a=He(0),l=He({x:-999,y:-999}),c=m=>{const{x:g,y}=m;l.value={x:g,y}};nl([o,e],()=>{const{size:m}=o.value;m===0&&e.value?r():a.value>=m&&(a.value=0)});const u=(m,g)=>{const y=a.value,b=typeof m=="function"?m(y):m;g?.(b),a.value=b},h=m=>{var g,y;const b=(g=s.value)==null?void 0:g.querySelector(`[data-index="${m}"]`),v=(y=s.value)==null?void 0:y.querySelector(".menu-groups");!b||!v||(v.scrollTop=b.offsetTop-v.offsetTop)},f=m=>{const g=o.value.groups.flatMap(y=>y.items).at(m);g?.onRun&&t&&g.onRun(t),r()},d=m=>{const{size:g,groups:y}=o.value;if(m.key==="Escape"){m.preventDefault(),r?.();return}if(m.key==="ArrowDown")return m.preventDefault(),u(b=>b<g-1?b+1:b,h);if(m.key==="ArrowUp")return m.preventDefault(),u(b=>b<=0?b:b-1,h);if(m.key==="ArrowLeft")return m.preventDefault(),u(b=>{const v=y.find(k=>k.range[0]<=b&&k.range[1]>b);if(!v)return b;const A=y[y.indexOf(v)-1];return A?A.range[1]-1:b},h);if(m.key==="ArrowRight")return m.preventDefault(),u(b=>{const v=y.find(k=>k.range[0]<=b&&k.range[1]>b);if(!v)return b;const A=y[y.indexOf(v)+1];return A?A.range[0]:b},h);m.key==="Enter"&&(m.preventDefault(),f(a.value))},p=m=>g=>{const y=l.value;if(!y)return;const{x:b,y:v}=g;b===y.x&&v===y.y||u(m)};return Kd(()=>{e.value?window.addEventListener("keydown",d,{capture:!0}):window.removeEventListener("keydown",d,{capture:!0})}),Jd(()=>{window.removeEventListener("keydown",d,{capture:!0})}),()=>W("div",{ref:s,onPointerdown:m=>m.preventDefault()},W("nav",{class:"tab-group"},W("ul",null,o.value.groups.map(m=>W("li",{key:m.key,onPointerdown:()=>u(m.range[0],h),class:a.value>=m.range[0]&&a.value<m.range[1]?"selected":""},m.label)))),W("div",{class:"menu-groups",onPointermove:c},o.value.groups.map(m=>W("div",{key:m.key,class:"menu-group"},W("h6",null,m.label),W("ul",null,m.items.map(g=>W("li",{key:g.key,"data-index":g.index,class:a.value===g.index?"hover":"",onPointerenter:p(g.index),onPointerdown:()=>{var y,b;(b=(y=s.value)==null?void 0:y.querySelector(`[data-index="${g.index}"]`))==null||b.classList.add("active")},onPointerup:()=>{var y,b;(b=(y=s.value)==null?void 0:y.querySelector(`[data-index="${g.index}"]`))==null||b.classList.remove("active"),f(g.index)}},W(ai,{icon:g.icon}),W("span",null,g.label))))))))}});var pK=t=>{throw TypeError(t)},mK=(t,e,n)=>e.has(t)||pK("Cannot "+n),$s=(t,e,n)=>(mK(t,e,"read from private field"),n?n.call(t):e.get(t)),$p=(t,e,n)=>e.has(t)?pK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),gu=(t,e,n,r)=>(mK(t,e,"write to private field"),e.set(t,n),n),x0,yv,bv,Ba,Df;const gK=Xye("CREPE_MENU"),B9=St({show:()=>{},hide:()=>{}},"menuAPICtx");function R3e(t,e){t.set(gK.key,{view:n=>new O3e(t,n,e)})}class O3e{constructor(e,n,r){$p(this,x0),$p(this,yv),$p(this,bv),$p(this,Ba),$p(this,Df,null),this.update=d=>{$s(this,Ba).update(d)},this.show=d=>{gu(this,Df,d),$s(this,bv).value="",$s(this,Ba).show()},this.hide=()=>{gu(this,Df,null),$s(this,Ba).hide()},this.destroy=()=>{$s(this,Ba).destroy(),$s(this,yv).unmount(),$s(this,x0).remove()};var i,s;const o=document.createElement("div");o.classList.add("milkdown-slash-menu");const a=He(!1),l=He("");gu(this,bv,l);const c=this.hide,u=fs(_3e,{ctx:e,config:r,show:a,filter:l,hide:c});gu(this,yv,u),u.mount(o),gu(this,x0,o);const h=this,f=(i=r?.slashMenu)!=null?i:{};gu(this,Ba,new ebe({content:$s(this,x0),debounce:20,shouldShow(d){if(uK(d.state.selection)||hK(d.state.selection))return!1;const p=this.getContent(d,g=>["paragraph","heading"].includes(g.type.name));if(p==null||!D3e(d.state.selection))return!1;const m=$s(h,Df);if(l.value=p.startsWith("/")?p.slice(1):p,typeof m=="number"){const g=d.state.doc.nodeSize-2,y=Math.min(m,g);return d.state.doc.resolve(y).node()!==d.state.doc.resolve(d.state.selection.from).node()?(gu(h,Df,null),!1):!0}return!!p.startsWith("/")},offset:(s=f.offset)!=null?s:10,middleware:f.middleware,floatingUIOptions:f.floatingUIOptions,root:f.root})),$s(this,Ba).onShow=()=>{a.value=!0},$s(this,Ba).onHide=()=>{a.value=!1},this.update(n),e.set(B9.key,{show:d=>this.show(d),hide:()=>this.hide()})}}x0=new WeakMap;yv=new WeakMap;bv=new WeakMap;Ba=new WeakMap;Df=new WeakMap;function D3e(t){if(!(t instanceof qe))return!1;const{$head:e}=t,n=e.parent;return e.parentOffset===n.content.size}Xc(W,Ft);const B3e=cr({props:{onAdd:{type:Function,required:!0},addIcon:{type:String,required:!0},handleIcon:{type:String,required:!0}},setup(t){const e=He();return()=>W(Ft,null,W("div",{ref:e,class:"operation-item",onPointerdown:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.add("active")},onPointerup:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.remove("active"),t.onAdd()}},W(ai,{icon:t.addIcon})),W("div",{class:"operation-item"},W(ai,{icon:t.handleIcon})))}});var yK=t=>{throw TypeError(t)},bK=(t,e,n)=>e.has(t)||yK("Cannot "+n),yu=(t,e,n)=>(bK(t,e,"read from private field"),n?n.call(t):e.get(t)),Jy=(t,e,n)=>e.has(t)?yK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Yy=(t,e,n,r)=>(bK(t,e,"write to private field"),e.set(t,n),n),vv,Eu,Av,wv;class N3e{constructor(e,n){Jy(this,vv),Jy(this,Eu),Jy(this,Av),Jy(this,wv),this.update=()=>{yu(this,Eu).update()},this.destroy=()=>{yu(this,Eu).destroy(),yu(this,vv).remove(),yu(this,Av).unmount()},this.onAdd=()=>{const h=yu(this,wv),f=h.get(bt);f.hasFocus()||f.focus();const{state:d,dispatch:p}=f,m=yu(this,Eu).active;if(!m)return;const y=m.$pos.pos+m.node.nodeSize;let b=d.tr.insert(y,cs.type(h).create());b=b.setSelection(qe.near(b.doc.resolve(y))),p(b.scrollIntoView()),yu(this,Eu).hide(),h.get(B9.key).show(b.selection.from)};var r,i,s,o,a;Yy(this,wv,e);const l=document.createElement("div");l.classList.add("milkdown-block-handle");const c=fs(B3e,{onAdd:this.onAdd,addIcon:(r=n?.handleAddIcon)!=null?r:e6,handleIcon:(i=n?.handleDragIcon)!=null?i:Fke});c.mount(l),Yy(this,Av,c),Yy(this,vv,l);const u=(s=n?.blockHandle)!=null?s:{};Yy(this,Eu,new Zye({ctx:e,content:l,getOffset:(o=u.getOffset)!=null?o:(()=>16),getPlacement:(a=u.getPlacement)!=null?a:(({active:h,blockDom:f})=>{if(h.node.type.name==="heading")return"left";let d=0;h.node.descendants(w=>{d+=w.childCount});const p=h.el,m=p.getBoundingClientRect(),g=f.getBoundingClientRect(),y=window.getComputedStyle(p),b=Number.parseInt(y.paddingTop,10)||0,v=Number.parseInt(y.paddingBottom,10)||0,A=m.height-b-v,k=g.height;return d>2||k<A?"left-start":"left"}),shouldShow:u.shouldShow,getPosition:u.getPosition,middleware:u.middleware,floatingUIOptions:u.floatingUIOptions,root:u.root})),this.update()}}vv=new WeakMap;Eu=new WeakMap;Av=new WeakMap;wv=new WeakMap;function P3e(t,e){t.set(u2.key,{filterNodes:n=>!Yo(i=>["table","blockquote","math_inline"].includes(i.type.name))(n)}),t.set(d2.key,{view:()=>new N3e(t,e)})}const L3e=(t,e)=>{t.config(Ws(Et.BlockEdit)).config(n=>P3e(n,e)).config(n=>R3e(n,e)).use(B9).use(d2).use(gK)},F3e=(t,e={})=>{t.config(Ws(Et.CodeMirror)).config(n=>{const{languages:r=[],theme:i}=e,s=[Vd.of(R$.concat(Dve)),Gwe];i&&s.push(i),e.extensions&&s.push(...e.extensions),n.update(p1.key,o=>{var a;return{extensions:s,languages:r,expandIcon:e.expandIcon||E9,searchIcon:e.searchIcon||jU,clearSearchIcon:e.clearSearchIcon||T9,searchPlaceholder:e.searchPlaceholder||"Search language",copyText:e.copyText||"Copy",copyIcon:e.copyIcon||FU,onCopy:e.onCopy||(()=>{}),noResultText:e.noResultText||"No result",renderLanguage:e.renderLanguage||o.renderLanguage,renderPreview:e.renderPreview||o.renderPreview,previewToggleButton:l=>{var c,u;const h=((c=e.previewToggleIcon)==null?void 0:c.call(e,l))||(l?hg:JU),f=((u=e.previewToggleText)==null?void 0:u.call(e,l))||(l?"Edit":"Hide");return[h,f].map(d=>d.trim()).join(" ")},previewLabel:e.previewLabel||o.previewLabel,previewLoading:e.previewLoading||o.previewLoading,previewOnlyByDefault:(a=e.previewOnlyByDefault)!=null?a:o.previewOnlyByDefault}})}).use(lAe)},z3e=(t,e)=>{if(t.config(Ws(Et.Cursor)).config(r=>{r.update(x2.key,()=>{var i,s;return{class:"crepe-drop-cursor",width:(i=e?.width)!=null?i:4,color:(s=e?.color)!=null?s:!1}})}).use(d2e),e?.virtual===!1)return;const n=p2e({skipWarning:["inlineCode"]});t.use(Qt(()=>n))},H3e=(t,e)=>{t.config(Ws(Et.ImageBlock)).config(n=>{n.update(k2.key,r=>{var i,s,o,a,l,c;return{uploadButton:(i=e?.inlineUploadButton)!=null?i:"Upload",imageIcon:(s=e?.inlineImageIcon)!=null?s:zA,confirmButton:(o=e?.inlineConfirmButton)!=null?o:z2,uploadPlaceholderText:(a=e?.inlineUploadPlaceholderText)!=null?a:"or paste link",onUpload:(c=(l=e?.inlineOnUpload)!=null?l:e?.onUpload)!=null?c:r.onUpload,proxyDomURL:e?.proxyDomURL}}),n.update(h1.key,r=>{var i,s,o,a,l,c,u,h,f;return{uploadButton:(i=e?.blockUploadButton)!=null?i:"Upload file",imageIcon:(s=e?.blockImageIcon)!=null?s:zA,captionIcon:(o=e?.blockCaptionIcon)!=null?o:Cke,confirmButton:(a=e?.blockConfirmButton)!=null?a:"Confirm",captionPlaceholderText:(l=e?.blockCaptionPlaceholderText)!=null?l:"Write Image Caption",uploadPlaceholderText:(c=e?.blockUploadPlaceholderText)!=null?c:"or paste link",onUpload:(h=(u=e?.blockOnUpload)!=null?u:e?.onUpload)!=null?h:r.onUpload,proxyDomURL:e?.proxyDomURL,onImageLoadError:(f=e?.onImageLoadError)!=null?f:r.onImageLoadError,maxWidth:e?.maxWidth,maxHeight:e?.maxHeight}})}).use(wbe).use(I2e)},W3e=Bs.extendSchema(t=>e=>{const n=t(e);return{...n,toMarkdown:{match:n.toMarkdown.match,runner:(r,i)=>{var s,o;if(((s=i.attrs.language)!=null?s:"").toLowerCase()==="latex")r.addNode("math",void 0,((o=i.content.firstChild)==null?void 0:o.text)||"");else return n.toMarkdown.runner(r,i)}}}}),zf="math_inline",q3e="ToggleLatex",WA=Dn(zf,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${zf}"]`,getAttrs:t=>{var e;return{value:(e=t.dataset.value)!=null?e:""}}}],toDOM:t=>{const e=t.attrs.value,n=document.createElement("span");return n.dataset.type=zf,n.dataset.value=e,cU.render(e,n,{throwOnError:!1}),n},parseMarkdown:{match:t=>t.type==="inlineMath",runner:(t,e,n)=>{t.addNode(n,{value:e.value})}},toMarkdown:{match:t=>t.type.name===zf,runner:(t,e)=>{t.addNode("inlineMath",void 0,e.attrs.value)}}})),V3e=je("ToggleLatex",t=>()=>(e,n)=>{const{hasNode:r,pos:i,target:s}=xL(e,WA.type(t)),{selection:o,doc:a,tr:l}=e;if(!r){const d=a.textBetween(o.from,o.to);let p=l.replaceSelectionWith(WA.type(t).create({value:d}));return n&&n(p.setSelection(Ze.create(p.doc,o.from))),!0}const{from:c,to:u}=o;if(!s||i<0)return!1;let h=l.delete(i,i+1);const f=s.attrs.value;return h=h.insertText(f,i),n&&n(h.setSelection(qe.create(h.doc,c,u+f.length-1))),!0}),_D=i1("INLINE_LATEX");Xc(W);const $3e=cr({props:{config:{type:Object,required:!0},innerView:{type:Object,required:!0},updateValue:{type:Object,required:!0}},setup(t){const e=r=>{if(!(!r||!(r instanceof HTMLElement))){for(;r.firstChild;)r.removeChild(r.firstChild);t.innerView.value&&r.appendChild(t.innerView.value.dom)}},n=r=>{r.preventDefault(),t.updateValue.value()};return()=>W("div",{class:"container"},t.innerView.value&&W("div",{ref:e}),W("button",{type:"button",onPointerdown:n},W(ai,{icon:t.config.inlineEditConfirm})))}});var vK=t=>{throw TypeError(t)},AK=(t,e,n)=>e.has(t)||vK("Cannot "+n),ur=(t,e,n)=>(AK(t,e,"read from private field"),n?n.call(t):e.get(t)),Ol=(t,e,n)=>e.has(t)?vK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Qy=(t,e,n,r)=>(AK(t,e,"write to private field"),e.set(t,n),n),k0,Bf,xv,Tu,C0,S0,l6,c6;class j3e{constructor(e,n,r){this.ctx=e,Ol(this,k0),Ol(this,Bf),Ol(this,xv),Ol(this,Tu,yA(null)),Ol(this,C0,yA(()=>{})),Ol(this,S0),Ol(this,l6,()=>{ur(this,Tu).value&&(ur(this,Tu).value.destroy(),ur(this,Tu).value=null)}),Ol(this,c6,s=>{const a=(()=>{if(!s.editable)return!1;const{selection:l,schema:c}=s.state;if(l.empty||!(l instanceof Ze))return!1;const u=l.node;if(u.type.name!==zf)return!1;const h=l.from,f=c.nodes.paragraph.create(null,c.text(u.attrs.value)),d=new a7(ur(this,xv),{state:tL.create({doc:f,schema:new zP({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},text:{group:"inline"}}}),plugins:[CL({"Mod-z":A2,"Mod-Z":Sd,"Mod-y":Sd,Enter:()=>(ur(this,C0).value(),!0)})]})});return ur(this,Tu).value=d,ur(this,C0).value=()=>{const{tr:p}=s.state;p.setNodeAttribute(h,"value",d.state.doc.textContent),s.dispatch(p),requestAnimationFrame(()=>{s.focus()})},!0})();return a||ur(this,l6).call(this),a}),this.update=(s,o)=>{ur(this,Bf).update(s,o)},this.destroy=()=>{ur(this,S0).unmount(),ur(this,Bf).destroy(),ur(this,k0).remove()};const i=document.createElement("div");i.className="milkdown-latex-inline-edit",Qy(this,k0,i),Qy(this,S0,fs($3e,{config:r,innerView:ur(this,Tu),updateValue:ur(this,C0)})),ur(this,S0).mount(i),Qy(this,Bf,new r1({debounce:0,content:ur(this,k0),shouldShow:ur(this,c6),offset:10,floatingUIOptions:{placement:"bottom"}})),ur(this,Bf).update(n),Qy(this,xv,document.createElement("div"))}}k0=new WeakMap;Bf=new WeakMap;xv=new WeakMap;Tu=new WeakMap;C0=new WeakMap;S0=new WeakMap;l6=new WeakMap;c6=new WeakMap;const U3e=Yr(t=>Wee(/(?:\$)([^$]+)(?:\$)$/,WA.type(t),{getAttr:e=>{var n;return{value:(n=e[1])!=null?n:""}}})),K3e=Yr(t=>Q6(/^\$\$[\s\n]$/,Bs.type(t),()=>({language:"LaTeX"}))),G3e=Qr("remarkMath",()=>Gxe);function J3e(t){return Wc(t,"math",(e,n,r)=>{const{value:i}=e,s={type:"code",lang:"LaTeX",value:i};r.children.splice(n,1,s)})}const Y3e=Qr("remarkMathBlock",()=>()=>J3e),Q3e=(t,e)=>{t.config(Ws(Et.Latex)).config(n=>{if(!rp(n).get().includes(Et.CodeMirror))throw new Error("You need to enable CodeMirror to use LaTeX feature");n.update(p1.key,s=>({...s,renderPreview:(o,a,l)=>{if(o.toLowerCase()==="latex"&&a.length>0)return Z3e(a,e?.katexOptions);const c=s.renderPreview;return c(o,a,l)}})),n.set(_D.key,{view:s=>{var o;return new j3e(n,s,{inlineEditConfirm:(o=e?.inlineEditConfirm)!=null?o:z2,...e})}})}).use(G3e).use(Y3e).use(WA).use(_D).use(U3e).use(K3e).use(W3e).use(V3e)};function Z3e(t,e){return cU.renderToString(t,{...e,throwOnError:!1,displayMode:!0})}const X3e=(t,e)=>{t.config(Ws(Et.LinkTooltip)).config(T5e).config(n=>{n.update(Rd.key,r=>{var i,s,o,a,l,c;return{...r,linkIcon:(i=e?.linkIcon)!=null?i:FU,editButton:(s=e?.editButton)!=null?s:hg,removeButton:(o=e?.removeButton)!=null?o:t6,confirmButton:(a=e?.confirmButton)!=null?a:z2,inputPlaceholder:(l=e?.inputPlaceholder)!=null?l:"Paste link...",onCopyLink:(c=e?.onCopyLink)!=null?c:(()=>{})}})}).use(I5e)};function eCe(t,e){t.set(N2.key,{renderLabel:({label:n,listType:r,checked:i})=>{var s,o,a;return i==null?r==="bullet"?(s=e?.bulletIcon)!=null?s:kke:n:i?(o=e?.checkBoxCheckedIcon)!=null?o:Ske:(a=e?.checkBoxUncheckedIcon)!=null?a:Eke}})}const tCe=(t,e)=>{t.config(Ws(Et.ListItem)).config(n=>eCe(n,e)).use(P5e)};function nCe(t){var e;return t.childCount<=1&&!((e=t.firstChild)!=null&&e.content.size)}function rCe(t,e){const{selection:n}=t;if(!n.empty)return null;const r=n.$anchor,i=r.parent;if(i.content.size>0||Yo(a=>a.type.name==="table")(r))return null;const o=r.before();return Cn.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":e})}const u6=St({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),iCe=Qt(t=>new Bt({key:new Vt("CREPE_PLACEHOLDER"),props:{decorations:e=>{var n;if(Kke(t).readonly)return null;const i=t.get(u6.key);if(i.mode==="doc"&&!nCe(e.doc)||uK(e.selection)||hK(e.selection))return null;const s=(n=i.text)!=null?n:"Please enter...",o=rCe(e,s);return o?It.create(e.doc,[o]):null}}})),sCe=(t,e)=>{t.config(Ws(Et.Placeholder)).config(n=>{e&&n.update(u6.key,r=>({...r,...e}))}).use(iCe).use(u6)},oCe=(t,e)=>{t.config(Ws(Et.Table)).config(n=>{n.update(P2.key,r=>({...r,renderButton:i=>{var s,o,a,l,c,u,h,f,d;switch(i){case"add_row":return(s=e?.addRowIcon)!=null?s:e6;case"add_col":return(o=e?.addColIcon)!=null?o:e6;case"delete_row":return(a=e?.deleteRowIcon)!=null?a:t6;case"delete_col":return(l=e?.deleteColIcon)!=null?l:t6;case"align_col_left":return(c=e?.alignLeftIcon)!=null?c:wke;case"align_col_center":return(u=e?.alignCenterIcon)!=null?u:Ake;case"align_col_right":return(h=e?.alignRightIcon)!=null?h:xke;case"col_drag_handle":return(f=e?.colDragHandleIcon)!=null?f:xD;case"row_drag_handle":return(d=e?.rowDragHandleIcon)!=null?d:xD}}}))}).use(cke)};function Zy(t,e){return{slice:t,entry:e}}function aCe(t){if(t===" "||t.toLowerCase()==="space")return{display:"Space",aria:" "};if(t.length===1){const e=t.toUpperCase();return{display:e,aria:e}}return{display:t,aria:t}}function lCe(t,e){var n;const r=t.split(/-(?!$)/),i=(n=r[r.length-1])!=null?n:"",s=r.slice(0,-1);let o=!1,a=!1,l=!1,c=!1;for(const d of s)switch(d.toLowerCase()){case"mod":e?o=!0:a=!0;break;case"meta":case"cmd":case"m":o=!0;break;case"ctrl":case"control":case"c":a=!0;break;case"alt":case"option":case"a":l=!0;break;case"shift":case"s":c=!0;break}const u=aCe(i),h=e?[a&&"⌃",l&&"⌥",c&&"⇧",o&&"⌘",u.display].filter(Boolean).join(""):[a&&"Ctrl",l&&"Alt",c&&"Shift",o&&"Meta",u.display].filter(Boolean).join("+"),f=[o&&"Meta",a&&"Control",l&&"Alt",c&&"Shift",u.aria].filter(Boolean).join("+");return{display:h,aria:f}}function cCe(t,e){if(!t.isInjected(e.slice))return;const n=t.get(e.slice)[e.entry],r=n?[n.shortcuts].flat()[0]:void 0;if(r)return lCe(r,e0.mac)}function uCe(t,e){var n,r,i,s,o,a,l,c,u,h,f,d,p,m,g,y,b,v;const A=new D9;A.addGroup("formatting","Formatting").addItem("bold",{icon:(n=t?.boldIcon)!=null?n:PU,label:(r=t?.boldLabel)!=null?r:"Bold",keymap:Zy(xw.key,"ToggleBold"),active:I=>I.get(Ce).call(_u.key,Lh.type(I)),onRun:I=>{I.get(Ce).call($g.key)}}).addItem("italic",{icon:(i=t?.italicIcon)!=null?i:WU,label:(s=t?.italicLabel)!=null?s:"Italic",keymap:Zy(ww.key,"ToggleEmphasis"),active:I=>I.get(Ce).call(_u.key,$c.type(I)),onRun:I=>{I.get(Ce).call(Vg.key)}}).addItem("strikethrough",{icon:(o=t?.strikethroughIcon)!=null?o:UU,label:(a=t?.strikethroughLabel)!=null?a:"Strikethrough",keymap:Zy(Tw.key,"ToggleStrikethrough"),active:I=>I.get(Ce).call(_u.key,Wh.type(I)),onRun:I=>{I.get(Ce).call(Ug.key)}});const k=A.addGroup("function","Function");k.addItem("code",{icon:(l=t?.codeIcon)!=null?l:I9,label:(c=t?.codeLabel)!=null?c:"Inline code",keymap:Zy(kw.key,"ToggleInlineCode"),active:I=>I.get(Ce).call(_u.key,Xs.type(I)),onRun:I=>{I.get(Ce).call(jg.key)}});const w=e&&rp(e).get();if(w?.includes(Et.Latex)&&k.addItem("latex",{icon:(u=t?.latexIcon)!=null?u:M9,label:(h=t?.latexLabel)!=null?h:"Inline math",active:I=>{const M=I.get(Ce),F=I.get(qi).nodes[zf];return M.call(GF.key,F)},onRun:I=>{I.get(Ce).call(q3e)}}),k.addItem("link",{icon:(f=t?.linkIcon)!=null?f:qU,label:(d=t?.linkLabel)!=null?d:"Link",active:I=>I.get(Ce).call(_u.key,as.type(I)),onRun:I=>{I.get(Ce).call(g9.key)}}),e&&w?.includes(Et.AI)){const I=e.get(Od.key);I.provider&&k.addItem("ai",{icon:(m=(p=t?.aiIcon)!=null?p:I.aiIcon)!=null?m:S9,label:(g=t?.aiLabel)!=null?g:"Ask AI",active:()=>!1,onRun:M=>{const F=M.get(O9.key),B=M.get(bt),{from:K,to:U}=B.state.selection;F.show(K,U)}})}(y=t?.buildToolbar)==null||y.call(t,A);const _=A.build();if(e)for(const I of _)for(const M of I.items){if(!M.keymap)continue;const F=cCe(e,M.keymap);F&&((b=M.shortcut)!=null||(M.shortcut=F.display),(v=M.ariaKeyshortcuts)!=null||(M.ariaKeyshortcuts=F.aria))}return _}Xc(W,Ft);const hCe=cr({props:{ctx:{type:Object,required:!0},hide:{type:Function,required:!0},show:{type:Object,required:!0},selection:{type:Object,required:!0},config:{type:Object,required:!1}},setup(t){const{ctx:e,config:n}=t,r=a=>l=>{l.preventDefault(),e&&a?.(e)};function i(a){return Xc(t.selection.value),e.get(zv).status!==Wv.Created?!1:a(e)}const s=rs(()=>uCe(n,e));function o(a){if(a.label)return a.shortcut?`${a.label} (${a.shortcut})`:a.label}return()=>W(Ft,null,s.value.map(a=>a.items.map(l=>W("button",{type:"button",class:Ar("toolbar-item",e&&i(l.active)&&"active"),"data-toolbar-item":l.key,title:o(l),"aria-label":l.label,"aria-keyshortcuts":l.ariaKeyshortcuts,onPointerdown:r(l.onRun)},W(ai,{icon:l.icon})))).reduce((a,l,c)=>(c===0?a.push(...l):a.push(W("div",{class:"divider"}),...l),a),[]))}});var wK=t=>{throw TypeError(t)},xK=(t,e,n)=>e.has(t)||wK("Cannot "+n),Ji=(t,e,n)=>(xK(t,e,"read from private field"),n?n.call(t):e.get(t)),jp=(t,e,n)=>e.has(t)?wK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Xy=(t,e,n,r)=>(xK(t,e,"write to private field"),e.set(t,n),n),Zl,E0,kv,T0,I0;const RD=i1("CREPE_TOOLBAR");class fCe{constructor(e,n,r){jp(this,Zl),jp(this,E0),jp(this,kv),jp(this,T0),jp(this,I0,He(!1)),this.update=(o,a)=>{Ji(this,Zl).update(o,a),Ji(this,T0).value=o.state.selection},this.destroy=()=>{Ji(this,Zl).destroy(),Ji(this,kv).unmount(),Ji(this,E0).remove()},this.hide=()=>{Ji(this,Zl).hide()};const i=document.createElement("div");i.className="milkdown-toolbar",Xy(this,T0,yA(n.state.selection));const s=fs(hCe,{ctx:e,hide:this.hide,config:r,selection:Ji(this,T0),show:Ji(this,I0)});s.mount(i),Xy(this,E0,i),Xy(this,kv,s),Xy(this,Zl,new r1({content:Ji(this,E0),debounce:20,offset:10,shouldShow(o){const{doc:a,selection:l}=o.state,{empty:c,from:u,to:h}=l,f=!a.textBetween(u,h).length&&l instanceof qe,d=!(l instanceof qe),p=o.dom.getRootNode().activeElement,m=i.contains(p),g=!o.hasFocus()&&!m,y=!o.editable;return!(g||d||c||f||y)}})),Ji(this,Zl).onShow=()=>{Ji(this,I0).value=!0},Ji(this,Zl).onHide=()=>{Ji(this,I0).value=!1},this.update(n)}}Zl=new WeakMap;E0=new WeakMap;kv=new WeakMap;T0=new WeakMap;I0=new WeakMap;const dCe=(t,e)=>{t.config(Ws(Et.Toolbar)).config(n=>{n.set(RD.key,{view:r=>new fCe(n,r,e)})}).use(RD)},kK=[{label:"Paragraph",level:null},{label:"Heading 1",level:1},{label:"Heading 2",level:2},{label:"Heading 3",level:3},{label:"Heading 4",level:4},{label:"Heading 5",level:5},{label:"Heading 6",level:6}];function pCe(t,e){var n,r;const i=e??kK,s=t.get(bt),{$from:o}=s.state.selection,a=o.parent,l=(n=i.find(c=>c.level===null))!=null?n:i[0];if(a.type===ci.type(t)){const c=a.attrs.level;return(r=i.find(u=>u.level===c))!=null?r:l}return l}function mCe(t,e){const n=t.get(Ce);if(e==null){const r=cs.type(t);n.call(As.key,{nodeType:r})}else{const r=ci.type(t);n.call(As.key,{nodeType:r,attrs:{level:e}})}}function bu(t,e){if(t.get(Ce).call(_u.key,e))return!0;const i=t.get(bt),{state:s}=i;if(s.storedMarks)return s.storedMarks.some(o=>o.type===e);if(s.selection instanceof qe){const{$cursor:o}=s.selection;if(o)return o.marks().some(a=>a.type===e)}return!1}function gCe(t,e){const n=t??kK;return{icon:"",active:()=>!1,selector:{chevronIcon:e??E9,activeLabel:r=>pCe(r,n).label,options:n.map(r=>({label:r.label,onSelect:i=>mCe(i,r.level)}))}}}function yCe(t,e){var n,r,i,s,o,a,l,c,u,h,f,d,p,m,g;const y=e&&rp(e).get(),b=y?.includes(Et.Latex),v=y?.includes(Et.ImageBlock),A=y?.includes(Et.Table),k=new D9;k.addGroup("heading","Heading").addItem("heading-selector",{...gCe(t?.headingOptions,t?.chevronDownIcon)}),k.addGroup("formatting","Formatting").addItem("bold",{icon:(n=t?.boldIcon)!=null?n:PU,active:_=>bu(_,Lh.type(_)),onRun:_=>{_.get(Ce).call($g.key)}}).addItem("italic",{icon:(r=t?.italicIcon)!=null?r:WU,active:_=>bu(_,$c.type(_)),onRun:_=>{_.get(Ce).call(Vg.key)}}).addItem("strikethrough",{icon:(i=t?.strikethroughIcon)!=null?i:UU,active:_=>bu(_,Wh.type(_)),onRun:_=>{_.get(Ce).call(Ug.key)}}).addItem("code",{icon:(s=t?.codeIcon)!=null?s:I9,active:_=>bu(_,Xs.type(_)),onRun:_=>{const I=_.get(bt),{state:M}=I;if(M.selection.empty){const F=Xs.type(_);bu(_,F)?I.dispatch(M.tr.removeStoredMark(F)):I.dispatch(M.tr.addStoredMark(F.create()))}else _.get(Ce).call(jg.key)}}),k.addGroup("list","List").addItem("bullet-list",{icon:(o=t?.bulletListIcon)!=null?o:LU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=jc.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("ordered-list",{icon:(a=t?.orderedListIcon)!=null?a:VU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Uc.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("task-list",{icon:(l=t?.taskListIcon)!=null?l:GU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Ls.type(_);I.call(Ka.key,{nodeType:M,attrs:{checked:!1}})}});const w=k.addGroup("insert","Insert");w.addItem("link",{icon:(c=t?.linkIcon)!=null?c:qU,active:_=>bu(_,as.type(_)),onRun:_=>{const I=_.get(bt),{state:M}=I,F=as.type(_);if(M.selection.empty&&bu(_,F)){I.dispatch(M.tr.removeStoredMark(F));return}_.get(Ce).call(g9.key)}}),v&&w.addItem("image",{icon:(u=t?.imageIcon)!=null?u:zA,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=f1.type(_);I.call(Ga.key,{nodeType:M})}}),A&&w.addItem("table",{icon:(h=t?.tableIcon)!=null?h:KU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=_.get(bt),{from:F}=M.state.selection;I.call(Ga.key,{nodeType:Iw(_,3,3)}),I.call($7.key,{pos:F})}});const S=k.addGroup("block","Block");return S.addItem("code-block",{icon:(f=t?.codeBlockIcon)!=null?f:Mke,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Bs.type(_);I.call(As.key,{nodeType:M})}}),b&&S.addItem("math",{icon:(d=t?.mathIcon)!=null?d:M9,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Bs.type(_);I.call(Ga.key,{nodeType:M,attrs:{language:"LaTeX"}})}}),k.addGroup("more","More").addItem("quote",{icon:(p=t?.quoteIcon)!=null?p:$U,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Fh.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("hr",{icon:(m=t?.hrIcon)!=null?m:zU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Hh.type(_);I.call(Ga.key,{nodeType:M})}}),(g=t?.buildTopBar)==null||g.call(t,k),k.build()}Xc(W,Ft);const bCe=cr({props:{ctx:{type:Object,required:!0},version:{type:Object,required:!0},config:{type:Object,required:!1}},setup(t){const{ctx:e,config:n}=t,r=He(null),i=p=>m=>{m.preventDefault(),e&&p(e)};function s(){return e.get(zv).status===Wv.Created}function o(){Xc(t.version.value)}function a(p){return o(),s()?p(e):!1}function l(p){var m,g;return o(),s()?p.activeLabel(e):(g=(m=p.options[0])==null?void 0:m.label)!=null?g:""}function c(p,m){m.preventDefault(),m.stopPropagation(),r.value=r.value===p?null:p}const u=p=>{p.target.closest(".top-bar-heading-selector")||(r.value=null)};Gd(()=>{window.addEventListener("pointerdown",u)}),Jd(()=>{window.removeEventListener("pointerdown",u)});const h=rs(()=>yCe(n,e));function f(p,m){const g=r.value===p,y=l(m);return W("div",{key:p,class:"top-bar-heading-selector"},W("button",{type:"button",class:"top-bar-heading-button",onPointerdown:b=>c(p,b)},W("span",{class:"top-bar-heading-label"},y),m.chevronIcon&&W("span",{class:"top-bar-chevron"},W(ai,{icon:m.chevronIcon}))),g&&W("div",{class:"top-bar-heading-dropdown"},m.options.map((b,v)=>W("button",{key:`${p}-${v}`,type:"button",class:Ar("top-bar-heading-option",y===b.label&&"active"),onPointerdown:A=>{A.preventDefault(),A.stopPropagation(),r.value=null,b.onSelect(e)}},b.label))))}function d(p){return W("button",{key:p.key,type:"button",class:Ar("top-bar-item",a(p.active)&&"active"),onPointerdown:i(p.onRun)},W(ai,{icon:p.icon}))}return()=>{const p=s()?e.get(bt):null;return(p?!p.editable:!1)?null:W("div",{class:"top-bar-inner"},h.value.map(g=>g.items.map(y=>y.selector?f(y.key,y.selector):y.onRun?d(y):null)).reduce((g,y,b)=>{var v,A;if(b===0)g.push(...y);else{const k=(A=(v=h.value[b])==null?void 0:v.key)!=null?A:b;g.push(W("div",{key:`divider-${k}`,class:"top-bar-divider"}),...y)}return g},[]))}}});var CK=t=>{throw TypeError(t)},SK=(t,e,n)=>e.has(t)||CK("Cannot "+n),Up=(t,e,n)=>(SK(t,e,"read from private field"),n?n.call(t):e.get(t)),m5=(t,e,n)=>e.has(t)?CK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),g5=(t,e,n,r)=>(SK(t,e,"write to private field"),e.set(t,n),n),M0,Cv,_0;const vCe=new Vt("CREPE_TOP_BAR");class ACe{constructor(e,n,r){m5(this,M0),m5(this,Cv),m5(this,_0),this.update=(a,l)=>{Up(this,M0).style.display=a.editable?"":"none",Up(this,_0).value++},this.destroy=()=>{Up(this,Cv).unmount(),Up(this,M0).remove()},g5(this,_0,He(0));const i=document.createElement("div");i.className="milkdown-top-bar";const s=fs(bCe,{ctx:e,config:r,version:Up(this,_0)});s.mount(i),g5(this,M0,i),g5(this,Cv,s);const o=n.dom.parentElement;o&&o.insertBefore(i,o.firstChild),this.update(n)}}M0=new WeakMap;Cv=new WeakMap;_0=new WeakMap;const h6=St({view:()=>({update:()=>{},destroy:()=>{}})},"topBarConfig"),wCe=Qt(t=>{const e=t.get(h6.key);return new Bt({key:vCe,view:e.view})}),xCe=(t,e)=>{t.config(Ws(Et.TopBar)).config(n=>{n.set(h6.key,{view:r=>new ACe(n,r,e)})}).use(h6).use(wCe)};function kCe(t,e,n){switch(t){case Et.CodeMirror:return F3e(e,n);case Et.ListItem:return tCe(e,n);case Et.LinkTooltip:return X3e(e,n);case Et.ImageBlock:return H3e(e,n);case Et.Cursor:return z3e(e,n);case Et.BlockEdit:return L3e(e,n);case Et.Placeholder:return sCe(e,n);case Et.Toolbar:return dCe(e,n);case Et.Table:return oCe(e,n);case Et.Latex:return Q3e(e,n);case Et.TopBar:return xCe(e,n);case Et.AI:return T3e(e,n)}}var EK=t=>{throw TypeError(t)},TK=(t,e,n)=>e.has(t)||EK("Cannot "+n),Yi=(t,e,n)=>(TK(t,e,"read from private field"),n?n.call(t):e.get(t)),y5=(t,e,n)=>e.has(t)?EK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),b5=(t,e,n,r)=>(TK(t,e,"write to private field"),e.set(t,n),n),Qi,Sv,R0;class CCe{constructor({root:e,defaultValue:n=""}={}){y5(this,Qi),y5(this,Sv),y5(this,R0,!0),this.addFeature=(i,s)=>(i(Yi(this,Qi),s),this),this.create=()=>Yi(this,Qi).create(),this.destroy=()=>Yi(this,Qi).destroy(),this.setReadonly=i=>(b5(this,R0,!i),Yi(this,Qi).action(s=>{Yi(this,Qi).status===Wv.Created&&s.get(bt).setProps({editable:()=>!i})}),this),this.getMarkdown=()=>Yi(this,Qi).action(are()),this.on=i=>Yi(this,Qi).status!==Wv.Created?(Yi(this,Qi).config(s=>{const o=s.get(FA);i(o)}),this):(Yi(this,Qi).action(s=>{const o=s.get(FA);i(o)}),this);var r;b5(this,Sv,(r=typeof e=="string"?document.querySelector(e):e)!=null?r:document.body),b5(this,Qi,CF.make().config(i=>{i.inject(Uke,this),i.inject(jke,[])}).config(i=>{i.set(J0,Yi(this,Sv)),i.set(K0,n),i.set(G0,{editable:()=>Yi(this,R0)}),i.update(F2.key,s=>({...s,size:4})),i.update(ch.key,s=>({...s,uploader:async(o,a,l)=>{const u=rp(l).get().includes(Et.ImageBlock),h=u?a.nodes["image-block"]:a.nodes.image;if(!h)return[];const f=u?l.get(h1.key).onUpload:void 0,d=[];for(let m=0;m<o.length;m++){const g=o.item(m);g&&g.type.includes("image")&&d.push(g)}return await Promise.all(d.map(async m=>{const g=f?await f(m):URL.createObjectURL(m);return h.createAndFill({src:g})}))}}))}).use(ez).use(DU).use(hke).use(dke).use(mke).use(MU).use(bke).use(Nz))}get editor(){return Yi(this,Qi)}get readonly(){return!Yi(this,R0)}}Qi=new WeakMap;Sv=new WeakMap;R0=new WeakMap;class _o extends CCe{constructor({features:e={},featureConfigs:n={},...r}={}){super(r);const i=yue(n,$ke);Object.entries({...vke,...e}).filter(([,o])=>o).map(([o])=>o).forEach(o=>{const a=i[o];kCe(o,this.editor,a)})}}_o.Feature=Et;function Bd(t){try{const e=t.get(bt);if(e&&e.state)return e}catch{}try{const e=t.get("editorView");if(e&&e.state)return e}catch{}}function IK(t){try{const e=t.get(so);if(typeof e=="function")return e}catch{}try{const e=t.get("parser");if(typeof e=="function")return e}catch{}}const SCe='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="4" y="3" width="16" height="18" rx="2"/><path d="M8 8h8M8 12h8M8 16h5"/></svg>',N9=[{key:"highlight",label:"高亮",mark:"highlight",text:"重点内容",attrs:{},icon:'<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><path d="m14 3 7 7-9 9H5v-7z" fill="#fef08a" stroke="#d97706" stroke-width="2"/><path d="M3 21h12" stroke="#d97706" stroke-width="2" stroke-linecap="round"/><path d="m11 6 7 7" stroke="#d97706" stroke-width="2"/><title>高亮</title></svg>'},{key:"kbd",label:"快捷键",mark:"kbd",text:"Cmd",attrs:{},icon:'<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><rect x="3" y="5" width="18" height="14" rx="3" fill="#f1f5f9" stroke="#475569" stroke-width="1.8"/><path d="M7 9h2m2 0h2m2 0h2M7 13h2m2 0h2m2 0h2M8 16h8" stroke="#64748b" stroke-width="1.5" stroke-linecap="round"/><title>快捷键</title></svg>'},...[["brand","重点徽章","重点","#ca6093","#fce7f3"],["success","成功徽章","完成","#16a34a","#dcfce7"],["warning","提醒徽章","待确认","#ea580c","#ffedd5"],["danger","风险徽章","风险","#dc2626","#fee2e2"],["info","信息徽章","说明","#0284c7","#e0f2fe"]].map(([t,e,n,r,i])=>({key:`badge-${t}`,label:e,mark:"badge",text:n,attrs:{type:t},icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><path d="M3 4h9l9 9-8 8-10-10z" fill="${i}" stroke="${r}" stroke-width="2"/><circle cx="8" cy="8" r="1.5" fill="${r}"/><title>${e}</title></svg>`}))],MK=["highlight","kbd","badge"];function P9(t,e,n=!1){const r=Bd(t);if(!r||!r.state)return;const{state:i}=r,{selection:s}=i;if(!(s instanceof qe)||!s.$from.sameParent(s.$to)||s.$from.parent.type.spec.code)return;const o=n?s.$from.start():s.from,a=s.to;if(i.doc.rangeHasMark(o,a,i.schema.marks.inlineCode))return;const l=i.schema.marks[e.mark];if(!l)return;const c=i.tr,u="type"in e.attrs?e.attrs.type:void 0;let h=!1;if(i.doc.nodesBetween(o,a,f=>{for(const d of f.marks)d.type===l&&(!u||d.attrs?.type===u)&&(h=!0)}),s.empty||n){const f=l.create(e.attrs);c.replaceWith(o,a,i.schema.text(e.text,[f])),c.setSelection(qe.create(c.doc,o+e.text.length))}else if(h)c.removeMark(o,a,l);else{if(e.mark==="badge"){const d=i.schema.marks.badge;d&&c.removeMark(o,a,d)}else if(e.mark==="kbd"){const d=i.schema.marks.kbd;d&&c.removeMark(o,a,d)}else if(e.mark==="highlight")for(const d of MK){const p=i.schema.marks[d];p&&c.removeMark(o,a,p)}const f=l.create(e.attrs);c.addMark(o,a,f)}c.setStoredMarks([]),r.dispatch(c.scrollIntoView()),r.focus()}function ECe(t){const e=Bd(t);if(!e||!e.state)return;const{state:n}=e,{from:r,to:i}=n.selection,s=n.tr;for(const o of MK){const a=n.schema.marks[o];a&&s.removeMark(r,i,a)}s.setStoredMarks([]),e.dispatch(s),e.focus()}const TCe=t=>{t.addGroup("article-inline","行内组件").addItem("article-inline",{icon:"",active:()=>!1,selector:{activeLabel:()=>"行内组件",options:[...N9.map(e=>({label:e.label,onSelect:n=>P9(n,e)})),{label:"清除行内组件",onSelect:ECe}]}})},ICe=t=>{const e=t.addGroup("article-inline","行内组件");for(const n of N9){const r="type"in n.attrs?n.attrs.type:void 0;e.addItem(n.key,{icon:n.icon,active:i=>{const s=Bd(i);if(!s||!s.state)return!1;const{state:o}=s,a=o.schema.marks[n.mark];if(!a)return!1;let l=!1;return o.doc.nodesBetween(o.selection.from,o.selection.to,c=>{for(const u of c.marks)u.type===a&&(r?u.attrs?.type===r&&(l=!0):l=!0)}),l},onRun:i=>P9(i,n)})}},MCe=t=>{const e=t.addGroup("article","文章组件"),n=[["intro","导读",`> [!INTRO] 导读
1919
+ `,$ke={[Et.CodeMirror]:{theme:r0e,languages:Upe,expandIcon:E9,searchIcon:jU,clearSearchIcon:T9,searchPlaceholder:"Search language",noResultText:"No result",previewToggleIcon:t=>t?hg:JU}},jke=Ct([],"FeaturesCtx"),Uke=Ct({},"CrepeCtx");function Kke(t){return t.get("CrepeCtx")}function rp(t){return t.use("FeaturesCtx")}function Ws(t){return e=>{rp(e).update(n=>n.includes(t)?n:[...n,t])}}function Gke(t,e){var n;const r=t.get(bt),i=t.get(Zu),{state:s}=r,o=i(s.doc);let a="";if(!s.selection.empty){const{from:l,to:c}=s.selection,u=s.doc.slice(l,c),{schema:h}=s.doc.type;let f=h.topNodeType.createAndFill(null,u.content);if(!f){const d=(n=h.nodes.paragraph)==null?void 0:n.createAndFill(null,u.content);d&&(f=h.topNodeType.createAndFill(null,d))}a=f?i(f):s.doc.textBetween(l,c)}return{document:o,selection:a,instruction:e}}const Od=St({provider:void 0,buildContext:void 0,diffReviewOnEnd:!0,onError:t=>{console.error(`[milkdown/ai] [${t.code}]`,t)},aiIcon:void 0},"aiProviderConfig"),sr=St({abortController:null,label:"",lastInstruction:"",lastLabel:void 0,lastFrom:-1,lastTo:-1,diffOwnedByAI:!1},"aiSession");function YU(t,e){const n=t.get(Od.key);try{n.onError(e)}catch(r){console.error("[milkdown/ai] onError handler failed:",r)}}function HA(t){const e=t.get(sr.key);t.set(sr.key,{...e,abortController:null,label:""})}async function Jke(t,e,n,r){try{const i=e(n,r.signal),s=t.get(Ce);for await(const l of i){if(r.signal.aborted)break;s.call(i8.key,l)}if(r.signal.aborted)return;const o=t.get(Od.key);if(o.diffReviewOnEnd){const l=t.get(sr.key);t.set(sr.key,{...l,diffOwnedByAI:!0})}const a=s.call(s8.key,{diffReview:o.diffReviewOnEnd});if(o.diffReviewOnEnd&&!a){const l=t.get(sr.key);t.set(sr.key,{...l,diffOwnedByAI:!1})}}catch(i){if(r.signal.aborted)return;const s=DJ(i);YU(t,s),t.get(Ce).call(jd.key,{keep:!1})}finally{t.get(sr.key).abortController===r&&HA(t)}}const _9=je("RunAI",t=>e=>(n,r)=>{var i,s,o,a;if(!e?.instruction)return!1;const l=t.get(Od.key);if(!l.provider||t.get(sr.key).abortController||(i=Yn.getState(n))!=null&&i.active||(s=Rn.getState(n))!=null&&s.active)return!1;if(!r)return!0;const u=new AbortController,{from:h,to:f}=n.selection;t.set(sr.key,{abortController:u,label:(o=e.label)!=null?o:"",lastInstruction:e.instruction,lastLabel:e.label,lastFrom:h,lastTo:f,diffOwnedByAI:!1});const d=t.get(Ce),p=n.selection.empty?"cursor":"selection";if(!d.call(r8.key,{insertAt:p}))return HA(t),!1;let m;try{m=((a=l.buildContext)!=null?a:Gke)(t,e.instruction)}catch(g){const y=BJ(g);return YU(t,y),d.call(jd.key,{keep:!1}),HA(t),!1}return Jke(t,l.provider,m,u),!0}),QU=je("AbortAI",t=>e=>(n,r)=>{var i;const s=t.get(sr.key);return r?s.abortController?(s.abortController.abort(),HA(t),(i=Yn.getState(n))!=null&&i.active&&t.get(Ce).call(jd.key,e),!0):!1:!!s.abortController});var ZU=t=>{throw TypeError(t)},R9=(t,e,n)=>e.has(t)||ZU("Cannot "+n),dr=(t,e,n)=>(R9(t,e,"read from private field"),n?n.call(t):e.get(t)),gs=(t,e,n)=>e.has(t)?ZU("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),So=(t,e,n,r)=>(R9(t,e,"write to private field"),e.set(t,n),n),ff=(t,e,n)=>(R9(t,e,"access private method"),n),b0,rv,v0,fg,iv,sv,uc,_f,Yl,XU,ov,eK,n6,tK,r6,i6;const Dd="milkdown-ai-diff-actions";function nK(t,e){t.innerHTML=zs.sanitize(e.trim())}function Yke(t){const e=document.createElement("span");return e.className=`${Dd}-icon`,nK(e,t),e}class Qke{constructor(e,n,r){this.ctx=e,gs(this,Yl),gs(this,b0),gs(this,rv),gs(this,v0),gs(this,fg),gs(this,iv,!1),gs(this,sv,!1),gs(this,uc,null),gs(this,_f,!1),gs(this,n6,()=>{const o=this.ctx.get(sr.key);if(!o.lastInstruction||!dr(this,_f)||!ff(this,Yl,tK).call(this))return;const a=this.ctx.get(Ce);a.call(uA.key);const l=this.ctx.get(bt),{doc:c}=l.state,u=Math.min(Math.max(o.lastFrom,0),c.content.size),h=Math.min(Math.max(o.lastTo,0),c.content.size);l.dispatch(l.state.tr.setSelection(qe.create(l.state.doc,u,h))),a.call(_9.key,{instruction:o.lastInstruction,label:o.lastLabel})}),gs(this,r6,()=>{this.ctx.get(Ce).call(uA.key)}),gs(this,i6,()=>{this.ctx.get(Ce).call(jw.key)}),So(this,fg,r),So(this,rv,ff(this,Yl,XU).call(this,n));const i=document.createElement("div");i.className=Dd,i.dataset.show="false",So(this,v0,ff(this,Yl,ov).call(this,"retry",r.retryIcon,r.retryLabel,dr(this,n6))),i.appendChild(dr(this,v0)),i.appendChild(ff(this,Yl,ov).call(this,"reject",r.rejectIcon,r.rejectAllLabel,dr(this,r6)));const s=ff(this,Yl,ov).call(this,"accept",r.acceptIcon,r.acceptAllLabel,dr(this,i6));s.appendChild(ff(this,Yl,eK).call(this)),i.appendChild(s),So(this,b0,i),dr(this,rv).appendChild(i),this.update(n)}update(e){var n;const r=!!((n=Rn.getState(e.state))!=null&&n.active);if(r!==dr(this,sv))if(So(this,sv,r),r){const s=this.ctx.get(sr.key);So(this,_f,s.diffOwnedByAI),So(this,uc,e.state.doc)}else{So(this,_f,!1),So(this,uc,null);const s=this.ctx.get(sr.key);s.diffOwnedByAI&&this.ctx.set(sr.key,{...s,diffOwnedByAI:!1})}const i=r&&dr(this,_f);if(i!==dr(this,iv)&&(So(this,iv,i),dr(this,b0).dataset.show=i?"true":"false"),i){const s=this.ctx.get(sr.key),o=!!dr(this,uc)&&e.state.doc.eq(dr(this,uc));dr(this,v0).disabled=!s.lastInstruction||!o}}destroy(){dr(this,b0).remove()}}b0=new WeakMap;rv=new WeakMap;v0=new WeakMap;fg=new WeakMap;iv=new WeakMap;sv=new WeakMap;uc=new WeakMap;_f=new WeakMap;Yl=new WeakSet;XU=function(t){var e;return(e=t.dom.closest(".milkdown"))!=null?e:document.body};ov=function(t,e,n,r){const i=document.createElement("button");i.type="button",i.className=`${Dd}-btn ${Dd}-btn-${t}`,i.appendChild(Yke(e));const s=document.createElement("span");return s.textContent=n,i.appendChild(s),i.addEventListener("mousedown",o=>o.preventDefault()),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r()}),i};eK=function(){const t=document.createElement("span");t.className=`${Dd}-shortcut`;const e=document.createElement("span");e.textContent=dr(this,fg).modSymbol;const n=document.createElement("span");return n.className=`${Dd}-shortcut-icon`,nK(n,dr(this,fg).enterKeyIcon),t.append(e,n),t};n6=new WeakMap;tK=function(){return dr(this,uc)?this.ctx.get(bt).state.doc.eq(dr(this,uc)):!1};r6=new WeakMap;i6=new WeakMap;const Zke=new Vt("CREPE_AI_DIFF_ACTIONS_PANEL"),Xke="Retry",e3e="Reject all",t3e="Accept all";function n3e(){var t,e,n,r;if(typeof navigator>"u")return"⌘";const i=navigator,s=(r=(n=(e=(t=i.userAgentData)==null?void 0:t.platform)!=null?e:i.platform)!=null?n:i.userAgent)!=null?r:"";return/mac|iphone|ipad|ipod/i.test(s)?"⌘":"Ctrl"}const r3e=n3e();function i3e(t){var e,n,r,i,s,o,a;const{config:l,enterKeyIcon:c}=t;return{retryLabel:(e=l?.retryLabel)!=null?e:Xke,rejectAllLabel:(n=l?.rejectAllLabel)!=null?n:e3e,acceptAllLabel:(r=l?.acceptAllLabel)!=null?r:t3e,retryIcon:(i=l?.retryIcon)!=null?i:zke,rejectIcon:(s=l?.rejectIcon)!=null?s:T9,acceptIcon:(o=l?.acceptIcon)!=null?o:z2,enterKeyIcon:c??HU,modSymbol:(a=l?.modSymbol)!=null?a:r3e}}function s3e(t={}){const e=i3e(t);return Qt(n=>new Bt({key:Zke,view(r){return new Qke(n,r,e)},props:{handleKeyDown(r,i){var s;return i.key!=="Enter"||!(i.metaKey||i.ctrlKey)||!((s=Rn.getState(r.state))!=null&&s.active)||!n.get(sr.key).diffOwnedByAI?!1:(i.preventDefault(),n.get(Ce).call(jw.key),!0)}}}))}var rK=t=>{throw TypeError(t)},iK=(t,e,n)=>e.has(t)||rK("Cannot "+n),Ma=(t,e,n)=>(iK(t,e,"read from private field"),n?n.call(t):e.get(t)),CD=(t,e,n)=>e.has(t)?rK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),SD=(t,e,n,r)=>(iK(t,e,"write to private field"),e.set(t,n),n),Mo,A0;function ED(t){const e={addItem:(n,r)=>(t.items.set(n,r),e),removeItem:n=>(t.items.delete(n),e),getItem:n=>t.items.get(n),clear:()=>(t.items.clear(),e)};return e}class o3e{constructor(){CD(this,Mo,[]),this.addItem=(e,n)=>(Ma(this,A0).call(this,e),Ma(this,Mo).push({kind:"item",id:e,item:n}),this),this.addSubmenu=(e,n,r)=>{Ma(this,A0).call(this,e);const i={def:n,items:new Map};return r&&r(ED(i)),Ma(this,Mo).push({kind:"submenu",id:e,node:i}),this},this.removeItem=e=>(Ma(this,A0).call(this,e),this),this.getItem=e=>{const n=Ma(this,Mo).find(r=>r.kind==="item"&&r.id===e);return n?.kind==="item"?n.item:void 0},this.getSubmenu=e=>{const n=Ma(this,Mo).find(r=>r.kind==="submenu"&&r.id===e);return n?.kind==="submenu"?ED(n.node):void 0},this.clear=()=>(SD(this,Mo,[]),this),this.build=()=>{const e=[],n={};for(const r of Ma(this,Mo))r.kind==="item"?e.push({kind:"item",id:r.id,item:r.item}):(e.push({kind:"submenu",id:r.id,def:r.node.def}),n[r.id]={def:r.node.def,items:Array.from(r.node.items.entries()).map(([i,s])=>({id:i,item:s}))});return{main:e,submenus:n}},CD(this,A0,e=>{SD(this,Mo,Ma(this,Mo).filter(n=>n.id!==e))})}}Mo=new WeakMap;A0=new WeakMap;function a3e(t){t.addItem("improve",{icon:S9,label:"Improve writing",streamingLabel:"Improving writing",prompt:"Improve the writing while preserving the original meaning."}).addItem("grammar",{icon:_ke,label:"Fix grammar & spelling",streamingLabel:"Fixing grammar & spelling",prompt:"Fix any grammar and spelling errors without changing the meaning."}).addItem("shorter",{icon:qke,label:"Make shorter",streamingLabel:"Making shorter",prompt:"Make this shorter while preserving the key information."}).addItem("longer",{icon:Lke,label:"Make longer",streamingLabel:"Expanding",prompt:"Expand this with more detail and examples."}),t.addSubmenu("tone",{icon:hg,label:"Change tone…",title:"Change tone",searchPlaceholder:"Search tones…"},e=>{const n=[["professional","Professional"],["casual","Casual"],["confident","Confident"],["friendly","Friendly"],["direct","Direct"],["formal","Formal"]];for(const[r,i]of n)e.addItem(r,{icon:hg,label:i,streamingLabel:"Adjusting tone",prompt:`Rewrite this in a ${i.toLowerCase()} tone.`})}),t.addSubmenu("translate",{icon:kD,label:"Translate…",title:"Translate",searchPlaceholder:"Search languages…"},e=>{const n=[["english","English","English"],["chinese","Chinese","Chinese (Simplified)"],["japanese","Japanese","Japanese"],["korean","Korean","Korean"],["spanish","Spanish","Spanish"],["french","French","French"],["german","German","German"]];for(const[r,i,s]of n)e.addItem(r,{icon:kD,label:i,streamingLabel:`Translating to ${i}`,prompt:`Translate this to ${s}.`})})}function Xc(...t){}Xc(W);function l3e(t,e){const n=e.trim();if(!n)return[t];const r=t.toLowerCase(),i=n.toLowerCase(),s=r.indexOf(i);return s===-1?[t]:[t.slice(0,s),W("mark",null,t.slice(s,s+n.length)),t.slice(s+n.length)]}const c3e=cr({props:{placeholder:{type:Object,required:!0},resetSignal:{type:Object,required:!0},suggestions:{type:Object,required:!0},chrome:{type:Object,required:!0},onConfirm:{type:Function,required:!0},onCancel:{type:Function,required:!0}},setup({placeholder:t,resetSignal:e,suggestions:n,chrome:r,onConfirm:i,onCancel:s}){const o=He(""),a=He({kind:"main"}),l=He(0),c=He(null),u=He(null),h=`ai-instruction-list-${Math.random().toString(36).slice(2,9)}`,f=B=>`${h}-opt-${B}`,d=`ai-instruction-input-${Math.random().toString(36).slice(2,9)}`;nl(e,()=>{o.value="",a.value={kind:"main"},l.value=0});const p=rs(()=>{if(a.value.kind==="submenu"){const B=n.submenus[a.value.id];return B?B.items.map(({id:K,item:U})=>({id:K,icon:U.icon,label:U.label,hasSubmenu:!1,prompt:{text:U.prompt,streamingLabel:U.streamingLabel}})):[]}return n.main.map(B=>B.kind==="item"?{id:B.id,icon:B.item.icon,label:B.item.label,hasSubmenu:!1,prompt:{text:B.item.prompt,streamingLabel:B.item.streamingLabel}}:{id:B.id,icon:B.def.icon,label:B.def.label,hasSubmenu:!0})}),m=rs(()=>{var B,K;return a.value.kind!=="submenu"?null:(K=(B=n.submenus[a.value.id])==null?void 0:B.def)!=null?K:null}),g=rs(()=>{const B=o.value.trim().toLowerCase();return B?p.value.filter(K=>K.label.toLowerCase().includes(B)):p.value}),y=rs(()=>o.value.trim().length>0),b=rs(()=>g.value.length+(y.value?1:0));nl([g,a,y],()=>{l.value=y.value?g.value.length:0});const v=()=>{fC(()=>{var B;return(B=c.value)==null?void 0:B.focus()})},A=B=>{a.value={kind:"submenu",id:B},o.value="",l.value=0,v()},k=()=>{a.value={kind:"main"},o.value="",l.value=0,v()},w=B=>{B.hasSubmenu?A(B.id):B.prompt&&(i(B.prompt.text,B.prompt.streamingLabel),o.value="")},S=()=>{const B=o.value.trim();B&&(i(B),o.value="")},_=()=>{const B=l.value,K=g.value;B<K.length?w(K[B]):y.value&&S()},I=()=>{fC(()=>{const B=u.value;if(!B)return;const K=B.querySelector(`[data-index="${l.value}"]`);K?.scrollIntoView({block:"nearest"})})},M=B=>{if(B.stopPropagation(),B.key==="ArrowDown"){if(B.preventDefault(),b.value===0)return;l.value=(l.value+1)%b.value,I();return}if(B.key==="ArrowUp"){if(B.preventDefault(),b.value===0)return;l.value=(l.value-1+b.value)%b.value,I();return}if(B.key==="Enter"){B.preventDefault(),_();return}if(B.key==="Escape"){B.preventDefault(),a.value.kind==="submenu"?k():s();return}B.key==="Backspace"&&o.value===""&&a.value.kind==="submenu"&&(B.preventDefault(),k())},F=B=>{B.preventDefault()};return()=>{const B=g.value,K=y.value,U=m.value;return W("div",{class:"ai-instruction"},W("div",{class:"ai-instruction-input"},W("span",{class:"ai-instruction-input-prefix"},W(ai,{icon:r.aiIcon})),W("input",{ref:c,id:d,class:"ai-instruction-input-field",role:"combobox","aria-expanded":"true","aria-autocomplete":"list","aria-controls":h,"aria-activedescendant":b.value>0?f(l.value):void 0,placeholder:U?U.searchPlaceholder:t.value,value:o.value,onInput:$=>{o.value=$.target.value},onKeydown:M}),W("button",{type:"button",class:"ai-instruction-submit","aria-label":r.submitButtonLabel,disabled:!K,onMousedown:F,onClick:S},W(ai,{icon:r.sendIcon}))),W("div",{class:"ai-instruction-list",ref:u,id:h,role:"listbox","aria-label":r.listboxLabel},U&&W("button",{type:"button",class:"ai-instruction-back",onMousedown:F,onClick:k},W("span",{class:"ai-instruction-back-icon","aria-hidden":"true"},W(ai,{icon:r.chevronLeftIcon})),W("span",null,U.title)),B.length>0&&W("div",{class:"ai-instruction-section"},W("div",{class:"ai-instruction-section-header"},r.suggestionsHeaderLabel),B.map(($,he)=>W("div",{key:$.id,id:f(he),"data-index":he,role:"option","aria-selected":he===l.value,class:["ai-instruction-item",he===l.value?"active":""],onMousedown:F,onClick:()=>w($),onPointerenter:()=>{l.value=he}},W("span",{class:"ai-instruction-item-icon"},W(ai,{icon:$.icon})),W("span",{class:"ai-instruction-item-label"},l3e($.label,o.value)),$.hasSubmenu&&W("span",{class:"ai-instruction-item-arrow"},W(ai,{icon:r.chevronRightIcon}))))),K&&W("div",{class:"ai-instruction-section"},W("div",{class:"ai-instruction-section-header"},r.sendAsPromptHeaderLabel),W("div",{id:f(B.length),"data-index":B.length,role:"option","aria-selected":l.value===B.length,class:["ai-instruction-item","ai-instruction-item-prompt",l.value===B.length?"active":""],onMousedown:F,onClick:S,onPointerenter:()=>{l.value=B.length}},W("span",{class:"ai-instruction-item-icon"},W(ai,{icon:r.sendPromptIcon})),W("span",{class:"ai-instruction-item-label"},r.sendAsPromptLabel," ",W("span",{class:"ai-instruction-item-quote"},'"',o.value,'"')),W("span",{class:"ai-instruction-item-shortcut"},W(ai,{icon:r.enterKeyIcon}))))))}}});var sK=t=>{throw TypeError(t)},oK=(t,e,n)=>e.has(t)||sK("Cannot "+n),zn=(t,e,n)=>(oK(t,e,"read from private field"),n?n.call(t):e.get(t)),Eo=(t,e,n)=>e.has(t)?sK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),ys=(t,e,n,r)=>(oK(t,e,"write to private field"),e.set(t,n),n),Su,Gs,av,lv,w0,cv,uv,Ql,s6,o6;class u3e{constructor(e,n,r){this.ctx=e,Eo(this,Su),Eo(this,Gs),Eo(this,av),Eo(this,lv),Eo(this,w0),Eo(this,cv,-1),Eo(this,uv,-1),Eo(this,Ql,!1),Eo(this,s6,(o,a)=>{!o.trim()||!this.ctx.get(Ce).call(_9.key,{instruction:o,label:a})||(ys(this,Ql,!1),zn(this,Gs).hide())}),Eo(this,o6,()=>{ys(this,Ql,!1),zn(this,Gs).hide()}),this.show=(o,a)=>{ys(this,cv,o),ys(this,uv,a),zn(this,w0).value++,ys(this,Ql,!0);const l=this.ctx.get(bt);zn(this,Gs).show({getBoundingClientRect:()=>Lg(l,o,a)},l),requestAnimationFrame(()=>{var c;(c=zn(this,Su).querySelector("input"))==null||c.focus()})},this.update=(o,a)=>{const{selection:l}=o.state,c=l instanceof qe,u=l.from!==zn(this,cv)||l.to!==zn(this,uv);if(!c||u){ys(this,Ql,!1),zn(this,Gs).hide();return}zn(this,Gs).update(o,a)},this.destroy=()=>{zn(this,av).unmount(),zn(this,Gs).destroy(),zn(this,Su).remove()},ys(this,lv,He(r.placeholder)),ys(this,w0,He(0));const i=document.createElement("div");i.className="milkdown-ai-instruction";const s=fs(c3e,{placeholder:zn(this,lv),resetSignal:zn(this,w0),suggestions:r.suggestions,chrome:r.chrome,onConfirm:zn(this,s6),onCancel:zn(this,o6)});s.mount(i),ys(this,av,s),ys(this,Su,i),ys(this,Gs,new r1({content:i,debounce:0,offset:10,shouldShow:()=>zn(this,Ql),floatingUIOptions:{placement:"bottom"}})),zn(this,Gs).onHide=()=>{ys(this,Ql,!1),requestAnimationFrame(()=>{try{const a=zn(this,Su).getRootNode().activeElement;if(!a||!zn(this,Su).contains(a))return;this.ctx.get(bt).dom.focus({preventScroll:!0})}catch{}})},zn(this,Gs).update(n)}}Su=new WeakMap;Gs=new WeakMap;av=new WeakMap;lv=new WeakMap;w0=new WeakMap;cv=new WeakMap;uv=new WeakMap;Ql=new WeakMap;s6=new WeakMap;o6=new WeakMap;const h3e={show:()=>{}},O9=St({...h3e},"aiInstructionTooltipAPI"),aK=i1("CREPE_AI_INSTRUCTION"),f3e="SUGGESTIONS",d3e="SEND AS PROMPT",p3e="Ask AI:",m3e="Send prompt",g3e="AI suggestions",y3e="Tell AI what to do with the selection…";function b3e(t){var e,n,r,i,s,o,a,l,c,u,h;return{aiIcon:(e=t?.aiIcon)!=null?e:S9,sendIcon:(n=t?.sendIcon)!=null?n:Hke,sendPromptIcon:(r=t?.sendPromptIcon)!=null?r:Wke,enterKeyIcon:(i=t?.enterKeyIcon)!=null?i:HU,chevronLeftIcon:(s=t?.chevronLeftIcon)!=null?s:Tke,chevronRightIcon:(o=t?.chevronRightIcon)!=null?o:Ike,suggestionsHeaderLabel:(a=t?.suggestionsHeaderLabel)!=null?a:f3e,sendAsPromptHeaderLabel:(l=t?.sendAsPromptHeaderLabel)!=null?l:d3e,sendAsPromptLabel:(c=t?.sendAsPromptLabel)!=null?c:p3e,submitButtonLabel:(u=t?.submitButtonLabel)!=null?u:m3e,listboxLabel:(h=t?.listboxLabel)!=null?h:g3e}}function v3e(t){var e,n;const r=new o3e;return a3e(r),(e=t?.buildAISuggestions)==null||e.call(t,r),{placeholder:(n=t?.instructionPlaceholder)!=null?n:y3e,chrome:b3e(t),suggestions:r.build()}}function A3e(t){return e=>{const n=v3e(t);let r=null;e.update(O9.key,i=>({...i,show:(s,o)=>{r?.show(s,o)}})),e.set(aK.key,{view:i=>(r=new u3e(e,i,n),r)})}}var lK=t=>{throw TypeError(t)},cK=(t,e,n)=>e.has(t)||lK("Cannot "+n),_a=(t,e,n)=>(cK(t,e,"read from private field"),n?n.call(t):e.get(t)),mu=(t,e,n)=>e.has(t)?lK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),df=(t,e,n,r)=>(cK(t,e,"write to private field"),e.set(t,n),n),hv,fv,dv,a6,pv,Rf,mv;const Gy="milkdown-ai-streaming",w3e=800,x3e="Generating",k3e="Esc to cancel",TD=new Vt("CREPE_AI_STREAMING_INDICATOR");class C3e{constructor(e,n,r){mu(this,hv),mu(this,fv),mu(this,dv),mu(this,a6,performance.now()),mu(this,pv,""),mu(this,Rf,0),mu(this,mv,()=>{const c=(performance.now()-_a(this,a6))/w3e*360;_a(this,hv).style.transform=`rotate(${c}deg)`,df(this,Rf,requestAnimationFrame(_a(this,mv)))}),df(this,dv,n);const i=document.createElement("span");i.className=`${Gy}-indicator`,i.contentEditable="false",i.setAttribute("role","status"),i.setAttribute("aria-live","polite");const s=document.createElement("span");s.className=`${Gy}-spinner`,s.setAttribute("aria-hidden","true"),i.appendChild(s);const o=document.createElement("span");o.className=`${Gy}-label`,i.appendChild(o);const a=document.createElement("span");a.className=`${Gy}-esc`,a.textContent=r,i.appendChild(a),this.dom=i,df(this,hv,s),df(this,fv,o),this.setLabel(e),_a(this,mv).call(this)}setLabel(e){const r=`${e.get(sr.key).label||_a(this,dv)}…`;r!==_a(this,pv)&&(df(this,pv,r),_a(this,fv).textContent=r)}destroy(){_a(this,Rf)&&cancelAnimationFrame(_a(this,Rf)),df(this,Rf,0)}}hv=new WeakMap;fv=new WeakMap;dv=new WeakMap;a6=new WeakMap;pv=new WeakMap;Rf=new WeakMap;mv=new WeakMap;function S3e(t={}){var e,n;const{config:r}=t,i=(e=r?.fallbackLabel)!=null?e:x3e,s=(n=r?.cancelHint)!=null?n:k3e;return Qt(o=>{let a=null;function l(){return a?a.setLabel(o):a=new C3e(o,i,s),a}function c(){a&&(a.destroy(),a=null)}function u(h,f){const d=Math.min(f,h.content.size),p=Cn.widget(d,l().dom,{side:1,key:"ai-streaming-indicator"});return It.create(h,[p])}return new Bt({key:TD,state:{init:()=>It.empty,apply(h,f,d,p){const m=Yn.getState(p);return!m?.active||m.insertEndPos==null?(c(),It.empty):h.getMeta(Yn)||h.docChanged?u(p.doc,m.insertEndPos):f.map(h.mapping,h.doc)}},view(){return{destroy(){c()}}},props:{decorations(h){var f;return(f=TD.getState(h))!=null?f:It.empty},handleKeyDown(h,f){var d;if(f.key!=="Escape")return!1;const p=o.get(Ce);return o.get(sr.key).abortController?(f.preventDefault(),p.call(QU.key,{keep:!0}),!0):(d=Yn.getState(h.state))!=null&&d.active?(f.preventDefault(),p.call(jd.key,{keep:!0}),!0):!1}}})})}const E3e=["table","image-block","code_block"],ID={heading:["id"]},T3e=(t,e)=>{var n,r;const i=(n=e?.diff)!=null?n:{},s=(r=e?.streaming)!=null?r:{};t.config(Ws(Et.AI)).config(o=>{o.update($w.key,c=>{var u;return{...c,ignoreAttrs:(u=i.ignoreAttrs)!=null?u:ID}});const{ignoreAttrs:a,...l}=i;o.update(Uw.key,c=>{var u;return{...c,customBlockTypes:(u=l.customBlockTypes)!=null?u:E3e,...l}})}).use(C0e).use(H0e).config(o=>{o.update(Vh.key,a=>{var l;return{...a,...s,ignoreAttrs:(l=s.ignoreAttrs)!=null?l:ID,...e?.diffReviewOnEnd!==void 0?{diffReviewOnEnd:e.diffReviewOnEnd}:{}}})}).use(X0e).config(o=>{o.update(Od.key,a=>{var l;return{...a,...e?.provider!==void 0?{provider:e.provider}:{},...e?.buildContext!==void 0?{buildContext:e.buildContext}:{},diffReviewOnEnd:(l=e?.diffReviewOnEnd)!=null?l:a.diffReviewOnEnd,...e?.onError!==void 0?{onError:e.onError}:{},...e?.aiIcon!==void 0?{aiIcon:e.aiIcon}:{}}})}).use(Od).use(sr).use(_9).use(QU).config(A3e(e)).use(O9).use(aK).use(S3e({config:e?.streamingIndicator})).use(s3e({config:e?.diffActions,enterKeyIcon:e?.enterKeyIcon}))};function uK(t){return t.$from.parent.type.name==="code_block"}function hK(t){var e;const n=(e=t.$from.node(t.$from.depth-1))==null?void 0:e.type;return n?.name==="list_item"}var fK=t=>{throw TypeError(t)},dK=(t,e,n)=>e.has(t)||fK("Cannot "+n),Vp=(t,e,n)=>(dK(t,e,"read from private field"),n?n.call(t):e.get(t)),MD=(t,e,n)=>e.has(t)?fK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),I3e=(t,e,n,r)=>(dK(t,e,"write to private field"),e.set(t,n),n),Of,gv;class D9{constructor(){MD(this,Of,[]),this.clear=()=>(I3e(this,Of,[]),this),MD(this,gv,e=>{const n={group:e,addItem:(r,i)=>{const s={...i,key:r};return e.items.push(s),n},clear:()=>(e.items=[],n)};return n}),this.addGroup=(e,n)=>{const i={key:e,label:n,items:[]};return Vp(this,Of).push(i),Vp(this,gv).call(this,i)},this.getGroup=e=>{const n=Vp(this,Of).find(r=>r.key===e);if(!n)throw new Error(`Group with key ${e} not found`);return Vp(this,gv).call(this,n)},this.build=()=>Vp(this,Of)}}Of=new WeakMap;gv=new WeakMap;function M3e(t,e,n){var r,i,s,o,a,l,c,u,h,f,d,p,m,g,y,b,v,A,k,w,S,_,I,M,F,B,K,U,$,he,ie,pe,Le,P,Q,z,E,X,V,se,_e,Re,Se,Ke,D,N,G,ae,re,Y,me,ne,ye,ee,Be,Te,Ne,Ue,it,pt,J,le,Oe,$e,Ht,gt,vn,$t,hn,Lr,Fr,xl,ba,tr,Ui,zr,bo,va,vo,fp,dp,pp,mp,gp,ru,iu,Ki,Aa,Yh,Qh,L1,yp,Zh,bp,Xh,F1,kl,z1,H1,wn,wa,W1,vp,ef,Ap,wp,q1,V1,$1,j1,qs,xp,tf,xa,kp,nf,rf,sf,U1;const ka=n&&rp(n).get(),t4=ka?.includes(Et.Latex),n4=ka?.includes(Et.ImageBlock),r4=ka?.includes(Et.Table),su=new D9;if(e?.textGroup!==null){const Nt=su.addGroup("text",(i=(r=e?.textGroup)==null?void 0:r.label)!=null?i:"Text");((s=e?.textGroup)==null?void 0:s.text)!==null&&Nt.addItem("text",{label:(l=(a=(o=e?.textGroup)==null?void 0:o.text)==null?void 0:a.label)!=null?l:"Text",icon:(h=(u=(c=e?.textGroup)==null?void 0:c.text)==null?void 0:u.icon)!=null?h:Vke,onRun:Ge=>{const Je=Ge.get(Ce),_t=cs.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t})}}),((f=e?.textGroup)==null?void 0:f.h1)!==null&&Nt.addItem("h1",{label:(m=(p=(d=e?.textGroup)==null?void 0:d.h1)==null?void 0:p.label)!=null?m:"Heading 1",icon:(b=(y=(g=e?.textGroup)==null?void 0:g.h1)==null?void 0:y.icon)!=null?b:Rke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:1}})}}),((v=e?.textGroup)==null?void 0:v.h2)!==null&&Nt.addItem("h2",{label:(w=(k=(A=e?.textGroup)==null?void 0:A.h2)==null?void 0:k.label)!=null?w:"Heading 2",icon:(I=(_=(S=e?.textGroup)==null?void 0:S.h2)==null?void 0:_.icon)!=null?I:Oke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:2}})}}),((M=e?.textGroup)==null?void 0:M.h3)!==null&&Nt.addItem("h3",{label:(K=(B=(F=e?.textGroup)==null?void 0:F.h3)==null?void 0:B.label)!=null?K:"Heading 3",icon:(he=($=(U=e?.textGroup)==null?void 0:U.h3)==null?void 0:$.icon)!=null?he:Dke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:3}})}}),((ie=e?.textGroup)==null?void 0:ie.h4)!==null&&Nt.addItem("h4",{label:(P=(Le=(pe=e?.textGroup)==null?void 0:pe.h4)==null?void 0:Le.label)!=null?P:"Heading 4",icon:(E=(z=(Q=e?.textGroup)==null?void 0:Q.h4)==null?void 0:z.icon)!=null?E:Bke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:4}})}}),((X=e?.textGroup)==null?void 0:X.h5)!==null&&Nt.addItem("h5",{label:(_e=(se=(V=e?.textGroup)==null?void 0:V.h5)==null?void 0:se.label)!=null?_e:"Heading 5",icon:(Ke=(Se=(Re=e?.textGroup)==null?void 0:Re.h5)==null?void 0:Se.icon)!=null?Ke:Nke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:5}})}}),((D=e?.textGroup)==null?void 0:D.h6)!==null&&Nt.addItem("h6",{label:(ae=(G=(N=e?.textGroup)==null?void 0:N.h6)==null?void 0:G.label)!=null?ae:"Heading 6",icon:(me=(Y=(re=e?.textGroup)==null?void 0:re.h6)==null?void 0:Y.icon)!=null?me:Pke,onRun:Ge=>{const Je=Ge.get(Ce),_t=ci.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t,attrs:{level:6}})}}),((ne=e?.textGroup)==null?void 0:ne.quote)!==null&&Nt.addItem("quote",{label:(Be=(ee=(ye=e?.textGroup)==null?void 0:ye.quote)==null?void 0:ee.label)!=null?Be:"Quote",icon:(Ue=(Ne=(Te=e?.textGroup)==null?void 0:Te.quote)==null?void 0:Ne.icon)!=null?Ue:$U,onRun:Ge=>{const Je=Ge.get(Ce),_t=Fh.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((it=e?.textGroup)==null?void 0:it.divider)!==null&&Nt.addItem("divider",{label:(le=(J=(pt=e?.textGroup)==null?void 0:pt.divider)==null?void 0:J.label)!=null?le:"Divider",icon:(Ht=($e=(Oe=e?.textGroup)==null?void 0:Oe.divider)==null?void 0:$e.icon)!=null?Ht:zU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Hh.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t})}})}if(e?.listGroup!==null){const Nt=su.addGroup("list",(vn=(gt=e?.listGroup)==null?void 0:gt.label)!=null?vn:"List");(($t=e?.listGroup)==null?void 0:$t.bulletList)!==null&&Nt.addItem("bullet-list",{label:(Fr=(Lr=(hn=e?.listGroup)==null?void 0:hn.bulletList)==null?void 0:Lr.label)!=null?Fr:"Bullet List",icon:(tr=(ba=(xl=e?.listGroup)==null?void 0:xl.bulletList)==null?void 0:ba.icon)!=null?tr:LU,onRun:Ge=>{const Je=Ge.get(Ce),_t=jc.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((Ui=e?.listGroup)==null?void 0:Ui.orderedList)!==null&&Nt.addItem("ordered-list",{label:(va=(bo=(zr=e?.listGroup)==null?void 0:zr.orderedList)==null?void 0:bo.label)!=null?va:"Ordered List",icon:(dp=(fp=(vo=e?.listGroup)==null?void 0:vo.orderedList)==null?void 0:fp.icon)!=null?dp:VU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Uc.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t})}}),((pp=e?.listGroup)==null?void 0:pp.taskList)!==null&&Nt.addItem("task-list",{label:(ru=(gp=(mp=e?.listGroup)==null?void 0:mp.taskList)==null?void 0:gp.label)!=null?ru:"Task List",icon:(Aa=(Ki=(iu=e?.listGroup)==null?void 0:iu.taskList)==null?void 0:Ki.icon)!=null?Aa:GU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Ls.type(Ge);Je.call(wr.key),Je.call(Ka.key,{nodeType:_t,attrs:{checked:!1}})}})}if(e?.advancedGroup!==null){const Nt=su.addGroup("advanced",(Qh=(Yh=e?.advancedGroup)==null?void 0:Yh.label)!=null?Qh:"Advanced");((L1=e?.advancedGroup)==null?void 0:L1.image)!==null&&n4&&Nt.addItem("image",{label:(bp=(Zh=(yp=e?.advancedGroup)==null?void 0:yp.image)==null?void 0:Zh.label)!=null?bp:"Image",icon:(kl=(F1=(Xh=e?.advancedGroup)==null?void 0:Xh.image)==null?void 0:F1.icon)!=null?kl:zA,onRun:Ge=>{const Je=Ge.get(Ce),_t=f1.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t})}}),((z1=e?.advancedGroup)==null?void 0:z1.codeBlock)!==null&&Nt.addItem("code",{label:(wa=(wn=(H1=e?.advancedGroup)==null?void 0:H1.codeBlock)==null?void 0:wn.label)!=null?wa:"Code",icon:(ef=(vp=(W1=e?.advancedGroup)==null?void 0:W1.codeBlock)==null?void 0:vp.icon)!=null?ef:I9,onRun:Ge=>{const Je=Ge.get(Ce),_t=Bs.type(Ge);Je.call(wr.key),Je.call(As.key,{nodeType:_t})}}),((Ap=e?.advancedGroup)==null?void 0:Ap.table)!==null&&r4&&Nt.addItem("table",{label:(V1=(q1=(wp=e?.advancedGroup)==null?void 0:wp.table)==null?void 0:q1.label)!=null?V1:"Table",icon:(qs=(j1=($1=e?.advancedGroup)==null?void 0:$1.table)==null?void 0:j1.icon)!=null?qs:KU,onRun:Ge=>{const Je=Ge.get(Ce),_t=Ge.get(bt);Je.call(wr.key);const{from:G1}=_t.state.selection;Je.call(Ga.key,{nodeType:Iw(Ge,3,3)}),Je.call($7.key,{pos:G1})}}),((xp=e?.advancedGroup)==null?void 0:xp.math)!==null&&t4&&Nt.addItem("math",{label:(kp=(xa=(tf=e?.advancedGroup)==null?void 0:tf.math)==null?void 0:xa.label)!=null?kp:"Math",icon:(sf=(rf=(nf=e?.advancedGroup)==null?void 0:nf.math)==null?void 0:rf.icon)!=null?sf:M9,onRun:Ge=>{const Je=Ge.get(Ce),_t=Bs.type(Ge);Je.call(wr.key),Je.call(Ga.key,{nodeType:_t,attrs:{language:"LaTeX"}})}})}(U1=e?.buildMenu)==null||U1.call(e,su);let Cl=su.build();t&&(Cl=Cl.map(Nt=>{const Ge=Nt.items.filter(Je=>Je.label.toLowerCase().includes(t.toLowerCase()));return{...Nt,items:Ge}}).filter(Nt=>Nt.items.length>0));const K1=Cl.flatMap(Nt=>Nt.items);return K1.forEach((Nt,Ge)=>{Object.assign(Nt,{index:Ge})}),Cl.reduce((Nt,Ge)=>{const Je=Nt+Ge.items.length;return Object.assign(Ge,{range:[Nt,Je]}),Je},0),{groups:Cl,size:K1.length}}Xc(W);const _3e=cr({props:{ctx:{type:Object,required:!0},show:{type:Object,required:!0},filter:{type:Object,required:!0},hide:{type:Function,required:!0},config:{type:Object,required:!1}},setup({ctx:t,show:e,filter:n,hide:r,config:i}){const s=He(),o=rs(()=>M3e(n.value,i,t)),a=He(0),l=He({x:-999,y:-999}),c=m=>{const{x:g,y}=m;l.value={x:g,y}};nl([o,e],()=>{const{size:m}=o.value;m===0&&e.value?r():a.value>=m&&(a.value=0)});const u=(m,g)=>{const y=a.value,b=typeof m=="function"?m(y):m;g?.(b),a.value=b},h=m=>{var g,y;const b=(g=s.value)==null?void 0:g.querySelector(`[data-index="${m}"]`),v=(y=s.value)==null?void 0:y.querySelector(".menu-groups");!b||!v||(v.scrollTop=b.offsetTop-v.offsetTop)},f=m=>{const g=o.value.groups.flatMap(y=>y.items).at(m);g?.onRun&&t&&g.onRun(t),r()},d=m=>{const{size:g,groups:y}=o.value;if(m.key==="Escape"){m.preventDefault(),r?.();return}if(m.key==="ArrowDown")return m.preventDefault(),u(b=>b<g-1?b+1:b,h);if(m.key==="ArrowUp")return m.preventDefault(),u(b=>b<=0?b:b-1,h);if(m.key==="ArrowLeft")return m.preventDefault(),u(b=>{const v=y.find(k=>k.range[0]<=b&&k.range[1]>b);if(!v)return b;const A=y[y.indexOf(v)-1];return A?A.range[1]-1:b},h);if(m.key==="ArrowRight")return m.preventDefault(),u(b=>{const v=y.find(k=>k.range[0]<=b&&k.range[1]>b);if(!v)return b;const A=y[y.indexOf(v)+1];return A?A.range[0]:b},h);m.key==="Enter"&&(m.preventDefault(),f(a.value))},p=m=>g=>{const y=l.value;if(!y)return;const{x:b,y:v}=g;b===y.x&&v===y.y||u(m)};return Kd(()=>{e.value?window.addEventListener("keydown",d,{capture:!0}):window.removeEventListener("keydown",d,{capture:!0})}),Jd(()=>{window.removeEventListener("keydown",d,{capture:!0})}),()=>W("div",{ref:s,onPointerdown:m=>m.preventDefault()},W("nav",{class:"tab-group"},W("ul",null,o.value.groups.map(m=>W("li",{key:m.key,onPointerdown:()=>u(m.range[0],h),class:a.value>=m.range[0]&&a.value<m.range[1]?"selected":""},m.label)))),W("div",{class:"menu-groups",onPointermove:c},o.value.groups.map(m=>W("div",{key:m.key,class:"menu-group"},W("h6",null,m.label),W("ul",null,m.items.map(g=>W("li",{key:g.key,"data-index":g.index,class:a.value===g.index?"hover":"",onPointerenter:p(g.index),onPointerdown:()=>{var y,b;(b=(y=s.value)==null?void 0:y.querySelector(`[data-index="${g.index}"]`))==null||b.classList.add("active")},onPointerup:()=>{var y,b;(b=(y=s.value)==null?void 0:y.querySelector(`[data-index="${g.index}"]`))==null||b.classList.remove("active"),f(g.index)}},W(ai,{icon:g.icon}),W("span",null,g.label))))))))}});var pK=t=>{throw TypeError(t)},mK=(t,e,n)=>e.has(t)||pK("Cannot "+n),$s=(t,e,n)=>(mK(t,e,"read from private field"),n?n.call(t):e.get(t)),$p=(t,e,n)=>e.has(t)?pK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),gu=(t,e,n,r)=>(mK(t,e,"write to private field"),e.set(t,n),n),x0,yv,bv,Ba,Df;const gK=Xye("CREPE_MENU"),B9=St({show:()=>{},hide:()=>{}},"menuAPICtx");function R3e(t,e){t.set(gK.key,{view:n=>new O3e(t,n,e)})}class O3e{constructor(e,n,r){$p(this,x0),$p(this,yv),$p(this,bv),$p(this,Ba),$p(this,Df,null),this.update=d=>{$s(this,Ba).update(d)},this.show=d=>{gu(this,Df,d),$s(this,bv).value="",$s(this,Ba).show()},this.hide=()=>{gu(this,Df,null),$s(this,Ba).hide()},this.destroy=()=>{$s(this,Ba).destroy(),$s(this,yv).unmount(),$s(this,x0).remove()};var i,s;const o=document.createElement("div");o.classList.add("milkdown-slash-menu");const a=He(!1),l=He("");gu(this,bv,l);const c=this.hide,u=fs(_3e,{ctx:e,config:r,show:a,filter:l,hide:c});gu(this,yv,u),u.mount(o),gu(this,x0,o);const h=this,f=(i=r?.slashMenu)!=null?i:{};gu(this,Ba,new ebe({content:$s(this,x0),debounce:20,shouldShow(d){if(uK(d.state.selection)||hK(d.state.selection))return!1;const p=this.getContent(d,g=>["paragraph","heading"].includes(g.type.name));if(p==null||!D3e(d.state.selection))return!1;const m=$s(h,Df);if(l.value=p.startsWith("/")?p.slice(1):p,typeof m=="number"){const g=d.state.doc.nodeSize-2,y=Math.min(m,g);return d.state.doc.resolve(y).node()!==d.state.doc.resolve(d.state.selection.from).node()?(gu(h,Df,null),!1):!0}return!!p.startsWith("/")},offset:(s=f.offset)!=null?s:10,middleware:f.middleware,floatingUIOptions:f.floatingUIOptions,root:f.root})),$s(this,Ba).onShow=()=>{a.value=!0},$s(this,Ba).onHide=()=>{a.value=!1},this.update(n),e.set(B9.key,{show:d=>this.show(d),hide:()=>this.hide()})}}x0=new WeakMap;yv=new WeakMap;bv=new WeakMap;Ba=new WeakMap;Df=new WeakMap;function D3e(t){if(!(t instanceof qe))return!1;const{$head:e}=t,n=e.parent;return e.parentOffset===n.content.size}Xc(W,Ft);const B3e=cr({props:{onAdd:{type:Function,required:!0},addIcon:{type:String,required:!0},handleIcon:{type:String,required:!0}},setup(t){const e=He();return()=>W(Ft,null,W("div",{ref:e,class:"operation-item",onPointerdown:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.add("active")},onPointerup:n=>{var r;n.preventDefault(),n.stopPropagation(),(r=e.value)==null||r.classList.remove("active"),t.onAdd()}},W(ai,{icon:t.addIcon})),W("div",{class:"operation-item"},W(ai,{icon:t.handleIcon})))}});var yK=t=>{throw TypeError(t)},bK=(t,e,n)=>e.has(t)||yK("Cannot "+n),yu=(t,e,n)=>(bK(t,e,"read from private field"),n?n.call(t):e.get(t)),Jy=(t,e,n)=>e.has(t)?yK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Yy=(t,e,n,r)=>(bK(t,e,"write to private field"),e.set(t,n),n),vv,Eu,Av,wv;class N3e{constructor(e,n){Jy(this,vv),Jy(this,Eu),Jy(this,Av),Jy(this,wv),this.update=()=>{yu(this,Eu).update()},this.destroy=()=>{yu(this,Eu).destroy(),yu(this,vv).remove(),yu(this,Av).unmount()},this.onAdd=()=>{const h=yu(this,wv),f=h.get(bt);f.hasFocus()||f.focus();const{state:d,dispatch:p}=f,m=yu(this,Eu).active;if(!m)return;const y=m.$pos.pos+m.node.nodeSize;let b=d.tr.insert(y,cs.type(h).create());b=b.setSelection(qe.near(b.doc.resolve(y))),p(b.scrollIntoView()),yu(this,Eu).hide(),h.get(B9.key).show(b.selection.from)};var r,i,s,o,a;Yy(this,wv,e);const l=document.createElement("div");l.classList.add("milkdown-block-handle");const c=fs(B3e,{onAdd:this.onAdd,addIcon:(r=n?.handleAddIcon)!=null?r:e6,handleIcon:(i=n?.handleDragIcon)!=null?i:Fke});c.mount(l),Yy(this,Av,c),Yy(this,vv,l);const u=(s=n?.blockHandle)!=null?s:{};Yy(this,Eu,new Zye({ctx:e,content:l,getOffset:(o=u.getOffset)!=null?o:(()=>16),getPlacement:(a=u.getPlacement)!=null?a:(({active:h,blockDom:f})=>{if(h.node.type.name==="heading")return"left";let d=0;h.node.descendants(w=>{d+=w.childCount});const p=h.el,m=p.getBoundingClientRect(),g=f.getBoundingClientRect(),y=window.getComputedStyle(p),b=Number.parseInt(y.paddingTop,10)||0,v=Number.parseInt(y.paddingBottom,10)||0,A=m.height-b-v,k=g.height;return d>2||k<A?"left-start":"left"}),shouldShow:u.shouldShow,getPosition:u.getPosition,middleware:u.middleware,floatingUIOptions:u.floatingUIOptions,root:u.root})),this.update()}}vv=new WeakMap;Eu=new WeakMap;Av=new WeakMap;wv=new WeakMap;function P3e(t,e){t.set(u2.key,{filterNodes:n=>!Yo(i=>["table","blockquote","math_inline"].includes(i.type.name))(n)}),t.set(d2.key,{view:()=>new N3e(t,e)})}const L3e=(t,e)=>{t.config(Ws(Et.BlockEdit)).config(n=>P3e(n,e)).config(n=>R3e(n,e)).use(B9).use(d2).use(gK)},F3e=(t,e={})=>{t.config(Ws(Et.CodeMirror)).config(n=>{const{languages:r=[],theme:i}=e,s=[Vd.of(R$.concat(Dve)),Gwe];i&&s.push(i),e.extensions&&s.push(...e.extensions),n.update(p1.key,o=>{var a;return{extensions:s,languages:r,expandIcon:e.expandIcon||E9,searchIcon:e.searchIcon||jU,clearSearchIcon:e.clearSearchIcon||T9,searchPlaceholder:e.searchPlaceholder||"Search language",copyText:e.copyText||"Copy",copyIcon:e.copyIcon||FU,onCopy:e.onCopy||(()=>{}),noResultText:e.noResultText||"No result",renderLanguage:e.renderLanguage||o.renderLanguage,renderPreview:e.renderPreview||o.renderPreview,previewToggleButton:l=>{var c,u;const h=((c=e.previewToggleIcon)==null?void 0:c.call(e,l))||(l?hg:JU),f=((u=e.previewToggleText)==null?void 0:u.call(e,l))||(l?"Edit":"Hide");return[h,f].map(d=>d.trim()).join(" ")},previewLabel:e.previewLabel||o.previewLabel,previewLoading:e.previewLoading||o.previewLoading,previewOnlyByDefault:(a=e.previewOnlyByDefault)!=null?a:o.previewOnlyByDefault}})}).use(lAe)},z3e=(t,e)=>{if(t.config(Ws(Et.Cursor)).config(r=>{r.update(x2.key,()=>{var i,s;return{class:"crepe-drop-cursor",width:(i=e?.width)!=null?i:4,color:(s=e?.color)!=null?s:!1}})}).use(d2e),e?.virtual===!1)return;const n=p2e({skipWarning:["inlineCode"]});t.use(Qt(()=>n))},H3e=(t,e)=>{t.config(Ws(Et.ImageBlock)).config(n=>{n.update(k2.key,r=>{var i,s,o,a,l,c;return{uploadButton:(i=e?.inlineUploadButton)!=null?i:"Upload",imageIcon:(s=e?.inlineImageIcon)!=null?s:zA,confirmButton:(o=e?.inlineConfirmButton)!=null?o:z2,uploadPlaceholderText:(a=e?.inlineUploadPlaceholderText)!=null?a:"or paste link",onUpload:(c=(l=e?.inlineOnUpload)!=null?l:e?.onUpload)!=null?c:r.onUpload,proxyDomURL:e?.proxyDomURL}}),n.update(h1.key,r=>{var i,s,o,a,l,c,u,h,f;return{uploadButton:(i=e?.blockUploadButton)!=null?i:"Upload file",imageIcon:(s=e?.blockImageIcon)!=null?s:zA,captionIcon:(o=e?.blockCaptionIcon)!=null?o:Cke,confirmButton:(a=e?.blockConfirmButton)!=null?a:"Confirm",captionPlaceholderText:(l=e?.blockCaptionPlaceholderText)!=null?l:"Write Image Caption",uploadPlaceholderText:(c=e?.blockUploadPlaceholderText)!=null?c:"or paste link",onUpload:(h=(u=e?.blockOnUpload)!=null?u:e?.onUpload)!=null?h:r.onUpload,proxyDomURL:e?.proxyDomURL,onImageLoadError:(f=e?.onImageLoadError)!=null?f:r.onImageLoadError,maxWidth:e?.maxWidth,maxHeight:e?.maxHeight}})}).use(wbe).use(I2e)},W3e=Bs.extendSchema(t=>e=>{const n=t(e);return{...n,toMarkdown:{match:n.toMarkdown.match,runner:(r,i)=>{var s,o;if(((s=i.attrs.language)!=null?s:"").toLowerCase()==="latex")r.addNode("math",void 0,((o=i.content.firstChild)==null?void 0:o.text)||"");else return n.toMarkdown.runner(r,i)}}}}),zf="math_inline",q3e="ToggleLatex",WA=Dn(zf,()=>({group:"inline",inline:!0,draggable:!0,atom:!0,attrs:{value:{default:""}},parseDOM:[{tag:`span[data-type="${zf}"]`,getAttrs:t=>{var e;return{value:(e=t.dataset.value)!=null?e:""}}}],toDOM:t=>{const e=t.attrs.value,n=document.createElement("span");return n.dataset.type=zf,n.dataset.value=e,cU.render(e,n,{throwOnError:!1}),n},parseMarkdown:{match:t=>t.type==="inlineMath",runner:(t,e,n)=>{t.addNode(n,{value:e.value})}},toMarkdown:{match:t=>t.type.name===zf,runner:(t,e)=>{t.addNode("inlineMath",void 0,e.attrs.value)}}})),V3e=je("ToggleLatex",t=>()=>(e,n)=>{const{hasNode:r,pos:i,target:s}=xL(e,WA.type(t)),{selection:o,doc:a,tr:l}=e;if(!r){const d=a.textBetween(o.from,o.to);let p=l.replaceSelectionWith(WA.type(t).create({value:d}));return n&&n(p.setSelection(Ze.create(p.doc,o.from))),!0}const{from:c,to:u}=o;if(!s||i<0)return!1;let h=l.delete(i,i+1);const f=s.attrs.value;return h=h.insertText(f,i),n&&n(h.setSelection(qe.create(h.doc,c,u+f.length-1))),!0}),_D=i1("INLINE_LATEX");Xc(W);const $3e=cr({props:{config:{type:Object,required:!0},innerView:{type:Object,required:!0},updateValue:{type:Object,required:!0}},setup(t){const e=r=>{if(!(!r||!(r instanceof HTMLElement))){for(;r.firstChild;)r.removeChild(r.firstChild);t.innerView.value&&r.appendChild(t.innerView.value.dom)}},n=r=>{r.preventDefault(),t.updateValue.value()};return()=>W("div",{class:"container"},t.innerView.value&&W("div",{ref:e}),W("button",{type:"button",onPointerdown:n},W(ai,{icon:t.config.inlineEditConfirm})))}});var vK=t=>{throw TypeError(t)},AK=(t,e,n)=>e.has(t)||vK("Cannot "+n),ur=(t,e,n)=>(AK(t,e,"read from private field"),n?n.call(t):e.get(t)),Ol=(t,e,n)=>e.has(t)?vK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Qy=(t,e,n,r)=>(AK(t,e,"write to private field"),e.set(t,n),n),k0,Bf,xv,Tu,C0,S0,l6,c6;class j3e{constructor(e,n,r){this.ctx=e,Ol(this,k0),Ol(this,Bf),Ol(this,xv),Ol(this,Tu,yA(null)),Ol(this,C0,yA(()=>{})),Ol(this,S0),Ol(this,l6,()=>{ur(this,Tu).value&&(ur(this,Tu).value.destroy(),ur(this,Tu).value=null)}),Ol(this,c6,s=>{const a=(()=>{if(!s.editable)return!1;const{selection:l,schema:c}=s.state;if(l.empty||!(l instanceof Ze))return!1;const u=l.node;if(u.type.name!==zf)return!1;const h=l.from,f=c.nodes.paragraph.create(null,c.text(u.attrs.value)),d=new a7(ur(this,xv),{state:tL.create({doc:f,schema:new zP({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},text:{group:"inline"}}}),plugins:[CL({"Mod-z":A2,"Mod-Z":Sd,"Mod-y":Sd,Enter:()=>(ur(this,C0).value(),!0)})]})});return ur(this,Tu).value=d,ur(this,C0).value=()=>{const{tr:p}=s.state;p.setNodeAttribute(h,"value",d.state.doc.textContent),s.dispatch(p),requestAnimationFrame(()=>{s.focus()})},!0})();return a||ur(this,l6).call(this),a}),this.update=(s,o)=>{ur(this,Bf).update(s,o)},this.destroy=()=>{ur(this,S0).unmount(),ur(this,Bf).destroy(),ur(this,k0).remove()};const i=document.createElement("div");i.className="milkdown-latex-inline-edit",Qy(this,k0,i),Qy(this,S0,fs($3e,{config:r,innerView:ur(this,Tu),updateValue:ur(this,C0)})),ur(this,S0).mount(i),Qy(this,Bf,new r1({debounce:0,content:ur(this,k0),shouldShow:ur(this,c6),offset:10,floatingUIOptions:{placement:"bottom"}})),ur(this,Bf).update(n),Qy(this,xv,document.createElement("div"))}}k0=new WeakMap;Bf=new WeakMap;xv=new WeakMap;Tu=new WeakMap;C0=new WeakMap;S0=new WeakMap;l6=new WeakMap;c6=new WeakMap;const U3e=Yr(t=>Wee(/(?:\$)([^$]+)(?:\$)$/,WA.type(t),{getAttr:e=>{var n;return{value:(n=e[1])!=null?n:""}}})),K3e=Yr(t=>Q6(/^\$\$[\s\n]$/,Bs.type(t),()=>({language:"LaTeX"}))),G3e=Qr("remarkMath",()=>Gxe);function J3e(t){return Wc(t,"math",(e,n,r)=>{const{value:i}=e,s={type:"code",lang:"LaTeX",value:i};r.children.splice(n,1,s)})}const Y3e=Qr("remarkMathBlock",()=>()=>J3e),Q3e=(t,e)=>{t.config(Ws(Et.Latex)).config(n=>{if(!rp(n).get().includes(Et.CodeMirror))throw new Error("You need to enable CodeMirror to use LaTeX feature");n.update(p1.key,s=>({...s,renderPreview:(o,a,l)=>{if(o.toLowerCase()==="latex"&&a.length>0)return Z3e(a,e?.katexOptions);const c=s.renderPreview;return c(o,a,l)}})),n.set(_D.key,{view:s=>{var o;return new j3e(n,s,{inlineEditConfirm:(o=e?.inlineEditConfirm)!=null?o:z2,...e})}})}).use(G3e).use(Y3e).use(WA).use(_D).use(U3e).use(K3e).use(W3e).use(V3e)};function Z3e(t,e){return cU.renderToString(t,{...e,throwOnError:!1,displayMode:!0})}const X3e=(t,e)=>{t.config(Ws(Et.LinkTooltip)).config(T5e).config(n=>{n.update(Rd.key,r=>{var i,s,o,a,l,c;return{...r,linkIcon:(i=e?.linkIcon)!=null?i:FU,editButton:(s=e?.editButton)!=null?s:hg,removeButton:(o=e?.removeButton)!=null?o:t6,confirmButton:(a=e?.confirmButton)!=null?a:z2,inputPlaceholder:(l=e?.inputPlaceholder)!=null?l:"Paste link...",onCopyLink:(c=e?.onCopyLink)!=null?c:(()=>{})}})}).use(I5e)};function eCe(t,e){t.set(N2.key,{renderLabel:({label:n,listType:r,checked:i})=>{var s,o,a;return i==null?r==="bullet"?(s=e?.bulletIcon)!=null?s:kke:n:i?(o=e?.checkBoxCheckedIcon)!=null?o:Ske:(a=e?.checkBoxUncheckedIcon)!=null?a:Eke}})}const tCe=(t,e)=>{t.config(Ws(Et.ListItem)).config(n=>eCe(n,e)).use(P5e)};function nCe(t){var e;return t.childCount<=1&&!((e=t.firstChild)!=null&&e.content.size)}function rCe(t,e){const{selection:n}=t;if(!n.empty)return null;const r=n.$anchor,i=r.parent;if(i.content.size>0||Yo(a=>a.type.name==="table")(r))return null;const o=r.before();return Cn.node(o,o+i.nodeSize,{class:"crepe-placeholder","data-placeholder":e})}const u6=St({text:"Please enter...",mode:"block"},"placeholderConfigCtx"),iCe=Qt(t=>new Bt({key:new Vt("CREPE_PLACEHOLDER"),props:{decorations:e=>{var n;if(Kke(t).readonly)return null;const i=t.get(u6.key);if(i.mode==="doc"&&!nCe(e.doc)||uK(e.selection)||hK(e.selection))return null;const s=(n=i.text)!=null?n:"Please enter...",o=rCe(e,s);return o?It.create(e.doc,[o]):null}}})),sCe=(t,e)=>{t.config(Ws(Et.Placeholder)).config(n=>{e&&n.update(u6.key,r=>({...r,...e}))}).use(iCe).use(u6)},oCe=(t,e)=>{t.config(Ws(Et.Table)).config(n=>{n.update(P2.key,r=>({...r,renderButton:i=>{var s,o,a,l,c,u,h,f,d;switch(i){case"add_row":return(s=e?.addRowIcon)!=null?s:e6;case"add_col":return(o=e?.addColIcon)!=null?o:e6;case"delete_row":return(a=e?.deleteRowIcon)!=null?a:t6;case"delete_col":return(l=e?.deleteColIcon)!=null?l:t6;case"align_col_left":return(c=e?.alignLeftIcon)!=null?c:wke;case"align_col_center":return(u=e?.alignCenterIcon)!=null?u:Ake;case"align_col_right":return(h=e?.alignRightIcon)!=null?h:xke;case"col_drag_handle":return(f=e?.colDragHandleIcon)!=null?f:xD;case"row_drag_handle":return(d=e?.rowDragHandleIcon)!=null?d:xD}}}))}).use(cke)};function Zy(t,e){return{slice:t,entry:e}}function aCe(t){if(t===" "||t.toLowerCase()==="space")return{display:"Space",aria:" "};if(t.length===1){const e=t.toUpperCase();return{display:e,aria:e}}return{display:t,aria:t}}function lCe(t,e){var n;const r=t.split(/-(?!$)/),i=(n=r[r.length-1])!=null?n:"",s=r.slice(0,-1);let o=!1,a=!1,l=!1,c=!1;for(const d of s)switch(d.toLowerCase()){case"mod":e?o=!0:a=!0;break;case"meta":case"cmd":case"m":o=!0;break;case"ctrl":case"control":case"c":a=!0;break;case"alt":case"option":case"a":l=!0;break;case"shift":case"s":c=!0;break}const u=aCe(i),h=e?[a&&"⌃",l&&"⌥",c&&"⇧",o&&"⌘",u.display].filter(Boolean).join(""):[a&&"Ctrl",l&&"Alt",c&&"Shift",o&&"Meta",u.display].filter(Boolean).join("+"),f=[o&&"Meta",a&&"Control",l&&"Alt",c&&"Shift",u.aria].filter(Boolean).join("+");return{display:h,aria:f}}function cCe(t,e){if(!t.isInjected(e.slice))return;const n=t.get(e.slice)[e.entry],r=n?[n.shortcuts].flat()[0]:void 0;if(r)return lCe(r,e0.mac)}function uCe(t,e){var n,r,i,s,o,a,l,c,u,h,f,d,p,m,g,y,b,v;const A=new D9;A.addGroup("formatting","Formatting").addItem("bold",{icon:(n=t?.boldIcon)!=null?n:PU,label:(r=t?.boldLabel)!=null?r:"Bold",keymap:Zy(xw.key,"ToggleBold"),active:I=>I.get(Ce).call(_u.key,Lh.type(I)),onRun:I=>{I.get(Ce).call($g.key)}}).addItem("italic",{icon:(i=t?.italicIcon)!=null?i:WU,label:(s=t?.italicLabel)!=null?s:"Italic",keymap:Zy(ww.key,"ToggleEmphasis"),active:I=>I.get(Ce).call(_u.key,$c.type(I)),onRun:I=>{I.get(Ce).call(Vg.key)}}).addItem("strikethrough",{icon:(o=t?.strikethroughIcon)!=null?o:UU,label:(a=t?.strikethroughLabel)!=null?a:"Strikethrough",keymap:Zy(Tw.key,"ToggleStrikethrough"),active:I=>I.get(Ce).call(_u.key,Wh.type(I)),onRun:I=>{I.get(Ce).call(Ug.key)}});const k=A.addGroup("function","Function");k.addItem("code",{icon:(l=t?.codeIcon)!=null?l:I9,label:(c=t?.codeLabel)!=null?c:"Inline code",keymap:Zy(kw.key,"ToggleInlineCode"),active:I=>I.get(Ce).call(_u.key,Xs.type(I)),onRun:I=>{I.get(Ce).call(jg.key)}});const w=e&&rp(e).get();if(w?.includes(Et.Latex)&&k.addItem("latex",{icon:(u=t?.latexIcon)!=null?u:M9,label:(h=t?.latexLabel)!=null?h:"Inline math",active:I=>{const M=I.get(Ce),F=I.get(qi).nodes[zf];return M.call(GF.key,F)},onRun:I=>{I.get(Ce).call(q3e)}}),k.addItem("link",{icon:(f=t?.linkIcon)!=null?f:qU,label:(d=t?.linkLabel)!=null?d:"Link",active:I=>I.get(Ce).call(_u.key,as.type(I)),onRun:I=>{I.get(Ce).call(g9.key)}}),e&&w?.includes(Et.AI)){const I=e.get(Od.key);I.provider&&k.addItem("ai",{icon:(m=(p=t?.aiIcon)!=null?p:I.aiIcon)!=null?m:S9,label:(g=t?.aiLabel)!=null?g:"Ask AI",active:()=>!1,onRun:M=>{const F=M.get(O9.key),B=M.get(bt),{from:K,to:U}=B.state.selection;F.show(K,U)}})}(y=t?.buildToolbar)==null||y.call(t,A);const _=A.build();if(e)for(const I of _)for(const M of I.items){if(!M.keymap)continue;const F=cCe(e,M.keymap);F&&((b=M.shortcut)!=null||(M.shortcut=F.display),(v=M.ariaKeyshortcuts)!=null||(M.ariaKeyshortcuts=F.aria))}return _}Xc(W,Ft);const hCe=cr({props:{ctx:{type:Object,required:!0},hide:{type:Function,required:!0},show:{type:Object,required:!0},selection:{type:Object,required:!0},config:{type:Object,required:!1}},setup(t){const{ctx:e,config:n}=t,r=a=>l=>{l.preventDefault(),e&&a?.(e)};function i(a){return Xc(t.selection.value),e.get(zv).status!==Wv.Created?!1:a(e)}const s=rs(()=>uCe(n,e));function o(a){if(a.label)return a.shortcut?`${a.label} (${a.shortcut})`:a.label}return()=>W(Ft,null,s.value.map(a=>a.items.map(l=>W("button",{type:"button",class:Ar("toolbar-item",e&&i(l.active)&&"active"),"data-toolbar-item":l.key,title:o(l),"aria-label":l.label,"aria-keyshortcuts":l.ariaKeyshortcuts,onPointerdown:r(l.onRun)},W(ai,{icon:l.icon})))).reduce((a,l,c)=>(c===0?a.push(...l):a.push(W("div",{class:"divider"}),...l),a),[]))}});var wK=t=>{throw TypeError(t)},xK=(t,e,n)=>e.has(t)||wK("Cannot "+n),Ji=(t,e,n)=>(xK(t,e,"read from private field"),n?n.call(t):e.get(t)),jp=(t,e,n)=>e.has(t)?wK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Xy=(t,e,n,r)=>(xK(t,e,"write to private field"),e.set(t,n),n),Zl,E0,kv,T0,I0;const RD=i1("CREPE_TOOLBAR");class fCe{constructor(e,n,r){jp(this,Zl),jp(this,E0),jp(this,kv),jp(this,T0),jp(this,I0,He(!1)),this.update=(o,a)=>{Ji(this,Zl).update(o,a),Ji(this,T0).value=o.state.selection},this.destroy=()=>{Ji(this,Zl).destroy(),Ji(this,kv).unmount(),Ji(this,E0).remove()},this.hide=()=>{Ji(this,Zl).hide()};const i=document.createElement("div");i.className="milkdown-toolbar",Xy(this,T0,yA(n.state.selection));const s=fs(hCe,{ctx:e,hide:this.hide,config:r,selection:Ji(this,T0),show:Ji(this,I0)});s.mount(i),Xy(this,E0,i),Xy(this,kv,s),Xy(this,Zl,new r1({content:Ji(this,E0),debounce:20,offset:10,shouldShow(o){const{doc:a,selection:l}=o.state,{empty:c,from:u,to:h}=l,f=!a.textBetween(u,h).length&&l instanceof qe,d=!(l instanceof qe),p=o.dom.getRootNode().activeElement,m=i.contains(p),g=!o.hasFocus()&&!m,y=!o.editable;return!(g||d||c||f||y)}})),Ji(this,Zl).onShow=()=>{Ji(this,I0).value=!0},Ji(this,Zl).onHide=()=>{Ji(this,I0).value=!1},this.update(n)}}Zl=new WeakMap;E0=new WeakMap;kv=new WeakMap;T0=new WeakMap;I0=new WeakMap;const dCe=(t,e)=>{t.config(Ws(Et.Toolbar)).config(n=>{n.set(RD.key,{view:r=>new fCe(n,r,e)})}).use(RD)},kK=[{label:"Paragraph",level:null},{label:"Heading 1",level:1},{label:"Heading 2",level:2},{label:"Heading 3",level:3},{label:"Heading 4",level:4},{label:"Heading 5",level:5},{label:"Heading 6",level:6}];function pCe(t,e){var n,r;const i=e??kK,s=t.get(bt),{$from:o}=s.state.selection,a=o.parent,l=(n=i.find(c=>c.level===null))!=null?n:i[0];if(a.type===ci.type(t)){const c=a.attrs.level;return(r=i.find(u=>u.level===c))!=null?r:l}return l}function mCe(t,e){const n=t.get(Ce);if(e==null){const r=cs.type(t);n.call(As.key,{nodeType:r})}else{const r=ci.type(t);n.call(As.key,{nodeType:r,attrs:{level:e}})}}function bu(t,e){if(t.get(Ce).call(_u.key,e))return!0;const i=t.get(bt),{state:s}=i;if(s.storedMarks)return s.storedMarks.some(o=>o.type===e);if(s.selection instanceof qe){const{$cursor:o}=s.selection;if(o)return o.marks().some(a=>a.type===e)}return!1}function gCe(t,e){const n=t??kK;return{icon:"",active:()=>!1,selector:{chevronIcon:e??E9,activeLabel:r=>pCe(r,n).label,options:n.map(r=>({label:r.label,onSelect:i=>mCe(i,r.level)}))}}}function yCe(t,e){var n,r,i,s,o,a,l,c,u,h,f,d,p,m,g;const y=e&&rp(e).get(),b=y?.includes(Et.Latex),v=y?.includes(Et.ImageBlock),A=y?.includes(Et.Table),k=new D9;k.addGroup("heading","Heading").addItem("heading-selector",{...gCe(t?.headingOptions,t?.chevronDownIcon)}),k.addGroup("formatting","Formatting").addItem("bold",{icon:(n=t?.boldIcon)!=null?n:PU,active:_=>bu(_,Lh.type(_)),onRun:_=>{_.get(Ce).call($g.key)}}).addItem("italic",{icon:(r=t?.italicIcon)!=null?r:WU,active:_=>bu(_,$c.type(_)),onRun:_=>{_.get(Ce).call(Vg.key)}}).addItem("strikethrough",{icon:(i=t?.strikethroughIcon)!=null?i:UU,active:_=>bu(_,Wh.type(_)),onRun:_=>{_.get(Ce).call(Ug.key)}}).addItem("code",{icon:(s=t?.codeIcon)!=null?s:I9,active:_=>bu(_,Xs.type(_)),onRun:_=>{const I=_.get(bt),{state:M}=I;if(M.selection.empty){const F=Xs.type(_);bu(_,F)?I.dispatch(M.tr.removeStoredMark(F)):I.dispatch(M.tr.addStoredMark(F.create()))}else _.get(Ce).call(jg.key)}}),k.addGroup("list","List").addItem("bullet-list",{icon:(o=t?.bulletListIcon)!=null?o:LU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=jc.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("ordered-list",{icon:(a=t?.orderedListIcon)!=null?a:VU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Uc.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("task-list",{icon:(l=t?.taskListIcon)!=null?l:GU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Ls.type(_);I.call(Ka.key,{nodeType:M,attrs:{checked:!1}})}});const w=k.addGroup("insert","Insert");w.addItem("link",{icon:(c=t?.linkIcon)!=null?c:qU,active:_=>bu(_,as.type(_)),onRun:_=>{const I=_.get(bt),{state:M}=I,F=as.type(_);if(M.selection.empty&&bu(_,F)){I.dispatch(M.tr.removeStoredMark(F));return}_.get(Ce).call(g9.key)}}),v&&w.addItem("image",{icon:(u=t?.imageIcon)!=null?u:zA,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=f1.type(_);I.call(Ga.key,{nodeType:M})}}),A&&w.addItem("table",{icon:(h=t?.tableIcon)!=null?h:KU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=_.get(bt),{from:F}=M.state.selection;I.call(Ga.key,{nodeType:Iw(_,3,3)}),I.call($7.key,{pos:F})}});const S=k.addGroup("block","Block");return S.addItem("code-block",{icon:(f=t?.codeBlockIcon)!=null?f:Mke,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Bs.type(_);I.call(As.key,{nodeType:M})}}),b&&S.addItem("math",{icon:(d=t?.mathIcon)!=null?d:M9,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Bs.type(_);I.call(Ga.key,{nodeType:M,attrs:{language:"LaTeX"}})}}),k.addGroup("more","More").addItem("quote",{icon:(p=t?.quoteIcon)!=null?p:$U,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Fh.type(_);I.call(Ka.key,{nodeType:M})}}).addItem("hr",{icon:(m=t?.hrIcon)!=null?m:zU,active:()=>!1,onRun:_=>{const I=_.get(Ce),M=Hh.type(_);I.call(Ga.key,{nodeType:M})}}),(g=t?.buildTopBar)==null||g.call(t,k),k.build()}Xc(W,Ft);const bCe=cr({props:{ctx:{type:Object,required:!0},version:{type:Object,required:!0},config:{type:Object,required:!1}},setup(t){const{ctx:e,config:n}=t,r=He(null),i=p=>m=>{m.preventDefault(),e&&p(e)};function s(){return e.get(zv).status===Wv.Created}function o(){Xc(t.version.value)}function a(p){return o(),s()?p(e):!1}function l(p){var m,g;return o(),s()?p.activeLabel(e):(g=(m=p.options[0])==null?void 0:m.label)!=null?g:""}function c(p,m){m.preventDefault(),m.stopPropagation(),r.value=r.value===p?null:p}const u=p=>{p.target.closest(".top-bar-heading-selector")||(r.value=null)};Gd(()=>{window.addEventListener("pointerdown",u)}),Jd(()=>{window.removeEventListener("pointerdown",u)});const h=rs(()=>yCe(n,e));function f(p,m){const g=r.value===p,y=l(m);return W("div",{key:p,class:"top-bar-heading-selector"},W("button",{type:"button",class:"top-bar-heading-button",onPointerdown:b=>c(p,b)},W("span",{class:"top-bar-heading-label"},y),m.chevronIcon&&W("span",{class:"top-bar-chevron"},W(ai,{icon:m.chevronIcon}))),g&&W("div",{class:"top-bar-heading-dropdown"},m.options.map((b,v)=>W("button",{key:`${p}-${v}`,type:"button",class:Ar("top-bar-heading-option",y===b.label&&"active"),onPointerdown:A=>{A.preventDefault(),A.stopPropagation(),r.value=null,b.onSelect(e)}},b.label))))}function d(p){return W("button",{key:p.key,type:"button",class:Ar("top-bar-item",a(p.active)&&"active"),onPointerdown:i(p.onRun)},W(ai,{icon:p.icon}))}return()=>{const p=s()?e.get(bt):null;return(p?!p.editable:!1)?null:W("div",{class:"top-bar-inner"},h.value.map(g=>g.items.map(y=>y.selector?f(y.key,y.selector):y.onRun?d(y):null)).reduce((g,y,b)=>{var v,A;if(b===0)g.push(...y);else{const k=(A=(v=h.value[b])==null?void 0:v.key)!=null?A:b;g.push(W("div",{key:`divider-${k}`,class:"top-bar-divider"}),...y)}return g},[]))}}});var CK=t=>{throw TypeError(t)},SK=(t,e,n)=>e.has(t)||CK("Cannot "+n),Up=(t,e,n)=>(SK(t,e,"read from private field"),n?n.call(t):e.get(t)),m5=(t,e,n)=>e.has(t)?CK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),g5=(t,e,n,r)=>(SK(t,e,"write to private field"),e.set(t,n),n),M0,Cv,_0;const vCe=new Vt("CREPE_TOP_BAR");class ACe{constructor(e,n,r){m5(this,M0),m5(this,Cv),m5(this,_0),this.update=(a,l)=>{Up(this,M0).style.display=a.editable?"":"none",Up(this,_0).value++},this.destroy=()=>{Up(this,Cv).unmount(),Up(this,M0).remove()},g5(this,_0,He(0));const i=document.createElement("div");i.className="milkdown-top-bar";const s=fs(bCe,{ctx:e,config:r,version:Up(this,_0)});s.mount(i),g5(this,M0,i),g5(this,Cv,s);const o=n.dom.parentElement;o&&o.insertBefore(i,o.firstChild),this.update(n)}}M0=new WeakMap;Cv=new WeakMap;_0=new WeakMap;const h6=St({view:()=>({update:()=>{},destroy:()=>{}})},"topBarConfig"),wCe=Qt(t=>{const e=t.get(h6.key);return new Bt({key:vCe,view:e.view})}),xCe=(t,e)=>{t.config(Ws(Et.TopBar)).config(n=>{n.set(h6.key,{view:r=>new ACe(n,r,e)})}).use(h6).use(wCe)};function kCe(t,e,n){switch(t){case Et.CodeMirror:return F3e(e,n);case Et.ListItem:return tCe(e,n);case Et.LinkTooltip:return X3e(e,n);case Et.ImageBlock:return H3e(e,n);case Et.Cursor:return z3e(e,n);case Et.BlockEdit:return L3e(e,n);case Et.Placeholder:return sCe(e,n);case Et.Toolbar:return dCe(e,n);case Et.Table:return oCe(e,n);case Et.Latex:return Q3e(e,n);case Et.TopBar:return xCe(e,n);case Et.AI:return T3e(e,n)}}var EK=t=>{throw TypeError(t)},TK=(t,e,n)=>e.has(t)||EK("Cannot "+n),Yi=(t,e,n)=>(TK(t,e,"read from private field"),n?n.call(t):e.get(t)),y5=(t,e,n)=>e.has(t)?EK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),b5=(t,e,n,r)=>(TK(t,e,"write to private field"),e.set(t,n),n),Qi,Sv,R0;class CCe{constructor({root:e,defaultValue:n=""}={}){y5(this,Qi),y5(this,Sv),y5(this,R0,!0),this.addFeature=(i,s)=>(i(Yi(this,Qi),s),this),this.create=()=>Yi(this,Qi).create(),this.destroy=()=>Yi(this,Qi).destroy(),this.setReadonly=i=>(b5(this,R0,!i),Yi(this,Qi).action(s=>{Yi(this,Qi).status===Wv.Created&&s.get(bt).setProps({editable:()=>!i})}),this),this.getMarkdown=()=>Yi(this,Qi).action(are()),this.on=i=>Yi(this,Qi).status!==Wv.Created?(Yi(this,Qi).config(s=>{const o=s.get(FA);i(o)}),this):(Yi(this,Qi).action(s=>{const o=s.get(FA);i(o)}),this);var r;b5(this,Sv,(r=typeof e=="string"?document.querySelector(e):e)!=null?r:document.body),b5(this,Qi,CF.make().config(i=>{i.inject(Uke,this),i.inject(jke,[])}).config(i=>{i.set(J0,Yi(this,Sv)),i.set(K0,n),i.set(G0,{editable:()=>Yi(this,R0)}),i.update(F2.key,s=>({...s,size:4})),i.update(ch.key,s=>({...s,uploader:async(o,a,l)=>{const u=rp(l).get().includes(Et.ImageBlock),h=u?a.nodes["image-block"]:a.nodes.image;if(!h)return[];const f=u?l.get(h1.key).onUpload:void 0,d=[];for(let m=0;m<o.length;m++){const g=o.item(m);g&&g.type.includes("image")&&d.push(g)}return await Promise.all(d.map(async m=>{const g=f?await f(m):URL.createObjectURL(m);return h.createAndFill({src:g})}))}}))}).use(ez).use(DU).use(hke).use(dke).use(mke).use(MU).use(bke).use(Nz))}get editor(){return Yi(this,Qi)}get readonly(){return!Yi(this,R0)}}Qi=new WeakMap;Sv=new WeakMap;R0=new WeakMap;class _o extends CCe{constructor({features:e={},featureConfigs:n={},...r}={}){super(r);const i=yue(n,$ke);Object.entries({...vke,...e}).filter(([,o])=>o).map(([o])=>o).forEach(o=>{const a=i[o];kCe(o,this.editor,a)})}}_o.Feature=Et;function Bd(t){try{const e=t.get(bt);if(e&&e.state)return e}catch{}try{const e=t.get("editorView");if(e&&e.state)return e}catch{}}function IK(t){try{const e=t.get(so);if(typeof e=="function")return e}catch{}try{const e=t.get("parser");if(typeof e=="function")return e}catch{}}const SCe='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="4" y="3" width="16" height="18" rx="2"/><path d="M8 8h8M8 12h8M8 16h5"/></svg>',N9=[{key:"highlight",label:"高亮",mark:"highlight",text:"重点内容",attrs:{},icon:'<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><path d="m14 3 7 7-9 9H5v-7z" fill="#fef08a" stroke="#d97706" stroke-width="2"/><path d="M3 21h12" stroke="#d97706" stroke-width="2" stroke-linecap="round"/><path d="m11 6 7 7" stroke="#d97706" stroke-width="2"/><title>高亮</title></svg>'},{key:"kbd",label:"快捷键",mark:"kbd",text:"Cmd",attrs:{},icon:'<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><rect x="3" y="5" width="18" height="14" rx="3" fill="#f1f5f9" stroke="#475569" stroke-width="1.8"/><path d="M7 9h2m2 0h2m2 0h2M7 13h2m2 0h2m2 0h2M8 16h8" stroke="#64748b" stroke-width="1.5" stroke-linecap="round"/><title>快捷键</title></svg>'},...[["brand","重点徽章","重点","#ca6093","#fce7f3"],["success","成功徽章","完成","#16a34a","#dcfce7"],["warning","提醒徽章","待确认","#ea580c","#ffedd5"],["danger","风险徽章","风险","#dc2626","#fee2e2"],["info","信息徽章","说明","#0284c7","#e0f2fe"]].map(([t,e,n,r,i])=>({key:`badge-${t}`,label:e,mark:"badge",text:n,attrs:{type:t},icon:`<svg viewBox="0 0 24 24" width="20" height="20" fill="none"><path d="M3 4h9l9 9-8 8-10-10z" fill="${i}" stroke="${r}" stroke-width="2"/><circle cx="8" cy="8" r="1.5" fill="${r}"/><title>${e}</title></svg>`}))],MK=["highlight","kbd","badge"];function P9(t,e,n=!1){const r=Bd(t);if(!r||!r.state)return;const{state:i}=r,{selection:s}=i;if(!(s instanceof qe)||!s.$from.sameParent(s.$to)||s.$from.parent.type.spec.code)return;const o=n?s.$from.start():s.from,a=s.to;if(i.doc.rangeHasMark(o,a,i.schema.marks.inlineCode))return;const l=i.schema.marks[e.mark];if(!l)return;const c=i.tr,u="type"in e.attrs?e.attrs.type:void 0;let h=!1;if(i.doc.nodesBetween(o,a,f=>{for(const d of f.marks)d.type===l&&(!u||d.attrs?.type===u)&&(h=!0)}),s.empty||n){const f=l.create(e.attrs);c.replaceWith(o,a,i.schema.text(e.text,[f])),c.setSelection(qe.create(c.doc,o+e.text.length))}else if(h)c.removeMark(o,a,l);else{if(e.mark==="badge"||e.mark==="kbd")c.removeMark(o,a);else if(e.mark==="highlight")for(const d of MK){const p=i.schema.marks[d];p&&c.removeMark(o,a,p)}const f=l.create(e.attrs);c.addMark(o,a,f)}c.setStoredMarks([]),r.dispatch(c.scrollIntoView()),r.focus()}function ECe(t){const e=Bd(t);if(!e||!e.state)return;const{state:n}=e,{from:r,to:i}=n.selection,s=n.tr;for(const o of MK){const a=n.schema.marks[o];a&&s.removeMark(r,i,a)}s.setStoredMarks([]),e.dispatch(s),e.focus()}const TCe=t=>{t.addGroup("article-inline","行内组件").addItem("article-inline",{icon:"",active:()=>!1,selector:{activeLabel:()=>"行内组件",options:[...N9.map(e=>({label:e.label,onSelect:n=>P9(n,e)})),{label:"清除行内组件",onSelect:ECe}]}})},ICe=t=>{const e=t.addGroup("article-inline","行内组件");for(const n of N9){const r="type"in n.attrs?n.attrs.type:void 0;e.addItem(n.key,{icon:n.icon,active:i=>{const s=Bd(i);if(!s||!s.state)return!1;const{state:o}=s,a=o.schema.marks[n.mark];if(!a)return!1;let l=!1;return o.doc.nodesBetween(o.selection.from,o.selection.to,c=>{for(const u of c.marks)u.type===a&&(r?u.attrs?.type===r&&(l=!0):l=!0)}),l},onRun:i=>P9(i,n)})}},MCe=t=>{const e=t.addGroup("article","文章组件"),n=[["intro","导读",`> [!INTRO] 导读
1920
1920
  > 请填写导读。`],["cta","文末互动",`> [!CTA] 交流与反馈
1921
1921
  > 请填写互动内容。`],["note","提示",`> [!NOTE]
1922
1922
  > 请填写提示内容。`],["tip","建议",`> [!TIP]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akairos/myno",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "WeChat article WYSIWYG editor & visual typography studio",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,6 +20,11 @@
20
20
  "types": "./dist/editor/index.d.ts",
21
21
  "default": "./dist/editor/index.js"
22
22
  },
23
+ "./menu": {
24
+ "import": "./dist/editor/article-menu.js",
25
+ "types": "./dist/editor/article-menu.d.ts",
26
+ "default": "./dist/editor/article-menu.js"
27
+ },
23
28
  "./style": "./dist/style.css"
24
29
  },
25
30
  "files": [