@ibgib/space-gib 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/bootstrap.mjs +1 -1
- package/dist/client/{chunk-AGISDFVA.mjs → chunk-4S4RYXGE.mjs} +1 -1
- package/dist/client/{chunk-KQUAM2F6.mjs → chunk-CITOSYSX.mjs} +1 -1
- package/dist/client/{chunk-4ISBBTBE.mjs → chunk-GL6JISTC.mjs} +1 -1
- package/dist/client/index.mjs +27 -27
- package/dist/client/script.mjs +1 -1
- package/dist/server/server.mjs +1 -1
- package/package.json +4 -4
- package/src/client/AUTO-GENERATED-version.mts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ca,b as xa,c as pt,d as Oa,e as Ra,f as Se,g as ke,h as Ma,i as Ua,j as Ba,k as va,l as Fa}from"./chunk-KQUAM2F6.mjs";import{a as ja,b as z,d as Jt,e as ka,f as qa}from"./chunk-4ISBBTBE.mjs";import{$ as ye,$a as ma,$c as dt,A as X,Aa as Ie,Ad as Da,B as j,Ba as aa,C as k,Ca as oa,Cd as je,Da as ia,Db as Ae,Ea as sa,Eb as $a,F as re,Fa as na,G as Ye,Ga as ca,H as ce,Ha as at,I as Ot,Ia as ot,J as Ne,Ja as la,K as Ce,Ka as da,L as Ur,M as Le,Ma as Oe,Mc as zt,N as Je,Na as Re,Nc as ct,O as Ee,Oa as Ft,Oc as Be,P as Br,Pc as Aa,Q as vr,R as Rt,Ra as it,Rc as Ht,S as Qe,Sa as fa,T as we,Ta as ba,Ua as pa,Ub as ya,V as Fr,Vb as q,W as jr,Wa as st,Wc as ae,Y as $e,Ya as Me,Yc as Xt,Z as De,Za as Ue,Zc as Sa,_ as kr,_a as ha,_c as lt,a as b,aa as qr,ab as jt,ad as _a,b as Gt,ba as zr,bd as Ta,ca as Mt,d as x,da as Ut,e as te,ea as Hr,ed as Ga,f as Pt,fa as Xr,fb as ua,g as O,ga as Vr,gd as Vt,h as y,ha as Wr,hb as kt,i as se,ia as Ke,ib as ga,id as ve,j as m,ja as Ze,jb as le,k as Mr,l as We,lb as Ea,m as Nt,ma as Yr,mb as wa,n as Ct,na as Jr,nc as Ia,o as Lt,oa as Qr,ob as nt,pa as et,pd as Pa,qa as Bt,r as ne,ra as Kr,rd as ft,s as ue,sa as Zr,t as Dt,ta as ea,td as Na,u as ge,ua as tt,va as xe,vd as Wt,w as $,wa as ta,wb as T,wd as Fe,x as N,xa as rt,xb as qt,xd as Yt,y as xt,ya as vt,yd as bt,za as ra,zd as La}from"./chunk-AGISDFVA.mjs";var za={src:["source","from","in","input"],dest:["destination","to","out","output"]};function jo({paramName:s,noBare:e,argTypeName:r,description:t}){let a={name:`src-${s}`,argTypeName:r??"string",synonyms:[...za.src.map(o=>`${o}-${s}`)],description:t};return e||a.synonyms.push(s),a}b(jo,"getParam_src");function ko({paramName:s,argTypeName:e="string",description:r}){return{name:`dest-${s}`,argTypeName:e??"string",synonyms:[...za.dest.map(a=>`${a}-${s}`)],description:r}}b(ko,"getParam_dest");var Ha={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 ji=jo({paramName:"path",description:"for referencing/ingesting file(s)/folder(s) in a fs"}),ki=ko({paramName:"path",description:"for indicating where to put generated file(s)/folder(s)"});var V=!1;function ht({paramInfo:s,valueString:e}){let r=`[${ht.name}]`;try{switch(s.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 a=Number.parseInt(e);if(typeof a!="number")throw new Error(`arg value string (${e})did not parse to an integer. parse result: ${a} (E: 43cde93160458610ffb49fd16a02d123)`);return a;case"boolean":if(e===void 0||e===""){if(!s.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(`${r} ${m(t)}`),t}}b(ht,"getValueFromRawString");function mt({argIdentifier:s,paramInfos:e,throwIfNotFound:r}){let t=`[${mt.name}]`;try{let a=e.filter(o=>o.name===s||(o.synonyms??[]).includes(s));if(a.length===1)return x(a[0]);if(a.length>1)throw new Error(`(UNEXPECTED) multiple param infos found with argIdentifier. do you have overlapping arg names/synonyms? (${s} found in (${a.length} param infos)) (E: d599a6647c5ead6d9fbac4e4c96e6d23)`);if(r)throw new Error(`(UNEXPECTED) param info not found for argIdentifier (${s}) (E: 47e704068f2eb5a0551cf45d0e72c823)`);return}catch(a){throw console.error(`${t} ${m(a)}`),a}}b(mt,"getParamInfo");function Xa({rawArg:s}){let e=`[${Xa.name}]`;try{V&&console.log(`${e} starting... (I: 5d51b75b7a025e2e3fa498da7c08ac24)`);let r=b(o=>o.startsWith('"')&&o.endsWith('"')?"double":o.startsWith("'")&&o.endsWith("'")?"single":void 0,"fnGetQuoteType"),t=b(o=>r(o)?o.slice(0,o.length-1).slice(1):o,"fnStripQuotes"),a=r(s);if(a)return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:s.concat(),resolvedValueString:t(s),singleQuoted:a==="single",doubleQuoted:a==="double"}};if(s.match(/^(--\w|-\w|:\w)/))if(s.includes("=")){let o=/^(--|-|:)([\w\-]+)=(['"]?.+['"]?)$/,i=s.match(o);if(!i)throw new Error(`invalid rawArg (${s}). expected an arg matching regexp ${o}. (E: 05ca56163e184faeb66456a0e9190b28)`);let[n,l,c,d]=i,f=r(d);return{prefix:l,identifier:c,isNameValuePair:!0,valueInfo:{rawValueString:d,resolvedValueString:f?t(d):d,singleQuoted:f==="single",doubleQuoted:f==="double"}}}else{let o=/^(--|-|:)([\w\-]+)$/,i=s.match(o);if(!i)throw new Error(`invalid rawArg (${s}). 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,l,c]=i;return{prefix:l,identifier:c,isNameValuePair:!1,valueInfo:{rawValueString:void 0,resolvedValueString:"true",singleQuoted:!1,doubleQuoted:!1}}}else{if(s.includes("="))throw new Error(`invalid rawArg (${s}). 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:s,resolvedValueString:s,doubleQuoted:!1,singleQuoted:!1}}}}catch(r){throw console.error(`${e} ${r.message}`),r}finally{V&&console.log(`${e} complete.`)}}b(Xa,"parseRawArg");function ut({args:s,paramInfos:e,bareArgParamInfo:r=x(Ha),logalot:t}){let a=`[${ut.name}]`;try{(V||t)&&console.log(`${a} starting... (I: f389aaa490796dfd823bc7b9d4e58b23)`);let o=!1;return s.map((n,l)=>{let c,d,f,{prefix:h,identifier:g,isNameValuePair:u,valueInfo:w}=Xa({rawArg:n});if(h){if((V||t)&&console.log(`identifier: ${g} (I: 519ce129a1e34753a9070d3a205c9a8b)`),!g)throw new Error("(UNEXPECTED) prefix truthy but identifier falsy? (E: f33ab3a2b623acc0d1bc36685edfaf24)");if(c=g,!w)throw new Error("(UNEXPECTED) !valueInfo? (E: 05249a361a59008cd313d2dfa8f08b24)");if(u){V&&console.log(`${a} identifier with equals: ${g}. (I: 5f8ae91d1ddd4a7f94c0f4fb7e688502)`);let E=mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0});f={...E,value:ht({paramInfo:E,valueString:w.rawValueString}),identifier:c}}else{V&&console.log(`${a} identifier without equals: ${g}`),c=g;let E=mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0});f={...E,value:ht({paramInfo:E,valueString:void 0}),identifier:c,isFlag:!0}}}else if(l===0){if(!w)throw new Error("(UNEXPECTED) argIndex === 0 but valueInfo falsy? (E: 4642b42c855593b7ffdacb85f27dab24)");if(!w.rawValueString)throw new Error("(UNEXPECTED) !valueInfo.rawValueString? (E: 0b35f71eb8227cdd67ccfc32f2e45824)");if(w.singleQuoted)throw new Error("first arg is quoted? (single). a bare arg in first position must be a command/flag. (E: 28cce820417fd3b4f95ba6c7e94b4624)");if(w.doubleQuoted)throw new Error("first arg is quoted? (double). a bare arg in first position must be a command/flag. (E: 0b948c87081043fdb168f08ba05ebbce)");c=w.rawValueString,f={...mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0}),value:!0,identifier:c,isFlag:!0}}else{if((V||t)&&console.log("bare arg found. (I: d6f67074c7e44a63864948d4bf04bee8)"),!r)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 ${ut.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 E=x(r);f={...E,isBare:!0,identifier:E.name,value:ht({paramInfo:E,valueString:n})}}return V&&console.log(`${a} argInfo: ${y(f)}`),f})}catch(o){throw console.error(`${a} ${m(o)}`),o}finally{(V||t)&&console.log(`${a} complete.`)}}b(ut,"buildArgInfos");var Qt={encrypt_gib:"encrypt-gib"},Ji=Object.values(Qt);var R={hi:"hi",welcome:"welcome",bye:"bye",yes:"yes",no:"no",learn:"learn",wtg:"wtg"},G={help:"semantic_help",hello:"semantic_hello",bye:"semantic_bye",yes:"semantic_yes",no:"semantic_no",cancel:"semantic_cancel",skip:"semantic_skip",forget:"semantic_forget",next:"semantic_next",please:"semantic_please",in_progress:"semantic_in_progress",list:"semantic_list",request:"semantic_request",count:"semantic_count",options:"semantic_options",ready:"semantic_ready",stop:"semantic_stop",result:"semantic_result",unknown:"semantic_unknown",default:"semantic_default"};function H(s,e){return e.flatMap(r=>({texts:[r],language:"en-US",props:{semanticId:s}}))}b(H,"toLexDatums_Semantics");function de(s,e){return e.flatMap(r=>({texts:[r],language:"en-US",props:{atomicId:s}}))}b(de,"toLexDatums_Atomics");var zo={[G.help]:[...H(G.help,["h","help","help me"])],[G.yes]:[...H(G.yes,["yes","y","yeah","yea","aye","yup","yep","sure","ok","sounds good","go for it","yes please","yes thanks","ok thanks","uh huh","god yes","affirmative","ten four","10-4","roger"])],[G.no]:[...H(G.no,["no","n","nah","nay","nope","uh uh","no thanks","ick","nuh uh","god no","no way","not at all","negative","that's a negative","nein"])],[G.cancel]:[...H(G.cancel,["cancel","nm","nevermind","cancel that","don't worry about it"])],[G.skip]:[...H(G.skip,["skip","sk"])],[G.forget]:[...H(G.forget,["forget","forget this","forget this one"])],[G.next]:[...H(G.next,["next"])],[G.bye]:[...H(G.bye,["bye","bye bye","see you later","see you"])],[G.unknown]:[...H(G.unknown,["are you mocking me, human?","mmhmm...","i see...","does not compute...","indeed"])]},Ho={[R.hi]:[...de(R.hi,["hi","howdy","hello","greetings","good day","hello there","good day to you","yo"])],[R.welcome]:[...de(R.welcome,["welcome"])],[R.yes]:[...de(R.yes,["yes","y","yeah","yea","aye","yup","yep","sure","ok","sounds good","go for it","yes please","yes thanks","ok thanks","uh huh","god yes","affirmative","ten four","10-4","roger"])],[R.no]:[...de(R.no,["no","n","nope","no thanks","no thank you"])],[R.bye]:[...de(R.bye,["bye","bye bye","adios","ciao","later"])],[R.learn]:[...de(R.learn,["learn","study","review"])],[R.wtg]:[...de(R.wtg,["wtg","nice","not bad","pretty good","good job"])]},Xo={...zo,...Ho},Va={...x(Xo)},Vo={...x(Va)},as=new qa(Vo,{requestLanguage:"en-US",defaultLanguage:"en-US",defaultCapitalize:"none",defaultLineConcat:"delim",defaultDelim:`
|
|
1
|
+
import{a as Ca,b as xa,c as pt,d as Oa,e as Ra,f as Se,g as ke,h as Ma,i as Ua,j as Ba,k as va,l as Fa}from"./chunk-CITOSYSX.mjs";import{a as ja,b as z,d as Jt,e as ka,f as qa}from"./chunk-GL6JISTC.mjs";import{$ as ye,$a as ma,$c as dt,A as X,Aa as Ie,Ad as Da,B as j,Ba as aa,C as k,Ca as oa,Cd as je,Da as ia,Db as Ae,Ea as sa,Eb as $a,F as re,Fa as na,G as Ye,Ga as ca,H as ce,Ha as at,I as Ot,Ia as ot,J as Ne,Ja as la,K as Ce,Ka as da,L as Ur,M as Le,Ma as Oe,Mc as zt,N as Je,Na as Re,Nc as ct,O as Ee,Oa as Ft,Oc as Be,P as Br,Pc as Aa,Q as vr,R as Rt,Ra as it,Rc as Ht,S as Qe,Sa as fa,T as we,Ta as ba,Ua as pa,Ub as ya,V as Fr,Vb as q,W as jr,Wa as st,Wc as ae,Y as $e,Ya as Me,Yc as Xt,Z as De,Za as Ue,Zc as Sa,_ as kr,_a as ha,_c as lt,a as b,aa as qr,ab as jt,ad as _a,b as Gt,ba as zr,bd as Ta,ca as Mt,d as x,da as Ut,e as te,ea as Hr,ed as Ga,f as Pt,fa as Xr,fb as ua,g as O,ga as Vr,gd as Vt,h as y,ha as Wr,hb as kt,i as se,ia as Ke,ib as ga,id as ve,j as m,ja as Ze,jb as le,k as Mr,l as We,lb as Ea,m as Nt,ma as Yr,mb as wa,n as Ct,na as Jr,nc as Ia,o as Lt,oa as Qr,ob as nt,pa as et,pd as Pa,qa as Bt,r as ne,ra as Kr,rd as ft,s as ue,sa as Zr,t as Dt,ta as ea,td as Na,u as ge,ua as tt,va as xe,vd as Wt,w as $,wa as ta,wb as T,wd as Fe,x as N,xa as rt,xb as qt,xd as Yt,y as xt,ya as vt,yd as bt,za as ra,zd as La}from"./chunk-4S4RYXGE.mjs";var za={src:["source","from","in","input"],dest:["destination","to","out","output"]};function jo({paramName:s,noBare:e,argTypeName:r,description:t}){let a={name:`src-${s}`,argTypeName:r??"string",synonyms:[...za.src.map(o=>`${o}-${s}`)],description:t};return e||a.synonyms.push(s),a}b(jo,"getParam_src");function ko({paramName:s,argTypeName:e="string",description:r}){return{name:`dest-${s}`,argTypeName:e??"string",synonyms:[...za.dest.map(a=>`${a}-${s}`)],description:r}}b(ko,"getParam_dest");var Ha={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 ji=jo({paramName:"path",description:"for referencing/ingesting file(s)/folder(s) in a fs"}),ki=ko({paramName:"path",description:"for indicating where to put generated file(s)/folder(s)"});var V=!1;function ht({paramInfo:s,valueString:e}){let r=`[${ht.name}]`;try{switch(s.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 a=Number.parseInt(e);if(typeof a!="number")throw new Error(`arg value string (${e})did not parse to an integer. parse result: ${a} (E: 43cde93160458610ffb49fd16a02d123)`);return a;case"boolean":if(e===void 0||e===""){if(!s.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(`${r} ${m(t)}`),t}}b(ht,"getValueFromRawString");function mt({argIdentifier:s,paramInfos:e,throwIfNotFound:r}){let t=`[${mt.name}]`;try{let a=e.filter(o=>o.name===s||(o.synonyms??[]).includes(s));if(a.length===1)return x(a[0]);if(a.length>1)throw new Error(`(UNEXPECTED) multiple param infos found with argIdentifier. do you have overlapping arg names/synonyms? (${s} found in (${a.length} param infos)) (E: d599a6647c5ead6d9fbac4e4c96e6d23)`);if(r)throw new Error(`(UNEXPECTED) param info not found for argIdentifier (${s}) (E: 47e704068f2eb5a0551cf45d0e72c823)`);return}catch(a){throw console.error(`${t} ${m(a)}`),a}}b(mt,"getParamInfo");function Xa({rawArg:s}){let e=`[${Xa.name}]`;try{V&&console.log(`${e} starting... (I: 5d51b75b7a025e2e3fa498da7c08ac24)`);let r=b(o=>o.startsWith('"')&&o.endsWith('"')?"double":o.startsWith("'")&&o.endsWith("'")?"single":void 0,"fnGetQuoteType"),t=b(o=>r(o)?o.slice(0,o.length-1).slice(1):o,"fnStripQuotes"),a=r(s);if(a)return{prefix:void 0,identifier:void 0,isNameValuePair:!1,valueInfo:{rawValueString:s.concat(),resolvedValueString:t(s),singleQuoted:a==="single",doubleQuoted:a==="double"}};if(s.match(/^(--\w|-\w|:\w)/))if(s.includes("=")){let o=/^(--|-|:)([\w\-]+)=(['"]?.+['"]?)$/,i=s.match(o);if(!i)throw new Error(`invalid rawArg (${s}). expected an arg matching regexp ${o}. (E: 05ca56163e184faeb66456a0e9190b28)`);let[n,l,c,d]=i,f=r(d);return{prefix:l,identifier:c,isNameValuePair:!0,valueInfo:{rawValueString:d,resolvedValueString:f?t(d):d,singleQuoted:f==="single",doubleQuoted:f==="double"}}}else{let o=/^(--|-|:)([\w\-]+)$/,i=s.match(o);if(!i)throw new Error(`invalid rawArg (${s}). 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,l,c]=i;return{prefix:l,identifier:c,isNameValuePair:!1,valueInfo:{rawValueString:void 0,resolvedValueString:"true",singleQuoted:!1,doubleQuoted:!1}}}else{if(s.includes("="))throw new Error(`invalid rawArg (${s}). 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:s,resolvedValueString:s,doubleQuoted:!1,singleQuoted:!1}}}}catch(r){throw console.error(`${e} ${r.message}`),r}finally{V&&console.log(`${e} complete.`)}}b(Xa,"parseRawArg");function ut({args:s,paramInfos:e,bareArgParamInfo:r=x(Ha),logalot:t}){let a=`[${ut.name}]`;try{(V||t)&&console.log(`${a} starting... (I: f389aaa490796dfd823bc7b9d4e58b23)`);let o=!1;return s.map((n,l)=>{let c,d,f,{prefix:h,identifier:g,isNameValuePair:u,valueInfo:w}=Xa({rawArg:n});if(h){if((V||t)&&console.log(`identifier: ${g} (I: 519ce129a1e34753a9070d3a205c9a8b)`),!g)throw new Error("(UNEXPECTED) prefix truthy but identifier falsy? (E: f33ab3a2b623acc0d1bc36685edfaf24)");if(c=g,!w)throw new Error("(UNEXPECTED) !valueInfo? (E: 05249a361a59008cd313d2dfa8f08b24)");if(u){V&&console.log(`${a} identifier with equals: ${g}. (I: 5f8ae91d1ddd4a7f94c0f4fb7e688502)`);let E=mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0});f={...E,value:ht({paramInfo:E,valueString:w.rawValueString}),identifier:c}}else{V&&console.log(`${a} identifier without equals: ${g}`),c=g;let E=mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0});f={...E,value:ht({paramInfo:E,valueString:void 0}),identifier:c,isFlag:!0}}}else if(l===0){if(!w)throw new Error("(UNEXPECTED) argIndex === 0 but valueInfo falsy? (E: 4642b42c855593b7ffdacb85f27dab24)");if(!w.rawValueString)throw new Error("(UNEXPECTED) !valueInfo.rawValueString? (E: 0b35f71eb8227cdd67ccfc32f2e45824)");if(w.singleQuoted)throw new Error("first arg is quoted? (single). a bare arg in first position must be a command/flag. (E: 28cce820417fd3b4f95ba6c7e94b4624)");if(w.doubleQuoted)throw new Error("first arg is quoted? (double). a bare arg in first position must be a command/flag. (E: 0b948c87081043fdb168f08ba05ebbce)");c=w.rawValueString,f={...mt({argIdentifier:c,paramInfos:e,throwIfNotFound:!0}),value:!0,identifier:c,isFlag:!0}}else{if((V||t)&&console.log("bare arg found. (I: d6f67074c7e44a63864948d4bf04bee8)"),!r)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 ${ut.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 E=x(r);f={...E,isBare:!0,identifier:E.name,value:ht({paramInfo:E,valueString:n})}}return V&&console.log(`${a} argInfo: ${y(f)}`),f})}catch(o){throw console.error(`${a} ${m(o)}`),o}finally{(V||t)&&console.log(`${a} complete.`)}}b(ut,"buildArgInfos");var Qt={encrypt_gib:"encrypt-gib"},Ji=Object.values(Qt);var R={hi:"hi",welcome:"welcome",bye:"bye",yes:"yes",no:"no",learn:"learn",wtg:"wtg"},G={help:"semantic_help",hello:"semantic_hello",bye:"semantic_bye",yes:"semantic_yes",no:"semantic_no",cancel:"semantic_cancel",skip:"semantic_skip",forget:"semantic_forget",next:"semantic_next",please:"semantic_please",in_progress:"semantic_in_progress",list:"semantic_list",request:"semantic_request",count:"semantic_count",options:"semantic_options",ready:"semantic_ready",stop:"semantic_stop",result:"semantic_result",unknown:"semantic_unknown",default:"semantic_default"};function H(s,e){return e.flatMap(r=>({texts:[r],language:"en-US",props:{semanticId:s}}))}b(H,"toLexDatums_Semantics");function de(s,e){return e.flatMap(r=>({texts:[r],language:"en-US",props:{atomicId:s}}))}b(de,"toLexDatums_Atomics");var zo={[G.help]:[...H(G.help,["h","help","help me"])],[G.yes]:[...H(G.yes,["yes","y","yeah","yea","aye","yup","yep","sure","ok","sounds good","go for it","yes please","yes thanks","ok thanks","uh huh","god yes","affirmative","ten four","10-4","roger"])],[G.no]:[...H(G.no,["no","n","nah","nay","nope","uh uh","no thanks","ick","nuh uh","god no","no way","not at all","negative","that's a negative","nein"])],[G.cancel]:[...H(G.cancel,["cancel","nm","nevermind","cancel that","don't worry about it"])],[G.skip]:[...H(G.skip,["skip","sk"])],[G.forget]:[...H(G.forget,["forget","forget this","forget this one"])],[G.next]:[...H(G.next,["next"])],[G.bye]:[...H(G.bye,["bye","bye bye","see you later","see you"])],[G.unknown]:[...H(G.unknown,["are you mocking me, human?","mmhmm...","i see...","does not compute...","indeed"])]},Ho={[R.hi]:[...de(R.hi,["hi","howdy","hello","greetings","good day","hello there","good day to you","yo"])],[R.welcome]:[...de(R.welcome,["welcome"])],[R.yes]:[...de(R.yes,["yes","y","yeah","yea","aye","yup","yep","sure","ok","sounds good","go for it","yes please","yes thanks","ok thanks","uh huh","god yes","affirmative","ten four","10-4","roger"])],[R.no]:[...de(R.no,["no","n","nope","no thanks","no thank you"])],[R.bye]:[...de(R.bye,["bye","bye bye","adios","ciao","later"])],[R.learn]:[...de(R.learn,["learn","study","review"])],[R.wtg]:[...de(R.wtg,["wtg","nice","not bad","pretty good","good job"])]},Xo={...zo,...Ho},Va={...x(Xo)},Vo={...x(Va)},as=new qa(Vo,{requestLanguage:"en-US",defaultLanguage:"en-US",defaultCapitalize:"none",defaultLineConcat:"delim",defaultDelim:`
|
|
2
2
|
|
|
3
3
|
`,defaultKeywordMode:"any",defaultPropsMode:"prop"}),Wa={...x(Va)};Wa[G.bye].push({texts:["EOL"],ssmls:[ka.sub("EOL","end of line")],language:"en-US",props:{semanticId:G.bye},weighting:100});Wa[G.unknown]=[...H(G.unknown,["i'm not quite sure what you mean","does not compute"])];var _e=!1;function Ya({robbotData:s}){let e=`[${Ya.name}]`;try{if(_e&&console.log(`${e} starting...`),!s)throw new Error("robbotData required (E: 1ac78ffae5354b67acb64a34cfe23c2f)");let r=[],{name:t,uuid:a,classname:o,outputPrefix:i,outputSuffix:n}=s;return t?t.match(Ne)||r.push(`name must match regexp: ${Ne}`):r.push("name required."),a?a.match(Gt)||r.push(`uuid must match regexp: ${Gt}`):r.push("uuid required."),i&&(i.match(Ce)||r.push(`outputPrefix must match regexp: ${Ce}`)),n&&(n.match(Ce)||r.push(`outputSuffix must match regexp: ${Ce}`)),o&&(o.match(Ne)||r.push(`classname must match regexp: ${Ne}`)),r}catch(r){throw console.error(`${e} ${r.message}`),r}finally{_e&&console.log(`${e} complete.`)}}b(Ya,"validateCommonRobbotData");async function Kt({robbotIbGib:s}){let e=`[${Kt.name}]`;try{_e&&console.log(`${e} starting... (I: f7b34d791a483b8c5a9d188da66d3f22)`);let r=await re({ibGib:s})??[];if(!s.data)throw new Error("robbotIbGib.data required (E: 754a8d2540610696aff04b0d159daa23)");let t=[],{robbotClassname:a,robbotName:o,robbotId:i}=Ja({robbotIb:s.ib});a||t.push("robbotClassname required (E: 3234d39bf1c74ec3aff59f374282dfc8)"),o||t.push("robbotName required (E: b329dcc62ff548d7aa0681393b2c7057)"),i||t.push("robbotId required (E: b562c953bfaf4dd49e4d3a08304ee2fc)");let n=Ya({robbotData:s.data}),l=[...r??[],...t??[],...n??[]];return l.length>0?l:void 0}catch(r){throw console.error(`${e} ${r.message}`),r}finally{_e&&console.log(`${e} complete.`)}}b(Kt,"validateCommonRobbotIbGib");function Ja({robbotIb:s}){let e=`[${Ja.name}]`;try{if(!s)throw new Error("robbotIb required (E: 4a35881058094f1a90bb4ea37052d6d7)");let r=s.split(" ");return{robbotClassname:r[2],robbotName:r[3],robbotId:r[4]}}catch(r){throw console.error(`${e} ${r.message}`),r}}b(Ja,"parseRobbotIb");async function Zt({fnPromptRobbot:s,ibgibs:e,space:r}){let t=`[${Zt.name}]`;try{if(_e&&console.log(`${t} starting...`),!e)throw new Error("(UNEXPECTED) ibgibs service required. (E: 4be5d20dc81fcdabb8d7d4cd47458522)");r=r??await e.getLocalUserSpace({lock:!0});let a=await s(r,null);if(!a)throw new Error("robbot prompt returned nothing. canceled? (E: 1a08529b53bd3d79c6587b196e5e0823)");let o=a.newIbGib;try{await se(1e3);let i=[];i.push(o),a.intermediateIbGibs?.forEach(d=>i.push(d)),a.dnas?.forEach(d=>i.push(d));for(let d=0;d<i.length;d++){let f=i[d],h=await re({ibGib:f});if((h??[]).length>0)throw new Error(`(unexpected) invalid robbot ibgib created. validationErrors: ${h}. robbot: ${y(o.toIbGibDto())} (E: a683268621cd6dd3dd60310b164c4d22)`)}await Ie({resTransform:a,space:r});let{zeroSpace:n,fnBroadcast:l,fnUpdateBootstrap:c}=e;await at({ibGib:o,space:r,fnBroadcast:b(d=>l(d),"fnBroadcast")}),await ot({type:"robbots",rel8nName:Le,ibGibsToRel8:[o],space:r,zeroSpace:n,fnUpdateBootstrap:c,fnBroadcast:l})}catch(i){throw console.error(`${t} ${i.message}`),i}return o}catch(a){console.error(`${t} ${a.message}`);return}finally{_e&&console.log(`${t} complete.`)}}b(Zt,"createNewRobbot");var gt="secret";var p=!1,Et=class s{static{b(this,"MetaspaceBase")}cacheSvc;lc=`[${s.name}]`;instanceId=new Date().toUTCString();_initialized=!1;get initialized(){return this._initialized}_initializedSubj;initialized$;_initializing=!1;get initializing(){return this._initializing}_latestSubj;latestObs;async getLocalUserSpace({lock:e=!1,localSpaceId:r}){let t=`${this.lc}[${this.getLocalUserSpace.name}]`;try{p&&console.log(`${t} starting...`),e??=!1;let a=await Re({zeroSpace:this.zeroSpace})??void 0;return await Ft({zeroSpace:this.zeroSpace,bootstrapIbGib:a,lock:e,callerInstanceId:this.instanceId,localSpaceId:r,fnDtoToSpace:b(i=>this.metaspaceFactory.fnDtoToSpace(i),"fnDtoToSpace"),localSpaceCacheSvc:this.cacheSvc})}catch(a){throw console.error(`${t} ${a.message}`),a}finally{p&&console.log(`${t} complete.`)}}async getLocalUserSpaces({lock:e=!1}){let r=`${this.lc}[${this.getLocalUserSpaces.name}]`;try{p&&console.log(`${r} starting...`);let t=[];e??=!1;let a=await Re({zeroSpace:this.zeroSpace});if(!a)throw new Error("(UNEXPECTED) bootstrapIbGib falsy (E: fff2de921a3ee56a1d70e4ac320e4122)");if(!a.data)throw new Error("(UNEXPECTED) bootstrapIbGib data falsy (E: 7f9d08050f214078b2f85dd2ed47e005)");if(!a.data[ye])throw new Error(`(UNEXPECTED) bootstrapIbGib data invalid. data[${ye}] falsy (E: 37614e2e8f914d6ab7c605cf064a80d2)`);if(a.data[ye].length===0)throw new Error(`(UNEXPECTED) bootstrapIbGib data invalid. data[${ye}] length === 0 (E: d57691d17e6b4d7ea3a8fed36c0f47e5)`);let o=a.data[ye];for(let i=0;i<o.length;i++){let n=o[i];if(!n)throw new Error("(UNEXPECTED) localSpaceId falsy (E: 582c520897f5355d642229eae122ac22)");let l=await Ft({zeroSpace:this.zeroSpace,bootstrapIbGib:a,lock:e,localSpaceId:n,callerInstanceId:this.instanceId,fnDtoToSpace:b(c=>this.metaspaceFactory.fnDtoToSpace(c),"fnDtoToSpace"),localSpaceCacheSvc:this.cacheSvc});t.push(l)}return t}catch(t){throw console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}async deleteLocalUserSpace({spaceId:e,deletePhysicalStorage:r=!0}){let t=`${this.lc}[${this.deleteLocalUserSpace.name}]`;try{if(p&&console.log(`${t} starting... spaceId: ${e} (I: 812fa4810b1241a590b512a8e0915623)`),!e)throw new Error("spaceId required. (E: 19fa5120a4024b819e917f9db0972b23)");await fa({spaceId:e,zeroSpace:this.zeroSpace}),await ba({spaceId:e,zeroSpace:this.zeroSpace}),p&&console.log(`${t} complete.`)}catch(a){throw console.error(`${t} ${a.message}`),a}}passwordCache={};_syncing=!1;get syncing(){return this._syncing}sagaInfoMap={};_alwaysAutosyncTjpAddrsCache=new Set;isPrompting=!1;_precalculatedIds=[];getUUIDSync(){let e=`${this.lc}[${this.getUUIDSync.name}]`;try{p&&console.log(`${e} starting...`);let r=this._precalculatedIds.pop();if(!r)throw new Error("no precalculated ids? (E: 14915489b21d031ee9ca695737ac6923)");return this._precalculatedIds.length<100&&this.precalculateSomeUUIDsPlease(),r}catch(r){throw console.error(`${e} ${r.message}`),r}finally{p&&console.log(`${e} complete.`)}}async precalculateSomeUUIDsPlease(){let e=`${this.lc}[${this.precalculateSomeUUIDsPlease.name}]`;try{p&&console.log(`${e} starting...`);let r=[];for(let t=0;t<500;t++){let a=await O();r.push(a)}this._precalculatedIds=r}catch(r){throw console.error(`${e} ${r.message}`),r}finally{p&&console.log(`${e} complete.`)}}async initializeObservables(){let e=`${this.lc}[${this.initializeObservables.name}]`;try{p&&console.log(`${e} starting... (I: f5dc6d6352eaf2f41809ddec76ea5923)`),this._initializedSubj=await je({replay:!0}),this.initialized$=this._initializedSubj.asObservable(),this._latestSubj=await je(),this.latestObs=this._latestSubj.asObservable()}catch(r){throw console.error(`${e} ${r.message}`),r}finally{p&&console.log(`${e} complete.`)}}metaspaceFactory={};getFnAlert;getFnPrompt;getFnPromptPassword;constructor(e){this.cacheSvc=e;let r=`${this.lc}[ctor]`;p&&(console.log(`${r}${Ot}`),console.timeLog(Ot),console.log(`${r} created. (I: 5fe7af9fccc2488282eecc8255729cec)`))}async initializeMetaspaceFactory({metaspaceFactory:e}){let r=`[${this.initializeMetaspaceFactory.name}]`;try{p&&console.log(`${r} starting... (I: 0b84dfb68c1e89e0af880d4461fe4b23)`),this.metaspaceFactory=e}catch(t){throw console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}async initialize({spaceName:e,metaspaceFactory:r,getFnAlert:t,getFnPrompt:a,getFnPromptPassword:o}){let i=`${this.lc}[${this.initialize.name}]`;try{if(this.instanceId=await O(),!t)throw new Error("getFnAlert required (E: c7ded289d9b6265b6d1294988faba923)");if(!a)throw new Error("getFnPrompt required (E: cce7733db0abbf9a41fa45b6b9bf9523)");if(!o)throw new Error("getFnPromptPassword required (E: cadae9f5df9a7c310e76b63cb6afb623)");this.getFnAlert=t,this.getFnPrompt=a,this.getFnPromptPassword=o;let n=`${i}[timer]`;p&&(n=i+"[timer 71cbfa]",console.log(`${i} starting timer ${n}`),console.time(n)),await this.precalculateSomeUUIDsPlease(),await this.initializeObservables(),p&&console.timeLog(n),await this.initializeMetaspaceFactory({metaspaceFactory:r??={}}),await this.initializeLocalSpaces({spaceName:e}),p&&console.timeLog(n),await this.initializeSpecialIbGibs_required({timerName:n}),await this.initializeSpecialIbGibs_other({timerName:n}),p&&(console.timeEnd(n),console.log(`${i} timer ${n} complete.`)),this._initialized=!0,await this._initializedSubj.next(ue),p&&console.log(`${i} initialized (I: e3b3a9652c09445cb055013166ff089c)`)}catch(n){throw console.error(`${i} ${n.message}`),n}}async initializeSpecialIbGibs_required({timerName:e}){let r=`[${this.initializeSpecialIbGibs_required.name}]`;try{p&&console.log(`${r} starting... (I: 8cb7f63d766ab38885dc63d8da9cd323)`),await this.getSpecialIbGib({type:"latest",initialize:!0}),p&&console.timeLog(e),await this.getSpecialIbGib({type:"roots",initialize:!0}),p&&console.timeLog(e),await this.getSpecialIbGib({type:"tags",initialize:!0}),p&&console.timeLog(e),await this.getSpecialIbGib({type:"apps",initialize:!0}),p&&console.timeLog(e)}catch(t){throw console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}async initializeSpecialIbGibs_outerspaces({timerName:e}){let r=`[${this.initializeSpecialIbGibs_outerspaces.name}]`;try{p&&console.log(`${r} starting... (I: 4f5ca25899384ceabd65e30cdf58f889)`),await this.getSpecialIbGib({type:"outerspaces",initialize:!0}),p&&console.timeLog(e),await this.getSpecialIbGib({type:"autosyncs",initialize:!0}),p&&console.timeLog(e),await this.loadAutoSyncs()}catch(t){throw console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}async initializeSpecialIbGibs_other({timerName:e}){let r=`[${this.initializeSpecialIbGibs_other.name}]`;try{p&&console.log(`${r} starting... (I: 3cad0b16f5dac3686929dd1923ee3623)`)}catch(t){throw console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}async initializeLocalSpaces({spaceName:e}){let r=`${this.lc}[${this.initializeLocalSpaces.name}]`;try{p&&console.log(`${r} starting...`);let t=this.zeroSpace;t.gib||(t.gib=await j({ibGib:t,hasTjp:!1})),p&&console.log(`${r} getting bootstrap ibgib (I: a4ad1cfd5c6f895e879d9e6a5f607b22)`);let a=kr,o=await Re({zeroSpace:t});o?(p&&console.log(`${r} getting bootstrap ibgib with locking from zero space...`),o=await Oe({space:t,scope:a,secondsValid:Fr,fn:b(async()=>{let i=await Re({zeroSpace:t});if(!i)throw new Error("failed to get validated bootstrapIbGib (E: a4318a8183c3d8979981c29bd4ecb223)");return i},"fn"),callerInstanceId:this.instanceId}),p&&console.log(`${r} got bootstrap ibgib with locking from zero space.`)):(p&&console.log(`${r} getting from default space...not found. bootstrap space not found. will create... (I: 3170ac1a310d41f29f2b2b075cde6bdb)`),await this.createLocalSpaceAndUpdateBootstrap({zeroSpace:t,allowCancel:!1,createBootstrap:!0,spaceName:e}))}catch(t){throw p&&console.log(`${r} getting from default space...not found. bootstrap space not found. (E: 617bb62c3b6c4c01a5faec7f06c719fd)`),console.error(`${r} ${t.message}`),t}finally{p&&console.log(`${r} complete.`)}}createNewLocalSpace({opts:e,fnLocalSpaceFactory:r}){let t=`[${this.createNewLocalSpace.name}]`;try{if(p&&console.log(`${t} starting... (I: ac652df9d652459d98832be8483544d1)`),!e)throw new Error("opts required (E: f1d50207b35c96985ba6c2e1a18a4e23)");if(e.getFnPrompt||(p&&console.log(`${t} incoming opts getFnPrompt falsy. using this.getFnPrompt (I: 1f331752ac81ffc48e2da0b27dafba23)`),e.getFnPrompt=this.getFnPrompt),r??=this.metaspaceFactory.fnDefaultLocalSpaceFactory,!r)throw new Error("neither fnLocalSpaceFactory nor this.fnDefaultLocalSpaceFactory provided (E: 5142df9dbae63fd0ffef8165782dc423)");return r(e)}catch(a){throw console.error(`${t} ${a.message}`),a}finally{p&&console.log(`${t} complete.`)}}async createLocalSpaceAndUpdateBootstrap({zeroSpace:e,allowCancel:r,createBootstrap:t,spaceName:a,getFnPrompt:o}){let i=`${this.lc}[${this.createLocalSpaceAndUpdateBootstrap.name}]`;try{let n;if(r){if(n=await this.createNewLocalSpace({opts:{allowCancel:r,spaceName:a,logalot:p,getFnPrompt:o??this.getFnPrompt}}),!n)return}else do n=await this.createNewLocalSpace({opts:{allowCancel:r,spaceName:a,logalot:p,getFnPrompt:o??this.getFnPrompt}});while(!n);t&&(p&&console.log(`${i} creating new bootstrap ibgib (I: ecc58dd4af21a0c69a16b3d71dad9c22)`),await it({space:n,zeroSpace:e,setSpaceAsDefault:!0,createIfNotFound:!0}));let l=await e.argy({ibMetadata:pa({space:n}),argData:{cmd:"put",ibGibAddrs:[$({ibGib:n})]},ibGibs:[n]});p&&console.log(`${i} save the localSpace in default zero space (I: 1b34fb9f548042ab9d9ae0619377e370)`);let c=await e.witness(l);if(c?.data?.success)p&&console.log(`${i} default zero space witnessed the user space (I: b6314ea887d34609904db3bb76ae2f9b)`);else throw new Error(`${c?.data?.errors?.join("|")||"There was a problem with zeroSpace witnessing the new localSpace (E: b952e888a4954cc5b671034b8384e750)"}`);p&&console.log(`${i} save the new localSpace in its own space (I: e1f520f2cc614b1fa9c1ebd1c4dd6957)`);let d=await n.witness(l);if(d?.data?.success)p&&console.log(`${i} user space witnessed itself`);else throw new Error(`${d?.data?.errors?.join("|")||"There was a problem with localSpace witnessing itself. (E: 33d4b1ffcca64160afe67046531958b5)"}`);return await it({space:n,zeroSpace:this.zeroSpace}),n}catch(n){throw console.error(`${i} ${n.message}`),this.getFnAlert()({title:"failed",msg:`failed to initialize the local space. error: ${n.message}`}),n}}async createTagIbGib({text:e,icon:r,description:t,space:a}){let o=`${this.lc}[${this.createTagIbGib.name}]`;try{if(a=a??await this.getLocalUserSpace({}),!a)throw new Error("space falsy and localUserSpace not initialized (E: 18f846b645124210a2ff1611641a8daf)");return da({text:e,icon:r,description:t,space:a,zeroSpace:this.zeroSpace,fnBroadcast:b(i=>this.fnBroadcast(i),"fnBroadcast"),fnUpdateBootstrap:b(i=>this.fnUpdateBootstrap(i),"fnUpdateBootstrap")})}catch(i){throw console.error(`${o} ${i.message}`),i}}async trash({ibGib_Context:e,rel8nName_Context:r,addr:t,space:a}){let o=`${this.lc}[${this.trash.name}]`;try{if(p&&console.log(`${o} starting... (I: 4cf73be6e3294124a78a4a45368bfbcc)`),!e)throw new Error("ibGib_Context required (E: 09dd5e5a9f784953a42d70b1827ba442)");if(!r)throw new Error("rel8nName_Context required (E: cb6edaaac586773b08fd18855fc11322)");if(!t)throw new Error("addr required (E: 14f27805749c499098cebc0b1b11bc57)");if(a=a??await this.getLocalUserSpace({}),!a)throw new Error("space falsy and localUserSpace not initialized (E: f81574e3437a4b88acd044b2abdc1ae4)");await ha({ibGib_Context:e,rel8nName_Context:r,addr:t,space:a,zeroSpace:this.zeroSpace,fnBroadcast:b(i=>this.fnBroadcast(i),"fnBroadcast"),fnUpdateBootstrap:b(i=>this.fnUpdateBootstrap(i),"fnUpdateBootstrap")})}catch(i){throw console.error(`${o} ${i.message}`),i}finally{p&&console.log(`${o} complete.`)}}async archive({ibGib_Context:e,rel8nName_Context:r,addr:t,space:a}){let o=`${this.lc}[${this.archive.name}]`;try{if(p&&console.log(`${o} starting... (I: 785b44dbb7b048cb8c210a907b73b4c8)`),!e)throw new Error("ibGib_Context required (E: dc277b47aa4f42118ad14bfc817bf1d5)");if(!r)throw new Error("rel8nName_Context required (E: 87bd7ffa820645e9bdfb17fc726249ba)");if(!t)throw new Error("addr required (E: f6ce4e1325c84aa9b3da31c5b9dcc787)");if(a=a??await this.getLocalUserSpace({}),!a)throw new Error("space falsy and localUserSpace not initialized (E: d6e0b1618eec400e820de6ac37491d39)");await ma({ibGib_Context:e,rel8nName_Context:r,addr:t,space:a,zeroSpace:this.zeroSpace,fnBroadcast:b(i=>this.fnBroadcast(i),"fnBroadcast"),fnUpdateBootstrap:b(i=>this.fnUpdateBootstrap(i),"fnUpdateBootstrap")}),p&&console.log(`${o} archived '${t.slice(0,32)}...' (I: 767b06c8cadd58c618924f0cd98a1723)`)}catch(i){throw console.error(`${o} ${i.message}`),i}finally{p&&console.log(`${o} complete.`)}}async getConfigAddr({key:e,space:r}){let t=`${this.lc}[${this.getConfigAddr.name}](${e})`;try{if(p&&console.log(`${t} getting...`),r=r??await this.getLocalUserSpace({}),!r)throw new Error("space falsy and could not get local space. (E: b6e7fcc09c6244b99b2e6e6ece398db0)");return ia({key:e,space:r})}catch(a){console.error(`${t} ${a.message}`);return}}fnUpdateBootstrap=b(async e=>{await it({space:e,zeroSpace:this.zeroSpace})},"fnUpdateBootstrap");fnBroadcast=b(e=>{this._latestSubj.next(e)},"fnBroadcast");async setConfigAddr({key:e,addr:r,space:t}){let a=`${this.lc}[${this.setConfigAddr.name}]`;try{if(t=t??await this.getLocalUserSpace({}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: 2149c59ebd584a118304dd54656aa800)");return await sa({key:e,addr:r,space:t,zeroSpace:this.zeroSpace,fnUpdateBootstrap:b(o=>this.fnUpdateBootstrap(o),"fnUpdateBootstrap")})}catch(o){throw console.error(`${a} ${o.message}`),o}}async getCurrentRoot({space:e}){let r=`${this.lc}[${this.getCurrentRoot.name}]`;try{if(e=e??await this.getLocalUserSpace({}),!e)throw new Error("space falsy and localUserSpace not initialized (?) (E: 1f4dc5e9560341a993bf0b28accd75fe)");for(;this.initializing;)p&&console.log(`${r} hacky wait while initializing ibgibs service (I: 5fd759510e584cb69b232259b891cca1)`),await se(100);let t=await this.getSpecialIbGib({type:"roots",space:e});if(!t)throw new Error("Roots not initialized. (E: e7712dc3d183487e98cd44a2b4324bc2)");if(!t.rel8ns)throw new Error("Roots not initialized properly. No rel8ns. (E: 689f47f5d1da4a868d1c1ddd2ff13e17)");if(!t.rel8ns.current)throw new Error("Roots not initialized properly. No current root. (E: 962acd3f60474a329bfbd7682c003916)");if(t.rel8ns.current.length===0)throw new Error("Invalid Roots: empty current root rel8n. (E: fbdc13c157514efa86ade1bf9a38bbd6)");if(t.rel8ns.current.length>1)throw new Error("Invalid Roots: multiple current roots selected. (E: 370fe6e3920a4a1299f879e6fcbbc448)");let a=t.rel8ns.current[0],o=await this.get({addr:a,space:e});if(o.ibGibs?.length===1)return o.ibGibs[0];throw new Error(`could not get current root. addr: ${a} (E: 69de35c5f71e45a1a5d83228e136642b)`)}catch(t){console.error(`${r} ${t.message}`);return}}async setCurrentRoot({root:e,space:r}){let t=`${this.lc}[${this.setCurrentRoot.name}]`;try{if(!e)throw new Error("root required.");if(r=r??await this.getLocalUserSpace({}),!r)throw new Error("space falsy and localUserSpace not initialized (?) (E: 222a3f5b39fc47ccb2a4aa3ddcd49969)");return na({root:e,space:r,zeroSpace:this.zeroSpace,fnBroadcast:b(a=>this.fnBroadcast(a),"fnBroadcast"),fnUpdateBootstrap:b(a=>this.fnUpdateBootstrap(a),"fnUpdateBootstrap")})}catch(a){throw console.error(`${t} ${a.message}`),a}}async rel8ToCurrentRoot({ibGib:e,linked:r,rel8nName:t,space:a}){let o=`${this.lc}[${this.rel8ToCurrentRoot.name}]`;try{if(a=a??await this.getLocalUserSpace({}),!a)throw new Error("space falsy and localUserSpace not initialized (?) (E: cbc4e519414a405eab7fe470eadbf8f0)");return ca({ibGib:e,linked:r,rel8nName:t,space:a,zeroSpace:this.zeroSpace,fnBroadcast:b(i=>this.fnBroadcast(i),"fnBroadcast"),fnUpdateBootstrap:b(i=>this.fnUpdateBootstrap(i),"fnUpdateBootstrap")})}catch(i){console.error(`${o} ${i.message}`);return}}async rel8ToSpecialIbGib(e){let r=`${this.lc}[${this.rel8ToSpecialIbGib.name}](type:${e.type},rel8nName:${e.rel8nName})`;try{let{type:t,rel8nName:a,ibGibsToRel8:o,ibGibsToUnRel8:i,addrsToUnRel8:n,linked:l,severPast:c,deletePreviousSpecialIbGib:d,space:f}=e;if(f=f??await this.getLocalUserSpace({}),!f)throw new Error("space falsy and localUserSpace not initialized (?) (E: af863928bbc945549ffc4dcca830a70a)");return ot({...e,space:f,zeroSpace:this.zeroSpace,fnUpdateBootstrap:b(h=>this.fnUpdateBootstrap(h),"fnUpdateBootstrap"),fnBroadcast:b(h=>this.fnBroadcast(h),"fnBroadcast")})}catch(t){throw console.error(`${r} ${t.message}`),t}}async registerNewIbGib({ibGib:e,space:r}){let t=`${this.lc}[${this.registerNewIbGib.name}]`;try{let a=$({ibGib:e});if(t=`${t}[${a}]`,r=r??await this.getLocalUserSpace({}),!r)throw new Error("space falsy and localUserSpace not initialized (?) (E: d7e6d609a784449087cbaf1bbfb6b0c2)");return p&&console.log(`${t} starting...`),at({ibGib:e,space:r,fnBroadcast:b(o=>this.fnBroadcast(o),"fnBroadcast")})}catch(a){throw console.error(`${t} ${a.message}`),a}finally{p&&console.log(`${t} complete.`)}}async pingLatest_Local({ibGib:e,tjpIbGib:r,space:t,useCache:a}){let o=`${this.lc}[${this.pingLatest_Local.name}]`;p&&console.log(`${o} starting...`);try{if(!e){p&&console.log(`${o} ibGib falsy.`);return}if(X({ibGib:e})){console.warn(`${o} tried to ping latest for primitive. returning early... (W: 06c50cfe028cc04cca67e97a48e6fe22)`);return}if(e.ib.startsWith("witness space IonicSpace_V1")){let{spaceId:d}=Me({spaceIb:e.ib}),f=await this.getLocalUserSpace({localSpaceId:d});await this._latestSubj.next({ib:"IbGibTimelineUpdateInfo",latestIbGib:f,latestAddr:$({ibGib:f}),tjpAddr:`${e.ib}^gib`});return}if(t=t??await this.getLocalUserSpace({}),!t){console.warn(`${o} space falsy and localUserSpace not initialized. (W: e6708e58618947a6b66f6a49406cbf35)`);return}let i,n=$({ibGib:e}),l,c=await this.getLatestAddr({ibGib:e,tjp:r,space:t})??n;if(r||(r=await this.getTjpIbGib({ibGib:e,space:t}),r||(console.warn(`${o} tjp not found for ${n}? Should at least just be the ibGib's address itself. (W: 15d9c6daca7e442e968af36b4c18b8f7)`),r=e)),l=$({ibGib:r}),c===n)p&&console.log(`${o} latestAddr === ibGibAddr (I: f38042421fcc3d148a26ed56651c2522)`),i=e;else{p&&console.log(`${o} later version found. ibGibAddr: ${n}
|
|
4
4
|
latestAddr: ${c} (I: 53cabd1643df7d43635af642e4c90922)`);let d=await this.get({addr:c,space:t});if(!d.success||d.ibGibs?.length!==1)throw new Error("latest not found (E: bc54e433573a5a89c6436dc6a3b60922)");i=d.ibGibs[0]}if(i&&c&&l)await this._latestSubj.next({ib:"IbGibTimelineUpdateInfo",latestIbGib:i,latestAddr:c,tjpAddr:l});else{debugger;throw new Error("(UNEXPECTED) latestIbGib, latestAddr and tjpAddr should all be truthy. (E: 20e71fa1a72c45deb1dc5083903a8622)")}}catch(i){console.error(`${o} ${i.message}`)}finally{p&&console.log(`${o} complete.`)}}async persistTransformResult({resTransform:e,force:r,space:t}){let a=`${this.lc}[${this.persistTransformResult.name}]`;try{if(t=t??await this.getLocalUserSpace({}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: f8b3d06006874b479240eb45f4015628)");return Ie({resTransform:e,force:r,space:t})}catch(o){throw console.error(`${a} ${o.message}`),o}}async get({addr:e,addrs:r,isDna:t,space:a}){let o=`${this.lc}[${this.get.name}]`;try{if(a=a??await this.getLocalUserSpace({}),!a)throw new Error("space falsy and localUserSpace not initialized (?) (E: 86ccdcf3417a45b4a3a8c280fb9a6df7)");return rt({addr:e,addrs:r,isDna:t,space:a})}catch(i){return console.error(`${o} ${i.message}`),Promise.resolve({errorMsg:i.message})}}async put({ibGib:e,ibGibs:r,isDna:t,force:a,space:o}){let i=`${this.lc}[${this.put.name}]`;try{if(o=o??await this.getLocalUserSpace({}),!o)throw new Error("space falsy and localUserSpace not initialized (?) (E: a00eebe0e3d348d09fda62a6be486b6c)");return vt({ibGib:e,ibGibs:r,isDna:t,force:a,space:o})}catch(n){return console.error(`${i} ${n.message}`),Promise.resolve({errorMsg:n.message})}}async delete({addr:e,isDna:r,space:t}){let a=`${this.lc}[${this.delete.name}]`;try{if(t=t??await this.getLocalUserSpace({}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: b4250b0045dc40629447f2cbd162faaa)");return ra({addr:e,isDna:r,space:t})}catch(o){return console.error(`${a} ${o.message}`),Promise.resolve({errorMsg:o.message})}}async getDependencyGraph(e){let r=`${this.lc}[${this.getDependencyGraph.name}]`;try{if(e.space=e.space??await this.getLocalUserSpace({})??null,!e.space)throw new Error("(UNEXPECTED) space falsy and localUserSpace not initialized (?) (E: e2a35a23d12d48ebadcfd4f1a396d6c1)");return Ia(e)}catch(t){throw console.error(`${r} ${t.message}`),t}}async getLatestAddr({ibGib:e,addr:r,tjpAddr:t,tjp:a,space:o}){let i=`${this.lc}[${this.getLatestAddr.name}]`;p&&console.log(`${i} starting...`);try{if(!e&&!a&&!t&&!r)throw new Error("ibGib && tjp && tjpAddr && addr are all falsy (E: fe725654342c4d80a33219160b5d81d3)");if(o=o??await this.getLocalUserSpace({}),!o)throw new Error("space falsy and localUserSpace not initialized (?) (E: fd01bb85e91f4c54bfe8b35714d48a38)");let n=await Ue({ibGibs:e?[e]:void 0,addrs:r?[r]:void 0,tjpAddrs:t?[t]:void 0,tjps:a?[a]:void 0,space:o});if(!n)throw new Error("resGetLatest falsy (E: 3851bbe4427ae11771f222234e8c6622)");if(!n.data)throw new Error("invalid resGetLatest: data falsy (E: 134e0f1f65edc69c6951c32e00a4bb22)");if(n.data.success){let l=n.data.latestAddrsMap;if(l){let c=Object.keys(l);if(c.length===1)return l[c[0]]||void 0;if(c.length===0)return n.data.addrsNotFound?.length===1,void 0;throw new Error("(UNEXPECTED) latestAddrsMap has multiple entries? We only asked for one. (E: 790518290f6b46729017684698539222)")}else{if(n.data.addrs?.length===1)return n.data.addrs[0];if(n.data.addrsNotFound?.length===1)return}if(n.data.addrsErrored?.length===1){let c=n.data.errors?.join("|")??"[unspecified error(s)] (E: 24f338036aa84ac99e3c39a660207222)";throw new Error(`resGetLatest had error(s): ${c}`)}else throw new Error(`unknown error, invalid resGetLatest: ${y(n)} (E: 6aa5aa225ebf49b588664370cb8feb22)`)}else{let l=n.data.errors?.join("|")??"[unspecified error(s)] (E: dcd6dcd6ec052fd112a4d48f1afa2922)";throw new Error(`resGetLatest had error(s): ${l}`)}}catch(n){throw console.error(`${i} ${n.message}`),n}finally{p&&console.log(`${i} complete.`)}}async getTjpIbGib({ibGib:e,naive:r=!0,space:t}){let a=`${this.lc}[${this.getTjpIbGib.name}]`;try{if(t=t??await this.getLocalUserSpace({}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: 0ec806bd2c5641c4844a3698c922e1f6)");return t?la({ibGib:e,naive:r,space:t}):(console.warn(`${a} space falsy and localUserSpace not initialized.`),e)}catch(o){throw console.error(`${a} ${o.message}`),o}}async getSpecialIbGib({type:e,initialize:r,space:t,lock:a,dontWarnIfNotExist:o}){let i=`${this.lc}[${this.getSpecialIbGib.name}]`;try{if(t=t??await this.getLocalUserSpace({lock:a}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: e08e85d8422e479f9d101194fd26cbda)");for(;this.initializing;)p&&console.log(`${i} hacky wait while initializing ibgibs service (I: 497d4becb94f4515a2ec389630420d6c)`),await se(100);return oa({type:e,initialize:r,space:t,zeroSpace:this.zeroSpace,fnUpdateBootstrap:b(n=>this.fnUpdateBootstrap(n),"fnUpdateBootstrap"),fnBroadcast:b(n=>this.fnBroadcast(n),"fnBroadcast"),fnGetInitializing:b(()=>this._initializing,"fnGetInitializing"),fnSetInitializing:b(n=>{this._initializing=n},"fnSetInitializing"),dontWarnIfNotExist:o})}catch(n){return console.error(`${i} ${n.message}`),null}}async getSpecialRel8dIbGibs({type:e,rel8nName:r,space:t}){let a=`${this.lc}[${this.getSpecialRel8dIbGibs.name}]`;try{if(t=t??await this.getLocalUserSpace({}),!t)throw new Error("space falsy and localUserSpace not initialized (?) (E: 476c7d7c68f34197b740be5df09238a2)");return aa({type:e,rel8nName:r,space:t})}catch(o){throw console.error(`${a} ${o.message}`),o}}async getPasswordForSecrets({secretIbGibs:e,fnPromptPassword:r,dontPrompt:t,checkCacheFirst:a,cacheAfter:o}){let i=`${this.lc}[${this.getPasswordForSecrets.name}]`,n=!1;try{let l=0;for(;this.isPrompting;)if(p&&console.log(`${i} hacky wait while already prompting (I: 852007c8549d42c096defe0105b5e2e6)`),await se(100),l++,l>1e3)throw n=!0,new Error("attempted to prompt for user password, but already prompting for quite awhile now. (E: 8bd4dc907422dd95862b2038ffe2b822)");let c=e.map(E=>$({ibGib:E})).join("");if(a){let E=await this.getCachedSecretPassword({cacheKey:c});if(E)return p&&console.log(`${i} using cachedPassword.`),E}if(t)return null;this.isPrompting=!0;let d=[];for(let E=0;E<e.length;E++){let S=e[E];if(!S.data)throw new Error("invalid secretIbGib. data falsy.");if(S.data.type==="password"){let A=S.data;d.push(A)}else throw new Error("Only password secrets are implemented atm.")}let f="-------------",h=d.map(E=>`name: ${E.name}
|
|
@@ -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(b=>I({ibGib:b}))},ibGibs:i.concat()}),u=await e.witness(d);if(u.data?.success)u.data.warnings?.length>0&&u.data.warnings.forEach(b=>console.warn(`${o} ${b}`));else{let b=u?.data?.errors?.length>0?u.data.errors.join(`
|
|
6
6
|
`):"unknown error putting dna ibGibs";throw new Error(b)}}}catch(n){throw console.error(`${o} ${n.message}`),n}finally{S&&console.log(`${o} complete. (I: dc6835614ff1a1b82b179225023ae823)`)}}f(Q,"persistTransformResult");async function fl({type:r,rel8nName:e,space:t}){let o=`[${fl.name}]`;try{if(!t)throw new Error("space required. (E: f73868a952ac4181a4f90ee6d86cacf3)");let n=await Xr({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(fl,"getSpecialRel8dIbGibs");async function Xr({type:r,initialize:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s,fnGetInitializing:i,fnSetInitializing:a,dontWarnIfNotExist:c}){let l=`[${Xr.name}]`;try{if(!t)throw new Error("space required. (E: d454b31d58764a9bb9c4e47fb5ef38b5)");let d=ae({type:r}),u=await Yr({key:d,space:t,dontWarn:c||!!e});if(!u){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)");u=await $i({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(!u){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: ${u}`);let b=await re({addr:u,space:t});if(b.success||(b=await re({addr:u,space:t}),b.success&&(console.warn(`${l} special ibgib was not stored in meta folder...putting in meta folder now for the future (W: e6f5571fd98c449bb2809359be5057cc)`),(await In({ibGib:b.ibGibs[0],space:t})).success||console.warn(`${l} (UNEXPECTED) tried to put special in meta but success was false? (W: b934b53571c24057af172c790e6a7240)`))),!b.success)throw new Error(b.errorMsg);if(b.ibGibs?.length!==1)throw new Error("no ibGib in result (E: 3a42abdddc3648e292d63dc45c560064)");let p=b.ibGibs[0],h=await me({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 u=`${l} ${d.message}`;return u.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(u),null}}f(Xr,"getSpecialIbGib");async function Yr({key:r,space:e,dontWarn:t}){let o=`[${Yr.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(Yr,"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 Ei({space:r}){let e=`[${Ei.name}]`;try{if(!r)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await Xr({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(Ei,"getCurrentRoot");async function Tn({root:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Tn.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 Xr({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"}),u=l.newIbGib,b=I({ibGib:u});await be({key:d,addr:b,space:e,zeroSpace:t,fnUpdateBootstrap:o}),await Ge({ibGib:u,space:e,fnBroadcast:n})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{S&&console.log(`${s} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}f(Tn,"setCurrentRoot");async function wi({ibGib:r,linked:e,rel8nName:t,space:o,fnBroadcast:n,zeroSpace:s,fnUpdateBootstrap:i}){let a=`[${wi.name}]`;try{if(!o)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!r)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await Ei({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||Qo;let u=await Ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await Q({resTransform:u,space:o});let b=u.newIbGib,p=I({ibGib:b});S&&console.log(`${a} updating _currentRoot root. newRootAddr: ${p}`),await Ge({ibGib:b,space:o,fnBroadcast:n}),await Tn({root:b,space:o,zeroSpace:s,fnUpdateBootstrap:i,fnBroadcast:n})}catch(c){console.error(`${a} ${c.message}`);return}}f(wi,"rel8ToCurrentRoot");async function $n({targetIbGib:r,space:e}){let t=`[${$n.name}]`;try{S&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let o=await wn({targetIbGib:r}),n=await In({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($n,"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 $n({targetIbGib:r,space:e});return}let a=fe({ibGib:r,defaultIfNone:"undefined"});if(!a){let h=r.data?.isTjp?r:await yn({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 $n({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 me({ibGibs:[r],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:u}=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(!u)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let b=Object.keys(u);if(b.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(b[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: ${b[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);S&&(console.log(`${o} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(u));let p=u[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 Ni({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 Rt({type:r,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:o,addrsToUnRel8:n,linked:s,severPast:i,deletePreviousSpecialIbGib:a,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:u}){let b=`[${Rt.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 Yr({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 _n({addr:g,space:c}),await Ge({ibGib:T,fnBroadcast:u,space:c}),A}catch(p){throw console.error(`${b} ${p.message}`),p}}f(Rt,"rel8ToSpecialIbGib");async function yn({ibGib:r,naive:e=!0,space:t}){let o=`[${yn.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 Dn({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 u=r.rel8ns.tjp[0],b=await re({addr:u,space:t});if(b.success&&b.ibGibs?.length===1)return b.ibGibs[0];{let p=b.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 yn({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${o} ${n.message}`),n}}f(yn,"getTjpIbGib");async function $i({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${$i.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(r){case"roots":return _i({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"tags":return yi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"secrets":return Ai({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"encryptions":return Si({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"outerspaces":return Gi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"autosyncs":return xi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"robbots":return vi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"apps":return Di({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});default:return Oi({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o})}}catch(i){throw console.error(`${s} ${i.message}`),i}}f($i,"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=xn({type:r}),c=M.primitive({ib:a}),l=await Gr({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 wi({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 yi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${yi.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 Ii({...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(yi,"createSpecial_Tags");async function Ii({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ii.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||Ks,t=t||Vs;let c=$t(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}),u=d.newIbGib;await Q({resTransform:d,space:o}),await Ge({ibGib:u,space:o,fnBroadcast:i});let b=await bl({tagIbGib:u,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newTagIbGib:u,newTagsAddr:b}}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(Ii,"createTagIbGibAndSundry");async function _i({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${_i.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(u=>({text:`${u}root`,icon:en,description:tn})),d;for(let u=0;u<l.length;u++){let b=l[u],p=await Ti({...b,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 Tn({root:d,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),a=await Yr({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(_i,"createSpecial_Roots");async function Ti({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ti.name}]`;try{if(!o)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");r=r||Hs,e=e||en,t=t||tn;let c=vn(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:u}=d;await Q({resTransform:d,space:o});let b=await Rt({type:"roots",rel8nName:Zo,ibGibsToRel8:[u],space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newRootIbGib:u,newRootsAddr:b}}catch(c){throw console.error(`${a} ${c.message}`),c}}f(Ti,"createRootIbGib");async function Ai({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ai.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(Ai,"createSpecial_Secrets");async function Si({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Si.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(Si,"createSpecial_Encryptions");async function Gi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Gi.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(Gi,"createSpecial_OuterSpaces");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:"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(xi,"createSpecial_Autosyncs");async function vi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${vi.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(vi,"createSpecial_Robbots");async function Di({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Di.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 Vr({defaultAppData:ai,defaultAppRel8ns:ci,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Vr({defaultAppData:li,defaultAppRel8ns:di,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Vr({defaultAppData:fi,defaultAppRel8ns:bi,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Di,"createSpecial_Apps");async function Vr({defaultAppData:r,defaultAppRel8ns:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${Vr.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===hn?await F():a.uuid;let{classname:l}=a,d=pn({appData:a,classname:l}),u=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:u,space:t}),await Ge({ibGib:u.newIbGib,fnBroadcast:s,space:t}),await Rt({type:"apps",rel8nName:Lr,ibGibsToRel8:[u.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(Vr,"createApp");async function Oi({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Oi.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(Oi,"createSpecial_Default");async function Ni({ibGib:r,ibGibAddr:e,existingLatest:t,existingLatestAddr:o,tjpAddr:n,space:s}){let i=`[${Ni.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,u=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 u(T.ibGibs[0],g+$.length,m)},"getPastCount");S&&console.log(`${i} doing ibGibPastCount`);let b=await u(r,0,o);if(l)return l;S&&console.log(`${i} Doing existingPastCount`),d=b;let p=await u(t,0,e);return l||(b>p?(S&&console.log(`${i} ibGibPastCount (${b}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(S&&console.log(`${i} existingPastCount (${p}) is longer than ibGibPastCount (${b}), so ibGib is newer.`),l=o),l)}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Ni,"getLatestAddr_Brute");function bl({tagIbGib:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){return Rt({type:"tags",rel8nName:rn,ibGibsToRel8:[r],space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n})}f(bl,"rel8TagToTagsIbGib");function ul({ibGibs:r,ibGibAddrs:e}){let t=`[${ul.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(ul,"throwIfDuplicates");function An({space:r,scope:e}){let t=`[${An.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=`${Bs} ${o} ${e}`;return I({ib:n,gib:U})}catch(o){throw console.error(`${t} ${o.message}`),o}finally{S&&console.log(`${t} complete.`)}}f(An,"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:Fs;let d=0;i=i??!1?i:qs;do{if(l=await Ci({space:r,scope:e,secondsValid:t,instanceId:s}),l?.data?.success)break;let b=Math.ceil(Math.random()*o);await de(b),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 u=`${a}[fn]`;try{S&&console.log(`${u} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(b){throw console.error(`${u} ${b.message}`),b}finally{S&&console.log(`${u} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await Pi({space:r,scope:e,instanceId:s}),S&&console.log(`${u} 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 sr({zeroSpace:r}){let e=`[${sr.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 gn(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(sr,"getValidatedBootstrapIbGib");async function pl({zeroSpace:r,bootstrapIbGib:e,localSpaceId:t,lock:o,callerInstanceId:n,fnDtoToSpace:s,localSpaceCacheSvc:i}){let a=`[${pl.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 u=await sr({zeroSpace:r});if(u)return u;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:Nr})}else S&&console.log(`${a} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await sr({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]}}),u=await r.witness(d);if(u?.data?.success&&u.ibGibs?.length===1){let b=u.ibGibs[0],p=await s(b);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:Nr})):(S&&console.log(`${a} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${a} ${c.message}`),c}}f(pl,"getLocalSpace");async function Ci({space:r,scope:e,secondsValid:t,instanceId:o}){let n=`[${Ci.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=An({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?Vo({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:Ko({seconds:t})}};let u=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"put",force:!0,ibGibAddrs:[i]},ibGibs:[s]}),b=await r.witness(u);if(b.data?.success)if((b.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: ${b.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(Ci,"lockSpace");async function Pi({space:r,scope:e,instanceId:t}){let o=`[${Pi.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=An({space:r,scope:e}),s=await _n({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(Pi,"unlockSpace");async function hl({space:r,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:o}){let n=`[${hl.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 sr({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,[Rr]:[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 Sn({zeroSpace:e,bootstrapIbGib:a}),S&&console.log(`${n} complete.`)}catch(s){throw console.error(`${n} ${s.message}`),s}}f(hl,"updateBootstrapIbGib");async function Sn({zeroSpace:r,bootstrapIbGib:e}){let t=`[${Sn.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(Sn,"persistBootstrapIbGibInZeroSpace");async function gl({spaceId:r,zeroSpace:e}){let t=`[${gl.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 sr({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[Rr]??[];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[Rr]=i.filter(a=>a!==r),n.rel8ns&&delete n.rel8ns[r],await Sn({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:Nr})}f(gl,"deregisterLocalSpaceFromBootstrap");async function ml({spaceId:r,zeroSpace:e}){let t=`[${ml.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(ml,"deleteSpaceRecordFromZeroSpace");function Ce({space:r}){return`${r.ib} ${ye()}`}f(Ce,"getSpaceArgMetadata");function bh({space:r}){return`${r.ib} ${ye()}`}f(bh,"getSpaceResultMetadata");function El({space:r,spaceData:e,classname:t}){let o=`[${El.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||js;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`${Hr} ${Or} ${t} ${n} ${s} ${i} ${a}`}catch(n){throw console.error(`${o} ${n.message}`),n}}f(El,"getSpaceIb");function wl({ib:r}){let e=`[${wl.name}]`;if(!r){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return r.startsWith(`${Hr} ${Or} `)}f(wl,"isSpaceIb");function Wr({spaceIb:r}){let e=`[${Wr.name}]`;try{if(!r)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,o,n,s,i,a,c]=r.split(" ");if(t!==Hr)throw new Error(`invalid spaceIb (${r}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(o!==Or)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(bn.includes(a))l=a;else throw new Error(`invalid spaceIb (${r}). spaceType (${a}) is set but not a valid type. valid types: ${bn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(un.includes(c))d=c;else throw new Error(`invalid spaceIb (${r}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${un.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:s,spaceId:i,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Wr,"parseSpaceIb");async function me({ibGibs:r,addrs:e,tjps:t,tjpAddrs:o,space:n}){let s=`[${me.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(b=>d.includes(b))||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(me,"getLatestAddrs");function Gn({ibGib_Context:r}){let e=`[${Gn.name}]`;try{if(S&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!ir({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(Gn,"throwIfContextIsSpecial");async function $l({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${$l.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=ir({ibGib:r});c&&Gn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Ys]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),u=zr({ib:r.ib}),b=ae({type:u});await be({key:b,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($l,"trash");async function yl({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${yl.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=ir({ibGib:r});c&&Gn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Xs]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),u=zr({ib:r.ib}),b=ae({type:u});await be({key:b,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(yl,"archive");function Il(r){let e=`[${Il.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(Il,"spaceNameIsValid");var K=!1;function Gh(r,e){return typeof r=="object"&&r!==null?`v:1^spaceId:${r.spaceId}^${r.ibGibAddr}`:`v:1^spaceId:${r}^${e}`}f(Gh,"getSpaceQualifiedIbGibAddr");function Li(r){try{if(typeof r!="string"||!r.match(Pr))return!1;let t=Jr({sqAddr:r});return!0}catch{return!1}}f(Li,"isSpaceQualifiedAddr");function Jr({sqAddr:r}){let e=`[${Jr.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(Pr);if(!t)throw new Error(`${e} invalid sqAddr (${r}). does not match SQ Addr regexp: ${Pr.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(Jr,"parseSpaceQualifiedIbGibAddr");async function _l({ibGib:r,rel8nNames:e,space:t}){let o=`[${_l.name}]`;try{if(!r)throw new Error("ibGib required (E: genuuid)");if(!t)throw new Error("space required (E: genuuid)");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: genuuid)`)}else n[s]=[]}return n}catch(n){throw console.error(`${o} ${E(n)}`),n}}f(_l,"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):Ms;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(b=>c.includes(b)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let u=(await M.firstGen({ib:e,parentIbGib:M.primitive({ib:r}),data:o,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return u?.rel8ns?.past&&delete u.rel8ns.past,u?.rel8ns?.tjp&&delete u.rel8ns.tjp,u?.rel8ns?.identity&&delete u.rel8ns.identity,u.gib=await X({ibGib:{ib:u.ib,data:u.data,rel8ns:u.rel8ns},hasTjp:!1}),u}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Oe,"constantIbGib");function xh({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(xh,"getBinIb");function vh({addr:r}){return Ri({addr:r})}f(vh,"getBinHashAndExt");function Ri({addr:r}){let e=`[${Ri.name}]`;try{if(!or({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(Ri,"parseBinIb");function or({ibGib:r,addr:e}){let t=`[${or.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(or,"isBinary");function xn({type:r}){if(!r.match(on))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${on.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${r}`}f(xn,"getSpecialIbGibIb");function zr({ib:r}){let e=`[${zr.name}]`;try{if(K&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!r)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!ir({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(Dr).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(zr,"getSpecialTypeFromIb");function Tl({type:r}){return`${xn({type:r})}^${U}`}f(Tl,"getSpecialIbGibAddr");function ae({type:r}){return`${zs} ${Tl({type:r})}`}f(ae,"getSpecialConfigKey");function ir({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(ir,"isSpecial");function vn(r){let e=`[${vn.name}]`;if(!r)throw new Error(`${e} text required.`);return`root ${r}`}f(vn,"getRootIb");function $t(r){let e=`[${$t.name}]`;if(!r)throw new Error(`${e} tag required.`);return`tag ${r}`}f($t,"tagTextToIb");function Zr({ibGibs:r,filterPrimitives:e}){let t=`[${Zr.name}]`;try{let o={},n={},s={};return(e?r.filter(a=>a.gib??a.gib!==U):r).forEach(a=>{Ui({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(Zr,"splitPerTjpAndOrDna");function ar({ibGibs:r}){let e=`[${ar.name}]`;try{K&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:o}=Zr({ibGibs:r,filterPrimitives:!0}),n={...t,...o},s=Object.values(n),i=Ho({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(ar,"getTimelinesGroupedByTjp");function Ui({ibGib:r}){let e=`[${Ui.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(Ui,"hasTjp");function fe({ibGib:r,defaultIfNone:e="undefined"}){let t=`[${fe.name}]`;try{let o=Mi({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 Mi({ibGibs:r,defaultIfNone:e="undefined"}){let t=`[${Mi.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(Mi,"getTjpAddrs");async function Dn({ibGib:r,naive:e=!0}){let t=`[${Dn.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(Dn,"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&&(or({ibGib:r})?t.data=r.data.slice():t.data=C(r.data)),r.rel8ns&&(t.rel8ns=C(r.rel8ns)),t}f(ve,"toDto");function On(r){let e=`[${On.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(On,"isIbGib");function rr({ibGib:r,data:e,timestamp:t}){let o=`[${rr.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()!==Cr)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()!==Cr)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()!==Cr)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(rr,"getTimestampInfo");async function Nn({addrs:r,readCache_graph:e,readCache_array:t,space:o}){let n=`[${Nn.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 u of l){let b=await re({addrs:d,space:u});if(b.success&&b.ibGibs&&b.ibGibs.length===d.length)b.ibGibs.forEach(p=>s[I({ibGib:p})]=p),d=[];else if(b.ibGibs&&b.ibGibs.length>0){if(d=d.filter(p=>!b.ibGibs.some(h=>I({ibGib:h})===p)),d.length===0)break}else K&&console.log(`${n} no addrs found in space (${u.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(u=>u.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(Nn,"getIbGibsFromCache_fallbackToSpaces");async function ki({addr:r,space:e,metaspace:t}){let o=`[${ki.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=Li(r)?Jr({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(ki,"getIbGibFromSpace");async function ji({addrs:r,space:e,metaspace:t}){let o=`[${ji.name}]`;try{if(K&&console.log(`${o} starting... (I: genuuid)`),!r)throw new Error("(UNEXPECTED) addrs falsy? (E: genuuid)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: genuuid)");if(r.length===0)return[];let n=r.map(c=>Li(c)?Jr({sqAddr:c}).ibGibAddr:c);for(let c of n){let l=qe({addr:c})??[];if(l.length>0)throw new Error(`invalid incoming addr (${c}). errors: ${l.join(", ")} (E: genuuid)`)}let s=await re({space:e,addrs:n});if(!s.success||s.errorMsg)throw new Error(`resGet failed. resGet.success: ${s.success}. errorMsg: ${s.errorMsg} (E: genuuid)`);let i=new Map;for(let c of s.ibGibs||[]){let l=I({ibGib:c});i.set(l,c)}let a=[];for(let c of n){let l=i.get(c);l&&a.push(l)}return a}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(ji,"getIbGibsFromSpace");async function Al({ibGib:r,space:e}){let t=`[${Al.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 me({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 ki({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(Al,"resolveLatestIbGibInSpace");async function Sl({ibGibs:r,space:e}){let t=`[${Sl.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 b of r){let p=I({ibGib:b}),h=fe({ibGib:b,defaultIfNone:"undefined"});n.push(p),s.push(h||""),h&&o.push(b)}if(o.length===0)return r;let i=await me({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 b=0;b<r.length;b++){let p=n[b],h=s[b],g=a[p]??a[h]??p;l.push(g),g&&g!==p&&c.push(g)}let d=new Map;if(c.length>0){let b=Array.from(new Set(c)),p=await ji({addrs:b,space:e});for(let h of p){let g=I({ibGib:h});d.set(g,h)}}let u=[];for(let b=0;b<r.length;b++){let p=r[b],h=l[b];if(h&&h!==n[b]){let g=d.get(h);if(g&&(g.data?.n??0)>=(p.data?.n??0)){u.push(g);continue}}u.push(p)}return u}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Sl,"resolveLatestIbGibsInSpace");var Bi=!1,Gl="space_gib_db",xl="space_gib_store",vl="space_gib_api_key";var Dl="agent";var Ph=$t(Dl);var Lh={dbName:Gl,storeName:xl,additionalStoreNames:[ks],apiKeyName:vl};var Fi="0.0.25";var at=!1,kh="[web^gib timer]",Qr="ibgib";var Ol="agent",jh="body-outline",Bh="This tag tracks the active agents for the current local user space.",Fh=$t(Ol),qi="#78f87e88",Hi="#78f87e10",Ki="#ffffff";var qh="AUTOMATED_TEXT";var Pe=!1;function Vi(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(Vi,"uint8ArrayToBase64");async function Xi(r){let e=`data:application/octet-stream;base64,${r}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}f(Xi,"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 Vi(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 Xi(s.value))}return o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(to,"deserializeStringToGraph");async function Yi(r){let e=`[${Yi.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(Yi,"compressIbGibToBlob");async function Nl(r){let e=r.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await to({jsonString:t})}f(Nl,"decompressIbGibFromBlob");async function Cn({graph:r}){let e=`[${Cn.name}]`;try{Pe&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let o=await(await Yi(r)).arrayBuffer(),n=new Uint8Array(o);return await Vi(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Cn,"compressIbGibGraphToString");async function Pn({compressedBase64:r}){let e=`[${Pn.name}]`;try{Pe&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await Xi(r),o=new Blob([t],{type:"application/gzip"});return await Nl(o)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Pn,"decompressIbGibGraphFromString");var Wi="export";var cr=!1;function zi({data:r}){let e=`[${zi.name}]`;try{cr&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:o,timestamp:n}=r,s=o.length,i=ye(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}),b=se({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Wi} ${p} ${a} ${t} ${s} ${b}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{cr&&console.log(`${e} complete.`)}}f(zi,"getRawExportIb");async function Ln({ibGib:r,metaspace:e,space:t,compress:o,live:n,ignoreErrors:s}){let i=`[${Ln.name}]`;try{if(cr&&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}),u=o?await Cn({graph:d}):await eo({graph:d}),b=fe({ibGib:r,defaultIfNone:"incomingAddr"})??a,p=new Date,h={contextIbGibAddr:a,tjpAddr:b,dependencyGraphAsString:u,graphSize:Object.keys(d).length,timestamp:Ae(p),timestampMs:p.getMilliseconds()};o&&(h.compression="gzip");let g={ib:zi({data:h}),data:h},m=await X({ibGib:g,hasTjp:!1});return g.gib=m,cr&&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{cr&&console.log(`${i} complete.`)}}f(Ln,"getRawExportIbGib");var ig="ibgib-shell-ready",ag="ibgib-ui-busy",cg="ibgib-ui-message",lg="ibgib-identity-request-change",dg="ibgib-identity-changed",fg="ibgib-identity-update-available",bg="ibgib-identity-renewal-required",ug="show-identity-manager",pg="show-keystone-creator",hg="show-add-device",gg="show-privacy-policy";var Ji=at;async function yt({title:r,msg:e,prompt:t,showInput:o,defaultValue:n,okButtonTitle:s,cancelButtonTitle:i,isPassword:a,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:u,onPasskeyAuth:b}){let p=`[${yt.name}]`;try{Ji&&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 u=`${l} ${d.message}`;return u.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(u),null}}f(Xr,"getSpecialIbGib");async function Yr({key:r,space:e,dontWarn:t}){let o=`[${Yr.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(Yr,"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 Ei({space:r}){let e=`[${Ei.name}]`;try{if(!r)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await Xr({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(Ei,"getCurrentRoot");async function Tn({root:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Tn.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 Xr({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"}),u=l.newIbGib,b=I({ibGib:u});await be({key:d,addr:b,space:e,zeroSpace:t,fnUpdateBootstrap:o}),await Ge({ibGib:u,space:e,fnBroadcast:n})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{S&&console.log(`${s} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}f(Tn,"setCurrentRoot");async function wi({ibGib:r,linked:e,rel8nName:t,space:o,fnBroadcast:n,zeroSpace:s,fnUpdateBootstrap:i}){let a=`[${wi.name}]`;try{if(!o)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!r)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await Ei({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||Qo;let u=await Ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await Q({resTransform:u,space:o});let b=u.newIbGib,p=I({ibGib:b});S&&console.log(`${a} updating _currentRoot root. newRootAddr: ${p}`),await Ge({ibGib:b,space:o,fnBroadcast:n}),await Tn({root:b,space:o,zeroSpace:s,fnUpdateBootstrap:i,fnBroadcast:n})}catch(c){console.error(`${a} ${c.message}`);return}}f(wi,"rel8ToCurrentRoot");async function $n({targetIbGib:r,space:e}){let t=`[${$n.name}]`;try{S&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let o=await wn({targetIbGib:r}),n=await In({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($n,"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 $n({targetIbGib:r,space:e});return}let a=fe({ibGib:r,defaultIfNone:"undefined"});if(!a){let h=r.data?.isTjp?r:await yn({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 $n({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 me({ibGibs:[r],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:u}=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(!u)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let b=Object.keys(u);if(b.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(b[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: ${b[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);S&&(console.log(`${o} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(u));let p=u[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 Ni({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 Rt({type:r,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:o,addrsToUnRel8:n,linked:s,severPast:i,deletePreviousSpecialIbGib:a,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:u}){let b=`[${Rt.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 Yr({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 _n({addr:g,space:c}),await Ge({ibGib:T,fnBroadcast:u,space:c}),A}catch(p){throw console.error(`${b} ${p.message}`),p}}f(Rt,"rel8ToSpecialIbGib");async function yn({ibGib:r,naive:e=!0,space:t}){let o=`[${yn.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 Dn({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 u=r.rel8ns.tjp[0],b=await re({addr:u,space:t});if(b.success&&b.ibGibs?.length===1)return b.ibGibs[0];{let p=b.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 yn({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${o} ${n.message}`),n}}f(yn,"getTjpIbGib");async function $i({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${$i.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(r){case"roots":return _i({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"tags":return yi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"secrets":return Ai({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"encryptions":return Si({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"outerspaces":return Gi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"autosyncs":return xi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"robbots":return vi({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});case"apps":return Di({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o});default:return Oi({type:r,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:o})}}catch(i){throw console.error(`${s} ${i.message}`),i}}f($i,"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=xn({type:r}),c=M.primitive({ib:a}),l=await Gr({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 wi({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 yi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${yi.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 Ii({...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(yi,"createSpecial_Tags");async function Ii({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ii.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||Ks,t=t||Vs;let c=$t(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}),u=d.newIbGib;await Q({resTransform:d,space:o}),await Ge({ibGib:u,space:o,fnBroadcast:i});let b=await bl({tagIbGib:u,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newTagIbGib:u,newTagsAddr:b}}catch(c){throw console.error(`${a} ${c.message}`),c}finally{S&&console.log(`${a} complete.`)}}f(Ii,"createTagIbGibAndSundry");async function _i({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${_i.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(u=>({text:`${u}root`,icon:en,description:tn})),d;for(let u=0;u<l.length;u++){let b=l[u],p=await Ti({...b,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 Tn({root:d,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),a=await Yr({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(_i,"createSpecial_Roots");async function Ti({text:r,icon:e,description:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${Ti.name}]`;try{if(!o)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");r=r||Hs,e=e||en,t=t||tn;let c=vn(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:u}=d;await Q({resTransform:d,space:o});let b=await Rt({type:"roots",rel8nName:Zo,ibGibsToRel8:[u],space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i});return{newRootIbGib:u,newRootsAddr:b}}catch(c){throw console.error(`${a} ${c.message}`),c}}f(Ti,"createRootIbGib");async function Ai({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Ai.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(Ai,"createSpecial_Secrets");async function Si({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Si.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(Si,"createSpecial_Encryptions");async function Gi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Gi.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(Gi,"createSpecial_OuterSpaces");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:"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(xi,"createSpecial_Autosyncs");async function vi({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${vi.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(vi,"createSpecial_Robbots");async function Di({space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}){let n=`[${Di.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 Vr({defaultAppData:ai,defaultAppRel8ns:ci,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Vr({defaultAppData:li,defaultAppRel8ns:di,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s=await Vr({defaultAppData:fi,defaultAppRel8ns:bi,space:r,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:o}),s}catch(s){return console.error(`${n} ${s.message}`),null}}f(Di,"createSpecial_Apps");async function Vr({defaultAppData:r,defaultAppRel8ns:e,space:t,zeroSpace:o,fnUpdateBootstrap:n,fnBroadcast:s}){let i=`[${Vr.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===hn?await F():a.uuid;let{classname:l}=a,d=pn({appData:a,classname:l}),u=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:u,space:t}),await Ge({ibGib:u.newIbGib,fnBroadcast:s,space:t}),await Rt({type:"apps",rel8nName:Lr,ibGibsToRel8:[u.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(Vr,"createApp");async function Oi({type:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){let s=`[${Oi.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(Oi,"createSpecial_Default");async function Ni({ibGib:r,ibGibAddr:e,existingLatest:t,existingLatestAddr:o,tjpAddr:n,space:s}){let i=`[${Ni.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,u=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 u(T.ibGibs[0],g+$.length,m)},"getPastCount");S&&console.log(`${i} doing ibGibPastCount`);let b=await u(r,0,o);if(l)return l;S&&console.log(`${i} Doing existingPastCount`),d=b;let p=await u(t,0,e);return l||(b>p?(S&&console.log(`${i} ibGibPastCount (${b}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(S&&console.log(`${i} existingPastCount (${p}) is longer than ibGibPastCount (${b}), so ibGib is newer.`),l=o),l)}catch(a){throw console.error(`${i} ${a.message}`),a}finally{S&&console.log(`${i} complete.`)}}f(Ni,"getLatestAddr_Brute");function bl({tagIbGib:r,space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n}){return Rt({type:"tags",rel8nName:rn,ibGibsToRel8:[r],space:e,zeroSpace:t,fnUpdateBootstrap:o,fnBroadcast:n})}f(bl,"rel8TagToTagsIbGib");function ul({ibGibs:r,ibGibAddrs:e}){let t=`[${ul.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(ul,"throwIfDuplicates");function An({space:r,scope:e}){let t=`[${An.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=`${Bs} ${o} ${e}`;return I({ib:n,gib:U})}catch(o){throw console.error(`${t} ${o.message}`),o}finally{S&&console.log(`${t} complete.`)}}f(An,"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:Fs;let d=0;i=i??!1?i:qs;do{if(l=await Ci({space:r,scope:e,secondsValid:t,instanceId:s}),l?.data?.success)break;let b=Math.ceil(Math.random()*o);await de(b),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 u=`${a}[fn]`;try{S&&console.log(`${u} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(b){throw console.error(`${u} ${b.message}`),b}finally{S&&console.log(`${u} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await Pi({space:r,scope:e,instanceId:s}),S&&console.log(`${u} 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 sr({zeroSpace:r}){let e=`[${sr.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 gn(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(sr,"getValidatedBootstrapIbGib");async function pl({zeroSpace:r,bootstrapIbGib:e,localSpaceId:t,lock:o,callerInstanceId:n,fnDtoToSpace:s,localSpaceCacheSvc:i}){let a=`[${pl.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 u=await sr({zeroSpace:r});if(u)return u;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:Nr})}else S&&console.log(`${a} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await sr({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]}}),u=await r.witness(d);if(u?.data?.success&&u.ibGibs?.length===1){let b=u.ibGibs[0],p=await s(b);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:Nr})):(S&&console.log(`${a} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${a} ${c.message}`),c}}f(pl,"getLocalSpace");async function Ci({space:r,scope:e,secondsValid:t,instanceId:o}){let n=`[${Ci.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=An({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?Vo({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:Ko({seconds:t})}};let u=await r.argy({ibMetadata:Ce({space:r}),argData:{cmd:"put",force:!0,ibGibAddrs:[i]},ibGibs:[s]}),b=await r.witness(u);if(b.data?.success)if((b.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: ${b.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(Ci,"lockSpace");async function Pi({space:r,scope:e,instanceId:t}){let o=`[${Pi.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=An({space:r,scope:e}),s=await _n({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(Pi,"unlockSpace");async function hl({space:r,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:o}){let n=`[${hl.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 sr({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,[Rr]:[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 Sn({zeroSpace:e,bootstrapIbGib:a}),S&&console.log(`${n} complete.`)}catch(s){throw console.error(`${n} ${s.message}`),s}}f(hl,"updateBootstrapIbGib");async function Sn({zeroSpace:r,bootstrapIbGib:e}){let t=`[${Sn.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(Sn,"persistBootstrapIbGibInZeroSpace");async function gl({spaceId:r,zeroSpace:e}){let t=`[${gl.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 sr({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[Rr]??[];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[Rr]=i.filter(a=>a!==r),n.rel8ns&&delete n.rel8ns[r],await Sn({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:Nr})}f(gl,"deregisterLocalSpaceFromBootstrap");async function ml({spaceId:r,zeroSpace:e}){let t=`[${ml.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(ml,"deleteSpaceRecordFromZeroSpace");function Ce({space:r}){return`${r.ib} ${ye()}`}f(Ce,"getSpaceArgMetadata");function bh({space:r}){return`${r.ib} ${ye()}`}f(bh,"getSpaceResultMetadata");function El({space:r,spaceData:e,classname:t}){let o=`[${El.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||js;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`${Hr} ${Or} ${t} ${n} ${s} ${i} ${a}`}catch(n){throw console.error(`${o} ${n.message}`),n}}f(El,"getSpaceIb");function wl({ib:r}){let e=`[${wl.name}]`;if(!r){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return r.startsWith(`${Hr} ${Or} `)}f(wl,"isSpaceIb");function Wr({spaceIb:r}){let e=`[${Wr.name}]`;try{if(!r)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,o,n,s,i,a,c]=r.split(" ");if(t!==Hr)throw new Error(`invalid spaceIb (${r}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(o!==Or)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(bn.includes(a))l=a;else throw new Error(`invalid spaceIb (${r}). spaceType (${a}) is set but not a valid type. valid types: ${bn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(un.includes(c))d=c;else throw new Error(`invalid spaceIb (${r}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${un.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:s,spaceId:i,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}f(Wr,"parseSpaceIb");async function me({ibGibs:r,addrs:e,tjps:t,tjpAddrs:o,space:n}){let s=`[${me.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(b=>d.includes(b))||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(me,"getLatestAddrs");function Gn({ibGib_Context:r}){let e=`[${Gn.name}]`;try{if(S&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!ir({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(Gn,"throwIfContextIsSpecial");async function $l({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${$l.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=ir({ibGib:r});c&&Gn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Ys]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),u=zr({ib:r.ib}),b=ae({type:u});await be({key:b,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($l,"trash");async function yl({ibGib_Context:r,rel8nName_Context:e,addr:t,space:o,zeroSpace:n,fnUpdateBootstrap:s,fnBroadcast:i}){let a=`[${yl.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=ir({ibGib:r});c&&Gn({ibGib_Context:r});let l=await Ie({src:r,rel8nsToAddByAddr:{[Xs]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await Q({resTransform:l,space:o}),c){let d=I({ibGib:l.newIbGib}),u=zr({ib:r.ib}),b=ae({type:u});await be({key:b,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(yl,"archive");function Il(r){let e=`[${Il.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(Il,"spaceNameIsValid");var K=!1;function Gh(r,e){return typeof r=="object"&&r!==null?`v:1^spaceId:${r.spaceId}^${r.ibGibAddr}`:`v:1^spaceId:${r}^${e}`}f(Gh,"getSpaceQualifiedIbGibAddr");function Li(r){try{if(typeof r!="string"||!r.match(Pr))return!1;let t=Jr({sqAddr:r});return!0}catch{return!1}}f(Li,"isSpaceQualifiedAddr");function Jr({sqAddr:r}){let e=`[${Jr.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(Pr);if(!t)throw new Error(`${e} invalid sqAddr (${r}). does not match SQ Addr regexp: ${Pr.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(Jr,"parseSpaceQualifiedIbGibAddr");async function _l({ibGib:r,rel8nNames:e,space:t}){let o=`[${_l.name}]`;try{if(!r)throw new Error("ibGib required (E: genuuid)");if(!t)throw new Error("space required (E: genuuid)");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: genuuid)`)}else n[s]=[]}return n}catch(n){throw console.error(`${o} ${E(n)}`),n}}f(_l,"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):Ms;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(b=>c.includes(b)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let u=(await M.firstGen({ib:e,parentIbGib:M.primitive({ib:r}),data:o,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return u?.rel8ns?.past&&delete u.rel8ns.past,u?.rel8ns?.tjp&&delete u.rel8ns.tjp,u?.rel8ns?.identity&&delete u.rel8ns.identity,u.gib=await X({ibGib:{ib:u.ib,data:u.data,rel8ns:u.rel8ns},hasTjp:!1}),u}catch(i){throw console.error(`${s} ${i.message}`),i}}f(Oe,"constantIbGib");function xh({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(xh,"getBinIb");function vh({addr:r}){return Ri({addr:r})}f(vh,"getBinHashAndExt");function Ri({addr:r}){let e=`[${Ri.name}]`;try{if(!or({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(Ri,"parseBinIb");function or({ibGib:r,addr:e}){let t=`[${or.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(or,"isBinary");function xn({type:r}){if(!r.match(on))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${on.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${r}`}f(xn,"getSpecialIbGibIb");function zr({ib:r}){let e=`[${zr.name}]`;try{if(K&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!r)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!ir({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(Dr).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(zr,"getSpecialTypeFromIb");function Tl({type:r}){return`${xn({type:r})}^${U}`}f(Tl,"getSpecialIbGibAddr");function ae({type:r}){return`${zs} ${Tl({type:r})}`}f(ae,"getSpecialConfigKey");function ir({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(ir,"isSpecial");function vn(r){let e=`[${vn.name}]`;if(!r)throw new Error(`${e} text required.`);return`root ${r}`}f(vn,"getRootIb");function $t(r){let e=`[${$t.name}]`;if(!r)throw new Error(`${e} tag required.`);return`tag ${r}`}f($t,"tagTextToIb");function Zr({ibGibs:r,filterPrimitives:e}){let t=`[${Zr.name}]`;try{let o={},n={},s={};return(e?r.filter(a=>a.gib??a.gib!==U):r).forEach(a=>{Ui({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(Zr,"splitPerTjpAndOrDna");function ar({ibGibs:r}){let e=`[${ar.name}]`;try{K&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:o}=Zr({ibGibs:r,filterPrimitives:!0}),n={...t,...o},s=Object.values(n),i=Ho({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(ar,"getTimelinesGroupedByTjp");function Ui({ibGib:r}){let e=`[${Ui.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(Ui,"hasTjp");function fe({ibGib:r,defaultIfNone:e="undefined"}){let t=`[${fe.name}]`;try{let o=Mi({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 Mi({ibGibs:r,defaultIfNone:e="undefined"}){let t=`[${Mi.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(Mi,"getTjpAddrs");async function Dn({ibGib:r,naive:e=!0}){let t=`[${Dn.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(Dn,"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&&(or({ibGib:r})?t.data=r.data.slice():t.data=C(r.data)),r.rel8ns&&(t.rel8ns=C(r.rel8ns)),t}f(ve,"toDto");function On(r){let e=`[${On.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(On,"isIbGib");function rr({ibGib:r,data:e,timestamp:t}){let o=`[${rr.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()!==Cr)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()!==Cr)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()!==Cr)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(rr,"getTimestampInfo");async function Nn({addrs:r,readCache_graph:e,readCache_array:t,space:o}){let n=`[${Nn.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 u of l){let b=await re({addrs:d,space:u});if(b.success&&b.ibGibs&&b.ibGibs.length===d.length)b.ibGibs.forEach(p=>s[I({ibGib:p})]=p),d=[];else if(b.ibGibs&&b.ibGibs.length>0){if(d=d.filter(p=>!b.ibGibs.some(h=>I({ibGib:h})===p)),d.length===0)break}else K&&console.log(`${n} no addrs found in space (${u.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(u=>u.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(Nn,"getIbGibsFromCache_fallbackToSpaces");async function ki({addr:r,space:e,metaspace:t}){let o=`[${ki.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=Li(r)?Jr({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(ki,"getIbGibFromSpace");async function ji({addrs:r,space:e,metaspace:t}){let o=`[${ji.name}]`;try{if(K&&console.log(`${o} starting... (I: genuuid)`),!r)throw new Error("(UNEXPECTED) addrs falsy? (E: genuuid)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: genuuid)");if(r.length===0)return[];let n=r.map(c=>Li(c)?Jr({sqAddr:c}).ibGibAddr:c);for(let c of n){let l=qe({addr:c})??[];if(l.length>0)throw new Error(`invalid incoming addr (${c}). errors: ${l.join(", ")} (E: genuuid)`)}let s=await re({space:e,addrs:n});if(!s.success||s.errorMsg)throw new Error(`resGet failed. resGet.success: ${s.success}. errorMsg: ${s.errorMsg} (E: genuuid)`);let i=new Map;for(let c of s.ibGibs||[]){let l=I({ibGib:c});i.set(l,c)}let a=[];for(let c of n){let l=i.get(c);l&&a.push(l)}return a}catch(n){throw console.error(`${o} ${E(n)}`),n}finally{K&&console.log(`${o} complete.`)}}f(ji,"getIbGibsFromSpace");async function Al({ibGib:r,space:e}){let t=`[${Al.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 me({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 ki({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(Al,"resolveLatestIbGibInSpace");async function Sl({ibGibs:r,space:e}){let t=`[${Sl.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 b of r){let p=I({ibGib:b}),h=fe({ibGib:b,defaultIfNone:"undefined"});n.push(p),s.push(h||""),h&&o.push(b)}if(o.length===0)return r;let i=await me({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 b=0;b<r.length;b++){let p=n[b],h=s[b],g=a[p]??a[h]??p;l.push(g),g&&g!==p&&c.push(g)}let d=new Map;if(c.length>0){let b=Array.from(new Set(c)),p=await ji({addrs:b,space:e});for(let h of p){let g=I({ibGib:h});d.set(g,h)}}let u=[];for(let b=0;b<r.length;b++){let p=r[b],h=l[b];if(h&&h!==n[b]){let g=d.get(h);if(g&&(g.data?.n??0)>=(p.data?.n??0)){u.push(g);continue}}u.push(p)}return u}catch(o){throw console.error(`${t} ${E(o)}`),o}finally{K&&console.log(`${t} complete.`)}}f(Sl,"resolveLatestIbGibsInSpace");var Bi=!1,Gl="space_gib_db",xl="space_gib_store",vl="space_gib_api_key";var Dl="agent";var Ph=$t(Dl);var Lh={dbName:Gl,storeName:xl,additionalStoreNames:[ks],apiKeyName:vl};var Fi="0.0.26";var at=!1,kh="[web^gib timer]",Qr="ibgib";var Ol="agent",jh="body-outline",Bh="This tag tracks the active agents for the current local user space.",Fh=$t(Ol),qi="#78f87e88",Hi="#78f87e10",Ki="#ffffff";var qh="AUTOMATED_TEXT";var Pe=!1;function Vi(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(Vi,"uint8ArrayToBase64");async function Xi(r){let e=`data:application/octet-stream;base64,${r}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}f(Xi,"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 Vi(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 Xi(s.value))}return o}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(to,"deserializeStringToGraph");async function Yi(r){let e=`[${Yi.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(Yi,"compressIbGibToBlob");async function Nl(r){let e=r.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await to({jsonString:t})}f(Nl,"decompressIbGibFromBlob");async function Cn({graph:r}){let e=`[${Cn.name}]`;try{Pe&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let o=await(await Yi(r)).arrayBuffer(),n=new Uint8Array(o);return await Vi(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Cn,"compressIbGibGraphToString");async function Pn({compressedBase64:r}){let e=`[${Pn.name}]`;try{Pe&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await Xi(r),o=new Blob([t],{type:"application/gzip"});return await Nl(o)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Pe&&console.log(`${e} complete.`)}}f(Pn,"decompressIbGibGraphFromString");var Wi="export";var cr=!1;function zi({data:r}){let e=`[${zi.name}]`;try{cr&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:o,timestamp:n}=r,s=o.length,i=ye(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}),b=se({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Wi} ${p} ${a} ${t} ${s} ${b}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{cr&&console.log(`${e} complete.`)}}f(zi,"getRawExportIb");async function Ln({ibGib:r,metaspace:e,space:t,compress:o,live:n,ignoreErrors:s}){let i=`[${Ln.name}]`;try{if(cr&&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}),u=o?await Cn({graph:d}):await eo({graph:d}),b=fe({ibGib:r,defaultIfNone:"incomingAddr"})??a,p=new Date,h={contextIbGibAddr:a,tjpAddr:b,dependencyGraphAsString:u,graphSize:Object.keys(d).length,timestamp:Ae(p),timestampMs:p.getMilliseconds()};o&&(h.compression="gzip");let g={ib:zi({data:h}),data:h},m=await X({ibGib:g,hasTjp:!1});return g.gib=m,cr&&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{cr&&console.log(`${i} complete.`)}}f(Ln,"getRawExportIbGib");var ig="ibgib-shell-ready",ag="ibgib-ui-busy",cg="ibgib-ui-message",lg="ibgib-identity-request-change",dg="ibgib-identity-changed",fg="ibgib-identity-update-available",bg="ibgib-identity-renewal-required",ug="show-identity-manager",pg="show-keystone-creator",hg="show-add-device",gg="show-privacy-policy";var Ji=at;async function yt({title:r,msg:e,prompt:t,showInput:o,defaultValue:n,okButtonTitle:s,cancelButtonTitle:i,isPassword:a,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:u,onPasskeyAuth:b}){let p=`[${yt.name}]`;try{Ji&&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&&b&&!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=u||"\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,4 +1,4 @@
|
|
|
1
|
-
import{$b as Ui,A as Ft,Ab as zs,Ac as at,Bb as Ks,Bc as Oi,Bd as gr,C as W,Cb as Ws,Cc as nr,Cd as qi,D as Ls,Dc as ir,Dd as br,E as it,Eb as Js,Ec as yn,F as ln,Fb as Ys,Fc as En,Gb as Bt,Gc as or,H as Ie,Hb as se,Hc as sr,Ib as Me,Ic as wn,Jb as Ce,Jc as vn,Kb as Vt,Kc as In,Lb as Xs,Lc as Cn,Ma as cn,Mb as dn,Nb as un,Ob as fn,Pb as Qs,Qb as Zs,Qc as lt,Rb as js,Rc as rr,Sb as pn,Sc as ar,Tb as Di,Tc as lr,Uc as Be,Vb as k,Vc as cr,W as Us,Wb as hn,Wc as dr,X as Fs,Xa as Bs,Xc as ur,Ya as Vs,Za as Os,Zb as Mi,_b as Li,_c as Tn,a as p,ac as Ot,b as on,bc as Fi,c as ki,cc as Le,d as xe,dc as Pe,e as Ds,ec as Ne,ed as fr,fc as ot,g as sn,gd as pr,h as V,hd as re,i as z,id as Et,j as E,kb as Ri,l as nt,lb as Se,lc as Bi,n as bt,nb as H,nd as D,o as yt,ob as J,q as rn,qd as hr,r as an,rc as st,rd as Ve,s as Ut,sc as mn,sd as mr,tc as Y,uc as er,ud as wt,v as Z,vc as Vi,vd as vt,w as _,wb as Q,wc as gn,wd as It,x as B,xc as bn,yb as qs,yc as tr,z as Ms,zb as Hs,zc as rt}from"./chunk-
|
|
1
|
+
import{$b as Ui,A as Ft,Ab as zs,Ac as at,Bb as Ks,Bc as Oi,Bd as gr,C as W,Cb as Ws,Cc as nr,Cd as qi,D as Ls,Dc as ir,Dd as br,E as it,Eb as Js,Ec as yn,F as ln,Fb as Ys,Fc as En,Gb as Bt,Gc as or,H as Ie,Hb as se,Hc as sr,Ib as Me,Ic as wn,Jb as Ce,Jc as vn,Kb as Vt,Kc as In,Lb as Xs,Lc as Cn,Ma as cn,Mb as dn,Nb as un,Ob as fn,Pb as Qs,Qb as Zs,Qc as lt,Rb as js,Rc as rr,Sb as pn,Sc as ar,Tb as Di,Tc as lr,Uc as Be,Vb as k,Vc as cr,W as Us,Wb as hn,Wc as dr,X as Fs,Xa as Bs,Xc as ur,Ya as Vs,Za as Os,Zb as Mi,_b as Li,_c as Tn,a as p,ac as Ot,b as on,bc as Fi,c as ki,cc as Le,d as xe,dc as Pe,e as Ds,ec as Ne,ed as fr,fc as ot,g as sn,gd as pr,h as V,hd as re,i as z,id as Et,j as E,kb as Ri,l as nt,lb as Se,lc as Bi,n as bt,nb as H,nd as D,o as yt,ob as J,q as rn,qd as hr,r as an,rc as st,rd as Ve,s as Ut,sc as mn,sd as mr,tc as Y,uc as er,ud as wt,v as Z,vc as Vi,vd as vt,w as _,wb as Q,wc as gn,wd as It,x as B,xc as bn,yb as qs,yc as tr,z as Ms,zb as Hs,zc as rt}from"./chunk-4S4RYXGE.mjs";var Ge=Q,Hi=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=qt.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]}},qt;async function ne(){let n=`[${ne.name}]`;try{return Ge&&console.log(`${n} starting... (I: 853694c88223381339103a3765129925)`),qt||(qt=new Hi,await qt.initialized),qt}catch(e){throw console.error(`${n} ${E(e)}`),e}finally{Ge&&console.log(`${n} complete.`)}}p(ne,"getComponentSvc");var yr="left-panel";var Er="right-panel";var wr="left-resizer",vr="right-resizer",Ir="footer-resizer",Cr="btn-left-panel-toggle",Tr="btn-right-panel-toggle",Sr="btn-create-keystone",Ht="center-panel-content";var Ki=class{static{p(this,"KeystoneSyncService")}lc="[KeystoneSyncService]";dispatchUpdateAvailableEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Vt,{detail:e,bubbles:!0,composed:!0}))}dispatchRenewalRequiredEvent(e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Xs,{detail:e,bubbles:!0,composed:!0}))}async getDeviceDelegateSecret({primaryTjpAddr:e}){return Oi({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 Oi({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=>gn({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}}},zi;function ct(){return zi||(zi=new Ki),zi}p(ct,"getKeystoneSyncService");var _r=`:host {
|
|
2
2
|
display: inline-block;
|
|
3
3
|
vertical-align: middle;
|
|
4
4
|
position: relative;
|