mcp-memory-bucket 0.11.0 → 0.12.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.
@@ -0,0 +1,2947 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();const ls="modulepreload",cs=function(n){return"/"+n},He={},ae=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){let o=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");i=o(t.map(d=>{if(d=cs(d),d in He)return;He[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":ls,u||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),u)return new Promise((x,m)=>{g.addEventListener("load",x),g.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const ne=globalThis,Te=ne.ShadowRoot&&(ne.ShadyCSS===void 0||ne.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ae=Symbol(),Ke=new WeakMap;let Lt=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==Ae)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Te&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=Ke.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&Ke.set(t,e))}return e}toString(){return this.cssText}};const ds=n=>new Lt(typeof n=="string"?n:n+"",void 0,Ae),$=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((s,i,r)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+n[r+1],n[0]);return new Lt(t,n,Ae)},hs=(n,e)=>{if(Te)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const s=document.createElement("style"),i=ne.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=t.cssText,n.appendChild(s)}},Ve=Te?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return ds(t)})(n):n;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:ps,defineProperty:us,getOwnPropertyDescriptor:fs,getOwnPropertyNames:gs,getOwnPropertySymbols:bs,getPrototypeOf:ms}=Object,pe=globalThis,Ge=pe.trustedTypes,vs=Ge?Ge.emptyScript:"",xs=pe.reactiveElementPolyfillSupport,Q=(n,e)=>n,ye={toAttribute(n,e){switch(e){case Boolean:n=n?vs:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},Ft=(n,e)=>!ps(n,e),We={attribute:!0,type:String,converter:ye,reflect:!1,useDefault:!1,hasChanged:Ft};Symbol.metadata??=Symbol("metadata"),pe.litPropertyMetadata??=new WeakMap;let B=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=We){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(e,s,t);i!==void 0&&us(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){const{get:i,set:r}=fs(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:i,set(o){const a=i?.call(this);r?.call(this,o),this.requestUpdate(e,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??We}static _$Ei(){if(this.hasOwnProperty(Q("elementProperties")))return;const e=ms(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Q("properties"))){const t=this.properties,s=[...gs(t),...bs(t)];for(const i of s)this.createProperty(i,t[i])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[s,i]of t)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);i!==void 0&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const i of s)t.unshift(Ve(i))}else e!==void 0&&t.push(Ve(e));return t}static _$Eu(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return hs(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){const s=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,s);if(i!==void 0&&s.reflect===!0){const r=(s.converter?.toAttribute!==void 0?s.converter:ye).toAttribute(t,s.type);this._$Em=e,r==null?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(e,t){const s=this.constructor,i=s._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const r=s.getPropertyOptions(i),o=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:ye;this._$Em=i;const a=o.fromAttribute(t,r.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(e,t,s,i=!1,r){if(e!==void 0){const o=this.constructor;if(i===!1&&(r=this[e]),s??=o.getPropertyOptions(e),!((s.hasChanged??Ft)(r,t)||s.useDefault&&s.reflect&&r===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:i,wrapped:r},o){s&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),r!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),i===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,r]of this._$Ep)this[i]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,r]of s){const{wrapped:o}=r,a=this[i];o!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,r,a)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};B.elementStyles=[],B.shadowRootOptions={mode:"open"},B[Q("elementProperties")]=new Map,B[Q("finalized")]=new Map,xs?.({ReactiveElement:B}),(pe.reactiveElementVersions??=[]).push("2.1.2");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const Ee=globalThis,Ze=n=>n,le=Ee.trustedTypes,Je=le?le.createPolicy("lit-html",{createHTML:n=>n}):void 0,Ot="$lit$",z=`lit$${Math.random().toFixed(9).slice(2)}$`,Dt="?"+z,ys=`<${Dt}>`,O=document,X=()=>O.createComment(""),ee=n=>n===null||typeof n!="object"&&typeof n!="function",Re=Array.isArray,ks=n=>Re(n)||typeof n?.[Symbol.iterator]=="function",be=`[
14
+ \f\r]`,Z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ye=/-->/g,Qe=/>/g,P=RegExp(`>|${be}(?:([^\\s"'>=/]+)(${be}*=${be}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Xe=/'/g,et=/"/g,Mt=/^(?:script|style|textarea|title)$/i,ws=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),l=ws(1),D=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),tt=new WeakMap,L=O.createTreeWalker(O,129);function Nt(n,e){if(!Re(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Je!==void 0?Je.createHTML(e):e}const $s=(n,e)=>{const t=n.length-1,s=[];let i,r=e===2?"<svg>":e===3?"<math>":"",o=Z;for(let a=0;a<t;a++){const c=n[a];let d,u,p=-1,g=0;for(;g<c.length&&(o.lastIndex=g,u=o.exec(c),u!==null);)g=o.lastIndex,o===Z?u[1]==="!--"?o=Ye:u[1]!==void 0?o=Qe:u[2]!==void 0?(Mt.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=P):u[3]!==void 0&&(o=P):o===P?u[0]===">"?(o=i??Z,p=-1):u[1]===void 0?p=-2:(p=o.lastIndex-u[2].length,d=u[1],o=u[3]===void 0?P:u[3]==='"'?et:Xe):o===et||o===Xe?o=P:o===Ye||o===Qe?o=Z:(o=P,i=void 0);const x=o===P&&n[a+1].startsWith("/>")?" ":"";r+=o===Z?c+ys:p>=0?(s.push(d),c.slice(0,p)+Ot+c.slice(p)+z+x):c+z+(p===-2?a:x)}return[Nt(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};let ke=class Ut{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let r=0,o=0;const a=e.length-1,c=this.parts,[d,u]=$s(e,t);if(this.el=Ut.createElement(d,s),L.currentNode=this.el.content,t===2||t===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=L.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(Ot)){const g=u[o++],x=i.getAttribute(p).split(z),m=/([.?@])?(.*)/.exec(g);c.push({type:1,index:r,name:m[2],strings:x,ctor:m[1]==="."?Ss:m[1]==="?"?Cs:m[1]==="@"?Ts:ue}),i.removeAttribute(p)}else p.startsWith(z)&&(c.push({type:6,index:r}),i.removeAttribute(p));if(Mt.test(i.tagName)){const p=i.textContent.split(z),g=p.length-1;if(g>0){i.textContent=le?le.emptyScript:"";for(let x=0;x<g;x++)i.append(p[x],X()),L.nextNode(),c.push({type:2,index:++r});i.append(p[g],X())}}}else if(i.nodeType===8)if(i.data===Dt)c.push({type:2,index:r});else{let p=-1;for(;(p=i.data.indexOf(z,p+1))!==-1;)c.push({type:7,index:r}),p+=z.length-1}r++}}static createElement(e,t){const s=O.createElement("template");return s.innerHTML=e,s}};function K(n,e,t=n,s){if(e===D)return e;let i=s!==void 0?t._$Co?.[s]:t._$Cl;const r=ee(e)?void 0:e._$litDirective$;return i?.constructor!==r&&(i?._$AO?.(!1),r===void 0?i=void 0:(i=new r(n),i._$AT(n,t,s)),s!==void 0?(t._$Co??=[])[s]=i:t._$Cl=i),i!==void 0&&(e=K(n,i._$AS(n,e.values),i,s)),e}let _s=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:s}=this._$AD,i=(e?.creationScope??O).importNode(t,!0);L.currentNode=i;let r=L.nextNode(),o=0,a=0,c=s[0];for(;c!==void 0;){if(o===c.index){let d;c.type===2?d=new ze(r,r.nextSibling,this,e):c.type===1?d=new c.ctor(r,c.name,c.strings,this,e):c.type===6&&(d=new As(r,this,e)),this._$AV.push(d),c=s[++a]}o!==c?.index&&(r=L.nextNode(),o++)}return L.currentNode=O,i}p(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}},ze=class jt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,s,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=K(this,e,t),ee(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==D&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ks(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&ee(this._$AH)?this._$AA.nextSibling.data=e:this.T(O.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:s}=e,i=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=ke.createElement(Nt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(t);else{const r=new _s(i,this),o=r.u(this.options);r.p(t),this.T(o),this._$AH=r}}_$AC(e){let t=tt.get(e.strings);return t===void 0&&tt.set(e.strings,t=new ke(e)),t}k(e){Re(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const r of e)i===t.length?t.push(s=new jt(this.O(X()),this.O(X()),this,this.options)):s=t[i],s._$AI(r),i++;i<t.length&&(this._$AR(s&&s._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const s=Ze(e).nextSibling;Ze(e).remove(),e=s}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ue=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,i,r){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=f}_$AI(e,t=this,s,i){const r=this.strings;let o=!1;if(r===void 0)e=K(this,e,t,0),o=!ee(e)||e!==this._$AH&&e!==D,o&&(this._$AH=e);else{const a=e;let c,d;for(e=r[0],c=0;c<r.length-1;c++)d=K(this,a[s+c],t,c),d===D&&(d=this._$AH[c]),o||=!ee(d)||d!==this._$AH[c],d===f?e=f:e!==f&&(e+=(d??"")+r[c+1]),this._$AH[c]=d}o&&!i&&this.j(e)}j(e){e===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Ss=class extends ue{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===f?void 0:e}},Cs=class extends ue{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==f)}},Ts=class extends ue{constructor(e,t,s,i,r){super(e,t,s,i,r),this.type=5}_$AI(e,t=this){if((e=K(this,e,t,0)??f)===D)return;const s=this._$AH,i=e===f&&s!==f||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==f&&(s===f||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},As=class{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){K(this,e)}};const Es=Ee.litHtmlPolyfillSupport;Es?.(ke,ze),(Ee.litHtmlVersions??=[]).push("3.3.3");const Rs=(n,e,t)=>{const s=t?.renderBefore??e;let i=s._$litPart$;if(i===void 0){const r=t?.renderBefore??null;s._$litPart$=i=new ze(e.insertBefore(X(),r),r,void 0,t??{})}return i._$AI(n),i};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */const Pe=globalThis;let k=class extends B{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Rs(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return D}};k._$litElement$=!0,k.finalized=!0,Pe.litElementHydrateSupport?.({LitElement:k});const zs=Pe.litElementPolyfillSupport;zs?.({LitElement:k});(Pe.litElementVersions??=[]).push("4.2.2");var qt;let me=0;const st=new Set;function Ps(n){me++;try{n()}finally{me--,me===0&&Is()}}function Is(){const n=new Set(st);st.clear();for(const e of n)e()}function Ls(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fs(n){return n&&typeof n.deref=="function"}class Ie{static#e=0;#t;#s;#n=new Set;#r=qt.#e++;name;constructor(e,t){this.#t=e,this.#s=e,this.name=t}_get(){return h.activeConsumer&&h.activeConsumer.track(this),this.#t}_set(e){return Ls(e,this.#t)?(this.#s=this.#t,this.#t=e,this._notify(),!0):!1}subscribe(e,t=!1){let s=e;return t&&(s=new WeakRef(e)),this.#n.add(s),()=>this.#n.delete(s)}_notify(){const e=[...this.#n];for(const t of e){let s;if(Fs(t)){if(s=t.deref(),!s){this.#n.delete(t);continue}}else s=t;s()}}get id(){return this.#r}get previousValue(){return this.#s}toString(){return this.name?`${this.constructor.name}(${this.name})`:`${this.constructor.name}#${this.id}`}}qt=Ie;class h extends Ie{static#e=[];constructor(e,t){super(e,t)}static get activeConsumer(){return this.#e[this.#e.length-1]}static push(e){this.#e.push(e)}static pop(){this.#e.pop()}get(){return this._get()}set(e){Ps(()=>{this._set(e)})}get value(){return this.get()}set value(e){this.set(e)}update(e){this.set(e(this.get()))}}class it extends Ie{#e;#t=!0;#s=!1;#n=new Map;_debugParent;#r;#u=()=>{this.#t||(this.#t=!0,this._notify())};constructor(e,t,s){super(void 0,t),this.#e=e,this.#r=s?.weak??!0}track(e){if(this.#n.has(e))return;const t=e.subscribe(this.#u,this.#r);this.#n.set(e,t)}dispose(){this.#a()}#a(){for(const e of this.#n.values())e();this.#n.clear()}get(){if(h.activeConsumer&&h.activeConsumer.track(this),!this.#t)return this._get();if(this.#s)throw new Error(`Cycle detected in ${this}
20
+ ↳ while computing ${this._debugParent??"root"}`);this.#s=!0,this.#a(),h.push(this);try{const e=this.#e();this._set(e)}finally{h.pop(),this.#t=!1,this.#s=!1}return this._get()}get value(){return this.get()}set value(e){throw new Error(`Cannot set value of Computed ${this}. Computed values are read-only.`)}subscribe(e,t=!1){const s=super.subscribe(e,t);return h.activeConsumer||this.get(),s}}class N{#e;#t=new Map;_debugParent;constructor(e){this.#e=e,e.addController(this);const t=e,s=t.update,i=this;t.update=function(r){h.push(i);try{s.call(this,r)}finally{h.pop()}}}track(e){this.#t.has(e)||this.#t.set(e,e.subscribe(this.#s,!0))}#s=()=>{this.#e.requestUpdate()};hostUpdate(){for(const e of this.#t.values())e();this.#t.clear()}hostDisconnected(){for(const e of this.#t.values())e();this.#t.clear()}toString(){const e=this.#e;return`SignalWatcher(${e?.localName??e?.tagName??e?.constructor?.name??"unknown"})`}}const Os=new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"});function Ds(n){if(!n)return"unknown age";const e=new Date(n);return Number.isNaN(e.getTime())?"unknown age":Os.format(e)}function Ms(n){const e=[],t=new Map,s=[];for(const r of n){const o=r._table==="memory_docs"?r.key:r.group;if(!o){s.push(r);continue}t.has(o)||(t.set(o,[]),e.push(o)),t.get(o).push(r)}const i=e.map(r=>({label:r,icon:t.get(r)[0]._table==="memory_docs"?"🔑":"📂",items:t.get(r)}));return s.length>0&&i.push({label:null,icon:s[0]._table==="memory_docs"?"🔑":"📂",items:s}),i}class Ns extends k{static{this.properties={results:{attribute:!1},showFolder:{attribute:!1},onSelect:{attribute:!1},selectedIds:{attribute:!1},onToggleSelect:{attribute:!1},onKeyClick:{attribute:!1},onGroupClick:{attribute:!1}}}static{this.styles=$`
21
+ :host { display: block; }
22
+ .count-header {
23
+ padding: 8px 14px;
24
+ font-size: 11px;
25
+ font-weight: 600;
26
+ text-transform: uppercase;
27
+ opacity: 0.6;
28
+ background: var(--bg);
29
+ border-bottom: 1px solid var(--border);
30
+ }
31
+ .key-group-header {
32
+ padding: 6px 14px;
33
+ font-size: 11px;
34
+ font-weight: 700;
35
+ opacity: 0.7;
36
+ background: var(--bg-subtle);
37
+ border-bottom: 1px solid var(--border);
38
+ display: flex;
39
+ align-items: center;
40
+ gap: 6px;
41
+ }
42
+ .key-group-count { opacity: 0.6; font-weight: 400; }
43
+ .key-group-link {
44
+ background: none; border: none; padding: 0; margin: 0; font: inherit; font-weight: 700;
45
+ color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
46
+ }
47
+ .key-group-link:hover { opacity: 0.8; }
48
+ .row { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 8px; }
49
+ .row:hover { background: var(--hover); }
50
+ .row.deprecated { opacity: 0.55; }
51
+ .row.paused { opacity: 0.6; }
52
+ .row-checkbox { flex: 0 0 auto; margin-top: 2px; cursor: pointer; }
53
+ .row-body { flex: 1 1 auto; min-width: 0; }
54
+ .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
55
+ .name { font-weight: 600; }
56
+ .deprecated .name { text-decoration: line-through; }
57
+ .meta { opacity: 0.65; font-size: 11px; white-space: nowrap; }
58
+ .folder-path { font-size: 10.5px; opacity: 0.55; margin-top: 1px; }
59
+ .key-line { font-size: 10.5px; opacity: 0.6; margin-top: 1px; }
60
+ .desc { font-size: 12px; opacity: 0.8; margin-top: 3px; }
61
+ .tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
62
+ .tag { font-size: 10px; border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 6px; }
63
+ .type-badge {
64
+ font-size: 10px; text-transform: uppercase; font-weight: 700; flex: 0 0 auto;
65
+ border-radius: 4px; padding: 1px 5px; display: inline-flex; align-items: center; gap: 3px;
66
+ }
67
+ .type-badge.skill {
68
+ border: 1px solid var(--purple); color: var(--purple-fg); background: var(--purple-tint);
69
+ }
70
+ .type-badge.memory {
71
+ border: 1px solid var(--accent); color: var(--accent); background: var(--accent-tint);
72
+ }
73
+ .deprecated-badge {
74
+ font-size: 10px; text-transform: uppercase; border: 1px solid var(--danger);
75
+ color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); border-radius: 4px; padding: 0 4px;
76
+ }
77
+ .paused-badge {
78
+ font-size: 10px; text-transform: uppercase; border: 1px solid var(--accent);
79
+ color: var(--accent); background: var(--accent-tint); border-radius: 4px; padding: 0 4px;
80
+ }
81
+ .empty { padding: 24px; opacity: 0.6; font-size: 13px; }
82
+ `}render(){return!this.results||this.results.length===0?l`<div class="empty">No results.</div>`:l`
83
+ <div class="count-header">${this.results.length} result${this.results.length===1?"":"s"}</div>
84
+ ${Ms(this.results).map(e=>l`
85
+ ${e.label?l`<div class="key-group-header">
86
+ ${e.icon}
87
+ <button
88
+ class="key-group-link"
89
+ title=${e.icon==="🔑"?"Search for this key":"Search for this group"}
90
+ @click=${()=>e.icon==="🔑"?this.onKeyClick?.(e.label):this.onGroupClick?.(e.label)}
91
+ >
92
+ ${e.label}
93
+ </button>
94
+ <span class="key-group-count">(${e.items.length})</span>
95
+ </div>`:e.items.length>0&&e.icon==="📂"?l`<div class="key-group-header">
96
+ 📂 <span>Ungrouped</span> <span class="key-group-count">(${e.items.length})</span>
97
+ </div>`:""}
98
+ ${e.items.map(t=>this.#e(t))}
99
+ `)}
100
+ `}#e(e){const t=e._table==="skills"&&e.folder==="builtin";return l`
101
+ <div class="row ${e.deprecated?"deprecated":""} ${e.paused?"paused":""}" @click=${()=>this.onSelect(e)}>
102
+ <input
103
+ type="checkbox"
104
+ class="row-checkbox"
105
+ .checked=${this.selectedIds?.has(e.id)??!1}
106
+ .disabled=${t}
107
+ title=${t?"Builtin skills can't be bulk-deprecated, paused, or deleted":""}
108
+ @click=${s=>{s.stopPropagation(),t||this.onToggleSelect(e)}}
109
+ />
110
+ <div class="row-body">
111
+ <div class="top">
112
+ <span class="name">
113
+ <span class="type-badge ${e._table==="skills"?"skill":"memory"}"
114
+ >${e._table==="skills"?"⚡ skill":"📝 memory"}</span
115
+ >
116
+ ${e.name}
117
+ </span>
118
+ <span class="meta">${Ds(e.created_at)} · ${e.owner??"—"} · ${e.status}</span>
119
+ </div>
120
+ ${e._table==="memory_docs"&&e.key?l`<div class="key-line">🔑 ${e.key}</div>`:""}
121
+ ${e._table==="skills"&&e.group?l`<div class="key-line">
122
+ 📂
123
+ <button
124
+ class="key-group-link"
125
+ title="Search for this group"
126
+ @click=${s=>{s.stopPropagation(),this.onGroupClick?.(e.group)}}
127
+ >
128
+ ${e.group}
129
+ </button>
130
+ </div>`:""}
131
+ ${this.showFolder&&e.folder?l`<div class="folder-path">📁 ${e.folder}</div>`:""}
132
+ <div class="desc">${e.description}</div>
133
+ <div class="tags">
134
+ ${e.deprecated?l`<span class="deprecated-badge">deprecated</span>`:""}
135
+ ${e.paused?l`<span class="paused-badge">paused</span>`:""}
136
+ ${e.tags.map(s=>l`<span class="tag">${s}</span>`)}
137
+ </div>
138
+ </div>
139
+ </div>
140
+ `}}customElements.define("result-list",Ns);function Le(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var U=Le();function Bt(n){U=n}var I={exec:()=>null};function j(n){let e=[];return t=>{let s=Math.max(0,Math.min(3,t-1)),i=e[s];return i||(i=n(s),e[s]=i),i}}function b(n,e=""){let t=typeof n=="string"?n:n.source,s={replace:(i,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(w.caret,"$1"),t=t.replace(i,o),s},getRegex:()=>new RegExp(t,e)};return s}var Us=((n="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+n)}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:j(n=>new RegExp(`^ {0,${n}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:j(n=>new RegExp(`^ {0,${n}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:j(n=>new RegExp(`^ {0,${n}}(?:\`\`\`|~~~)`)),headingBeginRegex:j(n=>new RegExp(`^ {0,${n}}#`)),htmlBeginRegex:j(n=>new RegExp(`^ {0,${n}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:j(n=>new RegExp(`^ {0,${n}}>`))},js=/^(?:[ \t]*(?:\n|$))+/,qs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Bs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,te=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Hs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Fe=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kt=b(Ht).replace(/bull/g,Fe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ks=b(Ht).replace(/bull/g,Fe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Oe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Vs=/^[^\n]+/,De=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Gs=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",De).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ws=b(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Fe).getRegex(),fe="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Me=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Zs=b("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Me).replace("tag",fe).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vt=n=>b(Oe).replace("hr",te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",n).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe).getRegex(),Js=Vt(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Ys=Vt(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Qs=b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ys).getRegex(),Ne={blockquote:Qs,code:qs,def:Gs,fences:Bs,heading:Hs,hr:te,html:Zs,lheading:Kt,list:Ws,newline:js,paragraph:Js,table:I,text:Vs},rt=b("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe).getRegex(),Xs={...Ne,lheading:Ks,table:rt,paragraph:b(Oe).replace("hr",te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe).getRegex()},ei={...Ne,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Me).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(Oe).replace("hr",te).replace("heading",` *#{1,6} *[^
141
+ ]`).replace("lheading",Kt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ti=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,si=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gt=/^( {2,}|\\)\n(?!\s*$)/,ii=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,E=/[\p{P}\p{S}]/u,V=/[\s\p{P}\p{S}]/u,se=/[^\s\p{P}\p{S}]/u,ri=b(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,V).getRegex(),ni=/[\p{Pi}\p{Ps}"']/u,Wt=/(?!~)[\p{P}\p{S}]/u,oi=/(?!~)[\s\p{P}\p{S}]/u,ai=/(?:[^\s\p{P}\p{S}]|~)/u,li=b(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Us?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Zt=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ci=b(Zt,"u").replace(/punct/g,E).getRegex(),di=b(Zt,"u").replace(/punct/g,Wt).getRegex(),hi=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,pi=b(hi,"u").replace(/openQuote/g,ni).replace(/punct/g,E).getRegex(),Jt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ui=b(Jt,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,V).replace(/punct/g,E).getRegex(),fi=b(Jt,"gu").replace(/notPunctSpace/g,ai).replace(/punctSpace/g,oi).replace(/punct/g,Wt).getRegex(),gi="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",bi=b(gi,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,V).replace(/punct/g,E).getRegex(),mi=b("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,V).replace(/punct/g,E).getRegex(),vi="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",xi=b(vi,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,V).replace(/punct/g,E).getRegex(),yi=b(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,E).getRegex(),ki="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",wi=b(ki,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,V).replace(/punct/g,E).getRegex(),$i=b(/\\(punct)/,"gu").replace(/punct/g,E).getRegex(),_i=b(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Si=b(Me).replace("(?:-->|$)","-->").getRegex(),Ci=b("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Si).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ce=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Ti=b(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ce).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yt=b(/^!?\[(label)\]\[(ref)\]/).replace("label",ce).replace("ref",De).getRegex(),Qt=b(/^!?\[(ref)\](?:\[\])?/).replace("ref",De).getRegex(),Ai=b("reflink|nolink(?!\\()","g").replace("reflink",Yt).replace("nolink",Qt).getRegex(),nt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ue={_backpedal:I,anyPunctuation:$i,autolink:_i,blockSkip:li,br:Gt,code:si,del:I,delLDelim:I,delRDelim:I,emStrongLDelim:ci,emStrongRDelimAst:ui,emStrongRDelimUnd:mi,escape:ti,link:Ti,nolink:Qt,punctuation:ri,reflink:Yt,reflinkSearch:Ai,tag:Ci,text:ii,url:I},Ei={...Ue,emStrongLDelim:pi,emStrongRDelimAst:bi,emStrongRDelimUnd:xi,link:b(/^!?\[(label)\]\((.*?)\)/).replace("label",ce).getRegex(),reflink:b(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce).getRegex()},we={...Ue,emStrongRDelimAst:fi,emStrongLDelim:di,delLDelim:yi,delRDelim:wi,url:b(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:b(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",nt).getRegex()},Ri={...we,br:b(Gt).replace("{2,}","*").getRegex(),text:b(we.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ie={normal:Ne,gfm:Xs,pedantic:ei},J={normal:Ue,gfm:we,breaks:Ri,pedantic:Ei},zi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ot=n=>zi[n];function A(n,e){if(e){if(w.escapeTest.test(n))return n.replace(w.escapeReplace,ot)}else if(w.escapeTestNoEncode.test(n))return n.replace(w.escapeReplaceNoEncode,ot);return n}function at(n){try{n=encodeURI(n).replace(w.percentDecode,"%")}catch{return null}return n}function lt(n,e){let t=n.replace(w.findPipe,(r,o,a)=>{let c=!1,d=o;for(;--d>=0&&a[d]==="\\";)c=!c;return c?"|":" |"}),s=t.split(w.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(w.slashPipe,"|");return s}function R(n,e,t){let s=n.length;if(s===0)return"";let i=0;for(;i<s&&n.charAt(s-i-1)===e;)i++;return n.slice(0,s-i)}function ct(n){let e=n.split(`
142
+ `),t=e.length-1;for(;t>=0&&w.blankLine.test(e[t]);)t--;return e.length-t<=2?n:e.slice(0,t+1).join(`
143
+ `)}function Pi(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function Ii(n,e=0){let t=e,s="";for(let i of n)if(i===" "){let r=4-t%4;s+=" ".repeat(r),t+=r}else s+=i,t++;return s}function dt(n,e,t,s,i){let r=e.href,o=e.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1"),c=n[0].charAt(0)==="!";s.state.inLink=!0;let d=s.state.linkEmitted,u=s.state.inRawBlock;s.state.linkEmitted=!1;let p=s.inlineTokens(a),g=s.state.linkEmitted;if(s.state.linkEmitted=d,s.state.inLink=!1,!c){if(g){s.state.inRawBlock=u;return}s.state.linkEmitted=!0}return{type:c?"image":"link",raw:t,href:r,title:o,text:a,tokens:p}}function Li(n,e,t){let s=n.match(t.other.indentCodeCompensation);if(s===null)return e;let i=s[1];return e.split(`
144
+ `).map(r=>{let o=r.match(t.other.beginningSpace);if(o===null)return r;let[a]=o;return a.length>=i.length?r.slice(i.length):r}).join(`
145
+ `)}var de=class{options;rules;lexer;constructor(n){this.options=n||U}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=this.options.pedantic?e[0]:ct(e[0]),s=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:s}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],s=Li(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=R(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:R(e[0],`
146
+ `),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:R(e[0],`
147
+ `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=R(e[0],`
148
+ `).split(`
149
+ `),s="",i="",r=[];for(;t.length>0;){let o=!1,a=[],c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),o=!0;else if(!o)a.push(t[c]);else break;t=t.slice(c);let d=a.join(`
150
+ `),u=d.replace(this.rules.other.blockquoteSetextReplace,`
151
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
152
+ ${d}`:d,i=i?`${i}
153
+ ${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,r,!0),this.lexer.state.top=p,t.length===0)break;let g=r.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let x=g,m=t.join(`
154
+ `),T=x.raw+`
155
+ `+m.replace(this.rules.other.blockquoteSetextReplace2,""),G=this.blockquote(T);r[r.length-1]=G,s=`${s}
156
+ ${m}`,i=i.substring(0,i.length-x.text.length)+G.text;break}else if(g?.type==="list"){let x=g,m=x.raw+`
157
+ `+t.join(`
158
+ `),T=this.list(m);r[r.length-1]=T,s=s.substring(0,s.length-g.raw.length)+T.raw,i=i.substring(0,i.length-x.raw.length)+T.raw,t=m.substring(r.at(-1).raw.length).split(`
159
+ `);continue}}return{type:"blockquote",raw:s,tokens:r,text:i}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim(),s=t.length>1,i={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let r=this.rules.other.listItemRegex(t),o=!1;for(;n;){let c=!1,d="",u="";if(!(e=r.exec(n))||this.rules.block.hr.test(n))break;d=e[0],n=n.substring(d.length);let p=Ii(e[2].split(`
160
+ `,1)[0],e[1].length),g=n.split(`
161
+ `,1)[0],x=!p.trim(),m=0;if(this.options.pedantic?(m=2,u=p.trimStart()):x?m=e[1].length+1:(m=p.search(this.rules.other.nonSpaceChar),m=m>4?1:m,u=p.slice(m),m+=e[1].length),x&&this.rules.other.blankLine.test(g)&&(d+=g+`
162
+ `,n=n.substring(g.length+1),c=!0),!c){let T=this.rules.other.nextBulletRegex(m),G=this.rules.other.hrRegex(m),qe=this.rules.other.fencesBeginRegex(m),Be=this.rules.other.headingBeginRegex(m),os=this.rules.other.htmlBeginRegex(m),as=this.rules.other.blockquoteBeginRegex(m);for(;n;){let ge=n.split(`
163
+ `,1)[0],W;if(g=ge,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),W=g):W=g.replace(this.rules.other.tabCharGlobal," "),qe.test(g)||Be.test(g)||os.test(g)||as.test(g)||T.test(g)||G.test(g))break;if(W.search(this.rules.other.nonSpaceChar)>=m||!g.trim())u+=`
164
+ `+W.slice(m);else{if(x||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||qe.test(p)||Be.test(p)||G.test(p))break;u+=`
165
+ `+g}x=!g.trim(),d+=ge+`
166
+ `,n=n.substring(ge.length+1),p=W.slice(m)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(o=!0)),i.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=d}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let c of i.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!i.loose){let d=c.tokens.filter(p=>p.type==="space"),u=d.length>0&&d.some(p=>this.rules.other.anyLine.test(p.raw));i.loose=u}for(let c of i.items){let d=c.tokens[0];if(c.task&&(d?.type==="text"||d?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),d.raw=d.raw.replace(this.rules.other.listReplaceTask,""),d.text=d.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(c.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};c.checked=p.checked,i.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=p.raw+c.tokens[0].raw,c.tokens[0].text=p.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(p)):c.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):c.tokens.unshift(p)}}else c.task&&(c.task=!1)}if(i.loose)for(let c of i.items){c.loose=!0;for(let d of c.tokens)d.type==="text"&&(d.type="paragraph")}return i}}html(n){let e=this.rules.block.html.exec(n);if(e){let t=ct(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:R(e[0],`
167
+ `),href:s,title:i}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=lt(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
168
+ `):[],r={type:"table",raw:R(e[0],`
169
+ `),header:[],align:[],rows:[]};if(t.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?r.align.push("right"):this.rules.other.tableAlignCenter.test(o)?r.align.push("center"):this.rules.other.tableAlignLeft.test(o)?r.align.push("left"):r.align.push(null);for(let o=0;o<t.length;o++)r.header.push({text:t[o],tokens:this.lexer.inline(t[o]),header:!0,align:r.align[o]});for(let o of i)r.rows.push(lt(o,r.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[c]})));return r}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:R(e[0],`
170
+ `),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
171
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let r=R(t.slice(0,-1),"\\");if((t.length-r.length)%2===0)return}else{let r=Pi(e[2],"()");if(r===-2)return;if(r>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let s=e[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),dt(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[s.toLowerCase()];if(!i){let r=t[0].charAt(0);return{type:"text",raw:r,text:r}}return dt(t,i,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!t||this.rules.inline.punctuation.exec(t))){let i=[...s[0]].length-1,r,o,a=i,c=0,d=s[0][0],u=t===d,p=d==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*n.length+i);(s=p.exec(e))!==null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(o=[...r].length,s[3]||s[4]){a+=o;continue}else if(s[5]||s[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let g=[...s[0]][0].length,x=n.slice(0,i+s.index+g+o);if(Math.min(i,o)%2){let T=x.slice(1,-1);return{type:"em",raw:x,text:T,tokens:this.lexer.inlineTokens(T)}}let m=x.slice(2,-2);return{type:"strong",raw:x,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),i=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&i&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let s=this.rules.inline.delLDelim.exec(n);if(s&&(!s[1]||!t||this.rules.inline.punctuation.exec(t))){let i=[...s[0]].length-1,r,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*n.length+i);(s=c.exec(e))!==null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r||(o=[...r].length,o!==i))continue;if(s[3]||s[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let d=[...s[0]][0].length,u=n.slice(0,i+s.index+d+o),p=u.slice(i,-i);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},S=class $e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||U,this.options.tokenizer=this.options.tokenizer||new de,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:w,block:ie.normal,inline:J.normal};this.options.pedantic?(t.block=ie.pedantic,t.inline=J.pedantic):this.options.gfm&&(t.block=ie.gfm,this.options.breaks?t.inline=J.breaks:t.inline=J.gfm),this.tokenizer.rules=t}static get rules(){return{block:ie,inline:J}}static lex(e,t){return new $e(t).lex(e)}static lexInline(e,t){return new $e(t).inlineTokens(e)}lex(e){e=e.replace(w.carriageReturn,`
172
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(w.tabCharGlobal," ").replace(w.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let r;if(this.options.extensions?.block?.some(a=>(r=a.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let a=t.at(-1);r.raw.length===1&&a!==void 0?a.raw+=`
173
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
174
+ `)?"":`
175
+ `)+r.raw,a.text+=`
176
+ `+r.text,this.inlineQueue.at(-1).src=a.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
177
+ `)?"":`
178
+ `)+r.raw,a.text+=`
179
+ `+r.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),d;this.options.extensions.startBlock.forEach(u=>{d=u.call({lexer:this},c),typeof d=="number"&&d>=0&&(a=Math.min(a,d))}),a<1/0&&a>=0&&(o=e.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(o))){let a=t.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
180
+ `)?"":`
181
+ `)+r.raw,a.text+=`
182
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),s=o.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
183
+ `)?"":`
184
+ `)+r.raw,a.text+=`
185
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes("["))return!1;let t=this.tokenizer.rules.inline.link;for(let s of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(s[0])&&e.charAt(s.index-1)!=="!")return!0;for(let s of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let i=s[0],r=i.lastIndexOf("[");if(!(i.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,i.slice(r+1,-1)))&&!(r>1&&this.linkInText(i.slice(1,r-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let s=e;if(this.tokens.links&&e.includes("[")){let a=this.tokenizer.rules.inline.reflinkSearch,c=d=>{let u=d.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,d.slice(u+1,-1)))return d;if(u>1&&d.charAt(0)!=="!"){let p=d.slice(1,u-1);if(this.linkInText(p))return"["+p.replace(a,c)+"]["+"a".repeat(d.length-u-2)+"]"}return"["+"a".repeat(d.length-2)+"]"};s=s.replace(a,c)}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,a=>"+".repeat(a.length)),s=s.replace(this.tokenizer.rules.inline.blockSkip,(a,c,d)=>{let u=d?d.length:0;return a.slice(0,u)+"["+"a".repeat(a.length-u-2)+"]"}),s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let i=!1,r="",o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(r=""),i=!1;let a;if(this.options.extensions?.inline?.some(d=>(a=d.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let d=t.at(-1);a.type==="text"&&d?.type==="text"?(d.raw+=a.raw,d.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,s,r)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e,s,r)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if(this.options.extensions?.startInline){let d=1/0,u=e.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},u),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(c=e.substring(0,d+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(r=a.raw.slice(-1)),i=!0;let d=t.at(-1);d?.type==="text"?(d.raw+=a.raw,d.text+=a.text):t.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},he=class{options;parser;constructor(n){this.options=n||U}space(n){return""}code({text:n,lang:e,escaped:t}){let s=(e||"").match(w.notSpaceStart)?.[0],i=n.replace(w.endingNewline,"")+`
186
+ `;return s?'<pre><code class="language-'+A(s)+'">'+(t?i:A(i,!0))+`</code></pre>
187
+ `:"<pre><code>"+(t?i:A(i,!0))+`</code></pre>
188
+ `}blockquote({tokens:n}){return`<blockquote>
189
+ ${this.parser.parse(n)}</blockquote>
190
+ `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
191
+ `}hr(n){return`<hr>
192
+ `}list(n){let e=n.ordered,t=n.start,s="";for(let o=0;o<n.items.length;o++){let a=n.items[o];s+=this.listitem(a)}let i=e?"ol":"ul",r=e&&t!==1?' start="'+t+'"':"";return"<"+i+r+`>
193
+ `+s+"</"+i+`>
194
+ `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
195
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
196
+ `}table(n){let e="",t="";for(let i=0;i<n.header.length;i++)t+=this.tablecell(n.header[i]);e+=this.tablerow({text:t});let s="";for(let i=0;i<n.rows.length;i++){let r=n.rows[i];t="";for(let o=0;o<r.length;o++)t+=this.tablecell(r[o]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
197
+ <thead>
198
+ `+e+`</thead>
199
+ `+s+`</table>
200
+ `}tablerow({text:n}){return`<tr>
201
+ ${n}</tr>
202
+ `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
203
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${A(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let s=this.parser.parseInline(t),i=at(n);if(i===null)return s;n=i;let r='<a href="'+n+'"';return e&&(r+=' title="'+A(e)+'"'),r+=">"+s+"</a>",r}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let i=at(n);if(i===null)return A(t);n=i;let r=`<img src="${n}" alt="${A(t)}"`;return e&&(r+=` title="${A(e)}"`),r+=">",r}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:A(n.text)}},je=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},C=class _e{options;renderer;textRenderer;constructor(e){this.options=e||U,this.options.renderer=this.options.renderer||new he,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new je}static parse(e,t){return new _e(t).parse(e)}static parseInline(e,t){return new _e(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){t+=a||"";continue}}let r=i;switch(r.type){case"space":{t+=this.renderer.space(r);break}case"hr":{t+=this.renderer.hr(r);break}case"heading":{t+=this.renderer.heading(r);break}case"code":{t+=this.renderer.code(r);break}case"table":{t+=this.renderer.table(r);break}case"blockquote":{t+=this.renderer.blockquote(r);break}case"list":{t+=this.renderer.list(r);break}case"checkbox":{t+=this.renderer.checkbox(r);break}case"html":{t+=this.renderer.html(r);break}case"def":{t+=this.renderer.def(r);break}case"paragraph":{t+=this.renderer.paragraph(r);break}case"text":{t+=this.renderer.text(r);break}default:{let o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let s="";for(let i=0;i<e.length;i++){let r=e[i];if(this.options.extensions?.renderers?.[r.type]){let a=this.options.extensions.renderers[r.type].call({parser:this},r);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(r.type)){s+=a||"";continue}}let o=r;switch(o.type){case"escape":{s+=t.text(o);break}case"html":{s+=t.html(o);break}case"link":{s+=t.link(o);break}case"image":{s+=t.image(o);break}case"checkbox":{s+=t.checkbox(o);break}case"strong":{s+=t.strong(o);break}case"em":{s+=t.em(o);break}case"codespan":{s+=t.codespan(o);break}case"br":{s+=t.br(o);break}case"del":{s+=t.del(o);break}case"text":{s+=t.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},Y=class{options;block;constructor(n){this.options=n||U}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(n=this.block){return n?S.lex:S.lexInline}provideParser(n=this.block){return n?C.parse:C.parseInline}},Fi=class{defaults=Le();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=C;Renderer=he;TextRenderer=je;Lexer=S;Tokenizer=de;Hooks=Y;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let i=s;for(let r of i.header)t=t.concat(this.walkTokens(r.tokens,e));for(let r of i.rows)for(let o of r)t=t.concat(this.walkTokens(o.tokens,e));break}case"list":{let i=s;t=t.concat(this.walkTokens(i.items,e));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(r=>{let o=i[r].flat(1/0);t=t.concat(this.walkTokens(o,e))}):i.tokens&&(t=t.concat(this.walkTokens(i.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=e.renderers[i.name];r?e.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=e[i.level];r?r.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),s.extensions=e),t.renderer){let i=this.defaults.renderer||new he(this.defaults);for(let r in t.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=t.renderer[o],c=i[o];i[o]=(...d)=>{let u=a.apply(i,d);return u===!1&&(u=c.apply(i,d)),u||""}}s.renderer=i}if(t.tokenizer){let i=this.defaults.tokenizer||new de(this.defaults);for(let r in t.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=t.tokenizer[o],c=i[o];i[o]=(...d)=>{let u=a.apply(i,d);return u===!1&&(u=c.apply(i,d)),u}}s.tokenizer=i}if(t.hooks){let i=this.defaults.hooks||new Y;for(let r in t.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=t.hooks[o],c=i[o];Y.passThroughHooks.has(r)?i[o]=d=>{if(this.defaults.async&&Y.passThroughHooksRespectAsync.has(r))return(async()=>{let p=await a.call(i,d);return c.call(i,p)})();let u=a.call(i,d);return c.call(i,u)}:i[o]=(...d)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(i,d);return p===!1&&(p=await c.apply(i,d)),p})();let u=a.apply(i,d);return u===!1&&(u=c.apply(i,d)),u}}s.hooks=i}if(t.walkTokens){let i=this.defaults.walkTokens,r=t.walkTokens;s.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return S.lex(n,e??this.defaults)}parser(n,e){return C.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let s={...t},i={...this.defaults,...s},r=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer(n):n?S.lex:S.lexInline)(o,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let d=await(i.hooks?await i.hooks.provideParser(n):n?C.parse:C.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(d):d})().catch(r);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer(n):n?S.lex:S.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser(n):n?C.parse:C.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return r(o)}}}onError(n,e){return t=>{if(t.message+=`
204
+ Please report this to https://github.com/markedjs/marked.`,n){let s="<p>An error occurred:</p><pre>"+A(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},M=new Fi;function v(n,e){return M.parse(n,e)}v.options=v.setOptions=function(n){return M.setOptions(n),v.defaults=M.defaults,Bt(v.defaults),v};v.getDefaults=Le;v.defaults=U;function Oi(...n){return M.use(...n),v.defaults=M.defaults,Bt(v.defaults),v}v.use=Oi;v.walkTokens=function(n,e){return M.walkTokens(n,e)};v.parseInline=M.parseInline;v.Parser=C;v.parser=C.parse;v.Renderer=he;v.TextRenderer=je;v.Lexer=S;v.lexer=S.lex;v.Tokenizer=de;v.Hooks=Y;v.parse=v;v.options;v.setOptions;v.walkTokens;v.parseInline;C.parse;S.lex;/**
205
+ * @license
206
+ * Copyright 2017 Google LLC
207
+ * SPDX-License-Identifier: BSD-3-Clause
208
+ */const Di={CHILD:2},Mi=n=>(...e)=>({_$litDirective$:n,values:e});class Ni{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,s){this._$Ct=e,this._$AM=t,this._$Ci=s}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
209
+ * @license
210
+ * Copyright 2017 Google LLC
211
+ * SPDX-License-Identifier: BSD-3-Clause
212
+ */class Se extends Ni{constructor(e){if(super(e),this.it=f,e.type!==Di.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===f||e==null)return this._t=void 0,this.it=e;if(e===D)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Se.directiveName="unsafeHTML",Se.resultType=1;const Ui=Mi(Se);let ht=0;class ji extends k{static{this.properties={tags:{attribute:!1},active:{attribute:!1},onToggle:{attribute:!1},allowCreate:{attribute:!1},width:{attribute:!1}}}#e=new h("");#t=new h(!1);#s=new h(-1);#n;#r;static{this.styles=$`
213
+ :host {
214
+ display: inline-block;
215
+ position: relative;
216
+ width: fit-content;
217
+ min-width: 200px;
218
+ max-width: 100%;
219
+ font: inherit;
220
+ font-size: 13px;
221
+ }
222
+ .field {
223
+ display: flex;
224
+ align-items: center;
225
+ gap: 4px;
226
+ border: 1px solid var(--border-strong);
227
+ border-radius: 6px;
228
+ background: none;
229
+ padding: 3px 4px 3px 8px;
230
+ min-height: 30px;
231
+ box-sizing: border-box;
232
+ }
233
+ .chips-and-input {
234
+ display: flex;
235
+ align-items: center;
236
+ flex-wrap: wrap;
237
+ gap: 4px;
238
+ flex: 1 1 auto;
239
+ min-width: 0;
240
+ }
241
+ .field:focus-within {
242
+ border-color: var(--accent);
243
+ box-shadow: 0 0 0 2px var(--accent-tint);
244
+ }
245
+ .selected-chip {
246
+ display: inline-flex;
247
+ align-items: center;
248
+ gap: 4px;
249
+ background: var(--accent);
250
+ color: var(--accent-fg);
251
+ border-radius: 999px;
252
+ padding: 2px 6px 2px 10px;
253
+ font-size: 12px;
254
+ white-space: nowrap;
255
+ }
256
+ .selected-chip .remove {
257
+ cursor: pointer;
258
+ opacity: 0.85;
259
+ line-height: 1;
260
+ padding: 2px;
261
+ border-radius: 50%;
262
+ }
263
+ .selected-chip .remove:hover { opacity: 1; background: #ffffff33; }
264
+ .input {
265
+ flex: 1 1 60px;
266
+ min-width: 60px;
267
+ border: none;
268
+ outline: none;
269
+ padding: 5px 2px;
270
+ font: inherit;
271
+ font-size: 13px;
272
+ background: transparent;
273
+ color: inherit;
274
+ }
275
+ .clear-btn, .chevron-btn {
276
+ border: none;
277
+ background: transparent;
278
+ cursor: pointer;
279
+ color: inherit;
280
+ opacity: 0.6;
281
+ font-size: 12px;
282
+ padding: 2px 5px;
283
+ line-height: 1;
284
+ }
285
+ .clear-btn:hover, .chevron-btn:hover { opacity: 1; }
286
+ .chevron-btn { transition: transform 0.15s ease; }
287
+ .chevron-btn.open { transform: rotate(180deg); }
288
+
289
+ .menu {
290
+ position: fixed;
291
+ margin: 0;
292
+ inset: auto;
293
+ top: anchor(bottom);
294
+ left: anchor(left);
295
+ width: anchor-size(width);
296
+ position-try-fallbacks: flip-block;
297
+ list-style: none;
298
+ padding: 4px;
299
+ margin: 0;
300
+ border: 1px solid var(--border);
301
+ border-radius: 8px;
302
+ background: var(--bg);
303
+ color: inherit;
304
+ box-shadow: 0 8px 24px var(--shadow);
305
+ max-height: 260px;
306
+ overflow-y: auto;
307
+ box-sizing: border-box;
308
+ }
309
+ .menu:popover-open { margin-top: 4px; }
310
+ .menu[popover] { display: none; }
311
+ .menu.visible[popover] { display: block; }
312
+
313
+ .option {
314
+ display: flex;
315
+ align-items: center;
316
+ gap: 8px;
317
+ padding: 6px 8px;
318
+ border-radius: 5px;
319
+ cursor: pointer;
320
+ font-size: 13px;
321
+ }
322
+ .option:hover, .option.highlighted { background: var(--hover); }
323
+ .option input { margin: 0; pointer-events: none; }
324
+ .empty { padding: 6px 8px; opacity: 0.6; font-style: italic; font-size: 12px; }
325
+ .create-option { color: var(--accent); font-style: italic; }
326
+ `}constructor(){super(),new N(this),this.tags=[],this.active=[],this.onToggle=()=>{},this.allowCreate=!1,this.#n=`--tag-multiselect-${++ht}`,this.#r=`tag-multiselect-listbox-${ht}`}willUpdate(){this.style.width=this.width??""}#u=e=>{e.composedPath().includes(this)||this.#o()};connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#u)}disconnectedCallback(){document.removeEventListener("click",this.#u),super.disconnectedCallback()}get#a(){const e=this.#e.value.trim().toLowerCase();return e?this.tags.filter(t=>t.toLowerCase().includes(e)):this.tags}#i(){this.#t.set(!0),this.updateComplete.then(()=>{this.renderRoot.querySelector(".menu")?.showPopover()})}#o(){this.#t.set(!1),this.#s.set(-1),this.renderRoot.querySelector(".menu")?.hidePopover()}#d(){this.#t.value?this.#o():(this.#i(),this.renderRoot.querySelector(".input")?.focus())}#g(e){this.#e.set(e.target.value),this.#s.set(-1),this.#i()}#h(e){this.onToggle(e),this.#e.set(""),this.#s.set(-1)}get#c(){if(!this.allowCreate)return!1;const e=this.#e.value.trim();return e.length>0&&!this.tags.includes(e)&&!this.active.includes(e)}#b(e){e.stopPropagation(),this.active.forEach(t=>this.onToggle(t)),this.#e.set(""),this.renderRoot.querySelector(".input")?.focus(),this.#i()}#w(e){const t=this.#a;if(e.key==="ArrowDown")e.preventDefault(),this.#i(),t.length&&this.#s.set((this.#s.value+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),this.#i(),t.length&&this.#s.set((this.#s.value-1+t.length)%t.length);else if(e.key==="Enter"||this.allowCreate&&e.key===","){const s=t[this.#s.value];s!==void 0?(e.preventDefault(),this.#h(s)):this.#c&&(e.preventDefault(),this.#h(this.#e.value.trim()))}else if(e.key==="Backspace"&&!this.#e.value&&this.active.length>0){const s=this.active[this.active.length-1];s!==void 0&&this.onToggle(s)}else e.key==="Escape"&&this.#o()}render(){const e=this.active,t=this.#a,s=this.#t.value,i=this.#s.value;return l`
327
+ <div class="field" style=${`anchor-name: ${this.#n}`}>
328
+ <div class="chips-and-input">
329
+ ${e.map(r=>l`
330
+ <span class="selected-chip">
331
+ ${r}
332
+ <span class="remove" @click=${()=>this.onToggle(r)}>✕</span>
333
+ </span>
334
+ `)}
335
+ <input
336
+ class="input"
337
+ role="combobox"
338
+ aria-autocomplete="list"
339
+ aria-expanded=${s}
340
+ aria-controls=${this.#r}
341
+ aria-activedescendant=${i>=0?`${this.#r}-opt-${i}`:""}
342
+ placeholder=${e.length===0?"Filter by tag…":""}
343
+ .value=${this.#e.value}
344
+ @input=${r=>this.#g(r)}
345
+ @focus=${()=>this.#i()}
346
+ @click=${()=>this.#i()}
347
+ @keydown=${r=>this.#w(r)}
348
+ />
349
+ </div>
350
+ ${e.length>0?l`<button class="clear-btn" tabindex="-1" @mousedown=${r=>r.preventDefault()} @click=${r=>this.#b(r)}>✕</button>`:""}
351
+ <button
352
+ class="chevron-btn ${s?"open":""}"
353
+ tabindex="-1"
354
+ @mousedown=${r=>r.preventDefault()}
355
+ @click=${()=>this.#d()}
356
+ >
357
+
358
+ </button>
359
+ </div>
360
+
361
+ <ul
362
+ id=${this.#r}
363
+ class="menu ${s?"visible":""}"
364
+ role="listbox"
365
+ aria-multiselectable="true"
366
+ popover="manual"
367
+ style=${`position-anchor: ${this.#n}`}
368
+ >
369
+ ${t.length?t.map((r,o)=>l`
370
+ <li
371
+ id=${`${this.#r}-opt-${o}`}
372
+ role="option"
373
+ aria-selected=${e.includes(r)}
374
+ class=${o===i?"option highlighted":"option"}
375
+ @mousedown=${a=>a.preventDefault()}
376
+ @click=${()=>this.#h(r)}
377
+ >
378
+ <input type="checkbox" .checked=${e.includes(r)} tabindex="-1" />
379
+ ${r}
380
+ </li>
381
+ `):this.#c?l`
382
+ <li
383
+ class="option create-option"
384
+ @mousedown=${r=>r.preventDefault()}
385
+ @click=${()=>this.#h(this.#e.value.trim())}
386
+ >
387
+ No match. Create '${this.#e.value.trim()}'
388
+ </li>
389
+ `:l`<li class="empty">${this.allowCreate?"Type to create a tag":"No matches"}</li>`}
390
+ </ul>
391
+ `}}customElements.define("tag-multiselect",ji);let pt=0;class qi extends k{static{this.properties={options:{attribute:!1},value:{attribute:!1},onChange:{attribute:!1}}}#e=new h("");#t=new h(!1);#s=new h(-1);#n;#r;static{this.styles=$`
392
+ :host {
393
+ display: inline-block;
394
+ position: relative;
395
+ width: 100%;
396
+ max-width: 320px;
397
+ font: inherit;
398
+ font-size: 13px;
399
+ }
400
+ .field {
401
+ display: flex;
402
+ align-items: center;
403
+ gap: 4px;
404
+ border: 1px solid var(--border-strong);
405
+ border-radius: 6px;
406
+ background: var(--bg);
407
+ padding: 3px 4px 3px 8px;
408
+ min-height: 30px;
409
+ box-sizing: border-box;
410
+ }
411
+ .field:focus-within {
412
+ border-color: var(--accent);
413
+ box-shadow: 0 0 0 2px var(--accent-tint);
414
+ }
415
+ .input {
416
+ flex: 1 1 auto;
417
+ min-width: 0;
418
+ border: none;
419
+ outline: none;
420
+ padding: 5px 2px;
421
+ font: inherit;
422
+ font-size: 13px;
423
+ background: transparent;
424
+ color: inherit;
425
+ }
426
+ .chevron-btn {
427
+ border: none;
428
+ background: transparent;
429
+ cursor: pointer;
430
+ color: inherit;
431
+ opacity: 0.6;
432
+ font-size: 12px;
433
+ padding: 2px 5px;
434
+ line-height: 1;
435
+ flex: 0 0 auto;
436
+ }
437
+ .chevron-btn:hover { opacity: 1; }
438
+ .chevron-btn { transition: transform 0.15s ease; }
439
+ .chevron-btn.open { transform: rotate(180deg); }
440
+
441
+ .menu {
442
+ position: fixed;
443
+ margin: 0;
444
+ inset: auto;
445
+ top: anchor(bottom);
446
+ left: anchor(left);
447
+ width: anchor-size(width);
448
+ position-try-fallbacks: flip-block;
449
+ list-style: none;
450
+ padding: 4px;
451
+ margin: 0;
452
+ border: 1px solid var(--border);
453
+ border-radius: 8px;
454
+ background: var(--bg);
455
+ color: inherit;
456
+ box-shadow: 0 8px 24px var(--shadow);
457
+ max-height: 260px;
458
+ overflow-y: auto;
459
+ box-sizing: border-box;
460
+ }
461
+ .menu:popover-open { margin-top: 4px; }
462
+ .menu[popover] { display: none; }
463
+ .menu.visible[popover] { display: block; }
464
+
465
+ .option {
466
+ display: flex;
467
+ align-items: center;
468
+ gap: 8px;
469
+ padding: 6px 8px;
470
+ border-radius: 5px;
471
+ cursor: pointer;
472
+ font-size: 13px;
473
+ }
474
+ .option:hover, .option.highlighted { background: var(--hover); }
475
+ .option.selected { font-weight: 600; }
476
+ .empty { padding: 6px 8px; opacity: 0.6; font-style: italic; font-size: 12px; }
477
+ .create-option { color: var(--accent); font-style: italic; }
478
+ `}constructor(){super(),new N(this),this.options=[],this.value="",this.onChange=()=>{},this.#n=`--status-select-${++pt}`,this.#r=`status-select-listbox-${pt}`}#u=e=>{e.composedPath().includes(this)||this.#o()};connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#u)}disconnectedCallback(){document.removeEventListener("click",this.#u),super.disconnectedCallback()}get#a(){const e=this.#e.value.trim().toLowerCase();return!e||e===this.value.trim().toLowerCase()?this.options:this.options.filter(t=>t.toLowerCase().includes(e))}#i(){this.#e.set(this.value),this.#t.set(!0),this.updateComplete.then(()=>{this.renderRoot.querySelector(".menu")?.showPopover()})}#o(){this.#t.set(!1),this.#s.set(-1),this.#e.set(this.value),this.renderRoot.querySelector(".menu")?.hidePopover()}#d(){this.#t.value?this.#o():(this.#i(),this.renderRoot.querySelector(".input")?.focus())}#g(e){this.#e.set(e.target.value),this.#s.set(-1),this.#t.value||this.#i()}#h(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}#c(e){const t=this.#h(e);if(!t)return this.#o();this.onChange(t),this.#e.set(t),this.#s.set(-1),this.#o()}get#b(){const e=this.#h(this.#e.value);return e.length>0&&!this.options.some(t=>t.toLowerCase()===e)}get#w(){return this.#a.length+(this.#b?1:0)}#x(e){const t=this.#w;if(e.key==="ArrowDown")e.preventDefault(),this.#i(),t&&this.#s.set((this.#s.value+1)%t);else if(e.key==="ArrowUp")e.preventDefault(),this.#i(),t&&this.#s.set((this.#s.value-1+t)%t);else if(e.key==="Enter"){e.preventDefault();const s=this.#a,i=s[this.#s.value];i!==void 0?this.#c(i):this.#s.value===s.length&&this.#b?this.#c(this.#e.value):this.#e.value.trim()&&this.#c(this.#e.value)}else e.key==="Escape"&&(e.preventDefault(),this.#o())}render(){const e=this.value,t=this.#a,s=this.#t.value,i=this.#s.value;return l`
479
+ <div class="field" style=${`anchor-name: ${this.#n}`}>
480
+ <input
481
+ class="input"
482
+ role="combobox"
483
+ aria-autocomplete="list"
484
+ aria-expanded=${s}
485
+ aria-controls=${this.#r}
486
+ aria-activedescendant=${i>=0?`${this.#r}-opt-${i}`:""}
487
+ .value=${s?this.#e.value:e}
488
+ @input=${r=>this.#g(r)}
489
+ @focus=${()=>this.#i()}
490
+ @click=${()=>this.#i()}
491
+ @keydown=${r=>this.#x(r)}
492
+ @blur=${()=>{this.#t.value&&this.#e.value.trim()&&this.#h(this.#e.value)!==e?this.#c(this.#e.value):this.#o()}}
493
+ />
494
+ <button
495
+ class="chevron-btn ${s?"open":""}"
496
+ tabindex="-1"
497
+ @mousedown=${r=>r.preventDefault()}
498
+ @click=${()=>this.#d()}
499
+ >
500
+
501
+ </button>
502
+ </div>
503
+
504
+ <ul
505
+ id=${this.#r}
506
+ class="menu ${s?"visible":""}"
507
+ role="listbox"
508
+ popover="manual"
509
+ style=${`position-anchor: ${this.#n}`}
510
+ >
511
+ ${t.map((r,o)=>l`
512
+ <li
513
+ id=${`${this.#r}-opt-${o}`}
514
+ role="option"
515
+ aria-selected=${r===e}
516
+ class=${`option ${r===e?"selected":""} ${o===i?"highlighted":""}`}
517
+ @mousedown=${a=>a.preventDefault()}
518
+ @click=${()=>this.#c(r)}
519
+ >
520
+ ${r}
521
+ </li>
522
+ `)}
523
+ ${this.#b?l`
524
+ <li
525
+ id=${`${this.#r}-opt-${t.length}`}
526
+ role="option"
527
+ class=${`option create-option ${t.length===i?"highlighted":""}`}
528
+ @mousedown=${r=>r.preventDefault()}
529
+ @click=${()=>this.#c(this.#e.value)}
530
+ >
531
+ ${t.length?"Create":"No match. Create"} '${this.#h(this.#e.value)}'
532
+ </li>
533
+ `:""}
534
+ ${!t.length&&!this.#b?l`<li class="empty">No options</li>`:""}
535
+ </ul>
536
+ `}}customElements.define("status-select",qi);let Bi=0;const Hi={top:"top: auto; bottom: anchor(top); left: anchor(center); right: auto; translate: -50% 0; margin-top: 0; margin-bottom: 6px;",bottom:"top: anchor(bottom); bottom: auto; left: anchor(center); right: auto; translate: -50% 0; margin-top: 6px; margin-bottom: 0;",left:"top: anchor(center); bottom: auto; left: auto; right: anchor(left); translate: 0 -50%; margin-right: 6px;",right:"top: anchor(center); bottom: auto; left: anchor(right); right: auto; translate: 0 -50%; margin-left: 6px;"},Ki=["top","bottom","left","right"];class Vi extends k{static{this.properties={text:{attribute:!1},placement:{attribute:!1}}}#e;#t=null;static{this.styles=$`
537
+ :host {
538
+ display: inline-flex;
539
+ position: relative;
540
+ vertical-align: middle;
541
+ }
542
+ .icon {
543
+ display: inline-flex;
544
+ align-items: center;
545
+ justify-content: center;
546
+ width: 14px;
547
+ height: 14px;
548
+ border-radius: 50%;
549
+ border: 1px solid var(--border-strong);
550
+ background: transparent;
551
+ color: inherit;
552
+ opacity: 0.55;
553
+ font-size: 10px;
554
+ line-height: 1;
555
+ cursor: help;
556
+ padding: 0;
557
+ }
558
+ .icon:hover, .icon:focus-visible {
559
+ opacity: 1;
560
+ border-color: var(--accent);
561
+ color: var(--accent);
562
+ }
563
+
564
+ .bubble {
565
+ /* Primary position (top/bottom/left/right + translate + margin) and
566
+ position-try-fallbacks are both set inline per-instance from the placement property —
567
+ see PRIMARY_POSITION/#fallbackNames and the inline style in render() below. */
568
+ position: fixed;
569
+ inset: auto;
570
+ border: 1px solid var(--border);
571
+ border-radius: 6px;
572
+ background: var(--bg);
573
+ color: inherit;
574
+ box-shadow: 0 6px 20px var(--shadow);
575
+ padding: 6px 9px;
576
+ max-width: 240px;
577
+ width: max-content;
578
+ font-size: 12px;
579
+ line-height: 1.4;
580
+ font-weight: 400;
581
+ text-align: left;
582
+ }
583
+ .bubble[popover] { display: none; }
584
+ .bubble:popover-open { display: block; }
585
+
586
+ /* One @position-try block per side. Named per-side (not per-placement-order) so any
587
+ placement's fallback list can reference the same four blocks in a different order. */
588
+ @position-try --bubble-top {
589
+ top: auto;
590
+ bottom: anchor(top);
591
+ left: anchor(center);
592
+ right: auto;
593
+ translate: -50% 0;
594
+ margin: 0 0 6px;
595
+ }
596
+ @position-try --bubble-bottom {
597
+ top: anchor(bottom);
598
+ bottom: auto;
599
+ left: anchor(center);
600
+ right: auto;
601
+ translate: -50% 0;
602
+ margin: 6px 0 0;
603
+ }
604
+ @position-try --bubble-left {
605
+ top: anchor(center);
606
+ bottom: auto;
607
+ left: auto;
608
+ right: anchor(left);
609
+ translate: 0 -50%;
610
+ margin: 0 6px 0 0;
611
+ }
612
+ @position-try --bubble-right {
613
+ top: anchor(center);
614
+ bottom: auto;
615
+ left: anchor(right);
616
+ right: auto;
617
+ translate: 0 -50%;
618
+ margin: 0 0 0 6px;
619
+ }
620
+ `}constructor(){super(),this.text="",this.placement="top",this.#e=`--help-tooltip-${++Bi}`}get#s(){const e=Ki.filter(t=>t!==this.placement);return[this.placement,...e].map(t=>`--bubble-${t}`).join(", ")}disconnectedCallback(){this.#t&&clearTimeout(this.#t),super.disconnectedCallback()}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null);const e=this.renderRoot.querySelector(".bubble");e&&!e.matches(":popover-open")&&e.showPopover()}#r(){this.#t=setTimeout(()=>{this.renderRoot.querySelector(".bubble")?.hidePopover()},100)}render(){return l`
621
+ <button
622
+ type="button"
623
+ class="icon"
624
+ style=${`anchor-name: ${this.#e}`}
625
+ aria-describedby="bubble"
626
+ @mouseenter=${()=>this.#n()}
627
+ @mouseleave=${()=>this.#r()}
628
+ @focus=${()=>this.#n()}
629
+ @blur=${()=>this.#r()}
630
+ >?</button>
631
+ <div
632
+ id="bubble"
633
+ role="tooltip"
634
+ class="bubble"
635
+ popover="manual"
636
+ style=${`position-anchor: ${this.#e}; position-try-fallbacks: ${this.#s}; ${Hi[this.placement]}`}
637
+ @mouseenter=${()=>this.#n()}
638
+ @mouseleave=${()=>this.#r()}
639
+ >
640
+ ${this.text}
641
+ </div>
642
+ `}}customElements.define("help-tooltip",Vi);const Ce="mem-bucket-toast",ut=3,Xt=2200;function q(n,e="default",t=Xt){window.dispatchEvent(new CustomEvent(Ce,{detail:{message:n,type:e,timeoutMs:t},bubbles:!0,composed:!0}))}const y={send:q,default:(n,e)=>q(n,"default",e),success:(n,e)=>q(n,"success",e),danger:(n,e)=>q(n,"danger",e),warning:(n,e)=>q(n,"warning",e),info:(n,e)=>q(n,"info",e)},Gi={default:"--fg",success:"--success",danger:"--danger",warning:"--warning",info:"--accent"};class Wi extends k{#e=new h([]);#t=e=>this.#s(e);constructor(){super(),new N(this)}connectedCallback(){super.connectedCallback(),window.addEventListener(Ce,this.#t)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(Ce,this.#t)}#s(e){const{message:t,type:s="default",timeoutMs:i=Xt}=e.detail,r=Math.random().toString(36).slice(2,11),o=[...this.#e.value,{id:r,type:s,message:t,timeout:i}];this.#e.set(o.length>ut?o.slice(o.length-ut):o),setTimeout(()=>{this.#e.set(this.#e.value.filter(a=>a.id!==r))},i)}static{this.styles=$`
643
+ :host {
644
+ position: fixed;
645
+ top: 14px;
646
+ left: 0;
647
+ right: 0;
648
+ z-index: 9999;
649
+ display: flex;
650
+ flex-direction: column;
651
+ align-items: center;
652
+ gap: 8px;
653
+ pointer-events: none;
654
+ }
655
+ .toast {
656
+ display: flex;
657
+ align-items: center;
658
+ gap: 8px;
659
+ padding: 9px 16px;
660
+ border-radius: 8px;
661
+ background: var(--bg);
662
+ color: inherit;
663
+ border: 1px solid var(--border-strong);
664
+ box-shadow: 0 4px 20px var(--shadow);
665
+ font-size: 13px;
666
+ max-width: min(420px, 90vw);
667
+ animation: toast-in 180ms ease-out;
668
+ }
669
+ .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
670
+ @keyframes toast-in {
671
+ from { opacity: 0; transform: translateY(-8px); }
672
+ to { opacity: 1; transform: translateY(0); }
673
+ }
674
+ `}render(){return l`
675
+ ${this.#e.value.map(e=>l`
676
+ <div class="toast">
677
+ <span class="dot" style=${`background: var(${Gi[e.type]})`}></span>
678
+ <span>${e.message}</span>
679
+ </div>
680
+ `)}
681
+ `}}customElements.define("toast-stack",Wi);const ft="mem-bucket-detail-view-mode",Zi=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]);function Ji(n){const e=n.lastIndexOf(".");return e===-1?!1:Zi.has(n.slice(e).toLowerCase())}function gt(n,e){const t={name:"",children:new Map};for(const s of n){const i=s.split("/").filter(Boolean);let r=t;i.forEach((o,a)=>{let c=r.children.get(o);c||(c={name:o,children:new Map},r.children.set(o,c)),a===i.length-1&&(c.leaf=e(s)),r=c})}return t}function Yi(n){return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(n))}const Qi=["stable","beta","unreviewed"],Xi=["active","shipped","abandoned"],bt=["plan","spec","sql","testing-todo","discovery","session-summary","other"],er=["ticket","freeform"],_={description:"What this doc is / does, shown in search results and list views. For skills, this is also the only thing an agent sees before deciding whether to load the full body — so state both what it does and when to use it.",tags:"Free-form keywords used to filter and search. Not the only thing matched during full-text search, but the fastest way to narrow a list view.",status:`Lifecycle state — stable/beta/unreviewed for skills, active/shipped/abandoned for memory docs. Skills default to "unreviewed" if left unset, so low-trust content doesn't read as equivalent to a reviewed pattern.`,name:"The skill's identifier — becomes its containing folder name on disk. Lowercase letters, numbers, and hyphens only.",owner:"Who authored or maintains this skill — a person or team name, free text.",extends:"Name of another skill this one builds on or specializes, if any. Leave blank if it doesn't extend anything.",group:"This skill's primary category — distinct from folder (physical location) and tags (cross-cutting labels). Leave blank if it doesn't belong to a group.",trigger_phrases:"Extra keyword phrases beyond the description that should surface this skill in search — phrasings a user might type that don't literally appear in the description text.",key:"The lookup handle for this memory doc — usually a ticket ID, sometimes a free-form name. One key can have several docs attached (a plan, a spec, session notes) all retrievable together.",key_type:'"ticket" if the key is a real ticket ID, "freeform" for a name like "Spot Chart Design".',doc_type:"What kind of content this is — shapes how it should be read (a plan reads differently than raw SQL or a session summary).",related_to:"Another key this doc relates to, if any — free text, not validated against existing keys."};function mt(n){return{description:n.description??"",tags:n.tags??[],status:n.status??"",name:n.name??"",owner:n.owner??"",extends:n.extends??"",group:n.group??"",trigger_phrases:n.trigger_phrases??[],key:n.key??"",key_type:n.key_type??"",doc_type:n.doc_type??"",related_to:n.related_to??""}}class tr extends k{constructor(){super(...arguments),this._viewMode=localStorage.getItem(ft)??"markdown",this._editing=!1,this._draft=null,this._addingFrontmatter=!1,this._renaming=!1,this._renameValue="",this._viewingAttachment=null,this._sharing=!1,this._shareUsername="",this._shareRole="member",this._shareBusy=!1,this._shareStatus=null}static{this.properties={selected:{attribute:!1},onChanged:{attribute:!1},facets:{attribute:!1},onTagClick:{attribute:!1},onFolderClick:{attribute:!1},onDateClick:{attribute:!1},onKeyClick:{attribute:!1},onGroupClick:{attribute:!1},onGone:{attribute:!1},_doc:{state:!0},_viewMode:{state:!0},_editing:{state:!0},_draft:{state:!0},_addingFrontmatter:{state:!0},_renaming:{state:!0},_renameValue:{state:!0},_viewingAttachment:{state:!0},_sharing:{state:!0},_shareUsername:{state:!0},_shareRole:{state:!0},_shareBusy:{state:!0},_shareStatus:{state:!0}}}static{this.styles=$`
682
+ :host { display: block; padding: 16px; }
683
+ h2 { margin: 0 0 4px; font-size: 16px; }
684
+ .title-row {
685
+ display: flex;
686
+ align-items: center;
687
+ gap: 8px;
688
+ flex-wrap: wrap;
689
+ margin-bottom: 10px;
690
+ }
691
+ .title-row h2 { margin: 0; }
692
+ .title-link {
693
+ background: none; border: none; padding: 0; margin: 0; font: inherit; font-weight: inherit;
694
+ color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
695
+ text-align: left;
696
+ }
697
+ .title-link:hover { opacity: 0.8; }
698
+ .key-subtitle { display: block; font-size: 12px; opacity: 0.65; margin-top: 2px; font-weight: 400; }
699
+ .key-link {
700
+ background: none; border: none; padding: 0; margin: 0; font: inherit;
701
+ color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
702
+ }
703
+ .key-link:hover { opacity: 0.8; }
704
+ .pill {
705
+ border: 1px solid var(--border-strong);
706
+ border-radius: 999px;
707
+ padding: 2px 9px;
708
+ font-size: 11px;
709
+ display: inline-flex;
710
+ align-items: center;
711
+ background: none;
712
+ color: inherit;
713
+ font-family: inherit;
714
+ }
715
+ .pill.folder-pill {
716
+ cursor: pointer;
717
+ color: var(--purple-fg);
718
+ border-color: var(--purple);
719
+ background: var(--purple-tint);
720
+ }
721
+ .pill.folder-pill:hover { background: var(--hover-strong); }
722
+ .pill.tag-pill {
723
+ cursor: pointer;
724
+ background: var(--bg-subtle);
725
+ }
726
+ .pill.tag-pill:hover { background: var(--hover); border-color: var(--border-strong); }
727
+ .pill.warn-pill {
728
+ border-color: var(--danger);
729
+ color: var(--danger);
730
+ background: none;
731
+ }
732
+ .pill.muted-pill {
733
+ opacity: 0.65;
734
+ }
735
+ .info-grid {
736
+ display: grid;
737
+ grid-template-columns: max-content 1fr;
738
+ column-gap: 10px;
739
+ row-gap: 7px;
740
+ font-size: 12px;
741
+ margin-bottom: 12px;
742
+ align-items: start;
743
+ }
744
+ .info-grid dt {
745
+ opacity: 0.55;
746
+ font-size: 10.5px;
747
+ text-transform: uppercase;
748
+ letter-spacing: 0.04em;
749
+ padding-top: 2px;
750
+ white-space: nowrap;
751
+ }
752
+ .info-grid dd {
753
+ margin: 0;
754
+ display: flex;
755
+ flex-wrap: wrap;
756
+ gap: 5px;
757
+ align-items: center;
758
+ }
759
+ .info-grid dd.description { opacity: 0.85; }
760
+ .info-grid .date-value {
761
+ cursor: pointer;
762
+ text-decoration: underline dotted;
763
+ text-underline-offset: 2px;
764
+ }
765
+ .info-grid .date-value:hover { opacity: 0.75; }
766
+ .info-grid .hint { opacity: 0.5; font-style: italic; }
767
+ .bare-notice { font-size: 12px; opacity: 0.6; font-style: italic; margin-bottom: 12px; }
768
+ .attachments-section {
769
+ font-size: 12px;
770
+ margin-bottom: 12px;
771
+ }
772
+ .attachments-section h4 {
773
+ margin: 0 0 6px;
774
+ font-size: 10.5px;
775
+ text-transform: uppercase;
776
+ letter-spacing: 0.04em;
777
+ opacity: 0.55;
778
+ font-weight: 600;
779
+ }
780
+ .attachment-add {
781
+ position: relative;
782
+ display: inline-block;
783
+ margin-top: 6px;
784
+ font-weight: 500;
785
+ opacity: 0.85;
786
+ cursor: pointer;
787
+ }
788
+ .attachment-add:hover { opacity: 1; }
789
+ .attachment-add input[type='file'] {
790
+ position: absolute;
791
+ inset: 0;
792
+ opacity: 0;
793
+ cursor: pointer;
794
+ }
795
+ .attachment-remove {
796
+ opacity: 0.55;
797
+ background: none;
798
+ border: none;
799
+ cursor: pointer;
800
+ font-size: 13px;
801
+ line-height: 1;
802
+ padding: 0 0 0 4px;
803
+ color: inherit;
804
+ }
805
+ .attachment-remove:hover { opacity: 1; color: var(--danger); }
806
+ .attachments-section ul {
807
+ list-style: none;
808
+ margin: 0;
809
+ padding: 0;
810
+ display: flex;
811
+ flex-direction: column;
812
+ gap: 4px;
813
+ }
814
+ .attachments-section ul.attachment-tree {
815
+ font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
816
+ gap: 2px;
817
+ }
818
+ .attachments-section .tree-dir {
819
+ opacity: 0.7;
820
+ }
821
+ .attachments-section .tree-prefix {
822
+ opacity: 0.45;
823
+ white-space: pre;
824
+ }
825
+ .attachment-download {
826
+ opacity: 0.55;
827
+ text-decoration: none;
828
+ margin-left: 2px;
829
+ }
830
+ .attachment-download:hover { opacity: 1; }
831
+ .attachment-view-header {
832
+ display: flex;
833
+ align-items: center;
834
+ gap: 10px;
835
+ margin-bottom: 8px;
836
+ }
837
+ .back-button {
838
+ font-size: 11px;
839
+ padding: 3px 8px;
840
+ border: 1px solid var(--border);
841
+ background: transparent;
842
+ color: inherit;
843
+ border-radius: 4px;
844
+ cursor: pointer;
845
+ }
846
+ .back-button:hover { background: var(--hover); }
847
+ .attachment-view-title {
848
+ font-size: 12px;
849
+ font-weight: 600;
850
+ flex: 1;
851
+ overflow: hidden;
852
+ text-overflow: ellipsis;
853
+ white-space: nowrap;
854
+ }
855
+ .attachment-view-download {
856
+ font-size: 11px;
857
+ text-decoration: none;
858
+ color: inherit;
859
+ opacity: 0.75;
860
+ }
861
+ .attachment-view-download:hover { opacity: 1; }
862
+ .attachment-frame {
863
+ width: 100%;
864
+ height: 65vh;
865
+ border: 1px solid var(--border);
866
+ border-radius: 6px;
867
+ background: var(--bg-subtle);
868
+ }
869
+ .attachment-image {
870
+ display: block;
871
+ max-width: 100%;
872
+ max-height: 65vh;
873
+ border-radius: 6px;
874
+ }
875
+ .source-path {
876
+ font-family: monospace;
877
+ font-size: 11px;
878
+ opacity: 0.6;
879
+ cursor: pointer;
880
+ word-break: break-all;
881
+ }
882
+ pre {
883
+ white-space: pre-wrap;
884
+ font-size: 12px;
885
+ background: var(--bg-subtle);
886
+ padding: 12px;
887
+ border-radius: 6px;
888
+ max-height: 60vh;
889
+ overflow-y: auto;
890
+ }
891
+ textarea {
892
+ width: 100%;
893
+ box-sizing: border-box;
894
+ font-family: monospace;
895
+ font-size: 12px;
896
+ background: var(--bg-subtle);
897
+ color: inherit;
898
+ border: 1px solid var(--border);
899
+ border-radius: 6px;
900
+ padding: 12px;
901
+ min-height: 30vh;
902
+ resize: vertical;
903
+ }
904
+ .empty { opacity: 0.5; font-size: 13px; }
905
+ .view-toggle {
906
+ display: flex;
907
+ gap: 4px;
908
+ margin-bottom: 8px;
909
+ }
910
+ .view-toggle button {
911
+ font-size: 11px;
912
+ padding: 3px 8px;
913
+ border: 1px solid var(--border);
914
+ background: transparent;
915
+ border-radius: 4px;
916
+ cursor: pointer;
917
+ opacity: 0.6;
918
+ }
919
+ .view-toggle button.active {
920
+ opacity: 1;
921
+ background: var(--hover);
922
+ font-weight: 600;
923
+ }
924
+ .markdown-body {
925
+ font-size: 13px;
926
+ line-height: 1.5;
927
+ max-height: 60vh;
928
+ overflow-y: auto;
929
+ padding: 12px;
930
+ background: var(--bg-subtle);
931
+ border-radius: 6px;
932
+ }
933
+ .markdown-body :first-child { margin-top: 0; }
934
+ .markdown-body :last-child { margin-bottom: 0; }
935
+ .markdown-body pre {
936
+ background: var(--hover);
937
+ max-height: none;
938
+ }
939
+ .markdown-body code {
940
+ font-family: monospace;
941
+ font-size: 12px;
942
+ }
943
+ .actions {
944
+ display: flex;
945
+ flex-wrap: wrap;
946
+ gap: 8px;
947
+ margin-bottom: 12px;
948
+ }
949
+ .actions button {
950
+ font-size: 11px;
951
+ padding: 4px 10px;
952
+ border: 1px solid var(--border);
953
+ background: transparent;
954
+ color: inherit;
955
+ border-radius: 4px;
956
+ cursor: pointer;
957
+ }
958
+ .actions button.danger {
959
+ border-color: var(--danger);
960
+ color: var(--danger);
961
+ }
962
+ .actions button.primary {
963
+ border-color: var(--accent);
964
+ color: var(--accent);
965
+ font-weight: 600;
966
+ }
967
+ .edit-form {
968
+ display: flex;
969
+ flex-direction: column;
970
+ gap: 10px;
971
+ margin-bottom: 12px;
972
+ padding: 12px;
973
+ background: var(--bg-subtle);
974
+ border-radius: 6px;
975
+ }
976
+ .field {
977
+ display: flex;
978
+ flex-direction: column;
979
+ gap: 4px;
980
+ }
981
+ .field label {
982
+ font-size: 11px;
983
+ font-weight: 600;
984
+ opacity: 0.7;
985
+ display: inline-flex;
986
+ align-items: center;
987
+ gap: 4px;
988
+ }
989
+ .field input[type='text'],
990
+ .field select,
991
+ .field textarea {
992
+ font-size: 13px;
993
+ padding: 6px 8px;
994
+ border: 1px solid var(--border-strong);
995
+ border-radius: 6px;
996
+ background: var(--bg);
997
+ color: inherit;
998
+ font-family: inherit;
999
+ }
1000
+ .field input[type='text'],
1001
+ .field select {
1002
+ max-width: 320px;
1003
+ }
1004
+ .field textarea {
1005
+ min-height: 60px;
1006
+ resize: vertical;
1007
+ }
1008
+ .field-row {
1009
+ display: flex;
1010
+ gap: 10px;
1011
+ }
1012
+ .field-row .field { flex: 1; }
1013
+ .form-actions {
1014
+ display: flex;
1015
+ gap: 8px;
1016
+ margin-top: 4px;
1017
+ }
1018
+ .form-actions button {
1019
+ font-size: 12px;
1020
+ padding: 5px 12px;
1021
+ border-radius: 4px;
1022
+ cursor: pointer;
1023
+ }
1024
+ .form-actions button.save {
1025
+ border: 1px solid var(--accent);
1026
+ background: var(--accent);
1027
+ color: var(--accent-fg);
1028
+ }
1029
+ .form-actions button.cancel {
1030
+ border: 1px solid var(--border);
1031
+ background: transparent;
1032
+ color: inherit;
1033
+ }
1034
+ .rename-row {
1035
+ display: flex;
1036
+ gap: 6px;
1037
+ align-items: center;
1038
+ }
1039
+ .rename-row input {
1040
+ flex: 1;
1041
+ font-size: 12px;
1042
+ padding: 4px 6px;
1043
+ border: 1px solid var(--border-strong);
1044
+ border-radius: 4px;
1045
+ background: var(--bg);
1046
+ color: inherit;
1047
+ }
1048
+ .hint { font-size: 11px; opacity: 0.6; }
1049
+ .share-form {
1050
+ display: flex; flex-direction: column; gap: 8px; padding: 10px; margin-top: 4px;
1051
+ border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg-subtle);
1052
+ }
1053
+ .share-row { display: flex; gap: 6px; align-items: center; }
1054
+ .share-row input[type='text'] {
1055
+ flex: 1; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border-strong);
1056
+ border-radius: 4px; background: var(--bg); color: inherit;
1057
+ }
1058
+ .share-row select {
1059
+ font-size: 12px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: 4px;
1060
+ background: var(--bg); color: inherit;
1061
+ }
1062
+ .share-links-row { display: flex; gap: 6px; }
1063
+ .share-status { font-size: 11px; opacity: 0.75; }
1064
+ `}updated(e){e.has("selected")&&this.selected&&(this._editing=!1,this._addingFrontmatter=!1,this._renaming=!1,this._viewingAttachment=null,this.#e(),this.scrollTop=0)}async#e(){const{table:e,id:t}=this.selected,s=await fetch(`/api/entries/${e}/${encodeURIComponent(t)}`);this._doc=s.ok?await s.json():null,await this.updateComplete,this.shadowRoot?.querySelector(".markdown-body")?.scrollTo(0,0),this.shadowRoot?.querySelector("pre")?.scrollTo(0,0)}async refresh(){if(!this.selected||this._editing||this._addingFrontmatter||this._renaming)return;const{table:e,id:t}=this.selected,s=await fetch(`/api/entries/${e}/${encodeURIComponent(t)}`);if(!s.ok){this._doc=null,this.onGone?.();return}const r=(this.shadowRoot?.querySelector(".markdown-body")??this.shadowRoot?.querySelector("pre"))?.scrollTop??0;this._doc=await s.json(),await this.updateComplete;const o=this.shadowRoot?.querySelector(".markdown-body")??this.shadowRoot?.querySelector("pre");o&&(o.scrollTop=r)}#t(){this._doc?.source_path&&navigator.clipboard?.writeText(this._doc.source_path)}#s(e){this._viewMode=e,localStorage.setItem(ft,e)}async#n(){const{table:e,id:t}=this.selected,s=!this._doc?.deprecated;if(!(await fetch(`/api/entries/${e}/${encodeURIComponent(t)}/deprecated`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({deprecated:s})})).ok){y.danger("Failed to update status");return}await this.#e(),this.onChanged?.()}async#r(){const{table:e,id:t}=this.selected,s=!this._doc?.paused;if(!(await fetch(`/api/entries/${e}/${encodeURIComponent(t)}/paused`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({paused:s})})).ok){y.danger("Failed to update status");return}await this.#e(),this.onChanged?.()}async#u(e){const{table:t,id:s}=this.selected,i=await e.arrayBuffer(),r=await fetch(`/api/entries/${t}/${encodeURIComponent(s)}/attachments?filename=${encodeURIComponent(e.name)}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:i});if(!r.ok){const{error:o}=await r.json().catch(()=>({error:`upload failed (${r.status})`}));window.alert(o);return}await this.#e(),this.onChanged?.()}#a(e){const t=e.currentTarget,s=t.files?.[0];t.value="",s&&this.#u(s)}async#i(e){if(!window.confirm(`Remove attachment "${e}"? This can't be undone.`))return;const{table:t,id:s}=this.selected;if(!(await fetch(`/api/entries/${t}/${encodeURIComponent(s)}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"})).ok){y.danger("Failed to remove attachment");return}this._viewingAttachment?.filename===e&&(this._viewingAttachment=null),await this.#e(),this.onChanged?.()}#o(){this._sharing=!0,this._shareUsername="",this._shareRole="member",this._shareStatus=null}#d(){this._sharing=!1,this._shareStatus=null}async#g(){if(!this.selected||!this._shareUsername.trim())return;const{table:e,id:t}=this.selected;this._shareBusy=!0,this._shareStatus=null;try{const s=await fetch(`/api/entries/${e}/${encodeURIComponent(t)}/share`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:this._shareUsername.trim(),role:this._shareRole})}),i=await s.json().catch(()=>({}));this._shareStatus=s.ok?`Shared with ${this._shareUsername.trim()}.`:`Share failed: ${i.error??s.statusText}`,s.ok&&(this._shareUsername="")}finally{this._shareBusy=!1}}async#h(e){if(!this.selected)return;const{table:t,id:s}=this.selected;this._shareBusy=!0,this._shareStatus=null;try{const i=await fetch(`/api/entries/${t}/${encodeURIComponent(s)}/${e}`,{method:"POST"}),r=await i.json().catch(()=>({}));if(!i.ok){this._shareStatus=`Failed to create link: ${r.error??i.statusText}`;return}const o=e==="share-link"?"shareToken":"publicToken",a=new URL(window.location.href);a.search=`?${o}=${encodeURIComponent(r.token)}`;const c=a.toString();try{await navigator.clipboard?.writeText(c),this._shareStatus=`${e==="share-link"?"Share":"Public"} link copied to clipboard.`}catch{this._shareStatus=`Link: ${c}`}}finally{this._shareBusy=!1}}async#c(){if(!window.confirm("Delete this doc? This can't be undone."))return;const{table:e,id:t}=this.selected;if(!(await fetch(`/api/entries/${e}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok){y.danger("Delete failed");return}this._doc=null,y.success("Deleted"),this.onChanged?.()}#b(){this._doc&&(this._draft=mt(this._doc),this._editing=!0,this._addingFrontmatter=!1)}#w(){this._doc&&(this._draft=mt(this._doc),this._addingFrontmatter=!0,this._editing=!1)}#x(e){this._draft&&(this._draft={...this._draft,doc_type:e},this._addingFrontmatter=!1,this._editing=!0)}#v(){this._editing=!1,this._addingFrontmatter=!1,this._draft=null}#p(e){this._draft&&(this._draft={...this._draft,...e})}#y(e){if(!this._draft)return;const t=this._draft.tags.includes(e)?this._draft.tags.filter(s=>s!==e):[...this._draft.tags,e];this.#p({tags:t})}#$(e){if(!this._draft)return;const t=this._draft.trigger_phrases.includes(e)?this._draft.trigger_phrases.filter(s=>s!==e):[...this._draft.trigger_phrases,e];this.#p({trigger_phrases:t})}async#l(){if(!this._draft||!this.selected)return;const{table:e,id:t}=this.selected,s=e==="skills",i={description:this._draft.description,tags:this._draft.tags,status:this._draft.status};s?(i.owner=this._draft.owner||null,i.extends=this._draft.extends||null,i.group=this._draft.group||null,i.trigger_phrases=this._draft.trigger_phrases):(i.key=this._draft.key,i.key_type=this._draft.key_type,i.doc_type=this._draft.doc_type,i.related_to=this._draft.related_to||null);const r=await fetch(`/api/entries/${e}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({frontmatter:i})});if(!r.ok){const o=await r.json().catch(()=>({}));window.alert(`Save failed: ${o.error??r.statusText}`);return}this._editing=!1,this._draft=null,await this.#e(),this.onChanged?.()}async#k(){if(!this.selected||!this._doc||this.selected.table!=="memory_docs")return;const{table:e,id:t}=this.selected;if(!window.confirm(`Delete frontmatter for "${this._doc.key}"?
1065
+
1066
+ This removes the doc's key, tags, and status — it drops out of key-based lookup and full-text search, and becomes a plain unmanaged file, until frontmatter is added again.`))return;const i=await fetch(`/api/entries/${e}/${encodeURIComponent(t)}/frontmatter`,{method:"DELETE"});if(!i.ok){const r=await i.json().catch(()=>({}));window.alert(`Delete failed: ${r.error??i.statusText}`);return}this._doc=null,this.selected=null,this.onChanged?.()}#_(){if(!this._doc||!this.selected)return;const e=this.selected.table==="skills";this._renameValue=e?this._doc.name??"":this._doc.source_path.split("/").pop()??"",this._renaming=!0}async#m(){if(!this._doc||!this.selected||!this._renameValue.trim())return;const e=this.selected.table==="skills",t=this._renameValue.trim(),s=e?this._doc.name:this._doc.source_path.split("/").pop();if(t===s){this._renaming=!1;return}const i=e?await fetch(`/api/entries/skills/${encodeURIComponent(this._doc.name)}/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({new_name:t})}):await fetch(`/api/entries/memory_docs/${encodeURIComponent(this.selected.id)}/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({new_filename:t})});if(!i.ok){const r=await i.json().catch(()=>({}));window.alert(`Rename failed: ${r.error??i.statusText}`);return}if(this._renaming=!1,e)this.selected={table:"skills",id:t};else{const r=await i.json();this.selected={table:"memory_docs",id:r.source_path}}await this.#e(),this.onChanged?.()}#C(){return l`
1067
+ <div class="edit-form">
1068
+ <div class="hint">What kind of doc is this? This shapes which fields apply next.</div>
1069
+ <div class="field">
1070
+ <label>doc_type <help-tooltip .text=${_.doc_type}></help-tooltip></label>
1071
+ <select
1072
+ @change=${e=>this.#x(e.target.value)}
1073
+ >
1074
+ <option value="" selected disabled>Choose…</option>
1075
+ ${bt.map(e=>l`<option value=${e}>${e}</option>`)}
1076
+ </select>
1077
+ </div>
1078
+ <div class="form-actions">
1079
+ <button class="cancel" @click=${()=>this.#v()}>Cancel</button>
1080
+ </div>
1081
+ </div>
1082
+ `}#T(e){const t=this._draft,s=this.facets;return l`
1083
+ <div class="edit-form">
1084
+ ${e?l`
1085
+ <div class="field">
1086
+ <label>name <help-tooltip .text=${_.name}></help-tooltip></label>
1087
+ <div class="hint">Renaming moves the skill's folder on disk — kept as a separate action.</div>
1088
+ </div>
1089
+ `:l`
1090
+ <div class="field-row">
1091
+ <div class="field">
1092
+ <label>key <help-tooltip .text=${_.key}></help-tooltip></label>
1093
+ <input
1094
+ type="text"
1095
+ .value=${t.key}
1096
+ @input=${i=>this.#p({key:i.target.value})}
1097
+ />
1098
+ </div>
1099
+ <div class="field">
1100
+ <label>key_type <help-tooltip .text=${_.key_type}></help-tooltip></label>
1101
+ <select
1102
+ .value=${t.key_type}
1103
+ @change=${i=>this.#p({key_type:i.target.value})}
1104
+ >
1105
+ ${er.map(i=>l`<option value=${i} ?selected=${i===t.key_type}>${i}</option>`)}
1106
+ </select>
1107
+ </div>
1108
+ </div>
1109
+ <div class="field">
1110
+ <label>doc_type <help-tooltip .text=${_.doc_type}></help-tooltip></label>
1111
+ <select
1112
+ .value=${t.doc_type}
1113
+ @change=${i=>this.#p({doc_type:i.target.value})}
1114
+ >
1115
+ ${bt.map(i=>l`<option value=${i} ?selected=${i===t.doc_type}>${i}</option>`)}
1116
+ </select>
1117
+ </div>
1118
+ `}
1119
+ <div class="field">
1120
+ <label>description <help-tooltip .text=${_.description}></help-tooltip></label>
1121
+ <textarea
1122
+ .value=${t.description}
1123
+ @input=${i=>this.#p({description:i.target.value})}
1124
+ ></textarea>
1125
+ </div>
1126
+ <div class="field">
1127
+ <label>tags <help-tooltip .text=${_.tags}></help-tooltip></label>
1128
+ <tag-multiselect
1129
+ .tags=${s?.tags??[]}
1130
+ .active=${t.tags}
1131
+ .allowCreate=${!0}
1132
+ .onToggle=${i=>this.#y(i)}
1133
+ ></tag-multiselect>
1134
+ </div>
1135
+ <div class="field">
1136
+ <label>status <help-tooltip .text=${_.status}></help-tooltip></label>
1137
+ <status-select
1138
+ .options=${[...new Set([...e?Qi:Xi,...s?.statuses??[]])]}
1139
+ .value=${t.status}
1140
+ .onChange=${i=>this.#p({status:i})}
1141
+ ></status-select>
1142
+ </div>
1143
+ ${e?l`
1144
+ <div class="field-row">
1145
+ <div class="field">
1146
+ <label>owner <help-tooltip .text=${_.owner}></help-tooltip></label>
1147
+ <input
1148
+ type="text"
1149
+ .value=${t.owner}
1150
+ @input=${i=>this.#p({owner:i.target.value})}
1151
+ />
1152
+ </div>
1153
+ <div class="field">
1154
+ <label>extends <help-tooltip .text=${_.extends}></help-tooltip></label>
1155
+ <input
1156
+ type="text"
1157
+ .value=${t.extends}
1158
+ @input=${i=>this.#p({extends:i.target.value})}
1159
+ />
1160
+ </div>
1161
+ </div>
1162
+ <div class="field">
1163
+ <label>group <help-tooltip .text=${_.group}></help-tooltip></label>
1164
+ <status-select
1165
+ .options=${s?.groups??[]}
1166
+ .value=${t.group}
1167
+ .onChange=${i=>this.#p({group:i})}
1168
+ ></status-select>
1169
+ </div>
1170
+ <div class="field">
1171
+ <label>trigger_phrases <help-tooltip .text=${_.trigger_phrases}></help-tooltip></label>
1172
+ <tag-multiselect
1173
+ .tags=${[]}
1174
+ .active=${t.trigger_phrases}
1175
+ .allowCreate=${!0}
1176
+ .onToggle=${i=>this.#$(i)}
1177
+ ></tag-multiselect>
1178
+ </div>
1179
+ `:l`
1180
+ <div class="field">
1181
+ <label>related_to <help-tooltip .text=${_.related_to}></help-tooltip></label>
1182
+ <input
1183
+ type="text"
1184
+ .value=${t.related_to}
1185
+ @input=${i=>this.#p({related_to:i.target.value})}
1186
+ />
1187
+ </div>
1188
+ `}
1189
+ <div class="form-actions">
1190
+ <button class="save" @click=${()=>this.#l()}>Save</button>
1191
+ <button class="cancel" @click=${()=>this.#v()}>Cancel</button>
1192
+ </div>
1193
+ </div>
1194
+ `}#S(e,t){const s=t?void 0:e.key,i=t?e.name??e.id:e.source_path?e.source_path.split("/").pop():e.id;return l`
1195
+ <div class="title-row">
1196
+ <div>
1197
+ <h2>${i}</h2>
1198
+ ${s?l`<button class="title-link key-subtitle" title="Search for key '${s}'" @click=${()=>this.onKeyClick?.(s)}>
1199
+ 🔑 ${s}
1200
+ </button>`:""}
1201
+ </div>
1202
+ <button class="pill folder-pill" title="Filter by folder '${e.folder}'" @click=${()=>this.onFolderClick?.(e.folder)}>
1203
+ 📁 ${e.folder}
1204
+ </button>
1205
+ </div>
1206
+ `}#z(e,t){const s=e.created_at?Yi(e.created_at):null;return l`
1207
+ <dl class="info-grid">
1208
+ <dt>Description</dt>
1209
+ <dd class="description">${e.description||"—"}</dd>
1210
+
1211
+ <dt>Tags</dt>
1212
+ <dd>
1213
+ ${e.tags?.length?e.tags.map(i=>l`<button class="pill tag-pill" @click=${()=>this.onTagClick?.(i)}>${i}</button>`):l`<span class="hint">no tags</span>`}
1214
+ </dd>
1215
+
1216
+ <dt>Status</dt>
1217
+ <dd>${e.status}</dd>
1218
+
1219
+ ${e.deprecated||e.paused?l`
1220
+ <dt>Flags</dt>
1221
+ <dd>
1222
+ ${e.deprecated?l`<span class="pill warn-pill">deprecated</span>`:f}
1223
+ ${e.paused?l`<span class="pill muted-pill">paused</span>`:f}
1224
+ </dd>
1225
+ `:f}
1226
+
1227
+ ${t?l`
1228
+ ${e.owner?l`<dt>Owner</dt>
1229
+ <dd>${e.owner}</dd>`:f}
1230
+ ${e.extends?l`<dt>Extends</dt>
1231
+ <dd>${e.extends}</dd>`:f}
1232
+ ${e.group?l`<dt>Group</dt>
1233
+ <dd>
1234
+ <button class="key-link" title="Search for this group" @click=${()=>e.group&&this.onGroupClick?.(e.group)}>
1235
+ ${e.group}
1236
+ </button>
1237
+ </dd>`:f}
1238
+ `:l`
1239
+ <dt>Key</dt>
1240
+ <dd>
1241
+ <button class="key-link" title="Search for this key" @click=${()=>e.key&&this.onKeyClick?.(e.key)}>
1242
+ ${e.key}
1243
+ </button>
1244
+ </dd>
1245
+
1246
+ <dt>Key type</dt>
1247
+ <dd>${e.key_type}</dd>
1248
+
1249
+ <dt>Doc type</dt>
1250
+ <dd>${e.doc_type}</dd>
1251
+
1252
+ ${e.related_to?l`<dt>Related to</dt>
1253
+ <dd>${e.related_to}</dd>`:f}
1254
+ `}
1255
+
1256
+ <dt>Created</dt>
1257
+ <dd>
1258
+ ${s?l`<span class="date-value" title="Filter to this day" @click=${()=>this.onDateClick?.(s)}
1259
+ >${s}</span
1260
+ >`:l`<span class="hint">unknown</span>`}
1261
+ </dd>
1262
+ </dl>
1263
+ `}#A(e,t){const s=new v.Renderer,i=s.link.bind(s);return s.link=r=>{if(typeof r.href=="string"&&r.href.startsWith("attachment://")){const o=r.href.slice(13);return i({...r,href:`/api/entries/${e}/${encodeURIComponent(t)}/attachments/${encodeURIComponent(o)}`})}return i(r)},s}#I(){return l`
1264
+ <div class="share-form">
1265
+ <div class="share-row">
1266
+ <input
1267
+ type="text"
1268
+ placeholder="username"
1269
+ .value=${this._shareUsername}
1270
+ @input=${e=>this._shareUsername=e.target.value}
1271
+ @keydown=${e=>e.key==="Enter"&&this.#g()}
1272
+ />
1273
+ <select .value=${this._shareRole} @change=${e=>this._shareRole=e.target.value}>
1274
+ <option value="member">Read-only</option>
1275
+ <option value="editor">Can edit</option>
1276
+ </select>
1277
+ <button ?disabled=${this._shareBusy||!this._shareUsername.trim()} @click=${()=>this.#g()}>Share</button>
1278
+ </div>
1279
+ <div class="share-links-row">
1280
+ <button ?disabled=${this._shareBusy} @click=${()=>this.#h("share-link")}>Copy share link</button>
1281
+ <button ?disabled=${this._shareBusy} @click=${()=>this.#h("public-link")}>Copy public link</button>
1282
+ <button @click=${()=>this.#d()}>Close</button>
1283
+ </div>
1284
+ ${this._shareStatus?l`<div class="share-status">${this._shareStatus}</div>`:f}
1285
+ </div>
1286
+ `}#P(e,t,s,i){return l`
1287
+ <a
1288
+ href="/api/entries/${t}/${encodeURIComponent(e.id)}/attachments/${encodeURIComponent(s.filename)}/view"
1289
+ target="_blank"
1290
+ rel="noopener"
1291
+ @click=${r=>{r.button!==0||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||(r.preventDefault(),this._viewingAttachment=s)}}
1292
+ >${i}</a
1293
+ >
1294
+ <a
1295
+ class="attachment-download"
1296
+ href="/api/entries/${t}/${encodeURIComponent(e.id)}/attachments/${encodeURIComponent(s.filename)}"
1297
+ title="Download"
1298
+ >⇩</a
1299
+ >
1300
+ <button class="attachment-remove" title="Remove" @click=${()=>this.#i(s.filename)}>×</button>
1301
+ `}#R(e,t,s){const i=[...e.children.values()].sort((r,o)=>r.name.localeCompare(o.name));return i.map((r,o)=>{const a=o===i.length-1,c=t.map(u=>u?"│ ":" ").join("")+(a?"└── ":"├── "),d=r.leaf===void 0;return l`
1302
+ <li>
1303
+ <span class="tree-prefix">${c}</span>${d?l`<span class="tree-dir">📁 ${r.name}</span>`:s(r.leaf,r.name)}
1304
+ </li>
1305
+ ${d?this.#R(r,[...t,!a],s):f}
1306
+ `})}#E(e){if(!e.sourceFiles?.length)return f;const t=gt(e.sourceFiles,()=>{});return l`
1307
+ <div class="attachments-section">
1308
+ <h4>Skill files</h4>
1309
+ <ul class="attachment-tree">${this.#R(t,[],(s,i)=>l`<span>${i}</span>`)}</ul>
1310
+ </div>
1311
+ `}#O(e,t){const s=e.attachments??[],i=new Map(s.map(a=>[a.filename,a])),r=s.length?gt(s.map(a=>a.filename),a=>i.get(a)):void 0,o=s.some(a=>a.filename.includes("/"));return l`
1312
+ <div class="attachments-section">
1313
+ <h4>Attachments</h4>
1314
+ ${r?o?l`<ul class="attachment-tree">
1315
+ ${this.#R(r,[],(a,c)=>this.#P(e,t,a,c))}
1316
+ </ul>`:l`
1317
+ <ul>
1318
+ ${s.map(a=>l`<li>${this.#P(e,t,a,a.filename)}</li>`)}
1319
+ </ul>
1320
+ `:f}
1321
+ <label class="attachment-add">
1322
+ + Add
1323
+ <input type="file" @change=${a=>this.#a(a)} />
1324
+ </label>
1325
+ </div>
1326
+ `}#F(e,t,s){const i=document.documentElement.getAttribute("data-theme"),r=i==="light"||i==="dark"?`?theme=${i}`:"",o=`/api/entries/${t}/${encodeURIComponent(e.id)}/attachments/${encodeURIComponent(s.filename)}/view${r}`,a=`/api/entries/${t}/${encodeURIComponent(e.id)}/attachments/${encodeURIComponent(s.filename)}`;return l`
1327
+ <div class="attachment-view-header">
1328
+ <button class="back-button" title="Back to ${e.name??e.key??e.id}" @click=${()=>this._viewingAttachment=null}>
1329
+ ← Back
1330
+ </button>
1331
+ <span class="attachment-view-title" title=${s.filename}>${s.filename}</span>
1332
+ <a class="attachment-view-download" href=${a} title="Download ${s.filename}">⇩ Download</a>
1333
+ </div>
1334
+ ${Ji(s.filename)?l`<img class="attachment-image" src=${o} alt=${s.filename} />`:l`<iframe class="attachment-frame" src=${o} title=${s.filename}></iframe>`}
1335
+ `}render(){if(!this.selected)return l`<div class="empty">Select an entry to view its details.</div>`;if(!this._doc)return f;const e=this._doc,t=this.selected.table==="skills",s=t&&e.folder==="builtin",i=!t&&e.has_frontmatter===!1;return this._addingFrontmatter?l`${this.#S(e,t)}${this.#C()}`:this._editing&&this._draft?l`${this.#S(e,t)}${this.#T(t)}`:this._viewingAttachment?l`${this.#S(e,t)}${this.#F(e,this.selected.table,this._viewingAttachment)}`:l`
1336
+ ${this.#S(e,t)}
1337
+ ${i?l`<div class="bare-notice">No frontmatter — this is a plain, unmanaged file.</div>`:this.#z(e,t)}
1338
+ ${s?f:l`
1339
+ <div class="actions">
1340
+ ${i?l`<button class="primary" @click=${()=>this.#w()}>Add frontmatter</button>`:l`
1341
+ <button @click=${()=>this.#b()}>Edit</button>
1342
+ <button @click=${()=>this.#_()}>Rename</button>
1343
+ <button @click=${()=>this.#n()}>${e.deprecated?"Un-deprecate":"Mark deprecated"}</button>
1344
+ <button @click=${()=>this.#r()}>${e.paused?"Resume":"Pause"}</button>
1345
+ ${t?f:l`<button class="danger" @click=${()=>this.#k()}>Delete frontmatter</button>`}
1346
+ ${e.remoteInfo?l`<button @click=${()=>this.#o()}>Share…</button>`:f}
1347
+ `}
1348
+ <button class="danger" @click=${()=>this.#c()}>Delete</button>
1349
+ </div>
1350
+ ${this._renaming?l`
1351
+ <div class="rename-row">
1352
+ <input
1353
+ type="text"
1354
+ .value=${this._renameValue}
1355
+ @input=${r=>this._renameValue=r.target.value}
1356
+ @keydown=${r=>r.key==="Enter"&&this.#m()}
1357
+ />
1358
+ <button @click=${()=>this.#m()}>Save</button>
1359
+ <button @click=${()=>this._renaming=!1}>Cancel</button>
1360
+ </div>
1361
+ `:f}
1362
+ ${this._sharing?this.#I():f}
1363
+ `}
1364
+ ${this.#E(e)}
1365
+ ${this.#O(e,this.selected.table)}
1366
+ <div class="view-toggle">
1367
+ <button
1368
+ class=${this._viewMode==="markdown"?"active":""}
1369
+ @click=${()=>this.#s("markdown")}
1370
+ >
1371
+ Preview
1372
+ </button>
1373
+ <button
1374
+ class=${this._viewMode==="raw"?"active":""}
1375
+ @click=${()=>this.#s("raw")}
1376
+ >
1377
+ Raw
1378
+ </button>
1379
+ </div>
1380
+ ${this._viewMode==="markdown"?l`<div class="markdown-body">${Ui(v.parse(e.body??"",{async:!1,renderer:this.#A(this.selected.table,e.id)}))}</div>`:l`<pre>${e.raw_file??e.body}</pre>`}
1381
+ <div class="source-path" title="click to copy" @click=${()=>this.#t()}>${e.source_path}</div>
1382
+ `}}customElements.define("detail-panel",tr);const F="membkt";let ve;function H(){return ve||(ve=fetch("/api/config").then(n=>n.json()).catch(()=>({folderfooMode:"off",folderfooHost:null}))),ve}class sr extends k{static{this.properties={defaultKind:{attribute:!1},lockKind:{attribute:!1},onAdded:{attribute:!1},onCancel:{attribute:!1}}}#e=new h("skill");#t=new h("local");#s=new h("");#n=new h([]);#r=new h(null);#u=new h("");#a=new h("");#i=new h("");#o=new h(!1);#d=new h(!1);#g=new h(!1);#h=new h("");#c=new h("");#b=new h(!1);#w=new h("");#x=new h(!1);#v=new h("");#p=new h(!1);#y=new h(!1);#$=new h([]);#l=new h("");#k=new h("");#_=new h(!1);#m;#C=new h("mine");#T=new h([]);#S=new h(!1);#z=new h(null);static{this.styles=$`
1383
+ :host { display: block; }
1384
+ .backdrop {
1385
+ position: fixed; inset: 0; background: var(--overlay);
1386
+ display: flex; align-items: center; justify-content: center; z-index: 100;
1387
+ }
1388
+ .modal {
1389
+ background: var(--bg);
1390
+ color: inherit;
1391
+ border-radius: 10px;
1392
+ width: min(560px, 92vw);
1393
+ max-height: 82vh;
1394
+ display: flex;
1395
+ flex-direction: column;
1396
+ box-shadow: 0 8px 40px var(--shadow);
1397
+ border: 1px solid var(--border);
1398
+ }
1399
+ .header { padding: 16px 20px 8px; }
1400
+ h2 { margin: 0; font-size: 16px; }
1401
+ .kind-toggle { display: flex; gap: 8px; padding: 0 20px 12px; }
1402
+ .kind-toggle button {
1403
+ flex: 1; padding: 8px; border: 1px solid var(--border-strong); background: none; color: inherit;
1404
+ border-radius: 6px; cursor: pointer; font-size: 13px;
1405
+ }
1406
+ .kind-toggle button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
1407
+ .breadcrumb-row {
1408
+ padding: 8px 20px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
1409
+ }
1410
+ .breadcrumb {
1411
+ font-size: 12px; opacity: 0.7; font-family: monospace;
1412
+ word-break: break-all;
1413
+ }
1414
+ .hidden-toggle {
1415
+ font-size: 11px; opacity: 0.7; display: flex; align-items: center; gap: 4px;
1416
+ cursor: pointer; white-space: nowrap; user-select: none;
1417
+ }
1418
+ .new-folder-btn {
1419
+ font-size: 11px; opacity: 0.7; background: none; border: none; color: inherit;
1420
+ cursor: pointer; white-space: nowrap; padding: 0;
1421
+ }
1422
+ .new-folder-btn:hover { opacity: 1; }
1423
+ .new-folder-row {
1424
+ padding: 8px 20px; display: flex; align-items: center; gap: 8px;
1425
+ border-top: 1px solid var(--border);
1426
+ }
1427
+ .new-folder-row input[type='text'] {
1428
+ flex: 1; padding: 5px 8px; font-size: 12px;
1429
+ border: 1px solid var(--border-strong); border-radius: 6px; background: none; color: inherit;
1430
+ }
1431
+ .new-folder-row button {
1432
+ font-size: 11px; padding: 5px 10px; border: 1px solid var(--border-strong); background: none;
1433
+ color: inherit; border-radius: 6px; cursor: pointer;
1434
+ }
1435
+ .browser {
1436
+ flex: 1; overflow-y: auto; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
1437
+ min-height: 200px;
1438
+ }
1439
+ .entry {
1440
+ padding: 8px 20px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 8px;
1441
+ }
1442
+ .entry:hover { background: var(--hover); }
1443
+ .entry .icon { opacity: 0.6; }
1444
+ .up { opacity: 0.7; }
1445
+ .empty { padding: 16px 20px; opacity: 0.6; font-size: 13px; }
1446
+ .footer { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }
1447
+ .selected-row { font-size: 12px; }
1448
+ .selected-row .path { font-family: monospace; opacity: 0.85; word-break: break-all; }
1449
+ label { font-size: 12px; opacity: 0.7; display: block; margin-bottom: 4px; }
1450
+ input[type='text'] {
1451
+ width: 100%; box-sizing: border-box; padding: 7px 9px; font-size: 13px;
1452
+ border: 1px solid var(--border-strong); border-radius: 6px; background: none; color: inherit;
1453
+ }
1454
+ .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
1455
+ button.primary {
1456
+ background: var(--accent); border: 1px solid var(--accent); color: var(--accent-fg); padding: 7px 16px;
1457
+ border-radius: 6px; cursor: pointer; font-size: 13px;
1458
+ }
1459
+ button.primary:disabled { opacity: 0.5; cursor: default; }
1460
+ button.secondary {
1461
+ background: none; border: 1px solid var(--border-strong); color: inherit; padding: 7px 16px;
1462
+ border-radius: 6px; cursor: pointer; font-size: 13px;
1463
+ }
1464
+ .error { color: var(--danger); font-size: 12px; }
1465
+ .source-toggle { display: flex; gap: 8px; padding: 0 20px 12px; }
1466
+ .source-toggle button {
1467
+ flex: 1; padding: 8px; border: 1px solid var(--border-strong); background: none; color: inherit;
1468
+ border-radius: 6px; cursor: pointer; font-size: 13px;
1469
+ }
1470
+ .source-toggle button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
1471
+ .ff-body { padding: 4px 20px 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
1472
+ .ff-hint { font-size: 12px; opacity: 0.7; }
1473
+ .ff-connected-row {
1474
+ font-size: 12px; display: flex; align-items: center; gap: 6px; padding: 6px 0;
1475
+ }
1476
+ .ff-connected-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
1477
+ .ff-folder-list { border: 1px solid var(--border); border-radius: 6px; max-height: 220px; overflow-y: auto; }
1478
+ .ff-folder-entry {
1479
+ padding: 8px 12px; cursor: pointer; font-size: 13px; font-family: monospace;
1480
+ }
1481
+ .ff-folder-entry:hover { background: var(--hover); }
1482
+ .ff-folder-entry.selected { background: var(--accent); color: var(--accent-fg); }
1483
+ .ff-empty { padding: 12px; opacity: 0.6; font-size: 13px; }
1484
+ .ff-widget-slot { display: flex; }
1485
+ `}constructor(){super(),new N(this),this.defaultKind="skill",this.lockKind=!1}connectedCallback(){super.connectedCallback(),this.#e.set(this.defaultKind),this.#A()}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this.#m)}async#A(e){const t=new URLSearchParams;e&&t.set("path",e),this.#d.value&&t.set("hidden","1");const s=await fetch(`/api/fs/list?${t.toString()}`);if(!s.ok){this.#i.set((await s.json()).error??"failed to list directory");return}const i=await s.json();this.#s.set(i.path),this.#r.set(i.parent),this.#n.set(i.entries),this.#i.set(""),this.renderRoot.querySelector(".browser")?.scrollTo(0,0)}#I(){this.#d.set(!this.#d.value),this.#A(this.#s.value)}#P(){this.#h.set(""),this.#g.set(!0)}#R(){this.#g.set(!1),this.#h.set("")}async#E(){const e=this.#h.value.trim();if(e){this.#i.set("");try{const t=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:this.#s.value,name:e})}),s=await t.json();if(!t.ok){this.#i.set(s.error??"failed to create folder");return}this.#g.set(!1),this.#h.set(""),await this.#A(this.#s.value)}catch(t){this.#i.set(t.message)}}}#O(){this.#u.set(this.#s.value),this.#a.value||this.#a.set(this.#s.value.split("/").filter(Boolean).pop()??"")}async#F(){const e=this.#u.value||this.#s.value;if(e){this.#o.set(!0),this.#i.set("");try{const t=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:this.#e.value,name:this.#a.value||void 0,path:e})}),s=await t.json();if(!t.ok){this.#i.set(s.error??"failed to add folder");return}this.onAdded()}finally{this.#o.set(!1)}}}async#G(){if(this.#p.value)return;const{folderfooMode:e,folderfooHost:t}=await H();if(e==="off"||!t)return;let s=null;try{s=localStorage.getItem("folderfoo_token")}catch{}s&&(this.#c.set(t),this.#v.set(F),this.#x.set(!0),this.#W(s))}async#U(){if(!this.#c.value){this.#i.set("enter a server URL first");return}this.#i.set("");try{await ae(()=>import(`${this.#c.value}/elements/folderfoo-profile-circle.js`),[]),this.#b.set(!0),this.#w.set(""),await this.updateComplete;const e=this.renderRoot.querySelector(".ff-widget-slot");if(e&&!e.querySelector("folderfoo-profile-circle")){const t=document.createElement("folderfoo-profile-circle");t.setAttribute("app-name","Memory Bucket"),e.appendChild(t)}this.#m=setInterval(()=>this.#j(),800),this.#j()}catch(e){this.#w.set(e.message)}}#j(){let e=null;try{e=localStorage.getItem("folderfoo_token")}catch{}!e||this.#p.value||(clearInterval(this.#m),this.#W(e))}async#W(e){this.#y.set(!0),this.#i.set("");try{const t=await fetch("/api/folderfoo/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:this.#c.value,token:e})}),s=await t.json();if(!t.ok){this.#i.set(s.error??"failed to persist folderfoo session");return}this.#p.set(!0),this.#v.set(F),await this.#q()}finally{this.#y.set(!1)}}async#q(e,t){this.#_.set(!0),this.#i.set("");try{const s=new URLSearchParams({server:this.#c.value,tenantId:this.#v.value});e&&s.set("owner",e),t&&s.set("rootFolder",t);const i=await fetch(`/api/folderfoo/folders?${s.toString()}`),r=await i.json();if(!i.ok){this.#i.set(r.error??"failed to list folderfoo folders");return}this.#$.set(r)}finally{this.#_.set(!1)}}async#J(){this.#S.set(!0),this.#i.set("");try{const e=new URLSearchParams({server:this.#c.value,tenantId:this.#v.value}),t=await fetch(`/api/folderfoo/shared-folders?${e.toString()}`),s=await t.json();if(!t.ok){this.#i.set(s.error??"failed to list folders shared with you");return}this.#T.set(s)}finally{this.#S.set(!1)}}#B(e){this.#C.set(e),this.#z.set(null),this.#l.set(""),this.#k.set(""),e==="shared"&&this.#T.value.length===0?this.#J():e==="mine"&&this.#q()}#Y(e){this.#z.set(e),this.#q(e.owner,e.path)}#H(e,t){this.#l.set(e),this.#k.set(t??""),this.#a.value||this.#a.set(e.split("/").filter(Boolean).pop()??this.#v.value)}#Q(e){this.#H(e.path,e.owner)}async#X(){if(this.#l.value){this.#o.set(!0),this.#i.set("");try{const e=await fetch("/api/remote-folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:this.#e.value,name:this.#a.value||void 0,server:this.#c.value,tenantId:this.#v.value,folderPath:this.#l.value,owner:this.#k.value||void 0})}),t=await e.json();if(!e.ok){this.#i.set(t.error??"failed to connect folder");return}this.onAdded(t.kindMismatchWarning)}finally{this.#o.set(!1)}}}#ee(){const e=this.#n.value;return l`
1486
+ <div class="breadcrumb-row">
1487
+ <div class="breadcrumb">${this.#s.value}</div>
1488
+ <button class="new-folder-btn" @click=${()=>this.#P()}>+ New folder</button>
1489
+ <label class="hidden-toggle">
1490
+ <input type="checkbox" .checked=${this.#d.value} @change=${()=>this.#I()} />
1491
+ Show hidden
1492
+ </label>
1493
+ </div>
1494
+ ${this.#g.value?l`
1495
+ <div class="new-folder-row">
1496
+ <input
1497
+ type="text"
1498
+ placeholder="Folder name"
1499
+ .value=${this.#h.value}
1500
+ @input=${t=>this.#h.set(t.target.value)}
1501
+ @keydown=${t=>{t.key==="Enter"&&this.#E(),t.key==="Escape"&&this.#R()}}
1502
+ />
1503
+ <button @click=${()=>this.#E()}>Create</button>
1504
+ <button @click=${()=>this.#R()}>Cancel</button>
1505
+ </div>
1506
+ `:""}
1507
+ <div class="browser">
1508
+ ${this.#r.value?l`<div class="entry up" @click=${()=>this.#A(this.#r.value)}>
1509
+ <span class="icon">📁</span> ..
1510
+ </div>`:""}
1511
+ ${e.length===0&&!this.#r.value?l`<div class="empty">No subdirectories here.</div>`:e.map(t=>l`<div class="entry" @click=${()=>this.#A(t.path)}>
1512
+ <span class="icon">📁</span> ${t.name}
1513
+ </div>`)}
1514
+ </div>
1515
+ <div class="footer">
1516
+ <button class="secondary" @click=${()=>this.#O()}>
1517
+ Select this folder
1518
+ </button>
1519
+ ${this.#u.value?l`<div class="selected-row">Selected: <span class="path">${this.#u.value}</span></div>`:""}
1520
+ <div>
1521
+ <label>Folder name</label>
1522
+ <input
1523
+ type="text"
1524
+ .value=${this.#a.value}
1525
+ placeholder="e.g. personal, company"
1526
+ @input=${t=>this.#a.set(t.target.value)}
1527
+ />
1528
+ </div>
1529
+ ${this.#i.value?l`<div class="error">${this.#i.value}</div>`:""}
1530
+ <div class="actions">
1531
+ <button class="secondary" @click=${()=>this.onCancel()}>Cancel</button>
1532
+ <button
1533
+ class="primary"
1534
+ ?disabled=${!this.#u.value||this.#o.value}
1535
+ @click=${()=>this.#F()}
1536
+ >
1537
+ ${this.#o.value?"Adding…":"Add folder"}
1538
+ </button>
1539
+ </div>
1540
+ </div>
1541
+ `}#M(){const e=this.#$.value;if(this.#x.value&&!this.#p.value)return l`
1542
+ <div class="ff-body">
1543
+ <div class="ff-connected-row"><span class="ff-connected-dot"></span> Already signed in to ${this.#c.value} — connecting…</div>
1544
+ ${this.#i.value?l`<div class="error">${this.#i.value}</div>`:""}
1545
+ <div class="actions">
1546
+ <button class="secondary" @click=${()=>this.onCancel()}>Cancel</button>
1547
+ </div>
1548
+ </div>
1549
+ `;if(!this.#p.value)return l`
1550
+ <div class="ff-body">
1551
+ <div class="ff-hint">
1552
+ Sign in to a folderfoo server to mount one of your folders (or a folder shared with you) as a
1553
+ ${this.#e.value==="skill"?"skill":"memory"} source. Content stays live-synced from folderfoo —
1554
+ reads and writes go straight through, with a local cache for fast search.
1555
+ </div>
1556
+ <div>
1557
+ <label>Server URL</label>
1558
+ <input
1559
+ type="text"
1560
+ .value=${this.#c.value}
1561
+ placeholder="https://folderfoo.example.com"
1562
+ ?disabled=${this.#b.value}
1563
+ @input=${i=>this.#c.set(i.target.value)}
1564
+ @keydown=${i=>i.key==="Enter"&&this.#U()}
1565
+ />
1566
+ </div>
1567
+ ${this.#b.value?l`
1568
+ <div class="ff-hint">Sign in below (this is folderfoo's own login widget, same one every folderfoo app uses):</div>
1569
+ <div class="ff-widget-slot"></div>
1570
+ ${this.#y.value?l`<div class="ff-hint">Finishing connection…</div>`:""}
1571
+ `:l`
1572
+ <div class="actions" style="justify-content: flex-start; margin-top: 0;">
1573
+ <button class="secondary" @click=${()=>this.#U()}>Continue</button>
1574
+ </div>
1575
+ `}
1576
+ ${this.#w.value?l`<div class="error">${this.#w.value}</div>`:""}
1577
+ ${this.#i.value?l`<div class="error">${this.#i.value}</div>`:""}
1578
+ <div class="actions">
1579
+ <button class="secondary" @click=${()=>this.onCancel()}>Cancel</button>
1580
+ </div>
1581
+ </div>
1582
+ `;const t=this.#T.value,s=this.#z.value;return l`
1583
+ <div class="ff-body">
1584
+ <div class="ff-connected-row"><span class="ff-connected-dot"></span> Connected to ${this.#c.value}</div>
1585
+ <div class="kind-toggle">
1586
+ <button
1587
+ class=${this.#C.value==="mine"?"active":""}
1588
+ @click=${()=>this.#B("mine")}
1589
+ >
1590
+ My folders
1591
+ </button>
1592
+ <button
1593
+ class=${this.#C.value==="shared"?"active":""}
1594
+ @click=${()=>this.#B("shared")}
1595
+ >
1596
+ Shared with me
1597
+ </button>
1598
+ </div>
1599
+ ${this.#C.value==="mine"?l`
1600
+ ${e.length>0?l`
1601
+ <div class="ff-folder-list">
1602
+ ${e.map(i=>l`<div
1603
+ class="ff-folder-entry ${this.#l.value===i.path&&!this.#k.value?"selected":""}"
1604
+ @click=${()=>this.#H(i.path)}
1605
+ >
1606
+ ${i.path}
1607
+ </div>`)}
1608
+ </div>
1609
+ `:this.#_.value?l`<div class="ff-hint">Loading folders…</div>`:l`<div class="ff-empty">No folders found.</div>`}
1610
+ `:s?l`
1611
+ <div class="breadcrumb-row">
1612
+ <div class="breadcrumb">${s.owner}:${s.path}</div>
1613
+ <button class="new-folder-btn" @click=${()=>this.#B("shared")}>← Back</button>
1614
+ </div>
1615
+ <div
1616
+ class="ff-folder-entry ${this.#l.value===s.path&&this.#k.value===s.owner?"selected":""}"
1617
+ @click=${()=>this.#Q(s)}
1618
+ >
1619
+ (connect this folder itself)
1620
+ </div>
1621
+ ${e.length>0?l`
1622
+ <div class="ff-folder-list">
1623
+ ${e.map(i=>l`<div
1624
+ class="ff-folder-entry ${this.#l.value===i.path&&this.#k.value===s.owner?"selected":""}"
1625
+ @click=${()=>this.#H(i.path,s.owner)}
1626
+ >
1627
+ ${i.path}
1628
+ </div>`)}
1629
+ </div>
1630
+ `:this.#_.value?l`<div class="ff-hint">Loading folders…</div>`:l`<div class="ff-empty">No subfolders.</div>`}
1631
+ `:l`
1632
+ ${t.length>0?l`
1633
+ <div class="ff-folder-list">
1634
+ ${t.map(i=>l`<div class="ff-folder-entry" @click=${()=>this.#Y(i)}>
1635
+ ${i.path} <span style="opacity:0.6">— shared by ${i.owner}${i.role==="member"?" (read-only)":""}</span>
1636
+ </div>`)}
1637
+ </div>
1638
+ `:this.#S.value?l`<div class="ff-hint">Loading shared folders…</div>`:l`<div class="ff-empty">No one has shared a folder with you yet.</div>`}
1639
+ `}
1640
+ ${this.#l.value?l`<div class="selected-row">
1641
+ Selected: <span class="path">${this.#k.value?`${this.#k.value}:`:""}${this.#l.value}</span>
1642
+ </div>`:""}
1643
+ <div>
1644
+ <label>Folder name</label>
1645
+ <input
1646
+ type="text"
1647
+ .value=${this.#a.value}
1648
+ placeholder="e.g. team-qa"
1649
+ @input=${i=>this.#a.set(i.target.value)}
1650
+ />
1651
+ </div>
1652
+ ${this.#i.value?l`<div class="error">${this.#i.value}</div>`:""}
1653
+ <div class="actions">
1654
+ <button class="secondary" @click=${()=>this.onCancel()}>Cancel</button>
1655
+ <button
1656
+ class="primary"
1657
+ ?disabled=${!this.#l.value||this.#o.value}
1658
+ @click=${()=>this.#X()}
1659
+ >
1660
+ ${this.#o.value?"Connecting…":"Connect folder"}
1661
+ </button>
1662
+ </div>
1663
+ </div>
1664
+ `}render(){return l`
1665
+ <div class="backdrop" @click=${e=>e.target===e.currentTarget&&this.onCancel()}>
1666
+ <div class="modal">
1667
+ <div class="header"><h2>Add a folder</h2></div>
1668
+ ${this.lockKind?l``:l`
1669
+ <div class="kind-toggle">
1670
+ <button
1671
+ class=${this.#e.value==="skill"?"active":""}
1672
+ @click=${()=>this.#e.set("skill")}
1673
+ >
1674
+ Skill folder
1675
+ </button>
1676
+ <button
1677
+ class=${this.#e.value==="memory"?"active":""}
1678
+ @click=${()=>this.#e.set("memory")}
1679
+ >
1680
+ Memory folder
1681
+ </button>
1682
+ </div>
1683
+ `}
1684
+ <div class="source-toggle">
1685
+ <button class=${this.#t.value==="local"?"active":""} @click=${()=>this.#t.set("local")}>
1686
+ Local folder
1687
+ </button>
1688
+ <button
1689
+ class=${this.#t.value==="folderfoo"?"active":""}
1690
+ @click=${()=>{this.#t.set("folderfoo"),this.#G()}}
1691
+ >
1692
+ Connect folderfoo
1693
+ </button>
1694
+ </div>
1695
+ ${this.#t.value==="local"?this.#ee():this.#M()}
1696
+ </div>
1697
+ </div>
1698
+ `}}customElements.define("add-folder-modal",sr);function vt(n){const e=Date.now()-n,t=Math.floor(e/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const s=Math.floor(t/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}class ir extends k{static{this.properties={channels:{attribute:!1},selected:{attribute:!1},detail:{attribute:!1},loading:{attribute:!1},onSelect:{attribute:!1},onRefresh:{attribute:!1}}}static{this.styles=$`
1699
+ :host { display: flex; flex: 1 1 auto; min-height: 0; }
1700
+ .nav {
1701
+ flex: 0 0 260px;
1702
+ overflow-y: auto;
1703
+ border-right: 1px solid var(--border);
1704
+ display: flex;
1705
+ flex-direction: column;
1706
+ }
1707
+ .nav-header {
1708
+ padding: 10px 14px;
1709
+ padding-top: 46px;
1710
+ font-size: 11px;
1711
+ font-weight: 600;
1712
+ text-transform: uppercase;
1713
+ opacity: 0.6;
1714
+ background: var(--bg);
1715
+ border-bottom: 1px solid var(--border);
1716
+ display: flex;
1717
+ align-items: center;
1718
+ justify-content: space-between;
1719
+ }
1720
+ .refresh-btn {
1721
+ border: none; background: none; color: inherit; cursor: pointer; opacity: 0.6;
1722
+ font-size: 12px; padding: 2px 4px; border-radius: 4px;
1723
+ }
1724
+ .refresh-btn:hover { opacity: 1; background: var(--hover); }
1725
+ .channel-row {
1726
+ padding: 10px 14px;
1727
+ border-bottom: 1px solid var(--border);
1728
+ cursor: pointer;
1729
+ display: flex;
1730
+ flex-direction: column;
1731
+ gap: 2px;
1732
+ }
1733
+ .channel-row:hover { background: var(--hover); }
1734
+ .channel-row.active { background: var(--accent-tint); border-left: 3px solid var(--accent); padding-left: 11px; }
1735
+ .channel-name { font-size: 13px; font-weight: 600; font-family: ui-monospace, monospace; }
1736
+ .channel-meta { font-size: 11px; opacity: 0.6; }
1737
+ .empty { padding: 24px; opacity: 0.6; font-size: 13px; }
1738
+ .content-pane { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: 16px 20px; padding-top: 46px; }
1739
+ .content-header {
1740
+ display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
1741
+ margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
1742
+ }
1743
+ .content-title { font-size: 15px; font-weight: 700; font-family: ui-monospace, monospace; }
1744
+ .content-meta { font-size: 12px; opacity: 0.6; }
1745
+ .content-body {
1746
+ white-space: pre-wrap;
1747
+ word-break: break-word;
1748
+ font-family: ui-monospace, monospace;
1749
+ font-size: 13px;
1750
+ line-height: 1.5;
1751
+ }
1752
+ .no-selection {
1753
+ flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
1754
+ opacity: 0.5; font-size: 13px; padding-top: 46px;
1755
+ }
1756
+ .placeholder-empty { opacity: 0.5; font-style: italic; }
1757
+ `}#e(){return!this.channels||this.channels.length===0?l`<div class="empty">No live channels right now. Channels appear here once an agent posts to one with memory_channel_post — they're ephemeral and disappear after a long idle period or server restart.</div>`:[...this.channels].sort((t,s)=>s.lastActivityAt-t.lastActivityAt).map(t=>l`
1758
+ <div
1759
+ class="channel-row ${this.selected===t.name?"active":""}"
1760
+ @click=${()=>this.onSelect(t.name)}
1761
+ >
1762
+ <span class="channel-name">${t.name}</span>
1763
+ <span class="channel-meta">${vt(t.lastActivityAt)}</span>
1764
+ </div>
1765
+ `)}#t(){return this.selected?this.loading?l`<div class="content-pane"><div class="content-meta">Loading…</div></div>`:this.detail?l`
1766
+ <div class="content-pane">
1767
+ <div class="content-header">
1768
+ <span class="content-title">${this.detail.name}</span>
1769
+ <span class="content-meta">last activity ${vt(this.detail.lastActivityAt)}</span>
1770
+ </div>
1771
+ ${this.detail.content?l`<div class="content-body">${this.detail.content}</div>`:l`<div class="placeholder-empty">Channel exists but nothing has been posted yet.</div>`}
1772
+ </div>
1773
+ `:l`<div class="content-pane"><div class="content-meta">Channel not found — it may have gone idle and been swept.</div></div>`:l`<div class="no-selection">Select a channel to view its content.</div>`}render(){return l`
1774
+ <div class="nav">
1775
+ <div class="nav-header">
1776
+ <span>Live channels</span>
1777
+ <button class="refresh-btn" title="Refresh" @click=${()=>this.onRefresh()}>⟳</button>
1778
+ </div>
1779
+ ${this.#e()}
1780
+ </div>
1781
+ ${this.#t()}
1782
+ `}}customElements.define("channel-view",ir);function rr(n){const e=new Map;for(const t of n){const s=t.tags.length>0?t.tags:[null];for(const i of s){const r=e.get(i);r?r.push(t):e.set(i,[t])}}return[...e.entries()].map(([t,s])=>({tag:t,items:s})).sort((t,s)=>t.tag===null?1:s.tag===null?-1:t.tag.localeCompare(s.tag))}function nr(n,e){const t=new Map;for(const r of n){const o=t.get(r.folder);o?o.push(r):t.set(r.folder,[r])}const s=[],i=[];for(const r of e){const o=t.get(r.name);if(!o)continue;const a={folder:r,tagGroups:[{tag:null,items:o}]};(r.remote?i:s).push(a)}return{local:s,remote:i}}const es="mem-bucket-folder-view-mode",ts="mem-bucket-folder-view-expanded",xt="mem-bucket-folder-view-tree-split-pct",yt="mem-bucket-folder-view-list-split-pct",kt=12,wt=40,$t=20,_t=80;function St(n,e,t,s){const i=Number(localStorage.getItem(n));return Number.isFinite(i)&&i>=t&&i<=s?i:e}const or=[{value:"all",label:"All"},{value:"skill",label:"Skills"},{value:"memory",label:"Memories"}],ar=[{value:"a",label:"Folder tree"},{value:"b",label:"Breadcrumb drill-down"},{value:"c",label:"Tag → Name"}];function lr(){const n=localStorage.getItem(es);return n==="a"||n==="b"||n==="c"?n:"a"}function cr(){try{const n=localStorage.getItem(ts);if(!n)return new Set;const e=JSON.parse(n);return Array.isArray(e)?new Set(e.map(String)):new Set}catch{return new Set}}function Ct(n){localStorage.setItem(ts,JSON.stringify([...n]))}class dr extends k{static{this.properties={entries:{attribute:!1},allFolders:{attribute:!1},facets:{attribute:!1},typeFilter:{attribute:!1},onTypeChange:{attribute:!1},onChanged:{attribute:!1},onDateClick:{attribute:!1},onKeyClick:{attribute:!1}}}#e=new h(lr());#t=new h(cr());#s=new h([]);#n=new h(null);#r=new h(null);#u=new h(St(xt,20,kt,wt));#a=new h(St(yt,40,$t,_t));#i=new h(null);#o=e=>this.#b(e);#d=()=>this.#w();static{this.styles=$`
1783
+ :host { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
1784
+ .mode-row {
1785
+ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px;
1786
+ border-bottom: 1px solid var(--border); background: var(--bg-subtle);
1787
+ }
1788
+ .mode-row .filter-label { font-size: 12px; opacity: 0.6; font-weight: 600; }
1789
+ .mode-row select {
1790
+ font-size: 13px; padding: 6px 8px; height: 30px; box-sizing: border-box;
1791
+ border: 1px solid var(--border-strong); border-radius: 6px; background: none; color: inherit;
1792
+ }
1793
+ .type-toggle { display: flex; gap: 0; }
1794
+ .type-toggle button {
1795
+ border: 1px solid var(--border-strong);
1796
+ background: none;
1797
+ color: inherit;
1798
+ padding: 6px 12px;
1799
+ font-size: 13px;
1800
+ cursor: pointer;
1801
+ height: 30px;
1802
+ box-sizing: border-box;
1803
+ }
1804
+ .type-toggle button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
1805
+ .type-toggle button:first-child { border-radius: 6px 0 0 6px; }
1806
+ .type-toggle button:last-child { border-radius: 0 6px 6px 0; }
1807
+ .type-toggle button:not(:first-child) { border-left: none; }
1808
+ .body-region { display: flex; flex: 1 1 auto; min-height: 0; }
1809
+ .tree-rail { flex: 0 0 auto; overflow-y: auto; padding: 8px 0; box-sizing: border-box; }
1810
+ result-list { flex: 0 0 auto; overflow-y: auto; box-sizing: border-box; }
1811
+ detail-panel { flex: 1 1 auto; min-width: 0; overflow-y: auto; }
1812
+ .no-selection {
1813
+ flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
1814
+ opacity: 0.5; font-size: 13px;
1815
+ }
1816
+ .splitter {
1817
+ flex: 0 0 auto;
1818
+ width: 6px;
1819
+ cursor: col-resize;
1820
+ background: var(--hover);
1821
+ position: relative;
1822
+ }
1823
+ .splitter:hover, .splitter.dragging { background: var(--accent-tint); }
1824
+ .splitter::after {
1825
+ content: '';
1826
+ position: absolute;
1827
+ top: 0; bottom: 0;
1828
+ left: -3px; right: -3px;
1829
+ }
1830
+ .section-header {
1831
+ padding: 8px 14px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; opacity: 0.55;
1832
+ }
1833
+ .node {
1834
+ display: flex; align-items: center; gap: 6px; padding: 6px 14px; cursor: pointer; font-size: 13px;
1835
+ border: none; background: none; color: inherit; width: 100%; text-align: left; box-sizing: border-box;
1836
+ }
1837
+ .node:hover { background: var(--hover); }
1838
+ .node.active { background: var(--accent-tint); }
1839
+ .node .caret { width: 12px; flex: 0 0 auto; opacity: 0.6; font-size: 10px; }
1840
+ .node .icon { flex: 0 0 auto; }
1841
+ .node .label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1842
+ .node .count { flex: 0 0 auto; opacity: 0.5; font-size: 11px; }
1843
+ .node.remote .icon { color: var(--accent); }
1844
+ .indent-1 { padding-left: 30px; }
1845
+ .indent-2 { padding-left: 46px; }
1846
+ .empty { padding: 24px; opacity: 0.6; font-size: 13px; }
1847
+ .breadcrumb-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; }
1848
+ .breadcrumb-bar button {
1849
+ background: none; border: none; color: inherit; cursor: pointer; padding: 2px 4px;
1850
+ text-decoration: underline; text-underline-offset: 2px; font: inherit;
1851
+ }
1852
+ .breadcrumb-sep { opacity: 0.5; }
1853
+ .folder-card {
1854
+ display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px;
1855
+ border: none; background: none; color: inherit; width: 100%; text-align: left; box-sizing: border-box;
1856
+ }
1857
+ .folder-card:hover { background: var(--hover); }
1858
+ `}constructor(){super(),new N(this)}#g(e){this.#e.set(e),localStorage.setItem(es,e),this.#t.set(new Set),Ct(new Set),this.#s.set([]),this.#n.set(null),this.#r.set(null)}#h(e){this.#g(e.target.value)}#c(e,t){t.preventDefault(),this.#i.set(e),document.addEventListener("pointermove",this.#o),document.addEventListener("pointerup",this.#d)}#b(e){const t=this.#i.value;if(!t)return;const s=this.renderRoot.querySelector(".body-region");if(!s)return;const i=s.getBoundingClientRect(),r=(e.clientX-i.left)/i.width*100;if(t==="tree")this.#u.set(Math.min(wt,Math.max(kt,r)));else{const o=100-this.#u.value,a=o>0?(r-this.#u.value)/o*100:0;this.#a.set(Math.min(_t,Math.max($t,a)))}}#w(){const e=this.#i.value;this.#i.set(null),document.removeEventListener("pointermove",this.#o),document.removeEventListener("pointerup",this.#d),e==="tree"?localStorage.setItem(xt,String(this.#u.value)):e==="list"&&localStorage.setItem(yt,String(this.#a.value))}#x(e){const t=new Set(this.#t.value);t.has(e)?t.delete(e):t.add(e),this.#t.set(t),Ct(t)}#v(e,t){this.#n.set({folder:e,tag:t})}#p(e){this.#n.set(null),this.#r.set({table:e._table,id:e.id})}#y(e){this.#r.set({table:e._table,id:e.id})}#$(e,t){const s=this.#t.value.has(t),i=e.tagGroups.reduce((o,a)=>o+a.items.length,0),r=this.#n.value?.folder===e.folder.name&&this.#n.value?.tag===null;return l`
1859
+ <button class="node ${e.folder.remote?"remote":""} ${r?"active":""}" @click=${()=>this.#x(t)}>
1860
+ <span class="caret">${s?"▾":"▸"}</span>
1861
+ <span class="icon">${e.folder.remote?"☁":"📁"}</span>
1862
+ <span
1863
+ class="label"
1864
+ @click=${o=>{o.stopPropagation(),this.#v(e.folder.name,null)}}
1865
+ >${e.folder.name}</span
1866
+ >
1867
+ <span class="count">${i}</span>
1868
+ </button>
1869
+ `}#l(e){const t=(s,i)=>s.length===0?"":l`
1870
+ <div class="section-header">${i}</div>
1871
+ ${s.map(r=>{const o=`folder:${r.folder.name}`,a=this.#t.value.has(o),c=r.tagGroups[0]?.items??[];return l`
1872
+ ${this.#$(r,o)}
1873
+ ${a?c.map(d=>l`
1874
+ <button class="node indent-1" @click=${()=>this.#p(d)}>
1875
+ <span class="caret"></span>
1876
+ <span class="icon">${d._table==="skills"?"⚡":"📝"}</span>
1877
+ <span class="label">${d.name}</span>
1878
+ </button>
1879
+ `):""}
1880
+ `})}
1881
+ `;return e.local.length===0&&e.remote.length===0?l`<div class="empty">No entries.</div>`:l`${t(e.local,"Folders")}${t(e.remote,"Remote")}`}#k(e){const t=this.#s.value;if(t.length===0){const o=[...e.local,...e.remote];return o.length===0?l`<div class="empty">No entries.</div>`:o.map(a=>{const c=a.tagGroups.reduce((d,u)=>d+u.items.length,0);return l`
1882
+ <button
1883
+ class="folder-card ${a.folder.remote?"remote":""}"
1884
+ @click=${()=>this.#s.set([a.folder.name])}
1885
+ >
1886
+ <span class="icon">${a.folder.remote?"☁":"📁"}</span>
1887
+ <span class="label">${a.folder.name}</span>
1888
+ <span class="count">${c}</span>
1889
+ </button>
1890
+ `})}const s=t[0],r=[...e.local,...e.remote].find(o=>o.folder.name===s)?.tagGroups[0]?.items??[];return l`
1891
+ <div class="breadcrumb-bar">
1892
+ <button @click=${()=>this.#s.set([])}>🏠 Folders</button>
1893
+ <span class="breadcrumb-sep">›</span>
1894
+ <span>${s}</span>
1895
+ </div>
1896
+ ${r.length===0?l`<div class="empty">No entries in this folder.</div>`:r.map(o=>l`
1897
+ <button class="node" @click=${()=>this.#p(o)}>
1898
+ <span class="caret"></span>
1899
+ <span class="icon">${o._table==="skills"?"⚡":"📝"}</span>
1900
+ <span class="label">${o.name}</span>
1901
+ </button>
1902
+ `)}
1903
+ `}#_(e){return e.length===0?l`<div class="empty">No entries.</div>`:e.map(t=>{const s=`tag:${t.tag??""}`,i=this.#t.value.has(s),r=this.#n.value?.folder===null&&this.#n.value?.tag===t.tag;return l`
1904
+ <button class="node ${r?"active":""}" @click=${()=>this.#x(s)}>
1905
+ <span class="caret">${i?"▾":"▸"}</span>
1906
+ <span class="icon">${t.tag===null?"":"🏷"}</span>
1907
+ <span
1908
+ class="label"
1909
+ @click=${o=>{o.stopPropagation(),this.#v(null,t.tag)}}
1910
+ >${t.tag??"(untagged)"}</span
1911
+ >
1912
+ <span class="count">${t.items.length}</span>
1913
+ </button>
1914
+ ${i?t.items.map(o=>l`
1915
+ <button class="node indent-1" @click=${()=>this.#p(o)}>
1916
+ <span class="caret"></span>
1917
+ <span class="icon">${o._table==="skills"?"⚡":"📝"}</span>
1918
+ <span class="label">${o.name}</span>
1919
+ <span class="count">${o.folder}</span>
1920
+ </button>
1921
+ `):""}
1922
+ `})}#m(){const e=this.#n.value;return e?(this.entries??[]).filter(s=>(e.folder===null||s.folder===e.folder)&&(e.tag===null||s.tags.includes(e.tag))):[]}render(){const e=this.#e.value,t=this.entries??[],s=this.allFolders??[],i=e==="c"?null:nr(t,s),r=e==="c"?rr(t):null,o=this.#n.value,a=this.#r.value;return l`
1923
+ <div class="mode-row">
1924
+ <span class="filter-label">View:</span>
1925
+ <select .value=${e} @change=${c=>this.#h(c)}>
1926
+ ${ar.map(c=>l`<option value=${c.value}>${c.label}</option>`)}
1927
+ </select>
1928
+ <div class="type-toggle">
1929
+ ${or.map(c=>l`
1930
+ <button
1931
+ class=${this.typeFilter===c.value?"active":""}
1932
+ @click=${()=>this.onTypeChange(c.value)}
1933
+ >
1934
+ ${c.label}
1935
+ </button>
1936
+ `)}
1937
+ </div>
1938
+ <slot name="mode-row-end"></slot>
1939
+ </div>
1940
+ <div class="body-region">
1941
+ <div
1942
+ class="tree-rail"
1943
+ style=${`width: ${this.#u.value}%; border-right: 1px solid var(--border);`}
1944
+ >
1945
+ ${e==="a"?this.#l(i):e==="b"?this.#k(i):this.#_(r)}
1946
+ </div>
1947
+ ${o?l`
1948
+ <div
1949
+ class="splitter ${this.#i.value==="tree"?"dragging":""}"
1950
+ @pointerdown=${c=>this.#c("tree",c)}
1951
+ ></div>
1952
+ <result-list
1953
+ style=${`width: ${this.#a.value}%; border-right: 1px solid var(--border);`}
1954
+ .results=${this.#m()}
1955
+ .showFolder=${!0}
1956
+ .onSelect=${c=>this.#y(c)}
1957
+ .selectedIds=${new Set}
1958
+ .onToggleSelect=${()=>{}}
1959
+ .onKeyClick=${this.onKeyClick}
1960
+ ></result-list>
1961
+ <div
1962
+ class="splitter ${this.#i.value==="list"?"dragging":""}"
1963
+ @pointerdown=${c=>this.#c("list",c)}
1964
+ ></div>
1965
+ `:l`
1966
+ <div
1967
+ class="splitter ${this.#i.value==="tree"?"dragging":""}"
1968
+ @pointerdown=${c=>this.#c("tree",c)}
1969
+ ></div>
1970
+ `}
1971
+ ${a?l`
1972
+ <detail-panel
1973
+ .selected=${a}
1974
+ .facets=${this.facets}
1975
+ .onChanged=${this.onChanged}
1976
+ .onTagClick=${()=>{}}
1977
+ .onFolderClick=${()=>{}}
1978
+ .onDateClick=${this.onDateClick}
1979
+ .onKeyClick=${this.onKeyClick}
1980
+ ></detail-panel>
1981
+ `:l`<div class="no-selection">Select an item to view it.</div>`}
1982
+ </div>
1983
+ `}}customElements.define("folder-view",dr);const hr={system:"◐",light:"☀",dark:"☾"},pr={system:"Auto",light:"Light",dark:"Dark"};class ur extends k{static{this.properties={showReindex:{attribute:!1},reindexing:{attribute:!1},channelsActive:{attribute:!1},folderViewActive:{attribute:!1},showShared:{attribute:!1},sharedActive:{attribute:!1},theme:{attribute:!1},onReindex:{attribute:!1},onToggleChannels:{attribute:!1},onToggleFolderView:{attribute:!1},onToggleShared:{attribute:!1},onCycleTheme:{attribute:!1}}}static{this.styles=$`
1984
+ :host {
1985
+ display: flex;
1986
+ align-items: center;
1987
+ gap: 6px;
1988
+ flex-shrink: 0;
1989
+ font-family: system-ui, sans-serif;
1990
+ font-size: 13px;
1991
+ line-height: normal;
1992
+ color: inherit;
1993
+ }
1994
+ .theme-toggle, .reindex-toggle {
1995
+ width: 28px;
1996
+ height: 28px;
1997
+ border: 1px solid var(--border-strong);
1998
+ border-radius: 50%;
1999
+ background: var(--bg);
2000
+ color: inherit;
2001
+ cursor: pointer;
2002
+ font-size: 14px;
2003
+ line-height: 1;
2004
+ display: flex;
2005
+ align-items: center;
2006
+ justify-content: center;
2007
+ opacity: 0.75;
2008
+ font-family: inherit;
2009
+ }
2010
+ .theme-toggle:hover, .reindex-toggle:hover { opacity: 1; background: var(--hover); }
2011
+ .folderfoo-slot { display: contents; }
2012
+ .reindex-toggle:disabled { cursor: default; opacity: 0.4; }
2013
+ .reindex-toggle.spinning { animation: reindex-spin 0.8s linear infinite; }
2014
+ @keyframes reindex-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
2015
+ .channels-toggle, .folder-view-toggle, .shared-toggle {
2016
+ height: 28px;
2017
+ padding: 0 12px;
2018
+ border: 1px solid var(--border-strong);
2019
+ border-radius: 14px;
2020
+ background: var(--bg);
2021
+ color: inherit;
2022
+ cursor: pointer;
2023
+ font-size: 12px;
2024
+ line-height: 1;
2025
+ display: flex;
2026
+ align-items: center;
2027
+ gap: 5px;
2028
+ opacity: 0.75;
2029
+ font-family: inherit;
2030
+ }
2031
+ .channels-toggle:hover, .folder-view-toggle:hover, .shared-toggle:hover { opacity: 1; background: var(--hover); }
2032
+ .channels-toggle.active, .folder-view-toggle.active, .shared-toggle.active {
2033
+ background: var(--accent); border-color: var(--accent); color: var(--accent-fg); opacity: 1;
2034
+ }
2035
+ `}#e(){return l`
2036
+ <button
2037
+ class=${`reindex-toggle${this.reindexing?" spinning":""}`}
2038
+ title=${this.reindexing?"Reindexing…":"Rebuild cache from disk"}
2039
+ aria-label="Rebuild cache from disk"
2040
+ ?disabled=${this.reindexing}
2041
+ @click=${()=>this.onReindex()}
2042
+ >
2043
+
2044
+ </button>
2045
+ `}render(){return l`
2046
+ ${this.showReindex?this.#e():""}
2047
+ <button
2048
+ class="channels-toggle ${this.channelsActive?"active":""}"
2049
+ title="Live memory channels"
2050
+ @click=${()=>this.onToggleChannels()}
2051
+ >
2052
+ ⛓ Channels
2053
+ </button>
2054
+ <button
2055
+ class="folder-view-toggle ${this.folderViewActive?"active":""}"
2056
+ title="Browse by folder"
2057
+ @click=${()=>this.onToggleFolderView()}
2058
+ >
2059
+ 🗂 Folder View
2060
+ </button>
2061
+ ${this.showShared?l`
2062
+ <button
2063
+ class="shared-toggle ${this.sharedActive?"active":""}"
2064
+ title="Items shared with you"
2065
+ @click=${()=>this.onToggleShared()}
2066
+ >
2067
+ 🤝 Shared
2068
+ </button>
2069
+ `:""}
2070
+ <button
2071
+ class="theme-toggle"
2072
+ title=${`Theme: ${pr[this.theme]} (click to change)`}
2073
+ aria-label="Toggle color theme"
2074
+ @click=${()=>this.onCycleTheme()}
2075
+ >
2076
+ ${hr[this.theme]}
2077
+ </button>
2078
+ <div class="folderfoo-slot"></div>
2079
+ `}}customElements.define("app-toolbar",ur);const Tt="mem-bucket-last-fork-folder";class fr extends k{constructor(){super(...arguments),this._forkOpenFor=null,this._forkFolder=localStorage.getItem(Tt)??"",this._forkBusy=!1,this._forkStatus=null}static{this.properties={items:{attribute:!1},refreshing:{attribute:!1},lastRefreshSummary:{attribute:!1},memoryFolderNames:{attribute:!1},skillFolderNames:{attribute:!1},onRefresh:{attribute:!1},onDismiss:{attribute:!1},onOpen:{attribute:!1},onFork:{attribute:!1},_forkOpenFor:{state:!0},_forkFolder:{state:!0},_forkBusy:{state:!0},_forkStatus:{state:!0}}}static{this.styles=$`
2080
+ :host { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
2081
+ .header {
2082
+ display: flex; align-items: center; gap: 10px; padding: 10px 16px;
2083
+ border-bottom: 1px solid var(--border); background: var(--bg-subtle);
2084
+ }
2085
+ .header h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; opacity: 0.6; margin: 0; flex: 1 1 auto; }
2086
+ .refresh-btn {
2087
+ width: 28px; height: 28px; border: 1px solid var(--border-strong); border-radius: 50%;
2088
+ background: var(--bg); color: inherit; cursor: pointer; font-size: 14px; line-height: 1;
2089
+ display: flex; align-items: center; justify-content: center; opacity: 0.75;
2090
+ }
2091
+ .refresh-btn:hover { opacity: 1; background: var(--hover); }
2092
+ .refresh-btn:disabled { cursor: default; opacity: 0.4; }
2093
+ .refresh-btn.spinning { animation: shared-refresh-spin 0.8s linear infinite; }
2094
+ @keyframes shared-refresh-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
2095
+ .summary { font-size: 12px; opacity: 0.6; }
2096
+ .body { flex: 1 1 auto; overflow-y: auto; }
2097
+ .owner-group { border-bottom: 1px solid var(--border); }
2098
+ .owner-header { padding: 8px 16px 4px; font-size: 12px; font-weight: 600; opacity: 0.7; }
2099
+ .row {
2100
+ display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer;
2101
+ }
2102
+ .row:hover { background: var(--hover); }
2103
+ .row.revoked { opacity: 0.55; cursor: default; }
2104
+ .row .icon { flex: 0 0 auto; }
2105
+ .row .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2106
+ .role-badge {
2107
+ flex: 0 0 auto; font-size: 10px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--border-strong);
2108
+ opacity: 0.7; text-transform: uppercase;
2109
+ }
2110
+ .revoked-badge {
2111
+ flex: 0 0 auto; font-size: 11px; opacity: 0.8; font-style: italic;
2112
+ }
2113
+ .dismiss-btn {
2114
+ flex: 0 0 auto; border: none; background: none; color: inherit; cursor: pointer; opacity: 0.5; font-size: 13px;
2115
+ }
2116
+ .dismiss-btn:hover { opacity: 1; }
2117
+ .fork-btn {
2118
+ flex: 0 0 auto; font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border-strong);
2119
+ background: var(--bg); color: inherit; cursor: pointer; opacity: 0.75;
2120
+ }
2121
+ .fork-btn:hover { opacity: 1; background: var(--hover); }
2122
+ .fork-row {
2123
+ display: flex; align-items: center; gap: 6px; padding: 6px 16px 10px 40px; font-size: 12px;
2124
+ }
2125
+ .fork-row select {
2126
+ font-size: 12px; padding: 3px 6px; border: 1px solid var(--border-strong); border-radius: 4px;
2127
+ background: var(--bg); color: inherit;
2128
+ }
2129
+ .fork-status { font-size: 11px; opacity: 0.75; padding: 0 16px 8px 40px; }
2130
+ .empty { padding: 24px; opacity: 0.6; font-size: 13px; text-align: center; }
2131
+ `}#e(e){const t=new Map;for(const s of e){const i=t.get(s.owner)??[];i.push(s),t.set(s.owner,i)}return t}#t(e){return e==="skill"?this.skillFolderNames??[]:this.memoryFolderNames??[]}#s(e){this._forkOpenFor=this._forkOpenFor===e.origin_id?null:e.origin_id,this._forkStatus=null;const t=this.#t(e.kind);!t.includes(this._forkFolder)&&t.length&&(this._forkFolder=t[0])}async#n(e){if(this._forkFolder){this._forkBusy=!0,this._forkStatus=null;try{const t=await this.onFork(e,this._forkFolder);this._forkStatus=t.message,t.ok&&(localStorage.setItem(Tt,this._forkFolder),this._forkOpenFor=null)}finally{this._forkBusy=!1}}}#r(e){const t=e.status==="revoked",s=!t&&e.entryId!==null,i=this._forkOpenFor===e.origin_id;return l`
2132
+ <div class="row ${t?"revoked":""}" @click=${()=>s&&this.onOpen(e)}>
2133
+ <span class="icon">${e.kind==="skill"?"⚡":"📝"}</span>
2134
+ <span class="name">${e.remote_path}</span>
2135
+ ${t?l`<span class="revoked-badge">no longer shared with you</span>`:l`<span class="role-badge">${e.role}</span>`}
2136
+ ${t?"":l`<button class="fork-btn" @click=${r=>{r.stopPropagation(),this.#s(e)}}>Fork to mine</button>`}
2137
+ ${t?l`<button class="dismiss-btn" title="Dismiss" @click=${r=>{r.stopPropagation(),this.onDismiss(e.origin_id)}}>✕</button>`:""}
2138
+ </div>
2139
+ ${i?l`
2140
+ <div class="fork-row" @click=${r=>r.stopPropagation()}>
2141
+ <select .value=${this._forkFolder} @change=${r=>this._forkFolder=r.target.value}>
2142
+ ${this.#t(e.kind).map(r=>l`<option value=${r}>${r}</option>`)}
2143
+ </select>
2144
+ <button ?disabled=${this._forkBusy||!this._forkFolder} @click=${()=>this.#n(e)}>Copy here</button>
2145
+ <button @click=${()=>this._forkOpenFor=null}>Cancel</button>
2146
+ </div>
2147
+ `:""}
2148
+ ${i&&this._forkStatus?l`<div class="fork-status">${this._forkStatus}</div>`:""}
2149
+ `}render(){const e=this.items??[],t=this.#e(e),s=this.lastRefreshSummary;return l`
2150
+ <div class="header">
2151
+ <h2>Shared with me</h2>
2152
+ ${s?l`<span class="summary">${s.added} added · ${s.updated} updated · ${s.revoked} revoked · ${s.unchanged} unchanged</span>`:""}
2153
+ <button
2154
+ class="refresh-btn ${this.refreshing?"spinning":""}"
2155
+ title="Refresh — check for updates or revoked shares"
2156
+ aria-label="Refresh shared items"
2157
+ ?disabled=${this.refreshing}
2158
+ @click=${()=>this.onRefresh()}
2159
+ >
2160
+
2161
+ </button>
2162
+ </div>
2163
+ <div class="body">
2164
+ ${e.length===0?l`<div class="empty">Nothing shared with you yet. Items shared directly with you, or via a share link, appear here.</div>`:[...t.entries()].map(([i,r])=>l`
2165
+ <div class="owner-group">
2166
+ <div class="owner-header">From ${i}</div>
2167
+ ${r.map(o=>this.#r(o))}
2168
+ </div>
2169
+ `)}
2170
+ </div>
2171
+ `}}customElements.define("shared-with-me-panel",fr);class gr extends k{static{this.properties={entityTitle:{attribute:!1},description:{attribute:!1},tags:{attribute:!1},iconOrEmoji:{attribute:!1},iconImageUrl:{attribute:!1},owner:{attribute:!1},verified:{attribute:!1},stats:{attribute:!1},pinned:{attribute:!1},onPin:{attribute:!1},onCopy:{attribute:!1},copyIcon:{attribute:!1},onEdit:{attribute:!1},onDelete:{attribute:!1},selected:{attribute:!1},onClick:{attribute:!1},onActivate:{attribute:!1},actionLabel:{attribute:!1},onAction:{attribute:!1}}}static{this.styles=$`
2172
+ :host { display: block; height: 100%; box-sizing: border-box; }
2173
+ .card {
2174
+ display: flex;
2175
+ flex-direction: column;
2176
+ height: 100%;
2177
+ box-sizing: border-box;
2178
+ border-radius: 10px;
2179
+ border: 1px solid var(--border);
2180
+ background: var(--bg);
2181
+ padding: 14px;
2182
+ color: inherit;
2183
+ transition: border-color 0.15s, background 0.15s;
2184
+ cursor: default;
2185
+ }
2186
+ .card.clickable { cursor: pointer; }
2187
+ .card:hover { background: var(--hover); }
2188
+ .card.selected { border-color: var(--accent); background: var(--accent-tint); }
2189
+ .top-row {
2190
+ display: flex;
2191
+ align-items: flex-start;
2192
+ justify-content: space-between;
2193
+ gap: 10px;
2194
+ margin-bottom: 10px;
2195
+ }
2196
+ .logo-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
2197
+ .logo {
2198
+ width: 32px;
2199
+ height: 32px;
2200
+ border-radius: 6px;
2201
+ object-fit: cover;
2202
+ flex-shrink: 0;
2203
+ }
2204
+ .logo-emoji {
2205
+ width: 32px;
2206
+ height: 32px;
2207
+ border-radius: 6px;
2208
+ flex-shrink: 0;
2209
+ display: flex;
2210
+ align-items: center;
2211
+ justify-content: center;
2212
+ font-size: 17px;
2213
+ background: var(--bg-subtle);
2214
+ }
2215
+ .name-group { min-width: 0; }
2216
+ .name {
2217
+ font-size: 14px;
2218
+ font-weight: 600;
2219
+ line-height: 1.3;
2220
+ margin: 0;
2221
+ display: -webkit-box;
2222
+ -webkit-line-clamp: 2;
2223
+ -webkit-box-orient: vertical;
2224
+ overflow: hidden;
2225
+ }
2226
+ .owner-row { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
2227
+ .owner {
2228
+ font-size: 12px;
2229
+ opacity: 0.65;
2230
+ white-space: nowrap;
2231
+ overflow: hidden;
2232
+ text-overflow: ellipsis;
2233
+ }
2234
+ .check { width: 12px; height: 12px; color: var(--accent); flex-shrink: 0; }
2235
+ .description {
2236
+ font-size: 12.5px;
2237
+ line-height: 1.45;
2238
+ opacity: 0.8;
2239
+ margin: 0 0 10px 0;
2240
+ display: -webkit-box;
2241
+ -webkit-line-clamp: 2;
2242
+ -webkit-box-orient: vertical;
2243
+ overflow: hidden;
2244
+ white-space: pre-wrap;
2245
+ }
2246
+ .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
2247
+ .badge {
2248
+ display: inline-flex;
2249
+ align-items: center;
2250
+ height: 18px;
2251
+ padding: 0 7px;
2252
+ border-radius: 9999px;
2253
+ font-size: 10px;
2254
+ font-weight: 500;
2255
+ white-space: nowrap;
2256
+ border: 1px solid var(--border-strong);
2257
+ background: var(--bg-subtle);
2258
+ }
2259
+ .spacer { flex: 1; }
2260
+ .footer {
2261
+ display: flex;
2262
+ align-items: center;
2263
+ justify-content: space-between;
2264
+ gap: 8px;
2265
+ padding-top: 10px;
2266
+ margin-top: auto;
2267
+ border-top: 1px solid var(--border);
2268
+ font-size: 12px;
2269
+ opacity: 0.75;
2270
+ }
2271
+ .footer.no-stats { justify-content: flex-end; }
2272
+ .stats-left { display: flex; align-items: center; gap: 10px; }
2273
+ .stats-left span { display: flex; align-items: center; gap: 3px; }
2274
+ .actions-right { display: flex; align-items: center; gap: 4px; }
2275
+ .icon-btn {
2276
+ background: none;
2277
+ border: none;
2278
+ color: inherit;
2279
+ opacity: 0.6;
2280
+ cursor: pointer;
2281
+ padding: 3px;
2282
+ display: flex;
2283
+ align-items: center;
2284
+ border-radius: 4px;
2285
+ font-size: 13px;
2286
+ line-height: 1;
2287
+ }
2288
+ .icon-btn:hover { opacity: 1; background: var(--bg-subtle); }
2289
+ .icon-btn.heart.pinned { opacity: 1; color: var(--danger); }
2290
+ .icon-btn.delete:hover { color: var(--danger); }
2291
+ .action-btn {
2292
+ display: flex;
2293
+ align-items: center;
2294
+ gap: 5px;
2295
+ padding: 4px 10px;
2296
+ border-radius: 6px;
2297
+ border: 1px solid var(--border-strong);
2298
+ background: none;
2299
+ font-size: 11.5px;
2300
+ font-weight: 500;
2301
+ color: inherit;
2302
+ cursor: pointer;
2303
+ }
2304
+ .action-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
2305
+ `}#e(e){e.stopPropagation()}render(){const e=this.entityTitle!==void 0||this.iconOrEmoji||this.iconImageUrl||this.owner,t=this.stats&&this.stats.length>0||this.onPin||this.onCopy||this.onEdit||this.onDelete||this.actionLabel&&this.onAction;return l`
2306
+ <div
2307
+ class="card ${this.onClick||this.onActivate?"clickable":""} ${this.selected?"selected":""}"
2308
+ @click=${()=>this.onClick?.()}
2309
+ @dblclick=${()=>this.onActivate?.()}
2310
+ >
2311
+ ${e?l`
2312
+ <div class="top-row">
2313
+ <div class="logo-name">
2314
+ ${this.iconImageUrl?l`<img class="logo" src=${this.iconImageUrl} alt="" loading="lazy" />`:this.iconOrEmoji?l`<div class="logo-emoji">${this.iconOrEmoji}</div>`:f}
2315
+ <div class="name-group">
2316
+ ${this.entityTitle!==void 0?l`<h3 class="name">${this.entityTitle||l`<em style="opacity:0.5">(untitled)</em>`}</h3>`:f}
2317
+ ${this.owner?l`
2318
+ <div class="owner-row">
2319
+ <span class="owner">${this.owner}</span>
2320
+ ${this.verified?l`<svg class="check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2321
+ <circle cx="12" cy="12" r="10" />
2322
+ <path d="m9 12 2 2 4-4" />
2323
+ </svg>`:f}
2324
+ </div>
2325
+ `:f}
2326
+ </div>
2327
+ </div>
2328
+ </div>
2329
+ `:f}
2330
+ ${this.description?l`<p class="description">${this.description}</p>`:f}
2331
+ ${this.tags&&this.tags.length>0?l`<div class="tags">${this.tags.map(s=>l`<span class="badge">${s}</span>`)}</div>`:f}
2332
+ ${t?l`
2333
+ <div class="footer ${this.stats&&this.stats.length>0?"":"no-stats"}">
2334
+ ${this.stats&&this.stats.length>0?l`
2335
+ <div class="stats-left">
2336
+ ${this.stats.map(s=>l`<span>${s.icon} ${s.label}</span>`)}
2337
+ </div>
2338
+ `:f}
2339
+ <div class="actions-right">
2340
+ ${this.onCopy?l`<button class="icon-btn copy" title="Copy" @click=${s=>{this.#e(s),this.onCopy?.()}}>${this.copyIcon||"📋"}</button>`:f}
2341
+ ${this.onPin?l`<button
2342
+ class="icon-btn heart ${this.pinned?"pinned":""}"
2343
+ title=${this.pinned?"Unpin":"Pin"}
2344
+ @click=${s=>{this.#e(s),this.onPin?.()}}
2345
+ >${this.pinned?"♥":"♡"}</button>`:f}
2346
+ ${this.onEdit?l`<button class="icon-btn edit" title="Edit" @click=${s=>{this.#e(s),this.onEdit?.()}}>✏️</button>`:f}
2347
+ ${this.onDelete?l`<button class="icon-btn delete" title="Delete" @click=${s=>{this.#e(s),this.onDelete?.()}}>🗑</button>`:f}
2348
+ ${this.actionLabel&&this.onAction?l`<button class="action-btn" @click=${s=>{this.#e(s),this.onAction?.()}}>${this.actionLabel}</button>`:f}
2349
+ </div>
2350
+ </div>
2351
+ `:f}
2352
+ </div>
2353
+ `}}customElements.define("entity-card",gr);let re=null;const br=200,At="mem-bucket-quick-prompts-folder";class mr extends k{static{this.properties={onClose:{attribute:!1},memoryFolders:{attribute:!1},openToAdd:{attribute:!1}}}#e=new h([]);#t=new h(!0);#s=new h("");#n=new h(-1);#r=new h(!1);#u=!1;#a=new h(null);#i=new h("");#o=new h("");#d=new h(localStorage.getItem(At)??"");#g=new h("");#h=new h("");#c=e=>this.#y(e);#b=e=>this.#$(e);static{this.styles=$`
2354
+ :host { display: block; }
2355
+ .backdrop {
2356
+ position: fixed; inset: 0; background: var(--overlay);
2357
+ display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; z-index: 200;
2358
+ }
2359
+ .modal {
2360
+ background: var(--bg);
2361
+ color: inherit;
2362
+ border-radius: 12px;
2363
+ width: min(760px, 92vw);
2364
+ max-height: 76vh;
2365
+ display: flex;
2366
+ flex-direction: column;
2367
+ box-shadow: 0 12px 48px var(--shadow);
2368
+ border: 1px solid var(--border);
2369
+ overflow: hidden;
2370
+ }
2371
+ .search-row {
2372
+ display: flex; align-items: center; gap: 8px; padding: 12px 16px;
2373
+ border-bottom: 1px solid var(--border);
2374
+ }
2375
+ .search-row input {
2376
+ flex: 1; border: none; background: none; color: inherit; font-size: 15px; outline: none;
2377
+ }
2378
+ .hint { font-size: 11px; opacity: 0.5; white-space: nowrap; }
2379
+ .body { flex: 1; overflow-y: auto; padding: 14px 16px; }
2380
+ .grid {
2381
+ display: grid;
2382
+ grid-template-columns: repeat(auto-fill, minmax(${br}px, 1fr));
2383
+ gap: 10px;
2384
+ }
2385
+ .add-tile {
2386
+ display: flex; align-items: center; justify-content: center;
2387
+ border: 1px dashed var(--border-strong);
2388
+ border-radius: 10px;
2389
+ min-height: 96px;
2390
+ cursor: pointer;
2391
+ font-size: 28px;
2392
+ opacity: 0.5;
2393
+ background: none;
2394
+ color: inherit;
2395
+ }
2396
+ .add-tile:hover { opacity: 1; background: var(--hover); }
2397
+ .empty { padding: 24px; text-align: center; opacity: 0.6; font-size: 13px; }
2398
+ .add-form { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; }
2399
+ .add-form input[type='text'] {
2400
+ padding: 6px 9px; font-size: 12.5px; border: 1px solid var(--border-strong); border-radius: 6px;
2401
+ background: none; color: inherit;
2402
+ }
2403
+ .add-form textarea {
2404
+ padding: 8px 9px; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 6px;
2405
+ background: none; color: inherit; resize: vertical; min-height: 140px; font-family: inherit;
2406
+ }
2407
+ .add-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
2408
+ .folder-pill {
2409
+ flex: 0 0 auto;
2410
+ padding: 4px 10px; font-size: 11.5px; border: 1px solid var(--border-strong); border-radius: 999px;
2411
+ background: var(--bg-subtle); color: inherit; cursor: pointer;
2412
+ }
2413
+ .folder-pill:hover { background: var(--hover); }
2414
+ button.primary {
2415
+ background: var(--accent); border: 1px solid var(--accent); color: var(--accent-fg); padding: 6px 14px;
2416
+ border-radius: 6px; cursor: pointer; font-size: 13px;
2417
+ }
2418
+ button.secondary {
2419
+ background: none; border: 1px solid var(--border-strong); color: inherit; padding: 6px 14px;
2420
+ border-radius: 6px; cursor: pointer; font-size: 13px;
2421
+ }
2422
+ .error { color: var(--danger); font-size: 12px; padding: 0 16px 10px; }
2423
+ .footer-bar {
2424
+ display: flex; align-items: center; justify-content: space-between; gap: 8px;
2425
+ padding: 8px 16px; border-top: 1px solid var(--border); font-size: 11px; opacity: 0.6;
2426
+ }
2427
+ `}constructor(){super(),new N(this)}willUpdate(e){e.has("memoryFolders")&&this.#C()}connectedCallback(){super.connectedCallback(),this.#w(),this.#C(),this.openToAdd&&(this.#u=!0,this.#T()),window.addEventListener("keydown",this.#b)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.#b)}firstUpdated(){this.renderRoot.querySelector(".search-row input")?.focus()}async#w(){this.#t.set(!0);try{const t=await(await fetch("/api/quick-prompts")).json();this.#e.set(t)}catch(e){this.#g.set(e.message)}finally{this.#t.set(!1)}}#x(){const e=this.#d.value?this.#e.value.filter(i=>i.folder===this.#d.value):this.#e.value,t=this.#s.value.trim().toLowerCase();return[...t?e.filter(i=>i.title.toLowerCase().includes(t)||i.body.toLowerCase().includes(t)||i.tags.some(r=>r.toLowerCase().includes(t))):e].sort((i,r)=>Number(r.pinned)-Number(i.pinned))}#v(e){const t=this.#x()[this.#n.value];this.#s.set(e.target.value);const s=this.#x(),i=t?s.findIndex(r=>r.id===t.id):-1;this.#n.set(i!==-1?i:s.length>0?0:-1)}#p(){const e=this.renderRoot.querySelector(".grid");if(!e)return 1;const t=getComputedStyle(e).gridTemplateColumns;return Math.max(1,t.split(" ").filter(Boolean).length)}#y(e){if((e.metaKey||e.ctrlKey)&&e.key==="Enter"&&!this.#r.value){e.preventDefault(),this.#T();return}const t=this.#x(),s=this.#p(),i=e.target,r=i instanceof HTMLInputElement,o=i instanceof HTMLTextAreaElement,a=(r||o)&&i.value.length>0;if(!((e.key==="ArrowLeft"||e.key==="ArrowRight")&&a)&&!((e.key==="ArrowUp"||e.key==="ArrowDown")&&o)){if(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight"){e.preventDefault();let c=this.#n.value;c===-1?c=0:e.key==="ArrowDown"?c=Math.min(t.length-1,c+s):e.key==="ArrowUp"?c=Math.max(0,c-s):e.key==="ArrowRight"?c=Math.min(t.length-1,c+1):e.key==="ArrowLeft"&&(c=Math.max(0,c-1)),this.#n.set(c);return}if(e.key==="Enter"){const c=t[this.#n.value];c&&(e.preventDefault(),this.#l(c));return}e.key==="Escape"&&!this.#r.value&&this.onClose()}}#$(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="z"&&re&&(e.preventDefault(),this.#m())}async#l(e){try{await navigator.clipboard.writeText(e.body),y.success("Copied to clipboard")}catch{y.danger("Copy failed")}this.onClose()}async#k(e){const t=!e.pinned;this.#e.set(this.#e.value.map(s=>s.id===e.id?{...s,pinned:t}:s)),await fetch(`/api/quick-prompts/${encodeURIComponent(e.id)}/pinned`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({pinned:t})})}async#_(e){re={title:e.title,body:e.body,tags:e.tags,pinned:e.pinned,folder:e.folder},this.#e.set(this.#e.value.filter(t=>t.id!==e.id)),this.#h.set("Deleted — press Cmd+Z / Ctrl+Z to undo");try{await fetch(`/api/quick-prompts/${encodeURIComponent(e.id)}`,{method:"DELETE"})}catch(t){this.#g.set(t.message)}}async#m(){const e=re;if(e){re=null,this.#h.set("");try{const s=await(await fetch("/api/quick-prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title,body:e.body,tags:e.tags,folder:e.folder})})).json();e.pinned&&(await fetch(`/api/quick-prompts/${encodeURIComponent(s.id)}/pinned`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({pinned:!0})}),s.pinned=!0),this.#e.set([s,...this.#e.value]),this.#h.set("Prompt restored"),setTimeout(()=>this.#h.set(""),2e3)}catch(t){this.#g.set(t.message)}}}#C(){const e=this.memoryFolders??[];e.length!==0&&(e.some(t=>t.name===this.#d.value)||this.#d.set(e[0].name))}#T(){this.#a.set(null),this.#i.set(""),this.#o.set(""),this.#C(),this.#r.set(!0),this.#z()}#S(e){this.#a.set(e.id),this.#i.set(e.title),this.#o.set(e.body),this.#d.set(e.folder),this.#r.set(!0),this.#z()}#z(){this.updateComplete.then(()=>{this.renderRoot.querySelector(".add-form textarea")?.focus()})}#A(){this.updateComplete.then(()=>{this.renderRoot.querySelector(".search-row input")?.focus()})}#I(e){this.#d.set(e),localStorage.setItem(At,e),this.#n.set(-1)}#P(){if(this.#u){this.onClose();return}this.#r.set(!1),this.#a.set(null),this.#A()}async#R(){const e=this.#o.value.trim();if(!e)return;this.#g.set("");const t=this.#a.value;try{const s=await fetch(t?`/api/quick-prompts/${encodeURIComponent(t)}`:"/api/quick-prompts",{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:this.#i.value.trim(),body:e,folder:this.#d.value||void 0})}),i=await s.json();if(!s.ok){this.#g.set(i.error??(t?"failed to update prompt":"failed to create prompt"));return}t?this.#e.set(this.#e.value.map(r=>r.id===t?i:r)):this.#e.set([i,...this.#e.value]),this.#r.set(!1),this.#a.set(null)}catch(s){this.#g.set(s.message)}}#E(e){e.key==="Escape"?(e.stopPropagation(),this.#P()):(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&this.#R()}render(){const e=this.#x();return l`
2428
+ <div class="backdrop" @click=${t=>t.target===t.currentTarget&&this.onClose()}>
2429
+ <div class="modal" @keydown=${this.#c}>
2430
+ <div class="search-row">
2431
+ <input
2432
+ type="search"
2433
+ placeholder="Search quick prompts…"
2434
+ .value=${this.#s.value}
2435
+ @input=${t=>this.#v(t)}
2436
+ />
2437
+ ${(this.memoryFolders?.length??0)>1?l`
2438
+ <select
2439
+ class="folder-pill"
2440
+ title="Shows and saves quick prompts for this folder"
2441
+ .value=${this.#d.value}
2442
+ @change=${t=>this.#I(t.target.value)}
2443
+ >
2444
+ ${this.memoryFolders.map(t=>l`<option value=${t.name}>${t.remote?"☁":"📁"} ${t.name}</option>`)}
2445
+ </select>
2446
+ `:""}
2447
+ <span class="hint">${this.#h.value||"↑↓←→ navigate · Enter copy · Esc close"}</span>
2448
+ </div>
2449
+ ${this.#g.value?l`<div class="error">${this.#g.value}</div>`:""}
2450
+ <div class="body">
2451
+ ${this.#r.value?l`
2452
+ <div class="add-form" @keydown=${this.#E}>
2453
+ <input
2454
+ type="text"
2455
+ placeholder="Title (optional)"
2456
+ .value=${this.#i.value}
2457
+ @input=${t=>this.#i.set(t.target.value)}
2458
+ />
2459
+ <textarea
2460
+ placeholder="Prompt text…"
2461
+ .value=${this.#o.value}
2462
+ @input=${t=>this.#o.set(t.target.value)}
2463
+ ></textarea>
2464
+ <div class="add-form-actions">
2465
+ <button class="secondary" @click=${()=>this.#P()}>Cancel</button>
2466
+ <button class="primary" ?disabled=${!this.#o.value.trim()} @click=${()=>this.#R()}>
2467
+ ${this.#a.value?"Save changes":"Add prompt"}
2468
+ </button>
2469
+ </div>
2470
+ </div>
2471
+ `:this.#t.value?l`<div class="empty">Loading…</div>`:e.length===0&&!this.#s.value?l`
2472
+ <div class="grid">
2473
+ <button class="add-tile" title="Add a quick prompt" @click=${()=>this.#T()}>+</button>
2474
+ </div>
2475
+ <div class="empty">No quick prompts yet — add one to get started.</div>
2476
+ `:l`
2477
+ <div class="grid">
2478
+ <button class="add-tile" title="Add a quick prompt" @click=${()=>this.#T()}>+</button>
2479
+ ${e.map((t,s)=>l`
2480
+ <entity-card
2481
+ .entityTitle=${t.title}
2482
+ .description=${t.body}
2483
+ .tags=${t.tags}
2484
+ .iconOrEmoji=${t.remote?"☁":"📝"}
2485
+ .pinned=${t.pinned}
2486
+ .selected=${s===this.#n.value}
2487
+ .onPin=${()=>this.#k(t)}
2488
+ .onCopy=${()=>this.#l(t)}
2489
+ copyIcon="📋"
2490
+ .onEdit=${()=>this.#S(t)}
2491
+ .onDelete=${()=>this.#_(t)}
2492
+ .onClick=${()=>this.#l(t)}
2493
+ .onActivate=${()=>this.#l(t)}
2494
+ ></entity-card>
2495
+ `)}
2496
+ </div>
2497
+ `}
2498
+ </div>
2499
+ <div class="footer-bar">
2500
+ <span>${e.length} quick prompt${e.length===1?"":"s"}</span>
2501
+ <span>⌘/Ctrl+Enter to add · Double-Shift to toggle this palette</span>
2502
+ </div>
2503
+ </div>
2504
+ </div>
2505
+ `}}customElements.define("quick-prompts-modal",mr);function vr(n){const e=n.split(":");if(e.length===1)return{folderPath:"",name:e[0]};if(e.length===2){const[r,o]=e;return r.includes("/")?{folderPath:r,name:o}:{owner:r,folderPath:"",name:o}}const[t,s,...i]=e;return{owner:t===""?void 0:t,folderPath:s,name:i.join(":")}}const oe=new h({mode:"off",username:null});let Et=!1;function xr(){if(Et)return;Et=!0;const n=new EventSource("/api/folderfoo/identity-stream");n.onmessage=e=>{try{oe.set(JSON.parse(e.data))}catch{}}}let Rt=!1;async function yr(n){if(Rt)return;Rt=!0;const{folderfooMode:e,folderfooHost:t}=await H();if(e==="off"||!t)return;const s=new URL(window.location.href),i=s.searchParams.has("shareToken"),r=s.searchParams.has("publicToken");if(!(!i&&!r)){document.addEventListener("folderfoo-share-redeemed",o=>{const a=o.detail;!a?.owner||!a?.path||a.type!=="file"||!a.originId||!a.kind||n({owner:a.owner,path:a.path,originId:a.originId,kind:a.kind,role:a.role??"member",server:t,tenantId:F})}),document.addEventListener("folderfoo-share-redeem-failed",o=>{const a=o.detail?.message;alert(a||"This link is invalid or has expired.")});try{const[o,a]=await Promise.all([ae(()=>import(`${t}/elements/auth-guard.js`),[]),ae(()=>import(`${t}/elements/api-client.js`),[])]);if(a.setTenantId(F),i&&o.redeemShareTokenFromUrl(),r){const c=s.searchParams.get("publicToken");s.searchParams.delete("publicToken"),window.history.replaceState(null,"",s.toString());const d=await o.getPublicLink(c).catch(u=>(alert(u.message||"This link is invalid or has expired."),null));d?.type==="file"&&d.originId&&d.kind&&n({owner:d.owner,path:d.path,originId:d.originId,kind:d.kind,role:"member",server:t,tenantId:F})}}catch(o){console.error("[memory-bucket] failed to load folderfoo share-accept widgets:",o)}}}let zt=!1;const kr=[{value:"all",label:"All"},{value:"skill",label:"Skills"},{value:"memory",label:"Memories"}],Pt=[{value:"all",label:"Show all"},{value:"hide",label:"Hide"},{value:"only",label:"Only"}],wr={tags:[],statuses:[],owners:[],doc_types:[],key_types:[],folders:[]},$r={skill:[],memory:[]},ss="mem-bucket-split-pct",is=20,rs=80;function _r(){const n=Number(localStorage.getItem(ss));return Number.isFinite(n)&&n>=is&&n<=rs?n:40}const ns="mem-bucket-theme",xe=["system","light","dark"];function Sr(){const n=localStorage.getItem(ns);return n==="light"||n==="dark"?n:"system"}function It(n){n==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",n)}function Cr(){const n=location.hash.slice(1);if(!n)return{};const e=new URLSearchParams(n),t={},s=e.get("q");s&&(t.query=s);const i=e.get("type");(i==="skill"||i==="memory"||i==="all")&&(t.typeFilter=i);const r=e.getAll("tag");r.length&&(t.activeTags=r);const o=e.getAll("folder");o.length&&(t.activeFolders=o);const a=e.get("sort");a&&(t.sort=a);const c=e.get("deprecated");c==="0"?t.deprecatedFilter="hide":c==="1"&&(t.deprecatedFilter="only");const d=e.get("paused");d==="0"?t.pausedFilter="hide":d==="1"&&(t.pausedFilter="only");const u=e.get("date_from");u&&(t.dateFrom=u);const p=e.get("date_to");return p&&(t.dateTo=p),t}class Tr extends k{static{this.styles=$`
2506
+ :host { display: flex; flex-direction: column; height: 100vh; position: relative; }
2507
+ /* Mounted inside whichever header row #renderBody() renders for the current mode (.folders-bar,
2508
+ .toolbar-bar, or folder-view's own .mode-row, via a <slot>) so it's a normal flex child of
2509
+ that row - margin-left: auto keeps it pinned to the right, and it wraps onto its own line
2510
+ with the rest of the row's content when the row gets too narrow. */
2511
+ .header-toolbar { margin-left: auto; }
2512
+ .filters {
2513
+ padding: 12px 16px;
2514
+ border-bottom: 1px solid var(--border);
2515
+ display: flex;
2516
+ flex-direction: column;
2517
+ gap: 8px;
2518
+ }
2519
+ .search-field {
2520
+ position: relative;
2521
+ flex: 1 1 240px;
2522
+ max-width: 480px;
2523
+ }
2524
+ .filters input[type='search'] {
2525
+ font-size: 13px;
2526
+ padding: 6px 28px 6px 10px;
2527
+ width: 100%;
2528
+ box-sizing: border-box;
2529
+ border: 1px solid var(--border-strong);
2530
+ border-radius: 6px;
2531
+ background: none;
2532
+ color: inherit;
2533
+ height: 30px;
2534
+ }
2535
+ .filters input[type='search']::-webkit-search-cancel-button { display: none; }
2536
+ .search-clear-btn {
2537
+ position: absolute;
2538
+ right: 4px;
2539
+ top: 50%;
2540
+ transform: translateY(-50%);
2541
+ border: none;
2542
+ background: transparent;
2543
+ cursor: pointer;
2544
+ color: inherit;
2545
+ opacity: 0.6;
2546
+ font-size: 12px;
2547
+ line-height: 1;
2548
+ padding: 4px 6px;
2549
+ border-radius: 50%;
2550
+ }
2551
+ .search-clear-btn:hover { opacity: 1; background: var(--hover); }
2552
+ .date-range { display: flex; align-items: center; gap: 4px; }
2553
+ .date-range input[type='date'] {
2554
+ font-size: 13px;
2555
+ padding: 5px 8px;
2556
+ border: 1px solid var(--border-strong);
2557
+ border-radius: 6px;
2558
+ background: none;
2559
+ color: inherit;
2560
+ height: 30px;
2561
+ box-sizing: border-box;
2562
+ }
2563
+ .date-range-sep { opacity: 0.5; font-size: 12px; }
2564
+ .date-range-clear {
2565
+ position: static;
2566
+ transform: none;
2567
+ opacity: 0.6;
2568
+ font-size: 12px;
2569
+ line-height: 1;
2570
+ padding: 4px 6px;
2571
+ border: none;
2572
+ background: transparent;
2573
+ cursor: pointer;
2574
+ color: inherit;
2575
+ border-radius: 50%;
2576
+ }
2577
+ .date-range-clear:hover { opacity: 1; background: var(--hover); }
2578
+ .search-row { align-items: center; }
2579
+ .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
2580
+ .filter-label { font-size: 12px; opacity: 0.6; font-weight: 600; }
2581
+ .type-toggle { gap: 0; }
2582
+ .type-toggle button {
2583
+ border: 1px solid var(--border-strong);
2584
+ background: none;
2585
+ color: inherit;
2586
+ padding: 6px 12px;
2587
+ font-size: 13px;
2588
+ cursor: pointer;
2589
+ height: 30px;
2590
+ box-sizing: border-box;
2591
+ }
2592
+ .type-toggle button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
2593
+ .type-toggle button:first-child { border-radius: 6px 0 0 6px; }
2594
+ .type-toggle button:last-child { border-radius: 0 6px 6px 0; }
2595
+ .type-toggle button:not(:first-child) { border-left: none; }
2596
+ .body-region { display: flex; flex: 1 1 auto; min-height: 0; }
2597
+ result-list { overflow-y: auto; flex: 0 0 auto; }
2598
+ detail-panel { overflow-y: auto; flex: 1 1 auto; min-width: 0; }
2599
+ .splitter {
2600
+ flex: 0 0 auto;
2601
+ width: 6px;
2602
+ cursor: col-resize;
2603
+ background: var(--hover);
2604
+ position: relative;
2605
+ }
2606
+ .splitter:hover, .splitter.dragging { background: var(--accent-tint); }
2607
+ .splitter::after {
2608
+ content: '';
2609
+ position: absolute;
2610
+ top: 0; bottom: 0;
2611
+ left: -3px; right: -3px;
2612
+ }
2613
+ label.small { font-size: 12px; opacity: 0.7; }
2614
+ .folders-bar {
2615
+ display: flex;
2616
+ gap: 6px;
2617
+ align-items: center;
2618
+ flex-wrap: wrap;
2619
+ padding: 10px 16px;
2620
+ border-bottom: 1px solid var(--border);
2621
+ background: var(--bg-subtle);
2622
+ }
2623
+ /* Chips live directly in .folders-bar's own flex-wrap flow (not a nested flex container) so a
2624
+ wrapped row of chips spans the bar's full width, left-aligned, instead of being squeezed into
2625
+ whatever width a nested flex item happened to get on the first line. */
2626
+ .folders-bar .folder-chips {
2627
+ display: contents;
2628
+ }
2629
+ .toolbar-bar {
2630
+ display: flex;
2631
+ align-items: center;
2632
+ flex-wrap: wrap;
2633
+ padding: 10px 16px;
2634
+ border-bottom: 1px solid var(--border);
2635
+ background: var(--bg-subtle);
2636
+ }
2637
+ .folder-chip {
2638
+ border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 8px 3px 10px; font-size: 12px;
2639
+ cursor: pointer; background: none; color: inherit; display: inline-flex; align-items: center; gap: 6px;
2640
+ }
2641
+ /* Active chips invert to a solid white fill with dark text in both themes, so they read
2642
+ clearly against remote chips' accent outline instead of blending into a similar tint. */
2643
+ .folder-chip.active { background: #ffffff; border-color: var(--purple); color: #111111; }
2644
+ /* Remote (folderfoo) folders get the accent color instead of the default border, so they're
2645
+ visually distinct from local folders at a glance — active-state purple still wins when both apply. */
2646
+ .folder-chip.remote { border-color: var(--accent); color: var(--accent); }
2647
+ .folder-chip.remote.active { background: #ffffff; border-color: var(--purple); color: #111111; }
2648
+ .folder-chip .remote-dot {
2649
+ width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
2650
+ }
2651
+ .folder-chip.active .remote-dot { background: var(--purple); }
2652
+ .folder-chip .kind {
2653
+ opacity: 0.55; font-size: 10px;
2654
+ }
2655
+ .folder-chip .remove {
2656
+ opacity: 0.6; font-size: 12px; line-height: 1; padding: 2px; border-radius: 50%;
2657
+ }
2658
+ .folder-chip .remove:hover { opacity: 1; background: var(--hover-strong); }
2659
+ .add-folder-btn {
2660
+ border: 1px dashed var(--border-strong); border-radius: 999px; padding: 3px 10px; font-size: 12px;
2661
+ cursor: pointer; background: none; color: inherit; opacity: 0.75;
2662
+ }
2663
+ .add-folder-btn:hover { opacity: 1; }
2664
+ .folderfoo-open-banner {
2665
+ display: flex; align-items: center; justify-content: space-between; gap: 12px;
2666
+ padding: 8px 16px; font-size: 12px; background: var(--accent-tint); border-bottom: 1px solid var(--border);
2667
+ }
2668
+ .folderfoo-open-banner .dismiss {
2669
+ background: none; border: none; color: inherit; cursor: pointer; opacity: 0.6; padding: 2px; border-radius: 50%;
2670
+ }
2671
+ .folderfoo-open-banner .dismiss:hover { opacity: 1; background: var(--hover-strong); }
2672
+ .first-run {
2673
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
2674
+ flex: 1 1 auto; gap: 16px; text-align: center; padding: 24px;
2675
+ }
2676
+ .first-run h1 { font-size: 18px; margin: 0; }
2677
+ .first-run p { opacity: 0.7; font-size: 13px; max-width: 420px; margin: 0; }
2678
+ select {
2679
+ font-size: 13px;
2680
+ padding: 6px 8px;
2681
+ height: 30px;
2682
+ box-sizing: border-box;
2683
+ border: 1px solid var(--border-strong);
2684
+ border-radius: 6px;
2685
+ background: none;
2686
+ color: inherit;
2687
+ }
2688
+ .bulk-bar {
2689
+ display: flex;
2690
+ gap: 8px;
2691
+ align-items: center;
2692
+ padding: 6px 16px;
2693
+ border-bottom: 1px solid var(--border);
2694
+ background: var(--accent-tint);
2695
+ font-size: 12px;
2696
+ }
2697
+ .bulk-bar button {
2698
+ font-size: 11px;
2699
+ padding: 4px 10px;
2700
+ border: 1px solid var(--border);
2701
+ background: transparent;
2702
+ color: inherit;
2703
+ border-radius: 4px;
2704
+ cursor: pointer;
2705
+ }
2706
+ .bulk-bar button.danger { border-color: var(--danger); color: var(--danger); }
2707
+ `}#e=Cr();#t=new h(this.#e.query??"");#s=new h(this.#e.typeFilter??"all");#n=new h(this.#e.activeTags??[]);#r=new h(this.#e.activeFolders??[]);#u=new h([]);#a=new h(wr);#i=new h(null);#o=new h($r);#d=new h(!1);#g=new h("");#h=new h(!1);#c=new h(_r());#b=new h("");#w=new h(!1);#x=new h(this.#e.sort??"");#v=new h(this.#e.deprecatedFilter??"all");#p=new h(this.#e.pausedFilter??"all");#y=new h(this.#e.dateFrom??"");#$=new h(this.#e.dateTo??"");#l=new h(new Set);#k=new h(Sr());#_=new h(!1);#m=new h("entries");#C=new h([]);#T=new h([]);#S=new h(null);#z=new h(null);#A=new h(!1);#I=new h([]);#P=new h(!1);#R=new h(null);#E=new h(!1);#O=new h(!1);#F=0;#G=e=>this.#H(e);#U=()=>this.#Q();#j=e=>this.#B(e);constructor(){super(),new N(this),It(this.#k.value)}#W(e){this.#k.set(e),localStorage.setItem(ns,e),It(e)}#q(){const e=xe[(xe.indexOf(this.#k.value)+1)%xe.length];this.#W(e)}async#J(){if(!this.#_.value){this.#_.set(!0);try{if(!(await fetch("/api/rebuild-cache",{method:"POST"})).ok)throw new Error("rebuild-cache request failed");await Promise.all([this.#D(),this.#L(),this.#f()]),y.success("Reindex complete")}catch{y.danger("Reindex failed")}finally{this.#_.set(!1)}}}#B(e){if((e.metaKey||e.ctrlKey)&&e.key==="Enter"&&!this.#E.value){e.preventDefault(),this.#O.set(!0),this.#E.set(!0);return}if(e.key!=="Shift"){this.#F=0;return}const t=Date.now();t-this.#F<450?(this.#F=0,this.#E.set(!this.#E.value)):this.#F=t}#Y(e){e.preventDefault(),this.#w.set(!0),document.addEventListener("pointermove",this.#G),document.addEventListener("pointerup",this.#U)}#H(e){const t=this.renderRoot.querySelector(".body-region");if(!t)return;const s=t.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*100;this.#c.set(Math.min(rs,Math.max(is,i)))}#Q(){this.#w.set(!1),document.removeEventListener("pointermove",this.#G),document.removeEventListener("pointerup",this.#U),localStorage.setItem(ss,String(this.#c.value))}#X=new it(()=>{const e=new URLSearchParams;this.#s.value!=="all"&&e.set("type",this.#s.value),this.#t.value.trim()&&e.set("q",this.#t.value.trim());for(const t of this.#n.value)e.append("tag",t);for(const t of this.#r.value)e.append("folder",t);return this.#x.value&&e.set("sort",this.#x.value),this.#v.value==="hide"?e.set("deprecated","0"):this.#v.value==="only"&&e.set("deprecated","1"),this.#p.value==="hide"?e.set("paused","0"):this.#p.value==="only"&&e.set("paused","1"),this.#y.value&&e.set("date_from",this.#y.value),this.#$.value&&e.set("date_to",this.#$.value),e.toString()});#ee=new it(()=>{const e=new URLSearchParams;return this.#s.value!=="all"&&e.set("type",this.#s.value),this.#t.value.trim()&&e.set("q",this.#t.value.trim()),this.#v.value==="hide"?e.set("deprecated","0"):this.#v.value==="only"&&e.set("deprecated","1"),this.#p.value==="hide"?e.set("paused","0"):this.#p.value==="only"&&e.set("paused","1"),this.#y.value&&e.set("date_from",this.#y.value),this.#$.value&&e.set("date_to",this.#$.value),e.toString()});#M=()=>this.#he();#re=e=>this.#we(e);#ne=e=>this.#$e(e);#oe=()=>this.#de();#ae;connectedCallback(){super.connectedCallback(),this.#f(),this.#L(),this.#D().then(()=>this.#he()),window.addEventListener("focus",this.#M),document.addEventListener("visibilitychange",this.#M),window.addEventListener("keydown",this.#j),document.addEventListener("folderfoo-file-open",this.#re),document.addEventListener("folderfoo-folder-changed",this.#ne),window.addEventListener("folderfoo-auth-change",this.#oe),this.#de(),xr(),yr(e=>this.#Te(e)),this.#Z(),this.#ae=oe.subscribe(()=>{this.#D(),this.#f(),this.#L(),this.#m.value==="shared"&&oe.value.username===null&&this.#N("entries")})}async#we(e){const t=e.detail?.name;if(!t)return;const s=vr(t);if(s.owner){this.#b.set(`"${s.name}" is from a shared folder — opening shared files here isn't supported yet.`);return}const{folderfooMode:i,folderfooHost:r}=await H();if(!(i==="off"||!r))try{const o=await fetch("/api/folderfoo/resolve-open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:r,tenantId:F,folderPath:s.folderPath,name:s.name})}),a=await o.json();if(!o.ok){this.#b.set(a.error??`couldn't open "${s.name}"`);return}this.#b.set(""),this.#i.set({table:a.table,id:a.id})}catch(o){this.#b.set(o.message)}}async#$e(e){const{path:t,action:s,newPath:i}=e.detail??{};if(!(t===void 0||!s)){if((s==="rename"||s==="move")&&i){const{folderfooHost:r}=await H();if(!r)return;try{await fetch("/api/folders/renamed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:r,oldPath:t,newPath:i})})}catch{}}this.#D()}}#le(){return this.shadowRoot?.querySelector("app-toolbar")?.shadowRoot?.querySelector(".folderfoo-slot")??null}#ce(e){const t=document.createElement("folderfoo-profile-circle");t.setAttribute("app-name","Memory Bucket"),t.setAttribute("tenant-id",F),t.style.zoom="0.875",e.appendChild(t)}async#_e(){const e=this.#le();if(!e||e.querySelector("folderfoo-profile-circle"))return;if(zt){this.#ce(e);return}if(e.hasAttribute("data-ff-attempted"))return;e.setAttribute("data-ff-attempted","");const{folderfooMode:t,folderfooHost:s}=await H();t==="off"||!s||ae(()=>import(`${s}/elements/folderfoo-profile-circle.js`),[]).then(async()=>{zt=!0,await this.updateComplete;const i=this.#le();i&&!i.querySelector("folderfoo-profile-circle")&&this.#ce(i)}).catch(i=>{console.warn("folderfoo-profile-circle unavailable:",i.message)})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("focus",this.#M),document.removeEventListener("visibilitychange",this.#M),window.removeEventListener("keydown",this.#j),document.removeEventListener("folderfoo-file-open",this.#re),document.removeEventListener("folderfoo-folder-changed",this.#ne),window.removeEventListener("folderfoo-auth-change",this.#oe),this.#ae?.()}async#de(){let e=null;try{e=localStorage.getItem("folderfoo_token")}catch{return}if(!e){fetch("/api/folderfoo/logout",{method:"POST"}).catch(()=>{});return}const{folderfooMode:t,folderfooHost:s}=await H();t==="off"||!s||fetch("/api/folderfoo/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:s,token:e})}).catch(()=>{})}#te=!1;async#he(){if(document.visibilityState==="visible"){if(this.#se().some(e=>e.remote)&&!this.#te){this.#te=!0;try{await fetch("/api/remote-folders/resync-all",{method:"POST"})}catch{}finally{this.#te=!1}}this.#f(),this.#L(),this.#D(),this.renderRoot.querySelector("detail-panel")?.refresh?.()}}async#f(){const e=this.#X.value;history.replaceState(null,"",e?`#${e}`:location.pathname+location.search);const t=await fetch(`/api/entries?${e}`);this.#u.set(await t.json()),this.renderRoot.querySelector("result-list")?.scrollTo(0,0),this.#m.value==="folder-view"&&this.#pe()}async#pe(){const e=await fetch(`/api/entries?${this.#ee.value}`);this.#C.set(await e.json())}async#L(){const e=this.#s.value==="all"?"":`?type=${this.#s.value}`,t=await fetch(`/api/facets${e}`);this.#a.set(await t.json())}async#D(){const t=await(await fetch("/api/folders")).json();this.#o.set(t),this.#h.set(!0);const s=new Set([...t.skill,...t.memory].map(o=>o.name)),i=this.#r.value.filter(o=>s.has(o));i.length!==this.#r.value.length&&(this.#r.set(i),this.#f());const r=this.#i.value;if(r){const o=this.#xe().get(r.id);o&&!s.has(o.folder)&&this.#i.set(null)}}#N(e){this.#m.set(e),e==="channels"?this.#fe():e==="folder-view"?this.#pe():e==="shared"&&(this.#Z(),this.#ue())}async#Z(){const e=await fetch("/api/shared-items");this.#I.set(e.ok?await e.json():[])}async#ue(){this.#P.set(!0);try{const e=await fetch("/api/shared-items/refresh",{method:"POST"});e.ok&&this.#R.set(await e.json()),await this.#Z()}finally{this.#P.set(!1)}}async#Se(e){await fetch(`/api/shared-items/${encodeURIComponent(e)}`,{method:"DELETE"}),await this.#Z()}#Ce(e){e.entryId&&(this.#i.set({table:e.kind==="skill"?"skills":"memory_docs",id:e.entryId}),this.#N("entries"))}async#Te(e){const t=await fetch("/api/shared-items/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json().catch(()=>({}));alert(s.error||"Failed to accept the shared item.");return}this.#N("shared")}async#Ae(e,t){const s=await fetch(`/api/shared-items/${encodeURIComponent(e.origin_id)}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:t})}),i=await s.json().catch(()=>({}));return s.ok?(await this.#f(),{ok:!0,message:`Copied into "${t}".`}):{ok:!1,message:i.error||`Fork failed (${s.status}).`}}async#fe(){const e=await fetch("/api/channels");this.#T.set(await e.json()),this.#S.value&&this.#ge(this.#S.value)}async#ge(e){this.#S.set(e),this.#A.set(!0);try{const t=await fetch(`/api/channels/${encodeURIComponent(e)}`);this.#z.set(t.ok?await t.json():null)}finally{this.#A.set(!1)}}#Ee(e){const t=this.#r.value;this.#r.set(t.includes(e)?t.filter(s=>s!==e):[...t,e]),this.#f()}async#Re(e,t){if(t.stopPropagation(),window.prompt(`Type "${e.name}" to remove this ${e.kind} folder (files on disk are untouched):`)===e.name){this.#g.set(e.name);try{if(!(await fetch(`/api/folders/${e.kind}/${encodeURIComponent(e.name)}`,{method:"DELETE"})).ok)throw new Error("remove folder request failed");this.#r.set(this.#r.value.filter(r=>r!==e.name)),await Promise.all([this.#D(),this.#L(),this.#f()]),y.success("Folder removed")}catch{y.danger("Failed to remove folder")}finally{this.#g.set("")}}}#be(e){this.#d.set(!1),this.#D(),this.#L(),this.#f(),y.success("Folder connected"),e&&alert(e)}#se(){return[...this.#o.value.skill,...this.#o.value.memory].sort((e,t)=>Number(e.remote)-Number(t.remote))}#me(e){this.#s.set(e),this.#n.set([]),this.#L(),this.#f()}#ze(e){const t=this.#n.value;this.#n.set(t.includes(e)?t.filter(s=>s!==e):[...t,e]),this.#f()}#Pe(e){this.#n.value.includes(e)||this.#n.set([...this.#n.value,e]),this.#f()}#Ie(e){this.#r.value.includes(e)||this.#r.set([...this.#r.value,e]),this.#f()}#ve(e){this.#y.set(e),this.#$.set(e),this.#f()}#Le(e){this.#t.set(e.target.value),this.#f()}#K(e){this.#t.set(e),this.#f()}#Fe(){this.#t.set(""),this.#f()}#Oe(e){this.#i.set({table:e._table,id:e.id})}#De(e){this.#x.set(e.target.value),this.#f()}#Me(e){this.#v.set(e.target.value),this.#f()}#Ne(e){this.#p.set(e.target.value),this.#f()}#Ue(e){this.#y.set(e.target.value),this.#f()}#je(e){this.#$.set(e.target.value),this.#f()}#qe(){this.#y.set(""),this.#$.set(""),this.#f()}#Be(e){const t=new Set(this.#l.value);t.has(e.id)?t.delete(e.id):t.add(e.id),this.#l.set(t)}#xe(){return new Map(this.#u.value.map(e=>[e.id,e]))}#ie(){const e=new Map,t=this.#xe();for(const s of this.#l.value){const i=t.get(s);if(!i)continue;const r=e.get(i._table)??[];r.push(s),e.set(i._table,r)}return e}async#ye(e){const t=this.#ie(),s=this.#l.value.size,i=await Promise.all([...t.entries()].map(([r,o])=>fetch(`/api/entries/${r}/bulk/deprecated`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:o,deprecated:e})})));this.#l.set(new Set),await this.#f(),i.every(r=>r.ok)?y.success(`${s} item${s===1?"":"s"} updated`):y.danger("Bulk update failed")}async#ke(e){const t=this.#ie(),s=this.#l.value.size,i=await Promise.all([...t.entries()].map(([r,o])=>fetch(`/api/entries/${r}/bulk/paused`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:o,paused:e})})));this.#l.set(new Set),await this.#f(),i.every(r=>r.ok)?y.success(`${s} item${s===1?"":"s"} updated`):y.danger("Bulk update failed")}async#He(){if(!window.confirm(`Delete ${this.#l.value.size} doc(s)? This can't be undone.`))return;const e=this.#ie(),t=this.#l.value.size,s=await Promise.all([...e.entries()].map(([i,r])=>fetch(`/api/entries/${i}/bulk/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:r})})));this.#l.set(new Set),await this.#f(),s.every(i=>i.ok)?y.success(`${t} item${t===1?"":"s"} deleted`):y.danger("Bulk delete failed")}#V(){const e=this.#m.value!=="channels"&&this.#m.value!=="shared"&&this.#h.value&&this.#se().length>0,t=oe.value.username!==null||this.#I.value.length>0;return l`
2708
+ <app-toolbar
2709
+ .showReindex=${e}
2710
+ .reindexing=${this.#_.value}
2711
+ .channelsActive=${this.#m.value==="channels"}
2712
+ .folderViewActive=${this.#m.value==="folder-view"}
2713
+ .showShared=${t}
2714
+ .sharedActive=${this.#m.value==="shared"}
2715
+ .theme=${this.#k.value}
2716
+ .onReindex=${()=>this.#J()}
2717
+ .onToggleChannels=${()=>this.#N(this.#m.value==="channels"?"entries":"channels")}
2718
+ .onToggleFolderView=${()=>this.#N(this.#m.value==="folder-view"?"entries":"folder-view")}
2719
+ .onToggleShared=${()=>this.#N(this.#m.value==="shared"?"entries":"shared")}
2720
+ .onCycleTheme=${()=>this.#q()}
2721
+ ></app-toolbar>
2722
+ `}updated(){this.#_e()}render(){return l`
2723
+ ${this.#Ke()}
2724
+ ${this.#E.value?l`<quick-prompts-modal
2725
+ .onClose=${()=>{this.#E.set(!1),this.#O.set(!1)}}
2726
+ .memoryFolders=${this.#o.value.memory}
2727
+ .openToAdd=${this.#O.value}
2728
+ ></quick-prompts-modal>`:""}
2729
+ <toast-stack></toast-stack>
2730
+ `}#Ke(){const e=this.#a.value,t=this.#se();return this.#m.value==="shared"?l`
2731
+ <div class="toolbar-bar">
2732
+ <div class="header-toolbar">${this.#V()}</div>
2733
+ </div>
2734
+ <shared-with-me-panel
2735
+ .items=${this.#I.value}
2736
+ .refreshing=${this.#P.value}
2737
+ .lastRefreshSummary=${this.#R.value}
2738
+ .memoryFolderNames=${this.#o.value.memory.map(s=>s.name)}
2739
+ .skillFolderNames=${this.#o.value.skill.map(s=>s.name)}
2740
+ .onRefresh=${()=>this.#ue()}
2741
+ .onDismiss=${s=>this.#Se(s)}
2742
+ .onOpen=${s=>this.#Ce(s)}
2743
+ .onFork=${(s,i)=>this.#Ae(s,i)}
2744
+ ></shared-with-me-panel>
2745
+ `:this.#m.value==="channels"?l`
2746
+ <div class="toolbar-bar">
2747
+ <div class="header-toolbar">${this.#V()}</div>
2748
+ </div>
2749
+ <channel-view
2750
+ .channels=${this.#T.value}
2751
+ .selected=${this.#S.value}
2752
+ .detail=${this.#z.value}
2753
+ .loading=${this.#A.value}
2754
+ .onSelect=${s=>this.#ge(s)}
2755
+ .onRefresh=${()=>this.#fe()}
2756
+ ></channel-view>
2757
+ `:this.#m.value==="folder-view"?l`
2758
+ <folder-view
2759
+ .entries=${this.#C.value}
2760
+ .allFolders=${t}
2761
+ .facets=${e}
2762
+ .typeFilter=${this.#s.value}
2763
+ .onTypeChange=${s=>this.#me(s)}
2764
+ .onChanged=${()=>{this.#f(),this.#L()}}
2765
+ .onDateClick=${s=>this.#ve(s)}
2766
+ .onKeyClick=${s=>this.#K(s)}
2767
+ >
2768
+ <div class="header-toolbar" slot="mode-row-end">${this.#V()}</div>
2769
+ </folder-view>
2770
+ `:this.#h.value&&t.length===0&&!this.#d.value?l`
2771
+ <div class="toolbar-bar">
2772
+ <div class="header-toolbar">${this.#V()}</div>
2773
+ </div>
2774
+ <div class="first-run">
2775
+ <h1>No folders configured yet</h1>
2776
+ <p>
2777
+ Add a folder of skills or memory docs to get started. You can add more folders later —
2778
+ e.g. a personal skills repo plus a shared company repo.
2779
+ </p>
2780
+ <button class="add-folder-btn" @click=${()=>this.#d.set(!0)}>+ Add your first folder</button>
2781
+ </div>
2782
+ ${this.#d.value?l`<add-folder-modal
2783
+ .defaultKind=${"skill"}
2784
+ .lockKind=${!1}
2785
+ .onAdded=${s=>this.#be(s)}
2786
+ .onCancel=${()=>this.#d.set(!1)}
2787
+ ></add-folder-modal>`:""}
2788
+ `:l`
2789
+ <div class="folders-bar">
2790
+ <span class="filter-label">Folders:</span>
2791
+ <div class="folder-chips">
2792
+ ${t.map(s=>l`
2793
+ <button
2794
+ class="folder-chip ${s.remote?"remote":""} ${this.#r.value.includes(s.name)?"active":""}"
2795
+ title=${s.remote?`${s.path} (remote — folderfoo)`:s.path}
2796
+ @click=${()=>this.#Ee(s.name)}
2797
+ >
2798
+ ${s.remote?l`<span class="remote-dot"></span>`:"📁"} ${s.name}
2799
+ <span class="kind">(${s.kind==="skill"?"s":"m"})</span>
2800
+ <span
2801
+ class="remove"
2802
+ title="Remove folder"
2803
+ @click=${i=>this.#Re(s,i)}
2804
+ >${this.#g.value===s.name?"…":"✕"}</span
2805
+ >
2806
+ </button>
2807
+ `)}
2808
+ <button class="add-folder-btn" @click=${()=>this.#d.set(!0)}>+ Add folder</button>
2809
+ </div>
2810
+ <div class="header-toolbar">${this.#V()}</div>
2811
+ </div>
2812
+ ${this.#b.value?l`
2813
+ <div class="folderfoo-open-banner">
2814
+ ${this.#b.value}
2815
+ <button class="dismiss" @click=${()=>this.#b.set("")}>✕</button>
2816
+ </div>
2817
+ `:""}
2818
+ <div class="filters">
2819
+ <div class="row search-row">
2820
+ <div class="search-field">
2821
+ <input
2822
+ type="search"
2823
+ placeholder="Search descriptions, bodies, tags..."
2824
+ .value=${this.#t.value}
2825
+ @input=${s=>this.#Le(s)}
2826
+ />
2827
+ ${this.#t.value?l`
2828
+ <button
2829
+ class="search-clear-btn"
2830
+ title="Clear search"
2831
+ aria-label="Clear search"
2832
+ @click=${()=>this.#Fe()}
2833
+ >
2834
+
2835
+ </button>
2836
+ `:""}
2837
+ </div>
2838
+ <div class="row type-toggle">
2839
+ ${kr.map(s=>l`
2840
+ <button
2841
+ class=${this.#s.value===s.value?"active":""}
2842
+ @click=${()=>this.#me(s.value)}
2843
+ >
2844
+ ${s.label}
2845
+ </button>
2846
+ `)}
2847
+ </div>
2848
+ ${e.tags.length===0?l`<span class="filter-label">Tags:</span> <label class="small">no tags yet</label>`:l`
2849
+ <tag-multiselect
2850
+ .tags=${e.tags}
2851
+ .active=${this.#n.value}
2852
+ .onToggle=${s=>this.#ze(s)}
2853
+ .width=${"260px"}
2854
+ ></tag-multiselect>
2855
+ `}
2856
+ <span class="filter-label">Dates:</span>
2857
+ <div class="date-range">
2858
+ <input
2859
+ type="date"
2860
+ aria-label="From date"
2861
+ .value=${this.#y.value}
2862
+ @change=${s=>this.#Ue(s)}
2863
+ />
2864
+ <span class="date-range-sep">–</span>
2865
+ <input
2866
+ type="date"
2867
+ aria-label="To date"
2868
+ .value=${this.#$.value}
2869
+ @change=${s=>this.#je(s)}
2870
+ />
2871
+ ${this.#y.value||this.#$.value?l`
2872
+ <button
2873
+ class="date-range-clear"
2874
+ title="Clear date range"
2875
+ aria-label="Clear date range"
2876
+ @click=${()=>this.#qe()}
2877
+ >
2878
+
2879
+ </button>
2880
+ `:""}
2881
+ </div>
2882
+ <span class="filter-label">Sort:</span>
2883
+ <select
2884
+ .value=${this.#x.value||(this.#t.value.trim()?"relevance":"mtime_desc")}
2885
+ @change=${s=>this.#De(s)}
2886
+ >
2887
+ ${this.#t.value.trim()?l`<option value="relevance">Relevance</option>`:""}
2888
+ <option value="mtime_desc">Recently touched</option>
2889
+ <option value="mtime_asc">Least recently touched</option>
2890
+ <option value="created_at_asc">Oldest first</option>
2891
+ <option value="name_asc">Name</option>
2892
+ </select>
2893
+ <span class="filter-label">Deprecated:</span>
2894
+ <select .value=${this.#v.value} @change=${s=>this.#Me(s)}>
2895
+ ${Pt.map(s=>l`<option value=${s.value}>${s.label}</option>`)}
2896
+ </select>
2897
+ <span class="filter-label">Paused:</span>
2898
+ <select .value=${this.#p.value} @change=${s=>this.#Ne(s)}>
2899
+ ${Pt.map(s=>l`<option value=${s.value}>${s.label}</option>`)}
2900
+ </select>
2901
+ </div>
2902
+ </div>
2903
+ ${this.#l.value.size>0?l`
2904
+ <div class="bulk-bar">
2905
+ <span>${this.#l.value.size} selected</span>
2906
+ <button @click=${()=>this.#ye(!0)}>Mark deprecated</button>
2907
+ <button @click=${()=>this.#ye(!1)}>Un-deprecate</button>
2908
+ <button @click=${()=>this.#ke(!0)}>Pause</button>
2909
+ <button @click=${()=>this.#ke(!1)}>Resume</button>
2910
+ <button class="danger" @click=${()=>this.#He()}>Delete</button>
2911
+ <button @click=${()=>this.#l.set(new Set)}>Clear</button>
2912
+ </div>
2913
+ `:""}
2914
+ <div class="body-region">
2915
+ <result-list
2916
+ style=${`width: ${this.#c.value}%; border-right: 1px solid var(--border);`}
2917
+ .results=${this.#u.value}
2918
+ .showFolder=${t.length>1}
2919
+ .onSelect=${s=>this.#Oe(s)}
2920
+ .selectedIds=${this.#l.value}
2921
+ .onToggleSelect=${s=>this.#Be(s)}
2922
+ .onKeyClick=${s=>this.#K(s)}
2923
+ .onGroupClick=${s=>this.#K(s)}
2924
+ ></result-list>
2925
+ <div
2926
+ class="splitter ${this.#w.value?"dragging":""}"
2927
+ @pointerdown=${s=>this.#Y(s)}
2928
+ ></div>
2929
+ <detail-panel
2930
+ .selected=${this.#i.value}
2931
+ .facets=${e}
2932
+ .onChanged=${()=>{this.#f(),this.#L()}}
2933
+ .onTagClick=${s=>this.#Pe(s)}
2934
+ .onFolderClick=${s=>this.#Ie(s)}
2935
+ .onDateClick=${s=>this.#ve(s)}
2936
+ .onKeyClick=${s=>this.#K(s)}
2937
+ .onGroupClick=${s=>this.#K(s)}
2938
+ .onGone=${()=>this.#i.set(null)}
2939
+ ></detail-panel>
2940
+ </div>
2941
+ ${this.#d.value?l`<add-folder-modal
2942
+ .defaultKind=${"skill"}
2943
+ .lockKind=${!1}
2944
+ .onAdded=${s=>this.#be(s)}
2945
+ .onCancel=${()=>this.#d.set(!1)}
2946
+ ></add-folder-modal>`:""}
2947
+ `}}customElements.define("mem-bucket-app",Tr);