/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import l from"../../../../core/Accessor.js";import{generateUUID as i}from"../../../../core/uuid.js";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";let s=class extends l{constructor(t){super(t),this.actual=null,this.lockable=!0,this.id=i(),this.inputValue=null,this.name=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 lockDisabled(){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,l,i){this.lockable?this._onCommitLockable(t,i):this._onCommitNonLockable(i),this.invalid&&"commit-and-exit"===t||i.onCommit(l,t)}_onCommitLockable(t,l){const{inputValue:i,locked:o}=this;o&&n(i)?this.unlock():("commit-and-exit"===t&&!o||null!=i)&&this._parseInputAndLock(l)}_onCommitNonLockable(t){const{inputValue:l}=this;n(l)?this.lockable?this.setActual(null):this.clearInputValue():null!=l&&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:l}=this;return"function"==typeof l?l(t):l}getFormattedValue(t){const{actual:l,committed:i,format:o}=this;return null!=i?o(i,t):null!=l?o(l,t):null}getRawDisplayValue(t){const{actual:l,committed:i,inputValue:o}=this;return null!=o?o:this.lockable&&null!=i?this.formatForInputMode(i,t):null!=l?this.formatForInputMode(l,t):null}_parseInputAndSetActual(t){const{inputValue:l}=this;if(null==l||n(l))return this.setActual(null);const i=this.parse(l,t);null!=i?this.setActual(i):this.invalid=!0}_parseInputAndLock(t){const{inputValue:l,actual:i}=this;if(n(l))return this.unlock();if(null==l)return this.lock(i);const o=this.parse(l,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,"lockDisabled",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};
