@ibgib/space-gib 0.0.27 → 0.0.30

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
@@ -50,6 +50,21 @@ npm run restart:space-gib
50
50
  > **STRICT RULE**: `src/common` MUST NEVER import from `src/client` or `src/server`. This ensures the shared layer remains portable and prevents circular dependencies.
51
51
  * [`dist/`](dist/): The output directory where `esbuild` writes the bundled client (`dist/client/`) and server (`dist/server/`) code.
52
52
 
53
+ ## 🗺️ Reference Implementation Map
54
+
55
+ Space-Gib serves as the concrete reference implementation for the architectural patterns described in the [IbGib Developer Guides](../../docs/CREATING_IBGIB_APPS_GUIDE.md). Use this map to navigate directly from guide concepts to working code:
56
+
57
+ | Guide Concept | Conceptual Guide | Concrete Reference in `space-gib` |
58
+ |---|---|---|
59
+ | **Client 3-Tier Bootstrap** | [Client Guide: Bootstrap](../../docs/IBGIB_CLIENT_APPS_GUIDE.md#1-the-three-tier-bootstrap-architecture) | [`src/client/bootstrap.mts`](src/client/bootstrap.mts) & [`src/client/index.mts`](src/client/index.mts) |
60
+ | **Keystone Web Components** | [Client Guide: Identity Components](../../docs/IBGIB_CLIENT_APPS_GUIDE.md#4-zero-boilerplate-identity-components-web-gib) | [`src/client/index.html`](src/client/index.html) & [`src/client/bootstrap.mts`](src/client/bootstrap.mts) |
61
+ | **Client App Configuration** | [Client Guide: APP_CONFIG](../../docs/IBGIB_CLIENT_APPS_GUIDE.md#3-configuration-pattern-app_config--remotes) | [`src/client/constants.mts`](src/client/constants.mts) & [`src/client/helpers.web.mts`](src/client/helpers.web.mts) |
62
+ | **Server Runner & Pipeline** | [Server Guide: Serve-Gib Microframework](../../docs/IBGIB_SERVER_APPS_GUIDE.md#1-architecture--the-serve-gib-microframework) | [`src/server/server.mts`](src/server/server.mts) |
63
+ | **Shared Policies & Contracts** | [App Guide: Identity Security Profiles](../../docs/CREATING_IBGIB_APPS_GUIDE.md#3-identity-security-profiles--keystone-policies) | [`src/common/keystone-policies.mts`](src/common/keystone-policies.mts) & [`src/common/keystone-policies.json`](src/common/keystone-policies.json) |
64
+ | **WebSocket Sync Upgrade** | [Server Guide: Real-Time Sync Upgrade](../../docs/IBGIB_SERVER_APPS_GUIDE.md#5-real-time-websocket-sync-upgrade) | [`src/server/server.mts`](src/server/server.mts) |
65
+ | **Email Infrastructure** | [Server Guide: Email Infrastructure](../../docs/IBGIB_SERVER_APPS_GUIDE.md#6-email-infrastructure-ses--custom-addresses) | [`src/server/handlers/api/email/`](src/server/handlers/api/email/) |
66
+ | **Docker & Traefik Setup** | [Server Guide: Local Docker Development](../../docs/IBGIB_SERVER_APPS_GUIDE.md#7-local-docker-development--sso-loopback) | [`docker-compose.yml`](docker-compose.yml) & [`Dockerfile`](Dockerfile) |
67
+
53
68
  ## Debugging the Server
54
69
 
55
70
  You can attach the VS Code debugger directly to the Node.js process running inside Docker.
@@ -1,4 +1,4 @@
1
- import{a as Mr,b as Br,c as gt,d as kr,e as Fr,f as Ge,g as He,h as jr,i as zr,j as qr,k as Hr,l as Xr}from"./chunk-VGNQAKB5.mjs";import{a as Vr,b as H,d as aa}from"./chunk-RQB5XDDL.mjs";import{$ as Se,$a as $r,$c as pt,A as V,Aa as Ae,Ad as Ur,B as j,Ba as lr,C as z,Ca as dr,Cd as qe,Da as fr,Db as Te,Ea as br,Eb as Tr,F as re,Fa as hr,G as Ze,Ga as pr,H as le,Ha as st,I as kt,Ia as ct,J as Le,Ja as ur,K as Oe,Ka as mr,L as za,M as De,Ma as ve,Mc as Yt,N as et,Na as Ue,Nc as bt,O as $e,Oa as Xt,Oc as Fe,P as qa,Pc as Nr,Q as Ha,R as Ft,Ra as lt,Rc as Qt,S as tt,Sa as gr,T as Ie,Ta as wr,Ua as Er,Ub as Gr,V as Xa,Vb as q,W as Va,Wa as dt,Wc as oe,Y as _e,Ya as Be,Yc as Kt,Z as Re,Za as ke,Zc as Cr,_ as Wa,_a as yr,_c as ht,a as b,aa as Ja,ab as Vt,ad as xr,b as Ot,ba as Ya,bd as Lr,ca as jt,d as D,da as zt,e as ae,ea as Qa,ed as Or,f as Dt,fa as Ka,fb as Ir,g as R,ga as Za,gd as Zt,h as $,ha as er,hb as Wt,i as se,ia as at,ib as _r,id as je,j as m,ja as rt,jb as de,k as ja,l as Ke,lb as Sr,m as Rt,ma as tr,mb as Ar,n as Mt,na as ar,nc as Pr,o as vt,oa as rr,ob as ft,pa as ot,pd as Dr,qa as qt,r as ce,ra as or,rd as ut,s as Ee,sa as ir,t as Ut,ta as nr,td as Rr,u as ye,ua as it,va as Me,vd as ea,w as y,wa as sr,wb as G,wd as ze,x as C,xa as nt,xb as Jt,xd as ta,y as Bt,ya as Ht,yd as mt,za as cr,zd as vr}from"./chunk-LAYDMZTA.mjs";var Wr={src:["source","from","in","input"],dest:["destination","to","out","output"]};function Ho({paramName:c,noBare:e,argTypeName:a,description:t}){let r={name:`src-${c}`,argTypeName:a??"string",synonyms:[...Wr.src.map(o=>`${o}-${c}`)],description:t};return e||r.synonyms.push(c),r}b(Ho,"getParam_src");function Xo({paramName:c,argTypeName:e="string",description:a}){return{name:`dest-${c}`,argTypeName:e??"string",synonyms:[...Wr.dest.map(r=>`${r}-${c}`)],description:a}}b(Xo,"getParam_dest");var Jr={name:"bare",description:`special param that is used as the only param allowed that doesn't have a "double-dash-specifier=" form. one "bare" arg is allowed atow. if a bare arg is found, it will be mapped to this param info.`,synonyms:["bare-arg","bare-param","no-name","manco","arg-with-no-name","param-with-no-name"],argTypeName:"string"};var Hi=Ho({paramName:"path",description:"for referencing/ingesting file(s)/folder(s) in a fs"}),Xi=Xo({paramName:"path",description:"for indicating where to put generated file(s)/folder(s)"});var W=!1;function wt({paramInfo:c,valueString:e}){let a=`[${wt.name}]`;try{switch(c.argTypeName){case"string":let t=e;return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1),t=t.slice(0,t.length-1)),t;case"integer":if(e===void 0)throw new Error("integer arg value is undefined. integers must be a valid integer string (E: ce17acde3b863ec5e2fdcc594f0f1423)");let r=Number.parseInt(e);if(typeof r!="number")throw new Error(`arg value string (${e})did not parse to an integer. parse result: ${r} (E: 43cde93160458610ffb49fd16a02d123)`);return r;case"boolean":if(e===void 0||e===""){if(!c.isFlag)throw new Error("valueString is undefined or empty string but paramInfo.argTypeName === 'boolean' and paramInfo.isFlag is falsy. (E: 482e595c0ec7344b04def76c1441d623)");return!0}else{if(e===null)throw new Error("(UNEXPECTED) valueString === null? (E: 78f548b93026407968356d9c4f106223)");if(!["true","false"].includes(e))throw new Error(`invalid boolean valueString ("${e}"). must be either "true" or "false" (E: ba7a0d0804131acc2bd9ab37c0382523)`);return e==="true"}default:throw new Error("(UNEXPECTED) invalid paramInfo.argTypeName (E: c8b03ccb71394d22a29858b98753a123)")}}catch(t){throw console.error(`${a} ${m(t)}`),t}}b(wt,"getValueFromRawString");function Et({argIdentifier:c,paramInfos:e,throwIfNotFound:a}){let t=`[${Et.name}]`;try{let r=e.filter(o=>o.name===c||(o.synonyms??[]).includes(c));if(r.length===1)return D(r[0]);if(r.length>1)throw new Error(`(UNEXPECTED) multiple param infos found with argIdentifier. do you have overlapping arg names/synonyms? (${c} found in (${r.length} param infos)) (E: d599a6647c5ead6d9fbac4e4c96e6d23)`);if(a)throw new Error(`(UNEXPECTED) param info not found for argIdentifier (${c}) (E: 47e704068f2eb5a0551cf45d0e72c823)`);return}catch(r){throw console.error(`${t} ${m(r)}`),r}}b(Et,"getParamInfo");function Yr({rawArg:c}){let e=`[${Yr.name}]`;try{W&&console.log(`${e} starting... (I: 5d51b75b7a025e2e3fa498da7c08ac24)`);let a=b(o=>o.startsWith('"')&&o.endsWith('"')?"double":o.startsWith("'")&&o.endsWith("'")?"single":void 0,"fnGetQuoteType"),t=b(o=>a(o)?o.slice(0,o.length-1).slice(1):o,"fnStripQuotes"),r=a(c);if(r)return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:c.concat(),resolvedValueString:t(c),singleQuoted:r==="single",doubleQuoted:r==="double"}};if(c.match(/^(--\w|-\w|:\w)/))if(c.includes("=")){let o=/^(--|-|:)([\w\-]+)=(['"]?.+['"]?)$/,i=c.match(o);if(!i)throw new Error(`invalid rawArg (${c}). expected an arg matching regexp ${o}. (E: 05ca56163e184faeb66456a0e9190b28)`);let[n,s,l,d]=i,f=a(d);return{prefix:s,identifier:l,isNameValuePair:!0,valueInfo:{rawValueString:d,resolvedValueString:f?t(d):d,singleQuoted:f==="single",doubleQuoted:f==="double"}}}else{let o=/^(--|-|:)([\w\-]+)$/,i=c.match(o);if(!i)throw new Error(`invalid rawArg (${c}). expected an arg matching regexp ${o}. at this point, it should have a prefix (e.g. "--"), and a single identifier (should be a flag since there is no equal sign). (E: 93305923465d9449bdce3f81373fae24)`);let[n,s,l]=i;return{prefix:s,identifier:l,isNameValuePair:!1,valueInfo:{rawValueString:void 0,resolvedValueString:"true",singleQuoted:!1,doubleQuoted:!1}}}else{if(c.includes("="))throw new Error(`invalid rawArg (${c}). isn't quoted, doesn't start with prefix, but it does have an equal sign? that's bad. (E: e8ad15211ce6fd56a4a214c2778c4724)`);return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:c,resolvedValueString:c,doubleQuoted:!1,singleQuoted:!1}}}}catch(a){throw console.error(`${e} ${a.message}`),a}finally{W&&console.log(`${e} complete.`)}}b(Yr,"parseRawArg");function yt({args:c,paramInfos:e,bareArgParamInfo:a=D(Jr),logalot:t}){let r=`[${yt.name}]`;try{(W||t)&&console.log(`${r} starting... (I: f389aaa490796dfd823bc7b9d4e58b23)`);let o=!1;return c.map((n,s)=>{let l,d,f,{prefix:h,identifier:u,isNameValuePair:g,valueInfo:E}=Yr({rawArg:n});if(h){if((W||t)&&console.log(`identifier: ${u} (I: 519ce129a1e34753a9070d3a205c9a8b)`),!u)throw new Error("(UNEXPECTED) prefix truthy but identifier falsy? (E: f33ab3a2b623acc0d1bc36685edfaf24)");if(l=u,!E)throw new Error("(UNEXPECTED) !valueInfo? (E: 05249a361a59008cd313d2dfa8f08b24)");if(g){W&&console.log(`${r} identifier with equals: ${u}. (I: 5f8ae91d1ddd4a7f94c0f4fb7e688502)`);let w=Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0});f={...w,value:wt({paramInfo:w,valueString:E.rawValueString}),identifier:l}}else{W&&console.log(`${r} identifier without equals: ${u}`),l=u;let w=Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0});f={...w,value:wt({paramInfo:w,valueString:void 0}),identifier:l,isFlag:!0}}}else if(s===0){if(!E)throw new Error("(UNEXPECTED) argIndex === 0 but valueInfo falsy? (E: 4642b42c855593b7ffdacb85f27dab24)");if(!E.rawValueString)throw new Error("(UNEXPECTED) !valueInfo.rawValueString? (E: 0b35f71eb8227cdd67ccfc32f2e45824)");if(E.singleQuoted)throw new Error("first arg is quoted? (single). a bare arg in first position must be a command/flag. (E: 28cce820417fd3b4f95ba6c7e94b4624)");if(E.doubleQuoted)throw new Error("first arg is quoted? (double). a bare arg in first position must be a command/flag. (E: 0b948c87081043fdb168f08ba05ebbce)");l=E.rawValueString,f={...Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0}),value:!0,identifier:l,isFlag:!0}}else{if((W||t)&&console.log("bare arg found. (I: d6f67074c7e44a63864948d4bf04bee8)"),!a)throw new Error(`bare arg found (one without prefix like "--" or ":") but there is no param info expected for bare args. You must provide which param info a bare arg maps to in this ${yt.name} call. (E: 650dd3695d62f0f87dd0cbafbf068c23)`);if(o)throw new Error('You can have the first arg - a special arg like a command - be bare (without prefix like "--" or ":") and one additional non-positional arg be bare. But more than one non-positional bare arg found. Also remember if the arg has spaces then you have to enclose it with single or double quotes. (E: 74dea8f13f0c14e3b7a2f125c7faca23)');o=!0;let w=D(a);f={...w,isBare:!0,identifier:w.name,value:wt({paramInfo:w,valueString:n})}}return W&&console.log(`${r} argInfo: ${$(f)}`),f})}catch(o){throw console.error(`${r} ${m(o)}`),o}finally{(W||t)&&console.log(`${r} complete.`)}}b(yt,"buildArgInfos");var ra={encrypt_gib:"encrypt-gib"},en=Object.values(ra);var Vo={characters:"characters",spell_out:"spell-out",cardinal:"cardinal",number:"number",ordinal:"ordinal",digits:"digits",fraction:"fraction",unit:"unit",date:"date",time:"time",telephone:"telephone",address:"address",interjection:"interjection",expletive:"expletive"};var fe=class c{static{b(this,"Ssml")}static lc=`[${c.name}]`;static wrapSsmlSpeak(e,a=!0){return"<speak>"+e.reduce((r,o)=>a?r+"<p>"+o+"</p>":r+o,"")+"</speak>"}static unwrapSsmlSpeak(e){return e.replace(/\<speak\>/g,"").replace(/\<\/speak\>/g,"")}static p(e){return"<p>"+e+"</p>"}static s(e){return"<s>"+e+"</s>"}static stripSsml(e){return e.replace(/\<\/p\>[ ]*\<p\>/g,"<p>").replace(/\<p\>(?=[ ])/g,"<p>").replace(/\<\/p\>(?=[ ])/g,"</p>").replace(/\<[\/]*p\>/g,`
1
+ import{a as Mr,b as Br,c as gt,d as kr,e as Fr,f as Ge,g as He,h as jr,i as zr,j as qr,k as Hr,l as Xr}from"./chunk-KWGI6EPS.mjs";import{a as Vr,b as H,d as aa}from"./chunk-7HABXN6F.mjs";import{$ as Se,$a as $r,$c as pt,A as V,Aa as Ae,Ad as Ur,B as j,Ba as lr,C as z,Ca as dr,Cd as qe,Da as fr,Db as Te,Ea as br,Eb as Tr,F as re,Fa as hr,G as Ze,Ga as pr,H as le,Ha as st,I as kt,Ia as ct,J as Le,Ja as ur,K as Oe,Ka as mr,L as za,M as De,Ma as ve,Mc as Yt,N as et,Na as Ue,Nc as bt,O as $e,Oa as Xt,Oc as Fe,P as qa,Pc as Nr,Q as Ha,R as Ft,Ra as lt,Rc as Qt,S as tt,Sa as gr,T as Ie,Ta as wr,Ua as Er,Ub as Gr,V as Xa,Vb as q,W as Va,Wa as dt,Wc as oe,Y as _e,Ya as Be,Yc as Kt,Z as Re,Za as ke,Zc as Cr,_ as Wa,_a as yr,_c as ht,a as b,aa as Ja,ab as Vt,ad as xr,b as Ot,ba as Ya,bd as Lr,ca as jt,d as D,da as zt,e as ae,ea as Qa,ed as Or,f as Dt,fa as Ka,fb as Ir,g as R,ga as Za,gd as Zt,h as $,ha as er,hb as Wt,i as se,ia as at,ib as _r,id as je,j as m,ja as rt,jb as de,k as ja,l as Ke,lb as Sr,m as Rt,ma as tr,mb as Ar,n as Mt,na as ar,nc as Pr,o as vt,oa as rr,ob as ft,pa as ot,pd as Dr,qa as qt,r as ce,ra as or,rd as ut,s as Ee,sa as ir,t as Ut,ta as nr,td as Rr,u as ye,ua as it,va as Me,vd as ea,w as y,wa as sr,wb as G,wd as ze,x as C,xa as nt,xb as Jt,xd as ta,y as Bt,ya as Ht,yd as mt,za as cr,zd as vr}from"./chunk-6AKXSINN.mjs";var Wr={src:["source","from","in","input"],dest:["destination","to","out","output"]};function Ho({paramName:c,noBare:e,argTypeName:a,description:t}){let r={name:`src-${c}`,argTypeName:a??"string",synonyms:[...Wr.src.map(o=>`${o}-${c}`)],description:t};return e||r.synonyms.push(c),r}b(Ho,"getParam_src");function Xo({paramName:c,argTypeName:e="string",description:a}){return{name:`dest-${c}`,argTypeName:e??"string",synonyms:[...Wr.dest.map(r=>`${r}-${c}`)],description:a}}b(Xo,"getParam_dest");var Jr={name:"bare",description:`special param that is used as the only param allowed that doesn't have a "double-dash-specifier=" form. one "bare" arg is allowed atow. if a bare arg is found, it will be mapped to this param info.`,synonyms:["bare-arg","bare-param","no-name","manco","arg-with-no-name","param-with-no-name"],argTypeName:"string"};var Hi=Ho({paramName:"path",description:"for referencing/ingesting file(s)/folder(s) in a fs"}),Xi=Xo({paramName:"path",description:"for indicating where to put generated file(s)/folder(s)"});var W=!1;function wt({paramInfo:c,valueString:e}){let a=`[${wt.name}]`;try{switch(c.argTypeName){case"string":let t=e;return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1),t=t.slice(0,t.length-1)),t;case"integer":if(e===void 0)throw new Error("integer arg value is undefined. integers must be a valid integer string (E: ce17acde3b863ec5e2fdcc594f0f1423)");let r=Number.parseInt(e);if(typeof r!="number")throw new Error(`arg value string (${e})did not parse to an integer. parse result: ${r} (E: 43cde93160458610ffb49fd16a02d123)`);return r;case"boolean":if(e===void 0||e===""){if(!c.isFlag)throw new Error("valueString is undefined or empty string but paramInfo.argTypeName === 'boolean' and paramInfo.isFlag is falsy. (E: 482e595c0ec7344b04def76c1441d623)");return!0}else{if(e===null)throw new Error("(UNEXPECTED) valueString === null? (E: 78f548b93026407968356d9c4f106223)");if(!["true","false"].includes(e))throw new Error(`invalid boolean valueString ("${e}"). must be either "true" or "false" (E: ba7a0d0804131acc2bd9ab37c0382523)`);return e==="true"}default:throw new Error("(UNEXPECTED) invalid paramInfo.argTypeName (E: c8b03ccb71394d22a29858b98753a123)")}}catch(t){throw console.error(`${a} ${m(t)}`),t}}b(wt,"getValueFromRawString");function Et({argIdentifier:c,paramInfos:e,throwIfNotFound:a}){let t=`[${Et.name}]`;try{let r=e.filter(o=>o.name===c||(o.synonyms??[]).includes(c));if(r.length===1)return D(r[0]);if(r.length>1)throw new Error(`(UNEXPECTED) multiple param infos found with argIdentifier. do you have overlapping arg names/synonyms? (${c} found in (${r.length} param infos)) (E: d599a6647c5ead6d9fbac4e4c96e6d23)`);if(a)throw new Error(`(UNEXPECTED) param info not found for argIdentifier (${c}) (E: 47e704068f2eb5a0551cf45d0e72c823)`);return}catch(r){throw console.error(`${t} ${m(r)}`),r}}b(Et,"getParamInfo");function Yr({rawArg:c}){let e=`[${Yr.name}]`;try{W&&console.log(`${e} starting... (I: 5d51b75b7a025e2e3fa498da7c08ac24)`);let a=b(o=>o.startsWith('"')&&o.endsWith('"')?"double":o.startsWith("'")&&o.endsWith("'")?"single":void 0,"fnGetQuoteType"),t=b(o=>a(o)?o.slice(0,o.length-1).slice(1):o,"fnStripQuotes"),r=a(c);if(r)return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:c.concat(),resolvedValueString:t(c),singleQuoted:r==="single",doubleQuoted:r==="double"}};if(c.match(/^(--\w|-\w|:\w)/))if(c.includes("=")){let o=/^(--|-|:)([\w\-]+)=(['"]?.+['"]?)$/,i=c.match(o);if(!i)throw new Error(`invalid rawArg (${c}). expected an arg matching regexp ${o}. (E: 05ca56163e184faeb66456a0e9190b28)`);let[n,s,l,d]=i,f=a(d);return{prefix:s,identifier:l,isNameValuePair:!0,valueInfo:{rawValueString:d,resolvedValueString:f?t(d):d,singleQuoted:f==="single",doubleQuoted:f==="double"}}}else{let o=/^(--|-|:)([\w\-]+)$/,i=c.match(o);if(!i)throw new Error(`invalid rawArg (${c}). expected an arg matching regexp ${o}. at this point, it should have a prefix (e.g. "--"), and a single identifier (should be a flag since there is no equal sign). (E: 93305923465d9449bdce3f81373fae24)`);let[n,s,l]=i;return{prefix:s,identifier:l,isNameValuePair:!1,valueInfo:{rawValueString:void 0,resolvedValueString:"true",singleQuoted:!1,doubleQuoted:!1}}}else{if(c.includes("="))throw new Error(`invalid rawArg (${c}). isn't quoted, doesn't start with prefix, but it does have an equal sign? that's bad. (E: e8ad15211ce6fd56a4a214c2778c4724)`);return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:c,resolvedValueString:c,doubleQuoted:!1,singleQuoted:!1}}}}catch(a){throw console.error(`${e} ${a.message}`),a}finally{W&&console.log(`${e} complete.`)}}b(Yr,"parseRawArg");function yt({args:c,paramInfos:e,bareArgParamInfo:a=D(Jr),logalot:t}){let r=`[${yt.name}]`;try{(W||t)&&console.log(`${r} starting... (I: f389aaa490796dfd823bc7b9d4e58b23)`);let o=!1;return c.map((n,s)=>{let l,d,f,{prefix:h,identifier:u,isNameValuePair:g,valueInfo:E}=Yr({rawArg:n});if(h){if((W||t)&&console.log(`identifier: ${u} (I: 519ce129a1e34753a9070d3a205c9a8b)`),!u)throw new Error("(UNEXPECTED) prefix truthy but identifier falsy? (E: f33ab3a2b623acc0d1bc36685edfaf24)");if(l=u,!E)throw new Error("(UNEXPECTED) !valueInfo? (E: 05249a361a59008cd313d2dfa8f08b24)");if(g){W&&console.log(`${r} identifier with equals: ${u}. (I: 5f8ae91d1ddd4a7f94c0f4fb7e688502)`);let w=Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0});f={...w,value:wt({paramInfo:w,valueString:E.rawValueString}),identifier:l}}else{W&&console.log(`${r} identifier without equals: ${u}`),l=u;let w=Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0});f={...w,value:wt({paramInfo:w,valueString:void 0}),identifier:l,isFlag:!0}}}else if(s===0){if(!E)throw new Error("(UNEXPECTED) argIndex === 0 but valueInfo falsy? (E: 4642b42c855593b7ffdacb85f27dab24)");if(!E.rawValueString)throw new Error("(UNEXPECTED) !valueInfo.rawValueString? (E: 0b35f71eb8227cdd67ccfc32f2e45824)");if(E.singleQuoted)throw new Error("first arg is quoted? (single). a bare arg in first position must be a command/flag. (E: 28cce820417fd3b4f95ba6c7e94b4624)");if(E.doubleQuoted)throw new Error("first arg is quoted? (double). a bare arg in first position must be a command/flag. (E: 0b948c87081043fdb168f08ba05ebbce)");l=E.rawValueString,f={...Et({argIdentifier:l,paramInfos:e,throwIfNotFound:!0}),value:!0,identifier:l,isFlag:!0}}else{if((W||t)&&console.log("bare arg found. (I: d6f67074c7e44a63864948d4bf04bee8)"),!a)throw new Error(`bare arg found (one without prefix like "--" or ":") but there is no param info expected for bare args. You must provide which param info a bare arg maps to in this ${yt.name} call. (E: 650dd3695d62f0f87dd0cbafbf068c23)`);if(o)throw new Error('You can have the first arg - a special arg like a command - be bare (without prefix like "--" or ":") and one additional non-positional arg be bare. But more than one non-positional bare arg found. Also remember if the arg has spaces then you have to enclose it with single or double quotes. (E: 74dea8f13f0c14e3b7a2f125c7faca23)');o=!0;let w=D(a);f={...w,isBare:!0,identifier:w.name,value:wt({paramInfo:w,valueString:n})}}return W&&console.log(`${r} argInfo: ${$(f)}`),f})}catch(o){throw console.error(`${r} ${m(o)}`),o}finally{(W||t)&&console.log(`${r} complete.`)}}b(yt,"buildArgInfos");var ra={encrypt_gib:"encrypt-gib"},en=Object.values(ra);var Vo={characters:"characters",spell_out:"spell-out",cardinal:"cardinal",number:"number",ordinal:"ordinal",digits:"digits",fraction:"fraction",unit:"unit",date:"date",time:"time",telephone:"telephone",address:"address",interjection:"interjection",expletive:"expletive"};var fe=class c{static{b(this,"Ssml")}static lc=`[${c.name}]`;static wrapSsmlSpeak(e,a=!0){return"<speak>"+e.reduce((r,o)=>a?r+"<p>"+o+"</p>":r+o,"")+"</speak>"}static unwrapSsmlSpeak(e){return e.replace(/\<speak\>/g,"").replace(/\<\/speak\>/g,"")}static p(e){return"<p>"+e+"</p>"}static s(e){return"<s>"+e+"</s>"}static stripSsml(e){return e.replace(/\<\/p\>[ ]*\<p\>/g,"<p>").replace(/\<p\>(?=[ ])/g,"<p>").replace(/\<\/p\>(?=[ ])/g,"</p>").replace(/\<[\/]*p\>/g,`
2
2
 
3
3
  `).replace(/(<([^>]*)>)/ig,"").replace(/ +/g," ").replace(/\\n\\n\\n/g,`
4
4
 
@@ -5,7 +5,7 @@ ${a.data.errors.join(`
5
5
  `):"unknown error putting ibGibs";throw new Error(d)}if(i?.length??!1){let d=await e.argy({ibMetadata:Ce({space:e}),argData:{cmd:"put",isDna:!0,force:t,ibGibAddrs:i.map(u=>I({ibGib:u}))},ibGibs:i.concat()}),b=await e.witness(d);if(b.data?.success)b.data.warnings?.length>0&&b.data.warnings.forEach(u=>console.warn(`${o} ${u}`));else{let u=b?.data?.errors?.length>0?b.data.errors.join(`
6
6
  `):"unknown error putting dna ibGibs";throw new Error(u)}}}catch(n){throw console.error(`${o} ${n.message}`),n}finally{S&&console.log(`${o} complete. (I: dc6835614ff1a1b82b179225023ae823)`)}}f(Q,"persistTransformResult");async function ll({type:r,rel8nName:e,space:t}){let o=`[${ll.name}]`;try{if(!t)throw new Error("space required. (E: f73868a952ac4181a4f90ee6d86cacf3)");let n=await Vr({type:r,space:t});if(!n)throw new Error(`couldn't get special (${r}) (E: a65bef190416479697605be486846731)`);let s=n.rel8ns?n.rel8ns[e]||[]:[],i=[];for(let a=0;a<s.length;a++){let c=s[a],l=await re({addr:c,space:t});if(l.success&&l.ibGibs?.length===1)i.push(l.ibGibs[0]);else throw new Error(`couldn't get addr: ${c} (E: 76ef256ee80149ab860c5786484b0e89)`)}return i}catch(n){throw console.error(`${o} ${n.message}`),n}}f(ll,"getSpecialRel8dIbGibs");async function Vr({type:r,initialize:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s,fnGetInitializing:i,fnSetInitializing:a,dontWarnIfNotExist:c}){let l=`[${Vr.name}]`;try{if(!t)throw new Error("space required. (E: d454b31d58764a9bb9c4e47fb5ef38b5)");let d=ae({type:r}),b=await Xr({key:d,space:t,dontWarn:c||!!e});if(!b){if(e&&(!i||!a))throw new Error("if initialize, you must provide fnGetInitializeLock & fnSetInitializeLock. (E: 8eb322625d0c4538be089800882487de)");if(e&&!i()){a(!0);try{if(!o)throw new Error("zeroSpace required when 'initialize' truthy (E: 8582c92c637f90c9b2dbe0ec8355b523)");b=await Ei({type:r,space:t,zeroSpace:o,fnBroadcast:s,fnUpdateBootstrap:n})??void 0}catch(g){console.error(`${l} error initializing: ${g.message}`)}finally{a(!1)}}if(!b){if(i&&i())return console.warn(`${l} couldn't get addr, but we're still initializing...`),null;throw new Error("Special address not in config and couldn't initialize it either. (E: d8ebdc9eaaa640b99cd206f132962c93)")}}S&&console.log(`${l} getting addr: ${b}`);let u=await re({addr:b,space:t});if(u.success||(u=await re({addr:b,space:t}),u.success&&(console.warn(`${l} special ibgib was not stored in meta folder...putting in meta folder now for the future (W: e6f5571fd98c449bb2809359be5057cc)`),(await yn({ibGib:u.ibGibs[0],space:t})).success||console.warn(`${l} (UNEXPECTED) tried to put special in meta but success was false? (W: b934b53571c24057af172c790e6a7240)`))),!u.success)throw new Error(u.errorMsg);if(u.ibGibs?.length!==1)throw new Error("no ibGib in result (E: 3a42abdddc3648e292d63dc45c560064)");let p=u.ibGibs[0],h=await ge({ibGibs:[p],space:t});if(h?.data?.success&&h.data.addrs?.length===1){let g=I({ibGib:p}),m=h.data.addrs[0];m!==g&&console.warn(`${l} latest addr is not the one associated with the local space.
7
7
  specialAddr: ${g}
8
- latestAddr: ${m} (W: 141b69dc3c414efc9645bb76fcf12df9)`)}return p}catch(d){let b=`${l} ${d.message}`;return b.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(b),null}}f(Vr,"getSpecialIbGib");async function Xr({key:r,space:e,dontWarn:t}){let o=`[${Xr.name}](${r})`;try{if(S&&console.log(`${o} getting... (I: 43e7bfc2515d45e5af8767b9a85b248e)`),!e)throw new Error("space required. (E: 4f135d4276e64054ba21aeb9c304ecec)");if(!e.rel8ns){(S||!t)&&console.warn(`${o} space.rel8ns falsy. (W: 7c642259fbf547dbaa1b2fdf0115f6ef)`);return}if(!e.rel8ns[r]){(S||!t)&&console.warn(`${o} space.rel8ns[${r}] falsy. (W: 3c1c49b9987b45cc96dd78b808f98e91)`);return}if(e.rel8ns[r].length===1)return S&&console.log(`${o} got (I: f13e71b693d5404c9535bda8ff0cc6a9)`),e.rel8ns[r][0];if(e.rel8ns[r].length>1)return(S||!t)&&console.warn(`${o} more than one config addr with ${r} rel8n. (W: 102f63eb74904bcfaac2eaf778043205)`),e.rel8ns[r][0];S&&console.log(`${o} didn't find (I: 1163e6ac60194d25b3f24881650edfad)`);return}catch(n){console.error(`${o} ${n.message}`);return}}f(Xr,"getConfigAddr");async function be({key:r,addr:e,space:t,zeroSpace:o,fnUpdateBootstrap:n}){let s=`[${be.name}]`;try{if(!t)throw new Error("space required. (E: c28b663c991d44419aef1026cc689636)");if(!o)throw new Error("zeroSpace required. (E: d3707ae5265d464891ad216f64be6184)");let i={[r]:[e]},a=await Ie({src:t.toIbGibDto(),dna:!1,linkedRel8ns:["past","ancestor",r],rel8nsToAddByAddr:i,nCounter:!0});if(!a.newIbGib)throw new Error("create new space failed.");await Q({resTransform:a,space:o}),await Q({resTransform:a,space:t});let c=a.newIbGib;return await t.loadIbGibDto(c),n?await n(c):console.warn(`${s} fnUpdateBootstrap is falsy. (W: 9fb874de2b19454dac18645e61ac463f)`),c}catch(i){throw console.error(`${s} ${i.message}`),i}}f(be,"setConfigAddr");async function gi({space:r}){let e=`[${gi.name}]`;try{if(!r)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await Vr({type:"roots",space:r});if(!t)throw new Error("Roots not initialized. (E: 89b1ba12ed12416aac41cef9fdaf1fc2)");if(!t.rel8ns)throw new Error("Roots not initialized properly. No rel8ns. (E: 8513a07cf530484db9521a2a3a27b7f6)");if(!t.rel8ns.current)throw new Error("Roots not initialized properly. No current root. (E: 459c3a007a30486d96fb8d83f696e239)");if(t.rel8ns.current.length===0)throw new Error("Invalid Roots: empty current root rel8n. (E: bede5864090440bca01ea7ab7fd107d6)");if(t.rel8ns.current.length>1)throw new Error("Invalid Roots: multiple current roots selected. (E: 97561acbf63a48ecaa037697bd26555a)");let o=t.rel8ns.current[0],n=await re({addr:o,space:r});if(n.ibGibs?.length===1)return n.ibGibs[0];throw new Error(`could not get current root. addr: ${o}`)}catch(t){console.error(`${e} ${t.message}`);return}}f(gi,"getCurrentRoot");async function _n({root:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${_n.name}]`;try{if(S&&console.log(`${s} starting... (I: 7f16e845a80fe95d28923e4170f0c825)`),!r)throw new Error("root required.");if(!e)throw new Error("space required. (E: 186af2731c5342a78b063a0a4346f3db)");let i=I({ibGib:r}),a=await Vr({type:"roots",space:e});if(!a)throw new Error("Roots not initialized. (E: a8232b9afac89d0d189534480b7a9825)");let l=await Ie({src:a,dna:!1,linkedRel8ns:["past","ancestor","current"],rel8nsToAddByAddr:{current:[i]},nCounter:!0});await Q({resTransform:l,space:e});let d=ae({type:"roots"}),b=l.newIbGib,u=I({ibGib:b});await be({key:d,addr:u,space:e,zeroSpace:t,fnUpdateBootstrap:o}),await Ge({ibGib:b,space:e,fnBroadcast:n})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{S&&console.log(`${s} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}f(_n,"setCurrentRoot");async function mi({ibGib:r,linked:e,rel8nName:t,space:o,fnBroadcast:n,zeroSpace:s,fnUpdateBootstrap:i}){let a=`[${mi.name}]`;try{if(!o)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!r)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await gi({space:o});if(!c)throw new Error("currentRoot undefined (E: 5c2d84dafc664808866008f6eb535750");let l=fe({ibGib:r,defaultIfNone:"incomingAddr"}),d=I({ibGib:r});if(t&&l&&c.rel8ns&&c.rel8ns[t]&&c.rel8ns[t].includes(l))return;t=t||Zo;let b=await Ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await Q({resTransform:b,space:o});let u=b.newIbGib,p=I({ibGib:u});S&&console.log(`${a} updating _currentRoot root. newRootAddr: ${p}`),await Ge({ibGib:u,space:o,fnBroadcast:n}),await _n({root:u,space:o,zeroSpace:s,fnUpdateBootstrap:i,fnBroadcast:n})}catch(c){console.error(`${a} ${c.message}`);return}}f(mi,"rel8ToCurrentRoot");async function wn({targetIbGib:r,space:e}){let t=`[${wn.name}]`;try{S&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let o=await En({targetIbGib:r}),n=await yn({ibGib:o,space:e});if(!n.success)throw new Error(`error putting metaStone in space. error: ${n.errorMsg??"[unknown error (E: 45f700f4f1ff463ca8f5353c8e796ac7)]"} (E: 4c25379e66365055e3e423561a7d6123)`)}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{S&&console.log(`${t} complete.`)}}f(wn,"createAndSaveNewMetaStone");async function Ge({ibGib:r,space:e,fnBroadcast:t}){let o=`[${Ge.name}]`,n=S;try{let s=I({ibGib:r});if(o=`${o}[${s}]`,!e)throw new Error("space required. (E: ea0c03256f8a4062b460aa4de11f1e3e)");if(S&&console.log(`${o} starting...`),!se({ibGibAddr:s}).tjpGib&&!r.data?.isTjp){S&&console.log(`${o} incoming ibGib has no timeline, so no broadcast. still going to create a metastone for it and return early. (I: 649752e3b1be0e0ceb078e0ec2a84f23)`),await wn({targetIbGib:r,space:e});return}let a=fe({ibGib:r,defaultIfNone:"undefined"});if(!a){let h=r.data?.isTjp?r:await $n({ibGib:r,space:e});h||(console.warn(`${o} tjp not found for ${s}? Should at least just be the ibGib's address itself. (W: d9b570e5bf6d4312bc7d9249ed3bbaad)`),h=r),a=I({ibGib:h})}if(!a)throw new Error("(UNEXPECTED) tjpAddr falsy? should be guaranteed at this point. (E: 39aafb70bc3c6d70b6d2cf8882311223)");let c=f(async()=>{S&&console.log(`${o} adding/replacing latest. tjp: ${a} (I: 7f848da003a2436089fd6f044d96bb42)`),await wn({targetIbGib:r,space:e}),t&&(S&&console.log(`${o} fnBroadcast is true...(I: 0e3b561fb5474a0598b5c6d698df5e1f)`),setTimeout(()=>{S&&console.log(`${o} broadcasting... (I: 61785937be0346f0959d476d7267ab24)`),t({ib:"IbGibTimelineUpdateInfo",tjpAddr:a,latestAddr:s,latestIbGib:r})}))},"replaceLatest");if(r.data?.isTjp){S&&console.log(`${o} ibGib.data?.isTjp true. replacingLatest and returning early. (I: 02c626e006668291550e278b461bcb23)`),await c();return}S&&console.log(`${o} ibGib.data?.isTjp is falsy. (I: 84940e3a9eff869c9474b7b92b864b23)`);let l=await ge({ibGibs:[r],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:b}=l.data;if(!d){let{errors:h}=l.data;throw h??=["[unknown error (E: 344857f1853641aa842cea3931f90428)]"],new Error(`resLatest.success falsy. errors: ${H(h)}. addr: ${s} (E: b66721da6e1ef9ac4f4089e86c059323)`)}if(!b)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let u=Object.keys(b);if(u.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(u[0]!==s)throw new Error(`(UNEXPECTED) latestAddrsMap has 1 key (correct) but the key isn't the incoming ibGibAddr? (incorrect). incoming ibGibAddr: ${s}. key found: ${u[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);S&&(console.log(`${o} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(b));let p=b[s];if(p)if(p===s){S&&console.log(`${o} no other found. possible idempotent replacement. addr: ${s} (I: 7f5bd5d3391be95919240f0e97976e22)`),await c();return}else{S&&console.log(`${o} different addr found. incoming ibgib addr is newer. existingLatestAddr: ${p}. incoming addr: ${s} (I: 6cadf13f82aabeb71d76babf1813e623)`);let h=await re({addr:p,space:e});if(!h.success||h.ibGibs?.length!==1){console.error(`Didn't find existing latest ibGib (${p}). I haven't implemented more robust multi-node/distributed strategies for this scenario yet. so we are going ahead with setting the incoming ibgib as the latest in the timeline. (E: 10f6cca6e5ef45bfacbfe48f652e2102)`),await c();return}let g=h.ibGibs[0];if(typeof r.data?.n=="number"&&r.data.n>=0){S&&console.log(`found ibGib.data.n (version counter), using this to determine latest ibGib: ${r.data.n}`);let $=r.data.n;if(typeof g.data?.n=="number"&&g.data.n>=0){let T=g.data.n;if(S&&console.log(`[registerNewIbGib] n_ibGib (${$}) vs n_existingLatest (${T}) in space: ${e.data?.name||e.ib}`),$>T)S&&console.log(`${o} is newer (I: 040d05ac2032f08c7fd0c4d8b2887323)`),await c();else{S&&console.log("is not newer, so we don't need to do anything else. (I: 14c25dc3314748dc909d61b77eb64354)"),console.warn(`${o} incoming ibGib (${s}) is NOT NEWER than existing latest (${p}). multiple branches for the same timeline? ignoring incoming ibGibAddr. n_ibGib: ${$}. n_existingLatest: ${T}. space.ib: ${e.ib} (W: 057baadca494473dabb26fb4fb879774)`);return}}else g.data?.isTjp&&r.data.n===0?await c():(console.warn(`${o} (UNEXPECTED) only existingLatestIbGib (isTjp: ${g.data?.isTjp}) has a data.n counter? ibGib.data.n: ${r.data.n}. usually this only happens when existing latest is a tjp and the new ibGib we are registering is n === 0. This is falsy in this instance though. We will go ahead and replace the latest with the new one, but this is an anomalous state. (W: 73d08aea17ad4e1481a5f97e2556a878)`),console.log(`${o} console.dir(existingLatestIbGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(g),console.log(`${o} console.dir(ibGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(r),await c())}else if(S&&console.log(`${o} no nCounter found. Trying brute force method.`),await Di({ibGib:r,ibGibAddr:s,existingLatest:g,existingLatestAddr:p,tjpAddr:a,space:e})===s)await c();else return}else if(p===null){S&&console.log(`${o} no existing tjp mapping so incoming ibgib is considered new to this space. ibGib addr: ${s} (I: 4f2bbc32b31e4fa982d95b3a785db82f)`),await c();return}else throw new Error("(UNEXPECTED) latestAddr is falsy but not null? the getLatestAddrs impl in the space should be guaranteed to provide either the incoming ibgib addr, the latest addr (if exists), or null if not found. (E: 3159dd531c0bc0efc1ece116adf28923)")}catch(s){throw console.error(`${o} ${s.message}`),s}finally{S&&console.log(`${o} complete.`),S=n}}f(Ge,"registerNewIbGib");async function Lt({type:r,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:o,addrsToUnRel8:n,linked:s,severPast:i,deletePreviousSpecialIbGib:a,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:b}){let u=`[${Lt.name}](type:${r},rel8nName:${e})`;try{if(!c)throw new Error("space required. (E: 956192eea28047eba6dad81620bb96fb)");if((t??[]).length===0&&(o??[]).length===0&&(n??[]).length===0)throw new Error("either ibGibsToRel8 or ibGibsToUnRel8 required. (E: 5add49c8e46a54e2c6b057c22646a822)");if((o??[]).length>0&&(n??[]).length>0)throw new Error("can't provide both ibGibsToUnRel8 and addrsToUnRel8. There isn't a technical reason but I'm too tired right now to implement the overhead to enable this atow (05/2025). (E: 31ef66be26349cfe1b1f352389b99425)");let p=t?.map(y=>I({ibGib:y}));n??=o?.map(y=>I({ibGib:y}));let h=ae({type:r}),g=await Xr({key:h,space:c});if(!g)throw new Error("specialAddr not found (E: 680dfd1caa3e4d7cb0f593b893a10f0d)");let m=await re({addr:g,space:c});if(!m.success)throw new Error("couldn't get special (E: 897f7671d2184515866c5a675d33b3dc)");if(!m.ibGibs)throw new Error("resGetSpecial.ibGibs falsy (E: 2405dd295b2444d88503f7731796a5a0)");if(m.ibGibs.length!==1)throw new Error(`resGetSpecial.ibGibs count is not 1 (${m.ibGibs.length}) (E: b4547789016a4729af30cd972a4ca4ab)`);let $=m.ibGibs[0],w=await Ie({src:$,rel8nsToAddByAddr:p?{[e]:p}:void 0,rel8nsToRemoveByAddr:n?{[e]:n}:void 0,dna:!1,linkedRel8ns:s?[W.past,e]:[W.past],nCounter:!0}),T=w.newIbGib;if(i){if(w.intermediateIbGibs)throw new Error("new special creates intermediate ibgibs. so severing past is harder. (E: b580c0c56253494192e9c62212ee187d)");T.rel8ns.past=[],T.gib=await X({ibGib:T})}await Q({resTransform:w,space:c});let A=I({ibGib:T}),G=fe({ibGib:T});return await be({key:h,addr:A,space:c,zeroSpace:l,fnUpdateBootstrap:d}),a&&await In({addr:g,space:c}),await Ge({ibGib:T,fnBroadcast:b,space:c}),A}catch(p){throw console.error(`${u} ${p.message}`),p}}f(Lt,"rel8ToSpecialIbGib");async function $n({ibGib:r,naive:e=!0,space:t}){let o=`[${$n.name}]`;try{if(!t)throw new Error("space required. (E: 941f973d50e84415b58724af173f52c2)");if(!r)throw new Error("ibGib required.");let n=I({ibGib:r}),{gib:s}=R({ibGibAddr:n});if(s===U||await vn({ibGib:r,naive:e}))return r;if(!r.rel8ns){S&&console.log(`${o} ibgib not tjp in data, and rel8ns is falsy. so tjp is undefined (I: acdadb76a7568807db7a68f6f866de22)`);return}if(r.rel8ns.tjp&&r.rel8ns.tjp.length>0){let b=r.rel8ns.tjp[0],u=await re({addr:b,space:t});if(u.success&&u.ibGibs?.length===1)return u.ibGibs[0];{let p=u.errorMsg??"[unspecified error in get result]";throw new Error(`ibGib references tjp but could not retrieve from space. res error: ${p} (E: 94f0340706ad48c794c6a62c1b235a22)`)}}let a=r.rel8ns.past||[];if(a.length===0){console.warn(`${o} past.length === 0, so there is no tjp.`),S&&console.log(`${o} ibgib is not tjp in data, not in tjp rel8n, and past is empty. so tjp is undefined (I: bf06f664917dcf4492fb9c4c106a6222)`);return}let c=a[a.length-1],l=await re({addr:c,space:t});if(!l.success||l.ibGibs?.length!==1)throw new Error(`get past failed. addr: ${c}`);let d=l.ibGibs[0];return await $n({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${o} ${n.message}`),n}}f($n,"getTjpIbGib");async function Ei({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Ei.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(r){case"roots":return yi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"tags":return wi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"secrets":return _i({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"encryptions":return Ti({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"outerspaces":return Ai({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"autosyncs":return Si({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"robbots":return Gi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"apps":return xi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});default:return vi({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o})}}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Ei,"createSpecial");async function je({type:r,skipRel8ToRoot:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${je.name}][${r||"falsy type?"}]`;try{S&&console.log(`${i} starting...`);let a=Gn({type:r}),c=M.primitive({ib:a}),l=await Sr({src:c,destIb:a,linkedRel8ns:[W.past,W.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0});return await Q({resTransform:l,space:t}),r!=="roots"&&r!=="latest"&&!e&&await mi({ibGib:l.newIbGib,linked:!0,space:t,zeroSpace:o,fnBroadcast:s,fnUpdateBootstrap:n}),S&&console.log(`${i} complete.`),l.newIbGib}catch(a){throw console.error(`${i} ${a.message}`),a}}f(je,"createSpecialIbGib");async function wi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${wi.name}]`;try{if(!r)throw new Error("space required. (E: 9c05b9bd355943a39ca47afef67a50eb)");let s=ae({type:"tags"}),i=await je({type:"tags",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t}),a=I({ibGib:i});await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});let c=[{text:"home",icon:"home-outline"},{text:"favorite",icon:"heart-outline"}];for(let l of c)a=(await $i({...l,space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t})).newTagsAddr,await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});return a}catch(s){return console.error(`${n} ${s.message}`),null}}f(wi,"createSpecial_Tags");async function $i({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${$i.name}]`;try{if(S&&console.log(`${a} starting...`),!o)throw new Error("space required. (E: 5def0b1afab74b0c9286e3ac5060cb8f)");if(!r)throw new Error(`${a} text required`);e=e||qs,t=t||Hs;let c=wt(r),l=M.primitive({ib:"tag"}),d=await M.firstGen({parentIbGib:l,ib:c,data:{text:r,icon:e,description:t},tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),b=d.newIbGib;await Q({resTransform:d,space:o}),await Ge({ibGib:b,space:o,fnBroadcast:i});let u=await dl({tagIbGib:b,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newTagIbGib:b,newTagsAddr:u}}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f($i,"createTagIbGibAndSundry");async function yi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${yi.name}]`;try{if(!r)throw new Error("space required. (E: d12a8ea31163429fb6e53ff8e7579c57)");let s=ae({type:"roots"}),i=await je({type:"roots",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t}),a=I({ibGib:i});await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});let l=["A","B","C","D","E","F","G"].map(b=>({text:`${b}root`,icon:Qo,description:en})),d;for(let b=0;b<l.length;b++){let u=l[b],p=await Ii({...u,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o});if(d||(d=p.newRootIbGib),!p.newRootIbGib)throw new Error("(UNEXPECTED) resCreate.newRootIbGib falsy? (E: c9fb2c94a9c1d762c1699b41a4d5ad23)");a=p.newRootsAddr,await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t})}if(!d)throw new Error("(UNEXPECTED) firstRoot still falsy? (E: b2e2c926d242966e7ed7159e4b129e23)");if(await _n({root:d,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),a=await Xr({key:s,space:r}),!a)throw new Error("(UNEXPECTED) no roots address in config? (E: 76345340699a4738a195e48803ef0d31)");return a}catch(s){return console.error(`${n} ${s.message}`),null}}f(yi,"createSpecial_Roots");async function Ii({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ii.name}]`;try{if(!o)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");r=r||Fs,e=e||Qo,t=t||en;let c=xn(r),l=M.primitive({ib:"root"}),d=await M.firstGen({parentIbGib:l,ib:c,data:{text:r,icon:e,description:t},linkedRel8ns:[W.past,W.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),{newIbGib:b}=d;await Q({resTransform:d,space:o});let u=await Lt({type:"roots",rel8nName:Jo,ibGibsToRel8:[b],space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newRootIbGib:b,newRootsAddr:u}}catch(c){throw console.error(`${a} ${c.message}`),c}}f(Ii,"createRootIbGib");async function _i({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${_i.name}]`;try{if(!r)throw new Error("space required. (E: 340960cd5ad24addb300b23d9722e30a)");let s,i=ae({type:"secrets"}),a=await je({type:"secrets",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(_i,"createSpecial_Secrets");async function Ti({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ti.name}]`;try{if(!r)throw new Error("space required. (E: 5084e698b6924e7090697ca50075ca59)");let s,i=ae({type:"encryptions"}),a=await je({type:"encryptions",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Ti,"createSpecial_Encryptions");async function Ai({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ai.name}]`;try{if(!r)throw new Error("space required. (E: 99dd9e92535c470482eb9f6625a33831)");let s,i=ae({type:"outerspaces"}),a=await je({type:"outerspaces",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Ai,"createSpecial_OuterSpaces");async function Si({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Si.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"autosyncs"}),a=await je({type:"autosyncs",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Si,"createSpecial_Autosyncs");async function Gi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Gi.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"robbots"}),a=await je({type:"robbots",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Gi,"createSpecial_Robbots");async function xi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${xi.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"apps"}),a=await je({type:"apps",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s=await Kr({defaultAppData:si,defaultAppRel8ns:ii,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Kr({defaultAppData:ai,defaultAppRel8ns:ci,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Kr({defaultAppData:li,defaultAppRel8ns:di,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(xi,"createSpecial_Apps");async function Kr({defaultAppData:r,defaultAppRel8ns:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${Kr.name}]`;try{S&&console.log(`${i} starting... (I: 677f68789abdc7316887e8f38c764e22)`),S&&console.log(`${i} starting...`);let a=C(r),c=e?C(e):void 0;a.uuid=!a.uuid||a.uuid===pn?await F():a.uuid;let{classname:l}=a,d=un({appData:a,classname:l}),b=await M.firstGen({ib:d,parentIbGib:M.primitive({ib:`app ${l}`}),data:a,rel8ns:c,dna:!0,linkedRel8ns:[W.ancestor,W.past],nCounter:!0,tjp:{timestamp:!0}});return await Q({resTransform:b,space:t}),await Ge({ibGib:b.newIbGib,fnBroadcast:s,space:t}),await Lt({type:"apps",rel8nName:Pr,ibGibsToRel8:[b.newIbGib],fnBroadcast:s,fnUpdateBootstrap:n,space:t,zeroSpace:o})}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Kr,"createApp");async function vi({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${vi.name}]`;try{if(!e)throw new Error("space required. (E: c7bbafcbe901418db4c6048f17f53091)");S&&console.log(`${s} creating special of type: ${r} (I: 283c8bb30ed6f9698b74b886c6078622)`);let i,a=ae({type:r}),c=await je({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});return i=I({ibGib:c}),await be({key:a,addr:i,space:e,zeroSpace:t,fnUpdateBootstrap:o}),i}catch(i){return console.error(`${s} ${i.message}`),null}}f(vi,"createSpecial_Default");async function Di({ibGib:r,ibGibAddr:e,existingLatest:t,existingLatestAddr:o,tjpAddr:n,space:s}){let i=`[${Di.name}][${e}]`;try{if(S&&console.log(`${i} starting...`),!s)throw new Error("space required. (E: 64eb9a271f5d43deadec30b9638746c8)");let a=r.rel8ns?.past||[],c=t.rel8ns?.past||[];if(a.length===1&&c.length===0)return S&&console.log(`prospective has a past, so it "must" be newer. (won't quote "must" anymore)`),e;if(c.length===1&&a.length===0)return S&&console.log("existing has a past, so it must be newer."),o;if(c.length===0&&a.length===0)return console.warn(`${i} neither existing latest nor prospective new ibGib has a past, so keeping existing.`),o;if(c.includes(e))return S&&console.log("existing by definition is newer"),o;if(a.includes(o))return S&&console.log("ibGib by definition is newer"),e;if(o===e)return S&&console.log("they're the same!"),o;if(o===n&&t.rel8ns?.tjp?.length===1)return S&&console.log("ibGib must be newer because the existingLatestAddr is the tjp, which is by definition first in unique past."),e;if(e===n&&r.rel8ns?.tjp?.length===1)return S&&console.log("existing must be newer because the ibGibAddr is the tjp, which is by definition first in unique past."),o;S&&console.log(`${i} brute forcing through iterating the pasts.`);let l,d=-1,b=f(async(h,g,m)=>{let $=h.rel8ns?.past||[];if($.includes(m))return l=I({ibGib:h}),-1;if($.length===0)return g;let w=g+$.length;if(d!==-1&&w>d)return l=I({ibGib:h}),-1;let T=await re({addr:$[0],space:s});if(!T.success||T.ibGibs?.length!==1)throw new Error(`Couldn't load past addr (xPast[0]): ${$[0]}`);return b(T.ibGibs[0],g+$.length,m)},"getPastCount");S&&console.log(`${i} doing ibGibPastCount`);let u=await b(r,0,o);if(l)return l;S&&console.log(`${i} Doing existingPastCount`),d=u;let p=await b(t,0,e);return l||(u>p?(S&&console.log(`${i} ibGibPastCount (${u}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(S&&console.log(`${i} existingPastCount (${p}) is longer than ibGibPastCount (${u}), so ibGib is newer.`),l=o),l)}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Di,"getLatestAddr_Brute");function dl({tagIbGib:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){return Lt({type:"tags",rel8nName:tn,ibGibsToRel8:[r],space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n})}f(dl,"rel8TagToTagsIbGib");function fl({ibGibs:r,ibGibAddrs:e}){let t=`[${fl.name}]`;try{if(!r&&!e)throw new Error("either ibGibs or ibGibAddrs required. (E: 37776788620f4966b0964945ce181fc6)");r&&e&&console.warn(`${t} both ibGibs and ibGibAddrs provided. You should only provide one. Only ibGibAddrs will be checked. (W: dc13f9e197834e2daaba3bcfd08418db)`);let o=e?e.concat():r.map(n=>I({ibGib:n}));for(let n=0;n<o.length;n++){let s=o[n];if(o.filter(i=>i===s).length>1)throw new Error(`duplicate addr found: ${s} (E: 70fbef040dd449c38c667d53b8092053)`)}}catch(o){throw console.error(`${t} ${o.message}`),o}}f(fl,"throwIfDuplicates");function Tn({space:r,scope:e}){let t=`[${Tn.name}]`;try{if(S&&console.log(`${t} starting...`),!r)throw new Error("space required. (E: 3ba16e6c3e5e47948b0e63448da11752)");if(!r.data?.uuid)throw new Error("invalid space (space.data.uuid falsy) (E: 273262b32f2ef27b2e690bc699f33822)");if(!e)throw new Error("scope required. (E: f47801d6c45e2247b42a53d9b604b522)");for(;e.includes(ne);)S&&console.log(`${t} scope contains ibgib delimiter...replacing... (I: 0f456fd7cc6552a799673a0c5b4a7d22)`),e=e.replace(ne,"_");let o=r.data.uuid,n=`${ks} ${o} ${e}`;return I({ib:n,gib:U})}catch(o){throw console.error(`${t} ${o.message}`),o}finally{S&&console.log(`${t} complete.`)}}f(Tn,"getSpaceLockAddr");async function Ne({space:r,scope:e,secondsValid:t,maxDelayMs:o,fn:n,callerInstanceId:s,maxLockAttempts:i}){let a=`[${Ne.name}]`;try{if(S&&console.log(`${a} starting...`),!r)throw new Error("space required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");if(!t)throw new Error("secondsValid required. (E: 92c5610e57ceede5ce83cff86d5c2a22)");if(t<0)throw new Error("secondsValid must be positive. (E: 970a7510c517235d7a355a843d18d222)");if(!n)throw new Error("fn required (E: 7022e280252ec2faf756b6db05c56e22)");let c;S&&console.log(`${a} attempting to acquire lock with scope ${e} (I: fed36d42a975b1c52897a4df804ac722)`);let l;o=(o??0)>0?o:js;let d=0;i=i??!1?i:Bs;do{if(l=await Oi({space:r,scope:e,secondsValid:t,instanceId:s}),l?.data?.success)break;let u=Math.ceil(Math.random()*o);await de(u),d++}while(d<i);if(l?.data?.success)S&&console.log(`${a} lock acquired. (I: d847fa953ee131a57e1a89c537342722)`);else throw new Error(`could not acquire lock after ${d} attempts with intermittent delays of ${o} ms (E: 898c559dbd0c9bf20c14cf87a8f1e222)`);let b=`${a}[fn]`;try{S&&console.log(`${b} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(u){throw console.error(`${b} ${u.message}`),u}finally{S&&console.log(`${b} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await Ni({space:r,scope:e,instanceId:s}),S&&console.log(`${b} complete. (I: 79d8ac03714a4d429c7e6c2ac6e18d22)`)}return c}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(Ne,"execInSpaceWithLocking");async function nr({zeroSpace:r}){let e=`[${nr.name}]`;try{if(S&&console.log(`${e} starting...`),!r)throw new Error("zeroSpace required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");let t=ot;S&&console.log(`${e} getting from zeroSpace...`);let o=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"get",ibGibAddrs:[t]}}),n=await r.witness(o);if(n?.data?.success&&n.ibGibs?.length===1){let s=n.ibGibs[0];return S&&console.log(`${e} bootstrapibGib found: ${H(s)}`),await hn(s)?s:(S&&console.log(`${e} bootstrapIbGib was invalid. (I: cce66b26805404fc85525d565e1f8b22)`),null)}else return S&&console.log(`${e} bootstrapIbGib NOT found. (I: 421562993bf3464eb507d2967d311e22)`),null}catch(t){throw console.error(`${e} ${t.message}`),t}finally{S&&console.log(`${e} complete.`)}}f(nr,"getValidatedBootstrapIbGib");async function bl({zeroSpace:r,bootstrapIbGib:e,localSpaceId:t,lock:o,callerInstanceId:n,fnDtoToSpace:s,localSpaceCacheSvc:i}){let a=`[${bl.name}]`;try{if(!r)throw new Error("zeroSpace required. (E: 0793781a98c456a666cfa9eb960bcd22)");if(!e)if(S&&console.log(`${a} bootstrap falsy, so loading it... (I: f2366e38283495a38b5501297aa34422)`),o){let d=ot;S&&console.log(`${a} using locked version of loading bootstrap... (I: 52b9b11999674e586d051c2b23f59b22)`),e=await Ne({space:r,scope:d,fn:f(async()=>{let b=await nr({zeroSpace:r});if(b)return b;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:Or})}else S&&console.log(`${a} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await nr({zeroSpace:r})??void 0;if(!e)throw new Error("bootstrapIbGib falsy. not initialized? (E: 91f5c82b5e124178d958701ebcb09822)");if(!e.data)throw new Error("(UNEXPECTED) bootstrapIbGib.data required. invalid bootstrap? (E: 568c6b837c1a39f7a25d188a90167423)");if(t=t??e.data[De],!e.rel8ns)throw new Error("(UNEXPECTED) bootstrapIbGib.rel8ns falsy? it should have been validated by now. (E: 817d9a2a0b98ec0c177cd7ab149b9426)");if(!e.rel8ns[t])throw new Error(`localSpaceId (${t}) not found in bootstrapIbGib.rel8ns (E: 8869884093984ec43f942fea24bd9926)`);let c=e.rel8ns[t][0],l=f(async()=>{let d=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"get",ibGibAddrs:[c]}}),b=await r.witness(d);if(b?.data?.success&&b.ibGibs?.length===1){let u=b.ibGibs[0],p=await s(u);return i&&(p.cacheSvc=i),p}else throw new Error(`Could not get local space addr (${c}) specified in bootstrap space (${I({ibGib:e})}). (E: 6d6b45e7eae4472697ddc971438e4922)`)},"fnGet");return o?(S&&console.log(`${a} getting localSpaceId (${t}) WITH locking (I: c48a0e4ac5971cdbc57273dd35f8a522)`),await Ne({space:r,scope:t,fn:f(()=>l(),"fn"),callerInstanceId:n,secondsValid:Or})):(S&&console.log(`${a} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${a} ${c.message}`),c}}f(bl,"getLocalSpace");async function Oi({space:r,scope:e,secondsValid:t,instanceId:o}){let n=`[${Oi.name}]`;try{if(S&&console.log(`${n} starting...`),!r)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");if(!t)throw new Error("secondsValid required and positive (E: b42b6733638b46c06c9aff59a6c49822)");if(t<0)throw new Error("secondsValid must be positive (E: bbe3b6d567583bfb35a1c0825eb29622)");let s,i=Tn({space:r,scope:e}),a,c=await re({addr:i,space:r,force:!0});if(c.success&&c.ibGibs?.length===1?(a=c.ibGibs[0],a?.data?.expirationUTC?Ko({expirationTimestampUTC:a.data.expirationUTC})&&(console.warn(`${n} ignoring expired existing lock in space at ${i}. Should be overwritten (W: 7421c5b051724b189f88cecbbd449b22)`),a=void 0):(console.error(`${n} (UNEXPECTED) exisingLock.data.expirationUTC falsy? (E: 218dc0e935534a149d0be153c532cf25)`),a=void 0)):S&&console.log(`${n} existing lock not found for ${i} (I: 191af56ec4e2db3d19084e46bf949222)`),a){if(!a.data)throw new Error("(UNEXPECTED) existingLock.data falsy? (E: 00069b4662e5566d971760d15e293723)");s=C(a),s.data.alreadyLocked=!0,s.data.success=!1}else{let{ib:l,gib:d}=R({ibGibAddr:i});s={ib:l,gib:d,data:{scope:e,secondsValid:t,instanceId:o,expirationUTC:Ho({seconds:t})}};let b=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"put",force:!0,ibGibAddrs:[i]},ibGibs:[s]}),u=await r.witness(b);if(u.data?.success)if((u.data.addrsAlreadyHave??[]).includes(i)){S&&console.log(`${n} racelost! addrsAlreadyHave includes spaceLockAddr (${i}) (I: 2e8a1562947c40698110b64251141753)`);let p=await re({addr:i,space:r,force:!0});if(p.success&&p.ibGibs?.length===1){let h=p.ibGibs[0];s=C(h),s.data.alreadyLocked=!0,s.data.success=!1}else{let h=`${n} (UNEXPECTED) addrsAlreadyHave true, but couldn't get lock? (E: 8374a2b6628b49369363bc5843105763)`;console.error(h),s.data.success=!1,s.data.errorMsg=h}}else s.data.success=!0;else{let p=`${n} there was an error putting the lock in the space: ${u.data?.errors?.join("|")}`;s.data.success=!1,s.data.errorMsg=p,console.error(p)}}return s}catch(s){throw console.error(`${n} ${s.message}`),s}finally{S&&console.log(`${n} complete.`)}}f(Oi,"lockSpace");async function Ni({space:r,scope:e,instanceId:t}){let o=`[${Ni.name}]`;try{if(S&&console.log(`${o} starting...`),!r)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");let n=Tn({space:r,scope:e}),s=await In({addr:n,space:r,force:!0});if(s.success){let{ib:i,gib:a}=R({ibGibAddr:n});return{ib:i,gib:a,data:{success:!0,instanceId:t,scope:e}}}else{let i=`Delete lock in space failed. delete errorMsg: ${s.errorMsg}`;if(i.includes("not implemented"))throw new Error(i);if(i.toLowerCase().includes("does not exist")||i.toLowerCase().includes("doesn't exist")||i.toLowerCase().includes("not found")){S&&console.log(`${o} ${i} (I: b647916fd0f3e5366e9387131be21c22)`);let{ib:a,gib:c}=R({ibGibAddr:n});return{ib:a,gib:c,data:{action:"unlock",success:!0,instanceId:t,scope:e}}}else console.warn(`${o} ${i} (W: 14c84fcac15944bd9a417099964d5d9d)`)}}catch(n){throw console.error(`${o} ${n.message}`),n}finally{S&&console.log(`${o} complete.`)}}f(Ni,"unlockSpace");async function ul({space:r,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:o}){let n=`[${ul.name}]`;try{if(S&&console.log(`${n} starting...`),!r)throw new Error("space required. (E: 6fc19548fa7d1d5219e19871f280a322)");if(!r.data?.uuid)throw new Error("space.data.uuid required (E: 6483188ca6f2ed2085fd355595f3ab22)");if(!e)throw new Error("zeroSpace required. (E: abbf156e18b1018d96273e22a260f122)");let s=r.data.uuid,i=I({ibGib:r}),a=await nr({zeroSpace:e});if(a){if(S&&console.log(`${n} updating existing bootstrap (I: 977d4aa7ed47bef73b35743c05ce0722)`),a.data.spaceIds.includes(s)){S&&console.log(`${n} space already rel8d to bootstrap, possibly updating its addr (I: b5e2c515ef732d4bbcf02625a9e7c722)`);let c=a.rel8ns[s][0];c===i?S&&console.log(`${n} bootstrap already rel8d to space (I: c1be027b23e7350c64790a631cae2822)`):(S&&console.log(`${n} updating rel8ns[${s}] with newSpaceAddr (${i}). (Old address: ${c})(I: 297a9b0061fd471b8d28a06e04a6ad22)`),a.rel8ns[s]=[i])}else S&&console.log(`${n} new space being rel8d. adding spaceId to data.spaceIds and amending rel8ns (I: 40903d71719aa1d56e498299f5699a22)`),a.data.spaceIds.push(s),a.rel8ns[s]=[i];t&&(S&&console.log(`${n} setting spaceId (${s}) as default space (I: f85eda6c6ad2b0bec9750ce3c7795b22)`),a.data[De]=s)}else{if(!o){S&&console.log(`${n} bootstrapIbGib not found but createIfNotFound falsy, so returning early. (I: 5c67d85a8599a5ba4a6780f26a66ea22)`);return}S&&console.log(`${n} creating new bootstrap ibgib for spaceId (${s}) with address of (${i}) (I: 651959c27bf2ebc5be1f7f44e2b9e422)`);let{ib:c,gib:l}=R({ibGibAddr:ot});a=M.primitive({ib:c}),a.gib=l,a.data={[De]:s,[Lr]:[s]},a.rel8ns={[s]:[i]}}if(!a)throw new Error("(UNEXPECTED) bootstrapIbGib still falsy? (E: cf21d7f1756710a66aa0e6a28d762723)");S&&console.log(`${n} saving bootstrapIbGib: ${H(a)} (I: 3cceca0b98dde90e4a58a734be252322)`),await An({zeroSpace:e,bootstrapIbGib:a}),S&&console.log(`${n} complete.`)}catch(s){throw console.error(`${n} ${s.message}`),s}}f(ul,"updateBootstrapIbGib");async function An({zeroSpace:r,bootstrapIbGib:e}){let t=`[${An.name}]`;if(!r)throw new Error("zeroSpace required. (E: 818fa8430b8040dca1917f9db0972b22)");if(!e)throw new Error("bootstrapIbGib required. (E: cf21d7f1756710a66aa0e6a28d762723)");let o=await r.argy({ibMetadata:e.ib,argData:{cmd:"put",force:!0,ibGibAddrs:[I({ibGib:e})]},ibGibs:[e]});S&&console.log(`${t} zeroSpace will witness/put... (I: 1be9aca22ffc4951b6690965a7aeae5b)`);let n=await r.witness(o);if(n?.data?.success)S&&console.log(`${t} zero space put complete. (I: ac3056d655e841f1a3c442bcc64942f9)`);else throw new Error(`${n?.data?.errors?.join("|")||"There was a problem with zeroSpace witnessing the bootstrap^gib primitive."}`)}f(An,"persistBootstrapIbGibInZeroSpace");async function pl({spaceId:r,zeroSpace:e}){let t=`[${pl.name}]`;if(!r)throw new Error("spaceId required. (E: 52f9c31405e24c2999e5a1b32d201a23)");if(!e)throw new Error("zeroSpace required. (E: a115f4007b2c4819a58cf093d5823b23)");await Ne({space:e,scope:ot,fn:f(async()=>{let n=await nr({zeroSpace:e});if(!n)throw new Error("bootstrapIbGib falsy in zeroSpace (E: e36a512781b0467ba1bf1d927a7c1d23)");if(!n.data)throw new Error("bootstrapIbGib.data falsy in zeroSpace (E: 8f92104192b44d71891b092481029ab0)");let s=n.data,i=s[Lr]??[];if(i.length<=1)throw new Error(`Cannot delete space (${r}). It is the only remaining local space. (E: 9c27f71120014b08b5e9f89993380e23)`);if(r===s[De])throw new Error(`Cannot delete space (${r}). It is the default local space. Please select a new default space before deleting. (E: f3c30a5170d14b4fb2478d102e3b2e23)`);if(!i.includes(r))throw new Error(`Space (${r}) not found in bootstrap spaceIds. (E: 61fa940e79124430a618e470bc551d23)`);s[Lr]=i.filter(a=>a!==r),n.rel8ns&&delete n.rel8ns[r],await An({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:Or})}f(pl,"deregisterLocalSpaceFromBootstrap");async function hl({spaceId:r,zeroSpace:e}){let t=`[${hl.name}]`;if(!r)throw new Error("spaceId required. (E: 7c2a10529a1b412a8069e22e5190b623)");if(!e)throw new Error("zeroSpace required. (E: f112a512019c41a590b512a8e0915623)");let o=await e.argy({ibMetadata:Ce({space:e}),argData:{cmd:"get",ibGibAddrs:[r]}}),n=await e.witness(o);if(n?.data?.success&&(n.ibGibs?.length??0)>0){let s=I({ibGib:n.ibGibs[0]}),i=await e.argy({ibMetadata:Ce({space:e}),argData:{cmd:"delete",ibGibAddrs:[s]}});await e.witness(i)}}f(hl,"deleteSpaceRecordFromZeroSpace");function Ce({space:r}){return`${r.ib} ${$e()}`}f(Ce,"getSpaceArgMetadata");function ch({space:r}){return`${r.ib} ${$e()}`}f(ch,"getSpaceResultMetadata");function gl({space:r,spaceData:e,classname:t}){let o=`[${gl.name}]`;try{if(!r&&!e)throw new Error("either space or spaceData required (E: 4dabec34ee77d67c9cc30ee3c3049622)");if(r&&!r.data)throw new Error("(UNEXPECTED) given space has falsy space.data? (E: 058d298876ebbeada7bbddb9e3da2f23)");if(r&&e){if(r.data.uuid!==e.uuid)throw new Error("(UNEXPECTED) both space and spaceData given, but uuid don't match? (E: efdd4603cba93a17340a76811fe56b24)");if(r.data.n!==e.n)throw new Error("(UNEXPECTED) both space and spaceData given, but n don't match? (E: e51278a707c9bccc57a08a4b86524524)")}if(e??=r.data,!e)throw new Error("(UNEXPECTED) spaceData falsy? (thought this was a compiler problem that this was even possible.) (E: b3c7ffedcae4b1f45b263b3825930b24)");if(t&&e.classname&&t!==e.classname)throw new Error(`both classname arg (${t}) and spaceData.classname (${e.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);if(t||=e.classname,!t)throw new Error("classname required (E: fa3af4613ad56742dab51d1b0d839322)");if(t.includes(" "))throw new Error(`invalid classname (${t}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`);let n=e?.name||Ms;if(n.includes(" "))throw new Error("invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)");let s=e?.uuid||void 0;if(!s)throw new Error("invalid space, spaceData.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)");if(s.includes(" "))throw new Error("invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)");let i=e.type??void 0,a=e.subtype??void 0;if(i&&!a)throw new Error(`spaceType (${i}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);return`${qr} ${Dr} ${t} ${n} ${s} ${i} ${a}`}catch(n){throw console.error(`${o} ${n.message}`),n}}f(gl,"getSpaceIb");function ml({ib:r}){let e=`[${ml.name}]`;if(!r){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return r.startsWith(`${qr} ${Dr} `)}f(ml,"isSpaceIb");function Yr({spaceIb:r}){let e=`[${Yr.name}]`;try{if(!r)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,o,n,s,i,a,c]=r.split(" ");if(t!==qr)throw new Error(`invalid spaceIb (${r}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(o!==Dr)throw new Error(`invalid spaceIb (${r}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`);if(!n)throw new Error(`invalid spaceIb (${r}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`);if(!s)throw new Error(`invalid spaceIb (${r}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`);if(!i)throw new Error(`invalid spaceIb (${r}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`);let l;if(a&&a!=="undefined")if(fn.includes(a))l=a;else throw new Error(`invalid spaceIb (${r}). spaceType (${a}) is set but not a valid type. valid types: ${fn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(bn.includes(c))d=c;else throw new Error(`invalid spaceIb (${r}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${bn.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:s,spaceId:i,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Yr,"parseSpaceIb");async function ge({ibGibs:r,addrs:e,tjps:t,tjpAddrs:o,space:n}){let s=`[${ge.name}]`;try{if(S&&console.log(`${s} starting...`),!n)throw new Error("space required. (E: 4d188d6c863246f28aa575753a052304)");if(r=r??[],e=e??[],t=t??[],o=o??[],e.length===0&&r.length===0&&t.length===0&&o.length===0)throw new Error("Either addrs, ibGibs, tjps, or tjpAddrs required. (E: 7c6ebfbab98d4d21a431b144457fd991)");let i=new Set(o.concat(t.map(l=>I({ibGib:l})))),a=Array.from(i).map(l=>R({ibGibAddr:l}).gib);r.map(l=>I({ibGib:l})).concat(e).forEach(l=>{let{gib:d}=R({ibGibAddr:l});a.some(u=>d.includes(u))||i.add(l)}),S&&console.log(`${s}[testing] ${n.data?.name||n.ib} (${n.data?.uuid||"[space.data.uuid falsy]"}) addrsToQuery: ${Array.from(i)} (I: 8a2202912c364238b6d6eb09577bc246)`);let c=await n.argy({ibMetadata:Ce({space:n}),argData:{cmd:"get",cmdModifiers:["latest","addrs"],ibGibAddrs:Array.from(i)}});return await n.witness(c)}catch(i){throw console.error(`${s} ${i.message}`),i}}f(ge,"getLatestAddrs");function Sn({ibGib_Context:r}){let e=`[${Sn.name}]`;try{if(S&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!sr({ibGib:r}))return;if(["roots","autosyncs"].some(o=>r.ib.includes(o)))throw new Error("cannot perform a modification of this type on this special ibgib (E: b8fb718a7323fc54454464b973412722)")}catch(t){throw console.error(`${e} ${t.message}`),t}finally{S&&console.log(`${e} complete.`)}}f(Sn,"throwIfContextIsSpecial");async function El({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${El.name}]`;try{if(S&&console.log(`${a} starting... (I: 2dc486bb2d516e4534f437aaf5ec7f22)`),!r)throw new Error("ibGib_Context required (E: 75f7bfa93145d6dffe85d488443ca722)");if(!e)throw new Error("rel8nName_Context required (E: 12aaa43de9e34b68b25dc9a2a68ad6b9)");if(!t)throw new Error("addr required (E: e27df3bdc5a2554697cc9597afc4e422)");if(!o)throw new Error("space required (E: 2e3562486ed2956a770ed9e8d77a3f22)");let c=sr({ibGib:r});c&&Sn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Vs]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),b=Wr({ib:r.ib}),u=ae({type:b});await be({key:u,addr:d,space:o,zeroSpace:n,fnUpdateBootstrap:s})}await Ge({ibGib:l.newIbGib,fnBroadcast:i,space:o})}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(El,"trash");async function wl({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${wl.name}]`;try{if(S&&console.log(`${a} starting... (I: 38098552b830495187299bb24fcddff0)`),!r)throw new Error("ibGib_Context required (E: d819e8c4db5b4c0bb721300ba434cd40)");if(!e)throw new Error("rel8nName_Context required (E: de061adff8c04429a211aa09116a532d)");if(!t)throw new Error("addr required (E: 7059ebb8ef6149ea94e22f961d6b5c81)");if(!o)throw new Error("space required (E: e19566f2d42347798621447edcae312e)");let c=sr({ibGib:r});c&&Sn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Ks]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),b=Wr({ib:r.ib}),u=ae({type:b});await be({key:u,addr:d,space:o,zeroSpace:n,fnUpdateBootstrap:s})}await Ge({ibGib:l.newIbGib,fnBroadcast:i,space:o})}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(wl,"archive");function $l(r){let e=`[${$l.name}]`;try{if(!r)return console.error(`${e} name is falsy`),!1;let t=/[\w-]+/,o=r.match(t);if(o?.length!==1||o[0].length!==r.length)return console.error(`${e} name can only contain letters, numbers, underscores, hyphens`),!1;let n=/[a-zA-Z\d]/;return r[0].match(n)?!0:(console.error(`${e} name must start with a letter or number`),!1)}catch(t){return console.error(`${e} ${t.message}`),!1}}f($l,"spaceNameIsValid");var K=!1;function _h(r,e){return typeof r=="object"&&r!==null?`v:1^spaceId:${r.spaceId}^${r.ibGibAddr}`:`v:1^spaceId:${r}^${e}`}f(_h,"getSpaceQualifiedIbGibAddr");function Ci(r){try{if(typeof r!="string"||!r.match(Cr))return!1;let t=zr({sqAddr:r});return!0}catch{return!1}}f(Ci,"isSpaceQualifiedAddr");function zr({sqAddr:r}){let e=`[${zr.name}]`;if(!r)throw new Error(`${e} sqAddr falsy (E: 3c7af8b05a68272478e830c89b617d26)`);if(typeof r!="string")throw new Error(`(UNEXPECTED) ${e} sqAddr not a string? (E: 172fd36b0e7d02905263bdef1374da26)`);let t=r.match(Cr);if(!t)throw new Error(`${e} invalid sqAddr (${r}). does not match SQ Addr regexp: ${Cr.source} (E: 71c93b63d4a82970c3bada8d92d4f826)`);let o=t[1],n=parseInt(o,10),s=t[2],i=t[3],a=qe({addr:i})??[];if(a.length>0)throw new Error(`${e} invalid sqAddr. ibGibAddr part is not a valid ibGibAddr. errors: ${a.join(",")} (E: 8e105870eb58c78978169d1d7b275526)`);let{ib:c,gib:l}=R({ibGibAddr:i});return{version:n,spaceId:s,ibGibAddr:i,ib:c,gib:l}}f(zr,"parseSpaceQualifiedIbGibAddr");async function yl({ibGib:r,rel8nNames:e,space:t}){let o=`[${yl.name}]`;try{if(!r)throw new Error("ibGib required (E: 9764881f4c59113a98faabb87aba5826)");if(!t)throw new Error("space required (E: ee110894949865a8a9075938471e1826)");e||(e=Object.keys(r.rel8ns||{}));let n={};for(let s of e){let i=r.rel8ns?.[s]||[];if(i.length>0){let a=await re({addrs:i,space:t});if(a.success&&a.ibGibs?.length===i.length)n[s]=a.ibGibs.concat();else throw new Error(`Problem getting rel8d ibgibs for rel8nName: ${s}. ${a.errorMsg||"Unknown error"} (E: 372b27ed859ca276fe132e7cd3cd1826)`)}else n[s]=[]}return n}catch(n){throw console.error(`${o} ${E(n)}`),n}}f(yl,"getRel8dIbGibs");async function Oe({parentPrimitiveIb:r,ib:e,ibRegExpPattern:t,data:o,rel8ns:n}){let s=`[${Oe.name}]`;try{if(!r)throw new Error("parentPrimitiveIb required. (E: 88ddf188cc5a4340b597abefba1481e2)");if(rt({ib:r})!==null)throw new Error(`Invalid parentPrimitiveIb: ${r}. (E:5aec0320956d492ebeeaca41eb1fe1c6)`);if(!e)throw new Error("ib required. (E: 7bbc88f4f2e842d6b00126e55b1783e4)");let i=t?new RegExp(t):Rs;if(!e.match(i))throw new Error(`invalid ib. does not match regexp (${i})`);let a=Object.keys(n??{}),c=[...et,"tjp"];if(a.some(u=>c.includes(u)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let b=(await M.firstGen({ib:e,parentIbGib:M.primitive({ib:r}),data:o,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return b?.rel8ns?.past&&delete b.rel8ns.past,b?.rel8ns?.tjp&&delete b.rel8ns.tjp,b?.rel8ns?.identity&&delete b.rel8ns.identity,b.gib=await X({ibGib:{ib:b.ib,data:b.data,rel8ns:b.rel8ns},hasTjp:!1}),b}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Oe,"constantIbGib");function Th({binHash:r,binExt:e,binEncoding:t}){return t?e?`bin ${r} ${e} enc=${t}`:`bin ${r} enc=${t}`:e?`bin ${r} ${e}`:`bin ${r}`}f(Th,"getBinIb");function Ah({addr:r}){return Pi({addr:r})}f(Ah,"getBinHashAndExt");function Pi({addr:r}){let e=`[${Pi.name}]`;try{if(!rr({addr:r}))throw new Error("not a bin address (E: df0804d129bc4888bd6939cb76c5e0f6)");let{ib:t}=R({ibGibAddr:r}),o=t.split(" ");if(o.length===2)return{binHash:o[1],binExt:""};if(o.length===3)return o[2].startsWith("enc=")?{binHash:o[1],binExt:"",binEncoding:o[2].substring(4)}:{binHash:o[1],binExt:o[2]};if(o.length===4){if(!o[3].startsWith("enc="))throw new Error(`bin ib (${t}) has 4 space-delimited pieces. we expect therefore the form to be bin \${binHash} \${binExt} enc=\${binEncoding}. but ibPieces[3] doesn't start with "enc=". (E: 87196d7cdd7c12d982cc8204a1163524)`);return{binHash:o[1],binExt:o[2],binEncoding:o[3].substring(4)}}else throw new Error('(UNEXPECTED) ibPieces.length not 2, 3, or 4? atow (01/2024) the only components of a bin ib are: atom, binHash, binExt, binEncoding. binExt and binEncoding are optional, with binEncoding being prefixed with "enc=". (E: b05df3c1b3949f76464a83c9fd1c4f24)')}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Pi,"parseBinIb");function rr({ibGib:r,addr:e}){let t=`[${rr.name}]`;try{if(!r&&!e)throw new Error("either ibGib or addr required. (E: c935b51e773f41a2a547c556e9dc16c6)");if(r&&!r.data)return!1;e=e||I({ibGib:r});let{ib:o,gib:n}=R({ibGibAddr:e});if(!o||!n||!o.startsWith("bin "))return!1;if(n.length!==64)throw new Error('ib starts with "bin " but gib length is not 64, so return false. Two things: 1) bin ibgibs are expected to be stones, i.e., have no temporal junction point and only a single punctiliar hash for the gib. the default hash used atow (01/2024) is sha-256, so the length should be 64. But this may not be true if using another hash algorithm. need to change this function when this becomes the case. (W: 60725d65d13c4b4fbb7b96d7feb19d67)');let s=o.split(" ");if(s.length===2){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: f6baca2ff155f1017b278a5d7597a224)')}else if(s.length===3){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 8d0443d6cada4b50be79a8390a7a426c)')}else if(s.length===4){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 3209eacc0a3848a59593d4c3ee956191)');if(!s[3].startsWith("enc="))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[3].startsWith("enc=")? (E: 4c8a0c3b07a90d30e3d1a4373d57d824)')}else throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited ibPieces length is not 2, 3 or 4? (E: c7eccf88518304997c7e42b32e08d224)');return!0}catch(o){throw console.error(`${t} ${o.message}`),o}}f(rr,"isBinary");function Gn({type:r}){if(!r.match(rn))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${rn.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${r}`}f(Gn,"getSpecialIbGibIb");function Wr({ib:r}){let e=`[${Wr.name}]`;try{if(K&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!r)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!sr({ib:r}))throw new Error("ib is not special (E: 174aff63b992adff3ac2394643735922)");let t=r.split(" ");if(t.length<3)throw new Error('invalid ib. should be space-delimited in form of "meta special [type]" (E: ffd89e2cbe63427f98634ab897aab222)');let o=t[2];return Object.values(vr).some(n=>n===o)||console.warn(`unknown special type (${o}). This may be expected, but atow I am adding special types to the SpecialIbGibType enum-like. (W: f4e26c3ebb57fe49d69014a4ba32a922)`),o}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(Wr,"getSpecialTypeFromIb");function Il({type:r}){return`${Gn({type:r})}^${U}`}f(Il,"getSpecialIbGibAddr");function ae({type:r}){return`${Ys} ${Il({type:r})}`}f(ae,"getSpecialConfigKey");function sr({ib:r,ibGib:e}){if(!r&&!e?.ib)throw new Error("either ib or ibGib.ib required (E: b4cf539638d7966c2e351987f55e1a23)");return(r??e?.ib)?.startsWith("meta special")}f(sr,"isSpecial");function xn(r){let e=`[${xn.name}]`;if(!r)throw new Error(`${e} text required.`);return`root ${r}`}f(xn,"getRootIb");function wt(r){let e=`[${wt.name}]`;if(!r)throw new Error(`${e} tag required.`);return`tag ${r}`}f(wt,"tagTextToIb");function Jr({ibGibs:r,filterPrimitives:e}){let t=`[${Jr.name}]`;try{let o={},n={},s={};return(e?r.filter(a=>a.gib??a.gib!==U):r).forEach(a=>{Li({ibGib:a})?(a.rel8ns?.dna??[]).length>0?o[a.gib]=a:n[a.gib]=a:s[a.gib]=a}),{mapWithTjp_YesDna:o,mapWithTjp_NoDna:n,mapWithoutTjps:s}}catch(o){throw console.error(`${t} ${o.message}`),o}}f(Jr,"splitPerTjpAndOrDna");function ir({ibGibs:r}){let e=`[${ir.name}]`;try{K&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:o}=Jr({ibGibs:r,filterPrimitives:!0}),n={...t,...o},s=Object.values(n),i=qo({items:s,keyFn:f(a=>a.data?.isTjp?I({ibGib:a}):a.rel8ns?.tjp?a.rel8ns?.tjp[0]??"":(K&&console.log(`${e} neither isTjp nor x.rel8ns.tjp truthy (I: ec9a5597bf53dec1bd3d83350abbf823)`),""),"keyFn")});return K&&console.log(`${e} sorting (ascending) ibGibsWithTjpGroupedByTjpAddr: ${H(i)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),Object.entries(i).forEach(([a,c])=>{c.some(l=>l.data?.n===void 0)&&console.warn(`${e} timeline includes ibgibs with ibGib.data?.n === undefined (W: cab9a6b64a38c4279fe82c3569bbab22)`),c.sort((l,d)=>(l.data?.n??-1)>(d.data?.n??-1)?1:-1)}),K&&console.log(`${e} after sort ibGibsWithTjpGroupedByTjpAddr: ${H(i)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),i}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(ir,"getTimelinesGroupedByTjp");function Li({ibGib:r}){let e=`[${Li.name}]`;if(!r)throw new Error("(UNEXPECTED) ibGib falsy? (E: ce3a59f9db14e6158bb2c438ca1a3823)");if((r.rel8ns?.tjp?.length??0)>0||r.data?.isTjp)return!0;let t=["fork^gib","mut8^gib","rel8^gib"];return(r.rel8ns?.ancestor??[]).some(n=>t.includes(n))?!1:r.gib?r.gib.includes(Ue)?!0:r.gib===U?!1:!!se({ibGibAddr:I({ibGib:r})}).tjpGib:(console.warn(`${e} ibGib.gib falsy. (W: 6400d780822b44d992846f1196509be3)`),!1)}f(Li,"hasTjp");function fe({ibGib:r,defaultIfNone:e="undefined"}){let t=`[${fe.name}]`;try{let o=Ri({ibGibs:[r],defaultIfNone:e});return o&&Object.keys(o).length===1?Object.values(o)[0]:void 0}catch(o){throw console.error(`${t} ${o.message}`),o}}f(fe,"getTjpAddr");function Ri({ibGibs:r,defaultIfNone:e="undefined"}){let t=`[${Ri.name}]`;try{let o={};return r.forEach(n=>{let s=I({ibGib:n}),i;n.rel8ns?.tjp?.length??!1?i=n.rel8ns.tjp[n.rel8ns.tjp.length-1]:n.data?.isTjp||e==="incomingAddr"?i=s:i=void 0,o[s]=i}),o}catch(o){throw console.error(`${t} ${o.message}`),o}}f(Ri,"getTjpAddrs");async function vn({ibGib:r,naive:e=!0}){let t=`[${vn.name}]`;try{if(!r)throw new Error("ibGib required.");if(e){if(r.data)return r.data.isTjp?!0:r.rel8ns?r.rel8ns.past&&r.rel8ns.past.length>0?!1:!!(r.rel8ns.past&&r.rel8ns.past.length===0):(K&&console.log(`${t} ibGib.rel8ns falsy (I: c69c9e78b34845311ce7c674d7195622)`),!1);throw new Error("loaded ibGib required (data).")}else throw new Error("only naive implemented right now.")}catch(o){throw console.error(`${t} ${o.message}`),o}}f(vn,"isTjp_Naive");function ve({ibGib:r}){let e=`[${ve.name}]`;r.ib||console.warn(`${e} ibGib.ib is falsy. (W: e60e41c2a1fc48268379d88ce13cb77b)`),r.gib||console.warn(`${e} ibGib.gib is falsy. (W: fb3889cbf0684ae4ac51e48f28570377)`);let t={ib:(r.ib||"").slice()};return r.gib&&(t.gib=r.gib.slice()),r.data&&(rr({ibGib:r})?t.data=r.data.slice():t.data=C(r.data)),r.rel8ns&&(t.rel8ns=C(r.rel8ns)),t}f(ve,"toDto");function Dn(r){let e=`[${Dn.name}]`;try{return K&&console.log(`${e} starting... (I: 57aef93fc6cc2309523b5c72a6b11823)`),!!r&&typeof r.ib=="string"}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(Dn,"isIbGib");function tr({ibGib:r,data:e,timestamp:t}){let o=`[${tr.name}]`;try{K&&console.log(`${o} starting... (I: 35cb68744bcf6139d78e37de644fad23)`),t=t||e?.timestamp||r?.data?.timestamp;let n=r?.data?.timestampMs||e?.timestampMs;if(!t){let s=`${o} timestamp is falsy. (W: 5f1f1182c8804807b886a3d922ac3dcf)`;return console.warn(s),{valid:!1,emsg:s}}if(typeof t=="string")if(Number.isInteger(Number.parseInt(t))){let s=Number.parseInt(t),i=new Date;if(i.setTime(s),i.toString()!==Nr)return K&&console.log(`${o} valid timestampInTicks string (I: 7069a1c3047f3bbc92b78674b20f5b23)`),{valid:!0,date:i,utc:i.toUTCString(),ticks:i.getTime().toString(),ms:n};{let a=`${o} data.timestamp (${t}) is an integer string but not a valid timestampInTicks string. (produces invalid date) (E: f49fbb600fe1426c8805dfc8afbe5cf3)`;return console.error(a),{valid:!1,emsg:a}}}else{let s=new Date(t);if(s.toString()!==Nr)return{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${o} data.timestamp is a non-integer string but not a valid date timestamp string (new date instantiated produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(i),{valid:!1,emsg:i}}}else if(typeof t=="number")if(Number.isInteger(t)){console.warn(`${o} expected data.timestamp to be a string but is a number (W: 9d786f4d4e8d4279b5af7bee19bf721b)`);let s=new Date;if(s.setTime(t),s.toString()!==Nr)return{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${o} timestamp (${t}) is an integer number but not a valid timestampInTicks (new date setTime produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(i),{valid:!1,emsg:i}}}else{let s=`${o} timestamp (${t}) is a non-integer number (supposed to be a string either timestamp string or ticks). (E: 2963d95f8d3b464c992b0bff948b4479)`;return console.error(s),{valid:!1,emsg:s}}else{let s=`${o} unknown typeof timestamp (${typeof t}). (E: 12458a9c16c84e4f859b5771a30dd2ef)`;return console.error(s),{valid:!1,emsg:s}}}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(tr,"getTimestampInfo");async function On({addrs:r,readCache_graph:e,readCache_array:t,space:o}){let n=`[${On.name}]`;try{K&&console.log(`${n} starting... (I: 5db66871239dfa05182277f886a20926)`),e??={},t??=[];let s={...e};t.forEach(l=>s[I({ibGib:l})]=l);let i=Object.keys(e),a=r.filter(l=>!i.includes(l));if(a.length>0){K&&console.log(`${n} ${a.length} addrsNotFoundInCache: ${a} (I: fccbd18116ffb849f813aaebfc6c0826)`);let l=[o],d=a.concat();for(let b of l){let u=await re({addrs:d,space:b});if(u.success&&u.ibGibs&&u.ibGibs.length===d.length)u.ibGibs.forEach(p=>s[I({ibGib:p})]=p),d=[];else if(u.ibGibs&&u.ibGibs.length>0){if(d=d.filter(p=>!u.ibGibs.some(h=>I({ibGib:h})===p)),d.length===0)break}else K&&console.log(`${n} no addrs found in space (${b.ib}). trying next space. (I: 4f99d8bacbb10ab3f8737a752564b326)`)}if(d.length>0)throw new Error(`could not get all addrs from cache or spaces. addrsStillNotFound: ${d}. spaces: ${l.map(b=>b.ib).join("|")} (E: 0c6418f83dd85bda886e56f5b98f3126)`)}let c=[];for(let l of r){let d=s[l];if(!d)throw new Error(`(UNEXPECTED) allIbGibs_graph doesn't have addr? We're expecting logic to preclude this at this point. addr: ${l} (E: f68e1d236ae5e3eb08da9933c8230626)`);c.push(d)}return c}catch(s){throw console.error(`${n} ${E(s)}`),s}finally{K&&console.log(`${n} complete.`)}}f(On,"getIbGibsFromCache_fallbackToSpaces");async function Zr({addr:r,space:e,metaspace:t}){let o=`[${Zr.name}]`;try{if(K&&console.log(`${o} starting... (I: 9252059c96132637381b3be5486e6826)`),!r)throw new Error("(UNEXPECTED) addr falsy? (E: aeb9084d7f68dabb8a49fd68526ff826)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 3ec9df4de82847e13f087bea6f98b826)");let n=Ci(r)?zr({sqAddr:r}).ibGibAddr:r,s=qe({addr:n})??[];if(s.length>0)throw new Error(`invalid incoming addr (${r}). (if space-qualified, then invalid extracted ibGibAddr). errors: ${s.join(", ")} (E: 040dbbcac39990abc8871a1d08b3d826)`);let i;try{let a=await re({space:e,addrs:[n]});if(!a.success||a.errorMsg)throw new Error(`resGet failed. resGet.success: ${a.success}.errorMsg: ${a.errorMsg} (E: 13f3d82381b87f8078583ad8b3676826)`);if(!a.ibGibs)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs falsy? (E: f3a75e6fe96b07d288ba9b3976e84826)");if(a.ibGibs.length===0)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs empty? (E: 4a06589d30050208284fef68adf20426)");if(a.ibGibs.length>1)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs.length > 1? what in the world? (E: a4d01caa4a78a0a1581b3bb8748af826)");i=a.ibGibs[0]}catch(a){K&&console.log(`${o} suppressing error: ${E(a)} (I: 1256ce73d8e8b567ff4fee4ea48c5d26)`)}return i}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(Zr,"getIbGibFromSpace");async function Ui({addrs:r,space:e}){let t=`[${Ui.name}]`;try{if(K&&console.log(`${t} starting... (I: 648eb9b61718fbc1684aabc60cba6826)`),!r)throw new Error("(UNEXPECTED) addrs falsy? (E: 258e489345f1c4b5794e4618f4118c26)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 9cb95bc39b41c1756c6e85384f766a26)");if(r.length===0)return[];let o=r.map(a=>Ci(a)?zr({sqAddr:a}).ibGibAddr:a);for(let a of o){let c=qe({addr:a})??[];if(c.length>0)throw new Error(`invalid incoming addr (${a}). errors: ${c.join(", ")} (E: 1674df15579c46cecd035ff637f41426)`)}let n=await re({space:e,addrs:o});if(!n.success||n.errorMsg)throw new Error(`resGet failed. resGet.success: ${n.success}. errorMsg: ${n.errorMsg} (E: 1a4c08eabeb957f388a79d7b42b60b26)`);if(!n.ibGibs||n.ibGibs.length!==o.length){let c=n.rawResultIbGib?.data?.addrsNotFound??"unknown";throw new Error(`couldn't find all addrs. addrsNotFound: ${c}? resGet.errorMsg: ${n.errorMsg} (E: 5ee272792fe8af335a8fd918c0971a26)`)}let s=new Map;for(let a of n.ibGibs||[]){let c=I({ibGib:a});s.set(c,a)}let i=[];for(let a of o){let c=s.get(a);c&&i.push(c)}return i}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Ui,"getIbGibsFromSpace");async function _l({ibGib:r,space:e}){let t=`[${_l.name}]`;try{K&&console.log(`${t} starting... (I: 64f6a8bd1248f8c3c8c86834431adb26)`);let o=I({ibGib:r}),n=fe({ibGib:r,defaultIfNone:"undefined"});if(!n)return K&&console.log(`${t} tjpAddr falsy. returning incoming ibGib (no timeline means no latest tip possible) (I: 621528e00b6988f0abb8a161e7042226)`),r;let s=await ge({ibGibs:[r],space:e});if(!s)throw new Error("(UNEXPECTED) resLatest falsy? (E: 8ce878315ec4020c082ee7796084b826)");if(!s.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: 3af5a84dd1eba399fcca51e179b36826)");if(!s.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest.data.latestAddrsMap falsy? (E: 37276c35ae58f65cb674389343c2fc26)");let{latestAddrsMap:i}=s.data,a=i[o]??i[n]??o;if(a&&a!==o){let c=await Zr({addr:a,space:e});if(c&&(c.data?.n??0)>=(r.data?.n??0))return c;console.warn(`${t} did not find latest. using incoming ibGib (W: 1079fd20b9183fc8a8fef55a8ad2d826)`)}return r}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(_l,"resolveLatestIbGibInSpace");async function Tl({ibGibs:r,space:e}){let t=`[${Tl.name}]`;try{if(K&&console.log(`${t} starting... (I: 8b0c418702fb42a6a12ee0153833f426)`),!e)throw new Error("space required. (E: b65c19273c524e9389271630af220926)");if(!r||r.length===0)return[];let o=[],n=[],s=[];for(let u of r){let p=I({ibGib:u}),h=fe({ibGib:u,defaultIfNone:"undefined"});n.push(p),s.push(h||""),h&&o.push(u)}if(o.length===0)return r;let i=await ge({ibGibs:o,space:e});if(!i||!i.data||!i.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest or latestAddrsMap falsy? (E: a951d3820ff541c88ba46f7725902126)");let{latestAddrsMap:a}=i.data,c=[],l=[];for(let u=0;u<r.length;u++){let p=n[u],h=s[u],g=a[p]??a[h]??p;l.push(g),g&&g!==p&&c.push(g)}let d=new Map;if(c.length>0){let u=Array.from(new Set(c)),p=await Ui({addrs:u,space:e});for(let h of p){let g=I({ibGib:h});d.set(g,h)}}let b=[];for(let u=0;u<r.length;u++){let p=r[u],h=l[u];if(h&&h!==n[u]){let g=d.get(h);if(g&&(g.data?.n??0)>=(p.data?.n??0)){b.push(g);continue}}b.push(p)}return b}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Tl,"resolveLatestIbGibsInSpace");var Mi=!1,Al="space_gib_db",Sl="space_gib_store",Gl="space_gib_api_key";var xl="agent";var Dh=wt(xl);var Oh={dbName:Al,storeName:Sl,additionalStoreNames:[Us],apiKeyName:Gl};var ki="0.0.27";var at=!1,Lh="[web^gib timer]",Qr="ibgib";var vl="agent",Rh="body-outline",Uh="This tag tracks the active agents for the current local user space.",Mh=wt(vl),ji="#78f87e88",Bi="#78f87e10",Fi="#ffffff";var kh="AUTOMATED_TEXT";var Pe=!1;function qi(r){return new Promise((e,t)=>{let o=new Blob([r],{type:"application/octet-stream"}),n=new FileReader;n.onload=()=>{let i=n.result.split(",")[1];e(i)},n.onerror=s=>t(s),n.readAsDataURL(o)})}f(qi,"uint8ArrayToBase64");async function Hi(r){let e=`data:application/octet-stream;base64,${r}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}f(Hi,"base64ToUint8Array");async function eo({graph:r}){let e=`[${eo.name}]`;try{Pe&&console.log(`${e} starting... (I: 4ddb8803cf68e1d3d35f60680cb69825)`);let t=JSON.parse(JSON.stringify(r));for(let n in t)r[n].data instanceof Uint8Array&&(t[n].data={_dataType:"Uint8Array_Base64",value:await qi(r[n].data)});let o=JSON.stringify(t);return Pe&&console.log(`${e} jsonString.length: ${o.length} (I: 56dec8ad0931ab8ba9b5ca3d4e66be25)`),o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(eo,"serializeGraphToString");async function to({jsonString:r}){let e=`[${to.name}]`;try{Pe&&console.log(`${e} starting... (I: 52e1a1fb1adcc75168fbc6d819868825)`);let o=JSON.parse(r,f((n,s)=>(s&&s._dataType==="Uint8Array_Base64",s),"reviver"));for(let n in o){let s=o[n].data;s&&s._dataType==="Uint8Array_Base64"&&(o[n].data=await Hi(s.value))}return o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(to,"deserializeStringToGraph");async function Ki(r){let e=`[${Ki.name}]`;try{Pe&&console.log(`${e} starting... (I: 8d306868b718596fe8f562bd5118d825)`);let t=await eo({graph:r}),o=new TextEncoder().encode(t),s=new Response(o).body.pipeThrough(new CompressionStream("gzip"));return await new Response(s).blob()}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Ki,"compressIbGibToBlob");async function Dl(r){let e=r.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await to({jsonString:t})}f(Dl,"decompressIbGibFromBlob");async function Nn({graph:r}){let e=`[${Nn.name}]`;try{Pe&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let o=await(await Ki(r)).arrayBuffer(),n=new Uint8Array(o);return await qi(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Nn,"compressIbGibGraphToString");async function Cn({compressedBase64:r}){let e=`[${Cn.name}]`;try{Pe&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await Hi(r),o=new Blob([t],{type:"application/gzip"});return await Dl(o)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Cn,"decompressIbGibGraphFromString");var Vi="export";var ar=!1;function Xi({data:r}){let e=`[${Xi.name}]`;try{ar&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:o,timestamp:n}=r,s=o.length,i=$e(n),a=r.compression==="gzip"?"gzip":"raw";if(!r.timestamp)throw new Error("(UNEXPECTED) data.timestamp falsy? (E: 2f5bc88488cbf260634239a8a8396825)");let c=new Date(r.timestamp),{ib:l,gib:d}=R({ibGibAddr:r.contextIbGibAddr}),u=se({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Vi} ${p} ${a} ${t} ${s} ${u}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{ar&&console.log(`${e} complete.`)}}f(Xi,"getRawExportIb");async function Pn({ibGib:r,metaspace:e,space:t,compress:o,live:n,ignoreErrors:s}){let i=`[${Pn.name}]`;try{if(ar&&console.log(`${i} starting... (I: 0b6ba8608ba8bde0682a0936b9a01825)`),!r)throw new Error("(UNEXPECTED) ibGib falsy? (E: d2898eea744360865f0da5fb91baae22)");let a=I({ibGib:r}),c=[],l=await ie({ibGib:r})??[];if(l.length>0){let $=`ibGib had validation errors: ${l} (E: 84890bbc0598192498178a98ae299825)`;if(s)c.push({errorMsg:$,ibGibAddr:a});else throw new Error($)}let d=await e.getDependencyGraph({ibGib:r,live:n,space:t}),b=o?await Nn({graph:d}):await eo({graph:d}),u=fe({ibGib:r,defaultIfNone:"incomingAddr"})??a,p=new Date,h={contextIbGibAddr:a,tjpAddr:u,dependencyGraphAsString:b,graphSize:Object.keys(d).length,timestamp:Ae(p),timestampMs:p.getMilliseconds()};o&&(h.compression="gzip");let g={ib:Xi({data:h}),data:h},m=await X({ibGib:g,hasTjp:!1});return g.gib=m,ar&&console.log(`${i} JSON.stringify(exportIbGib).length: ${JSON.stringify(g).length} (I: db3a8d913a91d8fc5d6e45981e034822)`),{rawExportIbGib:g,manifest:Object.keys(d),errors:c.length>0?c:void 0}}catch(a){throw console.error(`${i} ${E(a)}`),a}finally{ar&&console.log(`${i} complete.`)}}f(Pn,"getRawExportIbGib");var rg="ibgib-shell-ready",og="ibgib-ui-busy",ng="ibgib-ui-message",sg="ibgib-identity-request-change",ig="ibgib-identity-changed",ag="ibgib-identity-update-available",cg="ibgib-identity-renewal-required",lg="show-identity-manager",dg="show-keystone-creator",fg="show-add-device",bg="show-privacy-policy";var Yi=at;async function $t({title:r,msg:e,prompt:t,showInput:o,defaultValue:n,okButtonTitle:s,cancelButtonTitle:i,isPassword:a,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:b,onPasskeyAuth:u}){let p=`[${$t.name}]`;try{Yi&&console.log(`${p} starting... (I: 037b228a2568181cd3eb25dba4e03225)`);let h=document.getElementById("fullscreen-dialog"),g=document.getElementById("fullscreen-dialog-body"),m=document.getElementById("fullscreen-dialog-title"),$=document.getElementById("fullscreen-dialog-message"),w=document.getElementById("fullscreen-dialog-prompt-input"),T=document.getElementById("fullscreen-dialog-ok-button"),A=document.getElementById("fullscreen-dialog-cancel-button");if(!h||!g||!m||!$||!w||!T||!A)throw new Error("(UNEXPECTED) One or more dialog elements not found in DOM (E: 578e37c0271cc57a99e95e780ad18a25)");if(m.textContent=r||"",[...$.childNodes].forEach(D=>$.removeChild(D)),(e||"").split(`
8
+ latestAddr: ${m} (W: 141b69dc3c414efc9645bb76fcf12df9)`)}return p}catch(d){let b=`${l} ${d.message}`;return b.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(b),null}}f(Vr,"getSpecialIbGib");async function Xr({key:r,space:e,dontWarn:t}){let o=`[${Xr.name}](${r})`;try{if(S&&console.log(`${o} getting... (I: 43e7bfc2515d45e5af8767b9a85b248e)`),!e)throw new Error("space required. (E: 4f135d4276e64054ba21aeb9c304ecec)");if(!e.rel8ns){(S||!t)&&console.warn(`${o} space.rel8ns falsy. (W: 7c642259fbf547dbaa1b2fdf0115f6ef)`);return}if(!e.rel8ns[r]){(S||!t)&&console.warn(`${o} space.rel8ns[${r}] falsy. (W: 3c1c49b9987b45cc96dd78b808f98e91)`);return}if(e.rel8ns[r].length===1)return S&&console.log(`${o} got (I: f13e71b693d5404c9535bda8ff0cc6a9)`),e.rel8ns[r][0];if(e.rel8ns[r].length>1)return(S||!t)&&console.warn(`${o} more than one config addr with ${r} rel8n. (W: 102f63eb74904bcfaac2eaf778043205)`),e.rel8ns[r][0];S&&console.log(`${o} didn't find (I: 1163e6ac60194d25b3f24881650edfad)`);return}catch(n){console.error(`${o} ${n.message}`);return}}f(Xr,"getConfigAddr");async function be({key:r,addr:e,space:t,zeroSpace:o,fnUpdateBootstrap:n}){let s=`[${be.name}]`;try{if(!t)throw new Error("space required. (E: c28b663c991d44419aef1026cc689636)");if(!o)throw new Error("zeroSpace required. (E: d3707ae5265d464891ad216f64be6184)");let i={[r]:[e]},a=await Ie({src:t.toIbGibDto(),dna:!1,linkedRel8ns:["past","ancestor",r],rel8nsToAddByAddr:i,nCounter:!0});if(!a.newIbGib)throw new Error("create new space failed.");await Q({resTransform:a,space:o}),await Q({resTransform:a,space:t});let c=a.newIbGib;return await t.loadIbGibDto(c),n?await n(c):console.warn(`${s} fnUpdateBootstrap is falsy. (W: 9fb874de2b19454dac18645e61ac463f)`),c}catch(i){throw console.error(`${s} ${i.message}`),i}}f(be,"setConfigAddr");async function gi({space:r}){let e=`[${gi.name}]`;try{if(!r)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await Vr({type:"roots",space:r});if(!t)throw new Error("Roots not initialized. (E: 89b1ba12ed12416aac41cef9fdaf1fc2)");if(!t.rel8ns)throw new Error("Roots not initialized properly. No rel8ns. (E: 8513a07cf530484db9521a2a3a27b7f6)");if(!t.rel8ns.current)throw new Error("Roots not initialized properly. No current root. (E: 459c3a007a30486d96fb8d83f696e239)");if(t.rel8ns.current.length===0)throw new Error("Invalid Roots: empty current root rel8n. (E: bede5864090440bca01ea7ab7fd107d6)");if(t.rel8ns.current.length>1)throw new Error("Invalid Roots: multiple current roots selected. (E: 97561acbf63a48ecaa037697bd26555a)");let o=t.rel8ns.current[0],n=await re({addr:o,space:r});if(n.ibGibs?.length===1)return n.ibGibs[0];throw new Error(`could not get current root. addr: ${o}`)}catch(t){console.error(`${e} ${t.message}`);return}}f(gi,"getCurrentRoot");async function _n({root:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${_n.name}]`;try{if(S&&console.log(`${s} starting... (I: 7f16e845a80fe95d28923e4170f0c825)`),!r)throw new Error("root required.");if(!e)throw new Error("space required. (E: 186af2731c5342a78b063a0a4346f3db)");let i=I({ibGib:r}),a=await Vr({type:"roots",space:e});if(!a)throw new Error("Roots not initialized. (E: a8232b9afac89d0d189534480b7a9825)");let l=await Ie({src:a,dna:!1,linkedRel8ns:["past","ancestor","current"],rel8nsToAddByAddr:{current:[i]},nCounter:!0});await Q({resTransform:l,space:e});let d=ae({type:"roots"}),b=l.newIbGib,u=I({ibGib:b});await be({key:d,addr:u,space:e,zeroSpace:t,fnUpdateBootstrap:o}),await Ge({ibGib:b,space:e,fnBroadcast:n})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{S&&console.log(`${s} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}f(_n,"setCurrentRoot");async function mi({ibGib:r,linked:e,rel8nName:t,space:o,fnBroadcast:n,zeroSpace:s,fnUpdateBootstrap:i}){let a=`[${mi.name}]`;try{if(!o)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!r)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await gi({space:o});if(!c)throw new Error("currentRoot undefined (E: 5c2d84dafc664808866008f6eb535750");let l=fe({ibGib:r,defaultIfNone:"incomingAddr"}),d=I({ibGib:r});if(t&&l&&c.rel8ns&&c.rel8ns[t]&&c.rel8ns[t].includes(l))return;t=t||Zo;let b=await Ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await Q({resTransform:b,space:o});let u=b.newIbGib,p=I({ibGib:u});S&&console.log(`${a} updating _currentRoot root. newRootAddr: ${p}`),await Ge({ibGib:u,space:o,fnBroadcast:n}),await _n({root:u,space:o,zeroSpace:s,fnUpdateBootstrap:i,fnBroadcast:n})}catch(c){console.error(`${a} ${c.message}`);return}}f(mi,"rel8ToCurrentRoot");async function wn({targetIbGib:r,space:e}){let t=`[${wn.name}]`;try{S&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let o=await En({targetIbGib:r}),n=await yn({ibGib:o,space:e});if(!n.success)throw new Error(`error putting metaStone in space. error: ${n.errorMsg??"[unknown error (E: 45f700f4f1ff463ca8f5353c8e796ac7)]"} (E: 4c25379e66365055e3e423561a7d6123)`)}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{S&&console.log(`${t} complete.`)}}f(wn,"createAndSaveNewMetaStone");async function Ge({ibGib:r,space:e,fnBroadcast:t}){let o=`[${Ge.name}]`,n=S;try{let s=I({ibGib:r});if(o=`${o}[${s}]`,!e)throw new Error("space required. (E: ea0c03256f8a4062b460aa4de11f1e3e)");if(S&&console.log(`${o} starting...`),!se({ibGibAddr:s}).tjpGib&&!r.data?.isTjp){S&&console.log(`${o} incoming ibGib has no timeline, so no broadcast. still going to create a metastone for it and return early. (I: 649752e3b1be0e0ceb078e0ec2a84f23)`),await wn({targetIbGib:r,space:e});return}let a=fe({ibGib:r,defaultIfNone:"undefined"});if(!a){let h=r.data?.isTjp?r:await $n({ibGib:r,space:e});h||(console.warn(`${o} tjp not found for ${s}? Should at least just be the ibGib's address itself. (W: d9b570e5bf6d4312bc7d9249ed3bbaad)`),h=r),a=I({ibGib:h})}if(!a)throw new Error("(UNEXPECTED) tjpAddr falsy? should be guaranteed at this point. (E: 39aafb70bc3c6d70b6d2cf8882311223)");let c=f(async()=>{S&&console.log(`${o} adding/replacing latest. tjp: ${a} (I: 7f848da003a2436089fd6f044d96bb42)`),await wn({targetIbGib:r,space:e}),t&&(S&&console.log(`${o} fnBroadcast is true...(I: 0e3b561fb5474a0598b5c6d698df5e1f)`),setTimeout(()=>{S&&console.log(`${o} broadcasting... (I: 61785937be0346f0959d476d7267ab24)`),t({ib:"IbGibTimelineUpdateInfo",tjpAddr:a,latestAddr:s,latestIbGib:r})}))},"replaceLatest");if(r.data?.isTjp){S&&console.log(`${o} ibGib.data?.isTjp true. replacingLatest and returning early. (I: 02c626e006668291550e278b461bcb23)`),await c();return}S&&console.log(`${o} ibGib.data?.isTjp is falsy. (I: 84940e3a9eff869c9474b7b92b864b23)`);let l=await ge({ibGibs:[r],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:b}=l.data;if(!d){let{errors:h}=l.data;throw h??=["[unknown error (E: 344857f1853641aa842cea3931f90428)]"],new Error(`resLatest.success falsy. errors: ${H(h)}. addr: ${s} (E: b66721da6e1ef9ac4f4089e86c059323)`)}if(!b)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let u=Object.keys(b);if(u.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(u[0]!==s)throw new Error(`(UNEXPECTED) latestAddrsMap has 1 key (correct) but the key isn't the incoming ibGibAddr? (incorrect). incoming ibGibAddr: ${s}. key found: ${u[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);S&&(console.log(`${o} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(b));let p=b[s];if(p)if(p===s){S&&console.log(`${o} no other found. possible idempotent replacement. addr: ${s} (I: 7f5bd5d3391be95919240f0e97976e22)`),await c();return}else{S&&console.log(`${o} different addr found. incoming ibgib addr is newer. existingLatestAddr: ${p}. incoming addr: ${s} (I: 6cadf13f82aabeb71d76babf1813e623)`);let h=await re({addr:p,space:e});if(!h.success||h.ibGibs?.length!==1){console.error(`Didn't find existing latest ibGib (${p}). I haven't implemented more robust multi-node/distributed strategies for this scenario yet. so we are going ahead with setting the incoming ibgib as the latest in the timeline. (E: 10f6cca6e5ef45bfacbfe48f652e2102)`),await c();return}let g=h.ibGibs[0];if(typeof r.data?.n=="number"&&r.data.n>=0){S&&console.log(`found ibGib.data.n (version counter), using this to determine latest ibGib: ${r.data.n}`);let $=r.data.n;if(typeof g.data?.n=="number"&&g.data.n>=0){let T=g.data.n;if(S&&console.log(`[registerNewIbGib] n_ibGib (${$}) vs n_existingLatest (${T}) in space: ${e.data?.name||e.ib}`),$>T)S&&console.log(`${o} is newer (I: 040d05ac2032f08c7fd0c4d8b2887323)`),await c();else{S&&console.log("is not newer, so we don't need to do anything else. (I: 14c25dc3314748dc909d61b77eb64354)"),console.warn(`${o} incoming ibGib (${s}) is NOT NEWER than existing latest (${p}). multiple branches for the same timeline? ignoring incoming ibGibAddr. n_ibGib: ${$}. n_existingLatest: ${T}. space.ib: ${e.ib} (W: 057baadca494473dabb26fb4fb879774)`);return}}else g.data?.isTjp&&r.data.n===0?await c():(console.warn(`${o} (UNEXPECTED) only existingLatestIbGib (isTjp: ${g.data?.isTjp}) has a data.n counter? ibGib.data.n: ${r.data.n}. usually this only happens when existing latest is a tjp and the new ibGib we are registering is n === 0. This is falsy in this instance though. We will go ahead and replace the latest with the new one, but this is an anomalous state. (W: 73d08aea17ad4e1481a5f97e2556a878)`),console.log(`${o} console.dir(existingLatestIbGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(g),console.log(`${o} console.dir(ibGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(r),await c())}else if(S&&console.log(`${o} no nCounter found. Trying brute force method.`),await Di({ibGib:r,ibGibAddr:s,existingLatest:g,existingLatestAddr:p,tjpAddr:a,space:e})===s)await c();else return}else if(p===null){S&&console.log(`${o} no existing tjp mapping so incoming ibgib is considered new to this space. ibGib addr: ${s} (I: 4f2bbc32b31e4fa982d95b3a785db82f)`),await c();return}else throw new Error("(UNEXPECTED) latestAddr is falsy but not null? the getLatestAddrs impl in the space should be guaranteed to provide either the incoming ibgib addr, the latest addr (if exists), or null if not found. (E: 3159dd531c0bc0efc1ece116adf28923)")}catch(s){throw console.error(`${o} ${s.message}`),s}finally{S&&console.log(`${o} complete.`),S=n}}f(Ge,"registerNewIbGib");async function Lt({type:r,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:o,addrsToUnRel8:n,linked:s,severPast:i,deletePreviousSpecialIbGib:a,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:b}){let u=`[${Lt.name}](type:${r},rel8nName:${e})`;try{if(!c)throw new Error("space required. (E: 956192eea28047eba6dad81620bb96fb)");if((t??[]).length===0&&(o??[]).length===0&&(n??[]).length===0)throw new Error("either ibGibsToRel8 or ibGibsToUnRel8 required. (E: 5add49c8e46a54e2c6b057c22646a822)");if((o??[]).length>0&&(n??[]).length>0)throw new Error("can't provide both ibGibsToUnRel8 and addrsToUnRel8. There isn't a technical reason but I'm too tired right now to implement the overhead to enable this atow (05/2025). (E: 31ef66be26349cfe1b1f352389b99425)");let p=t?.map(y=>I({ibGib:y}));n??=o?.map(y=>I({ibGib:y}));let h=ae({type:r}),g=await Xr({key:h,space:c});if(!g)throw new Error("specialAddr not found (E: 680dfd1caa3e4d7cb0f593b893a10f0d)");let m=await re({addr:g,space:c});if(!m.success)throw new Error("couldn't get special (E: 897f7671d2184515866c5a675d33b3dc)");if(!m.ibGibs)throw new Error("resGetSpecial.ibGibs falsy (E: 2405dd295b2444d88503f7731796a5a0)");if(m.ibGibs.length!==1)throw new Error(`resGetSpecial.ibGibs count is not 1 (${m.ibGibs.length}) (E: b4547789016a4729af30cd972a4ca4ab)`);let $=m.ibGibs[0],w=await Ie({src:$,rel8nsToAddByAddr:p?{[e]:p}:void 0,rel8nsToRemoveByAddr:n?{[e]:n}:void 0,dna:!1,linkedRel8ns:s?[W.past,e]:[W.past],nCounter:!0}),T=w.newIbGib;if(i){if(w.intermediateIbGibs)throw new Error("new special creates intermediate ibgibs. so severing past is harder. (E: b580c0c56253494192e9c62212ee187d)");T.rel8ns.past=[],T.gib=await X({ibGib:T})}await Q({resTransform:w,space:c});let A=I({ibGib:T}),G=fe({ibGib:T});return await be({key:h,addr:A,space:c,zeroSpace:l,fnUpdateBootstrap:d}),a&&await In({addr:g,space:c}),await Ge({ibGib:T,fnBroadcast:b,space:c}),A}catch(p){throw console.error(`${u} ${p.message}`),p}}f(Lt,"rel8ToSpecialIbGib");async function $n({ibGib:r,naive:e=!0,space:t}){let o=`[${$n.name}]`;try{if(!t)throw new Error("space required. (E: 941f973d50e84415b58724af173f52c2)");if(!r)throw new Error("ibGib required.");let n=I({ibGib:r}),{gib:s}=R({ibGibAddr:n});if(s===U||await vn({ibGib:r,naive:e}))return r;if(!r.rel8ns){S&&console.log(`${o} ibgib not tjp in data, and rel8ns is falsy. so tjp is undefined (I: acdadb76a7568807db7a68f6f866de22)`);return}if(r.rel8ns.tjp&&r.rel8ns.tjp.length>0){let b=r.rel8ns.tjp[0],u=await re({addr:b,space:t});if(u.success&&u.ibGibs?.length===1)return u.ibGibs[0];{let p=u.errorMsg??"[unspecified error in get result]";throw new Error(`ibGib references tjp but could not retrieve from space. res error: ${p} (E: 94f0340706ad48c794c6a62c1b235a22)`)}}let a=r.rel8ns.past||[];if(a.length===0){console.warn(`${o} past.length === 0, so there is no tjp.`),S&&console.log(`${o} ibgib is not tjp in data, not in tjp rel8n, and past is empty. so tjp is undefined (I: bf06f664917dcf4492fb9c4c106a6222)`);return}let c=a[a.length-1],l=await re({addr:c,space:t});if(!l.success||l.ibGibs?.length!==1)throw new Error(`get past failed. addr: ${c}`);let d=l.ibGibs[0];return await $n({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${o} ${n.message}`),n}}f($n,"getTjpIbGib");async function Ei({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Ei.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(r){case"roots":return yi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"tags":return wi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"secrets":return _i({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"encryptions":return Ti({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"outerspaces":return Ai({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"autosyncs":return Si({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"robbots":return Gi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"apps":return xi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});default:return vi({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o})}}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Ei,"createSpecial");async function je({type:r,skipRel8ToRoot:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${je.name}][${r||"falsy type?"}]`;try{S&&console.log(`${i} starting...`);let a=Gn({type:r}),c=M.primitive({ib:a}),l=await Sr({src:c,destIb:a,linkedRel8ns:[W.past,W.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0});return await Q({resTransform:l,space:t}),r!=="roots"&&r!=="latest"&&!e&&await mi({ibGib:l.newIbGib,linked:!0,space:t,zeroSpace:o,fnBroadcast:s,fnUpdateBootstrap:n}),S&&console.log(`${i} complete.`),l.newIbGib}catch(a){throw console.error(`${i} ${a.message}`),a}}f(je,"createSpecialIbGib");async function wi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${wi.name}]`;try{if(!r)throw new Error("space required. (E: 9c05b9bd355943a39ca47afef67a50eb)");let s=ae({type:"tags"}),i=await je({type:"tags",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t}),a=I({ibGib:i});await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});let c=[{text:"home",icon:"home-outline"},{text:"favorite",icon:"heart-outline"}];for(let l of c)a=(await $i({...l,space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t})).newTagsAddr,await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});return a}catch(s){return console.error(`${n} ${s.message}`),null}}f(wi,"createSpecial_Tags");async function $i({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${$i.name}]`;try{if(S&&console.log(`${a} starting...`),!o)throw new Error("space required. (E: 5def0b1afab74b0c9286e3ac5060cb8f)");if(!r)throw new Error(`${a} text required`);e=e||qs,t=t||Hs;let c=wt(r),l=M.primitive({ib:"tag"}),d=await M.firstGen({parentIbGib:l,ib:c,data:{text:r,icon:e,description:t},tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),b=d.newIbGib;await Q({resTransform:d,space:o}),await Ge({ibGib:b,space:o,fnBroadcast:i});let u=await dl({tagIbGib:b,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newTagIbGib:b,newTagsAddr:u}}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f($i,"createTagIbGibAndSundry");async function yi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${yi.name}]`;try{if(!r)throw new Error("space required. (E: d12a8ea31163429fb6e53ff8e7579c57)");let s=ae({type:"roots"}),i=await je({type:"roots",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t}),a=I({ibGib:i});await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t});let l=["A","B","C","D","E","F","G"].map(b=>({text:`${b}root`,icon:Qo,description:en})),d;for(let b=0;b<l.length;b++){let u=l[b],p=await Ii({...u,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o});if(d||(d=p.newRootIbGib),!p.newRootIbGib)throw new Error("(UNEXPECTED) resCreate.newRootIbGib falsy? (E: c9fb2c94a9c1d762c1699b41a4d5ad23)");a=p.newRootsAddr,await be({key:s,addr:a,space:r,zeroSpace:e,fnUpdateBootstrap:t})}if(!d)throw new Error("(UNEXPECTED) firstRoot still falsy? (E: b2e2c926d242966e7ed7159e4b129e23)");if(await _n({root:d,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),a=await Xr({key:s,space:r}),!a)throw new Error("(UNEXPECTED) no roots address in config? (E: 76345340699a4738a195e48803ef0d31)");return a}catch(s){return console.error(`${n} ${s.message}`),null}}f(yi,"createSpecial_Roots");async function Ii({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ii.name}]`;try{if(!o)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");r=r||Fs,e=e||Qo,t=t||en;let c=xn(r),l=M.primitive({ib:"root"}),d=await M.firstGen({parentIbGib:l,ib:c,data:{text:r,icon:e,description:t},linkedRel8ns:[W.past,W.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),{newIbGib:b}=d;await Q({resTransform:d,space:o});let u=await Lt({type:"roots",rel8nName:Jo,ibGibsToRel8:[b],space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newRootIbGib:b,newRootsAddr:u}}catch(c){throw console.error(`${a} ${c.message}`),c}}f(Ii,"createRootIbGib");async function _i({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${_i.name}]`;try{if(!r)throw new Error("space required. (E: 340960cd5ad24addb300b23d9722e30a)");let s,i=ae({type:"secrets"}),a=await je({type:"secrets",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(_i,"createSpecial_Secrets");async function Ti({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ti.name}]`;try{if(!r)throw new Error("space required. (E: 5084e698b6924e7090697ca50075ca59)");let s,i=ae({type:"encryptions"}),a=await je({type:"encryptions",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Ti,"createSpecial_Encryptions");async function Ai({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ai.name}]`;try{if(!r)throw new Error("space required. (E: 99dd9e92535c470482eb9f6625a33831)");let s,i=ae({type:"outerspaces"}),a=await je({type:"outerspaces",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Ai,"createSpecial_OuterSpaces");async function Si({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Si.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"autosyncs"}),a=await je({type:"autosyncs",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Si,"createSpecial_Autosyncs");async function Gi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Gi.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"robbots"}),a=await je({type:"robbots",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Gi,"createSpecial_Robbots");async function xi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${xi.name}]`;try{if(!r)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let s,i=ae({type:"apps"}),a=await je({type:"apps",space:r,zeroSpace:e,fnBroadcast:o,fnUpdateBootstrap:t});return s=I({ibGib:a}),await be({key:i,addr:s,space:r,zeroSpace:e,fnUpdateBootstrap:t}),s=await Kr({defaultAppData:si,defaultAppRel8ns:ii,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Kr({defaultAppData:ai,defaultAppRel8ns:ci,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Kr({defaultAppData:li,defaultAppRel8ns:di,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(xi,"createSpecial_Apps");async function Kr({defaultAppData:r,defaultAppRel8ns:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${Kr.name}]`;try{S&&console.log(`${i} starting... (I: 677f68789abdc7316887e8f38c764e22)`),S&&console.log(`${i} starting...`);let a=C(r),c=e?C(e):void 0;a.uuid=!a.uuid||a.uuid===pn?await F():a.uuid;let{classname:l}=a,d=un({appData:a,classname:l}),b=await M.firstGen({ib:d,parentIbGib:M.primitive({ib:`app ${l}`}),data:a,rel8ns:c,dna:!0,linkedRel8ns:[W.ancestor,W.past],nCounter:!0,tjp:{timestamp:!0}});return await Q({resTransform:b,space:t}),await Ge({ibGib:b.newIbGib,fnBroadcast:s,space:t}),await Lt({type:"apps",rel8nName:Pr,ibGibsToRel8:[b.newIbGib],fnBroadcast:s,fnUpdateBootstrap:n,space:t,zeroSpace:o})}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Kr,"createApp");async function vi({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${vi.name}]`;try{if(!e)throw new Error("space required. (E: c7bbafcbe901418db4c6048f17f53091)");S&&console.log(`${s} creating special of type: ${r} (I: 283c8bb30ed6f9698b74b886c6078622)`);let i,a=ae({type:r}),c=await je({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});return i=I({ibGib:c}),await be({key:a,addr:i,space:e,zeroSpace:t,fnUpdateBootstrap:o}),i}catch(i){return console.error(`${s} ${i.message}`),null}}f(vi,"createSpecial_Default");async function Di({ibGib:r,ibGibAddr:e,existingLatest:t,existingLatestAddr:o,tjpAddr:n,space:s}){let i=`[${Di.name}][${e}]`;try{if(S&&console.log(`${i} starting...`),!s)throw new Error("space required. (E: 64eb9a271f5d43deadec30b9638746c8)");let a=r.rel8ns?.past||[],c=t.rel8ns?.past||[];if(a.length===1&&c.length===0)return S&&console.log(`prospective has a past, so it "must" be newer. (won't quote "must" anymore)`),e;if(c.length===1&&a.length===0)return S&&console.log("existing has a past, so it must be newer."),o;if(c.length===0&&a.length===0)return console.warn(`${i} neither existing latest nor prospective new ibGib has a past, so keeping existing.`),o;if(c.includes(e))return S&&console.log("existing by definition is newer"),o;if(a.includes(o))return S&&console.log("ibGib by definition is newer"),e;if(o===e)return S&&console.log("they're the same!"),o;if(o===n&&t.rel8ns?.tjp?.length===1)return S&&console.log("ibGib must be newer because the existingLatestAddr is the tjp, which is by definition first in unique past."),e;if(e===n&&r.rel8ns?.tjp?.length===1)return S&&console.log("existing must be newer because the ibGibAddr is the tjp, which is by definition first in unique past."),o;S&&console.log(`${i} brute forcing through iterating the pasts.`);let l,d=-1,b=f(async(h,g,m)=>{let $=h.rel8ns?.past||[];if($.includes(m))return l=I({ibGib:h}),-1;if($.length===0)return g;let w=g+$.length;if(d!==-1&&w>d)return l=I({ibGib:h}),-1;let T=await re({addr:$[0],space:s});if(!T.success||T.ibGibs?.length!==1)throw new Error(`Couldn't load past addr (xPast[0]): ${$[0]}`);return b(T.ibGibs[0],g+$.length,m)},"getPastCount");S&&console.log(`${i} doing ibGibPastCount`);let u=await b(r,0,o);if(l)return l;S&&console.log(`${i} Doing existingPastCount`),d=u;let p=await b(t,0,e);return l||(u>p?(S&&console.log(`${i} ibGibPastCount (${u}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(S&&console.log(`${i} existingPastCount (${p}) is longer than ibGibPastCount (${u}), so ibGib is newer.`),l=o),l)}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Di,"getLatestAddr_Brute");function dl({tagIbGib:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){return Lt({type:"tags",rel8nName:tn,ibGibsToRel8:[r],space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n})}f(dl,"rel8TagToTagsIbGib");function fl({ibGibs:r,ibGibAddrs:e}){let t=`[${fl.name}]`;try{if(!r&&!e)throw new Error("either ibGibs or ibGibAddrs required. (E: 37776788620f4966b0964945ce181fc6)");r&&e&&console.warn(`${t} both ibGibs and ibGibAddrs provided. You should only provide one. Only ibGibAddrs will be checked. (W: dc13f9e197834e2daaba3bcfd08418db)`);let o=e?e.concat():r.map(n=>I({ibGib:n}));for(let n=0;n<o.length;n++){let s=o[n];if(o.filter(i=>i===s).length>1)throw new Error(`duplicate addr found: ${s} (E: 70fbef040dd449c38c667d53b8092053)`)}}catch(o){throw console.error(`${t} ${o.message}`),o}}f(fl,"throwIfDuplicates");function Tn({space:r,scope:e}){let t=`[${Tn.name}]`;try{if(S&&console.log(`${t} starting...`),!r)throw new Error("space required. (E: 3ba16e6c3e5e47948b0e63448da11752)");if(!r.data?.uuid)throw new Error("invalid space (space.data.uuid falsy) (E: 273262b32f2ef27b2e690bc699f33822)");if(!e)throw new Error("scope required. (E: f47801d6c45e2247b42a53d9b604b522)");for(;e.includes(ne);)S&&console.log(`${t} scope contains ibgib delimiter...replacing... (I: 0f456fd7cc6552a799673a0c5b4a7d22)`),e=e.replace(ne,"_");let o=r.data.uuid,n=`${ks} ${o} ${e}`;return I({ib:n,gib:U})}catch(o){throw console.error(`${t} ${o.message}`),o}finally{S&&console.log(`${t} complete.`)}}f(Tn,"getSpaceLockAddr");async function Ne({space:r,scope:e,secondsValid:t,maxDelayMs:o,fn:n,callerInstanceId:s,maxLockAttempts:i}){let a=`[${Ne.name}]`;try{if(S&&console.log(`${a} starting...`),!r)throw new Error("space required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");if(!t)throw new Error("secondsValid required. (E: 92c5610e57ceede5ce83cff86d5c2a22)");if(t<0)throw new Error("secondsValid must be positive. (E: 970a7510c517235d7a355a843d18d222)");if(!n)throw new Error("fn required (E: 7022e280252ec2faf756b6db05c56e22)");let c;S&&console.log(`${a} attempting to acquire lock with scope ${e} (I: fed36d42a975b1c52897a4df804ac722)`);let l;o=(o??0)>0?o:js;let d=0;i=i??!1?i:Bs;do{if(l=await Oi({space:r,scope:e,secondsValid:t,instanceId:s}),l?.data?.success)break;let u=Math.ceil(Math.random()*o);await de(u),d++}while(d<i);if(l?.data?.success)S&&console.log(`${a} lock acquired. (I: d847fa953ee131a57e1a89c537342722)`);else throw new Error(`could not acquire lock after ${d} attempts with intermittent delays of ${o} ms (E: 898c559dbd0c9bf20c14cf87a8f1e222)`);let b=`${a}[fn]`;try{S&&console.log(`${b} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(u){throw console.error(`${b} ${u.message}`),u}finally{S&&console.log(`${b} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await Ni({space:r,scope:e,instanceId:s}),S&&console.log(`${b} complete. (I: 79d8ac03714a4d429c7e6c2ac6e18d22)`)}return c}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(Ne,"execInSpaceWithLocking");async function nr({zeroSpace:r}){let e=`[${nr.name}]`;try{if(S&&console.log(`${e} starting...`),!r)throw new Error("zeroSpace required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");let t=ot;S&&console.log(`${e} getting from zeroSpace...`);let o=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"get",ibGibAddrs:[t]}}),n=await r.witness(o);if(n?.data?.success&&n.ibGibs?.length===1){let s=n.ibGibs[0];return S&&console.log(`${e} bootstrapibGib found: ${H(s)}`),await hn(s)?s:(S&&console.log(`${e} bootstrapIbGib was invalid. (I: cce66b26805404fc85525d565e1f8b22)`),null)}else return S&&console.log(`${e} bootstrapIbGib NOT found. (I: 421562993bf3464eb507d2967d311e22)`),null}catch(t){throw console.error(`${e} ${t.message}`),t}finally{S&&console.log(`${e} complete.`)}}f(nr,"getValidatedBootstrapIbGib");async function bl({zeroSpace:r,bootstrapIbGib:e,localSpaceId:t,lock:o,callerInstanceId:n,fnDtoToSpace:s,localSpaceCacheSvc:i}){let a=`[${bl.name}]`;try{if(!r)throw new Error("zeroSpace required. (E: 0793781a98c456a666cfa9eb960bcd22)");if(!e)if(S&&console.log(`${a} bootstrap falsy, so loading it... (I: f2366e38283495a38b5501297aa34422)`),o){let d=ot;S&&console.log(`${a} using locked version of loading bootstrap... (I: 52b9b11999674e586d051c2b23f59b22)`),e=await Ne({space:r,scope:d,fn:f(async()=>{let b=await nr({zeroSpace:r});if(b)return b;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:Or})}else S&&console.log(`${a} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await nr({zeroSpace:r})??void 0;if(!e)throw new Error("bootstrapIbGib falsy. not initialized? (E: 91f5c82b5e124178d958701ebcb09822)");if(!e.data)throw new Error("(UNEXPECTED) bootstrapIbGib.data required. invalid bootstrap? (E: 568c6b837c1a39f7a25d188a90167423)");if(t=t??e.data[De],!e.rel8ns)throw new Error("(UNEXPECTED) bootstrapIbGib.rel8ns falsy? it should have been validated by now. (E: 817d9a2a0b98ec0c177cd7ab149b9426)");if(!e.rel8ns[t])throw new Error(`localSpaceId (${t}) not found in bootstrapIbGib.rel8ns (E: 8869884093984ec43f942fea24bd9926)`);let c=e.rel8ns[t][0],l=f(async()=>{let d=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"get",ibGibAddrs:[c]}}),b=await r.witness(d);if(b?.data?.success&&b.ibGibs?.length===1){let u=b.ibGibs[0],p=await s(u);return i&&(p.cacheSvc=i),p}else throw new Error(`Could not get local space addr (${c}) specified in bootstrap space (${I({ibGib:e})}). (E: 6d6b45e7eae4472697ddc971438e4922)`)},"fnGet");return o?(S&&console.log(`${a} getting localSpaceId (${t}) WITH locking (I: c48a0e4ac5971cdbc57273dd35f8a522)`),await Ne({space:r,scope:t,fn:f(()=>l(),"fn"),callerInstanceId:n,secondsValid:Or})):(S&&console.log(`${a} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${a} ${c.message}`),c}}f(bl,"getLocalSpace");async function Oi({space:r,scope:e,secondsValid:t,instanceId:o}){let n=`[${Oi.name}]`;try{if(S&&console.log(`${n} starting...`),!r)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");if(!t)throw new Error("secondsValid required and positive (E: b42b6733638b46c06c9aff59a6c49822)");if(t<0)throw new Error("secondsValid must be positive (E: bbe3b6d567583bfb35a1c0825eb29622)");let s,i=Tn({space:r,scope:e}),a,c=await re({addr:i,space:r,force:!0});if(c.success&&c.ibGibs?.length===1?(a=c.ibGibs[0],a?.data?.expirationUTC?Ko({expirationTimestampUTC:a.data.expirationUTC})&&(console.warn(`${n} ignoring expired existing lock in space at ${i}. Should be overwritten (W: 7421c5b051724b189f88cecbbd449b22)`),a=void 0):(console.error(`${n} (UNEXPECTED) exisingLock.data.expirationUTC falsy? (E: 218dc0e935534a149d0be153c532cf25)`),a=void 0)):S&&console.log(`${n} existing lock not found for ${i} (I: 191af56ec4e2db3d19084e46bf949222)`),a){if(!a.data)throw new Error("(UNEXPECTED) existingLock.data falsy? (E: 00069b4662e5566d971760d15e293723)");s=C(a),s.data.alreadyLocked=!0,s.data.success=!1}else{let{ib:l,gib:d}=R({ibGibAddr:i});s={ib:l,gib:d,data:{scope:e,secondsValid:t,instanceId:o,expirationUTC:Ho({seconds:t})}};let b=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"put",force:!0,ibGibAddrs:[i]},ibGibs:[s]}),u=await r.witness(b);if(u.data?.success)if((u.data.addrsAlreadyHave??[]).includes(i)){S&&console.log(`${n} racelost! addrsAlreadyHave includes spaceLockAddr (${i}) (I: 2e8a1562947c40698110b64251141753)`);let p=await re({addr:i,space:r,force:!0});if(p.success&&p.ibGibs?.length===1){let h=p.ibGibs[0];s=C(h),s.data.alreadyLocked=!0,s.data.success=!1}else{let h=`${n} (UNEXPECTED) addrsAlreadyHave true, but couldn't get lock? (E: 8374a2b6628b49369363bc5843105763)`;console.error(h),s.data.success=!1,s.data.errorMsg=h}}else s.data.success=!0;else{let p=`${n} there was an error putting the lock in the space: ${u.data?.errors?.join("|")}`;s.data.success=!1,s.data.errorMsg=p,console.error(p)}}return s}catch(s){throw console.error(`${n} ${s.message}`),s}finally{S&&console.log(`${n} complete.`)}}f(Oi,"lockSpace");async function Ni({space:r,scope:e,instanceId:t}){let o=`[${Ni.name}]`;try{if(S&&console.log(`${o} starting...`),!r)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");let n=Tn({space:r,scope:e}),s=await In({addr:n,space:r,force:!0});if(s.success){let{ib:i,gib:a}=R({ibGibAddr:n});return{ib:i,gib:a,data:{success:!0,instanceId:t,scope:e}}}else{let i=`Delete lock in space failed. delete errorMsg: ${s.errorMsg}`;if(i.includes("not implemented"))throw new Error(i);if(i.toLowerCase().includes("does not exist")||i.toLowerCase().includes("doesn't exist")||i.toLowerCase().includes("not found")){S&&console.log(`${o} ${i} (I: b647916fd0f3e5366e9387131be21c22)`);let{ib:a,gib:c}=R({ibGibAddr:n});return{ib:a,gib:c,data:{action:"unlock",success:!0,instanceId:t,scope:e}}}else console.warn(`${o} ${i} (W: 14c84fcac15944bd9a417099964d5d9d)`)}}catch(n){throw console.error(`${o} ${n.message}`),n}finally{S&&console.log(`${o} complete.`)}}f(Ni,"unlockSpace");async function ul({space:r,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:o}){let n=`[${ul.name}]`;try{if(S&&console.log(`${n} starting...`),!r)throw new Error("space required. (E: 6fc19548fa7d1d5219e19871f280a322)");if(!r.data?.uuid)throw new Error("space.data.uuid required (E: 6483188ca6f2ed2085fd355595f3ab22)");if(!e)throw new Error("zeroSpace required. (E: abbf156e18b1018d96273e22a260f122)");let s=r.data.uuid,i=I({ibGib:r}),a=await nr({zeroSpace:e});if(a){if(S&&console.log(`${n} updating existing bootstrap (I: 977d4aa7ed47bef73b35743c05ce0722)`),a.data.spaceIds.includes(s)){S&&console.log(`${n} space already rel8d to bootstrap, possibly updating its addr (I: b5e2c515ef732d4bbcf02625a9e7c722)`);let c=a.rel8ns[s][0];c===i?S&&console.log(`${n} bootstrap already rel8d to space (I: c1be027b23e7350c64790a631cae2822)`):(S&&console.log(`${n} updating rel8ns[${s}] with newSpaceAddr (${i}). (Old address: ${c})(I: 297a9b0061fd471b8d28a06e04a6ad22)`),a.rel8ns[s]=[i])}else S&&console.log(`${n} new space being rel8d. adding spaceId to data.spaceIds and amending rel8ns (I: 40903d71719aa1d56e498299f5699a22)`),a.data.spaceIds.push(s),a.rel8ns[s]=[i];t&&(S&&console.log(`${n} setting spaceId (${s}) as default space (I: f85eda6c6ad2b0bec9750ce3c7795b22)`),a.data[De]=s)}else{if(!o){S&&console.log(`${n} bootstrapIbGib not found but createIfNotFound falsy, so returning early. (I: 5c67d85a8599a5ba4a6780f26a66ea22)`);return}S&&console.log(`${n} creating new bootstrap ibgib for spaceId (${s}) with address of (${i}) (I: 651959c27bf2ebc5be1f7f44e2b9e422)`);let{ib:c,gib:l}=R({ibGibAddr:ot});a=M.primitive({ib:c}),a.gib=l,a.data={[De]:s,[Lr]:[s]},a.rel8ns={[s]:[i]}}if(!a)throw new Error("(UNEXPECTED) bootstrapIbGib still falsy? (E: cf21d7f1756710a66aa0e6a28d762723)");S&&console.log(`${n} saving bootstrapIbGib: ${H(a)} (I: 3cceca0b98dde90e4a58a734be252322)`),await An({zeroSpace:e,bootstrapIbGib:a}),S&&console.log(`${n} complete.`)}catch(s){throw console.error(`${n} ${s.message}`),s}}f(ul,"updateBootstrapIbGib");async function An({zeroSpace:r,bootstrapIbGib:e}){let t=`[${An.name}]`;if(!r)throw new Error("zeroSpace required. (E: 818fa8430b8040dca1917f9db0972b22)");if(!e)throw new Error("bootstrapIbGib required. (E: cf21d7f1756710a66aa0e6a28d762723)");let o=await r.argy({ibMetadata:e.ib,argData:{cmd:"put",force:!0,ibGibAddrs:[I({ibGib:e})]},ibGibs:[e]});S&&console.log(`${t} zeroSpace will witness/put... (I: 1be9aca22ffc4951b6690965a7aeae5b)`);let n=await r.witness(o);if(n?.data?.success)S&&console.log(`${t} zero space put complete. (I: ac3056d655e841f1a3c442bcc64942f9)`);else throw new Error(`${n?.data?.errors?.join("|")||"There was a problem with zeroSpace witnessing the bootstrap^gib primitive."}`)}f(An,"persistBootstrapIbGibInZeroSpace");async function pl({spaceId:r,zeroSpace:e}){let t=`[${pl.name}]`;if(!r)throw new Error("spaceId required. (E: 52f9c31405e24c2999e5a1b32d201a23)");if(!e)throw new Error("zeroSpace required. (E: a115f4007b2c4819a58cf093d5823b23)");await Ne({space:e,scope:ot,fn:f(async()=>{let n=await nr({zeroSpace:e});if(!n)throw new Error("bootstrapIbGib falsy in zeroSpace (E: e36a512781b0467ba1bf1d927a7c1d23)");if(!n.data)throw new Error("bootstrapIbGib.data falsy in zeroSpace (E: 8f92104192b44d71891b092481029ab0)");let s=n.data,i=s[Lr]??[];if(i.length<=1)throw new Error(`Cannot delete space (${r}). It is the only remaining local space. (E: 9c27f71120014b08b5e9f89993380e23)`);if(r===s[De])throw new Error(`Cannot delete space (${r}). It is the default local space. Please select a new default space before deleting. (E: f3c30a5170d14b4fb2478d102e3b2e23)`);if(!i.includes(r))throw new Error(`Space (${r}) not found in bootstrap spaceIds. (E: 61fa940e79124430a618e470bc551d23)`);s[Lr]=i.filter(a=>a!==r),n.rel8ns&&delete n.rel8ns[r],await An({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:Or})}f(pl,"deregisterLocalSpaceFromBootstrap");async function hl({spaceId:r,zeroSpace:e}){let t=`[${hl.name}]`;if(!r)throw new Error("spaceId required. (E: 7c2a10529a1b412a8069e22e5190b623)");if(!e)throw new Error("zeroSpace required. (E: f112a512019c41a590b512a8e0915623)");let o=await e.argy({ibMetadata:Ce({space:e}),argData:{cmd:"get",ibGibAddrs:[r]}}),n=await e.witness(o);if(n?.data?.success&&(n.ibGibs?.length??0)>0){let s=I({ibGib:n.ibGibs[0]}),i=await e.argy({ibMetadata:Ce({space:e}),argData:{cmd:"delete",ibGibAddrs:[s]}});await e.witness(i)}}f(hl,"deleteSpaceRecordFromZeroSpace");function Ce({space:r}){return`${r.ib} ${$e()}`}f(Ce,"getSpaceArgMetadata");function ch({space:r}){return`${r.ib} ${$e()}`}f(ch,"getSpaceResultMetadata");function gl({space:r,spaceData:e,classname:t}){let o=`[${gl.name}]`;try{if(!r&&!e)throw new Error("either space or spaceData required (E: 4dabec34ee77d67c9cc30ee3c3049622)");if(r&&!r.data)throw new Error("(UNEXPECTED) given space has falsy space.data? (E: 058d298876ebbeada7bbddb9e3da2f23)");if(r&&e){if(r.data.uuid!==e.uuid)throw new Error("(UNEXPECTED) both space and spaceData given, but uuid don't match? (E: efdd4603cba93a17340a76811fe56b24)");if(r.data.n!==e.n)throw new Error("(UNEXPECTED) both space and spaceData given, but n don't match? (E: e51278a707c9bccc57a08a4b86524524)")}if(e??=r.data,!e)throw new Error("(UNEXPECTED) spaceData falsy? (thought this was a compiler problem that this was even possible.) (E: b3c7ffedcae4b1f45b263b3825930b24)");if(t&&e.classname&&t!==e.classname)throw new Error(`both classname arg (${t}) and spaceData.classname (${e.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);if(t||=e.classname,!t)throw new Error("classname required (E: fa3af4613ad56742dab51d1b0d839322)");if(t.includes(" "))throw new Error(`invalid classname (${t}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`);let n=e?.name||Ms;if(n.includes(" "))throw new Error("invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)");let s=e?.uuid||void 0;if(!s)throw new Error("invalid space, spaceData.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)");if(s.includes(" "))throw new Error("invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)");let i=e.type??void 0,a=e.subtype??void 0;if(i&&!a)throw new Error(`spaceType (${i}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);return`${qr} ${Dr} ${t} ${n} ${s} ${i} ${a}`}catch(n){throw console.error(`${o} ${n.message}`),n}}f(gl,"getSpaceIb");function ml({ib:r}){let e=`[${ml.name}]`;if(!r){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return r.startsWith(`${qr} ${Dr} `)}f(ml,"isSpaceIb");function Yr({spaceIb:r}){let e=`[${Yr.name}]`;try{if(!r)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,o,n,s,i,a,c]=r.split(" ");if(t!==qr)throw new Error(`invalid spaceIb (${r}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(o!==Dr)throw new Error(`invalid spaceIb (${r}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`);if(!n)throw new Error(`invalid spaceIb (${r}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`);if(!s)throw new Error(`invalid spaceIb (${r}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`);if(!i)throw new Error(`invalid spaceIb (${r}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`);let l;if(a&&a!=="undefined")if(fn.includes(a))l=a;else throw new Error(`invalid spaceIb (${r}). spaceType (${a}) is set but not a valid type. valid types: ${fn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(bn.includes(c))d=c;else throw new Error(`invalid spaceIb (${r}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${bn.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:s,spaceId:i,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Yr,"parseSpaceIb");async function ge({ibGibs:r,addrs:e,tjps:t,tjpAddrs:o,space:n}){let s=`[${ge.name}]`;try{if(S&&console.log(`${s} starting...`),!n)throw new Error("space required. (E: 4d188d6c863246f28aa575753a052304)");if(r=r??[],e=e??[],t=t??[],o=o??[],e.length===0&&r.length===0&&t.length===0&&o.length===0)throw new Error("Either addrs, ibGibs, tjps, or tjpAddrs required. (E: 7c6ebfbab98d4d21a431b144457fd991)");let i=new Set(o.concat(t.map(l=>I({ibGib:l})))),a=Array.from(i).map(l=>R({ibGibAddr:l}).gib);r.map(l=>I({ibGib:l})).concat(e).forEach(l=>{let{gib:d}=R({ibGibAddr:l});a.some(u=>d.includes(u))||i.add(l)}),S&&console.log(`${s}[testing] ${n.data?.name||n.ib} (${n.data?.uuid||"[space.data.uuid falsy]"}) addrsToQuery: ${Array.from(i)} (I: 8a2202912c364238b6d6eb09577bc246)`);let c=await n.argy({ibMetadata:Ce({space:n}),argData:{cmd:"get",cmdModifiers:["latest","addrs"],ibGibAddrs:Array.from(i)}});return await n.witness(c)}catch(i){throw console.error(`${s} ${i.message}`),i}}f(ge,"getLatestAddrs");function Sn({ibGib_Context:r}){let e=`[${Sn.name}]`;try{if(S&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!sr({ibGib:r}))return;if(["roots","autosyncs"].some(o=>r.ib.includes(o)))throw new Error("cannot perform a modification of this type on this special ibgib (E: b8fb718a7323fc54454464b973412722)")}catch(t){throw console.error(`${e} ${t.message}`),t}finally{S&&console.log(`${e} complete.`)}}f(Sn,"throwIfContextIsSpecial");async function El({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${El.name}]`;try{if(S&&console.log(`${a} starting... (I: 2dc486bb2d516e4534f437aaf5ec7f22)`),!r)throw new Error("ibGib_Context required (E: 75f7bfa93145d6dffe85d488443ca722)");if(!e)throw new Error("rel8nName_Context required (E: 12aaa43de9e34b68b25dc9a2a68ad6b9)");if(!t)throw new Error("addr required (E: e27df3bdc5a2554697cc9597afc4e422)");if(!o)throw new Error("space required (E: 2e3562486ed2956a770ed9e8d77a3f22)");let c=sr({ibGib:r});c&&Sn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Vs]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),b=Wr({ib:r.ib}),u=ae({type:b});await be({key:u,addr:d,space:o,zeroSpace:n,fnUpdateBootstrap:s})}await Ge({ibGib:l.newIbGib,fnBroadcast:i,space:o})}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(El,"trash");async function wl({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${wl.name}]`;try{if(S&&console.log(`${a} starting... (I: 38098552b830495187299bb24fcddff0)`),!r)throw new Error("ibGib_Context required (E: d819e8c4db5b4c0bb721300ba434cd40)");if(!e)throw new Error("rel8nName_Context required (E: de061adff8c04429a211aa09116a532d)");if(!t)throw new Error("addr required (E: 7059ebb8ef6149ea94e22f961d6b5c81)");if(!o)throw new Error("space required (E: e19566f2d42347798621447edcae312e)");let c=sr({ibGib:r});c&&Sn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Ks]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),b=Wr({ib:r.ib}),u=ae({type:b});await be({key:u,addr:d,space:o,zeroSpace:n,fnUpdateBootstrap:s})}await Ge({ibGib:l.newIbGib,fnBroadcast:i,space:o})}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(wl,"archive");function $l(r){let e=`[${$l.name}]`;try{if(!r)return console.error(`${e} name is falsy`),!1;let t=/[\w-]+/,o=r.match(t);if(o?.length!==1||o[0].length!==r.length)return console.error(`${e} name can only contain letters, numbers, underscores, hyphens`),!1;let n=/[a-zA-Z\d]/;return r[0].match(n)?!0:(console.error(`${e} name must start with a letter or number`),!1)}catch(t){return console.error(`${e} ${t.message}`),!1}}f($l,"spaceNameIsValid");var K=!1;function _h(r,e){return typeof r=="object"&&r!==null?`v:1^spaceId:${r.spaceId}^${r.ibGibAddr}`:`v:1^spaceId:${r}^${e}`}f(_h,"getSpaceQualifiedIbGibAddr");function Ci(r){try{if(typeof r!="string"||!r.match(Cr))return!1;let t=zr({sqAddr:r});return!0}catch{return!1}}f(Ci,"isSpaceQualifiedAddr");function zr({sqAddr:r}){let e=`[${zr.name}]`;if(!r)throw new Error(`${e} sqAddr falsy (E: 3c7af8b05a68272478e830c89b617d26)`);if(typeof r!="string")throw new Error(`(UNEXPECTED) ${e} sqAddr not a string? (E: 172fd36b0e7d02905263bdef1374da26)`);let t=r.match(Cr);if(!t)throw new Error(`${e} invalid sqAddr (${r}). does not match SQ Addr regexp: ${Cr.source} (E: 71c93b63d4a82970c3bada8d92d4f826)`);let o=t[1],n=parseInt(o,10),s=t[2],i=t[3],a=qe({addr:i})??[];if(a.length>0)throw new Error(`${e} invalid sqAddr. ibGibAddr part is not a valid ibGibAddr. errors: ${a.join(",")} (E: 8e105870eb58c78978169d1d7b275526)`);let{ib:c,gib:l}=R({ibGibAddr:i});return{version:n,spaceId:s,ibGibAddr:i,ib:c,gib:l}}f(zr,"parseSpaceQualifiedIbGibAddr");async function yl({ibGib:r,rel8nNames:e,space:t}){let o=`[${yl.name}]`;try{if(!r)throw new Error("ibGib required (E: 9764881f4c59113a98faabb87aba5826)");if(!t)throw new Error("space required (E: ee110894949865a8a9075938471e1826)");e||(e=Object.keys(r.rel8ns||{}));let n={};for(let s of e){let i=r.rel8ns?.[s]||[];if(i.length>0){let a=await re({addrs:i,space:t});if(a.success&&a.ibGibs?.length===i.length)n[s]=a.ibGibs.concat();else throw new Error(`Problem getting rel8d ibgibs for rel8nName: ${s}. ${a.errorMsg||"Unknown error"} (E: 372b27ed859ca276fe132e7cd3cd1826)`)}else n[s]=[]}return n}catch(n){throw console.error(`${o} ${E(n)}`),n}}f(yl,"getRel8dIbGibs");async function Oe({parentPrimitiveIb:r,ib:e,ibRegExpPattern:t,data:o,rel8ns:n}){let s=`[${Oe.name}]`;try{if(!r)throw new Error("parentPrimitiveIb required. (E: 88ddf188cc5a4340b597abefba1481e2)");if(rt({ib:r})!==null)throw new Error(`Invalid parentPrimitiveIb: ${r}. (E:5aec0320956d492ebeeaca41eb1fe1c6)`);if(!e)throw new Error("ib required. (E: 7bbc88f4f2e842d6b00126e55b1783e4)");let i=t?new RegExp(t):Rs;if(!e.match(i))throw new Error(`invalid ib. does not match regexp (${i})`);let a=Object.keys(n??{}),c=[...et,"tjp"];if(a.some(u=>c.includes(u)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let b=(await M.firstGen({ib:e,parentIbGib:M.primitive({ib:r}),data:o,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return b?.rel8ns?.past&&delete b.rel8ns.past,b?.rel8ns?.tjp&&delete b.rel8ns.tjp,b?.rel8ns?.identity&&delete b.rel8ns.identity,b.gib=await X({ibGib:{ib:b.ib,data:b.data,rel8ns:b.rel8ns},hasTjp:!1}),b}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Oe,"constantIbGib");function Th({binHash:r,binExt:e,binEncoding:t}){return t?e?`bin ${r} ${e} enc=${t}`:`bin ${r} enc=${t}`:e?`bin ${r} ${e}`:`bin ${r}`}f(Th,"getBinIb");function Ah({addr:r}){return Pi({addr:r})}f(Ah,"getBinHashAndExt");function Pi({addr:r}){let e=`[${Pi.name}]`;try{if(!rr({addr:r}))throw new Error("not a bin address (E: df0804d129bc4888bd6939cb76c5e0f6)");let{ib:t}=R({ibGibAddr:r}),o=t.split(" ");if(o.length===2)return{binHash:o[1],binExt:""};if(o.length===3)return o[2].startsWith("enc=")?{binHash:o[1],binExt:"",binEncoding:o[2].substring(4)}:{binHash:o[1],binExt:o[2]};if(o.length===4){if(!o[3].startsWith("enc="))throw new Error(`bin ib (${t}) has 4 space-delimited pieces. we expect therefore the form to be bin \${binHash} \${binExt} enc=\${binEncoding}. but ibPieces[3] doesn't start with "enc=". (E: 87196d7cdd7c12d982cc8204a1163524)`);return{binHash:o[1],binExt:o[2],binEncoding:o[3].substring(4)}}else throw new Error('(UNEXPECTED) ibPieces.length not 2, 3, or 4? atow (01/2024) the only components of a bin ib are: atom, binHash, binExt, binEncoding. binExt and binEncoding are optional, with binEncoding being prefixed with "enc=". (E: b05df3c1b3949f76464a83c9fd1c4f24)')}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Pi,"parseBinIb");function rr({ibGib:r,addr:e}){let t=`[${rr.name}]`;try{if(!r&&!e)throw new Error("either ibGib or addr required. (E: c935b51e773f41a2a547c556e9dc16c6)");if(r&&!r.data)return!1;e=e||I({ibGib:r});let{ib:o,gib:n}=R({ibGibAddr:e});if(!o||!n||!o.startsWith("bin "))return!1;if(n.length!==64)throw new Error('ib starts with "bin " but gib length is not 64, so return false. Two things: 1) bin ibgibs are expected to be stones, i.e., have no temporal junction point and only a single punctiliar hash for the gib. the default hash used atow (01/2024) is sha-256, so the length should be 64. But this may not be true if using another hash algorithm. need to change this function when this becomes the case. (W: 60725d65d13c4b4fbb7b96d7feb19d67)');let s=o.split(" ");if(s.length===2){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: f6baca2ff155f1017b278a5d7597a224)')}else if(s.length===3){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 8d0443d6cada4b50be79a8390a7a426c)')}else if(s.length===4){if(!s[1].match(oe))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 3209eacc0a3848a59593d4c3ee956191)');if(!s[3].startsWith("enc="))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[3].startsWith("enc=")? (E: 4c8a0c3b07a90d30e3d1a4373d57d824)')}else throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited ibPieces length is not 2, 3 or 4? (E: c7eccf88518304997c7e42b32e08d224)');return!0}catch(o){throw console.error(`${t} ${o.message}`),o}}f(rr,"isBinary");function Gn({type:r}){if(!r.match(rn))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${rn.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${r}`}f(Gn,"getSpecialIbGibIb");function Wr({ib:r}){let e=`[${Wr.name}]`;try{if(K&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!r)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!sr({ib:r}))throw new Error("ib is not special (E: 174aff63b992adff3ac2394643735922)");let t=r.split(" ");if(t.length<3)throw new Error('invalid ib. should be space-delimited in form of "meta special [type]" (E: ffd89e2cbe63427f98634ab897aab222)');let o=t[2];return Object.values(vr).some(n=>n===o)||console.warn(`unknown special type (${o}). This may be expected, but atow I am adding special types to the SpecialIbGibType enum-like. (W: f4e26c3ebb57fe49d69014a4ba32a922)`),o}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(Wr,"getSpecialTypeFromIb");function Il({type:r}){return`${Gn({type:r})}^${U}`}f(Il,"getSpecialIbGibAddr");function ae({type:r}){return`${Ys} ${Il({type:r})}`}f(ae,"getSpecialConfigKey");function sr({ib:r,ibGib:e}){if(!r&&!e?.ib)throw new Error("either ib or ibGib.ib required (E: b4cf539638d7966c2e351987f55e1a23)");return(r??e?.ib)?.startsWith("meta special")}f(sr,"isSpecial");function xn(r){let e=`[${xn.name}]`;if(!r)throw new Error(`${e} text required.`);return`root ${r}`}f(xn,"getRootIb");function wt(r){let e=`[${wt.name}]`;if(!r)throw new Error(`${e} tag required.`);return`tag ${r}`}f(wt,"tagTextToIb");function Jr({ibGibs:r,filterPrimitives:e}){let t=`[${Jr.name}]`;try{let o={},n={},s={};return(e?r.filter(a=>a.gib??a.gib!==U):r).forEach(a=>{Li({ibGib:a})?(a.rel8ns?.dna??[]).length>0?o[a.gib]=a:n[a.gib]=a:s[a.gib]=a}),{mapWithTjp_YesDna:o,mapWithTjp_NoDna:n,mapWithoutTjps:s}}catch(o){throw console.error(`${t} ${o.message}`),o}}f(Jr,"splitPerTjpAndOrDna");function ir({ibGibs:r}){let e=`[${ir.name}]`;try{K&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:o}=Jr({ibGibs:r,filterPrimitives:!0}),n={...t,...o},s=Object.values(n),i=qo({items:s,keyFn:f(a=>a.data?.isTjp?I({ibGib:a}):a.rel8ns?.tjp?a.rel8ns?.tjp[0]??"":(K&&console.log(`${e} neither isTjp nor x.rel8ns.tjp truthy (I: ec9a5597bf53dec1bd3d83350abbf823)`),""),"keyFn")});return K&&console.log(`${e} sorting (ascending) ibGibsWithTjpGroupedByTjpAddr: ${H(i)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),Object.entries(i).forEach(([a,c])=>{c.some(l=>l.data?.n===void 0)&&console.warn(`${e} timeline includes ibgibs with ibGib.data?.n === undefined (W: cab9a6b64a38c4279fe82c3569bbab22)`),c.sort((l,d)=>(l.data?.n??-1)>(d.data?.n??-1)?1:-1)}),K&&console.log(`${e} after sort ibGibsWithTjpGroupedByTjpAddr: ${H(i)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),i}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(ir,"getTimelinesGroupedByTjp");function Li({ibGib:r}){let e=`[${Li.name}]`;if(!r)throw new Error("(UNEXPECTED) ibGib falsy? (E: ce3a59f9db14e6158bb2c438ca1a3823)");if((r.rel8ns?.tjp?.length??0)>0||r.data?.isTjp)return!0;let t=["fork^gib","mut8^gib","rel8^gib"];return(r.rel8ns?.ancestor??[]).some(n=>t.includes(n))?!1:r.gib?r.gib.includes(Ue)?!0:r.gib===U?!1:!!se({ibGibAddr:I({ibGib:r})}).tjpGib:(console.warn(`${e} ibGib.gib falsy. (W: 6400d780822b44d992846f1196509be3)`),!1)}f(Li,"hasTjp");function fe({ibGib:r,defaultIfNone:e="undefined"}){let t=`[${fe.name}]`;try{let o=Ri({ibGibs:[r],defaultIfNone:e});return o&&Object.keys(o).length===1?Object.values(o)[0]:void 0}catch(o){throw console.error(`${t} ${o.message}`),o}}f(fe,"getTjpAddr");function Ri({ibGibs:r,defaultIfNone:e="undefined"}){let t=`[${Ri.name}]`;try{let o={};return r.forEach(n=>{let s=I({ibGib:n}),i;n.rel8ns?.tjp?.length??!1?i=n.rel8ns.tjp[n.rel8ns.tjp.length-1]:n.data?.isTjp||e==="incomingAddr"?i=s:i=void 0,o[s]=i}),o}catch(o){throw console.error(`${t} ${o.message}`),o}}f(Ri,"getTjpAddrs");async function vn({ibGib:r,naive:e=!0}){let t=`[${vn.name}]`;try{if(!r)throw new Error("ibGib required.");if(e){if(r.data)return r.data.isTjp?!0:r.rel8ns?r.rel8ns.past&&r.rel8ns.past.length>0?!1:!!(r.rel8ns.past&&r.rel8ns.past.length===0):(K&&console.log(`${t} ibGib.rel8ns falsy (I: c69c9e78b34845311ce7c674d7195622)`),!1);throw new Error("loaded ibGib required (data).")}else throw new Error("only naive implemented right now.")}catch(o){throw console.error(`${t} ${o.message}`),o}}f(vn,"isTjp_Naive");function ve({ibGib:r}){let e=`[${ve.name}]`;r.ib||console.warn(`${e} ibGib.ib is falsy. (W: e60e41c2a1fc48268379d88ce13cb77b)`),r.gib||console.warn(`${e} ibGib.gib is falsy. (W: fb3889cbf0684ae4ac51e48f28570377)`);let t={ib:(r.ib||"").slice()};return r.gib&&(t.gib=r.gib.slice()),r.data&&(rr({ibGib:r})?t.data=r.data.slice():t.data=C(r.data)),r.rel8ns&&(t.rel8ns=C(r.rel8ns)),t}f(ve,"toDto");function Dn(r){let e=`[${Dn.name}]`;try{return K&&console.log(`${e} starting... (I: 57aef93fc6cc2309523b5c72a6b11823)`),!!r&&typeof r.ib=="string"}catch(t){throw console.error(`${e} ${t.message}`),t}finally{K&&console.log(`${e} complete.`)}}f(Dn,"isIbGib");function tr({ibGib:r,data:e,timestamp:t}){let o=`[${tr.name}]`;try{K&&console.log(`${o} starting... (I: 35cb68744bcf6139d78e37de644fad23)`),t=t||e?.timestamp||r?.data?.timestamp;let n=r?.data?.timestampMs||e?.timestampMs;if(!t){let s=`${o} timestamp is falsy. (W: 5f1f1182c8804807b886a3d922ac3dcf)`;return console.warn(s),{valid:!1,emsg:s}}if(typeof t=="string")if(Number.isInteger(Number.parseInt(t))){let s=Number.parseInt(t),i=new Date;if(i.setTime(s),i.toString()!==Nr)return K&&console.log(`${o} valid timestampInTicks string (I: 7069a1c3047f3bbc92b78674b20f5b23)`),{valid:!0,date:i,utc:i.toUTCString(),ticks:i.getTime().toString(),ms:n};{let a=`${o} data.timestamp (${t}) is an integer string but not a valid timestampInTicks string. (produces invalid date) (E: f49fbb600fe1426c8805dfc8afbe5cf3)`;return console.error(a),{valid:!1,emsg:a}}}else{let s=new Date(t);if(s.toString()!==Nr)return{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${o} data.timestamp is a non-integer string but not a valid date timestamp string (new date instantiated produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(i),{valid:!1,emsg:i}}}else if(typeof t=="number")if(Number.isInteger(t)){console.warn(`${o} expected data.timestamp to be a string but is a number (W: 9d786f4d4e8d4279b5af7bee19bf721b)`);let s=new Date;if(s.setTime(t),s.toString()!==Nr)return{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${o} timestamp (${t}) is an integer number but not a valid timestampInTicks (new date setTime produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(i),{valid:!1,emsg:i}}}else{let s=`${o} timestamp (${t}) is a non-integer number (supposed to be a string either timestamp string or ticks). (E: 2963d95f8d3b464c992b0bff948b4479)`;return console.error(s),{valid:!1,emsg:s}}else{let s=`${o} unknown typeof timestamp (${typeof t}). (E: 12458a9c16c84e4f859b5771a30dd2ef)`;return console.error(s),{valid:!1,emsg:s}}}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(tr,"getTimestampInfo");async function On({addrs:r,readCache_graph:e,readCache_array:t,space:o}){let n=`[${On.name}]`;try{K&&console.log(`${n} starting... (I: 5db66871239dfa05182277f886a20926)`),e??={},t??=[];let s={...e};t.forEach(l=>s[I({ibGib:l})]=l);let i=Object.keys(e),a=r.filter(l=>!i.includes(l));if(a.length>0){K&&console.log(`${n} ${a.length} addrsNotFoundInCache: ${a} (I: fccbd18116ffb849f813aaebfc6c0826)`);let l=[o],d=a.concat();for(let b of l){let u=await re({addrs:d,space:b});if(u.success&&u.ibGibs&&u.ibGibs.length===d.length)u.ibGibs.forEach(p=>s[I({ibGib:p})]=p),d=[];else if(u.ibGibs&&u.ibGibs.length>0){if(d=d.filter(p=>!u.ibGibs.some(h=>I({ibGib:h})===p)),d.length===0)break}else K&&console.log(`${n} no addrs found in space (${b.ib}). trying next space. (I: 4f99d8bacbb10ab3f8737a752564b326)`)}if(d.length>0)throw new Error(`could not get all addrs from cache or spaces. addrsStillNotFound: ${d}. spaces: ${l.map(b=>b.ib).join("|")} (E: 0c6418f83dd85bda886e56f5b98f3126)`)}let c=[];for(let l of r){let d=s[l];if(!d)throw new Error(`(UNEXPECTED) allIbGibs_graph doesn't have addr? We're expecting logic to preclude this at this point. addr: ${l} (E: f68e1d236ae5e3eb08da9933c8230626)`);c.push(d)}return c}catch(s){throw console.error(`${n} ${E(s)}`),s}finally{K&&console.log(`${n} complete.`)}}f(On,"getIbGibsFromCache_fallbackToSpaces");async function Zr({addr:r,space:e,metaspace:t}){let o=`[${Zr.name}]`;try{if(K&&console.log(`${o} starting... (I: 9252059c96132637381b3be5486e6826)`),!r)throw new Error("(UNEXPECTED) addr falsy? (E: aeb9084d7f68dabb8a49fd68526ff826)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 3ec9df4de82847e13f087bea6f98b826)");let n=Ci(r)?zr({sqAddr:r}).ibGibAddr:r,s=qe({addr:n})??[];if(s.length>0)throw new Error(`invalid incoming addr (${r}). (if space-qualified, then invalid extracted ibGibAddr). errors: ${s.join(", ")} (E: 040dbbcac39990abc8871a1d08b3d826)`);let i;try{let a=await re({space:e,addrs:[n]});if(!a.success||a.errorMsg)throw new Error(`resGet failed. resGet.success: ${a.success}.errorMsg: ${a.errorMsg} (E: 13f3d82381b87f8078583ad8b3676826)`);if(!a.ibGibs)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs falsy? (E: f3a75e6fe96b07d288ba9b3976e84826)");if(a.ibGibs.length===0)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs empty? (E: 4a06589d30050208284fef68adf20426)");if(a.ibGibs.length>1)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs.length > 1? what in the world? (E: a4d01caa4a78a0a1581b3bb8748af826)");i=a.ibGibs[0]}catch(a){K&&console.log(`${o} suppressing error: ${E(a)} (I: 1256ce73d8e8b567ff4fee4ea48c5d26)`)}return i}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(Zr,"getIbGibFromSpace");async function Ui({addrs:r,space:e}){let t=`[${Ui.name}]`;try{if(K&&console.log(`${t} starting... (I: 648eb9b61718fbc1684aabc60cba6826)`),!r)throw new Error("(UNEXPECTED) addrs falsy? (E: 258e489345f1c4b5794e4618f4118c26)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 9cb95bc39b41c1756c6e85384f766a26)");if(r.length===0)return[];let o=r.map(a=>Ci(a)?zr({sqAddr:a}).ibGibAddr:a);for(let a of o){let c=qe({addr:a})??[];if(c.length>0)throw new Error(`invalid incoming addr (${a}). errors: ${c.join(", ")} (E: 1674df15579c46cecd035ff637f41426)`)}let n=await re({space:e,addrs:o});if(!n.success||n.errorMsg)throw new Error(`resGet failed. resGet.success: ${n.success}. errorMsg: ${n.errorMsg} (E: 1a4c08eabeb957f388a79d7b42b60b26)`);if(!n.ibGibs||n.ibGibs.length!==o.length){let c=n.rawResultIbGib?.data?.addrsNotFound??"unknown";throw new Error(`couldn't find all addrs. addrsNotFound: ${c}? resGet.errorMsg: ${n.errorMsg} (E: 5ee272792fe8af335a8fd918c0971a26)`)}let s=new Map;for(let a of n.ibGibs||[]){let c=I({ibGib:a});s.set(c,a)}let i=[];for(let a of o){let c=s.get(a);c&&i.push(c)}return i}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Ui,"getIbGibsFromSpace");async function _l({ibGib:r,space:e}){let t=`[${_l.name}]`;try{K&&console.log(`${t} starting... (I: 64f6a8bd1248f8c3c8c86834431adb26)`);let o=I({ibGib:r}),n=fe({ibGib:r,defaultIfNone:"undefined"});if(!n)return K&&console.log(`${t} tjpAddr falsy. returning incoming ibGib (no timeline means no latest tip possible) (I: 621528e00b6988f0abb8a161e7042226)`),r;let s=await ge({ibGibs:[r],space:e});if(!s)throw new Error("(UNEXPECTED) resLatest falsy? (E: 8ce878315ec4020c082ee7796084b826)");if(!s.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: 3af5a84dd1eba399fcca51e179b36826)");if(!s.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest.data.latestAddrsMap falsy? (E: 37276c35ae58f65cb674389343c2fc26)");let{latestAddrsMap:i}=s.data,a=i[o]??i[n]??o;if(a&&a!==o){let c=await Zr({addr:a,space:e});if(c&&(c.data?.n??0)>=(r.data?.n??0))return c;console.warn(`${t} did not find latest. using incoming ibGib (W: 1079fd20b9183fc8a8fef55a8ad2d826)`)}return r}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(_l,"resolveLatestIbGibInSpace");async function Tl({ibGibs:r,space:e}){let t=`[${Tl.name}]`;try{if(K&&console.log(`${t} starting... (I: 8b0c418702fb42a6a12ee0153833f426)`),!e)throw new Error("space required. (E: b65c19273c524e9389271630af220926)");if(!r||r.length===0)return[];let o=[],n=[],s=[];for(let u of r){let p=I({ibGib:u}),h=fe({ibGib:u,defaultIfNone:"undefined"});n.push(p),s.push(h||""),h&&o.push(u)}if(o.length===0)return r;let i=await ge({ibGibs:o,space:e});if(!i||!i.data||!i.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest or latestAddrsMap falsy? (E: a951d3820ff541c88ba46f7725902126)");let{latestAddrsMap:a}=i.data,c=[],l=[];for(let u=0;u<r.length;u++){let p=n[u],h=s[u],g=a[p]??a[h]??p;l.push(g),g&&g!==p&&c.push(g)}let d=new Map;if(c.length>0){let u=Array.from(new Set(c)),p=await Ui({addrs:u,space:e});for(let h of p){let g=I({ibGib:h});d.set(g,h)}}let b=[];for(let u=0;u<r.length;u++){let p=r[u],h=l[u];if(h&&h!==n[u]){let g=d.get(h);if(g&&(g.data?.n??0)>=(p.data?.n??0)){b.push(g);continue}}b.push(p)}return b}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Tl,"resolveLatestIbGibsInSpace");var Mi=!1,Al="space_gib_db",Sl="space_gib_store",Gl="space_gib_api_key";var xl="agent";var Dh=wt(xl);var Oh={dbName:Al,storeName:Sl,additionalStoreNames:[Us],apiKeyName:Gl};var ki="0.0.30";var at=!1,Lh="[web^gib timer]",Qr="ibgib";var vl="agent",Rh="body-outline",Uh="This tag tracks the active agents for the current local user space.",Mh=wt(vl),ji="#78f87e88",Bi="#78f87e10",Fi="#ffffff";var kh="AUTOMATED_TEXT";var Pe=!1;function qi(r){return new Promise((e,t)=>{let o=new Blob([r],{type:"application/octet-stream"}),n=new FileReader;n.onload=()=>{let i=n.result.split(",")[1];e(i)},n.onerror=s=>t(s),n.readAsDataURL(o)})}f(qi,"uint8ArrayToBase64");async function Hi(r){let e=`data:application/octet-stream;base64,${r}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}f(Hi,"base64ToUint8Array");async function eo({graph:r}){let e=`[${eo.name}]`;try{Pe&&console.log(`${e} starting... (I: 4ddb8803cf68e1d3d35f60680cb69825)`);let t=JSON.parse(JSON.stringify(r));for(let n in t)r[n].data instanceof Uint8Array&&(t[n].data={_dataType:"Uint8Array_Base64",value:await qi(r[n].data)});let o=JSON.stringify(t);return Pe&&console.log(`${e} jsonString.length: ${o.length} (I: 56dec8ad0931ab8ba9b5ca3d4e66be25)`),o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(eo,"serializeGraphToString");async function to({jsonString:r}){let e=`[${to.name}]`;try{Pe&&console.log(`${e} starting... (I: 52e1a1fb1adcc75168fbc6d819868825)`);let o=JSON.parse(r,f((n,s)=>(s&&s._dataType==="Uint8Array_Base64",s),"reviver"));for(let n in o){let s=o[n].data;s&&s._dataType==="Uint8Array_Base64"&&(o[n].data=await Hi(s.value))}return o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(to,"deserializeStringToGraph");async function Ki(r){let e=`[${Ki.name}]`;try{Pe&&console.log(`${e} starting... (I: 8d306868b718596fe8f562bd5118d825)`);let t=await eo({graph:r}),o=new TextEncoder().encode(t),s=new Response(o).body.pipeThrough(new CompressionStream("gzip"));return await new Response(s).blob()}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Ki,"compressIbGibToBlob");async function Dl(r){let e=r.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await to({jsonString:t})}f(Dl,"decompressIbGibFromBlob");async function Nn({graph:r}){let e=`[${Nn.name}]`;try{Pe&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let o=await(await Ki(r)).arrayBuffer(),n=new Uint8Array(o);return await qi(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Nn,"compressIbGibGraphToString");async function Cn({compressedBase64:r}){let e=`[${Cn.name}]`;try{Pe&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await Hi(r),o=new Blob([t],{type:"application/gzip"});return await Dl(o)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Cn,"decompressIbGibGraphFromString");var Vi="export";var ar=!1;function Xi({data:r}){let e=`[${Xi.name}]`;try{ar&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:o,timestamp:n}=r,s=o.length,i=$e(n),a=r.compression==="gzip"?"gzip":"raw";if(!r.timestamp)throw new Error("(UNEXPECTED) data.timestamp falsy? (E: 2f5bc88488cbf260634239a8a8396825)");let c=new Date(r.timestamp),{ib:l,gib:d}=R({ibGibAddr:r.contextIbGibAddr}),u=se({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Vi} ${p} ${a} ${t} ${s} ${u}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{ar&&console.log(`${e} complete.`)}}f(Xi,"getRawExportIb");async function Pn({ibGib:r,metaspace:e,space:t,compress:o,live:n,ignoreErrors:s}){let i=`[${Pn.name}]`;try{if(ar&&console.log(`${i} starting... (I: 0b6ba8608ba8bde0682a0936b9a01825)`),!r)throw new Error("(UNEXPECTED) ibGib falsy? (E: d2898eea744360865f0da5fb91baae22)");let a=I({ibGib:r}),c=[],l=await ie({ibGib:r})??[];if(l.length>0){let $=`ibGib had validation errors: ${l} (E: 84890bbc0598192498178a98ae299825)`;if(s)c.push({errorMsg:$,ibGibAddr:a});else throw new Error($)}let d=await e.getDependencyGraph({ibGib:r,live:n,space:t}),b=o?await Nn({graph:d}):await eo({graph:d}),u=fe({ibGib:r,defaultIfNone:"incomingAddr"})??a,p=new Date,h={contextIbGibAddr:a,tjpAddr:u,dependencyGraphAsString:b,graphSize:Object.keys(d).length,timestamp:Ae(p),timestampMs:p.getMilliseconds()};o&&(h.compression="gzip");let g={ib:Xi({data:h}),data:h},m=await X({ibGib:g,hasTjp:!1});return g.gib=m,ar&&console.log(`${i} JSON.stringify(exportIbGib).length: ${JSON.stringify(g).length} (I: db3a8d913a91d8fc5d6e45981e034822)`),{rawExportIbGib:g,manifest:Object.keys(d),errors:c.length>0?c:void 0}}catch(a){throw console.error(`${i} ${E(a)}`),a}finally{ar&&console.log(`${i} complete.`)}}f(Pn,"getRawExportIbGib");var rg="ibgib-shell-ready",og="ibgib-ui-busy",ng="ibgib-ui-message",sg="ibgib-identity-request-change",ig="ibgib-identity-changed",ag="ibgib-identity-update-available",cg="ibgib-identity-renewal-required",lg="show-identity-manager",dg="show-keystone-creator",fg="show-add-device",bg="show-privacy-policy";var Yi=at;async function $t({title:r,msg:e,prompt:t,showInput:o,defaultValue:n,okButtonTitle:s,cancelButtonTitle:i,isPassword:a,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:b,onPasskeyAuth:u}){let p=`[${$t.name}]`;try{Yi&&console.log(`${p} starting... (I: 037b228a2568181cd3eb25dba4e03225)`);let h=document.getElementById("fullscreen-dialog"),g=document.getElementById("fullscreen-dialog-body"),m=document.getElementById("fullscreen-dialog-title"),$=document.getElementById("fullscreen-dialog-message"),w=document.getElementById("fullscreen-dialog-prompt-input"),T=document.getElementById("fullscreen-dialog-ok-button"),A=document.getElementById("fullscreen-dialog-cancel-button");if(!h||!g||!m||!$||!w||!T||!A)throw new Error("(UNEXPECTED) One or more dialog elements not found in DOM (E: 578e37c0271cc57a99e95e780ad18a25)");if(m.textContent=r||"",[...$.childNodes].forEach(D=>$.removeChild(D)),(e||"").split(`
9
9
  `).forEach(D=>{let L=document.createElement("p");L.textContent=D,$.appendChild(L)}),l){let D=document.createElement("div");D.id="fullscreen-dialog-animation-emoji",D.textContent=l,D.style.fontSize="3.5rem",D.style.textAlign="center",D.style.margin="1.5rem 0",D.style.animation="spin-bounce 5s infinite ease-in-out",$.appendChild(D)}let y=document.getElementById("fullscreen-dialog-passkey-container");y&&y.remove();let _=null,v=null,N=null,x=Object.values(d||{}).filter(D=>D!=null);if(x.length>0&&u&&!c){_=document.createElement("div"),_.id="fullscreen-dialog-passkey-container",_.style.margin="1rem 0",_.style.textAlign="center",v=document.createElement("button"),v.id="fullscreen-dialog-btn-passkey",v.type="button",v.className="action-btn",v.style.width="100%",v.style.padding="0.75rem 1rem",v.style.background="linear-gradient(135deg, #1b5e20, #2e7d32)",v.style.color="#ffffff",v.style.fontWeight="bold",v.style.borderRadius="8px",v.style.border="1px solid rgba(255,255,255,0.2)",v.style.cursor="pointer",v.style.fontSize="0.95rem",v.style.marginBottom="0.75rem",v.textContent=b||"\u{1F6E1}\uFE0F Touch ID / Security Key",x.length>1&&(N=document.createElement("select"),N.style.width="100%",N.style.padding="0.4rem",N.style.marginBottom="0.5rem",N.style.borderRadius="4px",N.style.background="rgba(0,0,0,0.3)",N.style.color="inherit",N.style.border="1px solid rgba(255,255,255,0.2)",x.forEach((L,V)=>{let J=document.createElement("option");J.value=V.toString(),J.textContent=`${L.name||"Key"} (${L.credentialId?.substring(0,8)}...)`,N.appendChild(J)}),_.appendChild(N)),_.appendChild(v);let D=document.createElement("div");D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="center",D.style.gap="0.5rem",D.style.fontSize="0.8rem",D.style.color="var(--clr-text-secondary, #b3b3b3)",D.style.margin="0.5rem 0",D.innerHTML=`
10
10
  <span style="flex: 1; height: 1px; background: rgba(255,255,255,0.15);"></span>
11
11
  <span>OR enter Password below</span>
@@ -1 +1 @@
1
- import{F as I,Va as A,a as l,j as o,ka as i,la as G,nc as S,sd as _,w as u,yd as D,zd as T}from"./chunk-LAYDMZTA.mjs";var L={undefined:"undefined",preparing:"preparing",started:"started",inserted:"inserted",updated:"updated",merged_dna:"merged_dna",merged_state:"merged_state",already_synced:"already_synced",completed:"completed"},O={...G},U={...O,sync:"sync"};var v=" ";var C=!1;function x({sagaId:c,statusCode:e,spaceType:t,spaceSubtype:r,delimiter:s}){let n=`[${x.name}]`;try{if(!c)throw new Error("sagaId required. (E: cfc923bb29ee4aa788e947b6416740e6)");if(e==null)throw new Error("status code required. (E: 4e0d232a9955496695012623c2e17ca2)");if(!Object.values(L).includes(e))throw new Error(`invalid status code (${e}) (E: 91d7655424c44d9680fff099ee2b54d2)`);if(!t)throw new Error("spaceType required. (E: 86e98694a56a4f599e98e50abf0eed43)");if(!r)throw new Error("spaceSubtype required. (E: 4857d4677ee34e95aeb2251dd633909e)");return s=s||v,`status ${c} ${e} ${t} ${r}`}catch(a){throw console.error(`${n} ${o(a)}`),a}}l(x,"getStatusIb");function j({participants:c}){let e=`[${j.name}]`;try{C&&console.log(`${e} starting... (I: 43c9a4f1fa1bbc944b98f8eed2f81924)`);let t=c.filter(r=>r.s_d==="src");if(t.length!==1)throw new Error("(UNEXPECTED) participants_src.length !== 1? atow (03/2024) only one src participant is expected. (E: ed4b3ae15f5da34c77655553aaf82224)");return t.at(0).id}catch(t){throw console.error(`${e} ${o(t)}`),t}finally{C&&console.log(`${e} complete.`)}}l(j,"getSrcLocalSpaceId");var d=!1,P=class c extends _{static{l(this,"SpaceBase_V1")}lc=`[${c.name}]`;cacheSvc;constructor(e,t){super(e,t),this.initialized=this.initialize()}async witnessImpl(e){let t=`${this.lc}[${this.witnessImpl.name}]`;return d&&console.log(`${t}`),await this.routeAndDoCommand({cmd:e.data.cmd,cmdModifiers:e.data.cmdModifiers??[],arg:e})}routeAndDoCommand({cmd:e,cmdModifiers:t,arg:r}){let s=`${this.lc}[${this.routeAndDoCommand.name}]`;switch(e){case i.get:return(t??[]).length===0?this.get(r):t.includes("can")?this.canGet(r):t.includes("latest")?t.includes("addrs")?this.getLatestAddrs(r):this.getLatestIbGibs(r):t.includes("tjps")?t.includes("addrs")?this.getTjpAddrs(r):this.getTjpIbGibs(r):t.includes("addrs")?this.getAddrs(r):t.includes("dependency-graph")?this.getDependencyGraph(r):this.get(r);case i.put:return(t??[]).length===0?this.put(r):t.includes("can")?this.canPut(r):this.put(r);case i.delete:return(t??[]).length===0?this.delete(r):t.includes("can")?this.canDelete(r):this.delete(r);default:throw new Error(`${s} unknown cmd: ${e}. cmdModifiers: ${t}`)}}get(e){return this.getImpl(e)}put(e){return this.putImpl(e)}delete(e){return this.deleteImpl(e)}deleteImpl(e){let t=`${this.lc}[${this.deleteImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getAddrs(e){return this.getAddrsImpl(e)}getAddrsImpl(e){let t=`${this.lc}[${this.getAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getLatestIbGibs(e){return this.getLatestIbGibsImpl(e)}getLatestIbGibsImpl(e){let t=`${this.lc}[${this.getLatestIbGibsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getLatestAddrs(e){return this.getLatestAddrsImpl(e)}getLatestAddrsImpl(e){let t=`${this.lc}[${this.getLatestAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getTjpIbGibs(e){return this.getTjpIbGibsImpl(e)}getTjpIbGibsImpl(e){let t=`${this.lc}[${this.getTjpIbGibsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getTjpAddrs(e){return this.getTjpAddrsImpl(e)}getTjpAddrsImpl(e){let t=`${this.lc}[${this.getTjpAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canGet(e){return this.canGetImpl(e)}canGetImpl(e){let t=`${this.lc}[${this.canGetImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canPut(e){return this.canPutImpl(e)}canPutImpl(e){let t=`${this.lc}[${this.canPutImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canDelete(e){return this.canPutImpl(e)}canDeleteImpl(e){let t=`${this.lc}[${this.canDeleteImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getDependencyGraph(e){return this.getDependencyGraphImpl(e)}async getDependencyGraphImpl(e){let t=`${this.lc}[${this.getDependencyGraphImpl.name}]`;try{if(d&&console.log(`${t} starting... (I: 0e5fe807a0169224781f6c2833f34826)`),!e.data)throw new Error("(UNEXPECTED) arg.data falsy? (E: 45eba816295a97a0e55f981861a03f26)");if((e.data.ibGibAddrs??[]).length===0)throw new Error("arg.data.ibGibAddrs is falsy/empty (E: 70adc939c7b80c9938d8fa18fd7c5826)");let r={space:this,ibGibAddrs:e.data.ibGibAddrs,live:e.data.live||!0},s=await S(r),n=Object.values(s),a={optsAddr:u({ibGib:e}),count:n.length,addrs:Object.keys(s)};return this.resulty({resultData:a,ibGibs:n})}catch(r){throw console.error(`${t} ${o(r)}`),r}finally{d&&console.log(`${t} complete.`)}}async validateWitnessArg(e){let t=`${this.lc}[${this.validateWitnessArg.name}]`,r=[];try{if(r=await super.validateWitnessArg(e),!e.data)return r.push("arg.data required (E: 8ee544d7d88a45c6adcbc15838a283a7)"),r;if(!this.data)return r.push("this.data required (E: 64f80642d7de44329355d6f907e272c8)"),r;let{cmd:s,ibGibAddrs:n}=e.data,a=e.data.cmdModifiers??[],f=e.ibGibs;s||r.push("arg.data.cmd required (E: 72a11ee87a0d4896bcacd65a9c0284d9)"),Object.values(i).includes(s)||r.push(`unknown arg.data.cmd: ${s}. (E: 95282ce61e97429f8049e61ec9f14f0b)`);let w=n?.length??0;if(s===i.get&&!a?.includes("addrs")&&!a?.includes("latest")&&w===0&&r.push(`ibGibAddrs required when cmd is ${s}. (E: ee55a3f60b90423cbe054f27c34ab7d5)`),s===i.put){d&&console.log(`${t} validate put cmd`);let g=f?.length??0;if(g===0)r.push(`ibGibs required when cmd is ${s}. (E: b3a422169f7344a48a1d44e7ad1ba44e)`);else if(this.data.validateIbGibAddrsMatchIbGibs)if(d&&console.log(`${t} validateIbGibAddrsMatchIbGibs true, so doing so.`),g!==w)r.push("ibGibsLength !== ibGibAddrsLength and this.data.validateIbGibAddrsMatchIbGibs is true. (E: 6c6bf824ab32443aa4d6b8bf4f8113dd)");else{d&&console.log(`${t} validateIbGibAddrsMatchIbGibs, lengths match. validating intrinsically`);let $=n.concat();for(let h=0;h<f.length;h++){let m=f[h],y=await I({ibGib:m});if(y?.length??!1){let p=u({ibGib:m});y.forEach(b=>r.push(`(${p}) ERROR: ${b}`))}else{let p=u({ibGib:m}),b=$.indexOf(p);if(b===-1){r.push(`ibGibAddrs don't map to calculated ibGib addrs. calculated Addr: (${p}) (E: b21b3a7a74db43e5a8722acc97274646)`);break}else $.splice(b,1)}}}}return r}catch(s){throw console.error(`${t} ${o(s)}`),s}finally{r?.length>0&&console.error(`${t} errors: ${r}`)}}async argy({argData:e,ibMetadata:t,noTimestamp:r,ibGibs:s}){let n=await D({argData:e,ibMetadata:t,noTimestamp:r});return s&&(n.ibGibs=s),n}async resulty({resultData:e,ibGibs:t}){let r=await T({ibMetadata:A({space:this}),resultData:e});return t&&(r.ibGibs=t),r}};export{P as a,L as b,x as c,j as d};
1
+ import{F as I,Va as A,a as l,j as o,ka as i,la as G,nc as S,sd as _,w as u,yd as D,zd as T}from"./chunk-6AKXSINN.mjs";var L={undefined:"undefined",preparing:"preparing",started:"started",inserted:"inserted",updated:"updated",merged_dna:"merged_dna",merged_state:"merged_state",already_synced:"already_synced",completed:"completed"},O={...G},U={...O,sync:"sync"};var v=" ";var C=!1;function x({sagaId:c,statusCode:e,spaceType:t,spaceSubtype:r,delimiter:s}){let n=`[${x.name}]`;try{if(!c)throw new Error("sagaId required. (E: cfc923bb29ee4aa788e947b6416740e6)");if(e==null)throw new Error("status code required. (E: 4e0d232a9955496695012623c2e17ca2)");if(!Object.values(L).includes(e))throw new Error(`invalid status code (${e}) (E: 91d7655424c44d9680fff099ee2b54d2)`);if(!t)throw new Error("spaceType required. (E: 86e98694a56a4f599e98e50abf0eed43)");if(!r)throw new Error("spaceSubtype required. (E: 4857d4677ee34e95aeb2251dd633909e)");return s=s||v,`status ${c} ${e} ${t} ${r}`}catch(a){throw console.error(`${n} ${o(a)}`),a}}l(x,"getStatusIb");function j({participants:c}){let e=`[${j.name}]`;try{C&&console.log(`${e} starting... (I: 43c9a4f1fa1bbc944b98f8eed2f81924)`);let t=c.filter(r=>r.s_d==="src");if(t.length!==1)throw new Error("(UNEXPECTED) participants_src.length !== 1? atow (03/2024) only one src participant is expected. (E: ed4b3ae15f5da34c77655553aaf82224)");return t.at(0).id}catch(t){throw console.error(`${e} ${o(t)}`),t}finally{C&&console.log(`${e} complete.`)}}l(j,"getSrcLocalSpaceId");var d=!1,P=class c extends _{static{l(this,"SpaceBase_V1")}lc=`[${c.name}]`;cacheSvc;constructor(e,t){super(e,t),this.initialized=this.initialize()}async witnessImpl(e){let t=`${this.lc}[${this.witnessImpl.name}]`;return d&&console.log(`${t}`),await this.routeAndDoCommand({cmd:e.data.cmd,cmdModifiers:e.data.cmdModifiers??[],arg:e})}routeAndDoCommand({cmd:e,cmdModifiers:t,arg:r}){let s=`${this.lc}[${this.routeAndDoCommand.name}]`;switch(e){case i.get:return(t??[]).length===0?this.get(r):t.includes("can")?this.canGet(r):t.includes("latest")?t.includes("addrs")?this.getLatestAddrs(r):this.getLatestIbGibs(r):t.includes("tjps")?t.includes("addrs")?this.getTjpAddrs(r):this.getTjpIbGibs(r):t.includes("addrs")?this.getAddrs(r):t.includes("dependency-graph")?this.getDependencyGraph(r):this.get(r);case i.put:return(t??[]).length===0?this.put(r):t.includes("can")?this.canPut(r):this.put(r);case i.delete:return(t??[]).length===0?this.delete(r):t.includes("can")?this.canDelete(r):this.delete(r);default:throw new Error(`${s} unknown cmd: ${e}. cmdModifiers: ${t}`)}}get(e){return this.getImpl(e)}put(e){return this.putImpl(e)}delete(e){return this.deleteImpl(e)}deleteImpl(e){let t=`${this.lc}[${this.deleteImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getAddrs(e){return this.getAddrsImpl(e)}getAddrsImpl(e){let t=`${this.lc}[${this.getAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getLatestIbGibs(e){return this.getLatestIbGibsImpl(e)}getLatestIbGibsImpl(e){let t=`${this.lc}[${this.getLatestIbGibsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getLatestAddrs(e){return this.getLatestAddrsImpl(e)}getLatestAddrsImpl(e){let t=`${this.lc}[${this.getLatestAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getTjpIbGibs(e){return this.getTjpIbGibsImpl(e)}getTjpIbGibsImpl(e){let t=`${this.lc}[${this.getTjpIbGibsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getTjpAddrs(e){return this.getTjpAddrsImpl(e)}getTjpAddrsImpl(e){let t=`${this.lc}[${this.getTjpAddrsImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canGet(e){return this.canGetImpl(e)}canGetImpl(e){let t=`${this.lc}[${this.canGetImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canPut(e){return this.canPutImpl(e)}canPutImpl(e){let t=`${this.lc}[${this.canPutImpl.name}]`;throw new Error(`${t} not implemented in base class`)}canDelete(e){return this.canPutImpl(e)}canDeleteImpl(e){let t=`${this.lc}[${this.canDeleteImpl.name}]`;throw new Error(`${t} not implemented in base class`)}getDependencyGraph(e){return this.getDependencyGraphImpl(e)}async getDependencyGraphImpl(e){let t=`${this.lc}[${this.getDependencyGraphImpl.name}]`;try{if(d&&console.log(`${t} starting... (I: 0e5fe807a0169224781f6c2833f34826)`),!e.data)throw new Error("(UNEXPECTED) arg.data falsy? (E: 45eba816295a97a0e55f981861a03f26)");if((e.data.ibGibAddrs??[]).length===0)throw new Error("arg.data.ibGibAddrs is falsy/empty (E: 70adc939c7b80c9938d8fa18fd7c5826)");let r={space:this,ibGibAddrs:e.data.ibGibAddrs,live:e.data.live||!0},s=await S(r),n=Object.values(s),a={optsAddr:u({ibGib:e}),count:n.length,addrs:Object.keys(s)};return this.resulty({resultData:a,ibGibs:n})}catch(r){throw console.error(`${t} ${o(r)}`),r}finally{d&&console.log(`${t} complete.`)}}async validateWitnessArg(e){let t=`${this.lc}[${this.validateWitnessArg.name}]`,r=[];try{if(r=await super.validateWitnessArg(e),!e.data)return r.push("arg.data required (E: 8ee544d7d88a45c6adcbc15838a283a7)"),r;if(!this.data)return r.push("this.data required (E: 64f80642d7de44329355d6f907e272c8)"),r;let{cmd:s,ibGibAddrs:n}=e.data,a=e.data.cmdModifiers??[],f=e.ibGibs;s||r.push("arg.data.cmd required (E: 72a11ee87a0d4896bcacd65a9c0284d9)"),Object.values(i).includes(s)||r.push(`unknown arg.data.cmd: ${s}. (E: 95282ce61e97429f8049e61ec9f14f0b)`);let w=n?.length??0;if(s===i.get&&!a?.includes("addrs")&&!a?.includes("latest")&&w===0&&r.push(`ibGibAddrs required when cmd is ${s}. (E: ee55a3f60b90423cbe054f27c34ab7d5)`),s===i.put){d&&console.log(`${t} validate put cmd`);let g=f?.length??0;if(g===0)r.push(`ibGibs required when cmd is ${s}. (E: b3a422169f7344a48a1d44e7ad1ba44e)`);else if(this.data.validateIbGibAddrsMatchIbGibs)if(d&&console.log(`${t} validateIbGibAddrsMatchIbGibs true, so doing so.`),g!==w)r.push("ibGibsLength !== ibGibAddrsLength and this.data.validateIbGibAddrsMatchIbGibs is true. (E: 6c6bf824ab32443aa4d6b8bf4f8113dd)");else{d&&console.log(`${t} validateIbGibAddrsMatchIbGibs, lengths match. validating intrinsically`);let $=n.concat();for(let h=0;h<f.length;h++){let m=f[h],y=await I({ibGib:m});if(y?.length??!1){let p=u({ibGib:m});y.forEach(b=>r.push(`(${p}) ERROR: ${b}`))}else{let p=u({ibGib:m}),b=$.indexOf(p);if(b===-1){r.push(`ibGibAddrs don't map to calculated ibGib addrs. calculated Addr: (${p}) (E: b21b3a7a74db43e5a8722acc97274646)`);break}else $.splice(b,1)}}}}return r}catch(s){throw console.error(`${t} ${o(s)}`),s}finally{r?.length>0&&console.error(`${t} errors: ${r}`)}}async argy({argData:e,ibMetadata:t,noTimestamp:r,ibGibs:s}){let n=await D({argData:e,ibMetadata:t,noTimestamp:r});return s&&(n.ibGibs=s),n}async resulty({resultData:e,ibGibs:t}){let r=await T({ibMetadata:A({space:this}),resultData:e});return t&&(r.ibGibs=t),r}};export{P as a,L as b,x as c,j as d};
@@ -1,4 +1,4 @@
1
- import{$b as Bi,A as Bt,Ab as Ws,Ac as ct,Bb as Js,Bc as Hi,Bd as yr,C as W,Cb as Ys,Cc as or,Cd as zi,D as Fs,Dc as sr,E as st,Eb as Xs,Ec as En,F as cn,Fb as Qs,Fc as wn,Gb as Vt,Gc as rr,H as Ie,Hb as se,Hc as ar,Ib as Me,Ic as vn,Jb as Ce,Jc as In,Kb as Ot,Kc as Cn,Lb as Zs,Lc as Tn,Ma as dn,Mb as un,Nb as fn,Ob as pn,Pb as js,Qb as er,Qc as dt,Rb as tr,Rc as lr,Sb as hn,Sc as cr,Tb as Li,Tc as dr,Uc as Be,Vb as k,Vc as ur,W as Bs,Wb as mn,Wc as fr,X as Vs,Xa as Os,Xc as pr,Ya as qs,Za as Hs,Zb as Ui,_b as Fi,_c as Sn,a as p,ac as qt,b as sn,bc as Vi,c as Di,cc as Le,d as xe,dc as Pe,e as Ls,ec as Ne,ed as hr,fc as rt,g as rn,gd as mr,h as V,hd as re,i as z,id as wt,j as E,kb as Mi,l as ot,lb as Se,lc as Oi,n as Ke,nb as H,nd as D,o as Et,ob as J,q as an,qd as gr,r as ln,rc as at,rd as Ve,s as Ft,sc as gn,sd as br,tc as Y,uc as nr,ud as vt,v as Z,vc as qi,vd as It,w as _,wb as Q,wc as bn,wd as Ct,x as B,xc as yn,yb as zs,yc as ir,z as Us,zb as Ks,zc as lt}from"./chunk-LAYDMZTA.mjs";var Ge=Q,Ki=class n{static{p(this,"IbGibComponentService")}lc=`[${n.name}]`;_registeredComponentsMeta=[];initialized;constructor(){this.initialized=this.initialize()}async initialize(){let e=`[${this.initialize.name}]`;try{Ge&&console.log(`${e} starting... (I: 1cf04e8d768f4b5c55e7c3861e2d2225)`),console.log(`${e} does nothing atow (I: 65bb46c88c82b637ad928b8bf1a07225)`)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Ge&&console.log(`${e} complete.`)}}registerComponentMeta(e){this._registeredComponentsMeta.push(e),Ge&&console.log(`${this.lc}[registerComponentMeta] component meta registered: ${e.constructor.name} (I: 88ddcbd0c8caa2342af0e7348f171225)`)}unregisterComponentMeta(e){this._registeredComponentsMeta=this._registeredComponentsMeta.filter(t=>t!==e),Ge&&console.log(`${this.lc}[unregisterComponentMeta] component meta unregistered: ${e.constructor.name} (I: 4e84b5274de688248984896a90f5cc25)`)}async getComponentInstance({useRegExpPrefilter:e,path:t,ibGibAddr:i}){let o=`${this.lc}[${this.getComponentInstance.name}]`;try{Ge&&console.log(`${o} starting... (I: 684ef316cbdb4a3b1fdc96096c273b25)`);let s,a=Ht.getRegisteredComponentsMeta(),c=e?a.filter(d=>{let u=d.routeRegExp?d.routeRegExp.test(t):!1;return Ge&&console.log(`${o} ${d.componentName} ${d.routeRegExp} componentMatchesPath: ${u} (I: 3758520e6a4a57f218396c8649283425)`),u}):a.concat();for(let d of c)if(d.fnHandleRoute?await d.fnHandleRoute({path:t,ibGibAddr:i}):!0){s=await d.createInstance({path:t,ibGibAddr:i});break}return s}catch(s){throw console.error(`${o} ${E(s)}`),s}finally{Ge&&console.log(`${o} complete.`)}}async inject({parentEl:e,componentToInject:t}){let i=`${this.lc}[${this.inject.name}]`;try{if(Ge&&console.log(`${i} starting... (I: 6844cf07eaf8a5b1b106784f7db17125)`),!e)throw new Error(`${i} parentEl required. (E: 6f4eb2d682856ef47d173b970ec3c825)`);if(!t)throw new Error(`${i} componentToInject required. (E: decf0b51ad49257ce44fecbcf84c3a25)`);if(!t.meta)throw new Error(`${i} componentToInject.meta required. (E: f8827c0602ca7b0e030d0b3e2c4a4825)`);if(!t.meta.componentName)throw new Error(`${i} componentToInject.meta.componentName required. (E: 5dcae244ae32690f7b73ce27a32a3c25)`);e.innerHTML="",e.appendChild(t),e.classList.remove("fade-out")}catch(o){console.error(`${i} ${E(o)}`),e.innerHTML=`<p class="error">Error loading component for route. error:</p><br /><br /><p>${o.message}</p>`}finally{Ge&&console.log(`${i} complete.`)}}getRegisteredComponentsMeta(){return[...this._registeredComponentsMeta]}},Ht;async function ne(){let n=`[${ne.name}]`;try{return Ge&&console.log(`${n} starting... (I: 853694c88223381339103a3765129925)`),Ht||(Ht=new Ki,await Ht.initialized),Ht}catch(e){throw console.error(`${n} ${E(e)}`),e}finally{Ge&&console.log(`${n} complete.`)}}p(ne,"getComponentSvc");var Er="left-panel";var wr="right-panel";var vr="left-resizer",Ir="right-resizer",Cr="footer-resizer",Tr="btn-left-panel-toggle",Sr="btn-right-panel-toggle",_r="btn-create-keystone",zt="center-panel-content";var Ji=class{static{p(this,"KeystoneSyncService")}lc="[KeystoneSyncService]";dispatchUpdateAvailableEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Ot,{detail:e,bubbles:!0,composed:!0}))}dispatchRenewalRequiredEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Zs,{detail:e,bubbles:!0,composed:!0}))}async getDeviceDelegateSecret({primaryTjpAddr:e}){return Hi({primaryTjpAddr:e})}async checkDelegateStatus({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.checkDelegateStatus.name}]`;try{if(t||(t=await k()),!t)throw new Error(`${o} (UNEXPECTED) metaspace falsy? (E: genuuid)`);if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error(`${o} (UNEXPECTED) space falsy? (E: genuuid)`);let s=W({ibGibAddr:e}),{ib:a}=B({ibGibAddr:e}),c=s.tjpGib?`${a}^${s.tjpGib}`:e;if(!await Hi({primaryTjpAddr:c}))return this.dispatchRenewalRequiredEvent({activePrimaryAddr:e,primaryTjpAddr:c,reason:"missing_secret"}),{isValid:!1,reason:"missing_secret"};let f=await new Y().getLatestKeystone({addr:e,metaspace:t,space:i});if(!f)throw new Error(`${o} (UNEXPECTED) latest primary keystone not found for addr: ${e} (E: genuuid)`);return f?.data?.delegates&&Object.values(f.data.delegates).some(g=>bn({delegateInfo:g}))?(this.dispatchRenewalRequiredEvent({activePrimaryAddr:e,primaryTjpAddr:c,reason:"expired"}),{isValid:!1,reason:"expired"}):{isValid:!0}}catch(s){return console.error(`${o} ${E(s)}`),{isValid:!1}}}async checkForKeystoneUpdate({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.checkForKeystoneUpdate.name}]`;try{if(t||(t=await k()),!t)throw new Error("Metaspace not available.");if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error("Local user space not available.");let s=await t.getLatestAddr({addr:e,space:i})||e,a=await t.get({addrs:[s],space:i}),c=a.success&&a.ibGibs&&a.ibGibs.length>0?a.ibGibs[0]:void 0,d=c?.data?.n??0,{ib:u}=B({ibGibAddr:e}),f=W({ibGibAddr:e}),h=f.tjpGib?`${u}^${f.tjpGib}`:e,m=(c?H({ibGib:c}):void 0)||h,g=await D().getKeystoneGraph(m);if(!g.success||!g.graph){let G={hasUpdate:!1,serverN:d,localN:d,serverLatestAddr:s,graph:{}};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:G.hasUpdate,serverN:G.serverN,localN:G.localN,serverLatestAddr:G.serverLatestAddr}),G}let b=g.graph,y=Object.values(b),w=Se({ibGibs:y}),v=w[m]||w[e]||w[Object.keys(w)[0]]||[];if(v.length===0){let G={hasUpdate:!1,serverN:d,localN:d,serverLatestAddr:s,graph:b};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:G.hasUpdate,serverN:G.serverN,localN:G.localN,serverLatestAddr:G.serverLatestAddr}),G}let I=[...v].sort((G,P)=>(G.data?.n??0)-(P.data?.n??0)),C=I[I.length-1],T=C.data?.n??0,x=_({ibGib:C}),S={hasUpdate:T>d,serverN:T,localN:d,serverLatestAddr:x,graph:b};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:S.hasUpdate,serverN:S.serverN,localN:S.localN,serverLatestAddr:S.serverLatestAddr}),S}catch(s){console.error(`${o} ${E(s)}`);let a={hasUpdate:!1,serverN:0,localN:0,serverLatestAddr:e,graph:{}};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:!1,serverN:0,localN:0,serverLatestAddr:e}),a}}async updateActiveKeystone({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.updateActiveKeystone.name}]`;try{if(t||(t=await k()),!t)throw new Error("Metaspace not available.");if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error("Local user space not available.");let s=await this.checkForKeystoneUpdate({activePrimaryAddr:e,metaspace:t,space:i});if(s.hasUpdate&&Object.keys(s.graph).length>0){let d=Object.values(s.graph);await t.put({ibGibs:d,space:i});let u=Se({ibGibs:d});for(let b of Object.keys(u)){let w=[...u[b]].sort((v,I)=>(v.data?.n??0)-(I.data?.n??0));for(let v of w)await t.registerNewIbGib({ibGib:v,space:i})}let f=W({ibGibAddr:e}).tjpGib??e,m=[...u[f]||u[e]||u[Object.keys(u)[0]]].sort((b,y)=>(b.data?.n??0)-(y.data?.n??0)),g=m[m.length-1];if(g)return await re({type:"keystones",rel8nInfos:[{rel8nName:"keystone",ibGibs:[J({ibGib:g})]}],metaspace:t,space:i}),g}let a=await t.getLatestAddr({addr:e,space:i})||e,c=await t.get({addrs:[a],space:i});return c.success&&c.ibGibs&&c.ibGibs.length>0?c.ibGibs[0]:void 0}catch(s){throw console.error(`${o} ${E(s)}`),s}}},Wi;function ut(){return Wi||(Wi=new Ji),Wi}p(ut,"getKeystoneSyncService");var Ar=`:host {
1
+ import{$b as Bi,A as Bt,Ab as Ws,Ac as ct,Bb as Js,Bc as Hi,Bd as yr,C as W,Cb as Ys,Cc as or,Cd as zi,D as Fs,Dc as sr,E as st,Eb as Xs,Ec as En,F as cn,Fb as Qs,Fc as wn,Gb as Vt,Gc as rr,H as Ie,Hb as se,Hc as ar,Ib as Me,Ic as vn,Jb as Ce,Jc as In,Kb as Ot,Kc as Cn,Lb as Zs,Lc as Tn,Ma as dn,Mb as un,Nb as fn,Ob as pn,Pb as js,Qb as er,Qc as dt,Rb as tr,Rc as lr,Sb as hn,Sc as cr,Tb as Li,Tc as dr,Uc as Be,Vb as k,Vc as ur,W as Bs,Wb as mn,Wc as fr,X as Vs,Xa as Os,Xc as pr,Ya as qs,Za as Hs,Zb as Ui,_b as Fi,_c as Sn,a as p,ac as qt,b as sn,bc as Vi,c as Di,cc as Le,d as xe,dc as Pe,e as Ls,ec as Ne,ed as hr,fc as rt,g as rn,gd as mr,h as V,hd as re,i as z,id as wt,j as E,kb as Mi,l as ot,lb as Se,lc as Oi,n as Ke,nb as H,nd as D,o as Et,ob as J,q as an,qd as gr,r as ln,rc as at,rd as Ve,s as Ft,sc as gn,sd as br,tc as Y,uc as nr,ud as vt,v as Z,vc as qi,vd as It,w as _,wb as Q,wc as bn,wd as Ct,x as B,xc as yn,yb as zs,yc as ir,z as Us,zb as Ks,zc as lt}from"./chunk-6AKXSINN.mjs";var Ge=Q,Ki=class n{static{p(this,"IbGibComponentService")}lc=`[${n.name}]`;_registeredComponentsMeta=[];initialized;constructor(){this.initialized=this.initialize()}async initialize(){let e=`[${this.initialize.name}]`;try{Ge&&console.log(`${e} starting... (I: 1cf04e8d768f4b5c55e7c3861e2d2225)`),console.log(`${e} does nothing atow (I: 65bb46c88c82b637ad928b8bf1a07225)`)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Ge&&console.log(`${e} complete.`)}}registerComponentMeta(e){this._registeredComponentsMeta.push(e),Ge&&console.log(`${this.lc}[registerComponentMeta] component meta registered: ${e.constructor.name} (I: 88ddcbd0c8caa2342af0e7348f171225)`)}unregisterComponentMeta(e){this._registeredComponentsMeta=this._registeredComponentsMeta.filter(t=>t!==e),Ge&&console.log(`${this.lc}[unregisterComponentMeta] component meta unregistered: ${e.constructor.name} (I: 4e84b5274de688248984896a90f5cc25)`)}async getComponentInstance({useRegExpPrefilter:e,path:t,ibGibAddr:i}){let o=`${this.lc}[${this.getComponentInstance.name}]`;try{Ge&&console.log(`${o} starting... (I: 684ef316cbdb4a3b1fdc96096c273b25)`);let s,a=Ht.getRegisteredComponentsMeta(),c=e?a.filter(d=>{let u=d.routeRegExp?d.routeRegExp.test(t):!1;return Ge&&console.log(`${o} ${d.componentName} ${d.routeRegExp} componentMatchesPath: ${u} (I: 3758520e6a4a57f218396c8649283425)`),u}):a.concat();for(let d of c)if(d.fnHandleRoute?await d.fnHandleRoute({path:t,ibGibAddr:i}):!0){s=await d.createInstance({path:t,ibGibAddr:i});break}return s}catch(s){throw console.error(`${o} ${E(s)}`),s}finally{Ge&&console.log(`${o} complete.`)}}async inject({parentEl:e,componentToInject:t}){let i=`${this.lc}[${this.inject.name}]`;try{if(Ge&&console.log(`${i} starting... (I: 6844cf07eaf8a5b1b106784f7db17125)`),!e)throw new Error(`${i} parentEl required. (E: 6f4eb2d682856ef47d173b970ec3c825)`);if(!t)throw new Error(`${i} componentToInject required. (E: decf0b51ad49257ce44fecbcf84c3a25)`);if(!t.meta)throw new Error(`${i} componentToInject.meta required. (E: f8827c0602ca7b0e030d0b3e2c4a4825)`);if(!t.meta.componentName)throw new Error(`${i} componentToInject.meta.componentName required. (E: 5dcae244ae32690f7b73ce27a32a3c25)`);e.innerHTML="",e.appendChild(t),e.classList.remove("fade-out")}catch(o){console.error(`${i} ${E(o)}`),e.innerHTML=`<p class="error">Error loading component for route. error:</p><br /><br /><p>${o.message}</p>`}finally{Ge&&console.log(`${i} complete.`)}}getRegisteredComponentsMeta(){return[...this._registeredComponentsMeta]}},Ht;async function ne(){let n=`[${ne.name}]`;try{return Ge&&console.log(`${n} starting... (I: 853694c88223381339103a3765129925)`),Ht||(Ht=new Ki,await Ht.initialized),Ht}catch(e){throw console.error(`${n} ${E(e)}`),e}finally{Ge&&console.log(`${n} complete.`)}}p(ne,"getComponentSvc");var Er="left-panel";var wr="right-panel";var vr="left-resizer",Ir="right-resizer",Cr="footer-resizer",Tr="btn-left-panel-toggle",Sr="btn-right-panel-toggle",_r="btn-create-keystone",zt="center-panel-content";var Ji=class{static{p(this,"KeystoneSyncService")}lc="[KeystoneSyncService]";dispatchUpdateAvailableEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Ot,{detail:e,bubbles:!0,composed:!0}))}dispatchRenewalRequiredEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Zs,{detail:e,bubbles:!0,composed:!0}))}async getDeviceDelegateSecret({primaryTjpAddr:e}){return Hi({primaryTjpAddr:e})}async checkDelegateStatus({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.checkDelegateStatus.name}]`;try{if(t||(t=await k()),!t)throw new Error(`${o} (UNEXPECTED) metaspace falsy? (E: genuuid)`);if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error(`${o} (UNEXPECTED) space falsy? (E: genuuid)`);let s=W({ibGibAddr:e}),{ib:a}=B({ibGibAddr:e}),c=s.tjpGib?`${a}^${s.tjpGib}`:e;if(!await Hi({primaryTjpAddr:c}))return this.dispatchRenewalRequiredEvent({activePrimaryAddr:e,primaryTjpAddr:c,reason:"missing_secret"}),{isValid:!1,reason:"missing_secret"};let f=await new Y().getLatestKeystone({addr:e,metaspace:t,space:i});if(!f)throw new Error(`${o} (UNEXPECTED) latest primary keystone not found for addr: ${e} (E: genuuid)`);return f?.data?.delegates&&Object.values(f.data.delegates).some(g=>bn({delegateInfo:g}))?(this.dispatchRenewalRequiredEvent({activePrimaryAddr:e,primaryTjpAddr:c,reason:"expired"}),{isValid:!1,reason:"expired"}):{isValid:!0}}catch(s){return console.error(`${o} ${E(s)}`),{isValid:!1}}}async checkForKeystoneUpdate({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.checkForKeystoneUpdate.name}]`;try{if(t||(t=await k()),!t)throw new Error("Metaspace not available.");if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error("Local user space not available.");let s=await t.getLatestAddr({addr:e,space:i})||e,a=await t.get({addrs:[s],space:i}),c=a.success&&a.ibGibs&&a.ibGibs.length>0?a.ibGibs[0]:void 0,d=c?.data?.n??0,{ib:u}=B({ibGibAddr:e}),f=W({ibGibAddr:e}),h=f.tjpGib?`${u}^${f.tjpGib}`:e,m=(c?H({ibGib:c}):void 0)||h,g=await D().getKeystoneGraph(m);if(!g.success||!g.graph){let G={hasUpdate:!1,serverN:d,localN:d,serverLatestAddr:s,graph:{}};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:G.hasUpdate,serverN:G.serverN,localN:G.localN,serverLatestAddr:G.serverLatestAddr}),G}let b=g.graph,y=Object.values(b),w=Se({ibGibs:y}),v=w[m]||w[e]||w[Object.keys(w)[0]]||[];if(v.length===0){let G={hasUpdate:!1,serverN:d,localN:d,serverLatestAddr:s,graph:b};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:G.hasUpdate,serverN:G.serverN,localN:G.localN,serverLatestAddr:G.serverLatestAddr}),G}let I=[...v].sort((G,P)=>(G.data?.n??0)-(P.data?.n??0)),C=I[I.length-1],T=C.data?.n??0,x=_({ibGib:C}),S={hasUpdate:T>d,serverN:T,localN:d,serverLatestAddr:x,graph:b};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:S.hasUpdate,serverN:S.serverN,localN:S.localN,serverLatestAddr:S.serverLatestAddr}),S}catch(s){console.error(`${o} ${E(s)}`);let a={hasUpdate:!1,serverN:0,localN:0,serverLatestAddr:e,graph:{}};return this.dispatchUpdateAvailableEvent({activePrimaryAddr:e,hasUpdate:!1,serverN:0,localN:0,serverLatestAddr:e}),a}}async updateActiveKeystone({activePrimaryAddr:e,metaspace:t,space:i}){let o=`${this.lc}[${this.updateActiveKeystone.name}]`;try{if(t||(t=await k()),!t)throw new Error("Metaspace not available.");if(i||(i=await t.getLocalUserSpace({lock:!1})),!i)throw new Error("Local user space not available.");let s=await this.checkForKeystoneUpdate({activePrimaryAddr:e,metaspace:t,space:i});if(s.hasUpdate&&Object.keys(s.graph).length>0){let d=Object.values(s.graph);await t.put({ibGibs:d,space:i});let u=Se({ibGibs:d});for(let b of Object.keys(u)){let w=[...u[b]].sort((v,I)=>(v.data?.n??0)-(I.data?.n??0));for(let v of w)await t.registerNewIbGib({ibGib:v,space:i})}let f=W({ibGibAddr:e}).tjpGib??e,m=[...u[f]||u[e]||u[Object.keys(u)[0]]].sort((b,y)=>(b.data?.n??0)-(y.data?.n??0)),g=m[m.length-1];if(g)return await re({type:"keystones",rel8nInfos:[{rel8nName:"keystone",ibGibs:[J({ibGib:g})]}],metaspace:t,space:i}),g}let a=await t.getLatestAddr({addr:e,space:i})||e,c=await t.get({addrs:[a],space:i});return c.success&&c.ibGibs&&c.ibGibs.length>0?c.ibGibs[0]:void 0}catch(s){throw console.error(`${o} ${E(s)}`),s}}},Wi;function ut(){return Wi||(Wi=new Ji),Wi}p(ut,"getKeystoneSyncService");var Ar=`:host {
2
2
  display: inline-block;
3
3
  vertical-align: middle;
4
4
  position: relative;