import{l as e,n as t}from"./AIManager-CoE5l2qX.js";var n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function r(e,t=0){return(n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+`-`+n[e[t+4]]+n[e[t+5]]+`-`+n[e[t+6]]+n[e[t+7]]+`-`+n[e[t+8]]+n[e[t+9]]+`-`+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]).toLowerCase()}var i=new Uint8Array(16);function a(){return crypto.getRandomValues(i)}function o(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():s(e,t,n)}function s(e,t,n){e||={};let i=e.random??e.rng?.()??a();if(i.length<16)throw Error(`Random bytes length must be >= 16`);if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return r(i)}var c=class{static async getProfiles(){return(await chrome.storage.local.get(`profiles`)).profiles||[]}static async saveProfile(n){let r=await this.getProfiles(),i;if(`id`in n&&n.id){i=n;let e=r.findIndex(e=>e.id===i.id);e===-1?r.push(i):r[e]=i}else i={...n,id:o()},r.push(i);return e.parse(i),await chrome.storage.local.set({profiles:r}),await t.queueUpsert(i),t.sync(),i}static async deleteProfile(e){let n=(await this.getProfiles()).filter(t=>t.id!==e);await chrome.storage.local.set({profiles:n}),await t.queueDelete(e),t.sync()}static async getActiveProfileId(){return(await chrome.storage.local.get(`activeProfileId`)).activeProfileId||null}static async setActiveProfileId(e){await chrome.storage.local.set({activeProfileId:e})}static async getActiveProfile(){let e=await this.getActiveProfileId();return e&&(await this.getProfiles()).find(t=>t.id===e)||null}};export{c as t};