/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../pacer-lite/dist/lite-throttler.js"),r=require("./EventClient.js");function t(e,r){return"function"==typeof e?e(r):e}const n=/^(\d+)$/gm,o=/\.(\d+)(?=\.)/gm,i=/^(\d+)\./gm,a=/\.(\d+$)/gm,s=/\.{2,}/gm,u="__int__",c=`${u}$1`;function l(e){if(Array.isArray(e))return[...e];if("string"!=typeof e)throw new Error("Path must be a string.");return e.replace(/(^\[)|]/gm,"").replace(/\[/g,".").replace(n,c).replace(o,`.${c}.`).replace(i,`${c}.`).replace(a,`.${c}`).replace(s,".").split(".").map(e=>{if(e.startsWith(u)){const r=e.substring(u.length),t=parseInt(r,10);return String(t)===r?t:r}return e})}let f=256;const y=[];let d;for(;f--;)y[f]=(f+256).toString(16).substring(1);const p=e.liteThrottle(e=>r.formEventClient.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});exports.deleteBy=function(e,r){const t=l(r);return function e(r){if(!r)return;if(1===t.length){const e=t[0];if(Array.isArray(r)&&"number"==typeof e)return r.filter((r,t)=>t!==e);const{[e]:n,...o}=r;return o}const n=t.shift();if(("string"==typeof n||"number"==typeof n&&!Array.isArray(r))&&"object"==typeof r)return{...r,[n]:e(r[n])};if("number"==typeof n&&Array.isArray(r)){if(n>=r.length)return r;const t=r.slice(0,n);return[...t.length?t:new Array(n),e(r[n]),...r.slice(n+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}(e)},exports.determineFieldLevelErrorSourceAndValue=({formLevelError:e,fieldLevelError:r})=>r?{newErrorValue:r,newSource:"field"}:e?{newErrorValue:e,newSource:"form"}:{newErrorValue:void 0,newSource:void 0},exports.determineFormLevelErrorSourceAndValue=({newFormValidatorError:e,isPreviousErrorFromFormValidator:r,previousErrorValue:t})=>e?{newErrorValue:e,newSource:"form"}:r?{newErrorValue:void 0,newSource:void 0}:t?{newErrorValue:t,newSource:"field"}:{newErrorValue:void 0,newSource:void 0},exports.evaluate=function e(r,t){if(Object.is(r,t))return!0;if("object"!=typeof r||null===r||"object"!=typeof t||null===t)return!1;if(r instanceof Date&&t instanceof Date)return r.getTime()===t.getTime();if(r instanceof Map&&t instanceof Map){if(r.size!==t.size)return!1;for(const[e,n]of r)if(!t.has(e)||!Object.is(n,t.get(e)))return!1;return!0}if(r instanceof Set&&t instanceof Set){if(r.size!==t.size)return!1;for(const e of r)if(!t.has(e))return!1;return!0}const n=Object.keys(r),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i)||!e(r[i],t[i]))return!1;return!0},exports.functionalUpdate=t,exports.getAsyncValidatorArray=function(e,r){const{asyncDebounceMs:t}=r,{onBlurAsyncDebounceMs:n,onChangeAsyncDebounceMs:o,onDynamicAsyncDebounceMs:i}=r.validators||{},a=t??0;return r.validationLogic({form:r.form,validators:r.validators,event:{type:e,async:!0},runValidation:r=>r.validators.filter(Boolean).map(r=>{const t=r?.cause||e;let s=a;switch(t){case"change":s=o??a;break;case"blur":s=n??a;break;case"dynamic":s=i??a;break;case"submit":s=0}return"submit"===e&&(s=0),{cause:t,validate:r.fn,debounceMs:s}})})},exports.getBy=function(e,r){return l(r).reduce((e,r)=>null===e?null:void 0!==e?e[r]:void 0,e)},exports.getSyncValidatorArray=function(e,r){return r.validationLogic({form:r.form,validators:r.validators,event:{type:e,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})},exports.isGlobalFormValidationError=e=>!!e&&"object"==typeof e&&"fields"in e,exports.isNonEmptyArray=function(e){return!(Array.isArray(e)&&0===e.length)},exports.makePathArray=l,exports.mergeOpts=function(e,r){return null==e?r:{...e,...r}},exports.setBy=function(e,r,n){const o=l(r);return function e(r){if(!o.length)return t(n,r);const i=o.shift();if("string"==typeof i||"number"==typeof i&&!Array.isArray(r))return"object"==typeof r?(null===r&&(r={}),{...r,[i]:e(r[i])}):{[i]:e()};if(Array.isArray(r)&&"number"==typeof i){const t=r.slice(0,i);return[...t.length?t:new Array(i),e(r[i]),...r.slice(i+1)]}return[...new Array(i),e()]}(e)},exports.throttleFormState=p,exports.uuid=function(){let e,r=0,t="";if(!d||f+16>256){for(d=new Array(256),r=256;r--;)d[r]=256*Math.random()|0;r=0,f=0}for(;r<16;r++)e=d[f+r],t+=6===r?y[15&e|64]:8===r?y[63&e|128]:y[e],1&r&&r>1&&r<11&&(t+="-");return f++,t};