/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as t}from"tslib";import i from"../../../../core/Accessor.js";import{generateUUID as l}from"../../../../core/uuid.js";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";let s=class extends i{constructor(t){super(t),this.actual=null,this.lockable=!0,this.id=l(),this.inputValue=null,this.readOnly=!1,this.suffix=null,this.visible=!0,this.invalid=!1,this.unlockOnVertexPlacement=!0,this.displayOrder=0}get committed(){return this.lockable?this._get("committed"):null}set committed(t){this.lockable&&this._set("committed",t)}get dirty(){return null!=this.inputValue}get disabled(){return null==this.actual&&!this.dirty&&!this.locked}get locked(){return this.lockable&&null!=this.committed}onInput(t){this.inputValue=t,this.invalid=!1}onCommit(t,i,l){this.lockable?this._onCommitLockable(t,l):this._onCommitNonLockable(l),this.invalid&&"commit-and-exit"===t||l.onCommit(i,t)}_onCommitLockable(t,i){const{inputValue:l,locked:o}=this;o&&n(l)?this.unlock():("commit-and-exit"===t&&!o||null!=l)&&this._parseInputAndLock(i)}_onCommitNonLockable(t){const{inputValue:i}=this;n(i)?this.lockable?this.setActual(null):this.clearInputValue():null!=i&&this._parseInputAndSetActual(t)}applyValue(t){this.lockable?this.lock(t):this.setActual(t)}clearInputValue(){this.inputValue=null,this.invalid=!1}setActual(t){this.actual=t,this.clearInputValue()}lock(t){this.lockable&&(this.committed=t??this.actual,this.clearInputValue())}unlock(){this.lockable&&(this.committed=null,this.clearInputValue())}toggleLock(t){this.lockable&&(this.locked?this.unlock():this._parseInputAndLock(t))}getSuffix(t){const{suffix:i}=this;return"function"==typeof i?i(t):i}getFormattedValue(t){const{actual:i,committed:l,format:o}=this;return null!=l?o(l,t):null!=i?o(i,t):null}getRawDisplayValue(t){const{actual:i,committed:l,inputValue:o}=this;return null!=o?o:this.lockable&&null!=l?this.formatForInputMode(l,t):null!=i?this.formatForInputMode(i,t):null}_parseInputAndSetActual(t){const{inputValue:i}=this;if(null==i||n(i))return this.setActual(null);const l=this.parse(i,t);null!=l?this.setActual(l):this.invalid=!0}_parseInputAndLock(t){const{inputValue:i,actual:l}=this;if(n(i))return this.unlock();if(null==i)return this.lock(l);const o=this.parse(i,t);null!=o?this.lock(o):this.invalid=!0}};function n(t){return null!=t&&""===t.trim()}t([o()],s.prototype,"actual",void 0),t([o()],s.prototype,"committed",null),t([o()],s.prototype,"dirty",null),t([o()],s.prototype,"disabled",null),t([o()],s.prototype,"format",void 0),t([o()],s.prototype,"formatForInputMode",void 0),t([o()],s.prototype,"lockable",void 0),t([o()],s.prototype,"locked",null),t([o()],s.prototype,"id",void 0),t([o()],s.prototype,"inputValue",void 0),t([o()],s.prototype,"name",void 0),t([o()],s.prototype,"parse",void 0),t([o()],s.prototype,"readOnly",void 0),t([o()],s.prototype,"suffix",void 0),t([o()],s.prototype,"title",void 0),t([o()],s.prototype,"visible",void 0),t([o()],s.prototype,"invalid",void 0),t([o()],s.prototype,"unlockOnVertexPlacement",void 0),t([o()],s.prototype,"displayOrder",void 0),s=t([e("esri.views.interactive.tooltip.fields.TooltipField")],s);export{s as TooltipField};
