@notionhq/custom-blocks-host 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/lifecycle/legacyPage.js +12 -0
- package/dist/protocol/messages/createPage.d.ts +24 -0
- package/dist/protocol/messages/createPageResult.d.ts +72 -0
- package/dist/protocol/messages/getPage.d.ts +72 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +264 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +48 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +48 -0
- package/dist/protocol/messages/updatePage.d.ts +24 -0
- package/dist/protocol/messages/updatePageResult.d.ts +72 -0
- package/dist/protocol/pages/page.d.ts +120 -0
- package/dist/protocol/pages/page.js +30 -0
- package/package.json +1 -1
- package/src/lifecycle/legacyPage.ts +12 -0
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var $e=6,Qe=6;function vn(e){let{manifestProperties:t,propertySchemasById:o}=e,i=[];for(let[c,l]of Object.entries(t)){let p=dn({propertyKey:c,manifestProperty:l,propertySchemasById:o});p!==void 0&&i.push([c,p])}return Object.fromEntries(i)}function dn(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:i}=e,c=bt(o.name),l=Object.entries(i).filter(([p,y])=>y.type===o.type&&(p===t||bt(y.name)===c));return l.length===1?l[0][0]:void 0}function bt(e){return e.trim().toLowerCase()}var qe,hn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Xe(e){return!e&&!qe?hn:{lang:e?.lang??qe?.lang,message:e?.message,abortEarly:e?.abortEarly??qe?.abortEarly,abortPipeEarly:e?.abortPipeEarly??qe?.abortPipeEarly}}var gn;function bn(e){return gn?.get(e)}var Sn;function kn(e){return Sn?.get(e)}var In;function _n(e,t){return In?.get(e)?.get(t)}function he(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function D(e,t,o,i,c){let l=c&&"input"in c?c.input:o.value,p=c?.expected??e.expects??null,y=c?.received??he(l),m={kind:e.kind,type:e.type,input:l,expected:p,received:y,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},x=e.kind==="schema",_=c?.message??e.message??_n(e.reference,m.lang)??(x?kn(m.lang):null)??i.message??bn(m.lang);_!==void 0&&(m.message=typeof _=="function"?_(m):_),x&&(o.typed=!1),o.issues?o.issues.push(m):o.issues=[m]}var St=new WeakMap;function Q(e){let t=St.get(e);return t||(t={version:1,vendor:"valibot",validate(o){return e["~run"]({value:o},Xe())}},St.set(e,t)),t}function xn(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function We(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}var Cn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ce(e){return{kind:"transformation",type:"brand",reference:ce,async:!1,name:e,"~run"(t){return t}}}function Ie(e){return{kind:"validation",type:"finite",reference:Ie,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&D(this,"finite",t,o),t}}}function Je(e,t){let o=he(e);return{kind:"validation",type:"includes",reference:Je,async:!1,expects:o,requirement:e,message:t,"~run"(i,c){return i.typed&&!i.value.includes(this.requirement)&&D(this,"content",i,c,{received:`!${o}`}),i}}}function Te(e,t){return{kind:"validation",type:"max_length",reference:Te,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&o.value.length>this.requirement&&D(this,"length",o,i,{received:`${o.value.length}`}),o}}}function _e(e,t){return{kind:"validation",type:"min_length",reference:_e,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&o.value.length<this.requirement&&D(this,"length",o,i,{received:`${o.value.length}`}),o}}}function xe(e,t){return{kind:"validation",type:"min_value",reference:xe,async:!1,expects:`>=${e instanceof Date?e.toJSON():he(e)}`,requirement:e,message:t,"~run"(o,i){return o.typed&&!(o.value>=this.requirement)&&D(this,"value",o,i,{received:o.value instanceof Date?o.value.toJSON():he(o.value)}),o}}}function Ke(e,t){return{kind:"validation",type:"regex",reference:Ke,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&!this.requirement.test(o.value)&&D(this,"format",o,i),o}}}function Ze(e){return{kind:"transformation",type:"transform",reference:Ze,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var It={abortEarly:!0};function _t(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function Ae(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function xt(e,t){return!e["~run"]({value:t},It).issues}function E(e,t){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){let c=o.value;if(Array.isArray(c)){o.typed=!0,o.value=[];for(let l=0;l<c.length;l++){let p=c[l],y=this.item["~run"]({value:p},i);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:p};for(let x of y.issues)x.path?x.path.unshift(m):x.path=[m],o.issues?.push(x);if(o.issues||(o.issues=y.issues),i.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value.push(y.value)}}else D(this,"type",o,i);return o}}}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:D(this,"type",t,o),t}}}function s(e,t){return{kind:"schema",type:"literal",reference:s,expects:he(e),async:!1,literal:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){return o.value===this.literal?o.typed=!0:D(this,"type",o,i),o}}}function Ye(e){return{kind:"schema",type:"nan",reference:Ye,expects:"NaN",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:D(this,"type",t,o),t}}}function U(e,t){return{kind:"schema",type:"nullable",reference:U,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(o,i){return o.value===null&&(this.default!==void 0&&(o.value=Ae(this,o,i)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,i)}}}function P(e){return{kind:"schema",type:"number",reference:P,expects:"number",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:D(this,"type",t,o),t}}}function n(e,t){return{kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],o.issues?.push(_);if(o.issues||(o.issues=m.issues),i.abortEarly){o.typed=!1;break}}m.typed||(o.typed=!1),o.value[l]=m.value}else if(p.fallback!==void 0)o.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(D(this,"key",o,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}}else D(this,"type",o,i);return o}}}function u(e,t){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(o,i){return o.value===void 0&&(this.default!==void 0&&(o.value=Ae(this,o,i)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,i)}}}function q(e,t){return{kind:"schema",type:"picklist",reference:q,expects:We(e.map(he),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){return this.options.includes(o.value)?o.typed=!0:D(this,"type",o,i),o}}}function V(e,t,o){return{kind:"schema",type:"record",reference:V,expects:"Object",async:!1,key:e,value:t,message:o,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){i.typed=!0,i.value={};for(let p in l)if(xn(l,p)){let y=l[p],m=this.key["~run"]({value:p},c);if(m.issues){let _={type:"object",origin:"key",input:l,key:p,value:y};for(let C of m.issues)C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=m.issues),c.abortEarly){i.typed=!1;break}}let x=this.value["~run"]({value:y},c);if(x.issues){let _={type:"object",origin:"value",input:l,key:p,value:y};for(let C of x.issues)C.path?C.path.unshift(_):C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=x.issues),c.abortEarly){i.typed=!1;break}}(!m.typed||!x.typed)&&(i.typed=!1),m.typed&&(i.value[m.value]=x.value)}}else D(this,"type",i,c);return i}}}function f(e,t){return{kind:"schema",type:"strict_object",reference:f,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],o.issues?.push(_);if(o.issues||(o.issues=m.issues),i.abortEarly){o.typed=!1;break}}m.typed||(o.typed=!1),o.value[l]=m.value}else if(p.fallback!==void 0)o.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(D(this,"key",o,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}if(!o.issues||!i.abortEarly){for(let l in c)if(!(l in this.entries)){D(this,"key",o,i,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else D(this,"type",o,i);return o}}}function r(e){return{kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,o){return typeof t.value=="string"?t.typed=!0:D(this,"type",t,o),t}}}function kt(e){let t;if(e)for(let o of e)if(t)for(let i of o.issues)t.push(i);else t=o.issues;return t}function g(e,t){return{kind:"schema",type:"union",reference:g,expects:We(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(o,i){let c,l,p;for(let y of this.options){let m=y["~run"]({value:o.value},i);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else p?p.push(m):p=[m]}if(c)return c;if(l){if(l.length===1)return l[0];D(this,"type",o,i,{issues:kt(l)}),o.typed=!0}else{if(p?.length===1)return p[0];D(this,"type",o,i,{issues:kt(p)})}return o}}}function Ce(){return{kind:"schema",type:"unknown",reference:Ce,expects:"unknown",async:!1,get"~standard"(){return Q(this)},"~run"(e){return e.typed=!0,e}}}function v(e,t,o){return{kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){let p,y=0,m=this.key,x=[],_=(C,b)=>{for(let L of C.options){if(L.type==="variant")_(L,new Set(b).add(L.key));else{let w=!0,T=0;for(let O of b){let H=L.entries[O];if(O in l?H["~run"]({typed:!1,value:l[O]},It).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){w=!1,m!==O&&(y<T||y===T&&O in l&&!(m in l))&&(y=T,m=O,x=[]),m===O&&x.push(L.entries[O].expects);break}T++}if(w){let O=L["~run"]({value:l},c);(!p||!p.typed&&O.typed)&&(p=O)}}if(p&&!p.issues)break}};if(_(this,new Set([this.key])),p)return p;D(this,"type",i,c,{input:l[m],expected:We(x,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else D(this,"type",i,c);return i}}}function ie(e,t,o){let i=e["~run"]({value:t},Xe(o));if(i.issues)throw new Cn(i.issues);return i.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return Q(this)},"~run"(t,o){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=i["~run"](t,o))}return t}}}function Pe(e,t,o){let i=e["~run"]({value:t},Xe(o));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var le=z(r(),ce("NotionBlockId")),K=z(r(),ce("NotionDataSourceId")),N=z(r(),ce("NotionPageId")),Ct=z(r(),ce("NotionAgentId")),Pt=z(r(),ce("NotionSpaceId"));var Et=q(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),et=n({id:r(),name:r(),color:u(Et),description:u(r())}),Pn=n({id:r(),name:r(),color:u(Et),option_ids:E(r())}),En=n({synced_property_id:r(),synced_property_name:r()}),j=n({name:r(),description:u(r())}),On=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],Ot=q(On),Rt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],tt=v("type",[n({...j.entries,type:s("title")}),n({...j.entries,type:s("rich_text")}),n({...j.entries,type:s("number")}),n({...j.entries,type:s("checkbox")}),n({...j.entries,type:s("url")}),n({...j.entries,type:s("email")}),n({...j.entries,type:s("phone_number")}),n({...j.entries,type:s("select"),options:E(et)}),n({...j.entries,type:s("multi_select"),options:E(et)}),n({...j.entries,type:s("status"),options:E(et),groups:E(Pn)}),n({...j.entries,type:s("date")}),n({...j.entries,type:s("people")}),n({...j.entries,type:s("files")}),n({...j.entries,type:s("unique_id")}),n({...j.entries,type:s("relation"),data_source_id:u(r()),dual_property:u(En)}),n({...j.entries,type:s("place")}),n({...j.entries,type:s("formula")}),n({...j.entries,type:s("rollup")}),n({...j.entries,type:s("button")}),n({...j.entries,type:s("verification")}),n({...j.entries,type:s("last_visited_time")}),n({...j.entries,type:s("location")}),n({...j.entries,type:s("created_time")}),n({...j.entries,type:s("last_edited_time")}),n({...j.entries,type:s("created_by")}),n({...j.entries,type:s("last_edited_by")})]);var jt=n({id:K,table:r(),spaceId:u(Pt)}),Mt=n({id:u(K),propertiesById:V(r(),tt)}),$o=n({key:r(),collectionPointer:u(jt),collectionSchema:u(Mt),propertyIdsByKey:V(r(),u(r())),propertySchemasById:V(r(),tt)}),Rn=n({collectionPointer:u(jt),collectionSchema:u(Mt),propertyIdsByKey:u(V(r(),u(r())))}),me=V(r(),Rn);var ge=q(["standard","high"]),Bt="standard";var Dt=n({type:s("contrastModeChanged"),contrastMode:ge});var Ne=n({unit:q(["year","month","week","day"]),value:P(),time:r(),defaultTimeZone:u(r())}),jn=n({unit:q(["hour","minute"]),value:P()}),Ee=n({unit:s("none")}),rt=g([Ne,jn]),wt=u(g([Ne,Ee])),qt=u(g([rt,Ee])),Mn=n({type:s("date"),start_date:r(),reminder:wt}),Bn=n({type:s("daterange"),start_date:r(),end_date:r(),reminder:wt}),Dn=n({type:s("datetime"),start_date:r(),start_time:r(),time_zone:u(r()),reminder:qt}),wn=n({type:s("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:u(r()),reminder:qt}),Tt=v("type",[Mn,Bn,Dn,wn]);var Ue=n({id:r(),table:r()});var ae=v("type",[n({type:s("page_id"),page_id:N}),n({type:s("data_source_id"),data_source_id:K}),n({type:s("workspace"),workspace:s(!0)}),n({type:s("block_id"),block_id:le}),n({type:s("agent_id"),agent_id:Ct}),n({type:s("unavailable")})]);var be=v("type",[n({type:s("unavailable")}),n({type:s("page"),id:N,parent:ae})]),qn=n({type:s("emoji"),emoji:r()}),Tn=n({type:s("custom_emoji"),custom_emoji:n({id:r(),name:u(r()),url:u(r())})}),Nt=n({type:s("external"),external:n({url:r()})}),Ut=n({type:s("file"),file:n({url:r(),expiry_time:u(r())})}),ze=v("type",[qn,Tn,Nt,Ut]),Le=v("type",[Nt,Ut]),Z=U(r()),At=V(r(),Ce()),nt=g([n({id:r(),name:u(r()),color:u(r()),description:u(Z)}),n({name:r(),id:u(r()),color:u(r()),description:u(Z)})]),ot={start:r(),end:u(Z),time_zone:u(Z),reminder:u(g([rt,Ee]))},An=g([n({...ot,start:z(r(),Je("T"))}),n({...ot,time_zone:r()}),n({...ot,reminder:u(g([Ne,Ee]))})]),Nn=g([n({object:u(s("user")),id:r()}),n({object:s("group"),id:r(),name:u(Z)})]),Un=n({id:r()}),Fn=g([n({type:s("external"),name:r(),external:n({url:r()})}),n({type:s("file"),name:r(),file:n({url:r(),expiry_time:u(r())})})]),zn=n({lat:P(),lon:P(),name:u(Z),address:u(Z),aws_place_id:u(Z),google_place_id:u(Z)}),F={id:r()},Fe=U(n({...Ue.entries,table:q(["notion_user","bot","organization_bot"]),spaceId:u(r())})),Ft=v("type",[n({...F,type:s("title"),title:E(At)}),n({...F,type:s("rich_text"),rich_text:E(At)}),n({...F,type:s("number"),number:U(P())}),n({...F,type:s("url"),url:Z}),n({...F,type:s("email"),email:Z}),n({...F,type:s("phone_number"),phone_number:Z}),n({...F,type:s("checkbox"),checkbox:h()}),n({...F,type:s("select"),select:U(nt)}),n({...F,type:s("status"),status:U(nt)}),n({...F,type:s("multi_select"),multi_select:E(nt)}),n({...F,type:s("date"),date:U(An)}),n({...F,type:s("people"),people:E(Nn)}),n({...F,type:s("relation"),has_more:u(h()),relation:E(Un)}),n({...F,type:s("files"),files:E(Fn)}),n({...F,type:s("place"),place:U(zn)}),n({...F,type:s("created_time"),created_time:Z}),n({...F,type:s("last_edited_time"),last_edited_time:Z}),n({...F,type:s("created_by"),created_by:Fe}),n({...F,type:s("last_edited_by"),last_edited_by:Fe}),n({...F,type:s("last_visited_time"),last_visited_time:Z})]),Oe=V(r(),Ft),Ln=V(r(),U(Ft)),ne=n({object:s("page"),id:N,parent:ae,properties:Ln,created_by:u(Fe,null),last_edited_by:u(Fe,null),last_visited_time:u(U(r()),null),created_time:u(U(r()),null),last_edited_time:u(U(r()),null),icon:u(U(ze),null),cover:u(U(Le),null),url:u(U(r()),null),public_url:u(U(r()),null),is_archived:h(),in_trash:h()}),Se=n({object:s("page"),id:N,parent:ae,properties:Oe,created_time:u(r()),last_edited_time:u(r()),icon:u(ze),cover:u(Le),url:u(r()),public_url:u(r()),is_archived:h(),in_trash:h()});var Hn=r(),zt=n({code:Hn,message:r(),isRetryable:h()}),Lt=v("status",[n({type:s("createPageResult"),requestId:r(),status:s("success"),page:ne}),n({type:s("createPageResult"),requestId:r(),status:s("error"),error:zt})]),Ht=v("status",[n({type:s("createPageResult"),requestId:r(),status:s("success"),page:g([ne,Se])}),n({type:s("createPageResult"),requestId:r(),status:s("error"),error:zt})]);var st=z(r(),ce("NotionUserId")),pe=n({object:s("user"),id:st,name:u(r()),avatar_url:U(r()),type:s("person"),person:n({email:r()})}),Vt=n({object:s("list"),results:E(pe),next_cursor:U(r()),has_more:h(),type:s("user"),user:V(r(),Ce())});var Gt=n({type:s("currentUserChanged"),currentUser:pe});var $t=n({type:s("dataSourcesChanged"),dataSources:n({bindings:me})});var Vn=r(),Qt=n({code:Vn,message:r(),isRetryable:h()}),Xt=n({type:s("getPage"),requestId:r(),pageId:N,dataSourceId:u(K)}),Wt=v("status",[n({type:s("getPageResult"),requestId:r(),status:s("success"),page:ne}),n({type:s("getPageResult"),requestId:r(),status:s("error"),error:Qt})]),Jt=v("status",[n({type:s("getPageResult"),requestId:r(),status:s("success"),page:g([ne,Se])}),n({type:s("getPageResult"),requestId:r(),status:s("error"),error:Qt})]);var Gn=r(),$n=n({code:Gn,message:r(),isRetryable:h()}),Kt=n({type:s("getUser"),requestId:r(),userId:st}),Zt=v("status",[n({type:s("getUserResult"),requestId:r(),status:s("success"),user:pe}),n({type:s("getUserResult"),requestId:r(),status:s("error"),error:$n})]);var Qn=v("type",[n({type:s("emoji"),emoji:r()}),n({type:s("external"),url:r()})]),Xn=n({name:r(),description:u(r()),type:Ot}),Wn=n({name:r(),description:u(r()),icon:u(Qn),properties:u(V(r(),Xn),{})}),ye=n({version:s(1),name:u(r()),description:u(r()),slashCommand:u(r()),icon:u(n({type:s("emoji"),emoji:r()})),dataSources:u(V(r(),Wn),{})});var ke=q(["light","dark"]);var Jn=r(),Kn=n({code:Jn,message:r(),isRetryable:h()});var He=v("status",[n({type:s("init"),initializationId:r(),status:s("success"),theme:ke,contrastMode:ge,blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe}),n({type:s("init"),initializationId:r(),status:s("error"),error:Kn})]);var Yt=n({type:s("invalidSandboxMessage"),reason:r()});var Zn=r(),Yn=n({code:Zn,message:r(),isRetryable:h()}),er=n({type:s("listUsers"),requestId:r(),startCursor:u(r()),pageSize:u(P())}),tr=v("status",[n({type:s("listUsersResult"),requestId:r(),status:s("success"),list:Vt}),n({type:s("listUsersResult"),requestId:r(),status:s("error"),error:Yn})]);var eo=r(),to=n({code:eo,message:r(),isRetryable:h()}),rr=n({type:s("openExternalUrl"),requestId:r(),url:r()}),nr=v("status",[n({type:s("openExternalUrlResult"),requestId:r(),status:s("success")}),n({type:s("openExternalUrlResult"),requestId:r(),status:s("error"),error:to})]);var ro=q(["side_peek","center_peek"]),no=r(),oo=n({code:no,message:r(),isRetryable:h()}),or=n({type:s("openPage"),requestId:r(),pageId:N,mode:ro}),sr=v("status",[n({type:s("openPageResult"),requestId:r(),status:s("success"),pageId:N}),n({type:s("openPageResult"),requestId:r(),status:s("error"),error:oo})]);var ir=n({type:s("pageChanged"),page:be});var ar=n({type:s("parentChanged"),parent:ae});var ur=g([r(),P(),h(),Tt,E(r()),E(Ue)]);var cr=n({id:N,is_archived:h(),in_trash:h(),propertiesById:V(r(),u(ur))});var so=r(),lr=n({code:so,message:r(),isRetryable:h()}),pr=v("status",[n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("success"),items:E(ne),hasMore:h()}),n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("error"),error:lr})]),fr=v("status",[n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("success"),items:E(g([ne,cr])),hasMore:h()}),n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("error"),error:lr})]);var mr=n({type:s("themeChanged"),theme:ke});var io=r(),yr=n({code:io,message:r(),isRetryable:h()}),vr=v("status",[n({type:s("updatePageResult"),requestId:r(),status:s("success"),page:ne}),n({type:s("updatePageResult"),requestId:r(),status:s("error"),error:yr})]),dr=v("status",[n({type:s("updatePageResult"),requestId:r(),status:s("success"),page:g([ne,Se])}),n({type:s("updatePageResult"),requestId:r(),status:s("error"),error:yr})]);var hr=v("type",[He,mr,Dt,ar,ir,Gt,$t,Zt,tr,sr,nr,Yt]),gr=v("type",[...hr.options,pr,Wt,Lt,vr]),vi=v("type",[...hr.options,fr,Jt,Ht,dr]);function br(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Sr(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function it(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function at(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function ut(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function kr(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Ir(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function _r(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function xr(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Cr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Pr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Re(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function re(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function ct(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var ao=5e3,uo=5e3,co=5e3;function Er(e){let{prepareInit:t,sendInitMessage:o,warn:i,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:p=ao,initialStateTimeoutMs:y=uo,noInitResultTimeoutMs:m=co,stopHostWithFailure:x,onInitResult:_,onConnectionFailure:C}=e,b="waitingForConnect",L,w,T,O,H=!1,$=!1;function X(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function ue(){w!==void 0&&(window.clearTimeout(w),w=void 0)}function W(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function M(S){let{initializationId:I,error:J,phase:oe,source:A}=S;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return re(b)}b="error",O=I,X(),ue(),o({type:"init",initializationId:I,status:"error",error:J}),C?.({...J,phase:oe,source:A})}async function G(S){if(b==="waitingForConnect"){b="preparingInit",O=S.initializationId,X(),w=window.setTimeout(()=>{if(b!=="preparingInit")return;let I=kr();i({...I,initializationId:S.initializationId}),M({initializationId:S.initializationId,error:I,phase:"init",source:"host"})},y);try{let I=await t(S);if(b!=="preparingInit")return;if(ue(),I.status==="error"){M({initializationId:S.initializationId,error:I.error,phase:"init",source:"host"});return}b="waitingForInitResult";let J={type:"init",initializationId:S.initializationId,status:"success",theme:I.initialState.theme,contrastMode:I.initialState.contrastMode??Bt,blockId:I.initialState.blockId,parent:I.initialState.parent,page:I.initialState.page,currentUser:I.initialState.currentUser,manifest:I.initialState.manifest,dataSources:I.initialState.dataSources};o(J),T=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="error";let oe=Cr();C?.({...oe,phase:"initResult",source:"host"}),i({...oe,initializationId:S.initializationId})},m)}catch(I){if(b!=="preparingInit")return;i({message:"Failed to prepare custom block initialization",error:I}),M({initializationId:S.initializationId,error:Re(),phase:"init",source:"host"})}}}function ee(S){if(b!=="stopped"&&b==="waitingForConnect"){if(!ct(S.bridgeProtocolVersion)){let I=it({currentBridgeProtocolVersion:S.bridgeProtocolVersion});M({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.bridgeProtocolVersion<l){let I=at({currentBridgeProtocolVersion:S.bridgeProtocolVersion,minBridgeProtocolVersion:l});M({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.status==="error"){M({initializationId:S.initializationId,error:S.error,phase:"connect",source:"sandbox"});return}$=!0,G(S)}}function se(S){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:I,bridgeProtocolVersion:J}=S;if(I===void 0)return"nack";let oe=S.error;return J!==void 0&&(ct(J)?J<l&&(oe=at({currentBridgeProtocolVersion:J,minBridgeProtocolVersion:l})):oe=it({currentBridgeProtocolVersion:J})),M({initializationId:I,error:oe,phase:"connect",source:"host"}),"handled"}function B(S){let{initializationId:I,error:J}=S;b!=="waitingForInitResult"||I===void 0||I!==O||(X(),W(),b="error",i(J),C?.({...J,phase:"initResult",source:"host"}))}function te(){if(b!=="stopped"){if(H){x({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}H=!0,X(),b==="waitingForConnect"&&(L=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="error";let S=br();i(S),C?.({...S,phase:"connect",source:"host"})},p))}}function fe(S){if(b!=="waitingForInitResult"||S.initializationId!==O){i({message:"Ignored stale or unexpected initResult",payload:S});return}W(),b=S.status==="success"?"initialized":"error",S.status==="success"?c():C?.({...S.error,phase:"initResult",source:"sandbox"}),_?.(S)}function we(){b="stopped",X(),ue(),W()}return{get status(){return b},get hasConnectedSandbox(){return $},handleConnect:ee,handleInitResult:fe,handleInvalidConnect:se,handleInvalidInitResult:B,onIframeLoad:te,stop:we}}function lt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}async function Or(e){let t=new AbortController,o=()=>t.abort();e.signal.addEventListener("abort",o,{once:!0});let i=new Promise((l,p)=>{t.signal.addEventListener("abort",()=>p(t.signal.reason),{once:!0})});e.signal.aborted&&t.abort();let c=e.manifestSource==="local"?window.setTimeout(()=>{t.abort(new Error("Manifest loading timed out after 5000 ms."))},5e3):void 0;try{let l=await Promise.race([e.manifestSource==="local"?lo(e.sandboxOrigin,t.signal):e.getPersistedManifest({signal:t.signal}),i]);if(t.signal.aborted)throw new Error("Manifest loading was cancelled.");return{status:"success",manifest:ie(ye,l)}}catch(l){return e.signal.aborted||e.onError(l),{status:"error",error:{code:"manifest_unavailable",message:"The custom block manifest is unavailable.",isRetryable:!0}}}finally{window.clearTimeout(c),e.signal.removeEventListener("abort",o)}}async function lo(e,t){let o=new URL(e);if(!lt({url:o,hostOrigin:window.location.origin}))throw new Error("Preview requires a separate loopback origin.");let i=await fetch(new URL("/manifest",o),{credentials:"omit",redirect:"error",cache:"no-store",signal:t});if(!i.ok)throw new Error(`Manifest request failed: HTTP ${i.status}.`);return i.json()}var de=class extends Error{};function pt(e){try{return po(e)}catch(t){throw t instanceof RangeError?new de(t.message):t}}function po(e){let{start:t,end:o,time_zone:i,reminder:c}=e;if(!t.split("T")[0])throw new de("Date values must include a date.");let l=t.includes("T")||i!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),y=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,m=i?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=m?(Number(m[2]??0)*60+Number(m[3]??0))*(m[1]==="-"?-1:1):y,_=w=>{if(!w.split("T")[0])throw new de("Date values must include a date.");if(!w.includes("T"))return{date:w,time:"00:00"};let T=w.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(T)return{date:T[1],time:T[2]};if(!i||m){let $=new Date(new Date(w).getTime()+x*6e4).toISOString();return{date:$.slice(0,10),time:$.slice(11,16)}}let O=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(w)),H=$=>O.find(X=>X.type===$)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},C=_(t),b=o?_(o):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new de("Hour and minute reminders require a date with a time.");return b?{type:"daterange",start_date:C.date,end_date:b.date,reminder:c}:{type:"date",start_date:C.date,reminder:c}}let L=i??(y===0?"UTC":`UTC${y<0?"-":"+"}${Math.floor(Math.abs(y)/60)}${Math.abs(y)%60===0?"":`:${String(Math.abs(y)%60).padStart(2,"0")}`}`);return b?{type:"datetimerange",start_date:C.date,start_time:C.time,end_date:b.date,end_time:b.time,time_zone:L,reminder:c}:{type:"datetime",start_date:C.date,start_time:C.time,time_zone:L,reminder:c}}function jr(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Mr(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=fo(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:t}}function Rr(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function ft(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}function fo(e){switch(e.type){case"title":return Rr(e.title);case"rich_text":return Rr(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?pt(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"place":return"";case"created_time":return ft(e.created_time);case"last_edited_time":return ft(e.last_edited_time);case"last_visited_time":return ft(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return re(e)}}function Br(e,t){if(t>=6||e.status==="error")return e;switch(e.type){case"queryDataSourceResult":return{...e,items:e.items.map(Mr)};case"getPageResult":case"createPageResult":case"updatePageResult":return{...e,page:jr(e.page)};default:return re(e)}}function Dr(e,t){return e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"?e:Br(e,t)}var wr=n({theme:ke,contrastMode:u(ge),blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe});function qr(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}function Tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Ar=n({code:r(),message:r(),isRetryable:h()});var Nr={type:s("connect"),initializationId:r(),bridgeProtocolVersion:P(),sdkVersion:r()},Ur=v("status",[n({status:s("success"),manifest:u(ye),...Nr}),n({status:s("error"),error:Ar,...Nr})]);var mo=v("type",[n({type:s("start")}),n({type:s("end")}),n({type:s("before"),blockId:le}),n({type:s("after"),blockId:le})]),yo=v("type",[n({type:s("page_id"),page_id:N}),n({type:s("data_source_id"),data_source_id:K})]),Fr=n({type:s("createPage"),requestId:r(),parent:yo,properties:Oe,position:u(mo)});var vo=r(),ho=n({code:vo,message:r(),isRetryable:h()}),zr=v("status",[n({type:s("initResult"),initializationId:r(),status:s("success"),initialHeight:u(z(P(),Ie(),xe(0)))}),n({type:s("initResult"),initializationId:r(),status:s("error"),error:ho})]);var Lr=n({type:s("invalidHostMessage"),reason:r()});var Hr=q(["ascending","descending"]);var Vr=z(N,Ke(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),mt=g([f({contains:Vr}),f({does_not_contain:Vr})]),De=g([f({is_empty:s(!0)}),f({is_not_empty:s(!0)})]),Be=g([r(),E(r())]),Gr=f({object:q(["user","group"]),id:z(r(),_e(1))}),go=g([f({contains:Gr}),f({does_not_contain:Gr}),De]),$r=f({object:s("user"),id:z(r(),_e(1),Te(2e3))}),bo=g([f({contains:$r}),f({does_not_contain:$r}),f({is_empty:s(!0)}),f({is_not_empty:s(!0)})]),je=g([f({equals:r()}),f({does_not_equal:r()}),f({contains:r()}),f({does_not_contain:r()}),f({starts_with:r()}),f({ends_with:r()}),De]),So=g([f({equals:P()}),f({does_not_equal:P()}),f({greater_than:P()}),f({less_than:P()}),f({greater_than_or_equal_to:P()}),f({less_than_or_equal_to:P()}),De]),ko=g([f({equals:h()}),f({does_not_equal:h()})]),Jr=g([f({equals:Be}),f({does_not_equal:Be}),De]),Qr=q(["To-do","In progress","Complete","Current","Future"]),Xr=g([Qr,z(E(Qr),_e(1),Te(5))]),Io=g([f({group_equals:Xr}),f({group_does_not_equal:Xr})]),_o=g([Jr,Io]),xo=g([f({contains:Be}),f({contains_all:Be}),f({does_not_contain:Be}),De]),Y=q(["start_date","end_date"]),Co=q(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Me=g([Co,r()]),Po=g([f({target:u(Y),equals:Me}),f({target:u(Y),before:Me}),f({target:u(Y),after:Me}),f({target:u(Y),on_or_before:Me}),f({target:u(Y),on_or_after:Me}),f({target:u(Y),this_week:f({})}),f({target:u(Y),past_week:f({})}),f({target:u(Y),past_month:f({})}),f({target:u(Y),past_year:f({})}),f({target:u(Y),next_week:f({})}),f({target:u(Y),next_month:f({})}),f({target:u(Y),next_year:f({})}),f({target:u(Y),is_empty:s(!0)}),f({target:u(Y),is_not_empty:s(!0)})]),Wr=g([f({propertyId:r(),relation:mt}),f({propertyId:r(),created_by:bo}),f({propertyId:r(),title:je}),f({propertyId:r(),rich_text:je}),f({propertyId:r(),url:je}),f({propertyId:r(),email:je}),f({propertyId:r(),phone_number:je}),f({propertyId:r(),number:So}),f({propertyId:r(),checkbox:ko}),f({propertyId:r(),select:Jr}),f({propertyId:r(),multi_select:xo}),f({propertyId:r(),status:_o}),f({propertyId:r(),date:Po}),f({propertyId:r(),people:go})]),Eo=g([Wr,f({and:E(Wr)})]),yt=10,Oo=f({propertyId:r(),direction:Hr}),Kr=n({type:s("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:P(),filter:u(Eo),sorts:u(E(Oo))});var Zr=n({type:s("resize"),height:z(P(),Ie(),xe(0))});var Yr=n({type:s("unsubscribeDataSourceQuery"),subscriptionId:r()});var en=n({type:s("updatePage"),requestId:r(),pageId:N,dataSourceId:u(K),properties:u(Oe),icon:u(ze),cover:u(Le),archived:u(h())});var tn=v("type",[Ur,zr,Kr,Yr,Fr,Xt,Kt,er,or,rr,en,Zr,Lr]);function rn(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function nn(e){let t=rn(e);return t==="invalidHostMessage"||t==="invalidSandboxMessage"?{incomingType:t}:{incomingType:t,nack:{type:"invalidSandboxMessage",reason:Ro(t)}}}function Ro(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var on=n({initializationId:r()}),jo=n({bridgeProtocolVersion:g([P(),Ye()])});function sn(e){let{iframe:t,sandboxOrigin:o,getInitStatus:i,emit:c,sendNack:l,onInvalidConnect:p,onInvalidInitResult:y,onConnect:m,onInitResult:x,onQueryDataSource:_,onUnsubscribeDataSourceQuery:C,onCreatePage:b,onGetPage:L,onOpenPage:w,onOpenExternalUrl:T,onGetUser:O,onListUsers:H,onUpdatePage:$,onResize:X}=e;function ue(W,M){c("warn",{message:"Ignored unsupported sandbox message",payload:vt(W),issues:M});let G=nn(W);if(G.incomingType==="connect"){let ee=Pe(on,W),se=Pe(jo,W);if(p({initializationId:ee.success?ee.output.initializationId:void 0,error:Sr(),bridgeProtocolVersion:se.success?se.output.bridgeProtocolVersion:void 0})==="handled")return}if(G.incomingType==="initResult"){let ee=Pe(on,W);y({initializationId:ee.success?ee.output.initializationId:void 0,error:Pr()})}G.nack!==void 0&&i()!=="stopped"&&l(G.nack)}return function(M){let G=M.source===t.contentWindow,ee=M.origin===o;if(!G||!ee)return;let se=Pe(tn,M.data);if(!se.success){ue(M.data,se.issues);return}let B=se.output;if(!Tr(B)&&i()!=="initialized"){c("warn",{message:`Ignored ${B.type} before initialization completed`,payload:vt(B)});return}switch(c("in",vt(B)),B.type){case"connect":m(B);return;case"initResult":x(B);return;case"queryDataSource":_(B);return;case"unsubscribeDataSourceQuery":C(B);return;case"createPage":b(B);return;case"openPage":w(B);return;case"openExternalUrl":T(B);return;case"getPage":L(B);return;case"getUser":O(B);return;case"listUsers":H(B);return;case"updatePage":$(B);return;case"resize":X(B);return;case"invalidHostMessage":return;default:re(B)}}}function vt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}var Ve=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],i=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(i=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,o.push({message:c.message,token:c.token})}return i?o:void 0}finish(t,o){let i=this.bySubscriptionId.get(t);if(i?.token===o&&(i.isRefreshing=!1,!!i.shouldRefreshAgain))return i.shouldRefreshAgain=!1,i.isRefreshing=!0,{message:i.message,token:i.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function an(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let i of o){let c=Mo(i,t);if(c!==void 0)return c}}function Mo(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let o=t.propertiesById[e.propertyId],i=Object.keys(e).find(y=>y!=="propertyId");if(i!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${i}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,_=(Array.isArray(m)?m:[m]).find(C=>!o.groups.some(b=>b.name===C));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!xt(mt,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Bo(e);if(c===void 0||o.type!==c.propertyType)return;let l=new Set(o.options.map(y=>y.name)),p=Do(c.operator).find(y=>!l.has(y));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Bo(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function Do(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:re(e);return Array.isArray(t)?t:[t]}var wo=new Set(Rt);function un(e,t){if(e===void 0)return;if(e.length>yt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${yt} entries.`,isRetryable:!1};let o=new Set;for(let i of e){if(o.has(i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${i.propertyId}".`,isRetryable:!1};if(o.add(i.propertyId),!Object.hasOwn(t.propertiesById,i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${i.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=t.propertiesById[i.propertyId];if(!wo.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var ln=5;function qo(e){let{iframe:t,prepareInitialState:o,handlers:i,onInitialized:c,onConnectionFailure:l,onLog:p,onQueryUnsubscribed:y,sandboxOrigin:m,minBridgeProtocolVersion:x,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b}=e,L=Math.max(x??3,3),w=new AbortController,T,O={},H=!1,$=new AbortController,X,ue,W=6,M=new Ve(a=>{y?.(a)});function G(a,k){p?.(a,k)}function ee(a){let k=A.status;switch(k){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return re(k)}let R=Dr(a,W);G("out",R),t.contentWindow?.postMessage(R,m)}function se(a){ee(ie(He,a))}function B(a){ee(a)}function te(a){let k=A.status;switch(k){case"initialized":ee(ie(gr,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:re(k)}}async function fe(a,k){if(k===void 0)return;let R=await k(a);te({type:`${a.type}Result`,requestId:a.requestId,...R})}function we(a){let k=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};te(k)}async function S(a,k=M.subscribe(a)){try{let R=To(ue,a.dataSourceId),ve=Ao(a,R);if(ve!==void 0){M.isCurrent(a.subscriptionId,k)&&(M.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:{status:"error",error:ve}}));return}let Ge=await i.queryDataSource(a);if(!M.isCurrent(a.subscriptionId,k))return;Ge.status==="error"&&!Ge.error.isRetryable&&M.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:Ge})}finally{let R=M.finish(a.subscriptionId,k);R!==void 0&&S(R.message,R.token)}}function I(a){A.status==="stopped"||A.status==="error"||(Object.assign(O,a),oe())}async function J(a){if(i.openExternalUrl===void 0||w.signal.aborted||T===a.requestId)return;if(T!==void 0){let R={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};te(R);return}let k=qr(a.url);if(k===void 0){let R={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};te(R);return}T=a.requestId;try{let R=await i.openExternalUrl({...a,url:k},{signal:w.signal});if(w.signal.aborted)return;let ve={type:"openExternalUrlResult",requestId:a.requestId,...R};te(ve)}catch(R){if(!w.signal.aborted)throw R}finally{T===a.requestId&&(T=void 0)}}function oe(){if(A.status!=="initialized")return;let a=O;O={},a.theme!==void 0&&te({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&te({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&te({type:"parentChanged",parent:a.parent}),a.page!==void 0&&te({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&te({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&te({type:"currentUserChanged",currentUser:a.currentUser})}let A=Er({async prepareInit(a){W=a.bridgeProtocolVersion;let k=await mn;return A.status!=="preparingInit"?k:fn(k)},sendInitMessage:se,warn:a=>G("warn",a),flushPendingHostStateChanges:oe,minBridgeProtocolVersion:L,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b,stopHostWithFailure:gt,onInitResult(a){a.status==="success"&&X!==void 0&&c?.({manifest:X,initialHeight:a.initialHeight})},onConnectionFailure:a=>{$.abort(),l?.(a)}});function fn(a){if(a.status==="error")return a;let k=ie(wr,{...a.initialState,...O});if(X=k.manifest,O={},W<ln&&k.page.type==="unavailable")return{status:"error",error:ut()};let R=pn(k.manifest,k.dataSources);return R!==void 0?{status:"error",error:R}:(ue=k.dataSources,H=!0,{status:"success",initialState:k})}let mn=yn().catch(a=>($.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:a}),{status:"error",error:Re()}));async function yn(){let a=await Or({...e,sandboxOrigin:m,signal:$.signal,onError:R=>{G("warn",{message:"Failed to load custom block manifest",error:R})}});if(a.status==="error")return a;if($.signal.aborted)return{status:"error",error:Re()};let k=await o({manifest:a.manifest,signal:$.signal});return k.status==="error"?k:{status:"success",initialState:{...k.initialState,manifest:a.manifest}}}let dt=sn({iframe:t,sandboxOrigin:m,getInitStatus:()=>A.status,emit:G,sendNack:B,onInvalidConnect:A.handleInvalidConnect,onInvalidInitResult:A.handleInvalidInitResult,onConnect:A.handleConnect,onInitResult:A.handleInitResult,onQueryDataSource:S,onUnsubscribeDataSourceQuery:a=>M.unsubscribe(a.subscriptionId),onOpenExternalUrl:J,onCreatePage:a=>fe(a,i.createPage),onGetPage:a=>fe(a,i.getPage),onOpenPage:a=>fe(a,i.openPage),onGetUser:a=>fe(a,i.getUser),onListUsers:a=>fe(a,i.listUsers),onUpdatePage:a=>fe(a,i.updatePage),onResize:a=>i.resize?.(a)});window.addEventListener("message",dt),t.addEventListener("load",A.onIframeLoad);function ht(){w.abort(),$.abort(),window.removeEventListener("message",dt),t.removeEventListener("load",A.onIframeLoad),A.stop(),M.unsubscribeAll()}function gt(a){ht(),G("warn",a),l?.(a)}return{stop:ht,setTheme(a){I({theme:a})},setContrastMode(a){I({contrastMode:a})},setParent(a){I({parent:a})},setPage(a){if(a.type==="unavailable"&&W<ln&&(A.status==="preparingInit"&&H||A.status==="waitingForInitResult"||A.status==="initialized")){gt({...ut(),phase:"runtime",source:"host"});return}I({page:a})},setCurrentUser(a){I({currentUser:a})},setDataSources(a){let k={bindings:ie(me,a.bindings)};if(A.hasConnectedSandbox&&X!==void 0&&pn(X,k)!==void 0){G("warn",{message:"Ignored invalid data source bindings update",payload:k});return}ue=k,I({dataSources:k})},refreshQuery({dataSourceId:a}){if(A.status!=="initialized")return;let k=ie(K,a),R=M.refresh(k);if(R===void 0){G("warn",`No active query exists for data source "${a}"`);return}for(let ve of R)S(ve.message,ve.token)}}}function To(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function pn(e,t){for(let[o,i]of Object.entries(e.dataSources)){let c=t.bindings[o];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Ir();for(let[l,p]of Object.entries(i.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return _r();if(c.collectionSchema.propertiesById[y]?.type!==p.type)return xr()}}}function Ao(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:an(e.filter,t)??un(e.sorts,t)}function No(e){return ie(N,e)}export{de as InvalidNotionDateError,$e as LATEST_BRIDGE_PROTOCOL_VERSION,Qe as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,qo as createCustomBlockHost,vn as getAutoBoundPropertyIdsByKey,lt as isLocalCustomBlockUrl,pt as toNotionDateValue,No as toNotionPageId};
|
|
1
|
+
var $e=6,Qe=6;function vn(e){let{manifestProperties:t,propertySchemasById:s}=e,i=[];for(let[c,l]of Object.entries(t)){let p=dn({propertyKey:c,manifestProperty:l,propertySchemasById:s});p!==void 0&&i.push([c,p])}return Object.fromEntries(i)}function dn(e){let{propertyKey:t,manifestProperty:s,propertySchemasById:i}=e,c=bt(s.name),l=Object.entries(i).filter(([p,y])=>y.type===s.type&&(p===t||bt(y.name)===c));return l.length===1?l[0][0]:void 0}function bt(e){return e.trim().toLowerCase()}var qe,hn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Xe(e){return!e&&!qe?hn:{lang:e?.lang??qe?.lang,message:e?.message,abortEarly:e?.abortEarly??qe?.abortEarly,abortPipeEarly:e?.abortPipeEarly??qe?.abortPipeEarly}}var gn;function bn(e){return gn?.get(e)}var Sn;function kn(e){return Sn?.get(e)}var In;function _n(e,t){return In?.get(e)?.get(t)}function he(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function w(e,t,s,i,c){let l=c&&"input"in c?c.input:s.value,p=c?.expected??e.expects??null,y=c?.received??he(l),m={kind:e.kind,type:e.type,input:l,expected:p,received:y,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},x=e.kind==="schema",_=c?.message??e.message??_n(e.reference,m.lang)??(x?kn(m.lang):null)??i.message??bn(m.lang);_!==void 0&&(m.message=typeof _=="function"?_(m):_),x&&(s.typed=!1),s.issues?s.issues.push(m):s.issues=[m]}var St=new WeakMap;function Q(e){let t=St.get(e);return t||(t={version:1,vendor:"valibot",validate(s){return e["~run"]({value:s},Xe())}},St.set(e,t)),t}function xn(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function We(e,t){let s=[...new Set(e)];return s.length>1?`(${s.join(` ${t} `)})`:s[0]??"never"}var Cn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ce(e){return{kind:"transformation",type:"brand",reference:ce,async:!1,name:e,"~run"(t){return t}}}function Ie(e){return{kind:"validation",type:"finite",reference:Ie,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,s){return t.typed&&!this.requirement(t.value)&&w(this,"finite",t,s),t}}}function Je(e,t){let s=he(e);return{kind:"validation",type:"includes",reference:Je,async:!1,expects:s,requirement:e,message:t,"~run"(i,c){return i.typed&&!i.value.includes(this.requirement)&&w(this,"content",i,c,{received:`!${s}`}),i}}}function Te(e,t){return{kind:"validation",type:"max_length",reference:Te,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&s.value.length>this.requirement&&w(this,"length",s,i,{received:`${s.value.length}`}),s}}}function _e(e,t){return{kind:"validation",type:"min_length",reference:_e,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&s.value.length<this.requirement&&w(this,"length",s,i,{received:`${s.value.length}`}),s}}}function xe(e,t){return{kind:"validation",type:"min_value",reference:xe,async:!1,expects:`>=${e instanceof Date?e.toJSON():he(e)}`,requirement:e,message:t,"~run"(s,i){return s.typed&&!(s.value>=this.requirement)&&w(this,"value",s,i,{received:s.value instanceof Date?s.value.toJSON():he(s.value)}),s}}}function Ke(e,t){return{kind:"validation",type:"regex",reference:Ke,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&!this.requirement.test(s.value)&&w(this,"format",s,i),s}}}function Ze(e){return{kind:"transformation",type:"transform",reference:Ze,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var It={abortEarly:!0};function _t(e,t,s){return typeof e.fallback=="function"?e.fallback(t,s):e.fallback}function Ae(e,t,s){return typeof e.default=="function"?e.default(t,s):e.default}function xt(e,t){return!e["~run"]({value:t},It).issues}function E(e,t){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(Array.isArray(c)){s.typed=!0,s.value=[];for(let l=0;l<c.length;l++){let p=c[l],y=this.item["~run"]({value:p},i);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:p};for(let x of y.issues)x.path?x.path.unshift(m):x.path=[m],s.issues?.push(x);if(s.issues||(s.issues=y.issues),i.abortEarly){s.typed=!1;break}}y.typed||(s.typed=!1),s.value.push(y.value)}}else w(this,"type",s,i);return s}}}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,s),t}}}function o(e,t){return{kind:"schema",type:"literal",reference:o,expects:he(e),async:!1,literal:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===this.literal?s.typed=!0:w(this,"type",s,i),s}}}function Ye(e){return{kind:"schema",type:"nan",reference:Ye,expects:"NaN",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return Number.isNaN(t.value)?t.typed=!0:w(this,"type",t,s),t}}}function F(e,t){return{kind:"schema",type:"nullable",reference:F,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===null&&(this.default!==void 0&&(s.value=Ae(this,s,i)),s.value===null)?(s.typed=!0,s):this.wrapped["~run"](s,i)}}}function P(e){return{kind:"schema",type:"number",reference:P,expects:"number",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,s),t}}}function n(e,t){return{kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(c&&typeof c=="object"){s.typed=!0,s.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],s.issues?.push(_);if(s.issues||(s.issues=m.issues),i.abortEarly){s.typed=!1;break}}m.typed||(s.typed=!1),s.value[l]=m.value}else if(p.fallback!==void 0)s.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(w(this,"key",s,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}}else w(this,"type",s,i);return s}}}function u(e,t){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===void 0&&(this.default!==void 0&&(s.value=Ae(this,s,i)),s.value===void 0)?(s.typed=!0,s):this.wrapped["~run"](s,i)}}}function T(e,t){return{kind:"schema",type:"picklist",reference:T,expects:We(e.map(he),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){return this.options.includes(s.value)?s.typed=!0:w(this,"type",s,i),s}}}function V(e,t,s){return{kind:"schema",type:"record",reference:V,expects:"Object",async:!1,key:e,value:t,message:s,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){i.typed=!0,i.value={};for(let p in l)if(xn(l,p)){let y=l[p],m=this.key["~run"]({value:p},c);if(m.issues){let _={type:"object",origin:"key",input:l,key:p,value:y};for(let C of m.issues)C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=m.issues),c.abortEarly){i.typed=!1;break}}let x=this.value["~run"]({value:y},c);if(x.issues){let _={type:"object",origin:"value",input:l,key:p,value:y};for(let C of x.issues)C.path?C.path.unshift(_):C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=x.issues),c.abortEarly){i.typed=!1;break}}(!m.typed||!x.typed)&&(i.typed=!1),m.typed&&(i.value[m.value]=x.value)}}else w(this,"type",i,c);return i}}}function f(e,t){return{kind:"schema",type:"strict_object",reference:f,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(c&&typeof c=="object"){s.typed=!0,s.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],s.issues?.push(_);if(s.issues||(s.issues=m.issues),i.abortEarly){s.typed=!1;break}}m.typed||(s.typed=!1),s.value[l]=m.value}else if(p.fallback!==void 0)s.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(w(this,"key",s,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}if(!s.issues||!i.abortEarly){for(let l in c)if(!(l in this.entries)){w(this,"key",s,i,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else w(this,"type",s,i);return s}}}function r(e){return{kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,s),t}}}function kt(e){let t;if(e)for(let s of e)if(t)for(let i of s.issues)t.push(i);else t=s.issues;return t}function g(e,t){return{kind:"schema",type:"union",reference:g,expects:We(e.map(s=>s.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c,l,p;for(let y of this.options){let m=y["~run"]({value:s.value},i);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else p?p.push(m):p=[m]}if(c)return c;if(l){if(l.length===1)return l[0];w(this,"type",s,i,{issues:kt(l)}),s.typed=!0}else{if(p?.length===1)return p[0];w(this,"type",s,i,{issues:kt(p)})}return s}}}function Ce(){return{kind:"schema",type:"unknown",reference:Ce,expects:"unknown",async:!1,get"~standard"(){return Q(this)},"~run"(e){return e.typed=!0,e}}}function v(e,t,s){return{kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:s,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){let p,y=0,m=this.key,x=[],_=(C,b)=>{for(let L of C.options){if(L.type==="variant")_(L,new Set(b).add(L.key));else{let q=!0,A=0;for(let O of b){let H=L.entries[O];if(O in l?H["~run"]({typed:!1,value:l[O]},It).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){q=!1,m!==O&&(y<A||y===A&&O in l&&!(m in l))&&(y=A,m=O,x=[]),m===O&&x.push(L.entries[O].expects);break}A++}if(q){let O=L["~run"]({value:l},c);(!p||!p.typed&&O.typed)&&(p=O)}}if(p&&!p.issues)break}};if(_(this,new Set([this.key])),p)return p;w(this,"type",i,c,{input:l[m],expected:We(x,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else w(this,"type",i,c);return i}}}function ie(e,t,s){let i=e["~run"]({value:t},Xe(s));if(i.issues)throw new Cn(i.issues);return i.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return Q(this)},"~run"(t,s){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!s.abortEarly&&!s.abortPipeEarly)&&(t=i["~run"](t,s))}return t}}}function Pe(e,t,s){let i=e["~run"]({value:t},Xe(s));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var le=z(r(),ce("NotionBlockId")),K=z(r(),ce("NotionDataSourceId")),U=z(r(),ce("NotionPageId")),Ct=z(r(),ce("NotionAgentId")),Pt=z(r(),ce("NotionSpaceId"));var Et=T(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),et=n({id:r(),name:r(),color:u(Et),description:u(r())}),Pn=n({id:r(),name:r(),color:u(Et),option_ids:E(r())}),En=n({synced_property_id:r(),synced_property_name:r()}),R=n({name:r(),description:u(r())}),On=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],Ot=T(On),jt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],tt=v("type",[n({...R.entries,type:o("title")}),n({...R.entries,type:o("rich_text")}),n({...R.entries,type:o("number")}),n({...R.entries,type:o("checkbox")}),n({...R.entries,type:o("url")}),n({...R.entries,type:o("email")}),n({...R.entries,type:o("phone_number")}),n({...R.entries,type:o("select"),options:E(et)}),n({...R.entries,type:o("multi_select"),options:E(et)}),n({...R.entries,type:o("status"),options:E(et),groups:E(Pn)}),n({...R.entries,type:o("date")}),n({...R.entries,type:o("people")}),n({...R.entries,type:o("files")}),n({...R.entries,type:o("unique_id")}),n({...R.entries,type:o("relation"),data_source_id:u(r()),dual_property:u(En)}),n({...R.entries,type:o("place")}),n({...R.entries,type:o("formula")}),n({...R.entries,type:o("rollup")}),n({...R.entries,type:o("button")}),n({...R.entries,type:o("verification")}),n({...R.entries,type:o("last_visited_time")}),n({...R.entries,type:o("location")}),n({...R.entries,type:o("created_time")}),n({...R.entries,type:o("last_edited_time")}),n({...R.entries,type:o("created_by")}),n({...R.entries,type:o("last_edited_by")})]);var Rt=n({id:K,table:r(),spaceId:u(Pt)}),Mt=n({id:u(K),propertiesById:V(r(),tt)}),$o=n({key:r(),collectionPointer:u(Rt),collectionSchema:u(Mt),propertyIdsByKey:V(r(),u(r())),propertySchemasById:V(r(),tt)}),jn=n({collectionPointer:u(Rt),collectionSchema:u(Mt),propertyIdsByKey:u(V(r(),u(r())))}),me=V(r(),jn);var ge=T(["standard","high"]),Bt="standard";var Dt=n({type:o("contrastModeChanged"),contrastMode:ge});var Ne=n({unit:T(["year","month","week","day"]),value:P(),time:r(),defaultTimeZone:u(r())}),Rn=n({unit:T(["hour","minute"]),value:P()}),Ee=n({unit:o("none")}),rt=g([Ne,Rn]),wt=u(g([Ne,Ee])),qt=u(g([rt,Ee])),Mn=n({type:o("date"),start_date:r(),reminder:wt}),Bn=n({type:o("daterange"),start_date:r(),end_date:r(),reminder:wt}),Dn=n({type:o("datetime"),start_date:r(),start_time:r(),time_zone:u(r()),reminder:qt}),wn=n({type:o("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:u(r()),reminder:qt}),Tt=v("type",[Mn,Bn,Dn,wn]);var Ue=n({id:r(),table:r()});var ae=v("type",[n({type:o("page_id"),page_id:U}),n({type:o("data_source_id"),data_source_id:K}),n({type:o("workspace"),workspace:o(!0)}),n({type:o("block_id"),block_id:le}),n({type:o("agent_id"),agent_id:Ct}),n({type:o("unavailable")})]);var be=v("type",[n({type:o("unavailable")}),n({type:o("page"),id:U,parent:ae})]),qn=n({type:o("emoji"),emoji:r()}),Tn=n({type:o("custom_emoji"),custom_emoji:n({id:r(),name:u(r()),url:u(r())})}),Nt=n({type:o("external"),external:n({url:r()})}),Ut=n({type:o("file"),file:n({url:r(),expiry_time:u(r())})}),ze=v("type",[qn,Tn,Nt,Ut]),Le=v("type",[Nt,Ut]),Z=F(r()),At=V(r(),Ce()),nt=g([n({id:r(),name:u(r()),color:u(r()),description:u(Z)}),n({name:r(),id:u(r()),color:u(r()),description:u(Z)})]),ot={start:r(),end:u(Z),time_zone:u(Z),reminder:u(g([rt,Ee]))},An=g([n({...ot,start:z(r(),Je("T"))}),n({...ot,time_zone:r()}),n({...ot,reminder:u(g([Ne,Ee]))})]),Nn=g([n({object:u(o("user")),id:r()}),n({object:o("group"),id:r(),name:u(Z)})]),Un=n({id:r()}),Fn=g([n({type:o("external"),name:r(),external:n({url:r()})}),n({type:o("file"),name:r(),file:n({url:r(),expiry_time:u(r())})})]),zn=n({lat:P(),lon:P(),name:u(Z),address:u(Z),aws_place_id:u(Z),google_place_id:u(Z)}),M={id:r()},Fe=F(n({...Ue.entries,table:T(["notion_user","bot","organization_bot"]),spaceId:u(r())})),Ft=v("type",[n({...M,type:o("title"),title:E(At)}),n({...M,type:o("rich_text"),rich_text:E(At)}),n({...M,type:o("number"),number:F(P())}),n({...M,type:o("url"),url:Z}),n({...M,type:o("email"),email:Z}),n({...M,type:o("phone_number"),phone_number:Z}),n({...M,type:o("checkbox"),checkbox:h()}),n({...M,type:o("select"),select:F(nt)}),n({...M,type:o("status"),status:F(nt)}),n({...M,type:o("multi_select"),multi_select:E(nt)}),n({...M,type:o("date"),date:F(An)}),n({...M,type:o("people"),people:E(Nn)}),n({...M,type:o("relation"),has_more:u(h()),relation:E(Un)}),n({...M,type:o("files"),files:E(Fn)}),n({...M,type:o("place"),place:F(zn)}),n({...M,type:o("created_time"),created_time:Z}),n({...M,type:o("last_edited_time"),last_edited_time:Z}),n({...M,type:o("created_by"),created_by:Fe}),n({...M,type:o("last_edited_by"),last_edited_by:Fe}),n({...M,type:o("last_visited_time"),last_visited_time:Z}),n({...M,type:o("unique_id"),unique_id:r()}),n({...M,type:o("button"),button:r()}),n({...M,type:o("formula"),formula:r()}),n({...M,type:o("location"),location:r()}),n({...M,type:o("rollup"),rollup:r()}),n({...M,type:o("verification"),verification:r()})]),Oe=V(r(),Ft),Ln=V(r(),F(Ft)),ne=n({object:o("page"),id:U,parent:ae,properties:Ln,created_by:u(Fe,null),last_edited_by:u(Fe,null),last_visited_time:u(F(r()),null),created_time:u(F(r()),null),last_edited_time:u(F(r()),null),icon:u(F(ze),null),cover:u(F(Le),null),url:u(F(r()),null),public_url:u(F(r()),null),is_archived:h(),in_trash:h()}),Se=n({object:o("page"),id:U,parent:ae,properties:Oe,created_time:u(r()),last_edited_time:u(r()),icon:u(ze),cover:u(Le),url:u(r()),public_url:u(r()),is_archived:h(),in_trash:h()});var Hn=r(),zt=n({code:Hn,message:r(),isRetryable:h()}),Lt=v("status",[n({type:o("createPageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("createPageResult"),requestId:r(),status:o("error"),error:zt})]),Ht=v("status",[n({type:o("createPageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("createPageResult"),requestId:r(),status:o("error"),error:zt})]);var st=z(r(),ce("NotionUserId")),pe=n({object:o("user"),id:st,name:u(r()),avatar_url:F(r()),type:o("person"),person:n({email:r()})}),Vt=n({object:o("list"),results:E(pe),next_cursor:F(r()),has_more:h(),type:o("user"),user:V(r(),Ce())});var Gt=n({type:o("currentUserChanged"),currentUser:pe});var $t=n({type:o("dataSourcesChanged"),dataSources:n({bindings:me})});var Vn=r(),Qt=n({code:Vn,message:r(),isRetryable:h()}),Xt=n({type:o("getPage"),requestId:r(),pageId:U,dataSourceId:u(K)}),Wt=v("status",[n({type:o("getPageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("getPageResult"),requestId:r(),status:o("error"),error:Qt})]),Jt=v("status",[n({type:o("getPageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("getPageResult"),requestId:r(),status:o("error"),error:Qt})]);var Gn=r(),$n=n({code:Gn,message:r(),isRetryable:h()}),Kt=n({type:o("getUser"),requestId:r(),userId:st}),Zt=v("status",[n({type:o("getUserResult"),requestId:r(),status:o("success"),user:pe}),n({type:o("getUserResult"),requestId:r(),status:o("error"),error:$n})]);var Qn=v("type",[n({type:o("emoji"),emoji:r()}),n({type:o("external"),url:r()})]),Xn=n({name:r(),description:u(r()),type:Ot}),Wn=n({name:r(),description:u(r()),icon:u(Qn),properties:u(V(r(),Xn),{})}),ye=n({version:o(1),name:u(r()),description:u(r()),slashCommand:u(r()),icon:u(n({type:o("emoji"),emoji:r()})),dataSources:u(V(r(),Wn),{})});var ke=T(["light","dark"]);var Jn=r(),Kn=n({code:Jn,message:r(),isRetryable:h()});var He=v("status",[n({type:o("init"),initializationId:r(),status:o("success"),theme:ke,contrastMode:ge,blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe}),n({type:o("init"),initializationId:r(),status:o("error"),error:Kn})]);var Yt=n({type:o("invalidSandboxMessage"),reason:r()});var Zn=r(),Yn=n({code:Zn,message:r(),isRetryable:h()}),er=n({type:o("listUsers"),requestId:r(),startCursor:u(r()),pageSize:u(P())}),tr=v("status",[n({type:o("listUsersResult"),requestId:r(),status:o("success"),list:Vt}),n({type:o("listUsersResult"),requestId:r(),status:o("error"),error:Yn})]);var eo=r(),to=n({code:eo,message:r(),isRetryable:h()}),rr=n({type:o("openExternalUrl"),requestId:r(),url:r()}),nr=v("status",[n({type:o("openExternalUrlResult"),requestId:r(),status:o("success")}),n({type:o("openExternalUrlResult"),requestId:r(),status:o("error"),error:to})]);var ro=T(["side_peek","center_peek"]),no=r(),oo=n({code:no,message:r(),isRetryable:h()}),or=n({type:o("openPage"),requestId:r(),pageId:U,mode:ro}),sr=v("status",[n({type:o("openPageResult"),requestId:r(),status:o("success"),pageId:U}),n({type:o("openPageResult"),requestId:r(),status:o("error"),error:oo})]);var ir=n({type:o("pageChanged"),page:be});var ar=n({type:o("parentChanged"),parent:ae});var ur=g([r(),P(),h(),Tt,E(r()),E(Ue)]);var cr=n({id:U,is_archived:h(),in_trash:h(),propertiesById:V(r(),u(ur))});var so=r(),lr=n({code:so,message:r(),isRetryable:h()}),pr=v("status",[n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("success"),items:E(ne),hasMore:h()}),n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("error"),error:lr})]),fr=v("status",[n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("success"),items:E(g([ne,cr])),hasMore:h()}),n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("error"),error:lr})]);var mr=n({type:o("themeChanged"),theme:ke});var io=r(),yr=n({code:io,message:r(),isRetryable:h()}),vr=v("status",[n({type:o("updatePageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("updatePageResult"),requestId:r(),status:o("error"),error:yr})]),dr=v("status",[n({type:o("updatePageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("updatePageResult"),requestId:r(),status:o("error"),error:yr})]);var hr=v("type",[He,mr,Dt,ar,ir,Gt,$t,Zt,tr,sr,nr,Yt]),gr=v("type",[...hr.options,pr,Wt,Lt,vr]),vi=v("type",[...hr.options,fr,Jt,Ht,dr]);function br(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Sr(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function it(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function at(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:s}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${s}.`,isRetryable:!1}}function ut(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function kr(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Ir(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function _r(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function xr(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Cr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Pr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function je(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function re(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function ct(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var ao=5e3,uo=5e3,co=5e3;function Er(e){let{prepareInit:t,sendInitMessage:s,warn:i,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:p=ao,initialStateTimeoutMs:y=uo,noInitResultTimeoutMs:m=co,stopHostWithFailure:x,onInitResult:_,onConnectionFailure:C}=e,b="waitingForConnect",L,q,A,O,H=!1,$=!1;function X(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function ue(){q!==void 0&&(window.clearTimeout(q),q=void 0)}function W(){A!==void 0&&(window.clearTimeout(A),A=void 0)}function B(S){let{initializationId:I,error:J,phase:oe,source:N}=S;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return re(b)}b="error",O=I,X(),ue(),s({type:"init",initializationId:I,status:"error",error:J}),C?.({...J,phase:oe,source:N})}async function G(S){if(b==="waitingForConnect"){b="preparingInit",O=S.initializationId,X(),q=window.setTimeout(()=>{if(b!=="preparingInit")return;let I=kr();i({...I,initializationId:S.initializationId}),B({initializationId:S.initializationId,error:I,phase:"init",source:"host"})},y);try{let I=await t(S);if(b!=="preparingInit")return;if(ue(),I.status==="error"){B({initializationId:S.initializationId,error:I.error,phase:"init",source:"host"});return}b="waitingForInitResult";let J={type:"init",initializationId:S.initializationId,status:"success",theme:I.initialState.theme,contrastMode:I.initialState.contrastMode??Bt,blockId:I.initialState.blockId,parent:I.initialState.parent,page:I.initialState.page,currentUser:I.initialState.currentUser,manifest:I.initialState.manifest,dataSources:I.initialState.dataSources};s(J),A=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="error";let oe=Cr();C?.({...oe,phase:"initResult",source:"host"}),i({...oe,initializationId:S.initializationId})},m)}catch(I){if(b!=="preparingInit")return;i({message:"Failed to prepare custom block initialization",error:I}),B({initializationId:S.initializationId,error:je(),phase:"init",source:"host"})}}}function ee(S){if(b!=="stopped"&&b==="waitingForConnect"){if(!ct(S.bridgeProtocolVersion)){let I=it({currentBridgeProtocolVersion:S.bridgeProtocolVersion});B({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.bridgeProtocolVersion<l){let I=at({currentBridgeProtocolVersion:S.bridgeProtocolVersion,minBridgeProtocolVersion:l});B({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.status==="error"){B({initializationId:S.initializationId,error:S.error,phase:"connect",source:"sandbox"});return}$=!0,G(S)}}function se(S){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:I,bridgeProtocolVersion:J}=S;if(I===void 0)return"nack";let oe=S.error;return J!==void 0&&(ct(J)?J<l&&(oe=at({currentBridgeProtocolVersion:J,minBridgeProtocolVersion:l})):oe=it({currentBridgeProtocolVersion:J})),B({initializationId:I,error:oe,phase:"connect",source:"host"}),"handled"}function D(S){let{initializationId:I,error:J}=S;b!=="waitingForInitResult"||I===void 0||I!==O||(X(),W(),b="error",i(J),C?.({...J,phase:"initResult",source:"host"}))}function te(){if(b!=="stopped"){if(H){x({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}H=!0,X(),b==="waitingForConnect"&&(L=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="error";let S=br();i(S),C?.({...S,phase:"connect",source:"host"})},p))}}function fe(S){if(b!=="waitingForInitResult"||S.initializationId!==O){i({message:"Ignored stale or unexpected initResult",payload:S});return}W(),b=S.status==="success"?"initialized":"error",S.status==="success"?c():C?.({...S.error,phase:"initResult",source:"sandbox"}),_?.(S)}function we(){b="stopped",X(),ue(),W()}return{get status(){return b},get hasConnectedSandbox(){return $},handleConnect:ee,handleInitResult:fe,handleInvalidConnect:se,handleInvalidInitResult:D,onIframeLoad:te,stop:we}}function lt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}async function Or(e){let t=new AbortController,s=()=>t.abort();e.signal.addEventListener("abort",s,{once:!0});let i=new Promise((l,p)=>{t.signal.addEventListener("abort",()=>p(t.signal.reason),{once:!0})});e.signal.aborted&&t.abort();let c=e.manifestSource==="local"?window.setTimeout(()=>{t.abort(new Error("Manifest loading timed out after 5000 ms."))},5e3):void 0;try{let l=await Promise.race([e.manifestSource==="local"?lo(e.sandboxOrigin,t.signal):e.getPersistedManifest({signal:t.signal}),i]);if(t.signal.aborted)throw new Error("Manifest loading was cancelled.");return{status:"success",manifest:ie(ye,l)}}catch(l){return e.signal.aborted||e.onError(l),{status:"error",error:{code:"manifest_unavailable",message:"The custom block manifest is unavailable.",isRetryable:!0}}}finally{window.clearTimeout(c),e.signal.removeEventListener("abort",s)}}async function lo(e,t){let s=new URL(e);if(!lt({url:s,hostOrigin:window.location.origin}))throw new Error("Preview requires a separate loopback origin.");let i=await fetch(new URL("/manifest",s),{credentials:"omit",redirect:"error",cache:"no-store",signal:t});if(!i.ok)throw new Error(`Manifest request failed: HTTP ${i.status}.`);return i.json()}var de=class extends Error{};function pt(e){try{return po(e)}catch(t){throw t instanceof RangeError?new de(t.message):t}}function po(e){let{start:t,end:s,time_zone:i,reminder:c}=e;if(!t.split("T")[0])throw new de("Date values must include a date.");let l=t.includes("T")||i!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),y=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,m=i?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=m?(Number(m[2]??0)*60+Number(m[3]??0))*(m[1]==="-"?-1:1):y,_=q=>{if(!q.split("T")[0])throw new de("Date values must include a date.");if(!q.includes("T"))return{date:q,time:"00:00"};let A=q.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(A)return{date:A[1],time:A[2]};if(!i||m){let $=new Date(new Date(q).getTime()+x*6e4).toISOString();return{date:$.slice(0,10),time:$.slice(11,16)}}let O=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(q)),H=$=>O.find(X=>X.type===$)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},C=_(t),b=s?_(s):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new de("Hour and minute reminders require a date with a time.");return b?{type:"daterange",start_date:C.date,end_date:b.date,reminder:c}:{type:"date",start_date:C.date,reminder:c}}let L=i??(y===0?"UTC":`UTC${y<0?"-":"+"}${Math.floor(Math.abs(y)/60)}${Math.abs(y)%60===0?"":`:${String(Math.abs(y)%60).padStart(2,"0")}`}`);return b?{type:"datetimerange",start_date:C.date,start_time:C.time,end_date:b.date,end_time:b.time,time_zone:L,reminder:c}:{type:"datetime",start_date:C.date,start_time:C.time,time_zone:L,reminder:c}}function Rr(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Mr(e){let t={};for(let s of Object.values(e.properties))s&&(t[s.id]=fo(s));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:t}}function jr(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let s=t.text;return s&&typeof s=="object"&&"content"in s&&typeof s.content=="string"?s.content:""}).join("")}function ft(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}function fo(e){switch(e.type){case"title":return jr(e.title);case"rich_text":return jr(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?pt(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return ft(e.created_time);case"last_edited_time":return ft(e.last_edited_time);case"last_visited_time":return ft(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return re(e)}}function Br(e,t){if(t>=6||e.status==="error")return e;switch(e.type){case"queryDataSourceResult":return{...e,items:e.items.map(Mr)};case"getPageResult":case"createPageResult":case"updatePageResult":return{...e,page:Rr(e.page)};default:return re(e)}}function Dr(e,t){return e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"?e:Br(e,t)}var wr=n({theme:ke,contrastMode:u(ge),blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe});function qr(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}function Tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Ar=n({code:r(),message:r(),isRetryable:h()});var Nr={type:o("connect"),initializationId:r(),bridgeProtocolVersion:P(),sdkVersion:r()},Ur=v("status",[n({status:o("success"),manifest:u(ye),...Nr}),n({status:o("error"),error:Ar,...Nr})]);var mo=v("type",[n({type:o("start")}),n({type:o("end")}),n({type:o("before"),blockId:le}),n({type:o("after"),blockId:le})]),yo=v("type",[n({type:o("page_id"),page_id:U}),n({type:o("data_source_id"),data_source_id:K})]),Fr=n({type:o("createPage"),requestId:r(),parent:yo,properties:Oe,position:u(mo)});var vo=r(),ho=n({code:vo,message:r(),isRetryable:h()}),zr=v("status",[n({type:o("initResult"),initializationId:r(),status:o("success"),initialHeight:u(z(P(),Ie(),xe(0)))}),n({type:o("initResult"),initializationId:r(),status:o("error"),error:ho})]);var Lr=n({type:o("invalidHostMessage"),reason:r()});var Hr=T(["ascending","descending"]);var Vr=z(U,Ke(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),mt=g([f({contains:Vr}),f({does_not_contain:Vr})]),De=g([f({is_empty:o(!0)}),f({is_not_empty:o(!0)})]),Be=g([r(),E(r())]),Gr=f({object:T(["user","group"]),id:z(r(),_e(1))}),go=g([f({contains:Gr}),f({does_not_contain:Gr}),De]),$r=f({object:o("user"),id:z(r(),_e(1),Te(2e3))}),bo=g([f({contains:$r}),f({does_not_contain:$r}),f({is_empty:o(!0)}),f({is_not_empty:o(!0)})]),Re=g([f({equals:r()}),f({does_not_equal:r()}),f({contains:r()}),f({does_not_contain:r()}),f({starts_with:r()}),f({ends_with:r()}),De]),So=g([f({equals:P()}),f({does_not_equal:P()}),f({greater_than:P()}),f({less_than:P()}),f({greater_than_or_equal_to:P()}),f({less_than_or_equal_to:P()}),De]),ko=g([f({equals:h()}),f({does_not_equal:h()})]),Jr=g([f({equals:Be}),f({does_not_equal:Be}),De]),Qr=T(["To-do","In progress","Complete","Current","Future"]),Xr=g([Qr,z(E(Qr),_e(1),Te(5))]),Io=g([f({group_equals:Xr}),f({group_does_not_equal:Xr})]),_o=g([Jr,Io]),xo=g([f({contains:Be}),f({contains_all:Be}),f({does_not_contain:Be}),De]),Y=T(["start_date","end_date"]),Co=T(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Me=g([Co,r()]),Po=g([f({target:u(Y),equals:Me}),f({target:u(Y),before:Me}),f({target:u(Y),after:Me}),f({target:u(Y),on_or_before:Me}),f({target:u(Y),on_or_after:Me}),f({target:u(Y),this_week:f({})}),f({target:u(Y),past_week:f({})}),f({target:u(Y),past_month:f({})}),f({target:u(Y),past_year:f({})}),f({target:u(Y),next_week:f({})}),f({target:u(Y),next_month:f({})}),f({target:u(Y),next_year:f({})}),f({target:u(Y),is_empty:o(!0)}),f({target:u(Y),is_not_empty:o(!0)})]),Wr=g([f({propertyId:r(),relation:mt}),f({propertyId:r(),created_by:bo}),f({propertyId:r(),title:Re}),f({propertyId:r(),rich_text:Re}),f({propertyId:r(),url:Re}),f({propertyId:r(),email:Re}),f({propertyId:r(),phone_number:Re}),f({propertyId:r(),number:So}),f({propertyId:r(),checkbox:ko}),f({propertyId:r(),select:Jr}),f({propertyId:r(),multi_select:xo}),f({propertyId:r(),status:_o}),f({propertyId:r(),date:Po}),f({propertyId:r(),people:go})]),Eo=g([Wr,f({and:E(Wr)})]),yt=10,Oo=f({propertyId:r(),direction:Hr}),Kr=n({type:o("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:P(),filter:u(Eo),sorts:u(E(Oo))});var Zr=n({type:o("resize"),height:z(P(),Ie(),xe(0))});var Yr=n({type:o("unsubscribeDataSourceQuery"),subscriptionId:r()});var en=n({type:o("updatePage"),requestId:r(),pageId:U,dataSourceId:u(K),properties:u(Oe),icon:u(ze),cover:u(Le),archived:u(h())});var tn=v("type",[Ur,zr,Kr,Yr,Fr,Xt,Kt,er,or,rr,en,Zr,Lr]);function rn(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function nn(e){let t=rn(e);return t==="invalidHostMessage"||t==="invalidSandboxMessage"?{incomingType:t}:{incomingType:t,nack:{type:"invalidSandboxMessage",reason:jo(t)}}}function jo(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var on=n({initializationId:r()}),Ro=n({bridgeProtocolVersion:g([P(),Ye()])});function sn(e){let{iframe:t,sandboxOrigin:s,getInitStatus:i,emit:c,sendNack:l,onInvalidConnect:p,onInvalidInitResult:y,onConnect:m,onInitResult:x,onQueryDataSource:_,onUnsubscribeDataSourceQuery:C,onCreatePage:b,onGetPage:L,onOpenPage:q,onOpenExternalUrl:A,onGetUser:O,onListUsers:H,onUpdatePage:$,onResize:X}=e;function ue(W,B){c("warn",{message:"Ignored unsupported sandbox message",payload:vt(W),issues:B});let G=nn(W);if(G.incomingType==="connect"){let ee=Pe(on,W),se=Pe(Ro,W);if(p({initializationId:ee.success?ee.output.initializationId:void 0,error:Sr(),bridgeProtocolVersion:se.success?se.output.bridgeProtocolVersion:void 0})==="handled")return}if(G.incomingType==="initResult"){let ee=Pe(on,W);y({initializationId:ee.success?ee.output.initializationId:void 0,error:Pr()})}G.nack!==void 0&&i()!=="stopped"&&l(G.nack)}return function(B){let G=B.source===t.contentWindow,ee=B.origin===s;if(!G||!ee)return;let se=Pe(tn,B.data);if(!se.success){ue(B.data,se.issues);return}let D=se.output;if(!Tr(D)&&i()!=="initialized"){c("warn",{message:`Ignored ${D.type} before initialization completed`,payload:vt(D)});return}switch(c("in",vt(D)),D.type){case"connect":m(D);return;case"initResult":x(D);return;case"queryDataSource":_(D);return;case"unsubscribeDataSourceQuery":C(D);return;case"createPage":b(D);return;case"openPage":q(D);return;case"openExternalUrl":A(D);return;case"getPage":L(D);return;case"getUser":O(D);return;case"listUsers":H(D);return;case"updatePage":$(D);return;case"resize":X(D);return;case"invalidHostMessage":return;default:re(D)}}}function vt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}var Ve=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let s={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:s,isRefreshing:!0,shouldRefreshAgain:!1}),s}isCurrent(t,s){return this.bySubscriptionId.get(t)?.token===s}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let s=[],i=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(i=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,s.push({message:c.message,token:c.token})}return i?s:void 0}finish(t,s){let i=this.bySubscriptionId.get(t);if(i?.token===s&&(i.isRefreshing=!1,!!i.shouldRefreshAgain))return i.shouldRefreshAgain=!1,i.isRefreshing=!0,{message:i.message,token:i.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function an(e,t){if(e===void 0)return;let s="and"in e?e.and:[e];for(let i of s){let c=Mo(i,t);if(c!==void 0)return c}}function Mo(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let s=t.propertiesById[e.propertyId],i=Object.keys(e).find(y=>y!=="propertyId");if(i!==s.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${i}" does not match property type "${s.type}".`,isRetryable:!1};if("status"in e&&s.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,_=(Array.isArray(m)?m:[m]).find(C=>!s.groups.some(b=>b.name===C));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!xt(mt,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Bo(e);if(c===void 0||s.type!==c.propertyType)return;let l=new Set(s.options.map(y=>y.name)),p=Do(c.operator).find(y=>!l.has(y));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Bo(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function Do(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:re(e);return Array.isArray(t)?t:[t]}var wo=new Set(jt);function un(e,t){if(e===void 0)return;if(e.length>yt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${yt} entries.`,isRetryable:!1};let s=new Set;for(let i of e){if(s.has(i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${i.propertyId}".`,isRetryable:!1};if(s.add(i.propertyId),!Object.hasOwn(t.propertiesById,i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${i.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=t.propertiesById[i.propertyId];if(!wo.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var ln=5;function qo(e){let{iframe:t,prepareInitialState:s,handlers:i,onInitialized:c,onConnectionFailure:l,onLog:p,onQueryUnsubscribed:y,sandboxOrigin:m,minBridgeProtocolVersion:x,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b}=e,L=Math.max(x??3,3),q=new AbortController,A,O={},H=!1,$=new AbortController,X,ue,W=6,B=new Ve(a=>{y?.(a)});function G(a,k){p?.(a,k)}function ee(a){let k=N.status;switch(k){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return re(k)}let j=Dr(a,W);G("out",j),t.contentWindow?.postMessage(j,m)}function se(a){ee(ie(He,a))}function D(a){ee(a)}function te(a){let k=N.status;switch(k){case"initialized":ee(ie(gr,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:re(k)}}async function fe(a,k){if(k===void 0)return;let j=await k(a);te({type:`${a.type}Result`,requestId:a.requestId,...j})}function we(a){let k=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};te(k)}async function S(a,k=B.subscribe(a)){try{let j=To(ue,a.dataSourceId),ve=Ao(a,j);if(ve!==void 0){B.isCurrent(a.subscriptionId,k)&&(B.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:{status:"error",error:ve}}));return}let Ge=await i.queryDataSource(a);if(!B.isCurrent(a.subscriptionId,k))return;Ge.status==="error"&&!Ge.error.isRetryable&&B.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:Ge})}finally{let j=B.finish(a.subscriptionId,k);j!==void 0&&S(j.message,j.token)}}function I(a){N.status==="stopped"||N.status==="error"||(Object.assign(O,a),oe())}async function J(a){if(i.openExternalUrl===void 0||q.signal.aborted||A===a.requestId)return;if(A!==void 0){let j={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};te(j);return}let k=qr(a.url);if(k===void 0){let j={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};te(j);return}A=a.requestId;try{let j=await i.openExternalUrl({...a,url:k},{signal:q.signal});if(q.signal.aborted)return;let ve={type:"openExternalUrlResult",requestId:a.requestId,...j};te(ve)}catch(j){if(!q.signal.aborted)throw j}finally{A===a.requestId&&(A=void 0)}}function oe(){if(N.status!=="initialized")return;let a=O;O={},a.theme!==void 0&&te({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&te({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&te({type:"parentChanged",parent:a.parent}),a.page!==void 0&&te({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&te({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&te({type:"currentUserChanged",currentUser:a.currentUser})}let N=Er({async prepareInit(a){W=a.bridgeProtocolVersion;let k=await mn;return N.status!=="preparingInit"?k:fn(k)},sendInitMessage:se,warn:a=>G("warn",a),flushPendingHostStateChanges:oe,minBridgeProtocolVersion:L,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b,stopHostWithFailure:gt,onInitResult(a){a.status==="success"&&X!==void 0&&c?.({manifest:X,initialHeight:a.initialHeight})},onConnectionFailure:a=>{$.abort(),l?.(a)}});function fn(a){if(a.status==="error")return a;let k=ie(wr,{...a.initialState,...O});if(X=k.manifest,O={},W<ln&&k.page.type==="unavailable")return{status:"error",error:ut()};let j=pn(k.manifest,k.dataSources);return j!==void 0?{status:"error",error:j}:(ue=k.dataSources,H=!0,{status:"success",initialState:k})}let mn=yn().catch(a=>($.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:a}),{status:"error",error:je()}));async function yn(){let a=await Or({...e,sandboxOrigin:m,signal:$.signal,onError:j=>{G("warn",{message:"Failed to load custom block manifest",error:j})}});if(a.status==="error")return a;if($.signal.aborted)return{status:"error",error:je()};let k=await s({manifest:a.manifest,signal:$.signal});return k.status==="error"?k:{status:"success",initialState:{...k.initialState,manifest:a.manifest}}}let dt=sn({iframe:t,sandboxOrigin:m,getInitStatus:()=>N.status,emit:G,sendNack:D,onInvalidConnect:N.handleInvalidConnect,onInvalidInitResult:N.handleInvalidInitResult,onConnect:N.handleConnect,onInitResult:N.handleInitResult,onQueryDataSource:S,onUnsubscribeDataSourceQuery:a=>B.unsubscribe(a.subscriptionId),onOpenExternalUrl:J,onCreatePage:a=>fe(a,i.createPage),onGetPage:a=>fe(a,i.getPage),onOpenPage:a=>fe(a,i.openPage),onGetUser:a=>fe(a,i.getUser),onListUsers:a=>fe(a,i.listUsers),onUpdatePage:a=>fe(a,i.updatePage),onResize:a=>i.resize?.(a)});window.addEventListener("message",dt),t.addEventListener("load",N.onIframeLoad);function ht(){q.abort(),$.abort(),window.removeEventListener("message",dt),t.removeEventListener("load",N.onIframeLoad),N.stop(),B.unsubscribeAll()}function gt(a){ht(),G("warn",a),l?.(a)}return{stop:ht,setTheme(a){I({theme:a})},setContrastMode(a){I({contrastMode:a})},setParent(a){I({parent:a})},setPage(a){if(a.type==="unavailable"&&W<ln&&(N.status==="preparingInit"&&H||N.status==="waitingForInitResult"||N.status==="initialized")){gt({...ut(),phase:"runtime",source:"host"});return}I({page:a})},setCurrentUser(a){I({currentUser:a})},setDataSources(a){let k={bindings:ie(me,a.bindings)};if(N.hasConnectedSandbox&&X!==void 0&&pn(X,k)!==void 0){G("warn",{message:"Ignored invalid data source bindings update",payload:k});return}ue=k,I({dataSources:k})},refreshQuery({dataSourceId:a}){if(N.status!=="initialized")return;let k=ie(K,a),j=B.refresh(k);if(j===void 0){G("warn",`No active query exists for data source "${a}"`);return}for(let ve of j)S(ve.message,ve.token)}}}function To(e,t){return Object.values(e?.bindings??{}).find(s=>s.collectionPointer?.id===t)?.collectionSchema}function pn(e,t){for(let[s,i]of Object.entries(e.dataSources)){let c=t.bindings[s];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Ir();for(let[l,p]of Object.entries(i.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return _r();if(c.collectionSchema.propertiesById[y]?.type!==p.type)return xr()}}}function Ao(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:an(e.filter,t)??un(e.sorts,t)}function No(e){return ie(U,e)}export{de as InvalidNotionDateError,$e as LATEST_BRIDGE_PROTOCOL_VERSION,Qe as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,qo as createCustomBlockHost,vn as getAutoBoundPropertyIdsByKey,lt as isLocalCustomBlockUrl,pt as toNotionDateValue,No as toNotionPageId};
|
|
@@ -93,6 +93,18 @@ function toLegacyProperty(property) {
|
|
|
93
93
|
return property.relation.map(page => ({ id: page.id, table: "block" }));
|
|
94
94
|
case "files":
|
|
95
95
|
return property.files.map(file => file.name).join(",");
|
|
96
|
+
case "unique_id":
|
|
97
|
+
return property.unique_id;
|
|
98
|
+
case "button":
|
|
99
|
+
return property.button;
|
|
100
|
+
case "formula":
|
|
101
|
+
return property.formula;
|
|
102
|
+
case "location":
|
|
103
|
+
return property.location;
|
|
104
|
+
case "rollup":
|
|
105
|
+
return property.rollup;
|
|
106
|
+
case "verification":
|
|
107
|
+
return property.verification;
|
|
96
108
|
case "place":
|
|
97
109
|
return "";
|
|
98
110
|
case "created_time":
|
|
@@ -247,6 +247,30 @@ export declare const createPageMessageSchema: v.ObjectSchema<{
|
|
|
247
247
|
readonly id: v.StringSchema<undefined>;
|
|
248
248
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
249
249
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
250
|
+
}, undefined>, v.ObjectSchema<{
|
|
251
|
+
readonly id: v.StringSchema<undefined>;
|
|
252
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
253
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
254
|
+
}, undefined>, v.ObjectSchema<{
|
|
255
|
+
readonly id: v.StringSchema<undefined>;
|
|
256
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
257
|
+
readonly button: v.StringSchema<undefined>;
|
|
258
|
+
}, undefined>, v.ObjectSchema<{
|
|
259
|
+
readonly id: v.StringSchema<undefined>;
|
|
260
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
261
|
+
readonly formula: v.StringSchema<undefined>;
|
|
262
|
+
}, undefined>, v.ObjectSchema<{
|
|
263
|
+
readonly id: v.StringSchema<undefined>;
|
|
264
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
265
|
+
readonly location: v.StringSchema<undefined>;
|
|
266
|
+
}, undefined>, v.ObjectSchema<{
|
|
267
|
+
readonly id: v.StringSchema<undefined>;
|
|
268
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
269
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
270
|
+
}, undefined>, v.ObjectSchema<{
|
|
271
|
+
readonly id: v.StringSchema<undefined>;
|
|
272
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
273
|
+
readonly verification: v.StringSchema<undefined>;
|
|
250
274
|
}, undefined>], undefined>, undefined>;
|
|
251
275
|
readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
252
276
|
readonly type: v.LiteralSchema<"start", undefined>;
|
|
@@ -227,6 +227,30 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
227
227
|
readonly id: v.StringSchema<undefined>;
|
|
228
228
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
229
229
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
230
|
+
}, undefined>, v.ObjectSchema<{
|
|
231
|
+
readonly id: v.StringSchema<undefined>;
|
|
232
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
233
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
234
|
+
}, undefined>, v.ObjectSchema<{
|
|
235
|
+
readonly id: v.StringSchema<undefined>;
|
|
236
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
237
|
+
readonly button: v.StringSchema<undefined>;
|
|
238
|
+
}, undefined>, v.ObjectSchema<{
|
|
239
|
+
readonly id: v.StringSchema<undefined>;
|
|
240
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
241
|
+
readonly formula: v.StringSchema<undefined>;
|
|
242
|
+
}, undefined>, v.ObjectSchema<{
|
|
243
|
+
readonly id: v.StringSchema<undefined>;
|
|
244
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
245
|
+
readonly location: v.StringSchema<undefined>;
|
|
246
|
+
}, undefined>, v.ObjectSchema<{
|
|
247
|
+
readonly id: v.StringSchema<undefined>;
|
|
248
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
249
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
250
|
+
}, undefined>, v.ObjectSchema<{
|
|
251
|
+
readonly id: v.StringSchema<undefined>;
|
|
252
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
253
|
+
readonly verification: v.StringSchema<undefined>;
|
|
230
254
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
231
255
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
232
256
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -506,6 +530,30 @@ export declare const createPageResultMessageLegacySchema: v.VariantSchema<"statu
|
|
|
506
530
|
readonly id: v.StringSchema<undefined>;
|
|
507
531
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
508
532
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
533
|
+
}, undefined>, v.ObjectSchema<{
|
|
534
|
+
readonly id: v.StringSchema<undefined>;
|
|
535
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
536
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
537
|
+
}, undefined>, v.ObjectSchema<{
|
|
538
|
+
readonly id: v.StringSchema<undefined>;
|
|
539
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
540
|
+
readonly button: v.StringSchema<undefined>;
|
|
541
|
+
}, undefined>, v.ObjectSchema<{
|
|
542
|
+
readonly id: v.StringSchema<undefined>;
|
|
543
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
544
|
+
readonly formula: v.StringSchema<undefined>;
|
|
545
|
+
}, undefined>, v.ObjectSchema<{
|
|
546
|
+
readonly id: v.StringSchema<undefined>;
|
|
547
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
548
|
+
readonly location: v.StringSchema<undefined>;
|
|
549
|
+
}, undefined>, v.ObjectSchema<{
|
|
550
|
+
readonly id: v.StringSchema<undefined>;
|
|
551
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
552
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
553
|
+
}, undefined>, v.ObjectSchema<{
|
|
554
|
+
readonly id: v.StringSchema<undefined>;
|
|
555
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
556
|
+
readonly verification: v.StringSchema<undefined>;
|
|
509
557
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
510
558
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
511
559
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -769,6 +817,30 @@ export declare const createPageResultMessageLegacySchema: v.VariantSchema<"statu
|
|
|
769
817
|
readonly id: v.StringSchema<undefined>;
|
|
770
818
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
771
819
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
820
|
+
}, undefined>, v.ObjectSchema<{
|
|
821
|
+
readonly id: v.StringSchema<undefined>;
|
|
822
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
823
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
824
|
+
}, undefined>, v.ObjectSchema<{
|
|
825
|
+
readonly id: v.StringSchema<undefined>;
|
|
826
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
827
|
+
readonly button: v.StringSchema<undefined>;
|
|
828
|
+
}, undefined>, v.ObjectSchema<{
|
|
829
|
+
readonly id: v.StringSchema<undefined>;
|
|
830
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
831
|
+
readonly formula: v.StringSchema<undefined>;
|
|
832
|
+
}, undefined>, v.ObjectSchema<{
|
|
833
|
+
readonly id: v.StringSchema<undefined>;
|
|
834
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
835
|
+
readonly location: v.StringSchema<undefined>;
|
|
836
|
+
}, undefined>, v.ObjectSchema<{
|
|
837
|
+
readonly id: v.StringSchema<undefined>;
|
|
838
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
839
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
840
|
+
}, undefined>, v.ObjectSchema<{
|
|
841
|
+
readonly id: v.StringSchema<undefined>;
|
|
842
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
843
|
+
readonly verification: v.StringSchema<undefined>;
|
|
772
844
|
}, undefined>], undefined>, undefined>;
|
|
773
845
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
774
846
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -233,6 +233,30 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
|
|
|
233
233
|
readonly id: v.StringSchema<undefined>;
|
|
234
234
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
235
235
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
236
|
+
}, undefined>, v.ObjectSchema<{
|
|
237
|
+
readonly id: v.StringSchema<undefined>;
|
|
238
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
239
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
240
|
+
}, undefined>, v.ObjectSchema<{
|
|
241
|
+
readonly id: v.StringSchema<undefined>;
|
|
242
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
243
|
+
readonly button: v.StringSchema<undefined>;
|
|
244
|
+
}, undefined>, v.ObjectSchema<{
|
|
245
|
+
readonly id: v.StringSchema<undefined>;
|
|
246
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
247
|
+
readonly formula: v.StringSchema<undefined>;
|
|
248
|
+
}, undefined>, v.ObjectSchema<{
|
|
249
|
+
readonly id: v.StringSchema<undefined>;
|
|
250
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
251
|
+
readonly location: v.StringSchema<undefined>;
|
|
252
|
+
}, undefined>, v.ObjectSchema<{
|
|
253
|
+
readonly id: v.StringSchema<undefined>;
|
|
254
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
255
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
256
|
+
}, undefined>, v.ObjectSchema<{
|
|
257
|
+
readonly id: v.StringSchema<undefined>;
|
|
258
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
259
|
+
readonly verification: v.StringSchema<undefined>;
|
|
236
260
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
237
261
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
238
262
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -511,6 +535,30 @@ export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status",
|
|
|
511
535
|
readonly id: v.StringSchema<undefined>;
|
|
512
536
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
513
537
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
538
|
+
}, undefined>, v.ObjectSchema<{
|
|
539
|
+
readonly id: v.StringSchema<undefined>;
|
|
540
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
541
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
542
|
+
}, undefined>, v.ObjectSchema<{
|
|
543
|
+
readonly id: v.StringSchema<undefined>;
|
|
544
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
545
|
+
readonly button: v.StringSchema<undefined>;
|
|
546
|
+
}, undefined>, v.ObjectSchema<{
|
|
547
|
+
readonly id: v.StringSchema<undefined>;
|
|
548
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
549
|
+
readonly formula: v.StringSchema<undefined>;
|
|
550
|
+
}, undefined>, v.ObjectSchema<{
|
|
551
|
+
readonly id: v.StringSchema<undefined>;
|
|
552
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
553
|
+
readonly location: v.StringSchema<undefined>;
|
|
554
|
+
}, undefined>, v.ObjectSchema<{
|
|
555
|
+
readonly id: v.StringSchema<undefined>;
|
|
556
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
557
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
558
|
+
}, undefined>, v.ObjectSchema<{
|
|
559
|
+
readonly id: v.StringSchema<undefined>;
|
|
560
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
561
|
+
readonly verification: v.StringSchema<undefined>;
|
|
514
562
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
515
563
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
516
564
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -774,6 +822,30 @@ export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status",
|
|
|
774
822
|
readonly id: v.StringSchema<undefined>;
|
|
775
823
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
776
824
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
825
|
+
}, undefined>, v.ObjectSchema<{
|
|
826
|
+
readonly id: v.StringSchema<undefined>;
|
|
827
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
828
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
829
|
+
}, undefined>, v.ObjectSchema<{
|
|
830
|
+
readonly id: v.StringSchema<undefined>;
|
|
831
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
832
|
+
readonly button: v.StringSchema<undefined>;
|
|
833
|
+
}, undefined>, v.ObjectSchema<{
|
|
834
|
+
readonly id: v.StringSchema<undefined>;
|
|
835
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
836
|
+
readonly formula: v.StringSchema<undefined>;
|
|
837
|
+
}, undefined>, v.ObjectSchema<{
|
|
838
|
+
readonly id: v.StringSchema<undefined>;
|
|
839
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
840
|
+
readonly location: v.StringSchema<undefined>;
|
|
841
|
+
}, undefined>, v.ObjectSchema<{
|
|
842
|
+
readonly id: v.StringSchema<undefined>;
|
|
843
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
844
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
845
|
+
}, undefined>, v.ObjectSchema<{
|
|
846
|
+
readonly id: v.StringSchema<undefined>;
|
|
847
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
848
|
+
readonly verification: v.StringSchema<undefined>;
|
|
777
849
|
}, undefined>], undefined>, undefined>;
|
|
778
850
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
779
851
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|