var __spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var n=0,r=t.length,a;n<r;n++){if(a||!(n in t)){if(!a)a=Array.prototype.slice.call(t,0,n);a[n]=t[n]}}return e.concat(a||Array.prototype.slice.call(t))};System.register(["./p-5e377a26.system.js","./p-fed348c1.system.js","./p-d29cc7ae.system.js","./p-1ce19ee6.system.js","./p-ab31f231.system.js","./p-6f3c3cb9.system.js","./p-db5487c5.system.js","./p-0bbf3c73.system.js","./p-58f2f536.system.js","./p-da593370.system.js","./p-70552f4e.system.js","./p-cb044807.system.js","./p-8e4283bf.system.js","./p-91343653.system.js","./p-fe1f76a3.system.js"],(function(e){"use strict";var t,i,n,r,a,l,o,s,d,c;return{setters:[function(e){t=e.r;i=e.c;n=e.h;r=e.H},function(e){a=e.D},function(e){l=e.D},function(e){o=e.r},function(e){s=e.D;d=e.d},function(e){c=e.g},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){}],execute:function(){var u="dvn-field-input-cell-reference{display:-ms-flexbox;display:flex;overflow:auto;padding:0 4px}";var f=e("dvn_field_input_cell_reference",function(){function e(e){t(this,e);this.cellFormCancel=i(this,"cellFormCancel",7);this.cellFormSubmit=i(this,"cellFormSubmit",7)}e.prototype.onAction=function(e){if(e.detail.name==="dvn-field-input-cell-reference.remove-item"){e.stopImmediatePropagation();var t=e.detail.params.item;this.internalValue=this.internalValue.filter((function(e){return e._id!==t._id}))}};e.prototype.componentWillLoad=function(){this.internalValue=this.value||[];this.dataProvider=m(this.field)};e.prototype.render=function(){var e;var t=this;var i=this,l=i.field,s=i.internalValue,d=i.meta;var c=this.value||[];return n(r,null,Array.isArray(c)?c.map((function(e){return o(l,e,d)})):o(l,c,d),n("dvn-dialog",{clip:false,shown:true,onDismiss:function(){return t.cellFormCancel.emit()}},n("dvn-list-view-table",{config:{hideHeader:true,separation:1,actions:[{ui:{name:"dvn-field-input-cell-reference.remove-item",buttonType:"icon-button",iconName:"uil uil-trash-alt",tint:"danger",view:"flat"}}],fields:[{fieldId:l.imageField},{fieldId:l.titleField}],columns:(e={},e[l.imageField]={width:50},e)},fields:l.fields,items:s,isEndReached:true}),n("br",null),n("dvn-select",{dataAdapter:new a(l.titleField,"_id"),dataProvider:this.dataProvider,onChange:function(e){var i,n;e.stopImmediatePropagation();var r=(n=(i=t.dataProvider.list)===null||i===void 0?void 0:i.data)===null||n===void 0?void 0:n.find((function(t){return t._id===e.detail}));t.internalValue=__spreadArray(__spreadArray([],t.internalValue,true),[r],false)},leaned:true,width:"100%",value:[]}),n("div",{slot:"actions"},n("dvn-button",{view:"flat",onClick:function(e){e.stopImmediatePropagation();t.cellFormCancel.emit()}},"Cancel"),n("dvn-button",{tint:"primary",view:"flat",onClick:function(e){e.stopImmediatePropagation();t.cellFormSubmit.emit({value:t.internalValue,apiValue:t.internalValue.map((function(e){return p(l,e)}))})}},"Save"))))};return e}());function m(e){var t=new l(d,{Authorization:"Bearer ".concat(c().token)});return new s(t,e.otherCollection,{fields:e.fields,sort:[{id:e.titleField,order:1}]},undefined,{fields:[{fieldId:e.imageField},{fieldId:e.titleField}]})}function p(e,t){var i=t._id;return{_ref:e.otherCollection,_id:i}}f.style=u}}}));