dsql-admin/dsql-app/.local_dist/static/chunks/1335-9b647f464da8b044.js
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

1 line
10 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1335],{489:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({clientId:e,redirectUrl:t,setLoading:n,scopes:i}){n&&n(!0);let o=i?i.join("%20"):"read:user",r=`https://github.com/login/oauth/authorize?client_id=${e}&scope=${o}&redirect_uri=${t}`;window.location.assign(r)}},8557:function(e,t){let n;var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function l(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,l)}u((i=i.apply(e,t||[])).next())})};function o({google:e,clientId:t,setLoading:n,triggerPrompt:i}){return setTimeout(()=>{null==n||n(!1)},3e3),new Promise((n,o)=>{e.accounts.oauth2.initTokenClient({client_id:t,scope:"email profile",callback:function(e){n(e.access_token)}}).requestAccessToken(),i&&e.accounts.id.prompt(function(e){console.log(e)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return i(this,void 0,void 0,function*(){var t,i;null===(t=e.setLoading)||void 0===t||t.call(e,!0);let r=yield new Promise((t,i)=>{n=setInterval(()=>{let i=window.google;i&&(window.clearInterval(n),t(o(Object.assign(Object.assign({},e),{google:i}))))},500)});return null===(i=e.setLoading)||void 0===i||i.call(e,!1),r})},t.googleLogin=o},7946:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function l(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,l)}u((i=i.apply(e,t||[])).next())})},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return i(this,void 0,void 0,function*(){try{let t;let n=localStorage.getItem("user");try{t=JSON.parse(n||"")}catch(e){console.log(e)}if(!t)return!1;let i=(0,r.default)(),o=(null==i?void 0:i.datasquirel_social_id)&&"string"==typeof i.datasquirel_social_id&&!i.datasquirel_social_id.match(/^null$/i)?i.datasquirel_social_id:null;return localStorage.setItem("user","{}"),localStorage.removeItem("csrf"),document.cookie="datasquirel_social_id=null;samesite=strict;path=/",yield new Promise((t,n)=>{if(!o||(null==o?void 0:o.match(/^null$/i)))t(!0);else{let n=null==e?void 0:e.googleClientId;if(n){let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.className="social-script-tag",document.body.appendChild(e),e.onload=function(e){let i=window.google;i&&(i.accounts.id.initialize({client_id:n}),i.accounts.id.revoke(o,e=>{console.log(e.error),t(!0)}))}}else t(!0)}})}catch(e){return!1}})};let r=o(n(2406))},4490:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){try{if(!e.payload||!e.payload.csrf_k)return!1;return localStorage.setItem("csrf",e.payload.csrf_k),localStorage.setItem("user",JSON.stringify(e.payload)),!0}catch(e){return!1}}},1335:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});let o=i(n(8753)),r=i(n(4715)),a=i(n(1168)),l=i(n(8557)),u=i(n(489)),c=i(n(7946)),s=i(n(1028)),d=i(n(1028)),f=i(n(4727)),g=i(n(8168)),h=i(n(834)),p=i(n(8226)),m=i(n(4567)),y=i(n(4490)),v={imageInputToBase64:r.default,imageInputFileToBase64:o.default,inputFileToBase64:a.default},_={google:{getAccessToken:l.default},github:{getAccessToken:u.default},logout:c.default,postLogin:y.default},w={serializeQuery:f.default,serializeCookies:g.default,EJSON:h.default,numberfy:p.default,slugify:m.default},b={fetchApi:s.default,clientFetch:d.default};t.default={media:v,auth:_,fetch:b,utils:w}},8753:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function l(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,l)}u((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return n(this,arguments,void 0,function*({imageInputFile:e,maxWidth:t,imagePreviewNode:n}){try{let i,o,r=e.name.replace(/\..*/,""),a=document.createElement("canvas"),l=e.type,u=t||null,c=URL.createObjectURL(e),s=new Image;return s.src=c,i=yield new Promise((e,t)=>{s.onerror=function(){URL.revokeObjectURL(this.src),console.log("Cannot load image")},s.onload=function(t){let i=t.target;if(URL.revokeObjectURL(i.src),u){let e=u/s.naturalWidth;a.width=s.naturalWidth<u?s.naturalWidth:u,a.height=s.naturalWidth<u?s.naturalHeight:s.naturalHeight*e}else a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");null==o||o.drawImage(s,0,0,a.width,a.height);let r=a.toDataURL(l,.95);n&&(n.src=r),e(r)}}),o=yield new Promise((e,t)=>{a.toBlob(t=>{e(null==t?void 0:t.size)},l,.95)}),{imageBase64:null==i?void 0:i.replace(/.*?base64,/,""),imageBase64Full:i,imageName:r,imageSize:o}}catch(e){return console.log("Image Processing Error! =>",e.message),{imageBase64:void 0,imageBase64Full:void 0,imageName:void 0,imageSize:void 0}}})}},4715:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function l(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,l)}u((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return n(this,arguments,void 0,function*({imageInput:e,maxWidth:t,mimeType:n}){var i,o;try{let r,a=document.querySelector("[data-imagepreview='image']"),l=null===(i=e.files)||void 0===i?void 0:i[0].name.replace(/\..*/,""),u=n||"image/jpeg",c=t||null,s=null===(o=e.files)||void 0===o?void 0:o[0],d=s?URL.createObjectURL(s):void 0,f=new Image;if(d)return f.src=d,{imageBase64:null==(r=yield new Promise((e,t)=>{f.onerror=function(){URL.revokeObjectURL(this.src),window.alert("Cannot load image!")},f.onload=function(t){let n=t.target;URL.revokeObjectURL(n.src);let i=document.createElement("canvas");if(c){let e=c/f.naturalWidth;i.width=f.naturalWidth<c?f.naturalWidth:c,i.height=f.naturalWidth<c?f.naturalHeight:f.naturalHeight*e}else i.width=f.naturalWidth,i.height=f.naturalHeight;let o=i.getContext("2d");null==o||o.drawImage(f,0,0,i.width,i.height);let r=i.toDataURL(u,.95);a&&document.querySelectorAll("[data-imagepreview='image']").forEach(e=>{e.src=r}),e(r)}}))?void 0:r.replace(/.*?base64,/,""),imageBase64Full:r,imageName:l};return{}}catch(e){return console.log("Image Processing Error! =>",e.message),{}}})}},1168:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function l(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,l)}u((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return n(this,arguments,void 0,function*({inputFile:e,allowedRegex:t}){var n;if(!(null===(n=null==e?void 0:e.type)||void 0===n?void 0:n.match(t||/image\/*|\/pdf/)))return window.alert(`We currently don't support ${e.type} file types. Support is coming soon. For now we support only images and PDFs.`),{fileName:e.name};try{let t=e.name.replace(/\..*/,""),n=yield new Promise((t,n)=>{var i=new FileReader;i.readAsDataURL(e),i.onload=function(){var e;t(null===(e=i.result)||void 0===e?void 0:e.toString())},i.onerror=function(e){console.log("Error: ",e.message)}});return{fileBase64:null==n?void 0:n.replace(/.*?base64,/,""),fileBase64Full:n,fileName:t,fileSize:e.size,fileType:e.type}}catch(t){return console.log("File Processing Error! =>",t.message),{fileName:e.name}}})}},2406:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){let e=document.cookie;if(!e||"string"!=typeof e)return null;let t=e.split(";"),n={};return t.forEach(e=>{let[t,i]=e.split("=");t&&"string"==typeof t&&(n[t.replace(/^ +| +$/,"")]=i&&"string"==typeof i?i.replace(/^ +| +$/,""):null)}),n}},834:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={parse:function(e,t){if(e){if("object"==typeof e)return e;if("string"==typeof e)try{return JSON.parse(e,t)}catch(e){return}}},stringify:function(e,t,n){try{return JSON.stringify(e,t||void 0,n)}catch(e){return}}}},8226:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){try{let n=Number(e);if("number"!=typeof n||isNaN(n))return 0;if(t)return Number(n.toFixed(t));return Math.round(n)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},8168:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({cookies:e}){let t=[];for(let n=0;n<e.length;n++){let i=e[n],o=`${i.name}=${i.value}`;i.maxAge&&(o+=`;Max-Age=${i.maxAge}`),i.path&&(o+=`;Path=${i.path}`),i.domain&&(o+=`;Domain=${i.domain}`),i.secure&&(o+=";Secure"),i.httpOnly&&(o+=";HttpOnly"),i.sameSite&&(o+=`;SameSite=${i.sameSite}`),i.expires&&(o+=`;expires=${i.expires}`),i.priority&&(o+=`;priority=${i.priority}`),t.push(o)}return t}},4727:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let t="?";if("object"!=typeof e)return console.log("Invalid Query type"),t;if(Array.isArray(e))return console.log("Query is an Array. This is invalid."),t;if(!e)return console.log("No Query provided."),t;let n=Object.keys(e),i=[];return n.forEach(t=>{if(!t||!e[t])return;let n=e[t];if("object"==typeof n){let e=o.default.stringify(n);i.push(`${t}=${encodeURIComponent(String(e))}`)}else"string"==typeof n||"number"==typeof n?i.push(`${t}=${encodeURIComponent(n)}`):i.push(`${t}=${String(n)}`)}),t+=i.join("&")};let o=i(n(834))},4567:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){try{return String(e).trim().toLowerCase().replace(/ {2,}/g," ").replace(/ /g,"-").replace(/[^a-z0-9]/g,"-").replace(/-{2,}/g,"-").replace(/^-/,"").replace(/-$/,"")}catch(e){return console.log(`Slugify ERROR: ${e.message}`),""}}}}]);