import t from"@arcgis/core/Graphic";import{checkArg as e}from"../utilities/checkArg.js";import{deepClone as p}from"../utilities/object.js";import{toEsriApiGeometry as r,toPortalGeometry as i}from"./Geometry.js";import{PopupInfo as o}from"./PopupInfo.js";import{fromEsriApiSymbol as s,toEsriApiSymbol as m}from"./Symbol.js";export var Feature;!function(u){u.GRAPHIC_VISIBLE_FIELD="graphic-visible",u.GRAPHIC_POPUP_TEMPLATE_FIELD="graphic-popup-template",u.toEsriApiGraphic=function(i){e("featureJson",i).isNotMissing();const s=new t;return s.attributes=i.attributes?p(i.attributes):{},i.geometry&&(s.geometry=r(i.geometry)),i.symbol&&(s.symbol=m(i.symbol)),s.visible=!i.attributes?.hasOwnProperty(u.GRAPHIC_VISIBLE_FIELD)||i.attributes[u.GRAPHIC_VISIBLE_FIELD],i.popupInfo?s.popupTemplate=o.toEsriApiPopupTemplate(i.popupInfo):i.attributes?.[u.GRAPHIC_POPUP_TEMPLATE_FIELD]&&(s.popupTemplate=o.toEsriApiPopupTemplate(JSON.parse(i.attributes[u.GRAPHIC_POPUP_TEMPLATE_FIELD]))),delete s.attributes[u.GRAPHIC_VISIBLE_FIELD],delete s.attributes[u.GRAPHIC_POPUP_TEMPLATE_FIELD],s},u.fromEsriApiGraphic=function(t){e("graphic",t).isNotMissing();const r={};return r.attributes=t.attributes?p(t.attributes):{},t.geometry&&(r.geometry=i(t.geometry)),t.symbol&&(r.symbol=s(t.symbol)),r.attributes[u.GRAPHIC_VISIBLE_FIELD]=t.visible,t.popupTemplate&&(r.popupInfo=o.fromEsriApiPopupTemplate(t.popupTemplate),r.attributes[u.GRAPHIC_POPUP_TEMPLATE_FIELD]=JSON.stringify(o.fromEsriApiPopupTemplate(t.popupTemplate))),r}}(Feature||(Feature={}));