import{i}from"./dc0o8kHW.js";import{t as E}from"./HL7kq492.js";const a=new Set(["tabs","tab","section","fieldset","columns","column","conditional","page-exists"]),u=new Set(["order_title","header.order_by","header.order_manual","enabled","health_status","active_triggers"]),l=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 d(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 y(e,n){for(const t of e){const r=a.has(t.type);if(!r&&t.name===n)return t;if(r&&t.fields?.length){const o=y(t.fields,n);if(o)return o}}}function p(e,n){for(const t of e){const r=a.has(t.type);t.validate?.required===!0&&!r&&!u.has(t.name)&&!l.has(t.type)&&n.push(t),t.fields?.length&&r&&p(t.fields,n)}}function h(e,n){const t=[];p(e,t);const r={};for(const o of t){const c=d(o,n);c&&(r[o.name]=c)}return r}function S(e,n,t){const r=y(e,n);return!r||r.validate?.required!==!0||u.has(r.name)||l.has(r.type)?null:d(r,t)}function f(e){if(Array.isArray(e))return e.map(f).filter(n=>!s(n));if(e&&typeof e=="object"){const n={};for(const[t,r]of Object.entries(e)){const o=f(r);s(o)||(n[t]=o)}return n}return e}function R(e){return JSON.stringify(f(e))}function _(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 I(){typeof document>"u"||requestAnimationFrame(()=>{document.querySelector("[data-field-error]")?.scrollIntoView({behavior:"smooth",block:"center"})})}export{R as a,_ as c,f as p,I as s,S as v};
