/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/Error","../../core/object","./parser","./utils"],(function(e,t,r,s,n){"use strict";function a(e,t,r){try{return u(e)}catch(n){var s;null==r||null==(s=r.messages)||s.push(n)}return null}function c(e,t,s,n){try{const n=o(e);r.setDeepValue(s,n,t)}catch(a){n.messages&&n.messages.push(a)}}function o(e){const t=s.parse(e);return t?n.isEffectFunctions(t)?t.map((e=>e.toJSON())):t.map((({scale:e,effects:t})=>({scale:e,value:t.map((e=>e.toJSON()))}))):null}function u(e){if(!e||0===e.length)return null;if(i(e)){const t=[];for(const r of e)t.push({scale:r.scale,value:f(r.value)});return t}return f(e)}function i(e){const t=e[0];return!!t&&"scale"in t}function f(e){if(!e||!e.length)return"";const t=[];for(const r of e){let e=[];switch(r.type){case"grayscale":case"sepia":case"saturate":case"invert":case"brightness":case"contrast":case"opacity":e=[l(r,"amount")];break;case"blur":e=[l(r,"radius","pt")];break;case"hue-rotate":e=[l(r,"angle","deg")];break;case"drop-shadow":e=[l(r,"xoffset","pt"),l(r,"yoffset","pt"),l(r,"blurRadius","pt"),p(r,"color")];break;case"bloom":e=[l(r,"strength"),l(r,"radius","pt"),l(r,"threshold")]}const n=`${r.type}(${e.filter(Boolean).join(" ")})`;s.parse(n),t.push(n)}return t.join(" ")}function l(e,r,s){if(null==e[r])throw new t("effect:missing-parameter",`Missing parameter '${r}' in ${e.type} effect`,{effect:e});return s?e[r]+s:""+e[r]}function p(e,r){if(null==e[r])throw new t("effect:missing-parameter",`Missing parameter '${r}' in ${e.type} effect`,{effect:e});const s=e[r];return`rgba(${s[0]||0}, ${s[1]||0}, ${s[2]||0}, ${s[3]/255||0})`}e.effectFunctionsFromJSON=f,e.fromJSON=u,e.read=a,e.toJSON=o,e.write=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
