/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as C } from "../../chunks/runtime.js";
import { css as $, html as s } from "lit";
import { keyed as T } from "lit/directives/keyed.js";
import { createRef as I, ref as z } from "lit/directives/ref.js";
import { LitElement as M, createEvent as m, nothing as c, safeClassMap as f } from "@arcgis/lumina";
import { usePropertyChange as F } from "@arcgis/lumina/controllers";
import { classes as g } from "@arcgis/toolkit/dom";
import { m as B } from "../../chunks/useViewModel.js";
import { u as P } from "../../chunks/useT9n.js";
import { hasDisplayProperties as b } from "@arcgis/core/applications/Components/formatUtils.js";
import V from "@arcgis/core/geometry/Point.js";
import w from "@arcgis/core/widgets/CoordinateConversion/support/Conversion.js";
import L from "@arcgis/core/widgets/CoordinateConversion/CoordinateConversionViewModel.js";
import { rethrowError as x } from "@arcgis/toolkit/log";
const S = $`[class^=esri-icon-],[class*=" esri-icon-"]{speak:none;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-style:normal;font-weight:var(--calcite-font-weight-normal);line-height:1;font-family:CalciteWebCoreIcons!important}.esri-icon-close:before{content:"";color:inherit}.esri-icon-drag-horizontal:before{content:"";color:inherit}.esri-icon-drag-vertical:before{content:"";color:inherit}.esri-icon-handle-horizontal:before{content:"";color:inherit}.esri-icon-handle-vertical:before{content:"";color:inherit}.esri-icon-check-mark:before{content:"";color:inherit}.esri-icon-left-triangle-arrow:before{content:"";color:inherit}.esri-icon-right-triangle-arrow:before{content:"";color:inherit}.esri-icon-down-arrow:before{content:"";color:inherit}.esri-icon-up-arrow:before{content:"";color:inherit}.esri-icon-overview-arrow-bottom-left:before{content:"";color:inherit}.esri-icon-overview-arrow-bottom-right:before{content:"";color:inherit}.esri-icon-overview-arrow-top-left:before{content:"";color:inherit}.esri-icon-overview-arrow-top-right:before{content:"";color:inherit}.esri-icon-maximize:before{content:"";color:inherit}.esri-icon-minimize:before{content:"";color:inherit}.esri-icon-checkbox-unchecked:before{content:"";color:inherit}.esri-icon-checkbox-checked:before{content:"";color:inherit}.esri-icon-radio-unchecked:before{content:"";color:inherit}.esri-icon-radio-checked:before{content:"";color:inherit}.esri-icon-up-arrow-circled:before{content:"";color:inherit}.esri-icon-down-arrow-circled:before{content:"";color:inherit}.esri-icon-left-arrow-circled:before{content:"";color:inherit}.esri-icon-right-arrow-circled:before{content:"";color:inherit}.esri-icon-zoom-out-fixed:before{content:"";color:inherit}.esri-icon-zoom-in-fixed:before{content:"";color:inherit}.esri-icon-refresh:before{content:"";color:inherit}.esri-icon-edit:before{content:"";color:inherit}.esri-icon-authorize:before{content:"";color:inherit}.esri-icon-map-pin:before{content:"";color:inherit}.esri-icon-blank-map-pin:before{content:"";color:inherit}.esri-icon-table:before{content:"";color:inherit}.esri-icon-plus:before{content:"";color:inherit}.esri-icon-minus:before{content:"";color:inherit}.esri-icon-beginning:before{content:"";color:inherit}.esri-icon-reverse:before{content:"";color:inherit}.esri-icon-pause:before{content:"";color:inherit}.esri-icon-play:before{content:"";color:inherit}.esri-icon-forward:before{content:"";color:inherit}.esri-icon-end:before{content:"";color:inherit}.esri-icon-erase:before{content:"";color:inherit}.esri-icon-up-down-arrows:before{content:"";color:inherit}.esri-icon-left:before{content:"";color:inherit}.esri-icon-right:before{content:"";color:inherit}.esri-icon-announcement:before{content:"";color:inherit}.esri-icon-notice-round:before{content:"";color:inherit}.esri-icon-notice-triangle:before{content:"";color:inherit}.esri-icon-home:before{content:"";color:inherit}.esri-icon-locate:before{content:"";color:inherit}.esri-icon-expand:before{content:"";color:inherit}.esri-icon-collapse:before{content:"";color:inherit}.esri-icon-layer-list:before{content:"";color:inherit}.esri-icon-basemap:before{content:"";color:inherit}.esri-icon-globe:before{content:"";color:inherit}.esri-icon-applications:before{content:"";color:inherit}.esri-icon-arrow-up-circled:before{content:"";color:inherit}.esri-icon-arrow-down-circled:before{content:"";color:inherit}.esri-icon-arrow-left-circled:before{content:"";color:inherit}.esri-icon-arrow-right-circled:before{content:"";color:inherit}.esri-icon-minus-circled:before{content:"";color:inherit}.esri-icon-plus-circled:before{content:"";color:inherit}.esri-icon-add-attachment:before{content:"";color:inherit}.esri-icon-attachment:before{content:"";color:inherit}.esri-icon-calendar:before{content:"";color:inherit}.esri-icon-close-circled:before{content:"";color:inherit}.esri-icon-browser:before{content:"";color:inherit}.esri-icon-collection:before{content:"";color:inherit}.esri-icon-comment:before{content:"";color:inherit}.esri-icon-configure-popup:before{content:"";color:inherit}.esri-icon-contact:before{content:"";color:inherit}.esri-icon-dashboard:before{content:"";color:inherit}.esri-icon-deny:before{content:"";color:inherit}.esri-icon-description:before{content:"";color:inherit}.esri-icon-directions:before{content:"";color:inherit}.esri-icon-directions2:before{content:"";color:inherit}.esri-icon-documentation:before{content:"";color:inherit}.esri-icon-duplicate:before{content:"";color:inherit}.esri-icon-review:before{content:"";color:inherit}.esri-icon-environment-settings:before{content:"";color:inherit}.esri-icon-error:before{content:"";color:inherit}.esri-icon-error2:before{content:"";color:inherit}.esri-icon-experimental:before{content:"";color:inherit}.esri-icon-feature-layer:before{content:"";color:inherit}.esri-icon-filter:before{content:"";color:inherit}.esri-icon-grant:before{content:"";color:inherit}.esri-icon-group:before{content:"";color:inherit}.esri-icon-key:before{content:"";color:inherit}.esri-icon-labels:before{content:"";color:inherit}.esri-icon-tag:before{content:"";color:inherit}.esri-icon-layers:before{content:"";color:inherit}.esri-icon-left-arrow:before{content:"";color:inherit}.esri-icon-right-arrow:before{content:"";color:inherit}.esri-icon-link-external:before{content:"";color:inherit}.esri-icon-link:before{content:"";color:inherit}.esri-icon-loading-indicator:before{content:"";color:inherit}.esri-icon-maps:before{content:"";color:inherit}.esri-icon-marketplace:before{content:"";color:inherit}.esri-icon-media:before{content:"";color:inherit}.esri-icon-media2:before{content:"";color:inherit}.esri-icon-menu:before{content:"";color:inherit}.esri-icon-mobile:before{content:"";color:inherit}.esri-icon-phone:before{content:"";color:inherit}.esri-icon-navigation:before{content:"";color:inherit}.esri-icon-pan:before{content:"";color:inherit}.esri-icon-printer:before{content:"";color:inherit}.esri-icon-pie-chart:before{content:"";color:inherit}.esri-icon-chart:before{content:"";color:inherit}.esri-icon-line-chart:before{content:"";color:inherit}.esri-icon-question:before{content:"";color:inherit}.esri-icon-resend-invitation:before{content:"";color:inherit}.esri-icon-rotate:before{content:"";color:inherit}.esri-icon-save:before{content:"";color:inherit}.esri-icon-settings:before{content:"";color:inherit}.esri-icon-settings2:before{content:"";color:inherit}.esri-icon-share:before{content:"";color:inherit}.esri-icon-sign-out:before{content:"";color:inherit}.esri-icon-support:before{content:"";color:inherit}.esri-icon-user:before{content:"";color:inherit}.esri-icon-time-clock:before{content:"";color:inherit}.esri-icon-trash:before{content:"";color:inherit}.esri-icon-upload:before{content:"";color:inherit}.esri-icon-download:before{content:"";color:inherit}.esri-icon-zoom-in-magnifying-glass:before{content:"";color:#6e6e6e}.esri-icon-search:before{content:"";color:inherit}.esri-icon-zoom-out-magnifying-glass:before{content:"";color:#6e6e6e}.esri-icon-locked:before{content:"";color:inherit}.esri-icon-unlocked:before{content:"";color:inherit}.esri-icon-favorites:before{content:"";color:inherit}.esri-icon-compass:before{content:"";color:inherit}.esri-icon-down:before{content:"";color:inherit}.esri-icon-up:before{content:"";color:inherit}.esri-icon-chat:before{content:"";color:inherit}.esri-icon-dock-bottom:before{content:"";color:inherit}.esri-icon-dock-left:before{content:"";color:inherit}.esri-icon-dock-right:before{content:"";color:inherit}.esri-icon-organization:before{content:"";color:inherit}.esri-icon-north-navigation:before{content:"";color:inherit}.esri-icon-locate-circled:before{content:"";color:inherit}.esri-icon-dial:before{content:"";color:inherit}.esri-icon-polygon:before{content:"";color:inherit}.esri-icon-polyline:before{content:"";color:inherit}.esri-icon-visible:before{content:"";color:inherit}.esri-icon-non-visible:before{content:"";color:inherit}.esri-icon-link-vertical:before{content:"";color:inherit}.esri-icon-unlocked-link-vertical:before{content:"";color:inherit}.esri-icon-link-horizontal:before{content:"";color:inherit}.esri-icon-unlocked-link-horizontal:before{content:"";color:inherit}.esri-icon-swap:before{content:"";color:inherit}.esri-icon-cta-link-external:before{content:"";color:inherit}.esri-icon-reply:before{content:"";color:inherit}.esri-icon-public:before{content:"";color:inherit}.esri-icon-share2:before{content:"";color:inherit}.esri-icon-launch-link-external:before{content:"";color:inherit}.esri-icon-rotate-back:before{content:"";color:inherit}.esri-icon-pan2:before{content:"";color:inherit}.esri-icon-tracking:before{content:"";color:inherit}.esri-icon-expand2:before{content:"";color:inherit}.esri-icon-arrow-down:before{content:"";color:inherit}.esri-icon-arrow-up:before{content:"";color:inherit}.esri-icon-hollow-eye:before{content:"";color:inherit}.esri-icon-play-circled:before{content:"";color:inherit}.esri-icon-volume-off:before{content:"";color:inherit}.esri-icon-volume-on:before{content:"";color:inherit}.esri-icon-bookmark:before{content:"";color:inherit}.esri-icon-lightbulb:before{content:"";color:inherit}.esri-icon-sketch-rectangle:before{content:"";color:inherit}.esri-icon-north-navigation-filled:before{content:"";color:inherit}.esri-icon-default-action:before{content:"";color:inherit}.esri-icon-undo:before{content:"";color:inherit}.esri-icon-redo:before{content:"";color:inherit}.esri-icon-cursor:before{content:"";color:inherit}.esri-icon-cursor-filled:before{content:"";color:inherit}.esri-icon-measure:before{content:"";color:inherit}.esri-icon-measure-line:before{content:"";color:inherit}.esri-icon-measure-area:before{content:"";color:inherit}.esri-icon-legend:before{content:"";color:inherit}.esri-icon-sliders:before{content:"";color:inherit}.esri-icon-sliders-horizontal:before{content:"";color:inherit}.esri-icon-cursor-marquee:before{content:"";color:inherit}.esri-icon-lasso:before{content:"";color:inherit}.esri-icon-elevation-profile:before{content:"";color:inherit}.esri-icon-slice:before{content:"";color:inherit}.esri-icon-line-of-sight:before{content:"";color:inherit}.esri-icon-zoom-to-object:before{content:"";color:inherit}.esri-icon-urban-model:before{content:"";color:inherit}.esri-icon-measure-building-height-shadow:before{content:"";color:inherit}.esri-icon-partly-cloudy:before{content:"";color:inherit}.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden}.esri-button{box-sizing:border-box;cursor:pointer;white-space:normal;word-break:normal;color:var(--calcite-color-text-1);background-color:var(--calcite-color-status-info);border:var(--calcite-spacing-px) solid var(--calcite-color-status-info);justify-content:center;align-items:center;width:100%;min-height:var(--calcite-spacing-xxxl);padding:6px 7px;font-family:inherit;font-size:var(--calcite-font-size);transition:background-color .125s ease-in-out,border .125s ease-in-out;display:flex;overflow:hidden;&:hover{color:var(--calcite-color-text-1);background-color:var(--calcite-color-status-info-hover);border:var(--calcite-spacing-px) solid var(--calcite-color-status-info-hover)}}.esri-button:hover{color:var(--calcite-color-text-1);background-color:var(--calcite-color-text-2);border:1px solid var(--calcite-color-text-2)}.esri-button.esri-button--small{min-height:var(--calcite-spacing-xl);font-size:var(--calcite-font-size-sm)}.esri-button.esri-button--half{width:50%;display:inline-block}.esri-button.esri-button--third{width:33%;display:inline-block}.esri-button--secondary{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-button--tertiary{color:var(--calcite-color-brand);background-color:var(--calcite-color-transparent);border-color:var(--calcite-color-transparent)}.esri-button--tertiary:hover{color:var(--calcite-color-brand-hover);background-color:var(--calcite-color-foreground-2);border-color:var(--calcite-color-transparent)}.esri-button--disabled{opacity:.4;pointer-events:none}.esri-button--drill-in{outline-offset:-4px;cursor:pointer;text-align:unset;background-color:var(--calcite-color-foreground-1);border:none;border-radius:2px;justify-content:space-between;align-items:center;margin:var(--calcite-spacing-md) 7px;padding:var(--calcite-spacing-md) 7px;text-decoration:none;transition:background-color .125s ease-in-out;display:flex;box-shadow:0 0 0 1px #adadad4d}.esri-button--drill-in:hover,.esri-button--drill-in:focus{background-color:var(--calcite-color-foreground-2)}.esri-button--drill-in__title{font-size:var(--calcite-font-size)}.esri-button--drill-in [class^=esri-icon-],.esri-button--drill-in [class*=" esri-icon-"]{padding:0 7px}.esri-widget--button{cursor:pointer;text-align:center;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);flex-flow:row;justify-content:center;align-items:center;width:var(--calcite-spacing-xxxl);height:var(--calcite-spacing-xxxl);margin:0;padding:0;font-size:var(--calcite-font-size);transition:background-color .125s ease-in-out;display:flex;overflow:hidden}.esri-widget--button:is(calcite-button):not(:hover){--calcite-icon-color: var(--calcite-color-text-3)}.esri-widget--button:not([appearance]),.esri-widget--button[appearance=solid]{--calcite-color-foreground-3: var(--calcite-color-foreground-1)}.esri-widget--button:is(calcite-button){--calcite-offset-invert-focus: 1}.esri-widget--button calcite-loader[inline]{margin:auto}.esri-button--secondary{color:var(--calcite-color-brand);background-color:var(--calcite-color-foreground-1);&:hover{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-status-info);border:1px solid var(--calcite-color-status-info)}}:host{background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2);--coordinate-conversion-width: 425px;--coordinate-font-size: var(--calcite-font-size-sm);--alert-width: 225px;--arcgis-internal-coordinate-conversion-flex-direction: column;width:var(--coordinate-conversion-width)}.no-basemap{padding:var(--calcite-spacing-xxs)}.root{background-color:var(--calcite-color-foreground-1);position:relative}.conversions-view{display:flex;flex-direction:var(--arcgis-internal-coordinate-conversion-flex-direction);background-color:var(--calcite-color-foreground-1)}.conversion-list{flex-direction:var(--arcgis-internal-coordinate-conversion-flex-direction)}.conversions-view.expand-down{display:flex;flex-direction:column}.conversions-view.expand-down .conversion-list{flex-direction:column}.conversions-view.expand-up{display:flex;flex-direction:column-reverse}.conversions-view.expand-up .conversion-list{flex-direction:column-reverse}.conversion-list{display:flex;padding-left:0;margin:0}.tool-display{list-style:none;display:flex;margin:0;padding:0;font-size:var(--calcite-font-size-sm)}.conversion-row{padding:0 var(--esri-widget-padding-y);justify-content:space-between;align-items:center;display:flex}.conversion-row:hover .copy-button{display:block}.conversions-view{padding:var(--arcgis-internal-padding-md)}.coordinate-display{font-size:var(--coordinate-font-size);word-break:break-word;word-wrap:break-word;direction:ltr;flex:auto;display:flex;align-items:center;padding-left:var(--calcite-spacing-sm);min-height:var(--calcite-spacing-xxxl)}.coordinate-display:hover{background:var(--calcite-color-transparent-hover)}.copy-button{display:none}.row-select{width:5rem;flex-shrink:0;text-align-last:center}.section-heading{display:flex;align-items:center;background-color:var(--calcite-color-background);width:100%;height:var(--calcite-size-fixed-xxxl)}.section-title{margin:0 auto!important}.input-form-group{display:flex;align-items:center;justify-content:space-between;margin:var(--calcite-spacing-md) auto var(--calcite-spacing-md) auto;width:80%}.input-form{display:flex;flex-direction:column;background-color:var(--calcite-color-foreground-1)}.coordinate-input{flex:1;margin:0;font-size:var(--coordinate-font-size)}.settings{display:flex;flex-direction:column;align-items:center;background-color:var(--calcite-color-foreground-1)}.settings-form-group{display:flex;flex-direction:column;align-items:center;width:60%}.settings-form-group-horizontal{display:flex;position:relative;flex-direction:row;width:100%}.settings-form-group-first{margin-top:var(--calcite-spacing-sm)}.settings-form-group:last-child{width:100%;text-align:center}.preview-coordinate{min-height:var(--calcite-spacing-xl)}`, D = 2500, E = 1e3, A = new V({
  x: 0,
  y: 0
}), d = {
  chevronDown: "chevron-down",
  chevronUp: "chevron-up",
  copy: "copy",
  pinTear: "pin-tear",
  pinTearF: "pin-tear-f",
  arrowLeft: "arrow-left",
  refresh: "refresh"
}, O = B(L);
class U extends M {
  constructor() {
    super(...arguments), this.alertTimer = -1, this.messages = P(), this._coordinateInput = I(), this._currentView = "conversions", this._multipleConversionsDisabled = !1, this.viewModel = O(this), this.clearAlertTimeout = () => {
      window.clearTimeout(this.alertTimer), this.alertProperties = {
        ...this.alertProperties,
        open: !1
      };
    }, this.alertProperties = {
      kind: "brand",
      message: null,
      title: null,
      open: !1
    }, this.invalidInput = !1, this.goToEnabled = !1, this.inputFormat = null, this.previewConversion = null, this.settingsFormat = null, this.view = this.viewModel.view, this.autoDestroyDisabled = !1, this.conversions = this.viewModel.conversions, this.currentLocation = this.viewModel.currentLocation, this.expanded = !1, this.formats = this.viewModel.formats, this.goToOverride = this.viewModel.goToOverride, this.headingLevel = 4, this.hideCaptureButton = !1, this.hideInputButton = !1, this.hideExpandButton = !1, this.hideSettingsButton = !1, this.icon = "coordinate-system", this.label = this.messages?.componentLabel, this.locationSymbol = this.viewModel.locationSymbol, this.mode = this.viewModel.mode, this.orientation = "auto", this.removeLeadingZeros = this.viewModel.removeLeadingZeros, this.state = this.viewModel.state, this.storageDisabled = this.viewModel.storageEnabled, this.storageType = this.viewModel.storageType, this.arcgisConversionChange = m(), this.arcgisPropertyChange = F()("currentLocation", "state", "expanded", "mode"), this.arcgisReady = m();
  }
  static {
    this.properties = { alertProperties: 16, invalidInput: 16, currentView: 16, goToEnabled: 16, inputFormat: 16, previewConversion: 16, settingsFormat: 16, view: 0, autoDestroyDisabled: 5, conversions: 0, currentLocation: 0, expanded: 7, formats: 0, goToOverride: 0, headingLevel: 9, hideCaptureButton: 7, hideInputButton: 7, hideExpandButton: 7, hideSettingsButton: 7, icon: 1, ignoreCoordinatePrecision: 5, label: 1, locationSymbol: 0, mode: 3, multipleConversionsDisabled: 7, orientation: 3, referenceElement: 1, removeLeadingZeros: 7, state: 32, storageDisabled: 7, storageType: 1 };
  }
  static {
    this.styles = S;
  }
  get currentView() {
    return this._currentView;
  }
  set currentView(e) {
    e !== "conversions" ? this.viewModel.pause() : this.viewModel.resume(), e === "settings" && this.setPreviewConversion(), e !== "coordinate-input" && (this.invalidInput = !1), this._currentView = e;
  }
  get ignoreCoordinatePrecision() {
    return !this.viewModel.calculateCoordinatePrecision;
  }
  set ignoreCoordinatePrecision(e) {
    this.viewModel.calculateCoordinatePrecision = !e;
  }
  get multipleConversionsDisabled() {
    return this._multipleConversionsDisabled;
  }
  set multipleConversionsDisabled(e) {
    e && (this.expanded = !1, this.conversions.splice(1, this.conversions.length - 1)), this._multipleConversionsDisabled = e;
  }
  async destroy() {
    this.clearAlertTimeout(), await this.manager.destroy();
  }
  async reverseConvert(e, o) {
    return await this.viewModel.reverseConvert(e, o);
  }
  addConversion(e) {
    const o = e.target, t = o.selectedOption.value, i = j(o);
    if (t == null || i == null)
      return;
    const r = new w({ format: t });
    o.value = "default", i >= 0 ? (this.conversions.removeAt(i), this.conversions.add(r, i)) : this.conversions.add(r), this.arcgisConversionChange.emit();
  }
  async copyToClipboard(e) {
    e && (e = e.replace(/‎/gu, ""), await navigator.clipboard.writeText(e), this.showAlertMessage(null, this.messages.copySuccessMessage, "success", E));
  }
  findSettingsFormat() {
    return this.settingsFormat || this.conversions.reduceRight((e, o) => {
      const t = o.format;
      return t && b(t) ? t : e;
    }, null) || this.formats.find((e) => b(e)) || null;
  }
  getId(e) {
    return `arcgis-coordinate-conversion-${e}`;
  }
  async processUserInput(e, o) {
    const { viewModel: t } = this;
    try {
      const i = await this._reverseConvert(e, o);
      if (!i)
        throw new Error("failed to process user input");
      this.mode === "capture" ? t.resume() : this.mode = "capture", this.invalidInput = !1, this.currentLocation = i ?? void 0, t.setLocation(i), this.currentView = "conversions", this._coordinateInput.value && (this._coordinateInput.value.value = "");
    } catch (i) {
      x(this)(i), this.showAlertMessage(null, this.messages?.invalidCoordinate, "warning"), this.invalidInput = !0;
    }
  }
  async processUserKeyboardInput(e) {
    const { key: o } = e;
    if (o === "Enter") {
      const t = this.inputFormat || this.conversions.at(0)?.format, i = this._coordinateInput.value?.value;
      if (!t || !i)
        return;
      await this.processUserInput(i, t);
    } else
      this.invalidInput = !1;
  }
  async processUserMouseInput() {
    const e = this.inputFormat || this.conversions.at(0)?.format, o = this._coordinateInput.value?.value;
    !e || !o || await this.processUserInput(o, e);
  }
  removeConversion(e) {
    this.conversions.remove(e), this.arcgisConversionChange.emit();
  }
  async _reverseConvert(e, o) {
    const t = this.viewModel, i = await o.reverseConvert(e);
    return this.goToEnabled && i && t.goToLocation(i).catch((r) => {
      x(this)(r), this.showAlertMessage(null, this.messages?.locationOffBasemap, "warning");
    }), i;
  }
  setDefaultPattern(e) {
    e.stopPropagation();
    const o = this.findSettingsFormat();
    o?.defaultPattern && (o.currentPattern = o.defaultPattern);
  }
  setInputFormat(e) {
    const o = e.target.selectedOption.value;
    o != null && (this.inputFormat = o);
  }
  setPreviewConversion() {
    const e = this.findSettingsFormat(), o = this.viewModel;
    if (e) {
      const t = this.conversions.find((i) => i.format === e);
      this.previewConversion = new w({
        format: e,
        position: {
          location: this.currentLocation,
          coordinate: t?.position?.coordinate
        }
      }), this.previewConversion.position?.coordinate || o.previewConversion(this.previewConversion, o.currentLocation ?? A);
    }
  }
  setSettingsFormat(e) {
    const o = e.target.selectedOption.value;
    o != null && (this.settingsFormat = o, this.setPreviewConversion());
  }
  showAlertMessage(e, o, t, i = D) {
    this.alertProperties = {
      ...this.alertProperties,
      title: e,
      message: o,
      kind: t,
      open: !0
    }, window.clearTimeout(this.alertTimer), this.alertTimer = window.setTimeout(() => {
      this.alertProperties = {
        ...this.alertProperties,
        open: !1
      };
    }, i);
  }
  toggleGoTo() {
    this.goToEnabled = !this.goToEnabled;
  }
  toggleMode() {
    this.mode = this.mode === "live" ? "capture" : "live";
  }
  updateCurrentPattern(e) {
    e.stopPropagation();
    const o = e.target, t = this.findSettingsFormat();
    t && (t.currentPattern = o.value);
  }
  render() {
    const { currentView: e, headingLevel: o, messages: t } = this;
    let i, r;
    return this.viewModel.state === "disabled" || e === "no-basemap" ? i = this.renderNoBasemapView() : e === "coordinate-input" ? (r = t.inputCoordTitle, i = this.renderCoordinateInputView()) : e === "settings" ? (r = t.settingsTitle, i = this.renderSettingsView()) : i = this.renderConversionsView(), s`<calcite-panel class="root" .heading=${r} .headingLevel=${o} scale=s>${i}${this.renderAlert()}</calcite-panel>`;
  }
  renderAlert() {
    const { messages: e } = this, { open: o, message: t, title: i, kind: r } = this.alertProperties;
    return s`<calcite-alert class="alert" .open=${o} scale=s .kind=${r} .label=${e.alertLabel} @calciteAlertClose=${this.clearAlertTimeout} slot=alerts>${i ? s`<div slot=title>${i}</div>` : null}${t ? s`<div slot=message>${t}</div>` : null}</calcite-alert>`;
  }
  renderConversionOptions(e, o, t) {
    const i = this.conversions.at(0), r = i?.format?.name;
    return e.map((n, l) => {
      const a = o ?? !i ? !1 : r === n.name || this.conversions.map((h) => h.format?.name).includes(n.name);
      return s`<calcite-option .disabled=${a} .label=${n.label.toUpperCase()} .selected=${l === t} .value=${n}>${n.label}</calcite-option>`;
    });
  }
  renderConversionView(e, o) {
    const { messages: t } = this, { format: i } = e, r = i?.label ?? "", n = o === 0, l = this.getId(`list-item-${o}`), a = t.conversionOutput.replace("{format name}", r), h = n || this.expanded, u = n ? this.renderFirstConversionTools(e) : this.renderTools(e, l), p = n && !e.displayCoordinate ? t.noLocation : e.displayCoordinate, y = s`<div aria-label=${p ?? c} class="coordinate-display" data-conversion=${e ?? c} tabindex=0 title=${p ?? "" ?? c}>${p}</div>`, _ = this.renderConversionOptions(this.formats.filter((k) => k !== i));
    return h ? s`<li aria-label=${a ?? c} class="conversion-row" id=${l ?? c} tabindex=0><calcite-select aria-controls=${l ?? c} class="row-select" data-index=${String(o) ?? c} .label=${t.selectFormat ?? ""} scale=s @calciteSelectChange=${this.addConversion}>${T(i, s`<calcite-option .label=${r.toUpperCase()} selected>${r.toUpperCase()}</calcite-option>`)}${_}</calcite-select>${y}${u}</li>` : null;
  }
  renderConversionsView() {
    const { messages: e } = this, o = this.viewModel.conversions.map(this.renderConversionView.bind(this)), t = this.getId("conversion-list"), i = this.expanded ? s`<div class="conversion-row"><calcite-select aria-controls=${t ?? c} data-index=-1 .label=${e.addConversion} scale=s @calciteSelectChange=${this.addConversion} title=${e.addConversion ?? c}><calcite-option disabled selected value=default>${e.addConversion}</calcite-option>${this.renderConversionOptions(this.formats)}</calcite-select>${this.renderPrimaryTools()}</div>` : null, r = {
      "expand-up": this.orientation === "expand-up",
      "expand-down": this.orientation === "expand-down"
    };
    return s`<div class=${f(g("conversions-view", r))}><ul aria-expanded=${this.expanded ?? c} class="conversion-list" id=${t ?? c}>${o}</ul>${i}</div>`;
  }
  renderCoordinateInputView() {
    const e = this.inputFormat ?? this.conversions.at(0)?.format, o = this.formats.findIndex((n) => n.name === e?.name), t = this.getId("coordinate-input"), i = this.renderConversionOptions(this.formats, !1, o), { messages: r } = this;
    return r ? [
      s`<calcite-action .icon=${d.arrowLeft} @click=${() => this.currentView = "conversions"} .text=${r.back} slot=header-actions-start></calcite-action>`,
      s`<div class="input-form" role=search><div class="input-form-group"><calcite-select aria-controls=${t ?? c} class="input-select" .label=${r.selectFormat} scale=s @calciteSelectChange=${this.setInputFormat}>${i}</calcite-select><calcite-input class="coordinate-input" data-format=${e ?? c} id=${t ?? c} @keydown=${this.processUserKeyboardInput} .placeholder=${r.inputCoordTitle} required scale=s .status=${this.invalidInput ? "invalid" : "idle"} ${z(this._coordinateInput)}></calcite-input></div><div class="input-form-group"><calcite-label layout=inline scale=s><calcite-checkbox .checked=${this.goToEnabled} @calciteCheckboxChange=${this.toggleGoTo}></calcite-checkbox>${r.goTo}</calcite-label><calcite-button appearance=outline kind=neutral @click=${this.processUserMouseInput} type=button width=auto>${r.convert}</calcite-button></div></div>`
    ] : null;
  }
  renderCopyButton(e) {
    const { messages: o } = this;
    return this.renderIconButton({
      iconType: d.copy,
      clickFunction: () => this.copyToClipboard(e.displayCoordinate),
      buttonClasses: ["copy-button"],
      ariaLabel: o.copy,
      title: o.copy
    });
  }
  renderFirstConversionTools(e) {
    const { messages: o, multipleConversionsDisabled: t, hideCaptureButton: i, hideExpandButton: r } = this;
    if (!o)
      return null;
    const n = this.mode === "live" ? o.captureMode : o.liveMode, l = this.expanded ? o.collapse : o.expand, a = e.displayCoordinate && this.mode === "capture" ? this.renderCopyButton(e) : null, h = !t && !r ? this.renderIconButton({
      iconType: this.expanded ? d.chevronDown : d.chevronUp,
      clickFunction: () => {
        this.expanded = !this.expanded;
      },
      ariaControls: this.getId("conversion-list"),
      label: l,
      title: l
    }) : null, u = t && !i ? this.renderIconButton({
      iconType: this.mode === "live" ? d.pinTear : d.pinTearF,
      clickFunction: this.toggleMode,
      label: n,
      title: n
    }) : null;
    return s`<ul class="tool-display"><li>${a}</li><li>${h}</li><li>${u}</li></ul>`;
  }
  renderIconButton(e) {
    const { iconType: o, clickFunction: t, buttonClasses: i, ariaLabel: r, ariaControls: n, label: l, flipRtl: a, title: h } = e;
    return s`<calcite-button appearance=transparent aria-label=${r ?? c} aria-controls=${n ?? c} class=${f(g(i))} .iconFlipRtl=${a ? "start" : void 0} .iconStart=${o} kind=neutral .label=${l} @click=${t} title=${h ?? c}></calcite-button>`;
  }
  renderNoBasemapView() {
    return s`<div class="no-basemap">${this.messages.noBasemap}</div>`;
  }
  renderPrimaryTools() {
    const { messages: e, hideInputButton: o, hideCaptureButton: t, hideSettingsButton: i } = this;
    if (!e)
      return null;
    const r = this.mode === "live" ? e.captureMode : e.liveMode, n = o ? null : this.renderIconButton({
      iconType: "pencil",
      clickFunction: () => {
        this.currentView = "coordinate-input";
      },
      label: e.inputCoordTitle,
      title: e.inputCoordTitle
    }), l = t ? null : this.renderIconButton({
      iconType: this.mode === "live" ? d.pinTear : d.pinTearF,
      clickFunction: this.toggleMode,
      label: r,
      title: r
    }), a = i ? null : this.renderIconButton({
      iconType: "gear",
      clickFunction: () => {
        this.currentView = "settings";
      },
      label: e.settingsTitle,
      title: e.settingsTitle
    });
    return s`<ul class="tool-display"><li>${n}</li><li>${l}</li><li>${a}</li></ul>`;
  }
  renderSettingsView() {
    const e = this.getId("pattern-input"), o = this.getId("preview-coordinate"), t = this.formats.filter((u) => b(u)), i = this.findSettingsFormat(), r = i ? t.indexOf(i) : -1, n = this.renderConversionOptions(t, !0, r), l = i?.currentPattern, { messages: a } = this;
    if (!a)
      return null;
    const h = this.renderIconButton({
      iconType: d.refresh,
      clickFunction: this.setDefaultPattern,
      label: a.defaultPattern,
      title: a.defaultPattern
    });
    return [
      s`<calcite-action .icon=${d.arrowLeft} @click=${() => this.currentView = "conversions"} .text=${a.back} slot=header-actions-start></calcite-action>`,
      s`<div class="settings"><div class=${f(g("settings-form-group", "settings-form-group-first"))}><calcite-label alignment=center .for=${e} scale=s>${a.changeCoordinateDisplay}<calcite-select .label=${a.selectFormat} width=full @calciteSelectChange=${this.setSettingsFormat}>${n}</calcite-select><div class="settings-form-group-horizontal"><calcite-input aria-controls=${o ?? c} class="pattern-input" id=${e ?? c} type=text .value=${l} @calciteInputInput=${this.updateCurrentPattern}></calcite-input>${h}</div></calcite-label></div><div class="settings-form-group"><calcite-label alignment=center scale=s>${a.preview}<div class="preview-coordinate" id=${o ?? c} tabindex=0>${this.previewConversion?.displayCoordinate}</div></calcite-label></div></div>`
    ];
  }
  renderTools(e, o) {
    const t = e.displayCoordinate && this.mode === "capture" ? this.renderCopyButton(e) : null, { messages: i } = this;
    if (!i)
      return null;
    const r = this.renderIconButton({
      iconType: "x",
      clickFunction: () => this.removeConversion(e),
      ariaControls: o,
      label: i.removeConversion,
      title: i.removeConversion
    });
    return s`<ul class="tool-display"><li>${t}</li><li>${r}</li></ul>`;
  }
}
function j(v) {
  const e = v.getAttribute("data-index");
  return e ? window.parseInt(e) : null;
}
C("arcgis-coordinate-conversion", U);
export {
  U as ArcgisCoordinateConversion
};
