import{i}from"./CVq-Ik9t.js";import{t as E}from"./CDBVw774.js";const l=new Set(["tabs","tab","section","fieldset","columns","column","conditional","page-exists"]),d=new Set(["order_title","header.order_by","header.order_manual","enabled","health_status","active_triggers"]),y=new Set(["order","blueprint","hidden","spacer","display"]);function m(e,n){if(!e)return;let t=e;for(const r of n.split(".")){if(t==null||typeof t!="object")return;t=t[r]}return t}function s(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function f(e,n){const t=m(n,e.name),r=s(t)?e.default:t;if(!s(r))return null;if(e.validate?.message)return i.tMaybe(e.validate.message);const o=e.label?i.tMaybe(e.label):"";return o?i.t("ADMIN_NEXT.VALIDATION.FIELD_REQUIRED",{label:o}):i.t("ADMIN_NEXT.VALIDATION.REQUIRED_GENERIC")}function p(e,n){for(const t of e){const r=l.has(t.type);if(!r&&t.name===n)return t;if(r&&t.fields?.length){const o=p(t.fields,n);if(o)return o}}}function a(e,n){for(const t of e){const r=l.has(t.type);t.validate?.required===!0&&!r&&!d.has(t.name)&&!y.has(t.type)&&n.push(t),t.fields?.length&&r&&a(t.fields,n)}}function h(e,n){const t=[];a(e,t);const r={};for(const o of t){const u=f(o,n);u&&(r[o.name]=u)}return r}function R(e,n,t){const r=p(e,n);return!r||r.validate?.required!==!0||d.has(r.name)||y.has(r.type)?null:f(r,t)}function S(e,n){const t=[];return a(e,t),t.some(r=>f(r,n)!==null)}function c(e){if(Array.isArray(e))return e.map(c).filter(n=>!s(n));if(e&&typeof e=="object"){const n={};for(const[t,r]of Object.entries(e)){const o=c(r);s(o)||(n[t]=o)}return n}return e}function _(e){return JSON.stringify(c(e))}function I(e,n){const t=h(e,n),r=Object.keys(t).length;return r>0&&E.error(i.t("ADMIN_NEXT.VALIDATION.FORM_HAS_ERRORS",{count:r})),t}function g(){typeof document>"u"||requestAnimationFrame(()=>{document.querySelector("[data-field-error]")?.scrollIntoView({behavior:"smooth",block:"center"})})}export{_ as a,I as c,S as h,c as p,g as s,R as v};
