@enbox/api 0.6.12 → 0.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.mjs CHANGED
@@ -2076,7 +2076,7 @@ zoo`.split(`
2076
2076
  `),e+=` Deleted: ${this.deleted}
2077
2077
  `,e+=` Created: ${this.dateCreated}
2078
2078
  `,e+=` Timestamp: ${this.timestamp}
2079
- `,e+="}",e}async paginationCursor(e){return pR(ke.RecordsWrite,this.rawMessage)?l7(this.rawMessage,e):void 0}async update({timestamp:e,data:r,encryption:n,protocolRole:i,store:a=!0,...s}){if(this.deleted)throw new Error("Record: Cannot revive a deleted record.");let o=n??this._encryption!==void 0,{parentId:c,...l}=this._recordsWriteDescriptor,d=c?this._contextId.split("/").slice(0,-1).join("/"):void 0,u={...l,...s,parentContextId:d,protocolRole:i??this._protocolRole,messageTimestamp:e,recordId:this._recordId};(B3(u.tags)||u.tags===null)&&delete u.tags;let f;r!==void 0&&(delete u.dataCid,delete u.dataSize,{dataBlob:f}=Iv(r,u.dataFormat));let h=new Set(["data","dataCid","dataFormat","dataSize","datePublished","messageTimestamp","published","tags"]);lu.verifyPermittedMutation(Object.keys(s),h),s.published===!1&&u.datePublished!==void 0&&delete u.datePublished;let p={author:this._connectedDid,dataStream:f,messageParams:{...u},messageType:ke.RecordsWrite,target:this._connectedDid,store:a,encryption:o||void 0};await this.applyDelegateGrant(p);let m=await this._agent.processDwnRequest(p),{message:g,reply:{status:_}}=m;if(!(200<=_.code&&_.code<=299))return{status:_,record:this};let w=this._initialWrite??{...this.rawMessage},E=new lu(this._agent,{author:this._author,connectedDid:this._connectedDid,delegateDid:this._delegateDid,remoteOrigin:this._remoteOrigin,protocolRole:i??this._protocolRole,initialWrite:w,encodedData:r!==void 0?f:this._encodedData,...g},this._permissionsApi),k=g;return this._descriptor=k.descriptor,this._attestation=k.attestation,this._authorization=k.authorization,this._encryption=k.encryption,this._contextId=k.contextId,this._initialWrite=w,this._protocolRole=i??this._protocolRole,this._encodedData=r!==void 0?f:this._encodedData,this._readableStream=void 0,this._rawMessageDirty=!0,{status:_,record:E}}async delete(e){let{store:r=!0,signAsOwner:n,timestamp:i,prune:a=!1}=e||{},s=n&&this._delegateDid===void 0,o=n&&this._delegateDid!==void 0;if(this.deleted&&!this._initialWrite)throw new Error("Record: Record is in an invalid state, initial write is missing.");this._initialWrite||(this._initialWrite={...this.rawMessage}),await this.processInitialWriteIfNeeded({store:r,signAsOwner:n});let c={messageType:ke.RecordsDelete,author:this._connectedDid,target:this._connectedDid,signAsOwner:s,signAsOwnerDelegate:o,store:r},l=e?.protocolRole?d7(this.rawMessage)!==e.protocolRole:!1;this.deleted&&!l?c.rawMessage=this.rawMessage:c.messageParams={prune:a,recordId:this._recordId,messageTimestamp:i,protocolRole:e?.protocolRole??this._protocolRole},await this.applyDelegateGrant(c);let d=await this._agent.processDwnRequest(c),{message:u,reply:{status:f}}=d;if(f.code!==202)return{status:f,record:this};let h=this._initialWrite,p=new lu(this._agent,{author:Jo(u),connectedDid:this._connectedDid,delegateDid:this._delegateDid,remoteOrigin:this._remoteOrigin,protocolRole:e?.protocolRole??this._protocolRole,initialWrite:h,...u},this._permissionsApi),m=u;return this._descriptor=m.descriptor,this._authorization=m.authorization,this._protocolRole=e?.protocolRole??this._protocolRole,this._encodedData=void 0,this._readableStream=void 0,this._rawMessageDirty=!0,{status:f,record:p}}async processInitialWriteIfNeeded({store:e,signAsOwner:r}){if(this.initialWrite&&(r&&!this._initialWriteSigned||e&&!this._initialWriteStored)){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0,a={messageType:ke.RecordsWrite,rawMessage:this.initialWrite,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e};await this.applyDelegateGrant(a);let s=await this._agent.processDwnRequest(a),{message:o,reply:{status:c}}=s,l=o;200<=c.code&&c.code<=299&&(e&&(this._initialWriteStored=!0),r&&(this._initialWriteSigned=!0,this.initialWrite.authorization=l.authorization))}}async processRecord({store:e,signAsOwner:r}){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0;await this.processInitialWriteIfNeeded({store:e,signAsOwner:r});let a;this.deleted?a={messageType:ke.RecordsDelete,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e}:a={messageType:ke.RecordsWrite,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,dataStream:await this.data.blob(),signAsOwner:n,signAsOwnerDelegate:i,store:e},await this.applyDelegateGrant(a);let s=await this._agent.processDwnRequest(a),{message:o,reply:{status:c}}=s,l=o;return 200<=c.code&&c.code<=299&&r&&(this._authorization=l.authorization,this._rawMessageDirty=!0),{status:c}}async readRecordData({target:e,isRemote:r}){let n={author:this._connectedDid,messageParams:{filter:{recordId:this.id},protocolRole:this._protocolRole},messageType:ke.RecordsRead,target:e,...this._encryption?{encryption:!0}:{}};if(this._delegateDid)try{await this.applyDelegateGrant(n)}catch{n.author=this._delegateDid}let i=r?this._agent.sendDwnRequest(n):this._agent.processDwnRequest(n);try{let{reply:{status:a,entry:s}}=await i;if(a.code!==200)throw new Error(`${a.code}: ${a.detail}`);return s.data}catch(a){throw new Error(`Error encountered while attempting to read data: ${a.message}`)}}async applyDelegateGrant(e){if(!this._delegateDid)return;let{message:r}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:e.messageType});e.messageParams={...e.messageParams,delegatedGrant:r},e.granteeDid=this._delegateDid}static verifyPermittedMutation(e,r){for(let n of e)if(!r.has(n))throw new Error(`${n} is an immutable property. Its value cannot be changed.`)}isRecordsDeleteDescriptor(e){return e.interface+e.method===ke.RecordsDelete}};lu._sendCache=Tv;var qd=lu;var bR=class extends CustomEvent{constructor(e){super(e.type,{detail:e})}},$x=class extends EventTarget{constructor(r){super();this._closed=!1;this._connected=!0;let{agent:n,connectedDid:i,cursor:a,delegateDid:s,protocolRole:o,remoteOrigin:c,permissionsApi:l,initialEntries:d,subscription:u}=r;this._subscription=u,this.cursor=a,this.records=d.map(f=>new qd(n,{author:Jo(f),connectedDid:i,remoteOrigin:c,delegateDid:s,protocolRole:o,...f},l)),this._knownRecords=new Map;for(let f of this.records)this._knownRecords.set(f.id,f.timestamp)}get isConnected(){return this._connected}handleEvent(r){if(this._closed)return;let n;if(r.deleted)n="delete",this._knownRecords.delete(r.id);else{let a=this._knownRecords.get(r.id);if(a!==void 0){if(r.timestamp<=a)return;n="update"}else n="create";this._knownRecords.set(r.id,r.timestamp)}let i={type:n,record:r};this.dispatchEvent(new bR(i)),this.dispatchEvent(new CustomEvent("change",{detail:i}))}handleLifecycleEvent(r,n){this._closed||(r==="disconnected"?this._connected=!1:r==="reconnected"&&(this._connected=!0),this.dispatchEvent(new CustomEvent(r,{detail:n})))}on(r,n){let i=a=>{let s=a.detail;r==="change"?n(s):r==="create"||r==="update"||r==="delete"?n(s.record):r==="reconnecting"?n(s):n()};return this.addEventListener(r,i),()=>{this.removeEventListener(r,i)}}async close(){this._closed||(this._closed=!0,await this._subscription.close())}};y();qt();y();qt();var Ox=class t{constructor(e,r){this._permissions=e,this._connectedDid=r.connectedDid,this._message=r.message}get author(){return Jo(this._message)}static async parse({connectedDid:e,agent:r,message:n}){let i=new ei({agent:r});return new t(i,{connectedDid:e,message:n})}get agent(){return this._permissions.agent}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(e){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}};var dp=class t{constructor({api:e,connectedDid:r,message:n,grant:i}){this._permissions=e,this._connectedDid=r,this._message=n,this._grant=i}static parse(e){let r=lr.parse(e.message),n=new ei({agent:e.agent});return new t({...e,grant:r,api:n})}get agent(){return this._permissions.agent}get id(){return this._grant.id}get grantor(){return this._grant.grantor}get grantee(){return this._grant.grantee}get dateGranted(){return this._grant.dateGranted}get description(){return this._grant.description}get requestId(){return this._grant.requestId}get dateExpires(){return this._grant.dateExpires}get delegated(){return this._grant.delegated}get scope(){return this._grant.scope}get conditions(){return this._grant.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({store:!0,author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}async import(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({store:e,author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:!0,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}async revoke(e=!0){let r=await this._permissions.createRevocation({store:e,author:this._connectedDid,grant:this._grant});return Ox.parse({connectedDid:this._connectedDid,agent:this.agent,message:r.message})}isRevoked(e=!1){return this._permissions.isGrantRevoked({author:this._connectedDid,target:this.grantor,grantRecordId:this.id,remote:e})}toJSON(){return{id:this.id,grantor:this.grantor,grantee:this.grantee,dateGranted:this.dateGranted,description:this.description,requestId:this.requestId,dateExpires:this.dateExpires,delegated:this.delegated,scope:this.scope,conditions:this.conditions}}};y();qt();var Dv=class t{constructor({api:e,connectedDid:r,message:n,request:i}){this._permissions=e,this._connectedDid=r,this._request=i,this._message=n}static parse({connectedDid:e,agent:r,message:n}){let i=$a.parse(n),a=new ei({agent:r});return new t({api:a,connectedDid:e,message:n,request:i})}get agent(){return this._permissions.agent}get id(){return this._request.id}get requester(){return this._request.requester}get description(){return this._request.description}get delegated(){return this._request.delegated}get scope(){return this._request.scope}get conditions(){return this._request.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(){let{encodedData:e,...r}=this.rawMessage,n=new Blob([Ue.base64Url(e).toUint8Array()]),{reply:i,message:a}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,rawMessage:r,dataStream:n});return this._message={...a,encodedData:e},{status:i.status}}async grant(e,r=!0){let{message:n}=await this._permissions.createGrant({requestId:this.id,grantedTo:this.requester,scope:this.scope,delegated:this.delegated,author:this._connectedDid,store:r,dateExpires:e});return dp.parse({connectedDid:this._connectedDid,agent:this.agent,message:n})}toJSON(){return this._request}};y();var Av=class{constructor(e,r,n){this._agent=e,this._metadata=n,this._protocolsConfigureMessage=r}get definition(){return this._protocolsConfigureMessage.descriptor.definition}toJSON(){return this._protocolsConfigureMessage}async send(e){let{reply:r}=await this._agent.sendDwnRequest({author:this._metadata.author,messageCid:this._metadata.messageCid,messageType:ke.ProtocolsConfigure,target:e});return{status:r.status}}};var jx=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid,this.delegateDid=e.delegateDid,this.permissionsApi=new ei({agent:this.agent})}get isDelegate(){return this.delegateDid!==void 0}get permissions(){return{request:async e=>{let{message:r}=await this.permissionsApi.createRequest({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return Dv.parse(n)},grant:async e=>{let{message:r}=await this.permissionsApi.createGrant({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return dp.parse(n)},queryRequests:async(e={})=>{let{from:r,...n}=e,i=await this.permissionsApi.fetchRequests({...n,author:this.delegateDid??this.connectedDid,target:r??this.delegateDid??this.connectedDid,remote:r!==void 0}),a=[];for(let s of i){let o={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:s.message};a.push(Dv.parse(o))}return a},queryGrants:async(e={})=>{let{from:r,...n}=e,i=r!==void 0,a=this.delegateDid??this.connectedDid,s=r??this.delegateDid??this.connectedDid,o=await this.permissionsApi.fetchGrants({...n,author:a,target:s,remote:i}),c=[];for(let l of o){let d={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:l.message};c.push(dp.parse(d))}return c}}}get protocols(){return{configure:async e=>{let{encryption:r,...n}=e,i={author:this.connectedDid,messageParams:n,messageType:ke.ProtocolsConfigure,target:this.connectedDid,encryption:r};if(this.delegateDid){let{message:d}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.definition.protocol,delegate:!0,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,delegatedGrant:d},i.granteeDid=this.delegateDid}let a=await this.agent.processDwnRequest(i),{message:s,messageCid:o,reply:{status:c}}=a,l={status:c};if(c.code<300){let d={author:this.connectedDid,messageCid:o};l.protocol=new Av(this.agent,s,d)}return l},query:async e=>{let{from:r,...n}=e,i={author:this.connectedDid,messageParams:n,messageType:ke.ProtocolsQuery,target:r||this.connectedDid};if(this.delegateDid)try{let{grant:{id:d}}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.filter.protocol,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,permissionGrantId:d},i.granteeDid=this.delegateDid}catch{i.author=this.delegateDid}let a;r?a=await this.agent.sendDwnRequest(i):a=await this.agent.processDwnRequest(i);let s=a.reply,{entries:o=[],status:c}=s;return{protocols:o.map(d=>{let u={author:this.connectedDid};return new Av(this.agent,d,u)}),status:c}}}}get records(){return{delete:async e=>{let{from:r,protocol:n,...i}=e,a={author:this.connectedDid,messageParams:i,messageType:ke.RecordsDelete,target:r||this.connectedDid};if(this.delegateDid){let{message:c}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n,delegate:!0,cached:!0,messageType:a.messageType});a.messageParams={...a.messageParams,delegatedGrant:c},a.granteeDid=this.delegateDid}let s;r?s=await this.agent.sendDwnRequest(a):s=await this.agent.processDwnRequest(a);let{reply:{status:o}}=s;return{status:o}},query:async e=>{let{from:r,encryption:n,...i}=e,a={author:this.connectedDid,messageParams:i,messageType:ke.RecordsQuery,target:r||this.connectedDid,encryption:n};if(this.delegateDid)try{let{message:f}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:i.filter?.protocol,delegate:!0,cached:!0,messageType:a.messageType});a.messageParams={...a.messageParams,delegatedGrant:f},a.granteeDid=this.delegateDid}catch{a.author=this.delegateDid}let s;r?s=await this.agent.sendDwnRequest(a):s=await this.agent.processDwnRequest(a);let o=s.reply,{entries:c=[],status:l,cursor:d}=o;return{records:c.map(f=>{let h={author:Jo(f),connectedDid:this.connectedDid,remoteOrigin:r,delegateDid:this.delegateDid,protocolRole:a.messageParams.protocolRole,...f};return new qd(this.agent,h,this.permissionsApi)}),status:l,cursor:d}},read:async e=>{let{from:r,protocol:n,encryption:i,...a}=e,s={author:this.connectedDid,messageParams:a,messageType:ke.RecordsRead,target:r||this.connectedDid,encryption:i};if(this.delegateDid)try{let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n,delegate:!0,cached:!0,messageType:s.messageType});s.messageParams={...s.messageParams,delegatedGrant:u},s.granteeDid=this.delegateDid}catch{s.author=this.delegateDid}let o;r?o=await this.agent.sendDwnRequest(s):o=await this.agent.processDwnRequest(s);let{reply:{entry:c,status:l}}=o,d;if(200<=l.code&&l.code<=299){let u={author:Jo(c.recordsWrite),connectedDid:this.connectedDid,remoteOrigin:r,delegateDid:this.delegateDid,data:c.data,initialWrite:c.initialWrite,...c.recordsWrite};d=new qd(this.agent,u,this.permissionsApi)}return{record:d,status:l}},subscribe:async e=>{let{from:r,...n}=e,i,a=r,s=n.protocolRole,o=m=>{if(m.type==="eose"){i?.handleLifecycleEvent("eose");return}if(m.type==="disconnected"){i?.handleLifecycleEvent("disconnected");return}if(m.type==="reconnected"){i?.handleLifecycleEvent("reconnected");return}if(m.type==="reconnecting"){i?.handleLifecycleEvent("reconnecting",{attempt:m.attempt});return}let{message:g,initialWrite:_}=m.event,w=new qd(this.agent,{...g,author:Jo(g),connectedDid:this.connectedDid,remoteOrigin:a,initialWrite:_,protocolRole:s,delegateDid:this.delegateDid},this.permissionsApi);i?.handleEvent(w)},c={author:this.connectedDid,messageParams:n,messageType:ke.RecordsSubscribe,target:r||this.connectedDid,subscriptionHandler:o};if(this.delegateDid)try{let{message:m}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.filter?.protocol,delegate:!0,cached:!0,messageType:c.messageType});c.messageParams={...c.messageParams,delegatedGrant:m},c.granteeDid=this.delegateDid}catch{c.author=this.delegateDid}let l;r?l=await this.agent.sendDwnRequest(c):l=await this.agent.processDwnRequest(c);let d=l.reply,{status:u,subscription:f,entries:h=[],cursor:p}=d;return f&&(i=new $x({agent:this.agent,connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocolRole:s,remoteOrigin:a,permissionsApi:this.permissionsApi,initialEntries:h,cursor:p,subscription:f})),{status:u,liveQuery:i}},write:async e=>{let{data:r,store:n,encryption:i,...a}=e,{dataBlob:s,dataFormat:o}=Iv(r,a.dataFormat),c={...a,dataFormat:o},l={store:n,messageType:ke.RecordsWrite,messageParams:c,author:this.connectedDid,target:this.connectedDid,dataStream:s,encryption:i};if(this.delegateDid){let{message:p}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:c.protocol,delegate:!0,cached:!0,messageType:l.messageType});l.messageParams={...l.messageParams,delegatedGrant:p},l.granteeDid=this.delegateDid}let d=await this.agent.processDwnRequest(l),{message:u,reply:{status:f}}=d,h;if(200<=f.code&&f.code<=299){let p={author:this.connectedDid,connectedDid:this.connectedDid,encodedData:s,delegateDid:this.delegateDid,...u};h=new qd(this.agent,p,this.permissionsApi)}return{record:h,status:f}}}}};y();y();y();var Nc=class t{constructor(e){this._record=e}get rawRecord(){return this._record}get data(){let e=this._record.data;return{blob:()=>e.blob(),bytes:()=>e.bytes(),json:()=>e.json(),text:()=>e.text(),stream:()=>e.stream(),then:e.then.bind(e),catch:e.catch.bind(e)}}async update(e){let{status:r,record:n}=await this._record.update(e);return{status:r,record:new t(n)}}async delete(e){let{status:r,record:n}=await this._record.delete(e);return{status:r,record:new t(n)}}async store(e=!1){return this._record.store(e)}async import(e=!0){return this._record.import(e)}async send(e){return this._record.send(e)}toJSON(){return this._record.toJSON()}toString(){return this._record.toString()}async paginationCursor(e){return this._record.paginationCursor(e)}get id(){return this._record.id}get contextId(){return this._record.contextId}get dateCreated(){return this._record.dateCreated}get parentId(){return this._record.parentId}get protocol(){return this._record.protocol}get protocolPath(){return this._record.protocolPath}get recipient(){return this._record.recipient}get schema(){return this._record.schema}get dataFormat(){return this._record.dataFormat}get dataCid(){return this._record.dataCid}get dataSize(){return this._record.dataSize}get datePublished(){return this._record.datePublished}get published(){return this._record.published}get tags(){return this._record.tags}get author(){return this._record.author}get creator(){return this._record.creator}get timestamp(){return this._record.timestamp}get encryption(){return this._record.encryption}get authorization(){return this._record.authorization}get attestation(){return this._record.attestation}get protocolRole(){return this._record.protocolRole}get deleted(){return this._record.deleted}get initialWrite(){return this._record.initialWrite}get rawMessage(){return this._record.rawMessage}};var Bx=class{constructor(e){this._liveQuery=e}get rawLiveQuery(){return this._liveQuery}get records(){return this._typedRecords||(this._typedRecords=this._liveQuery.records.map(e=>new Nc(e))),this._typedRecords}get cursor(){return this._liveQuery.cursor}get isConnected(){return this._liveQuery.isConnected}on(e,r){return e==="disconnected"?this._liveQuery.on("disconnected",r):e==="reconnected"?this._liveQuery.on("reconnected",r):e==="eose"?this._liveQuery.on("eose",r):e==="reconnecting"?this._liveQuery.on("reconnecting",r):e==="change"?this._liveQuery.on("change",n=>{r({type:n.type,record:new Nc(n.record)})}):this._liveQuery.on(e,n=>{r(new Nc(n))})}async close(){return this._liveQuery.close()}};var Nx=class{constructor(e,r){this._configured=!1;this._ensureReadyPromise=null;this._dwn=e,this._definition=r.definition,this._validPaths=B7(this._definition.structure)}get protocol(){return this._definition.protocol}get definition(){return this._definition}async configure(e){let{protocols:r}=await this._dwn.protocols.query({filter:{protocol:this._definition.protocol}});if(r.length>0){let s=r[0];if(j7(s.definition,this._definition))return this._configured=!0,{status:{code:200,detail:"OK"},protocol:s}}let n=Object.values(this._definition.types).some(s=>s?.encryptionRequired===!0);if(this._dwn.isDelegate&&n)throw new Error(`TypedEnbox: Protocol '${this._definition.protocol}' requires encryption but is not installed or has changed. In delegate mode, encrypted protocols must be installed by the wallet during the connect flow. Ensure the sync engine has completed its initial sync before performing record operations.`);let i=!this._dwn.isDelegate&&n,a=await this._dwn.protocols.configure({definition:this._definition,encryption:e?.encryption??(i||void 0)});return a.status.code===202&&(this._configured=!0),a}get isConfigured(){return this._configured}async subscribe(e){await this._autoConfigureOnce();let{liveQuery:r}=await this._dwn.records.subscribe({from:e?.from,filter:{protocol:this._definition.protocol}});return r}_assertValidPath(e){if(!this._validPaths.has(e))throw new Error(`TypedEnbox: invalid protocol path '${e}'. Valid paths are: ${[...this._validPaths].join(", ")}.`)}async _ensureReady(e){if(this._configured){this._assertValidPath(e);return}this._ensureReadyPromise===null&&(this._ensureReadyPromise=this._autoConfigureOnce()),await this._ensureReadyPromise,this._assertValidPath(e)}async _autoConfigureOnce(){let{protocols:e}=await this._dwn.protocols.query({filter:{protocol:this._definition.protocol}});if(e.length>0){let a=e[0];if(j7(a.definition,this._definition)){this._configured=!0;return}console.warn(`TypedEnbox: installed protocol '${this._definition.protocol}' differs from the provided definition. Call configure() to update it.`),this._configured=!0;return}let r=Object.values(this._definition.types).some(a=>a?.encryptionRequired===!0);if(this._dwn.isDelegate&&r)throw new Error(`TypedEnbox: Protocol '${this._definition.protocol}' requires encryption but is not yet installed. In delegate mode, encrypted protocols must be installed by the wallet during the connect flow. Ensure the sync engine has completed its initial sync before performing record operations.`);let n=!this._dwn.isDelegate&&r;(await this._dwn.protocols.configure({definition:this._definition,encryption:n||void 0})).status.code===202&&(this._configured=!0)}get records(){if(this._records!==void 0)return this._records;let e={create:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=s?.encryptionRequired===!0?!0:void 0,{status:c,record:l}=await this._dwn.records.write({data:n.data,store:n.store,encryption:n.encryption??o,parentContextId:n.parentContextId,published:n.published,datePublished:n.datePublished,recipient:n.recipient,protocolRole:n.protocolRole,tags:n.tags,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{},dataFormat:n.dataFormat??s?.dataFormats?.[0]});return{status:c,record:l?new Nc(l):void 0}},query:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n?.filter),c=s?.encryptionRequired===!0?!0:void 0,{status:l,records:d,cursor:u}=await this._dwn.records.query({from:n?.from,encryption:n?.encryption??c,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}},dateSort:n?.dateSort,pagination:n?.pagination,protocolRole:n?.protocolRole});return{status:l,records:d.map(f=>new Nc(f)),cursor:u}},read:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n.filter),c=s?.encryptionRequired===!0?!0:void 0,{status:l,record:d}=await this._dwn.records.read({from:n.from,encryption:n.encryption??c,protocol:this._definition.protocol,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}}});return{status:l,record:d?new Nc(d):void 0}},delete:async(r,n)=>(await this._ensureReady(Rv(r)),this._dwn.records.delete({from:n.from,protocol:this._definition.protocol,recordId:n.recordId})),subscribe:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n?.filter),{status:c,liveQuery:l}=await this._dwn.records.subscribe({from:n?.from,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}},protocolRole:n?.protocolRole});return{status:c,liveQuery:l?new Bx(l):void 0}}};return this._records=e,e}};function PR(t){if(!t)return;let{parentContextId:e,...r}=t;return e!==void 0&&r.parentId===void 0&&(r.parentId=e),r}function j7(t,e){return Kx(Ux(t))===Kx(Ux(e))}function Ux(t){if(t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>Ux(r));let e={};for(let[r,n]of Object.entries(t))r!=="$encryption"&&(e[r]=Ux(n));return e}function Rv(t){return t.replace(/^\/+|\/+$/g,"")}function Mx(t){let e=t.split("/");return e[e.length-1]}function B7(t,e=""){let r=new Set;for(let n of Object.keys(t)){if(n.startsWith("$"))continue;let i=e?`${e}/${n}`:n;r.add(i);let a=t[n];if(a!==null&&typeof a=="object")for(let s of B7(a,i))r.add(s)}return r}function Kx(t){return t==null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?"["+t.map(n=>Kx(n)).join(",")+"]":"{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+Kx(t[n])).join(",")+"}"}y();var Lx=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(){throw new Error("Not implemented.")}};var M7=class t{constructor({agent:e,connectedDid:r,delegateDid:n}){this._typedInstances=new Map;this.agent=e,this.did=new Rx({agent:e,connectedDid:r}),this._dwn=new jx({agent:e,connectedDid:r,delegateDid:n}),this.vc=new Lx({agent:e,connectedDid:r})}using(e){let r=e.definition.protocol,n=this._typedInstances.get(r);if(n)return n;let i=new Nx(this._dwn,e);return this._typedInstances.set(r,i),i}async disconnect(e){"sync"in this.agent&&typeof this.agent.sync?.stopSync=="function"&&await this.agent.sync.stopSync(e),this._typedInstances.clear()}static anonymous(e){let r=new uv({didResolvers:e?.didResolvers??[ou,ep,VP,UA],cache:new JP}),n=new Mm,i=new bx({didResolver:r,rpcClient:n});return{dwn:new Cx(i)}}static connect(e){if("session"in e){let{session:r}=e;return new t({agent:r.agent,connectedDid:r.did,delegateDid:r.delegateDid})}return new t(e)}};y();y();y();function N7(t){return t.code===400&&t.detail.includes("record limit")}function rhe(t,e){let r=e.split("/"),n=t.structure;for(let a of r){if(!n||typeof n!="object")return!1;n=n[a]}if(!n||typeof n!="object")return!1;let i=n.$recordLimit;return i!==void 0&&typeof i=="object"&&i!==null&&i.max===1}function nhe(t,e){let r=e.split("/"),n=t.structure;for(let i of r){if(!n||typeof n!="object")return[];n=n[i]}return!n||typeof n!="object"?[]:Object.keys(n).filter(i=>!i.startsWith("$"))}function ihe(t,e){return{async create(r){let{status:n,record:i}=await t.records.create(e,r);return{status:n,record:i}},async query(r){let{status:n,records:i,cursor:a}=await t.records.query(e,r);return{status:n,records:i,cursor:a}},async get(r){let{record:n}=await t.records.read(e,{filter:{recordId:r}});return n},async delete(r){return t.records.delete(e,{recordId:r})},async subscribe(r){let{liveQuery:n}=await t.records.subscribe(e,r);return n}}}function ohe(t,e){return{async set(r){let n=await t.records.create(e,r);if(N7(n.status)){let{records:i}=await t.records.query(e);if(i.length>0){let{status:a,record:s}=await i[0].update({data:r.data,...r.tags!==void 0?{tags:r.tags}:{}});return{status:a,record:s}}}return{status:n.status,record:n.record}},async get(){let{records:r}=await t.records.query(e);return r.length>0?r[0]:void 0},async delete(r){return t.records.delete(e,{recordId:r})}}}function she(t,e){return{async create(r,n){let{status:i,record:a}=await t.records.create(e,{...n,parentContextId:r});return{status:i,record:a}},async query(r,n){let{status:i,records:a,cursor:s}=await t.records.query(e,{...n,filter:{...n?.filter,contextId:r}});return{status:i,records:a,cursor:s}},async get(r){let{record:n}=await t.records.read(e,{filter:{recordId:r}});return n},async delete(r){return t.records.delete(e,{recordId:r})},async subscribe(r,n){let{liveQuery:i}=await t.records.subscribe(e,{...n,filter:{...n?.filter,contextId:r}});return i}}}function ahe(t,e){return{async set(r,n){let i=await t.records.create(e,{...n,parentContextId:r});if(N7(i.status)){let{records:a}=await t.records.query(e,{filter:{contextId:r}});if(a.length>0){let{status:s,record:o}=await a[0].update({data:n.data,...n.tags!==void 0?{tags:n.tags}:{}});return{status:s,record:o}}}return{status:i.status,record:i.record}},async get(r){let{records:n}=await t.records.query(e,{filter:{contextId:r}});return n.length>0?n[0]:void 0},async delete(r){return t.records.delete(e,{recordId:r})}}}function U7(t,e,r,n){let i=rhe(e,r),a;n?a=i?ahe(t,r):she(t,r):a=i?ohe(t,r):ihe(t,r);let s=nhe(e,r),o={};return new Proxy(a,{get(c,l){if(typeof l=="string"){if(l in c)return c[l];if(s.includes(l))return l in o||(o[l]=U7(t,e,`${r}/${l}`,!0)),o[l]}}})}function JZe(t){let e=t.definition,r=Object.keys(e.structure).filter(a=>!a.startsWith("$")),n={};return new Proxy({},{get(a,s){if(typeof s=="string"){if(s==="configure")return async o=>await t.configure(o);if(r.includes(s))return s in n||(n[s]=U7(t,e,s,!1)),n[s]}}})}y();export{Rx as DidApi,Cx as DwnReaderApi,M7 as Enbox,$x as LiveQuery,dp as PermissionGrant,Ox as PermissionGrantRevocation,Dv as PermissionRequest,Av as Protocol,kv as ReadOnlyRecord,qd as Record,bR as RecordChangeEvent,Nx as TypedEnbox,Bx as TypedLiveQuery,Nc as TypedRecord,Lx as VcApi,O7 as createRecordData,whe as defineProtocol,j7 as definitionsEqual,C7 as isOk,JZe as repository,$7 as utils};
2079
+ `,e+="}",e}async paginationCursor(e){return pR(ke.RecordsWrite,this.rawMessage)?l7(this.rawMessage,e):void 0}async update({timestamp:e,data:r,encryption:n,protocolRole:i,store:a=!0,...s}){if(this.deleted)throw new Error("Record: Cannot revive a deleted record.");let o=n??this._encryption!==void 0,{parentId:c,...l}=this._recordsWriteDescriptor,d=c?this._contextId.split("/").slice(0,-1).join("/"):void 0,u={...l,...s,parentContextId:d,protocolRole:i??this._protocolRole,messageTimestamp:e,recordId:this._recordId};(B3(u.tags)||u.tags===null)&&delete u.tags;let f;r!==void 0&&(delete u.dataCid,delete u.dataSize,{dataBlob:f}=Iv(r,u.dataFormat));let h=new Set(["data","dataCid","dataFormat","dataSize","datePublished","messageTimestamp","published","tags"]);lu.verifyPermittedMutation(Object.keys(s),h),s.published===!1&&u.datePublished!==void 0&&delete u.datePublished;let p={author:this._connectedDid,dataStream:f,messageParams:{...u},messageType:ke.RecordsWrite,target:this._connectedDid,store:a,encryption:o||void 0};await this.applyDelegateGrant(p);let m=await this._agent.processDwnRequest(p),{message:g,reply:{status:_}}=m;if(!(200<=_.code&&_.code<=299))return{status:_,record:this};let w=this._initialWrite??{...this.rawMessage},E=new lu(this._agent,{author:this._author,connectedDid:this._connectedDid,delegateDid:this._delegateDid,remoteOrigin:this._remoteOrigin,protocolRole:i??this._protocolRole,initialWrite:w,encodedData:r!==void 0?f:this._encodedData,...g},this._permissionsApi),k=g;return this._descriptor=k.descriptor,this._attestation=k.attestation,this._authorization=k.authorization,this._encryption=k.encryption,this._contextId=k.contextId,this._initialWrite=w,this._protocolRole=i??this._protocolRole,this._encodedData=r!==void 0?f:this._encodedData,this._readableStream=void 0,this._rawMessageDirty=!0,{status:_,record:E}}async delete(e){let{store:r=!0,signAsOwner:n,timestamp:i,prune:a=!1}=e||{},s=n&&this._delegateDid===void 0,o=n&&this._delegateDid!==void 0;if(this.deleted&&!this._initialWrite)throw new Error("Record: Record is in an invalid state, initial write is missing.");this._initialWrite||(this._initialWrite={...this.rawMessage}),await this.processInitialWriteIfNeeded({store:r,signAsOwner:n});let c={messageType:ke.RecordsDelete,author:this._connectedDid,target:this._connectedDid,signAsOwner:s,signAsOwnerDelegate:o,store:r},l=e?.protocolRole?d7(this.rawMessage)!==e.protocolRole:!1;this.deleted&&!l?c.rawMessage=this.rawMessage:c.messageParams={prune:a,recordId:this._recordId,messageTimestamp:i,protocolRole:e?.protocolRole??this._protocolRole},await this.applyDelegateGrant(c);let d=await this._agent.processDwnRequest(c),{message:u,reply:{status:f}}=d;if(f.code!==202)return{status:f,record:this};let h=this._initialWrite,p=new lu(this._agent,{author:Jo(u),connectedDid:this._connectedDid,delegateDid:this._delegateDid,remoteOrigin:this._remoteOrigin,protocolRole:e?.protocolRole??this._protocolRole,initialWrite:h,...u},this._permissionsApi),m=u;return this._descriptor=m.descriptor,this._authorization=m.authorization,this._protocolRole=e?.protocolRole??this._protocolRole,this._encodedData=void 0,this._readableStream=void 0,this._rawMessageDirty=!0,{status:f,record:p}}async processInitialWriteIfNeeded({store:e,signAsOwner:r}){if(this.initialWrite&&(r&&!this._initialWriteSigned||e&&!this._initialWriteStored)){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0,a={messageType:ke.RecordsWrite,rawMessage:this.initialWrite,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e};await this.applyDelegateGrant(a);let s=await this._agent.processDwnRequest(a),{message:o,reply:{status:c}}=s,l=o;200<=c.code&&c.code<=299&&(e&&(this._initialWriteStored=!0),r&&(this._initialWriteSigned=!0,this.initialWrite.authorization=l.authorization))}}async processRecord({store:e,signAsOwner:r}){let n=r&&this._delegateDid===void 0,i=r&&this._delegateDid!==void 0;await this.processInitialWriteIfNeeded({store:e,signAsOwner:r});let a;this.deleted?a={messageType:ke.RecordsDelete,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,signAsOwner:n,signAsOwnerDelegate:i,store:e}:a={messageType:ke.RecordsWrite,rawMessage:this.rawMessage,author:this._connectedDid,target:this._connectedDid,dataStream:await this.data.blob(),signAsOwner:n,signAsOwnerDelegate:i,store:e},await this.applyDelegateGrant(a);let s=await this._agent.processDwnRequest(a),{message:o,reply:{status:c}}=s,l=o;return 200<=c.code&&c.code<=299&&r&&(this._authorization=l.authorization,this._rawMessageDirty=!0),{status:c}}async readRecordData({target:e,isRemote:r}){let n={author:this._connectedDid,messageParams:{filter:{recordId:this.id},protocolRole:this._protocolRole},messageType:ke.RecordsRead,target:e,...this._encryption?{encryption:!0}:{}};if(this._delegateDid)try{await this.applyDelegateGrant(n)}catch{n.author=this._delegateDid}let i=r?this._agent.sendDwnRequest(n):this._agent.processDwnRequest(n);try{let{reply:{status:a,entry:s}}=await i;if(a.code!==200)throw new Error(`${a.code}: ${a.detail}`);return s.data}catch(a){throw new Error(`Error encountered while attempting to read data: ${a.message}`)}}async applyDelegateGrant(e){if(!this._delegateDid)return;let{message:r}=await this._permissionsApi.getPermissionForRequest({connectedDid:this._connectedDid,delegateDid:this._delegateDid,protocol:this.protocol,delegate:!0,cached:!0,messageType:e.messageType});e.messageParams={...e.messageParams,delegatedGrant:r},e.granteeDid=this._delegateDid}static verifyPermittedMutation(e,r){for(let n of e)if(!r.has(n))throw new Error(`${n} is an immutable property. Its value cannot be changed.`)}isRecordsDeleteDescriptor(e){return e.interface+e.method===ke.RecordsDelete}};lu._sendCache=Tv;var qd=lu;var bR=class extends CustomEvent{constructor(e){super(e.type,{detail:e})}},$x=class extends EventTarget{constructor(r){super();this._closed=!1;this._connected=!0;let{agent:n,connectedDid:i,cursor:a,delegateDid:s,protocolRole:o,remoteOrigin:c,permissionsApi:l,initialEntries:d,subscription:u}=r;this._subscription=u,this.cursor=a,this.records=d.map(f=>new qd(n,{author:Jo(f),connectedDid:i,remoteOrigin:c,delegateDid:s,protocolRole:o,...f},l)),this._knownRecords=new Map;for(let f of this.records)this._knownRecords.set(f.id,f.timestamp)}get isConnected(){return this._connected}handleEvent(r){if(this._closed)return;let n;if(r.deleted)n="delete",this._knownRecords.delete(r.id);else{let a=this._knownRecords.get(r.id);if(a!==void 0){if(r.timestamp<=a)return;n="update"}else n="create";this._knownRecords.set(r.id,r.timestamp)}let i={type:n,record:r};this.dispatchEvent(new bR(i)),this.dispatchEvent(new CustomEvent("change",{detail:i}))}handleLifecycleEvent(r,n){this._closed||(r==="disconnected"?this._connected=!1:r==="reconnected"&&(this._connected=!0),this.dispatchEvent(new CustomEvent(r,{detail:n})))}on(r,n){let i=a=>{let s=a.detail;r==="change"?n(s):r==="create"||r==="update"||r==="delete"?n(s.record):r==="reconnecting"?n(s):n()};return this.addEventListener(r,i),()=>{this.removeEventListener(r,i)}}async close(){this._closed||(this._closed=!0,await this._subscription.close())}};y();qt();y();qt();var Ox=class t{constructor(e,r){this._permissions=e,this._connectedDid=r.connectedDid,this._message=r.message}get author(){return Jo(this._message)}static async parse({connectedDid:e,agent:r,message:n}){let i=new ei({agent:r});return new t(i,{connectedDid:e,message:n})}get agent(){return this._permissions.agent}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(e){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}};var dp=class t{constructor({api:e,connectedDid:r,message:n,grant:i}){this._permissions=e,this._connectedDid=r,this._message=n,this._grant=i}static parse(e){let r=lr.parse(e.message),n=new ei({agent:e.agent});return new t({...e,grant:r,api:n})}get agent(){return this._permissions.agent}get id(){return this._grant.id}get grantor(){return this._grant.grantor}get grantee(){return this._grant.grantee}get dateGranted(){return this._grant.dateGranted}get description(){return this._grant.description}get requestId(){return this._grant.requestId}get dateExpires(){return this._grant.dateExpires}get delegated(){return this._grant.delegated}get scope(){return this._grant.scope}get conditions(){return this._grant.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({store:!0,author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:e,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}async import(e=!1){let{encodedData:r,...n}=this.rawMessage,i=new Blob([Ue.base64Url(r).toUint8Array()]),{reply:a,message:s}=await this.agent.processDwnRequest({store:e,author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,signAsOwner:!0,rawMessage:n,dataStream:i});return this._message={...s,encodedData:r},{status:a.status}}async revoke(e=!0){let r=await this._permissions.createRevocation({store:e,author:this._connectedDid,grant:this._grant});return Ox.parse({connectedDid:this._connectedDid,agent:this.agent,message:r.message})}isRevoked(e=!1){return this._permissions.isGrantRevoked({author:this._connectedDid,target:this.grantor,grantRecordId:this.id,remote:e})}toJSON(){return{id:this.id,grantor:this.grantor,grantee:this.grantee,dateGranted:this.dateGranted,description:this.description,requestId:this.requestId,dateExpires:this.dateExpires,delegated:this.delegated,scope:this.scope,conditions:this.conditions}}};y();qt();var Dv=class t{constructor({api:e,connectedDid:r,message:n,request:i}){this._permissions=e,this._connectedDid=r,this._request=i,this._message=n}static parse({connectedDid:e,agent:r,message:n}){let i=$a.parse(n),a=new ei({agent:r});return new t({api:a,connectedDid:e,message:n,request:i})}get agent(){return this._permissions.agent}get id(){return this._request.id}get requester(){return this._request.requester}get description(){return this._request.description}get delegated(){return this._request.delegated}get scope(){return this._request.scope}get conditions(){return this._request.conditions}get rawMessage(){return this._message}async send(e){e??=this._connectedDid;let{encodedData:r,...n}=this._message,i=new Blob([Ue.base64Url(r).toUint8Array()]),a={messageType:ke.RecordsWrite,author:this._connectedDid,target:e,dataStream:i,rawMessage:n},{reply:s}=await this.agent.sendDwnRequest(a);return s}async store(){let{encodedData:e,...r}=this.rawMessage,n=new Blob([Ue.base64Url(e).toUint8Array()]),{reply:i,message:a}=await this.agent.processDwnRequest({author:this._connectedDid,target:this._connectedDid,messageType:ke.RecordsWrite,rawMessage:r,dataStream:n});return this._message={...a,encodedData:e},{status:i.status}}async grant(e,r=!0){let{message:n}=await this._permissions.createGrant({requestId:this.id,grantedTo:this.requester,scope:this.scope,delegated:this.delegated,author:this._connectedDid,store:r,dateExpires:e});return dp.parse({connectedDid:this._connectedDid,agent:this.agent,message:n})}toJSON(){return this._request}};y();var Av=class{constructor(e,r,n){this._agent=e,this._metadata=n,this._protocolsConfigureMessage=r}get definition(){return this._protocolsConfigureMessage.descriptor.definition}toJSON(){return this._protocolsConfigureMessage}async send(e){let{reply:r}=await this._agent.sendDwnRequest({author:this._metadata.author,messageCid:this._metadata.messageCid,messageType:ke.ProtocolsConfigure,target:e});return{status:r.status}}};var jx=class{get connectedDid(){return this._connectedDid}set connectedDid(e){this._connectedDid=e}constructor(e){this.agent=e.agent,this._connectedDid=e.connectedDid,this.delegateDid=e.delegateDid,this.permissionsApi=new ei({agent:this.agent})}get isDelegate(){return this.delegateDid!==void 0}get permissions(){return{request:async e=>{let{message:r}=await this.permissionsApi.createRequest({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return Dv.parse(n)},grant:async e=>{let{message:r}=await this.permissionsApi.createGrant({...e,author:this.delegateDid??this.connectedDid}),n={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:r};return dp.parse(n)},queryRequests:async(e={})=>{let{from:r,...n}=e,i=await this.permissionsApi.fetchRequests({...n,author:this.delegateDid??this.connectedDid,target:r??this.delegateDid??this.connectedDid,remote:r!==void 0}),a=[];for(let s of i){let o={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:s.message};a.push(Dv.parse(o))}return a},queryGrants:async(e={})=>{let{from:r,...n}=e,i=r!==void 0,a=this.delegateDid??this.connectedDid,s=r??this.delegateDid??this.connectedDid,o=await this.permissionsApi.fetchGrants({...n,author:a,target:s,remote:i}),c=[];for(let l of o){let d={connectedDid:this.delegateDid??this.connectedDid,agent:this.agent,message:l.message};c.push(dp.parse(d))}return c}}}get protocols(){return{configure:async e=>{let{encryption:r,...n}=e,i={author:this.connectedDid,messageParams:n,messageType:ke.ProtocolsConfigure,target:this.connectedDid,encryption:r};if(this.delegateDid){let{message:d}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.definition.protocol,delegate:!0,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,delegatedGrant:d},i.granteeDid=this.delegateDid}let a=await this.agent.processDwnRequest(i),{message:s,messageCid:o,reply:{status:c}}=a,l={status:c};if(c.code<300){let d={author:this.connectedDid,messageCid:o};l.protocol=new Av(this.agent,s,d)}return l},query:async e=>{let{from:r,...n}=e,i={author:this.connectedDid,messageParams:n,messageType:ke.ProtocolsQuery,target:r||this.connectedDid};if(this.delegateDid)try{let{grant:{id:d}}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.filter.protocol,cached:!0,messageType:i.messageType});i.messageParams={...i.messageParams,permissionGrantId:d},i.granteeDid=this.delegateDid}catch{i.author=this.delegateDid}let a;r?a=await this.agent.sendDwnRequest(i):a=await this.agent.processDwnRequest(i);let s=a.reply,{entries:o=[],status:c}=s;return{protocols:o.map(d=>{let u={author:this.connectedDid};return new Av(this.agent,d,u)}),status:c}}}}get records(){return{delete:async e=>{let{from:r,protocol:n,...i}=e,a={author:this.connectedDid,messageParams:i,messageType:ke.RecordsDelete,target:r||this.connectedDid};if(this.delegateDid){let{message:c}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n,delegate:!0,cached:!0,messageType:a.messageType});a.messageParams={...a.messageParams,delegatedGrant:c},a.granteeDid=this.delegateDid}let s;r?s=await this.agent.sendDwnRequest(a):s=await this.agent.processDwnRequest(a);let{reply:{status:o}}=s;return{status:o}},query:async e=>{let{from:r,encryption:n,...i}=e,a={author:this.connectedDid,messageParams:i,messageType:ke.RecordsQuery,target:r||this.connectedDid,encryption:n};if(this.delegateDid)try{let{message:f}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:i.filter?.protocol,delegate:!0,cached:!0,messageType:a.messageType});a.messageParams={...a.messageParams,delegatedGrant:f},a.granteeDid=this.delegateDid}catch{a.author=this.delegateDid}let s;r?s=await this.agent.sendDwnRequest(a):s=await this.agent.processDwnRequest(a);let o=s.reply,{entries:c=[],status:l,cursor:d}=o;return{records:c.map(f=>{let h={author:Jo(f),connectedDid:this.connectedDid,remoteOrigin:r,delegateDid:this.delegateDid,protocolRole:a.messageParams.protocolRole,...f};return new qd(this.agent,h,this.permissionsApi)}),status:l,cursor:d}},read:async e=>{let{from:r,protocol:n,encryption:i,...a}=e,s={author:this.connectedDid,messageParams:a,messageType:ke.RecordsRead,target:r||this.connectedDid,encryption:i};if(this.delegateDid)try{let{message:u}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n,delegate:!0,cached:!0,messageType:s.messageType});s.messageParams={...s.messageParams,delegatedGrant:u},s.granteeDid=this.delegateDid}catch{s.author=this.delegateDid}let o;r?o=await this.agent.sendDwnRequest(s):o=await this.agent.processDwnRequest(s);let{reply:{entry:c,status:l}}=o,d;if(200<=l.code&&l.code<=299){let u={author:Jo(c.recordsWrite),connectedDid:this.connectedDid,remoteOrigin:r,delegateDid:this.delegateDid,data:c.data,initialWrite:c.initialWrite,...c.recordsWrite};d=new qd(this.agent,u,this.permissionsApi)}return{record:d,status:l}},subscribe:async e=>{let{from:r,...n}=e,i,a=r,s=n.protocolRole,o=m=>{if(m.type==="eose"){i?.handleLifecycleEvent("eose");return}if(m.type==="disconnected"){i?.handleLifecycleEvent("disconnected");return}if(m.type==="reconnected"){i?.handleLifecycleEvent("reconnected");return}if(m.type==="reconnecting"){i?.handleLifecycleEvent("reconnecting",{attempt:m.attempt});return}let{message:g,initialWrite:_}=m.event,w=new qd(this.agent,{...g,author:Jo(g),connectedDid:this.connectedDid,remoteOrigin:a,initialWrite:_,protocolRole:s,delegateDid:this.delegateDid},this.permissionsApi);i?.handleEvent(w)},c={author:this.connectedDid,messageParams:n,messageType:ke.RecordsSubscribe,target:r||this.connectedDid,subscriptionHandler:o};if(this.delegateDid)try{let{message:m}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:n.filter?.protocol,delegate:!0,cached:!0,messageType:c.messageType});c.messageParams={...c.messageParams,delegatedGrant:m},c.granteeDid=this.delegateDid}catch{c.author=this.delegateDid}let l;r?l=await this.agent.sendDwnRequest(c):l=await this.agent.processDwnRequest(c);let d=l.reply,{status:u,subscription:f,entries:h=[],cursor:p}=d;return f&&(i=new $x({agent:this.agent,connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocolRole:s,remoteOrigin:a,permissionsApi:this.permissionsApi,initialEntries:h,cursor:p,subscription:f})),{status:u,liveQuery:i}},write:async e=>{let{data:r,store:n,encryption:i,...a}=e,{dataBlob:s,dataFormat:o}=Iv(r,a.dataFormat),c={...a,dataFormat:o},l={store:n,messageType:ke.RecordsWrite,messageParams:c,author:this.connectedDid,target:this.connectedDid,dataStream:s,encryption:i};if(this.delegateDid){let{message:p}=await this.permissionsApi.getPermissionForRequest({connectedDid:this.connectedDid,delegateDid:this.delegateDid,protocol:c.protocol,delegate:!0,cached:!0,messageType:l.messageType});l.messageParams={...l.messageParams,delegatedGrant:p},l.granteeDid=this.delegateDid}let d=await this.agent.processDwnRequest(l),{message:u,reply:{status:f}}=d,h;if(200<=f.code&&f.code<=299){let p={author:this.connectedDid,connectedDid:this.connectedDid,encodedData:s,delegateDid:this.delegateDid,...u};h=new qd(this.agent,p,this.permissionsApi)}return{record:h,status:f}}}}};y();y();y();var Nc=class t{constructor(e){this._record=e}get rawRecord(){return this._record}get data(){let e=this._record.data;return{blob:()=>e.blob(),bytes:()=>e.bytes(),json:()=>e.json(),text:()=>e.text(),stream:()=>e.stream(),then:e.then.bind(e),catch:e.catch.bind(e)}}async update(e){let{status:r,record:n}=await this._record.update(e);return{status:r,record:new t(n)}}async delete(e){let{status:r,record:n}=await this._record.delete(e);return{status:r,record:new t(n)}}async store(e=!1){return this._record.store(e)}async import(e=!0){return this._record.import(e)}async send(e){return this._record.send(e)}toJSON(){return this._record.toJSON()}toString(){return this._record.toString()}async paginationCursor(e){return this._record.paginationCursor(e)}get id(){return this._record.id}get contextId(){return this._record.contextId}get dateCreated(){return this._record.dateCreated}get parentId(){return this._record.parentId}get protocol(){return this._record.protocol}get protocolPath(){return this._record.protocolPath}get recipient(){return this._record.recipient}get schema(){return this._record.schema}get dataFormat(){return this._record.dataFormat}get dataCid(){return this._record.dataCid}get dataSize(){return this._record.dataSize}get datePublished(){return this._record.datePublished}get published(){return this._record.published}get tags(){return this._record.tags}get author(){return this._record.author}get creator(){return this._record.creator}get timestamp(){return this._record.timestamp}get encryption(){return this._record.encryption}get authorization(){return this._record.authorization}get attestation(){return this._record.attestation}get protocolRole(){return this._record.protocolRole}get deleted(){return this._record.deleted}get initialWrite(){return this._record.initialWrite}get rawMessage(){return this._record.rawMessage}};var Bx=class{constructor(e){this._liveQuery=e}get rawLiveQuery(){return this._liveQuery}get records(){return this._typedRecords||(this._typedRecords=this._liveQuery.records.map(e=>new Nc(e))),this._typedRecords}get cursor(){return this._liveQuery.cursor}get isConnected(){return this._liveQuery.isConnected}on(e,r){return e==="disconnected"?this._liveQuery.on("disconnected",r):e==="reconnected"?this._liveQuery.on("reconnected",r):e==="eose"?this._liveQuery.on("eose",r):e==="reconnecting"?this._liveQuery.on("reconnecting",r):e==="change"?this._liveQuery.on("change",n=>{r({type:n.type,record:new Nc(n.record)})}):this._liveQuery.on(e,n=>{r(new Nc(n))})}async close(){return this._liveQuery.close()}};var Nx=class{constructor(e,r){this._configured=!1;this._ensureReadyPromise=null;this._dwn=e,this._definition=r.definition,this._validPaths=B7(this._definition.structure)}get protocol(){return this._definition.protocol}get definition(){return this._definition}async configure(e){let{protocols:r}=await this._dwn.protocols.query({filter:{protocol:this._definition.protocol}});if(r.length>0){let s=r[0];if(j7(s.definition,this._definition))return this._configured=!0,{status:{code:200,detail:"OK"},protocol:s}}let n=Object.values(this._definition.types).some(s=>s?.encryptionRequired===!0);if(this._dwn.isDelegate&&n)throw new Error(`TypedEnbox: Protocol '${this._definition.protocol}' requires encryption but is not installed or has changed. In delegate mode, encrypted protocols must be installed by the wallet during the connect flow. Ensure the sync engine has completed its initial sync before performing record operations.`);let i=!this._dwn.isDelegate&&n,a=await this._dwn.protocols.configure({definition:this._definition,encryption:e?.encryption??(i||void 0)});return a.status.code===202&&(this._configured=!0),a}get isConfigured(){return this._configured}async subscribe(e){await this._autoConfigureOnce();let{liveQuery:r}=await this._dwn.records.subscribe({from:e?.from,filter:{protocol:this._definition.protocol}});return r}_assertValidPath(e){if(!this._validPaths.has(e))throw new Error(`TypedEnbox: invalid protocol path '${e}'. Valid paths are: ${[...this._validPaths].join(", ")}.`)}async _ensureReady(e){if(this._configured){this._assertValidPath(e);return}this._ensureReadyPromise===null&&(this._ensureReadyPromise=this._autoConfigureOnce()),await this._ensureReadyPromise,this._assertValidPath(e)}async _autoConfigureOnce(){let{protocols:e}=await this._dwn.protocols.query({filter:{protocol:this._definition.protocol}});if(e.length>0){let i=e[0];if(j7(i.definition,this._definition)){this._configured=!0;return}console.warn(`TypedEnbox: installed protocol '${this._definition.protocol}' differs from the provided definition. Call configure() to update it.`),this._configured=!0;return}if(this._dwn.isDelegate){if(await this._autoConfigureDelegateProtocol())return;if(Object.values(this._definition.types).some(o=>o?.encryptionRequired===!0))throw new Error(`TypedEnbox: delegate cannot install protocol '${this._definition.protocol}' because it contains types with encryptionRequired but the owner's remote protocol definition (with $encryption keys) could not be fetched. Ensure the owner has installed the protocol on their DWN and that the delegate has network access to the owner's DWN endpoints.`);(await this._dwn.protocols.configure({definition:this._definition})).status.code===202&&(this._configured=!0);return}let r=Object.values(this._definition.types).some(i=>i?.encryptionRequired===!0);(await this._dwn.protocols.configure({definition:this._definition,encryption:r||void 0})).status.code===202&&(this._configured=!0)}async _autoConfigureDelegateProtocol(){try{let{protocols:e}=await this._dwn.protocols.query({from:this._dwn.connectedDid,filter:{protocol:this._definition.protocol}});if(e.length===0)return!1;let r=e[0].definition;return(await this._dwn.protocols.configure({definition:r})).status.code===202?(this._configured=!0,!0):!1}catch{return!1}}get records(){if(this._records!==void 0)return this._records;let e={create:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=s?.encryptionRequired===!0?!0:void 0,{status:c,record:l}=await this._dwn.records.write({data:n.data,store:n.store,encryption:n.encryption??o,parentContextId:n.parentContextId,published:n.published,datePublished:n.datePublished,recipient:n.recipient,protocolRole:n.protocolRole,tags:n.tags,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{},dataFormat:n.dataFormat??s?.dataFormats?.[0]});return{status:c,record:l?new Nc(l):void 0}},query:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n?.filter),c=s?.encryptionRequired===!0?!0:void 0,{status:l,records:d,cursor:u}=await this._dwn.records.query({from:n?.from,encryption:n?.encryption??c,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}},dateSort:n?.dateSort,pagination:n?.pagination,protocolRole:n?.protocolRole});return{status:l,records:d.map(f=>new Nc(f)),cursor:u}},read:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n.filter),c=s?.encryptionRequired===!0?!0:void 0,{status:l,record:d}=await this._dwn.records.read({from:n.from,encryption:n.encryption??c,protocol:this._definition.protocol,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}}});return{status:l,record:d?new Nc(d):void 0}},delete:async(r,n)=>(await this._ensureReady(Rv(r)),this._dwn.records.delete({from:n.from,protocol:this._definition.protocol,recordId:n.recordId})),subscribe:async(r,n)=>{let i=Rv(r);await this._ensureReady(i);let a=Mx(i),s=this._definition.types[a],o=PR(n?.filter),{status:c,liveQuery:l}=await this._dwn.records.subscribe({from:n?.from,filter:{...o,protocol:this._definition.protocol,protocolPath:i,...s?.schema!==void 0?{schema:s.schema}:{}},protocolRole:n?.protocolRole});return{status:c,liveQuery:l?new Bx(l):void 0}}};return this._records=e,e}};function PR(t){if(!t)return;let{parentContextId:e,...r}=t;return e!==void 0&&r.parentId===void 0&&(r.parentId=e),r}function j7(t,e){return Kx(Ux(t))===Kx(Ux(e))}function Ux(t){if(t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>Ux(r));let e={};for(let[r,n]of Object.entries(t))r!=="$encryption"&&(e[r]=Ux(n));return e}function Rv(t){return t.replace(/^\/+|\/+$/g,"")}function Mx(t){let e=t.split("/");return e[e.length-1]}function B7(t,e=""){let r=new Set;for(let n of Object.keys(t)){if(n.startsWith("$"))continue;let i=e?`${e}/${n}`:n;r.add(i);let a=t[n];if(a!==null&&typeof a=="object")for(let s of B7(a,i))r.add(s)}return r}function Kx(t){return t==null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?"["+t.map(n=>Kx(n)).join(",")+"]":"{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+Kx(t[n])).join(",")+"}"}y();var Lx=class{constructor(e){this.agent=e.agent,this.connectedDid=e.connectedDid}async create(){throw new Error("Not implemented.")}};var M7=class t{constructor({agent:e,connectedDid:r,delegateDid:n}){this._typedInstances=new Map;this.agent=e,this.did=new Rx({agent:e,connectedDid:r}),this._dwn=new jx({agent:e,connectedDid:r,delegateDid:n}),this.vc=new Lx({agent:e,connectedDid:r})}using(e){let r=e.definition.protocol,n=this._typedInstances.get(r);if(n)return n;let i=new Nx(this._dwn,e);return this._typedInstances.set(r,i),i}async disconnect(e){"sync"in this.agent&&typeof this.agent.sync?.stopSync=="function"&&await this.agent.sync.stopSync(e),this._typedInstances.clear()}static anonymous(e){let r=new uv({didResolvers:e?.didResolvers??[ou,ep,VP,UA],cache:new JP}),n=new Mm,i=new bx({didResolver:r,rpcClient:n});return{dwn:new Cx(i)}}static connect(e){if("session"in e){let{session:r}=e;return new t({agent:r.agent,connectedDid:r.did,delegateDid:r.delegateDid})}return new t(e)}};y();y();y();function N7(t){return t.code===400&&t.detail.includes("record limit")}function rhe(t,e){let r=e.split("/"),n=t.structure;for(let a of r){if(!n||typeof n!="object")return!1;n=n[a]}if(!n||typeof n!="object")return!1;let i=n.$recordLimit;return i!==void 0&&typeof i=="object"&&i!==null&&i.max===1}function nhe(t,e){let r=e.split("/"),n=t.structure;for(let i of r){if(!n||typeof n!="object")return[];n=n[i]}return!n||typeof n!="object"?[]:Object.keys(n).filter(i=>!i.startsWith("$"))}function ihe(t,e){return{async create(r){let{status:n,record:i}=await t.records.create(e,r);return{status:n,record:i}},async query(r){let{status:n,records:i,cursor:a}=await t.records.query(e,r);return{status:n,records:i,cursor:a}},async get(r){let{record:n}=await t.records.read(e,{filter:{recordId:r}});return n},async delete(r){return t.records.delete(e,{recordId:r})},async subscribe(r){let{liveQuery:n}=await t.records.subscribe(e,r);return n}}}function ohe(t,e){return{async set(r){let n=await t.records.create(e,r);if(N7(n.status)){let{records:i}=await t.records.query(e);if(i.length>0){let{status:a,record:s}=await i[0].update({data:r.data,...r.tags!==void 0?{tags:r.tags}:{}});return{status:a,record:s}}}return{status:n.status,record:n.record}},async get(){let{records:r}=await t.records.query(e);return r.length>0?r[0]:void 0},async delete(r){return t.records.delete(e,{recordId:r})}}}function she(t,e){return{async create(r,n){let{status:i,record:a}=await t.records.create(e,{...n,parentContextId:r});return{status:i,record:a}},async query(r,n){let{status:i,records:a,cursor:s}=await t.records.query(e,{...n,filter:{...n?.filter,contextId:r}});return{status:i,records:a,cursor:s}},async get(r){let{record:n}=await t.records.read(e,{filter:{recordId:r}});return n},async delete(r){return t.records.delete(e,{recordId:r})},async subscribe(r,n){let{liveQuery:i}=await t.records.subscribe(e,{...n,filter:{...n?.filter,contextId:r}});return i}}}function ahe(t,e){return{async set(r,n){let i=await t.records.create(e,{...n,parentContextId:r});if(N7(i.status)){let{records:a}=await t.records.query(e,{filter:{contextId:r}});if(a.length>0){let{status:s,record:o}=await a[0].update({data:n.data,...n.tags!==void 0?{tags:n.tags}:{}});return{status:s,record:o}}}return{status:i.status,record:i.record}},async get(r){let{records:n}=await t.records.query(e,{filter:{contextId:r}});return n.length>0?n[0]:void 0},async delete(r){return t.records.delete(e,{recordId:r})}}}function U7(t,e,r,n){let i=rhe(e,r),a;n?a=i?ahe(t,r):she(t,r):a=i?ohe(t,r):ihe(t,r);let s=nhe(e,r),o={};return new Proxy(a,{get(c,l){if(typeof l=="string"){if(l in c)return c[l];if(s.includes(l))return l in o||(o[l]=U7(t,e,`${r}/${l}`,!0)),o[l]}}})}function JZe(t){let e=t.definition,r=Object.keys(e.structure).filter(a=>!a.startsWith("$")),n={};return new Proxy({},{get(a,s){if(typeof s=="string"){if(s==="configure")return async o=>await t.configure(o);if(r.includes(s))return s in n||(n[s]=U7(t,e,s,!1)),n[s]}}})}y();export{Rx as DidApi,Cx as DwnReaderApi,M7 as Enbox,$x as LiveQuery,dp as PermissionGrant,Ox as PermissionGrantRevocation,Dv as PermissionRequest,Av as Protocol,kv as ReadOnlyRecord,qd as Record,bR as RecordChangeEvent,Nx as TypedEnbox,Bx as TypedLiveQuery,Nc as TypedRecord,Lx as VcApi,O7 as createRecordData,whe as defineProtocol,j7 as definitionsEqual,C7 as isOk,JZe as repository,$7 as utils};
2080
2080
  /*! Bundled license information:
2081
2081
 
2082
2082
  ieee754/index.js: