/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{RenderingInfo as e}from"./RenderingInfo.js";import{getVisualVariableValues as t}from"../visualVariables/support/visualVariableUtils.js";function o(e,t){if(null!=e.symbol)return e.symbol;const o=t?.renderer;return null!=o&&"dot-density"!==o.type?o.getSymbol(e,t):null}function i(i,r){const n=o(i,r);if(null==n)return null;const l=r?.renderer,a=new e(l,n);if(null==l||!("visualVariables"in l)||!l.visualVariables)return a;const s=t(l,i,r)??[],u=["proportional","proportional","proportional"];for(const{variable:e,value:t}of s)if(null!=t||"size"===e.type&&e.useSymbolValue)switch(e.type){case"color":a.color=t?.toRgba();break;case"size":if("outline"===e.target)a.outlineSize=t;else{const o=e.axis,i=e.useSymbolValue?"symbol-value":t??"proportional";switch(o){case"width":u[0]=i;break;case"depth":u[1]=i;break;case"height":u[2]=i;break;case"width-and-depth":u[0]=u[1]=i;break;default:u[0]=u[1]=u[2]=i}}break;case"opacity":a.opacity=t;break;case"rotation":switch(e.axis){case"tilt":a.tilt=t;break;case"roll":a.roll=t;break;default:a.heading=t}}return"proportional"===u[0]&&"proportional"===u[1]&&"proportional"===u[2]||(a.size=u),a}async function r(e,t){return null!=e.symbol?e.symbol:t?.renderer?.getSymbolAsync(e,t)??null}async function n(o,i){const n=await r(o,i);if(!n)return null;const l=i?.renderer,a=new e(l,n);if(!l||!("visualVariables"in l)||!l.visualVariables)return a;const s=t(l,o,i)??[],u=["proportional","proportional","proportional"];for(const{variable:e,value:t}of s)if("color"===e.type)a.color=t.toUnitRGBA();else if("size"===e.type)if("outline"===e.target)a.outlineSize=t;else{const o=e.axis,i=e.useSymbolValue?"symbol-value":t;"width"===o?u[0]=i:"depth"===o?u[1]=i:"height"===o?u[2]=i:u[0]=u[1]="width-and-depth"===o?i:u[2]=i}else"opacity"===e.type?a.opacity=t:"rotation"===e.type&&"tilt"===e.axis?a.tilt=t:"rotation"===e.type&&"roll"===e.axis?a.roll=t:"rotation"===e.type&&(a.heading=t);return(isFinite(u[0])||isFinite(u[1])||isFinite(u[2]))&&(a.size=u),a}function l(e,t=0){const o=e[t];return"number"==typeof o&&isFinite(o)?o:null}function a(e){for(let t=0;t<3;t++){const o=e[t];if("number"==typeof o)return isFinite(o)?o:0}return 0}export{l as getDriverAxisSizeValue,a as getDriverAxisSizeValueAny,i as getRenderingInfo,n as getRenderingInfoAsync,r as getSymbolAsync};
