var __awaiter=this&&this.__awaiter||function(e,t,n,i){function o(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,l){function r(e){try{c(i.next(e))}catch(e){l(e)}}function a(e){try{c(i["throw"](e))}catch(e){l(e)}}function c(e){e.done?n(e.value):o(e.value).then(r,a)}c((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},i,o,l,r;return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(e){return function(t){return c([e,t])}}function c(r){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,o&&(l=r[0]&2?o["return"]:r[0]?o["throw"]||((l=o["return"])&&l.call(o),0):o.next)&&!(l=l.call(o,r[1])).done)return l;if(o=0,l)r=[r[0]&2,l.value];switch(r[0]){case 0:case 1:l=r;break;case 4:n.label++;return{value:r[1],done:false};case 5:n.label++;o=r[1];r=[0];continue;case 7:r=n.ops.pop();n.trys.pop();continue;default:if(!(l=n.trys,l=l.length>0&&l[l.length-1])&&(r[0]===6||r[0]===2)){n=0;continue}if(r[0]===3&&(!l||r[1]>l[0]&&r[1]<l[3])){n.label=r[1];break}if(r[0]===6&&n.label<l[1]){n.label=l[1];l=r;break}if(l&&n.label<l[2]){n.label=l[2];n.ops.push(r);break}if(l[2])n.ops.pop();n.trys.pop();continue}r=t.call(e,n)}catch(e){r=[6,e];o=0}finally{i=l=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-b7735e0d.js";var dvnFieldInputCellRichContentCss="dvn-field-input-cell-rich-content{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;height:100%}dvn-field-input-cell-rich-content .form-footer{padding:calc(2 * var(--spacing-unit));background-color:var(--color-background-secondary)}";var DvnFieldInputCellRichContent=function(){function e(e){registerInstance(this,e);this.cellFormCancel=createEvent(this,"cellFormCancel",7);this.cellFormSubmit=createEvent(this,"cellFormSubmit",7);this.isConfirmationDialogShown=false}e.prototype.focus=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){(t=(e=this.el.querySelector("dvn-input"))===null||e===void 0?void 0:e.focus)===null||t===void 0?void 0:t.call(e);return[2]}))}))};e.prototype.render=function(){var e=this;var t=this,n=t.field,i=t.value;var o=i||{version:"0.0.1",content:[{type:"text",id:"form-content",value:{placeholder:n.placeholder,text:""}}]};return h(Host,null,h("dvn-side-modal",{shown:true,onDismiss:function(){var t,n;if(JSON.stringify((t=e.value)===null||t===void 0?void 0:t.content)!==JSON.stringify((n=e.internalValue)===null||n===void 0?void 0:n.content)){e.isConfirmationDialogShown=true}else{e.cellFormCancel.emit()}}},h("div",{class:"flex-grow-1 d-flex flex-column mt-3"},h("div",{class:"flex-grow-1"},h("dvn-rich-editor",{key:"editor",onChange:function(t){t.stopImmediatePropagation();var n=t.detail;e.internalValue={version:"0.0.1",content:n}},editorSettings:n.settings||defaultSettings,value:o.content})),h("div",{class:"form-footer"},h("dvn-button",{leaned:true,onClick:function(t){t.stopImmediatePropagation();e.cellFormSubmit.emit({value:e.internalValue});e.cellFormCancel.emit()}},"Save")))),h("dvn-dialog",{shown:this.isConfirmationDialogShown,title:"You have unsaved changes"},"You're going to loose the changes if you don't save.",h("div",{slot:"actions"},h("dvn-button",{tint:"danger",view:"flat",onClick:function(t){t.stopImmediatePropagation();e.cellFormCancel.emit()}},"Discard Changes"),h("dvn-button",{view:"flat",onClick:function(){return e.isConfirmationDialogShown=false}},"Cancel"))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();var defaultSettings={enableDrag:false,enableBlockCreation:false,enableBlockDeletion:false,hideDragControls:true,blockTypes:[],blockSettings:{text:{textSelectionOptions:["bold","link"]}}};DvnFieldInputCellRichContent.style=dvnFieldInputCellRichContentCss;export{DvnFieldInputCellRichContent as dvn_field_input_cell_rich_content};