"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6830],{8032:(e,t,a)=>{a.d(t,{A:()=>v});var l=a(4848),i=a(6540),d=a(2675),s=a(9020),n=a(65),r=a(1342),o=a(1710),c=a(1580),u=a(2543),p=a.n(u),m=a(8845),f=a(3238),h=a(5143);function b(e){let{user:t,table:a,entry:d,url:s,query:n}=e,[r,o]=i.useState(!1),c=i.useRef(null);return(0,l.jsx)("div",{className:"relative z-[1000]",children:(0,l.jsx)(h.Popover,{isOpen:r,onClickOutside:()=>o(!1),containerClassName:"z-[1000]",positions:["bottom"],align:"end",content:(0,l.jsx)("div",{className:"bg-white dark:bg-slate-900 rounded shadow-md cancel-link",children:(0,l.jsxs)("div",{className:"flex-col min-w-[200px] items-stretch gap-0",children:[(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(d)).then(()=>{window.alert("Post Copied"),o(!1)})},children:"Copy Object"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let e=(0,m.A)({paradigm:"JavaScript",table:a,query:n,user:t});navigator.clipboard.writeText(e||"").then(()=>{window.alert("JavaScript Type Definition Copied"),o(!1)})},children:"Copy JS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let e=(0,m.A)({paradigm:"TypeScript",table:a,query:n,user:t});navigator.clipboard.writeText(e||"").then(()=>{window.alert("TypeScript Type Definition Copied"),o(!1)})},children:"Copy TS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("a",{href:s,className:"button plain-text justify-start py-3",children:(0,l.jsx)("span",{children:"View Entry"})})]})}),children:(0,l.jsx)("button",{onClick:()=>{o(!r)},ref:c,className:"ghost p-2",children:(0,l.jsx)(f.A,{})})})})}function v(e){var t,a,u,m,f;let{user:h,database:v,table:x,dbSchemaData:N,richTextEditors:y,jsonTextEditors:g,dataTypes:w,entry:j,entryPage:T,confirmedDelegetedUser:_,query:E}=e,C=x.fields.filter(e=>e.fieldName&&!e.fieldName.match(d.A)),S=x.fields.find(e=>"uuid"===e.fieldName),k=null==_?void 0:_.delegated;null==_||null===(t=_.priviledges)||void 0===t||t.match(/Edit Tables/i),null==_||null===(a=_.priviledges)||void 0===a||a.match(/Delete Tables/i),null==_||null===(u=_.priviledges)||void 0===u||u.match(/Create Tables/i),null==_||null===(m=_.priviledges)||void 0===m||m.match(/Edit Entries/i);let A=null==_?void 0:null===(f=_.priviledges)||void 0===f?void 0:f.match(/Delete Entries/i);S&&C.unshift({dataType:"UUID",fieldName:"uuid",defaultField:!0}),C.unshift({dataType:"BIGINT",fieldName:"id",defaultField:!0}),C.push({dataType:"VARCHAR(250)",fieldName:"date_created",defaultField:!0}),C.push({dataType:"BIGINT",fieldName:"date_created_code",defaultField:!0}),C.push({dataType:"TIMESTAMP",fieldName:"date_created_timestamp",defaultField:!0}),C.push({dataType:"VARCHAR(250)",fieldName:"date_updated",defaultField:!0}),C.push({dataType:"BIGINT",fieldName:"date_updated_code",defaultField:!0}),C.push({dataType:"TIMESTAMP",fieldName:"date_updated_timestamp",defaultField:!0});let[I,F]=i.useState(!1),[D,R]=i.useState(!0),[L,O]=i.useState(j),[M,P]=i.useState(!1);i.useRef(null);let U=i.useRef([]),[B,J]=i.useState("/admin/".concat(null==h?void 0:h.id,"/databases/").concat(v.db_slug,"/tables/").concat(x.tableName,"/entries/").concat(L.id));i.useEffect(()=>{(null==_?void 0:_.dbUserId)&&Number(h.id)!==Number(_.dbUserId)&&J("/admin/".concat(null==h?void 0:h.id,"/databases/").concat(v.db_slug,"/tables/").concat(x.tableName,"/entries/").concat(L.id)+window.location.search)},[]);let z="".concat(v.db_slug,"-").concat(x.tableName,"-").concat(L.id,"-submit-button");return(0,l.jsxs)("div",{className:"card col w-full overflow-hidden",children:[(0,l.jsx)("a",{href:B,onClick:e=>{let t=e.target;(t.closest(".cancel-link")||t.closest(".MuiPopover-root"))&&e.preventDefault()},className:"w-full",children:(0,l.jsxs)("div",{className:"w-full bg-slate-700 text-white py-2 px-4 rounded justify-between flex-wrap hover:bg-slate-800 cursor-pointer relative z-[1000] ",onClick:e=>{let t=e.target;t.closest(".cancel-link")||t.closest(".MuiPopover-root")||(e.ctrlKey?window.open(B,"__blank"):window.location.href=B)},children:[(0,l.jsxs)("span",{children:["Entry #",L.id]}),(0,l.jsxs)("div",{className:"flex-wrap cancel-link",children:[(!k||k&&A)&&(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer"+(I?" pointer-events-none opacity-40":""),onClick:e=>{window.confirm("Delete Entry #".concat(L.id,"?"))&&(F(!0),(0,s.A)("/api/deleteTableEntry"+window.location.search,{method:"post",body:{dbFullName:v.db_full_name,tableName:x.tableName,entryId:L.id,dbSlug:v.db_slug,dbId:v.id,delegated:null==E?void 0:E.delegated,confirmedDelegetedUser:_}},!0).then(e=>{e.success?(0,n.A)().then(()=>{window.location.reload()}):(window.alert(e.msg),setTimeout(()=>{F(!1)},500))}))},children:"Delete Entry"}),!T&&(0,l.jsxs)(i.Fragment,{children:[(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer",onClick:e=>{D?R(!1):R(!0)},children:D?(0,l.jsx)("span",{children:"Expand"}):(0,l.jsx)("span",{children:"Collapse"})})]}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("div",{className:"button ghost px-0",onClick:e=>{let t=p().cloneDeep(j);delete t.date_created,delete t.date_created_code,delete t.date_created_timestamp,delete t.date_updated,delete t.date_updated_code,delete t.date_updated_timestamp,delete t.id,delete t.uuid,localStorage.setItem("duplicate_entry",JSON.stringify(t)),window.location.href="/admin/".concat(null==h?void 0:h.id,"/databases/").concat(v.db_slug,"/tables/").concat(x.tableName,"/entries/add-entry?duplicate=true&id=").concat(j.id)},children:(0,l.jsx)("span",{className:"text-slate-300",children:"Duplicate"})}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)(b,{table:x,user:h,entry:j,query:E,url:B})]})]})}),(0,l.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative",style:T?{}:{maxHeight:D?"300px":"none",paddingTop:"10px",paddingBottom:"10px",overflow:"hidden"},onSubmit:e=>{e.preventDefault(),F(!0);let t={},a=e.target;C.forEach(e=>{var l;if(!e.fieldName||!a[e.fieldName])return;let i="string"!=typeof a[e.fieldName].value,d="number"!=typeof a[e.fieldName].value;(i||d||a[e.fieldName].value)&&(null!==(l=a[e.fieldName])&&void 0!==l&&l.dataset.default||(t[e.fieldName]=a[e.fieldName].value))}),U.current[0]&&U.current.forEach(e=>{var a;(null==e?void 0:e.fieldName)&&(null==e?void 0:null===(a=e.ref)||void 0===a?void 0:a.current)&&(t[e.fieldName]=e.ref.current.getContent())}),g.current[0]&&g.current.forEach(e=>{var a;(null==e?void 0:e.fieldName)&&(null==e?void 0:null===(a=e.ref)||void 0===a?void 0:a.current)&&(t[e.fieldName]=e.ref.current.getValue())}),(0,s.A)("/api/updateTableEntry",{method:"post",body:{dbFullName:v.db_full_name,dbSlug:v.db_slug,dbId:v.id,tableName:x.tableName,entryId:L.id,payload:t,tableSchema:x,delegated:null==E?void 0:E.delegated,confirmedDelegetedUser:_}},!0).then(e=>{e.success?(0,s.A)("/api/refreshEntry",{method:"POST",body:{table:x.tableName,db:v.db_full_name,id:L.id,schema:JSON.stringify(x)}}).then(e=>{e.success&&(O(e.entry),setTimeout(()=>{F(!1)},500))}):(window.alert(e.msg+"\n"+(e.err||"")),setTimeout(()=>{F(!1)},500))})},onKeyUp:e=>{if(e.ctrlKey&&"Enter"==e.key){var t;window.confirm("Update this Form?")&&(null===(t=document.getElementById(z))||void 0===t||t.click())}},children:[I&&(0,l.jsx)(o.A,{}),(D&&!T?C.slice(0,3):C).map((e,t)=>{let a=w.filter(t=>{var a;return t.name===(null===(a=e.dataType)||void 0===a?void 0:a.replace(/\d|\(|\)/g,""))});return(0,l.jsx)(c.A,{fieldObject:e,dataTypeSchema:a[0],richTextEditors:y,currentRichTextEditorForms:U,entry:L,query:E,entryPage:T,confirmedDelegetedUser:_,jsonTextEditors:g,formButtonId:z},t+1)}),(0,l.jsx)("button",{type:"submit",className:I?" pointer-events-none opacity-40":"",id:z,children:"Update Entry"})]}),!T&&(0,l.jsx)(r.A,{collapse:D,setCollapse:R})]})}},6959:(e,t,a)=>{a.d(t,{A:()=>d});var l=a(4848),i=a(2027);function d(e){let{selectOptions:t,name:a,onChangeHandler:d,required:s,setAlert:n,title:r,defaultValue:o,info:c,id:u}=e;try{function p(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),a=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!a.classList.contains("hidden")){a.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&a.classList.contains("hidden"))){if(!t){a.classList.add("hidden");return}if(a.classList.contains("hidden")){a.classList.remove("hidden");return}a.classList.add("hidden")}}return(0,l.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[r&&(0,l.jsxs)("label",{htmlFor:a,children:[r,s?"":" (optional)"]}),(0,l.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,l.jsx)("select",{name:a,id:u||a,className:"w-full bg-white",required:s,onChange:e=>{n&&n(null),e.target.classList.remove("warning"),d&&d(e)},defaultValue:o||void 0,children:t.map((e,t)=>{let{payload:a,title:i}=e;return(0,l.jsx)("option",{value:a,selected:!!e.default,children:i},t+1)})}),(0,l.jsx)(i.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(0,l.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:p,onMouseLeave:p,onClick:p,children:[(0,l.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,l.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,l.jsx)("span",{children:c})}),(0,l.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,l.jsx)("div",{children:"Form Select Error"})}}a(6540)}}]);