"use strict";(globalThis.webpackChunknotion_next=globalThis.webpackChunknotion_next||[]).push([[47384],{161179:(e,t,r)=>{function n(e){if(e instanceof Error)return e;if("string"==typeof e)try{e=JSON.parse(e)}catch{}return"object"==typeof e&&null!==e?Object.assign(Error("Expected error, but caught non-error object"),e):"string"==typeof e?Object.assign(Error(e),{cause:e}):Object.assign(Error(`Expected error, but caught \`${String(e)}\` (${typeof e})`),{cause:e})}r.d(t,{A:()=>n}),r(16280)},446130:(e,t,r)=>{function n(e){switch(e){case"TEXT":case"NUMERIC":case"INTEGER":case"REAL":case"BLOB":return!0;default:return!1}}function a(e){return"Error"===e.type||"ErrorBefore"===e.type||"PreconditionFailed"===e.type||"OutOfSpace"===e.type||"SharedWorkerFailedToDelegate"===e.type}function i(e){return e}r.d(t,{Ll:()=>a,Xb:()=>i,tx:()=>n})},573146:(e,t,r)=>{var n;let a,i,s;function o(e,t){for(let r of t)e.push(r)}r.d(t,{F4:()=>E}),r(16280),r(581454),r(944114),r(517642),r(658004),r(733853),r(845876),r(432475),r(515024),r(731698),r(898992),r(803949);let l=Symbol("QueryArg");class p{constructor(e){this.value=e}}let u=new Set(["IS NULL","IS NOT NULL","IS TRUE","IS FALSE","=","!=","<","<=",">",">=","IS","IN","NOT IN","LIKE","NOT LIKE","MATCH"]);function c(e){if(u.has(e))return e;throw Error(`Not a SQL operator: "${e}"`)}class f{chunks=[];args=[];static TagName="sql";appendTemplate(e,...t){if(!Array.isArray(e)||!Array.isArray(e.raw))throw Error("sql`` can only be used as a template literal tag");for(let r of e)if(this.appendRaw_DANGEROUS(r),t.length){let e=t.shift();if(e instanceof p){this.appendIdentifier(e);continue}if(e instanceof f){this.append(e);continue}this.appendArg(e)}return this}append(e){return o(this.chunks,e.chunks),o(this.args,e.args),this}appendArg(e){return this.chunks.push(l),this.args.push(e),this}appendRaw_DANGEROUS(e){return this.chunks.push(e),this}appendIdentifier(e){let t=e instanceof p?e.value:e;return this.appendRaw_DANGEROUS(this.escapeIdentifier(t))}escapeIdentifier(e){if(/^[\w]+$/.test(e))return`"${e}"`;throw Error(`Unexpected SQL identifier format: ${e}`)}sql(){let e=0;return this.chunks.map(t=>t===l?`$${++e}`:t).join("")}toString(){let e=JSON.stringify(this.args),t=this.constructor,r=t===f?"Sql":t.name||t.TagName;return`${r}(\`${this.sql()}\`, ${e})`}DEBUG_ONLY_getInterpolatedQuery(){let e=0;return this.chunks.map(t=>{if(t===l){let t=this.args[e];return e++,function(e){if(Array.isArray(e)){let t=!1,r=e.map(e=>"string"==typeof e?y(e):("number"==typeof e||(t=!0),e));if(!t)return`ARRAY[${r.join(",")}]`}if(null==e)return"NULL";switch(typeof e){case"string":case"symbol":return y(String(e));case"number":case"bigint":case"boolean":return String(e);case"function":case"object":case"undefined":return y(JSON.stringify(e))}}(t)}return t}).join("")}}function h(e,t){if(t instanceof f)return t;if("string"==typeof t){if(!/^[ \t]*$/.test(t))throw Error(`Unexpected indent format ${t}`);return e.raw_DANGEROUS(t)}if(t<0)return;let r=" ".repeat(t);return e`\n`.appendRaw_DANGEROUS(`${r}`)}function d(e,t,r){let n=e``;return t.forEach((e,a)=>{n.append(e),a!==t.length-1&&n.append(r)}),n}"u"e),o=function(e){try{return a?a.highlight(e):e}catch{return e}}(r),l=o.split(` `),p=[i?s(`(${i}) `,"undefined"):"",s(n??"sql","special"),s("`","string")];return l.length>2?(r.startsWith(` `)||p.push(` `),p.push(l.map(e=>` ${e}`).join(` `)),r.endsWith(` `)||p.push(` `)):p.push(o),p.push(s("`","string")),p.join("")}({sql:this.DEBUG_ONLY_getInterpolatedQuery(),tagName:this.constructor.TagName||"sql",className:this.constructor===f?void 0:this.constructor.name},t)});let g=new f().appendRaw_DANGEROUS(" "),w=new f;function y(e){let t=!1,r="'";for(let n=0;ne===l?"?":e).join("")}asRead(){return{sql:this.sql(),args:this.args,getData:!0}}asWrite(){return{sql:this.sql(),args:this.args}}async all(e,t){return(0,r(911822).qU)({connection:e,sql:this.sql(),args:this.args,queryName:t})}async first(e){return(await this.all(e))[0]}async run(e){return(0,r(911822).kx)({connection:e,sql:this.sql(),args:this.args})}},s=n,(i=(e,...t)=>new s().appendTemplate(e,...t)).raw_DANGEROUS=e=>new n().appendRaw_DANGEROUS(e),i.ident=e=>new n().appendIdentifier(e),i.col=(e,t)=>{let r=new n;return t?(r.appendIdentifier(e),r.appendRaw_DANGEROUS("."),r.appendIdentifier(t)):r.appendIdentifier(e),r},i.cols=e=>{var t;let a,i,s,o,l,p,u;return null!=e&&e.prefix?a=e.prefix:null!=e&&e.table&&(a="string"==typeof e.table?new n().appendIdentifier(e.table):new n().append(e.table)).appendRaw_DANGEROUS("."),t={dialect:n,prefix:a,iterable:null==e?void 0:e.allowed},i=Object.create(null),s=t.dialect,o=t.prefix,l=t.iterable?new Set(t.iterable):void 0,p=e=>{let t=new s;return o&&t.append(o),t.appendIdentifier(e)},u=e=>{if("string"==typeof e)return!l||!!l.has(e);return!1},l&&(i[Symbol.iterator]=()=>r(331653).jY.map(l,p)[Symbol.iterator]()),new Proxy(i,{get:(e,t,r)=>u(t)?p(t):Reflect.get(e,t,r),has:(e,t)=>u(t)||Reflect.has(e,t),ownKeys(e){let t=Object.keys(e);return l?Array.from(l).concat(t):t}})},i.op=e=>new n().appendRaw_DANGEROUS(c(e)),i.expr=(e,t,r)=>{let a=new n;if("string"==typeof e){let t=e.split(".");for(let e=0;ed(i,e,t),i.and=(e,t)=>(function(e,t,r=-1){if(0===t.length)return e`TRUE`;if(1===t.length)return e`(${t[0]})`;let n=h(e,r),a=d(e,t,e`${n??g}AND `);return e`(${n??w}${a})`})(i,e,t),i.or=(e,t)=>(function(e,t,r=-1){if(0===t.length)return e`FALSE`;if(1===t.length)return e`(${t[0]})`;let n=h(e,r),a=d(e,t,e`${n??g}OR `);return e`(${n??w}${a})`})(i,e,t),i.comma=(e,t)=>(function(e,t,r=-1){return d(e,t,e`,${h(e,r)??g}`)})(i,e,t),i.newline=e=>h(i,e??0)??i`\n`,i.comment=e=>new n().appendRaw_DANGEROUS(`/* ${e.replace(/\/(?=\*)|\*(?=\/)/g,"$& ")} */`),i)}}]);