/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{setDeepValue as e}from"../../core/object.js";import{isSceneServiceLayer as o}from"../../layers/support/layerUtils.js";import n from"../WebStyleSymbol.js";import{to3D as r}from"./symbolConversion.js";import{readSymbol as t,isSymbol3D as l}from"./typeUtils.js";import{addSymbolUnsupportedError as i}from"../../webdoc/support/unsupportedErrors.js";function s(o,n,r,t){const l=p(o,{},{context:t,isLabelSymbol:!1});null!=l&&e(r,l,n)}function u(e,o,n,r){const t=p(e,{},{context:r,isLabelSymbol:!0});null!=t&&(o[n]=t)}function m(e){return l(e)||e instanceof n}function y(e){return"polygon-3d"===e?.type||"line-3d"===e?.type}function p(e,n,t){if(null==e)return null;const{context:l,isLabelSymbol:s}=t,u=l?.origin;if("web-scene"===u&&!m(e)){const o=r(e,{retainCIM:!0,hasLabelingContext:s});return null!=o.symbol?o.symbol.write(n,l):(i(l,e,"Use 3D symbology instead when working with WebScene and SceneView",{error:o.error}),null)}return o(l?.layer)&&y(e)?(i(l,e,`unsupported in layers of type ${l?.layer?.declaredClass}`),null):("web-map"===u||"portal-item"===u&&!o(l?.layer))&&m(e)?(i(l,e,"Use 2D symbology and CIMSymbol instead when working with MapView"),null):e.write(n,l)}function a(e,o){return t(e,null,o)}export{a as fromJSON,s as write,u as writeLabelSymbol};
