@notionhq/custom-blocks-host 0.2.19 → 0.2.21

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 CHANGED
@@ -1 +1 @@
1
- function Ar(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=qr({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function qr(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=tt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||tt(y.name)===c));return l.length===1?l[0][0]:void 0}function tt(e){return e.trim().toLowerCase()}var Re,Tr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Te(e){return!e&&!Re?Tr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Nr;function Fr(e){return Nr?.get(e)}var Ur;function zr(e){return Ur?.get(e)}var Hr;function Lr(e,o){return Hr?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function j(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??Lr(e.reference,m.lang)??(S?zr(m.lang):null)??s.message??Fr(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var rt=new WeakMap;function U(e){let o=rt.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Te())}},rt.set(e,o)),o}function Gr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Ne(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Vr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&j(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Fe(e,o){return{kind:"validation",type:"regex",reference:Fe,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function Ue(e){return{kind:"transformation",type:"transform",reference:Ue,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var ot={abortEarly:!0};function it(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function De(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function st(e,o){return!e["~run"]({value:o},ot).issues}function E(e,o){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else j(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:j(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function ze(e){return{kind:"schema",type:"nan",reference:ze,expects:"NaN",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function Z(e,o){return{kind:"schema",type:"nullable",reference:Z,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return U(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function O(e){return{kind:"schema",type:"number",reference:O,expects:"number",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=it(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else j(this,"type",n,s);return n}}}function a(e,o){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return U(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function D(e,o){return{kind:"schema",type:"picklist",reference:D,expects:Ne(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function z(e,o,n){return{kind:"schema",type:"record",reference:z,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return U(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Gr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let B of m.issues)B.path=[I],s.issues?.push(B);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let B of S.issues)B.path?B.path.unshift(I):B.path=[I],s.issues?.push(B);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else j(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=it(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){j(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else j(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function nt(e){let o;if(e)for(let n of e)if(o)for(let s of n.issues)o.push(s);else o=n.issues;return o}function x(e,o){return{kind:"schema",type:"union",reference:x,expects:Ne(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];j(this,"type",n,s,{issues:nt(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:nt(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return U(this)},"~run"(e){return e.typed=!0,e}}}function h(e,o,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return U(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(B,k)=>{for(let L of B.options){if(L.type==="variant")I(L,new Set(k).add(L.key));else{let W=!0,T=0;for(let R of k){let N=L.entries[R];if(R in l?N["~run"]({typed:!1,value:l[R]},ot).issues:N.type!=="exact_optional"&&N.type!=="optional"&&N.type!=="nullish"){W=!1,m!==R&&(y<T||y===T&&R in l&&!(m in l))&&(y=T,m=R,S=[]),m===R&&S.push(L.entries[R].expects);break}T++}if(W){let R=L["~run"]({value:l},c);(!f||!f.typed&&R.typed)&&(f=R)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Ne(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function ut(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return U(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Te(n));if(s.issues)throw new Vr(s.issues);return s.value}function H(...e){return{...e[0],pipe:e,get"~standard"(){return U(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function xe(e,o,n){let s=e["~run"]({value:o},Te(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=H(t(),te("NotionBlockId")),Y=H(t(),te("NotionDataSourceId")),q=H(t(),te("NotionPageId")),at=H(t(),te("NotionAgentId")),ct=H(t(),te("NotionSpaceId"));var lt=D(["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"]),He=r({id:t(),name:t(),color:a(lt),description:a(t())}),$r=r({id:t(),name:t(),color:a(lt),option_ids:E(t())}),Qr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Xr=["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"],pt=D(Xr),ft=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Le=h("type",[r({...P.entries,type:i("title")}),r({...P.entries,type:i("rich_text")}),r({...P.entries,type:i("number")}),r({...P.entries,type:i("checkbox")}),r({...P.entries,type:i("url")}),r({...P.entries,type:i("email")}),r({...P.entries,type:i("phone_number")}),r({...P.entries,type:i("select"),options:E(He)}),r({...P.entries,type:i("multi_select"),options:E(He)}),r({...P.entries,type:i("status"),options:E(He),groups:E($r)}),r({...P.entries,type:i("date")}),r({...P.entries,type:i("people")}),r({...P.entries,type:i("files")}),r({...P.entries,type:i("unique_id")}),r({...P.entries,type:i("relation"),data_source_id:a(t()),dual_property:a(Qr)}),r({...P.entries,type:i("place")}),r({...P.entries,type:i("formula")}),r({...P.entries,type:i("rollup")}),r({...P.entries,type:i("button")}),r({...P.entries,type:i("verification")}),r({...P.entries,type:i("last_visited_time")}),r({...P.entries,type:i("location")}),r({...P.entries,type:i("created_time")}),r({...P.entries,type:i("last_edited_time")}),r({...P.entries,type:i("created_by")}),r({...P.entries,type:i("last_edited_by")})]);var mt={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var yt=r({id:Y,table:t(),spaceId:a(ct)}),vt=r({id:a(Y),propertiesById:z(t(),Le)}),fo=r({key:t(),collectionPointer:a(yt),collectionSchema:a(vt),propertyIdsByKey:z(t(),a(t())),propertySchemasById:z(t(),Le)}),Wr=r({collectionPointer:a(yt),collectionSchema:a(vt),propertyIdsByKey:a(z(t(),a(t())))}),le=z(t(),Wr);var Jr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Kr=r({name:t(),description:a(t()),type:pt}),Zr=r({name:t(),description:a(t()),icon:a(Jr),properties:a(z(t(),Kr),{})}),pe=r({version:i(1),name:a(t()),description:a(t()),slashCommand:a(t()),icon:a(r({type:i("emoji"),emoji:t()})),dataSources:a(z(t(),Zr),{})});var me=D(["standard","high"]),dt="standard";var ht=r({type:i("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:i("page_id"),page_id:q}),r({type:i("data_source_id"),data_source_id:Y}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:at}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:q,parent:ne})]),Yr=r({type:i("emoji"),emoji:t()}),en=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),bt=r({type:i("external"),external:r({url:t()})}),kt=r({type:i("file"),file:r({url:t(),expiry_time:a(t())})}),Ve=h("type",[Yr,en,bt,kt]),$e=h("type",[bt,kt]),X=Z(t()),gt=z(t(),Ie()),Ge=x([r({id:t(),name:a(t()),color:a(t()),description:a(X)}),r({name:t(),id:a(t()),color:a(t()),description:a(X)})]),tn=r({start:t(),end:a(X),time_zone:a(X)}),rn=x([r({object:a(i("user")),id:t()}),r({object:i("group"),id:t(),name:a(X)})]),nn=r({id:t()}),on=x([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),sn=r({lat:O(),lon:O(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),V={id:t()},un=h("type",[r({...V,type:i("title"),title:E(gt)}),r({...V,type:i("rich_text"),rich_text:E(gt)}),r({...V,type:i("number"),number:Z(O())}),r({...V,type:i("url"),url:X}),r({...V,type:i("email"),email:X}),r({...V,type:i("phone_number"),phone_number:X}),r({...V,type:i("checkbox"),checkbox:b()}),r({...V,type:i("select"),select:Z(Ge)}),r({...V,type:i("status"),status:Z(Ge)}),r({...V,type:i("multi_select"),multi_select:E(Ge)}),r({...V,type:i("date"),date:Z(tn)}),r({...V,type:i("people"),people:E(rn)}),r({...V,type:i("relation"),has_more:a(b()),relation:E(nn)}),r({...V,type:i("files"),files:E(on)}),r({...V,type:i("place"),place:Z(sn)})]),_e=z(t(),un),ve=r({object:i("page"),id:q,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(Ve),cover:a($e),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var an=t(),cn=r({code:an,message:t(),isRetryable:b()}),St=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:cn})]);var Qe=H(t(),te("NotionUserId")),oe=r({object:i("user"),id:Qe,name:a(t()),avatar_url:Z(t()),type:i("person"),person:r({email:t()})}),It=r({object:i("list"),results:E(oe),next_cursor:Z(t()),has_more:b(),type:i("user"),user:z(t(),Ie())});var xt=r({type:i("currentUserChanged"),currentUser:oe});var _t=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var ln=t(),pn=r({code:ln,message:t(),isRetryable:b()}),Ct=r({type:i("getPage"),requestId:t(),pageId:q}),Ot=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:pn})]);var fn=t(),mn=r({code:fn,message:t(),isRetryable:b()}),Et=r({type:i("getUser"),requestId:t(),userId:Qe}),Pt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:mn})]);var de=D(["light","dark"]);var yn=t(),vn=r({code:yn,message:t(),isRetryable:b()});var we=h("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:i("init"),initializationId:t(),status:i("error"),error:vn})]);var jt=r({type:i("invalidSandboxMessage"),reason:t()});var dn=t(),hn=r({code:dn,message:t(),isRetryable:b()}),Bt=r({type:i("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(O())}),Rt=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:It}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:hn})]);var gn=D(["side_peek","center_peek"]),bn=t(),kn=r({code:bn,message:t(),isRetryable:b()}),Mt=r({type:i("openPage"),requestId:t(),pageId:q,mode:gn}),Dt=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:q}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:kn})]);var wt=r({type:i("pageChanged"),page:ye});var At=r({type:i("parentChanged"),parent:ne});var qt=r({unit:D(["year","month","week","day"]),value:O(),time:t(),defaultTimeZone:a(t())}),Sn=r({unit:D(["hour","minute"]),value:O()}),Tt=r({unit:i("none")}),In=x([qt,Sn]),Nt=a(x([qt,Tt])),Ft=a(x([In,Tt])),xn=r({type:i("date"),start_date:t(),reminder:Nt}),_n=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Nt}),Cn=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:Ft}),On=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:Ft}),Ut=h("type",[xn,_n,Cn,On]);var zt=r({id:t(),table:t()});var Ht=x([t(),O(),b(),Ut,E(t()),E(zt)]);var Lt=r({id:q,is_archived:b(),in_trash:b(),propertiesById:z(t(),a(Ht))});var En=t(),Pn=r({code:En,message:t(),isRetryable:b()}),Gt=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:E(Lt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:Pn})]);var Vt=r({type:i("themeChanged"),theme:de});var jn=t(),Bn=r({code:jn,message:t(),isRetryable:b()}),$t=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Bn})]);var Qt=h("type",[we,Vt,ht,At,wt,xt,_t,Gt,St,Ot,Pt,Rt,Dt,$t,jt]);function Xt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Wt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Xe(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function We(e){let{currentBridgeProtocolVersion:o,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${o} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function Je(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Jt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Kt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function Zt(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Yt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function er(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function tr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function rr(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Ke(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Rn=5e3,Mn=5e3,Dn=5e3;function nr(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=Rn,initialStateTimeoutMs:y=Mn,noInitResultTimeoutMs:m=Dn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:B}=e,k="waitingForConnect",L,W,T,R,N=!1,se=!1;function Q(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function M(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function F(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:G,phase:K,source:Be}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",R=v,Q(),M(),n({type:"init",initializationId:v,status:"error",error:G}),B?.({...G,phase:K,source:Be})}async function J(g){if(k==="waitingForConnect"){k="preparingInit",R=g.initializationId,Q(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Jt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(M(),v.status==="error"){A({initializationId:g.initializationId,error:v.error,phase:"init",source:"host"});return}k="waitingForInitResult";let G={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??dt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(G),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let K=er();B?.({...K,phase:"initResult",source:"host"}),s({...K,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:rr(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Ke(g.bridgeProtocolVersion)){let v=Xe({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=We({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:G}=g;if(v===void 0)return"nack";let K=g.error;return G!==void 0&&(Ke(G)?G<l&&(K=We({currentBridgeProtocolVersion:G,minBridgeProtocolVersion:l})):K=Xe({currentBridgeProtocolVersion:G})),A({initializationId:v,error:K,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:G}=g;k!=="waitingForInitResult"||v===void 0||v!==R||(Q(),F(),k="error",s(G),B?.({...G,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(N){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}N=!0,Q(),k==="waitingForConnect"&&(L=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Xt();s(g),B?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==R){s({message:"Ignored stale or unexpected initResult",payload:g});return}F(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():B?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",Q(),M(),F()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function or(e,o){return o>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...mt}}}]))}}}var ir=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function sr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var ur=r({code:t(),message:t(),isRetryable:b()});var ar={type:i("connect"),initializationId:t(),bridgeProtocolVersion:O(),sdkVersion:t()},cr=h("status",[r({status:i("success"),manifest:a(pe),...ar}),r({status:i("error"),error:ur,...ar})]);var wn=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),An=h("type",[r({type:i("page_id"),page_id:q}),r({type:i("data_source_id"),data_source_id:Y})]),lr=r({type:i("createPage"),requestId:t(),parent:An,properties:_e,position:a(wn)});var qn=t(),Tn=r({code:qn,message:t(),isRetryable:b()}),pr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:a(H(O(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Tn})]);var fr=r({type:i("invalidHostMessage"),reason:t()});var mr=D(["ascending","descending"]);var yr=H(q,Fe(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Ue(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ze=x([p({contains:yr}),p({does_not_contain:yr})]),Pe=x([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ee=x([t(),E(t())]),vr=p({object:D(["user","group"]),id:H(t(),ke(1))}),Nn=x([p({contains:vr}),p({does_not_contain:vr}),Pe]),dr=p({object:i("user"),id:H(t(),ke(1),Me(2e3))}),Fn=x([p({contains:dr}),p({does_not_contain:dr}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=x([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),Un=x([p({equals:O()}),p({does_not_equal:O()}),p({greater_than:O()}),p({less_than:O()}),p({greater_than_or_equal_to:O()}),p({less_than_or_equal_to:O()}),Pe]),zn=x([p({equals:b()}),p({does_not_equal:b()})]),kr=x([p({equals:Ee}),p({does_not_equal:Ee}),Pe]),hr=D(["To-do","In progress","Complete","Current","Future"]),gr=x([hr,H(E(hr),ke(1),Me(5))]),Hn=x([p({group_equals:gr}),p({group_does_not_equal:gr})]),Ln=x([kr,Hn]),Gn=x([p({contains:Ee}),p({contains_all:Ee}),p({does_not_contain:Ee}),Pe]),$=D(["start_date","end_date"]),Vn=D(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Oe=x([Vn,t()]),$n=x([p({target:a($),equals:Oe}),p({target:a($),before:Oe}),p({target:a($),after:Oe}),p({target:a($),on_or_before:Oe}),p({target:a($),on_or_after:Oe}),p({target:a($),this_week:p({})}),p({target:a($),past_week:p({})}),p({target:a($),past_month:p({})}),p({target:a($),past_year:p({})}),p({target:a($),next_week:p({})}),p({target:a($),next_month:p({})}),p({target:a($),next_year:p({})}),p({target:a($),is_empty:i(!0)}),p({target:a($),is_not_empty:i(!0)})]),br=x([p({propertyId:t(),relation:Ze}),p({propertyId:t(),created_by:Fn}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:Un}),p({propertyId:t(),checkbox:zn}),p({propertyId:t(),select:kr}),p({propertyId:t(),multi_select:Gn}),p({propertyId:t(),status:Ln}),p({propertyId:t(),date:$n}),p({propertyId:t(),people:Nn})]),Qn=x([br,p({and:E(br)})]),Ye=10,Xn=p({propertyId:t(),direction:mr}),Sr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:O(),filter:a(Qn),sorts:a(E(Xn))});var Ir=r({type:i("resize"),height:H(O(),be(),Se(0))});var xr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var _r=r({type:i("updatePage"),requestId:t(),pageId:q,properties:a(_e),icon:a(Ve),cover:a($e),archived:a(b())});var Cr=h("type",[cr,pr,Sr,xr,lr,Ct,Et,Bt,Mt,_r,Ir,fr]);function Or(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Er(e){let o=Or(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Wn(o)}}}function Wn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Pr=r({initializationId:t()}),Jn=r({bridgeProtocolVersion:x([O(),ze()])});function jr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:B,onCreatePage:k,onGetPage:L,onOpenPage:W,onGetUser:T,onListUsers:R,onUpdatePage:N,onResize:se}=e;function Q(M,F){c("warn",{message:"Ignored unsupported sandbox message",payload:M,issues:F});let A=Er(M);if(A.incomingType==="connect"){let J=xe(Pr,M),ee=xe(Jn,M);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Wt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Pr,M);y({initializationId:J.success?J.output.initializationId:void 0,error:tr()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(F){let A=F.source===o.contentWindow,J=F.origin===n;if(!A||!J)return;let ee=xe(Cr,F.data);if(!ee.success){Q(F.data,ee.issues);return}let _=ee.output;if(!sr(_)&&s()!=="initialized"){c("warn",{message:`Ignored ${_.type} before initialization completed`,payload:_});return}switch(c("in",_),_.type){case"connect":m(_);return;case"initResult":S(_);return;case"queryDataSource":I(_);return;case"unsubscribeDataSourceQuery":B(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":L(_);return;case"getUser":T(_);return;case"listUsers":R(_);return;case"updatePage":N(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}var Ae=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function Br(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Kn(s,o);if(c!==void 0)return c}}function Kn(e,o){if(!Object.hasOwn(o.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 n=o.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.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,I=(Array.isArray(m)?m:[m]).find(B=>!n.groups.some(k=>k.name===B));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}if("relation"in e&&!st(Ze,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Zn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=Yn(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Zn(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 o=e.status;return"group_equals"in o||"group_does_not_equal"in o?void 0:{propertyType:"status",operator:o}}}function Yn(e){let o;if("equals"in e)o=e.equals;else if("does_not_equal"in e)o=e.does_not_equal;else if("contains"in e)o=e.contains;else if("contains_all"in e)o=e.contains_all;else if("does_not_contain"in e)o=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ie(e);return Array.isArray(o)?o:[o]}var eo=new Set(ft);function Rr(e,o){if(e===void 0)return;if(e.length>Ye)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Ye} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(o.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=o.propertiesById[s.propertyId];if(!eo.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 Dr=5;function ro(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:B,initialStateTimeoutMs:k,noInitResultTimeoutMs:L}=e,W=Math.max(I??3,3),T={},R=!1,N,se,Q=5,M=new Ae(u=>{m?.(u)});function F(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let w=or(u,Q);F("out",w),o.contentWindow?.postMessage(w,S)}function J(u){A(fe(we,u))}function ee(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Qt,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let w=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...w})}function je(u){let C=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};_(C)}async function he(u,C=M.subscribe(u)){try{let w=no(se,u.dataSourceId),ce=oo(u,w);if(ce!==void 0){M.isCurrent(u.subscriptionId,C)&&(M.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let qe=await s.queryDataSource(u);if(!M.isCurrent(u.subscriptionId,C))return;qe.status==="error"&&!qe.error.isRetryable&&M.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:qe})}finally{let w=M.finish(u.subscriptionId,C);w!==void 0&&he(w.message,w.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=nr({async prepareInit(u){Q=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:G(C)},sendInitMessage:J,warn:u=>F("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:B,initialStateTimeoutMs:k,noInitResultTimeoutMs:L,stopHostWithFailure:et,onInitResult(u){u.status==="success"&&N!==void 0&&l?.({manifest:N,initialHeight:u.initialHeight})},onConnectionFailure:f});function G(u){if(u.status==="error")return u;N=fe(pe,u.initialState.manifest),c?.(N);let C={...u.initialState,...T};T={};let w={...fe(ut(ir,["manifest"]),C),manifest:N};if(Q<Dr&&w.page.type==="unavailable")return{status:"error",error:Je()};let ce=wr(w.manifest,w.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=w.dataSources,R=!0,{status:"success",initialState:w})}let K=jr({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:F,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>M.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",K),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",K),o.removeEventListener("load",v.onIframeLoad),v.stop(),M.unsubscribeAll()}function et(u){Be(),F("warn",u),f?.(u)}return{stop:Be,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&Q<Dr&&(v.status==="preparingInit"&&R||v.status==="waitingForInitResult"||v.status==="initialized")){et({...Je(),phase:"runtime",source:"host"});return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&N!==void 0&&wr(N,C)!==void 0){F("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Y,u),w=M.refresh(C);if(w===void 0){F("warn",`No active query exists for data source "${u}"`);return}for(let ce of w)he(ce.message,ce.token)}}}function no(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function wr(e,o){for(let[n,s]of Object.entries(e.dataSources)){let c=o.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Kt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return Zt();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Yt()}}}function oo(e,o){return o===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}:Br(e.filter,o)??Rr(e.sorts,o)}function io(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{ro as createCustomBlockHost,Ar as getAutoBoundPropertyIdsByKey,io as isLocalCustomBlockUrl};
1
+ var Nr=6;function Fr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=Ur({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Ur(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=nt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||nt(y.name)===c));return l.length===1?l[0][0]:void 0}function nt(e){return e.trim().toLowerCase()}var Re,zr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ne(e){return!e&&!Re?zr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Hr;function Lr(e){return Hr?.get(e)}var Gr;function Vr(e){return Gr?.get(e)}var $r;function Qr(e,o){return $r?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function j(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},I=e.kind==="schema",_=c?.message??e.message??Qr(e.reference,m.lang)??(I?Vr(m.lang):null)??s.message??Lr(m.lang);_!==void 0&&(m.message=typeof _=="function"?_(m):_),I&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var ot=new WeakMap;function H(e){let o=ot.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Ne())}},ot.set(e,o)),o}function Xr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Fe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Wr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&j(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_length",reference:Se,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_value",reference:ke,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Ue(e,o){return{kind:"validation",type:"regex",reference:Ue,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function ze(e){return{kind:"transformation",type:"transform",reference:ze,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var st={abortEarly:!0};function ut(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function De(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function at(e,o){return!e["~run"]({value:o},st).issues}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let I of y.issues)I.path?I.path.unshift(m):I.path=[m],n.issues?.push(I);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else j(this,"type",n,s);return n}}}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return H(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:j(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function He(e){return{kind:"schema",type:"nan",reference:He,expects:"NaN",async:!1,message:e,get"~standard"(){return H(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function W(e,o){return{kind:"schema",type:"nullable",reference:W,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return H(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function P(e){return{kind:"schema",type:"number",reference:P,expects:"number",async:!1,message:e,get"~standard"(){return H(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let I={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(I):_.path=[I],n.issues?.push(_);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=ut(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else j(this,"type",n,s);return n}}}function u(e,o){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return H(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function B(e,o){return{kind:"schema",type:"picklist",reference:B,expects:Fe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function N(e,o,n){return{kind:"schema",type:"record",reference:N,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return H(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Xr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let _={type:"object",origin:"key",input:l,key:f,value:y};for(let R of m.issues)R.path=[_],s.issues?.push(R);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let I=this.value["~run"]({value:y},c);if(I.issues){let _={type:"object",origin:"value",input:l,key:f,value:y};for(let R of I.issues)R.path?R.path.unshift(_):R.path=[_],s.issues?.push(R);if(s.issues||(s.issues=I.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!I.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=I.value)}}else j(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let I={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(I):_.path=[I],n.issues?.push(_);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=ut(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){j(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else j(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return H(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function it(e){let o;if(e)for(let n of e)if(o)for(let s of n.issues)o.push(s);else o=n.issues;return o}function k(e,o){return{kind:"schema",type:"union",reference:k,expects:Fe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];j(this,"type",n,s,{issues:it(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:it(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return H(this)},"~run"(e){return e.typed=!0,e}}}function g(e,o,n){return{kind:"schema",type:"variant",reference:g,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return H(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,I=[],_=(R,S)=>{for(let G of R.options){if(G.type==="variant")_(G,new Set(S).add(G.key));else{let J=!0,F=0;for(let M of S){let U=G.entries[M];if(M in l?U["~run"]({typed:!1,value:l[M]},st).issues:U.type!=="exact_optional"&&U.type!=="optional"&&U.type!=="nullish"){J=!1,m!==M&&(y<F||y===F&&M in l&&!(m in l))&&(y=F,m=M,I=[]),m===M&&I.push(G.entries[M].expects);break}F++}if(J){let M=G["~run"]({value:l},c);(!f||!f.typed&&M.typed)&&(f=M)}}if(f&&!f.issues)break}};if(_(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Fe(I,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function ct(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return H(this)}}}function re(e,o,n){let s=e["~run"]({value:o},Ne(n));if(s.issues)throw new Wr(s.issues);return s.value}function L(...e){return{...e[0],pipe:e,get"~standard"(){return H(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function _e(e,o,n){let s=e["~run"]({value:o},Ne(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ne=L(t(),te("NotionBlockId")),Z=L(t(),te("NotionDataSourceId")),D=L(t(),te("NotionPageId")),lt=L(t(),te("NotionAgentId")),pt=L(t(),te("NotionSpaceId"));var ft=B(["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"]),Le=r({id:t(),name:t(),color:u(ft),description:u(t())}),Jr=r({id:t(),name:t(),color:u(ft),option_ids:O(t())}),Kr=r({synced_property_id:t(),synced_property_name:t()}),E=r({name:t(),description:u(t())}),Yr=["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"],mt=B(Yr),yt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ge=g("type",[r({...E.entries,type:i("title")}),r({...E.entries,type:i("rich_text")}),r({...E.entries,type:i("number")}),r({...E.entries,type:i("checkbox")}),r({...E.entries,type:i("url")}),r({...E.entries,type:i("email")}),r({...E.entries,type:i("phone_number")}),r({...E.entries,type:i("select"),options:O(Le)}),r({...E.entries,type:i("multi_select"),options:O(Le)}),r({...E.entries,type:i("status"),options:O(Le),groups:O(Jr)}),r({...E.entries,type:i("date")}),r({...E.entries,type:i("people")}),r({...E.entries,type:i("files")}),r({...E.entries,type:i("unique_id")}),r({...E.entries,type:i("relation"),data_source_id:u(t()),dual_property:u(Kr)}),r({...E.entries,type:i("place")}),r({...E.entries,type:i("formula")}),r({...E.entries,type:i("rollup")}),r({...E.entries,type:i("button")}),r({...E.entries,type:i("verification")}),r({...E.entries,type:i("last_visited_time")}),r({...E.entries,type:i("location")}),r({...E.entries,type:i("created_time")}),r({...E.entries,type:i("last_edited_time")}),r({...E.entries,type:i("created_by")}),r({...E.entries,type:i("last_edited_by")})]);var vt={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var dt=r({id:Z,table:t(),spaceId:u(pt)}),ht=r({id:u(Z),propertiesById:N(t(),Ge)}),go=r({key:t(),collectionPointer:u(dt),collectionSchema:u(ht),propertyIdsByKey:N(t(),u(t())),propertySchemasById:N(t(),Ge)}),Zr=r({collectionPointer:u(dt),collectionSchema:u(ht),propertyIdsByKey:u(N(t(),u(t())))}),pe=N(t(),Zr);var en=g("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),tn=r({name:t(),description:u(t()),type:mt}),rn=r({name:t(),description:u(t()),icon:u(en),properties:u(N(t(),tn),{})}),fe=r({version:i(1),name:u(t()),description:u(t()),slashCommand:u(t()),icon:u(r({type:i("emoji"),emoji:t()})),dataSources:u(N(t(),rn),{})});var me=B(["standard","high"]),gt="standard";var bt=r({type:i("contrastModeChanged"),contrastMode:me});var we=r({id:t(),table:t()});var oe=g("type",[r({type:i("page_id"),page_id:D}),r({type:i("data_source_id"),data_source_id:Z}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:ne}),r({type:i("agent_id"),agent_id:lt}),r({type:i("unavailable")})]);var ye=g("type",[r({type:i("unavailable")}),r({type:i("page"),id:D,parent:oe})]),nn=r({type:i("emoji"),emoji:t()}),on=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:u(t()),url:u(t())})}),It=r({type:i("external"),external:r({url:t()})}),_t=r({type:i("file"),file:r({url:t(),expiry_time:u(t())})}),$e=g("type",[nn,on,It,_t]),Qe=g("type",[It,_t]),$=W(t()),St=N(t(),Ie()),Ve=k([r({id:t(),name:u(t()),color:u(t()),description:u($)}),r({name:t(),id:u(t()),color:u(t()),description:u($)})]),sn=r({start:t(),end:u($),time_zone:u($)}),un=k([r({object:u(i("user")),id:t()}),r({object:i("group"),id:t(),name:u($)})]),an=r({id:t()}),cn=k([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:u(t())})})]),ln=r({lat:P(),lon:P(),name:u($),address:u($),aws_place_id:u($),google_place_id:u($)}),A={id:t()},kt=W(r({...we.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:u(t())})),Xe=g("type",[r({...A,type:i("title"),title:O(St)}),r({...A,type:i("rich_text"),rich_text:O(St)}),r({...A,type:i("number"),number:W(P())}),r({...A,type:i("url"),url:$}),r({...A,type:i("email"),email:$}),r({...A,type:i("phone_number"),phone_number:$}),r({...A,type:i("checkbox"),checkbox:h()}),r({...A,type:i("select"),select:W(Ve)}),r({...A,type:i("status"),status:W(Ve)}),r({...A,type:i("multi_select"),multi_select:O(Ve)}),r({...A,type:i("date"),date:W(sn)}),r({...A,type:i("people"),people:O(un)}),r({...A,type:i("relation"),has_more:u(h()),relation:O(an)}),r({...A,type:i("files"),files:O(cn)}),r({...A,type:i("place"),place:W(ln)}),r({...A,type:i("created_time"),created_time:$}),r({...A,type:i("last_edited_time"),last_edited_time:$}),r({...A,type:i("created_by"),created_by:kt}),r({...A,type:i("last_edited_by"),last_edited_by:kt}),r({...A,type:i("last_visited_time"),last_visited_time:$})]),xe=N(t(),Xe),ve=r({object:i("page"),id:D,parent:oe,properties:xe,created_time:u(t()),last_edited_time:u(t()),icon:u($e),cover:u(Qe),url:u(t()),public_url:u(t()),is_archived:h(),in_trash:h()});var pn=t(),fn=r({code:pn,message:t(),isRetryable:h()}),xt=g("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:fn})]);var We=L(t(),te("NotionUserId")),ie=r({object:i("user"),id:We,name:u(t()),avatar_url:W(t()),type:i("person"),person:r({email:t()})}),Ct=r({object:i("list"),results:O(ie),next_cursor:W(t()),has_more:h(),type:i("user"),user:N(t(),Ie())});var Pt=r({type:i("currentUserChanged"),currentUser:ie});var Ot=r({type:i("dataSourcesChanged"),dataSources:r({bindings:pe})});var mn=t(),yn=r({code:mn,message:t(),isRetryable:h()}),Et=r({type:i("getPage"),requestId:t(),pageId:D}),jt=g("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:yn})]);var vn=t(),dn=r({code:vn,message:t(),isRetryable:h()}),Bt=r({type:i("getUser"),requestId:t(),userId:We}),Rt=g("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:ie}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:dn})]);var de=B(["light","dark"]);var hn=t(),gn=r({code:hn,message:t(),isRetryable:h()});var Ae=g("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:ne,parent:oe,page:ye,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie}),r({type:i("init"),initializationId:t(),status:i("error"),error:gn})]);var Mt=r({type:i("invalidSandboxMessage"),reason:t()});var bn=t(),Sn=r({code:bn,message:t(),isRetryable:h()}),Dt=r({type:i("listUsers"),requestId:t(),startCursor:u(t()),pageSize:u(P())}),wt=g("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:Ct}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:Sn})]);var kn=B(["side_peek","center_peek"]),In=t(),_n=r({code:In,message:t(),isRetryable:h()}),At=r({type:i("openPage"),requestId:t(),pageId:D,mode:kn}),qt=g("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:D}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:_n})]);var Tt=r({type:i("pageChanged"),page:ye});var Nt=r({type:i("parentChanged"),parent:oe});var Ft=r({unit:B(["year","month","week","day"]),value:P(),time:t(),defaultTimeZone:u(t())}),xn=r({unit:B(["hour","minute"]),value:P()}),Ut=r({unit:i("none")}),Cn=k([Ft,xn]),zt=u(k([Ft,Ut])),Ht=u(k([Cn,Ut])),Pn=r({type:i("date"),start_date:t(),reminder:zt}),On=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:zt}),En=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:u(t()),reminder:Ht}),jn=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:u(t()),reminder:Ht}),Lt=g("type",[Pn,On,En,jn]);var Gt=k([t(),P(),h(),Lt,O(t()),O(we)]);var Vt=r({id:D,is_archived:h(),in_trash:h(),propertiesById:N(t(),u(Gt))}),$t=r({id:D,is_archived:h(),in_trash:h(),properties:N(t(),u(Xe))});var Bn=t(),Rn=r({code:Bn,message:t(),isRetryable:h()}),Qt=g("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(k([$t,Vt])),hasMore:h()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:Rn})]);var Xt=r({type:i("themeChanged"),theme:de});var Mn=t(),Dn=r({code:Mn,message:t(),isRetryable:h()}),Wt=g("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Dn})]);var Jt=g("type",[Ae,Xt,bt,Nt,Tt,Pt,Ot,Qt,xt,jt,Rt,wt,qt,Wt,Mt]);function Kt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Yt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Je(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function Ke(e){let{currentBridgeProtocolVersion:o,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${o} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function Ye(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Zt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function er(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function tr(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function rr(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function nr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function or(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function ir(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function se(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Ze(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var wn=5e3,An=5e3,qn=5e3;function sr(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=wn,initialStateTimeoutMs:y=An,noInitResultTimeoutMs:m=qn,stopHostWithFailure:I,onInitResult:_,onConnectionFailure:R}=e,S="waitingForConnect",G,J,F,M,U=!1,ue=!1;function X(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function w(){J!==void 0&&(window.clearTimeout(J),J=void 0)}function z(){F!==void 0&&(window.clearTimeout(F),F=void 0)}function T(b){let{initializationId:v,error:V,phase:Y,source:Be}=b;switch(S){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return se(S)}S="error",M=v,X(),w(),n({type:"init",initializationId:v,status:"error",error:V}),R?.({...V,phase:Y,source:Be})}async function K(b){if(S==="waitingForConnect"){S="preparingInit",M=b.initializationId,X(),J=window.setTimeout(()=>{if(S!=="preparingInit")return;let v=Zt();s({...v,initializationId:b.initializationId}),T({initializationId:b.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(b);if(S!=="preparingInit")return;if(w(),v.status==="error"){T({initializationId:b.initializationId,error:v.error,phase:"init",source:"host"});return}S="waitingForInitResult";let V={type:"init",initializationId:b.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??gt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),F=window.setTimeout(()=>{if(S!=="waitingForInitResult")return;S="error";let Y=nr();R?.({...Y,phase:"initResult",source:"host"}),s({...Y,initializationId:b.initializationId})},m)}catch(v){if(S!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),T({initializationId:b.initializationId,error:ir(),phase:"init",source:"host"})}}}function ee(b){if(S!=="stopped"&&S==="waitingForConnect"){if(!Ze(b.bridgeProtocolVersion)){let v=Je({currentBridgeProtocolVersion:b.bridgeProtocolVersion});T({initializationId:b.initializationId,error:v,phase:"connect",source:"host"});return}if(b.bridgeProtocolVersion<l){let v=Ke({currentBridgeProtocolVersion:b.bridgeProtocolVersion,minBridgeProtocolVersion:l});T({initializationId:b.initializationId,error:v,phase:"connect",source:"host"});return}if(b.status==="error"){T({initializationId:b.initializationId,error:b.error,phase:"connect",source:"sandbox"});return}ue=!0,K(b)}}function x(b){if(S==="stopped"||S!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=b;if(v===void 0)return"nack";let Y=b.error;return V!==void 0&&(Ze(V)?V<l&&(Y=Ke({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):Y=Je({currentBridgeProtocolVersion:V})),T({initializationId:v,error:Y,phase:"connect",source:"host"}),"handled"}function ae(b){let{initializationId:v,error:V}=b;S!=="waitingForInitResult"||v===void 0||v!==M||(X(),z(),S="error",s(V),R?.({...V,phase:"initResult",source:"host"}))}function je(){if(S!=="stopped"){if(U){I({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}U=!0,X(),S==="waitingForConnect"&&(G=window.setTimeout(()=>{if(S!=="waitingForConnect")return;S="error";let b=Kt();s(b),R?.({...b,phase:"connect",source:"host"})},f))}}function he(b){if(S!=="waitingForInitResult"||b.initializationId!==M){s({message:"Ignored stale or unexpected initResult",payload:b});return}z(),S=b.status==="success"?"initialized":"error",b.status==="success"?c():R?.({...b.error,phase:"initResult",source:"sandbox"}),_?.(b)}function ce(){S="stopped",X(),w(),z()}return{get status(){return S},get hasConnectedSandbox(){return ue},handleConnect:ee,handleInitResult:he,handleInvalidConnect:x,handleInvalidInitResult:ae,onIframeLoad:je,stop:ce}}function ur(e,o){return o>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...vt}}}]))}}}var ar=r({theme:de,contrastMode:u(me),blockId:ne,parent:oe,page:ye,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie});function cr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var lr=r({code:t(),message:t(),isRetryable:h()});var pr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:P(),sdkVersion:t()},fr=g("status",[r({status:i("success"),manifest:u(fe),...pr}),r({status:i("error"),error:lr,...pr})]);var Tn=g("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:ne}),r({type:i("after"),blockId:ne})]),Nn=g("type",[r({type:i("page_id"),page_id:D}),r({type:i("data_source_id"),data_source_id:Z})]),mr=r({type:i("createPage"),requestId:t(),parent:Nn,properties:xe,position:u(Tn)});var Fn=t(),Un=r({code:Fn,message:t(),isRetryable:h()}),yr=g("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:u(L(P(),be(),ke(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Un})]);var vr=r({type:i("invalidHostMessage"),reason:t()});var dr=B(["ascending","descending"]);var hr=L(D,Ue(/^(?:[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"))),et=k([p({contains:hr}),p({does_not_contain:hr})]),Ee=k([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=k([t(),O(t())]),gr=p({object:B(["user","group"]),id:L(t(),Se(1))}),zn=k([p({contains:gr}),p({does_not_contain:gr}),Ee]),br=p({object:i("user"),id:L(t(),Se(1),Me(2e3))}),Hn=k([p({contains:br}),p({does_not_contain:br}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=k([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Ee]),Ln=k([p({equals:P()}),p({does_not_equal:P()}),p({greater_than:P()}),p({less_than:P()}),p({greater_than_or_equal_to:P()}),p({less_than_or_equal_to:P()}),Ee]),Gn=k([p({equals:h()}),p({does_not_equal:h()})]),_r=k([p({equals:Oe}),p({does_not_equal:Oe}),Ee]),Sr=B(["To-do","In progress","Complete","Current","Future"]),kr=k([Sr,L(O(Sr),Se(1),Me(5))]),Vn=k([p({group_equals:kr}),p({group_does_not_equal:kr})]),$n=k([_r,Vn]),Qn=k([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Ee]),Q=B(["start_date","end_date"]),Xn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Pe=k([Xn,t()]),Wn=k([p({target:u(Q),equals:Pe}),p({target:u(Q),before:Pe}),p({target:u(Q),after:Pe}),p({target:u(Q),on_or_before:Pe}),p({target:u(Q),on_or_after:Pe}),p({target:u(Q),this_week:p({})}),p({target:u(Q),past_week:p({})}),p({target:u(Q),past_month:p({})}),p({target:u(Q),past_year:p({})}),p({target:u(Q),next_week:p({})}),p({target:u(Q),next_month:p({})}),p({target:u(Q),next_year:p({})}),p({target:u(Q),is_empty:i(!0)}),p({target:u(Q),is_not_empty:i(!0)})]),Ir=k([p({propertyId:t(),relation:et}),p({propertyId:t(),created_by:Hn}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:Ln}),p({propertyId:t(),checkbox:Gn}),p({propertyId:t(),select:_r}),p({propertyId:t(),multi_select:Qn}),p({propertyId:t(),status:$n}),p({propertyId:t(),date:Wn}),p({propertyId:t(),people:zn})]),Jn=k([Ir,p({and:O(Ir)})]),tt=10,Kn=p({propertyId:t(),direction:dr}),xr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Z,limit:P(),filter:u(Jn),sorts:u(O(Kn))});var Cr=r({type:i("resize"),height:L(P(),be(),ke(0))});var Pr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var Or=r({type:i("updatePage"),requestId:t(),pageId:D,properties:u(xe),icon:u($e),cover:u(Qe),archived:u(h())});var Er=g("type",[fr,yr,xr,Pr,mr,Et,Bt,Dt,At,Or,Cr,vr]);function jr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Br(e){let o=jr(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Yn(o)}}}function Yn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Rr=r({initializationId:t()}),Zn=r({bridgeProtocolVersion:k([P(),He()])});function Mr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:I,onQueryDataSource:_,onUnsubscribeDataSourceQuery:R,onCreatePage:S,onGetPage:G,onOpenPage:J,onGetUser:F,onListUsers:M,onUpdatePage:U,onResize:ue}=e;function X(w,z){c("warn",{message:"Ignored unsupported sandbox message",payload:w,issues:z});let T=Br(w);if(T.incomingType==="connect"){let K=_e(Rr,w),ee=_e(Zn,w);if(f({initializationId:K.success?K.output.initializationId:void 0,error:Yt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(T.incomingType==="initResult"){let K=_e(Rr,w);y({initializationId:K.success?K.output.initializationId:void 0,error:or()})}T.nack!==void 0&&s()!=="stopped"&&l(T.nack)}return function(z){let T=z.source===o.contentWindow,K=z.origin===n;if(!T||!K)return;let ee=_e(Er,z.data);if(!ee.success){X(z.data,ee.issues);return}let x=ee.output;if(!cr(x)&&s()!=="initialized"){c("warn",{message:`Ignored ${x.type} before initialization completed`,payload:x});return}switch(c("in",x),x.type){case"connect":m(x);return;case"initResult":I(x);return;case"queryDataSource":_(x);return;case"unsubscribeDataSourceQuery":R(x);return;case"createPage":S(x);return;case"openPage":J(x);return;case"getPage":G(x);return;case"getUser":F(x);return;case"listUsers":M(x);return;case"updatePage":U(x);return;case"resize":ue(x);return;case"invalidHostMessage":return;default:se(x)}}}var qe=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function Dr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=eo(s,o);if(c!==void 0)return c}}function eo(e,o){if(!Object.hasOwn(o.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 n=o.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.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(R=>!n.groups.some(S=>S.name===R));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!at(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=to(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=ro(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function to(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 o=e.status;return"group_equals"in o||"group_does_not_equal"in o?void 0:{propertyType:"status",operator:o}}}function ro(e){let o;if("equals"in e)o=e.equals;else if("does_not_equal"in e)o=e.does_not_equal;else if("contains"in e)o=e.contains;else if("contains_all"in e)o=e.contains_all;else if("does_not_contain"in e)o=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:se(e);return Array.isArray(o)?o:[o]}var no=new Set(yt);function wr(e,o){if(e===void 0)return;if(e.length>tt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${tt} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(o.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=o.propertiesById[s.propertyId];if(!no.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 qr=5;function io(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:I,minBridgeProtocolVersion:_,noConnectTimeoutMs:R,initialStateTimeoutMs:S,noInitResultTimeoutMs:G}=e,J=Math.max(_??3,3),F={},M=!1,U,ue,X=6,w=new qe(a=>{m?.(a)});function z(a,C){y?.(a,C)}function T(a){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return se(C)}let q=ur(a,X);z("out",q),o.contentWindow?.postMessage(q,I)}function K(a){T(re(Ae,a))}function ee(a){T(a)}function x(a){let C=v.status;switch(C){case"initialized":T(re(Jt,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:se(C)}}async function ae(a,C){if(C===void 0)return;let q=await C(a);x({type:`${a.type}Result`,requestId:a.requestId,...q})}function je(a){let C=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};x(C)}async function he(a,C=w.subscribe(a)){try{let q=so(ue,a.dataSourceId),le=uo(a,q);if(le!==void 0){w.isCurrent(a.subscriptionId,C)&&(w.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:{status:"error",error:le}}));return}let Te=await s.queryDataSource(a);if(!w.isCurrent(a.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&w.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:Te})}finally{let q=w.finish(a.subscriptionId,C);q!==void 0&&he(q.message,q.token)}}function ce(a){v.status==="stopped"||v.status==="error"||(Object.assign(F,a),b())}function b(){if(v.status!=="initialized")return;let a=F;F={},a.theme!==void 0&&x({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&x({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&x({type:"parentChanged",parent:a.parent}),a.page!==void 0&&x({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&x({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&x({type:"currentUserChanged",currentUser:a.currentUser})}let v=sr({async prepareInit(a){X=a.bridgeProtocolVersion;let C=await n(a);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:K,warn:a=>z("warn",a),flushPendingHostStateChanges:b,minBridgeProtocolVersion:J,noConnectTimeoutMs:R,initialStateTimeoutMs:S,noInitResultTimeoutMs:G,stopHostWithFailure:rt,onInitResult(a){a.status==="success"&&U!==void 0&&l?.({manifest:U,initialHeight:a.initialHeight})},onConnectionFailure:f});function V(a){if(a.status==="error")return a;U=re(fe,a.initialState.manifest),c?.(U);let C={...a.initialState,...F};F={};let q={...re(ct(ar,["manifest"]),C),manifest:U};if(X<qr&&q.page.type==="unavailable")return{status:"error",error:Ye()};let le=Tr(q.manifest,q.dataSources);return le!==void 0?{status:"error",error:le}:(ue=q.dataSources,M=!0,{status:"success",initialState:q})}let Y=Mr({iframe:o,sandboxOrigin:I,getInitStatus:()=>v.status,emit:z,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:a=>w.unsubscribe(a.subscriptionId),onCreatePage:a=>ae(a,s.createPage),onGetPage:a=>ae(a,s.getPage),onOpenPage:a=>ae(a,s.openPage),onGetUser:a=>ae(a,s.getUser),onListUsers:a=>ae(a,s.listUsers),onUpdatePage:a=>ae(a,s.updatePage),onResize:a=>s.resize?.(a)});window.addEventListener("message",Y),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",Y),o.removeEventListener("load",v.onIframeLoad),v.stop(),w.unsubscribeAll()}function rt(a){Be(),z("warn",a),f?.(a)}return{stop:Be,setTheme(a){ce({theme:a})},setContrastMode(a){ce({contrastMode:a})},setParent(a){ce({parent:a})},setPage(a){if(a.type==="unavailable"&&X<qr&&(v.status==="preparingInit"&&M||v.status==="waitingForInitResult"||v.status==="initialized")){rt({...Ye(),phase:"runtime",source:"host"});return}ce({page:a})},setCurrentUser(a){ce({currentUser:a})},setDataSources(a){let C={bindings:re(pe,a.bindings)};if(v.hasConnectedSandbox&&U!==void 0&&Tr(U,C)!==void 0){z("warn",{message:"Ignored invalid data source bindings update",payload:C});return}ue=C,ce({dataSources:C})},refreshQuery({dataSourceId:a}){if(v.status!=="initialized")return;let C=re(Z,a),q=w.refresh(C);if(q===void 0){z("warn",`No active query exists for data source "${a}"`);return}for(let le of q)he(le.message,le.token)}}}function so(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Tr(e,o){for(let[n,s]of Object.entries(e.dataSources)){let c=o.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return er();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return tr();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return rr()}}}function uo(e,o){return o===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}:Dr(e.filter,o)??wr(e.sorts,o)}function ao(e){return re(D,e)}function co(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{Nr as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,io as createCustomBlockHost,Fr as getAutoBoundPropertyIdsByKey,co as isLocalCustomBlockUrl,ao as toNotionPageId};
package/dist/ids.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { type NotionPageId } from "./protocol/ids.js";
2
+ export declare function toNotionPageId(id: string): NotionPageId;
3
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAEjB,MAAM,yCAAyC,CAAA;AAGhD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAEvD"}
package/dist/ids.js ADDED
@@ -0,0 +1,5 @@
1
+ import { notionPageIdSchema, } from "./protocol/ids.js";
2
+ import * as v from "valibot";
3
+ export function toNotionPageId(id) {
4
+ return v.parse(notionPageIdSchema, id);
5
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ export type { LegacyNotionDataSourcePageBridge, NotionDataSourcePageBridge, } from "./protocol/dataSources/dataSourcePage.js";
2
+ export type { NotionPropertySchemasById } from "./protocol/dataSources/propertySchema.js";
1
3
  export type { CustomBlockErrorInfo } from "./protocol/errors.js";
4
+ export type { NotionPageId } from "./protocol/ids.js";
2
5
  export type { CreatePageMessage } from "./protocol/messages/createPage.js";
3
6
  export type { GetPageMessage } from "./protocol/messages/getPage.js";
4
7
  export type { GetUserMessage } from "./protocol/messages/getUser.js";
@@ -7,9 +10,11 @@ export type { OpenPageMessage } from "./protocol/messages/openPage.js";
7
10
  export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockRelationFilterOperator, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
8
11
  export type { ResizeMessage } from "./protocol/messages/resize.js";
9
12
  export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
10
- export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
13
+ export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyReadMap, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
14
+ export { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
11
15
  export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
12
16
  export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
17
+ export { toNotionPageId } from "./ids.js";
13
18
  export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostGetInitialState, CustomBlockHostInitialState, CustomBlockHostInitialStateResult, } from "./lifecycle/types.js";
14
19
  export { isLocalCustomBlockUrl } from "./localBlockUrl.js";
15
20
  export type { CreatePageMessageInput, CustomBlockHostCreatePageResult, CustomBlockHostFailure, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostOpenPageResult, CustomBlockHostUpdatePageResult, GetPageMessageInput, GetUserMessageInput, ListUsersMessageInput, OpenPageMessageInput, QueryDataSourceMessageInput, ResizeMessageInput, UpdatePageMessageInput, } from "./messages/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,gCAAgC,EAChC,0BAA0B,GAC1B,MAAM,gEAAgE,CAAA;AACvE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAA;AAC/G,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,qDAAqD,CAAA;AAC5G,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
1
2
  export { getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
2
3
  export { createCustomBlockHost, } from "./createCustomBlockHost.js";
4
+ export { toNotionPageId } from "./ids.js";
3
5
  export { isLocalCustomBlockUrl } from "./localBlockUrl.js";
@@ -4,7 +4,7 @@ import * as v from "valibot";
4
4
  * properties by raw property ID. The four built-ins (`created_time`, `last_edited_time`,
5
5
  * `created_by`, `last_edited_by`) are normally present, possibly with `undefined` values.
6
6
  */
7
- export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
7
+ export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
8
8
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
9
9
  /** Whether the page or an ancestor is archived. */
10
10
  readonly is_archived: v.BooleanSchema<undefined>;
@@ -72,5 +72,164 @@ export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
72
72
  readonly table: v.StringSchema<undefined>;
73
73
  }, undefined>, undefined>], undefined>, undefined>, undefined>;
74
74
  }, undefined>;
75
+ export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
76
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
77
+ readonly is_archived: v.BooleanSchema<undefined>;
78
+ readonly in_trash: v.BooleanSchema<undefined>;
79
+ readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
80
+ readonly id: v.StringSchema<undefined>;
81
+ readonly type: v.LiteralSchema<"title", undefined>;
82
+ readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
83
+ }, undefined>, v.ObjectSchema<{
84
+ readonly id: v.StringSchema<undefined>;
85
+ readonly type: v.LiteralSchema<"rich_text", undefined>;
86
+ readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
87
+ }, undefined>, v.ObjectSchema<{
88
+ readonly id: v.StringSchema<undefined>;
89
+ readonly type: v.LiteralSchema<"number", undefined>;
90
+ readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
91
+ }, undefined>, v.ObjectSchema<{
92
+ readonly id: v.StringSchema<undefined>;
93
+ readonly type: v.LiteralSchema<"url", undefined>;
94
+ readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
95
+ }, undefined>, v.ObjectSchema<{
96
+ readonly id: v.StringSchema<undefined>;
97
+ readonly type: v.LiteralSchema<"email", undefined>;
98
+ readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
99
+ }, undefined>, v.ObjectSchema<{
100
+ readonly id: v.StringSchema<undefined>;
101
+ readonly type: v.LiteralSchema<"phone_number", undefined>;
102
+ readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
103
+ }, undefined>, v.ObjectSchema<{
104
+ readonly id: v.StringSchema<undefined>;
105
+ readonly type: v.LiteralSchema<"checkbox", undefined>;
106
+ readonly checkbox: v.BooleanSchema<undefined>;
107
+ }, undefined>, v.ObjectSchema<{
108
+ readonly id: v.StringSchema<undefined>;
109
+ readonly type: v.LiteralSchema<"select", undefined>;
110
+ readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
111
+ readonly id: v.StringSchema<undefined>;
112
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
113
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
114
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
115
+ }, undefined>, v.ObjectSchema<{
116
+ readonly name: v.StringSchema<undefined>;
117
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
118
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
119
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
120
+ }, undefined>], undefined>, undefined>;
121
+ }, undefined>, v.ObjectSchema<{
122
+ readonly id: v.StringSchema<undefined>;
123
+ readonly type: v.LiteralSchema<"status", undefined>;
124
+ readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
125
+ readonly id: v.StringSchema<undefined>;
126
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
127
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
128
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
129
+ }, undefined>, v.ObjectSchema<{
130
+ readonly name: v.StringSchema<undefined>;
131
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
132
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
133
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
134
+ }, undefined>], undefined>, undefined>;
135
+ }, undefined>, v.ObjectSchema<{
136
+ readonly id: v.StringSchema<undefined>;
137
+ readonly type: v.LiteralSchema<"multi_select", undefined>;
138
+ readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
139
+ readonly id: v.StringSchema<undefined>;
140
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
141
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
142
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
143
+ }, undefined>, v.ObjectSchema<{
144
+ readonly name: v.StringSchema<undefined>;
145
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
146
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
147
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
148
+ }, undefined>], undefined>, undefined>;
149
+ }, undefined>, v.ObjectSchema<{
150
+ readonly id: v.StringSchema<undefined>;
151
+ readonly type: v.LiteralSchema<"date", undefined>;
152
+ readonly date: v.NullableSchema<v.ObjectSchema<{
153
+ readonly start: v.StringSchema<undefined>;
154
+ readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
155
+ readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
156
+ }, undefined>, undefined>;
157
+ }, undefined>, v.ObjectSchema<{
158
+ readonly id: v.StringSchema<undefined>;
159
+ readonly type: v.LiteralSchema<"people", undefined>;
160
+ readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
161
+ readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
162
+ readonly id: v.StringSchema<undefined>;
163
+ }, undefined>, v.ObjectSchema<{
164
+ readonly object: v.LiteralSchema<"group", undefined>;
165
+ readonly id: v.StringSchema<undefined>;
166
+ readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
167
+ }, undefined>], undefined>, undefined>;
168
+ }, undefined>, v.ObjectSchema<{
169
+ readonly id: v.StringSchema<undefined>;
170
+ readonly type: v.LiteralSchema<"relation", undefined>;
171
+ readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
172
+ readonly relation: v.ArraySchema<v.ObjectSchema<{
173
+ readonly id: v.StringSchema<undefined>;
174
+ }, undefined>, undefined>;
175
+ }, undefined>, v.ObjectSchema<{
176
+ readonly id: v.StringSchema<undefined>;
177
+ readonly type: v.LiteralSchema<"files", undefined>;
178
+ readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
179
+ readonly type: v.LiteralSchema<"external", undefined>;
180
+ readonly name: v.StringSchema<undefined>;
181
+ readonly external: v.ObjectSchema<{
182
+ readonly url: v.StringSchema<undefined>;
183
+ }, undefined>;
184
+ }, undefined>, v.ObjectSchema<{
185
+ readonly type: v.LiteralSchema<"file", undefined>;
186
+ readonly name: v.StringSchema<undefined>;
187
+ readonly file: v.ObjectSchema<{
188
+ readonly url: v.StringSchema<undefined>;
189
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
190
+ }, undefined>;
191
+ }, undefined>], undefined>, undefined>;
192
+ }, undefined>, v.ObjectSchema<{
193
+ readonly id: v.StringSchema<undefined>;
194
+ readonly type: v.LiteralSchema<"place", undefined>;
195
+ readonly place: v.NullableSchema<v.ObjectSchema<{
196
+ readonly lat: v.NumberSchema<undefined>;
197
+ readonly lon: v.NumberSchema<undefined>;
198
+ readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
199
+ readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
200
+ readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
201
+ readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
202
+ }, undefined>, undefined>;
203
+ }, undefined>, v.ObjectSchema<{
204
+ readonly id: v.StringSchema<undefined>;
205
+ readonly type: v.LiteralSchema<"created_time", undefined>;
206
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
207
+ }, undefined>, v.ObjectSchema<{
208
+ readonly id: v.StringSchema<undefined>;
209
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
210
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
211
+ }, undefined>, v.ObjectSchema<{
212
+ readonly id: v.StringSchema<undefined>;
213
+ readonly type: v.LiteralSchema<"created_by", undefined>;
214
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
215
+ readonly id: v.StringSchema<undefined>;
216
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
217
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
218
+ }, undefined>, undefined>;
219
+ }, undefined>, v.ObjectSchema<{
220
+ readonly id: v.StringSchema<undefined>;
221
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
222
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
223
+ readonly id: v.StringSchema<undefined>;
224
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
225
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
226
+ }, undefined>, undefined>;
227
+ }, undefined>, v.ObjectSchema<{
228
+ readonly id: v.StringSchema<undefined>;
229
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
230
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
231
+ }, undefined>], undefined>, undefined>, undefined>;
232
+ }, undefined>;
233
+ export type LegacyNotionDataSourcePageBridge = v.InferOutput<typeof legacyNotionDataSourcePageBridgeSchema>;
75
234
  /** Internal SDK type for a parsed bridge page. */
76
235
  export type NotionDataSourcePageBridge = v.InferOutput<typeof notionDataSourcePageBridgeSchema>;
@@ -1,12 +1,13 @@
1
1
  import * as v from "valibot";
2
2
  import { notionPageIdSchema } from "../ids.js";
3
+ import { notionPagePropertyValueSchema } from "../pages/page.js";
3
4
  import { notionDataSourceValueSchema } from "./dataSourceValue.js";
4
5
  /**
5
6
  * Bridge shape for a data source page, as parsed from inbound host messages. The host keys
6
7
  * properties by raw property ID. The four built-ins (`created_time`, `last_edited_time`,
7
8
  * `created_by`, `last_edited_by`) are normally present, possibly with `undefined` values.
8
9
  */
9
- export const notionDataSourcePageBridgeSchema = v.object({
10
+ export const legacyNotionDataSourcePageBridgeSchema = v.object({
10
11
  id: notionPageIdSchema,
11
12
  /** Whether the page or an ancestor is archived. */
12
13
  is_archived: v.boolean(),
@@ -14,3 +15,9 @@ export const notionDataSourcePageBridgeSchema = v.object({
14
15
  in_trash: v.boolean(),
15
16
  propertiesById: v.record(v.string(), v.optional(notionDataSourceValueSchema)),
16
17
  });
18
+ export const notionDataSourcePageBridgeSchema = v.object({
19
+ id: notionPageIdSchema,
20
+ is_archived: v.boolean(),
21
+ in_trash: v.boolean(),
22
+ properties: v.record(v.string(), v.optional(notionPagePropertyValueSchema)),
23
+ });
@@ -189,6 +189,7 @@ export declare const notionPropertySchemaSchema: v.VariantSchema<"type", [v.Obje
189
189
  readonly type: v.LiteralSchema<"last_edited_by", undefined>;
190
190
  }, undefined>], undefined>;
191
191
  export type NotionPropertySchema = v.InferOutput<typeof notionPropertySchemaSchema>;
192
+ export type NotionPropertySchemasById = Record<string, NotionPropertySchema>;
192
193
  /**
193
194
  * The four synthetic built-in property IDs the host always includes in every
194
195
  * data source's `propertySchemasById` and every row's `propertiesById`.
@@ -181,6 +181,34 @@ export declare const createPageMessageSchema: v.ObjectSchema<{
181
181
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
182
182
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
183
183
  }, undefined>, undefined>;
184
+ }, undefined>, v.ObjectSchema<{
185
+ readonly id: v.StringSchema<undefined>;
186
+ readonly type: v.LiteralSchema<"created_time", undefined>;
187
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
188
+ }, undefined>, v.ObjectSchema<{
189
+ readonly id: v.StringSchema<undefined>;
190
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
191
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
192
+ }, undefined>, v.ObjectSchema<{
193
+ readonly id: v.StringSchema<undefined>;
194
+ readonly type: v.LiteralSchema<"created_by", undefined>;
195
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
196
+ readonly id: v.StringSchema<undefined>;
197
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
198
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
199
+ }, undefined>, undefined>;
200
+ }, undefined>, v.ObjectSchema<{
201
+ readonly id: v.StringSchema<undefined>;
202
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
203
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
204
+ readonly id: v.StringSchema<undefined>;
205
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
206
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
207
+ }, undefined>, undefined>;
208
+ }, undefined>, v.ObjectSchema<{
209
+ readonly id: v.StringSchema<undefined>;
210
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
211
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
184
212
  }, undefined>], undefined>, undefined>;
185
213
  readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
186
214
  readonly type: v.LiteralSchema<"start", undefined>;
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "../ids.js";
3
- import { notionPagePropertyWriteMapSchema } from "../pages/page.js";
3
+ import { notionPagePropertyReadMapSchema } from "../pages/page.js";
4
4
  /**
5
5
  * Describes where the newly created page should be inserted.
6
6
  * - `start` / `end` (default): prepend / append to the request's `parent`
@@ -46,6 +46,6 @@ export const createPageMessageSchema = v.object({
46
46
  * To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
47
47
  * those keys before it sends this message.
48
48
  */
49
- properties: notionPagePropertyWriteMapSchema,
49
+ properties: notionPagePropertyReadMapSchema,
50
50
  position: v.optional(notionCreatePagePositionSchema),
51
51
  });
@@ -161,6 +161,34 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
161
161
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
162
162
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
163
163
  }, undefined>, undefined>;
164
+ }, undefined>, v.ObjectSchema<{
165
+ readonly id: v.StringSchema<undefined>;
166
+ readonly type: v.LiteralSchema<"created_time", undefined>;
167
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
168
+ }, undefined>, v.ObjectSchema<{
169
+ readonly id: v.StringSchema<undefined>;
170
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
171
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
172
+ }, undefined>, v.ObjectSchema<{
173
+ readonly id: v.StringSchema<undefined>;
174
+ readonly type: v.LiteralSchema<"created_by", undefined>;
175
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
176
+ readonly id: v.StringSchema<undefined>;
177
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
178
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
179
+ }, undefined>, undefined>;
180
+ }, undefined>, v.ObjectSchema<{
181
+ readonly id: v.StringSchema<undefined>;
182
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
183
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
184
+ readonly id: v.StringSchema<undefined>;
185
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
186
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
187
+ }, undefined>, undefined>;
188
+ }, undefined>, v.ObjectSchema<{
189
+ readonly id: v.StringSchema<undefined>;
190
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
191
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
164
192
  }, undefined>], undefined>, undefined>;
165
193
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
166
194
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;