decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 3.21 kB
JavaScript
import{aw as b,cN as g,c as p,cO as h,u as A}from"./index-ztdGKvBm.js";import{u as y}from"./use-blog-view-DMfZjkz0.js";import{e as f,i as o,g as d,t as S}from"./thread-intent-DyZ5A9F9.js";import{a as v,d as w}from"./session-runtime-DBl1Hlcw.js";const D=1e4,P="true",l=2;function c(t,e){return b.chatAutosend(t,e)}function T(t){return t==="pending"||t==="sending"}function N(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const n=e;let a=0;n.status==="sending"?a=n.retryAt===void 0?1:l:n.retryAt!==void 0&&(a=1);const r=n.attempt===void 0?a:n.attempt;return typeof n.createdAt!="number"||typeof n.message!="object"||!T(n.status)||n.retryAt!==void 0&&typeof n.retryAt!="number"||typeof r!="number"||!Number.isInteger(r)||r<0||r>l?null:{...e,attempt:r}}function U(t,e,n,a,r=Date.now()){const i={message:a,createdAt:r,status:"pending",attempt:0};return t.setItem(c(e,n),JSON.stringify(i)),i}function E(t,e,n){const a=c(e,n),r=N(t.getItem(a));return r||(t.removeItem(a),null)}function k(t,e,n,a=Date.now()){const r=c(e,n),i=E(t,e,n);if(!i||i.status!=="pending")return null;if(i.attempt>=l)return t.removeItem(r),null;const s=i.retryAt??i.createdAt;if(a-s>=D)return t.removeItem(r),null;const u={...i,status:"sending",attempt:i.attempt+1};return t.setItem(r,JSON.stringify(u)),{message:u.message,createdAt:u.createdAt,attempt:u.attempt}}function M(t,e,n){t.removeItem(c(e,n))}const x=new Set(["site-editor","content","code","calendar","experiments"]);function _(t,e,n){return n?t==="blog"||t==="blog-post"?"blog":t==="monitoring"?e==="experiments"?"site":null:t&&x.has(t)?"site":null:null}function m(t){return o(t)?"blog":"site"}function j(t,e,n){return e===null?[...t]:t.filter(a=>m(a.branch)===e||a.branch===n)}function F(t,e,n,a){const r=t.filter(i=>i.branch!==e&&(n===null||m(i.branch)===n));return r.find(i=>(i.runtime??a)!=="sandbox")??r[0]}function J(t){return o(t)?"thread.branchPicker.blogDraftName":"thread.branchPicker.defaultVersionName"}function O(t,e,n){return t==="blog"?o(e.branch)||v(e.metadata,n)==="sandbox":t==="site"?!o(e.branch):!0}function C(t,e,n){return!e.partial&&t==="blog"===o(e.branch)&&S(e,w(n))}function Y(t,e){const n=t||f(e);return o(n)?{branch:n}:{branch:n,runtime:"sandbox"}}function K(t,e,n){return O(t,e,n)?null:t==="blog"?"site-editor":"blog"}function G(t,e,n){return n&&o(t)?f(e):d(e)}function Q(t){const e=t.viewKind==="blog"||t.blogView&&o(t.branch)?f(t.userLabel):d(t.userLabel);return t.projectDefault==="cms"?{kind:"new-thread",runtime:"cms",branch:e}:{kind:"repoint",branch:e}}function R(t){if(!t)return null;const e=g(t);return e.kind==="blog"?"blog":e.kind==="site-editor"||e.kind==="agent-section"&&(e.section==="calendar"||e.section==="experiments")?"site":null}function W(t,e,n){return!t||!e||!n?t:K(R(t),e,void 0)??t}function X(){const t=p.c(5),e=h(),n=y();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},t[0]=a):a=t[0];const r=A(a),i="view"in r&&typeof r.view=="string"?r.view:void 0;let s;return t[1]!==n||t[2]!==e||t[3]!==i?(s=_(e,i,n),t[1]=n,t[2]=e,t[3]=i,t[4]=s):s=t[4],s}export{P as A,M as a,Y as b,k as c,J as d,j as e,m as f,Q as g,C as i,G as n,F as s,W as t,X as u,O as v,U as w};