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AAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC;YAC7E,CAAC;YACD,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAClE,CAAC;IACH,CAAC,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;QACpC,qFAAqF;QACrF,mCAAmC;QACnC,WAAW,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,8EAA8E;QAC9E,WAAW,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC","file":"authRedirect.js","sourcesContent":["function googleUploadFile() {\n // Get the current date\n const currentDate = new Date();\n const formattedDate = currentDate.toISOString().split(\"T\")[0]; // Format as YYYY-MM-DD\n\n // Get the contents of localStorage DAYTOOL\n const localStorageData = localStorage.getItem(\"DAYTOOL\");\n\n if (!localStorageData) {\n console.error(\"No data found in localStorage DAYTOOL.\");\n return;\n }\n\n // Convert the data to JSON\n const jsonData = JSON.parse(localStorageData);\n\n // Convert JSON to string\n const jsonString = JSON.stringify(jsonData);\n\n tokenClient.callback = async (resp) => {\n if (resp.error !== undefined) {\n throw resp;\n }\n\n const boundary = \"-------314159265358979323846\";\n const delimiter = \"\\r\\n--\" + boundary + \"\\r\\n\";\n const close_delim = \"\\r\\n--\" + boundary + \"--\";\n\n const fileMetadata = {\n name: `daytool_${formattedDate}.json`, // Replace with your desired file name\n mimeType: \"application/json\",\n };\n\n const multipartRequestBody =\n delimiter +\n \"Content-Type: application/json\\r\\n\\r\\n\" +\n JSON.stringify(fileMetadata) +\n delimiter +\n \"Content-Type: application/json\\r\\n\" +\n \"\\r\\n\" +\n jsonString +\n close_delim;\n\n // Create the file in Google Drive\n gapi.client\n .request({\n path: \"/upload/drive/v3/files\",\n method: \"POST\",\n params: { uploadType: \"multipart\" },\n headers: {\n \"Content-Type\": \"multipart/related; boundary=\" + boundary,\n },\n body: multipartRequestBody,\n })\n .then((response) => {\n console.log(\"JSON file created:\", response.result);\n })\n .catch((error) => {\n console.error(\"Error creating JSON file:\", error);\n });\n };\n\n if (gapi.client.getToken() === null) {\n // Prompt the user to select a Google Account and ask for consent to share their data\n // when establishing a new session.\n tokenClient.requestAccessToken({ prompt: \"consent\" });\n } else {\n // Skip display of account chooser and consent dialog for an existing session.\n tokenClient.requestAccessToken({ prompt: \"\" });\n }\n}\n\nasync function googleReturnLatest() {\n tokenClient.callback = async (resp) => {\n if (resp.error !== undefined) {\n throw resp;\n }\n\n // gapi.client\n // .request({\n // path: \"/upload/drive/v3/files\",\n // method: \"GET\",\n // params: { uploadType: \"multipart\" },\n // headers: {\n // \"Content-Type\": \"multipart/related; boundary=\" + boundary,\n // },\n // body: multipartRequestBody,\n // })\n gapi.client.drive.files\n .list({\n q: \"name contains 'daytool_' and mimeType = 'application/json'\",\n orderBy: \"createdTime desc\",\n pageSize: 1,\n })\n .then((response) => {\n // Check if any files were found\n if (response.result.files.length === 0) {\n console.error(\n 'No \"daytool_.json\" files found in Google Drive.'\n );\n DAYTOOL.saveToLocalStorage();\n googleUploadFile();\n } else {\n // Get the latest file's metadata\n const latestFileMetadata = response.result.files[0];\n\n // Download the content of the latest file\n const downloadRequest = gapi.client.drive.files.get({\n fileId: latestFileMetadata.id,\n alt: \"media\",\n });\n\n // Get the content of the latest file\n const fileContent = downloadRequest.body;\n\n // Store the content in the localStorage DAYTOOL\n localStorage.setItem(\"DAYTOOL\", fileContent);\n }\n\n modal_layer.classList.remove(\"active\");\n welcome_modal.classList.remove(\"active\");\n })\n .catch((error) => {\n console.error(\n \"Error occurred while retrieving the latest file:\",\n error\n );\n });\n };\n if (gapi.client.getToken() === null) {\n // Prompt the user to select a Google Account and ask for consent to share their data\n // when establishing a new session.\n tokenClient.requestAccessToken({ prompt: \"consent\" });\n } else {\n // Skip display of account chooser and consent dialog for an existing session.\n tokenClient.requestAccessToken({ prompt: \"\" });\n }\n}\n\n/**\n * Print metadata for first 10 files.\n */\nasync function listFiles() {\n tokenClient.callback = async (resp) => {\n if (resp.error !== undefined) {\n throw resp;\n }\n let response;\n try {\n response = await gapi.client.drive.files.list({\n pageSize: 10,\n fields: \"files(id, name)\",\n });\n } catch (err) {\n document.getElementById(\"content\").innerText = err.message;\n return;\n }\n const files = response.result.files;\n if (!files || files.length == 0) {\n document.getElementById(\"content\").innerText = \"No files found.\";\n return;\n }\n // Flatten to string to display\n const output = files.reduce(\n (str, file) => `${str}${file.name} (${file.id})\\n`,\n \"Files:\\n\"\n );\n document.getElementById(\"content\").innerText = output;\n };\n if (gapi.client.getToken() === null) {\n // Prompt the user to select a Google Account and ask for consent to share their data\n // when establishing a new session.\n tokenClient.requestAccessToken({ prompt: \"consent\" });\n } else {\n // Skip display of account chooser and consent dialog for an existing session.\n tokenClient.requestAccessToken({ prompt: \"\" });\n }\n}\n\nasync function getAllCalendarsEvents() {\n tokenClient.callback = async (resp) => {\n if (resp.error !== undefined) {\n throw resp;\n }\n\n try {\n // Get a list of all calendars\n const calendarsResponse = await gapi.client.calendar.calendarList.list();\n const calendars = calendarsResponse.result.items;\n var events_array = [];\n // Loop through each calendar and fetch events\n for (const cal of calendars) {\n const calendarId = cal.id;\n\n // Fetch calendar events\n const response = await gapi.client.calendar.events.list({\n calendarId,\n timeMin: new Date().toISOString(),\n maxResults: 10,\n singleEvents: true,\n orderBy: 'startTime',\n });\n // Extract events from the response\n const events = response.result.items;\n events_array.push(events);\n // Save events as JSON\n // fs.writeFileSync(`calendar_events_${calendarId}.json`, JSON.stringify(events, null, 2));\n\n console.log(`Calendar events for ${cal.summary} have been saved as JSON.`);\n }\n localStorage.setItem(\"GOOGLE_CALENDARS\", JSON.stringify(events_array, null, 2));\n } catch (error) {\n console.error('Error fetching calendar events:', error.message);\n }\n };\n if (gapi.client.getToken() === null) {\n // Prompt the user to select a Google Account and ask for consent to share their data\n // when establishing a new session.\n tokenClient.requestAccessToken({ prompt: \"consent\" });\n } else {\n // Skip display of account chooser and consent dialog for an existing session.\n tokenClient.requestAccessToken({ prompt: \"\" });\n }\n}\n"]}