@notionhq/custom-blocks-host 0.5.2 → 0.7.0

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.
Files changed (90) hide show
  1. package/README.md +9 -0
  2. package/dist/browser.js +1 -1
  3. package/dist/compatibility/normalizeHostToSandboxMessage.d.ts.map +1 -1
  4. package/dist/compatibility/normalizeHostToSandboxMessage.js +5 -1
  5. package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +100 -15
  6. package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
  7. package/dist/compatibility/pages/toIconForProtocol3To8.d.ts +4 -0
  8. package/dist/compatibility/pages/toIconForProtocol3To8.d.ts.map +1 -0
  9. package/dist/compatibility/pages/toIconForProtocol3To8.js +13 -0
  10. package/dist/compatibility/pages/toPageWithNullTextFallbackProperties.d.ts.map +1 -1
  11. package/dist/compatibility/pages/toPageWithNullTextFallbackProperties.js +0 -1
  12. package/dist/compatibility/protocol3To4/addMetadataReadSchemasForProtocol3To4.d.ts +15 -34
  13. package/dist/compatibility/protocol3To4/addMetadataReadSchemasForProtocol3To4.d.ts.map +1 -1
  14. package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts.map +1 -1
  15. package/dist/compatibility/protocol3To5/toPageForProtocol3To5.js +2 -1
  16. package/dist/compatibility/protocol3To5/toPropertyValueForProtocol3To5.d.ts.map +1 -1
  17. package/dist/compatibility/protocol3To5/toPropertyValueForProtocol3To5.js +0 -2
  18. package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.d.ts +8 -8
  19. package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.d.ts.map +1 -1
  20. package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.js +9 -2
  21. package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts +4 -0
  22. package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts.map +1 -0
  23. package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.js +16 -0
  24. package/dist/context/initialState.d.ts +39 -38
  25. package/dist/context/initialState.d.ts.map +1 -1
  26. package/dist/createCustomBlockHost.d.ts.map +1 -1
  27. package/dist/createCustomBlockHost.js +1 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/manifest/types.d.ts +13 -2
  31. package/dist/manifest/types.d.ts.map +1 -1
  32. package/dist/messages/createSandboxMessageRouter.d.ts +3 -2
  33. package/dist/messages/createSandboxMessageRouter.d.ts.map +1 -1
  34. package/dist/messages/createSandboxMessageRouter.js +7 -1
  35. package/dist/messages/invalidNativeIconColor.d.ts +5 -0
  36. package/dist/messages/invalidNativeIconColor.d.ts.map +1 -0
  37. package/dist/messages/invalidNativeIconColor.js +34 -0
  38. package/dist/pages/types.d.ts +2 -0
  39. package/dist/pages/types.d.ts.map +1 -1
  40. package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +7 -5
  41. package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +0 -4
  42. package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +0 -4
  43. package/dist/protocol/dataSources/collectionSchema.d.ts +0 -4
  44. package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +0 -4
  45. package/dist/protocol/dataSources/messages/queryDataSource.d.ts +14 -12
  46. package/dist/protocol/dataSources/notionDataSource.d.ts +0 -8
  47. package/dist/protocol/dataSources/properties/propertySchema.d.ts +3 -7
  48. package/dist/protocol/dataSources/properties/propertySchema.js +1 -3
  49. package/dist/protocol/handshake/connect.d.ts +13 -2
  50. package/dist/protocol/handshake/init.d.ts +13 -6
  51. package/dist/protocol/icons.d.ts +17 -0
  52. package/dist/protocol/icons.js +27 -0
  53. package/dist/protocol/index.d.ts +6 -5
  54. package/dist/protocol/index.js +4 -3
  55. package/dist/protocol/manifest/capabilities.d.ts +19 -8
  56. package/dist/protocol/manifest/capabilities.js +9 -3
  57. package/dist/protocol/manifest/manifest.d.ts +27 -4
  58. package/dist/protocol/manifest/manifest.js +6 -0
  59. package/dist/protocol/messages/hostToSandbox.d.ts +103 -83
  60. package/dist/protocol/messages/sandboxToHost.d.ts +100 -15
  61. package/dist/protocol/pages/bridgePage.d.ts +7 -6
  62. package/dist/protocol/pages/bridgePage.js +0 -1
  63. package/dist/protocol/pages/messages/createPage.d.ts +102 -26
  64. package/dist/protocol/pages/messages/createPage.js +3 -1
  65. package/dist/protocol/pages/messages/getPage.d.ts +21 -17
  66. package/dist/protocol/pages/messages/updatePage.d.ts +29 -23
  67. package/dist/protocol/pages/pageAppearance.d.ts +36 -1
  68. package/dist/protocol/pages/pageAppearance.js +9 -0
  69. package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +0 -8
  70. package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +0 -4
  71. package/dist/protocol/pages/properties/bridgePagePropertyValue.js +0 -5
  72. package/dist/protocol/utils/protocolVersion.d.ts +2 -1
  73. package/dist/protocol/utils/protocolVersion.js +3 -1
  74. package/docs/bridge/changelog.md +21 -1
  75. package/docs/bridge/protocol.md +20 -3
  76. package/docs/bridge/versioning.md +1 -0
  77. package/docs/compatibility.md +15 -7
  78. package/package.json +1 -1
  79. package/src/compatibility/normalizeHostToSandboxMessage.ts +5 -0
  80. package/src/compatibility/pages/toIconForProtocol3To8.ts +17 -0
  81. package/src/compatibility/pages/toPageWithNullTextFallbackProperties.ts +0 -1
  82. package/src/compatibility/protocol3To5/toPageForProtocol3To5.ts +2 -1
  83. package/src/compatibility/protocol3To5/toPropertyValueForProtocol3To5.ts +0 -2
  84. package/src/compatibility/protocol6/normalizePageResultsForProtocol6.ts +11 -2
  85. package/src/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.ts +22 -0
  86. package/src/createCustomBlockHost.ts +1 -0
  87. package/src/index.ts +1 -0
  88. package/src/messages/createSandboxMessageRouter.ts +18 -2
  89. package/src/messages/invalidNativeIconColor.ts +43 -0
  90. package/src/pages/types.ts +3 -0
package/README.md CHANGED
@@ -182,3 +182,12 @@ These schemas validate wire payloads. Your application still enforces permission
182
182
 
183
183
  `dist/browser.js` is one ES module with all dependencies. Use it when the browser must not fetch
184
184
  additional modules, such as under an exact-URL Content Security Policy.
