import{I as _,j as u,O as m,F as r,v as l}from"./parser-DaoUb5SB.js";import{P as I}from"./index-BT0jOPXg.js";import{c as P}from"./api-D2oYCc9G.js";import{o as w,J as x,K as v,L as h,N as F,O as A}from"./app-QjDgb7aF.js";import"./charts-3gEHPHRq.js";import"./vue-Cm77DuTi.js";import"./media-DuCIZ-3n.js";const C=new I,s=new Map;function K(n){console.info("Plugin installed:",n.name,`v${n.version}`);const i=new _(k({plugin:n,storageKey:`plugins:${n.id}`}),{in:e=>new Promise(t=>{w({title:e}).then(({canceled:o,result:g})=>{t(g)})}),out:e=>{console.log(e)},log:(e,t)=>{}});N({plugin:n,aiscript:i}),i.exec(C.parse(n.src))}function k(n){const i=new Map;for(const[e,t]of Object.entries(n.plugin.config??{}))i.set(e,u(typeof n.plugin.configData[e]<"u"?n.plugin.configData[e]:t.default));return{...P({...n,token:n.plugin.token}),"Mk:register_post_form_action":r(([e,t])=>{p({pluginId:n.plugin.id,title:e.value,handler:t})}),"Mk:register_user_action":r(([e,t])=>{f({pluginId:n.plugin.id,title:e.value,handler:t})}),"Mk:register_note_action":r(([e,t])=>{d({pluginId:n.plugin.id,title:e.value,handler:t})}),"Plugin:register_post_form_action":r(([e,t])=>{p({pluginId:n.plugin.id,title:e.value,handler:t})}),"Plugin:register_user_action":r(([e,t])=>{f({pluginId:n.plugin.id,title:e.value,handler:t})}),"Plugin:register_note_action":r(([e,t])=>{d({pluginId:n.plugin.id,title:e.value,handler:t})}),"Plugin:register_note_view_interruptor":r(([e])=>{V({pluginId:n.plugin.id,handler:e})}),"Plugin:register_note_post_interruptor":r(([e])=>{y({pluginId:n.plugin.id,handler:e})}),"Plugin:register_page_view_interruptor":r(([e])=>{M({pluginId:n.plugin.id,handler:e})}),"Plugin:open_url":r(([e])=>{window.open(e.value,"_blank")}),"Plugin:config":m(i)}}function N({plugin:n,aiscript:i}){s.set(n.id,i)}function p({pluginId:n,title:i,handler:e}){x.push({title:i,handler:(t,o)=>{const g=s.get(n);g&&g.execFn(e,[u(t),r(([a,c])=>{!a||!c||o(l(a),l(c))})])}})}function f({pluginId:n,title:i,handler:e}){v.push({title:i,handler:t=>{const o=s.get(n);o&&o.execFn(e,[u(t)])}})}function d({pluginId:n,title:i,handler:e}){h.push({title:i,handler:t=>{const o=s.get(n);o&&o.execFn(e,[u(user)])}})}function V({pluginId:n,handler:i}){F.push({handler:async e=>{const t=s.get(n);if(t)return l(await t.execFn(i,[u(e)]))}})}function y({pluginId:n,handler:i}){A.push({handler:async e=>{const t=s.get(n);if(t)return l(await t.execFn(i,[u(e)]))}})}function M({pluginId:n,handler:i}){pageViewInterruptors.push({handler:async e=>{const t=s.get(n);if(t)return l(await t.execFn(i,[u(e)]))}})}export{K as install};
//# sourceMappingURL=plugin-s80iBwlJ.js.map
