From 9d50e20880a4dd65739c75d6d41d580054858dea Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Thu, 14 May 2026 10:02:42 +0300 Subject: [PATCH] updated api preview examples --- CHANGELOG.md | 2 ++ ...ithOTP-B7z2VJzp.js => docsAuthWithOTP-CJKph96j.js} | 2 +- ...Change-B---6FKV.js => docsEmailChange-BgOZfOYE.js} | 11 ++++++++--- ...eset-vLO_ZWrq.js => docsPasswordReset-db1tMCuS.js} | 11 ++++++++--- .../assets/{index-Dko-neZT.js => index-CphO81V5.js} | 4 ++-- ui/dist/index.html | 2 +- ui/src/apiPreview/docsAuthWithOTP.js | 4 ++++ ui/src/apiPreview/docsEmailChange.js | 11 ++++++++--- ui/src/apiPreview/docsPasswordReset.js | 11 ++++++++--- 9 files changed, 42 insertions(+), 16 deletions(-) rename ui/dist/assets/{docsAuthWithOTP-B7z2VJzp.js => docsAuthWithOTP-CJKph96j.js} (92%) rename ui/dist/assets/{docsEmailChange-B---6FKV.js => docsEmailChange-BgOZfOYE.js} (89%) rename ui/dist/assets/{docsPasswordReset-vLO_ZWrq.js => docsPasswordReset-db1tMCuS.js} (87%) rename ui/dist/assets/{index-Dko-neZT.js => index-CphO81V5.js} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f607f1a..dbd6038c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - Updated `modernc.org/sqlite` to v1.50.1 (SQLite 3.53.1). +- Other minor fixes (_updated API preview examples, fixed code comment typos, etc._). + ## v0.38.0 diff --git a/ui/dist/assets/docsAuthWithOTP-B7z2VJzp.js b/ui/dist/assets/docsAuthWithOTP-CJKph96j.js similarity index 92% rename from ui/dist/assets/docsAuthWithOTP-B7z2VJzp.js rename to ui/dist/assets/docsAuthWithOTP-CJKph96j.js index 059b9d2f..0a513cfc 100644 --- a/ui/dist/assets/docsAuthWithOTP-B7z2VJzp.js +++ b/ui/dist/assets/docsAuthWithOTP-CJKph96j.js @@ -1,4 +1,4 @@ -import{t as e}from"./expandInfo-DGS0CLSa.js";import{t as n}from"./fieldsInfo-Bz62125-.js";function r(e){let n=app.utils.getApiExampleURL(),r=[{title:`OTP request`,content:i},{title:`OTP auth`,content:a}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewAuthWithOTP`,className:`content`},t.p(null,`Authenticate with an one-time/short-lived password (OTP).`),t.p(null,`Note that when requesting an OTP we return an `,t.code(null,`otpId`),` even if a user with the provided email doesn't exist as a very basic enumeration protection.`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` +import{t as e}from"./expandInfo-DGS0CLSa.js";import{t as n}from"./fieldsInfo-Bz62125-.js";function r(e){let n=app.utils.getApiExampleURL(),r=[{title:`OTP request`,content:i},{title:`OTP auth`,content:a}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewAuthWithOTP`,className:`content`},t.p(null,`Authenticate with an one-time/short-lived password (OTP).`),t.p(null,`On successful authentication the user will be also marked as verified (if the OTP source is email and the user is not verified already).`),t.p(null,`Note that when requesting an OTP we return an `,t.code(null,`otpId`),` even if a user with the provided email doesn't exist as a very basic enumeration protection.`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${n}'); diff --git a/ui/dist/assets/docsEmailChange-B---6FKV.js b/ui/dist/assets/docsEmailChange-BgOZfOYE.js similarity index 89% rename from ui/dist/assets/docsEmailChange-B---6FKV.js rename to ui/dist/assets/docsEmailChange-BgOZfOYE.js index 55b47ff5..adbfea2a 100644 --- a/ui/dist/assets/docsEmailChange-B---6FKV.js +++ b/ui/dist/assets/docsEmailChange-BgOZfOYE.js @@ -1,4 +1,4 @@ -function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request email change`,content:n},{title:`Confirm email change`,content:r}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewEmailChange`,className:`content`},t.p(null,`Sends ${e.name} email change request.`),t.p(null,`On successful email change all previously issued auth tokens for the specific record will be automatically invalidated.`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` +function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request email change`,content:n},{title:`Confirm email change`,content:r}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewEmailChange`,className:`content`},t.p(null,`Sends ${e.name} email change request.`),t.p(null,`On successful email change all previously issued auth tokens for the specific record will be invalidated (and the user will be marked as verified if not already).`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${i}'); @@ -16,7 +16,8 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request email change // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${e.name}').confirmEmailChange( 'EMAIL_CHANGE_TOKEN', 'YOUR_PASSWORD', @@ -39,7 +40,8 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request email change // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${e.name}').confirmEmailChange( 'EMAIL_CHANGE_TOKEN', 'YOUR_PASSWORD', @@ -53,6 +55,9 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request email change '${i}/api/collections/${e.name}/request-email-change' # Confirm email change + # + # note: all previous user auth tokens will be invalidated + # (and the user will be marked as verified if not already) curl -X POST \\ -H 'Content-Type:application/json' \\ -d '{ "token":"...", "password":"" }' \\ diff --git a/ui/dist/assets/docsPasswordReset-vLO_ZWrq.js b/ui/dist/assets/docsPasswordReset-db1tMCuS.js similarity index 87% rename from ui/dist/assets/docsPasswordReset-vLO_ZWrq.js rename to ui/dist/assets/docsPasswordReset-db1tMCuS.js index 2ae0aa1d..3284b8e2 100644 --- a/ui/dist/assets/docsPasswordReset-vLO_ZWrq.js +++ b/ui/dist/assets/docsPasswordReset-db1tMCuS.js @@ -1,4 +1,4 @@ -function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request password reset`,content:n},{title:`Confirm password reset`,content:r}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewPasswordReset`,className:`content`},t.p(null,`Sends ${e.name} password reset email request.`),t.p(null,`On successful password reset all previously issued auth tokens for the specific record will be automatically invalidated.`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` +function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request password reset`,content:n},{title:`Confirm password reset`,content:r}],o=store({activeActionIndex:0});return t.div({pbEvent:`apiPreviewPasswordReset`,className:`content`},t.p(null,`Sends ${e.name} password reset email request.`),t.p(null,`On successful password reset all previously issued auth tokens for the specific record will be invalidated (and the user will be marked as verified if not already).`),app.components.codeBlockTabs({className:`sdk-examples m-t-sm`,historyKey:`pbLastSDK`,tabs:[{title:`JS SDK`,language:`js`,value:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${i}'); @@ -11,7 +11,8 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request password res // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${e.name}').confirmPasswordReset( 'RESET_TOKEN', 'NEW_PASSWORD', @@ -30,7 +31,8 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request password res // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${e.name}').confirmPasswordReset( 'RESET_TOKEN', 'NEW_PASSWORD', @@ -44,6 +46,9 @@ function e(e){let i=app.utils.getApiExampleURL(),a=[{title:`Request password res '${i}/api/collections/${e.name}/request-password-reset' # Confirm password reset + # + # note: all previous user auth tokens will be invalidated + # (and the user will be marked as verified if not already) curl -X POST \\ -H 'Content-Type:application/json' \\ -d '{ "token":"...", "password":"", "passwordConfirm":"" }' \\ diff --git a/ui/dist/assets/index-Dko-neZT.js b/ui/dist/assets/index-CphO81V5.js similarity index 99% rename from ui/dist/assets/index-Dko-neZT.js rename to ui/dist/assets/index-CphO81V5.js index b9efdf3b..e72fa163 100644 --- a/ui/dist/assets/index-Dko-neZT.js +++ b/ui/dist/assets/index-CphO81V5.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./docsList-BAfVNUIM.js","./expandInfo-DGS0CLSa.js","./fieldsInfo-Bz62125-.js","./filterSyntax-Df6AnI5x.js","./docsView-Be6Uhvcf.js","./docsCreate-Be3S3y5K.js","./docsUpdate-LtD8DbWI.js","./docsListAuthMethods-9feSopQX.js","./docsAuthWithPassword-DEWj8Jyn.js","./docsAuthWithOAuth2-DUIE4EoY.js","./docsAuthWithOTP-B7z2VJzp.js","./docsAuthRefresh-UjveHHwo.js","./pageInstaller-CboSj8bL.js","./pocketbase.es-B_4DUNUU.js","./pageConfirmPasswordReset-xSsXQyFi.js","./pageConfirmVerification-BSn_UexA.js","./pageConfirmEmailChange-DWXtM27Q.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./docsList-BAfVNUIM.js","./expandInfo-DGS0CLSa.js","./fieldsInfo-Bz62125-.js","./filterSyntax-Df6AnI5x.js","./docsView-Be6Uhvcf.js","./docsCreate-Be3S3y5K.js","./docsUpdate-LtD8DbWI.js","./docsListAuthMethods-9feSopQX.js","./docsAuthWithPassword-DEWj8Jyn.js","./docsAuthWithOAuth2-DUIE4EoY.js","./docsAuthWithOTP-CJKph96j.js","./docsAuthRefresh-UjveHHwo.js","./pageInstaller-CboSj8bL.js","./pocketbase.es-B_4DUNUU.js","./pageConfirmPasswordReset-xSsXQyFi.js","./pageConfirmVerification-BSn_UexA.js","./pageConfirmEmailChange-DWXtM27Q.js"])))=>i.map(i=>d[i]); import{a as e,n,r,t as i}from"./pocketbase.es-B_4DUNUU.js";var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),f=(e,n,r,i)=>{if(n&&typeof n==`object`||typeof n==`function`)for(var a=c(n),l=0,d=a.length,f;ln[e]).bind(null,f),enumerable:!(i=s(n,f))||i.enumerable});return e},p=(e,n,r)=>(r=e==null?{}:a(l(e)),f(n||!e||!e.__esModule?o(r,`default`,{value:e,enumerable:!0}):r,e));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))r(e);new MutationObserver(e=>{for(let n of e)if(n.type===`childList`)for(let e of n.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&r(e)}).observe(document,{childList:!0,subtree:!0});function n(e){let n={};return e.integrity&&(n.integrity=e.integrity),e.referrerPolicy&&(n.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?n.credentials=`include`:e.crossOrigin===`anonymous`?n.credentials=`omit`:n.credentials=`same-origin`,n}function r(e){if(e.ep)return;e.ep=!0;let r=n(e);fetch(e.href,r)}})();var m=`abcdefghijklmnopqrstuvwxyz0123456789`,h=`pb_redirect`,g=store({hash:window.location.hash});window.addEventListener(`hashchange`,()=>{g.hash=window.location.hash}),Prism.languages.pbrule={string:Prism.languages.js.string,number:Prism.languages.js.number,function:Prism.languages.js.function,boolean:/\b(?:true|false)\b/i,constant:/\b(?:null)\b/i,comment:{pattern:/\/\/.*/,greedy:!0},italic:/_via_|\:\w+/,keyword:/&&|\|\||\??(?:!~|!=|>=|<=|=|~|>|>|<)(?=[@\w\s]|$)/};var _={isObject(e){return typeof e==`object`&&!!e&&e.constructor===Object},isEmpty(e){return e==null||e===``||Array.isArray(e)&&e.length===0||typeof e==`object`&&app.utils.isEmptyObject(e)},isEmptyObject(e){for(let n in e)return!1;return!0},toArray(e,n=!1){return Array.isArray(e)?e.slice():(n||!_.isEmpty(e))&&e!==void 0?[e]:[]},removeByValue(e,n){if(!Array.isArray(e)){console.warn(`[removeByValue] not an array:`,e);return}for(let r=e.length-1;r>=0;r--)if(e[r]==n){e.splice(r,1);break}},removeByKey(e,n,r){if(!Array.isArray(e)){console.warn(`[removeByKey] not an array:`,e);return}for(let i in e)if(e[i][n]==r){e.splice(i,1);break}},pushUnique(e,n){if(!Array.isArray(e)){console.warn(`[pushUnique] not an array:`,e);return}e.includes(n)||e.push(n)},mergeUnique(e,n){for(let r of n)app.utils.pushUnique(e,r);return e},pushOrReplaceObject(e,n,r=`id`){for(let i=e.length-1;i>=0;i--)if(e[i][r]==n[r]){e[i]=n;return}e.push(n)},filterDuplicatesByKey(e,n=`id`){e=Array.isArray(e)?e:[];let r={};for(let i of e)r[i[n]]=i;return Object.values(r)},filterRedactedProps(e,n=`******`){let r=JSON.parse(JSON.stringify(e||{}));for(let e in r)typeof r[e]==`object`&&r[e]!==null?r[e]=_.filterRedactedProps(r[e],n):r[e]===n&&delete r[e];return r},getByPath(e,n,r=null,i=`.`){let a=e||{},o=(n||``).split(i);for(let e of o){if(!_.isObject(a)&&!Array.isArray(a)||a[e]===void 0)return r;a=a[e]}return a},setByPath(e,n,r,i=`.`){if(typeof e!=`object`||!e){console.warn(`setByPath: data not an object or array.`);return}let a=e,o=n.split(i),s=o.pop();for(let e of o)(!_.isObject(a)&&!Array.isArray(a)||!_.isObject(a[e])&&!Array.isArray(a[e]))&&(a[e]={}),a=a[e];a[s]=r},deleteByPath(e,n,r=`.`){let i=e||{},a=(n||``).split(r),o=a.pop();for(let e of a)(!_.isObject(i)&&!Array.isArray(i)||!_.isObject(i[e])&&!Array.isArray(i[e]))&&(i[e]={}),i=i[e];Array.isArray(i)?i.splice(o,1):_.isObject(i)&&delete i[o],a.length>0&&(Array.isArray(i)&&!i.length||_.isObject(i)&&!Object.keys(i).length)&&(Array.isArray(e)&&e.length>0||_.isObject(e)&&Object.keys(e).length>0)&&_.deleteByPath(e,a.join(r),r)},emptyClone(e,n=[]){let r=JSON.parse(JSON.stringify(e));for(let e in r)n.includes(e)||(typeof r[e]==`string`?r[e]=``:typeof r[e]==`number`?r[e]=0:typeof r[e]==`boolean`?r[e]=!1:Array.isArray(r[e])?r[e]=[]:app.utils.isObject(r[e])&&(r[e]={}));return r},randomString(e=8,n=m){let r=``;for(let i=0;i`u`)return app.utils.randomString(e);let n=new Uint8Array(e);crypto.getRandomValues(n);let r=``;for(let i=0;i`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`):``},plainText(e){return e?(new DOMParser().parseFromString(e,`text/html`).body.textContent||``).trim():``},truncate(e,n=150,r=!0){if(e=``+e,e.length<=n)return e;if(e=e.slice(0,n),r){for(;e.endsWith(`.`);)e=e.slice(0,-1);e+=`...`}return e},truncateObject(e,n=150,r=!0){let i=Array.isArray(e)?[]:{};for(let a in e){let o=e[a];typeof o==`string`?o=app.utils.truncate(o,n,r):(Array.isArray(o)||app.utils.isObject(o))&&(o=app.utils.truncateObject(o,n,r)),i[a]=o}return i},displayValue(e,n=150,r=`N/A`){if(_.isEmpty(e))return r;if(typeof e!=`string`)if(typeof e==`boolean`)e=e?`True`:`False`;else if(Array.isArray(e)&&typeof e[0]!=`object`)e=e.map(e=>_.displayValue(e,n,r)).join(`, `);else try{e=JSON.stringify(e)||``}catch{e=``+e}return e?_.truncate(e,n):r},splitNonEmpty(e,n=`,`){let r=(e||``).split(n),i=[];for(let e of r)e=e.trim(),_.isEmpty(e)||i.push(e);return i},joinNonEmpty(e,n=`, `){e||=[];let r=[];for(let n of e)n=typeof n==`string`?n.trim():n,_.isEmpty(n)||r.push(``+n);return r.join(n)},formattedFileSize(e){let n=e?Math.floor(Math.log(e)/Math.log(1024)):0;return(e/1024**n).toFixed(2)*1+` `+[`B`,`KB`,`MB`,`GB`,`TB`][n]},toRFC3339Datetime(e){if(!e)return``;let n;return n=e instanceof Date?e:typeof e==`string`?new Date(e.replace(` `,`T`)):new Date(e),n.toISOString().replace(`T`,` `)},toLocalDatetime(e){if(!e)return``;let n;n=e instanceof Date?e:typeof e==`string`?new Date(e.replace(` `,`T`)):new Date(e);let r=n.getFullYear();return isNaN(r)?``:`${r}-${(n.getMonth()+1).toString().padStart(2,`0`)}-${n.getDate().toString().padStart(2,`0`)} ${n.getHours().toString().padStart(2,`0`)}:${n.getMinutes().toString().padStart(2,`0`)}:${n.getSeconds().toString().padStart(2,`0`)}.${n.getMilliseconds().toString().padStart(3,`0`)}`},toDatetimeLocalInputValue(e){if(!e)return``;let n;n=e instanceof Date?e:typeof e==`string`?new Date(e.replaceAll(` `,`T`)):new Date(e);let r=n.getFullYear();return isNaN(r)?``:`${r}-${(n.getMonth()+1).toString().padStart(2,`0`)}-${n.getDate().toString().padStart(2,`0`)}T${n.getHours().toString().padStart(2,`0`)}:${n.getMinutes().toString().padStart(2,`0`)}:${n.getSeconds().toString().padStart(2,`0`)}`},async copyToClipboard(e){if(e=e==null?``:e instanceof Date?e.toISOString():typeof e==`object`?JSON.stringify(e):``+e,!(!e.length||!window.navigator?.clipboard))return window.navigator.clipboard.writeText(e).catch(e=>{console.warn(`Failed to copy.`,e)})},download(e,n){let r=document.createElement(`a`);r.setAttribute(`href`,e),r.setAttribute(`download`,n),r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.click(),r=null},downloadJSON(e,n){n=n.endsWith(`.json`)?n:n+`.json`;let r=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),i=window.URL.createObjectURL(r);_.download(i,n)},getApiExampleURL(){let e;if(app.pb.baseURL.startsWith(`http://`)||app.pb.baseURL.startsWith(`https://`))e=app.pb.baseURL;else{e=window.location.href;let n=e.indexOf(`/_/`);e=n>=0?e.substring(0,n):window.location.origin}return e.replace(`//localhost`,`//127.0.0.1`)},isActivePath(e,n=!0,r=``){r||=g.hash;let i;return i=RegExp(n?`^`+RegExp.escape(e)+`\\/?.*$`:`^`+RegExp.escape(e)+`\\/?(?:\\?.+)?$`),i.test(r)},getHashQueryParams(e=``){e||=g.hash;let n=``,r=e.indexOf(`?`);return r>-1&&(n=window.location.hash.substring(r+1)),Object.fromEntries(new URLSearchParams(n))},replaceHashQueryParams(e,n=null){e||={};let r=``,i=window.location.hash,a=i.indexOf(`?`);a>-1&&(r=i.substring(a+1),i=i.substring(0,a));let o=new URLSearchParams(r);for(let n in e){let r=e[n];_.isEmpty(r)?o.delete(n):o.set(n,r)}r=o.toString(),r!=``&&(i+=`?`+r);let s=window.location.href,c=s.indexOf(`#`);c>-1&&(s=s.substring(0,c));let l=s+i;return n===!1||(n===!0?window.history.pushState(null,``,l):window.history.replaceState(null,``,l)),l},rememberPath(){window.localStorage.setItem(h,window.location.hash)},toRememberedPath(e=`#/collections`){let n=window.localStorage.getItem(h);n&&window.localStorage.removeItem(h),window.location.hash=n||e},getLocalHistory(e,n=null){try{let r=window.localStorage.getItem(e);if(r)return JSON.parse(r)||n}catch(n){console.log(`failed to load local history:`,e,n)}return n},saveLocalHistory(e,n){try{app.utils.isEmpty(n)?window.localStorage.removeItem(e):typeof n==`string`?window.localStorage.setItem(e,n):window.localStorage.setItem(e,JSON.stringify(n))}catch(n){console.log(`failed to save local history:`,e,n)}},generateThumb(e,n=100,r=100){return new Promise(i=>{let a=new FileReader;a.onload=function(a){let o=new Image;o.onload=function(){let a=document.createElement(`canvas`),s=a.getContext(`2d`),c=o.width,l=o.height;return a.width=n,a.height=r,s.drawImage(o,c>l?(c-l)/2:0,0,c>l?l:c,c>l?l:c,0,0,n,r),i(a.toDataURL(e.type))},o.src=a.target.result},a.readAsDataURL(e)})},normalizeSearchFilter(e,n=[]){if(e=(e||``).trim(),!e||!n.length)return e;for(let n of[`=`,`!=`,`~`,`!~`,`>`,`>=`,`<`,`<=`])if(e.includes(n))return e;return e=isNaN(e)&&e!=`true`&&e!=`false`?`"${e.replace(/^[\"\'\`]|[\"\'\`]$/gm,``)}"`:e,n.map(n=>`${n}~${e}`).join(`||`)},logLevels:{[-4]:{label:`DEBUG`,class:``},0:{label:`INFO`,class:`success`},4:{label:`WARN`,class:`warning`},8:{label:`ERROR`,class:`danger`}},logDataFormatters:{execTime:function(e){return e?.data?.execTime===void 0?`N/A`:e.data.execTime+`ms`}},extendStore(e,n={},...r){let i=[];for(let a in n){let o=n[a];typeof e.__raw?.[a]==`function`||typeof o!=`function`||a.length>2&&a.startsWith(`on`)||r.includes(a)?e[a]=o:i.push(watch(o,n=>{e[a]=n}))}return i},cssTimeToMs(e){return e?(e=e.toLowerCase(),e.endsWith(`ms`)?Number(e.substring(0,e.length-2)):e.endsWith(`s`)?Number(e.substring(0,e.length-1)):Number(e)||0):0},isDarkEnoughForWhiteText(e){if(e=e?.startsWith(`#`)?e.substring(1):e,e?.length!=6)return!1;let n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);return(n*299+r*587+i*114)/1e3<128},imageExtensions:[`.jpg`,`.jpeg`,`.png`,`.svg`,`.gif`,`.jfif`,`.webp`,`.avif`],videoExtensions:[`.mp4`,`.avi`,`.mov`,`.3gp`,`.wmv`],audioExtensions:[`.aa`,`.aac`,`.m4v`,`.mp3`,`.ogg`,`.oga`,`.mogg`,`.amr`],documentExtensions:[`.pdf`,`.doc`,`.docx`,`.xls`,`.xlsx`,`.ppt`,`.pptx`,`.odp`,`.odt`,`.ods`,`.txt`],hasImageExtension(e){return e=(e||``).toLowerCase(),!!app.utils.imageExtensions.find(n=>e.endsWith(n))},hasVideoExtension(e){return e=(e||``).toLowerCase(),!!app.utils.videoExtensions.find(n=>e.endsWith(n))},hasAudioExtension(e){return e=(e||``).toLowerCase(),!!app.utils.audioExtensions.find(n=>e.endsWith(n))},hasDocumentExtension(e){return e=(e||``).toLowerCase(),!!app.utils.documentExtensions.find(n=>e.endsWith(n))},getFileType(e){return app.utils.hasImageExtension(e)?`image`:app.utils.hasVideoExtension(e)?`video`:app.utils.hasAudioExtension(e)?`audio`:app.utils.hasDocumentExtension(e)?`document`:`file`},fileTypeIcons:{image:`ri-image-line`,video:`ri-movie-line`,audio:`ri-music-2-line`,document:`ri-file-line`,file:`ri-file-line`},fallbackFieldIcon:`ri-puzzle-line`,fallbackCollectionIcon:`ri-puzzle-line`,fallbackProviderIcon:`ri-puzzle-line`,fallbackPresentableProps:[`title`,`name`,`slug`,`email`,`username`,`nickname`,`displayName`,`label`,`subject`,`topic`,`message`,`heading`,`headline`,`header`,`caption`,`key`,`identifier`,`id`],sortedCollections(e=[]){let n,r;function i(e,i){return n=e.name.startsWith(`_`),r=i.name.startsWith(`_`),n&&!r?1:!n&&r?-1:e.name>i.name?1:e.namee?.id&&!a.find(n=>n.id==e.id)),s=a.filter(e=>e?.id&&!i.find(n=>n.id==e.id)),c=a.filter(e=>{let n=app.utils.isObject(e)&&i.find(n=>n.id==e.id);if(!n)return!1;for(let r in n)if(JSON.stringify(e[r])!=JSON.stringify(n[r]))return!0;return!1});return!!(s.length||c.length||r&&o.length)},extractColumnsFromQuery(e){let n=`__PBGROUP__`;e=(e||``).replace(/\([\s\S]+?\)/gm,n).replace(/[\t\r\n]|(?:\s\s)+/g,` `);let r=e.match(/select\s+([\s\S]+)\s+from/)?.[1]?.split(`,`)||[],i=[];for(let e of r){let r=e.trim().split(` `).pop();r!=``&&r!=n&&i.push(r.replace(/[\'\"\`\[\]\s]/g,``))}return i},getAllCollectionIdentifiers(e,n=``){if(!e)return[];let r=[n+`id`],i=e.type==`auth`;if(e.type===`view`)for(let i of app.utils.extractColumnsFromQuery(e.viewQuery))app.utils.pushUnique(r,n+i);let a=e.fields||[];for(let e of a)if(!(e.type==`password`||i&&e.name==`tokenKey`))if(app.fieldTypes[e.type]?.identifierExtractor){let i=app.utils.toArray(app.fieldTypes[e.type]?.identifierExtractor(e,n));for(let e of i)app.utils.pushUnique(r,e)}else app.utils.pushUnique(r,n+e.name);return r},getDummyFieldsData(e,n=!1){let r=e?.fields||[],i={};for(let e of r)if(!e.hidden)if(app.fieldTypes[e.type]?.dummyData){let r=app.fieldTypes[e.type].dummyData(e,n);r!==void 0&&(i[e.name]=r)}else i[e.name]=`[[DATA]]`;return i},parseIndex(e){let n={unique:!1,optional:!1,schemaName:``,indexName:``,tableName:``,columns:[],where:``},r=/create\s+(unique\s+)?\s*index\s*(if\s+not\s+exists\s+)?(\S*)\s+on\s+(\S*)\s*\(([\s\S]*)\)(?:\s*where\s+([\s\S]*))?/gim.exec((e||``).trim());if(r?.length!=7)return n;let i=/^[\"\'\`\[\{}]|[\"\'\`\]\}]$/gm;n.unique=r[1]?.trim().toLowerCase()===`unique`,n.optional=!app.utils.isEmpty(r[2]?.trim());let a=(r[3]||``).split(`.`);a.length==2?(n.schemaName=a[0].replace(i,``),n.indexName=a[1].replace(i,``)):(n.schemaName=``,n.indexName=a[0].replace(i,``)),n.tableName=(r[4]||``).replace(i,``);let o=(r[5]||``).replace(/,(?=[^\(]*\))/gim,`{PB_TEMP}`).split(`,`);for(let e of o){e=e.trim().replaceAll(`{PB_TEMP}`,`,`);let r=/^([\s\S]+?)(?:\s+collate\s+([\w]+))?(?:\s+(asc|desc))?$/gim.exec(e);if(r?.length!=4)continue;let a=r[1]?.trim()?.replace(i,``);a&&n.columns.push({name:a,collate:r[2]||``,sort:r[3]?.toUpperCase()||``})}return n.where=r[6]||``,n},buildIndex(e){let n=`CREATE `;e.unique&&(n+=`UNIQUE `),n+=`INDEX `,e.optional&&(n+=`IF NOT EXISTS `),e.schemaName&&(n+=`\`${e.schemaName}\`.`),n+=`\`${e.indexName||`idx_`+app.utils.randomString(10)}\` `,n+=`ON \`${e.tableName}\` (`;let r=e.columns.filter(e=>!!e?.name);return r.length>1&&(n+=` `),n+=r.map(e=>{let n=``;return e.name.includes(`(`)||e.name.includes(` `)?n+=e.name:n+="`"+e.name+"`",e.collate&&(n+=` COLLATE `+e.collate),e.sort&&(n+=` `+e.sort.toUpperCase()),n}).join(`, `),r.length>1&&(n+=` @@ -26,7 +26,7 @@ import{a as e,n,r,t as i}from"./pocketbase.es-B_4DUNUU.js";var a=Object.create,o `;let _=g.querySelector(`.paths-group`);return a=t.div({tabIndex:-1,rid:n.rid,id:()=>n.id,hidden:()=>n.hidden,inert:()=>n.inert,className:()=>`erd ${n.className} ${i.isUpdating?`updating`:``} ${i.isPanning?`panning`:``} ${i.activeCollection?`active`:``}`,onkeydown:e=>{(e.ctrlKey||e.metaKey)&&e.key==`0`&&f()},onmount:async e=>{e.addEventListener(`wheel`,r=>{r.preventDefault();let a=e.getBoundingClientRect(),o=r.clientX-a.left,s=r.clientY-a.top,c=(o-i.viewX)/n.scale,l=(s-i.viewY)/n.scale,u=Math.min(Math.max(-r.deltaY*.001+n.scale,Qe),Ze);i.viewX=o-c*u,i.viewY=s-l*u,n.scale=u}),e.addEventListener(`pointerdown`,e=>{e.buttons==1&&(i.isPanning=!0,i.panStartX=e.clientX-i.viewX,i.panStartY=e.clientY-i.viewY)}),e._ondragging=function(e){i.isPanning&&(i.viewX=e.clientX-i.panStartX,i.viewY=e.clientY-i.panStartY)},e._ondragstop=function(){i.isPanning=!1},window.addEventListener(`pointermove`,e._ondragging),window.addEventListener(`pointerup`,e._ondragstop),c()},onunmount:e=>{window.removeEventListener(`pointermove`,e._ondragging),window.removeEventListener(`pointerup`,e._ondragstop),r.forEach(e=>e?.unwatch())}},t.div({className:`erd-area`,style:()=>`transform: translate(${i.viewX}px, ${i.viewY}px) scale(${n.scale});`},m,t.div({className:`erd-tables`},()=>n.collections.map(e=>t.div({style:()=>`left:${i.positions[e.id]?.x||0}px;top:${i.positions[e.id]?.y||0}px`,className:()=>`erd-table type-${e.type} ${p(e)?`active`:``} ${e.system?`system`:``}`,"html-data-collection-id":()=>e.id,"html-data-collection-name":()=>e.name,onmouseenter:()=>{h.querySelectorAll(`[data-to="${e.id}"]`)?.forEach(e=>{e.classList.add(`active-to`),_.append(e)}),h.querySelectorAll(`[data-from="${e.id}"]`)?.forEach(e=>{e.classList.add(`active-from`),_.append(e)}),i.activeCollection=e},onmouseleave:()=>{for(let e of _.children)e.classList.remove(`active-from`,`active-to`);h.append(..._.children),i.activeCollection=null}},t.div({className:`erd-table-row header`},()=>e.name),()=>e.fields?.map(e=>t.div({className:`erd-table-row type-${e.type} ${e.primaryKey?`primary-key`:``}`,"html-data-field-id":()=>e.id,"html-data-field-name":()=>e.name},t.i({ariaHidden:!0,title:()=>e.type,className:()=>`field-icon ${app.fieldTypes[e.type].icon||app.utils.fallbackFieldIcon}`}),t.span({className:`field-name`},()=>e.name),()=>{if(e.hidden)return t.span({className:`label danger field-hidden-label`},`Hidden`)},()=>{if(e.maxSelect!==void 0)return t.span({className:`meta`},e.maxSelect>1?`multiple`:`single`)}))))),g),t.nav({className:`erd-nav`,onmousedown:e=>{e.stopImmediatePropagation()}},t.button({type:`button`,className:`btn sm circle secondary`,title:`Zoom in`,onclick:()=>{n.scale+=.05}},t.i({className:`ri-add-line`,ariaHidden:!0})),t.button({type:`button`,className:`btn sm circle secondary`,title:`Zoom out`,onclick:()=>{n.scale-=.05}},t.i({className:`ri-subtract-line`,ariaHidden:!0})))),a};function et(e,n,r=1,i=``,a=``,o=2){if(!e||!n)return;let s=e.closest(`.erd-area`).getBoundingClientRect(),c=e.getBoundingClientRect(),l=n.getBoundingClientRect();o*=r;let u=c.top-s.top+c.height/2,d=l.top-s.top+l.height/2,f,p;c.leftl.left?(f=c.left-s.left-o,p=l.left-s.left+l.width+o):(f=c.left-s.left-o,p=l.left-s.left-o),f/=r,p/=r,u/=r,d/=r;let m=f+(p-f)/2;f==p&&(m-=20);let h=`M ${f} ${u} L ${m} ${u} L ${m} ${d} - L ${p} ${d}`,g=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return g.setAttribute(`class`,`relation-path`),g.setAttribute(`data-from`,i||``),g.setAttribute(`data-to`,a||``),g.setAttribute(`d`,h),g}window.app=window.app||{},window.app.components=window.app.components||{};var tt=1e3;window.app.components.pageSidebar=function(e={},...n){let r,i=store({rid:void 0,id:void 0,hidden:void 0,inert:void 0,className:``,widthHistoryKey:`pbPageSidebarWidth`,onmount:void 0,onunmount:void 0}),a=app.utils.extendStore(i,e),o=store({responsiveShow:!1}),s;function c(){if(r){if(window.innerWidth>tt){o.responsiveShow=!1,r.dataset.responsive=!1,s?.remove(),s=null;return}r.dataset.responsive=!0,s||(s=t.button({type:`button`,className:`btn transparent secondary responsive-sidebar-btn`,title:`Toggle sidebar`,onclick:e=>{e.stopPropagation(),o.responsiveShow=!o.responsiveShow}},t.i({className:`ri-menu-2-line`,ariaHidden:!0})),document.body.querySelector(`.page-header .breadcrumbs`).before(s))}}function l(e){if(e.target.closest(`.responsive-close`)){o.responsiveShow=!1;return}if(!(e.target.closest(`.page-sidebar`)||e.target.closest(`.app-header`)||e.target.closest(`.modal`)))return e.preventDefault(),e.stopImmediatePropagation(),o.responsiveShow=!1,!1}return a.push(watch(()=>o.responsiveShow,e=>{e?window.addEventListener(`click`,l,!0):window.removeEventListener(`click`,l,!0)})),r=t.aside({pbEvent:`pageSidebar`,rid:i.rid,id:()=>i.id,hidden:()=>i.hidden,inert:()=>i.inert,className:()=>`page-sidebar ${i.className} ${o.responsiveShow?`active`:``}`,onmount:e=>{c(e),window.addEventListener(`resize`,c),i.onmount?.(e)},onunmount:e=>{i.onunmount?.(e),window.removeEventListener(`click`,l,!0),window.removeEventListener(`resize`,c),s?.remove(),a.forEach(e=>e?.unwatch())}},e=>{let n;return i.widthHistoryKey&&(n=localStorage.getItem(i.widthHistoryKey),n&&(e.style.width=n)),app.components.dragline({ondragstart:n=>{e._startWidth=e.offsetWidth},ondragging:(r,a,o)=>{n=e._startWidth+a+`px`,e.style.width=n,i.widthHistoryKey&&localStorage.setItem(i.widthHistoryKey,n)}})},...n),r};var P=`modulepreload`,nt=function(e,n){return new URL(e,n).href},rt={},F=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let e=document.getElementsByTagName(`link`),a=document.querySelector(`meta[property=csp-nonce]`),o=a?.nonce||a?.getAttribute(`nonce`);function s(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}i=s(n.map(n=>{if(n=nt(n,r),n in rt)return;rt[n]=!0;let i=n.endsWith(`.css`),a=i?`[rel="stylesheet"]`:``;if(r)for(let r=e.length-1;r>=0;r--){let a=e[r];if(a.href===n&&(!i||a.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${n}"]${a}`))return;let s=document.createElement(`link`);if(s.rel=i?`stylesheet`:P,i||(s.as=`script`),s.crossOrigin=``,s.href=n,o&&s.setAttribute(`nonce`,o),document.head.appendChild(s),i)return new Promise((e,r)=>{s.addEventListener(`load`,e),s.addEventListener(`error`,()=>r(Error(`Unable to preload CSS for ${n}`)))})}))}function a(e){let n=new Event(`vite:preloadError`,{cancelable:!0});if(n.payload=e,window.dispatchEvent(n),!n.defaultPrevented)throw e}return i.then(n=>{for(let e of n||[])e.status===`rejected`&&a(e.reason);return e().catch(a)})};window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openApiPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=it(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function it(e,n){if(!e){console.warn(`[apiPreviewModal] missing required collection`);return}let r,i=store({activeTab:`List/Search`,tabEl:null,isLoading:!1}),a={"List/Search":async e=>{let{docsList:n}=await F(async()=>{let{docsList:e}=await import(`./docsList-BAfVNUIM.js`);return{docsList:e}},__vite__mapDeps([0,1,2,3]),import.meta.url);return i.tabEl=n(e)},View:async e=>{let{docsView:n}=await F(async()=>{let{docsView:e}=await import(`./docsView-Be6Uhvcf.js`);return{docsView:e}},__vite__mapDeps([4,1,2]),import.meta.url);return i.tabEl=n(e)}};e.type!=`view`&&(a.Create=async e=>{let{docsCreate:n}=await F(async()=>{let{docsCreate:e}=await import(`./docsCreate-Be3S3y5K.js`);return{docsCreate:e}},__vite__mapDeps([5,1,2]),import.meta.url);return i.tabEl=n(e)},a.Update=async e=>{let{docsUpdate:n}=await F(async()=>{let{docsUpdate:e}=await import(`./docsUpdate-LtD8DbWI.js`);return{docsUpdate:e}},__vite__mapDeps([6,5,1,2]),import.meta.url);return i.tabEl=n(e)},a.Delete=async e=>{let{docsDelete:n}=await F(async()=>{let{docsDelete:e}=await import(`./docsDelete-CybOn5jy.js`);return{docsDelete:e}},[],import.meta.url);return i.tabEl=n(e)},a.Realtime=async e=>{let{docsRealtime:n}=await F(async()=>{let{docsRealtime:e}=await import(`./docsRealtime-PMESvmJN.js`);return{docsRealtime:e}},[],import.meta.url);return i.tabEl=n(e)},a.Batch=async e=>{let{docsBatch:n}=await F(async()=>{let{docsBatch:e}=await import(`./docsBatch-DNJl1NTn.js`);return{docsBatch:e}},[],import.meta.url);return i.tabEl=n(e)}),e.type==`auth`&&(a[``]=null,a[`List auth methods`]=async e=>{let{docsListAuthMethods:n}=await F(async()=>{let{docsListAuthMethods:e}=await import(`./docsListAuthMethods-9feSopQX.js`);return{docsListAuthMethods:e}},__vite__mapDeps([7,2]),import.meta.url);return i.tabEl=n(e)},a[`Auth with password`]=e.passwordAuth?.enabled?async e=>{let{docsAuthWithPassword:n}=await F(async()=>{let{docsAuthWithPassword:e}=await import(`./docsAuthWithPassword-DEWj8Jyn.js`);return{docsAuthWithPassword:e}},__vite__mapDeps([8,1,2]),import.meta.url);return i.tabEl=n(e)}:null,e.name!=`_superusers`&&(a[`Auth with OAuth2`]=e.oauth2?.enabled?async e=>{let{docsAuthWithOAuth2:n}=await F(async()=>{let{docsAuthWithOAuth2:e}=await import(`./docsAuthWithOAuth2-DUIE4EoY.js`);return{docsAuthWithOAuth2:e}},__vite__mapDeps([9,1,2]),import.meta.url);return i.tabEl=n(e)}:null),a[`Auth with OTP`]=e.otp?.enabled?async e=>{let{docsAuthWithOTP:n}=await F(async()=>{let{docsAuthWithOTP:e}=await import(`./docsAuthWithOTP-B7z2VJzp.js`);return{docsAuthWithOTP:e}},__vite__mapDeps([10,1,2]),import.meta.url);return i.tabEl=n(e)}:null,a[`Auth refresh`]=async e=>{let{docsAuthRefresh:n}=await F(async()=>{let{docsAuthRefresh:e}=await import(`./docsAuthRefresh-UjveHHwo.js`);return{docsAuthRefresh:e}},__vite__mapDeps([11,1,2]),import.meta.url);return i.tabEl=n(e)},e.name!=`_superusers`&&(a.Verification=async e=>{let{docsVerification:n}=await F(async()=>{let{docsVerification:e}=await import(`./docsVerification-B_Nb90xU.js`);return{docsVerification:e}},[],import.meta.url);return i.tabEl=n(e)}),a[`Password reset`]=async e=>{let{docsPasswordReset:n}=await F(async()=>{let{docsPasswordReset:e}=await import(`./docsPasswordReset-vLO_ZWrq.js`);return{docsPasswordReset:e}},[],import.meta.url);return i.tabEl=n(e)},a[`Email change`]=async e=>{let{docsEmailChange:n}=await F(async()=>{let{docsEmailChange:e}=await import(`./docsEmailChange-B---6FKV.js`);return{docsEmailChange:e}},[],import.meta.url);return i.tabEl=n(e)});let o=[watch(()=>i.activeTab,async()=>{i.isLoading=!0,await a[i.activeTab]?.(e),i.isLoading=!1})];return r=t.div({pbEvent:`apiPreviewModal`,className:`modal api-preview-modal`,onbeforeopen:e=>n.onbeforeopen?.(e),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),o.forEach(e=>e?.unwatch()),e?.remove()},onmount:e=>{},onunmount:e=>{o.forEach(e=>e?.unwatch())}},t.div({className:`modal-content`},t.aside({className:`api-preview-sidebar`},t.nav({className:`api-preview-nav`},()=>{let e=[];for(let n in a){if(!n){e.push(t.hr());continue}let r=!a[n];e.push(t.button({type:`button`,className:()=>`nav-item ${i.activeTab==n?`active`:``}`,disabled:r,ariaDescription:app.attrs.tooltip(()=>r?`Not enabled for the collection`:``,`left`),onclick:()=>{r||(i.activeTab=n)}},n))}return e})),t.div({className:()=>`api-preview-content ${i.isLoading?`faded`:``}`,scrollTop:()=>i.activeTab?0:null},t.header({className:`api-preview-content-header`},t.h6(null,()=>i.activeTab+` (${e.name})`),t.button({type:`button`,className:()=>`btn sm circle transparent secondary m-l-auto preview-close-btn ${i.isLoading?`loading`:``}`,title:`Close`,onclick:()=>app.modals.close(r)},t.i({className:`ri-close-line`,ariaHidden:!0}))),()=>i.tabEl))),r}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openMailTest=function(e=``,n=``){let r=at(e,n);document.body.appendChild(r),app.modals.open(r)};function at(e=``,n=``){let r=`mail_test_`+app.utils.randomString(),i=`pbLastTestEmail`,a=`email_test_request`,o=[{label:`Verification`,value:`verification`},{label:`Password reset`,value:`password-reset`},{label:`Confirm email change`,value:`email-change`},{label:`OTP`,value:`otp`},{label:`Login alert`,value:`login-alert`}],s=store({email:localStorage.getItem(i)||app.store.superuser?.email||``,template:n||o[0].value,isSending:!1,collectionIdOrName:e,get isAuthCollectionsLoading(){return app.store.isCollectionsLoading},get authCollections(){return app.utils.sortedCollections(app.store.collections.filter(e=>e.type==`auth`))},get canSubmit(){return!!s.email&&!!s.template&&!!s.collectionIdOrName}}),c;async function l(){if(!(s.isSending||!s.canSubmit)){s.isSending=!0,clearTimeout(c),c=setTimeout(()=>{s.isSending=!1,app.pb.cancelRequest(a),app.modals.close(),app.toasts.error(`Test email send timeout.`)},15e3);try{s.email!=app.pb.authStore.record?.email&&localStorage.setItem(i,s.email),await app.pb.settings.testEmail(s.collectionIdOrName,s.email,s.template,{requestKey:a}),app.toasts.success(`Successfully sent test email.`),app.modals.close()}catch(e){app.checkApiError(e)}s.isSending=!1,clearTimeout(c)}}let u=[];return t.div({className:`modal popup sm`,onbeforeopen:e=>{u.push(watch(()=>s.isAuthCollectionsLoading,e=>{!e&&!s.collectionIdOrName&&(s.collectionIdOrName=s.authCollections[0]?.id||``)}))},onafterclose:e=>{clearTimeout(c),e?.remove()},onunmount:()=>{clearTimeout(c),u.forEach(e=>e?.unwatch())}},t.header({className:`modal-header`},t.h5({className:`m-auto`},`Send test email`)),t.form({id:r,className:`modal-content mail-settings-test-form`,onsubmit:e=>{e.preventDefault(),l()}},t.div({className:`grid`},t.div({className:`col-lg-12`},()=>o.map((e,n)=>t.field({className:()=>`field ${n>0?`m-t-10`:``}`},t.input({type:`radio`,id:r+`.template.`+e.value,name:`template`,checked:()=>s.template==e.value,onchange:n=>s.template=e.value}),t.label({htmlFor:r+`.template.`+e.value},e.label||e.value)))),()=>{if(!e)return t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`.collection`},`Auth collection`),app.components.select({id:r+`.collection`,name:`collection`,required:!0,placeholder:()=>s.isAuthCollectionsLoading?`Loading auth collections...`:`Select auth collection`,options:()=>s.authCollections.map(e=>({value:e.id,label:e.name})),value:()=>s.collectionIdOrName||``,onchange:e=>{s.collectionIdOrName=e?.[0]?.value}})))},t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`.email`},`To email address`),t.input({id:r+`.email`,name:`email`,type:`email`,required:!0,value:()=>s.email||``,oninput:e=>s.email=e.target.value}))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(),disabled:()=>s.isSending},t.span({className:`txt`},`Close`)),t.button({"html-form":r,type:`submit`,className:()=>`btn expanded ${s.isSending?`loading`:``}`,disabled:()=>s.isSending||!s.canSubmit},t.i({className:`ri-mail-send-line`,ariaHidden:!0}),t.span({className:`txt`},`Send`))))}function ot(e={}){let n=store({rid:void 0,collectionA:null,collectionB:null,deleteMissing:!1,className:``}),r=app.utils.extendStore(n,e),i=store({hasAnyChange:!1,get isDeleteDiff(){return!n.collectionB?.id&&!n.collectionB?.name},get isCreateDiff(){return!i.isDeleteDiff&&!n.collectionA?.id},get hasAnyChange(){return app.utils.hasCollectionChanges(n.collectionA,n.collectionB,n.deleteMissing)},get fieldsListA(){return Array.isArray(n.collectionA?.fields)?n.collectionA?.fields:[]},get fieldsListB(){let e=Array.isArray(n.collectionB?.fields)?n.collectionB?.fields:[];return n.deleteMissing||(e=e.concat(n.collectionA?.fields?.filter(n=>!e.find(e=>n.id==e.id))||[])),e},get mainModelProps(){return app.utils.mergeUnique(Object.keys(n.collectionA||{}),Object.keys(n.collectionB||{})).filter(e=>![`fields`,`created`,`updated`].includes(e))},get removedFields(){return i.fieldsListA.filter(e=>!i.fieldsListB.find(n=>e.id==n.id))},get sharedFields(){return i.fieldsListB.filter(e=>i.fieldsListA.find(n=>n.id==e.id))},get addedFields(){return i.fieldsListB.filter(e=>!i.fieldsListA.find(n=>n.id==e.id))}});function a(e){return e===void 0?``:app.utils.isObject(e)?JSON.stringify(e,null,4):``+e}function o(e,n){return e===n?!1:JSON.stringify(e)!=JSON.stringify(n)}function s(e,n){return(e||[]).find(e=>e.id==n)}return t.div({rid:n.rid,pbEvent:`collectionsDiffTableWrapper`,className:()=>`collections-diff-table-wrapper ${n.className}`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},t.div({className:`collections-diff-table-title`},()=>n.collectionA?.id?n.collectionB?.id?[t.span({hidden:()=>!i.hasAnyChange,className:`label import-change-label warning`,textContent:`Changed`}),t.div({className:`inline-flex gap-5`},()=>{if(n.collectionA?.name!=n.collectionB?.name)return[t.strong({className:`txt-strikethrough txt-hint`,textContent:n.collectionA?.name}),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0})]},t.strong({textContent:()=>n.collectionB?.name}))]:[t.span({className:`label import-change-label danger`,textContent:`Deleted`}),t.strong({textContent:()=>n.collectionA?.name})]:[t.span({className:`label import-change-label success`,textContent:`Added`}),t.strong({textContent:()=>n.collectionB?.name})]),t.table({className:`collections-diff-table`},t.thead(null,t.tr(null,t.th({className:`min-width`},`Props`),t.th({width:`40%`},`Old`),t.th({width:`40%`},`New`))),t.tbody(null,()=>i.mainModelProps.map(e=>{let r=o(n.collectionA?.[e],n.collectionB?.[e]);return t.tr({className:r?`txt-primary`:``},t.td({className:`min-width`},e),t.td({className:()=>i.isCreateDiff?`changed-non-col`:r?`changed-old-col`:``},t.pre({className:`txt diff-value`},a(n.collectionA?.[e]))),t.td({className:()=>i.isDeleteDiff?`changed-non-col`:r?`changed-new-col`:``},t.pre({className:`txt diff-value`},a(n.collectionB?.[e]))))}),()=>{if(!n.deleteMissing&&!i.isDeleteDiff)return;let e=[];for(let n of i.removedFields){e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label danger m-l-5`},`Deleted - `,t.small(null,`All stored data related to '${n.name}' will be deleted!`)))));for(let r in n){let i=n[r];e.push(t.tr(null,t.td({className:`min-width field-key-col`},r),t.td({className:`changed-old-col`},t.pre({className:`txt`},a(i))),t.td({className:`changed-none-col`})))}}return e},()=>{let e=[];for(let n of i.sharedFields){let r=s(i.fieldsListA,n.id),c=o(r,s(i.fieldsListB,n.id));e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label warning m-l-5 ${c?``:`hidden`}`,textContent:`Changed`}))));for(let i in n){let s=n[i],c=o(r?.[i],s);e.push(t.tr({className:c?`txt-primary`:``},t.td({className:`min-width field-key-col`},i),t.td({className:c?`changed-old-col`:``},t.pre({className:`txt`},a(r?.[i]))),t.td({className:c?`changed-new-col`:``},t.pre({className:`txt`},a(s)))))}}return e},()=>{let e=[];for(let n of i.addedFields){e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label success m-l-5`},`Added`))));for(let r in n){let i=n[r];e.push(t.tr({className:`txt-primary`},t.td({className:`min-width field-key-col`},r),t.td({className:`changed-none-col`}),t.td({className:`changed-new-col`},t.pre({className:`txt`},a(i)))))}}return e})))}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openImportCollectionsReview=function(e,n,r={deleteMissing:!1,onsubmit:null}){let i=st(e,n,r);i&&(document.body.appendChild(i),app.modals.open(i))};function st(e,n,r){let i,a=store({deleteMissing:!1,onsubmit:function(e){}}),o=app.utils.extendStore(a,r),s=store({isImporting:!1,pairs:[]});function c(){let r=[];for(let i of e){let e=n.find(e=>e.id==i.id);(a.deleteMissing&&!e?.id||e?.id&&app.utils.hasCollectionChanges(i,e,a.deleteMissing))&&r.push({old:i,new:e})}for(let i of n){let n=e.find(e=>e.id==i.id);n?.id||r.push({old:n,new:i})}s.pairs=r}function l(){let r=[];if(a.deleteMissing)for(let i of e){let e=n.find(e=>e.id==i.id);if(!e)r.push(i.name+`.*`);else{let n=Array.isArray(i.fields)?i.fields:[];for(let a of n)e.fields.find(e=>e.id==a.id)||r.push(`${i.name}.${a.name} (${a.id})`)}}r.length?app.modals.confirm([t.h6(null,`Do you really want to delete the following collection fields and their related records data:`),t.ul(null,()=>r.map(e=>t.li(null,e)))],()=>u()):u()}async function u(){if(!s.isImporting){s.isImporting=!0;try{await app.pb.collections.import(n,a.deleteMissing),await app.store.loadCollections(),a.onsubmit?.(JSON.parse(JSON.stringify(app.store.collections))),app.toasts.success(`Successfully imported collections configuration.`)}catch(e){app.checkApiError(e)}s.isImporting=!1,app.modals.close(i)}}return i=t.div({pbEvent:`importCollectionsReviewModal`,className:`modal popup full import-collections-review-modal`,onbeforeopen:()=>{c()},onbeforeclose:()=>!s.isImporting,onafterclose:e=>{e?.remove()},onunmount:()=>{o.forEach(e=>e?.unwatch())}},t.header({className:`modal-header`},t.h5(null,`Side-by-side diff`)),t.div({className:`modal-content`},()=>s.pairs.map(e=>ot({collectionA:e.old,collectionB:e.new,deleteMissing:a.deleteMissing}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,disabled:()=>s.isImporting,onclick:()=>app.modals.close(i)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:()=>`btn expanded ${s.isImporting?`loading`:``}`,disabled:()=>s.isImporting,onclick:()=>l()},t.span({className:`txt`},`Confirm and import`)))),i}window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.recordSummary=function(e,n=null){let r=store({get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)},get presentableFields(){if(!r.collection?.id)return[];let e=r.collection.fields.filter(e=>e.presentable).sort((e,n)=>{let r=app.fieldTypes[e.type].summaryPriority||0,i=app.fieldTypes[n.type].summaryPriority||0;return r>i?1:re.name==n);if(i){e.push(i);break}}return e}});return t.div({className:`label record-summary`},t.i({ariaHidden:!0,className:`ri-eye-line link-hint record-preview-icon`,onclick:e=>{e.stopImmediatePropagation(),e.preventDefault()},onmouseenter:n=>{lt(n.target,e,100)},onmouseleave:e=>{ct(e.target,100)},onunmount:e=>{ct(e,0)}}),()=>{let i=[];function a(e){(e==null||e==``)&&(e=t.span({className:`missing-value`})),i.push(e)}for(let i of r.presentableFields){let r=app.fieldTypes[i.type]?.view;if(r)a(r({short:!0,get record(){return e},get field(){return i},get meta(){return n}}));else{let n=app.utils.toArray(e[i.name]).splice(0,3);for(let e of n)a(e)}}return i})};function ct(e,n=150){if(e){if(clearTimeout(e._summaryDropdownTimeoutId),n<=0){e?._summaryDropdown?.hidePopover?.();return}e._summaryDropdownTimeoutId=setTimeout(()=>{e?._summaryDropdown?.hidePopover?.()},n)}}function lt(e,n,r=150){if(e){if(clearTimeout(e._summaryDropdownTimeoutId),r<=0){ut(e,n);return}e._summaryDropdownTimeoutId=setTimeout(()=>{ut(e,n)},r)}}var ut=function(e,n){e&&(e._summaryDropdown||(e._summaryDropdown=t.div({className:`dropdown record-summary-dropdown`,popover:`manual`,onclick:e=>{e.stopImmediatePropagation(),e.preventDefault()}},t.div({className:`record-header`},t.a({className:`link-hint txt-bold m-r-auto`,target:`_blank`,href:`#/collections?collection=${n.collectionName}&record=${n.id}`,onclick:e=>{e.stopImmediatePropagation()}},t.span({className:`txt`},`Edit relation record`),t.i({className:`ri-external-link-line`,ariaHidden:!0})),t.button({type:`button`,className:`link-hint`,title:`Close`,onclick:()=>ct(e,0)},t.i({className:`ri-close-line`,ariaHidden:!0}))),t.hr(),t.pre({className:`record-json`},()=>{let e=app.store.collections.find(e=>e.id==n.collectionId||e.name==n.collectionName)?.fields||[];if(!e.length)return;let r={collectionId:n.collectionId,collectionName:n.collectionName};for(let i of e)r[i.name]=n[i.name];return JSON.stringify(app.utils.truncateObject(r,27),null,2)})),e.appendChild(e._summaryDropdown)),e._summaryDropdown?.showPopover({source:e}))};window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.recordsSearchbar=function(e={}){let n=store({rid:void 0,id:void 0,hidden:void 0,inert:void 0,disabled:void 0,value:``,className:``,collection:void 0,onsubmit:e=>{}}),r=app.utils.extendStore(n,e);return t.div({rid:n.rid,id:()=>n.id,hidden:()=>n.hidden,inert:()=>n.inert,className:()=>`full-width records-searchbar-wrapper ${n.className}`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},app.components.searchbar({placeholder:()=>!n.disabled&&!n.collection?.id?`Loading...`:`Search term or filter...`,historyKey:()=>`pbRecordsSearchHistory_`+n.collection?.id,disabled:()=>n.disabled||!n.collection,value:()=>n.value,autocomplete:e=>app.utils.collectionAutocompleteKeys(n.collection,e,{requestKeys:!1,collectionJoinKeys:!1}),onsubmit:n.onsubmit}))},window.app=window.app||{},window.app.components=window.app.components||{};var dt={max:10,pending:new Set,processing:new Set};function ft(e){return dt.pending.add(e),dt.processing.size<=dt.max&&pt(),()=>{dt.pending.delete(e),dt.processing.delete(e),dt.processing.sizen.id,hidden:()=>n.hidden,inert:()=>n.inert,type:`button`,draggable:!1,className:()=>`thumb ${n.extraClasses} ${i.isPreviewLoading?`loading`:``}`,title:()=>(i.hasPreview?`Preview`:`Download`)+` `+n.filename,onclick:async e=>{e.stopPropagation();async function r(){let e=await app.getFileToken(n.record.collectionId);return app.pb.files.getURL(n.record,n.filename,{token:e})}if(i.hasPreview)app.modals.openFilePreview(r);else{let e=await r();app.utils.download(e,n.filename)}},onunmount:()=>{r.forEach(e=>e?.unwatch())}},()=>{if(i.fileType==`image`){let e=t.img({draggable:!1,alt:()=>`Thumb of `+n.filename,src:()=>i.previewURL,onerror:n=>{console.warn(`[recordFileThumb] load err:`,n),i.isPreviewLoading=!1,e?._semaphoreRelease?.()},onload:()=>{i.isPreviewLoading=!1,e?._semaphoreRelease?.()},onmount:e=>{i.isPreviewLoading=!0,e._semaphoreRelease=ft(async()=>{try{i.previewToken=await app.getFileToken(n.record.collectionId),i.previewURL=app.pb.files.getURL(n.record,n.filename,{thumb:`100x100`,token:i.previewToken})}catch(e){console.warn(e)}})},onunmount:e=>{i.isPreviewLoading=!1,e._semaphoreRelease?.()}});return e}return t.i({className:app.utils.fileTypeIcons[i.fileType]||`ri-file-line`,ariaHidden:!0})})},window.app=window.app||{},window.app.modals=window.app.modals||{};var mt=100,ht={btnText:`Insert`,fileTypes:[],onselect:function(e){}},gt=`pbLastRecordFilePickerCollection`,_t=`listFilePickerRecords`;window.app.modals.openRecordFilePicker=function(e={}){e=Object.assign({},ht,e);let n=vt(e);document.body.appendChild(n),app.modals.open(n)};function vt(e=ht){let n,r=`file_picker_`+app.utils.randomString(),i=store({selectedFile:{},records:[],activeCollectionId:``,searchTerm:``,lastRecordsPage:1,lastTotalRecords:0,isLoadingRecords:!1,get collections(){return app.utils.sortedCollections(app.store.collections.filter(e=>e.type==`view`?!1:!!e.fields?.find(e=>e.type===`file`&&!e.protected)))},get activeCollection(){return i.collections.find(e=>e.id==i.activeCollectionId)||i.collections[0]},get activeCollectionFileFields(){return i.activeCollection?.fields?.filter(e=>e.type===`file`&&!e.protected)||[]},get isLoading(){return app.store.isLoadingCollections||i.isLoadingRecords},get canLoadMore(){return!i.isLoadingRecords&&i.lastTotalRecords==mt},get hasAtleastOneFile(){return!!i.records.find(e=>c(e).length>0)}}),a=[];a.push(watch(()=>{i.activeCollectionId?(window.localStorage.setItem(gt,i.activeCollectionId),i.searchTerm=``):i.activeCollectionId=window.localStorage.getItem(gt)})),a.push(watch(()=>[i.activeCollection,i.searchTerm],()=>s(!0)));function o(){app.pb.cancelRequest(_t),i.isLoadingRecords=!1,i.records=[],i.lastTotalRecords=0,i.lastRecordsPage=1,i.selectedFile={}}async function s(e=!1){if(!i.activeCollection){o();return}e&&o(),i.isLoadingRecords=!0;try{let n=e?1:i.lastRecordsPage+1,r=app.utils.getAllCollectionIdentifiers(i.activeCollection),a=app.utils.normalizeSearchFilter(i.searchTerm,r)||``;a&&(a+=` && `),a+=`(`+i.activeCollectionFileFields.map(e=>`${e.name}:length>0`).join(`||`)+`)`;let o=await app.pb.collection(i.activeCollection.id).getList(n,mt,{requestKey:_t,filter:a,skipTotal:1,sort:i.activeCollection.type==`view`?``:`-@rowid`});i.lastRecordsPage=o.page,i.lastTotalRecords=o.items.length,i.records=app.utils.filterDuplicatesByKey(i.records.concat(o.items)),i.isLoadingRecords=!1}catch(e){e.isAbort||(i.isLoadingRecords=!1,app.checkApiError(e))}}function c(n){let r=[];for(let a of i.activeCollectionFileFields){let i=app.utils.toArray(n[a.name]);for(let n of i)(app.utils.isEmpty(e.fileTypes)||e.fileTypes?.includes(app.utils.getFileType(n)))&&r.push(n)}return r}function l(e,n){i.selectedFile={record:e,name:n,thumb:``}}function u(e,n){return i.selectedFile?.name==n&&i.selectedFile?.record?.id==e?.id}let d={"record:create":e=>{e.detail.collectionId==i.activeCollection?.id&&(i.selectedFile?.record?.id==e.detail.id&&(i.selectedFile.record=e.detail),s(!0))},"record:delete":e=>{e.detail.collectionId!=i.activeCollection?.id&&e.detail.collectionName!=i.activeCollection?.name||(i.selectedFile?.record?.id==e.detail.id&&(i.selectedFile={}),s(!0))}};return n=t.div({className:`modal popup record-file-picker-modal`,onafterclose:e=>{e?.remove()},onmount:e=>{for(let e in d)document.addEventListener(e,d[e])},onunmount:e=>{a.forEach(e=>e?.unwatch());for(let e in d)document.removeEventListener(e,d[e])}},t.header({className:`modal-header`},t.button({className:()=>`btn primary outline record-file-picker-collection-select-btn ${app.store.isLoadingCollections?`loading`:``}`,disabled:()=>app.store.isLoadingCollections,"html-popovertarget":`collections_dropdown`+r},t.span({className:`txt-lg collection-name m-r-auto`},()=>i.activeCollection?.name||`Select collection`),t.i({className:`ri-arrow-drop-down-line`,ariaHidden:!0})),t.div({id:`collections_dropdown`+r,className:`dropdown`,popover:`hint`},()=>i.collections.map(e=>t.button({type:`button`,className:()=>`dropdown-item ${i.activeCollectionId==e.id?`active`:``}`,onclick:n=>{i.activeCollectionId=e.id,n.target?.closest(`.dropdown`)?.hidePopover()}},e.name))),app.components.recordsSearchbar({disabled:()=>!i.activeCollection?.id,collection:()=>i.activeCollection,value:()=>i.searchTerm,onsubmit:e=>i.searchTerm=e}),t.button({type:`button`,className:`btn circle transparent`,ariaLabel:app.attrs.tooltip(`Add new record`),onclick:()=>app.modals.openRecordUpsert(i.activeCollection)},t.i({className:`ri-add-line txt-hint`,ariaHidden:!0}))),t.div({className:`modal-content`},t.div({className:`block txt-center`,hidden:()=>i.hasAtleastOneFile||!i.isLoading},t.span({className:`loader`})),t.div({className:`record-file-picker-list`},()=>{let e=[];for(let n of i.records){let r=c(n);for(let i of r)e.push(t.button({rid:n.id+`:`+i,className:()=>`list-item thumb ${u(n,i)?`success`:``}`,ariaDescription:app.attrs.tooltip(i,`bottom`),onclick:()=>l(n,i)},()=>{if(app.utils.hasImageExtension(i))return t.img({loading:`lazy`,src:app.pb.files.getURL(n,i,{thumb:`100x100`}),alt:i});let e=app.utils.getFileType(i);return t.i({className:app.utils.fileTypeIcons[e]||`ri-file-line`,ariaHidden:!0})}))}return e}),t.div({hidden:()=>!i.canLoadMore||!i.hasAtleastOneFile,className:`block txt-center`},t.button({className:()=>`btn secondary expanded-lg m-t-base ${i.isLoadingRecords?`loading`:``}`,disabled:()=>i.isLoadingRecords,onclick:()=>s()},t.span({className:`txt`},`Load more`))),t.div({className:`block txt-center txt-hint p-t-10 p-b-10`,hidden:()=>i.hasAtleastOneFile||i.isLoading},()=>app.utils.isEmpty(e.fileTypes)?t.p(null,`No records with selectable files found.`):t.p(null,`No "${e.fileTypes.join(`", "`)}" files found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,hidden:()=>!i.searchTerm?.length,onclick:()=>{i.searchTerm=``}}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Close`)),()=>{if(!i.selectedFile?.name||!app.utils.hasImageExtension(i.selectedFile.name))return;let e=[{value:``,label:`Original size`},{value:`100x100`,label:`100x100 thumb`}],n=i.activeCollectionFileFields.find(e=>i.selectedFile.record[e.name].includes(i.selectedFile.name)),r=app.utils.toArray(n.thumbs);for(let n of r)e.push({value:n,label:`${n} thumb`});return t.div({className:`record-file-picker-thumb-select`},app.components.select({required:!0,value:i.selectedFile.thumb||``,options:e,onchange:e=>{i.selectedFile.thumb=e?.[0].value}}))},t.button({type:`button`,className:`btn expanded`,disabled:()=>i.isLoading||!i.selectedFile?.name,onclick:()=>{let r=JSON.parse(JSON.stringify(i.selectedFile));if(e.onselect&&e.onselect(r)===!1)return!1;app.modals.close(n)}},t.span({className:`txt`},()=>e.btnText||ht.btnText)))),n}window.app=window.app||{},window.app.modals=window.app.modals||{};var yt=50,bt=100,xt=`listRelationPickerRecords`,St={collection:``,selectedIds:[],maxSelect:1,btnText:`Set selection`,onselect:function(e){}};window.app.modals.openRecordsPicker=function(e={}){e=Object.assign({},St,e);let n=Ct(e);document.body.appendChild(n),app.modals.open(n)};function Ct(e=St){let n,r=store({searchTerm:``,selected:[],preselected:[],isLoadingPreselected:!1,records:[],isLoadingRecords:!1,lastRecordsPage:1,lastRecordsTotal:0,get collection(){let n=e.collection;return typeof e.collection==`object`&&e.collection?.id&&(n=e.collection?.id),app.store.collections.find(e=>e.id==n||e.name==n)},get isLoading(){return r.isLoadingPreselected||r.isLoadingRecords},get canLoadMore(){return!r.isLoadingRecords&&r.lastRecordsTotal==yt}}),i=[watch(()=>[e.collection,e.selectedIds],()=>{o()}),watch(()=>[r.collection,r.searchTerm],()=>{s(!0)})];function a(){setTimeout(()=>app.modals.close(n),0)}async function o(){let n=app.utils.toArray(e.selectedIds),i=e.collection?.id||e.collection;if(!i||!n.length)return;r.isLoadingSelected=!0;let a=[],o=n.slice(),s=[];for(;o.length>0;){let e=[],n=o.splice(0,bt);for(let r of n)e.push(`id="${r}"`);s.push(app.pb.collection(i).getFullList({requestKey:null,filter:e.join(`||`)}))}try{await Promise.all(s).then(e=>{a=a.concat(...e)});let e=[];for(let r of n){let n=a.find(e=>e.id==r);n&&e.push(n)}r.searchTerm.trim()||(r.records=app.utils.filterDuplicatesByKey(e.concat(r.records))),r.selected=e,r.isLoadingSelected=!1}catch(e){e.isAbort||(app.checkApiError(e),r.isLoadingSelected=!1)}}async function s(e=!1){if(r.collection?.id){e&&(c(),r.searchTerm.trim()||(r.records=r.selected.slice())),r.isLoadingRecords=!0;try{let n=e?1:r.lastRecordsPage+1,i=app.utils.getAllCollectionIdentifiers(r.collection),a=app.utils.normalizeSearchFilter(r.searchTerm,i)||``,o=await app.pb.collection(r.collection.id).getList(n,yt,{requestKey:xt,filter:a,skipTotal:1,sort:r.collection.type==`view`?``:`-@rowid`});r.lastRecordsPage=o.page,r.lastRecordsTotal=o.items.length,r.records=app.utils.filterDuplicatesByKey(r.records.concat(o.items)),r.isLoadingRecords=!1}catch(e){e.isAbort||(r.isLoadingRecords=!1,app.checkApiError(e))}}}function c(){app.pb.cancelRequest(xt),r.isLoadingRecords=!1,r.records=[],r.lastTotalRecords=0,r.lastRecordsPage=1}function l(e){e.target.scrollHeight-e.target.clientHeight-e.target.scrollTop<=100&&r.canLoadMore&&s()}function u(n){let i=r.selected.findIndex(e=>e.id==n.id);if(i>=0)r.selected.splice(i,1);else{let i=e.maxSelect||1,a=r.selected.length-i;for(;a>=0;)r.selected.pop(),a--;r.selected.push(n)}}function d(e){return r.selected.findIndex(n=>n.id==e.id)>=0}let f={"record:save":e=>{if(e.detail.collectionId!=r.collection?.id)return;let n=r.selected?.findIndex(n=>n.id==e.detail.id);n>=0&&(r.selected[n]=e.detail),app.utils.pushOrReplaceObject(r.records,e.detail),s(!0)},"record:delete":e=>{e.detail.collectionId!=r.collection?.id&&e.detail.collectionName!=r.collection?.name||(d(e.detail)&&u(e.detail),app.utils.removeByKey(r.records,`id`,e.detail.id),s(!0))}};return n=t.div({className:`modal popup lg records-picker-modal`,onafterclose:e=>{e.remove()},onmount:e=>{for(let e in f)document.addEventListener(e,f[e])},onunmount:e=>{i.forEach(e=>e?.unwatch());for(let e in f)document.removeEventListener(e,f[e])}},t.header({className:`modal-header`},t.h6({className:`collection-name`},()=>r.collection.name),app.components.recordsSearchbar({disabled:()=>!r.collection?.id,collection:()=>r.collection,value:()=>r.searchTerm,onsubmit:e=>r.searchTerm=e}),t.button({type:`button`,className:`btn circle transparent`,ariaLabel:app.attrs.tooltip(`Add new record`),onclick:()=>{app.modals.openRecordUpsert(r.collection)}},t.i({className:`ri-add-line txt-hint`,ariaHidden:!0}))),t.div({className:`modal-content`,hidden:()=>r.isLoadingCollection},t.div({className:`list records-picker-list`,onscroll:l,onresize:l},()=>r.records.map(e=>t.div({tabIndex:0,className:`list-item handle`,onclick:()=>{u(e),document.activeElement?.blur()}},t.div({className:`content`},t.span({className:`state-icon`},t.i({ariaHidden:!0,className:()=>d(e)?`ri-checkbox-circle-fill txt-success`:`ri-checkbox-blank-circle-line txt-disabled`})),()=>app.components.recordSummary(e)),t.div({className:`actions autohide`},t.button({className:`btn sm secondary transparent circle`,ariaLabel:app.attrs.tooltip(`Edit`),onclick:n=>{n.stopPropagation(),app.modals.openRecordUpsert(r.collection,e)}},t.i({className:`ri-pencil-line`,ariaHidden:!0}))))),t.div({className:`list-item`,hidden:()=>!r.isLoading},t.div({className:`skeleton-loader`})),t.div({className:`list-item`,hidden:()=>r.records.length||r.isLoading},t.div({className:`content txt-hint`},t.span({className:`txt`},`No records found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,hidden:()=>!r.searchTerm.trim().length,onclick:()=>{r.searchTerm=``}})))),t.div({className:`block m-t-base`},t.p({className:`txt-bold`},()=>`Selected (${r.selected.length} of max ${e.maxSelect||1})`),t.span({className:`txt-hint`,hidden:()=>r.selected},`No selected records.`),app.components.sortable({className:`records-picker-selected-list`,data:()=>r.selected,dataItem:(e,n)=>t.div({rid:e,className:`label handle`},()=>app.components.recordSummary(e,[],!0),t.span({className:`link-hint`,title:`Remove`,role:`button`,onclick:()=>u(e)},t.i({className:`ri-close-line`,ariaHidden:!0}))),onchange:(e,n,i)=>{r.selected=e}}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>a()},t.span({className:`txt`},`Close`)),()=>{if(!r.selectedFile?.name||!app.utils.hasImageExtension(r.selectedFile.name))return;let e=[{value:``,label:`Original size`},{value:`100x100`,label:`100x100 thumb`}],n=r.activeCollectionFileFields.find(e=>r.selectedFile.record[e.name].includes(r.selectedFile.name)),i=app.utils.toArray(n.thumbs);for(let n of i)e.push({value:n,label:`${n} thumb`});return t.div({className:`record-file-picker-thumb-select`},app.components.select({required:!0,value:r.selectedFile.thumb||``,options:e,onchange:e=>{r.selectedFile.thumb=e?.[0].value}}))},t.button({type:`button`,className:`btn expanded`,disabled:()=>r.isLoadingCollection,onclick:()=>{let n=JSON.parse(JSON.stringify(r.selected));if(e.onselect&&e.onselect(n)===!1)return!1;a()}},t.span({className:`txt`},e.btnText||St.btnText)))),n}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openRecordPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=I(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function wt(e){e.expand&&(e=Object.assign({},e),delete e.expand),app.utils.downloadJSON(e,e.collectionName+`_`+e.id+`.json`)}function Tt(e){e.expand&&(e=Object.assign({},e),delete e.expand),app.utils.copyToClipboard(JSON.stringify(e,null,2)),app.toasts.success(`Record copied to clipboard!`)}function I(e,n){if(!e?.id){app.toasts.error(`Failed to load record.`),console.warn(`[recordPreviewModal] missing required record id field:`,e);return}if(!e.collectionId&&!e.collectionName){app.toasts.error(`Failed to load record.`),console.warn(`[recordPreviewModal] missing required collectionId or collectionName field:`,e);return}let r,i=app.utils.randomString(),a=store({isLoading:!1,record:null,get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)}});async function o(){a.isLoading=!0;try{a.record=JSON.parse(JSON.stringify(e));let n=[],r=a.collection?.fields?.filter(e=>!e.hidden&&e.type==`relation`)||[];for(let e of r)n.push(e.name);let i=await app.pb.collection(e.collectionName||e.collectionId).getOne(e.id,{requestKey:`record_preview_`+e.id,expand:n.join(`,`)||void 0});Object.assign(a.record,i),a.isLoading=!1}catch(e){e?.isAbort||(a.isLoading=!1,app.checkApiError(e),setTimeout(()=>app.modals.close(r),0))}}return r=t.div({pbEvent:`recordPreviewModal`,className:`modal record-preview-modal`,onbeforeopen:e=>(o(),n.onbeforeopen?.(e)),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()}},t.header({className:`modal-header`},t.h6(null,t.strong(null,()=>e?.collectionName||a.collection?.name),` record preview`),t.button({title:`More options`,className:()=>`btn sm circle transparent m-l-auto ${a.isLoading?`loading`:``}`,disabled:()=>a.isLoading,"html-popovertarget":i+`preview-dropdown`},t.i({className:`ri-more-line`,ariaHidden:!0})),t.div({id:i+`preview-dropdown`,className:`dropdown`,popover:`auto`},e=>t.button({className:`dropdown-item`,onclick:()=>{Tt(a.record),e.hidePopover()}},t.i({className:`ri-braces-line`,ariaHidden:!0}),t.span({className:`txt`},`Copy JSON`)))),t.div({className:`modal-content`},t.table({pbEvent:`recordPreviewTable`,className:`record-preview-table responsive-table`},t.tbody(null,()=>(a.collection?.fields?.filter(e=>e.type!=`password`)||[]).map(e=>t.tr(null,t.th({className:()=>`min-width p-r-0 col-field-name-${e.name}`},e.name),t.td({className:()=>`col-field-name-${e.name}`},()=>app.fieldTypes[e.type]?.view?app.fieldTypes[e.type].view({short:!1,get record(){return a.record},get field(){return e}}):app.utils.displayValue(a.record[e.name],1e3))))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:()=>`btn ${a.isLoading?`loading`:``}`,disabled:()=>a.isLoading,onclick:()=>wt(a.record)},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download JSON`)))),r}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openRecordImpersontate=function(e){let n=R(e);document.body.appendChild(n),app.modals.open(n)};function R(e){let n=`impersonate_`+app.utils.randomString(),r=store({isLoading:!1,token:``,duration:0,get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)}}),i=app.utils.getApiExampleURL();async function a(){if(!r.isLoading){r.isLoading=!0;try{r.token=(await app.pb.collection(r.collection.name).impersonate(e.id,r.duration)).authStore.token}catch(e){app.checkApiError(e)}r.isLoading=!1}}function o(){r.token=``,r.duration=0}return t.div({className:`modal popup record-impersonate-auth-modal`,onbeforeclose:()=>!r.isLoading,onafterclose:e=>{e?.remove()}},t.header({className:`modal-header`},t.h6(null,`Generate nonrenewable auth token for `,t.strong(null,()=>e.email||e.id))),t.div({className:`modal-content`},t.form({id:n+`_form`,hidden:()=>r.token,className:`block`,onsubmit:e=>{e.preventDefault(),a()}},t.div({className:`field`},t.label({htmlFor:n+`_duration`},`Token duration (in seconds)`),t.input({id:n+`_duration`,type:`number`,name:`duration`,min:0,step:1,placeholder:()=>`Default to the collection settings (${r.collection?.authToken?.duration||0}s)`,value:e=>r.duration||``,oninput:e=>r.duration=parseInt(e.target.value,10)}))),t.div({hidden:()=>!r.token,className:`alert success impersonate-success`},t.strong(null,()=>r.token),` `,app.components.copyButton(()=>r.token)),app.components.codeBlockTabs({hidden:()=>!r.token,className:`sdk-examples m-t-base`,tabs:[{title:`JS SDK`,language:`js`,value:` + L ${p} ${d}`,g=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return g.setAttribute(`class`,`relation-path`),g.setAttribute(`data-from`,i||``),g.setAttribute(`data-to`,a||``),g.setAttribute(`d`,h),g}window.app=window.app||{},window.app.components=window.app.components||{};var tt=1e3;window.app.components.pageSidebar=function(e={},...n){let r,i=store({rid:void 0,id:void 0,hidden:void 0,inert:void 0,className:``,widthHistoryKey:`pbPageSidebarWidth`,onmount:void 0,onunmount:void 0}),a=app.utils.extendStore(i,e),o=store({responsiveShow:!1}),s;function c(){if(r){if(window.innerWidth>tt){o.responsiveShow=!1,r.dataset.responsive=!1,s?.remove(),s=null;return}r.dataset.responsive=!0,s||(s=t.button({type:`button`,className:`btn transparent secondary responsive-sidebar-btn`,title:`Toggle sidebar`,onclick:e=>{e.stopPropagation(),o.responsiveShow=!o.responsiveShow}},t.i({className:`ri-menu-2-line`,ariaHidden:!0})),document.body.querySelector(`.page-header .breadcrumbs`).before(s))}}function l(e){if(e.target.closest(`.responsive-close`)){o.responsiveShow=!1;return}if(!(e.target.closest(`.page-sidebar`)||e.target.closest(`.app-header`)||e.target.closest(`.modal`)))return e.preventDefault(),e.stopImmediatePropagation(),o.responsiveShow=!1,!1}return a.push(watch(()=>o.responsiveShow,e=>{e?window.addEventListener(`click`,l,!0):window.removeEventListener(`click`,l,!0)})),r=t.aside({pbEvent:`pageSidebar`,rid:i.rid,id:()=>i.id,hidden:()=>i.hidden,inert:()=>i.inert,className:()=>`page-sidebar ${i.className} ${o.responsiveShow?`active`:``}`,onmount:e=>{c(e),window.addEventListener(`resize`,c),i.onmount?.(e)},onunmount:e=>{i.onunmount?.(e),window.removeEventListener(`click`,l,!0),window.removeEventListener(`resize`,c),s?.remove(),a.forEach(e=>e?.unwatch())}},e=>{let n;return i.widthHistoryKey&&(n=localStorage.getItem(i.widthHistoryKey),n&&(e.style.width=n)),app.components.dragline({ondragstart:n=>{e._startWidth=e.offsetWidth},ondragging:(r,a,o)=>{n=e._startWidth+a+`px`,e.style.width=n,i.widthHistoryKey&&localStorage.setItem(i.widthHistoryKey,n)}})},...n),r};var P=`modulepreload`,nt=function(e,n){return new URL(e,n).href},rt={},F=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let e=document.getElementsByTagName(`link`),a=document.querySelector(`meta[property=csp-nonce]`),o=a?.nonce||a?.getAttribute(`nonce`);function s(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}i=s(n.map(n=>{if(n=nt(n,r),n in rt)return;rt[n]=!0;let i=n.endsWith(`.css`),a=i?`[rel="stylesheet"]`:``;if(r)for(let r=e.length-1;r>=0;r--){let a=e[r];if(a.href===n&&(!i||a.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${n}"]${a}`))return;let s=document.createElement(`link`);if(s.rel=i?`stylesheet`:P,i||(s.as=`script`),s.crossOrigin=``,s.href=n,o&&s.setAttribute(`nonce`,o),document.head.appendChild(s),i)return new Promise((e,r)=>{s.addEventListener(`load`,e),s.addEventListener(`error`,()=>r(Error(`Unable to preload CSS for ${n}`)))})}))}function a(e){let n=new Event(`vite:preloadError`,{cancelable:!0});if(n.payload=e,window.dispatchEvent(n),!n.defaultPrevented)throw e}return i.then(n=>{for(let e of n||[])e.status===`rejected`&&a(e.reason);return e().catch(a)})};window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openApiPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=it(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function it(e,n){if(!e){console.warn(`[apiPreviewModal] missing required collection`);return}let r,i=store({activeTab:`List/Search`,tabEl:null,isLoading:!1}),a={"List/Search":async e=>{let{docsList:n}=await F(async()=>{let{docsList:e}=await import(`./docsList-BAfVNUIM.js`);return{docsList:e}},__vite__mapDeps([0,1,2,3]),import.meta.url);return i.tabEl=n(e)},View:async e=>{let{docsView:n}=await F(async()=>{let{docsView:e}=await import(`./docsView-Be6Uhvcf.js`);return{docsView:e}},__vite__mapDeps([4,1,2]),import.meta.url);return i.tabEl=n(e)}};e.type!=`view`&&(a.Create=async e=>{let{docsCreate:n}=await F(async()=>{let{docsCreate:e}=await import(`./docsCreate-Be3S3y5K.js`);return{docsCreate:e}},__vite__mapDeps([5,1,2]),import.meta.url);return i.tabEl=n(e)},a.Update=async e=>{let{docsUpdate:n}=await F(async()=>{let{docsUpdate:e}=await import(`./docsUpdate-LtD8DbWI.js`);return{docsUpdate:e}},__vite__mapDeps([6,5,1,2]),import.meta.url);return i.tabEl=n(e)},a.Delete=async e=>{let{docsDelete:n}=await F(async()=>{let{docsDelete:e}=await import(`./docsDelete-CybOn5jy.js`);return{docsDelete:e}},[],import.meta.url);return i.tabEl=n(e)},a.Realtime=async e=>{let{docsRealtime:n}=await F(async()=>{let{docsRealtime:e}=await import(`./docsRealtime-PMESvmJN.js`);return{docsRealtime:e}},[],import.meta.url);return i.tabEl=n(e)},a.Batch=async e=>{let{docsBatch:n}=await F(async()=>{let{docsBatch:e}=await import(`./docsBatch-DNJl1NTn.js`);return{docsBatch:e}},[],import.meta.url);return i.tabEl=n(e)}),e.type==`auth`&&(a[``]=null,a[`List auth methods`]=async e=>{let{docsListAuthMethods:n}=await F(async()=>{let{docsListAuthMethods:e}=await import(`./docsListAuthMethods-9feSopQX.js`);return{docsListAuthMethods:e}},__vite__mapDeps([7,2]),import.meta.url);return i.tabEl=n(e)},a[`Auth with password`]=e.passwordAuth?.enabled?async e=>{let{docsAuthWithPassword:n}=await F(async()=>{let{docsAuthWithPassword:e}=await import(`./docsAuthWithPassword-DEWj8Jyn.js`);return{docsAuthWithPassword:e}},__vite__mapDeps([8,1,2]),import.meta.url);return i.tabEl=n(e)}:null,e.name!=`_superusers`&&(a[`Auth with OAuth2`]=e.oauth2?.enabled?async e=>{let{docsAuthWithOAuth2:n}=await F(async()=>{let{docsAuthWithOAuth2:e}=await import(`./docsAuthWithOAuth2-DUIE4EoY.js`);return{docsAuthWithOAuth2:e}},__vite__mapDeps([9,1,2]),import.meta.url);return i.tabEl=n(e)}:null),a[`Auth with OTP`]=e.otp?.enabled?async e=>{let{docsAuthWithOTP:n}=await F(async()=>{let{docsAuthWithOTP:e}=await import(`./docsAuthWithOTP-CJKph96j.js`);return{docsAuthWithOTP:e}},__vite__mapDeps([10,1,2]),import.meta.url);return i.tabEl=n(e)}:null,a[`Auth refresh`]=async e=>{let{docsAuthRefresh:n}=await F(async()=>{let{docsAuthRefresh:e}=await import(`./docsAuthRefresh-UjveHHwo.js`);return{docsAuthRefresh:e}},__vite__mapDeps([11,1,2]),import.meta.url);return i.tabEl=n(e)},e.name!=`_superusers`&&(a.Verification=async e=>{let{docsVerification:n}=await F(async()=>{let{docsVerification:e}=await import(`./docsVerification-B_Nb90xU.js`);return{docsVerification:e}},[],import.meta.url);return i.tabEl=n(e)}),a[`Password reset`]=async e=>{let{docsPasswordReset:n}=await F(async()=>{let{docsPasswordReset:e}=await import(`./docsPasswordReset-db1tMCuS.js`);return{docsPasswordReset:e}},[],import.meta.url);return i.tabEl=n(e)},a[`Email change`]=async e=>{let{docsEmailChange:n}=await F(async()=>{let{docsEmailChange:e}=await import(`./docsEmailChange-BgOZfOYE.js`);return{docsEmailChange:e}},[],import.meta.url);return i.tabEl=n(e)});let o=[watch(()=>i.activeTab,async()=>{i.isLoading=!0,await a[i.activeTab]?.(e),i.isLoading=!1})];return r=t.div({pbEvent:`apiPreviewModal`,className:`modal api-preview-modal`,onbeforeopen:e=>n.onbeforeopen?.(e),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),o.forEach(e=>e?.unwatch()),e?.remove()},onmount:e=>{},onunmount:e=>{o.forEach(e=>e?.unwatch())}},t.div({className:`modal-content`},t.aside({className:`api-preview-sidebar`},t.nav({className:`api-preview-nav`},()=>{let e=[];for(let n in a){if(!n){e.push(t.hr());continue}let r=!a[n];e.push(t.button({type:`button`,className:()=>`nav-item ${i.activeTab==n?`active`:``}`,disabled:r,ariaDescription:app.attrs.tooltip(()=>r?`Not enabled for the collection`:``,`left`),onclick:()=>{r||(i.activeTab=n)}},n))}return e})),t.div({className:()=>`api-preview-content ${i.isLoading?`faded`:``}`,scrollTop:()=>i.activeTab?0:null},t.header({className:`api-preview-content-header`},t.h6(null,()=>i.activeTab+` (${e.name})`),t.button({type:`button`,className:()=>`btn sm circle transparent secondary m-l-auto preview-close-btn ${i.isLoading?`loading`:``}`,title:`Close`,onclick:()=>app.modals.close(r)},t.i({className:`ri-close-line`,ariaHidden:!0}))),()=>i.tabEl))),r}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openMailTest=function(e=``,n=``){let r=at(e,n);document.body.appendChild(r),app.modals.open(r)};function at(e=``,n=``){let r=`mail_test_`+app.utils.randomString(),i=`pbLastTestEmail`,a=`email_test_request`,o=[{label:`Verification`,value:`verification`},{label:`Password reset`,value:`password-reset`},{label:`Confirm email change`,value:`email-change`},{label:`OTP`,value:`otp`},{label:`Login alert`,value:`login-alert`}],s=store({email:localStorage.getItem(i)||app.store.superuser?.email||``,template:n||o[0].value,isSending:!1,collectionIdOrName:e,get isAuthCollectionsLoading(){return app.store.isCollectionsLoading},get authCollections(){return app.utils.sortedCollections(app.store.collections.filter(e=>e.type==`auth`))},get canSubmit(){return!!s.email&&!!s.template&&!!s.collectionIdOrName}}),c;async function l(){if(!(s.isSending||!s.canSubmit)){s.isSending=!0,clearTimeout(c),c=setTimeout(()=>{s.isSending=!1,app.pb.cancelRequest(a),app.modals.close(),app.toasts.error(`Test email send timeout.`)},15e3);try{s.email!=app.pb.authStore.record?.email&&localStorage.setItem(i,s.email),await app.pb.settings.testEmail(s.collectionIdOrName,s.email,s.template,{requestKey:a}),app.toasts.success(`Successfully sent test email.`),app.modals.close()}catch(e){app.checkApiError(e)}s.isSending=!1,clearTimeout(c)}}let u=[];return t.div({className:`modal popup sm`,onbeforeopen:e=>{u.push(watch(()=>s.isAuthCollectionsLoading,e=>{!e&&!s.collectionIdOrName&&(s.collectionIdOrName=s.authCollections[0]?.id||``)}))},onafterclose:e=>{clearTimeout(c),e?.remove()},onunmount:()=>{clearTimeout(c),u.forEach(e=>e?.unwatch())}},t.header({className:`modal-header`},t.h5({className:`m-auto`},`Send test email`)),t.form({id:r,className:`modal-content mail-settings-test-form`,onsubmit:e=>{e.preventDefault(),l()}},t.div({className:`grid`},t.div({className:`col-lg-12`},()=>o.map((e,n)=>t.field({className:()=>`field ${n>0?`m-t-10`:``}`},t.input({type:`radio`,id:r+`.template.`+e.value,name:`template`,checked:()=>s.template==e.value,onchange:n=>s.template=e.value}),t.label({htmlFor:r+`.template.`+e.value},e.label||e.value)))),()=>{if(!e)return t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`.collection`},`Auth collection`),app.components.select({id:r+`.collection`,name:`collection`,required:!0,placeholder:()=>s.isAuthCollectionsLoading?`Loading auth collections...`:`Select auth collection`,options:()=>s.authCollections.map(e=>({value:e.id,label:e.name})),value:()=>s.collectionIdOrName||``,onchange:e=>{s.collectionIdOrName=e?.[0]?.value}})))},t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`.email`},`To email address`),t.input({id:r+`.email`,name:`email`,type:`email`,required:!0,value:()=>s.email||``,oninput:e=>s.email=e.target.value}))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(),disabled:()=>s.isSending},t.span({className:`txt`},`Close`)),t.button({"html-form":r,type:`submit`,className:()=>`btn expanded ${s.isSending?`loading`:``}`,disabled:()=>s.isSending||!s.canSubmit},t.i({className:`ri-mail-send-line`,ariaHidden:!0}),t.span({className:`txt`},`Send`))))}function ot(e={}){let n=store({rid:void 0,collectionA:null,collectionB:null,deleteMissing:!1,className:``}),r=app.utils.extendStore(n,e),i=store({hasAnyChange:!1,get isDeleteDiff(){return!n.collectionB?.id&&!n.collectionB?.name},get isCreateDiff(){return!i.isDeleteDiff&&!n.collectionA?.id},get hasAnyChange(){return app.utils.hasCollectionChanges(n.collectionA,n.collectionB,n.deleteMissing)},get fieldsListA(){return Array.isArray(n.collectionA?.fields)?n.collectionA?.fields:[]},get fieldsListB(){let e=Array.isArray(n.collectionB?.fields)?n.collectionB?.fields:[];return n.deleteMissing||(e=e.concat(n.collectionA?.fields?.filter(n=>!e.find(e=>n.id==e.id))||[])),e},get mainModelProps(){return app.utils.mergeUnique(Object.keys(n.collectionA||{}),Object.keys(n.collectionB||{})).filter(e=>![`fields`,`created`,`updated`].includes(e))},get removedFields(){return i.fieldsListA.filter(e=>!i.fieldsListB.find(n=>e.id==n.id))},get sharedFields(){return i.fieldsListB.filter(e=>i.fieldsListA.find(n=>n.id==e.id))},get addedFields(){return i.fieldsListB.filter(e=>!i.fieldsListA.find(n=>n.id==e.id))}});function a(e){return e===void 0?``:app.utils.isObject(e)?JSON.stringify(e,null,4):``+e}function o(e,n){return e===n?!1:JSON.stringify(e)!=JSON.stringify(n)}function s(e,n){return(e||[]).find(e=>e.id==n)}return t.div({rid:n.rid,pbEvent:`collectionsDiffTableWrapper`,className:()=>`collections-diff-table-wrapper ${n.className}`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},t.div({className:`collections-diff-table-title`},()=>n.collectionA?.id?n.collectionB?.id?[t.span({hidden:()=>!i.hasAnyChange,className:`label import-change-label warning`,textContent:`Changed`}),t.div({className:`inline-flex gap-5`},()=>{if(n.collectionA?.name!=n.collectionB?.name)return[t.strong({className:`txt-strikethrough txt-hint`,textContent:n.collectionA?.name}),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0})]},t.strong({textContent:()=>n.collectionB?.name}))]:[t.span({className:`label import-change-label danger`,textContent:`Deleted`}),t.strong({textContent:()=>n.collectionA?.name})]:[t.span({className:`label import-change-label success`,textContent:`Added`}),t.strong({textContent:()=>n.collectionB?.name})]),t.table({className:`collections-diff-table`},t.thead(null,t.tr(null,t.th({className:`min-width`},`Props`),t.th({width:`40%`},`Old`),t.th({width:`40%`},`New`))),t.tbody(null,()=>i.mainModelProps.map(e=>{let r=o(n.collectionA?.[e],n.collectionB?.[e]);return t.tr({className:r?`txt-primary`:``},t.td({className:`min-width`},e),t.td({className:()=>i.isCreateDiff?`changed-non-col`:r?`changed-old-col`:``},t.pre({className:`txt diff-value`},a(n.collectionA?.[e]))),t.td({className:()=>i.isDeleteDiff?`changed-non-col`:r?`changed-new-col`:``},t.pre({className:`txt diff-value`},a(n.collectionB?.[e]))))}),()=>{if(!n.deleteMissing&&!i.isDeleteDiff)return;let e=[];for(let n of i.removedFields){e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label danger m-l-5`},`Deleted - `,t.small(null,`All stored data related to '${n.name}' will be deleted!`)))));for(let r in n){let i=n[r];e.push(t.tr(null,t.td({className:`min-width field-key-col`},r),t.td({className:`changed-old-col`},t.pre({className:`txt`},a(i))),t.td({className:`changed-none-col`})))}}return e},()=>{let e=[];for(let n of i.sharedFields){let r=s(i.fieldsListA,n.id),c=o(r,s(i.fieldsListB,n.id));e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label warning m-l-5 ${c?``:`hidden`}`,textContent:`Changed`}))));for(let i in n){let s=n[i],c=o(r?.[i],s);e.push(t.tr({className:c?`txt-primary`:``},t.td({className:`min-width field-key-col`},i),t.td({className:c?`changed-old-col`:``},t.pre({className:`txt`},a(r?.[i]))),t.td({className:c?`changed-new-col`:``},t.pre({className:`txt`},a(s)))))}}return e},()=>{let e=[];for(let n of i.addedFields){e.push(t.tr(null,t.th({className:`min-width`,colSpan:3},t.span({className:`txt`},`field: `,n.name),t.span({className:`label success m-l-5`},`Added`))));for(let r in n){let i=n[r];e.push(t.tr({className:`txt-primary`},t.td({className:`min-width field-key-col`},r),t.td({className:`changed-none-col`}),t.td({className:`changed-new-col`},t.pre({className:`txt`},a(i)))))}}return e})))}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openImportCollectionsReview=function(e,n,r={deleteMissing:!1,onsubmit:null}){let i=st(e,n,r);i&&(document.body.appendChild(i),app.modals.open(i))};function st(e,n,r){let i,a=store({deleteMissing:!1,onsubmit:function(e){}}),o=app.utils.extendStore(a,r),s=store({isImporting:!1,pairs:[]});function c(){let r=[];for(let i of e){let e=n.find(e=>e.id==i.id);(a.deleteMissing&&!e?.id||e?.id&&app.utils.hasCollectionChanges(i,e,a.deleteMissing))&&r.push({old:i,new:e})}for(let i of n){let n=e.find(e=>e.id==i.id);n?.id||r.push({old:n,new:i})}s.pairs=r}function l(){let r=[];if(a.deleteMissing)for(let i of e){let e=n.find(e=>e.id==i.id);if(!e)r.push(i.name+`.*`);else{let n=Array.isArray(i.fields)?i.fields:[];for(let a of n)e.fields.find(e=>e.id==a.id)||r.push(`${i.name}.${a.name} (${a.id})`)}}r.length?app.modals.confirm([t.h6(null,`Do you really want to delete the following collection fields and their related records data:`),t.ul(null,()=>r.map(e=>t.li(null,e)))],()=>u()):u()}async function u(){if(!s.isImporting){s.isImporting=!0;try{await app.pb.collections.import(n,a.deleteMissing),await app.store.loadCollections(),a.onsubmit?.(JSON.parse(JSON.stringify(app.store.collections))),app.toasts.success(`Successfully imported collections configuration.`)}catch(e){app.checkApiError(e)}s.isImporting=!1,app.modals.close(i)}}return i=t.div({pbEvent:`importCollectionsReviewModal`,className:`modal popup full import-collections-review-modal`,onbeforeopen:()=>{c()},onbeforeclose:()=>!s.isImporting,onafterclose:e=>{e?.remove()},onunmount:()=>{o.forEach(e=>e?.unwatch())}},t.header({className:`modal-header`},t.h5(null,`Side-by-side diff`)),t.div({className:`modal-content`},()=>s.pairs.map(e=>ot({collectionA:e.old,collectionB:e.new,deleteMissing:a.deleteMissing}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,disabled:()=>s.isImporting,onclick:()=>app.modals.close(i)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:()=>`btn expanded ${s.isImporting?`loading`:``}`,disabled:()=>s.isImporting,onclick:()=>l()},t.span({className:`txt`},`Confirm and import`)))),i}window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.recordSummary=function(e,n=null){let r=store({get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)},get presentableFields(){if(!r.collection?.id)return[];let e=r.collection.fields.filter(e=>e.presentable).sort((e,n)=>{let r=app.fieldTypes[e.type].summaryPriority||0,i=app.fieldTypes[n.type].summaryPriority||0;return r>i?1:re.name==n);if(i){e.push(i);break}}return e}});return t.div({className:`label record-summary`},t.i({ariaHidden:!0,className:`ri-eye-line link-hint record-preview-icon`,onclick:e=>{e.stopImmediatePropagation(),e.preventDefault()},onmouseenter:n=>{lt(n.target,e,100)},onmouseleave:e=>{ct(e.target,100)},onunmount:e=>{ct(e,0)}}),()=>{let i=[];function a(e){(e==null||e==``)&&(e=t.span({className:`missing-value`})),i.push(e)}for(let i of r.presentableFields){let r=app.fieldTypes[i.type]?.view;if(r)a(r({short:!0,get record(){return e},get field(){return i},get meta(){return n}}));else{let n=app.utils.toArray(e[i.name]).splice(0,3);for(let e of n)a(e)}}return i})};function ct(e,n=150){if(e){if(clearTimeout(e._summaryDropdownTimeoutId),n<=0){e?._summaryDropdown?.hidePopover?.();return}e._summaryDropdownTimeoutId=setTimeout(()=>{e?._summaryDropdown?.hidePopover?.()},n)}}function lt(e,n,r=150){if(e){if(clearTimeout(e._summaryDropdownTimeoutId),r<=0){ut(e,n);return}e._summaryDropdownTimeoutId=setTimeout(()=>{ut(e,n)},r)}}var ut=function(e,n){e&&(e._summaryDropdown||(e._summaryDropdown=t.div({className:`dropdown record-summary-dropdown`,popover:`manual`,onclick:e=>{e.stopImmediatePropagation(),e.preventDefault()}},t.div({className:`record-header`},t.a({className:`link-hint txt-bold m-r-auto`,target:`_blank`,href:`#/collections?collection=${n.collectionName}&record=${n.id}`,onclick:e=>{e.stopImmediatePropagation()}},t.span({className:`txt`},`Edit relation record`),t.i({className:`ri-external-link-line`,ariaHidden:!0})),t.button({type:`button`,className:`link-hint`,title:`Close`,onclick:()=>ct(e,0)},t.i({className:`ri-close-line`,ariaHidden:!0}))),t.hr(),t.pre({className:`record-json`},()=>{let e=app.store.collections.find(e=>e.id==n.collectionId||e.name==n.collectionName)?.fields||[];if(!e.length)return;let r={collectionId:n.collectionId,collectionName:n.collectionName};for(let i of e)r[i.name]=n[i.name];return JSON.stringify(app.utils.truncateObject(r,27),null,2)})),e.appendChild(e._summaryDropdown)),e._summaryDropdown?.showPopover({source:e}))};window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.recordsSearchbar=function(e={}){let n=store({rid:void 0,id:void 0,hidden:void 0,inert:void 0,disabled:void 0,value:``,className:``,collection:void 0,onsubmit:e=>{}}),r=app.utils.extendStore(n,e);return t.div({rid:n.rid,id:()=>n.id,hidden:()=>n.hidden,inert:()=>n.inert,className:()=>`full-width records-searchbar-wrapper ${n.className}`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},app.components.searchbar({placeholder:()=>!n.disabled&&!n.collection?.id?`Loading...`:`Search term or filter...`,historyKey:()=>`pbRecordsSearchHistory_`+n.collection?.id,disabled:()=>n.disabled||!n.collection,value:()=>n.value,autocomplete:e=>app.utils.collectionAutocompleteKeys(n.collection,e,{requestKeys:!1,collectionJoinKeys:!1}),onsubmit:n.onsubmit}))},window.app=window.app||{},window.app.components=window.app.components||{};var dt={max:10,pending:new Set,processing:new Set};function ft(e){return dt.pending.add(e),dt.processing.size<=dt.max&&pt(),()=>{dt.pending.delete(e),dt.processing.delete(e),dt.processing.sizen.id,hidden:()=>n.hidden,inert:()=>n.inert,type:`button`,draggable:!1,className:()=>`thumb ${n.extraClasses} ${i.isPreviewLoading?`loading`:``}`,title:()=>(i.hasPreview?`Preview`:`Download`)+` `+n.filename,onclick:async e=>{e.stopPropagation();async function r(){let e=await app.getFileToken(n.record.collectionId);return app.pb.files.getURL(n.record,n.filename,{token:e})}if(i.hasPreview)app.modals.openFilePreview(r);else{let e=await r();app.utils.download(e,n.filename)}},onunmount:()=>{r.forEach(e=>e?.unwatch())}},()=>{if(i.fileType==`image`){let e=t.img({draggable:!1,alt:()=>`Thumb of `+n.filename,src:()=>i.previewURL,onerror:n=>{console.warn(`[recordFileThumb] load err:`,n),i.isPreviewLoading=!1,e?._semaphoreRelease?.()},onload:()=>{i.isPreviewLoading=!1,e?._semaphoreRelease?.()},onmount:e=>{i.isPreviewLoading=!0,e._semaphoreRelease=ft(async()=>{try{i.previewToken=await app.getFileToken(n.record.collectionId),i.previewURL=app.pb.files.getURL(n.record,n.filename,{thumb:`100x100`,token:i.previewToken})}catch(e){console.warn(e)}})},onunmount:e=>{i.isPreviewLoading=!1,e._semaphoreRelease?.()}});return e}return t.i({className:app.utils.fileTypeIcons[i.fileType]||`ri-file-line`,ariaHidden:!0})})},window.app=window.app||{},window.app.modals=window.app.modals||{};var mt=100,ht={btnText:`Insert`,fileTypes:[],onselect:function(e){}},gt=`pbLastRecordFilePickerCollection`,_t=`listFilePickerRecords`;window.app.modals.openRecordFilePicker=function(e={}){e=Object.assign({},ht,e);let n=vt(e);document.body.appendChild(n),app.modals.open(n)};function vt(e=ht){let n,r=`file_picker_`+app.utils.randomString(),i=store({selectedFile:{},records:[],activeCollectionId:``,searchTerm:``,lastRecordsPage:1,lastTotalRecords:0,isLoadingRecords:!1,get collections(){return app.utils.sortedCollections(app.store.collections.filter(e=>e.type==`view`?!1:!!e.fields?.find(e=>e.type===`file`&&!e.protected)))},get activeCollection(){return i.collections.find(e=>e.id==i.activeCollectionId)||i.collections[0]},get activeCollectionFileFields(){return i.activeCollection?.fields?.filter(e=>e.type===`file`&&!e.protected)||[]},get isLoading(){return app.store.isLoadingCollections||i.isLoadingRecords},get canLoadMore(){return!i.isLoadingRecords&&i.lastTotalRecords==mt},get hasAtleastOneFile(){return!!i.records.find(e=>c(e).length>0)}}),a=[];a.push(watch(()=>{i.activeCollectionId?(window.localStorage.setItem(gt,i.activeCollectionId),i.searchTerm=``):i.activeCollectionId=window.localStorage.getItem(gt)})),a.push(watch(()=>[i.activeCollection,i.searchTerm],()=>s(!0)));function o(){app.pb.cancelRequest(_t),i.isLoadingRecords=!1,i.records=[],i.lastTotalRecords=0,i.lastRecordsPage=1,i.selectedFile={}}async function s(e=!1){if(!i.activeCollection){o();return}e&&o(),i.isLoadingRecords=!0;try{let n=e?1:i.lastRecordsPage+1,r=app.utils.getAllCollectionIdentifiers(i.activeCollection),a=app.utils.normalizeSearchFilter(i.searchTerm,r)||``;a&&(a+=` && `),a+=`(`+i.activeCollectionFileFields.map(e=>`${e.name}:length>0`).join(`||`)+`)`;let o=await app.pb.collection(i.activeCollection.id).getList(n,mt,{requestKey:_t,filter:a,skipTotal:1,sort:i.activeCollection.type==`view`?``:`-@rowid`});i.lastRecordsPage=o.page,i.lastTotalRecords=o.items.length,i.records=app.utils.filterDuplicatesByKey(i.records.concat(o.items)),i.isLoadingRecords=!1}catch(e){e.isAbort||(i.isLoadingRecords=!1,app.checkApiError(e))}}function c(n){let r=[];for(let a of i.activeCollectionFileFields){let i=app.utils.toArray(n[a.name]);for(let n of i)(app.utils.isEmpty(e.fileTypes)||e.fileTypes?.includes(app.utils.getFileType(n)))&&r.push(n)}return r}function l(e,n){i.selectedFile={record:e,name:n,thumb:``}}function u(e,n){return i.selectedFile?.name==n&&i.selectedFile?.record?.id==e?.id}let d={"record:create":e=>{e.detail.collectionId==i.activeCollection?.id&&(i.selectedFile?.record?.id==e.detail.id&&(i.selectedFile.record=e.detail),s(!0))},"record:delete":e=>{e.detail.collectionId!=i.activeCollection?.id&&e.detail.collectionName!=i.activeCollection?.name||(i.selectedFile?.record?.id==e.detail.id&&(i.selectedFile={}),s(!0))}};return n=t.div({className:`modal popup record-file-picker-modal`,onafterclose:e=>{e?.remove()},onmount:e=>{for(let e in d)document.addEventListener(e,d[e])},onunmount:e=>{a.forEach(e=>e?.unwatch());for(let e in d)document.removeEventListener(e,d[e])}},t.header({className:`modal-header`},t.button({className:()=>`btn primary outline record-file-picker-collection-select-btn ${app.store.isLoadingCollections?`loading`:``}`,disabled:()=>app.store.isLoadingCollections,"html-popovertarget":`collections_dropdown`+r},t.span({className:`txt-lg collection-name m-r-auto`},()=>i.activeCollection?.name||`Select collection`),t.i({className:`ri-arrow-drop-down-line`,ariaHidden:!0})),t.div({id:`collections_dropdown`+r,className:`dropdown`,popover:`hint`},()=>i.collections.map(e=>t.button({type:`button`,className:()=>`dropdown-item ${i.activeCollectionId==e.id?`active`:``}`,onclick:n=>{i.activeCollectionId=e.id,n.target?.closest(`.dropdown`)?.hidePopover()}},e.name))),app.components.recordsSearchbar({disabled:()=>!i.activeCollection?.id,collection:()=>i.activeCollection,value:()=>i.searchTerm,onsubmit:e=>i.searchTerm=e}),t.button({type:`button`,className:`btn circle transparent`,ariaLabel:app.attrs.tooltip(`Add new record`),onclick:()=>app.modals.openRecordUpsert(i.activeCollection)},t.i({className:`ri-add-line txt-hint`,ariaHidden:!0}))),t.div({className:`modal-content`},t.div({className:`block txt-center`,hidden:()=>i.hasAtleastOneFile||!i.isLoading},t.span({className:`loader`})),t.div({className:`record-file-picker-list`},()=>{let e=[];for(let n of i.records){let r=c(n);for(let i of r)e.push(t.button({rid:n.id+`:`+i,className:()=>`list-item thumb ${u(n,i)?`success`:``}`,ariaDescription:app.attrs.tooltip(i,`bottom`),onclick:()=>l(n,i)},()=>{if(app.utils.hasImageExtension(i))return t.img({loading:`lazy`,src:app.pb.files.getURL(n,i,{thumb:`100x100`}),alt:i});let e=app.utils.getFileType(i);return t.i({className:app.utils.fileTypeIcons[e]||`ri-file-line`,ariaHidden:!0})}))}return e}),t.div({hidden:()=>!i.canLoadMore||!i.hasAtleastOneFile,className:`block txt-center`},t.button({className:()=>`btn secondary expanded-lg m-t-base ${i.isLoadingRecords?`loading`:``}`,disabled:()=>i.isLoadingRecords,onclick:()=>s()},t.span({className:`txt`},`Load more`))),t.div({className:`block txt-center txt-hint p-t-10 p-b-10`,hidden:()=>i.hasAtleastOneFile||i.isLoading},()=>app.utils.isEmpty(e.fileTypes)?t.p(null,`No records with selectable files found.`):t.p(null,`No "${e.fileTypes.join(`", "`)}" files found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,hidden:()=>!i.searchTerm?.length,onclick:()=>{i.searchTerm=``}}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Close`)),()=>{if(!i.selectedFile?.name||!app.utils.hasImageExtension(i.selectedFile.name))return;let e=[{value:``,label:`Original size`},{value:`100x100`,label:`100x100 thumb`}],n=i.activeCollectionFileFields.find(e=>i.selectedFile.record[e.name].includes(i.selectedFile.name)),r=app.utils.toArray(n.thumbs);for(let n of r)e.push({value:n,label:`${n} thumb`});return t.div({className:`record-file-picker-thumb-select`},app.components.select({required:!0,value:i.selectedFile.thumb||``,options:e,onchange:e=>{i.selectedFile.thumb=e?.[0].value}}))},t.button({type:`button`,className:`btn expanded`,disabled:()=>i.isLoading||!i.selectedFile?.name,onclick:()=>{let r=JSON.parse(JSON.stringify(i.selectedFile));if(e.onselect&&e.onselect(r)===!1)return!1;app.modals.close(n)}},t.span({className:`txt`},()=>e.btnText||ht.btnText)))),n}window.app=window.app||{},window.app.modals=window.app.modals||{};var yt=50,bt=100,xt=`listRelationPickerRecords`,St={collection:``,selectedIds:[],maxSelect:1,btnText:`Set selection`,onselect:function(e){}};window.app.modals.openRecordsPicker=function(e={}){e=Object.assign({},St,e);let n=Ct(e);document.body.appendChild(n),app.modals.open(n)};function Ct(e=St){let n,r=store({searchTerm:``,selected:[],preselected:[],isLoadingPreselected:!1,records:[],isLoadingRecords:!1,lastRecordsPage:1,lastRecordsTotal:0,get collection(){let n=e.collection;return typeof e.collection==`object`&&e.collection?.id&&(n=e.collection?.id),app.store.collections.find(e=>e.id==n||e.name==n)},get isLoading(){return r.isLoadingPreselected||r.isLoadingRecords},get canLoadMore(){return!r.isLoadingRecords&&r.lastRecordsTotal==yt}}),i=[watch(()=>[e.collection,e.selectedIds],()=>{o()}),watch(()=>[r.collection,r.searchTerm],()=>{s(!0)})];function a(){setTimeout(()=>app.modals.close(n),0)}async function o(){let n=app.utils.toArray(e.selectedIds),i=e.collection?.id||e.collection;if(!i||!n.length)return;r.isLoadingSelected=!0;let a=[],o=n.slice(),s=[];for(;o.length>0;){let e=[],n=o.splice(0,bt);for(let r of n)e.push(`id="${r}"`);s.push(app.pb.collection(i).getFullList({requestKey:null,filter:e.join(`||`)}))}try{await Promise.all(s).then(e=>{a=a.concat(...e)});let e=[];for(let r of n){let n=a.find(e=>e.id==r);n&&e.push(n)}r.searchTerm.trim()||(r.records=app.utils.filterDuplicatesByKey(e.concat(r.records))),r.selected=e,r.isLoadingSelected=!1}catch(e){e.isAbort||(app.checkApiError(e),r.isLoadingSelected=!1)}}async function s(e=!1){if(r.collection?.id){e&&(c(),r.searchTerm.trim()||(r.records=r.selected.slice())),r.isLoadingRecords=!0;try{let n=e?1:r.lastRecordsPage+1,i=app.utils.getAllCollectionIdentifiers(r.collection),a=app.utils.normalizeSearchFilter(r.searchTerm,i)||``,o=await app.pb.collection(r.collection.id).getList(n,yt,{requestKey:xt,filter:a,skipTotal:1,sort:r.collection.type==`view`?``:`-@rowid`});r.lastRecordsPage=o.page,r.lastRecordsTotal=o.items.length,r.records=app.utils.filterDuplicatesByKey(r.records.concat(o.items)),r.isLoadingRecords=!1}catch(e){e.isAbort||(r.isLoadingRecords=!1,app.checkApiError(e))}}}function c(){app.pb.cancelRequest(xt),r.isLoadingRecords=!1,r.records=[],r.lastTotalRecords=0,r.lastRecordsPage=1}function l(e){e.target.scrollHeight-e.target.clientHeight-e.target.scrollTop<=100&&r.canLoadMore&&s()}function u(n){let i=r.selected.findIndex(e=>e.id==n.id);if(i>=0)r.selected.splice(i,1);else{let i=e.maxSelect||1,a=r.selected.length-i;for(;a>=0;)r.selected.pop(),a--;r.selected.push(n)}}function d(e){return r.selected.findIndex(n=>n.id==e.id)>=0}let f={"record:save":e=>{if(e.detail.collectionId!=r.collection?.id)return;let n=r.selected?.findIndex(n=>n.id==e.detail.id);n>=0&&(r.selected[n]=e.detail),app.utils.pushOrReplaceObject(r.records,e.detail),s(!0)},"record:delete":e=>{e.detail.collectionId!=r.collection?.id&&e.detail.collectionName!=r.collection?.name||(d(e.detail)&&u(e.detail),app.utils.removeByKey(r.records,`id`,e.detail.id),s(!0))}};return n=t.div({className:`modal popup lg records-picker-modal`,onafterclose:e=>{e.remove()},onmount:e=>{for(let e in f)document.addEventListener(e,f[e])},onunmount:e=>{i.forEach(e=>e?.unwatch());for(let e in f)document.removeEventListener(e,f[e])}},t.header({className:`modal-header`},t.h6({className:`collection-name`},()=>r.collection.name),app.components.recordsSearchbar({disabled:()=>!r.collection?.id,collection:()=>r.collection,value:()=>r.searchTerm,onsubmit:e=>r.searchTerm=e}),t.button({type:`button`,className:`btn circle transparent`,ariaLabel:app.attrs.tooltip(`Add new record`),onclick:()=>{app.modals.openRecordUpsert(r.collection)}},t.i({className:`ri-add-line txt-hint`,ariaHidden:!0}))),t.div({className:`modal-content`,hidden:()=>r.isLoadingCollection},t.div({className:`list records-picker-list`,onscroll:l,onresize:l},()=>r.records.map(e=>t.div({tabIndex:0,className:`list-item handle`,onclick:()=>{u(e),document.activeElement?.blur()}},t.div({className:`content`},t.span({className:`state-icon`},t.i({ariaHidden:!0,className:()=>d(e)?`ri-checkbox-circle-fill txt-success`:`ri-checkbox-blank-circle-line txt-disabled`})),()=>app.components.recordSummary(e)),t.div({className:`actions autohide`},t.button({className:`btn sm secondary transparent circle`,ariaLabel:app.attrs.tooltip(`Edit`),onclick:n=>{n.stopPropagation(),app.modals.openRecordUpsert(r.collection,e)}},t.i({className:`ri-pencil-line`,ariaHidden:!0}))))),t.div({className:`list-item`,hidden:()=>!r.isLoading},t.div({className:`skeleton-loader`})),t.div({className:`list-item`,hidden:()=>r.records.length||r.isLoading},t.div({className:`content txt-hint`},t.span({className:`txt`},`No records found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,hidden:()=>!r.searchTerm.trim().length,onclick:()=>{r.searchTerm=``}})))),t.div({className:`block m-t-base`},t.p({className:`txt-bold`},()=>`Selected (${r.selected.length} of max ${e.maxSelect||1})`),t.span({className:`txt-hint`,hidden:()=>r.selected},`No selected records.`),app.components.sortable({className:`records-picker-selected-list`,data:()=>r.selected,dataItem:(e,n)=>t.div({rid:e,className:`label handle`},()=>app.components.recordSummary(e,[],!0),t.span({className:`link-hint`,title:`Remove`,role:`button`,onclick:()=>u(e)},t.i({className:`ri-close-line`,ariaHidden:!0}))),onchange:(e,n,i)=>{r.selected=e}}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>a()},t.span({className:`txt`},`Close`)),()=>{if(!r.selectedFile?.name||!app.utils.hasImageExtension(r.selectedFile.name))return;let e=[{value:``,label:`Original size`},{value:`100x100`,label:`100x100 thumb`}],n=r.activeCollectionFileFields.find(e=>r.selectedFile.record[e.name].includes(r.selectedFile.name)),i=app.utils.toArray(n.thumbs);for(let n of i)e.push({value:n,label:`${n} thumb`});return t.div({className:`record-file-picker-thumb-select`},app.components.select({required:!0,value:r.selectedFile.thumb||``,options:e,onchange:e=>{r.selectedFile.thumb=e?.[0].value}}))},t.button({type:`button`,className:`btn expanded`,disabled:()=>r.isLoadingCollection,onclick:()=>{let n=JSON.parse(JSON.stringify(r.selected));if(e.onselect&&e.onselect(n)===!1)return!1;a()}},t.span({className:`txt`},e.btnText||St.btnText)))),n}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openRecordPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=I(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function wt(e){e.expand&&(e=Object.assign({},e),delete e.expand),app.utils.downloadJSON(e,e.collectionName+`_`+e.id+`.json`)}function Tt(e){e.expand&&(e=Object.assign({},e),delete e.expand),app.utils.copyToClipboard(JSON.stringify(e,null,2)),app.toasts.success(`Record copied to clipboard!`)}function I(e,n){if(!e?.id){app.toasts.error(`Failed to load record.`),console.warn(`[recordPreviewModal] missing required record id field:`,e);return}if(!e.collectionId&&!e.collectionName){app.toasts.error(`Failed to load record.`),console.warn(`[recordPreviewModal] missing required collectionId or collectionName field:`,e);return}let r,i=app.utils.randomString(),a=store({isLoading:!1,record:null,get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)}});async function o(){a.isLoading=!0;try{a.record=JSON.parse(JSON.stringify(e));let n=[],r=a.collection?.fields?.filter(e=>!e.hidden&&e.type==`relation`)||[];for(let e of r)n.push(e.name);let i=await app.pb.collection(e.collectionName||e.collectionId).getOne(e.id,{requestKey:`record_preview_`+e.id,expand:n.join(`,`)||void 0});Object.assign(a.record,i),a.isLoading=!1}catch(e){e?.isAbort||(a.isLoading=!1,app.checkApiError(e),setTimeout(()=>app.modals.close(r),0))}}return r=t.div({pbEvent:`recordPreviewModal`,className:`modal record-preview-modal`,onbeforeopen:e=>(o(),n.onbeforeopen?.(e)),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()}},t.header({className:`modal-header`},t.h6(null,t.strong(null,()=>e?.collectionName||a.collection?.name),` record preview`),t.button({title:`More options`,className:()=>`btn sm circle transparent m-l-auto ${a.isLoading?`loading`:``}`,disabled:()=>a.isLoading,"html-popovertarget":i+`preview-dropdown`},t.i({className:`ri-more-line`,ariaHidden:!0})),t.div({id:i+`preview-dropdown`,className:`dropdown`,popover:`auto`},e=>t.button({className:`dropdown-item`,onclick:()=>{Tt(a.record),e.hidePopover()}},t.i({className:`ri-braces-line`,ariaHidden:!0}),t.span({className:`txt`},`Copy JSON`)))),t.div({className:`modal-content`},t.table({pbEvent:`recordPreviewTable`,className:`record-preview-table responsive-table`},t.tbody(null,()=>(a.collection?.fields?.filter(e=>e.type!=`password`)||[]).map(e=>t.tr(null,t.th({className:()=>`min-width p-r-0 col-field-name-${e.name}`},e.name),t.td({className:()=>`col-field-name-${e.name}`},()=>app.fieldTypes[e.type]?.view?app.fieldTypes[e.type].view({short:!1,get record(){return a.record},get field(){return e}}):app.utils.displayValue(a.record[e.name],1e3))))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:()=>`btn ${a.isLoading?`loading`:``}`,disabled:()=>a.isLoading,onclick:()=>wt(a.record)},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download JSON`)))),r}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openRecordImpersontate=function(e){let n=R(e);document.body.appendChild(n),app.modals.open(n)};function R(e){let n=`impersonate_`+app.utils.randomString(),r=store({isLoading:!1,token:``,duration:0,get collection(){return app.store.collections.find(n=>n.id==e.collectionId||n.name==e.collectionName)}}),i=app.utils.getApiExampleURL();async function a(){if(!r.isLoading){r.isLoading=!0;try{r.token=(await app.pb.collection(r.collection.name).impersonate(e.id,r.duration)).authStore.token}catch(e){app.checkApiError(e)}r.isLoading=!1}}function o(){r.token=``,r.duration=0}return t.div({className:`modal popup record-impersonate-auth-modal`,onbeforeclose:()=>!r.isLoading,onafterclose:e=>{e?.remove()}},t.header({className:`modal-header`},t.h6(null,`Generate nonrenewable auth token for `,t.strong(null,()=>e.email||e.id))),t.div({className:`modal-content`},t.form({id:n+`_form`,hidden:()=>r.token,className:`block`,onsubmit:e=>{e.preventDefault(),a()}},t.div({className:`field`},t.label({htmlFor:n+`_duration`},`Token duration (in seconds)`),t.input({id:n+`_duration`,type:`number`,name:`duration`,min:0,step:1,placeholder:()=>`Default to the collection settings (${r.collection?.authToken?.duration||0}s)`,value:e=>r.duration||``,oninput:e=>r.duration=parseInt(e.target.value,10)}))),t.div({hidden:()=>!r.token,className:`alert success impersonate-success`},t.strong(null,()=>r.token),` `,app.components.copyButton(()=>r.token)),app.components.codeBlockTabs({hidden:()=>!r.token,className:`sdk-examples m-t-base`,tabs:[{title:`JS SDK`,language:`js`,value:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${i}'); diff --git a/ui/dist/index.html b/ui/dist/index.html index 71788d24..f3a4bf0a 100644 --- a/ui/dist/index.html +++ b/ui/dist/index.html @@ -13,7 +13,7 @@ - + diff --git a/ui/src/apiPreview/docsAuthWithOTP.js b/ui/src/apiPreview/docsAuthWithOTP.js index ff609921..0569a9d9 100644 --- a/ui/src/apiPreview/docsAuthWithOTP.js +++ b/ui/src/apiPreview/docsAuthWithOTP.js @@ -20,6 +20,10 @@ export function docsAuthWithOTP(collection) { }, // description t.p(null, "Authenticate with an one-time/short-lived password (OTP)."), + t.p( + null, + "On successful authentication the user will be also marked as verified (if the OTP source is email and the user is not verified already).", + ), t.p( null, "Note that when requesting an OTP we return an ", diff --git a/ui/src/apiPreview/docsEmailChange.js b/ui/src/apiPreview/docsEmailChange.js index 466675c1..13e93669 100644 --- a/ui/src/apiPreview/docsEmailChange.js +++ b/ui/src/apiPreview/docsEmailChange.js @@ -19,7 +19,7 @@ export function docsEmailChange(collection) { t.p(null, `Sends ${collection.name} email change request.`), t.p( null, - "On successful email change all previously issued auth tokens for the specific record will be automatically invalidated.", + "On successful email change all previously issued auth tokens for the specific record will be invalidated (and the user will be marked as verified if not already).", ), app.components.codeBlockTabs({ className: "sdk-examples m-t-sm", @@ -46,7 +46,8 @@ export function docsEmailChange(collection) { // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${collection.name}').confirmEmailChange( 'EMAIL_CHANGE_TOKEN', 'YOUR_PASSWORD', @@ -83,7 +84,8 @@ export function docsEmailChange(collection) { // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${collection.name}').confirmEmailChange( 'EMAIL_CHANGE_TOKEN', 'YOUR_PASSWORD', @@ -111,6 +113,9 @@ export function docsEmailChange(collection) { '${baseURL}/api/collections/${collection.name}/request-email-change' # Confirm email change + # + # note: all previous user auth tokens will be invalidated + # (and the user will be marked as verified if not already) curl -X POST \\ -H 'Content-Type:application/json' \\ -d '{ "token":"...", "password":"" }' \\ diff --git a/ui/src/apiPreview/docsPasswordReset.js b/ui/src/apiPreview/docsPasswordReset.js index ce65f43c..920657ab 100644 --- a/ui/src/apiPreview/docsPasswordReset.js +++ b/ui/src/apiPreview/docsPasswordReset.js @@ -19,7 +19,7 @@ export function docsPasswordReset(collection) { t.p(null, `Sends ${collection.name} password reset email request.`), t.p( null, - "On successful password reset all previously issued auth tokens for the specific record will be automatically invalidated.", + "On successful password reset all previously issued auth tokens for the specific record will be invalidated (and the user will be marked as verified if not already).", ), app.components.codeBlockTabs({ className: "sdk-examples m-t-sm", @@ -41,7 +41,8 @@ export function docsPasswordReset(collection) { // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${collection.name}').confirmPasswordReset( 'RESET_TOKEN', 'NEW_PASSWORD', @@ -74,7 +75,8 @@ export function docsPasswordReset(collection) { // (optional) in your custom confirmation page: // --- - // note: after this call all previously issued auth tokens are invalidated + // note: all previous user auth tokens will be invalidated + // (and the user will be marked as verified if not already) await pb.collection('${collection.name}').confirmPasswordReset( 'RESET_TOKEN', 'NEW_PASSWORD', @@ -102,6 +104,9 @@ export function docsPasswordReset(collection) { '${baseURL}/api/collections/${collection.name}/request-password-reset' # Confirm password reset + # + # note: all previous user auth tokens will be invalidated + # (and the user will be marked as verified if not already) curl -X POST \\ -H 'Content-Type:application/json' \\ -d '{ "token":"...", "password":"", "passwordConfirm":"" }' \\