import{isPointCloudLayer as o}from"../utilities/_layers.js";import{checkArg as e}from"../utilities/checkArg.js";import{LayerDefinition as i}from"./LayerDefinition.js";import{PopupInfo as r}from"./PopupInfo.js";import{ERR_LAYER_TYPE_MISMATCH as p,applyLayerBaseToEsriApiLayer as a,applyOperationalLayerToEsriApiLayer as l,fromEsriApiLayerToLayerBase as n,fromEsriApiLayerToOperationalLayer as s}from"./_layerHelper.js";export var PointCloudLayer;!function(t){async function u(n,s){e("layerJson",n).isNotMissing(),e("layerJson.layerType",n.layerType).satisfies((o=>!o||"PointCloudLayer"===o),p),e("layer",s).isNotMissing().satisfies(o,p),a(n,s),l(n,s),n.hasOwnProperty("url")&&(s.url=n.url),n.hasOwnProperty("layerDefinition")&&null!=n.layerDefinition&&await i.applyToEsriApiLayer(n.layerDefinition,s),n.hasOwnProperty("disablePopup")&&(s.popupEnabled=!n.disablePopup),n.hasOwnProperty("popupInfo")&&null!=n.popupInfo&&(s.popupTemplate=r.toEsriApiPopupTemplate(n.popupInfo))}t.esriPointCloudLayerDefaults={visible:!0,popupEnabled:!0},t.toEsriApiLayer=async function(o){e("layerJson",o).isNotMissing(),e("layerJson.layerType",o.layerType).satisfies((o=>!o||"PointCloudLayer"===o),p);const i={};o?.url&&(i.url=o.url);const r=new((await import("@arcgis/core/layers/PointCloudLayer")).default);return await u(o,r),r},t.applyToEsriApiLayer=u,t.fromEsriApiPointCloudLayer=function(o){e("layer",o).isNotMissing();const p={...n(o),...s(o),layerType:"PointCloudLayer",layerDefinition:i.fromEsriApiLayer(o,t.esriPointCloudLayerDefaults),url:o.url??void 0};return o.popupEnabled!==t.esriPointCloudLayerDefaults.popupEnabled&&(p.disablePopup=!o.popupEnabled),o.popupTemplate&&(p.popupInfo=r.fromEsriApiPopupTemplate(o.popupTemplate)),p}}(PointCloudLayer||(PointCloudLayer={}));