185
+
186
+ ### Native page icons
187
+
188
+ `CustomBlockHostPageIcon` accepts canonical native icon names from adapters. Adapters validate names
189
+ and colors before writing. The runtime validates response payloads.
190
+
191
+ Adapters must check URL-backed icon and cover writes against the block's network permissions before
192
+ mutating records. Notion permits the submitted HTTPS destination only when its origin is
193
+ allowlisted; that origin is trusted to redirect.
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- var Le,Yo={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function st(e){return!e&&!Le?Yo:{lang:e?.lang??Le?.lang,message:e?.message,abortEarly:e?.abortEarly??Le?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Le?.abortPipeEarly}}var en;function tn(e){return en?.get(e)}var rn;function on(e){return rn?.get(e)}var nn;function sn(e,t){return nn?.get(e)?.get(t)}function _e(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function w(e,t,n,s,c){let p=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,h=c?.received??_e(p),y={kind:e.kind,type:e.type,input:p,expected:f,received:h,message:`Invalid ${t}: ${f?`Expected ${f} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},x=e.kind==="schema",I=c?.message??e.message??sn(e.reference,y.lang)??(x?on(y.lang):null)??s.message??tn(y.lang);I!==void 0&&(y.message=typeof I=="function"?I(y):I),x&&(n.typed=!1),n.issues?n.issues.push(y):n.issues=[y]}function an(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function un(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function at(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function W(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},st())},e}var cn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function pe(e){return{kind:"transformation",type:"brand",reference:pe,async:!1,name:e,"~run"(t){return t}}}function De(e){return{kind:"validation",type:"finite",reference:De,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&w(this,"finite",t,n),t}}}function ut(e,t){let n=_e(e);return{kind:"validation",type:"includes",reference:ut,async:!1,expects:n,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&w(this,"content",s,c,{received:`!${n}`}),s}}}function we(e,t){return{kind:"validation",type:"max_length",reference:we,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&w(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ge(e,t){return{kind:"validation",type:"min_length",reference:ge,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&w(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Te(e,t){return{kind:"validation",type:"min_value",reference:Te,async:!1,expects:`>=${e instanceof Date?e.toJSON():_e(e)}`,requirement:e,message:t,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&w(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():_e(n.value)}),n}}}function ct(e,t){return{kind:"validation",type:"regex",reference:ct,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&w(this,"format",n,s),n}}}function lt(e){return{kind:"transformation",type:"transform",reference:lt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var Dt={abortEarly:!0};function wt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function Ve(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function Tt(e,t){return!e["~run"]({value:t},Dt).issues}function E(e,t){return W({kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let p=0;p<c.length;p++){let f=c[p],h=this.item["~run"]({value:f},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:p,value:f};for(let x of h.issues)x.path?x.path.unshift(y):x.path=[y],n.issues?.push(x);if(n.issues||(n.issues=h.issues),s.abortEarly){n.typed=!1;break}}h.typed||(n.typed=!1),n.value.push(h.value)}}else w(this,"type",n,s);return n}})}function g(e){return W({kind:"schema",type:"boolean",reference:g,expects:"boolean",async:!1,message:e,"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,n),t}})}function i(e,t){return W({kind:"schema",type:"literal",reference:i,expects:_e(e),async:!1,literal:e,message:t,"~run"(n,s){return an(n.value,this.literal)?n.typed=!0:w(this,"type",n,s),n}})}function pt(e){return W({kind:"schema",type:"nan",reference:pt,expects:"NaN",async:!1,message:e,"~run"(t,n){return Number.isNaN(t.value)?t.typed=!0:w(this,"type",t,n),t}})}function mt(e){return W({kind:"schema",type:"never",reference:mt,expects:"never",async:!1,message:e,"~run"(t,n){return w(this,"type",t,n),t}})}function D(e,t){return W({kind:"schema",type:"nullable",reference:D,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=Ve(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}})}function O(e){return W({kind:"schema",type:"number",reference:O,expects:"number",async:!1,message:e,"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,n),t}})}function o(e,t){return W({kind:"schema",type:"object",reference:o,expects:"Object",async:!1,entries:e,message:t,"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let p in this.entries){let f=this.entries[p];if(p in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let h=p in c?c[p]:Ve(f),y=f["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:p,value:h};for(let I of y.issues)I.path?I.path.unshift(x):I.path=[x],n.issues?.push(I);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value[p]=y.value}else if(f.fallback!==void 0)n.value[p]=wt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(w(this,"key",n,s,{input:void 0,expected:`"${p}"`,path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]}),s.abortEarly))break}}else w(this,"type",n,s);return n}})}function a(e,t){return W({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=Ve(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}})}function T(e,t){return W({kind:"schema",type:"picklist",reference:T,expects:at(e.map(_e),"|"),async:!1,options:e,message:t,"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:w(this,"type",n,s),n}})}function Q(e,t,n){return W({kind:"schema",type:"record",reference:Q,expects:"Object",async:!1,key:e,value:t,message:n,"~run"(s,c){let p=s.value;if(p&&typeof p=="object"){s.typed=!0,s.value={};for(let f in p)if(un(p,f)){let h=p[f],y=this.key["~run"]({value:f},c);if(y.issues){let I={type:"object",origin:"key",input:p,key:f,value:h};for(let M of y.issues)M.path=[I],s.issues?.push(M);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let x=this.value["~run"]({value:h},c);if(x.issues){let I={type:"object",origin:"value",input:p,key:f,value:h};for(let M of x.issues)M.path?M.path.unshift(I):M.path=[I],s.issues?.push(M);if(s.issues||(s.issues=x.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!x.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=x.value)}}else w(this,"type",s,c);return s}})}function l(e,t){return W({kind:"schema",type:"strict_object",reference:l,expects:"Object",async:!1,entries:e,message:t,"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let p in this.entries){let f=this.entries[p];if(p in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let h=p in c?c[p]:Ve(f),y=f["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:p,value:h};for(let I of y.issues)I.path?I.path.unshift(x):I.path=[x],n.issues?.push(I);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value[p]=y.value}else if(f.fallback!==void 0)n.value[p]=wt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(w(this,"key",n,s,{input:void 0,expected:`"${p}"`,path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let p in c)if(!Object.prototype.hasOwnProperty.call(this.entries,p)){w(this,"key",n,s,{input:p,expected:"never",path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]});break}}}else w(this,"type",n,s);return n}})}function r(e){return W({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,n){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,n),t}})}function Mt(e){let t;if(e)for(let n of e)if(t)for(let s of n.issues)t.push(s);else t=n.issues;return t}function d(e,t){return W({kind:"schema",type:"union",reference:d,expects:at(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,"~run"(n,s){let c,p,f;for(let h of this.options){let y=h["~run"]({value:n.value},s);if(y.typed)if(y.issues)p?p.push(y):p=[y];else{c=y;break}else f?f.push(y):f=[y]}if(c)return c;if(p){if(p.length===1)return p[0];w(this,"type",n,s,{issues:Mt(p)}),n.typed=!0}else{if(f?.length===1)return f[0];w(this,"type",n,s,{issues:Mt(f)})}return n}})}function qe(){return W({kind:"schema",type:"unknown",reference:qe,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,n){return W({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:n,"~run"(s,c){let p=s.value;if(p&&typeof p=="object"){let f,h=0,y=this.key,x=[],I=(M,X)=>{for(let V of M.options){if(V.type==="variant")I(V,new Set(X).add(V.key));else{let b=!0,N=0;for(let B of X){let z=V.entries[B];if(B in p?z["~run"]({typed:!1,value:p[B]},Dt).issues:z.type!=="exact_optional"&&z.type!=="optional"&&z.type!=="nullish"){b=!1,y!==B&&(h<N||h===N&&B in p&&!(y in p))&&(h=N,y=B,x=[]),y===B&&x.push(V.entries[B].expects);break}N++}if(b){let B=V["~run"]({value:p},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;w(this,"type",s,c,{input:p[y],expected:at(x,"|"),path:[{type:"object",origin:"value",input:p,key:y,value:p[y]}]})}else w(this,"type",s,c);return s}})}function qt(e,t){let n={...e.entries};for(let s of t)delete n[s];return W({...e,entries:n})}function ae(e,t,n){let s=e["~run"]({value:t},st(n));if(s.issues)throw new cn(s.issues);return s.value}function A(...e){return W({...e[0],pipe:e,"~run"(t,n){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=s["~run"](t,n))}return t}})}function de(e,t,n){let s=e["~run"]({value:t},st(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var me=A(r(),pe("NotionBlockId")),Z=A(r(),pe("NotionDataSourceId")),F=A(r(),pe("NotionPageId")),At=A(r(),pe("NotionAgentId")),Nt=A(r(),pe("NotionSpaceId"));var Ut=o({id:Z,table:r(),spaceId:a(Nt)});var Ft=T(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),ft=o({id:r(),name:r(),color:a(Ft),description:a(r())}),ln=o({id:r(),name:r(),color:a(Ft),option_ids:E(r())}),pn=o({synced_property_id:r(),synced_property_name:r()}),R=o({name:r(),description:a(r())}),mn=["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"],zt=T(mn),Ht=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Lt=v("type",[o({...R.entries,type:i("title")}),o({...R.entries,type:i("rich_text")}),o({...R.entries,type:i("number")}),o({...R.entries,type:i("checkbox")}),o({...R.entries,type:i("url")}),o({...R.entries,type:i("email")}),o({...R.entries,type:i("phone_number")}),o({...R.entries,type:i("select"),options:E(ft)}),o({...R.entries,type:i("multi_select"),options:E(ft)}),o({...R.entries,type:i("status"),options:E(ft),groups:E(ln)}),o({...R.entries,type:i("date")}),o({...R.entries,type:i("people")}),o({...R.entries,type:i("files")}),o({...R.entries,type:i("unique_id")}),o({...R.entries,type:i("relation"),data_source_id:a(r()),dual_property:a(pn)}),o({...R.entries,type:i("place")}),o({...R.entries,type:i("formula")}),o({...R.entries,type:i("rollup")}),o({...R.entries,type:i("button")}),o({...R.entries,type:i("verification")}),o({...R.entries,type:i("last_visited_time")}),o({...R.entries,type:i("location")}),o({...R.entries,type:i("created_time")}),o({...R.entries,type:i("last_edited_time")}),o({...R.entries,type:i("created_by")}),o({...R.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 Gt=o({id:a(Z),propertiesById:Q(r(),Lt)});var $t=o({collectionPointer:a(Ut),collectionSchema:a(Gt),propertyIdsByKey:a(Q(r(),a(r()))),inaccessible:a(i(!0))});var ve=Q(r(),$t);function Qt(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([n,s])=>{let c=e.propertyIdsByKey?.[n],p=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return fn(n,c,p?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(n=>n.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function fn(e,t,n,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:n===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:n===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var Ge=o({type:i("page_id"),page_id:F}),$e=o({type:i("data_source_id"),data_source_id:Z}),yn=o({type:i("workspace"),workspace:i(!0)}),dn=o({type:i("block_id"),block_id:me}),vn=o({type:i("agent_id"),agent_id:At}),hn=o({type:i("unavailable")}),re=v("type",[Ge,$e,yn,dn,vn,hn]);var Ie=v("type",[o({type:i("unavailable")}),o({type:i("page"),id:F,parent:re})]);var xe=T(["standard","high"]),Wt="standard";var Ce=T(["light","dark"]);var Xt=o({capability:r(),resource:r()});var gn=v("type",[o({type:i("emoji"),emoji:r()}),o({type:i("external"),url:r()})]),bn=o({name:r(),description:a(r()),type:zt}),Sn=o({name:r(),description:a(r()),icon:a(gn),properties:a(Q(r(),bn),{})}),he=o({version:i(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(o({type:i("emoji"),emoji:r()})),dataSources:a(Q(r(),Sn),{}),capabilities:a(E(Xt))});var Qe=A(r(),pe("NotionUserId"));var ue=o({object:i("user"),id:Qe,name:a(r()),avatar_url:D(r()),type:i("person"),person:o({email:r()})});var kn=r(),Ne=o({code:kn,message:r(),isRetryable:g()}),Ae=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},We=v("status",[o({type:i("init"),initializationId:r(),status:i("success"),theme:Ce,contrastMode:xe,blockId:me,parent:re,page:Ie,manifest:he,dataSources:o({bindings:ve}),currentUser:ue}),o({type:i("init"),initializationId:r(),status:i("error"),error:Ne})]);var Kt=o({type:i("contrastModeChanged"),contrastMode:xe});var Zt=o({type:i("pageChanged"),page:Ie});var Jt=o({type:i("parentChanged"),parent:re});var Yt=o({type:i("themeChanged"),theme:Ce});var er=o({type:i("dataSourcesChanged"),dataSources:o({bindings:ve})});var Xe=o({unit:T(["year","month","week","day"]),value:O(),time:r(),defaultTimeZone:a(r())}),_n=o({unit:T(["hour","minute"]),value:O()}),Ue=o({unit:i("none")}),yt=d([Xe,_n]),tr=a(d([Xe,Ue])),rr=a(d([yt,Ue])),In=o({type:i("date"),start_date:r(),reminder:tr}),xn=o({type:i("daterange"),start_date:r(),end_date:r(),reminder:tr}),Cn=o({type:i("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:rr}),Pn=o({type:i("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:rr}),or=v("type",[In,xn,Cn,Pn]);var Ke=o({id:r(),table:r()});var nr=d([r(),O(),g(),or,E(r()),E(Ke)]);var ir=o({id:F,is_archived:g(),in_trash:g(),propertiesById:Q(r(),a(nr))});var En=o({type:i("emoji"),emoji:r()}),On=o({type:i("custom_emoji"),custom_emoji:o({id:r(),name:a(r()),url:a(r())})}),sr=o({type:i("external"),external:o({url:r()})}),ar=o({type:i("file"),file:o({url:r(),expiry_time:a(r())})}),Pe=v("type",[En,On,sr,ar]),Ee=v("type",[sr,ar]);var L=D(r());var dt={start:r(),end:a(L),time_zone:a(L),reminder:a(d([yt,Ue]))},ur=d([o({...dt,start:A(r(),ut("T"))}),o({...dt,time_zone:r()}),o({...dt,reminder:a(d([Xe,Ue]))})]);var cr=d([o({type:i("external"),name:r(),external:o({url:r()})}),o({type:i("file"),name:r(),file:o({url:r(),expiry_time:a(r())})})]);var Oe=D(o({...Ke.entries,table:T(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var lr=o({lat:O(),lon:O(),name:a(L),address:a(L),aws_place_id:a(L),google_place_id:a(L)});var pr=o({id:r()});var vt=Q(r(),qe());var Ze=d([o({id:r(),name:a(r()),color:a(r()),description:a(L)}),o({name:r(),id:a(r()),color:a(r()),description:a(L)})]);var mr=d([o({object:a(i("user")),id:r()}),o({object:i("group"),id:r(),name:a(L)})]);var j={id:r()},ht=v("type",[o({...j,type:i("title"),title:E(vt)}),o({...j,type:i("rich_text"),rich_text:E(vt)}),o({...j,type:i("number"),number:D(O())}),o({...j,type:i("url"),url:L}),o({...j,type:i("email"),email:L}),o({...j,type:i("phone_number"),phone_number:L}),o({...j,type:i("checkbox"),checkbox:g()}),o({...j,type:i("select"),select:D(Ze)}),o({...j,type:i("status"),status:D(Ze)}),o({...j,type:i("multi_select"),multi_select:E(Ze)}),o({...j,type:i("date"),date:D(ur)}),o({...j,type:i("people"),people:E(mr)}),o({...j,type:i("relation"),has_more:a(g()),relation:E(pr)}),o({...j,type:i("files"),files:E(cr)}),o({...j,type:i("place"),place:D(lr)}),o({...j,type:i("created_time"),created_time:L}),o({...j,type:i("last_edited_time"),last_edited_time:L}),o({...j,type:i("created_by"),created_by:Oe}),o({...j,type:i("last_edited_by"),last_edited_by:Oe}),o({...j,type:i("last_visited_time"),last_visited_time:L}),o({...j,type:i("unique_id"),unique_id:r()}),o({...j,type:i("button"),button:r()}),o({...j,type:i("formula"),formula:r()}),o({...j,type:i("location"),location:r()}),o({...j,type:i("rollup"),rollup:r()}),o({...j,type:i("verification"),verification:r()})]);var Be=Q(r(),ht),fr=Q(r(),D(ht));var oe=o({object:i("page"),id:F,parent:re,properties:fr,created_by:a(Oe,null),last_edited_by:a(Oe,null),last_visited_time:a(D(r()),null),created_time:a(D(r()),null),last_edited_time:a(D(r()),null),icon:a(D(Pe),null),cover:a(D(Ee),null),url:a(D(r()),null),public_url:a(D(r()),null),is_archived:g(),in_trash:g()});var yr=d([l({equals:g()}),l({does_not_equal:g()})]);var ce=d([l({is_empty:i(!0)}),l({is_not_empty:i(!0)})]);var be=d([r(),E(r())]);var dr=d([l({contains:be}),l({contains_all:be}),l({does_not_contain:be}),ce]);var vr=l({object:i("user"),id:A(r(),ge(1),we(2e3))}),hr=d([l({contains:vr}),l({does_not_contain:vr}),l({is_empty:i(!0)}),l({is_not_empty:i(!0)})]);var J=T(["start_date","end_date"]),Bn=T(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Fe=d([Bn,r()]),gr=d([l({target:a(J),equals:Fe}),l({target:a(J),before:Fe}),l({target:a(J),after:Fe}),l({target:a(J),on_or_before:Fe}),l({target:a(J),on_or_after:Fe}),l({target:a(J),this_week:l({})}),l({target:a(J),past_week:l({})}),l({target:a(J),past_month:l({})}),l({target:a(J),past_year:l({})}),l({target:a(J),next_week:l({})}),l({target:a(J),next_month:l({})}),l({target:a(J),next_year:l({})}),l({target:a(J),is_empty:i(!0)}),l({target:a(J),is_not_empty:i(!0)})]);var br=d([l({equals:O()}),l({does_not_equal:O()}),l({greater_than:O()}),l({less_than:O()}),l({greater_than_or_equal_to:O()}),l({less_than_or_equal_to:O()}),ce]);var Je=d([l({equals:be}),l({does_not_equal:be}),ce]);var Sr=l({object:T(["user","group"]),id:A(r(),ge(1))}),kr=d([l({contains:Sr}),l({does_not_contain:Sr}),ce]);var _r=A(F,ct(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),lt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ye=d([l({contains:_r}),l({does_not_contain:_r}),l({is_empty:i(!0)}),l({is_not_empty:i(!0)})]);var Ir=T(["To-do","In progress","Complete","Current","Future"]),xr=d([Ir,A(E(Ir),ge(1),we(5))]),Cr=d([l({group_equals:xr}),l({group_does_not_equal:xr})]);var Pr=d([Je,Cr]);var Re=d([l({equals:r()}),l({does_not_equal:r()}),l({contains:r()}),l({does_not_contain:r()}),l({starts_with:r()}),l({ends_with:r()}),ce]);var gt=d([l({propertyId:r(),relation:Ye}),l({propertyId:r(),created_by:hr}),l({propertyId:r(),title:Re}),l({propertyId:r(),rich_text:Re}),l({propertyId:r(),url:Re}),l({propertyId:r(),email:Re}),l({propertyId:r(),phone_number:Re}),l({propertyId:r(),number:br}),l({propertyId:r(),checkbox:yr}),l({propertyId:r(),select:Je}),l({propertyId:r(),multi_select:dr}),l({propertyId:r(),status:Pr}),l({propertyId:r(),date:gr}),l({propertyId:r(),people:kr})]);var Er=d([gt,l({and:E(gt)})]);var Or=T(["ascending","descending"]);var bt=10,Br=l({propertyId:r(),direction:Or});var Rr=o({type:i("queryDataSource"),subscriptionId:r(),dataSourceId:Z,limit:O(),filter:a(Er),sorts:a(E(Br))}),Rn=r(),jr=o({code:Rn,message:r(),isRetryable:g()}),Mr=v("status",[o({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:E(oe),hasMore:g()}),o({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:jr})]),Dr=v("status",[o({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:E(d([oe,ir])),hasMore:g()}),o({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:jr})]);var jn=r(),Mn=o({code:jn,message:r(),isRetryable:g()}),wr=o({type:i("openExternalUrl"),requestId:r(),url:r()}),Tr=v("status",[o({type:i("openExternalUrlResult"),requestId:r(),status:i("success")}),o({type:i("openExternalUrlResult"),requestId:r(),status:i("error"),error:Mn})]);var je=o({object:i("page"),id:F,parent:re,properties:Be,created_time:a(r()),last_edited_time:a(r()),icon:a(Pe),cover:a(Ee),url:a(r()),public_url:a(r()),is_archived:g(),in_trash:g()});var Dn=r(),Ar=o({code:Dn,message:r(),isRetryable:g()}),Nr=v("status",[o({type:i("createPageResult"),requestId:r(),status:i("success"),page:oe}),o({type:i("createPageResult"),requestId:r(),status:i("error"),error:Ar})]),Ur=v("status",[o({type:i("createPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),o({type:i("createPageResult"),requestId:r(),status:i("error"),error:Ar})]),wn=v("type",[o({type:i("start")}),o({type:i("end")}),o({type:i("before"),blockId:me}),o({type:i("after"),blockId:me})]),Za=v("type",[Ge,$e]),qr={type:i("createPage"),requestId:r(),properties:Be},Fr=v("type",[o({...qr,parent:Ge,position:a(wn)}),o({...qr,parent:$e,position:a(mt())})]);var Tn=r(),zr=o({code:Tn,message:r(),isRetryable:g()}),Hr=o({type:i("getPage"),requestId:r(),pageId:F,dataSourceId:a(Z)}),Lr=v("status",[o({type:i("getPageResult"),requestId:r(),status:i("success"),page:oe}),o({type:i("getPageResult"),requestId:r(),status:i("error"),error:zr})]),Vr=v("status",[o({type:i("getPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),o({type:i("getPageResult"),requestId:r(),status:i("error"),error:zr})]);var qn=T(["side_peek","center_peek"]),An=r(),Nn=o({code:An,message:r(),isRetryable:g()}),Gr=o({type:i("openPage"),requestId:r(),pageId:F,mode:qn}),$r=v("status",[o({type:i("openPageResult"),requestId:r(),status:i("success"),pageId:F}),o({type:i("openPageResult"),requestId:r(),status:i("error"),error:Nn})]);var Un=r(),Qr=o({code:Un,message:r(),isRetryable:g()}),Wr=v("status",[o({type:i("updatePageResult"),requestId:r(),status:i("success"),page:oe}),o({type:i("updatePageResult"),requestId:r(),status:i("error"),error:Qr})]),Xr=v("status",[o({type:i("updatePageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),o({type:i("updatePageResult"),requestId:r(),status:i("error"),error:Qr})]),Kr=o({type:i("updatePage"),requestId:r(),pageId:F,dataSourceId:a(Z),properties:a(Be),icon:a(Pe),cover:a(Ee),archived:a(g())});var Zr=o({type:i("currentUserChanged"),currentUser:ue});var Fn=r(),zn=o({code:Fn,message:r(),isRetryable:g()}),Jr=o({type:i("getUser"),requestId:r(),userId:Qe}),Yr=v("status",[o({type:i("getUserResult"),requestId:r(),status:i("success"),user:ue}),o({type:i("getUserResult"),requestId:r(),status:i("error"),error:zn})]);var eo=o({object:i("list"),results:E(ue),next_cursor:D(r()),has_more:g(),type:i("user"),user:Q(r(),qe())});var Hn=r(),Ln=o({code:Hn,message:r(),isRetryable:g()}),to=o({type:i("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(O())}),ro=v("status",[o({type:i("listUsersResult"),requestId:r(),status:i("success"),list:eo}),o({type:i("listUsersResult"),requestId:r(),status:i("error"),error:Ln})]);var oo=o({type:i("invalidSandboxMessage"),requestId:a(r()),reason:r()});var no=v("type",[We,Yt,Kt,Jt,Zt,Zr,er,Yr,ro,$r,Tr,oo]),io=v("type",[...no.options,Mr,Lr,Nr,Wr]),Au=v("type",[...no.options,Dr,Vr,Ur,Xr]);function so(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,n])=>[t,{...n,collectionSchema:{...n.collectionSchema,propertiesById:{...n.collectionSchema?.propertiesById,...Vt}}}]))}}}function ee(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function ze(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,n])=>{switch(n?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case"last_visited_time":case void 0:return[t,n];default:return ee(n)}}))}}function ao(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Se(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var ke=class extends Error{};function St(e){try{return Vn(e)}catch(t){throw t instanceof RangeError?new ke(t.message):t}}function Vn(e){let{start:t,end:n,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new ke("Date values must include a date.");let p=t.includes("T")||s!=null,f=t.match(/([+-])(\d{2}):(\d{2})$/),h=f?(Number(f[2])*60+Number(f[3]))*(f[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,I=b=>{if(!b.split("T")[0])throw new ke("Date values must include a date.");if(!b.includes("T"))return{date:b,time:"00:00"};let N=b.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(N)return{date:N[1],time:N[2]};if(!s||y){let U=new Date(new Date(b).getTime()+x*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let B=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(b)),z=U=>B.find(te=>te.type===U)?.value;return{date:`${z("year")}-${z("month")}-${z("day")}`,time:`${z("hour")}:${z("minute")}`}},M=I(t),X=n?I(n):void 0;if(!p){if(c&&!("time"in c)&&c.unit!=="none")throw new ke("Hour and minute reminders require a date with a time.");return X?{type:"daterange",start_date:M.date,end_date:X.date,reminder:c}:{type:"date",start_date:M.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return X?{type:"datetimerange",start_date:M.date,start_time:M.time,end_date:X.date,end_time:X.time,time_zone:V,reminder:c}:{type:"datetime",start_date:M.date,start_time:M.time,time_zone:V,reminder:c}}function co(e){switch(e.type){case"title":return uo(e.title);case"rich_text":return uo(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?St(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return Se(e.created_time);case"last_edited_time":return Se(e.last_edited_time);case"last_visited_time":return Se(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return ee(e)}}function uo(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let n=t.text;return n&&typeof n=="object"&&"content"in n&&typeof n.content=="string"?n.content:""}).join("")}function lo(e){let t={};for(let n of Object.values(e.properties))n&&(t[n.id]=co(n));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:Se(e.created_time),last_edited_time:Se(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function po(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(lo)}:{...e,page:ao(ze(e.page))}}function mo(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(ze)}:{...e,page:ze(e.page)}}function fo(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?so(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?po(e):t<7?mo(e):e}var kt=o({theme:Ce,contrastMode:a(xe),blockId:me,parent:re,page:Ie,manifest:he,dataSources:o({bindings:ve}),currentUser:ue}),yo=v("status",[o({status:i("success"),initialState:qt(kt,["manifest"])}),o({status:i("error"),error:Ne})]);var et=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(t,n){return this.bySubscriptionId.get(t)?.token===n}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){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(t,n){let s=this.bySubscriptionId.get(t);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 t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function vo(e,t){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Qn(s,t);if(c!==void 0)return c}}function Qn(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="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 h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,I=(Array.isArray(y)?y:[y]).find(M=>!n.groups.some(X=>X.name===M));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}if("relation"in e&&!Tt(Ye,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Wn(e);if(c===void 0||n.type!==c.propertyType)return;let p=new Set(n.options.map(h=>h.name)),f=Xn(c.operator).find(h=>!p.has(h));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 Wn(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function Xn(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ee(e);return Array.isArray(t)?t:[t]}var Kn=new Set(Ht);function ho(e,t){if(e===void 0)return;if(e.length>bt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${bt} 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(t.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=t.propertiesById[s.propertyId];if(!Kn.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}}}function go(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function _t(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function bo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function So(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function tt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function It(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function xt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Zn=5e3,Jn=5e3,Yn=5e3;function ko(e){let{manifestSource:t,prepareInit:n,sendInitMessage:s,warn:c,flushPendingHostStateChanges:p,minBridgeProtocolVersion:f,noConnectTimeoutMs:h=Zn,initialStateTimeoutMs:y=Jn,noInitResultTimeoutMs:x=Yn,stopHostWithFailure:I,onInitResult:M,onInitSent:X,onConnectionFailure:V}=e,b="waitingForConnect",N,B,z,U,te=!1,fe=!1;function K(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function H(){B!==void 0&&(window.clearTimeout(B),B=void 0)}function G(){z!==void 0&&(window.clearTimeout(z),z=void 0)}function $(k){let{initializationId:C,error:_,phase:se,source:ot}=k;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return ee(b)}b="failed",U=C,K(),H(),s({type:"init",initializationId:C,status:"error",error:_}),V({..._,phase:se,source:ot})}async function ne(k){if(b==="waitingForConnect"){b="preparingInit",U=k.initializationId,K(),B=window.setTimeout(()=>{if(b!=="preparingInit")return;let C=go();c({...C,initializationId:k.initializationId}),$({initializationId:k.initializationId,error:C,phase:"init",source:"host"})},y);try{let C=await n(k);if(b!=="preparingInit")return;if(H(),C.status==="error"){$({initializationId:k.initializationId,error:C.error,phase:"init",source:"host"});return}b="waitingForInitResult";let _={type:"init",initializationId:k.initializationId,status:"success",theme:C.initialState.theme,contrastMode:C.initialState.contrastMode??Wt,blockId:C.initialState.blockId,parent:C.initialState.parent,page:C.initialState.page,currentUser:C.initialState.currentUser,manifest:C.initialState.manifest,dataSources:C.initialState.dataSources};if(s(_),b!=="waitingForInitResult"||(X(),b!=="waitingForInitResult"))return;z=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="failed";let se=So();V({...se,phase:"initResult",source:"host"}),c({...se,initializationId:k.initializationId})},x)}catch(C){if(b!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:C}),$({initializationId:k.initializationId,error:tt(),phase:"init",source:"host"})}}}function q(k){if(b!=="stopped"&&b==="waitingForConnect"){if(!xt(k.bridgeProtocolVersion)){let C=_t({currentBridgeProtocolVersion:k.bridgeProtocolVersion});$({initializationId:k.initializationId,error:C,phase:"connect",source:"host"});return}if(k.bridgeProtocolVersion<f){let C=It({currentBridgeProtocolVersion:k.bridgeProtocolVersion,minBridgeProtocolVersion:f});$({initializationId:k.initializationId,error:C,phase:"connect",source:"host"});return}if(k.status==="error"&&(t==="sandbox"||k.error.code!=="manifest_invalid")){$({initializationId:k.initializationId,error:k.error,phase:"connect",source:"sandbox"});return}fe=!0,ne(k)}}function Y(k){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:C,bridgeProtocolVersion:_}=k;if(C===void 0)return"nack";let se=k.error;return _!==void 0&&(xt(_)?_<f&&(se=It({currentBridgeProtocolVersion:_,minBridgeProtocolVersion:f})):se=_t({currentBridgeProtocolVersion:_})),$({initializationId:C,error:se,phase:"connect",source:"host"}),"handled"}function ie(k){let{initializationId:C,error:_}=k;b!=="waitingForInitResult"||C===void 0||C!==U||(K(),G(),b="failed",c(_),V({..._,phase:"initResult",source:"host"}))}function He(){if(b!=="stopped"){if(te){I({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}te=!0,K(),b==="waitingForConnect"&&(N=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="failed";let k=bo();c(k),V({...k,phase:"connect",source:"host"})},h))}}function Me(k){if(b!=="waitingForInitResult"||k.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:k});return}G(),b=k.status==="success"?"initialized":"failed",k.status==="success"?p():V({...k.error,phase:"initResult",source:"sandbox"}),M(k)}function ye(){b="stopped",K(),H(),G()}return{get status(){return b},get hasConnectedSandbox(){return fe},handleConnect:q,handleInitResult:Me,handleInvalidConnect:Y,handleInvalidInitResult:ie,onIframeLoad:He,stop:ye}}function Ct(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Pt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function _o(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Io(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function xo(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}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===""}function rt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&Co(e)}async function Po(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var Eo=v("status",[o({status:i("success"),manifest:he}),o({status:i("error"),error:Ne})]);function Oo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Bo=o({type:i("resize"),height:A(O(),De(),Te(0))});var Ro=o({type:i("unsubscribeDataSourceQuery"),subscriptionId:r()});var jo=o({code:r(),message:r(),isRetryable:g()});var Mo={type:i("connect"),initializationId:r(),bridgeProtocolVersion:O(),sdkVersion:r()},Do=v("status",[o({status:i("success"),manifest:a(he),...Mo}),o({status:i("error"),error:jo,...Mo})]);var ei=r(),ti=o({code:ei,message:r(),isRetryable:g()}),wo=v("status",[o({type:i("initResult"),initializationId:r(),status:i("success"),initialHeight:a(A(O(),De(),Te(0)))}),o({type:i("initResult"),initializationId:r(),status:i("error"),error:ti})]);var To=o({type:i("invalidHostMessage"),requestId:a(r()),reason:r()});var qo=v("type",[Do,wo,Rr,Ro,Fr,Hr,Jr,to,Gr,wr,Kr,Bo,To]);function Ao(e){return de(qo,e)}function No(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Uo(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Fo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}var ri=o({requestId:r()});function zo(e){let t=de(ri,e);return t.success?t.output.requestId:void 0}function Ho(e){let t=Fo(e);if(t==="invalidHostMessage"||t==="invalidSandboxMessage")return{incomingType:t};let n=zo(e);return{incomingType:t,nack:{type:"invalidSandboxMessage",...n!==void 0?{requestId:n}:{},reason:oi(t)}}}function oi(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Lo=o({initializationId:r()}),ni=o({bridgeProtocolVersion:d([O(),pt()])});function Vo(e){let{iframe:t,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:p,onInvalidConnect:f,onInvalidInitResult:h,onConnect:y,onInitResult:x,onQueryDataSource:I,onUnsubscribeDataSourceQuery:M,onCreatePage:X,onGetPage:V,onOpenPage:b,onOpenExternalUrl:N,onGetUser:B,onListUsers:z,onUpdatePage:U,onResize:te}=e;function fe(K,H){c("warn",{message:"Ignored unsupported sandbox message",payload:Et(K),issues:H});let G=Ho(K);if(G.incomingType==="connect"){let $=de(Lo,K),ne=de(ni,K);if(f({initializationId:$.success?$.output.initializationId:void 0,error:No(),bridgeProtocolVersion:ne.success?ne.output.bridgeProtocolVersion:void 0})==="handled")return}if(G.incomingType==="initResult"){let $=de(Lo,K);h({initializationId:$.success?$.output.initializationId:void 0,error:Uo()})}G.nack!==void 0&&s()!=="stopped"&&p(G.nack)}return function(H){let G=H.source===t.contentWindow,$=H.origin===n;if(!G||!$)return;let ne=Ao(H.data);if(!ne.success){fe(H.data,ne.issues);return}let q=ne.output;if(!Oo(q)&&s()!=="initialized"){c("warn",{message:`Ignored ${q.type} before initialization completed`,payload:Et(q)});return}switch(c("in",Et(q)),q.type){case"connect":y(q);return;case"initResult":x(q);return;case"queryDataSource":I(q);return;case"unsubscribeDataSourceQuery":M(q);return;case"createPage":X(q);return;case"openPage":b(q);return;case"openExternalUrl":N(q);return;case"getPage":V(q);return;case"getUser":B(q);return;case"listUsers":z(q);return;case"updatePage":U(q);return;case"resize":te(q);return;case"invalidHostMessage":return;default:ee(q)}}}function Et(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function Go(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var Qo=5;function si(e){let{iframe:t,prepareInitialState:n,handlers:s,onStatusChange:c,onLog:p,onQueryUnsubscribed:f,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:I}=e,M=ai(e.sandboxUrl,e.manifestSource),X=M.origin,V=Math.max(h??3,3),b=new AbortController,N,B={},z=!1,U=new AbortController,te,fe,K=8,H=new et(u=>{f?.(u)});function G(u,S){p?.(u,S)}function $(u){let S=_.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return ee(S)}let P=fo(u,K);G("out",P),t.contentWindow?.postMessage(P,X)}function ne(u){$(ae(We,u))}function q(u){$(u)}function Y(u){let S=_.status;switch(S){case"initialized":$(ae(io,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:ee(S)}}async function ie(u,S){try{let P=S===void 0?ci(u.type):await S(u);Y({...P,type:`${u.type}Result`,requestId:u.requestId})}catch(P){if(_.status!=="initialized")return;G("warn",P),Y({type:`${u.type}Result`,requestId:u.requestId,status:"error",error:{code:"unknown_error",message:`The host could not complete ${u.type}.`,isRetryable:!1}})}}function He(u){let S=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};Y(S)}async function Me(u,S=H.subscribe(u)){try{let P=ui(fe,u.dataSourceId),le=li(u,P);if(le!==void 0){H.isCurrent(u.subscriptionId,S)&&(H.unsubscribe(u.subscriptionId),He({subscriptionId:u.subscriptionId,response:{status:"error",error:le}}));return}let it=await s.queryDataSource(u);if(!H.isCurrent(u.subscriptionId,S))return;it.status==="error"&&!it.error.isRetryable&&H.unsubscribe(u.subscriptionId),He({subscriptionId:u.subscriptionId,response:it})}finally{let P=H.finish(u.subscriptionId,S);P!==void 0&&Me(P.message,P.token)}}function ye(u){_.status==="stopped"||_.status==="failed"||(Object.assign(B,u),C())}async function k(u){if(b.signal.aborted)return;let S=s.openExternalUrl;if(S===void 0){await ie(u,void 0);return}if(N===u.requestId)return;if(N!==void 0){let le={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};Y(le);return}let P=Go(u.url);if(P===void 0){let le={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};Y(le);return}N=u.requestId;try{await ie(u,()=>S({...u,url:P},{signal:b.signal}))}finally{N===u.requestId&&(N=void 0)}}function C(){if(_.status!=="initialized")return;let u=B;B={},u.theme!==void 0&&Y({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&Y({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&Y({type:"parentChanged",parent:u.parent}),u.page!==void 0&&Y({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&Y({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&Y({type:"currentUserChanged",currentUser:u.currentUser})}let _=ko({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;K=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:rt({url:M,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let P=await(Ko??Bt(S));return _.status!=="preparingInit"?P:se(P)},sendInitMessage:ne,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>G("warn",u),flushPendingHostStateChanges:C,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:I,stopHostWithFailure:jt,onInitResult(u){u.status==="success"&&te!==void 0&&c({status:"initialized",resolvedManifest:te,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function se(u){if(u.status==="error")return u;let S=ae(kt,{...u.initialState,...B});if(te=S.manifest,B={},K<Qo&&S.page.type==="unavailable")return{status:"error",error:Ct()};let P=Wo(S.manifest,S.dataSources);return P!==void 0?{status:"error",error:P}:(fe=S.dataSources,z=!0,{status:"success",initialState:S})}let ot=Zo().catch(Ot),Ko=e.manifestSource==="host"?Bt(void 0).catch(Ot):void 0;async function Zo(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),ae(Eo,u)}function Ot(u){return U.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:tt()}}async function Bt(u){U.signal.throwIfAborted();let S=await Po({manifestSource:e.manifestSource,hostManifest:ot,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let P=ae(yo,await n({manifest:S.manifest,signal:U.signal}));return P.status==="error"?P:{status:"success",initialState:{...P.initialState,manifest:S.manifest}}}let Rt=Vo({iframe:t,sandboxOrigin:X,getInitStatus:()=>_.status,emit:G,sendNack:q,onInvalidConnect:_.handleInvalidConnect,onInvalidInitResult:_.handleInvalidInitResult,onConnect:_.handleConnect,onInitResult:_.handleInitResult,onQueryDataSource:Me,onUnsubscribeDataSourceQuery:u=>H.unsubscribe(u.subscriptionId),onOpenExternalUrl:k,onCreatePage:u=>ie(u,s.createPage),onGetPage:u=>ie(u,s.getPage),onOpenPage:u=>ie(u,s.openPage),onGetUser:u=>ie(u,s.getUser),onListUsers:u=>ie(u,s.listUsers),onUpdatePage:u=>ie(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",Rt),t.addEventListener("load",_.onIframeLoad);function nt(){b.abort(),U.abort(),window.removeEventListener("message",Rt),t.removeEventListener("load",_.onIframeLoad),_.stop(),H.unsubscribeAll()}function Jo(){let u=_.status;nt(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function jt(u){if(_.status!=="stopped"){if(_.status==="failed"){nt();return}nt(),G("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:Jo,setTheme(u){ye({theme:u})},setContrastMode(u){ye({contrastMode:u})},setParent(u){ye({parent:u})},setPage(u){if(u.type==="unavailable"&&K<Qo&&(_.status==="preparingInit"&&z||_.status==="waitingForInitResult"||_.status==="initialized")){jt({...Ct(),phase:"runtime",source:"host"});return}ye({page:u})},setCurrentUser(u){ye({currentUser:u})},setDataSources(u){let S={bindings:ae(ve,u.bindings)},P=_.hasConnectedSandbox&&te!==void 0?Wo(te,S):void 0;return P!==void 0?(G("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:P}):(fe=S,ye({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(_.status!=="initialized")return;let S=ae(Z,u),P=H.refresh(S);if(P===void 0){G("warn",`No active query exists for data source "${u}"`);return}for(let le of P)Me(le.message,le.token)}}}function ai(e,t){let n;try{n=new URL(e)}catch(s){throw t==="host"?s:new Ae(Pt())}if(t==="sandbox"&&!rt({url:n,hostOrigin:window.location.origin}))throw new Ae(Pt());return n}function ui(e,t){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===t)?.collectionSchema}function Wo(e,t){for(let[n,s]of Object.entries(e.dataSources)){let c=t.bindings[n];if(c?.inaccessible===!0)continue;let p=Qt({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||p.status==="missing_schema")return Io();for(let f of p.properties){if(f.status==="missing")return xo();if(f.status!=="mapped")return _o()}}}function ci(e){return{status:"error",error:{code:"unsupported_operation",message:`The host does not support ${e}.`,isRetryable:!1}}}function li(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:vo(e.filter,t)??ho(e.sorts,t)}function pi(e){let{manifestProperties:t,propertySchemasById:n}=e,s=[];for(let[c,p]of Object.entries(t)){let f=mi({propertyKey:c,manifestProperty:p,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function mi(e){let{propertyKey:t,manifestProperty:n,propertySchemasById:s}=e,c=Xo(n.name),p=Object.entries(s).filter(([f,h])=>h.type===n.type&&(f===t||Xo(h.name)===c));return p.length===1?p[0][0]:void 0}function Xo(e){return e.trim().toLowerCase()}function fi(e){return ae(F,e)}export{ke as InvalidNotionDateError,si as createCustomBlockHost,pi as getAutoBoundPropertyIdsByKey,rt as isAllowedLocalPreviewUrl,St as toNotionDateValue,fi as toNotionPageId};
1
+ var Ve,fn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ut(e){return!e&&!Ve?fn:{lang:e?.lang??Ve?.lang,message:e?.message,abortEarly:e?.abortEarly??Ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ve?.abortPipeEarly}}var yn;function dn(e){return yn?.get(e)}var vn;function hn(e){return vn?.get(e)}var gn;function bn(e,t){return gn?.get(e)?.get(t)}function _e(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function M(e,t,o,s,c){let l=c&&"input"in c?c.input:o.value,p=c?.expected??e.expects??null,h=c?.received??_e(l),y={kind:e.kind,type:e.type,input:l,expected:p,received:h,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},x=e.kind==="schema",k=c?.message??e.message??bn(e.reference,y.lang)??(x?hn(y.lang):null)??s.message??dn(y.lang);k!==void 0&&(y.message=typeof k=="function"?k(y):k),x&&(o.typed=!1),o.issues?o.issues.push(y):o.issues=[y]}function Sn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function ct(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}function $(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},ut())},e}var kn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function me(e){return{kind:"transformation",type:"brand",reference:me,async:!1,name:e,"~run"(t){return t}}}function Te(e){return{kind:"validation",type:"finite",reference:Te,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&M(this,"finite",t,o),t}}}function lt(e,t){let o=_e(e);return{kind:"validation",type:"includes",reference:lt,async:!1,expects:o,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&M(this,"content",s,c,{received:`!${o}`}),s}}}function qe(e,t){return{kind:"validation",type:"max_length",reference:qe,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length>this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function fe(e,t){return{kind:"validation",type:"min_length",reference:fe,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length<this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function Ne(e,t){return{kind:"validation",type:"min_value",reference:Ne,async:!1,expects:`>=${e instanceof Date?e.toJSON():_e(e)}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!(o.value>=this.requirement)&&M(this,"value",o,s,{received:o.value instanceof Date?o.value.toJSON():_e(o.value)}),o}}}function pt(e,t){return{kind:"validation",type:"regex",reference:pt,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!this.requirement.test(o.value)&&M(this,"format",o,s),o}}}function mt(e){return{kind:"transformation",type:"transform",reference:mt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var zt={abortEarly:!0};function ft(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function Ae(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function Ht(e,t){return!e["~run"]({value:t},zt).issues}function P(e,t){return $({kind:"schema",type:"array",reference:P,expects:"Array",async:!1,item:e,message:t,"~run"(o,s){let c=o.value;if(Array.isArray(c)){o.typed=!0,o.value=[];for(let l=0;l<c.length;l++){let p=c[l],h=this.item["~run"]({value:p},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:l,value:p};for(let x of h.issues)x.path?x.path.unshift(y):x.path=[y],o.issues?.push(x);if(o.issues||(o.issues=h.issues),s.abortEarly){o.typed=!1;break}}h.typed||(o.typed=!1),o.value.push(h.value)}}else M(this,"type",o,s);return o}})}function g(e){return $({kind:"schema",type:"boolean",reference:g,expects:"boolean",async:!1,message:e,"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:M(this,"type",t,o),t}})}function i(e,t){return $({kind:"schema",type:"literal",reference:i,expects:_e(e),async:!1,literal:e,message:t,"~run"(o,s){return Sn(o.value,this.literal)?o.typed=!0:M(this,"type",o,s),o}})}function Ge(e,t){return $({kind:"schema",type:"loose_object",reference:Ge,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly)for(let l in c)Ft(c,l)&&!Object.prototype.hasOwnProperty.call(this.entries,l)&&(o.value[l]=c[l])}else M(this,"type",o,s);return o}})}function yt(e){return $({kind:"schema",type:"nan",reference:yt,expects:"NaN",async:!1,message:e,"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function dt(e){return $({kind:"schema",type:"never",reference:dt,expects:"never",async:!1,message:e,"~run"(t,o){return M(this,"type",t,o),t}})}function q(e,t){return $({kind:"schema",type:"nullable",reference:q,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===null&&(this.default!==void 0&&(o.value=Ae(this,o,s)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function R(e){return $({kind:"schema",type:"number",reference:R,expects:"number",async:!1,message:e,"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function n(e,t){return $({kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",o,s);return o}})}function a(e,t){return $({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===void 0&&(this.default!==void 0&&(o.value=Ae(this,o,s)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function B(e,t){return $({kind:"schema",type:"picklist",reference:B,expects:ct(e.map(_e),"|"),async:!1,options:e,message:t,"~run"(o,s){return this.options.includes(o.value)?o.typed=!0:M(this,"type",o,s),o}})}function L(e,t,o){return $({kind:"schema",type:"record",reference:L,expects:"Object",async:!1,key:e,value:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let p in l)if(Ft(l,p)){let h=l[p],y=this.key["~run"]({value:p},c);if(y.issues){let k={type:"object",origin:"key",input:l,key:p,value:h};for(let D of y.issues)D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let x=this.value["~run"]({value:h},c);if(x.issues){let k={type:"object",origin:"value",input:l,key:p,value:h};for(let D of x.issues)D.path?D.path.unshift(k):D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=x.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!x.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=x.value)}}else M(this,"type",s,c);return s}})}function m(e,t){return $({kind:"schema",type:"strict_object",reference:m,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly){for(let l in c)if(!Object.prototype.hasOwnProperty.call(this.entries,l)){M(this,"key",o,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",o,s);return o}})}function r(e){return $({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,o){return typeof t.value=="string"?t.typed=!0:M(this,"type",t,o),t}})}function Ut(e){let t;if(e)for(let o of e)if(t)for(let s of o.issues)t.push(s);else t=o.issues;return t}function d(e,t){return $({kind:"schema",type:"union",reference:d,expects:ct(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,"~run"(o,s){let c,l,p;for(let h of this.options){let y=h["~run"]({value:o.value},s);if(y.typed)if(y.issues)l?l.push(y):l=[y];else{c=y;break}else p?p.push(y):p=[y]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",o,s,{issues:Ut(l)}),o.typed=!0}else{if(p?.length===1)return p[0];M(this,"type",o,s,{issues:Ut(p)})}return o}})}function Se(){return $({kind:"schema",type:"unknown",reference:Se,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,o){return $({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let p,h=0,y=this.key,x=[],k=(D,W)=>{for(let V of D.options){if(V.type==="variant")k(V,new Set(W).add(V.key));else{let b=!0,A=0;for(let j of W){let H=V.entries[j];if(j in l?H["~run"]({typed:!1,value:l[j]},zt).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){b=!1,y!==j&&(h<A||h===A&&j in l&&!(y in l))&&(h=A,y=j,x=[]),y===j&&x.push(V.entries[j].expects);break}A++}if(b){let j=V["~run"]({value:l},c);(!p||!p.typed&&j.typed)&&(p=j)}}if(p&&!p.issues)break}};if(k(this,new Set([this.key])),p)return p;M(this,"type",s,c,{input:l[y],expected:ct(x,"|"),path:[{type:"object",origin:"value",input:l,key:y,value:l[y]}]})}else M(this,"type",s,c);return s}})}function Lt(e,t){let o={...e.entries};for(let s of t)delete o[s];return $({...e,entries:o})}function ue(e,t,o){let s=e["~run"]({value:t},ut(o));if(s.issues)throw new kn(s.issues);return s.value}function N(...e){return $({...e[0],pipe:e,"~run"(t,o){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=s["~run"](t,o))}return t}})}function ie(e,t,o){let s=e["~run"]({value:t},ut(o));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ye=N(r(),me("NotionBlockId")),K=N(r(),me("NotionDataSourceId")),z=N(r(),me("NotionPageId")),Vt=N(r(),me("NotionAgentId")),Gt=N(r(),me("NotionSpaceId"));var $t=n({id:K,table:r(),spaceId:a(Gt)});var Qt=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"]),vt=n({id:r(),name:r(),color:a(Qt),description:a(r())}),In=n({id:r(),name:r(),color:a(Qt),option_ids:P(r())}),_n=n({synced_property_id:r(),synced_property_name:r()}),w=n({name:r(),description:a(r())}),xn=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","location","created_time","last_edited_time","created_by","last_edited_by"],Wt=B(xn),Xt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Kt=v("type",[n({...w.entries,type:i("title")}),n({...w.entries,type:i("rich_text")}),n({...w.entries,type:i("number")}),n({...w.entries,type:i("checkbox")}),n({...w.entries,type:i("url")}),n({...w.entries,type:i("email")}),n({...w.entries,type:i("phone_number")}),n({...w.entries,type:i("select"),options:P(vt)}),n({...w.entries,type:i("multi_select"),options:P(vt)}),n({...w.entries,type:i("status"),options:P(vt),groups:P(In)}),n({...w.entries,type:i("date")}),n({...w.entries,type:i("people")}),n({...w.entries,type:i("files")}),n({...w.entries,type:i("unique_id")}),n({...w.entries,type:i("relation"),data_source_id:a(r()),dual_property:a(_n)}),n({...w.entries,type:i("place")}),n({...w.entries,type:i("formula")}),n({...w.entries,type:i("rollup")}),n({...w.entries,type:i("button")}),n({...w.entries,type:i("verification")}),n({...w.entries,type:i("location")}),n({...w.entries,type:i("created_time")}),n({...w.entries,type:i("last_edited_time")}),n({...w.entries,type:i("created_by")}),n({...w.entries,type:i("last_edited_by")})]);var Zt={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 Jt=n({id:a(K),propertiesById:L(r(),Kt)});var Yt=n({collectionPointer:a($t),collectionSchema:a(Jt),propertyIdsByKey:a(L(r(),a(r()))),inaccessible:a(i(!0))});var he=L(r(),Yt);function er(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([o,s])=>{let c=e.propertyIdsByKey?.[o],l=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return Cn(o,c,l?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(o=>o.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function Cn(e,t,o,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:o===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:o===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var $e=n({type:i("page_id"),page_id:z}),Qe=n({type:i("data_source_id"),data_source_id:K}),Pn=n({type:i("workspace"),workspace:i(!0)}),En=n({type:i("block_id"),block_id:ye}),On=n({type:i("agent_id"),agent_id:Vt}),Rn=n({type:i("unavailable")}),re=v("type",[$e,Qe,Pn,En,On,Rn]);var xe=v("type",[n({type:i("unavailable")}),n({type:i("page"),id:z,parent:re})]);var Ce=B(["standard","high"]),tr="standard";var Pe=B(["light","dark"]);var rr=n({capability:r(),resource:d([r(),N(P(r()),fe(1))])});var or=v("type",[n({type:i("emoji"),emoji:r()}),n({type:i("external"),url:r()})]),Bn=n({name:r(),description:a(r()),type:Wt}),jn=n({name:r(),description:a(r()),icon:a(or)}),Mn=n({name:r(),description:a(r()),icon:a(or),properties:a(L(r(),Bn),{})}),ge=n({version:i(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(n({type:i("emoji"),emoji:r()})),dataSources:a(L(r(),Mn),{}),pages:a(L(r(),jn)),capabilities:a(P(rr))});var We=N(r(),me("NotionUserId"));var ce=n({object:i("user"),id:We,name:a(r()),avatar_url:q(r()),type:i("person"),person:n({email:r()})});var Dn=r(),Fe=n({code:Dn,message:r(),isRetryable:g()}),Ue=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},Xe=v("status",[n({type:i("init"),initializationId:r(),status:i("success"),theme:Pe,contrastMode:Ce,blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),n({type:i("init"),initializationId:r(),status:i("error"),error:Fe})]);var nr=n({type:i("contrastModeChanged"),contrastMode:Ce});var ir=n({type:i("pageChanged"),page:xe});var sr=n({type:i("parentChanged"),parent:re});var ar=n({type:i("themeChanged"),theme:Pe});var ur=n({type:i("dataSourcesChanged"),dataSources:n({bindings:he})});var Ke=n({unit:B(["year","month","week","day"]),value:R(),time:r(),defaultTimeZone:a(r())}),wn=n({unit:B(["hour","minute"]),value:R()}),ze=n({unit:i("none")}),ht=d([Ke,wn]),cr=a(d([Ke,ze])),lr=a(d([ht,ze])),Tn=n({type:i("date"),start_date:r(),reminder:cr}),qn=n({type:i("daterange"),start_date:r(),end_date:r(),reminder:cr}),Nn=n({type:i("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:lr}),An=n({type:i("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:lr}),pr=v("type",[Tn,qn,Nn,An]);var Ze=n({id:r(),table:r()});var mr=d([r(),R(),g(),pr,P(r()),P(Ze)]);var fr=n({id:z,is_archived:g(),in_trash:g(),propertiesById:L(r(),a(mr))});var Un=r(),Fn=B(["gray","lightgray","brown","yellow","orange","green","blue","purple","pink","red"]),gt=d([Fn,r()]),bt=Ge({type:i("icon"),icon:Ge({name:Un,color:a(gt)})});var yr=n({type:i("emoji"),emoji:r()}),dr=n({type:i("custom_emoji"),custom_emoji:n({id:r(),name:a(r()),url:a(r())})}),St=n({type:i("external"),external:n({url:r()})}),kt=n({type:i("file"),file:n({url:r(),expiry_time:a(r())})}),Ee=v("type",[bt,yr,dr,St,kt]),be=v("type",[St,kt]),vr=v("type",[bt,yr,dr,St,kt]);var Q=q(r());var It={start:r(),end:a(Q),time_zone:a(Q),reminder:a(d([ht,ze]))},hr=d([n({...It,start:N(r(),lt("T"))}),n({...It,time_zone:r()}),n({...It,reminder:a(d([Ke,ze]))})]);var gr=d([n({type:i("external"),name:r(),external:n({url:r()})}),n({type:i("file"),name:r(),file:n({url:r(),expiry_time:a(r())})})]);var Oe=q(n({...Ze.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var br=n({lat:R(),lon:R(),name:a(Q),address:a(Q),aws_place_id:a(Q),google_place_id:a(Q)});var Sr=n({id:r()});var _t=L(r(),Se());var Je=d([n({id:r(),name:a(r()),color:a(r()),description:a(Q)}),n({name:r(),id:a(r()),color:a(r()),description:a(Q)})]);var kr=d([n({object:a(i("user")),id:r()}),n({object:i("group"),id:r(),name:a(Q)})]);var T={id:r()},xt=v("type",[n({...T,type:i("title"),title:P(_t)}),n({...T,type:i("rich_text"),rich_text:P(_t)}),n({...T,type:i("number"),number:q(R())}),n({...T,type:i("url"),url:Q}),n({...T,type:i("email"),email:Q}),n({...T,type:i("phone_number"),phone_number:Q}),n({...T,type:i("checkbox"),checkbox:g()}),n({...T,type:i("select"),select:q(Je)}),n({...T,type:i("status"),status:q(Je)}),n({...T,type:i("multi_select"),multi_select:P(Je)}),n({...T,type:i("date"),date:q(hr)}),n({...T,type:i("people"),people:P(kr)}),n({...T,type:i("relation"),has_more:a(g()),relation:P(Sr)}),n({...T,type:i("files"),files:P(gr)}),n({...T,type:i("place"),place:q(br)}),n({...T,type:i("created_time"),created_time:Q}),n({...T,type:i("last_edited_time"),last_edited_time:Q}),n({...T,type:i("created_by"),created_by:Oe}),n({...T,type:i("last_edited_by"),last_edited_by:Oe}),n({...T,type:i("unique_id"),unique_id:r()}),n({...T,type:i("button"),button:r()}),n({...T,type:i("formula"),formula:r()}),n({...T,type:i("location"),location:r()}),n({...T,type:i("rollup"),rollup:r()}),n({...T,type:i("verification"),verification:r()})]);var Re=L(r(),xt),Ir=L(r(),q(xt));var oe=n({object:i("page"),id:z,parent:re,properties:Ir,created_by:a(Oe,null),last_edited_by:a(Oe,null),created_time:a(q(r()),null),last_edited_time:a(q(r()),null),icon:a(q(Ee),null),cover:a(q(be),null),url:a(q(r()),null),public_url:a(q(r()),null),is_archived:g(),in_trash:g()});var _r=d([m({equals:g()}),m({does_not_equal:g()})]);var le=d([m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var ke=d([r(),P(r())]);var xr=d([m({contains:ke}),m({contains_all:ke}),m({does_not_contain:ke}),le]);var Cr=m({object:i("user"),id:N(r(),fe(1),qe(2e3))}),Pr=d([m({contains:Cr}),m({does_not_contain:Cr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Z=B(["start_date","end_date"]),zn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),He=d([zn,r()]),Er=d([m({target:a(Z),equals:He}),m({target:a(Z),before:He}),m({target:a(Z),after:He}),m({target:a(Z),on_or_before:He}),m({target:a(Z),on_or_after:He}),m({target:a(Z),this_week:m({})}),m({target:a(Z),past_week:m({})}),m({target:a(Z),past_month:m({})}),m({target:a(Z),past_year:m({})}),m({target:a(Z),next_week:m({})}),m({target:a(Z),next_month:m({})}),m({target:a(Z),next_year:m({})}),m({target:a(Z),is_empty:i(!0)}),m({target:a(Z),is_not_empty:i(!0)})]);var Or=d([m({equals:R()}),m({does_not_equal:R()}),m({greater_than:R()}),m({less_than:R()}),m({greater_than_or_equal_to:R()}),m({less_than_or_equal_to:R()}),le]);var Ye=d([m({equals:ke}),m({does_not_equal:ke}),le]);var Rr=m({object:B(["user","group"]),id:N(r(),fe(1))}),Br=d([m({contains:Rr}),m({does_not_contain:Rr}),le]);var jr=N(z,pt(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),mt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),et=d([m({contains:jr}),m({does_not_contain:jr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Mr=B(["To-do","In progress","Complete","Current","Future"]),Dr=d([Mr,N(P(Mr),fe(1),qe(5))]),wr=d([m({group_equals:Dr}),m({group_does_not_equal:Dr})]);var Tr=d([Ye,wr]);var Be=d([m({equals:r()}),m({does_not_equal:r()}),m({contains:r()}),m({does_not_contain:r()}),m({starts_with:r()}),m({ends_with:r()}),le]);var Ct=d([m({propertyId:r(),relation:et}),m({propertyId:r(),created_by:Pr}),m({propertyId:r(),title:Be}),m({propertyId:r(),rich_text:Be}),m({propertyId:r(),url:Be}),m({propertyId:r(),email:Be}),m({propertyId:r(),phone_number:Be}),m({propertyId:r(),number:Or}),m({propertyId:r(),checkbox:_r}),m({propertyId:r(),select:Ye}),m({propertyId:r(),multi_select:xr}),m({propertyId:r(),status:Tr}),m({propertyId:r(),date:Er}),m({propertyId:r(),people:Br})]);var qr=d([Ct,m({and:P(Ct)})]);var Nr=B(["ascending","descending"]);var Pt=10,Ar=m({propertyId:r(),direction:Nr});var Ur=n({type:i("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:R(),filter:a(qr),sorts:a(P(Ar))}),Hn=r(),Fr=n({code:Hn,message:r(),isRetryable:g()}),zr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(oe),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Fr})]),Hr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(d([oe,fr])),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Fr})]);var Ln=r(),Vn=n({code:Ln,message:r(),isRetryable:g()}),Lr=n({type:i("openExternalUrl"),requestId:r(),url:r()}),Vr=v("status",[n({type:i("openExternalUrlResult"),requestId:r(),status:i("success")}),n({type:i("openExternalUrlResult"),requestId:r(),status:i("error"),error:Vn})]);var je=n({object:i("page"),id:z,parent:re,properties:Re,created_time:a(r()),last_edited_time:a(r()),icon:a(Ee),cover:a(be),url:a(r()),public_url:a(r()),is_archived:g(),in_trash:g()});var Gn=r(),$r=n({code:Gn,message:r(),isRetryable:g()}),Qr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:$r})]),Wr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:$r})]),$n=v("type",[n({type:i("start")}),n({type:i("end")}),n({type:i("before"),blockId:ye}),n({type:i("after"),blockId:ye})]),yu=v("type",[$e,Qe]),Gr={type:i("createPage"),requestId:r(),properties:Re,icon:a(vr),cover:a(be)},Xr=v("type",[n({...Gr,parent:$e,position:a($n)}),n({...Gr,parent:Qe,position:a(dt())})]);var Qn=r(),Kr=n({code:Qn,message:r(),isRetryable:g()}),Zr=n({type:i("getPage"),requestId:r(),pageId:z,dataSourceId:a(K)}),Jr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Kr})]),Yr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Kr})]);var Wn=B(["side_peek","center_peek"]),Xn=r(),Kn=n({code:Xn,message:r(),isRetryable:g()}),eo=n({type:i("openPage"),requestId:r(),pageId:z,mode:Wn}),to=v("status",[n({type:i("openPageResult"),requestId:r(),status:i("success"),pageId:z}),n({type:i("openPageResult"),requestId:r(),status:i("error"),error:Kn})]);var Zn=r(),ro=n({code:Zn,message:r(),isRetryable:g()}),oo=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:ro})]),no=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:ro})]),io=n({type:i("updatePage"),requestId:r(),pageId:z,dataSourceId:a(K),properties:a(Re),icon:a(Ee),cover:a(be),archived:a(g())});var so=n({type:i("currentUserChanged"),currentUser:ce});var Jn=r(),Yn=n({code:Jn,message:r(),isRetryable:g()}),ao=n({type:i("getUser"),requestId:r(),userId:We}),uo=v("status",[n({type:i("getUserResult"),requestId:r(),status:i("success"),user:ce}),n({type:i("getUserResult"),requestId:r(),status:i("error"),error:Yn})]);var co=n({object:i("list"),results:P(ce),next_cursor:q(r()),has_more:g(),type:i("user"),user:L(r(),Se())});var ei=r(),ti=n({code:ei,message:r(),isRetryable:g()}),lo=n({type:i("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(R())}),po=v("status",[n({type:i("listUsersResult"),requestId:r(),status:i("success"),list:co}),n({type:i("listUsersResult"),requestId:r(),status:i("error"),error:ti})]);var mo=n({type:i("invalidSandboxMessage"),requestId:a(r()),reason:r()});var fo=v("type",[Xe,ar,nr,sr,ir,so,ur,uo,po,to,Vr,mo]),yo=v("type",[...fo.options,zr,Jr,Qr,oo]),ec=v("type",[...fo.options,Hr,Yr,Wr,no]);function vo(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,o])=>[t,{...o,collectionSchema:{...o.collectionSchema,propertiesById:{...o.collectionSchema?.propertiesById,...Zt}}}]))}}}function Y(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function tt(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,o])=>{switch(o?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case void 0:return[t,o];default:return Y(o)}}))}}function Me(e){if(e?.type!=="icon")return e;let{name:t,color:o}=e.icon;return{type:"external",external:{url:`https://www.notion.so/icons/${t}_${o??"gray"}.svg`}}}function ho(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:Me(e.icon)??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function De(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var Ie=class extends Error{};function Et(e){try{return ri(e)}catch(t){throw t instanceof RangeError?new Ie(t.message):t}}function ri(e){let{start:t,end:o,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new Ie("Date values must include a date.");let l=t.includes("T")||s!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),h=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,k=b=>{if(!b.split("T")[0])throw new Ie("Date values must include a date.");if(!b.includes("T"))return{date:b,time:"00:00"};let A=b.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(A)return{date:A[1],time:A[2]};if(!s||y){let U=new Date(new Date(b).getTime()+x*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let j=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(b)),H=U=>j.find(ee=>ee.type===U)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},D=k(t),W=o?k(o):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new Ie("Hour and minute reminders require a date with a time.");return W?{type:"daterange",start_date:D.date,end_date:W.date,reminder:c}:{type:"date",start_date:D.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return W?{type:"datetimerange",start_date:D.date,start_time:D.time,end_date:W.date,end_time:W.time,time_zone:V,reminder:c}:{type:"datetime",start_date:D.date,start_time:D.time,time_zone:V,reminder:c}}function bo(e){switch(e.type){case"title":return go(e.title);case"rich_text":return go(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?Et(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return De(e.created_time);case"last_edited_time":return De(e.last_edited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return Y(e)}}function go(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function So(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=bo(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:De(e.created_time),last_edited_time:De(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function ko(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(So)}:{...e,page:ho(tt(e.page))}}function _o(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(Io)}:{...e,page:Io(e.page)}}function Io(e){return{...tt(e),icon:Me(e.icon)}}function Co(e){if(e.type==="queryDataSourceResult")return e.items.some(o=>o.icon?.type==="icon")?{...e,items:e.items.map(xo)}:e;let t=xo(e.page);return t===e.page?e:{...e,page:t}}function xo(e){let t=Me(e.icon);return t===e.icon?e:{...e,icon:t}}function Po(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?vo(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?ko(e):t<7?_o(e):t<9?Co(e):e}var Ot=n({theme:Pe,contrastMode:a(Ce),blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),Eo=v("status",[n({status:i("success"),initialState:Lt(Ot,["manifest"])}),n({status:i("error"),error:Fe})]);var rt=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,o.push({message:c.message,token:c.token})}return s?o:void 0}finish(t,o){let s=this.bySubscriptionId.get(t);if(s?.token===o&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function Oo(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let s of o){let c=si(s,t);if(c!==void 0)return c}}function si(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let o=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="propertyId");if(s!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,k=(Array.isArray(y)?y:[y]).find(D=>!o.groups.some(W=>W.name===D));return k===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${k}".`,isRetryable:!1}}}if("relation"in e&&!Ht(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=ai(e);if(c===void 0||o.type!==c.propertyType)return;let l=new Set(o.options.map(h=>h.name)),p=ui(c.operator).find(h=>!l.has(h));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function ai(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function ui(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:Y(e);return Array.isArray(t)?t:[t]}var ci=new Set(Xt);function Ro(e,t){if(e===void 0)return;if(e.length>Pt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Pt} entries.`,isRetryable:!1};let o=new Set;for(let s of e){if(o.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(o.add(s.propertyId),!Object.hasOwn(t.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=t.propertiesById[s.propertyId];if(!ci.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}}}function Bo(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Rt(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function jo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Mo(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function ot(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function Bt(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function jt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var li=5e3,pi=5e3,mi=5e3;function Do(e){let{manifestSource:t,prepareInit:o,sendInitMessage:s,warn:c,flushPendingHostStateChanges:l,minBridgeProtocolVersion:p,noConnectTimeoutMs:h=li,initialStateTimeoutMs:y=pi,noInitResultTimeoutMs:x=mi,stopHostWithFailure:k,onInitResult:D,onInitSent:W,onConnectionFailure:V}=e,b="waitingForConnect",A,j,H,U,ee=!1,de=!1;function te(){A!==void 0&&(window.clearTimeout(A),A=void 0)}function F(){j!==void 0&&(window.clearTimeout(j),j=void 0)}function G(){H!==void 0&&(window.clearTimeout(H),H=void 0)}function X(I){let{initializationId:E,error:_,phase:ae,source:it}=I;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return Y(b)}b="failed",U=E,te(),F(),s({type:"init",initializationId:E,status:"error",error:_}),V({..._,phase:ae,source:it})}async function se(I){if(b==="waitingForConnect"){b="preparingInit",U=I.initializationId,te(),j=window.setTimeout(()=>{if(b!=="preparingInit")return;let E=Bo();c({...E,initializationId:I.initializationId}),X({initializationId:I.initializationId,error:E,phase:"init",source:"host"})},y);try{let E=await o(I);if(b!=="preparingInit")return;if(F(),E.status==="error"){X({initializationId:I.initializationId,error:E.error,phase:"init",source:"host"});return}b="waitingForInitResult";let _={type:"init",initializationId:I.initializationId,status:"success",theme:E.initialState.theme,contrastMode:E.initialState.contrastMode??tr,blockId:E.initialState.blockId,parent:E.initialState.parent,page:E.initialState.page,currentUser:E.initialState.currentUser,manifest:E.initialState.manifest,dataSources:E.initialState.dataSources};if(s(_),b!=="waitingForInitResult"||(W(),b!=="waitingForInitResult"))return;H=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="failed";let ae=Mo();V({...ae,phase:"initResult",source:"host"}),c({...ae,initializationId:I.initializationId})},x)}catch(E){if(b!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:E}),X({initializationId:I.initializationId,error:ot(),phase:"init",source:"host"})}}}function J(I){if(b!=="stopped"&&b==="waitingForConnect"){if(!jt(I.bridgeProtocolVersion)){let E=Rt({currentBridgeProtocolVersion:I.bridgeProtocolVersion});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.bridgeProtocolVersion<p){let E=Bt({currentBridgeProtocolVersion:I.bridgeProtocolVersion,minBridgeProtocolVersion:p});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.status==="error"&&(t==="sandbox"||I.error.code!=="manifest_invalid")){X({initializationId:I.initializationId,error:I.error,phase:"connect",source:"sandbox"});return}de=!0,se(I)}}function C(I){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:E,bridgeProtocolVersion:_}=I;if(E===void 0)return"nack";let ae=I.error;return _!==void 0&&(jt(_)?_<p&&(ae=Bt({currentBridgeProtocolVersion:_,minBridgeProtocolVersion:p})):ae=Rt({currentBridgeProtocolVersion:_})),X({initializationId:E,error:ae,phase:"connect",source:"host"}),"handled"}function ne(I){let{initializationId:E,error:_}=I;b!=="waitingForInitResult"||E===void 0||E!==U||(te(),G(),b="failed",c(_),V({..._,phase:"initResult",source:"host"}))}function Le(){if(b!=="stopped"){if(ee){k({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}ee=!0,te(),b==="waitingForConnect"&&(A=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="failed";let I=jo();c(I),V({...I,phase:"connect",source:"host"})},h))}}function we(I){if(b!=="waitingForInitResult"||I.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:I});return}G(),b=I.status==="success"?"initialized":"failed",I.status==="success"?l():V({...I.error,phase:"initResult",source:"sandbox"}),D(I)}function ve(){b="stopped",te(),F(),G()}return{get status(){return b},get hasConnectedSandbox(){return de},handleConnect:J,handleInitResult:we,handleInvalidConnect:C,handleInvalidInitResult:ne,onIframeLoad:Le,stop:ve}}function Mt(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Dt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function wo(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function To(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function qo(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function No(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===""}function nt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&No(e)}async function Ao(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var Uo=v("status",[n({status:i("success"),manifest:ge}),n({status:i("error"),error:Fe})]);function Fo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var zo=n({type:i("resize"),height:N(R(),Te(),Ne(0))});var Ho=n({type:i("unsubscribeDataSourceQuery"),subscriptionId:r()});var Lo=n({code:r(),message:r(),isRetryable:g()});var Vo={type:i("connect"),initializationId:r(),bridgeProtocolVersion:R(),sdkVersion:r()},Go=v("status",[n({status:i("success"),manifest:a(ge),...Vo}),n({status:i("error"),error:Lo,...Vo})]);var fi=r(),yi=n({code:fi,message:r(),isRetryable:g()}),$o=v("status",[n({type:i("initResult"),initializationId:r(),status:i("success"),initialHeight:a(N(R(),Te(),Ne(0)))}),n({type:i("initResult"),initializationId:r(),status:i("error"),error:yi})]);var Qo=n({type:i("invalidHostMessage"),requestId:a(r()),reason:r()});var Wo=v("type",[Go,$o,Ur,Ho,Xr,Zr,ao,lo,eo,Lr,io,zo,Qo]);function Xo(e){return ie(Wo,e)}function Ko(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Zo(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Jo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}var di=n({requestId:r()});function Yo(e){let t=ie(di,e);return t.success?t.output.requestId:void 0}function en(e){let t=Jo(e);if(t==="invalidHostMessage"||t==="invalidSandboxMessage")return{incomingType:t};let o=Yo(e);return{incomingType:t,nack:{type:"invalidSandboxMessage",...o!==void 0?{requestId:o}:{},reason:vi(t)}}}function vi(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var hi=n({type:B(["updatePage","createPage"]),requestId:r(),icon:n({type:i("icon"),icon:n({color:Se()})})});function tn(e){let t=ie(hi,e);if(!t.success)return;let o=t.output.icon.icon.color;if(!(o===void 0||ie(gt,o).success))return{type:t.output.type==="createPage"?"createPageResult":"updatePageResult",requestId:t.output.requestId,status:"error",error:{code:"invalid_icon_color",message:"Use a supported Notion icon color.",isRetryable:!1}}}var rn=n({initializationId:r()}),gi=n({bridgeProtocolVersion:d([R(),yt()])});function on(e){let{iframe:t,sandboxOrigin:o,getInitStatus:s,emit:c,sendNack:l,sendPageMutationError:p,onInvalidConnect:h,onInvalidInitResult:y,onConnect:x,onInitResult:k,onQueryDataSource:D,onUnsubscribeDataSourceQuery:W,onCreatePage:V,onGetPage:b,onOpenPage:A,onOpenExternalUrl:j,onGetUser:H,onListUsers:U,onUpdatePage:ee,onResize:de}=e;function te(F,G){let X=tn(F);if(X!==void 0&&s()==="initialized"){p(X);return}c("warn",{message:"Ignored unsupported sandbox message",payload:wt(F),issues:G});let se=en(F);if(se.incomingType==="connect"){let J=ie(rn,F),C=ie(gi,F);if(h({initializationId:J.success?J.output.initializationId:void 0,error:Ko(),bridgeProtocolVersion:C.success?C.output.bridgeProtocolVersion:void 0})==="handled")return}if(se.incomingType==="initResult"){let J=ie(rn,F);y({initializationId:J.success?J.output.initializationId:void 0,error:Zo()})}se.nack!==void 0&&s()!=="stopped"&&l(se.nack)}return function(G){let X=G.source===t.contentWindow,se=G.origin===o;if(!X||!se)return;let J=Xo(G.data);if(!J.success){te(G.data,J.issues);return}let C=J.output;if(!Fo(C)&&s()!=="initialized"){c("warn",{message:`Ignored ${C.type} before initialization completed`,payload:wt(C)});return}switch(c("in",wt(C)),C.type){case"connect":x(C);return;case"initResult":k(C);return;case"queryDataSource":D(C);return;case"unsubscribeDataSourceQuery":W(C);return;case"createPage":V(C);return;case"openPage":A(C);return;case"openExternalUrl":j(C);return;case"getPage":b(C);return;case"getUser":H(C);return;case"listUsers":U(C);return;case"updatePage":ee(C);return;case"resize":de(C);return;case"invalidHostMessage":return;default:Y(C)}}}function wt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function nn(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var an=5;function Si(e){let{iframe:t,prepareInitialState:o,handlers:s,onStatusChange:c,onLog:l,onQueryUnsubscribed:p,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k}=e,D=ki(e.sandboxUrl,e.manifestSource),W=D.origin,V=Math.max(h??3,3),b=new AbortController,A,j={},H=!1,U=new AbortController,ee,de,te=10,F=new rt(u=>{p?.(u)});function G(u,S){l?.(u,S)}function X(u){let S=_.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return Y(S)}let O=Po(u,te);G("out",O),t.contentWindow?.postMessage(O,W)}function se(u){X(ue(Xe,u))}function J(u){X(u)}function C(u){let S=_.status;switch(S){case"initialized":X(ue(yo,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:Y(S)}}async function ne(u,S){try{let O=S===void 0?_i(u.type):await S(u);C({...O,type:`${u.type}Result`,requestId:u.requestId})}catch(O){if(_.status!=="initialized")return;G("warn",O),C({type:`${u.type}Result`,requestId:u.requestId,status:"error",error:{code:"unknown_error",message:`The host could not complete ${u.type}.`,isRetryable:!1}})}}function Le(u){let S=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(S)}async function we(u,S=F.subscribe(u)){try{let O=Ii(de,u.dataSourceId),pe=xi(u,O);if(pe!==void 0){F.isCurrent(u.subscriptionId,S)&&(F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:{status:"error",error:pe}}));return}let at=await s.queryDataSource(u);if(!F.isCurrent(u.subscriptionId,S))return;at.status==="error"&&!at.error.isRetryable&&F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:at})}finally{let O=F.finish(u.subscriptionId,S);O!==void 0&&we(O.message,O.token)}}function ve(u){_.status==="stopped"||_.status==="failed"||(Object.assign(j,u),E())}async function I(u){if(b.signal.aborted)return;let S=s.openExternalUrl;if(S===void 0){await ne(u,void 0);return}if(A===u.requestId)return;if(A!==void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};C(pe);return}let O=nn(u.url);if(O===void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};C(pe);return}A=u.requestId;try{await ne(u,()=>S({...u,url:O},{signal:b.signal}))}finally{A===u.requestId&&(A=void 0)}}function E(){if(_.status!=="initialized")return;let u=j;j={},u.theme!==void 0&&C({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&C({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&C({type:"parentChanged",parent:u.parent}),u.page!==void 0&&C({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&C({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&C({type:"currentUserChanged",currentUser:u.currentUser})}let _=Do({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;te=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:nt({url:D,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let O=await(ln??qt(S));return _.status!=="preparingInit"?O:ae(O)},sendInitMessage:se,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>G("warn",u),flushPendingHostStateChanges:E,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k,stopHostWithFailure:At,onInitResult(u){u.status==="success"&&ee!==void 0&&c({status:"initialized",resolvedManifest:ee,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function ae(u){if(u.status==="error")return u;let S=ue(Ot,{...u.initialState,...j});if(ee=S.manifest,j={},te<an&&S.page.type==="unavailable")return{status:"error",error:Mt()};let O=un(S.manifest,S.dataSources);return O!==void 0?{status:"error",error:O}:(de=S.dataSources,H=!0,{status:"success",initialState:S})}let it=pn().catch(Tt),ln=e.manifestSource==="host"?qt(void 0).catch(Tt):void 0;async function pn(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),ue(Uo,u)}function Tt(u){return U.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:ot()}}async function qt(u){U.signal.throwIfAborted();let S=await Ao({manifestSource:e.manifestSource,hostManifest:it,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let O=ue(Eo,await o({manifest:S.manifest,signal:U.signal}));return O.status==="error"?O:{status:"success",initialState:{...O.initialState,manifest:S.manifest}}}let Nt=on({iframe:t,sandboxOrigin:W,getInitStatus:()=>_.status,emit:G,sendNack:J,sendPageMutationError:X,onInvalidConnect:_.handleInvalidConnect,onInvalidInitResult:_.handleInvalidInitResult,onConnect:_.handleConnect,onInitResult:_.handleInitResult,onQueryDataSource:we,onUnsubscribeDataSourceQuery:u=>F.unsubscribe(u.subscriptionId),onOpenExternalUrl:I,onCreatePage:u=>ne(u,s.createPage),onGetPage:u=>ne(u,s.getPage),onOpenPage:u=>ne(u,s.openPage),onGetUser:u=>ne(u,s.getUser),onListUsers:u=>ne(u,s.listUsers),onUpdatePage:u=>ne(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",Nt),t.addEventListener("load",_.onIframeLoad);function st(){b.abort(),U.abort(),window.removeEventListener("message",Nt),t.removeEventListener("load",_.onIframeLoad),_.stop(),F.unsubscribeAll()}function mn(){let u=_.status;st(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function At(u){if(_.status!=="stopped"){if(_.status==="failed"){st();return}st(),G("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:mn,setTheme(u){ve({theme:u})},setContrastMode(u){ve({contrastMode:u})},setParent(u){ve({parent:u})},setPage(u){if(u.type==="unavailable"&&te<an&&(_.status==="preparingInit"&&H||_.status==="waitingForInitResult"||_.status==="initialized")){At({...Mt(),phase:"runtime",source:"host"});return}ve({page:u})},setCurrentUser(u){ve({currentUser:u})},setDataSources(u){let S={bindings:ue(he,u.bindings)},O=_.hasConnectedSandbox&&ee!==void 0?un(ee,S):void 0;return O!==void 0?(G("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:O}):(de=S,ve({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(_.status!=="initialized")return;let S=ue(K,u),O=F.refresh(S);if(O===void 0){G("warn",`No active query exists for data source "${u}"`);return}for(let pe of O)we(pe.message,pe.token)}}}function ki(e,t){let o;try{o=new URL(e)}catch(s){throw t==="host"?s:new Ue(Dt())}if(t==="sandbox"&&!nt({url:o,hostOrigin:window.location.origin}))throw new Ue(Dt());return o}function Ii(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function un(e,t){for(let[o,s]of Object.entries(e.dataSources)){let c=t.bindings[o];if(c?.inaccessible===!0)continue;let l=er({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||l.status==="missing_schema")return To();for(let p of l.properties){if(p.status==="missing")return qo();if(p.status!=="mapped")return wo()}}}function _i(e){return{status:"error",error:{code:"unsupported_operation",message:`The host does not support ${e}.`,isRetryable:!1}}}function xi(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:Oo(e.filter,t)??Ro(e.sorts,t)}function Ci(e){let{manifestProperties:t,propertySchemasById:o}=e,s=[];for(let[c,l]of Object.entries(t)){let p=Pi({propertyKey:c,manifestProperty:l,propertySchemasById:o});p!==void 0&&s.push([c,p])}return Object.fromEntries(s)}function Pi(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:s}=e,c=cn(o.name),l=Object.entries(s).filter(([p,h])=>h.type===o.type&&(p===t||cn(h.name)===c));return l.length===1?l[0][0]:void 0}function cn(e){return e.trim().toLowerCase()}function Ei(e){return ue(z,e)}export{Ie as InvalidNotionDateError,Si as createCustomBlockHost,Ci as getAutoBoundPropertyIdsByKey,nt as isAllowedLocalPreviewUrl,Et as toNotionDateValue,Ei as toNotionPageId};
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeHostToSandboxMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeHostToSandboxMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,iDAAiD,EACjD,MAAM,4DAA4D,CAAA;AASnE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,oBAAoB,EAC7B,qBAAqB,EAAE,MAAM,GAC3B,iDAAiD,CAiCnD"}
1
+ {"version":3,"file":"normalizeHostToSandboxMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeHostToSandboxMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,iDAAiD,EACjD,MAAM,4DAA4D,CAAA;AAWnE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,oBAAoB,EAC7B,qBAAqB,EAAE,MAAM,GAC3B,iDAAiD,CAoCnD"}
@@ -1,7 +1,8 @@
1
- import { TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "../protocol/utils/protocolVersion.js";
1
+ import { NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "../protocol/utils/protocolVersion.js";
2
2
  import { addMetadataReadSchemasForProtocol3To4 } from "./protocol3To4/addMetadataReadSchemasForProtocol3To4.js";
3
3
  import { normalizePageResultsForProtocol3To5 } from "./protocol3To5/normalizePageResultsForProtocol3To5.js";
4
4
  import { normalizePageResultsForProtocol6 } from "./protocol6/normalizePageResultsForProtocol6.js";
5
+ import { normalizePageResultsForProtocol7To8 } from "./protocol7To8/normalizePageResultsForProtocol7To8.js";
5
6
  /**
6
7
  * Encodes current host messages for the sandbox's declared protocol. Handlers use
7
8
  * current shapes. Each target adapter starts from that shape to avoid data loss.
@@ -35,5 +36,8 @@ export function normalizeHostToSandboxMessage(message, bridgeProtocolVersion) {
35
36
  if (bridgeProtocolVersion < TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION) {
36
37
  return normalizePageResultsForProtocol6(message);
37
38
  }
39
+ if (bridgeProtocolVersion < NATIVE_ICON_PROTOCOL_VERSION) {
40
+ return normalizePageResultsForProtocol7To8(message);
41
+ }
38
42
  return message;
39
43
  }
@@ -31,12 +31,23 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
31
31
  readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
32
32
  readonly name: v.StringSchema<undefined>;
33
33
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
34
- readonly type: v.PicklistSchema<readonly ["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"], undefined>;
34
+ readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
35
35
  }, undefined>, undefined>, {}>;
36
36
  }, undefined>, undefined>, {}>;
37
+ readonly pages: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
38
+ readonly name: v.StringSchema<undefined>;
39
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
40
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
41
+ readonly type: v.LiteralSchema<"emoji", undefined>;
42
+ readonly emoji: v.StringSchema<undefined>;
43
+ }, undefined>, v.ObjectSchema<{
44
+ readonly type: v.LiteralSchema<"external", undefined>;
45
+ readonly url: v.StringSchema<undefined>;
46
+ }, undefined>], undefined>, undefined>;
47
+ }, undefined>, undefined>, undefined>;
37
48
  readonly capabilities: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
38
49
  readonly capability: v.StringSchema<undefined>;
39
- readonly resource: v.StringSchema<undefined>;
50
+ readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
40
51
  }, undefined>, undefined>, undefined>;
41
52
  }, undefined>, undefined>;
42
53
  }, undefined>, v.ObjectSchema<{
@@ -768,10 +779,6 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
768
779
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
769
780
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
770
781
  }, undefined>, undefined>;
771
- }, undefined>, v.ObjectSchema<{
772
- readonly id: v.StringSchema<undefined>;
773
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
774
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
775
782
  }, undefined>, v.ObjectSchema<{
776
783
  readonly id: v.StringSchema<undefined>;
777
784
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -797,6 +804,46 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
797
804
  readonly type: v.LiteralSchema<"verification", undefined>;
798
805
  readonly verification: v.StringSchema<undefined>;
799
806
  }, undefined>], undefined>, undefined>;
807
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
808
+ readonly type: v.LiteralSchema<"icon", undefined>;
809
+ readonly icon: v.LooseObjectSchema<{
810
+ readonly name: v.StringSchema<undefined>;
811
+ readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
812
+ }, undefined>;
813
+ }, undefined>, v.ObjectSchema<{
814
+ readonly type: v.LiteralSchema<"emoji", undefined>;
815
+ readonly emoji: v.StringSchema<undefined>;
816
+ }, undefined>, v.ObjectSchema<{
817
+ readonly type: v.LiteralSchema<"custom_emoji", undefined>;
818
+ readonly custom_emoji: v.ObjectSchema<{
819
+ readonly id: v.StringSchema<undefined>;
820
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
821
+ readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
822
+ }, undefined>;
823
+ }, undefined>, v.ObjectSchema<{
824
+ readonly type: v.LiteralSchema<"external", undefined>;
825
+ readonly external: v.ObjectSchema<{
826
+ readonly url: v.StringSchema<undefined>;
827
+ }, undefined>;
828
+ }, undefined>, v.ObjectSchema<{
829
+ readonly type: v.LiteralSchema<"file", undefined>;
830
+ readonly file: v.ObjectSchema<{
831
+ readonly url: v.StringSchema<undefined>;
832
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
833
+ }, undefined>;
834
+ }, undefined>], undefined>, undefined>;
835
+ readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
836
+ readonly type: v.LiteralSchema<"external", undefined>;
837
+ readonly external: v.ObjectSchema<{
838
+ readonly url: v.StringSchema<undefined>;
839
+ }, undefined>;
840
+ }, undefined>, v.ObjectSchema<{
841
+ readonly type: v.LiteralSchema<"file", undefined>;
842
+ readonly file: v.ObjectSchema<{
843
+ readonly url: v.StringSchema<undefined>;
844
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
845
+ }, undefined>;
846
+ }, undefined>], undefined>, undefined>;
800
847
  readonly parent: v.ObjectSchema<{
801
848
  readonly type: v.LiteralSchema<"page_id", undefined>;
802
849
  readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
@@ -1001,10 +1048,6 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
1001
1048
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
1002
1049
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1003
1050
  }, undefined>, undefined>;
1004
- }, undefined>, v.ObjectSchema<{
1005
- readonly id: v.StringSchema<undefined>;
1006
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
1007
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1008
1051
  }, undefined>, v.ObjectSchema<{
1009
1052
  readonly id: v.StringSchema<undefined>;
1010
1053
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -1030,6 +1073,46 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
1030
1073
  readonly type: v.LiteralSchema<"verification", undefined>;
1031
1074
  readonly verification: v.StringSchema<undefined>;
1032
1075
  }, undefined>], undefined>, undefined>;
1076
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
1077
+ readonly type: v.LiteralSchema<"icon", undefined>;
1078
+ readonly icon: v.LooseObjectSchema<{
1079
+ readonly name: v.StringSchema<undefined>;
1080
+ readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
1081
+ }, undefined>;
1082
+ }, undefined>, v.ObjectSchema<{
1083
+ readonly type: v.LiteralSchema<"emoji", undefined>;
1084
+ readonly emoji: v.StringSchema<undefined>;
1085
+ }, undefined>, v.ObjectSchema<{
1086
+ readonly type: v.LiteralSchema<"custom_emoji", undefined>;
1087
+ readonly custom_emoji: v.ObjectSchema<{
1088
+ readonly id: v.StringSchema<undefined>;
1089
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1090
+ readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1091
+ }, undefined>;
1092
+ }, undefined>, v.ObjectSchema<{
1093
+ readonly type: v.LiteralSchema<"external", undefined>;
1094
+ readonly external: v.ObjectSchema<{
1095
+ readonly url: v.StringSchema<undefined>;
1096
+ }, undefined>;
1097
+ }, undefined>, v.ObjectSchema<{
1098
+ readonly type: v.LiteralSchema<"file", undefined>;
1099
+ readonly file: v.ObjectSchema<{
1100
+ readonly url: v.StringSchema<undefined>;
1101
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1102
+ }, undefined>;
1103
+ }, undefined>], undefined>, undefined>;
1104
+ readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
1105
+ readonly type: v.LiteralSchema<"external", undefined>;
1106
+ readonly external: v.ObjectSchema<{
1107
+ readonly url: v.StringSchema<undefined>;
1108
+ }, undefined>;
1109
+ }, undefined>, v.ObjectSchema<{
1110
+ readonly type: v.LiteralSchema<"file", undefined>;
1111
+ readonly file: v.ObjectSchema<{
1112
+ readonly url: v.StringSchema<undefined>;
1113
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1114
+ }, undefined>;
1115
+ }, undefined>], undefined>, undefined>;
1033
1116
  readonly parent: v.ObjectSchema<{
1034
1117
  readonly type: v.LiteralSchema<"data_source_id", undefined>;
1035
1118
  readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
@@ -1249,10 +1332,6 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
1249
1332
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
1250
1333
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1251
1334
  }, undefined>, undefined>;
1252
- }, undefined>, v.ObjectSchema<{
1253
- readonly id: v.StringSchema<undefined>;
1254
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
1255
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1256
1335
  }, undefined>, v.ObjectSchema<{
1257
1336
  readonly id: v.StringSchema<undefined>;
1258
1337
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -1278,7 +1357,13 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
1278
1357
  readonly type: v.LiteralSchema<"verification", undefined>;
1279
1358
  readonly verification: v.StringSchema<undefined>;
1280
1359
  }, undefined>], undefined>, undefined>, undefined>;
1281
- readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
1360
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
1361
+ readonly type: v.LiteralSchema<"icon", undefined>;
1362
+ readonly icon: v.LooseObjectSchema<{
1363
+ readonly name: v.StringSchema<undefined>;
1364
+ readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
1365
+ }, undefined>;
1366
+ }, undefined>, v.ObjectSchema<{
1282
1367
  readonly type: v.LiteralSchema<"emoji", undefined>;
1283
1368
  readonly emoji: v.StringSchema<undefined>;
1284
1369
  }, undefined>, v.ObjectSchema<{
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAE7D"}
1
+ {"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAE7D"}
@@ -0,0 +1,4 @@
1
+ import type { NotionPageIcon } from "../../protocol/pages/pageAppearance.js";
2
+ /** Converts native icons for legacy receivers. Delete when the runtime minimum reaches 9. */
3
+ export declare function toIconForProtocol3To8(icon: NotionPageIcon | null): NotionPageIcon | null;
4
+ //# sourceMappingURL=toIconForProtocol3To8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toIconForProtocol3To8.d.ts","sourceRoot":"","sources":["../../../src/compatibility/pages/toIconForProtocol3To8.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAA;AAE9F,6FAA6F;AAC7F,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,cAAc,GAAG,IAAI,GACzB,cAAc,GAAG,IAAI,CAWvB"}
@@ -0,0 +1,13 @@
1
+ /** Converts native icons for legacy receivers. Delete when the runtime minimum reaches 9. */
2
+ export function toIconForProtocol3To8(icon) {
3
+ if (icon?.type !== "icon") {
4
+ return icon;
5
+ }
6
+ const { name, color } = icon.icon;
7
+ return {
8
+ type: "external",
9
+ external: {
10
+ url: `https://www.notion.so/icons/${name}_${color ?? "gray"}.svg`,
11
+ },
12
+ };
13
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"toPageWithNullTextFallbackProperties.d.ts","sourceRoot":"","sources":["../../../src/compatibility/pages/toPageWithNullTextFallbackProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAA;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;GAIG;AACH,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,WAAW,CAAC,OAAO,gBAAgB,CAAC,GACxC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAyCtC"}
1
+ {"version":3,"file":"toPageWithNullTextFallbackProperties.d.ts","sourceRoot":"","sources":["../../../src/compatibility/pages/toPageWithNullTextFallbackProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAA;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;GAIG;AACH,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,WAAW,CAAC,OAAO,gBAAgB,CAAC,GACxC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAwCtC"}
@@ -35,7 +35,6 @@ export function toPageWithNullTextFallbackProperties(page) {
35
35
  case "last_edited_time":
36
36
  case "created_by":
37
37
  case "last_edited_by":
38
- case "last_visited_time":
39
38
  case undefined:
40
39
  return [name, property];
41
40
  default: