UNPKG

decocms

Version:

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

2 lines (1 loc) • 7.13 kB
import{bD as g,bC as E,fd as w,eU as L,fe as A,ff as y,fg as P,eP as d,fh as j,fi as T,fj as k,fk as D,fl as x,fm as R,bq as B,fn as C,fo as K}from"./index-DoEtSiIe.js";import{A as I,r as F,z as U,$,aa as W}from"./blocks-tab-states-CTy1iAF5.js";const l="https://docs.decocms.com/storefront/blocks",ne={quickstart:`${l}/next/quickstart`,siteEditor:`${l}/next/site-editor#edit-on-your-machine`,serve:`${l}/next/cli#deco-serve`,schema:`${l}/next/cli#deco-schema-and-deco-content`,troubleshooting:`${l}/next/troubleshooting#site-editor`},ae="https://github.com/decocms/blocks/tree/main/.agents/skills/deco-site-workflow";function q(e){return e.includes("matchers")||e.includes("Match")}function m(e,r){const t=e.__resolveType;return typeof t!="string"||!t||$(t,r)?!1:r?w(r,t):q(t)}function oe(e,r){const t=[];for(const[n,a]of Object.entries(r)){if(n.includes("/")||!g(n,e)||E(n)||!a||typeof a!="object"||Array.isArray(a))continue;const o=a;m(o,e)&&t.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return t.sort((n,a)=>(n.name??n.blockKey).localeCompare(a.name??a.blockKey))}function p(e,r,t){if(!e)return!1;const n=e.__resolveType;if(typeof n!="string"||!g(n,t)||!Object.hasOwn(r,n))return!1;const a=r[n];return!a||typeof a!="object"||Array.isArray(a)?!1:m(a,t)}function se(e,r,t){return p(e,r,t)?e?.__resolveType??null:null}function S(e,r,t){if(!e)return null;const n=e.__resolveType??"";if(!n)return null;if(p(e,r,t)){const s=r[n]??{},i=s.__resolveType??n,{__resolveType:c,name:u,...v}=s;return{resolveType:i,data:v,blockKey:n}}const{__resolveType:a,...o}=e;return{resolveType:n,data:o}}function Y(e,r,t){const n=S(e,r,t);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function ie(e,r,t){if(e)return p(e,r,t)?Y(e,r,t):e}function z(e,r,t,n){if(!e)return"Default";if(p(e,r,n)){const a=e.__resolveType??"",o=r[a];return I(a,o)}return t(e,F(r))}function ce(e,r,t){return{__resolveType:e,...r,name:t}}function ue(e){return{__resolveType:e}}function le(e,r,t){const n=S(e,r,t);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}function fe(e,r){const t={__resolveType:e};if(!e||!r)return t;const n=U(e,r),a=n?.type==="inline-union"?n.inlineUnionBranches?.[0]?.discriminators:void 0;return a?{...t,...a}:t}function V(e){const r=[];for(let t=e;t?.key!=null;t=t.parent)r.push(t.key);return r.reverse()}function G(e){return{blockKey:e.blockKey,path:V(e)}}function N(e,r,t){const n=[];for(const[o,s]of Object.entries(e))o!==r&&n.push({node:s,blockKey:o,parent:null,key:null});const a=new Set;for(;n.length>0;){const o=n.pop(),{node:s}=o;if(!(!s||typeof s!="object")&&!a.has(s)){if(a.add(s),Array.isArray(s)){s.forEach((i,c)=>{n.push({node:i,blockKey:o.blockKey,parent:o,key:c})});continue}t(s,o);for(const[i,c]of Object.entries(s))n.push({node:c,blockKey:o.blockKey,parent:o,key:i})}}}function H(e,r,t){if(!r)return[];const n=[];return N(e,r,(a,o)=>{if(a.__resolveType!==r||!p(a,e,t))return;const s=J(o);n.push({...G(o),...s?{variant:s}:{}})}),n}function J(e){for(let r=e;r;r=r.parent){const t=r.parent,n=t?.parent,a=n?.parent;if(!t||!n||!a)return;if(r.key==="rule"&&typeof t.key=="number"&&n.key==="variants"&&W(a.node)&&L(a.node.__resolveType)){const o=a.node.experiment;return{containerPath:V(a),containerType:a.node.__resolveType,index:t.key,...typeof o=="string"?{experiment:o}:{}}}}}function Q(e){for(const r of e.anyOfRefs??[]){if(r.resolveType!==A&&r.resolveType!==y)continue;const t=r.schema?.properties?.variants?.items?.properties?.value,n=t?.lazy?t.properties?.value:t;if(n?.type==="array")return n}}function X(e){return Q(e)!==void 0}function ye(e,r){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Array.isArray(t.variants)?t.__resolveType===R?!0:r&&t.__resolveType===y&&!M(t.variants):!1}function M(e){return e.some(r=>Array.isArray(d(r)))}function O(e,r){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return t.__resolveType===A?!0:r&&t.__resolveType===y&&Array.isArray(t.variants)&&M(t.variants)}function pe(e,r){if(!O(e,r))return null;const t=e.variants;if(!Array.isArray(t))return null;const n=B(t[0],r);return Array.isArray(n)?n:null}function ve(e,r,t,n){if(!O(e,n))return r;const a=structuredClone(e),o=[...a.variants??[]];return o.length===0?o.push({rule:k(t),value:T(a.__resolveType,r)}):o[0]=C(a.__resolveType,o[0],r),{...a,variants:o}}function de(e,r){const n=e[r]?.sections;if(!n||Array.isArray(n))return 1;const a=n;return Array.isArray(a.variants)?a.variants.length:1}function _e(e,r,t){const a=e[r]?.sections;if(Array.isArray(a))return t===0?a:[];if(a&&typeof a=="object"){const o=a.variants;if(Array.isArray(o)){const s=d(o[t]);return Array.isArray(s)?s:[]}}return[]}function he(e,r,t){if(Array.isArray(e))return[{label:"Default",sections:e}];if(e&&typeof e=="object"){const n=e;if(Array.isArray(n.variants)){const a=n.variants,o=P(a.map(s=>z(s.rule,r,t)));return a.map((s,i)=>{const c=o[i],u=d(s);return{label:c||`Variant ${i+1}`,sections:Array.isArray(u)?u:[],rule:s.rule}})}}return[]}function _(e,r,t){return{rule:k(r),value:T(t,e)}}function h(e,r){return e?e.__resolveType===y?y:A:D(r)}function f(e,r,t){return{...r,__resolveType:h(r,t),variants:e}}function be(e,r,t,n=!1){const a=structuredClone(r);if(e&&typeof e=="object"&&!Array.isArray(e)){const c=e;if(!Array.isArray(c.variants))return null;const u=[...c.variants],v=j(u,n);return u.splice(v,0,_(a,t,h(c))),{sections:f(u,c),newVariantIndex:v}}const o=h(void 0,t),s=_(Array.isArray(e)?e:[],t,o),i=_(a,t,o);return{sections:f(n?[i,s]:[s,i],void 0,t),newVariantIndex:n?0:1}}function Ae(e,r,t=!1){const n=e[r];if(!n)return null;const a=[...e];return a.splice(K(e,r,t),0,structuredClone(n)),a}function ge(e,r){if(r.length===0)return f([],e);if(r.length===1){const t=r[0],n=t?.rule;if(!x(n))return f(r,e);const a=d(t);if(Array.isArray(a))return a}return f(r,e)}function Z(e,r,t){return H(e,r,t).length}function Te(e,r,t,n){return n?!1:Z(e,r,t)===0}const ke={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}};function b(e){return e.includes("/sections/")||e.includes("multivariate/section")||e===R}function ee(e){if(e.anyOfRefs?.length)return e.anyOfRefs.some(t=>b(t.resolveType));const r=e.properties?.__resolveType;return r?.type==="block-ref"&&r.anyOfRefs?.length?r.anyOfRefs.some(t=>b(t.resolveType)):!1}function Re(e){return e.type!=="block-ref"||!e.anyOfRefs?.length?!1:e.anyOfRefs.some(r=>b(r.resolveType))}function me(e,r){if(r==="global"||r==="sections"||X(e))return!0;const t=e.type==="array"?e.items:void 0;return t?ee(t):!1}export{Te as A,Ae as B,ke as C,ae as D,de as a,be as b,ne as c,X as d,me as e,Y as f,_e as g,ue as h,b as i,Re as j,z as k,oe as l,se as m,le as n,p as o,he as p,ce as q,ie as r,fe as s,ye as t,O as u,pe as v,ve as w,Q as x,S as y,ge as z};