cozy-external-bridge 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # cozy-external-bridge
2
2
 
3
- This library allows communication between a container app and an app embedded in an iframe. It is used with [cozy-twakechat](https://github.com/cozy/cozy-twakechat/) and [cozy-twakemail](https://github.com/cozy/cozy-twakemail/)
3
+ This library allows communication between a container app and an app embedded in an iframe. It is used with [cozy-twakechat](https://github.com/cozy/cozy-twakechat/) and [cozy-twakemail](https://github.com/cozy/cozy-twakemail/).
4
4
 
5
5
  This is the embedded lib. You can also check the [container lib](https://github.com/linagora/cozy-libs/tree/master/packages/cozy-external-bridge-container).
6
6
 
@@ -8,26 +8,64 @@ This is the embedded lib. You can also check the [container lib](https://github.
8
8
 
9
9
  ## Setup
10
10
 
11
- Import `dist/bundle.js` script.
11
+ ### Class API (React, Vue, ...)
12
+
13
+ Install package using your usual package manager:
14
+
15
+ ```bash
16
+ npm install cozy-external-bridge
17
+ ```
18
+
19
+ ```bash
20
+ yarn add cozy-external-bridge
21
+ ```
22
+
23
+ ### Window API (Flutter)
24
+
25
+ Load the script directly in your `index.html`:
26
+
27
+ ```html
28
+ <script src="cozy-external-bridge/dist/bundle.js"></script>
29
+ ```
30
+
31
+ This will automatically expose methods in `window._cozyBridge`.
12
32
 
13
33
  ## Usage
14
34
 
15
- When imported, it exposes methods in `window._cozyBridge`.
35
+ The API works the same way whether you use Class or Window API. The only difference is how you access the methods:
36
+
37
+ - **Class API**: `bridge.methodName()`
38
+ - **Window API**: `window._cozyBridge.methodName()`
16
39
 
17
- At first, you have the following methods in `window._cozyBridge` :
40
+ ### Class API
18
41
 
19
- - `requestParentOrigin: () => Promise<string | undefined>` : request origin from parent iframe; returns undefined if not in an iframe or no answer from iframe
20
- - `isInIframe: () => boolean` : check if inside an iframe
21
- - `isInsideCozy: (targetOrigin: string) => boolean` : \[DEPRECATED] check if target origin is a Cozy origin
22
- - `setupBridge: (targetOrigin: string) => boolean` : setup bridge to communicate with target origin
42
+ ```javascript
43
+ import { CozyBridge } from 'cozy-external-bridge'
44
+
45
+ const bridge = new CozyBridge()
46
+
47
+ if (bridge.isInIframe()) {
48
+ bridge.setupBridge('https://my-safe-container-app.com')
49
+
50
+ // Now you can use all the additional methods
51
+ const lang = await bridge.getLang()
52
+ const contacts = await bridge.getContacts()
53
+ }
54
+ ```
23
55
 
24
- After setupping bridge, you have the following methods in `window._cozyBridge` :
56
+ ### Window API
25
57
 
26
- - `startHistorySyncing: () => void` : start sending history updates to parent window
27
- - `stopHistorySyncing: () => void` : stop sending history updates to parent window
28
- - `getLang: () => Promise<string>` : get lang from parent window
29
- - `getContacts: () => Promise<IOCozyContact[]>` : get contacts from parent window
30
- - `getFlag: (key: string) => Promise<string | boolean>` : get flags from parent window
58
+ ```javascript
59
+ if(window._cozyBridge.isInIframe()) {
60
+ window._cozyBridge.setupBridge('https://my-safe-container-app.com')
61
+
62
+ // Now you can use all the additional methods
63
+ const lang = await window._cozyBridge.getLang()
64
+ const contacts = await window._cozyBridge.getContacts()
65
+ }
66
+ ```
67
+
68
+ ⚠️ **Important Warning**: When using the Window API, `setupBridge()` replaces the entire `window._cozyBridge` object. Do NOT cache references like `const bridge = window._cozyBridge` before calling `setupBridge()`, as this would create a stale reference. Always access methods directly via `window._cozyBridge.methodName()`.
31
69
 
32
70
  ### How to determine the target origin?
33
71
 
@@ -37,12 +75,26 @@ The bridge simplifies data exchange to a parent window. If not used properly, it
37
75
 
38
76
  You know the URL of the container app? Or you are able to build it? In this case, the setup is easy:
39
77
 
78
+ ```javascript
79
+ import { CozyBridge } from 'cozy-external-bridge'
80
+ const bridge = new CozyBridge()
81
+ const mySafeTargetOrigin = 'https://my-safe-container-app.com'
82
+
83
+ if(bridge.isInIframe()) {
84
+ bridge.setupBridge(mySafeTargetOrigin)
85
+ // bridge safe and ready ✅
86
+ } else {
87
+ // no bridge ❌
88
+ }
89
+ ```
90
+
91
+ With Window API:
92
+
40
93
  ```javascript
41
94
  const mySafeTargetOrigin = 'https://my-safe-container-app.com'
42
95
 
43
96
  if(window._cozyBridge.isInIframe()) {
44
97
  window._cozyBridge.setupBridge(mySafeTargetOrigin)
45
-
46
98
  // bridge safe and ready ✅
47
99
  } else {
48
100
  // no bridge ❌
@@ -51,15 +103,41 @@ if(window._cozyBridge.isInIframe()) {
51
103
 
52
104
  #### Method 2: Check the parent origin
53
105
 
54
- In some case, you may want to be able connect to multiple parent app. In this case, you can leverage the `window._cozyBridge.requestParentOrigin()` method:
106
+ In some case, you may want to be able connect to multiple parent app. In this case, you can leverage the `requestParentOrigin()` method:
55
107
 
56
108
  ```javascript
109
+ import { CozyBridge } from 'cozy-external-bridge'
110
+ const bridge = new CozyBridge()
111
+
57
112
  // check the parent origin e.g. with an allow list
58
113
  const myParentOriginCheck = (parentOrigin) => {
59
114
  if (MY_ALLOW_LIST.includes(parentOrigin)) {
60
115
  return true
61
116
  }
117
+ return false
118
+ }
119
+
120
+ if(bridge.isInIframe()) {
121
+ const parentOrigin = await bridge.requestParentOrigin()
122
+ if(myParentOriginCheck(parentOrigin)) {
123
+ bridge.setupBridge(parentOrigin)
124
+ // bridge safe and ready ✅
125
+ } else {
126
+ // no bridge ❌
127
+ }
128
+ } else {
129
+ // no bridge ❌
130
+ }
131
+ ```
62
132
 
133
+ With Window API:
134
+
135
+ ```javascript
136
+ // check the parent origin e.g. with an allow list
137
+ const myParentOriginCheck = (parentOrigin) => {
138
+ if (MY_ALLOW_LIST.includes(parentOrigin)) {
139
+ return true
140
+ }
63
141
  return false
64
142
  }
65
143
 
@@ -68,7 +146,6 @@ if(window._cozyBridge.isInIframe()) {
68
146
 
69
147
  if(myParentOriginCheck(parentOrigin)) {
70
148
  window._cozyBridge.setupBridge(parentOrigin)
71
-
72
149
  // bridge safe and ready ✅
73
150
  } else {
74
151
  // no bridge ❌
@@ -82,12 +159,129 @@ if(window._cozyBridge.isInIframe()) {
82
159
 
83
160
  In **development environment** ⚠️ only ⚠️, you may want to connect to '\*' as target origin:
84
161
 
162
+ ```javascript
163
+ import { CozyBridge } from 'cozy-external-bridge'
164
+ const bridge = new CozyBridge()
165
+
166
+ if(bridge.isInIframe()) {
167
+ bridge.setupBridge('*')
168
+ // bridge unsafe and ready ⚠️
169
+ } else {
170
+ // no bridge ❌
171
+ }
172
+ ```
173
+
174
+ With Window API:
175
+
85
176
  ```javascript
86
177
  if(window._cozyBridge.isInIframe()) {
87
178
  window._cozyBridge.setupBridge('*')
88
-
89
179
  // bridge unsafe and ready ⚠️
90
180
  } else {
91
181
  // no bridge ❌
92
182
  }
93
183
  ```
184
+
185
+ ## API Reference
186
+
187
+ The library provides a unified API with the following methods and type signatures:
188
+
189
+ ### Core Methods (Available immediately)
190
+
191
+ ```typescript
192
+ interface CozyBridge {
193
+ /**
194
+ * Request origin from parent iframe
195
+ * @returns Promise<string | undefined> - parent origin or undefined if not in iframe/no answer
196
+ */
197
+ requestParentOrigin(): Promise<string | undefined>
198
+
199
+ /**
200
+ * Check if inside an iframe
201
+ * @returns boolean - true if in iframe
202
+ */
203
+ isInIframe(): boolean
204
+
205
+ /**
206
+ * [DEPRECATED] Check if target origin is a Cozy origin
207
+ * @param targetOrigin - origin to check
208
+ * @returns boolean
209
+ */
210
+ isInsideCozy(targetOrigin: string): boolean
211
+
212
+ /**
213
+ * Setup bridge to communicate with target origin
214
+ * @param targetOrigin - the origin to setup bridge with
215
+ * @returns boolean - true if setup successful
216
+ */
217
+ setupBridge(targetOrigin: string): boolean
218
+ }
219
+ ```
220
+
221
+ ### Additional Methods (Available after setupBridge)
222
+
223
+ ```typescript
224
+ interface CozyBridge {
225
+ /**
226
+ * Start sending history updates to parent window
227
+ */
228
+ startHistorySyncing(): void
229
+
230
+ /**
231
+ * Stop sending history updates to parent window
232
+ */
233
+ stopHistorySyncing(): void
234
+
235
+ /**
236
+ * Get lang from parent window
237
+ * @returns Promise<string> - language code
238
+ */
239
+ getLang(): Promise<string>
240
+
241
+ /**
242
+ * Get contacts from parent window
243
+ * @returns Promise<IOCozyContact[]> - array of contacts
244
+ */
245
+ getContacts(): Promise<IOCozyContact[]>
246
+
247
+ /**
248
+ * Get flags from parent window
249
+ * @param key - flag key
250
+ * @returns Promise<string | boolean> - flag value
251
+ */
252
+ getFlag(key: string): Promise<string | boolean>
253
+
254
+ /**
255
+ * Create documents in parent window
256
+ * @param data - document data
257
+ * @returns Promise<object> - created documents
258
+ */
259
+ createDocs(data: object): Promise<object>
260
+
261
+ /**
262
+ * Update documents in parent window
263
+ * @param data - document data
264
+ * @returns Promise<object> - updated documents
265
+ */
266
+ updateDocs(data: object): Promise<object>
267
+
268
+ /**
269
+ * Request notification permission from parent window
270
+ * @returns Promise<NotificationPermission> - permission status
271
+ */
272
+ requestNotificationPermission(): Promise<NotificationPermission>
273
+
274
+ /**
275
+ * Send notification via parent window
276
+ * @param data - notification data with title and body
277
+ */
278
+ sendNotification(data: { title: string; body: string }): Promise<void>
279
+
280
+ /**
281
+ * Perform search via parent window
282
+ * @param searchQuery - search query string
283
+ * @returns Promise<object[]> - search results
284
+ */
285
+ search(searchQuery: string): Promise<object[]>
286
+ }
287
+ ```
package/dist/bundle.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{var t={627:function(t){function e(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){r(t);return}s.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise(function(o,i){var a=t.apply(r,n);function s(t){e(a,o,i,s,u,"next",t)}function u(t){e(a,o,i,s,u,"throw",t)}s(void 0)})}},t.exports.__esModule=!0,t.exports.default=t.exports},35:function(t){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports},755:function(t){t.exports=function(t){return t&&t.__esModule?t:{default:t}},t.exports.__esModule=!0,t.exports.default=t.exports},17:function(t,e,r){var n=r(430).default;function o(){"use strict";t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},r=Object.prototype,i=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o,i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new L(n||[]);return i._invoke=(o="suspendedStart",function(e,n){if("executing"===o)throw Error("Generator is already running");if("completed"===o){if("throw"===e)throw n;return P()}for(a.method=e,a.arg=n;;){var i=a.delegate;if(i){var s=function t(e,r){var n=e.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,t(e,r),"throw"===r.method))return d;r.method="throw",r.arg=TypeError("The iterator does not provide a 'throw' method")}return d}var o=p(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):i:(r.method="throw",r.arg=TypeError("iterator result is not an object"),r.delegate=null,d)}(i,a);if(s){if(s===d)continue;return s}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var u=p(t,r,a);if("normal"===u.type){if(o=a.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:a.done}}"throw"===u.type&&(o="completed",a.method="throw",a.arg=u.arg)}}),i}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var d={};function h(){}function g(){}function y(){}var v={};l(v,s,function(){return this});var m=Object.getPrototypeOf,w=m&&m(m(k([])));w&&w!==r&&i.call(w,s)&&(v=w);var b=y.prototype=h.prototype=Object.create(v);function x(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function E(t,e){var r;this._invoke=function(o,a){function s(){return new e(function(r,s){!function r(o,a,s,u){var c=p(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&i.call(f,"__await")?e.resolve(f.__await).then(function(t){r("next",t,s,u)},function(t){r("throw",t,s,u)}):e.resolve(f).then(function(t){l.value=t,s(l)},function(t){return r("throw",t,s,u)})}u(c.arg)}(o,a,r,s)})}return r=r?r.then(s,s):s()}}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function k(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(i.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:P}}function P(){return{value:void 0,done:!0}}return g.prototype=y,l(b,"constructor",y),l(y,"constructor",g),g.displayName=l(y,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},e.awrap=function(t){return{__await:t}},x(E.prototype),l(E.prototype,u,function(){return this}),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new E(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(b),l(b,c,"Generator"),l(b,s,function(){return this}),l(b,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=i.call(o,"catchLoc"),u=i.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},430:function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},134:function(t,e,r){var n=r(17)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},408:function(t,e,r){"use strict";r.r(e),r.d(e,{createEndpoint:()=>o,expose:()=>l,finalizer:()=>a,proxy:()=>b,proxyMarker:()=>n,releaseProxy:()=>i,transfer:()=>w,transferHandlers:()=>c,windowEndpoint:()=>x,wrap:()=>p});let n=Symbol("Comlink.proxy"),o=Symbol("Comlink.endpoint"),i=Symbol("Comlink.releaseProxy"),a=Symbol("Comlink.finalizer"),s=Symbol("Comlink.thrown"),u=t=>"object"==typeof t&&null!==t||"function"==typeof t,c=new Map([["proxy",{canHandle:t=>u(t)&&t[n],serialize(t){let{port1:e,port2:r}=new MessageChannel;return l(t,e),[r,[r]]},deserialize:t=>(t.start(),p(t))}],["throw",{canHandle:t=>u(t)&&s in t,serialize({value:t}){let e;return[t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[]]},deserialize(t){if(t.isError)throw Object.assign(Error(t.value.message),t.value);throw t.value}}]]);function l(t,e=globalThis,r=["*"]){e.addEventListener("message",function n(o){let i;if(!o||!o.data)return;if(!function(t,e){for(let r of t)if(e===r||"*"===r||r instanceof RegExp&&r.test(e))return!0;return!1}(r,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}let{id:u,type:c,path:p}=Object.assign({path:[]},o.data),d=(o.data.argumentList||[]).map(O);try{let e=p.slice(0,-1).reduce((t,e)=>t[e],t),r=p.reduce((t,e)=>t[e],t);switch(c){case"GET":i=r;break;case"SET":e[p.slice(-1)[0]]=O(o.data.value),i=!0;break;case"APPLY":i=r.apply(e,d);break;case"CONSTRUCT":{let t=new r(...d);i=b(t)}break;case"ENDPOINT":{let{port1:e,port2:r}=new MessageChannel;l(t,r),i=w(e,[e])}break;case"RELEASE":i=void 0;break;default:return}}catch(t){i={value:t,[s]:0}}Promise.resolve(i).catch(t=>({value:t,[s]:0})).then(r=>{let[o,i]=E(r);e.postMessage(Object.assign(Object.assign({},o),{id:u}),i),"RELEASE"===c&&(e.removeEventListener("message",n),f(e),a in t&&"function"==typeof t[a]&&t[a]())}).catch(t=>{let[r,n]=E({value:TypeError("Unserializable return value"),[s]:0});e.postMessage(Object.assign(Object.assign({},r),{id:u}),n)})}),e.start&&e.start()}function f(t){"MessagePort"===t.constructor.name&&t.close()}function p(t,e){return function t(e,r=[],n=function(){}){let a=!1,s=new Proxy(n,{get(n,o){if(d(a),o===i)return()=>{y&&y.unregister(s),h(e),a=!0};if("then"===o){if(0===r.length)return{then:()=>s};let t=S(e,{type:"GET",path:r.map(t=>t.toString())}).then(O);return t.then.bind(t)}return t(e,[...r,o])},set(t,n,o){d(a);let[i,s]=E(o);return S(e,{type:"SET",path:[...r,n].map(t=>t.toString()),value:i},s).then(O)},apply(n,i,s){d(a);let u=r[r.length-1];if(u===o)return S(e,{type:"ENDPOINT"}).then(O);if("bind"===u)return t(e,r.slice(0,-1));let[c,l]=v(s);return S(e,{type:"APPLY",path:r.map(t=>t.toString()),argumentList:c},l).then(O)},construct(t,n){d(a);let[o,i]=v(n);return S(e,{type:"CONSTRUCT",path:r.map(t=>t.toString()),argumentList:o},i).then(O)}});return!function(t,e){let r=(g.get(e)||0)+1;g.set(e,r),y&&y.register(t,e,t)}(s,e),s}(t,[],e)}function d(t){if(t)throw Error("Proxy has been released and is not useable")}function h(t){return S(t,{type:"RELEASE"}).then(()=>{f(t)})}let g=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{let e=(g.get(t)||0)-1;g.set(t,e),0===e&&h(t)});function v(t){var e;let r=t.map(E);return[r.map(t=>t[0]),(e=r.map(t=>t[1]),Array.prototype.concat.apply([],e))]}let m=new WeakMap;function w(t,e){return m.set(t,e),t}function b(t){return Object.assign(t,{[n]:!0})}function x(t,e=globalThis,r="*"){return{postMessage:(e,n)=>t.postMessage(e,r,n),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function E(t){for(let[e,r]of c)if(r.canHandle(t)){let[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},m.get(t)||[]]}function O(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function S(t,e,r){return new Promise(n=>{let o=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.addEventListener("message",function e(r){r.data&&r.data.id&&r.data.id===o&&(t.removeEventListener("message",e),n(r.data))}),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),r)})}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.rv=()=>"1.2.7",r.ruid="bundler=rspack@1.2.7",(()=>{"use strict";var t,e=r(755),n=e(r(134)),o=e(r(35)),i=e(r(627)),a=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var r=s(e);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if("default"!==i&&Object.prototype.hasOwnProperty.call(t,i)){var a=o?Object.getOwnPropertyDescriptor(t,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=t[i]}return n.default=t,r&&r.set(t,n),n}(r(408));function s(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(s=function(t){return t?r:e})(t)}function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function c(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach(function(e){(0,o.default)(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var l=history.pushState,f=history.replaceState,p=function(){t.updateHistory(document.location.href)},d=function(){console.log("\uD83D\uDFE3 Starting history syncing"),history.pushState=function(e,r,n){l.call(history,e,r,n),n&&t.updateHistory(n.toString())},history.replaceState=function(e,r,n){f.call(history,e,r,n),n&&t.updateHistory(n.toString())},window.addEventListener("popstate",p)},h=function(){console.log("\uD83D\uDFE3 Stopping history syncing"),history.pushState=l,history.replaceState=f,window.removeEventListener("popstate",p)},g=function(){var e=(0,i.default)(n.default.mark(function e(){var r;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Fetching contacts..."),e.next=3,t.getContacts();case 3:return console.log("\uD83D\uDFE3 Twake received contacts...",r=e.sent),e.abrupt("return",r);case 6:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),y=function(){var e=(0,i.default)(n.default.mark(function e(){var r;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Fetching lang..."),e.next=3,t.getLang();case 3:return console.log("\uD83D\uDFE3 Twake received lang...",r=e.sent),e.abrupt("return",r);case 6:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),v=function(){var e=(0,i.default)(n.default.mark(function e(r){var o;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Getting flag..."),e.next=3,t.getFlag(r);case 3:return console.log("\uD83D\uDFE3 Twake received flag...",o=e.sent),e.abrupt("return",o);case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),m=function(){var e=(0,i.default)(n.default.mark(function e(r){var o;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Creating file..."),e.next=3,t.createDocs(r);case 3:return console.log("\uD83D\uDFE3 Twake received created file...",o=e.sent),e.abrupt("return",o);case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),w=function(){var e=(0,i.default)(n.default.mark(function e(r){var o;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Updating data..."),e.next=3,t.updateDocs(r);case 3:return console.log("\uD83D\uDFE3 Twake received updated file...",o=e.sent),e.abrupt("return",o);case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),b=function(){var e=(0,i.default)(n.default.mark(function e(r){var o;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Search..."),e.next=3,t.search(r);case 3:return console.log("\uD83D\uDFE3 Search results: ",o=e.sent),e.abrupt("return",o);case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),x=function(){var e=(0,i.default)(n.default.mark(function e(){var r;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Requesting notification permission..."),e.next=3,t.requestNotificationPermission();case 3:return console.log("\uD83D\uDFE3 Notification permission request result: ",r=e.sent),e.abrupt("return",r);case 6:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),E=function(){var e=(0,i.default)(n.default.mark(function e(r){return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("\uD83D\uDFE3 Sending notification..."),e.next=3,t.sendNotification(r);case 3:console.log("\uD83D\uDFE3 Notification sent");case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}();window._cozyBridge={requestParentOrigin:function(){return new Promise(function(t){if(window.self===window.parent)return t(void 0);var e=function e(n){if("answerParentOrigin"===n.data)return clearTimeout(r),window.removeEventListener("message",e),t(n.origin)};window.addEventListener("message",e),window.parent.postMessage("requestParentOrigin","*");var r=setTimeout(function(){return window.removeEventListener("message",e),t(void 0)},1e3)})},isInIframe:function(){return window.self!==window.top},isInsideCozy:function(t){console.log("[DEPRECATED] isInsideCozy is deprecated:\n - please use isInIframe to check if you are inside an iframe\n - please setup the bridge directly with the legitimate container target origin or check the container target origin on your side");try{if(!t)return!1;var e=new URL(t);return e.hostname.endsWith(".linagora.com")||e.hostname.endsWith(".twake.app")||e.hostname.endsWith(".lin-saas.com")||e.hostname.endsWith(".lin-saas.dev")||e.hostname.endsWith(".mycozy.cloud")||e.hostname.endsWith(".cozy.works")||e.hostname.endsWith(".cozy.company")||e.hostname.endsWith(".localhost")||e.hostname.endsWith(".local")}catch(t){return!1}},setupBridge:function(e){return e?(console.log("\uD83D\uDFE3 Setup bridge to",e),t=a.wrap(a.windowEndpoint(self.parent,self,e)),window._cozyBridge=c(c({},window._cozyBridge),{},{startHistorySyncing:d,stopHistorySyncing:h,getContacts:g,getLang:y,getFlag:v,createDocs:m,updateDocs:w,requestNotificationPermission:x,sendNotification:E,search:b}),console.log("\uD83D\uDFE3 Bridge ready"),!0):(console.log("\uD83D\uDFE3 No target origin, doing nothing"),!1)}}})()})();
1
+ (()=>{var e={590:function(e,t,r){"use strict";var n=r(755);Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.CozyBridge=void 0;var o=n(r(134)),a=n(r(627)),i=n(r(329)),s=n(r(344)),u=n(r(35)),c=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}(r(408));function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}var f=(0,i.default)(function e(){var t,r,n,i,l,f=this;(0,s.default)(this,e),(0,u.default)(this,"availableMethods",void 0),(0,u.default)(this,"originalPushState",history.pushState),(0,u.default)(this,"originalReplaceState",history.replaceState),(0,u.default)(this,"onPopstate",function(){var e;null===(e=f.availableMethods)||void 0===e||e.updateHistory(document.location.href)}),(0,u.default)(this,"startHistorySyncing",function(){if(!f.availableMethods){console.log("\uD83D\uDFE3 Bridge not setup, cannot start history syncing");return}console.log("\uD83D\uDFE3 Starting history syncing");var e=f.availableMethods;history.pushState=function(t,r,n){f.originalPushState.call(history,t,r,n),n&&e.updateHistory(n.toString())},history.replaceState=function(t,r,n){f.originalReplaceState.call(history,t,r,n),n&&e.updateHistory(n.toString())},window.addEventListener("popstate",f.onPopstate)}),(0,u.default)(this,"stopHistorySyncing",function(){console.log("\uD83D\uDFE3 Stopping history syncing"),history.pushState=f.originalPushState,history.replaceState=f.originalReplaceState,window.removeEventListener("popstate",f.onPopstate)}),(0,u.default)(this,"getContacts",(0,a.default)(o.default.mark(function e(){var t;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Fetching contacts..."),e.next=5,f.availableMethods.getContacts();case 5:return console.log("\uD83D\uDFE3 Twake received contacts...",t=e.sent),e.abrupt("return",t);case 8:case"end":return e.stop()}},e)}))),(0,u.default)(this,"getLang",(0,a.default)(o.default.mark(function e(){var t;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Fetching lang..."),e.next=5,f.availableMethods.getLang();case 5:return console.log("\uD83D\uDFE3 Twake received lang...",t=e.sent),e.abrupt("return",t);case 8:case"end":return e.stop()}},e)}))),(0,u.default)(this,"getFlag",(t=(0,a.default)(o.default.mark(function e(t){var r;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Getting flag..."),e.next=5,f.availableMethods.getFlag(t);case 5:return console.log("\uD83D\uDFE3 Twake received flag...",r=e.sent),e.abrupt("return",r);case 8:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)})),(0,u.default)(this,"createDocs",(r=(0,a.default)(o.default.mark(function e(t){var r;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Creating file..."),e.next=5,f.availableMethods.createDocs(t);case 5:return console.log("\uD83D\uDFE3 Twake received created file...",r=e.sent),e.abrupt("return",r);case 8:case"end":return e.stop()}},e)})),function(e){return r.apply(this,arguments)})),(0,u.default)(this,"updateDocs",(n=(0,a.default)(o.default.mark(function e(t){var r;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Updating data..."),e.next=5,f.availableMethods.updateDocs(t);case 5:return console.log("\uD83D\uDFE3 Twake received updated file...",r=e.sent),e.abrupt("return",r);case 8:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)})),(0,u.default)(this,"search",(i=(0,a.default)(o.default.mark(function e(t){var r;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Search..."),e.next=5,f.availableMethods.search(t);case 5:return console.log("\uD83D\uDFE3 Search results: ",r=e.sent),e.abrupt("return",r);case 8:case"end":return e.stop()}},e)})),function(e){return i.apply(this,arguments)})),(0,u.default)(this,"requestNotificationPermission",(0,a.default)(o.default.mark(function e(){var t;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Requesting notification permission..."),e.next=5,f.availableMethods.requestNotificationPermission();case 5:return console.log("\uD83D\uDFE3 Notification permission request result: ",t=e.sent),e.abrupt("return",t);case 8:case"end":return e.stop()}},e)}))),(0,u.default)(this,"sendNotification",(l=(0,a.default)(o.default.mark(function e(t){return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f.availableMethods){e.next=2;break}throw Error("Bridge not setup");case 2:return console.log("\uD83D\uDFE3 Sending notification..."),e.next=5,f.availableMethods.sendNotification(t);case 5:console.log("\uD83D\uDFE3 Notification sent");case 6:case"end":return e.stop()}},e)})),function(e){return l.apply(this,arguments)})),(0,u.default)(this,"requestParentOrigin",function(){return new Promise(function(e){if(window.self===window.parent)return e(void 0);var t=function t(n){if("answerParentOrigin"===n.data&&n.source===window.parent&&n.origin)return clearTimeout(r),window.removeEventListener("message",t),e(n.origin)};window.addEventListener("message",t),window.parent.postMessage("requestParentOrigin","*");var r=setTimeout(function(){return window.removeEventListener("message",t),e(void 0)},1e3)})}),(0,u.default)(this,"isInIframe",function(){return window.self!==window.top}),(0,u.default)(this,"isInsideCozy",function(e){console.log("[DEPRECATED] isInsideCozy is deprecated:\n - please use isInIframe to check if you are inside an iframe\n - please setup the bridge directly with the legitimate container target origin or check the container target origin on your side");try{if(!e)return!1;var t=new URL(e);return t.hostname.endsWith(".linagora.com")||t.hostname.endsWith(".twake.app")||t.hostname.endsWith(".lin-saas.com")||t.hostname.endsWith(".lin-saas.dev")||t.hostname.endsWith(".mycozy.cloud")||t.hostname.endsWith(".cozy.works")||t.hostname.endsWith(".cozy.company")||t.hostname.endsWith(".localhost")||t.hostname.endsWith(".local")}catch(e){return!1}}),(0,u.default)(this,"setupBridge",function(e){return e?(console.log("\uD83D\uDFE3 Setup bridge to",e),f.availableMethods=c.wrap(c.windowEndpoint(self.parent,self,e)),!0):(console.log("\uD83D\uDFE3 No target origin, doing nothing"),!1)})});t.CozyBridge=f,t.default=f},627:function(e){function t(e,t,r,n,o,a,i){try{var s=e[a](i),u=s.value}catch(e){r(e);return}s.done?t(u):Promise.resolve(u).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise(function(o,a){var i=e.apply(r,n);function s(e){t(i,o,a,s,u,"next",e)}function u(e){t(i,o,a,s,u,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},344:function(e){e.exports=function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},329:function(e){function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},35:function(e){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},755:function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},17:function(e,t,r){var n=r(430).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},r=Object.prototype,a=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o,a=Object.create((t&&t.prototype instanceof h?t:h).prototype),i=new P(n||[]);return a._invoke=(o="suspendedStart",function(t,n){if("executing"===o)throw Error("Generator is already running");if("completed"===o){if("throw"===t)throw n;return L()}for(i.method=t,i.arg=n;;){var a=i.delegate;if(a){var s=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return d;r.method="throw",r.arg=TypeError("The iterator does not provide a 'throw' method")}return d}var o=p(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):a:(r.method="throw",r.arg=TypeError("iterator result is not an object"),r.delegate=null,d)}(a,i);if(s){if(s===d)continue;return s}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===o)throw o="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);o="executing";var u=p(e,r,i);if("normal"===u.type){if(o=i.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(o="completed",i.method="throw",i.arg=u.arg)}}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d={};function h(){}function g(){}function y(){}var v={};l(v,s,function(){return this});var m=Object.getPrototypeOf,w=m&&m(m(k([])));w&&w!==r&&a.call(w,s)&&(v=w);var b=y.prototype=h.prototype=Object.create(v);function x(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function E(e,t){var r;this._invoke=function(o,i){function s(){return new t(function(r,s){!function r(o,i,s,u){var c=p(e[o],e,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&a.call(f,"__await")?t.resolve(f.__await).then(function(e){r("next",e,s,u)},function(e){r("throw",e,s,u)}):t.resolve(f).then(function(e){l.value=e,s(l)},function(e){return r("throw",e,s,u)})}u(c.arg)}(o,i,r,s)})}return r=r?r.then(s,s):s()}}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function k(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(a.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:L}}function L(){return{value:void 0,done:!0}}return g.prototype=y,l(b,"constructor",y),l(y,"constructor",g),g.displayName=l(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,l(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},x(E.prototype),l(E.prototype,u,function(){return this}),t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},x(b),l(b,c,"Generator"),l(b,s,function(){return this}),l(b,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},430:function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},134:function(e,t,r){var n=r(17)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},408:function(e,t,r){"use strict";r.r(t),r.d(t,{createEndpoint:()=>o,expose:()=>l,finalizer:()=>i,proxy:()=>b,proxyMarker:()=>n,releaseProxy:()=>a,transfer:()=>w,transferHandlers:()=>c,windowEndpoint:()=>x,wrap:()=>p});let n=Symbol("Comlink.proxy"),o=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),i=Symbol("Comlink.finalizer"),s=Symbol("Comlink.thrown"),u=e=>"object"==typeof e&&null!==e||"function"==typeof e,c=new Map([["proxy",{canHandle:e=>u(e)&&e[n],serialize(e){let{port1:t,port2:r}=new MessageChannel;return l(e,t),[r,[r]]},deserialize:e=>(e.start(),p(e))}],["throw",{canHandle:e=>u(e)&&s in e,serialize({value:e}){let t;return[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]]},deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function l(e,t=globalThis,r=["*"]){t.addEventListener("message",function n(o){let a;if(!o||!o.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(r,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}let{id:u,type:c,path:p}=Object.assign({path:[]},o.data),d=(o.data.argumentList||[]).map(O);try{let t=p.slice(0,-1).reduce((e,t)=>e[t],e),r=p.reduce((e,t)=>e[t],e);switch(c){case"GET":a=r;break;case"SET":t[p.slice(-1)[0]]=O(o.data.value),a=!0;break;case"APPLY":a=r.apply(t,d);break;case"CONSTRUCT":{let e=new r(...d);a=b(e)}break;case"ENDPOINT":{let{port1:t,port2:r}=new MessageChannel;l(e,r),a=w(t,[t])}break;case"RELEASE":a=void 0;break;default:return}}catch(e){a={value:e,[s]:0}}Promise.resolve(a).catch(e=>({value:e,[s]:0})).then(r=>{let[o,a]=E(r);t.postMessage(Object.assign(Object.assign({},o),{id:u}),a),"RELEASE"===c&&(t.removeEventListener("message",n),f(t),i in e&&"function"==typeof e[i]&&e[i]())}).catch(e=>{let[r,n]=E({value:TypeError("Unserializable return value"),[s]:0});t.postMessage(Object.assign(Object.assign({},r),{id:u}),n)})}),t.start&&t.start()}function f(e){"MessagePort"===e.constructor.name&&e.close()}function p(e,t){return function e(t,r=[],n=function(){}){let i=!1,s=new Proxy(n,{get(n,o){if(d(i),o===a)return()=>{y&&y.unregister(s),h(t),i=!0};if("then"===o){if(0===r.length)return{then:()=>s};let e=S(t,{type:"GET",path:r.map(e=>e.toString())}).then(O);return e.then.bind(e)}return e(t,[...r,o])},set(e,n,o){d(i);let[a,s]=E(o);return S(t,{type:"SET",path:[...r,n].map(e=>e.toString()),value:a},s).then(O)},apply(n,a,s){d(i);let u=r[r.length-1];if(u===o)return S(t,{type:"ENDPOINT"}).then(O);if("bind"===u)return e(t,r.slice(0,-1));let[c,l]=v(s);return S(t,{type:"APPLY",path:r.map(e=>e.toString()),argumentList:c},l).then(O)},construct(e,n){d(i);let[o,a]=v(n);return S(t,{type:"CONSTRUCT",path:r.map(e=>e.toString()),argumentList:o},a).then(O)}});return!function(e,t){let r=(g.get(t)||0)+1;g.set(t,r),y&&y.register(e,t,e)}(s,t),s}(e,[],t)}function d(e){if(e)throw Error("Proxy has been released and is not useable")}function h(e){return S(e,{type:"RELEASE"}).then(()=>{f(e)})}let g=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(g.get(e)||0)-1;g.set(e,t),0===t&&h(e)});function v(e){var t;let r=e.map(E);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let m=new WeakMap;function w(e,t){return m.set(e,t),e}function b(e){return Object.assign(e,{[n]:!0})}function x(e,t=globalThis,r="*"){return{postMessage:(t,n)=>e.postMessage(t,r,n),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function E(e){for(let[t,r]of c)if(r.canHandle(e)){let[n,o]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},o]}return[{type:"RAW",value:e},m.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return c.get(e.name).deserialize(e.value);case"RAW":return e.value}}function S(e,t,r){return new Promise(n=>{let o=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.addEventListener("message",function t(r){r.data&&r.data.id&&r.data.id===o&&(e.removeEventListener("message",t),n(r.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),r)})}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.rv=()=>"1.2.7",r.ruid="bundler=rspack@1.2.7";(()=>{"use strict";var e=r(755)(r(35));function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}var o=new(r(590)).CozyBridge;window._cozyBridge={requestParentOrigin:o.requestParentOrigin,isInIframe:o.isInIframe,isInsideCozy:o.isInsideCozy,setupBridge:function(e){var t=o.setupBridge(e);return t&&(window._cozyBridge=n(n({},window._cozyBridge),{},{startHistorySyncing:o.startHistorySyncing,stopHistorySyncing:o.stopHistorySyncing,getContacts:o.getContacts,getLang:o.getLang,getFlag:o.getFlag,createDocs:o.createDocs,updateDocs:o.updateDocs,requestNotificationPermission:o.requestNotificationPermission,sendNotification:o.sendNotification,search:o.search})),t}}})()})();
2
2
  //# sourceMappingURL=bundle.js.map