UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 1.16 kB
import{aw as y}from"./index-ztdGKvBm.js";function p(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(r=>r.type==="hardBreak"||r.type==="text"&&(!r.text||r.text.trim()==="")):!1)}const d="__home__";function c(t,e){return y.chatDraft(t,e)}function l(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const r=e.tiptapDoc;return!r||typeof r!="object"||r.type!=="doc"||!Array.isArray(r.content)?null:r}function _(t,e,r,n,a){const o=c(e,r);if(p(n)){t.removeItem(o);return}const i={tiptapDoc:n,updatedAt:Date.now()},u=JSON.stringify(i);try{t.setItem(o,u)}catch(f){if(m(f)){const s=new TextEncoder().encode(u).byteLength;a?.onQuotaExceeded?.({docSizeBytes:s});return}throw f}}function h(t,e,r){const n=c(e,r),a=t.getItem(n),o=l(a);return a!==null&&o===null&&t.removeItem(n),o}function D(t,e,r){t.removeItem(c(e,r))}function m(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}export{d as H,D as c,p as i,h as r,_ as w};