"use strict";exports.id=8842,exports.ids=[8842],exports.modules={30469:(e,t,a)=>{a.d(t,{A:()=>o});var s=a(8732),l=a(82015),i=a.n(l),r=a(32415),n=a(83147),d=a(63715);function c({paradigm:e,payload:t,setLoading:a,table:s,database:l}){a(!0),(0,d.A)("/api/exportTableData",{method:"POST",body:{paradigm:e,dbName:l.db_slug,tableName:s.tableName,payload:t}},!0).then(t=>{if(t.success){if("export"==e){let e=new Blob([JSON.stringify(t.data||[],null,4)],{type:"application/json"}),a=URL.createObjectURL(e),i=document.createElement("a");i.href=a,i.style.display="none",i.download=`${l.db_slug}-${s.tableName}-${Date.now()}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}else"import"==e&&(window.alert("Data Imported Successfully"),window.location.reload())}else t.msg&&window.alert(t.msg)}).catch(e=>{console.log(e)}).finally(()=>{a(!1)})}function o({database:e,table:t}){let[a,l]=i().useState(!1),[d,o]=i().useState(!0),u=i().useRef(null);return i().useRef(null),(0,s.jsxs)("div",{className:"relative",children:[a&&(0,s.jsx)(r.A,{width:"15px"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{c({paradigm:"export",database:e,setLoading:l,table:t})},children:"Export"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{u.current?.addEventListener("change",a=>{l(!0);let s=a.target;if(!s.files?.[0]){window.alert("No FIles selected"),l(!1);return}n.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)?c({paradigm:"import",payload:a.fileBase64,database:e,setLoading:l,table:t}):l(!1),o(!1),setTimeout(()=>{o(!0)},200)})}),u.current?.click()},children:"Import"}),d&&(0,s.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:u})]})}},29766:(e,t,a)=>{a.d(t,{A:()=>x});var s=a(8732),l=a(82015),i=a.n(l),r=a(41836),n=a(95939),d=a(43656),c=a(51548),o=a(32415),u=a(2817),m=a(63715);function p({database:e,table:t,setOpenPopover:a,dbSchemaData:l,query:r}){let[n,d]=i().useState(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{className:"ghost p-3 justify-start",onClick:()=>{d(!0),setTimeout(()=>{a&&a(!1)},200)},children:"Sync Data"}),(0,s.jsx)(u.A,{open:n,setOpen:d,children:(0,s.jsx)(h,{database:e,table:t,dbSchemaData:l,query:r})})]})}function h({database:e,table:t,query:a,dbSchemaData:l}){let[r,n]=i().useState(l),[u,p]=i().useState("Push"),[h,x]=i().useState(r?.[0]),[f,b]=i().useState(h?.tables),[g,j]=i().useState(f?.[0]),[N,y]=i().useState(!1),[w,v]=i().useState(!1);return(0,s.jsxs)("div",{className:"stack gap-2 relative w-full",children:[N||!r&&(0,s.jsx)(o.A,{width:"20px"}),(0,s.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),w?(0,s.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,s.jsx)("b",{children:t.tableFullName})," ","schema"]}):(0,s.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,s.jsx)("b",{children:t.tableFullName})]}),r&&(0,s.jsxs)("form",{onSubmit:s=>{!function({e,setLoading:t,database:a,table:s,query:l}){e.preventDefault(),t(!0);let i=e.target,r=i.paradigm?.value,n=i.database?.value,d=i.table?.value,c={paradigm:r,src:{db:a.db_slug,table:s.tableName},dst:{db:n,table:d},delegated:l.delegated};if(!window.confirm("Pull"==r?"NOTE: This operation will override the current database entries. Continue?":"NOTE: This operation will override the selected database entries. Continue?")){setTimeout(()=>{t(!1)},1e3);return}(0,m.A)("/api/sync-table-data",{method:"POST",body:{...c}},!0).then(e=>{e.success?(window.alert("Data Sync Successful"),window.location.reload()):e.msg&&window.alert("ERROR: "+e.msg)}).finally(()=>{setTimeout(()=>{t(!1)},1e3)})}({e:s,database:e,setLoading:y,table:t,query:a})},className:"w-full stack gap-2 items-stretch",children:[(0,s.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,s.jsx)(d.A,{radioValues:[{title:"Push",payload:"Push",default:!0},{title:"Pull",payload:"Pull"}],name:"paradigm",smallText:!0,flexRow:!0,onChangeHandler:e=>{p(e.target.value)}}),(0,s.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Push"==u?(0,s.jsxs)(s.Fragment,{children:["Sync data from the current table(",(0,s.jsx)("b",{children:t.tableFullName}),") to the selected table below"]}):(0,s.jsxs)(s.Fragment,{children:["Sync data from the selected table below to the current table(",(0,s.jsx)("b",{children:t.tableFullName}),")"]})})]}),(0,s.jsx)(c.A,{selectOptions:r.filter(t=>t.dbFullName!==e.db_full_name).map(e=>({title:e.dbName,payload:e.dbSlug})),name:"database",onChangeHandler:e=>{let t=r.find(t=>t.dbSlug==e.target.value);t&&(x(t),b(t.tables),j(t.tables?.[0]))}}),(0,s.jsx)(c.A,{selectOptions:f.map(e=>({title:e.tableFullName,payload:e.tableName})),name:"table",onChangeHandler:e=>{let t=f.find(t=>t.tableName===e.target.value);t&&j(t)}}),(0,s.jsx)("button",{className:w?"":"disabled",children:"Sync"})]})]})}function x({database:e,table:t,dbSchemaData:a,query:l}){let[d,c]=i().useState(!1);return(0,s.jsx)(r.Popover,{isOpen:d,onClickOutside:()=>c(!1),positions:["bottom"],align:"end",content:(0,s.jsxs)("div",{className:"stack items-stretch bg-white rounded shadow-md gap-0 min-w-[200px]",children:[(0,s.jsx)(p,{database:e,table:t,setOpenPopover:c,dbSchemaData:a,query:l}),(0,s.jsx)("hr",{className:"m-0"})]}),containerClassName:"z-[1000]",children:(0,s.jsx)("button",{onClick:()=>{c(!d)},className:"outlined gray px-2 py-1.5",children:(0,s.jsx)(n.A,{})})})}a(27825)},87663:(e,t,a)=>{a.a(e,async(e,s)=>{try{let h;a.d(t,{A:()=>p});var l=a(8732),i=a(82015),r=a.n(i),n=a(98842),d=a(51548),c=a(13737),o=a(63715),u=a(32415),m=e([n]);function p({data:e}){let{table:t,entries:s,activeEntries:i,setActiveEntries:m,confirmedDelegetedUser:p,database:x,targetField:f,searchTerm:b}=r().useContext(n.TableEntriesContext);a(94327),p?.delegated,p?.priviledges?.match(/Edit Tables/i),p?.priviledges?.match(/Delete Tables/i),p?.priviledges?.match(/Create Tables/i);let[g,j]=r().useState(!1),N=r().useRef(),[y,w]=r().useState(null);function v(e){if(j(!0),i&&m(null),!e?.toString().match(/./)){setTimeout(()=>{m&&m(s||[]),j(!1)},500);return}window.clearTimeout(h);let a=t?.fields.filter(e=>e.fieldName===f?.current),l=a&&a[0]&&a[0].dataType?.match(/int/i)||f?.current?.match(/^id$/)?"equal":"like";h=setTimeout(()=>{j(!1),(0,o.A)(`/api/queryEntriesSearchTerm?db=${x?.db_full_name}&table=${t?.tableName}&field=${f?.current}&term=${e}&operator=${l}`).then(e=>{"number"==typeof e.count&&w(e.count),e.success&&m&&m(e.result),j(!1)})},500)}return(0,l.jsxs)("div",{className:"w-full flex-col items-stretch",children:[(0,l.jsxs)("form",{onSubmit:e=>{e.preventDefault(),b?.current&&v(b.current)},className:"flex flex-row items-stretch gap-4 w-full",children:[(0,l.jsx)("div",{className:"max-w-xs",children:(0,l.jsx)(d.A,{required:!0,selectOptions:t?t.fields.map(e=>({title:e.fieldName||"",payload:e.fieldName||""})):[],name:"database_tables",onChangeHandler:e=>{f&&(f.current=e.target.value)},title:"Select Field",defaultValue:f?.current,id:"entries-search-field-select"})}),(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(c.A,{title:"Search Term",placeholder:"Enter search term that corresponds with the selected field type ...",onInputHandler:e=>{let t=e.target;t.value?.match(/./)&&b?b.current=t.value:b&&(b.current=null),v(t.value)},elementRef:N,id:"entries-search-input"})}),g&&(0,l.jsx)("div",{className:"relative items-center justify-center",children:(0,l.jsx)("div",{className:"relative mt-5 w-6",children:(0,l.jsx)(u.A,{width:"20px"})})})]}),b?.current?.match(/./)&&(0,l.jsx)("div",{className:"py-4",children:(0,l.jsxs)("span",{className:"text-lg",children:["number"==typeof y?y>0?(0,l.jsxs)("b",{children:[y," "]}):(0,l.jsx)(l.Fragment,{children:"No "}):"... ","Search result",y&&1!==y?"s":""," for"," ",(0,l.jsxs)("b",{children:['"',b.current,'"']})]})})]})}n=(m.then?(await m)():m)[0],s()}catch(e){s(e)}})},74511:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.d(t,{A:()=>j});var l=a(8732),i=a(82015),r=a.n(i),n=a(98842),d=a(46437),c=a(58548),o=a(94010),u=a(34486),m=a(86571),p=a(65241),h=a(59621),x=a(32415);a(63715),a(27825);var f=a(30469),b=a(29766),g=e([n,o,u,h]);function j(e){let{user:t,database:s,table:i,dbSchemaData:x,setTargetEntry:g,richTextEditors:j,jsonTextEditors:y,query:w,confirmedDelegetedUser:v,activeEntries:T,entriesCount:S,setActiveEntries:E}=r().useContext(n.TableEntriesContext),A=a(94327);return v?.delegated,v?.priviledges?.match(/Edit Tables/i),v?.priviledges?.match(/Delete Tables/i),v?.priviledges?.match(/Create Tables/i),(0,l.jsxs)(r().Fragment,{children:[(0,l.jsxs)("div",{className:"flex-col items-start gap-0 w-full relative z-50",children:[(0,l.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,l.jsxs)("div",{className:"flex-wrap",children:[(0,l.jsx)(d.A,{}),(0,l.jsx)("h1",{className:"text-3xl m-0",children:(0,l.jsxs)("span",{className:"flex items-center flex-wrap gap-2",children:["All Entries In"," ",(0,l.jsxs)("span",{className:"bg-slate-100 dark:bg-slate-800 px-2 py-1 border border-solid border-slate-400 dark:border-slate-600 rounded relative",children:[i.tableFullName,(0,l.jsx)("div",{className:"absolute -top-5 -right-4",children:(0,l.jsx)(o.A,{slugText:i.tableName,justIcon:!0})})]})," ","Table"]})})]}),(0,l.jsxs)("div",{className:"w-full sm:w-auto",children:[(0,l.jsxs)("a",{href:`/admin/${t?.id}/databases/${s.db_slug}/tables/${i.tableName}/entries/add-entry`,className:"button flex items-center gap-2 w-full sm:w-auto justify-center",children:[(0,l.jsx)("span",{className:"symbol",children:"+"}),(0,l.jsx)("span",{children:"Add New Entry"})]}),(0,l.jsx)(f.A,{database:s,table:i}),(0,l.jsx)(b.A,{database:s,table:i,dbSchemaData:x,query:w})]})]}),(0,l.jsx)(c.A,{confirmedDelegetedUser:w?.delegated,user:t})]}),s.active_clone?(0,l.jsx)(m.A,{database:s,user:t}):(0,l.jsx)(l.Fragment,{}),s.remote_connected?(0,l.jsx)(h.p,{database:s}):(0,l.jsx)(l.Fragment,{}),(0,l.jsx)(p.A,{table:i,database:s,user:t}),(0,l.jsx)(u.A,{user:t,entries:T,database:s,table:i,setTargetEntry:g,dbSchemaData:x,richTextEditors:j,dataTypes:A,query:w,confirmedDelegetedUser:v,jsonTextEditors:y,search:!0}),S>20&&(0,l.jsx)(N,{activeEntries:T,setActiveEntries:E,database:s,table:i,entriesCount:S})]})}function N({activeEntries:e,setActiveEntries:t,database:a,table:s,entriesCount:i}){r().useContext(n.TableEntriesContext);let d=r().useRef(),c=r().useRef(1);return 20*Number(c.current)>=i?(0,l.jsx)(r().Fragment,{}):(0,l.jsx)("div",{className:"w-full flex items-center justify-center",ref:d,children:(0,l.jsx)(x.A,{position:"relative",style:{backgroundColor:"transparent"},width:"20px"})})}[n,o,u,h]=g.then?(await g)():g,s()}catch(e){s(e)}})},34486:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.d(t,{A:()=>h});var l=a(8732),i=a(82015),r=a.n(i),n=a(89579),d=a(87663),c=a(32415),o=a(30469),u=a(29766),m=a(2833),p=e([d]);function h({user:e,entries:t,database:a,table:s,setTargetEntry:i,dbSchemaData:p,richTextEditors:h,jsonTextEditors:x,dataTypes:f,title:b,confirmedDelegetedUser:g,query:j,search:N,entriesCount:y}){g?.delegated,g?.priviledges?.match(/Edit Tables/i),g?.priviledges?.match(/Delete Tables/i),g?.priviledges?.match(/Create Tables/i),g?.priviledges?.match(/Edit Entries/i),g?.priviledges?.match(/Delete Entries/i);let{active_clone:w,active_clone_parent_db:v,remote_connected:T}=a;return(0,l.jsx)(r().Fragment,{children:(0,l.jsxs)("section",{className:"paper gray gray-bg",children:[b&&(0,l.jsxs)("div",{className:"justify-between w-full flex-wrap px-4 sm:px-0 pt-4 sm:pt-0",children:[(0,l.jsx)("h2",{className:"text-xl m-0",children:b}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("a",{className:"button flex gap-2 items-center",href:`/admin/${e?.id}/databases/${a.db_slug}/tables/${s.tableName}/entries/add-entry`,children:[(0,l.jsx)("span",{className:"symbol",children:"+"}),(0,l.jsx)("span",{children:"Add New Entry"})]}),(0,l.jsx)(o.A,{database:a,table:s}),(0,l.jsx)(u.A,{database:a,table:s,dbSchemaData:p,query:j})]})]}),N&&(0,l.jsx)(d.A,{}),(0,l.jsxs)("div",{className:"w-full flex-col gap-6",children:[t?.[0]&&t.map(t=>(0,l.jsx)(r().Fragment,{children:(0,l.jsx)(n.A,{user:e,database:a,table:s,dbSchemaData:p,richTextEditors:h,dataTypes:f,entry:t,query:j,confirmedDelegetedUser:g,jsonTextEditors:x})},t.id)),!t&&(0,l.jsx)("div",{className:"w-full h-[300px]",children:(0,l.jsx)(c.A,{position:"relative"})}),t&&!t?.[0]&&(0,l.jsxs)("a",{href:`/admin/${e?.id}/databases/${a.db_slug}/tables/${s.tableName}/entries/add-entry`,className:"border-dotted border-slate-200 border-2 p-4 w-full flex-col rounded flex items-center hover:border-primary/50 gap-2",children:[(0,l.jsx)("span",{className:"text-slate-400 text-center",children:"No Entries Added Yet."}),(0,l.jsx)(m.A,{}),(0,l.jsx)("span",{className:"text-center",children:"Add an Entry to this Table"})]}),y&&y>10?(0,l.jsx)("a",{href:`/admin/${e?.id}/databases/${a.db_slug}/tables/${s.tableName}/entries`,className:"button outlined gray w-full -mb-4",children:(0,l.jsx)("span",{children:"See All Entries"})}):null,t?.[0]&&b&&(0,l.jsxs)("a",{className:"button flex gap-2 items-center w-full justify-center mt-2 more-padding",href:`/admin/${e?.id}/databases/${a.db_slug}/tables/${s.tableName}/entries/add-entry`,style:{borderStyle:"dotted",borderWidth:"2px"},children:[(0,l.jsx)("span",{className:"symbol",children:"+"}),(0,l.jsx)("span",{children:"Add New Entry"})]})]})]})})}d=(p.then?(await p)():p)[0],s()}catch(e){s(e)}})},89579:(e,t,a)=>{a.d(t,{A:()=>g});var s=a(8732),l=a(82015),i=a.n(l),r=a(64030),n=a(63715),d=a(86152),c=a(39897),o=a(32415),u=a(81897),m=a(27825),p=a.n(m),h=a(63014),x=a(95939),f=a(41836);function b({user:e,table:t,entry:a,url:l,query:r}){let[n,d]=i().useState(!1),c=i().useRef(null);return(0,s.jsx)("div",{className:"relative z-[1000]",children:(0,s.jsx)(f.Popover,{isOpen:n,onClickOutside:()=>d(!1),containerClassName:"z-[1000]",positions:["bottom"],align:"end",content:(0,s.jsx)("div",{className:"bg-white dark:bg-slate-900 rounded shadow-md cancel-link",children:(0,s.jsxs)("div",{className:"flex-col min-w-[200px] items-stretch gap-0",children:[(0,s.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(a)).then(()=>{window.alert("Post Copied"),d(!1)})},children:"Copy Object"}),(0,s.jsx)("hr",{className:"m-0"}),(0,s.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let a=(0,h.A)({paradigm:"JavaScript",table:t,query:r,user:e});navigator.clipboard.writeText(a||"").then(()=>{window.alert("JavaScript Type Definition Copied"),d(!1)})},children:"Copy JS Type Definition"}),(0,s.jsx)("hr",{className:"m-0"}),(0,s.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let a=(0,h.A)({paradigm:"TypeScript",table:t,query:r,user:e});navigator.clipboard.writeText(a||"").then(()=>{window.alert("TypeScript Type Definition Copied"),d(!1)})},children:"Copy TS Type Definition"}),(0,s.jsx)("hr",{className:"m-0"}),(0,s.jsx)("a",{href:l,className:"button plain-text justify-start py-3",children:(0,s.jsx)("span",{children:"View Entry"})})]})}),children:(0,s.jsx)("button",{onClick:()=>{d(!n)},ref:c,className:"ghost p-2",children:(0,s.jsx)(x.A,{})})})})}function g({user:e,database:t,table:a,dbSchemaData:l,richTextEditors:m,jsonTextEditors:h,dataTypes:x,entry:f,entryPage:g,confirmedDelegetedUser:j,query:N}){let y=a.fields.filter(e=>e.fieldName&&!e.fieldName.match(r.A)),w=a.fields.find(e=>"uuid"===e.fieldName),v=j?.delegated;j?.priviledges?.match(/Edit Tables/i),j?.priviledges?.match(/Delete Tables/i),j?.priviledges?.match(/Create Tables/i),j?.priviledges?.match(/Edit Entries/i);let T=j?.priviledges?.match(/Delete Entries/i);w&&y.unshift({dataType:"UUID",fieldName:"uuid",defaultField:!0}),y.unshift({dataType:"BIGINT",fieldName:"id",defaultField:!0}),y.push({dataType:"VARCHAR(250)",fieldName:"date_created",defaultField:!0}),y.push({dataType:"BIGINT",fieldName:"date_created_code",defaultField:!0}),y.push({dataType:"TIMESTAMP",fieldName:"date_created_timestamp",defaultField:!0}),y.push({dataType:"VARCHAR(250)",fieldName:"date_updated",defaultField:!0}),y.push({dataType:"BIGINT",fieldName:"date_updated_code",defaultField:!0}),y.push({dataType:"TIMESTAMP",fieldName:"date_updated_timestamp",defaultField:!0});let[S,E]=i().useState(!1),[A,_]=i().useState(!0),[C,$]=i().useState(f),[F,D]=i().useState(!1);i().useRef(null);let k=i().useRef([]),[R,O]=i().useState(`/admin/${e?.id}/databases/${t.db_slug}/tables/${a.tableName}/entries/${C.id}`),I=`${t.db_slug}-${a.tableName}-${C.id}-submit-button`;return(0,s.jsxs)("div",{className:"card col w-full overflow-hidden",children:[(0,s.jsx)("a",{href:R,onClick:e=>{let t=e.target;(t.closest(".cancel-link")||t.closest(".MuiPopover-root"))&&e.preventDefault()},className:"w-full",children:(0,s.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(R,"__blank"):window.location.href=R)},children:[(0,s.jsxs)("span",{children:["Entry #",C.id]}),(0,s.jsxs)("div",{className:"flex-wrap cancel-link",children:[(!v||v&&T)&&(0,s.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer"+(S?" pointer-events-none opacity-40":""),onClick:e=>{window.confirm(`Delete Entry #${C.id}?`)&&(E(!0),(0,n.A)("/api/deleteTableEntry"+window.location.search,{method:"post",body:{dbFullName:t.db_full_name,tableName:a.tableName,entryId:C.id,dbSlug:t.db_slug,dbId:t.id,delegated:N?.delegated,confirmedDelegetedUser:j}},!0).then(e=>{e.success?(0,d.A)().then(()=>{window.location.reload()}):(window.alert(e.msg),setTimeout(()=>{E(!1)},500))}))},children:"Delete Entry"}),!g&&(0,s.jsxs)(i().Fragment,{children:[(0,s.jsx)("span",{className:"opacity-20",children:"|"}),(0,s.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer",onClick:e=>{A?_(!1):_(!0)},children:A?(0,s.jsx)("span",{children:"Expand"}):(0,s.jsx)("span",{children:"Collapse"})})]}),(0,s.jsx)("span",{className:"opacity-20",children:"|"}),(0,s.jsx)("div",{className:"button ghost px-0",onClick:s=>{let l=p().cloneDeep(f);delete l.date_created,delete l.date_created_code,delete l.date_created_timestamp,delete l.date_updated,delete l.date_updated_code,delete l.date_updated_timestamp,delete l.id,delete l.uuid,localStorage.setItem("duplicate_entry",JSON.stringify(l)),window.location.href=`/admin/${e?.id}/databases/${t.db_slug}/tables/${a.tableName}/entries/add-entry?duplicate=true&id=${f.id}`},children:(0,s.jsx)("span",{className:"text-slate-300",children:"Duplicate"})}),(0,s.jsx)("span",{className:"opacity-20",children:"|"}),(0,s.jsx)(b,{table:a,user:e,entry:f,query:N,url:R})]})]})}),(0,s.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative",style:g?{}:{maxHeight:A?"300px":"none",paddingTop:"10px",paddingBottom:"10px",overflow:"hidden"},onSubmit:e=>{e.preventDefault(),E(!0);let s={},l=e.target;y.forEach(e=>{if(!e.fieldName||!l[e.fieldName])return;let t="string"!=typeof l[e.fieldName].value,a="number"!=typeof l[e.fieldName].value;(t||a||l[e.fieldName].value)&&(l[e.fieldName]?.dataset.default||(s[e.fieldName]=l[e.fieldName].value))}),k.current[0]&&k.current.forEach(e=>{e?.fieldName&&e?.ref?.current&&(s[e.fieldName]=e.ref.current.getContent())}),h.current[0]&&h.current.forEach(e=>{e?.fieldName&&e?.ref?.current&&(s[e.fieldName]=e.ref.current.getValue())}),(0,n.A)("/api/updateTableEntry",{method:"post",body:{dbFullName:t.db_full_name,dbSlug:t.db_slug,dbId:t.id,tableName:a.tableName,entryId:C.id,payload:s,tableSchema:a,delegated:N?.delegated,confirmedDelegetedUser:j}},!0).then(e=>{e.success?(0,n.A)(`/api/refreshEntry?table=${a.tableName}&db=${t.db_full_name}&id=${C.id}&schema=${JSON.stringify(a)}`).then(e=>{e.success&&($(e.entry),setTimeout(()=>{E(!1)},500))}):(window.alert(e.msg+"\n"+(e.err||"")),setTimeout(()=>{E(!1)},500))})},onKeyUp:e=>{e.ctrlKey&&"Enter"==e.key&&window.confirm("Update this Form?")&&document.getElementById(I)?.click()},children:[S&&(0,s.jsx)(o.A,{}),(A&&!g?y.slice(0,3):y).map((e,t)=>{let a=x.filter(t=>t.name===e.dataType?.replace(/\d|\(|\)/g,""));return(0,s.jsx)(u.A,{fieldObject:e,dataTypeSchema:a[0],richTextEditors:m,currentRichTextEditorForms:k,entry:C,query:N,entryPage:g,confirmedDelegetedUser:j,jsonTextEditors:h,formButtonId:I},t+1)}),(0,s.jsx)("button",{type:"submit",className:S?" pointer-events-none opacity-40":"",id:I,children:"Update Entry"})]}),!g&&(0,s.jsx)(c.A,{collapse:A,setCollapse:_})]})}},43656:(e,t,a)=>{a.d(t,{A:()=>l});var s=a(8732);function l({radioValues:e,name:t,onChangeHandler:a,setAlert:l,flexRow:i,labelColor:r,baseText:n,smallText:d,className:c}){try{return(0,s.jsx)("div",{className:"flex items-start gap-4 flex-wrap "+(i?"":" flex-col ")+(c||""),children:e.map((e,i)=>{let{payload:c,title:o,jsx:u}=e,m=!1===c?c:c||o||null;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{className:"m-0"+(n?" w-5 h-5":d?" w-4 h-4":" w-6 h-6"),type:"radio",defaultChecked:!!e.default,name:t,id:t+"_"+m,onChange:t=>{l&&l(null),e.onChangeHandler?e.onChangeHandler(t):a&&a(t)},value:"string"==typeof m?m:void 0}),u||(0,s.jsx)("label",{htmlFor:t+"_"+m,className:"text-lg m-0 "+(r||"text-slate-800")+(n?" text-base":d?" text-sm":" text-lg"),children:o})]},i+1)})})}catch(e){return console.log("ERROR in FormRadio =>",e),(0,s.jsx)("div",{children:"Form Radio Error"})}}a(82015)},51548:(e,t,a)=>{a.d(t,{A:()=>i});var s=a(8732),l=a(58526);function i({selectOptions:e,name:t,onChangeHandler:a,required:i,setAlert:r,title:n,defaultValue:d,info:c,id:o}){try{function u(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,s.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[n&&(0,s.jsxs)("label",{htmlFor:t,children:[n,i?"":" (optional)"]}),(0,s.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,s.jsx)("select",{name:t,id:o||t,className:"w-full bg-white",required:i,onChange:e=>{r&&r(null),e.target.classList.remove("warning"),a&&a(e)},defaultValue:d||void 0,children:e.map((e,t)=>{let{payload:a,title:l}=e;return(0,s.jsx)("option",{value:a,selected:!!e.default,children:l},t+1)})}),(0,s.jsx)(l.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(0,s.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:u,onMouseLeave:u,onClick:u,children:[(0,s.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,s.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,s.jsx)("span",{children:c})}),(0,s.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,s.jsx)("div",{children:"Form Select Error"})}}a(82015)},95939:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},98842:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.r(t),a.d(t,{TableEntriesContext:()=>S,default:()=>w,getServerSideProps:()=>v});var l=a(8732),i=a(82015),r=a.n(i),n=a(20048),d=a.n(n),c=a(95222),o=a(74511),u=a(64098),m=a(90378),p=a.n(m),h=a(31651),x=a.n(h),f=a(22373),b=a.n(f),g=a(67216),j=a.n(g),N=a(11169),y=e([o,u]);[o,u]=y.then?(await y)():y;let T=a(29021),S=r().createContext({});function w({user:e,database:t,table:a,dbSchemaData:s,entries:i,query:n,confirmedDelegetedUser:d,entriesCount:m}){let p=`${a.tableFullName} Table Entries | Datasquirel`,h=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:p}),(0,l.jsx)("meta",{name:"description",content:"All Entries in table"})]}),[x,f]=r().useState(null),[b,g]=r().useState(i),j=r().useRef("title"),y=r().useRef(null),w=r().useRef([]),v=r().useRef([]);return(0,l.jsx)(c.A,{head:h,user:e,extraHeaderContent:(0,l.jsx)(u.A,{database:t,query:n,confirmedDelegetedUser:d,user:e}),children:(0,l.jsxs)(S.Provider,{value:{user:e,database:t,table:a,dbSchemaData:s,entries:i,targetEntry:x,setTargetEntry:f,richTextEditors:w,jsonTextEditors:v,query:n,confirmedDelegetedUser:d,activeEntries:b,setActiveEntries:g,targetField:j,searchTerm:y,entriesCount:m},children:[(0,l.jsx)(o.A,{}),(0,l.jsx)(N.A,{snug:!0})]})})}async function v({req:e,res:t,query:a}){let s=await d()(e,t);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};try{let t=a.single,l=await x()({request:e,user:s,databaseSlug:t,query:a});if(!l)throw Error("No Db Object Found!");let{dbUserId:i}=l,r=await j()(`SELECT * FROM user_databases WHERE user_id='${i}' AND db_slug='${a.single}'`);if(!r||!r[0])return{redirect:{destination:`/admin/${s?.id}/databases`,permanent:!1}};let n=JSON.parse(T.readFileSync(`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${i}/main.json`,"utf-8")),d=(n.filter(e=>e.dbFullName===r[0].db_full_name)[0]?.tables).filter(e=>e.tableName===a.single_table)[0],c=await p()({database:r[0].db_full_name,queryString:`SELECT * FROM \`${d.tableName}\` ORDER BY id DESC LIMIT 20`,tableSchema:d}),o=await p()({database:r[0].db_full_name,queryString:`SELECT COUNT(id) AS count FROM ${d.tableName}`,tableSchema:d});return{props:{user:s,database:r[0],table:d,dbSchemaData:n,entries:c,query:a,confirmedDelegetedUser:l,entriesCount:o?.[0]?.count||0}}}catch(e){return b()({component:"[single_table]/entries-page-component/getServerSideProps/catch-error",message:e.message,user:s}),{props:{user:s,database:null,table:null,entries:[]}}}}s()}catch(e){s(e)}})}};