/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../handleUtils","../lang","../maybe"],(function(r,e,n,t){"use strict";function i(r){return r?r.__accessor__?r.__accessor__:r.propertyInvalidated?r:null:null}function o(r,e){return null!=r&&r.metadatas&&null!=r.metadatas[e]}function u(r,e){const n=i(r);return n?n.getDependsInfo(r,e,""):""}function a(r,e,n){if(n){return l(r,e,{policy:n,path:""})}return l(r,e,null)}function l(r,e,i){return e?Object.keys(e).reduce(((r,o)=>{let u=null,a="merge";if(i&&(u=i.path?`${i.path}.${o}`:o,a=i.policy(u)),"replace"===a)return r[o]=e[o],r;if(void 0===r[o])return r[o]=n.clone(e[o]),r;let s=r[o],c=e[o];if(s===c)return r;if(Array.isArray(c)||Array.isArray(r))s=s?Array.isArray(s)?r[o]=s.concat():r[o]=[s]:r[o]=[],c&&(Array.isArray(c)||(c=[c]),c.forEach((r=>{s.includes(r)||s.push(r)})));else if(c&&"object"==typeof c)if(i){const e=i.path;i.path=t.assumeNonNull(u),r[o]=l(s,c,i),i.path=e}else r[o]=l(s,c,null);else r.hasOwnProperty(o)&&!e.hasOwnProperty(o)||(r[o]=c);return r}),r||{}):r}function s(r){return r&&("string"!=typeof r||r.includes("."))?c(r):r}function c(r){return Array.isArray(r)?r:r.split(".")}function f(r){return r.includes(",")?r.split(",").map((r=>r.trim())):[r.trim()]}function p(r){if(Array.isArray(r)){const e=[];for(const n of r)e.push(...f(n));return e}return f(r)}function y(r){if(!r.includes("?"))return null;const e=c(r),n=new Array(e.length);for(let t=0;t<e.length;t++){const r=e[t];n[t]="?"===r[r.length-1],n[t]&&(e[t]=r.slice(0,-1))}return{fullPath:e.join("."),conditional:n}}function h(r,n,t,i){const o=p(n);if(1!==o.length){const n=o.map((e=>i(r,e,t)));return e.handlesGroup(n)}return i(r,o[0],t)}function d(r){let e=!1;return()=>{e||(e=!0,r())}}r.getDependsInfo=u,r.getProperties=i,r.isPropertyDeclared=o,r.merge=a,r.once=d,r.parse=h,r.parseConditionalPath=y,r.pathToArray=c,r.pathToStringOrArray=s,r.splitPath=p,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
