"use strict";exports.id=9216,exports.ids=[9216],exports.modules={22621:(e,t,a)=>{a.d(t,{A:()=>S});var l=a(8732),r=a(82015),s=a.n(r),d=a(32415),i=a(93669),n=a(40373),o=a(1976),c=a.n(o);function m({editor:e,rootElement:t}){return(0,l.jsx)("div",{className:"embed-popup-form-content-wrapper text-sm mt-2 flex-wrap bg-white p-10 rounded max-w-2xl w-full",children:(0,l.jsxs)("form",{onSubmit:a=>{a.preventDefault();let l=a.target["embed-text-area"].value;if(!l?.match(/./))return alert("Please Enter HTML Text to continue.");e.insertContent(l),document.body.removeChild(t)},className:"w-full flex flex-col items-stretch gap-2",children:[(0,l.jsx)("h3",{className:"m-0 text-center text-lg",children:"Enter HTML code"}),(0,l.jsx)("textarea",{name:"embed-text-area",id:"embed-text-area",cols:30,rows:10,placeholder:"Paste Code here ..."}),(0,l.jsx)("button",{type:"submit",children:"Embed"})]})})}function p({editor:e}){navigator.clipboard.writeText(e?.getContent()||"").then(()=>{alert("Html Copied to Clipboard!")})}var u=a(58150);function x({editor:e,rootElement:t}){e.getContent();let a=s().useRef(),r=s().useRef(),[d,i]=s().useState(null);return(0,l.jsxs)("div",{onKeyUp:e=>{e.ctrlKey&&"Enter"==e.key&&r.current?.click()},children:[(0,l.jsx)("div",{className:"embed-popup-form-content-wrapper relative flex flex-col items-center justify-center",children:(0,l.jsxs)("div",{className:"max-w-[1200px] rounded-md overflow-hidden bg-white w-[90vw] items-start justify-start relative",children:[(0,l.jsx)("div",{ref:a,className:"w-full h-[80vh] text-[18px]"}),(0,l.jsx)("button",{className:"absolute bottom-4 right-4",onClick:a=>{if(d){let a=d.getValue();e.setContent(a),setTimeout(()=>{document.body.removeChild(t)},200)}},ref:r,children:"Save"})]})}),(0,l.jsx)("button",{className:"absolute top-4 right-8 rounded-full white",onClick:()=>{try{document.body.removeChild(t)}catch(e){}},style:{width:"40px",height:"40px",padding:"0",zIndex:"12039800000"},children:(0,l.jsx)(u.A,{})})]})}function f({editor:e}){let t=document.createElement("div");t.style.position="fixed",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="123000000000000000",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.top="0",t.style.left="0",document.body.append(t),t.onclick=e=>{e.target.closest(".embed-popup-form-content-wrapper")||document.body.removeChild(t)},e&&c().createRoot(t).render((0,l.jsx)(x,{editor:e,rootElement:t}))}function h({editor:e}){let t=document.createElement("div");t.style.position="fixed",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="123000000000000000",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.top="0",t.style.left="0",document.body.append(t),t.onclick=e=>{if(e.target.closest(".embed-popup-form-content-wrapper")){console.log("Still In Form");return}document.body.removeChild(t)},e&&c().createRoot(t).render((0,l.jsx)(m,{editor:e,rootElement:t}))}function y({fieldObject:e,dataTypeSchema:t,richTextEditors:a,entry:r,currentRichTextEditorForms:o,entryPage:c,formButtonId:m}){let[u,x]=s().useState(!1),y=s().useRef(),b=s().useRef();return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,l.jsx)(i.A,{fontSize:"small",className:"opacity-50"}),(0,l.jsx)("span",{children:e.fieldName})]}),(0,l.jsxs)("div",{ref:y,id:e.fieldName,className:"w-full p-0 sm:p-4 flex-col items-stretch bg-slate-100 relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},children:[!u&&(0,l.jsx)(d.A,{}),u&&(0,l.jsx)(s().Fragment,{children:(0,l.jsx)(n.Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",onInit:(e,t)=>{b.current=t},initialValue:e.defaultValue||(r&&e.fieldName&&r[e.fieldName]?r[e.fieldName]:""),init:{height:c?400:300,width:"100%",convert_urls:!1,menubar:!1,plugins:["advlist","lists","link","image","charmap","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","preview","help","wordcount"],toolbar:"undo redo | blocks | bold italic forecolor | link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat help | editCode embedCode copyCode",placeholder:"Type something ...",document_base_url:"/",content_css:e.cssFiles||void 0,setup:e=>{!function({editor:e,formButtonId:t}){e.addShortcut("meta+13","Save Entry.",()=>{window.confirm("Update this Form?")&&t&&document.getElementById(t)?.click()}),e.addShortcut("meta+shift+e","Edit Code.",()=>{f({editor:e})}),e.addShortcut("meta+shift+d","Embed Code.",()=>{h({editor:e})}),e.addShortcut("meta+shift+c","Copy Code.",()=>{p({editor:e})}),e.ui.registry.addButton("editCode",{icon:"edit-block",onAction:t=>f({editor:e}),tooltip:"Edit HTML Code"}),e.ui.registry.addButton("embedCode",{icon:"sourcecode",onAction:t=>h({editor:e}),tooltip:"Embed Code"}),e.ui.registry.addButton("copyCode",{icon:"copy",onAction:t=>p({editor:e}),tooltip:"Copy HTML"})}({editor:e,formButtonId:m})}}})})]})]})}a(90317),a(63715),a(51859);var b=a(82544);let g=(0,b.A)("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),N=(0,b.A)("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function v({fieldObject:e,typeFinal:t,isExpanded:a,setHeight:r,COLLAPSED_HEIGHT:s,EXPANDED_HEIGHT:d}){return(0,l.jsxs)("div",{className:"gap-2 w-full",children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,l.jsx)(i.A,{fontSize:"small",className:"opacity-50"}),(0,l.jsx)("span",{children:e.fieldName})]}),(0,l.jsx)("div",{className:"px-4 py-1 bg-secondary text-white rounded-full text-sm font-bold -mt-2",children:(0,l.jsx)("span",{children:t})}),(0,l.jsxs)("div",{className:"ml-auto cursor-pointer gap-1 text-slate-400 hover:text-slate-800 -mt-2 items-center flex",onClick:e=>{a?r(s):r(d)},children:[(0,l.jsx)("span",{className:"font-semibold text-sm",children:a?"Collapse":"Expand"}),a?(0,l.jsx)(g,{size:18,className:"mt-[-1px]"}):(0,l.jsx)(N,{size:18,className:"mt-[-1px]"})]})]})}function j({fieldObject:e,dataTypeSchema:t,entry:a,entryPage:r,jsonTextEditors:d,type:i}){try{let[t,a]=s().useState(0),[r,d]=s().useState(300),n=s().useRef();return s().useRef(),(0,l.jsx)(s().Fragment,{children:(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,l.jsx)(v,{fieldObject:e,isExpanded:300!==r,setHeight:d,typeFinal:i||"json",COLLAPSED_HEIGHT:300,EXPANDED_HEIGHT:600}),(0,l.jsx)(_,{height:r,jsonEditorRef:n})]})})}catch(e){return(0,l.jsx)(s().Fragment,{children:(0,l.jsx)("span",{children:"Editor Load Error"})})}}function _({height:e,jsonEditorRef:t}){return(0,l.jsx)("div",{className:"w-full p-0 sm:p-4 flex-col relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20 overflow-hidden",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px",height:`${e}px`},children:(0,l.jsx)("div",{ref:t,className:"w-full text-[18px] h-full"})})}function S({fieldObject:e,dataTypeSchema:t,richTextEditors:a,jsonTextEditors:r,entry:d,currentRichTextEditorForms:n,confirmedDelegetedUser:o,query:c,entryPage:m,formButtonId:p}){o?.delegated,o?.priviledges?.match(/Edit Tables/i),o?.priviledges?.match(/Delete Tables/i),o?.priviledges?.match(/Create Tables/i),o?.priviledges?.match(/Edit Entries/i),o?.priviledges?.match(/Delete Entries/i);let u=function({fieldObject:e,dataTypeSchema:t,elementRef:a,entry:r}){let s;let d=e=>{let t=e.target.closest("form");if(!t)return;let a=t?.querySelector("#slug");a&&(a.value=e.target.value.toLowerCase().replace(/ /g,"-").replace(/[^a-z\-0-9]/g,""))};return e.defaultField?s=(0,l.jsx)("input",{ref:a,type:"text",name:"def_field_"+e.fieldName,id:"def_field_"+e.fieldName,placeholder:e.fieldName,defaultValue:r&&r[e.fieldName||""]?r[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},readOnly:!0,"data-default":"true"}):(e.dataType?.match(/varchar/i)&&(s=(0,l.jsx)("textarea",{ref:a,name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,maxLength:e.dataType?.match(/\d+/)?.[0]?parseInt(e.dataType?.match(/\d+/)?.[0]||""):void 0,defaultValue:r&&r[e.fieldName||""]?r[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},onChange:t=>{e.fieldName?.match(/^title$/)&&d(t)}})),e.dataType?.match(/int$/i)&&(s=(0,l.jsx)("input",{ref:a,type:"number",name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,max:t.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:r&&r[e.fieldName||""]?r[e.fieldName||""]:e.defaultValue?e.defaultValue:"",onChange:e=>{}})),e.dataType?.match(/text$/i)&&(s=(0,l.jsx)("textarea",{ref:a,name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,defaultValue:r&&r[e.fieldName||""]?r[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},rows:10,onChange:e=>{}})),e.fieldName?.match(/password|^pass$|^key$/i)&&(s=(0,l.jsxs)("div",{className:"w-full relative",children:[(0,l.jsx)("input",{ref:a,type:"password",name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,max:t.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:r&&r[e.fieldName]?r[e.fieldName]:e.defaultValue?e.defaultValue:"",onChange:e=>{}}),(0,l.jsx)("span",{className:"absolute right-4 cursor-pointer",onClick:e=>{let t=e.target.closest("div").querySelector("input");"password"===t.type?(t.type="text",e.target.innerText="Hide"):(t.type="password",e.target.innerText="Reveal")},children:"Reveal"})]})),s||(s=(0,l.jsx)("input",{ref:a,type:"text",name:e.fieldName,id:e.fieldName,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:r&&r[e.fieldName||""]?r[e.fieldName||""]:e.defaultValue?e.defaultValue:"",onChange:e=>{}})),s)}({fieldObject:e,dataTypeSchema:t,elementRef:s().useRef(),entry:d});if(e.dataType?.match(/text$/i)&&e.richText&&!e.plainText&&!e.fieldName?.match(/^pass|^key$/i)&&!e.encrypted||e.encrypted&&e.richText)return(0,l.jsx)(s().Fragment,{children:(0,l.jsx)(y,{fieldObject:e,dataTypeSchema:t,richTextEditors:a,currentRichTextEditorForms:n,entry:d,entryPage:m,formButtonId:p})});let x=e.json||e.yaml||e.html||e.css||e.javascript||e.shell;return e.dataType?.match(/text$/i)&&x&&!e.plainText&&!e.fieldName?.match(/^pass|^key$/i)&&!e.encrypted||e.encrypted&&x?(0,l.jsx)(j,{fieldObject:e,dataTypeSchema:t,entry:d,entryPage:m,jsonTextEditors:r,type:e.json?"json":e.yaml?"yaml":e.html?"html":e.css?"css":e.javascript?"javascript":e.shell?"shell":"json"}):(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full"+(e.defaultField?" opacity-50":""),children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,l.jsx)(s().Fragment,{children:(0,l.jsx)(i.A,{fontSize:"small",className:"opacity-50"})}),(0,l.jsx)("span",{children:e.fieldName}),e.defaultField&&(0,l.jsx)("span",{className:"bg-white dark:bg-slate-900 text-primary dark:text-slate-300 font-semibold text-xs px-2 py-0.5 rounded-xs",children:"Default Field"})]}),u]})}},65241:(e,t,a)=>{a.d(t,{A:()=>d});var l=a(8732),r=a(82015),s=a.n(r);function d({table:e,database:t,user:a,activeDbClone:r}){let d=e?.childTableDbFullName?e.childTableDbFullName.replace(new RegExp(/datasquirel_user_\d+_/),""):null,i=e.childTableDbFullName===t.db_full_name;return d?(0,l.jsxs)("span",{className:"info small green gap-1"+(t?.active_clone?" -mt-6":""),style:{fontWeight:"500"},children:["This Table is an active clone of"," ",(0,l.jsx)("a",{href:`/admin/${a?.id}/databases/${d}/tables/${e.childTableName}`,target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,l.jsx)("b",{children:e.childTableName})})," ","in"," ",i?(0,l.jsxs)("span",{children:["this current database(",(0,l.jsx)("b",{children:t.db_name}),")."]}):(0,l.jsxs)(s().Fragment,{children:[(0,l.jsx)("a",{href:`/admin/${a?.id}/databases/${d}`,target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,l.jsx)("b",{children:d})}),(0,l.jsx)("span",{children:"database."})]})," ",t?.active_clone?"":"Only Foreign keys and Entries can be updated."]}):(0,l.jsx)(s().Fragment,{})}},31651:(e,t,a)=>{a(81630);let l=a(83007);e.exports=async function({request:e,databaseSlug:t,user:a,query:r}){try{let s=a.id,d=null;if(!r?.delegated)return{dbUserId:s};let i=r.dbUserId,n=`${process.env.DSQL_USER_DB_PREFIX}${i}_${t}`,o=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${n}`;try{if(!e.cookies?.[o])throw Error("Cookie not present");let a=l(e.cookies[o]);if(!a)throw Error("Invalid Token");if((d=JSON.parse(a)).databaseSlug===t)return{dbUserId:s=d.rootUserId,rootUserId:d.rootUserId,rootUserName:d.rootUserName,rootUserEmail:d.rootUserEmail,rootUserImage:d.rootUserImage,databaseFullName:d.databaseFullName,databaseSlug:d.databaseSlug,allowedTables:d.allowedTables,priviledges:d.priviledges,database:d.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:s}}catch(e){return null}}},93669:(e,t,a)=>{var l=a(24994);t.A=void 0;var r=l(a(30887)),s=a(8732);t.A=(0,r.default)((0,s.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"}),"LockOutlined")},68743:e=>{e.exports=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/},89545:(e,t,a)=>{let l=a(83007),r=a(68743);e.exports=async function({unparsedResults:e,tableSchema:t}){let a=[];try{for(let s=0;s",t.message),e}}},22373:(e,t,a)=>{let l=a(29021);e.exports=async function({user:e,message:t,component:a,noMail:r}){let s=`🚀 SERVER ERROR =========================== User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email} Error Message: ${t} Component: ${a} Date: ${Date()} ========================================`;l.existsSync("./.tmp/error.log")||l.writeFileSync("./.tmp/error.log","","utf-8");let d=l.readFileSync("./.tmp/error.log","utf-8");l.writeFileSync("./.tmp/error.log",s),l.appendFileSync("./.tmp/error.log",` ${d}`)}},90378:(e,t,a)=>{a(29021);let l=a(89545),r=a(22373),s=a(67216),d=a(1231);e.exports=async function({queryString:e,queryValuesArray:t,database:a,tableSchema:i}){let n;let o=!!a?.match(/^datasquirel$/),c=o?s:d;try{n=e&&t&&Array.isArray(t)&&t[0]?o?await c(e,t):await c({paradigm:"Full Access",database:a,queryString:e,queryValues:t}):o?await c(e):await c({paradigm:"Full Access",database:a,queryString:e})}catch(e){r({component:"varDatabaseDbHandler/lines-29-32",message:e.message})}if(n&&i)try{let e=n;return await l({unparsedResults:e,tableSchema:i})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",a,e),r({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(n)return n;else return null}},1231:(e,t,a)=>{let l=a(29021);a(33873);let r=a(9973),s=a(31976),d=r({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,charset:"utf8mb4",ssl:s()}});e.exports=function({paradigm:e,database:t,queryString:a,queryValues:i}){try{return new Promise((n,o)=>{let c=!!e?.match(/full.access|^fa$/i);try{function m(e){d.end(),n(JSON.parse(JSON.stringify(e)))}function p(e){d.end(),n({error:e.message,queryStringGenerated:a,queryValuesGenerated:i,sql:e.sql})}d=c?r({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,database:t,ssl:s()}}):r({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,database:t,ssl:s()}}),i&&Array.isArray(i)&&i[0]?d.query(a,i).then(m).catch(p):d.query(a).then(m).catch(p)}catch(e){l.appendFileSync("./.tmp/dbErrorLogs.txt",e.message+"\n"+Date()+"\n\n\n","utf8"),n({error:e.message})}})}catch(e){return{success:!1,error:e.message}}}}};