agent-remnote 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +19 -0
- package/dist/main.js +2097 -388
- package/package.json +4 -2
- package/plugin-artifacts/PluginZip.zip +0 -0
- package/plugin-artifacts/dist/README.md +50 -0
- package/plugin-artifacts/dist/blank-line-B2rM3oxN.js +1 -0
- package/plugin-artifacts/dist/index-4b5IDxii.js +3 -0
- package/plugin-artifacts/dist/index-BnR23rlw.js +12 -0
- package/plugin-artifacts/dist/index-BpbrUbge.js +20 -0
- package/plugin-artifacts/dist/index-CMP2i-HY.js +1 -0
- package/plugin-artifacts/dist/index-CTg2hlbS.js +58 -0
- package/plugin-artifacts/dist/index-Ch_qCilz.js +1 -0
- package/plugin-artifacts/dist/index-OYpYHp3Y.js +1 -0
- package/plugin-artifacts/dist/index-XfOTAlvl.js +5 -0
- package/plugin-artifacts/dist/index-dJjNfQvw.js +1 -0
- package/plugin-artifacts/dist/index-sandbox.css +1 -0
- package/plugin-artifacts/dist/index-sandbox.js +1 -0
- package/plugin-artifacts/dist/index.css +1 -0
- package/plugin-artifacts/dist/index.html +2 -0
- package/plugin-artifacts/dist/index.js +1 -0
- package/plugin-artifacts/dist/indexPlugin-DQCvhQLc.js +12 -0
- package/plugin-artifacts/dist/indexPlugin.css +1 -0
- package/plugin-artifacts/dist/jsx-runtime-D6ZSwAL5.js +8 -0
- package/plugin-artifacts/dist/manifest.json +29 -0
- package/plugin-artifacts/dist/sample_widget-sandbox.js +1 -0
- package/plugin-artifacts/dist/sample_widget.js +1 -0
- package/plugin-artifacts/dist/widget-bootstrap.js +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?t(n.position):"start"in n||"end"in n?t(n):"line"in n||"column"in n?i(n):""}function i(n){return r(n&&n.line)+":"+r(n&&n.column)}function t(n){return i(n&&n.start)+"-"+i(n&&n.end)}function r(n){return n&&typeof n=="number"?n:1}export{o as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as M}from"./index-CTg2hlbS.js";import{s as Y}from"./index-Ch_qCilz.js";function R(n){if(n)throw n}var b=Object.prototype.hasOwnProperty,H=Object.prototype.toString,C=Object.defineProperty,D=Object.getOwnPropertyDescriptor,F=function(e){return typeof Array.isArray=="function"?Array.isArray(e):H.call(e)==="[object Array]"},k=function(e){if(!e||H.call(e)!=="[object Object]")return!1;var t=b.call(e,"constructor"),s=e.constructor&&e.constructor.prototype&&b.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!s)return!1;var i;for(i in e);return typeof i>"u"||b.call(e,i)},V=function(e,t){C&&t.name==="__proto__"?C(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},N=function(e,t){if(t==="__proto__")if(b.call(e,t)){if(D)return D(e,t).value}else return;return e[t]},q=function n(){var e,t,s,i,r,o,f=arguments[0],l=1,c=arguments.length,a=!1;for(typeof f=="boolean"&&(a=f,f=arguments[1]||{},l=2),(f==null||typeof f!="object"&&typeof f!="function")&&(f={});l<c;++l)if(e=arguments[l],e!=null)for(t in e)s=N(f,t),i=N(e,t),f!==i&&(a&&i&&(k(i)||(r=F(i)))?(r?(r=!1,o=s&&F(s)?s:[]):o=s&&k(s)?s:{},V(f,{name:t,newValue:n(a,o,i)})):typeof i<"u"&&V(f,{name:t,newValue:i}));return f};const x=M(q);function _(n){if(typeof n!="object"||n===null)return!1;const e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function G(){const n=[],e={run:t,use:s};return e;function t(...i){let r=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);f(null,...i);function f(l,...c){const a=n[++r];let u=-1;if(l){o(l);return}for(;++u<i.length;)(c[u]===null||c[u]===void 0)&&(c[u]=i[u]);i=c,a?J(a,f)(...c):o(null,...c)}}function s(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function J(n,e){let t;return s;function s(...o){const f=n.length>o.length;let l;f&&o.push(i);try{l=n.apply(this,o)}catch(c){const a=c;if(f&&t)throw a;return i(a)}f||(l&&l.then&&typeof l.then=="function"?l.then(r,i):l instanceof Error?i(l):r(l))}function i(o,...f){t||(t=!0,e(o,...f))}function r(o){i(null,o)}}class h extends Error{constructor(e,t,s){super(),typeof t=="string"&&(s=t,t=void 0);let i="",r={},o=!1;if(t&&("line"in t&&"column"in t?r={place:t}:"start"in t&&"end"in t?r={place:t}:"type"in t?r={ancestors:[t],place:t.position}:r={...t}),typeof e=="string"?i=e:!r.cause&&e&&(o=!0,i=e.message,r.cause=e),!r.ruleId&&!r.source&&typeof s=="string"){const l=s.indexOf(":");l===-1?r.ruleId=s:(r.source=s.slice(0,l),r.ruleId=s.slice(l+1))}if(!r.place&&r.ancestors&&r.ancestors){const l=r.ancestors[r.ancestors.length-1];l&&(r.place=l.position)}const f=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=f?f.line:void 0,this.name=Y(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=o&&r.cause&&typeof r.cause.stack=="string"?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}h.prototype.file="";h.prototype.name="";h.prototype.reason="";h.prototype.message="";h.prototype.stack="";h.prototype.column=void 0;h.prototype.line=void 0;h.prototype.ancestors=void 0;h.prototype.cause=void 0;h.prototype.fatal=void 0;h.prototype.place=void 0;h.prototype.ruleId=void 0;h.prototype.source=void 0;const p={basename:K,dirname:Q,extname:W,join:X,sep:"/"};function K(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');g(n);let t=0,s=-1,i=n.length,r;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(r){t=i+1;break}}else s<0&&(r=!0,s=i+1);return s<0?"":n.slice(t,s)}if(e===n)return"";let o=-1,f=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(r){t=i+1;break}}else o<0&&(r=!0,o=i+1),f>-1&&(n.codePointAt(i)===e.codePointAt(f--)?f<0&&(s=i):(f=-1,s=o));return t===s?s=o:s<0&&(s=n.length),n.slice(t,s)}function Q(n){if(g(n),n.length===0)return".";let e=-1,t=n.length,s;for(;--t;)if(n.codePointAt(t)===47){if(s){e=t;break}}else s||(s=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function W(n){g(n);let e=n.length,t=-1,s=0,i=-1,r=0,o;for(;e--;){const f=n.codePointAt(e);if(f===47){if(o){s=e+1;break}continue}t<0&&(o=!0,t=e+1),f===46?i<0?i=e:r!==1&&(r=1):i>-1&&(r=-1)}return i<0||t<0||r===0||r===1&&i===t-1&&i===s+1?"":n.slice(i,t)}function X(...n){let e=-1,t;for(;++e<n.length;)g(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Z(t)}function Z(n){g(n);const e=n.codePointAt(0)===47;let t=O(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function O(n,e){let t="",s=0,i=-1,r=0,o=-1,f,l;for(;++o<=n.length;){if(o<n.length)f=n.codePointAt(o);else{if(f===47)break;f=47}if(f===47){if(!(i===o-1||r===1))if(i!==o-1&&r===2){if(t.length<2||s!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(l=t.lastIndexOf("/"),l!==t.length-1){l<0?(t="",s=0):(t=t.slice(0,l),s=t.length-1-t.lastIndexOf("/")),i=o,r=0;continue}}else if(t.length>0){t="",s=0,i=o,r=0;continue}}e&&(t=t.length>0?t+"/..":"..",s=2)}else t.length>0?t+="/"+n.slice(i+1,o):t=n.slice(i+1,o),s=o-i-1;i=o,r=0}else f===46&&r>-1?r++:r=-1}return t}function g(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const v={cwd:ee};function ee(){return"/"}function z(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function te(n){if(typeof n=="string")n=new URL(n);else if(!z(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return ne(n)}function ne(n){if(n.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const e=n.pathname;let t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){const s=e.codePointAt(t+2);if(s===70||s===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const E=["history","path","basename","stem","extname","dirname"];class ie{constructor(e){let t;e?z(e)?t={path:e}:typeof e=="string"||se(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":v.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<E.length;){const r=E[s];r in t&&t[r]!==void 0&&t[r]!==null&&(this[r]=r==="history"?[...t[r]]:t[r])}let i;for(i in t)E.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?p.basename(this.path):void 0}set basename(e){I(e,"basename"),A(e,"basename"),this.path=p.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?p.dirname(this.path):void 0}set dirname(e){U(this.basename,"dirname"),this.path=p.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?p.extname(this.path):void 0}set extname(e){if(A(e,"extname"),U(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=p.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){z(e)&&(e=te(e)),I(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?p.basename(this.path,this.extname):void 0}set stem(e){I(e,"stem"),A(e,"stem"),this.path=p.join(this.dirname||"",e+(this.extname||""))}fail(e,t,s){const i=this.message(e,t,s);throw i.fatal=!0,i}info(e,t,s){const i=this.message(e,t,s);return i.fatal=void 0,i}message(e,t,s){const i=new h(e,t,s);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function A(n,e){if(n&&n.includes(p.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+p.sep+"`")}function I(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function U(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function se(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const re=function(n){const s=this.constructor.prototype,i=s[n],r=function(){return i.apply(r,arguments)};return Object.setPrototypeOf(r,s),r},oe={}.hasOwnProperty;class L extends re{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=G()}copy(){const e=new L;let t=-1;for(;++t<this.attachers.length;){const s=this.attachers[t];e.use(...s)}return e.data(x(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(P("data",this.frozen),this.namespace[e]=t,this):oe.call(this.namespace,e)&&this.namespace[e]||void 0:e?(P("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const i=t.call(e,...s);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=w(e),s=this.parser||this.Parser;return S("parse",s),s(String(t),t)}process(e,t){const s=this;return this.freeze(),S("process",this.parser||this.Parser),T("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(r,o){const f=w(e),l=s.parse(f);s.run(l,f,function(a,u,d){if(a||!u||!d)return c(a);const y=u,m=s.stringify(y,d);ce(m)?d.value=m:d.result=m,c(a,d)});function c(a,u){a||!u?o(a):r?r(u):t(void 0,u)}}}processSync(e){let t=!1,s;return this.freeze(),S("processSync",this.parser||this.Parser),T("processSync",this.compiler||this.Compiler),this.process(e,i),$("processSync","process",t),s;function i(r,o){t=!0,R(r),s=o}}run(e,t,s){B(e),this.freeze();const i=this.transformers;return!s&&typeof t=="function"&&(s=t,t=void 0),s?r(void 0,s):new Promise(r);function r(o,f){const l=w(t);i.run(e,l,c);function c(a,u,d){const y=u||e;a?f(a):o?o(y):s(void 0,y,d)}}}runSync(e,t){let s=!1,i;return this.run(e,t,r),$("runSync","run",s),i;function r(o,f){R(o),i=f,s=!0}}stringify(e,t){this.freeze();const s=w(t),i=this.compiler||this.Compiler;return T("stringify",i),B(e),i(e,s)}use(e,...t){const s=this.attachers,i=this.namespace;if(P("use",this.frozen),e!=null)if(typeof e=="function")l(e,t);else if(typeof e=="object")Array.isArray(e)?f(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function r(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[a,...u]=c;l(a,u)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(c.plugins),c.settings&&(i.settings=x(!0,i.settings,c.settings))}function f(c){let a=-1;if(c!=null)if(Array.isArray(c))for(;++a<c.length;){const u=c[a];r(u)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,a){let u=-1,d=-1;for(;++u<s.length;)if(s[u][0]===c){d=u;break}if(d===-1)s.push([c,...a]);else if(a.length>0){let[y,...m]=a;const j=s[d][1];_(j)&&_(y)&&(y=x(!0,j,y)),s[d]=[c,y,...m]}}}}const he=new L().freeze();function S(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function T(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function P(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function B(n){if(!_(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function $(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function w(n){return fe(n)?n:new ie(n)}function fe(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function ce(n){return typeof n=="string"||le(n)}function le(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}export{he as unified};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n as O,b as bt,f as L,s as B,r as wt,c as xt}from"./blank-line-B2rM3oxN.js";import{u as E,k as G,b as $,a as P,j as A,d as yt,c as X,m as I,f as T}from"./index-dJjNfQvw.js";import{c as Ct,v as dt,h as it}from"./index-BnR23rlw.js";function Y(t,n){const e=String(t);if(typeof n!="string")throw new TypeError("Expected character");let r=0,o=e.indexOf(n);for(;o!==-1;)r++,o=e.indexOf(n,o+n.length);return r}function Dt(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function At(t,n,e){const o=Ct((e||{}).ignore||[]),a=Ft(n);let i=-1;for(;++i<a.length;)dt(t,"text",u);function u(c,m){let l=-1,g;for(;++l<m.length;){const k=m[l],h=g?g.children:void 0;if(o(k,h?h.indexOf(k):void 0,g))return;g=k}if(g)return s(c,m)}function s(c,m){const l=m[m.length-1],g=a[i][0],k=a[i][1];let h=0;const w=l.children.indexOf(c);let p=!1,x=[];g.lastIndex=0;let y=g.exec(c.value);for(;y;){const D=y.index,d={index:y.index,input:y.input,stack:[...m,c]};let C=k(...y,d);if(typeof C=="string"&&(C=C.length>0?{type:"text",value:C}:void 0),C===!1?g.lastIndex=D+1:(h!==D&&x.push({type:"text",value:c.value.slice(h,D)}),Array.isArray(C)?x.push(...C):C&&x.push(C),h=D+y[0].length,p=!0),!g.global)break;y=g.exec(c.value)}return p?(h<c.value.length&&x.push({type:"text",value:c.value.slice(h)}),l.children.splice(w,1,...x)):x=[c],w+x.length}}function Ft(t){const n=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const e=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<e.length;){const o=e[r];n.push([St(o[0]),Lt(o[1])])}return n}function St(t){return typeof t=="string"?new RegExp(Dt(t),"g"):t}function Lt(t){return typeof t=="function"?t:function(){return t}}const W="phrasing",H=["autolink","link","image","label"];function zt(){return{transforms:[Ot],enter:{literalAutolink:Mt,literalAutolinkEmail:V,literalAutolinkHttp:V,literalAutolinkWww:V},exit:{literalAutolink:Pt,literalAutolinkEmail:It,literalAutolinkHttp:Et,literalAutolinkWww:Rt}}}function Tt(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:W,notInConstruct:H},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:W,notInConstruct:H},{character:":",before:"[ps]",after:"\\/",inConstruct:W,notInConstruct:H}]}}function Mt(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function V(t){this.config.enter.autolinkProtocol.call(this,t)}function Et(t){this.config.exit.autolinkProtocol.call(this,t)}function Rt(t){this.config.exit.data.call(this,t);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(t)}function It(t){this.config.exit.autolinkEmail.call(this,t)}function Pt(t){this.exit(t)}function Ot(t){At(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jt],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,_t]],{ignore:["link","linkReference"]})}function jt(t,n,e,r,o){let a="";if(!rt(o)||(/^w/i.test(n)&&(e=n+e,n="",a="http://"),!vt(e)))return!1;const i=Bt(e+r);if(!i[0])return!1;const u={type:"link",title:null,url:a+n+i[0],children:[{type:"text",value:n+i[0]}]};return i[1]?[u,{type:"text",value:i[1]}]:u}function _t(t,n,e,r){return!rt(r,!0)||/[-\d_]$/.test(e)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+e,children:[{type:"text",value:n+"@"+e}]}}function vt(t){const n=t.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function Bt(t){const n=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!n)return[t,void 0];t=t.slice(0,n.index);let e=n[0],r=e.indexOf(")");const o=Y(t,"(");let a=Y(t,")");for(;r!==-1&&o>a;)t+=e.slice(0,r+1),e=e.slice(r+1),r=e.indexOf(")"),a++;return[t,e]}function rt(t,n){const e=t.input.charCodeAt(t.index-1);return(t.index===0||E(e)||G(e))&&(!n||e!==47)}lt.peek=Zt;function Wt(){this.buffer()}function Ht(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Vt(){this.buffer()}function qt(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Ut(t){const n=this.resume(),e=this.stack[this.stack.length-1];e.type,e.identifier=O(this.sliceSerialize(t)).toLowerCase(),e.label=n}function Gt(t){this.exit(t)}function $t(t){const n=this.resume(),e=this.stack[this.stack.length-1];e.type,e.identifier=O(this.sliceSerialize(t)).toLowerCase(),e.label=n}function Nt(t){this.exit(t)}function Zt(){return"["}function lt(t,n,e,r){const o=e.createTracker(r);let a=o.move("[^");const i=e.enter("footnoteReference"),u=e.enter("reference");return a+=o.move(e.safe(e.associationId(t),{after:"]",before:a})),u(),i(),a+=o.move("]"),a}function Qt(){return{enter:{gfmFootnoteCallString:Wt,gfmFootnoteCall:Ht,gfmFootnoteDefinitionLabelString:Vt,gfmFootnoteDefinition:qt},exit:{gfmFootnoteCallString:Ut,gfmFootnoteCall:Gt,gfmFootnoteDefinitionLabelString:$t,gfmFootnoteDefinition:Nt}}}function Jt(t){let n=!1;return t&&t.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:e,footnoteReference:lt},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function e(r,o,a,i){const u=a.createTracker(i);let s=u.move("[^");const c=a.enter("footnoteDefinition"),m=a.enter("label");return s+=u.move(a.safe(a.associationId(r),{before:s,after:"]"})),m(),s+=u.move("]:"),r.children&&r.children.length>0&&(u.shift(4),s+=u.move((n?`
|
|
2
|
+
`:" ")+a.indentLines(a.containerFlow(r,u.current()),n?at:Xt))),c(),s}}function Xt(t,n,e){return n===0?t:at(t,n,e)}function at(t,n,e){return(e?"":" ")+t}const Yt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ot.peek=ie;function Kt(){return{canContainEols:["delete"],enter:{strikethrough:ee},exit:{strikethrough:ne}}}function te(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Yt}],handlers:{delete:ot}}}function ee(t){this.enter({type:"delete",children:[]},t)}function ne(t){this.exit(t)}function ot(t,n,e,r){const o=e.createTracker(r),a=e.enter("strikethrough");let i=o.move("~~");return i+=e.containerPhrasing(t,{...o.current(),before:i,after:"~"}),i+=o.move("~~"),a(),i}function ie(){return"~"}function re(t){return t.length}function le(t,n){const e=n||{},r=(e.align||[]).concat(),o=e.stringLength||re,a=[],i=[],u=[],s=[];let c=0,m=-1;for(;++m<t.length;){const b=[],w=[];let p=-1;for(t[m].length>c&&(c=t[m].length);++p<t[m].length;){const x=ae(t[m][p]);if(e.alignDelimiters!==!1){const y=o(x);w[p]=y,(s[p]===void 0||y>s[p])&&(s[p]=y)}b.push(x)}i[m]=b,u[m]=w}let l=-1;if(typeof r=="object"&&"length"in r)for(;++l<c;)a[l]=K(r[l]);else{const b=K(r);for(;++l<c;)a[l]=b}l=-1;const g=[],k=[];for(;++l<c;){const b=a[l];let w="",p="";b===99?(w=":",p=":"):b===108?w=":":b===114&&(p=":");let x=e.alignDelimiters===!1?1:Math.max(1,s[l]-w.length-p.length);const y=w+"-".repeat(x)+p;e.alignDelimiters!==!1&&(x=w.length+x+p.length,x>s[l]&&(s[l]=x),k[l]=x),g[l]=y}i.splice(1,0,g),u.splice(1,0,k),m=-1;const h=[];for(;++m<i.length;){const b=i[m],w=u[m];l=-1;const p=[];for(;++l<c;){const x=b[l]||"";let y="",D="";if(e.alignDelimiters!==!1){const d=s[l]-(w[l]||0),C=a[l];C===114?y=" ".repeat(d):C===99?d%2?(y=" ".repeat(d/2+.5),D=" ".repeat(d/2-.5)):(y=" ".repeat(d/2),D=y):D=" ".repeat(d)}e.delimiterStart!==!1&&!l&&p.push("|"),e.padding!==!1&&!(e.alignDelimiters===!1&&x==="")&&(e.delimiterStart!==!1||l)&&p.push(" "),e.alignDelimiters!==!1&&p.push(y),p.push(x),e.alignDelimiters!==!1&&p.push(D),e.padding!==!1&&p.push(" "),(e.delimiterEnd!==!1||l!==c-1)&&p.push("|")}h.push(e.delimiterEnd===!1?p.join("").replace(/ +$/,""):p.join(""))}return h.join(`
|
|
3
|
+
`)}function ae(t){return t==null?"":String(t)}function K(t){const n=typeof t=="string"?t.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function oe(){return{enter:{table:ue,tableData:tt,tableHeader:tt,tableRow:fe},exit:{codeText:he,table:se,tableData:q,tableHeader:q,tableRow:q}}}function ue(t){const n=t._align;this.enter({type:"table",align:n.map(function(e){return e==="none"?null:e}),children:[]},t),this.data.inTable=!0}function se(t){this.exit(t),this.data.inTable=void 0}function fe(t){this.enter({type:"tableRow",children:[]},t)}function q(t){this.exit(t)}function tt(t){this.enter({type:"tableCell",children:[]},t)}function he(t){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,ce));const e=this.stack[this.stack.length-1];e.type,e.value=n,this.exit(t)}function ce(t,n){return n==="|"?n:t}function me(t){const n=t||{},e=n.tableCellPadding,r=n.tablePipeAlign,o=n.stringLength,a=e?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
4
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:i,tableCell:s,tableRow:u}};function i(k,h,b,w){return c(m(k,b,w),k.align)}function u(k,h,b,w){const p=l(k,b,w),x=c([p]);return x.slice(0,x.indexOf(`
|
|
5
|
+
`))}function s(k,h,b,w){const p=b.enter("tableCell"),x=b.enter("phrasing"),y=b.containerPhrasing(k,{...w,before:a,after:a});return x(),p(),y}function c(k,h){return le(k,{align:h,alignDelimiters:r,padding:e,stringLength:o})}function m(k,h,b){const w=k.children;let p=-1;const x=[],y=h.enter("table");for(;++p<w.length;)x[p]=l(w[p],h,b);return y(),x}function l(k,h,b){const w=k.children;let p=-1;const x=[],y=h.enter("tableRow");for(;++p<w.length;)x[p]=s(w[p],k,h,b);return y(),x}function g(k,h,b){let w=it.inlineCode(k,h,b);return b.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function ge(){return{exit:{taskListCheckValueChecked:et,taskListCheckValueUnchecked:et,paragraph:ke}}}function pe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:be}}}function et(t){const n=this.stack[this.stack.length-2];n.type,n.checked=t.type==="taskListCheckValueChecked"}function ke(t){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const e=this.stack[this.stack.length-1];e.type;const r=e.children[0];if(r&&r.type==="text"){const o=n.children;let a=-1,i;for(;++a<o.length;){const u=o[a];if(u.type==="paragraph"){i=u;break}}i===e&&(r.value=r.value.slice(1),r.value.length===0?e.children.shift():e.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,e.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function be(t,n,e,r){const o=t.children[0],a=typeof t.checked=="boolean"&&o&&o.type==="paragraph",i="["+(t.checked?"x":" ")+"] ",u=e.createTracker(r);a&&u.move(i);let s=it.listItem(t,n,e,{...r,...u.current()});return a&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),s;function c(m){return m+i}}function we(){return[zt(),Qt(),Kt(),oe(),ge()]}function xe(t){return{extensions:[Tt(),Jt(t),te(),me(t),pe()]}}const ye={tokenize:Se,partial:!0},ut={tokenize:Le,partial:!0},st={tokenize:ze,partial:!0},ft={tokenize:Te,partial:!0},Ce={tokenize:Me,partial:!0},ht={name:"wwwAutolink",tokenize:Ae,previous:mt},ct={name:"protocolAutolink",tokenize:Fe,previous:gt},S={name:"emailAutolink",tokenize:De,previous:pt},F={};function de(){return{text:F}}let z=48;for(;z<123;)F[z]=S,z++,z===58?z=65:z===91&&(z=97);F[43]=S;F[45]=S;F[46]=S;F[95]=S;F[72]=[S,ct];F[104]=[S,ct];F[87]=[S,ht];F[119]=[S,ht];function De(t,n,e){const r=this;let o,a;return i;function i(l){return!U(l)||!pt.call(r,r.previous)||N(r.events)?e(l):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(l))}function u(l){return U(l)?(t.consume(l),u):l===64?(t.consume(l),s):e(l)}function s(l){return l===46?t.check(Ce,m,c)(l):l===45||l===95||$(l)?(a=!0,t.consume(l),s):m(l)}function c(l){return t.consume(l),o=!0,s}function m(l){return a&&o&&P(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),n(l)):e(l)}}function Ae(t,n,e){const r=this;return o;function o(i){return i!==87&&i!==119||!mt.call(r,r.previous)||N(r.events)?e(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(ye,t.attempt(ut,t.attempt(st,a),e),e)(i))}function a(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),n(i)}}function Fe(t,n,e){const r=this;let o="",a=!1;return i;function i(l){return(l===72||l===104)&>.call(r,r.previous)&&!N(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(l),t.consume(l),u):e(l)}function u(l){if(P(l)&&o.length<5)return o+=String.fromCodePoint(l),t.consume(l),u;if(l===58){const g=o.toLowerCase();if(g==="http"||g==="https")return t.consume(l),s}return e(l)}function s(l){return l===47?(t.consume(l),a?c:(a=!0,s)):e(l)}function c(l){return l===null||yt(l)||A(l)||E(l)||G(l)?e(l):t.attempt(ut,t.attempt(st,m),e)(l)}function m(l){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),n(l)}}function Se(t,n,e){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,t.consume(i),o):i===46&&r===3?(t.consume(i),a):e(i)}function a(i){return i===null?e(i):n(i)}}function Le(t,n,e){let r,o,a;return i;function i(c){return c===46||c===95?t.check(ft,s,u)(c):c===null||A(c)||E(c)||c!==45&&G(c)?s(c):(a=!0,t.consume(c),i)}function u(c){return c===95?r=!0:(o=r,r=void 0),t.consume(c),i}function s(c){return o||r||!a?e(c):n(c)}}function ze(t,n){let e=0,r=0;return o;function o(i){return i===40?(e++,t.consume(i),o):i===41&&r<e?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(ft,n,a)(i):i===null||A(i)||E(i)?n(i):(t.consume(i),o)}function a(i){return i===41&&r++,t.consume(i),o}}function Te(t,n,e){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(t.consume(u),r):u===38?(t.consume(u),a):u===93?(t.consume(u),o):u===60||u===null||A(u)||E(u)?n(u):e(u)}function o(u){return u===null||u===40||u===91||A(u)||E(u)?n(u):r(u)}function a(u){return P(u)?i(u):e(u)}function i(u){return u===59?(t.consume(u),r):P(u)?(t.consume(u),i):e(u)}}function Me(t,n,e){return r;function r(a){return t.consume(a),o}function o(a){return $(a)?e(a):n(a)}}function mt(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||A(t)}function gt(t){return!P(t)}function pt(t){return!(t===47||U(t))}function U(t){return t===43||t===45||t===46||t===95||$(t)}function N(t){let n=t.length,e=!1;for(;n--;){const r=t[n][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){e=!0;break}if(r._gfmAutolinkLiteralWalkedInto){e=!1;break}}return t.length>0&&!e&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),e}const Ee={tokenize:Be,partial:!0};function Re(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:je,continuation:{tokenize:_e},exit:ve}},text:{91:{name:"gfmFootnoteCall",tokenize:Oe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ie,resolveTo:Pe}}}}function Ie(t,n,e){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const s=r.events[o][1];if(s.type==="labelImage"){i=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return u;function u(s){if(!i||!i._balanced)return e(s);const c=O(r.sliceSerialize({start:i.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?e(s):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(s),t.exit("gfmFootnoteCallLabelMarker"),n(s))}}function Pe(t,n){let e=t.length;for(;e--;)if(t[e][1].type==="labelImage"&&t[e][0]==="enter"){t[e][1];break}t[e+1][1].type="data",t[e+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[e+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[e+3][1].end),end:Object.assign({},t[e+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},t[t.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},u=[t[e+1],t[e+2],["enter",r,n],t[e+3],t[e+4],["enter",o,n],["exit",o,n],["enter",a,n],["enter",i,n],["exit",i,n],["exit",a,n],t[t.length-2],t[t.length-1],["exit",r,n]];return t.splice(e,t.length-e+1,...u),t}function Oe(t,n,e){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return u;function u(l){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),s}function s(l){return l!==94?e(l):(t.enter("gfmFootnoteCallMarker"),t.consume(l),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(l){if(a>999||l===93&&!i||l===null||l===91||A(l))return e(l);if(l===93){t.exit("chunkString");const g=t.exit("gfmFootnoteCallString");return o.includes(O(r.sliceSerialize(g)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),n):e(l)}return A(l)||(i=!0),a++,t.consume(l),l===92?m:c}function m(l){return l===91||l===92||l===93?(t.consume(l),a++,c):c(l)}}function je(t,n,e){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,i=0,u;return s;function s(h){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",m):e(h)}function m(h){if(i>999||h===93&&!u||h===null||h===91||A(h))return e(h);if(h===93){t.exit("chunkString");const b=t.exit("gfmFootnoteDefinitionLabelString");return a=O(r.sliceSerialize(b)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),g}return A(h)||(u=!0),i++,t.consume(h),h===92?l:m}function l(h){return h===91||h===92||h===93?(t.consume(h),i++,m):m(h)}function g(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),o.includes(a)||o.push(a),L(t,k,"gfmFootnoteDefinitionWhitespace")):e(h)}function k(h){return n(h)}}function _e(t,n,e){return t.check(bt,n,t.attempt(Ee,n,e))}function ve(t){t.exit("gfmFootnoteDefinition")}function Be(t,n,e){const r=this;return L(t,o,"gfmFootnoteDefinitionIndent",5);function o(a){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?n(a):e(a)}}function We(t){let e=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:o};return e==null&&(e=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,u){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let c=s;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[s][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[s][1].end)},l={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[s][1].start)},g=[["enter",m,u],["enter",i[c][1],u],["exit",i[c][1],u],["enter",l,u]],k=u.parser.constructs.insideSpan.null;k&&B(g,g.length,0,wt(k,i.slice(c+1,s),u)),B(g,g.length,0,[["exit",l,u],["enter",i[s][1],u],["exit",i[s][1],u],["exit",m,u]]),B(i,c-1,s-c+3,g),s=c+g.length-2;break}}for(s=-1;++s<i.length;)i[s][1].type==="strikethroughSequenceTemporary"&&(i[s][1].type="data");return i}function a(i,u,s){const c=this.previous,m=this.events;let l=0;return g;function g(h){return c===126&&m[m.length-1][1].type!=="characterEscape"?s(h):(i.enter("strikethroughSequenceTemporary"),k(h))}function k(h){const b=X(c);if(h===126)return l>1?s(h):(i.consume(h),l++,k);if(l<2&&!e)return s(h);const w=i.exit("strikethroughSequenceTemporary"),p=X(h);return w._open=!p||p===2&&!!b,w._close=!b||b===2&&!!p,u(h)}}}class He{constructor(){this.map=[]}add(n,e,r){Ve(this,n,e,r)}consume(n){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let e=this.map.length;const r=[];for(;e>0;)e-=1,r.push(n.slice(this.map[e][0]+this.map[e][1]),this.map[e][2]),n.length=this.map[e][0];r.push(n.slice()),n.length=0;let o=r.pop();for(;o;){for(const a of o)n.push(a);o=r.pop()}this.map.length=0}}function Ve(t,n,e,r){let o=0;if(!(e===0&&r.length===0)){for(;o<t.map.length;){if(t.map[o][0]===n){t.map[o][1]+=e,t.map[o][2].push(...r);return}o+=1}t.map.push([n,e,r])}}function qe(t,n){let e=!1;const r=[];for(;n<t.length;){const o=t[n];if(e){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(t[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[n-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(e=!0);n+=1}return r}function Ue(){return{flow:{null:{name:"table",tokenize:Ge,resolveAll:$e}}}}function Ge(t,n,e){const r=this;let o=0,a=0,i;return u;function u(f){let R=r.events.length-1;for(;R>-1;){const J=r.events[R][1].type;if(J==="lineEnding"||J==="linePrefix")R--;else break}const Z=R>-1?r.events[R][1].type:null,Q=Z==="tableHead"||Z==="tableRow"?C:s;return Q===C&&r.parser.lazy[r.now().line]?e(f):Q(f)}function s(f){return t.enter("tableHead"),t.enter("tableRow"),c(f)}function c(f){return f===124||(i=!0,a+=1),m(f)}function m(f){return f===null?e(f):I(f)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),k):e(f):T(f)?L(t,m,"whitespace")(f):(a+=1,i&&(i=!1,o+=1),f===124?(t.enter("tableCellDivider"),t.consume(f),t.exit("tableCellDivider"),i=!0,m):(t.enter("data"),l(f)))}function l(f){return f===null||f===124||A(f)?(t.exit("data"),m(f)):(t.consume(f),f===92?g:l)}function g(f){return f===92||f===124?(t.consume(f),l):l(f)}function k(f){return r.interrupt=!1,r.parser.lazy[r.now().line]?e(f):(t.enter("tableDelimiterRow"),i=!1,T(f)?L(t,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):h(f))}function h(f){return f===45||f===58?w(f):f===124?(i=!0,t.enter("tableCellDivider"),t.consume(f),t.exit("tableCellDivider"),b):d(f)}function b(f){return T(f)?L(t,w,"whitespace")(f):w(f)}function w(f){return f===58?(a+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(f),t.exit("tableDelimiterMarker"),p):f===45?(a+=1,p(f)):f===null||I(f)?D(f):d(f)}function p(f){return f===45?(t.enter("tableDelimiterFiller"),x(f)):d(f)}function x(f){return f===45?(t.consume(f),x):f===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(f),t.exit("tableDelimiterMarker"),y):(t.exit("tableDelimiterFiller"),y(f))}function y(f){return T(f)?L(t,D,"whitespace")(f):D(f)}function D(f){return f===124?h(f):f===null||I(f)?!i||o!==a?d(f):(t.exit("tableDelimiterRow"),t.exit("tableHead"),n(f)):d(f)}function d(f){return e(f)}function C(f){return t.enter("tableRow"),j(f)}function j(f){return f===124?(t.enter("tableCellDivider"),t.consume(f),t.exit("tableCellDivider"),j):f===null||I(f)?(t.exit("tableRow"),n(f)):T(f)?L(t,j,"whitespace")(f):(t.enter("data"),_(f))}function _(f){return f===null||f===124||A(f)?(t.exit("data"),j(f)):(t.consume(f),f===92?kt:_)}function kt(f){return f===92||f===124?(t.consume(f),_):_(f)}}function $e(t,n){let e=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],u=!1,s=0,c,m,l;const g=new He;for(;++e<t.length;){const k=t[e],h=k[1];k[0]==="enter"?h.type==="tableHead"?(u=!1,s!==0&&(nt(g,n,s,c,m),m=void 0,s=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},g.add(e,0,[["enter",c,n]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(r=!0,l=void 0,a=[0,0,0,0],i=[0,e+1,0,0],u&&(u=!1,m={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},g.add(e,0,[["enter",m,n]])),o=h.type==="tableDelimiterRow"?2:m?3:1):o&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],l=v(g,n,a,o,void 0,l),a=[0,0,0,0]),i[2]=e)):h.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],l=v(g,n,a,o,void 0,l)),a=i,i=[a[1],e,0,0])):h.type==="tableHead"?(u=!0,s=e):h.type==="tableRow"||h.type==="tableDelimiterRow"?(s=e,a[1]!==0?(i[0]=i[1],l=v(g,n,a,o,e,l)):i[1]!==0&&(l=v(g,n,i,o,e,l)),o=0):o&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(i[3]=e)}for(s!==0&&nt(g,n,s,c,m),g.consume(n.events),e=-1;++e<n.events.length;){const k=n.events[e];k[0]==="enter"&&k[1].type==="table"&&(k[1]._align=qe(n.events,e))}return t}function v(t,n,e,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";e[0]!==0&&(a.end=Object.assign({},M(n.events,e[0])),t.add(e[0],0,[["exit",a,n]]));const s=M(n.events,e[1]);if(a={type:i,start:Object.assign({},s),end:Object.assign({},s)},t.add(e[1],0,[["enter",a,n]]),e[2]!==0){const c=M(n.events,e[2]),m=M(n.events,e[3]),l={type:u,start:Object.assign({},c),end:Object.assign({},m)};if(t.add(e[2],0,[["enter",l,n]]),r!==2){const g=n.events[e[2]],k=n.events[e[3]];if(g[1].end=Object.assign({},k[1].end),g[1].type="chunkText",g[1].contentType="text",e[3]>e[2]+1){const h=e[2]+1,b=e[3]-e[2]-1;t.add(h,b,[])}}t.add(e[3]+1,0,[["exit",l,n]])}return o!==void 0&&(a.end=Object.assign({},M(n.events,o)),t.add(o,0,[["exit",a,n]]),a=void 0),a}function nt(t,n,e,r,o){const a=[],i=M(n.events,e);o&&(o.end=Object.assign({},i),a.push(["exit",o,n])),r.end=Object.assign({},i),a.push(["exit",r,n]),t.add(e+1,0,a)}function M(t,n){const e=t[n],r=e[0]==="enter"?"start":"end";return e[1][r]}const Ne={name:"tasklistCheck",tokenize:Qe};function Ze(){return{text:{91:Ne}}}function Qe(t,n,e){const r=this;return o;function o(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?e(s):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(s),t.exit("taskListCheckMarker"),a)}function a(s){return A(s)?(t.enter("taskListCheckValueUnchecked"),t.consume(s),t.exit("taskListCheckValueUnchecked"),i):s===88||s===120?(t.enter("taskListCheckValueChecked"),t.consume(s),t.exit("taskListCheckValueChecked"),i):e(s)}function i(s){return s===93?(t.enter("taskListCheckMarker"),t.consume(s),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),u):e(s)}function u(s){return I(s)?n(s):T(s)?t.check({tokenize:Je},n,e)(s):e(s)}}function Je(t,n,e){return L(t,r,"whitespace");function r(o){return o===null?e(o):n(o)}}function Xe(t){return xt([de(),Re(),We(t),Ue(),Ze()])}const Ye={};function nn(t){const n=this,e=t||Ye,r=n.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(Xe(e)),a.push(we()),i.push(xe(e))}export{nn as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={};function h(n,i){const t=e,o=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,s=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return c(n,o,s)}function c(n,i,t){if(u(n)){if("value"in n)return n.type==="html"&&!t?"":n.value;if(i&&"alt"in n&&n.alt)return n.alt;if("children"in n)return a(n.children,i,t)}return Array.isArray(n)?a(n,i,t):""}function a(n,i,t){const o=[];let s=-1;for(;++s<n.length;)o[s]=c(n[s],i,t);return o.join("")}function u(n){return!!(n&&typeof n=="object")}const g=r(/[A-Za-z]/),m=r(/[\dA-Za-z]/),A=r(/[#-'*+\--9=?A-Z^-~]/);function y(n){return n!==null&&(n<32||n===127)}const d=r(/\d/),k=r(/[\dA-Fa-f]/),x=r(/[!-/:-@[-`{-~]/);function C(n){return n!==null&&n<-2}function f(n){return n!==null&&(n<0||n===32)}function S(n){return n===-2||n===-1||n===32}const l=r(/\p{P}|\p{S}/u),p=r(/\s/);function r(n){return i;function i(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function b(n){if(n===null||f(n)||p(n))return 1;if(l(n))return 2}export{g as a,m as b,b as c,y as d,A as e,S as f,x as g,k as h,d as i,f as j,l as k,C as m,h as t,p as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.visible{visibility:visible}.m-2{margin:.5rem}.block{display:block}.inline{display:inline}.\!table{display:table!important}.table{display:table}.hidden{display:none}.rounded-lg{border-radius:.5rem}.p-2{padding:.5rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}html,:host-context(div){line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body,:host{margin:0;line-height:inherit}body,:host{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a}from"./index-CTg2hlbS.js";import{o,a as t}from"./indexPlugin-DQCvhQLc.js";a.declareIndexPlugin(o,t);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.visible{visibility:visible}.m-2{margin:.5rem}.block{display:block}.inline{display:inline}.\!table{display:table!important}.table{display:table}.hidden{display:none}.rounded-lg{border-radius:.5rem}.p-2{padding:.5rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}html,:host-context(div){line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body,:host{margin:0;line-height:inherit}body,:host{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./index-CTg2hlbS.js";import{o,a}from"./indexPlugin-DQCvhQLc.js";t.declareIndexPlugin(o,a);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-OYpYHp3Y.js","./index-CTg2hlbS.js","./index-Ch_qCilz.js","./index-4b5IDxii.js","./index-CMP2i-HY.js","./blank-line-B2rM3oxN.js","./index-dJjNfQvw.js","./index-XfOTAlvl.js","./index-BnR23rlw.js","./index-BpbrUbge.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var xt=Object.defineProperty;var Mt=(e,t,r)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Pe=(e,t,r)=>Mt(e,typeof t!="symbol"?t+"":t,r);import{d as S}from"./index-CTg2hlbS.js";const ie={name:"agent-remnote backup",code:"agent_remnote_backup",description:"Internal backup marker for replace-style write operations."},Pt={slots:[{code:"backup_kind",name:"Kind",propertyType:S.PropertyType.SINGLE_SELECT,enumValues:{children_replace:"Children Replace",selection_replace:"Selection Replace"},propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"cleanup_policy",name:"Cleanup Policy",propertyType:S.PropertyType.SINGLE_SELECT,enumValues:{auto:"Auto",visible:"Visible"},propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"cleanup_state",name:"Cleanup State",propertyType:S.PropertyType.SINGLE_SELECT,enumValues:{pending:"Pending",orphan:"Orphan",retained:"Retained",cleaned:"Cleaned"},propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"source_txn",name:"Source Txn",propertyType:S.PropertyType.TEXT,propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"source_op",name:"Source Op",propertyType:S.PropertyType.TEXT,propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"source_parent",name:"Source Parent",propertyType:S.PropertyType.TEXT,propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"source_anchor",name:"Source Anchor",propertyType:S.PropertyType.TEXT,propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0},{code:"created_at",name:"Created At",propertyType:S.PropertyType.TEXT,propertyLocation:S.PropertyLocation.ONLY_DOCUMENT,onlyProgrammaticModifying:!0}]};async function Ot(e){await e.app.registerPowerup({name:ie.name,code:ie.code,description:ie.description,options:Pt})}function st(e,t=8e3){return new Promise((r,o)=>{const n=new WebSocket(e);let i=!1;const s=()=>{try{n.onopen=null}catch{}try{n.onerror=null}catch{}try{n.onclose=null}catch{}clearTimeout(a)},c=d=>{i||(i=!0,s(),o(d))};n.onopen=()=>{i||(i=!0,s(),r(n))},n.onerror=()=>c(new Error("WebSocket connection failed")),n.onclose=()=>c(new Error("WebSocket closed"));const a=setTimeout(()=>c(new Error("WebSocket connection timeout")),t)})}function Lt(e,t=15e3){return new Promise((r,o)=>{const n=d=>{try{r(JSON.parse(String(d.data)))}catch{r(null)}c()},i=()=>{c(),o(new Error("WebSocket closed"))},s=()=>{c(),o(new Error("WebSocket error"))},c=()=>{e.removeEventListener("message",n),e.removeEventListener("close",i),e.removeEventListener("error",s),clearTimeout(a)};e.addEventListener("message",n),e.addEventListener("close",i),e.addEventListener("error",s);const a=setTimeout(()=>{c(),o(new Error("WebSocket timeout"))},t)})}function Nt(e,t=15e3){return new Promise((r,o)=>{const n=l=>{try{const f=JSON.parse(String(l.data));(f?.type==="OpDispatchBatch"||f?.type==="OpDispatch"||f?.type==="NoWork"||f?.type==="Error")&&(a(),r(f))}catch{}},i=()=>{a(),o(new Error("WebSocket closed"))},s=()=>{a(),o(new Error("WebSocket error"))},c=()=>{a(),o(new Error("WebSocket timeout"))},a=()=>{e.removeEventListener("message",n),e.removeEventListener("close",i),e.removeEventListener("error",s),clearTimeout(d)};e.addEventListener("message",n),e.addEventListener("close",i),e.addEventListener("error",s);const d=setTimeout(c,t)})}function re(e,t){e.send(JSON.stringify(t))}async function Dt(e){const t=await st(e);re(t,{type:"QueryStats"});const r=await Lt(t);if(t.close(),r?.type!=="Stats")throw new Error("Invalid Stats response");return r}const z={wsPort:"ws-port",autoConnectControl:"auto-connect-control",autoSyncOnConnect:"auto-sync-on-connect",syncConcurrency:"sync-concurrency"},dt=6789;function Ft(e){if(typeof e!="number"||!Number.isFinite(e))return null;const t=Math.trunc(e);return t<1||t>65535?null:t}function $t(e){return`ws://localhost:${e}/ws`}async function ge(e){let t=null;try{t=await e.settings.getSetting(z.wsPort)}catch{}const r=Ft(t)??dt;return $t(r)}const tt="agent-remnote.client-instance-id";function Wt(){try{const r=globalThis.crypto;if(r&&typeof r.randomUUID=="function")return r.randomUUID()}catch{}const e=Math.random().toString(36).slice(2,12);return`client-${Date.now().toString(36)}-${e}`}async function qe(e){try{const r=await e.storage.getLocal(tt);if(typeof r=="string"&&r.trim())return r.trim()}catch{}const t=Wt();try{await e.storage.setLocal(tt,t)}catch{}return t}async function Bt(e){try{await e.settings.registerNumberSetting({id:z.wsPort,title:"WebSocket Port",defaultValue:dt})}catch{}try{await e.settings.registerBooleanSetting({id:z.autoConnectControl,title:"Auto-connect control channel",defaultValue:!0})}catch{}try{await e.settings.registerBooleanSetting({id:z.autoSyncOnConnect,title:"Auto-sync on connect",defaultValue:!0})}catch{}try{await e.settings.registerNumberSetting({id:z.syncConcurrency,title:"Sync concurrency",defaultValue:4})}catch{}}function lt(e){const t=String(e||""),r={"rem.create":"create_rem","rem.createPortal":"create_portal","rem.createSingleWithMarkdown":"create_single_rem_with_markdown","rem.createTreeWithMarkdown":"create_tree_with_markdown","rem.replaceChildrenWithMarkdown":"replace_children_with_markdown","rem.createLink":"create_link_rem","rem.updateText":"update_text","rem.move":"move_rem","rem.delete":"delete_rem","backup.deleteArtifact":"delete_backup_artifact","portal.create":"create_portal","tag.add":"add_tag","tag.remove":"remove_tag","attribute.set":"set_attribute","table.create":"create_table","property.add":"add_property","property.setType":"set_property_type","table.setFilter":"set_table_filter","option.add":"add_option","option.remove":"remove_option","table.addRow":"table_add_row","table.removeRow":"table_remove_row","cell.setSelect":"set_cell_select","cell.setCheckbox":"set_cell_checkbox","cell.setNumber":"set_cell_number","cell.setDate":"set_cell_date","table.cellWrite":"table_cell_write","source.add":"add_source","source.remove":"remove_source","todo.setStatus":"set_todo_status"};return r[t]?r[t]:t}const Ut="modulepreload",qt=function(e,t){return new URL(e,t).href},rt={},ye=function(t,r,o){let n=Promise.resolve();if(r&&r.length>0){const s=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),a=c?.nonce||c?.getAttribute("nonce");n=Promise.allSettled(r.map(d=>{if(d=qt(d,o),d in rt)return;rt[d]=!0;const l=d.endsWith(".css"),f=l?'[rel="stylesheet"]':"";if(!!o)for(let m=s.length-1;m>=0;m--){const w=s[m];if(w.href===d&&(!l||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${f}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":Ut,l||(u.as="script"),u.crossOrigin="",u.href=d,a&&u.setAttribute("nonce",a),document.head.appendChild(u),l)return new Promise((m,w)=>{u.addEventListener("load",m),u.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return n.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function K(e){return new Promise(t=>setTimeout(t,e))}async function fe(e,t,r,o=0){const n=typeof r=="string"?r.trim():"";if(!n)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");try{typeof t.setParent=="function"?await t.setParent(n):await e.rem.moveRems([t._id],n,o)}catch(i){try{await t.remove()}catch{}throw i}}function Vt(e){const t=[],r=/\(\(([^\s()|]+)(?:\|[^()]+)?\)\)|\{ref:([A-Za-z0-9]+)\}/g;let o=0;for(const i of e.matchAll(r)){const s=e.slice(o,i.index??0);s&&t.push({i:"m",text:s});const c=(i[1]??i[2]??"").trim();c&&t.push({i:"q",_id:c}),o=(i.index??0)+i[0].length}const n=e.slice(o);return n&&t.push({i:"m",text:n}),t.length>0?t:[{i:"m",text:e}]}function q(e){return e==null?[]:Array.isArray(e)?e:typeof e=="string"?Vt(e):typeof e=="object"?[e]:[{i:"m",text:String(e)}]}async function zt(e){const{unified:t}=await ye(async()=>{const{unified:f}=await import("./index-OYpYHp3Y.js");return{unified:f}},__vite__mapDeps([0,1,2]),import.meta.url),{default:r}=await ye(async()=>{const{default:f}=await import("./index-4b5IDxii.js");return{default:f}},__vite__mapDeps([3,4,5,6,2]),import.meta.url),{default:o}=await ye(async()=>{const{default:f}=await import("./index-XfOTAlvl.js");return{default:f}},__vite__mapDeps([7,5,6,8]),import.meta.url),{default:n}=await ye(async()=>{const{default:f}=await import("./index-BpbrUbge.js");return{default:f}},__vite__mapDeps([9,8,6,4]),import.meta.url),s=t().use(r).use(o).parse(e);s.children=Yt(s.children);const c=[],a=[];let d=[];for(const f of s.children)if(f.type==="heading"){if(a.length>0&&c.length>0){const u=t().use(n).stringify({type:"root",children:a});c[c.length-1].body=Oe(u),a.length=0}const y=t().use(n).stringify({type:"root",children:[f]});c.push({heading:y.trim(),body:""})}else c.length===0?d.push(f):a.push(f);if(a.length>0&&c.length>0){const f=t().use(n).stringify({type:"root",children:a});c[c.length-1].body=Oe(f)}return{preface:d.length>0?Oe(t().use(n).stringify({type:"root",children:d})):void 0,items:c}}function Yt(e){const t=[];for(const r of e)if(r.type==="list"&&Array.isArray(r.children))for(const o of r.children){if(!o||!Array.isArray(o.children)||o.children.length===0)continue;const n=o.children[0];if(n&&n.type==="heading"){t.push(n);const i=o.children.slice(1);i.length>0&&t.push(...i)}else t.push(o)}else t.push(r);return t}function Oe(e){return e=Xe(e),e=mt(e),e=yt(e),e=He(e),e}const Gt=/^[A-Za-z0-9]{17}$/,jt=/\(\(([^\s()|]+)(?:\|[^()]+)?\)\)|\{ref:([A-Za-z0-9]+)\}/g;function ut(e){const t=e.includes("((")&&e.includes("))"),r=e.includes("{ref:")&&e.includes("}");if(!t&&!r)return{markdown:e,refs:[]};const o=[];return{markdown:e.replace(jt,(i,s,c)=>{const a=typeof s=="string"&&s.trim()?s:c,d=typeof a=="string"?a.trim():"";if(!Gt.test(d))return i;const l=`AGENT_REMNOTE_REF_PLACEHOLDER_${o.length}`;return o.push({placeholder:l,remId:d,original:i}),l}),refs:o}}async function ft(e,t){const r=new Map;for(const o of t)if(!r.has(o.remId))try{r.set(o.remId,!!await e.rem.findOne(o.remId))}catch{r.set(o.remId,!1)}return r}function he(e,t,r,o){if(!Array.isArray(e)||t.length===0)return{richText:e,changed:!1};const n=(a,d)=>{let l=0,f=!1;const y=[],u=w=>{w&&(d&&typeof d=="object"?y.push({...d,text:w}):y.push(w))};for(;l<a.length;){let w=-1,A;for(const C of t){const k=a.indexOf(C.placeholder,l);k>=0&&(w<0||k<w)&&(w=k,A=C)}if(w<0||!A)break;const b=a.slice(l,w);u(b),o==="resolve"&&r.get(A.remId)===!0?y.push({i:"q",_id:A.remId}):u(A.original),l=w+A.placeholder.length,f=!0}const m=a.slice(l);return u(m),f?y.length===0?{items:d?[d]:[a],changed:!1}:{items:y,changed:!0}:{items:d?[d]:[a],changed:!1}},i=a=>{if(typeof a=="string")return n(a);if(a&&typeof a=="object"){if(a.i==="m"&&typeof a.text=="string")return n(a.text,a);const d=a.children;if(Array.isArray(d)){const l=he(d,t,r,o);return l.changed?{items:[{...a,children:l.richText}],changed:!0}:{items:[a],changed:!1}}}return{items:[a],changed:!1}};let s=!1;const c=[];for(const a of e){const d=i(a);d.changed&&(s=!0),c.push(...d.items)}return s?{richText:c,changed:!0}:{richText:e,changed:!1}}function Kt(e){if(!Array.isArray(e)||e.length===0||!e.every(r=>typeof r=="string"))return!1;const t=e.join("");return t.trim()?!!(/\[[^\]]+\]\([^)]+\)/.test(t)||t.includes("**")||t.includes("`")||t.includes("~~")):!1}async function Y(e,t,r){const o=ht(t),{markdown:n,refs:i}=ut(o),s=await e.rem.createSingleRemWithMarkdown(n,r);if(!s)return;if(i.length===0)return s;const c=await ft(e,i),a=he(s.text,i,c,"resolve");if(!a.changed)return s;try{await s.setText(a.richText)}catch{const d=he(s.text,i,c,"plain");try{await s.setText(d.richText)}catch{}}return s}async function j(e,t,r){const o=ht(t),{markdown:n,refs:i}=ut(o),s=await e.rem.createTreeWithMarkdown(n,r);if(!Array.isArray(s)||s.length===0)return s;const c=i.length>0?await ft(e,i):null;for(const a of s){if(!a)continue;const d=a.text;let l=d,f=!1;if(Kt(d))try{l=await e.richText.parseFromMarkdown(d.join("")),f=!0}catch{}let y=f,u=l;if(c){const m=he(l,i,c,"resolve");m.changed&&(u=m.richText,y=!0)}if(y)try{await a.setText(u)}catch{if(!c)continue;const m=he(l,i,c,"plain");if(!m.changed&&!f)continue;try{await a.setText(m.richText)}catch{}}}return s}async function Xt(e,t,r,o=2){const n=[],i=[{level:-1,id:r??null}],s=t.replace(/\r\n?/g,`
|
|
3
|
+
`).replace(/\t/g," ").split(`
|
|
4
|
+
`),c=s.some(b=>(b.match(/^\s*/)?.[0]??"").length>=o),a=s.some(b=>/^(?:\s*[-*+]\s+)?\s*#{1,6}\s+/.test(b));let d=0;const l=async(b,h)=>{const C=typeof h=="string"?h.trim():"";if(!C)return null;const k=await e.rem.createRem();if(!k)return null;await fe(e,k,C,999999);try{await k.setText(q(b))}catch{}return k},f=async(b,h)=>{const C=typeof h=="string"?h.trim():"";if(!C)return null;const k=await e.rem.createRem();if(!k)return null;await fe(e,k,C,999999);try{await k.setText(q(b))}catch{}return k},y=b=>{const h=b.match(/^\[([ xX])\]\s+(.*)$/);if(!h)return null;const C=(h[1]??" ").toLowerCase(),k=String(h[2]??"").trim();return k?{status:C==="x"?"Finished":"Unfinished",body:k}:null},u=async(b,h,C)=>{const k={i:"m",code:!0,text:b},T=h.trim();T&&(k.language=T);const E=await f([k],C);if(E)try{typeof E.setIsCode=="function"&&await E.setIsCode(!0)}catch{}return E},m=async(b,h,C)=>{const k=typeof C=="string"?C.trim():"";if(!k)return null;try{const T=await Y(e,b,k);if(T)return T}catch{}return await l(h,k)},w=async()=>{const b=i.slice();for(;d<s.length;){let h=s[d];if(!h||/^\s*$/.test(h)){d+=1;continue}const C=h.match(/^(\s*)```(.*)$/);if(C){const p=(C[1]??"").length,g=Math.max(0,Math.floor(p/Math.max(1,o))),R=[],I=String(C[2]??"").trimEnd();for(d+=1;d<s.length;){const B=s[d];if(/^\s*```\s*$/.test(B)){d+=1;break}R.push(B),d+=1}const F=R.join(`
|
|
5
|
+
`),_=Le(b,g),P=await u(F,I,_);P&&(n.push(P),nt(b,g,P._id));continue}const k=(h.match(/^\s*/)?.[0]??"").length;let T=Math.max(0,Math.floor(k/Math.max(1,o))),E=h.slice(k),M=E,x=null;const L=E.match(/^([*+-])\s+(.*)$/);if(L){E=L[2];const O=y(E);O?(x=O.status,E=O.body,M=O.body):M=E;const p=b[b.length-1];T===0&&p&&p.level>=0&&p.id&&(T=p.level+1)}else{const O=E.match(/^(\d+\.)\s+(.*)$/);if(O){E=O[2],M=E;const p=b[b.length-1];T===0&&p&&p.level>=0&&p.id&&(T=p.level+1)}}const D=Le(b,T),v=await m(M,E,D);if(v){if(x){try{typeof v.setIsTodo=="function"&&await v.setIsTodo(!0)}catch{}try{typeof v.setTodoStatus=="function"&&await v.setTodoStatus(x)}catch{}}n.push(v),nt(b,T,v._id)}d+=1,n.length%20===0&&await K(15)}},A=async()=>{const b=Le(i,0);let h=null,C=[];const k=async()=>{const M=C.join(`
|
|
6
|
+
`);C=[];let x=M.replace(/\r\n?/g,`
|
|
7
|
+
`);if(x=x.replace(/^\s*\n+/g,"").replace(/\n+\s*$/g,""),!x.trim())return;x=Xe(x),x=mt(x),x=yt(x),x=He(x);const L=h??b;if(L){try{await j(e,x,L)}catch{}await K(10)}},T=async M=>{await k();const x=b??"";if(!x)return;const L=await Y(e,M.trim(),x);L&&(n.push(L),h=L._id)};let E=!1;for(;d<s.length;){const x=s[d]??"";if(d+=1,x.trim().length===0){C.push(x);continue}if(/^\s*```/.test(x)){E=!E,C.push(x);continue}if(E){C.push(x);continue}const L=x.match(/^\s*(?:[-*+]\s+)?(#{1,6})\s+(.*)$/);if(L){await k();const D=L[1],v=L[2];await T(`${D} ${v}`);continue}C.push(x)}await k()};if(a)await A();else if(c)await w();else for(;d<s.length;){const b=s[d];if(d+=1,!b||/^\s*$/.test(b))continue;let h=b.trimEnd();const C=h.match(/^([*+-])\s+(.*)$/);let k=h;if(C){h=C[2];const E=y(h);if(E){k=E.body,h=E.body;const M=await m(k.replace(/^\s+/,""),h.replace(/^\s+/,""),r??null);if(M){try{typeof M.setIsTodo=="function"&&await M.setIsTodo(!0)}catch{}try{typeof M.setTodoStatus=="function"&&await M.setTodoStatus(E.status)}catch{}n.push(M)}n.length%20===0&&await K(15);continue}k=h}else{const E=h.match(/^(\d+\.)\s+(.*)$/);E&&(h=E[2],k=h)}const T=await m(k.replace(/^\s+/,""),h.replace(/^\s+/,""),r??null);T&&n.push(T),n.length%20===0&&await K(15)}return n}function Le(e,t){for(;e.length>0&&e[e.length-1].level>=t;)e.pop();return e.length>0?e[e.length-1].id:null}function nt(e,t,r){e.push({level:t,id:r})}function mt(e){const t=e.split(`
|
|
8
|
+
`);let r=!1;for(let o=0;o<t.length;o+=1){const n=t[o];if(/^\s*```/.test(n)){r=!r;continue}if(!r){if(/^\s{1,3}[-*+]\s+/.test(n)){t[o]=n.replace(/^\s{1,3}([-*+])\s+/,"$1 ");continue}if(/^\s{1,3}\d+\.\s+/.test(n)){t[o]=n.replace(/^\s{1,3}(\d+\.)\s+/,"$1 ");continue}}}return t.join(`
|
|
9
|
+
`)}function yt(e){const t=e.split(`
|
|
10
|
+
`),r=[];let o=!1;for(let n=0;n<t.length;n+=1){const i=t[n];if(/^\s*```/.test(i)){o=!o,r.push(i);continue}if(o)r.push(i);else{if(i.trim().length===0)continue;r.push(i)}}return r.join(`
|
|
11
|
+
`)}function Xe(e){return e.replace(/[\u00A0\u2007\u202F\u2002-\u2006\u2008-\u200A\u3000]/g," ").replace(/[\u200B\u200C\u200D\u2060]/g,"")}function He(e){const t=e.split(`
|
|
12
|
+
`).filter(n=>n.trim().length>0);if(t.length!==1)return e;const r=t[0].match(/^\s*[-*+]\s+(.*)$/),o=t[0].match(/^\s*\d+\.\s+(.*)$/);return r?r[1]:o?o[1]:e}function ht(e){return He(Xe(e))}function Ve(e){return typeof e=="string"?e.trim():""}function Ht(e){return Ve(e.title)||"Imported (bundle)"}function Qt(e){const t=e?.bundle;if(!t||typeof t!="object")return null;const r=t.enabled===!0,o=Ve(t.title)||Ve(e?.bundle_title);return!r&&!o?null:{title:o||"Imported (bundle)"}}async function Jt(e,t){const{text:r,markdown:o,date:n,offset_days:i,prepend:s,position:c}=t.payload||{};let a=null;if(typeof n=="string"||typeof n=="number"){const u=new Date(n);isNaN(u.getTime())||(a=u)}if(!a){const u=typeof i=="number"?i:0,m=new Date;a=new Date(m.getFullYear(),m.getMonth(),m.getDate()+u)}const d=await e.date.getDailyDoc(a);if(!d?._id)throw new Error("Daily document not found for that date. Please open it in RemNote first.");const l=typeof c=="number"&&Number.isFinite(c)&&c>=0?Math.floor(c):void 0,f=Qt(t.payload||{});if(f){const u=[];let m=null;try{const w=Ht(f);try{if(m=await Y(e,w,d._id),!m?._id)throw new Error("createSingleRemWithMarkdown returned null for bundle title")}catch{if(m=await e.rem.createRem(),!m?._id)throw new Error("createRem failed for bundle title");await m.setText(q(w))}const A=l!==void 0?l:typeof s=="boolean"&&s?0:999999;try{await e.rem.moveRems([m._id],d._id,A)}catch(b){try{await m.remove()}catch{}throw b}if(typeof o=="string"&&o.trim())try{const b=await j(e,o,m._id);if(Array.isArray(b))for(const h of b)h?._id&&u.push(h._id)}catch{const b=await Y(e,o,m._id);b?._id&&u.push(b._id)}else if(r!=null){const b=await e.rem.createRem();if(!b)throw new Error("createRem failed");try{await b.setText(q(r))}catch(h){try{await b.remove()}catch{}throw h}try{await e.rem.moveRems([b._id],m._id,999999)}catch(h){try{await b.remove()}catch{}throw h}b?._id&&u.push(b._id)}else throw new Error("Missing content (text/markdown)");return{ok:!0,daily_id:d._id,created_ids:[m._id],bundle:{rem_id:m._id},bundle_inner_created_ids:u.length?u:void 0}}catch(w){if(m?._id)try{await m.remove()}catch{}throw w}}const y=[];if(typeof o=="string"&&o.trim())try{const u=await j(e,o,d._id);if(Array.isArray(u))for(const m of u)m?._id&&y.push(m._id)}catch{const u=await Y(e,o,d._id);u?._id&&y.push(u._id)}else if(r!=null){const u=await e.rem.createRem();if(!u)throw new Error("createRem failed");try{await u.setText(q(r))}catch(m){try{await u.remove()}catch{}throw m}try{await e.rem.moveRems([u._id],d._id,typeof s=="boolean"&&s?0:999999)}catch(m){try{await u.remove()}catch{}throw m}u?._id&&y.push(u._id)}else throw new Error("Missing content (text/markdown)");return{ok:!0,daily_id:d._id,created_ids:y}}function ze(e){return typeof e=="string"?e.trim():""}function pe(e){return typeof e=="string"?e.trim():""}function te(e){const t=e?.parent;if(typeof t=="string")return t.trim();const r=t?._id;return typeof r=="string"?r.trim():""}function pt(e){const t=e?.text;return typeof t=="string"?pe(t):Array.isArray(t)&&t.every(r=>typeof r=="string")?pe(t.join("")):""}const Zt=["agent-remnote: children replace backup (auto)","agent-remnote: replace backup (auto)"],ot=50;async function er(e){if(!e)return!1;try{if(typeof e.hasPowerup=="function"&&await e.hasPowerup(ie.code)===!0)return!0}catch{}const t=pt(e);return Zt.some(r=>t===r||t.startsWith(r))}async function tr(e,t){const r=[],o=[];for(const n of t)try{const i=await e.rem.findOne(n);await er(i)?o.push(n):r.push(n)}catch{r.push(n)}return{contentChildIds:r,backupChildIds:o}}async function rr(e,t,r){const o=[...t];let n=0;for(;o.length>0;){const i=o.shift();if(i){if(n+=1,n>r)return n;try{const s=await e.rem.findOne(i),c=be(s);for(const a of c)o.push(a)}catch{}}}return n}async function nr(e){try{if(typeof e.rem?.setHiddenExplicitlyIncludedState=="function")return await e.rem.setHiddenExplicitlyIncludedState("hidden",e.portalId),!0}catch{}return!1}async function _t(e){const t=e.rem;if(!t)return;try{typeof t.addPowerup=="function"&&await t.addPowerup(ie.code)}catch{}const r=async(n,i)=>{try{typeof t.setPowerupProperty=="function"&&await t.setPowerupProperty(ie.code,n,[i])}catch{}},o=new Date().toISOString();await r("backup_kind",e.backupKind),await r("cleanup_policy",e.cleanupPolicy),await r("cleanup_state",e.cleanupState),await r("source_txn",e.op.txn_id),await r("source_op",e.op.op_id),await r("source_parent",e.sourceParentId),await r("source_anchor",e.sourceAnchorId),await r("created_at",o)}function be(e){return Array.isArray(e?.children)?e.children.filter(t=>typeof t=="string"&&t.trim()).map(t=>t.trim()):[]}async function Ie(e,t,r,o,n){const i=[];if(Array.isArray(t))for(let c=0;c<t.length;c+=1){const a=t[c],d=ze(a?._id);d&&te(a)===o&&i.push({id:d,rem:a,index:c})}if(i.length===0)for(let c=0;c<r.length;c+=1){const a=ze(r[c]);if(a)try{const d=await e.rem.findOne(a);if(!d)continue;te(d)===o&&i.push({id:a,rem:d,index:c})}catch{}}if(i.length===0)return[];const s=[];for(const c of i){let a;try{typeof c.rem?.positionAmongstVisibleSiblings=="function"&&(a=await c.rem.positionAmongstVisibleSiblings(n))}catch{}if(a===void 0)try{typeof c.rem?.positionAmongstSiblings=="function"&&(a=await c.rem.positionAmongstSiblings(n))}catch{}typeof a=="number"&&Number.isFinite(a)&&a>=0&&s.push({id:c.id,pos:Math.floor(a),index:c.index})}if(s.length!==i.length){const c=new Set,a=[];for(const d of i)c.has(d.id)||(c.add(d.id),a.push(d.id));return a}return s.sort((c,a)=>c.pos!==a.pos?c.pos-a.pos:c.index-a.index),s.map(c=>c.id)}function or(e){return pe(e.title)||"Imported (bundle)"}function ar(e){const t=e?.bundle;if(!t||typeof t!="object")return null;const r=t.enabled===!0,o=pe(t.title)||pe(e?.bundle_title);return!r&&!o?null:{title:o||"Imported (bundle)"}}function ir(e){if(!e||typeof e!="object")return!1;if(e.staged===!0)return!0;const t=e.staging;return!!(t===!0||t&&typeof t=="object"&&t.enabled===!0)}async function cr(e,t){const{markdown:r,parent_id:o,client_temp_id:n}=t.payload||{},i=typeof o=="string"?o.trim():"";if(!i)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");const s=await Y(e,String(r??""),i);if(!s)throw new Error("createSingleRemWithMarkdown returned null");const c={ok:!0};return n&&s._id&&(c.created={client_temp_id:n,remote_id:s._id,remote_type:"rem"}),c}async function wt(e,t){const{markdown:r,parent_id:o,client_temp_ids:n,indent_mode:i,parse_mode:s,indent_size:c,prepared:a,position:d}=t.payload||{},l=typeof o=="string"?o.trim():"";if(!l)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");const f=ir(t.payload||{});let y=f;const u=typeof d=="number"&&Number.isFinite(d)&&d>=0?Math.floor(d):void 0,m=typeof s=="string"?s:void 0,w=m==="ast"||m==="prepared",A={ok:!0},b=String(r??""),h=ar(t.payload||{}),C=h?or(h):"";let k=null,T=l,E=null;if(f)try{const v=await Y(e,"agent-remnote: staged import (auto)",l);if(!v?._id)throw new Error("createSingleRemWithMarkdown returned null for staged import container");k=String(v._id);try{await e.rem.moveRems([k],l,1e9)}catch{}T=k}catch{if(k)try{const v=await e.rem.findOne(k);v&&await v.remove()}catch{}y=!1,k=null,T=l}const M=async()=>{if(!y||!k)return;const v=u??999999,O=await e.rem.findOne(k),p=Array.isArray(O?.children)?O.children.filter(g=>typeof g=="string"&&g.trim()).map(g=>g.trim()):[];if(p.length===0)throw new Error(`Staged import produced no root Rems (staging_rem_id=${k})`);try{await e.rem.moveRems(p,l,v)}catch(g){try{for(const R of p)try{const I=await e.rem.findOne(R);if(!I)continue;te(I)===l&&await I.remove()}catch{}}catch{}try{const R=await e.rem.findOne(k);R&&await R.remove()}catch{}throw new Error(`Failed to move staged content to target parent: ${String(g?.message||g)} (rolled_back=true, staging_rem_id=${k})`)}try{const g=await e.rem.findOne(k);g&&await g.remove()}catch{}};if(h){try{if(E=await Y(e,C,T),!E?._id)throw new Error("createSingleRemWithMarkdown returned null for bundle title");!y&&u!==void 0&&await e.rem.moveRems([E._id],l,u)}catch{if(E?._id)try{await E.remove()}catch{}if(E=await e.rem.createRem(),!E?._id)throw new Error("createRem failed for bundle title");await E.setText(q(C));try{y?await e.rem.moveRems([E._id],T,999999):await e.rem.moveRems([E._id],l,u??999999)}catch(v){try{await E.remove()}catch{}throw v}}T=String(E._id)}const x=y||h?void 0:u,L=x===void 0&&i!==!1&&!w&&m!=="raw",D=async()=>{E?._id&&(Array.isArray(A.created_ids)&&(A.bundle_inner_created_ids=A.created_ids),A.bundle={rem_id:E._id},A.created_ids=[E._id])};try{if(w&&a&&Array.isArray(a.items)){const p=a;if(p.preface&&p.preface.trim())try{await j(e,p.preface,T)}catch{}const g=[];for(const R of p.items){const I=await Y(e,R.heading,T);if(I){if(Array.isArray(n)&&g.length<n.length){const F=n[g.length];F&&g.push({client_temp_id:F,remote_id:I._id,remote_type:"rem"})}if(R.body&&R.body.trim())try{await j(e,R.body,I._id)}catch{}}await K(10)}return g.length&&(A.id_map=g),await D(),await M(),A}if(w){const p=await zt(b);if(p.preface&&p.preface.trim())try{await j(e,p.preface,T)}catch{}const g=[];for(const R of p.items){const I=await Y(e,R.heading,T);if(I){if(Array.isArray(n)&&g.length<n.length){const F=n[g.length];F&&g.push({client_temp_id:F,remote_id:I._id,remote_type:"rem"})}if(R.body&&R.body.trim())try{await j(e,R.body,I._id)}catch{}}await K(10)}return g.length&&(A.id_map=g),await D(),await M(),A}if(L){const p=await Xt(e,b,T,typeof c=="number"?c:2),g=Array.isArray(p)?p.filter(R=>R?._id).map(R=>String(R._id)):[];if(g.length>0){const R=await Ie(e,p,g,T);A.created_ids=R.length>0?R:g}if(Array.isArray(p)&&Array.isArray(n)){const R=[];for(let I=0;I<Math.min(p.length,n.length);I+=1){const F=p[I],_=n[I];F&&F._id&&_&&R.push({client_temp_id:_,remote_id:F._id,remote_type:"rem"})}R.length&&(A.id_map=R)}return await D(),await M(),A}const v=await j(e,b,T),O=[];if(Array.isArray(v))for(const p of v)p?._id&&O.push(p._id);if(O.length&&(A.created_ids=O),x!==void 0&&O.length>0){const p=await Ie(e,v,O,T);if(p.length===0)throw new Error("Failed to determine root Rems for moveRems");try{await e.rem.moveRems(p,T,x)}catch(g){for(const R of O)try{const I=await e.rem.findOne(R);I&&await I.remove()}catch{}throw g}}if(Array.isArray(v)&&Array.isArray(n)){const p=[];for(let g=0;g<Math.min(v.length,n.length);g+=1){const R=v[g],I=n[g];R?._id&&I&&p.push({client_temp_id:I,remote_id:R._id,remote_type:"rem"})}p.length&&(A.id_map=p)}return await D(),await M(),A}catch(v){if(E?._id&&!y)try{await E.remove()}catch{}if(y&&k)try{const O=await e.rem.findOne(k);O&&await O.remove()}catch{}throw v}}async function sr(e,t){const{markdown:r,target:o,require_same_parent:n,require_contiguous:i,portal_id:s}=t.payload||{},c="none",a=String(r??"");if(!a.trim())return{ok:!1,fatal:!0,error:"Missing markdown"};const d=n!==!1,l=i!==!1,f=typeof o?.mode=="string"?o.mode:"",y=f==="current"?"current":f==="explicit"?"explicit":"expected",u=Array.isArray(o?.rem_ids)?o.rem_ids.map(_=>typeof _=="string"?_.trim():"").filter(Boolean):[];if(y!=="current"&&u.length===0)return{ok:!1,fatal:!0,error:`${y} mode requires target.rem_ids`};let w=(typeof s=="string"?s.trim():"")||void 0;if(!w)try{const _=await e.focus.getFocusedPortal();_?._id&&(w=String(_._id))}catch{}let A=[];if(y!=="explicit")try{const _=await e.editor.getSelection();if(!_?.type||_.type!==S.SelectionType.Rem)return{ok:!1,fatal:!0,error:`Current selectionType=${_?.type??"None"}; only Rem selection is supported`};A=Array.isArray(_.remIds)?_.remIds.filter(P=>typeof P=="string"&&P.trim()).map(P=>P.trim()):[]}catch{return{ok:!1,fatal:!0,error:"Failed to read current selection"}}if(y!=="explicit"&&A.length===0)return{ok:!1,fatal:!0,error:"No Rem is selected"};if(y==="expected"&&!((_,P)=>{if(_.length!==P.length)return!1;const B=new Set(_),H=new Set(P);if(B.size!==H.size)return!1;for(const Ct of B)if(!H.has(Ct))return!1;return!0})(A,u))return{ok:!1,fatal:!0,error:`Selection changed (expected=${u.length}, current=${A.length})`};const h=y==="current"?A:u,C=Array.from(new Set(h)),k=await Promise.all(C.map(_=>e.rem.findOne(_))),T=C.filter((_,P)=>!k[P]);if(T.length>0)return{ok:!1,fatal:!0,error:`Cannot access Rems (permission/deleted): ${T.slice(0,3).join(", ")}${T.length>3?"…":""}`};const E=new Set;for(const _ of k){const P=_?.parent;typeof P=="string"&&P.trim()&&E.add(P.trim())}if(d&&E.size!==1)return{ok:!1,fatal:!0,error:`Selected Rems do not share the same parent (parents=${Array.from(E).length}); cannot replace in place`};const M=E.size===1?Array.from(E)[0]:"";if(!M)return{ok:!1,fatal:!0,error:"Cannot determine parentId (top-level Rems are not supported)"};const x=[];for(const _ of k){let P;try{typeof _?.positionAmongstVisibleSiblings=="function"&&(P=await _.positionAmongstVisibleSiblings(w))}catch{}if(P===void 0)try{typeof _?.positionAmongstSiblings=="function"&&(P=await _.positionAmongstSiblings(w))}catch{}if(typeof P!="number"||!Number.isFinite(P)||P<0)return{ok:!1,fatal:!0,error:"Failed to compute selection position"};x.push(Math.floor(P))}const L=[];for(let _=0;_<C.length;_+=1)L.push({id:C[_],pos:x[_]});L.sort((_,P)=>_.pos-P.pos);const D=L.map(_=>_.pos),v=L.map(_=>_.id),O=D[0]??0;if(l){for(let _=0;_<D.length;_+=1)if(D[_]!==O+_)return{ok:!1,fatal:!0,error:"Selection is not contiguous (use Shift to select a contiguous block)"}}const p=await j(e,a,M),g=[];if(Array.isArray(p))for(const _ of p)_?._id&&g.push(_._id);if(g.length===0)return{ok:!1,fatal:!0,error:"createTreeWithMarkdown returned no created Rems"};const R=async()=>{for(const _ of g)try{const P=await e.rem.findOne(_);P&&await P.remove()}catch{}};try{if(w){const _=await Ie(e,p,g,M,w);if(_.length===0)return{ok:!1,fatal:!0,error:"Failed to determine root Rems for moveRems"};await e.rem.moveRems(_,M,O,w)}else{const _=await Ie(e,p,g,M);if(_.length===0)return{ok:!1,fatal:!0,error:"Failed to determine root Rems for moveRems"};await e.rem.moveRems(_,M,O)}}catch(_){return await R(),{ok:!1,fatal:!0,error:`Failed to move new content: ${String(_?.message||_)}`}}let I=null;try{const _=await e.rem.createSingleRemWithMarkdown("agent-remnote: replace backup (auto)",M);if(!_?._id)throw new Error("createSingleRemWithMarkdown returned null");I=String(_._id),await _t({rem:_,backupKind:"selection_replace",cleanupPolicy:"auto",cleanupState:"pending",op:t,sourceParentId:M,sourceAnchorId:v[0]??""});try{w?await e.rem.moveRems([I],M,1e9,w):await e.rem.moveRems([I],M,1e9)}catch{}w?await e.rem.moveRems(v,I,0,w):await e.rem.moveRems(v,I,0)}catch(_){if(await R(),I){try{const P=[];for(const B of v)try{const H=await e.rem.findOne(B);if(!H)continue;te(H)===I&&P.push(B)}catch{}if(P.length>0)try{w?await e.rem.moveRems(P,M,O,w):await e.rem.moveRems(P,M,O)}catch{}}catch{}try{const P=await e.rem.findOne(I);P&&await P.remove()}catch{}}return{ok:!1,fatal:!0,error:`Failed to move old content to backup: ${String(_?.message||_)}`,backup_policy:c}}let F=!1;if(I)try{const _=await e.rem.findOne(I);_&&await _.remove(),F=!0,I=null}catch{F=!1}if(!F&&I){try{await R()}catch{}let _=!1;try{w?await e.rem.moveRems(v,M,O,w):await e.rem.moveRems(v,M,O),_=!0}catch{}if(_)try{const P=[];for(const B of v)try{const H=await e.rem.findOne(B);if(!H)continue;te(H)===I&&P.push(B)}catch{}if(P.length===0){const B=await e.rem.findOne(I);B&&await B.remove(),I=null}}catch{}return{ok:!1,fatal:!0,error:"Failed to delete replace backup container; rolled back to original content",rolled_back:!0,backup_rem_id:I,backup_policy:c}}return{ok:!0,target_mode:y,parent_id:M,portal_id:w??null,position:O,selection_rem_ids:C,created_ids:g,deleted_rem_ids:v,backup_deleted:F,backup_rem_id:I,backup_policy:c}}async function dr(e,t){const{parent_id:r,markdown:o,indent_mode:n,indent_size:i,parse_mode:s,prepared:c,staged:a,bundle:d,backup:l,assertions:f}=t.payload||{},y=ze(r);if(!y)return{ok:!1,fatal:!0,error:"Missing parent_id"};const u=typeof l=="string"&&l.trim()==="visible"?"visible":"none",m=Array.isArray(f)?f.filter(p=>typeof p=="string").map(p=>p.trim()).filter(Boolean):[],w=m.includes("single-root"),A=m.includes("no-literal-bullet"),b=await e.rem.findOne(y);if(!b)return{ok:!1,fatal:!0,error:`Rem not found: ${y}`};const h=be(b),{contentChildIds:C,backupChildIds:k}=await tr(e,h),T=[...C],E=new Set(h),M=String(o??"");let x=[],L=[];const D=async()=>{for(const p of x)try{const g=await e.rem.findOne(p);g&&await g.remove()}catch{}x=[]};if(M.trim()){const p=await wt(e,{...t,payload:{parent_id:y,markdown:M,position:0,...typeof n=="boolean"?{indent_mode:n}:{},...typeof i=="number"?{indent_size:i}:{},...typeof s=="string"?{parse_mode:s}:{},...c!==void 0?{prepared:c}:{},...a===!0?{staged:!0}:{},...d&&typeof d=="object"?{bundle:d}:{}}});if(x=Array.isArray(p?.created_ids)?p.created_ids.filter(g=>typeof g=="string"&&g.trim()).map(g=>g.trim()):[],x.length===0)try{const g=await e.rem.findOne(y);x=be(g).filter(R=>!E.has(R))}catch{}try{const g=await e.rem.findOne(y);L=be(g).filter(R=>!E.has(R))}catch{}}if(M.trim()){if(w&&L.length!==1)return await D(),{ok:!1,fatal:!0,error:`Assertion failed: single-root (created_roots=${L.length})`,assertion:"single-root"};if(A&&L.length===1)try{const p=await e.rem.findOne(L[0]),g=pt(p);if(/^\s*(?:[-*+]|\d+\.)\s+/.test(g))return await D(),{ok:!1,fatal:!0,error:"Assertion failed: no-literal-bullet",assertion:"no-literal-bullet"}}catch{}}if(T.length===0)return{ok:!0,parent_id:y,created_ids:x,deleted_rem_ids:[],ignored_backup_rem_ids:k,backup_deleted:!0,backup_rem_id:null,backup_policy:u};let v=null;try{const p=await e.rem.createSingleRemWithMarkdown("agent-remnote: children replace backup (auto)",y);if(!p?._id)throw new Error("createSingleRemWithMarkdown returned null");v=String(p._id),await _t({rem:p,backupKind:"children_replace",cleanupPolicy:u==="visible"?"visible":"auto",cleanupState:u==="visible"?"retained":"pending",op:t,sourceParentId:y,sourceAnchorId:y});try{await e.rem.moveRems([v],y,1e9)}catch{}await e.rem.moveRems(T,v,0)}catch(p){if(await D(),v){try{const g=[];for(const R of T)try{const I=await e.rem.findOne(R);I&&te(I)===v&&g.push(R)}catch{}if(g.length>0)try{await e.rem.moveRems(g,y,0)}catch{}}catch{}try{const g=[];for(const R of T)try{const I=await e.rem.findOne(R);I&&te(I)===v&&g.push(R)}catch{}if(g.length===0){const R=await e.rem.findOne(v);R&&await R.remove()}}catch{}}return{ok:!1,fatal:!0,error:`Failed to move old children to backup: ${String(p?.message||p)}`,backup_rem_id:v,backup_policy:u}}if(u==="visible")return{ok:!0,parent_id:y,created_ids:x,deleted_rem_ids:T,ignored_backup_rem_ids:k,backup_deleted:!1,backup_rem_id:v,backup_policy:u};let O=!1;if(v&&u==="none"&&await rr(e,[v],ot)>ot){const g=await e.rem.findOne(v),R=await nr({rem:g});return{ok:!0,parent_id:y,created_ids:x,deleted_rem_ids:T,ignored_backup_rem_ids:k,backup_deleted:!1,backup_rem_id:v,backup_policy:u,backup_hidden:R,backup_cleanup_state:"pending"}}if(v)try{const p=await e.rem.findOne(v);p&&await p.remove(),O=!0,v=null}catch{O=!1}if(!O&&v){await D();let p=!1;try{await e.rem.moveRems(T,y,0),p=!0}catch{}if(p)try{const g=[];for(const R of T)try{const I=await e.rem.findOne(R);I&&te(I)===v&&g.push(R)}catch{}if(g.length===0){const R=await e.rem.findOne(v);R&&await R.remove(),v=null}}catch{}return{ok:!1,fatal:!0,error:"Failed to delete children replace backup; rolled back to original content",rolled_back:!0,backup_rem_id:v,backup_policy:u}}return{ok:!0,parent_id:y,created_ids:x,deleted_rem_ids:T,ignored_backup_rem_ids:k,backup_deleted:O,backup_rem_id:v,backup_policy:u}}const lr=100,ur=3e3,fr=150;function Ne(e,t){const r=typeof e=="number"?e:Number(e);return!Number.isFinite(r)||r<=0?t:Math.floor(r)}function mr(e){return Array.isArray(e?.children)?e.children.filter(t=>typeof t=="string"&&t.trim()).map(t=>t.trim()):[]}async function yr(e,t,r,o){const n=Date.now()+r;for(;;){if(!await e.rem.findOne(t))return!0;if(Date.now()>=n)return!1;await K(o)}}async function hr(e,t){const r=[t],o=new Set,n=new Map;for(;r.length>0;){const i=r.shift();if(!i||o.has(i))continue;o.add(i);const s=await e.rem.findOne(i);if(!s)continue;const c=mr(s);n.set(i,{id:i,childIds:c});for(const a of c)r.push(a)}return n}function pr(e,t){if(t<=0||e.length===0)return new Set;const r=new Array(t+1).fill(!1),o=new Array(t+1).fill(-1),n=new Array(t+1).fill(-1);r[0]=!0;for(let a=0;a<e.length;a+=1){const d=e[a];for(let l=t;l>=d;l-=1)!r[l]&&r[l-d]&&(r[l]=!0,o[l]=l-d,n[l]=a)}let i=t;for(;i>0&&!r[i];)i-=1;const s=new Set;let c=i;for(;c>0;){const a=n[c];if(a<0)break;s.add(a),c=o[c]}return s}function _r(e,t,r){const o=n=>{const i=e.get(n);if(!i)return{deleteRootIds:[],residualRootId:n,residualSize:1,nodeCount:1};const s=i.childIds.map(f=>o(f)),c=[];let a=1;for(const f of s)c.push(...f.deleteRootIds),a+=f.nodeCount;const d=pr(s.map(f=>f.residualSize),Math.max(0,r-1));let l=1;for(let f=0;f<s.length;f+=1){const y=s[f];d.has(f)?l+=y.residualSize:c.push(y.residualRootId)}return{deleteRootIds:c,residualRootId:n,residualSize:l,nodeCount:a}};return o(t)}async function wr(e,t,r,o){const n=await e.rem.findOne(t);return n?(await n.remove(),yr(e,t,r,o)):!0}async function gr(e,t,r={}){const o=Ne(r.maxDeleteSubtreeNodes,lr),n=Ne(r.verifyTimeoutMs,ur),i=Ne(r.verifyPollMs,fr);if(!await e.rem.findOne(t))return{existed:!1,deleted:!0,mode:"direct",nodeCount:0,batchCount:0};const c=await hr(e,t),a=_r(c,t,o),d=[...a.deleteRootIds,a.residualRootId],l=d.length===1?"direct":"bottom_up";for(const f of d)if(!await wr(e,f,n,i))return{existed:!0,deleted:!1,mode:l,nodeCount:a.nodeCount,batchCount:d.length,failedRemId:f};return{existed:!0,deleted:!0,mode:l,nodeCount:a.nodeCount,batchCount:d.length}}function br(e){const t=e?.max_delete_subtree_nodes,r=typeof t=="number"?t:Number(t);if(!(!Number.isFinite(r)||r<=0))return Math.floor(r)}async function gt(e,t,r){const{rem_id:o}=t.payload||{},n=typeof o=="string"?o.trim():"";if(!n)return{ok:!1,fatal:!0,error:"Missing rem_id"};const i=br(t.payload),s=await gr(e,n,{maxDeleteSubtreeNodes:i??100});return s.deleted?{ok:!0,...r.includeRemIdInSuccess?{rem_id:n}:{},deleted:!0,existed:s.existed,delete_mode:s.mode,node_count:s.nodeCount,batch_count:s.batchCount}:{ok:!1,fatal:!0,error:`Failed to verify ${r.errorContext}; Rem still exists: ${s.failedRemId??n}`,rem_id:n}}async function kr(e,t){const{parent_id:r,text:o,tags:n,is_document:i,client_temp_id:s,position:c}=t.payload||{},a=typeof r=="string"?r.trim():"";if(!a)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");const d=await e.rem.createRem();if(!d)throw new Error("createRem returned null");const l=async()=>{try{await d.remove()}catch{}};try{const y=typeof c=="number"&&Number.isFinite(c)&&c>=0?Math.floor(c):0;if(await e.rem.moveRems([d._id],a,y),i===!0&&typeof d.setIsDocument=="function"&&await d.setIsDocument(!0),o!==void 0&&await d.setText(q(o)),Array.isArray(n)&&n.length>0)for(const u of n)await d.addTag(u)}catch(y){throw await l(),y}const f={ok:!0};return s&&d._id&&(f.created={client_temp_id:s,remote_id:d._id,remote_type:"rem"}),f}async function vr(e,t){const{url:r,add_title:o,client_temp_id:n,parent_id:i}=t.payload||{},s=typeof i=="string"?i.trim():"";if(!s)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");const c=await e.rem.createLinkRem(String(r??""),o!==!1);if(!c)throw new Error("createLinkRem returned null");try{await e.rem.moveRems([c._id],s,0)}catch(d){try{await c.remove()}catch{}throw d}const a={ok:!0};return n&&c._id&&(a.created={client_temp_id:n,remote_id:c._id,remote_type:"rem"}),a}async function Sr(e,t){const{rem_id:r,text:o}=t.payload||{};if(!r)throw new Error("Missing rem_id");const n=await e.rem.findOne(r);if(!n)throw new Error(`Rem not found: ${r}`);return await n.setText(q(o)),{ok:!0}}async function Rr(e,t){const{rem_id:r,new_parent_id:o,position:n}=t.payload||{};if(!r||!o)throw new Error("Missing rem_id/new_parent_id");return await e.rem.moveRems([r],o,typeof n=="number"?n:0),{ok:!0}}async function Er(e,t){return gt(e,t,{errorContext:"rem deletion",includeRemIdInSuccess:!1})}async function Tr(e,t){return gt(e,t,{errorContext:"backup deletion",includeRemIdInSuccess:!0})}function at(e){return typeof e=="string"?e.trim():""}function Ir(e){if(!(typeof e!="number"||!Number.isFinite(e)||e<0))return Math.floor(e)}async function Ar(e,t){const{parent_id:r,target_rem_id:o,rem_id:n,position:i,client_temp_id:s}=t.payload||{},c=at(r);if(!c)throw new Error("Missing parent_id (refusing to create a Portal without a parent)");const a=at(o??n);if(!a)throw new Error("Missing target_rem_id (or rem_id) for portal target");const d=await e.rem.createPortal();if(!d?._id)throw new Error("createPortal returned null");const l=async()=>{try{await d.remove()}catch{}};try{const u=Ir(i)??0;await e.rem.moveRems([d._id],c,u)}catch(u){throw await l(),u}const f=await e.rem.findOne(a);if(!f)throw await l(),new Error(`Target Rem not found: ${a}`);try{await f.addToPortal(d._id)}catch(u){throw await l(),u}const y={ok:!0,portal_id:d._id,target_rem_id:a,parent_id:c};return s&&d._id&&(y.created={client_temp_id:s,remote_id:d._id,remote_type:"rem"}),y}function ke(e,t){if(!t||typeof t!="object")return null;const{Query:r,TextMatcher:o,NumberMatcher:n,DateMatcher:i,SingleSelectMatcher:s,MultiSelectMatcher:c,CheckboxMatcher:a}=e||{};if(!r)return null;switch(t.op){case"and":{const d=Array.isArray(t.exprs)?t.exprs.map(l=>ke(e,l)).filter(Boolean):[];return r.and(d)}case"or":{const d=Array.isArray(t.exprs)?t.exprs.map(l=>ke(e,l)).filter(Boolean):[];return r.or(d)}case"not":{const d=ke(e,t.expr);return r.not(d)}case"column_text_contains":return t.column_id?r.tableColumn(t.column_id,r.text(o.Contains,String(t.value??""))):null;case"column_text_prefix":return t.column_id?r.tableColumn(t.column_id,r.text(o.Prefix,String(t.value??""))):null;case"column_text_suffix":return t.column_id?r.tableColumn(t.column_id,r.text(o.Suffix,String(t.value??""))):null;case"column_text_phrase":return t.column_id?r.tableColumn(t.column_id,r.text(o.Phrase,String(t.value??""))):null;case"column_number":{if(!t.column_id||typeof r.number!="function")return null;const d=n[t.matcher]??n.Equals,l=t.value??(typeof t.min=="number"&&typeof t.max=="number"?[t.min,t.max]:void 0);return r.tableColumn(t.column_id,r.number(d,l))}case"column_date":{if(!t.column_id||typeof r.date!="function")return null;const d=i[t.matcher]??i.Equals;let l=t.value;if(d===i.Between||d===i.IsBetween)if(t.from&&t.to)l={from:t.from,to:t.to};else return null;return r.tableColumn(t.column_id,r.date(d,l))}case"column_single_select_in":{if(!t.column_id||typeof r.singleSelect!="function")return null;const d=s?.In??s?.Equals??void 0;return r.tableColumn(t.column_id,r.singleSelect(d,Array.isArray(t.option_ids)?t.option_ids:[t.option_ids]))}case"column_multi_select_contains_any":{if(!t.column_id||typeof r.multiSelect!="function")return null;const d=c?.ContainsAny??c?.Contains??void 0;return r.tableColumn(t.column_id,r.multiSelect(d,Array.isArray(t.option_ids)?t.option_ids:[t.option_ids]))}case"column_multi_select_contains_all":{if(!t.column_id||typeof r.multiSelect!="function")return null;const d=c?.ContainsAll??c?.Contains??void 0;return r.tableColumn(t.column_id,r.multiSelect(d,Array.isArray(t.option_ids)?t.option_ids:[t.option_ids]))}case"column_checkbox_equals":{if(!t.column_id||typeof r.checkbox!="function")return null;const d=a?.Equals??a?.Is??void 0;return r.tableColumn(t.column_id,r.checkbox(d,!!t.value))}default:return null}}async function Qe(e,t){const r=typeof t=="string"?t.trim():"";if(r){try{const o=await e.rem.findOne(r);if(o)return o}catch(o){console.warn("[agent-remnote][tableOps] findOne failed",{remId:r,error:String(o?.message||o)})}try{const o=await e.rem.findMany([r]);if(Array.isArray(o)){const n=o.find(i=>i?._id===r);if(n)return n}}catch(o){console.warn("[agent-remnote][tableOps] findMany failed",{remId:r,error:String(o?.message||o)})}}}function bt(e){return new Error(`Property type mutation is unsupported by the current RemNote plugin runtime: public rem.setPropertyType() is unavailable, and host endpoints rem.setPropertyType/rem.setSlotType are not exposed for ${String(e??"unknown-property")}`)}async function Cr(e,t){const{tag_id:r,client_temp_id:o,parent_id:n,position:i}=t.payload||{},s=typeof n=="string"?n.trim():"";if(!s)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");const c=await e.rem.createTable(r);if(!c)throw new Error("createTable returned null");try{const d=typeof i=="number"&&Number.isFinite(i)&&i>=0?Math.floor(i):0;await e.rem.moveRems([c._id],s,d)}catch(d){try{await c.remove()}catch{}throw d}const a={ok:!0};return o&&c._id&&(a.created={client_temp_id:o,remote_id:c._id,remote_type:"rem"}),a}async function xr(e,t){const{tag_id:r,name:o,property_id:n,type:i,options:s}=t.payload||{},c=await e.rem.findOne(r);if(!c)throw new Error("tag_rem not found");const a=await e.rem.createRem();if(!a)throw new Error("createRem returned null");try{if(await fe(e,a,c._id,0),await a.setText(q(o??"Property")),a.setIsProperty&&await a.setIsProperty(!0),i)if(typeof a.setPropertyType=="function")await a.setPropertyType(i);else throw bt(a?._id??n);if(Array.isArray(s)&&s.length>0)for(const l of s){const f=await e.rem.createRem();if(!f)throw new Error("createRem returned null");await fe(e,f,a._id,0),await f.setText(q(l))}}catch(l){try{await a.remove()}catch{}throw l}const d={ok:!0};return n&&a._id&&(d.created={client_temp_id:n,remote_id:a._id,remote_type:"property"}),d}async function Mr(e,t){const{property_id:r,type:o}=t.payload||{},n=await Qe(e,r);if(!n)throw new Error("property rem not found");if(typeof n.setPropertyType=="function")return await n.setPropertyType(o),{ok:!0};throw bt(r??n._id)}async function Pr(e,t){const{table_id:r,column_id:o,contains_text:n,expr:i}=t.payload||{},s=await e.rem.findOne(r);if(!s)throw new Error("table rem not found");if(typeof s.setTableFilter!="function")return{ok:!1};const c=await ye(()=>import("./index-CTg2hlbS.js").then(A=>A.i),[],import.meta.url),a=c.Query,d=c.TextMatcher,l=c.NumberMatcher,f=c.DateMatcher,y=c.SingleSelectMatcher,u=c.MultiSelectMatcher,m=c.CheckboxMatcher;let w=null;if(i)w=ke({Query:a,TextMatcher:d,NumberMatcher:l,DateMatcher:f,SingleSelectMatcher:y,MultiSelectMatcher:u,CheckboxMatcher:m},i);else if(o&&n){if(!a||!d)return{ok:!1};w=a.tableColumn(o,a.text(d.Contains,String(n)))}return w?(await s.setTableFilter(w),{ok:!0}):{ok:!1}}async function Or(e,t){const{property_id:r,text:o,option_id:n}=t.payload||{},i=await Qe(e,r);if(!i)throw new Error("property rem not found");const s=await e.rem.createRem();if(!s)throw new Error("createRem returned null");try{await fe(e,s,i._id,0),await s.setText(q(o))}catch(a){try{await s.remove()}catch{}throw a}const c={ok:!0};return n&&s._id&&(c.created={client_temp_id:n,remote_id:s._id,remote_type:"option"}),c}async function Lr(e,t){const{option_id:r}=t.payload||{},o=await Qe(e,r);return o?(await o.remove(),{ok:!0}):{ok:!0}}async function Nr(e,t){const{table_tag_id:r,rem_id:o,text:n,parent_id:i,client_temp_id:s,values:c,extra_tags:a}=t.payload||{};let d=o?await e.rem.findOne(o):void 0;const l=!d;if(!d){if(d=await e.rem.createRem(),!d)throw new Error("createRem returned null");const u=typeof i=="string"?i.trim():"";if(!u)throw new Error("Missing parent_id (refusing to create a Rem without a parent)");try{await fe(e,d,u,0),n!==void 0&&await d.setText(q(n))}catch(m){try{await d.remove()}catch{}throw m}}const f=async()=>{if(l)try{await d.remove()}catch{}};try{if(await d.addTag(r),Array.isArray(a))for(const u of a)await d.addTag(u);if(Array.isArray(c))for(const u of c)await d.setTagPropertyValue(u.property_id,q(u.value))}catch(u){throw await f(),u}const y={ok:!0};return!o&&s&&d?._id&&(y.created={client_temp_id:s,remote_id:d._id,remote_type:"row"}),y}async function Dr(e,t){const{table_tag_id:r,rem_id:o,remove_properties:n}=t.payload||{},i=await e.rem.findOne(o);return i?(await i.removeTag(r,!!n),{ok:!0}):{ok:!0}}async function Fr(e,t){const{rem_id:r,property_id:o,option_ids:n}=t.payload||{},i=await e.rem.findOne(r);if(!i)throw new Error("Rem not found");const c=(Array.isArray(n)?n:[n]).filter(Boolean).map(a=>({i:"q",_id:a}));return await i.setTagPropertyValue(o,c),{ok:!0}}async function $r(e,t){const{rem_id:r,property_id:o,value:n}=t.payload||{},i=await e.rem.findOne(r);if(!i)throw new Error("Rem not found");return await i.setTagPropertyValue(o,[{i:"m",text:n?"Yes":"No"}]),{ok:!0}}async function Wr(e,t){const{rem_id:r,property_id:o,value:n}=t.payload||{},i=await e.rem.findOne(r);if(!i)throw new Error("Rem not found");return await i.setTagPropertyValue(o,[{i:"m",text:String(n)}]),{ok:!0}}async function Br(e,t){const{rem_id:r,property_id:o,value:n}=t.payload||{},i=await e.rem.findOne(r);if(!i)throw new Error("Rem not found");let s=null;if(typeof n=="string"||typeof n=="number"){const a=new Date(n);isNaN(a.getTime())||(s=a)}else if(n&&typeof n=="object"&&n.year&&n.month&&n.day){const a=new Date(n.year,n.month-1,n.day);isNaN(a.getTime())||(s=a)}if(!s)throw new Error("Invalid date");const c=await e.date.getDailyDoc(s);if(!c?._id)throw new Error("Daily document not found for that date. Please open it in RemNote first.");return await i.setTagPropertyValue(o,[{i:"q",_id:c._id}]),{ok:!0}}async function Ur(e,t){const{rem_id:r,tag_id:o}=t.payload||{};if(!r||!o)throw new Error("Missing rem_id/tag_id");const n=await e.rem.findOne(r);if(!n)throw new Error(`Rem not found: ${r}`);return await n.addTag(o),{ok:!0}}async function qr(e,t){const{rem_id:r,tag_id:o,remove_properties:n}=t.payload||{};if(!r||!o)throw new Error("Missing rem_id/tag_id");const i=await e.rem.findOne(r);if(!i)throw new Error(`Rem not found: ${r}`);return await i.removeTag(o,!!n),{ok:!0}}async function Vr(e,t){const{rem_id:r,property_id:o,value:n}=t.payload||{};if(!r||!o)throw new Error("Missing rem_id/property_id");const i=await e.rem.findOne(r);if(!i)throw new Error(`Rem not found: ${r}`);return await i.setTagPropertyValue(o,q(n)),{ok:!0}}async function zr(e,t){const{rem_id:r,source_id:o}=t.payload||{},n=await e.rem.findOne(r);if(!n)throw new Error("Rem not found");return await n.addSource(o),{ok:!0}}async function Yr(e,t){const{rem_id:r,source_id:o}=t.payload||{},n=await e.rem.findOne(r);if(!n)throw new Error("Rem not found");return await n.removeSource(o),{ok:!0}}async function Gr(e,t){const{rem_id:r,status:o}=t.payload||{},n=await e.rem.findOne(r);if(!n)throw new Error("Rem not found");return typeof n.setTodoStatus=="function"?(await n.setTodoStatus(o),{ok:!0}):{ok:!1}}const kt=new Set,De=new Set,vt=new Map;function jr(e,t){e.idempotency_key&&t&&t.ok&&(kt.add(e.idempotency_key),vt.set(e.idempotency_key,t))}async function Kr(e,t){const r=t.idempotency_key?String(t.idempotency_key):"";try{if(r&&kt.has(r)){const i=vt.get(r);return i&&typeof i=="object"?{...i,dedup:!0}:{ok:!0,dedup:!0}}if(r&&De.has(r))return{ok:!1,fatal:!1,error:"idempotency_key is in-flight; retry later"};r&&De.add(r);const o=lt(t.op_type);let n;switch(o){case"daily_note_write":n=await Jt(e,t);break;case"create_rem":n=await kr(e,t);break;case"create_portal":n=await Ar(e,t);break;case"create_single_rem_with_markdown":n=await cr(e,t);break;case"create_tree_with_markdown":n=await wt(e,t);break;case"replace_selection_with_markdown":n=await sr(e,t);break;case"replace_children_with_markdown":n=await dr(e,t);break;case"create_link_rem":n=await vr(e,t);break;case"create_table":n=await Cr(e,t);break;case"add_property":n=await xr(e,t);break;case"set_property_type":n=await Mr(e,t);break;case"set_table_filter":n=await Pr(e,t);break;case"add_option":n=await Or(e,t);break;case"remove_option":n=await Lr(e,t);break;case"table_add_row":n=await Nr(e,t);break;case"table_remove_row":n=await Dr(e,t);break;case"set_cell_select":n=await Fr(e,t);break;case"set_cell_checkbox":n=await $r(e,t);break;case"set_cell_number":n=await Wr(e,t);break;case"set_cell_date":n=await Br(e,t);break;case"update_text":n=await Sr(e,t);break;case"move_rem":n=await Rr(e,t);break;case"add_tag":n=await Ur(e,t);break;case"remove_tag":n=await qr(e,t);break;case"set_attribute":case"table_cell_write":n=await Vr(e,t);break;case"add_source":n=await zr(e,t);break;case"remove_source":n=await Yr(e,t);break;case"set_todo_status":n=await Gr(e,t);break;case"delete_rem":n=await Er(e,t);break;case"delete_backup_artifact":n=await Tr(e,t);break;default:n={ok:!1,error:`unknown op_type: ${t.op_type}`,fatal:!0};break}return jr(t,n),n}catch(o){const n=String(o?.message||o);return await e.app.toast(`Execution failed: ${n}`),{ok:!1,error:n,fatal:!0}}finally{r&&De.delete(r)}}function $(e){return typeof e=="string"?e.trim():""}function Xr(e){const t=e?.parent;if(typeof t=="string")return t.trim();const r=t?._id;return typeof r=="string"?r.trim():""}class Hr{constructor(){Pe(this,"locked",new Set);Pe(this,"waiters",[])}acquire(t){const r=Array.from(new Set(t.map(i=>String(i||"").trim()).filter(Boolean))).sort();if(r.length===0)return Promise.resolve(()=>{});const n=(()=>{for(const i of r)if(this.locked.has(i))return null;for(const i of r)this.locked.add(i);return()=>{for(const i of r)this.locked.delete(i);this.drain()}})();return n?Promise.resolve(n):new Promise(i=>{this.waiters.push({keys:r,resolve:i}),this.drain()})}drain(){if(this.waiters.length===0)return;const t=new Set;for(let r=0;r<this.waiters.length;r+=1){const o=this.waiters[r],n=o.keys.some(s=>t.has(s)),i=o.keys.every(s=>!this.locked.has(s));if(!n&&i){for(const s of o.keys)this.locked.add(s);this.waiters.splice(r,1),r-=1,o.resolve(()=>{for(const s of o.keys)this.locked.delete(s);this.drain()});continue}for(const s of o.keys)t.add(s)}}}function Qr(e){return`rem:${e}`}function Jr(e){return`children:${e}`}async function Fe(e,t){try{const r=await e.rem.findOne(t);return(r?Xr(r):"")||void 0}catch{return}}async function Zr(e,t){const r=lt(t.op_type),o=t.payload||{},n=[],i=a=>{const d=String(a||"").trim();d&&n.push(d)},s=a=>{a&&i(Qr(a))},c=a=>{a&&i(Jr(a))};switch(r){case"create_rem":case"create_portal":case"create_link_rem":case"create_table":case"create_single_rem_with_markdown":case"create_tree_with_markdown":{const a=$(o.parent_id);if(s(a),c(a),r==="create_portal"){const d=$(o.target_rem_id??o.rem_id);s(d)}return n}case"replace_selection_with_markdown":{const a=o?.target?.rem_ids,d=Array.isArray(a)?a.map(f=>$(f)).filter(Boolean):[];if(d.length===0)return["global:replace_selection_with_markdown"];for(const f of d)s(f);const l=d.length>0?await Fe(e,d[0]):void 0;return s(l),c(l),n}case"replace_children_with_markdown":{const a=$(o.parent_id);if(!a)return["global:replace_children_with_markdown"];s(a),c(a);try{const d=await e.rem.findOne(a),l=Array.isArray(d?.children)?d.children.filter(f=>typeof f=="string"&&f.trim()).map(f=>f.trim()):[];for(const f of l)s(f)}catch{}return n}case"update_text":case"add_tag":case"remove_tag":case"set_attribute":case"table_cell_write":case"add_source":case"remove_source":case"set_todo_status":case"set_cell_select":case"set_cell_checkbox":case"set_cell_number":case"set_cell_date":{const a=$(o.rem_id);return s(a),n}case"set_table_filter":{const a=$(o.table_id);return s(a),n}case"add_property":{const a=$(o.tag_id);return s(a),c(a),n}case"set_property_type":{const a=$(o.property_id);return s(a),n}case"add_option":{const a=$(o.property_id);return s(a),c(a),n}case"remove_option":{const a=$(o.option_id);return s(a),n}case"table_add_row":{const a=$(o.rem_id);if(a)return s(a),n;const d=$(o.parent_id);return s(d),c(d),n}case"table_remove_row":{const a=$(o.rem_id);return s(a),n}case"move_rem":{const a=$(o.rem_id),d=$(o.new_parent_id);s(a),s(d),c(d);const l=a?await Fe(e,a):void 0;return s(l),c(l),n}case"delete_rem":case"delete_backup_artifact":{const a=$(o.rem_id);s(a);const d=a?await Fe(e,a):void 0;return s(d),c(d),n}case"daily_note_write":return["global:daily_note_write"];default:return["global:unknown_op"]}}let N=null,G=null,X=null,oe=!1,V=null,en=0,ae=0,Ye=0,W=null,me=!1,Ge=0,ve=0,je=!1,Se=!1,Re=!1,Ae=null,ce=null,Z=null,Ke=!1,Ee=!1,Te=!1,$e=null,Ce=null;const tn=!0;let U=null;const We="agent-remnote.selection-forwarder",Be={editor:`${We}.editor`,focusedRem:`${We}.focused-rem`,focusedPortal:`${We}.focused-portal`},ne="agent-remnote.ui-context-forwarder",Q={url:`${ne}.url`,openRem:`${ne}.open-rem`,focusedPane:`${ne}.focused-pane`,windowTree:`${ne}.window-tree`,focusedRem:`${ne}.focused-rem`,focusedPortal:`${ne}.focused-portal`,selection:`${ne}.selection`},rn=4,St=12e4,nn=512e3,on=256e3,an=250,cn=2e3,sn=5,dn=new Set(["PROTOCOL_MISMATCH","INVALID_MESSAGE","UNSUPPORTED_CLIENT","UNSUPPORTED_VERSION"]),ln=2e4,un=3e4,fn=new Hr;function mn(e){return e?!dn.has(e):!0}function yn(e){const t=Math.max(1,Math.floor(e)),r=an*Math.pow(2,Math.max(0,t-1));return Math.min(cn,r)}const se=new Map,ee=new Map,it=new WeakSet;let de=null;const hn=1500,Rt=600,pn=5e3,le=new Map,ct=new WeakSet;function _n(){if(de){try{clearTimeout(de)}catch{}de=null}for(const e of ee.values()){try{clearTimeout(e.timer)}catch{}try{e.resolve(null)}catch{}}ee.clear(),se.clear(),le.clear()}function Et(){try{At()}catch{}try{et()}catch{}if(V){try{clearTimeout(V)}catch{}V=null}if(X){try{clearTimeout(X)}catch{}X=null}oe=!1,ae=0,Ye=0,_n()}function Me(e,t){return`${e}:${t}`}function wn(e){ct.has(e)||(ct.add(e),e.addEventListener("message",t=>{let r;try{r=JSON.parse(String(t?.data))}catch{return}if(r?.type!=="LeaseExtendRejected"&&r?.type!=="LeaseExtendOk")return;const o=typeof r?.op_id=="string"?r.op_id:typeof r?.opId=="string"?r.opId:"",n=typeof r?.attempt_id=="string"?r.attempt_id:typeof r?.attemptId=="string"?r.attemptId:"";if(!o||!n)return;const i=Me(o,n);if(r.type==="LeaseExtendRejected"){if(le.has(i))return;const s=typeof r?.reason=="string"?r.reason:"rejected";le.set(i,{reason:s,at:Date.now()});try{console.warn("[agent-remnote][lease] rejected",{opId:o,attemptId:n,reason:s,current:r?.current})}catch{}}else le.delete(i)}))}function gn(e,t,r){wn(e);const o=Me(t,r);let n=!1,i=null;const s=()=>{if(!n){if(le.has(o)){n=!0;return}try{re(e,{type:"LeaseExtend",op_id:t,attempt_id:r,extendMs:St})}catch{}i=setTimeout(s,un)}};return i=setTimeout(s,ln),()=>{if(n=!0,le.delete(o),i)try{clearTimeout(i)}catch{}}}function Je(e){it.has(e)||(it.add(e),e.addEventListener("message",t=>{let r;try{r=JSON.parse(String(t?.data))}catch{return}if(r?.type!=="AckOk"&&r?.type!=="AckRejected")return;const o=typeof r?.op_id=="string"?r.op_id:typeof r?.opId=="string"?r.opId:"",n=typeof r?.attempt_id=="string"?r.attempt_id:typeof r?.attemptId=="string"?r.attemptId:"";if(!o||!n)return;const i=Me(o,n);se.delete(i);const s=ee.get(i);if(s){ee.delete(i);try{clearTimeout(s.timer)}catch{}s.resolve(r)}if(r.type==="AckRejected")try{console.warn("[agent-remnote][ack] rejected",{opId:o,attemptId:n,reason:r?.reason,current:r?.current})}catch{}}))}function Tt(){de||(de=setTimeout(()=>{de=null,bn()},300))}function bn(){const e=Date.now();for(const t of se.values()){if(!t.ws||t.ws.readyState!==WebSocket.OPEN){se.delete(t.key);continue}if(e<t.nextRetryAt)continue;try{re(t.ws,t.payload)}catch{}t.retries+=1;const r=Math.min(pn,Rt+t.retries*500);t.nextRetryAt=e+r}se.size>0&&Tt()}function kn(e,t){return new Promise(r=>{const o=ee.get(e);if(o){try{clearTimeout(o.timer)}catch{}ee.delete(e)}const n=setTimeout(()=>{ee.delete(e),r(null)},Math.max(1,t));ee.set(e,{resolve:r,timer:n})})}async function Ue(e,t,r=hn){const o=typeof t?.op_id=="string"?t.op_id:"",n=typeof t?.attempt_id=="string"?t.attempt_id:"";if(!o||!n)return"timeout";Je(e);const i=Me(o,n);se.set(i,{key:i,op_id:o,attempt_id:n,ws:e,payload:t,retries:0,nextRetryAt:Date.now()+Rt});const s=kn(i,r);try{re(e,t)}catch{}const c=await s;return c?c.type==="AckOk"?"ok":"rejected":(Tt(),"timeout")}const vn=18e4,Sn=12e4;function we(e,t,r,o){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?Math.max(r,Math.min(o,Math.floor(n))):t}function Rn(e){const t=String(e||"").trim();if(!t)return[];const r=t.replace(/[^\p{L}\p{N}]+/gu," ").split(/\s+/).map(n=>n.trim()).filter(Boolean),o=[];for(const n of r){const i=n.toLowerCase();if(!(i.length<2)&&!o.includes(i)&&(o.push(i),o.length>=8))break}return o}function En(e,t,r){const o=String(e||"").replace(/\s+/g," ").trim();if(o.length<=r)return{text:o,truncated:!1};const n=Rn(t),i=o.toLowerCase();let s=-1;for(const f of n){const y=i.indexOf(f);y<0||(s<0||y<s)&&(s=y)}let c=0;s>=0&&(c=Math.max(0,s-Math.floor(r/3)));let a=c+r;a>o.length&&(a=o.length,c=Math.max(0,a-r));const d=o.slice(c,a).trim(),l=c>0||a<o.length;return{text:d,truncated:l}}function Tn(e,t){return new Promise((r,o)=>{const n=setTimeout(()=>o(new Error("timeout")),t);e.then(i=>{clearTimeout(n),r(i)},i=>{clearTimeout(n),o(i)})})}async function In(e,t,r){const o=Date.now(),n=typeof r?.requestId=="string"?r.requestId.trim():"";if(!n)return;const i=typeof r?.queryText=="string"?r.queryText:"",s=typeof r?.searchContextRemId=="string"?r.searchContextRemId.trim():"",c=200,a=we(r?.limit,20,1,1e4),d=we(a,20,1,100),l=d!==a,f=we(r?.timeoutMs,3e3,1,6e4),y=we(f,3e3,1,5e3),u={timeoutMs:y,limitRequested:a,limitEffective:d,limitClamped:l,maxPreviewChars:c,durationMs:0},m=w=>{try{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(w))}catch{}};if(!i.trim())return m({type:"SearchResponse",requestId:n,ok:!1,budget:{...u,durationMs:Date.now()-o},error:{code:"VALIDATION_ERROR",message:"queryText must not be empty"}});try{const w=await e.richText.parseFromMarkdown(i),A=await Tn(e.search.search(w,s||void 0,{numResults:d}),y),b=[];for(const h of A.slice(0,d)){const C=String(h?._id||"").trim();if(!C)continue;let k="";try{k=String(await e.richText.toString(h?.text??[]))}catch{}let T="";try{h?.backText&&(T=String(await e.richText.toString(h.backText)))}catch{}T.trim()||(T=k);const E=En(T,i,c);b.push({remId:C,title:k.trim(),snippet:E.text,truncated:E.truncated})}return m({type:"SearchResponse",requestId:n,ok:!0,budget:{...u,durationMs:Date.now()-o},results:b})}catch(w){const A=String(w?.message||w||"search failed"),b=A.toLowerCase().includes("timeout")?"TIMEOUT":"PLUGIN_ERROR";return m({type:"SearchResponse",requestId:n,ok:!1,budget:{...u,durationMs:Date.now()-o},error:{code:b,message:A},nextActions:["Retry later","Check that the plugin is connected and responsive",'Fallback to DB search: agent-remnote read search --query "<keywords>"']})}}function xe(){ce&&(clearTimeout(ce),ce=null)}function It(e){ce||(ce=setTimeout(()=>{ce=null,me&&(!N||N.readyState!==WebSocket.OPEN||(ue(e,{force:!1}),It(e)))},500))}function An(e){je=!0;try{const n=Z?.editor;n&&e.event.removeListener(S.AppEvents.EditorSelectionChanged,void 0,n)}catch{}try{const n=Z?.focusedRem;n&&e.event.removeListener(S.AppEvents.FocusedRemChange,void 0,n)}catch{}try{const n=Z?.focusedPortal;n&&e.event.removeListener(S.AppEvents.FocusedPortalChange,void 0,n)}catch{}try{e.event.removeListener(S.AppEvents.EditorSelectionChanged,Be.editor)}catch{}try{e.event.removeListener(S.AppEvents.FocusedRemChange,Be.focusedRem)}catch{}try{e.event.removeListener(S.AppEvents.FocusedPortalChange,Be.focusedPortal)}catch{}const t=()=>{ue(e,{force:!1})},r=()=>{ue(e,{force:!1})},o=()=>{ue(e,{force:!1})};Z={editor:t,focusedRem:r,focusedPortal:o},e.event.addListener(S.AppEvents.EditorSelectionChanged,void 0,t),e.event.addListener(S.AppEvents.FocusedRemChange,void 0,r),e.event.addListener(S.AppEvents.FocusedPortalChange,void 0,o)}function Cn(e){if(je){je=!1,Se=!1,Re=!1,Ae=null,xe();try{const t=Z?.editor;e.event.removeListener(S.AppEvents.EditorSelectionChanged,void 0,t)}catch{}try{const t=Z?.focusedRem;e.event.removeListener(S.AppEvents.FocusedRemChange,void 0,t)}catch{}try{const t=Z?.focusedPortal;e.event.removeListener(S.AppEvents.FocusedPortalChange,void 0,t)}catch{}Z=null}}function xn(e){Ke=!0;try{const c=U?.url;c&&e.event.removeListener(S.AppEvents.URLChange,void 0,c)}catch{}try{const c=U?.openRem;c&&e.event.removeListener(S.AppEvents.GlobalOpenRem,void 0,c)}catch{}try{const c=U?.focusedPane;c&&e.event.removeListener(S.AppEvents.FocusedPaneChange,void 0,c)}catch{}try{const c=U?.windowTree;c&&e.event.removeListener(S.AppEvents.CurrentWindowTreeChange,void 0,c)}catch{}try{const c=U?.focusedRem;c&&e.event.removeListener(S.AppEvents.FocusedRemChange,void 0,c)}catch{}try{const c=U?.focusedPortal;c&&e.event.removeListener(S.AppEvents.FocusedPortalChange,void 0,c)}catch{}try{e.event.removeListener(S.AppEvents.URLChange,Q.url)}catch{}try{e.event.removeListener(S.AppEvents.GlobalOpenRem,Q.openRem)}catch{}try{e.event.removeListener(S.AppEvents.FocusedPaneChange,Q.focusedPane)}catch{}try{e.event.removeListener(S.AppEvents.CurrentWindowTreeChange,Q.windowTree)}catch{}try{e.event.removeListener(S.AppEvents.FocusedRemChange,Q.focusedRem)}catch{}try{e.event.removeListener(S.AppEvents.FocusedPortalChange,Q.focusedPortal)}catch{}try{e.event.removeListener(S.AppEvents.EditorSelectionChanged,Q.selection)}catch{}const t=()=>void J(e,{force:!1,source:"event:URLChange"}),r=()=>void J(e,{force:!1,source:"event:GlobalOpenRem"}),o=()=>void J(e,{force:!1,source:"event:FocusedPaneChange"}),n=()=>void J(e,{force:!1,source:"event:CurrentWindowTreeChange"}),i=()=>void J(e,{force:!1,source:"event:FocusedRemChange"}),s=()=>void J(e,{force:!1,source:"event:FocusedPortalChange"});U={url:t,openRem:r,focusedPane:o,windowTree:n,focusedRem:i,focusedPortal:s},e.event.addListener(S.AppEvents.URLChange,void 0,t),e.event.addListener(S.AppEvents.GlobalOpenRem,void 0,r),e.event.addListener(S.AppEvents.FocusedPaneChange,void 0,o),e.event.addListener(S.AppEvents.CurrentWindowTreeChange,void 0,n),e.event.addListener(S.AppEvents.FocusedRemChange,void 0,i),e.event.addListener(S.AppEvents.FocusedPortalChange,void 0,s)}function Mn(e){if(Ke){Ke=!1,Ee=!1,Te=!1,Ce=null;try{const t=U?.url;e.event.removeListener(S.AppEvents.URLChange,void 0,t)}catch{}try{const t=U?.openRem;e.event.removeListener(S.AppEvents.GlobalOpenRem,void 0,t)}catch{}try{const t=U?.focusedPane;e.event.removeListener(S.AppEvents.FocusedPaneChange,void 0,t)}catch{}try{const t=U?.windowTree;e.event.removeListener(S.AppEvents.CurrentWindowTreeChange,void 0,t)}catch{}try{const t=U?.focusedRem;e.event.removeListener(S.AppEvents.FocusedRemChange,void 0,t)}catch{}try{const t=U?.focusedPortal;e.event.removeListener(S.AppEvents.FocusedPortalChange,void 0,t)}catch{}try{e.event.removeListener(S.AppEvents.EditorSelectionChanged,Q.selection)}catch{}U=null}}async function ue(e,t){if(Se){Re=!0;return}Se=!0;try{const r=N;if(!r||r.readyState!==WebSocket.OPEN)return;const o=await Pn(e);let n=o.kind,i=n==="rem"?S.SelectionType.Rem:n==="text"?S.SelectionType.Text:void 0,s=0,c=!1,a=[],d="",l,f=!1;if(o.kind==="rem"){a=o.remIds,s=a.length;const u=200;c=s>u,c&&(a=a.slice(0,u)),s<=0&&(n="none",i=void 0)}else o.kind==="text"&&(d=o.remId,l=o.range,f=o.isReverse,s=1);if(n==="rem"&&a.length>0&&!c){let u="";try{const m=await e.focus.getFocusedRem();m?._id&&(u=String(m._id).trim())}catch{}u&&!a.includes(u)&&(n="none",i=void 0,s=0,c=!1,a=[])}if(n==="text"&&d){let u="";try{const m=await e.focus.getFocusedRem();m?._id&&(u=String(m._id).trim())}catch{}u&&u!==d&&(n="none",i=void 0,s=0,c=!1,d="",l=void 0,f=!1)}const y=n==="rem"?`rem:${s}:${c?"1":"0"}:${a.join(",")}`:n==="text"?`text:${d}:${l?.start??""}-${l?.end??""}:${f?"1":"0"}`:"none";if(!t.force&&Ae===y)return;Ae=y;try{r.send(JSON.stringify({type:"SelectionChanged",kind:n,selectionType:i,remIds:a,totalCount:s,truncated:c,remId:d,range:l,isReverse:f,ts:Date.now()}))}catch{}}finally{Se=!1,Re&&(Re=!1,ue(e,{force:!1}))}}async function Pn(e){try{const t=await e.editor.getSelection();if(!t?.type)return{kind:"none"};if(t.type===S.SelectionType.Rem)return{kind:"rem",remIds:Array.isArray(t.remIds)?t.remIds.filter(o=>typeof o=="string"&&o.trim()):[]};if(t.type===S.SelectionType.Text){const r=typeof t.remId=="string"?t.remId.trim():"",o=t?.range?.start,n=t?.range?.end,i=typeof o=="number"&&Number.isFinite(o)?Math.floor(o):NaN,s=typeof n=="number"&&Number.isFinite(n)?Math.floor(n):NaN,c=t?.isReverse===!0;return r?!Number.isFinite(i)||!Number.isFinite(s)?{kind:"none"}:i===s?{kind:"none"}:{kind:"text",remId:r,range:{start:i,end:s},isReverse:c}:{kind:"none"}}return{kind:"none"}}catch{return{kind:"none"}}}async function On(e){let t="";try{t=await e.window.getURL()||""}catch{}let r="";try{r=await e.window.getFocusedPaneId()||""}catch{}let o="";try{o=await e.window.getOpenPaneRemId(r)||""}catch{}let n="";try{const a=await e.focus.getFocusedRem();a?._id&&(n=String(a._id))}catch{}let i="";try{const a=await e.focus.getFocusedPortal();a?._id&&(i=String(a._id))}catch{}let s="",c="";try{const d=new URL(t).pathname.split("/").filter(Boolean);d.length>=2&&d[0]==="w"&&(s=String(d[1]||""))}catch{}if(!s)try{const a=await e.kb?.getCurrentKnowledgeBaseData?.();a?._id&&(s=String(a._id)),a?.name&&(c=String(a.name))}catch{}return{url:t,paneId:r,pageRemId:o,focusedRemId:n,focusedPortalId:i,kbId:s,kbName:c}}async function J(e,t){if(Ee){Te=!0,$e=t.source;return}Ee=!0;try{const r=N;if(!r||r.readyState!==WebSocket.OPEN)return;const o=await On(e),n=`${o.url}|${o.paneId}|${o.pageRemId}|${o.focusedRemId}|${o.focusedPortalId}|${o.kbId}`;if(!t.force&&Ce===n)return;Ce=n;try{r.send(JSON.stringify({type:"UiContextChanged",...o,source:t.source,ts:Date.now()}))}catch{}if(tn)try{console.log("[agent-remnote][ui-context]",{...o,source:t.source})}catch{}}finally{if(Ee=!1,Te){const r=$e||"pending";Te=!1,$e=null,J(e,{force:!1,source:r})}}}function Ln(e){const o=Math.min(Math.max(e,0),10),n=Math.min(3e4,500*Math.pow(2,o)),i=n*.2;return Math.max(0,Math.round(n+(Math.random()*2-1)*i))}function At(){me=!1,G&&(clearTimeout(G),G=null),X&&(clearTimeout(X),X=null),xe(),Ge+=1,ve=0;const e=N;N=null;try{e&&e.readyState!==WebSocket.CLOSED&&e.close()}catch{}}function Ze(e,t,r){if(me=!0,N&&(N.readyState===WebSocket.OPEN||N.readyState===WebSocket.CONNECTING))return;G&&(clearTimeout(G),G=null);const o=Ge+=1,n=new WebSocket(t);N=n;const i=()=>N===n&&Ge===o,s=setTimeout(()=>{if(i()&&n.readyState===WebSocket.CONNECTING)try{n.close()}catch{}},8e3);n.onopen=async()=>{if(i()){clearTimeout(s),ve=0;try{if(n.send(JSON.stringify({type:"Hello"})),n.send(JSON.stringify({type:"Register",protocolVersion:2,clientType:"remnote-plugin",clientInstanceId:r,capabilities:{control:!0,worker:!0,readRpc:!0,batchPull:!0}})),Ae=null,ue(e,{force:!0}),Ce=null,J(e,{force:!0,source:"connect"}),It(e),await e.app.toast("Control channel connected"),await e.settings.getSetting(z.autoSyncOnConnect))try{await _e(e,t,r,{silent:!0})}catch(d){try{console.warn("[agent-remnote][control] auto-sync on connect failed",{message:String(d?.message||d||"unknown error")})}catch{}}}catch{}}},n.onmessage=async a=>{if(i())try{const d=JSON.parse(String(a.data));if(d?.type==="StartSync"){try{await _e(e,t,r,{silent:!0})}catch(l){try{console.warn("[agent-remnote][control] StartSync failed",{message:String(l?.message||l||"unknown error")})}catch{}}return}if(d?.type==="SearchRequest"){In(e,n,d);return}}catch{}};const c=()=>{if(!me||!i()||G)return;const a=Ln(ve);ve+=1,G=setTimeout(()=>{G=null,Ze(e,t,r)},a)};n.onclose=()=>{clearTimeout(s),i()&&(xe(),c(),N=null)},n.onerror=()=>{clearTimeout(s),xe(),c()}}async function Nn(e,t=!0){return t&&N&&N.readyState===WebSocket.OPEN?N:(W&&W.readyState===WebSocket.OPEN||(W=await st(e),W.onclose=()=>{W&&W.readyState!==WebSocket.OPEN&&(W=null)},Je(W)),W)}async function Dn(e,t){const r=Math.max(1,Math.min(50,Math.floor(t)));re(e,{type:"RequestOps",leaseMs:St,maxOps:r,maxBytes:nn,maxOpBytes:on});const o=await Nt(e);if(!o||o.type==="NoWork")return{kind:"no_work"};if(o.type==="Error"){const n=typeof o?.code=="string"?o.code:"",i=typeof o?.message=="string"?o.message:"";if(n==="OP_PAYLOAD_TOO_LARGE")try{re(e,{type:"TriggerStartSync"})}catch{}try{console.warn("[agent-remnote][ws] RequestOps error",{code:n,message:i,details:o?.details,nextActions:o?.nextActions})}catch{}return{kind:"error",code:n,message:i,retryable:mn(n)}}if(o.type==="OpDispatchBatch"){const n=o;return{kind:"ops",ops:Array.isArray(n.ops)?n.ops:[]}}if(o.type==="OpDispatch"){const n=o;if(n?.op_id&&n?.attempt_id)return{kind:"ops",ops:[{op_id:String(n.op_id),attempt_id:String(n.attempt_id),txn_id:String(n.txn_id??""),op_seq:Number(n.op_seq??0),op_type:String(n.op_type??""),payload:n.payload??null,idempotency_key:n.idempotency_key??null,lease_expires_at:typeof n.lease_expires_at=="number"?n.lease_expires_at:void 0}]}}return{kind:"no_work"}}async function _e(e,t,r,o){const n=Date.now();if(o?.silent&&Ye>n)return;if(oe){o?.silent||await e.app.toast("A sync is already running");return}oe=!0;const i=en+=1;ae=i,V&&(clearTimeout(V),V=null),V=setTimeout(()=>{if(oe&&ae===i){ae=0,oe=!1,Ye=Date.now()+Sn,V=null;try{et()}catch{}try{N&&N.readyState!==WebSocket.CLOSED&&N.close()}catch{}try{e.app.toast("Sync watchdog tripped; please retry")}catch{}}},vn),o?.silent||await e.app.toast("Starting sync…");let s=0;try{const c=await Nn(t,!0);Je(c);const a=c===N;try{re(c,{type:"Hello"})}catch{}try{re(c,{type:"Register",protocolVersion:2,clientType:"remnote-plugin",clientInstanceId:r,capabilities:{control:a,worker:!0,readRpc:!0,batchPull:!0}})}catch{}let d=rn;try{const m=await e.settings.getSetting(z.syncConcurrency);typeof m=="number"&&Number.isFinite(m)&&m>=1&&(d=Math.min(16,Math.floor(m)))}catch{}const l=new Map;let f=!1;const y=async m=>{let w,A;try{const b=await Zr(e,m);w=await fn.acquire(b),A=gn(c,m.op_id,m.attempt_id);const h=await Kr(e,m);if(h&&h.ok)await Ue(c,{type:"OpAck",op_id:m.op_id,attempt_id:m.attempt_id,status:"success",result:h});else{const C=h&&h.fatal||!1,k=h&&h.error||"executor error";await Ue(c,{type:"OpAck",op_id:m.op_id,attempt_id:m.attempt_id,status:C?"failed":"retry",error_code:"EXEC_ERROR",error_message:k})}}catch(b){const h=String(b?.message||b);await Ue(c,{type:"OpAck",op_id:m.op_id,attempt_id:m.attempt_id,status:"retry",error_code:"EXEC_ERROR",error_message:h})}finally{try{A?.()}catch{}try{w?.()}catch{}s+=1,s%10===0&&await K(50)}};let u=0;for(;;){for(;!f&&l.size<d;){const m=d-l.size,w=await Dn(c,m);if(w.kind==="error"){if(u+=1,w.retryable&&u<=sn){const h=yn(u);try{console.warn("[agent-remnote][ws] RequestOps transient error; retrying",{code:w.code,message:w.message,streak:u,delayMs:h})}catch{}await K(h);continue}try{console.warn("[agent-remnote][ws] RequestOps error; stopping pull loop",{code:w.code,message:w.message,streak:u,retryable:w.retryable})}catch{}f=!0;break}if(u=0,w.kind==="no_work"){f=!0;break}const A=w.ops;if(A.length===0){f=!0;break}for(const b of A){const h={type:"OpDispatch",...b},C=y(h).catch(()=>{}).finally(()=>{l.delete(h.op_id)});l.set(h.op_id,C)}}if(f&&l.size===0)break;l.size>0&&await Promise.race(l.values())}if(c!==N){try{c.close()}catch{}W===c&&(W=null)}o?.silent||await e.app.toast("Sync finished (or no work)")}finally{if(!(ae===i))return;oe=!1,ae=0,V&&(clearTimeout(V),V=null);try{const a=await e.settings.getSetting(z.autoSyncOnConnect);s>0&&a&&me&&N&&N.readyState===WebSocket.OPEN&&(X||(X=setTimeout(()=>{X=null,me&&(!N||N.readyState!==WebSocket.OPEN||oe||_e(e,t,r,{silent:!0}))},1500)))}catch{}}}function et(){try{W&&W.readyState!==WebSocket.CLOSED&&W.close()}catch{}W=null}async function Fn(e){try{await e.app.registerCommand({id:"start-sync-ops",name:"Start sync",action:async()=>{const t=await ge(e),r=await qe(e);try{await _e(e,t,r,{silent:!1})}catch(o){await e.app.toast(`Failed to start sync: ${o?.message||o}`)}}})}catch{}try{await e.app.registerCommand({id:"show-queue-stats",name:"Show queue stats",action:async()=>{const t=await ge(e);try{const r=await Dt(t);await e.app.toast(`Pending: ${r.pending} | In-flight: ${r.in_flight} | Dead: ${r.dead}`)}catch(r){await e.app.toast(`Query failed: ${r?.message||r}`)}}})}catch{}try{await e.app.registerCommand({id:"connect-control",name:"Connect control channel",action:async()=>{const t=await ge(e),r=await qe(e);Ze(e,t,r)}})}catch{}try{await e.app.registerCommand({id:"disconnect-control",name:"Disconnect control channel",action:async()=>{try{At(),et(),await e.app.toast("Control channel disconnected")}catch(t){await e.app.toast(`Disconnect failed: ${t?.message||t}`)}}})}catch{}}async function Bn(e){try{Et()}catch{}try{const t=globalThis;t.__REMNOTE_BRIDGE_REGISTERED__=!0}catch{}try{await Bt(e)}catch{}try{await Ot(e)}catch{}try{An(e)}catch{}try{xn(e)}catch{}try{await Fn(e)}catch{}try{const t=await e.settings.getSetting(z.autoConnectControl),r=await e.settings.getSetting(z.autoSyncOnConnect),o=await ge(e),n=await qe(e);if(t)Ze(e,o,n);else if(r)try{await _e(e,o,n,{silent:!1})}catch{}}catch{}}async function Un(e){try{Cn(e)}catch{}try{Mn(e)}catch{}try{Et()}catch{}try{const t=globalThis;delete t.__REMNOTE_BRIDGE_REGISTERED__}catch{}}export{Un as a,Bn as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.visible{visibility:visible}.m-2{margin:.5rem}.block{display:block}.inline{display:inline}.\!table{display:table!important}.table{display:table}.hidden{display:none}.rounded-lg{border-radius:.5rem}.p-2{padding:.5rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}html,:host-context(div){line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body,:host{margin:0;line-height:inherit}body,:host{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as m}from"./index-CTg2hlbS.js";var _={exports:{}},t={};/** @license React v17.0.2
|
|
2
|
+
* react-jsx-runtime.production.min.js
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/var a=m,i=60103;t.Fragment=60107;if(typeof Symbol=="function"&&Symbol.for){var u=Symbol.for;i=u("react.element"),t.Fragment=u("react.fragment")}var y=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,v=Object.prototype.hasOwnProperty,x={key:!0,ref:!0,__self:!0,__source:!0};function l(o,r,p){var e,n={},f=null,s=null;p!==void 0&&(f=""+p),r.key!==void 0&&(f=""+r.key),r.ref!==void 0&&(s=r.ref);for(e in r)v.call(r,e)&&!x.hasOwnProperty(e)&&(n[e]=r[e]);if(o&&o.defaultProps)for(e in r=o.defaultProps,r)n[e]===void 0&&(n[e]=r[e]);return{$$typeof:i,type:o,key:f,ref:s,props:n,_owner:y.current}}t.jsx=l;t.jsxs=l;_.exports=t;var d=_.exports;export{d as j};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifestVersion": 1,
|
|
3
|
+
"id": "agent-remnote-bridge",
|
|
4
|
+
"name": "Agent Remnote Bridge",
|
|
5
|
+
"author": "yoyooyooo",
|
|
6
|
+
"repoUrl": "https://github.com/yoyooyooo/agent-remnote",
|
|
7
|
+
"projectUrl": "https://github.com/yoyooyooo/agent-remnote",
|
|
8
|
+
"supportUrl": "https://github.com/yoyooyooo/agent-remnote/issues",
|
|
9
|
+
"changelogUrl": "https://github.com/yoyooyooo/agent-remnote/releases",
|
|
10
|
+
"version": {
|
|
11
|
+
"major": 0,
|
|
12
|
+
"minor": 0,
|
|
13
|
+
"patch": 2
|
|
14
|
+
},
|
|
15
|
+
"theme": [],
|
|
16
|
+
"enableOnMobile": false,
|
|
17
|
+
"description": "Bridge plugin that executes queued write operations through the RemNote SDK.",
|
|
18
|
+
"requestNative": true,
|
|
19
|
+
"requiredScopes": [
|
|
20
|
+
{
|
|
21
|
+
"type": "All",
|
|
22
|
+
"level": "ReadCreateModifyDelete"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "KnowledgeBaseInfo",
|
|
26
|
+
"level": "Read"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./jsx-runtime-D6ZSwAL5.js";import{d as n,r as t}from"./index-CTg2hlbS.js";const m=()=>{const e=n.usePlugin(),[a,r]=t.useState(""),[o,c]=t.useState(!1),[u,l]=t.useState(0);return t.useEffect(()=>{(async()=>{try{r(await e.settings.getSetting("name")||""),c(!!await e.settings.getSetting("pizza"));const i=await e.settings.getSetting("favorite-number");l(typeof i=="number"?i:0)}catch{}})()},[]),s.jsxs("div",{className:"p-2 m-2 rounded-lg rn-clr-background-light-positive rn-clr-content-positive",children:[s.jsx("h1",{className:"text-xl",children:"Sample Plugin"}),s.jsxs("div",{children:["Hi ",a,", you ",o?"do":"don't"," like pizza and your favorite number is ",u,"!"]})]})};n.renderWidget(m);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./jsx-runtime-D6ZSwAL5.js";import{d as n,r as t}from"./index-CTg2hlbS.js";const l=()=>{const e=n.usePlugin(),[a,r]=t.useState(""),[o,c]=t.useState(!1),[m,u]=t.useState(0);return t.useEffect(()=>{(async()=>{try{r(await e.settings.getSetting("name")||""),c(!!await e.settings.getSetting("pizza"));const i=await e.settings.getSetting("favorite-number");u(typeof i=="number"?i:0)}catch{}})()},[]),s.jsxs("div",{className:"p-2 m-2 rounded-lg rn-clr-background-light-positive rn-clr-content-positive",children:[s.jsx("h1",{className:"text-xl",children:"Sample Plugin"}),s.jsxs("div",{children:["Hi ",a,", you ",o?"do":"don't"," like pizza and your favorite number is ",m,"!"]})]})};n.renderWidget(l);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function toUrl(input) {
|
|
2
|
+
if (input instanceof URL) return input;
|
|
3
|
+
if (typeof input === 'string') return new URL(input);
|
|
4
|
+
|
|
5
|
+
if (input && typeof input === 'object') {
|
|
6
|
+
if (typeof input.href === 'string') return new URL(input.href);
|
|
7
|
+
|
|
8
|
+
const origin = typeof input.origin === 'string' && input.origin !== 'null' ? input.origin : 'http://localhost';
|
|
9
|
+
const pathname = typeof input.pathname === 'string' ? input.pathname : '/';
|
|
10
|
+
const search = typeof input.search === 'string' ? input.search : '';
|
|
11
|
+
return new URL(`${origin}${pathname}${search}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
throw new TypeError('Unsupported location input');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function resolveWidgetName(input) {
|
|
18
|
+
const url = toUrl(input);
|
|
19
|
+
const queryWidgetName = url.searchParams.get('widgetName');
|
|
20
|
+
|
|
21
|
+
if (queryWidgetName) return queryWidgetName;
|
|
22
|
+
|
|
23
|
+
const normalizedPath = url.pathname.replace(/\/+$/, '') || '/';
|
|
24
|
+
const lastSegment = normalizedPath === '/' ? '' : normalizedPath.split('/').pop() ?? '';
|
|
25
|
+
|
|
26
|
+
if (lastSegment && lastSegment !== 'index' && lastSegment !== 'index.html') {
|
|
27
|
+
return lastSegment;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return 'index';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createSandboxScript(input) {
|
|
34
|
+
const widgetName = resolveWidgetName(input);
|
|
35
|
+
return {
|
|
36
|
+
src: `${widgetName}-sandbox.js`,
|
|
37
|
+
type: 'module',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function mountSandboxScript({ location = window.location, document = window.document } = {}) {
|
|
42
|
+
const sandboxScript = createSandboxScript(location);
|
|
43
|
+
const script = document.createElement('script');
|
|
44
|
+
script.type = sandboxScript.type;
|
|
45
|
+
script.src = sandboxScript.src;
|
|
46
|
+
document.body.appendChild(script);
|
|
47
|
+
return script;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
51
|
+
mountSandboxScript();
|
|
52
|
+
}
|