graview 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/preview/chunk.2643W7FT.js +1 -0
  2. package/dist/preview/chunk.2CLPRG3I.js +1 -0
  3. package/dist/preview/chunk.2IZFIORK.js +1 -0
  4. package/dist/preview/chunk.2NCTM5K2.js +2 -0
  5. package/dist/preview/{chunk.5BN2ARQ2.js → chunk.3G5MQFZK.js} +1 -1
  6. package/dist/preview/chunk.3JM2TNDD.js +2 -0
  7. package/dist/preview/chunk.44FVJOK4.js +28 -0
  8. package/dist/preview/chunk.4GGAPOMK.js +2 -0
  9. package/dist/preview/chunk.5AT4O4BN.js +1 -0
  10. package/dist/preview/chunk.5JXUAMKI.js +1 -0
  11. package/dist/preview/chunk.5R66YTET.js +2 -0
  12. package/dist/preview/chunk.64P76WK4.js +1 -0
  13. package/dist/preview/chunk.7D77HEIJ.js +1 -0
  14. package/dist/preview/chunk.7DNFXJH3.js +1 -0
  15. package/dist/preview/{chunk.HPD3DSTP.js → chunk.7PRFYYVM.js} +1 -1
  16. package/dist/preview/chunk.AE5GKL4C.js +1 -0
  17. package/dist/preview/chunk.ARR75WBP.js +35 -0
  18. package/dist/preview/chunk.AVUS5LMG.js +3 -0
  19. package/dist/preview/chunk.BKPGDEES.js +1 -0
  20. package/dist/preview/chunk.BZ5OJYHU.js +1 -0
  21. package/dist/preview/chunk.CK7QWLMX.js +1 -0
  22. package/dist/preview/chunk.COTG2IG5.js +1 -0
  23. package/dist/preview/chunk.D4GOVA25.js +1 -0
  24. package/dist/preview/chunk.DAA6XWLF.js +1 -0
  25. package/dist/preview/chunk.DKTCRFMS.js +1 -0
  26. package/dist/preview/chunk.DLGTFXGM.js +1 -0
  27. package/dist/preview/chunk.DN7SN6ZR.js +1 -0
  28. package/dist/preview/chunk.G4WQGTZR.js +3 -0
  29. package/dist/preview/chunk.GDA3G4U2.js +6 -0
  30. package/dist/preview/chunk.GS4T26WW.js +328 -0
  31. package/dist/preview/chunk.GZH6PTXN.js +1 -0
  32. package/dist/preview/chunk.HFKMHLJ3.js +1 -0
  33. package/dist/preview/chunk.HGAMNIST.js +1 -0
  34. package/dist/preview/chunk.HJCQ6I3S.js +1 -0
  35. package/dist/preview/chunk.HKBKH7EK.js +1 -0
  36. package/dist/preview/chunk.HLLWKSZB.js +5 -0
  37. package/dist/preview/chunk.HONUT6OG.js +1 -0
  38. package/dist/preview/chunk.HRWLR7T4.js +1 -0
  39. package/dist/preview/chunk.HV6I74DF.js +1 -0
  40. package/dist/preview/chunk.IPBXAAQV.js +17 -0
  41. package/dist/preview/chunk.IWYUFYDJ.js +1 -0
  42. package/dist/preview/chunk.IZW7DBK4.js +1 -0
  43. package/dist/preview/chunk.J46KDTEZ.js +10 -0
  44. package/dist/preview/chunk.JNGUSAWX.js +70 -0
  45. package/dist/preview/chunk.JU2ZVKMT.js +2 -0
  46. package/dist/preview/chunk.K4ZUVH2G.js +1 -0
  47. package/dist/preview/chunk.KC6UZHBM.js +1 -0
  48. package/dist/preview/chunk.KLITC55P.js +1 -0
  49. package/dist/preview/chunk.KZ2376BD.js +19 -0
  50. package/dist/preview/chunk.LYJAVUST.js +1 -0
  51. package/dist/preview/chunk.MB7LKKUD.js +1 -0
  52. package/dist/preview/chunk.MOUGB4H6.js +1 -0
  53. package/dist/preview/chunk.MYFWM572.js +1 -0
  54. package/dist/preview/chunk.N4FBDA2W.js +1 -0
  55. package/dist/preview/chunk.O42YET3W.js +1 -0
  56. package/dist/preview/chunk.O4QPITBD.js +9 -0
  57. package/dist/preview/{chunk.IXVSJJQH.js → chunk.OGXE2RHC.js} +4 -4
  58. package/dist/preview/chunk.OHE5AMHH.js +0 -0
  59. package/dist/preview/chunk.ONGVH3ZM.js +1076 -0
  60. package/dist/preview/chunk.OQDETV4X.js +1 -0
  61. package/dist/preview/chunk.OWBEV6FR.js +1 -0
  62. package/dist/preview/chunk.OWE6OJ4P.js +1 -0
  63. package/dist/preview/chunk.OYJSFO3A.js +1 -0
  64. package/dist/preview/chunk.P62SKNJS.js +27 -0
  65. package/dist/preview/chunk.PA5HYAEO.js +1 -0
  66. package/dist/preview/{chunk.OA5BVKJH.js → chunk.PMEDLEZY.js} +2 -2
  67. package/dist/preview/chunk.PTXQHHKF.js +1 -0
  68. package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
  69. package/dist/preview/chunk.QNHECGMH.js +1 -0
  70. package/dist/preview/chunk.QSDT2RLY.js +1 -0
  71. package/dist/preview/chunk.R2D373VG.js +1 -0
  72. package/dist/preview/chunk.RB4RTBRZ.js +1 -0
  73. package/dist/preview/chunk.RCLJ4H52.js +116 -0
  74. package/dist/preview/chunk.RKRSRKF3.js +1 -0
  75. package/dist/preview/chunk.RWGLKDWH.js +1 -0
  76. package/dist/preview/chunk.SIL4KD3K.js +1 -0
  77. package/dist/preview/chunk.SS76EIMI.js +1 -0
  78. package/dist/preview/{chunk.IKT7JQUW.js → chunk.T4LY5QXO.js} +1 -1
  79. package/dist/preview/chunk.UIIVEQAT.js +1 -0
  80. package/dist/preview/chunk.UT6642FC.js +1 -0
  81. package/dist/preview/chunk.UTHHX2TJ.js +1 -0
  82. package/dist/preview/chunk.UWNYT7PF.js +1 -0
  83. package/dist/preview/chunk.V6TK4LHW.js +6 -0
  84. package/dist/preview/chunk.VNBO2RXD.js +1 -0
  85. package/dist/preview/chunk.VPPUTA74.js +1 -0
  86. package/dist/preview/chunk.WKXNBHTL.js +4 -0
  87. package/dist/preview/chunk.WLRTPFAC.js +1 -0
  88. package/dist/preview/chunk.X53HI436.js +1 -0
  89. package/dist/preview/chunk.XAXJHEMD.js +1 -0
  90. package/dist/preview/chunk.XDYAG276.js +1 -0
  91. package/dist/preview/chunk.XDZSTIS6.js +88 -0
  92. package/dist/preview/chunk.XXHNV24G.js +1 -0
  93. package/dist/preview/chunk.YCA7P5MK.js +1 -0
  94. package/dist/preview/chunk.YRQZZH5V.js +1 -0
  95. package/dist/preview/chunk.YUWRZWGX.js +1 -0
  96. package/dist/preview/chunk.Z2RGLFLS.js +1 -0
  97. package/dist/preview/chunk.Z56B2JR2.js +25 -0
  98. package/dist/preview/chunk.Z5V23DQN.js +3 -0
  99. package/dist/preview/chunk.ZBXOX3W3.js +1 -0
  100. package/dist/preview/chunk.ZEGSQCSD.js +1 -0
  101. package/dist/preview/chunk.ZEVVWWNA.js +44 -0
  102. package/dist/preview/chunk.ZS4DJ76C.js +1 -0
  103. package/dist/preview/chunk.ZSKP6UQS.js +3 -0
  104. package/dist/preview/page.js +6 -6
  105. package/package.json +6 -6
  106. package/dist/preview/chunk.4HGBVU5B.js +0 -1
  107. package/dist/preview/chunk.4JXWQO6Y.js +0 -1
  108. package/dist/preview/chunk.4R7LDCDO.js +0 -1
  109. package/dist/preview/chunk.4W24TPMR.js +0 -1
  110. package/dist/preview/chunk.6LJ66MB7.js +0 -1
  111. package/dist/preview/chunk.6R4EI47C.js +0 -1
  112. package/dist/preview/chunk.7CO6VP6F.js +0 -1
  113. package/dist/preview/chunk.7QTBDACG.js +0 -1
  114. package/dist/preview/chunk.7SVIRYBB.js +0 -1
  115. package/dist/preview/chunk.7THQFY52.js +0 -1
  116. package/dist/preview/chunk.AHDOKM4O.js +0 -1
  117. package/dist/preview/chunk.AS35X6KA.js +0 -1
  118. package/dist/preview/chunk.ATLUMYAJ.js +0 -23
  119. package/dist/preview/chunk.CW7BMVBG.js +0 -321
  120. package/dist/preview/chunk.DG2UE7PJ.js +0 -1
  121. package/dist/preview/chunk.DG2WKNMX.js +0 -1
  122. package/dist/preview/chunk.DQ5OWYLQ.js +0 -1
  123. package/dist/preview/chunk.DY2FFBWF.js +0 -1
  124. package/dist/preview/chunk.E3SZ7T75.js +0 -1
  125. package/dist/preview/chunk.EVTZE2OZ.js +0 -1
  126. package/dist/preview/chunk.FS5K4AVA.js +0 -8
  127. package/dist/preview/chunk.FTBKJ5RZ.js +0 -16
  128. package/dist/preview/chunk.GHMICJIB.js +0 -1
  129. package/dist/preview/chunk.HO6JR7VY.js +0 -1
  130. package/dist/preview/chunk.I5KD54S6.js +0 -1
  131. package/dist/preview/chunk.IZDKEFPJ.js +0 -1
  132. package/dist/preview/chunk.J36GTQTV.js +0 -1
  133. package/dist/preview/chunk.KAKX5TZN.js +0 -3
  134. package/dist/preview/chunk.LHAAZQNQ.js +0 -19
  135. package/dist/preview/chunk.LQZ2VQWN.js +0 -107
  136. package/dist/preview/chunk.MHJJEGQO.js +0 -1
  137. package/dist/preview/chunk.MNPNW4BQ.js +0 -1
  138. package/dist/preview/chunk.MRK6QJV5.js +0 -25
  139. package/dist/preview/chunk.NKIFVPS3.js +0 -1
  140. package/dist/preview/chunk.NQNQPPPM.js +0 -1
  141. package/dist/preview/chunk.OHGJ5BZ4.js +0 -2
  142. package/dist/preview/chunk.OYULDOQP.js +0 -1
  143. package/dist/preview/chunk.PHY3AH3L.js +0 -1
  144. package/dist/preview/chunk.Q7544RCB.js +0 -1
  145. package/dist/preview/chunk.QZWN46V6.js +0 -1
  146. package/dist/preview/chunk.RUC4HFVC.js +0 -1
  147. package/dist/preview/chunk.S5JWZIVE.js +0 -1
  148. package/dist/preview/chunk.SHDYLMZE.js +0 -2
  149. package/dist/preview/chunk.T2EZ5MTH.js +0 -1
  150. package/dist/preview/chunk.TMPV4HLQ.js +0 -1
  151. package/dist/preview/chunk.TX2GOL65.js +0 -29
  152. package/dist/preview/chunk.U5ZUXGWM.js +0 -1040
  153. package/dist/preview/chunk.UMMN5Z6V.js +0 -1
  154. package/dist/preview/chunk.UPGDSOBY.js +0 -1
  155. package/dist/preview/chunk.V57P4LIZ.js +0 -1
  156. package/dist/preview/chunk.VD6FJ6KJ.js +0 -2
  157. package/dist/preview/chunk.VFICMX5G.js +0 -61
  158. package/dist/preview/chunk.VMD4PDYJ.js +0 -1
  159. package/dist/preview/chunk.VMEX2KZ4.js +0 -8
  160. package/dist/preview/chunk.XDHBV5K5.js +0 -1
  161. package/dist/preview/chunk.YO7UFBJP.js +0 -1
  162. package/dist/preview/chunk.YSYT3ASK.js +0 -1
  163. package/dist/preview/chunk.YV2RTNPU.js +0 -6
  164. package/dist/preview/chunk.ZD5HGRPR.js +0 -1
  165. package/dist/preview/chunk.ZKM4P7US.js +0 -1
  166. package/dist/preview/chunk.ZMMMKTAG.js +0 -1
  167. package/dist/preview/chunk.ZNIJONZN.js +0 -1
@@ -0,0 +1,5 @@
1
+ var Kr="en-US",lt=/^\d{4}-\d{2}-\d{2}$/,ga=/^\d{4}(-\d\d){2}[T ]\d\d:\d\d(:[\d.]+)?(Z|[+-][\d:]+)?$/,ju=n=>!Number.isNaN(Date.parse(n)),nn=()=>new Date().toISOString().slice(0,10),Vr,Wr;function ma(n){Vr=ut(n.reader),Wr=ut(n.app)}var qr=n=>Vr??ut(n)??Wr??Kr,en=new Map;function ut(n){if(n&&!en.has(n)){let e=!1;try{e=Intl.DateTimeFormat.supportedLocalesOf(n).length>0}catch{}en.set(n,e)}return n&&en.get(n)?n:void 0}function ue(n,e,t,r){let o=`${t=qr(t)}${r?"#":"@"}${JSON.stringify(e)}`,i=en.get(o);return i||en.set(o,i=r?new Intl.NumberFormat(t,e):new Intl.DateTimeFormat(t,e)),i.format(n).replace(/ /g," ")}var xe="UTC",En=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10));function Pe(n,e){return lt.test(n)?ue(En(n),{year:"numeric",month:"short",day:"numeric",timeZone:xe},e):n}function Hr(n,e,t){if(!ga.test(n))return n;let r=/[Z+-][\d:]*$/.test(n.slice(16)),o=Date.parse(n.replace(" ","T")+(r?"":"Z"));return Number.isNaN(o)?n:ue(o,{...e,hour:"numeric",minute:"2-digit",...r?{}:{timeZone:xe}},t)}var ya=(n,e)=>Hr(n,{year:"numeric",month:"short",day:"numeric"},e),ba=(n,e)=>Hr(n,{},e);function le(n,e,t={maximumFractionDigits:2}){return Number.isFinite(n)?ue(n,t,e,!0):String(n)}function xa(n,e={},t){return lt.test(n)?ue(En(n),{weekday:e.weekday??"long",month:"short",day:"numeric",...e.year?{year:"numeric"}:{},timeZone:xe},t):n}function va(n,e){return lt.test(n)?ue(En(n),{month:"short",day:"numeric",timeZone:xe},e):n}function wa(n,e={},t){if(!/^\d{4}-\d{2}/.test(n))return n;let r=e.year??!e.short;return ue(En(`${n.slice(0,7)}-01`),{month:e.short?"short":"long",...r?{year:e.short?"2-digit":"numeric"}:{},timeZone:xe},t)}var ka=(n,e="short",t)=>ue(Date.UTC(1970,0,4+n),{weekday:e,timeZone:xe},t),Sa=(n,e)=>ue(Date.UTC(1970,0,1,0,Math.round(n)),{hour:"numeric",minute:"2-digit",timeZone:xe},e),$a=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function ft(n,e){return n.includes("-")?n.replace($a,t=>Pe(t,e)):n}var tn=n=>n.charAt(0).toUpperCase()+n.slice(1),Jr=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"";function _a(n,e){return{...e,kind:n,edges:e.edges??{}}}function pt(n,e,t){let r=n?.lifecycle;if(!r)return!0;let o=e[r.field];return r.retired==="date"?typeof o!="string"||o.length===0?!0:o>=(t??nn()):!r.retired.includes(o)}function T(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function Aa(n){return n.title??U(n.name)}function U(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return tn(e)}function Ra(n,e,t){let r=n.tryDefinition(e);return`${le(t)} ${t===1?ne(r,e):rn(n,e).toLowerCase()}`}function rn(n,e){return n.tryDefinition(e)?.plural??`${U(e).toLowerCase()}s`}function Oa(n,e){return tn(rn(n,e))}function zn(n,e){let t=n?.computed&&Object.hasOwn(n.computed,e)?n.computed[e]:void 0;return n?.display?.labels?.[e]??(typeof t=="object"?t.label:void 0)??(e==="label"?"Name":U(e))}var Pa=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,Ea=/^(hour|honest|hono[ur]r?|heir)/;function Yr(n){let e=U(n).toLowerCase();return Ea.test(e)?"an":Pa.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function Mn(n){return`${Yr(n)} ${U(n).toLowerCase()}`}function ne(n,e){return n?.noun??U(e).toLowerCase()}function mt(n){let e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,o])=>e.indexOf(+r)===-1).map(([r,o])=>o)}function yt(n,e="|"){return n.map(t=>kt(t)).join(e)}function Xr(n,e){return typeof e=="bigint"?e.toString():e}var gt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Qr(n){return new gt(n)}function eo(n){return n==null}function bt(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function no(n,e){let t=n/e,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-r)<o?0:t-r}function In(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function to(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function xt(n){return to(n._zod.def)??n._zod.def.shape}function ro(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return In(this,e,r),r},enumerable:!0,configurable:!0})}function oo(n,e,t){e in n?In(n,e,t):n[e]=t}function za(n,e,t,r){let o=xt(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?ro(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):oo(n,i,r?r(s.value,i):s.value))}}function Ma(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?ro(n,t,()=>e[t]):oo(n,t,r.value))}}function io(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var vt="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Nn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function wt(n){if(Nn(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(Nn(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var so=new Set(["string","number","symbol"]);function sn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ee(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function P(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function kt(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function ao(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var co={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function uo(n,e){if(!wt(e))throw new Error("Invalid input to extend: expected a plain object");let t=n._zod.def.checks;if(t&&t.length>0){let o=xt(n);for(let i of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ee(n,io(n._zod.def,{shape:Na(n,e)}))}function Na(n,e){let t={};return za(t,n,Reflect.ownKeys(xt(n))),Ma(t,e),t}function te(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue!==!0)return!0;return!1}function lo(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue===!1)return!0;return!1}function pe(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function on(n){return typeof n=="string"?n:n?.message}function St(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function re(n,e,t){var r;let o=n.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=n).schema??(r.schema=n.inst):n.schema=n.inst);let i=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,s=n.message?n.message:on(n.inst?._zod.def?.error?.(n))??on(i?.(n))??on(e?.error?.(n))??on(t.customError?.(n))??on(t.localeError?.(n))??"Invalid input",a={};for(let d of Object.keys(n))d==="inst"||d==="schema"||d==="continue"||d==="input"||d==="__proto__"||(a[d]=n[d]);return a.path??(a.path=[]),a.message=s,e?.reportInput&&(a.input=n.input),a}var Ia=/[\uD800-\uDBFF]/;function $t(n){let e=n.length;if(!Ia.test(n))return e;let t=e;for(let r=0;r<e-1;r++)(n.charCodeAt(r)&64512)===55296&&(n.charCodeAt(r+1)&64512)===56320&&(t--,r++);return t}function _t(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function fo(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let t=n;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function an(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function po(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):ja(n,t,r.value)}}function ve(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function At(n,e,t){return ve(n,e,t,!1)}function ja(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:ve(this,e,t.bind(this))},set(r){ve(this,e,r)}})}function Da(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var ht,fe=!1,Ta={configurable:!0,get(){fe=!0}};function q(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&ht!==n._zod){ht=void 0;return}ht=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,Ta);let o=fe;fe=!1;try{let i=t(this);return fe?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),fe=fe||o,i}catch(i){throw delete this[e],fe=fe||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function ho(n,e,t,r){let o=Da(n,e);o&&Object.defineProperty(o,e,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,e,i),i.value=t(this),Object.defineProperty(this,e,i),i.value},set(i){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var go;var Rt={value:void 0,enumerable:!1},mo="captureStackTrace"in Error?Error:null;function Za(n){let e=mo;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return mo=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function A(n,e,t,r){let o={};function i(c){this.def=c,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(c,f){if(c._zod){if(c._zod.traits.has(n))return}else{Rt.value=new i(f);try{Object.defineProperty(c,"_zod",Rt)}finally{Rt.value=void 0}}if(c._zod.traits.add(n),e(c,f),a){let h=Object.getPrototypeOf(c),x=c._zod.constr.prototype,b=h;for(;b&&b!==x;)b=Object.getPrototypeOf(b);let k=b??h;a.has(k)||(a.add(k),po(k,s))}let g=p.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in c||(c[h]=g[h].bind(c)))}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:n});function p(c){let f=r?.Parent?Za(l):this;d(f,c);let g=f._zod.deferred;if(g){for(let x of g)x();f._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(f),f}return Object.defineProperty(p,"init",{value:d}),Object.defineProperty(p,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(p,"name",{value:n}),p}var ie=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(go=globalThis).__zod_globalConfig??(go.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function K(n){return n&&Object.assign(ze,n),ze}function Fa(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,Xr,2)),n.message}function Ca(n){this._zod.message=n}var La={get:Fa,set:Ca,enumerable:!0,configurable:!0},Pt={value:void 0,enumerable:!1},yo=new WeakSet([Object.prototype,Error.prototype]),bo=(n,e)=>{n.name="$ZodError",Pt.value=e,Object.defineProperty(n,"issues",Pt),Pt.value=void 0,Object.defineProperty(n,"message",La);let t=Object.getPrototypeOf(n);yo.has(t)||(yo.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Bu=A("$ZodError",bo),dn=A("$ZodError",bo,void 0,{Parent:Error});var Ba=n=>{let e=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ie;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(u=>re(u,s,K())));throw vt(d,i?.callee??e),d}return a.value};return e},Et=Ba(dn),Ua=n=>{let e=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let d=new(i?.Err??n)(a.issues.map(u=>re(u,s,K())));throw vt(d,i?.callee??e),d}return a.value};return e},zt=Ua(dn),Ka=n=>(e,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new ie;return i.issues.length?xo(n,i.issues,o):{success:!0,data:i.value}},Mt=Ka(dn);function xo(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>re(o,t,K()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var Va=n=>async(e,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=e._zod.run({value:t,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?xo(n,i.issues,o):{success:!0,data:i.value}},Nt=Va(dn);var vo=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var wo=/^https?$/;var ko=/^[\s\S]{0,}$/;var It=/^-?\d+(?:\.\d+)?$/,So=/^(?:true|false)$/i,$o=/^null$/i;var V=A("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var _o=n=>{let e=n.value;return!eo(e)&&e.length!==void 0},jn={number:"number",bigint:"bigint",object:"date"},Ao=A("$ZodCheckLessThan",(n,e)=>{V.init(n,e);let t=jn[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:jn[typeof r.value]??t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Ro=A("$ZodCheckGreaterThan",(n,e)=>{V.init(n,e);let t=jn[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:jn[typeof r.value]??t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Oo=A("$ZodCheckMultipleOf",(n,e)=>{V.init(n,e),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?e.value!==BigInt(0)&&t.value%e.value===BigInt(0):no(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),Po=A("$ZodCheckNumberFormat",(n,e)=>{V.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=co[e.format];n._zod.check=s=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:n});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:n,continue:!e.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:n,continue:!e.abort})}});var Eo=A("$ZodCheckMaxLength",(n,e)=>{var t;V.init(n,e),(t=n._zod.def).when??(t.when=_o),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?$t(o):i)<=e.maximum)return;let a=_t(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),zo=A("$ZodCheckMinLength",(n,e)=>{var t;V.init(n,e),(t=n._zod.def).when??(t.when=_o),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?$t(o):i)>=e.minimum)return;let a=_t(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var Dt=A("$ZodCheckStringFormat",(n,e)=>{var t,r;V.init(n,e),e.pattern?(t=n._zod).check??(t.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),Mo=A("$ZodCheckRegex",(n,e)=>{Dt.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}});var Io={major:4,minor:6,patch:5};var Z=A("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=Io;let r=n._zod.def.checks,o=n._zod.traits.has("$ZodCheck")?[n,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(n);if(o.length===0)(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let i=(a,d,u)=>{if(a.memo)return a;let l=te(a),p;for(let c of d){if(c._zod.def.when){if(lo(a)||!c._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,g=c._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new ie;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,a.issues.length!==f&&(St(a.issues,f,n),l||(l=te(a,f)))});else{if(a.issues.length===f)continue;St(a.issues,f,n),l||(l=te(a,f))}}return p?p.then(()=>a):a},s=(a,d,u)=>{if(te(a))return a.aborted=!0,a;let l=i(d,o,u);if(l instanceof Promise){if(u.async===!1)throw new ie;return l.then(p=>n._zod.parse(p,u))}return n._zod.parse(l,u)};n._zod.run=(a,d)=>{if(d.skipChecks)return n._zod.parse(a,d);if(d.direction==="backward"){let l=n._zod.parse({value:a.value,issues:[]},{...d,skipChecks:!0});return l instanceof Promise?l.then(p=>s(p,a,d)):s(l,a,d)}let u=n._zod.parse(a,d);if(u instanceof Promise){if(d.async===!1)throw new ie;return u.then(l=>i(l,o,d))}return i(u,o,d)}}},{get"~standard"(){return At(this,"~standard",qa(this))},set"~standard"(n){ve(this,"~standard",n)}}),Co=(n,e)=>n.issues.length?{issues:n.issues.map(t=>re(t,e,K()))}:{value:n.value};async function Wa(n,e){let t={async:!0};return Co(await n._zod.run({value:e,issues:[]},t),t)}function qa(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return Co(r,t)}catch{}return Wa(n,e)},vendor:"zod",version:1}}var Tt=A("$ZodString",(n,e)=>{Z.init(n,e),n._zod.pattern=e.pattern??ko,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:n}),t}}),Zn=A("$ZodStringFormat",(n,e)=>{Dt.init(n,e),Tt.init(n,e)});var Lo=A("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=vo),Zn.init(n,e)}),Go=1,Dn=2;function Ha(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function Ja(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?Ha(n)||Dn:Ya(n,e)}function Ya(n,e){if(!e.normalize&&e.protocol?.source===wo.source&&!/^https?:\/\//i.test(n))return Go;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??Dn}return new URL(n)}catch{return Dn}}var Xa=/[\t\n\r]/g;function jo(n){return n.replace(Xa,"")}function Qa(n,e){return e.lastIndex=0,e.test(n.hostname)}function ed(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var Bo=A("$ZodURL",(n,e)=>{Zn.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=Ja(r,e);if(o===Go){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===Dn){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=jo(r);return}e.hostname&&!Qa(o,e.hostname)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort}),e.protocol&&!ed(o,e.protocol)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort}),t.value=e.normalize?o.href:jo(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var Zt=A("$ZodNumber",(n,e)=>{Z.init(n,e),n._zod.pattern=It,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}let o=t.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:n,...i?{received:i}:{}}),t}}),Uo=A("$ZodNumberFormat",(n,e)=>{Po.init(n,e),Zt.init(n,e)}),Ko=A("$ZodBoolean",(n,e)=>{Z.init(n,e),n._zod.pattern=So,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}let o=t.value;return typeof o=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:n}),t}});var Vo=A("$ZodNull",(n,e)=>{Z.init(n,e),n._zod.pattern=$o,n._zod.values=new Set([null]),n._zod.parse=(t,r)=>{let o=t.value;return o===null||t.issues.push({expected:"null",code:"invalid_type",input:o,inst:n}),t}});var Wo=A("$ZodUnknown",(n,e)=>{Z.init(n,e),n._zod.parse=t=>t}),qo=A("$ZodNever",(n,e)=>{Z.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Do(n,e,t){n.issues.length&&e.issues.push(...pe(t,n.issues)),e.value[t]=n.value}var Ho=A("$ZodArray",(n,e)=>{Z.init(n,e);let t=ze.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),r;r.value=t?t.alloc(n,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let d=0;d<i.length;d++){let u=i[d],l=e.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then(p=>Do(p,r,d)));else if(Do(l,r,d),a&&l.issues.length!==0&&te(l))break}return s.length?Promise.all(s).then(()=>r):r}});function Tn(n,e,t,r,o,i){let s=t in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(n.issues.length){if(o!==void 0&&a&&!s)return;e.issues.push(...pe(t,n.issues))}if(!s&&o===void 0){n.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}n.value===void 0?(s||o==="defaulted"&&!a)&&(e.value[t]=void 0):e.value[t]=n.value}}var nd=[];function td(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:nd,o=r.length?[...e,...r]:e;for(let s of o)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=ao(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function rd(n,e,t,r,o,i,s){let a=[],d=o.keySet,u=o.catchall._zod,l=u.def.type,p=u.optin,c=u.optout,f=0;for(let g in e){if(s&&t.issues.length!==f){if(te(t,f))break;f=t.issues.length}if(d.has(g))continue;if(g==="__proto__"){l==="never"&&a.push(g);continue}if(l==="never"){a.push(g);continue}let h=u.run({value:e[g],issues:[]},r);h instanceof Promise?n.push(h.then(x=>Tn(x,t,g,e,p,c))):Tn(h,t,g,e,p,c)}return a.length&&t.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:i,continue:!0}),n.length?Promise.all(n).then(()=>t):t}var Jo=A("$ZodObject",(n,e)=>{Z.init(n,e);let t=Object.getOwnPropertyDescriptor(e,"shape"),r=t?.get?t.get.raw:e.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(e,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(e,"shape",{get:u})}let o=Qr(()=>td(e));q(n,"propValues",u=>{let l=u.def.shape,p={};for(let c in l){let f=l[c]._zod;if(f.values){Object.prototype.hasOwnProperty.call(p,c)||In(p,c,new Set);for(let g of f.values)p[c].add(g);f.optin!==void 0&&p[c].add(void 0)}}return p});let i=Nn,s=e.catchall,a,d=ze.memoizer;d?.attach(n),n._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),u;u.value=d?d.alloc(n,u,{},l):{};let c=[],f=a.shape,g=l?.abortEarly,h=u.issues.length;for(let x of a.allKeys){if(g&&u.issues.length!==h){if(te(u,h))break;h=u.issues.length}if(x==="__proto__")continue;let b=f[x],k=b._zod.optin,$=b._zod.optout,m=b._zod.run({value:p[x],issues:[]},l);m instanceof Promise?c.push(m.then(y=>Tn(y,u,x,p,k,$))):Tn(m,u,x,p,k,$)}return s?rd(c,p,u,l,o.value,n,g===!0):c.length?Promise.all(c).then(()=>u):u}});function To(n,e,t,r){for(let i of n)if(i.issues.length===0)return e.value=i.value,e;let o=n.filter(i=>!te(i));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(i=>i.issues.map(s=>re(s,r,K())))}),e)}var Yo=A("$ZodUnion",(n,e)=>{Z.init(n,e),q(n,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),q(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),q(n,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),q(n,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>bt(i.source)).join("|")})$`)}});let t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of e.options){let d=a._zod.run({value:r.value,issues:[]},o);if(d instanceof Promise)s.push(d),i=!0;else{if(d.issues.length===0)return d;s.push(d)}}return i?Promise.all(s).then(a=>To(a,r,n,o)):To(s,r,n,o)}});var Xo=A("$ZodRecord",(n,e)=>{Z.init(n,e);let t=ze.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!wt(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),r;let s=[],a=e.keyType._zod.values;if(a&&!e.partial){r.value=t?t.alloc(n,r,{},o):{};let d=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(d.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let p=e.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>re(g,o,K())),input:l,path:[l],inst:n});continue}let c=p.value;if(c==="__proto__")continue;let f=e.valueType._zod.run({value:i[l],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...pe(l,g.issues)),r.value[c]=g.value})):(f.issues.length&&r.issues.push(...pe(l,f.issues)),r.value[c]=f.value)}let u;for(let l in i)if(!d.has(l))if(e.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:u,continue:!0})}else{r.value=t?t.alloc(n,r,{},o):{};let d;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=e.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&It.test(u)&&l.issues.length){let g=e.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(l=g)}if(l.issues.length){e.mode==="loose"?r.value[u]=i[u]:a?(d=d??[],d.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(g=>re(g,o,K())),input:u,path:[u],inst:n});continue}let c=l.value;if(c==="__proto__")continue;let f=e.valueType._zod.run({value:i[u],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...pe(u,g.issues)),r.value[c]=g.value})):(f.issues.length&&r.issues.push(...pe(u,f.issues)),r.value[c]=f.value)}d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:d,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var Qo=A("$ZodEnum",(n,e)=>{Z.init(n,e);let t=mt(e.entries),r=new Set(t);n._zod.values=r,q(n,"pattern",o=>{let i=mt(o.def.entries).filter(s=>so.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>sn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(o,i)=>{let s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:t,input:s,inst:n}),o}}),ei=A("$ZodLiteral",(n,e)=>{Z.init(n,e);let t=new Set(e.values);n._zod.values=t,q(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?sn(i):i?sn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{let i=r.value;return t.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:n}),r}});function Zo(n,e){return n.value=e.issues.length?void 0:e.value,n}var ni=A("$ZodOptional",(n,e)=>{Z.init(n,e),q(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",q(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),q(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${bt(r.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;let o=e.innerType._zod.run({value:t.value,issues:[]},r);return o instanceof Promise?o.then(i=>Zo(t,i)):Zo(t,o)}return e.innerType._zod.run(t,r)}});var ti=A("$ZodCustom",(n,e)=>{V.init(n,e),Z.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{let r=t.value,o=e.fn(r);if(o instanceof Promise)return o.then(i=>Fo(i,t,r,n));Fo(o,t,r,n)}});function Fo(n,e,t,r){if(!n){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),e.issues.push(an(o))}}var od=()=>{let n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(i){return n[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=fo(i.input),d=o(a,i.input);return`Invalid input: expected ${s}, received ${d}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${kt(i.values[0])}`:`Invalid option: expected one of ${yt(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=e(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=e(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${yt(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function ri(){return{localeError:od()}}var oi;var Ft=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ii(){return new Ft}(oi=globalThis).__zod_globalRegistry??(oi.__zod_globalRegistry=ii());var Me=globalThis.__zod_globalRegistry;function si(n){return n.checks&&(n.checks=[...n.checks]),n}function ai(n,e){return new n(si({type:"string",...P(e)}))}function di(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...P(e)})}function ci(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...P(e)})}function ui(n,e){return new n(si({type:"number",checks:[],...P(e)}))}function li(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...P(e)})}function fi(n,e){return new n({type:"boolean",...P(e)})}function pi(n,e){return new n({type:"null",...P(e)})}function hi(n){return new n({type:"unknown"})}function gi(n,e){return new n({type:"never",...P(e)})}function mi(n,e){return new Ao({check:"less_than",...P(e),value:n,inclusive:!0})}function yi(n,e){return new Ro({check:"greater_than",...P(e),value:n,inclusive:!0})}function dd(n,e){return new Oo({check:"multiple_of",...P(e),value:n})}function Ct(n,e){return new Eo({check:"max_length",...P(e),maximum:n})}function cn(n,e){return new zo({check:"min_length",...P(e),minimum:n})}function un(n,e){return new Mo({check:"string_format",format:"regex",...P(e),pattern:n})}function bi(n,e,t){return new n({type:"custom",check:"custom",fn:e,...P(t)})}function xi(n,e){let t=cd(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(an(o,r.value,t._zod.def));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(an(i))}},n(r.value,r)),e);return t}function cd(n,e){let t=new V({check:"custom",...P(e)});return t._zod.check=n,t}function vi(n){let e=new V({check:"describe"});return e._zod.onattach=[t=>{let r=Me.get(t)??{};Me.add(t,{...r,description:n})}],e._zod.check=()=>{},e}var G=A("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");Z.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){ve(this,"with",n)},parse(n,e){return Et(this,n,e,{callee:this.parse})},parseAsync(n,e){return zt(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return Mt(this,n,e)},safeParseAsync(n,e){return Nt(this,n,e)},check(...n){let e=this.def;return this.clone({...e,checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]},{parent:!0})},clone(n,e){return Ee(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},apply(n,...e){return e.length===0?n(this):n(this,...e)}}),ki=A("ZodMiniString",(n,e)=>{Tt.init(n,e),G.init(n,e)});function j(n){return ai(ki,n)}var Si=A("ZodMiniStringFormat",(n,e)=>{Zn.init(n,e),ki.init(n,e)}),fd=A("ZodMiniEmail",(n,e)=>{Lo.init(n,e),Si.init(n,e)});function qp(n){return di(fd,n)}var pd=A("ZodMiniURL",(n,e)=>{Bo.init(n,e),Si.init(n,e)});function Hp(n){return ci(pd,n)}var $i=A("ZodMiniNumber",(n,e)=>{Zt.init(n,e),G.init(n,e)});function Fn(n){return ui($i,n)}var hd=A("ZodMiniNumberFormat",(n,e)=>{Uo.init(n,e),$i.init(n,e)});function Jp(n){return li(hd,n)}var gd=A("ZodMiniBoolean",(n,e)=>{Ko.init(n,e),G.init(n,e)});function Yp(n){return fi(gd,n)}var md=A("ZodMiniNull",(n,e)=>{Vo.init(n,e),G.init(n,e)});function Xp(n){return pi(md,n)}var yd=A("ZodMiniUnknown",(n,e)=>{Wo.init(n,e),G.init(n,e)});function Lt(){return hi(yd)}var bd=A("ZodMiniNever",(n,e)=>{qo.init(n,e),G.init(n,e)});function xd(n){return gi(bd,n)}var vd=A("ZodMiniArray",(n,e)=>{Ho.init(n,e),G.init(n,e)});function Qp(n,e){return new vd({type:"array",element:n,...P(e)})}var Gt=A("ZodMiniObject",(n,e)=>{Jo.init(n,e),G.init(n,e),ho(n,"shape",t=>t._zod.def.shape,!1)});function Ne(n,e){let t={type:"object",shape:n??{},...P(e)};return new Gt(t)}function Cn(n,e){return new Gt({type:"object",shape:n,catchall:xd(),...P(e)})}function eh(n,e){return new Gt({type:"object",shape:n,catchall:Lt(),...P(e)})}function _i(n,e){return uo(n,e)}var wd=A("ZodMiniUnion",(n,e)=>{Yo.init(n,e),G.init(n,e)});function nh(n,e){return new wd({type:"union",options:n,...P(e)})}var wi=A("ZodMiniRecord",(n,e)=>{Xo.init(n,e),G.init(n,e)});function th(n,e,t){return!e||!e._zod?new wi({type:"record",keyType:j(),valueType:n,...P(e)}):new wi({type:"record",keyType:n,valueType:e,...P(t)})}var kd=A("ZodMiniEnum",(n,e)=>{Qo.init(n,e),G.init(n,e),n.options=[...n._zod.values]});function Ai(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new kd({type:"enum",entries:t,...P(e)})}var Sd=A("ZodMiniLiteral",(n,e)=>{ei.init(n,e),G.init(n,e)});function Ri(n,e){return new Sd({type:"literal",values:Array.isArray(n)?n:[n],...P(e)})}var $d=A("ZodMiniOptional",(n,e)=>{ni.init(n,e),G.init(n,e)});function se(n){return new $d({type:"optional",innerType:n})}var _d=A("ZodMiniCustom",(n,e)=>{ti.init(n,e),G.init(n,e)});function Ln(n,e={}){return bi(_d,n,e)}function rh(n,e){return xi(n,e)}var oh=vi;K().localeError||K(ri());var I=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Ad=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=Me.get(n)?.description;return typeof e=="string"?e:void 0};var Oi=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),Bt=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function Ut(n){let e=n??{};return Oi(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&Bt(e.bytes,0)&&Bt(e.width)&&Bt(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)}var Pi=n=>n.type.startsWith("image/"),ln=n=>(Array.isArray(n)?n:[n]).filter(Ut),Ei=Symbol.for("@graview/core:file"),Rd=(n,e)=>(Object.defineProperty(I(n),Ei,{value:e,enumerable:!0}),n);function zi(n){let e=I(n);return e?.[Ei]??(e?.innerType?zi(e.innerType):void 0)}var Od=()=>({href:j(),name:j(),type:j(),bytes:Fn(),width:se(Fn()),height:se(Fn()),caption:se(j())});function ig(n){return Rd(Ne(Od()).check(Ln(e=>Ut(e)&&(n==="file"||Pi(e)),`${n==="image"?"an image":"a file"} the host stored, at a path on this host`)),n)}var Gn=["sun","mon","tue","wed","thu","fri","sat"],Pd=["day","week","month","year"],je=n=>`${n}Repeat`,Wt=n=>n.endsWith("Repeat")&&n.length>6?n.slice(0,-6):void 0,Ii=/^\d{4}-\d{2}-\d{2}$/,ji=Symbol.for("@graview/core:repeat");function Bn(n){let e=I(n);return!!e&&(e[ji]===1||Bn(e.innerType))}var Ed=n=>(Object.defineProperty(I(n),ji,{value:1,enumerable:!0}),n),Kt=(n,e,t)=>n===void 0||Number.isInteger(n)&&n>=e&&n<=t,Mi=(n,e)=>n===void 0||Array.isArray(n)&&n.length<=e&&n.every(t=>typeof t=="string"&&Ii.test(t)),zd=["every","interval","on","until","count","except","continues"],Di=n=>De(n)&&Object.keys(n).every(e=>zd.includes(e))&&Kt(n.interval,1,99)&&Kt(n.count,1,1e3)&&Mi(n.until===void 0?void 0:[n.until],1)&&Mi(n.except,500)&&(n.continues===void 0||typeof n.continues=="string"&&n.continues.length<=200)&&(n.on===void 0||Array.isArray(n.on)&&n.on.length>0&&n.on.length<=31&&n.on.every(e=>n.every==="week"?Gn.includes(e):n.every==="month"&&e!==0&&Kt(e,-1,31))),dg=()=>Ed(Lt().check(Ln(n=>n===null||Di(n),"how a date repeats, or null"))),fn=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),Ti=n=>new Date(n).toISOString().slice(0,10),Vt=(n,e)=>Ti(fn(n)+e*864e5),Ni=(n,e,t)=>{let r=new Date(Date.UTC(n,e+1,0)).getUTCDate();return Ti(Date.UTC(n,e,t<0||t>r?r:t))},De=n=>typeof n=="object"&&n!==null&&Pd.includes(n.every);function Ie(n,e,t={}){let r=n.slice(0,10),o=n.slice(10),i=[];if(!Ii.test(r))return i;let s=Math.max(1,e.interval??1),a=e.every,d=t.from&&t.from>r?t.from.slice(0,10):r,u=[e.until,t.to?.slice(0,10)].filter(Boolean).sort()[0],l=t.limit??1e3,p=new Set(e.except??[]),c=+r.slice(0,4),f=+r.slice(5,7)-1,g=+r.slice(8,10),h=Vt(r,-new Date(fn(r)).getUTCDay()),x=(e.on?.length?e.on:[a==="week"?Gn[new Date(fn(r)).getUTCDay()]:g]).map(y=>typeof y=="string"?Gn.indexOf(y):y),b=a==="day"?1:a==="week"?7:0,k=(+d.slice(0,4)-c)*12+(+d.slice(5,7)-1-f),$=e.count?0:Math.max(0,Math.floor((b?(fn(d)-fn(b===7?h:r))/864e5/b:a==="month"?k:k/12)/s)-1),m=0;for(let y=0;y<5e4&&i.length<l;y++,$++){let v=$*s,S=a==="day"?[Vt(r,v)]:a==="week"?x.map(w=>Vt(h,v*7+w)):a==="month"?x.map(w=>Ni(c,f+v,w)):[Ni(c+v,f,g)];for(let w of[...new Set(S)].sort())if(!(w<r)&&(u&&w>u||e.count&&m>=e.count||(m++,w>=d&&!p.has(w)&&i.push(w+o),i.length>=l)))return i}return i}function Zi(n,e,t){if(!De(e)||typeof n!="string")return n;let r=Ie(n,e,{from:t,limit:1})[0];if(r)return r;let o=e.until||e.count?Ie(n,e):[];return o[o.length-1]??n}function Md(n,e,t){let r=n[e],o=n[je(e)];return typeof r=="string"&&De(o)?Zi(r,o,t):r}var Y="$archived",we=n=>n?.[Y]===!0,ug=(n,e=!1)=>e==="all"||we(n)===e,qt=n=>n===!0||n==="true"?!0:n==="all"?"all":!1;var X="\0graview:unset",Te=n=>n===void 0||n===X;function pn(n){if(n.op!=="patch-node")return n;let e=t=>Object.fromEntries(Object.entries(t).map(([r,o])=>[r,o===void 0?X:o]));return{...n,before:e(n.before),after:e(n.after)}}function hn(n){switch(n.op){case"add-node":return{op:"remove-node",node:n.node};case"remove-node":return{op:"add-node",node:n.node};case"patch-node":return{op:"patch-node",id:n.id,before:n.after,after:n.before};case"add-edge":return{op:"remove-edge",edge:n.edge};case"remove-edge":return{op:"add-edge",edge:n.edge}}}function ke(n){switch(n.op){case"add-node":case"remove-node":return[n.node.id];case"patch-node":return[n.id];case"add-edge":case"remove-edge":return[n.edge.from,n.edge.to]}}var H=class extends Error{constructor(t,r){super(r?`${t}
2
+ \u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function Nd(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new H(`Duplicate node kind "${a.kind}"`,"Each kind may be declared once; merge the two defineNode calls.");r.set(a.kind,a)}let o=new Map;for(let a of t)for(let[d,u]of Object.entries(a.edges)){if(u.to!=="*"){for(let p of u.to)if(!r.has(p))throw new H(`Edge "${d}" on "${a.kind}" points at undeclared kind "${p}"`,`Declared kinds: ${[...r.keys()].join(", ")}`)}let l=o.get(d);l?l.from.push(a.kind):o.set(d,{from:[a.kind],decl:u})}let i=new Map;for(let[a,{from:d,decl:u}]of o){let l=d.map(p=>r.get(p).edges[a].to);i.set(a,{kind:a,from:d,to:l.includes("*")?"*":[...new Set(l.flat())],cardinality:u.cardinality??"many",...u.description===void 0?{}:{description:u.description}})}let s=new Map;for(let a of t)s.set(a.kind,_i(a.fields,{id:j().check(cn(1)),kind:Ri(a.kind)}));return{definitions:t,computed:e,kinds:t.map(a=>a.kind),edgeKinds:[...i.keys()],definition(a){let d=r.get(a);if(!d)throw new H(`Unknown node kind "${String(a)}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);return d},tryDefinition(a){return r.get(a)},edge(a){return i.get(a)},edgeAllowed(a,d,u){let l=r.get(d)?.edges[a];return l?l.to==="*"||l.to.includes(u):!1},parseNode(a){let d=a?.kind;if(typeof d!="string")throw new H("Node is missing a `kind`");let u=s.get(d);if(!u)throw new H(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);let{[Y]:l,...p}=a,c=u.parse(p);return l===!0?{...c,[Y]:!0}:c},__node:void 0}}function O(n){return`${n.kind}\0${n.from}\0${n.to}`}var Ht={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function Fi(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function Id(n,e){let t=new Set([...Object.keys(n),...Object.keys(e)]),r=[];for(let o of t){let i=n[o],s=e[o];JSON.stringify(i)!==JSON.stringify(s)&&r.push(o)}return r.sort()}function J(n,e){let t=new Map(n.nodes.map(c=>[c.id,c])),r=new Map(e.nodes.map(c=>[c.id,c])),o=e.nodes.filter(c=>!t.has(c.id)),i=n.nodes.filter(c=>!r.has(c.id)),s=[];for(let c of n.nodes){let f=r.get(c.id);if(!f||f===c)continue;let g=Id(c,f);g.length>0&&s.push({before:c,after:f,fields:g})}let a=new Map(n.edges.map(c=>[O(c),c])),d=new Map(e.edges.map(c=>[O(c),c])),u=e.edges.filter(c=>!a.has(O(c))),l=n.edges.filter(c=>!d.has(O(c))),p=new Set;for(let c of o)p.add(c.id);for(let c of i)p.add(c.id);for(let c of s)p.add(c.after.id);for(let c of[...u,...l])p.add(c.from),p.add(c.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:u,removedEdges:l,touched:[...p].sort()}}function jd(n){let e=n?.issues;return!Array.isArray(e)||e.length===0?n instanceof Error?n.message:String(n):e.map(t=>{let r=t.path?.length?U(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var E=class extends Error{constructor(t,r){super(r?`${t}
3
+ ${r}`:t);this.hint=r;this.name="GraphError"}},F=class extends E{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}};function Un(n,e){try{n.parseNode(e);return}catch(t){if(t instanceof H)throw t;let r=t.issues??[];return{fields:new Set(r.flatMap(i=>i.code==="unrecognized_keys"&&i.keys?[...i.keys]:typeof i.path?.[0]=="string"?[i.path[0]]:[""])),error:t}}}var Jt="n\0",Yt="e\0",C=class n{constructor(e,t={}){this.schema=e;this.validate=t.validate??!0}nodes=new Map;edges=new Map;outIndex=new Map;inIndex=new Map;rank=0;ranks=new Map;lapsed=new Map;reordered=!1;counts=new Map;archived=new Set;listeners=new Set;validate;static from(e,t,r={}){let o=new n(e,r);return o.load(t),o}load(e){let t=this.snapshot();this.restore(e);let r=J(t,this.snapshot());return this.emit(r),r}getNode(e){return this.nodes.get(e)}has(e){return this.nodes.has(e)}allNodes(e){return this.reach([...this.nodes.values()],e,this.held)}count(e,t){return t||this.archived.size?this.nodesOfKind(e,t).length:this.counts.get(e)??0}allEdges(e){return this.reach([...this.edges.values()],e,t=>this.archived.has(t.from)||this.archived.has(t.to))}nodesOfKind(e,t){return this.allNodes(t).filter(r=>r.kind===e)}edgesOfKind(e,t){return this.allEdges(t).filter(r=>r.kind===e)}out(e,t,r){return this.reach(this.resolve(this.outIndex.get(e),t,"to"),r,this.held)}in(e,t,r){return this.reach(this.resolve(this.inIndex.get(e),t,"from"),r,this.held)}neighbors(e,t){let r=new Map;for(let o of[...this.out(e,void 0,t),...this.in(e,void 0,t)])r.set(o.id,o);return[...r.values()]}isArchived(e){return this.archived.has(e)}outEdges(e,t){return this.edgesFrom(this.outIndex.get(e),t)}inEdges(e,t){return this.edgesFrom(this.inIndex.get(e),t)}snapshot(){return{nodes:[...this.nodes.values()],edges:[...this.edges.values()]}}get size(){return{nodes:this.nodes.size,edges:this.edges.size}}applyPrimitives(e,t={}){let r=this.snapshot(),o=new Set(e.flatMap(a=>a.op==="patch-node"?[a.id]:"node"in a?[a.node.id]:[a.edge.from,a.edge.to])),i=a=>({nodes:a.nodes.filter(d=>o.has(d.id)),edges:a.edges.filter(d=>o.has(d.from)||o.has(d.to))});try{for(let a of e)this.applyOne(a,t.restoring===!0,t.inPlace===!0);this.settleOrder()}catch(a){throw this.restore(r),a}let s=J(i(r),i(this.snapshot()));return this.emit(s),s}preview(e,t={}){return n.from(this.schema,this.snapshot(),{validate:this.validate}).applyPrimitives(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}restore(e){for(let t of[this.nodes,this.edges,this.outIndex,this.inIndex,this.ranks,this.lapsed,this.counts,this.archived])t.clear();this.reordered=!1;for(let t of e.nodes)this.insertNode(t,!0);for(let t of e.edges)this.insertEdge(t,!0)}tally(e,t){this.counts.set(e,(this.counts.get(e)??0)+t)}place(e,t){let r=t?this.lapsed.get(e):void 0;if(r===void 0){this.ranks.set(e,++this.rank);return}this.ranks.set(e,r),this.lapsed.delete(e),this.reordered=!0}lapse(e){let t=this.ranks.get(e);t!==void 0&&(this.ranks.delete(e),this.lapsed.set(e,t),this.lapsed.size>4096&&this.lapsed.delete(this.lapsed.keys().next().value))}settleOrder(){if(!this.reordered)return;this.reordered=!1;let e=o=>(i,s)=>this.ranks.get(o+i[0])-this.ranks.get(o+s[0]),t=[...this.nodes.entries()].sort(e(Jt));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(Yt));this.edges.clear();for(let[o,i]of r)this.edges.set(o,i)}emit(e){if(!(e.addedNodes.length===0&&e.removedNodes.length===0&&e.changedNodes.length===0&&e.addedEdges.length===0&&e.removedEdges.length===0))for(let t of this.listeners)t(e)}applyOne(e,t,r){switch(e.op){case"add-node":this.insertNode(e.node,t,r);return;case"remove-node":{let o=e.node.id,i=this.nodes.get(o);if(!i)throw new F(o,`Cannot remove missing node "${o}"`);for(let s of[...this.outEdges(o),...this.inEdges(o)])this.deleteEdge(s);this.tally(i.kind,-1),this.archived.delete(o),this.nodes.delete(o),this.lapse(Jt+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new F(e.id,`Cannot patch missing node "${e.id}"`);let i={...o};for(let[a,d]of Object.entries(e.after))Te(d)?delete i[a]:i[a]=d;let s=t?i:this.checkPatch(o,i,Object.keys(e.after));this.nodes.set(e.id,s),this.archived[we(s)?"add":"delete"](e.id),s.kind!==o.kind&&(this.tally(o.kind,-1),this.tally(s.kind,1));return}case"add-edge":this.insertEdge(e.edge,t,r);return;case"remove-edge":{if(!this.edges.has(O(e.edge)))throw new F(O(e.edge),`Cannot remove missing edge ${O(e.edge)}`);this.deleteEdge(e.edge);return}}}check(e){if(!this.validate)return e;try{return this.schema.parseNode(e)}catch(t){throw this.refusal(e,t)}}checkPatch(e,t,r){if(!this.validate)return t;let o=this.schema.tryDefinition(String(t.kind))?.fields?.shape;if(!o)return this.check(t);for(let a of r){if(a==="id"||a==="kind"||a===Y)continue;let d=o[a];if(!d){delete t[a];continue}let u=d.safeParse(t[a]);u.success&&(u.data===void 0?delete t[a]:t[a]=u.data)}let i=Un(this.schema,t);if(i===void 0)return t;let s=Un(this.schema,e)?.fields??new Set;if([...i.fields].some(a=>r.includes(a)||!s.has(a)))throw this.refusal(t,i.error);return t}refusal(e,t){if(t instanceof H)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?T(i,e):r;return new E(`${s} does not match what ${o} declares`,jd(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new E(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),we(e)&&this.archived.add(e.id),this.tally(e.kind,1),this.place(Jt+e.id,r)}insertEdge(e,t,r=!1){let o=this.nodes.get(e.from),i=this.nodes.get(e.to);if(!o||!i){let a=o?e.to:e.from;throw new F(a,`Edge "${e.kind}" references missing node "${a}"`)}if(this.validate&&!t&&!this.schema.edgeAllowed(e.kind,o.kind,i.kind)){let a=this.schema.edge(e.kind);throw new E(`Edge "${e.kind}" is not declared from ${o.kind} to ${i.kind}`,a?`Declared: ${a.from.join("|")} -> ${a.to==="*"?"*":a.to.join("|")}`:`No edge kind "${e.kind}" is declared in this schema`)}let s=O(e);this.edges.has(s)||(this.edges.set(s,e),this.place(Yt+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=O(e);this.edges.delete(t),this.lapse(Yt+t),this.outIndex.get(e.from)?.delete(t),this.inIndex.get(e.to)?.delete(t)}index(e,t,r){(e.get(t)??e.set(t,new Set).get(t)).add(r)}edgesFrom(e,t){if(!e)return[];let r=[];for(let o of e){let i=this.edges.get(o);i&&(t===void 0||i.kind===t)&&r.push(i)}return r}resolve(e,t,r){let o=[];for(let i of this.edgesFrom(e,t)){let s=this.nodes.get(i[r]);s&&o.push(s)}return o}held=e=>this.archived.has(e.id);reach(e,t,r){let o=t?.archived??!1;return o==="all"||!o&&!this.archived.size?e:e.filter(i=>r(i)===o)}};var Kn=class extends Error{constructor(t,r){super(`No invariant registered under "${t}" (required by node "${r}")`);this.invariant=t;this.nodeId=r;this.name="UnregisteredInvariantError"}};function Dd(n,e){return{...e,name:n}}var Vn=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function Ci(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof Vn,i=r instanceof Error?r.message:String(r),s=n.label??n.name.replace(/-/g," ");return[{invariant:n.name,status:o?"over-budget":"could-not-judge",...t!==void 0?{subjectId:t}:{},label:s,message:`${s} could not be judged: ${i}`,nodeIds:t!==void 0?[t]:[],repairs:[]}]}}function Ze(n,e,t={}){let r=t.context??{},o=t.today===void 0?{}:{today:t.today},i=t.onUnregistered??"skip",s=new Set(e.map(c=>c.name)),a=[];for(let c of e)c.scope==="graph"&&a.push(...Ci(c,()=>c.evaluate({graph:n,subject:void 0,context:r,...o}),void 0));let d=e.filter(c=>c.scope!=="graph"),u=new Map;for(let c of d){let f=c.scope.kind,g=u.get(f);g?g.push(c):u.set(f,[c])}for(let c of n.allNodes()){let f=n.schema.tryDefinition(c.kind),g=f?.requiresInvariant?.(c)??null;if(t.subjectFilter&&!t.subjectFilter(c,r))continue;if(g!==null&&!s.has(g)){if(i==="throw")throw new Kn(g,c.id);continue}let h=!pt(f,c,t.today);for(let x of u.get(c.kind)??[]){if(h&&x.judgesPast!==!0)continue;let b=x.scope.match;b&&!b(c)||a.push(...Ci(x,()=>x.evaluate({graph:n,subject:c,context:r,...o}),c.id))}}let l=new Set,p=a.filter(c=>{let f=`${c.message}|${[...c.nodeIds].sort().join(",")}`;return l.has(f)?!1:(l.add(f),!0)}).map(c=>{let f=ft(c.message);return f===c.message?c:{...c,message:f}});return Xt?Xt(n,e,p,t.today):p}var Xt;function Rg(n){Xt=n}function Td(n,e){let t=new Set(e);return n.filter(r=>r.nodeIds.some(o=>t.has(o))||r.subjectId!==void 0&&t.has(r.subjectId))}function Zd(n){let e=new Set(n.map(r=>r.invariant)).size;if(e===0)return"All rules hold";let t=`${e} ${e===1?"rule":"rules"} broken`;return n.length>e?`${t} in ${n.length} places`:t}var Wn=(n,e)=>n==="*"||n.includes(e);function M(n){let e=n.onBehalfOf;if(!e)return n;let t=e.roles??[],r=n.roles===void 0?t:n.roles.filter(o=>t.includes(o));return{...n,...e.id!==void 0?{id:e.id}:{},roles:r}}var L=n=>n.kind==="system"&&n.onBehalfOf===void 0,ge=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function Li(n){return Jr(n.map(e=>Mn(U(e).toLowerCase())),"or")}function me(n,e,t,r,o,i,s={},a,d){if(!n)return{ok:!0};if(L(e))return{ok:!0};if(e=M(e),o!==void 0){if(me(n,e,t,r,void 0,i).ok)return{ok:!0};let c=!1;if(o.some(x=>me(n,e,x,r,void 0,i).ok)){if(!d||i===void 0||e.id!==void 0&&d()===e.id||n.grants.some(x=>x.roles!=="*"&&ge(x,e)&&o.some(b=>Wn(x.mutations,b))))return{ok:!0};c=!0}let f=c?[t]:[t,...o],g=[...new Set(f.flatMap(x=>Qt(n,x,r)))].sort(),h=(c?"only on what you made; ":"")+(g.length===0?o.length===0?"no declared act creates or changes it, so no role can":"no role can":`${Li(g)} can`);return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:g,message:Gi(n,f,r,h,s)}}}let u=!1;for(let c of n.grants){if(!ge(c,e)||!Wn(c.mutations,t)||c.kinds!==void 0&&c.kinds!=="*"&&(r===void 0||!c.kinds.includes(r))||c.self&&(i===void 0||e.id===void 0||i!==e.id))continue;let f=c.ownEnd?a?.()??[]:[e.id];if(!f.length||f.some(g=>g!==e.id)){u=!0;continue}return{ok:!0}}let l=Qt(n,t,r),p=u?"only on your own end of the link":l.length===0?"no role can":`${Li(l)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:l,message:Gi(n,[t],r,p,s)}}}function Gi(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>Bi(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${Mn(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function Bi(n,e,t){return[...new Set(Ui(n,e,t).flatMap(r=>r.describe||[]))]}var Ui=(n,e,t)=>n.grants.filter(r=>Wn(r.mutations,e)&&(t===void 0||Wn(r.kinds??"*",t)));function Qt(n,e,t){let r=Ui(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function er(n,e,t){return n?t.filter(r=>{let o=M(e).id;return nr(r).some(i=>me(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var nr=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];var Q=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};var gn=class{constructor(e,t,r){this.present=e;this.timeline=t;this.unversioned=r}nodes=new Map;edges=new Map;touching=new Map;seq=Number.MAX_SAFE_INTEGER;wrote=new Map;begin(e){this.seq=e,this.wrote.clear()}writerOf(e){return t=>{let r=`${e}\0${t}`;return this.wrote.has(r)?this.wrote.get(r):this.timeline?.writers?.writerAt(e,t,this.seq)}}note(e,t){let r=e.op==="add-node"?e.node.id:e.op==="patch-node"?e.id:"";if(r===""||this.unversioned?.has(r))return;let o=e.op==="add-node"?Object.keys(e.node):Object.keys(e.after);for(let i of o)i!=="id"&&i!=="kind"&&this.wrote.set(`${r}\0${i}`,t(r,i))}node(e){return this.nodes.has(e)?this.nodes.get(e)??void 0:this.present.getNode(e)}setNode(e,t){this.nodes.set(e,t)}setEdge(e,t){let r=O(e);this.edges.set(r,t?e:null);for(let o of[e.from,e.to]){let i=this.touching.get(o);i||this.touching.set(o,i=new Set),i.add(r)}}incident(e){let t=new Map;for(let r of[...this.present.outEdges(e),...this.present.inEdges(e)]){let o=O(r);this.edges.has(o)||t.set(o,r)}for(let r of this.touching.get(e)??[]){let o=this.edges.get(r);o&&t.set(r,o)}return[...t.values()]}undo(e){switch(e.op){case"add-node":this.setNode(e.node.id,null);return;case"remove-node":this.setNode(e.node.id,e.node);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,Ki(t,e.before));return}case"add-edge":this.setEdge(e.edge,!1);return;case"remove-edge":this.setEdge(e.edge,!0);return}}apply(e){switch(e.op){case"add-node":this.setNode(e.node.id,e.node);return;case"remove-node":for(let t of this.incident(e.node.id))this.setEdge(t,!1);this.setNode(e.node.id,null);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,Ki(t,e.after));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function Ki(n,e){let t={...n};for(let[r,o]of Object.entries(e))Te(o)?delete t[r]:t[r]=o;return t}var Fd=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"?n.id:void 0;function tr(n,e,t,r){let o=l=>{let p=e.node(l);return p?t.served(p,e.writerOf(l))!==void 0:t.sees?.(l)??!1},i=Fd(n);if(i===void 0){let l=n.edge,p=t.edgeClean(l)&&o(l.from)&&o(l.to);return e.apply(n),{primitives:p?[n]:[],faithful:!0}}let s=e.node(i),a=s?t.served(s,e.writerOf(i)):void 0;e.apply(n),e.note(n,r);let d=e.node(i),u=d?t.served(d,e.writerOf(i)):void 0;if(!a&&!u)return{primitives:[],faithful:!1};if(!a&&u){let l=e.incident(i).filter(c=>t.edgeClean(c)&&o(c.from===i?c.to:c.from)).map(c=>({op:"add-edge",edge:c})),p=n.op==="add-node"&&u===n.node&&l.length===0;return{primitives:p?[n]:[{op:"add-node",node:u},...l],faithful:p}}if(a&&!u){let l=n.op==="remove-node"&&a===s;return{primitives:l?[n]:[{op:"remove-node",node:a}],faithful:l}}if(n.op==="patch-node"){let l=(c,f)=>g=>g in c==(f!==void 0&&g in f);if(Object.keys(n.after).every(c=>l(a,s)(c)&&l(u,d)(c)))return{primitives:[n],faithful:!0};let p=c=>Object.fromEntries(Object.keys(n.after).map(f=>[f,f in c?c[f]:X]));return{primitives:[{op:"patch-node",id:i,before:p(a),after:p(u)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:u}],faithful:!1}}function Vi(n,e,t){if(n.length===0)return[];let r=e.log.all(),o=r[0]?.seq??0,i=n.every(c=>r[c.seq-o]?.id===c.id),s=new gn(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(c=>{let f=M(c.author).id,g=c.primitives.map(h=>tr(h,s,t,()=>f));return{op:c,primitives:g.flatMap(h=>h.primitives),faithful:g.every(h=>h.faithful)}});let a=new Set(n.map(c=>c.seq)),d=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(let c of a)c<d&&(d=c),c>u&&(u=c);d-=o,u-=o;let l=Cd(r,d,e.present,t),p=l?new gn(e.present,e,l.unversioned):s;for(let c=r.length-1;c>=d;c--){let f=r[c].primitives;for(let g=f.length-1;g>=0;g--)p.undo(f[g])}return Ld(n,r,d,u,a,p,l?.judge??t,e)}function Cd(n,e,t,r){let{sees:o,names:i}=r;if(!o||!i)return;let s=new Set,a=new Set,d=new Set,u=(p,c)=>{s.has(p)||a.has(p)||(o(p)?i(c)?(a.add(p),d.delete(p)):d.add(p):(s.add(p),d.delete(p)))};for(let p=e;p<n.length;p++)for(let c of n[p].primitives)c.op==="add-node"||c.op==="remove-node"?u(c.node.id,c.node):c.op==="patch-node"&&(u(c.id,c.before),u(c.id,c.after));for(let p of d){let c=t.getNode(p);c&&i(c)&&(d.delete(p),a.add(p))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(p,c)=>d.has(p.id)?p:s.has(p.id)?void 0:r.served(p,c)}}}function Ld(n,e,t,r,o,i,s,a){let d=new Map;for(let u=t;u<=r;u++){let l=e[u];if(i.begin(l.seq),!o.has(l.seq)){for(let f of l.primitives)i.apply(f);continue}let p=(f,g)=>a.writers?.writerAt(f,g,l.seq+1),c=l.primitives.map(f=>tr(f,i,s,p));d.set(l.seq,{op:l,primitives:c.flatMap(f=>f.primitives),faithful:c.every(f=>f.faithful)})}return n.map(u=>d.get(u.seq))}function Tg(n,e,t,r){let o=new gn(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>tr(i,o,t,()=>r).primitives)}var qi="A change you cannot see",Hi={kind:"system",id:"withheld",name:"Someone"};function Fe(n){return n.withheld===!0}var mn=ke,Ji=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&z(r,e));function Yi(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!Ji(r,e)?r:void 0;return{sees:e,shows:e,served:t,servedWith:t,optional:()=>!1,kindOf:()=>{}}}function z(n,e){if(typeof n=="string")return!e(n);if(n===null||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0;t<n.length;t++)if(z(n[t],e))return!0;return!1}for(let t in n)if(Object.hasOwn(n,t)&&(!e(t)||z(n[t],e)))return!0;return!1}function Xi(n,e){let t=r=>!e(r);return n.primitives.some(r=>mn(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&z(n.mutation.args,e)}function Gd(n,e){if(mn(n).every(e.shows))switch(n.op){case"add-node":{let t=e.served(n.node);return t?t===n.node?n:{op:"add-node",node:t}:void 0}case"remove-node":{let t=n.node;return Ji(t,e.sees)?{op:"remove-node",node:Object.fromEntries(Object.entries(t).filter(([r,o])=>r==="id"||r==="kind"||!z(o,e.sees)))}:n}case"patch-node":{let t=e.kindOf(n.id),r={};for(let[i,s]of Object.entries(n.after))if(!z(s,e.sees))r[i]=s;else if(t!==void 0&&e.optional(t,i))r[i]=X;else return;let o=Object.fromEntries(Object.entries(n.before).filter(([,i])=>!z(i,e.sees)));return{op:"patch-node",id:n.id,before:o,after:r}}case"add-edge":case"remove-edge":return z(n.edge,e.sees)?void 0:n}}function rr(n,e,t){let r=Yi(e),o=i=>r.shows(i)&&Qi(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:Hi,intent:qi,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=Gd(i,r);return s?[s]:[]}),inverse:[],reads:n.reads.filter(o),writes:n.writes.filter(o),at:n.at,...n.undoes!==void 0?{undoes:n.undoes}:{},withheld:!0}}function Ce(n,e){let t=Yi(e);if(t.hides?.()===!1)return[...n];let r=t.pin?.()??t;if(r.redact)return r.redact(n);if(r.timeline){let o={served:(i,s)=>r.servedWith(i,s),edgeClean:i=>!z(i,r.sees),sees:r.sees,names:i=>z(i,r.sees)};return Vi(n,r.timeline,o).map(({op:i,primitives:s,faithful:a})=>(!i.withheld&&a?Wi(i,r,s):void 0)??rr(i,r,s))}return n.map(o=>(!o.withheld&&!Xi(o,r.shows)?Wi(o,r):void 0)??rr(o,r))}function Wi(n,e,t){if(t&&t.length<n.primitives.length){if(!t.length)return;n={...n,primitives:t,inverse:n.inverse.filter(c=>mn(c).every(e.shows))}}let r=c=>e.sees(c)&&Qi(e,c),o=n.reads.filter(r),i=new Set(n.primitives.flatMap(mn)),s=n.writes.filter(c=>r(c)||e.sees(c)&&i.has(c)),a=o.length===n.reads.length&&s.length===n.writes.length?n:{...n,reads:o,writes:s},d=e.actor!==void 0&&M(n.author).id===e.actor;if(!d&&n.described?.some(c=>!e.sees(c)))return;if(!z(n,e.sees))return a;let u=new Set,l=c=>{if(typeof c=="string")u.add(c);else if(Array.isArray(c))for(let f of c)l(f);else if(c!==null&&typeof c=="object")for(let[f,g]of Object.entries(c))u.add(f),l(g)};t&&l(t);let p=c=>e.sees(c)||u.has(c);if(!z(a.inverse,p))return d&&n.mutation&&l(n.mutation.args),z({...a,primitives:[],inverse:[]},d?p:e.sees)?void 0:a}function Qi(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var Se=class extends E{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function yn(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(c=>t.has(c.batch)&&!r.has(c.id)),i=[...n.epochs()].reverse().find(c=>c.horizon);if(i){let c=new Set(n.all().map(g=>g.batch)),f=e.filter(g=>!c.has(g));if(f.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${f.map(g=>`batch ${g}`).join(", ")}: it is not after the undo horizon at op ${i.seq}${i.at?` (${i.at})`:""}. What was done before the horizon is archived, and undo does not reach behind it.`}}if(o.length===0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:e.length===0?"No batch given to undo":`Nothing live to undo in ${e.join(", ")} \u2014 already undone, or never applied`};if(o.some(Fe))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(Fe)?"Cannot undo a change you cannot see: only somebody who can see it can take it back.":"Cannot undo this here: part of it is a change you cannot see, and only somebody who can see it can take it back."};if(o.some(c=>c.enabledModules!==void 0))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:"Cannot undo turning a module off or on: it is changed by turning the module the other way."};let s=new Set;for(let c of o)for(let f of c.writes)s.add(f);let a=Math.min(...o.map(c=>c.seq)),d=n.epochs().find(c=>c.change!==void 0&&c.seq>a);if(d){let c=o.find(f=>f.seq<d.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${c.intent}": ${c.intent===d.change?"it changed the declaration":`it was done before the declaration changed (${d.change})`}, and undo does not reach back across that change.`}}let u=[];for(let c of n.all()){if(c.seq<=a||t.has(c.batch)||r.has(c.id))continue;let f=c.reads.filter(g=>s.has(g));f.length>0&&u.push({op:c,overlap:f})}if(u.length===0)return{ok:!0,ops:o};let l=u.filter(c=>!Fe(c.op)).map(c=>`"${c.op.intent}" (op ${c.op.id}, read ${c.overlap.join(", ")})`).join("; ");if(u.some(c=>Fe(c.op)))return{ok:!1,ops:o,blockedBy:u,includeBatches:[],message:`Cannot undo on its own \u2014 ${l?`a later operation depends on it: ${l}; and `:""}a later change you cannot see depends on it, which only somebody who can see it can take back.`};let p=[...new Set(u.map(c=>c.op.batch))];return{ok:!1,ops:o,blockedBy:u,includeBatches:p,message:`Cannot undo on its own \u2014 a later operation depends on it: ${l}. Include ${p.map(c=>`batch ${c}`).join(", ")} to undo them together.`}}function es(n){return[...n].sort((e,t)=>t.seq-e.seq).flatMap(e=>e.inverse)}var Le=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};function Bd(n){let e=n instanceof Error?n.message:String(n);if(n instanceof Le){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof F?{reason:"missing",sentence:e}:n instanceof Q?{reason:n.reason,sentence:n.sentence}:n instanceof Se?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var Ge=class extends E{constructor(t,r){super(`Invalid arguments for mutation "${t}"`,r.map(o=>`${o.path.map(String).join(".")||"(root)"}: ${o.message}`).join("; "));this.mutation=t;this.issues=r;this.name="InvalidArguments"}};var qn={scene:0,overview:10,rail:20,popover:30,dialog:40,toast:50},Ud={plots:0,stage:1,tag:2,ties:2,lines:3,tieLabels:4,occupants:6,seatMarks:7,zoom:8,card:10,opened:11},Kd={under:0,raised:1,over:2},or=n=>`--graview-layer-${n}`,Vd=n=>`var(${or(n)}, ${qn[n]})`;function Wd(){return Object.keys(qn).map(n=>` ${or(n)}: ${qn[n]};`).join(`
4
+ `)}var qd=n=>`Op "${n.id}" has seq ${n.seq}, so the log begins at seq ${n.seq}: a log that begins past 0 begins at its undo horizon, and none was given (a checkpoint epoch, or { horizon })`,Be=class n{ops=[];marks=[];start=0;get length(){return this.start+this.ops.length}get horizon(){return this.start}all(){return this.ops}opsFrom(e){return this.ops.slice(Math.max(0,e-this.start))}append(e){if(e.seq!==this.length)throw new Error(this.length===0&&e.seq>0?qd(e):`Op "${e.id}" has seq ${e.seq} but the log is ${this.length} long`);this.ops.push(e)}static from(e,t=[],r={}){let o=new n,i=[...t].reverse().find(d=>d.horizon),s=r.horizon??i?.seq??0;if(!Number.isInteger(s)||s<0)throw new Error(`A log cannot begin at seq ${s}`);if(i&&r.horizon!==void 0&&i.seq!==r.horizon)throw new Error(`A log said to begin at seq ${r.horizon} has its checkpoint at seq ${i.seq}`);let a=e[0];if(a&&s>0&&a.seq!==s)throw new Error(`A log compacted at seq ${s} begins with op "${a.id}" at seq ${a.seq}`);o.start=s;for(let d of e)o.append(d);for(let d of t)o.markEpoch(d);return o}replace(e,t=[],r={}){let o=n.from(e,t,r);this.ops=o.ops,this.marks=o.marks,this.start=o.start}epochs(){return this.marks}lastEpoch(){return this.marks.at(-1)}markEpoch(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>this.length)throw new Error(`An epoch at seq ${e.seq} starts past the end of a log ${this.length} long`);if(e.seq<this.start)throw new Error(`An epoch at seq ${e.seq} is behind the horizon at seq ${this.start}: it went to the archive with the ops before it`);let t=this.lastEpoch();if(t&&e.seq<t.seq)throw new Error(`An epoch at seq ${e.seq} comes before the last one, at seq ${t.seq}`);this.marks.push(e)}truncate(e){if(!Number.isInteger(e)||e<this.start||e>this.length)throw new Error(`Cannot cut a log ${this.length} long back to ${e}`);let t=this.lastEpoch();if(t&&t.seq>e)throw new Error(`Cannot cut the log back to ${e}: an epoch begins at seq ${t.seq}`);return this.ops.splice(e-this.start)}checkpointAt(e,t,r={}){if(!Number.isInteger(t)||t<this.start||t>this.length)throw new Error(`No checkpoint at seq ${t}: this log holds seqs ${this.start} to ${this.length}`);let o=[...this.marks].reverse().find(a=>a.seq<=t);if(o?.seq===t)return{...o,horizon:!0};let i=this.fold(e,{...r,...o?{from:o}:{},to:t}).snapshot(),s=this.ops[t-1-this.start]?.at??o?.at;return{seq:t,base:i,...o?.version!==void 0?{version:o.version}:{},...s!==void 0?{at:s}:{},horizon:!0}}compact(e){if(!Number.isInteger(e.seq)||e.seq<this.start||e.seq>this.length)throw new Error(`Cannot compact at seq ${e.seq}: this log holds seqs ${this.start} to ${this.length}`);let t=this.ops.slice(0,e.seq-this.start),r=this.marks.filter(o=>o.seq<e.seq);return this.ops=this.ops.slice(e.seq-this.start),this.marks=[{...e,horizon:!0},...this.marks.filter(o=>o.seq>e.seq)],this.start=e.seq,{ops:t,epochs:r}}get(e){return this.ops.find(t=>t.id===e)}live(){let e=this.undoneIds();return this.ops.filter(t=>!e.has(t.id))}undoneIds(){return bn(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return ir(this.ops,this.undoneIds())}fold(e,t={}){let r=t.from?.seq??0;if(r<this.start)throw new Error(t.from?`An epoch at seq ${r} is behind the horizon at seq ${this.start}: fold from the checkpoint`:`A log compacted at seq ${this.start} does not fold from empty: fold from its checkpoint`);let o=t.from?.base??{nodes:[],edges:[]},i=C.from(e,o,t.validate!==void 0?{validate:t.validate}:{}),s=t.to??this.length;for(let a of this.ops.slice(r-this.start,Math.max(0,s-this.start))){if(a.undoes!==void 0){i.applyPrimitives(a.primitives,{restoring:!0});continue}try{i.applyPrimitives(a.primitives)}catch{i.applyPrimitives(a.primitives,{restoring:!0})}}return i}toJSON(){return[...this.ops]}};function bn(n){let e=new Map;for(let r of n){if(!r.undoes)continue;let o=e.get(r.undoes);o?o.push(r.id):e.set(r.undoes,[r.id])}let t=new Map;for(let r=n.length-1;r>=0;r--){let o=n[r],i=e.get(o.id)??[];t.set(o.id,!i.some(s=>t.get(s)===!0))}return new Set(n.filter(r=>t.get(r.id)===!1).map(r=>r.id))}function ir(n,e){let t=[],r=new Map;for(let o of n){let i=r.get(o.batch);i?i.push(o):(r.set(o.batch,[o]),t.push(o.batch))}return t.map(o=>{let i=r.get(o)??[],s=i[0];return{id:o,author:s.author,intent:s.batchIntent??s.intent,at:s.at,...s.lineage?{lineage:s.lineage}:{},ops:i,undone:i.every(a=>e.has(a.id))}})}var ts=(n,e)=>`${n}\0${e}`,ns=new WeakMap;function Hd(n){let e=new Map;return{base:n,end:n,read:[],fields:e,written:[],seqOf:new Map,writers:{writerAt:(r,o,i)=>{let s=e.get(ts(r,o));if(!s)return;let a=0,d=s.length;for(;a<d;){let u=a+d>>1;s[u].seq<i?a=u+1:d=u}return a===0?void 0:s[a-1].by}}}}function Jd(n){if(n.op==="add-node")return[n.node.id,Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind")];if(n.op==="patch-node")return[n.id,Object.keys(n.after).filter(e=>!Te(n.after[e]))]}function Yd(n,e){let t=n.end,r=M(e.author).id,o=e.undoes!==void 0?n.seqOf.get(e.undoes):void 0,i=[];for(let s of e.primitives){let a=Jd(s);if(!a)continue;let[d,u]=a;for(let l of u){let p=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,l,o):void 0,c=ts(d,l),f=n.fields.get(c);f||n.fields.set(c,f=[]),f.push({seq:t,by:p}),i.push(c)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function Xd(n,e){for(;n.written.length>0&&n.written.at(-1).seq>=e;){let{keys:t}=n.written.pop();for(let r of t)n.fields.get(r)?.pop()}for(let t of n.read.slice(e-n.base))n.seqOf.delete(t.id);n.read.length=e-n.base,n.end=e}function Hn(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=ns.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&Xd(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||ns.set(n,o=Hd(r));for(let i=o.end;i<t;i++)Yd(o,e[i-r]);return o.writers}var Ue={served:new WeakSet},xn=n=>n.fields!==void 0||(n.hide?.length??0)>0,ye=n=>Ue.on===!0||Ue.served.has(n);var sr=new WeakMap;function Qd(n,e){let t=new Map,r=new Map(Object.entries(e??{}));return{base:n,end:n,read:[],kinds:t,creators:r,entries:[],records:{kindOf:o=>t.get(o),creatorOf:o=>r.get(o)}}}function ec(n,e){let t=n.end;for(let r of e.primitives){if(r.op!=="add-node"&&r.op!=="remove-node")continue;let{id:o,kind:i}=r.node;if(n.kinds.has(o)||(n.kinds.set(o,i),n.entries.push({seq:t,id:o,creator:!1})),r.op!=="add-node"||n.creators.has(o)||e.undoes!==void 0)continue;let s=M(e.author).id;s!==void 0&&(n.creators.set(o,s),n.entries.push({seq:t,id:o,creator:!0}))}n.read.push(e),n.end++}function nc(n,e){for(;n.entries.length>0&&n.entries.at(-1).seq>=e;){let t=n.entries.pop();(t.creator?n.creators:n.kinds).delete(t.id)}n.read.length=e-n.base,n.end=e}function ae(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=sr.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&nc(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||sr.set(n,o=Qd(r,r>0?tc(n,r)?.creators:void 0));for(let i=o.end;i<t;i++)ec(o,e[i-r]);return o.records}function tc(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function rs(n,e){ae(n);let t=sr.get(n),r=new Set;for(let i=t.entries.length-1;i>=0&&t.entries[i].seq>=e;i--)t.entries[i].creator&&r.add(t.entries[i].id);let o={};for(let[i,s]of t.creators)r.has(i)||(o[i]=s);return o}function Ke(n,e,t,r,o,i=Ue.on===!0){if(!n?.sees?.length||L(e))return!0;let s=n.sees.filter(a=>a.kinds.includes(t.kind)&&(i||!xn(a)));return s.length===0?!1:(e=M(e),s.some(a=>{if(!ge(a,e))return!1;if(!a.own&&!a.via)return!0;let d=e.id;if(d===void 0)return!1;let u=l=>l.id===d;return a.via?r.out(t.id,a.via).some(u)||r.in(t.id,a.via).some(u):t.id===d||r.out(t.id).some(u)||r.in(t.id).some(u)||o?.creatorOf(t.id)===d}))}var dr=new Set;function Jn(n,e){return L(e)?dr:n.modules?.disabledKinds??dr}function Ve(n,e){return L(e)?!1:(n.policy?.sees?.length??0)>0||Jn(n,e).size>0}function as(n,e){if(!Ve(n,e))return()=>!0;let t=n.modules?.disabledKinds??dr,r=n.policy?.sees??[],o=M(e),i=ye(n),s=d=>!t.has(d)&&(r.length===0||r.some(u=>u.kinds.includes(d)&&ge(u,o)&&!u.own&&!u.via&&(i||!xn(u)))),a=n.schema.kinds.every(s);return d=>a||d!==void 0&&s(d)}function vn(n,e){return t=>{let r=Jn(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=ae(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&Ke(n.policy,e,i,n.graph,o,ye(n));let s=o.kindOf(t);return s===void 0?!0:!r.has(s)&&Ke(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o,ye(n))}}var rc={out:()=>[],in:()=>[]};function oc(n,e,t=new Map,r){let o=Jn(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=ae(n.log);return s=>{let a=t.get(s);if(a!==void 0)return a;let d,u=n.graph.getNode(s);if(u)d=!o.has(u.kind)&&Ke(n.policy,e,u,n.graph,i,ye(n));else{let l=i.kindOf(s);if(l===void 0)return r?.add(s),!0;d=!o.has(l)&&Ke(n.policy,e,{id:s,kind:l},rc,i,ye(n))}return t.set(s,d),d}}function ic(n){let e=new Map;return(t,r)=>{let o=`${t}\0${r}`,i=e.get(o);if(i===void 0){let s=n?.tryDefinition(t)?.fields?.shape,a=s?.[r];i=s!==void 0&&(a===void 0||a.safeParse?.(void 0).success===!0),e.set(o,i)}return i}}function ur(n,e){return ds(n,e).lens}var cr=()=>({judged:new Map,shown:new Map});function ds(n,e){let t=ic(n.schema),r=L(e)?void 0:M(e).id,o=()=>n.log.length??n.log.all().length,i=new WeakMap,s=n.graph,a=(l,p,c,f,g)=>{let h=(w,_)=>{if(!l(w.id))return;let R;for(let W in w)if(!(!Object.hasOwn(w,W)||W==="id"||W==="kind"||!z(w[W],l))&&!(r!==void 0&&_(W)===r)){if(!t(w.kind,W))return;(R??=[]).push(W)}if(!R)return w;let D=R.join("\0"),ce=i.get(w);if(ce?.without===D)return ce.node;let Oe=Object.fromEntries(Object.entries(w).filter(([W])=>!R.includes(W)));return i.set(w,{without:D,node:Oe}),Oe},x=w=>{let _=c();return h(w,R=>p().writerAt(w.id,R,_))},b=new WeakMap,k=g?w=>{let _=b.get(w);return _||b.set(w,_={node:x(w)}),_.node}:x,$=w=>{if(!l(w))return!1;let _=s.getNode(w);return _===void 0||k(_)!==void 0},m=g?.shown??new Map,y=g?w=>{let _=m.get(w);return _===void 0&&m.set(w,_=$(w)),_}:$,v=s.outEdges&&s.inEdges?{present:{getNode:w=>s.getNode(w),outEdges:w=>s.outEdges(w),inEdges:w=>s.inEdges(w)},log:n.log,get writers(){return p()}}:void 0,S={sees:l,shows:y,served:k,servedWith:h,optional:t,kindOf:f,...r!==void 0?{actor:r}:{},...v?{timeline:v}:{},hides:()=>Ve(n,e),pin:g?()=>S:()=>d(cr())};return Ue.lens?.(S,n,e)??S};function d(l){let p,c=o(),f=ae(n.log);return a(oc(n,e,l.judged,l.unnamed),()=>p??=Hn(n.log),()=>c,g=>s.getNode(g)?.kind??f.kindOf(g),l)}return{lens:a(vn(n,e),()=>Hn(n.log),o,l=>s.getNode(l)?.kind??ae(n.log).kindOf(l)),pinWith:d}}var os=new WeakMap,is=new WeakMap,sc=n=>{let e=new Set;for(let t of n)for(let r of t.primitives)r.op==="add-node"||r.op==="remove-node"?e.add(r.node.id):r.op==="patch-node"?e.add(r.id):(e.add(r.edge.from),e.add(r.edge.to));return e};function ac(n,e){if(!Ve(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...Jn(n,e)].sort().join("\0"),s=cs(e),a=os.get(n.log);a||os.set(n.log,a=new Map);let d=a.get(s),{pinWith:u}=ds(n,e),l=is.get(n.log);l||is.set(n.log,l=new Set);let p=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&p){if(d.length===r)return d.ops;let g=t.slice(d.length-o),h=u(cr()),x=!0,b=sc(g);for(let k of b){let $=d.judgments.judged.get(k),m=d.judgments.shown.get(k);if($!==void 0&&h.sees(k)!==$||m!==void 0&&h.shows(k)!==m){x=!1;break}}if(x){for(let k of b)if(l.has(k)){x=!1;break}}if(x){let k=[...d.ops,...Ce(g,u(d.judgments))],$={horizon:o,off:i,length:r,last:t.at(-1),ops:k,judgments:d.judgments};return a.set(s,$),k}}let c={...cr(),unnamed:l},f=Ce(t,u(c));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:f,judgments:c}),f}function dc(n,e,t){return(t.subjectId===void 0||!e(t.subjectId)||n.shows(t.subjectId))&&t.nodeIds.every(r=>!e(r)||n.shows(r))&&!z(t,n.sees)}function lr(n,e){return{all:()=>n,undoneIds:()=>bn(n),epochs:e}}var ss=new WeakMap;function cs(n){let e=L(n)?n:M(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?"for":""}`}var ar=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t};function wn(n,e){if(!Ve(n,e))return n;let t=cs(e),r=ss.get(n);r||ss.set(n,r=new Map);let o=r.get(t);if(o)return o;let i=n.graph,s=ur(n,e),a=m=>{let y=R=>R===void 0?void 0:m.served(R),v=R=>y(R)!==void 0,S=R=>v(i.getNode(R));return{served:y,seenNode:v,seenId:S,seenEdge:R=>S(R.from)&&S(R.to)&&!z(R,m.sees),servedAll:R=>R.flatMap(D=>y(D)??[])}},{served:d,seenId:u}=a(s),l=()=>a(s.pin?.()??s),p=(m,y)=>{let v=Hn(n.log),S=s.pin?.()??s,w=m.nodes.flatMap(R=>S.servedWith(R,D=>v.writerAt(R.id,D,y))??[]),_=new Set(w.map(R=>R.id));return{nodes:w,edges:m.edges.filter(R=>_.has(R.from)&&_.has(R.to)&&!z(R,S.sees))}},c=m=>{let y=p(m.base,m.seq);if(!m.creators)return{...m,base:y};let v=new Set(y.nodes.map(w=>w.id)),S=Object.fromEntries(Object.entries(m.creators).filter(([w,_])=>v.has(w)&&!z(_,s.sees)));return{...m,base:y,creators:S}},f=m=>m&&c(m),g=()=>ac(n,e),h=()=>lr(g(),()=>n.log.epochs()),x=new Proxy(i,{get(m,y){switch(y){case"getNode":return v=>d(m.getNode(v));case"has":return u;case"allNodes":case"nodesOfKind":return(...v)=>l().servedAll(m[y](...v));case"count":return(...v)=>l().servedAll(m.nodesOfKind(...v)).length;case"allEdges":case"edgesOfKind":case"outEdges":case"inEdges":return(...v)=>m[y](...v).filter(l().seenEdge);case"out":case"in":case"neighbors":return(v,...S)=>{let w=l();return w.seenId(v)?w.servedAll(m[y](v,...S)):[]};case"snapshot":return()=>{let v=m.snapshot(),S=l();return{...v,nodes:S.servedAll(v.nodes),edges:v.edges.filter(S.seenEdge)}};case"size":{let v=l();return{nodes:v.servedAll(m.allNodes({archived:"all"})).length,edges:m.allEdges({archived:"all"}).filter(v.seenEdge).length}}default:return ar(m,y)}}}),b=()=>{let m=g();return ir(m,bn(m))},k=new Proxy(n.log,{get(m,y){switch(y){case"all":case"toJSON":return()=>[...g()];case"epochs":return()=>m.epochs().map(c);case"lastEpoch":return()=>f(m.lastEpoch());case"live":return()=>{let v=g(),S=bn(v);return v.filter(w=>!S.has(w.id))};case"get":return v=>g().find(S=>S.id===v);case"opsInBatch":return v=>g().filter(S=>S.batch===v);case"batches":return b;default:return ar(m,y)}}}),$=new Proxy(n,{get(m,y){switch(y){case"graph":return x;case"log":return k;case"snapshot":return x.snapshot;case"batches":return b;case"canUndo":return v=>yn(h(),typeof v=="string"?[v]:v);case"violations":return v=>m.violations(v,x).filter(S=>dc(s,w=>i.has(w),S));case"findings":return()=>m.findings().filter(v=>(v.id.includes("->")?v.id.split("->").map((w,_)=>_===0?w.slice(w.indexOf(":")+1):w):[v.id]).every(w=>!i.has(w)||u(w))&&!z(v,s.sees));case"wouldChange":return v=>m.wouldChange(v,e);case"preview":return(v,S,w)=>m.preview(v,S,{author:e,...w});case"seenBy":return v=>wn(m,v);case"seenFor":return e;case"checkpoint":return(...v)=>f(m.checkpoint(...v));default:return ar(m,y)}}});return r.set(t,$),$}var fr=new Set;function pr(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:fr,disabledMutations:fr,disabledInvariants:fr,administered:us(n,new Set(Object.keys(n??{})))};let t=new Set,r=a=>{if(!(t.has(a)||!(a in n))){t.add(a);for(let d of n[a]?.requires??[])r(d)}};for(let a of e)r(a);for(let[a,d]of Object.entries(n))d.required&&r(a);let o=new Set,i=new Set,s=new Set;for(let[a,d]of Object.entries(n))if(!t.has(a)){for(let u of d.kinds??[])o.add(u);for(let u of d.mutations??[])i.add(u);for(let u of d.invariants??[])s.add(u)}for(let a of t){let d=n[a];for(let u of d?.kinds??[])o.delete(u);for(let u of d?.mutations??[])i.delete(u);for(let u of d?.invariants??[])s.delete(u)}return{enabled:t,disabledKinds:o,disabledMutations:i,disabledInvariants:s,administered:us(n,t)}}function us(n,e){let t=new Map;for(let[r,o]of Object.entries(n??{}))e.has(r)&&o.visibility==="admin"&&t.set(r,o);return t}function ls(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var Yn=class{constructor(e){this.graph=e;for(let t of e.allNodes({archived:"all"}))this.file(t);e.subscribe(t=>this.follow(t))}kinds=new Map;filed=new Map;labelOf(e){return this.filed.get(e)?.label}lookup(e,t){let r=ls(t);if(r.length===0)return{exact:[],prefix:[]};let o=e.includes("*")?[...this.kinds.values()]:e.flatMap(a=>this.kinds.get(a)??[]),i=[],s=[];for(let a of o)for(let d=hr(a.sorted,r);d<a.sorted.length&&a.sorted[d].startsWith(r);d+=1){let u=[...a.ids.get(a.sorted[d])??[]];s.push(...u),a.sorted[d]===r&&i.push(...u)}return{exact:i,prefix:s}}follow(e){for(let t of e.removedNodes)this.unfile(t.id);for(let t of e.changedNodes)this.unfile(t.after.id),this.file(t.after);for(let t of e.addedNodes)this.file(t)}file(e){let t=T(this.graph.schema.tryDefinition(e.kind),e),r=ls(t);this.filed.set(e.id,{kind:e.kind,key:r,label:t});let o=this.kinds.get(e.kind);o||this.kinds.set(e.kind,o={ids:new Map,sorted:[]});let i=o.ids.get(r);i?i.add(e.id):(o.ids.set(r,new Set([e.id])),o.sorted.splice(hr(o.sorted,r),0,r))}unfile(e){let t=this.filed.get(e);if(!t)return;this.filed.delete(e);let r=this.kinds.get(t.kind),o=r?.ids.get(t.key);if(!r||!o||(o.delete(e),o.size>0))return;r.ids.delete(t.key);let i=hr(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function hr(n,e){let t=0,r=n.length;for(;t<r;){let o=t+r>>>1;n[o]<e?t=o+1:r=o}return t}function cc(n,e){return e.includes("*")?"record":e.map(t=>ne(n.tryDefinition(t),t)).join(" or ")}function fs(n,e,t,r){let o=cc(n,e.kinds);if(r.length===0)return{ok:!1,reason:"none",candidates:r,message:`There is no ${o} called "${t}".`};let i=r.slice(0,10).map(a=>`${a.label} (${a.id})`),s=r.length>i.length?`, and ${r.length-i.length} more`:"";return{ok:!1,reason:"ambiguous",candidates:r,message:`"${t}" names more than one ${o}: ${i.join(", ")}${s}. Pass the id of the one you mean as ${e.name}.`}}var hs=Symbol.for("@graview/core:node-ref"),ps=n=>typeof n=="object"&&n!==null?n[hs]:void 0;function kn(n="*"){return uc(j().check(cn(1)),n)}function uc(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,hs,{value:t,enumerable:!0,configurable:!0})};return r(n),r(I(n)),n}function gr(n){if(typeof n!="object"||n===null)return;let e=ps(n);if(e)return e;let t=I(n),r=ps(t);if(r)return r;let o=t?.innerType;return o?gr(o):void 0}function Sn(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=gr(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}function mr(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(r=>r===void 0?"null":mr(r)).join(",")}]`;let e=n;return`{${Object.keys(e).filter(r=>e[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${mr(e[r])}`).join(",")}}`}var gs=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function lc(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(gs),t=n.edges.map(r=>({key:O(r),value:{kind:r.kind,from:r.from,to:r.to}})).sort(gs);return mr({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function We(n){return`sha256:${ys(lc(n))}`}function ms(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=We(t),a=C.from(n,i,{validate:o});for(let[h,x]of e.entries())try{a.applyPrimitives(x.primitives)}catch(b){let k=e[h-1];return{ok:!1,expected:We(a.snapshot()),actual:s,...k?{divergedAfter:k.id}:{},reason:`The log does not fold: op "${x.id}" (${x.intent}) could not be applied. ${b instanceof Error?b.message:String(b)}`}}let d=We(a.snapshot());if(d===s)return{ok:!0,hash:s};let u=h=>{let x=C.from(n,i,{validate:o});for(let b=0;b<=h;b++)x.applyPrimitives(e[b].primitives);return We(x.snapshot())},l=h=>{try{let x=C.from(n,t,{validate:o});for(let b=e.length-1;b>h;b--)x.applyPrimitives(e[b].inverse);return We(x.snapshot())}catch{return}},p=h=>{let x=l(h);return x!==void 0&&x!==u(h)},c=-1,f=e.length-1;for(;c<f;){let h=Math.floor((c+f)/2);p(h)?f=h:c=h+1}let g=f>=0?e[f]:void 0;return{ok:!1,expected:d,actual:s,...g?{divergedAfter:g.id}:{},reason:g?`The graph and the fold of its log part after op "${g.id}" (${g.intent}).`:"The graph and the fold of its log disagree before any op: the base it folds from does not match."}}var fc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pc=new TextEncoder,hc=new Uint32Array(64),gc=new Uint32Array(8),Xn=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ys(n){let e=pc.encode(n),t=e.length*8,r=new Uint8Array(e.length+9+63>>6<<6);r.set(e),r[e.length]=128;let o=new DataView(r.buffer);o.setUint32(r.length-8,Math.floor(t/2**32)),o.setUint32(r.length-4,t>>>0);let i=gc;i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225;let s=hc;for(let d=0;d<r.length;d+=64){for(let b=0;b<16;b++)s[b]=o.getUint32(d+b*4);for(let b=16;b<64;b++){let k=s[b-15],$=s[b-2],m=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,y=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;s[b]=s[b-16]+m+s[b-7]+y>>>0}let u=i[0],l=i[1],p=i[2],c=i[3],f=i[4],g=i[5],h=i[6],x=i[7];for(let b=0;b<64;b++){let k=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),$=f&g^~f&h,m=x+k+$+fc[b]+s[b]>>>0,y=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),v=u&l^u&p^l&p,S=y+v>>>0;x=h,h=g,g=f,f=c+m>>>0,c=p,p=l,l=u,u=m+S>>>0}i[0]=i[0]+u>>>0,i[1]=i[1]+l>>>0,i[2]=i[2]+p>>>0,i[3]=i[3]+c>>>0,i[4]=i[4]+f>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+h>>>0,i[7]=i[7]+x>>>0}let a="";for(let d=0;d<8;d++){let u=i[d];a+=Xn[u>>>24]+Xn[u>>>16&255]+Xn[u>>>8&255]+Xn[u&255]}return a}var $n=class{constructor(e){this.inner=e}seen=new Set;reads(){return[...this.seen]}markAll(e){for(let t of e)this.seen.add(t.id);return e}markEdges(e){for(let t of e)this.seen.add(t.from),this.seen.add(t.to);return e}getNode(e){return this.seen.add(e),this.inner.getNode(e)}has(e){return this.seen.add(e),this.inner.has(e)}allNodes(e){return this.markAll(this.inner.allNodes(e))}allEdges(e){return this.markEdges(this.inner.allEdges(e))}nodesOfKind(e,t){return this.markAll(this.inner.nodesOfKind(e,t))}edgesOfKind(e,t){return this.markEdges(this.inner.edgesOfKind(e,t))}out(e,t,r){return this.seen.add(e),this.markAll(this.inner.out(e,t,r))}in(e,t,r){return this.seen.add(e),this.markAll(this.inner.in(e,t,r))}neighbors(e,t){return this.seen.add(e),this.markAll(this.inner.neighbors(e,t))}};function mc(n,e){return{...e,name:n}}function yr(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function ws(n){let e=n.input,t=e._zod?.def;if(t?.type!=="object"||t.catchall!==void 0||!e.shape)return;let r=Object.keys(e.shape);return yr(n)?[...r,"id"]:r}var bs=(n,e)=>`does not take ${n.map(t=>`"${t}"`).join(", ")}; it takes ${e.length>0?e.map(t=>`"${t}"`).join(", "):"nothing"}`;function yc(n){if(typeof n!="object"||n===null)return;let e=n.id;if(e!==void 0){if(typeof e!="string"||e.trim().length===0)throw new E("An id must be a non-empty string",`Got ${JSON.stringify(e)}.`);return e}}function bc(n){let{id:e,...t}=n;return t}function xs(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function ks(n){let e=2166136261;for(let t=0;t<n.length;t++)e=Math.imul(e^n.charCodeAt(t),16777619);return(e>>>0).toString(36).padStart(7,"0")}function xc(n,e){if(e.limited&&e.me===void 0)return vs(n,e.held);let t=e.limited?`${n}.${ks(e.me)}`:n,r=t;for(let o=2;e.seen(r);o++)r=`${t}-${o}`;return e.held(r)?vs(t,e.held):r}function vs(n,e){let t;do t=`${n}-${Math.floor(Math.random()*36**6).toString(36).padStart(6,"0")}`;while(e(t));return t}function qe(n,e,t,r={}){let o=yr(e)?yc(t):void 0,i=o===void 0?t:bc(t),s=ws(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let m=Object.keys(i).filter(y=>!s.includes(y)&&i[y]!==void 0);if(m.length>0)throw new Ge(e.name,[{path:[],message:bs(m,s)}])}let a=e.input.safeParse(i);if(!a.success){let m=Object.keys(e.input.shape??{});throw new Ge(e.name,a.error.issues.map(y=>y.code==="unrecognized_keys"&&m.length>0?{...y,message:bs(y.keys,m)}:y))}let d=a.data,u=new $n(r.seen??n),l=[],p=new Set,c=m=>u.has(m)||n.has(m)||p.has(m),f,g=m=>{let y=new Set([...n.outEdges(m),...n.inEdges(m)]);for(let v of y)u.getNode(v.from),u.getNode(v.to),l.push({op:"remove-edge",edge:v});return y},h={graph:u,schema:n.schema,me:r.me,emit(m){l.push(m)},addNode(m){l.push({op:"add-node",node:m})},removeNode(m){let y=u.getNode(m)&&n.getNode(m);if(!y)throw new F(m,`Cannot remove missing node "${m}"`);g(m),l.push({op:"remove-node",node:y})},patchNode(m,y){let v=u.getNode(m)&&n.getNode(m);if(!v)throw new F(m,`Cannot patch missing node "${m}"`);let S={},w={};for(let[_,R]of Object.entries(y)){let D=v[_];JSON.stringify(D)===JSON.stringify(R)&&!r.keepUnchanged?.(R,_,v)||(S[_]=D,w[_]=R)}Object.keys(w).length!==0&&l.push({op:"patch-node",id:m,before:S,after:w})},archiveNode:m=>h.patchNode(m,{[Y]:!0}),unarchiveNode:m=>h.patchNode(m,{[Y]:void 0}),mergeNode(m,y){let v=u.getNode(y)&&n.getNode(y);if(!v)throw new F(y,`Cannot merge into missing node "${y}"`);if(m===y||we(v))throw new E(m===y?"Cannot merge a record into itself":"Cannot merge into an archived record");let S=new Set([...n.outEdges(y),...n.inEdges(y)].map(O));for(let w of g(m)){let _={kind:w.kind,from:w.from===m?y:w.from,to:w.to===m?y:w.to};_.from!==_.to&&!S.has(O(_))&&(S.add(O(_)),l.push({op:"add-edge",edge:_}))}h.archiveNode(m),f=y},addEdge(m){l.push({op:"add-edge",edge:m})},removeEdge(m){l.push({op:"remove-edge",edge:m})},setSingleSource(m,y,v){n.inEdges(y,m).some(S=>S.from===v)||l.push({op:"add-edge",edge:{kind:m,from:v,to:y}});for(let S of n.inEdges(y,m))u.getNode(S.from),S.from!==v&&l.push({op:"remove-edge",edge:S})},freshId(m,y){if(o!==void 0&&!p.has(o)){if(r.seesInFull&&!r.seesInFull())throw new E(`"${e.name}" makes its own id here`,"Leave id out: the answer says the id it made.");if(c(o))throw new E(`Id "${o}" is already taken`,`"${e.name}" was asked to make a node with that id, and the graph has one. Pick another, or leave id out and let the act mint one.`);return p.add(o),o}let v=y?`${y}:${xs(m)}`:xs(m),w=xc(v,{seen:_=>(r.seen?r.seen.has(_):n.has(_))||p.has(_),held:c,limited:r.seesInFull!==void 0&&!r.seesInFull(y),me:r.me});return p.add(w),w}};e.apply(h,d);let x=r.check?.(l,e),b=new Set(l.flatMap(ke)),k=new $n(r.seen??n),$=e.describe?.(d,k)??`${e.name}(${Object.entries(d).map(([m,y])=>`${m}=${JSON.stringify(y)}`).join(", ")})`;return{primitives:l,reads:[...new Set([...u.reads(),...k.reads()])],...e.describe?{described:[...k.reads(),...x??[]]}:{},writes:[...b],intent:$,...f!==void 0?{mergedInto:f}:{}}}var Ss=Symbol.for("@graview/core:amount"),Mm=(n,e)=>(Object.defineProperty(I(n),Ss,{value:e,enumerable:!0}),n);function br(n,e=!0){let t=I(n);return t?.[Ss]??(e&&t?.innerType?br(t.innerType):void 0)}function $s(n,e={}){let t=Number.isInteger(n),r={maximumFractionDigits:t?0:2,minimumFractionDigits:t?0:2};try{return le(n,e.locale,e.currency?{style:"currency",currency:e.currency,...r}:r)}catch{return le(n,e.locale,r)}}var vc=/^[("'“‘]*(?:(?:[a-z]{1,3}\.){2,}|(?:dr|mr|mrs|ms|mx|st|mt|vs|jr|sr|prof|no|fig|approx)\.)$/i;function wc(n){for(let e of n.matchAll(/[.!?](?=\s|$)/g)){let t=n.slice(0,e.index+1),r=/\S+$/.exec(t)?.[0]??"";if(!(e[0]==="."&&vc.test(r))&&!(t.split(" ").length<3&&e.index+1<n.length))return t}}function _s(n,e=140){let t=n.replace(/^[#>\s]+|\*\*|`|\](\([^)\s]*\))?|\[/gm,"").replace(/\s+/g," ").trim(),r=wc(t);return r&&r.length<=e?r:t.length<=e?t:`${(t.slice(0,e+1).replace(/\s+\S*$/,"")||t.slice(0,e)).replace(/[\s,;:.—-]+$/,"")}\u2026`}function kc(n){let e=n.fields.shape;return Object.keys(e).flatMap(t=>{let r=Bn(e[t])?Wt(t):void 0;return r&&e[r]?[r]:[]})}var Sc=[["skip","Skip this one","Leave one day out of the series; the rest stay as they are.","Skip {} on "],["detach","Change just this one","Make one day of the series a record of its own, to change apart from the rest.","Change {} only on "],["split","Change from here","End the series the day before, and start it again from that day with what changes.","Change {} from "]];function As(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=kc(o);if(i.length===0)continue;let s=o.kind,a=o.fields.shape,d=Object.keys(a).filter(l=>!(l in(o.fixed??{}))),u=l=>T(o,l);for(let[l,p,c,f]of Sc){let g=`${l}-${s}`;t.has(g)||r.push({name:g,derived:{kind:s,act:l},title:p,description:c,subject:{kinds:[s],arg:"id"},writes:i.map(je),...l==="skip"?{}:{creates:[s]},input:Cn({id:kn([s]),on:j().check(un(/^\d{4}-\d{2}-\d{2}$/,"a day, like 2026-10-21")),...i.length>1?{field:se(Ai(i))}:{},...l==="skip"?{}:Object.fromEntries(d.map(h=>[h,se(a[h])]))}),describe:(h,x)=>f.replace("{}",u(x.getNode(String(h.id))??{id:h.id}))+Pe(String(h.on)),apply(h,x){let b=h.graph.getNode(String(x.id)),k=String(x.field??i[0]),$=b?.[k],m=b?.[je(k)],y=String(x.on);if(typeof $!="string"||!De(m))throw new Q(`${u(b??{id:x.id})} does not repeat`,"refused");let v=Ie($,m,{from:y,to:y})[0];if(!v)throw new Q(`${u(b)} does not fall on ${Pe(y)}`,"refused");let S=String(b.id),w=Object.fromEntries(d.filter(B=>x[B]!==void 0).map(B=>[B,x[B]])),_=je(k),R=B=>{let Br=Object.fromEntries(Object.entries({...b,...B,...w}).filter(([Pn,ct])=>ct!=null&&Pn!=="id")),Ur=h.freshId(u(Br));h.addNode({...Br,id:Ur,kind:s});for(let Pn of Object.keys(o.edges??{}))for(let ct of h.graph.out(S,Pn))h.addEdge({kind:Pn,from:Ur,to:ct.id})};if(l!=="split"){h.patchNode(S,{[_]:{...m,except:[...new Set([...m.except??[],y])].sort()}}),l==="detach"&&R({[k]:v,[_]:null});return}if(Object.keys(w).length===0)throw new Q(`Nothing to change: give ${u(b)} from ${Pe(y)} something new`,"invalid");if(y<=$.slice(0,10))return h.patchNode(S,w);let D=new Date(Date.parse(`${y}T00:00:00Z`)-864e5).toISOString().slice(0,10),ce=m.count?Ie($,{...m,except:[]},{to:D}).length:0,{count:Oe,except:W,...Lr}=m,Gr=B=>W?.some(B)?{except:W.filter(B)}:{};h.patchNode(S,{[_]:{...Lr,until:D,...Gr(B=>B<y),...Oe?{count:ce}:{}}}),R({[k]:v,[_]:{...Lr,...Gr(B=>B>=y),...Oe?{count:Oe-ce}:{},continues:S}})}})}}return r}function Rs(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function xr(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function vr(n,e){let t=n.subject;if(!t||!n.writes&&n.creates?.length)return[];let r=new Set(Object.keys(e.fields.shape));if(n.writes)return n.writes.filter(s=>r.has(s));let o=n.input.shape??{},i=new Set(Sn(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function Os(n,e){let t=new Map,r=(o,i,s)=>{let a=t.get(o)??new Map;a.get(i)?.includes(s)||(a.set(i,[...a.get(i)??[],s]),t.set(o,a))};for(let o of e){for(let i of xr(n,o)){let s=n.tryDefinition(i);if(s)for(let a of vr(o,s))r(i,a,o.name)}for(let[i,s]of Object.entries(o.writesOther??{})){let a=n.tryDefinition(i)?.fields.shape;if(a)for(let d of s)d in a&&r(i,d,o.name)}}return t}function Ps(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=Os(n,e).get(t);return Rs(r).filter(i=>!o?.has(i))}var Es=n=>`edit-${n}`;function zs(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=new Set;for(let i of e)i.derived||((i.creates??[]).includes(t)&&o.add(i.name),xr(n,i).includes(t)&&vr(i,r).length>0&&o.add(i.name));return[...o]}function Ms(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Es(i);if(t.has(s))continue;let a=Ps(n,e,i);if(a.length===0)continue;let d=o.fields.shape,u=ne(o,i),l=a.map(p=>zn(o,p).toLowerCase());r.push({name:s,derived:{kind:i,act:"edit"},idempotent:!0,title:`Change the ${u}`,description:`Change what was set when this ${u} was made: ${l.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:a,input:Cn({id:kn([i]),...Object.fromEntries(a.map(p=>[p,se($c(d[p]))]))}),describe:(p,c)=>{let f=c.getNode(p.id),g=f?T(o,f):p.id,h=o.display,x=k=>k===k.toUpperCase()?k:k.charAt(0).toLowerCase()+k.slice(1),b=a.filter(k=>p[k]!==void 0).map(k=>{let $=p[k],m=h?.format?.[k],y;try{let v=typeof $=="number"?br(d[k]):void 0;y=m?String(m($)):v?v.format==="money"?$s($,/^[A-Z]{3}$/.test(v.unit??"")?{...v,currency:v.unit}:v):v.format==="percent"?le($,v.locale,{style:"percent",maximumFractionDigits:0}):JSON.stringify($):ln($).length>0?ln($).map(S=>S.name).join(", "):JSON.stringify(typeof $=="string"&&$.length>60?_s($,60):$)}catch{y=JSON.stringify($)}return`${x(zn(o,k))} \u2192 ${y}`});return`Change ${g}: ${b.join(", ")||"nothing"}`},apply(p,c){let f={};for(let g of a){let h=c[g];h!==void 0&&(f[g]=h)}if(Object.keys(f).length===0)throw new Q(`Nothing to change \u2014 give at least one of ${l.join(", ")} a value.`,"invalid");p.patchNode(c.id,f)}})}return r}function $c(n){let e=n;for(let t=0;t<4;t++){let r=e._zod?.def;if((r?.type==="default"||r?.type==="prefault")&&r.innerType)e=r.innerType;else break}return e}function Ns(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function wr(n,e,t){if(t.derived)return t.derived.act==="edit"||t.derived.act==="skip"||t.derived.act==="detach"||t.derived.act==="split"?zs(n,e,t.derived.kind):Ns(e,t.derived.kind)}function _c(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=ne(o,i),a=(u,l)=>{let p=u.getNode(String(l));return p?T(o,p):String(l)},d=kn([i]);for(let[u,l,p,c]of[["remove","Remove",`Remove the ${s}`,`Take this ${s} out of the graph, with every tie it has. Undo puts it back.`],["archive","Archive",`Archive the ${s}`,`Set this ${s} aside, with its ties and history kept.`],["unarchive","Bring back","Bring it back",`Bring this archived ${s} back.`],["merge","Merge",`Merge into another ${s}`,`The other takes this ${s}'s ties, and this one is archived.`]]){let f=`${u}-${i}`;t.has(f)||u!=="remove"&&o.archives===!1||r.push({name:f,derived:{kind:i,act:u},title:p,description:c,subject:{kinds:[i],arg:"id"},...u==="remove"?{destructive:!0}:{},idempotent:!0,input:Ne(u==="merge"?{id:d,into:d}:{id:d}),describe:(g,h)=>{let x=u==="remove"&&h.getNode(String(g.id)),b=x?new Set(Object.values(x).flatMap(k=>ln(k).map($=>$.href))).size:0;return`${l} ${a(h,g.id)}${u==="merge"?` into ${a(h,g.into)}`:""}${b?` and its ${b} file${b>1?"s":""}`:""}`},apply:(g,h)=>g[`${u}Node`](h.id,h.into)})}}return r}function kr(n,e){return[...Ms(n,e),..._c(n,e),...As(n,e)]}var Ac=500,Rc=120;function _n(n){if(n===void 0)return;let{basis:e,confidence:t,model:r}=n??{},o=typeof e=="string"?e.trim():"",i=typeof r=="string"?r.trim():"";if(!o||o.length>Ac||t!==void 0&&!(typeof t=="number"&&t>=0&&t<=1)||r!==void 0&&!(i&&i.length<=Rc))throw new E("A lineage is { basis: 1\u2013500 characters, confidence?: 0\u20131, model?: 1\u2013120 characters }");return{basis:o,...t!==void 0?{confidence:t}:{},...i?{model:i}:{}}}var He="keep-link";function Is(n){let e=(t,r)=>{let o=t.getNode(r);return o?T(n.tryDefinition(o.kind),o):r};return{name:He,title:"Keep this link",input:Ne({kind:j(),from:j(),to:j()}),describe:(t,r)=>`Keep the link from ${e(r,t.from)} to ${e(r,t.to)}`,apply(t,r){let{kind:o,from:i,to:s}=r;if(!t.graph.getNode(i)||!t.graph.getNode(s)){let a=O({kind:o,from:i,to:s});throw new F(a,`Cannot remove missing edge ${a}`)}t.removeEdge({kind:o,from:i,to:s}),t.addEdge({kind:o,from:i,to:s})}}}var js=(n,e)=>[...n].filter(t=>!t.derived&&t.name!==He&&typeof e=="string"&&(t.connects?.includes(e)||t.severs?.includes(e))).map(t=>t.name);var Ds=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget"];function Ts(n,e){let t=Un(n,e);return t&&[...t.fields].filter(Boolean)}function Oc(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function Qn(n,e){try{return T(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var Pc=n=>`${n.kind}:${n.from}->${n.to}`,et=(n,e)=>n<e?-1:n>e?1:0;function Zs(n,e,t={}){let{schema:r}=n,o=[],i=new Map;for(let c of e.nodes)i.has(c.id)||i.set(c.id,c);let s=c=>e.edges.filter(f=>f.from===c||f.to===c),a=c=>({action:"drop",primitives:[...s(c.id).filter(f=>i.has(f.from)&&i.has(f.to)).map(f=>({op:"remove-edge",edge:f})),{op:"remove-node",node:c}]}),d=new Set;for(let c of[...i.values()].sort((f,g)=>et(f.id,g.id))){if(!r.tryDefinition(c.kind)){d.add(c.id),o.push({code:"kind-unknown",id:c.id,message:`${Qn(r,c)} is a kind of record this app no longer has`,repair:a(c)});continue}let f=Ts(r,c);if(f===void 0)continue;let g=Qn(r,c),h=new Map,x=f.length>0;for(let b of f){if(b==="id"||b==="kind"){x=!1;continue}let k=Oc(r,c.kind,b),$=k?k.safeParse(void 0):{success:!0,data:void 0},m=r.tryDefinition(c.kind)?.defaults;!$.success&&k&&m&&Object.hasOwn(m,b)&&($=k.safeParse(m[b])),$.success?$.data===void 0?h.set(b,{action:"clear",value:X}):h.set(b,{action:"coerce",value:$.data}):x=!1}if(x){let b={...c};for(let[k,$]of h)$.value===X?delete b[k]:b[k]=$.value;Ts(r,b)!==void 0&&(x=!1)}if(f.length===0){o.push({code:"node-shape",id:c.id,message:`${g} does not fit what ${c.kind} declares`,repair:a(c)});continue}for(let b of f){let k=h.get(b),$=x&&k?{action:k.action,primitives:[{op:"patch-node",id:c.id,before:{[b]:c[b]===void 0?X:c[b]},after:{[b]:k.value}}]}:a(c);o.push({code:"node-shape",id:c.id,detail:b,message:`${g}: ${U(b)} does not fit what ${c.kind} declares`,repair:$})}}let u=new Set,l=[];for(let c of[...e.edges].sort((f,g)=>et(O(f),O(g)))){if(u.has(O(c)))continue;u.add(O(c));let f=Pc(c),g=i.get(c.from),h=i.get(c.to);if(!g||!h){o.push({code:"edge-dangling",id:f,message:"A link points at a record that is not there",repair:{action:"drop",primitives:[{op:"remove-edge",edge:c}]}});continue}l.push(c),!(d.has(g.id)||d.has(h.id))&&(r.edgeAllowed(c.kind,g.kind,h.kind)||o.push({code:"edge-disallowed",id:f,message:`${Qn(r,g)} \u2192 ${Qn(r,h)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:c}]}}))}let p=n.invariants??[];if(p.length>0){let c=C.from(r,{nodes:[...i.values()],edges:l},{validate:!1}),f=new Set,g;try{g=Ze(c,p,t.invariantOptions??{})}catch{g=[{invariant:"rules",status:"could-not-judge",label:"The rules",message:"The rules could not be judged",nodeIds:[],repairs:[]}]}for(let h of g){let x=h.status==="could-not-judge"?"rule-error":h.status==="over-budget"?"rule-budget":void 0;if(!x)continue;let b=h.subjectId??h.invariant,k=`${x}|${b}|${h.invariant}`;f.has(k)||(f.add(k),o.push({code:x,id:b,detail:h.invariant,message:h.message}))}}return o.sort((c,f)=>Ds.indexOf(c.code)-Ds.indexOf(f.code)||et(c.id,f.id)||et(c.detail??"",f.detail??""))}var nt=()=>globalThis.__graviewWatch;function Fs(n){nt()?.store?.(n)}function tt(n){n!==void 0&&nt()?.learn?.({ids:[n],words:[]})}function Cs(n,e){nt()?.refused?.({...n,...e===void 0?{}:{author:e}})}function Ec(n,e,t){nt()?.seat?.(n,e,t)}function Sr(n){if(typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n))return n;let e=new Date(n);if(Number.isNaN(e.getTime()))throw new Error(`Not a day: ${String(n)}`);return e.toISOString().slice(0,10)}function Ls(n=Date.now()){let e=new Date(n).getTime(),t=new Date(e);return t.setUTCHours(24,0,0,0),t.getTime()-e}function zc(n,e){let t,r=()=>{t=setTimeout(()=>{let o=n.tick(new Date);r(),e?.(o)},Ls()+1e3),t.unref?.()};return r(),()=>clearTimeout(t)}var $r="preview",N=(n,e)=>e===void 0?{}:{[n]:e},$e={kind:"human"},Gs={kind:"system"},Us={kind:"system",id:"modules",name:"Modules"},Bs=n=>n.mutation===null&&n.undoes===void 0;function _r(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var Mc={has:()=>!0},Ks=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function Vs(n,e,t){let r=Ks(n),o=p=>_r(p,r),i=new Set(e.map(o)),s=new Set(t.map(o)),a=t.filter(p=>!i.has(o(p))),d=e.filter(p=>!s.has(o(p)));if(a.length===0||d.length===0)return{introduces:a,resolves:d};let u=p=>p.subjectId&&_r(p,Mc),l=d.map(u);return{introduces:a.filter(p=>{let c=u(p)?l.indexOf(u(p)):-1;return c<0||(l[c]=null,!1)}),resolves:d.filter((p,c)=>l[c]!==null)}}var Je=class extends Error{constructor(t,r){super(`Op "${t.id}" (${t.intent}) could not be applied: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.op=t;this.name="ReceiveError"}},rt=class extends E{constructor(t,r){super(`Unknown mutation "${t}"`,`Registered: ${r.join(", ")||"(none)"}`);this.mutation=t;this.name="UnknownMutationError"}};function Nc(){let n=globalThis.crypto,e=new Uint8Array(6);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return[...e].map(t=>t.toString(36).padStart(2,"0")).join("")}var Ar=class n{schema;graph;log;mutations=new Map;keeper;invariants;invariantOptions;policy;intelligence;may=new Map;by;declaredModules;startingModules;projected;nextId;now;validate;mintBatch;batchTag;counter=0;opCount=0;quiet=0;rehearsing=!1;ticked;listeners=new Set;constructor(e){this.schema=e.schema,this.invariants=e.invariants??[],this.invariantOptions=e.invariantOptions??{},this.policy=e.policy,this.by=e.principal??$e,this.intelligence=e.intelligence??[];for(let i of e.intelligence??[])i.may&&this.may.set(i.name,new Set(i.may));this.declaredModules=e.modules,this.startingModules=e.enabledModules,this.nextId=e.ids??(()=>`op${++this.opCount}`),this.now=e.now??(()=>new Date().toISOString()),this.validate=e.validate??!0;let t=Nc();this.batchTag=e.batchIds?void 0:t,this.mintBatch=e.batchIds??(i=>`${i}:${t}:${++this.counter}`);for(let i of e.mutations??[]){if(this.mutations.has(i.name))throw new E(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of kr(e.schema,e.mutations??[]))this.mutations.set(i.name,i);this.mutations.has(He)||(this.keeper=Is(e.schema),this.mutations.set(He,this.keeper));let r=N("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=Be.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?C.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=Be.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=C.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);this.countPastTheLog(),Fs(this)}countPastTheLog(){let e=t=>{let r=/(\d+)$/.exec(t);return r?Number(r[1]):0};for(let t of this.log.all())this.counter=Math.max(this.counter,e(t.batch)),this.opCount=Math.max(this.opCount,e(t.id));this.log.horizon>0&&(this.opCount=Math.max(this.opCount,this.log.length))}get modules(){let e=this.log.all(),t=e.at(-1)?.id,r=this.projected;if(r&&r.length===e.length&&r.last===t)return r.projection;let o,i=0;r&&r.length<=e.length&&(r.length===0||e[r.length-1]?.id===r.last)&&(o=r.said,i=r.length);for(let a=e.length-1;a>=i;a--){let d=e[a].enabledModules;if(d!==void 0){o=d;break}}let s=r&&o===r.said?r.projection:pr(this.declaredModules,o??this.startingModules);return this.projected={projection:s,length:e.length,last:t,said:o},s}setEnabledModules(e,t={}){let r=this.modules.enabled,o=pr(this.declaredModules,e).enabled,i=[...r].filter(l=>!o.has(l)),s=[...o].filter(l=>!r.has(l));if(i.length===0&&s.length===0)return;let a=l=>l.map(p=>{let c=this.declaredModules?.[p]?.kinds??[];return c.length>0?c.map(f=>rn(this.schema,f)).join(", "):p}).join(", "),d=[i.length>0?`Turn off ${a(i)}`:"",s.length>0?`turn on ${a(s)}`:""].filter(Boolean).join("; "),u={id:this.nextId(),seq:this.log.length,batch:t.batch??this.mintBatch("batch"),author:Us,intent:tn(d),mutation:null,primitives:[],inverse:[],reads:[],writes:[],at:this.now(),...N("via",t.via),enabledModules:[...o].sort()};return this.log.append(u),this.notify(Ht,[u]),u}mutation(e){let t=this.mutations.get(e);if(!t)throw new rt(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new E(`Mutation "${e}" belongs to a module this workspace has turned off`,`Enabled modules: ${[...this.modules.enabled].join(", ")||"(none)"}`);return t}mutationDisabled(e){return this.modules.disabledMutations.has(e.name)?!0:e.derived!==void 0&&this.modules.disabledKinds.has(e.derived.kind)}allMutations(){return[...this.mutations.values()].filter(e=>e!==this.keeper&&!this.mutationDisabled(e))}viaOf(e,t){if(e!==void 0&&e===this.keeper)return js(this.mutations.values(),t?.args.kind);if(e?.derived)return wr(this.schema,[...this.mutations.values()],e)}moved(e,t){return Vs(this.allInvariants(),e,t)}allInvariants(){return this.invariants.filter(e=>this.invariantEnabled(e))}invariantEnabled(e){if(this.modules.disabledInvariants.has(e.name))return!1;if(e.scope!=="graph"){let t=e.scope.kind;if(this.modules.disabledKinds.has(t))return!1}return!0}permits(e,t=$e){let r=this.refusesAgent(e,t)??this.namesTurnedOff(e,t);if(r)return{ok:!1,refusal:r};let o=this.mutations.get(e.name),i=o?.subject&&e.args[o.subject.arg];return me(this.policy,t,e.name,this.subjectKindOf(e,t),this.viaOf(o,e),typeof i=="string"?i:void 0,this.words,()=>{let s=M(t).id,a=this.namedIn(e,!1);try{for(let d of qe(this.graph,o,e.args,this.sighted(t)).primitives)"edge"in d&&d.edge.from!==s&&d.edge.to!==s&&a.push(d.edge.to)}catch{}return a},o?.derived&&(()=>ae(this.log).creatorOf(i)))}namedIn(e,t=!0){let r=this.mutations.get(e.name);if(!r)return[];let o=r.subject?.arg;return[...t&&o?[e.args[o]]:[],...Sn(r.input).flatMap(s=>s.name===o?[]:[e.args[s.name]])].flat().filter(s=>typeof s=="string")}refuse(e,t,r=!this.rehearsing){throw r&&Cs(e,t),new Le(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>ne(this.schema.tryDefinition(e),e)}}refusesAgent(e,t){if(t.kind!=="agent"||t.id===void 0)return;let r=this.may.get(t.id);if(!r||r.has(e.name))return;let o=s=>`\u201C${this.mutations.get(s)?.title??s}\u201D`,i=[...r].map(o);return{mutation:e.name,message:`${t.id} may not ${o(e.name)} here: it was declared able to ${i.length===0?"do nothing else":i.join(", ")}.`,wouldNeed:[]}}namesTurnedOff(e,t=Gs){let r=this.modules.disabledKinds;if(r.size===0||!L(t))return;let o=this.mutations.get(e.name);if(!(!o||!this.namedIn(e).some(i=>r.has(this.graph.getNode(i)?.kind))))return{mutation:e.name,message:`\u201C${o.title??e.name}\u201D names a record of a module this workspace has turned off.`,wouldNeed:[]}}sighted(e){let t={me:e&&M(e).id};if(e===void 0||!Ve(this,e))return t;let r=vn(this,e);return{...t,seen:wn(this,e).graph,keepUnchanged:o=>z(o,r),seesInFull:as(this,e)}}missingFor(e,t=$e){let r=this.mutations.get(e.name),o=new Set(this.namedIn(e));if(!r||o.size===0)return;let i=wn(this,t).graph;for(let s of o)if(!i.has(s))return new F(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=$e){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&nr(i).some(s=>me(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e){return wn(this,e)}sees(e,t){return this.graph.has(t)&&vn(this,e)(t)}labels;resolveRef(e,t,r=$e){let o=(this.policy?.sees?.length??0)>0,i=c=>!o||this.sees(r,c),s=this.graph.getNode(t);if(this.labels??=new Yn(this.graph),s&&i(t))return{ok:!0,id:t,label:this.labels.labelOf(t)??t,by:"id"};let a=this.labels.lookup(e.kinds,t),d=c=>{let f=c.filter(g=>!this.graph.isArchived(g));return f.length?f:c},u=d(a.exact.filter(i)),l=u.length>0,p=(l?u:d(a.prefix.filter(i))).map(c=>({id:c,kind:this.graph.getNode(c).kind,label:this.labels.labelOf(c)??c})).sort((c,f)=>c.label<f.label?-1:c.label>f.label?1:c.id<f.id?-1:1);return p.length===1?{ok:!0,id:p[0].id,label:p[0].label,by:l?"label":"prefix"}:fs(this.schema,e,t,p)}kindsKeptFrom(e=$e){let t=new Set;for(let[o,i]of this.modules.administered)if(!this.mayAdminister(o,e))for(let s of i.kinds??[])t.add(s);let r=this.policy?.sees??[];if(r.length>0&&!L(e)){let o=new Set(this.permittedMutations(e).flatMap(s=>s.creates??[])),i=ye(this);for(let s of this.schema.kinds)!r.some(d=>d.kinds.includes(s)&&ge(d,e)&&(!d.own&&!d.via||e.id!==void 0)&&(i||!xn(d)))&&!o.has(s)&&t.add(s)}return t}permittedMutations(e=$e){let t=this.allMutations(),r=er(this.policy,e,t.filter(i=>!i.derived)),o=t.filter(i=>i.derived!==void 0&&me(this.policy,e,i.name,i.derived.kind,this.viaOf(i),M(e).id).ok);return[...r,...o]}subjectKindOf(e,t=Gs){let o=this.mutations.get(e.name)?.subject;if(!o)return;let i=e.args[o.arg];if(typeof i!="string")return o.kinds!=="*"&&o.kinds.length===1?o.kinds[0]:void 0;if(!(!L(t)&&!vn(this,t)(i)))return this.graph.getNode(i)?.kind}today(){return this.pinned()??(this.ticked&&this.ticked.on===nn()?this.ticked.day:void 0)}pinned(){let e=this.invariantOptions.context,t=this.invariantOptions.today??e?.today;return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)?t:void 0}judging(e){let t=this.today();return{...this.invariantOptions,...e===void 0?{}:{context:e},...t===void 0?{}:{today:t}}}tick(e=new Date){let t=this.pinned();if(t!==void 0)return{day:t,was:t,appeared:[],cleared:[]};let r=Sr(e),o=this.today(),i=this.violations();this.ticked={day:r,on:nn()};let s=this.moved(i,this.violations());if(r!==o&&!this.rehearsing&&this.quiet===0)for(let a of this.listeners)a(Ht,[]);return{day:r,...o===void 0?{}:{was:o},appeared:s.introduces,cleared:s.resolves}}violations(e,t=this.graph){return Ze(t,this.allInvariants(),this.judging(e))}wouldChange(e,t){try{return qe(this.graph,this.mutation(e.name),e.args,this.sighted(t)).primitives.length>0}catch{return!0}}preview(e,t,r={}){let o=this.mutation(e.name),i=qe(this.graph,o,e.args,this.sighted(r.author));return this.previewPrimitives(i.primitives,{reads:i.reads,writes:i.writes,intent:i.intent,context:t})}previewAll(e,t={}){let{context:r,...o}=t;return{...this.rehearsal().applying(e,o,r),kept:!1}}rehearsal(){let e=Object.assign(Object.create(n.prototype),this),t=0;return Object.assign(e,{graph:C.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:Be.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${$r}:${++t}`,mintBatch:()=>$r,rehearsing:!0}),e}previewPrimitives(e,t){let r=this.violations(t.context),o=C.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=Ze(o,this.allInvariants(),this.judging(t.context));return{diff:i,primitives:e,reads:t.reads,writes:t.writes,intent:t.intent,...this.moved(r,s),violationsAfter:s}}apply(e,t={}){return this.applyAll([e],t)}applyAll(e,t={}){return this.applying(e,t)}applying(e,t,r){let o=t.batch??this.mintBatch("batch"),i=t.author??this.by,s=_n(t.lineage),a=[],d=[],u=new Set,l=new Set,p=[],c=this.violations(r),f=this.graph.snapshot(),g=this.log.length;if(this.policy)for(let b of e){let k=this.permits(b,i);k.ok||this.refuse(k.refusal,i.id)}for(let b of e){let k=this.refusesAgent(b,i)??this.namesTurnedOff(b,i);k&&this.refuse(k,i.id)}this.rehearsing||tt(i.id);try{for(let b of e){let k=this.mutation(b.name),$=this.missingFor(b,i);if($)throw $;let m=qe(this.graph,k,b.args,this.sighted(i));if(m.primitives.length===0)continue;let y={id:this.nextId(),seq:this.log.length,batch:o,author:i,intent:k.describe!==void 0?m.intent:t.intent??m.intent,...N("batchIntent",t.intent),mutation:b,primitives:m.primitives.map(pn),inverse:[...m.primitives].reverse().map(pn).map(hn),reads:m.reads,writes:m.writes,...k.describe!==void 0&&m.described&&m.described.length>0?{described:m.described}:{},...N("mergedInto",m.mergedInto),at:this.now(),...N("via",t.via),...N("lineage",s)};this.graph.applyPrimitives(y.primitives),this.log.append(y),a.push(y),d.push(...y.primitives);for(let v of y.reads)u.add(v);for(let v of y.writes)l.add(v);p.push(y.intent)}}catch(b){throw this.putBack(f,g),b}let h=J(f,this.graph.snapshot());this.admitted(t,a,d,h,f,g);let x=this.violations(r);return this.notify(h,a),{batch:o,ops:a,diff:h,primitives:d,reads:[...u],writes:[...l],intent:t.intent??p.join("; "),...this.moved(c,x),violationsAfter:x}}receive(e,t={}){let r=new Set(this.log.all().map(d=>d.id)),o=e.filter(d=>!r.has(d.id));if(o.length===0)return[];let i=this.graph.snapshot(),s=[];if(!t.applied)for(let d of o)try{this.graph.applyPrimitives(d.primitives,{restoring:d.undoes!==void 0})}catch(u){throw this.graph.load(i),new Je(d,u)}let a=this.log.length;for(let[d,u]of o.entries()){let l={...u,seq:a+d};this.log.append(l),s.push(l)}return this.notify(J(i,this.graph.snapshot()),s),s}append(e,t={}){if(e.length===0)return[];let r=new Set(this.log.all().map(a=>a.id)),o,i=e.map((a,d)=>{let u=a.primitives.map(pn),l={id:a.id??this.nextId(),seq:this.log.length+d,batch:a.batch??t.batch??(o??=this.mintBatch("batch")),author:a.author,intent:a.intent,...N("batchIntent",a.batchIntent),mutation:a.mutation??null,primitives:u,inverse:a.inverse??[...u].reverse().map(hn),reads:a.reads??[],writes:a.writes??[...new Set(u.flatMap(ke))],at:a.at??this.now(),...N("undoes",a.undoes),...N("via",a.via),...N("lineage",_n(a.lineage))};if(r.has(l.id))throw new E(`Op "${l.id}" (${l.intent}) is already in the log`,"A host-made op needs an id of its own; leave `id` out and the store mints one.");return r.add(l.id),l}),s=this.graph.snapshot();for(let a of i)try{this.graph.applyPrimitives(a.primitives,{restoring:a.undoes!==void 0})}catch(d){throw this.graph.load(s),new Je(a,d)}for(let a of i)this.log.append(a);for(let a of i)tt(a.author.id);return this.notify(J(s,this.graph.snapshot()),i),i}applyPrimitives(e,t={}){let r=t.batch??this.mintBatch("batch"),o=t.author??this.by,i=this.violations(),s=this.graph.snapshot(),a=t.intent??"Apply a change",d=_n(t.lineage),u=e.map(pn),l=[];if(u.length>0){let f={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:u,inverse:[...u].reverse().map(hn),reads:[],writes:[...new Set(u.flatMap(ke))],at:this.now(),...N("via",t.via),...N("lineage",d)};this.graph.applyPrimitives(f.primitives),this.log.append(f),l.push(f),tt(o.id)}let p=this.violations(),c=J(s,this.graph.snapshot());return this.notify(c,l),{batch:r,ops:l,diff:c,primitives:u,reads:[],writes:l[0]?.writes??[],intent:a,...this.moved(i,p),violationsAfter:p}}findings(){return Zs({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return yn(this.log,typeof e=="string"?[e]:e)}previewUndo(e,t){let r=this.canUndo(e);if(!r.ok)return{ok:!1,check:r};let o=es(r.ops),i=new Set;for(let s of r.ops)for(let a of s.writes)i.add(a);return{ok:!0,check:r,...this.previewPrimitives(o,{reads:[...new Set(r.ops.flatMap(s=>[...s.reads]))],writes:[...i],intent:`Undo: ${r.ops.map(s=>s.intent).join("; ")}`,restoring:r.ops.every(Bs),...t===void 0?{}:{context:t}})}}undo(e,t={}){return this.undoing(e,t)}undoing(e,t){let r=typeof e=="string"?[e]:e,o=t.author??this.by,i=(this.policy?.sees?.length??0)>0&&!L(o);if(i){let h=yn(lr(Ce(this.log.all(),ur(this,o)),()=>this.log.epochs()),r);if(!h.ok)throw new Se(h)}let s=this.canUndo(r);if(!s.ok)throw new Se(i?{ok:!1,ops:[],blockedBy:[],includeBatches:[],message:"Cannot undo on its own \u2014 a later change you cannot see depends on it, which only somebody who can see it can take back."}:s);let a=t.batch??this.mintBatch("undo"),d=_n(t.lineage);if(this.policy)for(let h of s.ops){if(!h.mutation)continue;let x=M(h.author).id,b=$=>JSON.stringify($).includes(JSON.stringify(x)),k=x!==void 0&&x!==M(o).id&&!L(o)&&!b(h.mutation.args)&&b(h.primitives)?{ok:!1,refusal:{mutation:h.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.permits(h.mutation,o);k.ok||this.refuse({...k.refusal,message:`Not permitted to undo "${h.intent}": ${k.refusal.message}`},o.id,!0)}let u=this.graph.snapshot(),l=this.violations(),p=[],c=this.log.length;for(let h of[...s.ops].sort((x,b)=>b.seq-x.seq)){let x={id:this.nextId(),seq:this.log.length,batch:a,author:o,intent:`Undo: ${h.intent}`,...N("batchIntent",t.intent),mutation:null,primitives:h.inverse,inverse:[...h.inverse].reverse().map(hn),reads:h.reads,writes:h.writes,at:this.now(),undoes:h.id,...N("via",t.via),...N("lineage",d),...N("undoneLineage",h.lineage)};this.graph.applyPrimitives(x.primitives,{restoring:Bs(h)}),this.log.append(x),p.push(x)}let f=J(u,this.graph.snapshot());this.admitted(t,p,p.flatMap(h=>[...h.primitives]),f,u,c);let g=this.violations();return this.notify(f,p),{batch:a,ops:p,diff:f,primitives:p.flatMap(h=>[...h.primitives]),reads:[...new Set(p.flatMap(h=>[...h.reads]))],writes:[...new Set(p.flatMap(h=>[...h.writes]))],intent:t.intent??p.map(h=>h.intent).join("; "),...this.moved(l,g),violationsAfter:g}}putBack(e,t){this.graph.load(e),this.log.length>t&&this.log.truncate(t)}admitted(e,t,r,o,i,s){if(!e.admit||t.length===0)return;let a=this.graph.size;try{e.admit({ops:t,primitives:r,added:{nodes:o.addedNodes.length,edges:o.addedEdges.length},removed:{nodes:o.removedNodes.length,edges:o.removedEdges.length},changed:{nodes:o.changedNodes.length},nodesAfter:a.nodes,edgesAfter:a.edges})}catch(d){throw this.putBack(i,s),d}}redo(e,t={}){return this.undo(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){if(!(this.quiet>0)&&!(t.length===0&&Fi(e)))for(let r of this.listeners)r(e,t)}rebase(e){let t=new Set([...e.pending,...e.drop??[]]),r=this.log.all(),o=r.findIndex(h=>t.has(h.batch)),i=r.slice(o<0?r.length:o),s=this.log.horizon+(o<0?r.length:o),a=i.find(h=>!t.has(h.batch));if(a)throw new E(`Cannot rebase: op "${a.id}" (${a.intent}) comes after a pending batch and is neither pending nor dropped`,"While anything is pending, land the server's ops through rebase, so the log stays confirmed ops then pending ones.");let d=this.log.lastEpoch();if(d&&d.seq>s)throw new E(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let u=this.graph.snapshot(),l=[],p=[],c=[];this.quiet++;try{for(let x of[...i].reverse())this.graph.applyPrimitives(x.inverse,{restoring:!0,inPlace:!0});this.log.truncate(s);let h=new Set(this.log.all().map(x=>x.id));for(let x of e.confirmed){if(h.has(x.id))continue;try{this.graph.applyPrimitives(x.primitives,{restoring:x.undoes!==void 0})}catch(k){throw new Je(x,k)}let b={...x,seq:this.log.length};this.log.append(b),h.add(x.id),l.push(b)}for(let x of e.pending){let b=i.filter(k=>k.batch===x);if(b.length!==0)try{p.push(...this.replay(x,b))}catch(k){c.push({batch:x,error:k})}}}catch(h){this.log.truncate(s);for(let x of i)this.log.append(x);throw this.graph.load(u),h}finally{this.quiet--}let f=J(u,this.graph.snapshot()),g=[...l,...p];return this.notify(f,g),{diff:f,confirmed:l,pending:p,refused:c}}adopt(e){let t=new Set(e.drop??[]),r=(e.pending??[]).filter(f=>!t.has(f)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(f=>f.id)),d=new Map(r.map(f=>[f,o.filter(g=>g.batch===f)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,N("horizon",e.horizon));else{let f=e.horizon??0;this.log.replace([],e.epochs??[{seq:f,base:e.snapshot}],{horizon:f})}let u=[],l=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let f of r){let g=d.get(f)??[];if(g.length!==0)try{u.push(...this.replay(f,g))}catch(h){l.push({batch:f,error:h})}}}catch(f){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,f}finally{this.quiet--}let p=this.log.all().filter(f=>!a.has(f.id)&&!u.includes(f)),c=J(i,this.graph.snapshot());return this.notify(c,[...p,...u]),{diff:c,adopted:p,pending:u,refused:l}}replay(e,t){let r=t[0],o={author:r.author,batch:e,...N("intent",r.batchIntent),...N("via",r.via),...N("lineage",r.lineage)};if(r.undoes!==void 0){let i=t.map(a=>this.log.get(a.undoes??"")),s=t.find((a,d)=>i[d]===void 0);if(s)throw new E(`What "${s.intent}" took back is no longer in the log`);return this.undoing([...new Set(i.map(a=>a.batch))],o).ops}return t.every(i=>i.mutation!==null)?this.applying(t.map(i=>i.mutation),o).ops:this.append(t.map(({seq:i,...s})=>s))}snapshot(){return this.graph.snapshot()}verify(){let e=this.log.lastEpoch();return ms(this.schema,this.log.opsFrom(e?.seq??0),this.graph.snapshot(),{validate:this.validate,...e?{base:e.base}:{}})}checkpoint(e={}){let t=this.log.all(),r;if(e.seq!==void 0)r=e.seq;else{let a=this.log.length-(e.keepOps??1e3),u=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,l=t.find(c=>Date.parse(c.at)>u),p=l?l.seq:this.log.length;r=Math.min(a,p)}for(r=Math.min(Math.max(r,this.log.horizon),this.log.length);r>this.log.horizon&&r<this.log.length&&t[r-this.log.horizon].batch===t[r-1-this.log.horizon].batch;)r--;if(r<=this.log.horizon)return;let o=this.verify();if(!o.ok)throw new E(`Cannot compact a store that does not verify: ${o.reason}`);let i=this.log.checkpointAt(this.schema,r,{validate:this.validate}),s=rs(this.log,r);return Object.keys(s).length>0?{...i,creators:s}:i}compact(e){return this.log.compact(e)}};var Ws=["full","summary","glyph"],Or=(n,e)=>n.as===e.as&&(n.over??[n.kind]).includes(e.kind),Ic=n=>n.filter((e,t)=>!n.slice(0,t).some(r=>Or(r,e)));function de(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function An(n,e){return`/${de(n.tryDefinition(e)?.plural??`${e}s`)}`}function jc(n,e,t){return`${An(n,e)}/${encodeURIComponent(t)}`}function Dc(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function qs(n,e){return e.some(t=>t.as===n.as&&!Or(n,t))}function Tc(n,e,t){return qs(n,e)?`${n.title} \xB7 ${(t.tryDefinition(n.kind)?.plural??`${n.kind}s`).toLowerCase()}`:n.title}var _e=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function Rr(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function Zc(n){let e=new Map,t=[],r=[],o,i,s={arrange(a){return a!==void 0&&(o=a),s},arrangement:()=>o,home(a){return a!==void 0&&(i=a),s},homeView:()=>i,register(a,d,u,l){let p=l?.over?.[1]?{over:l.over}:{},c={kind:a,cardinality:d.cardinality,fidelity:d.fidelity,view:u,...l?.title?{title:l.title}:{},...l?.across?{across:l.across}:{},...l?.beside?{beside:!0}:{},...p};if(r.push(c),l?.beside||e.set(_e(a,d),c),l?.title){let f=de(l.title);e.set(_e(a,d,f),c),d.cardinality==="many"&&!t.some(g=>g.kind===a&&g.as===f)&&t.push({kind:a,title:l.title,as:f,...l.across?{across:l.across}:{},...p})}return s},places:()=>t,forget(a,d){for(let l of Ws)e.delete(_e(a,{cardinality:"many",fidelity:l},d));let u=t.findIndex(l=>l.kind===a&&l.as===d);return u>=0&&t.splice(u,1),s},lookup(a,d){return e.get(_e(a,d))?.view},resolve(a,d,u){if(u)for(let l of Rr(d.fidelity)){let p=e.get(_e(a,{cardinality:d.cardinality,fidelity:l},u));if(p)return p}for(let l of Rr(d.fidelity)){let p=e.get(_e(a,{cardinality:d.cardinality,fidelity:l}));if(p)return p}if(d.cardinality==="one")for(let l of Rr(d.fidelity)){let p=e.get(_e(a,{cardinality:"many",fidelity:l}));if(p)return p}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}var Fc=["day","week","month","year","decade"];function Hs(n){let e={};n.q&&n.q.trim().length>0&&(e.query=n.q);let t=qt(n.archived);if(t&&(e.archived=t),n.sort){let[r,o]=n.sort.split(":");r&&(e.sort={by:r,direction:o==="desc"?"desc":"asc"})}if(n.filter){let r=[];for(let o of n.filter.split(",")){let i=o.indexOf(":");i<=0||r.push({key:o.slice(0,i),value:o.slice(i+1)})}r.length>0&&(e.filter=r)}if(n.group){let[r,o]=n.group.split(":");r&&(e.group={by:r,...Fc.includes(o)?{bucket:o}:{}})}return e}var ot={timeline:{binds:"fields",requiredRoles:["start","end"],options:["columns","extent","tick","minWindow","arranging"]},calendar:{binds:"fields",requiredRoles:["start"],options:["today","range","weekStartsOn","perCell","horizon","arranging"]},coverage:{binds:"entities",requiredRoles:["rows","columns","link"],options:["rowRef","rowGroup","groupOrder","requiredGroups","requiredVia","badge","columnGroup"]},board:{binds:"entities",requiredRoles:["slots","x","y","fill"],options:["fillFrom","slotCode","zones","aspect","emptyLabel","pickTarget","arranging","arrange"]},plan:{binds:"entities",requiredRoles:["regions","outline"],options:["hues","aspect","undrawnLabel","strayLabel","draw","place","help"]},reach:{binds:"nothing",requiredRoles:[],options:[]},blocks:{binds:"nothing",requiredRoles:[],options:["blocks"]},columns:{binds:"fields",requiredRoles:["column"],options:[]}},Ys=Object.keys(ot),Xs=n=>Object.hasOwn(ot,n);var Rn=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function Js(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=I(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=I(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function Cc(n){let e=[],t=[],r=[],o=new Set(n.schema.kinds),i=new Set;for(let d of o)for(let u of Object.keys(n.schema.tryDefinition(d)?.edges??{}))i.add(u);let s=d=>Object.keys(n.schema.tryDefinition(d)?.fields.shape??{}),a=new Map;return(n.lenses??[]).forEach((d,u)=>{let l=`lenses.${u}`,p=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,c=(y,v)=>{t.push({index:u,name:d.name,...p?{title:p}:{},why:y}),v&&r.push({severity:"warning",...v})};if(!Xs(d.name)){p?c(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${l}.name`,message:`"${p}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${Ys.join(", ")} \u2014 or register the view yourself and drop the title.`}):c("it is a lens this app wrote, drawn by the app's own views");return}if(!p)return c("it has no title, so it is bindings the checker holds and no place");let f=ot[d.name],g=Rn(d.options)?d.options:{};if(d.options!==void 0&&!Rn(d.options))return c("its options are not an object",{code:"lens-options-not-an-object",path:`${l}.options`,message:`"${p}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let y of Object.keys(g))f.options.includes(y)||r.push({severity:"warning",code:"lens-option-unknown",path:`${l}.options.${y}`,message:`The ${d.name} lens takes no option "${y}", so "${p}" ignores it.`,fix:f.options.length===0?`The ${d.name} lens takes no options; drop it.`:`Use one of: ${f.options.join(", ")}.`});let h={};for(let y of f.options)g[y]!==void 0&&(h[y]=g[y]);d.arrangedBy&&(h.arrangedBy=Hs(d.arrangedBy));let x=Rn(d.bindings)?d.bindings:{},b=[],k,$=(y,v,S)=>c(v,{code:"lens-cannot-draw",path:y,message:`"${p}" cannot draw: ${v}.`,fix:S});if(f.binds==="fields"){let y=Object.keys(x).filter(S=>Rn(x[S])),v=y.filter(S=>!o.has(S));if(y.length===0)return $(`${l}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${f.requiredRoles.map(S=>`"${S}": "<field>"`).join(", ")} } }.`);if(v.length>0)return;if(h.bindings=x,b=y,d.name==="timeline"){let S=g.columns;if(Array.isArray(S))h.columns=S.map(w=>typeof w=="string"?{id:w,label:w}:w);else{let w=y.flatMap(R=>{let D=x[R],ce=typeof D.column=="string"?D.column:typeof D.columns=="string"?D.columns:void 0;return ce?Js(n.schema,R,ce):[]}),_=[...new Set(w)];if(_.length===0)return $(`${l}.options.columns`,"it has no columns \u2014 no option names them and no `column` role is bound to a field of set values",'Bind "column" to a field whose values are the columns, or say "columns": ["mon", "tue", \u2026].');h.columns=_.map(R=>({id:R,label:R.toUpperCase()}))}h.extent===void 0&&(h.extent=1440)}if(d.name==="columns")for(let S of y){let w=x[S].column;if(typeof w!="string"||!s(S).includes(w))return;if(Js(n.schema,S,w).length===0)return $(`${l}.bindings.${S}.column`,`its column field "${w}" is not a choice`,`Bind "column" to a choice field of ${S}, like a status.`)}if(d.name==="calendar"&&h.today!==void 0&&!(typeof h.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.today)))return $(`${l}.options.today`,"its today is not a date",'Write it as "YYYY-MM-DD", or leave it out and the calendar opens on the day it is drawn.');if(d.name==="calendar"&&h.range!==void 0&&!["day","week","month","quarter","year","years","agenda"].includes(h.range))return $(`${l}.options.range`,`its range "${String(h.range)}" is not one a calendar opens at`,"Use one of: day, week, month, quarter, year, agenda.")}else if(f.binds==="entities"){let y=w=>{let _=x[w];if(Rn(_)){if(typeof _.kind=="string")return _.kind;if(typeof _.edge=="string")return _.edge;if(Array.isArray(_.path))return{path:_.path};if(typeof _.field=="string")return _.field}};for(let w of f.requiredRoles)if(y(w)===void 0)return;let v=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",S=y(v);if(!o.has(S))return;if(d.name==="coverage"){let w=y("columns");if(!o.has(w))return;let _=y("link");if(typeof _=="string"&&!i.has(_))return;Object.assign(h,{rows:S,columns:w,link:_}),w!==S&&(k=w)}else if(d.name==="board"){Object.assign(h,{slots:S,x:y("x"),y:y("y"),fill:y("fill")});for(let w of["x","y"])if(!s(S).includes(h[w]))return}else{Object.assign(h,{regions:S,outline:y("outline")});for(let w of["markers","at","within","nests","regionKind","markerKind"]){let _=y(w);typeof _=="string"&&(h[w]=_)}}b=[S]}else if(d.name==="blocks"){if(!d.on)return $(`${l}.on`,"it does not say which kind it stands on",'Say "on": "<the kind it is a place of>".');if(!Array.isArray(h.blocks)||h.blocks.length===0)return $(`${l}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let y=["user","person","member"].find(v=>o.has(v));if(!d.on&&!y)return $(`${l}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');b=y?[y]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return $(`${l}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(b=[d.on],d.name==="coverage"){let y=[h.rows,h.columns].find(v=>v!==d.on);k=typeof y=="string"?y:void 0}}let m=de(p);if(m.length===0)return $(`${l}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let y of b){let v=`${y}|${m}`;if(a.has(v))return c(`another lens on ${y} is already called "${p}"`,{code:"lens-title-taken",path:`${l}.title`,message:`"${p}" is the title of lenses.${a.get(v)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let y of b)a.set(`${y}|${m}`,u);e.push({index:u,lens:d.name,title:p,as:m,kinds:b,...k?{across:k}:{},options:h})}),{drawn:e,undrawn:t,findings:r}}var Lc=6;function Gc(n,e,t=[]){let r=n.kinds,o=s=>Object.values(n.tryDefinition(s)?.edges??{}).map(a=>(a.to??[]).filter(d=>d!==s)),i=new Set(r.flatMap(s=>o(s).flat()));return new Set([...e?.hide??[],...t,...r.filter(s=>!i.has(s)&&o(s).length>0&&o(s).every(a=>a.length>=2))])}function Bc(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(de));return{kinds:new Set(e.kinds.filter(o=>r.has(de(o))||r.has(An(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(de(o.title))).map(o=>`${o.kind}|${o.as}`))}}var Qs="overview",Uc=`/places/${Qs}`;function Kc(n){let e=n?.scene?.trim();return e||"Scene"}function Vc(n){let e=n?.pages?.trim();return e||"Pages"}function Wc(n,e){if(!e||e.length===0)return n;let t=e.filter(r=>n.includes(r));return[...new Set(t),...n.filter(r=>!t.includes(r))]}function qc(n,e,t){if(n===void 0)return;let r=n.trim();if(r==="")return;if(r.toLowerCase()==="home"||r==="/")return{to:"home"};let o=de(r),i=t.find(d=>d.title===r)??t.find(d=>d.as===o);if(i)return{to:"place",place:i};let s=e.kinds,a=s.find(d=>d===r)??s.find(d=>An(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function Pr(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function Hc(n,e={}){let t=typeof n=="string"?n:n.address,r=Pr(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function Jc(n,e){let t=Pr(e);if(t==="")return n.startsWith("/")?n:`/${n}`;if(!n.toLowerCase().startsWith(t.toLowerCase()))return null;let r=n.slice(t.length);return r===""||r==="/"?"/":r.startsWith("/")?r:null}var ea=/^(?:https?:\/\/[^\s<>"'`\\]+|@?[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)$/,Yc=n=>typeof n=="string"&&n.length<501&&ea.test(n),na=Symbol.for("@graview/core:app-link"),Xc=n=>(Object.defineProperty(I(n),na,{value:1,enumerable:!0}),n);function ta(n){let e=I(n);return!!e&&(e[na]===1||ta(e.innerType))}var Jy=()=>Xc(j().check(Ct(500),un(ea,"another app's address")));function Er(n,e){if(n.onBehalfOf){let{onBehalfOf:i,...s}=n;return`${Er(s,e)}, for ${Er(i,e)}`}if(n.id===void 0)return n.name??(n.kind==="agent"?"an agent":n.kind);let t=e.graph.getNode(n.id);if(t)return T(e.schema.tryDefinition(t.kind),t);let r=e.seats?.find(i=>i.principal.id===n.id);if(r)return r.label;let o=e.people?.find(i=>i.id===n.id&&(i.kind===void 0||i.kind===n.kind));return o?o.name:n.name?n.name:/(^|:)migration$/.test(n.id)?"the upgrade":/[:_/]/.test(n.id)?{human:"somebody",agent:"an agent",rule:"a rule",system:"the system"}[n.kind]:n.id}var Qc=1;var it=(n,e)=>`${n}\0${e}`;function Mr(n){return n.op==="add-node"?Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind").map(e=>[n.node.id,e]):n.op==="patch-node"?Object.keys(n.after).map(e=>[n.id,e]):[]}var zr=class n{revs=new Map;static of(e){let t=new n;return t.note(e),t}note(e){for(let t of e)for(let r of t.primitives)for(let[o,i]of Mr(r)){let s=it(o,i);(this.revs.get(s)??-1)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(it(e,t))??-1}baseFor(e,t=new Set){let r=new Set,o=new Map;for(let i of e)for(let s of i.primitives)if(s.op==="add-node"&&r.add(s.node.id),!(s.op!=="patch-node"||r.has(s.id)||t.has(s.id)))for(let a of Object.keys(s.after)){let d=it(s.id,a);t.has(d)||o.has(d)||o.set(d,{node:s.id,field:a,rev:this.of(s.id,a)})}return[...o.values()]}stale(e){return e.filter(t=>this.of(t.node,t.field)!==t.rev)}};function eu(n){let e=new Set;for(let t of n)for(let r of t.primitives){r.op==="add-node"&&e.add(r.node.id);for(let[o,i]of Mr(r))e.add(it(o,i))}return e}var nu=/^#([0-9a-f]{3,8})$/i,tu=/(rgba?|hsla?)\(([^)]+)\)/gi;function ru(n){let e=nu.exec(n.trim());if(!e)return null;let t=e[1];if((t.length===3||t.length===4)&&(t=[...t].map(i=>i+i).join("")),t.length!==6&&t.length!==8)return null;let r=Number.parseInt(t.slice(0,6),16),o=t.length===8?Number.parseInt(t.slice(6,8),16)/255:1;return{r:r>>16&255,g:r>>8&255,b:r&255,a:o}}function ou(n){let e=n.slice(0,n.indexOf("(")).toLowerCase(),r=n.slice(n.indexOf("(")+1,n.lastIndexOf(")")).split(/[,\s/]+/).filter(Boolean).map(d=>d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d));if(r.some(Number.isNaN))return null;if(e.startsWith("rgb")){let[d,u,l,p]=r;return d===void 0||u===void 0||l===void 0?null:{r:d,g:u,b:l,a:p??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...oa(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function Ir(n){let e=n.r/255,t=n.g/255,r=n.b/255,o=Math.max(e,t,r),i=Math.min(e,t,r),s=(o+i)/2;if(o===i)return{h:0,s:0,l:s};let a=o-i,d=a/(1-Math.abs(2*s-1));return{h:((o===e?60*((t-r)/a%6):o===t?60*((r-e)/a+2):60*((e-t)/a+4))+360)%360,s:d,l:s}}function jr(n,e,t){return{...oa(n,e,t),a:1}}function oa(n,e,t){let r=(1-Math.abs(2*t-1))*e,o=(n%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[s,a,d]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],u=t-r/2;return{r:Math.round((s+u)*255),g:Math.round((a+u)*255),b:Math.round((d+u)*255)}}function Ye(n){let e=[];for(let t of n.matchAll(tu)){let r=ou(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=ru(t[0]);r&&e.push(r)}return e}function Dr(n,e){let t=n.a+e.a*(1-n.a);if(t===0)return{r:0,g:0,b:0,a:0};let r=(o,i)=>(o*n.a+i*e.a*(1-n.a))/t;return{r:r(n.r,e.r),g:r(n.g,e.g),b:r(n.b,e.b),a:t}}function Nr(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function ra(n){return .2126*Nr(n.r)+.7152*Nr(n.g)+.0722*Nr(n.b)}function Xe(n,e){let[t,r]=[ra(n),ra(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}var st=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,ia={r:0,g:0,b:0,a:1},at={r:255,g:255,b:255,a:1};function dt(n){let e=Ye(n.accent)[0];if(!e)return{ok:!1,missing:["accent"],why:`"${n.accent}" is not a color this can read. Use a hex, rgb() or hsl() value.`};let t={},r=new Set,o=[],i=Ir(e);for(let s of["dark","light"]){let a=n.base[s],d=Ye(a.ground)[0]??(s==="dark"?ia:at),u=Dr(Ye(a.panel)[0]??at,d),l=du(i,[u,d],s,4.5);l?Math.abs(l.l-i.l)>au&&(r.add(`accent (${s})`),o.push(`reaching 4.5:1 on the ${s} panel would move the accent's lightness by ${Math.round(Math.abs(l.l-i.l)*100)} points, which is far enough that it stops being the same color \u2014 supply one for ${s}`)):(r.add(`accent (${s})`),o.push(`no lightness of this hue clears 4.5:1 as text on the ${s} panel, so ${s} needs an accent of its own`));let p=l??i,c=jr(p.h,p.s,p.l),f=n.accentInk?.[s]??(Xe(at,c)>=Xe(ia,c)?"#ffffff":"#000000"),g=Xe(Ye(f)[0]??at,c);g+.005<4.5&&(r.add(`accentInk (${s})`),o.push(`neither black nor white clears 4.5:1 on the accent (best ${g.toFixed(2)}:1), so text on a filled button has to be given`)),t[s]={...a,accent:st(c,1),accentDim:st(c,s==="dark"?.35:.22),accentInk:f,glow:st(c,s==="dark"?.28:.1),edgeBright:st(c,iu(c,u,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let h=Ye(t[s].warn)[0];h&&su(Ir(h).h,p.h)<25&&(r.add(`warn (${s})`),o.push(`the warning color shares the accent's hue in ${s}, so "something is broken" looks like "this is selected"`))}return r.size>0?{ok:!1,missing:[...r].sort(),why:o.join("; ")}:{ok:!0,schemes:t}}function iu(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(Xe(Dr({...n,a:i},e),e)>=r)return i}return 1}function su(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var au=.3;function du(n,e,t,r){let o=t==="dark";for(let i=0;i<=100;i++){let s=o?n.l+i/100:n.l-i/100,a=o?n.l-i/100:n.l+i/100;for(let d of[s,a])if(!(d<0||d>1)&&e.every(u=>Xe(jr(n.h,n.s,d),u)>=r))return{...n,l:d}}return null}function cu(n,e){let t=e?.[n];if(t!==void 0)return(t%360+360)%360;let r=2166136261;for(let o=0;o<n.length;o++)r^=n.charCodeAt(o),r=Math.imul(r,16777619);return(r>>>0)%360}var Ae=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),Tr="Montserrat",Zr=Object.freeze({display:550,body:450,label:600}),Fr=Object.freeze({display:600,body:400,label:600}),uu="-0.025em",lu=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var sa={ground:"#0a0f1f",groundDeep:"#060914",wash:"none",panel:"rgba(19, 27, 52, 0.96)",panelMuted:"rgba(14, 21, 42, 0.94)",panelWarning:"rgba(48, 33, 18, 0.95)",edge:"rgba(164, 178, 222, 0.18)",edgeBright:"rgba(154, 171, 255, 0.6)",ink:"#eef0f6",inkMuted:"#aab2c6",inkFaint:"#97a0b6",accent:"#9aabff",accentDim:"rgba(154, 171, 255, 0.32)",accentInk:Ae.navy,warn:"#f0a868",good:"#8fdcaa",bad:"#ffa3a3",glow:"rgba(154, 171, 255, 0.18)",bar:"rgba(10, 15, 31, 0.96)",float:"rgba(16, 23, 45, 0.98)",liftLow:"0 14px 36px -22px #000",liftHigh:"0 28px 64px -30px #000",tintAlpha:.2,tintLightness:52,gridAlpha:.35},aa={ground:Ae.paper,groundDeep:"#efefe8",wash:"none",panel:"#ffffff",panelMuted:"#fafaf6",panelWarning:"#fdf4ea",edge:"rgba(24, 33, 58, 0.12)",edgeBright:"rgba(0, 23, 105, 0.6)",ink:Ae.ink,inkMuted:Ae.muted,inkFaint:"#626b7d",accent:Ae.navy,accentDim:"rgba(0, 23, 105, 0.16)",accentInk:"#ffffff",warn:"#9a5312",good:"#1b6436",bad:"#a1232d",glow:"rgba(0, 23, 105, 0.08)",bar:"rgba(255, 255, 255, 0.96)",float:"#ffffff",liftLow:"0 1px 2px rgba(24,33,58,0.06), 0 8px 24px -12px rgba(24,33,58,0.16)",liftHigh:"0 2px 6px rgba(24,33,58,0.08), 0 24px 56px -24px rgba(24,33,58,0.26)",tintAlpha:.16,tintLightness:46,gridAlpha:.5},Qe={dark:sa,light:aa};var be=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),Re=Object.freeze({body:`"${Tr}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function fu(n){let e=n?.shape?.radius??be.radius,t=n?.shape?.density??be.density;return Object.freeze({radius:e,radiusSmall:Math.max(be.radiusSmallFloor,Math.round(e*be.radiusSmall)),pad:Math.round(be.pad*t),padSmall:Math.round(be.padSmall*t),gap:Math.round(be.gap*t)})}function pu(n){let e=n?.typography?.body??Re.body,t=n?.typography?.display??e,o=e===Re.body&&t===Re.body?Zr:Fr,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??Re.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var ub=Object.freeze({light:Object.freeze({roof:Object.freeze({saturation:48,lightness:82}),right:Object.freeze({saturation:40,lightness:66}),left:Object.freeze({saturation:34,lightness:55}),roofEdge:"rgba(255,255,255,0.75)",plot:Object.freeze({saturation:45,lightness:58,alpha:.12}),plotEdge:Object.freeze({saturation:40,lightness:48,alpha:.55})}),dark:Object.freeze({roof:Object.freeze({saturation:42,lightness:32}),right:Object.freeze({saturation:40,lightness:21}),left:Object.freeze({saturation:38,lightness:13}),roofEdge:"rgba(255,255,255,0.14)",plot:Object.freeze({saturation:45,lightness:48,alpha:.2}),plotEdge:Object.freeze({saturation:40,lightness:62,alpha:.55})})});function ca(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var ua="http://www.w3.org/2000/svg",hu=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",ua],gu=new Set("svg g defs symbol use title desc path rect circle ellipse line polyline polygon text tspan textPath linearGradient radialGradient stop pattern clipPath mask marker image filter feBlend feColorMatrix feComponentTransfer feComposite feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feMerge feMergeNode feMorphology feOffset feTile feTurbulence".split(" ")),mu=new Set(["title","desc"]),On="it embeds a page or media",yu={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:On,embed:On,object:On,audio:On,video:On,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},bu={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function xu(n){let e=!1,t=n.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/gi,(r,o)=>{if(o[0]==="#"){let s=o[1]==="x"||o[1]==="X"?parseInt(o.slice(2),16):parseInt(o.slice(1),10);return s>0&&s<=1114111?String.fromCodePoint(s):"\uFFFD"}let i=bu[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function vu(n){if(/\\|@|expression\s*\(|(?:image-set|cross-fade|image|element|src)\s*\(/i.test(n))return!1;for(let[,e]of n.matchAll(/url\s*\(\s*["']?\s*([^)]*)/gi))if(!e.startsWith("#"))return!1;return!0}function wu(n,e,t){let r=xu(t);if(r===null)return"it declares XML entities";let o=(e.includes(":")?e.slice(e.indexOf(":")+1):e).toLowerCase();if(o.startsWith("on"))return"it has an event handler (an on\u2026 attribute)";if(e==="xml:base")return"it loads or links to something outside itself";if(e==="xmlns")return r===ua?null:"it changes what its elements are (another xmlns)";if(e.startsWith("xmlns:"))return hu.includes(r)?"it changes what its elements are (another xmlns)":null;if(o==="href"||o==="src"){let i=r.replace(/[\u0000- ]+/g,"");return i.startsWith("#")||n==="image"&&/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(i)?null:"it loads or links to something outside itself"}return vu(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var da=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function la(n){if(/<!ENTITY/i.test(n))return"it declares XML entities";if(/<!\[CDATA\[/i.test(n))return"it has a CDATA section, which the page and the picture read differently";let e=[],t=!1,r=/^\s*(<\?xml\s[^?<>]*\?>)?/.exec(n)[0].length;for(;r<n.length;){let o=n.slice(r),i=/^[^<]+/.exec(o);if(i){if(e.length===0&&i[0].trim()!=="")return"it is not one SVG: there is text outside it";r+=i[0].length;continue}if(o.startsWith("<!--")){let f=o.indexOf("-->",4);if(f<0)return"it has a comment that never ends";let g=o.slice(4,f);if(/^-?>/.test(g)||g.includes("--")||g.includes("<!")||g.endsWith("-"))return"it has a comment the page and the picture read differently";r+=f+3;continue}if(/^<!DOCTYPE/i.test(o)){let f=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!f||e.length>0||t)return"it declares XML entities";r+=f[0].length;continue}let s=/^<\/([A-Za-z][A-Za-z0-9_.:-]*)\s*>/.exec(o);if(s){if(e.pop()!==s[1])return`it is not one SVG: </${s[1]}> closes what is not open`;e.length===0&&(t=!0),r+=s[0].length;continue}let a=/^<([A-Za-z][A-Za-z0-9_.:-]*)/.exec(o);if(!a)return"it is not one SVG: it has markup a picture cannot hold";let d=a[1],u=yu[d.toLowerCase()];if(u)return u;if(t)return`it is not one SVG: <${d}> comes after it ends`;if(e.length===0&&d!=="svg")return"it is not one SVG";if(d.includes(":"))return`it has an element of another kind (<${d}>)`;if(!gu.has(d))return`it has a <${d}> element, which a picture does not need`;let l=e[e.length-1];if(l&&mu.has(l))return`it has an element inside a <${l}>, which the page reads as HTML`;let p=a[0].length;for(let f=da.exec(o.slice(p));f;f=da.exec(o.slice(p))){let g=wu(d,f[1],f[2]??f[3]??"");if(g)return g;p+=f[0].length}let c=/^\s*(\/?)>/.exec(o.slice(p));if(!c)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(p,p+400))?"it has an event handler (an on\u2026 attribute)":`it is not one SVG: <${d}>'s attributes are not each quoted and apart`;c[1]!=="/"?e.push(d):e.length===0&&(t=!0),r+=p+c[0].length}return e.length>0?`it is not one SVG: <${e[e.length-1]}> is never closed`:t?null:"it is not one SVG"}function fa(n){if(n){if(!ca(n)){if(/^\s*</.test(n))return;let e=/^\s*([a-z][a-z0-9+.-]*):/i.exec(n)?.[1]?.toLowerCase();return e===void 0||e==="http"||e==="https"||e==="data"&&/^\s*data:image\//i.test(n)?n:void 0}return la(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}function ku(n){return fa(n?.favicon)}var pa={"system-sans":'ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"system-serif":'ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif',"system-mono":Re.mono},Su=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],ha=["Georgia","Times New Roman","Times","Iowan Old Style","Palatino","Palatino Linotype","Charter","Cambria","Baskerville","Optima","Helvetica","Helvetica Neue","Arial","Verdana","Segoe UI","Roboto","Avenir","Avenir Next","Gill Sans","Menlo","Monaco","Consolas","SF Mono","SFMono-Regular","Courier New"];var $u=n=>new Set(n.map(e=>e.toLowerCase()));function _u(n){return $u([...Su,...ha]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function Au(n){return pa[n]??n}function yb(n){let e=dt({accent:n,base:Qe});return e.ok||!e.missing.every(t=>t.startsWith("warn"))?e:dt({accent:n,base:Qe,warn:{light:Qe.light.bad,dark:Qe.dark.bad}})}var ee={connectors:{all:{route:"curve",visible:!0},byEdge:{}},captions:{visible:!0},grid:{visible:!0,size:64},lattice:{visible:!0,size:46},tags:{visible:!0},emphasis:{rest:.34,dim:.12},marks:{flag:"\u26A0"}};function Ru(n){return n?{connectors:{all:{...ee.connectors.all,...n.connectors?.all??{}},byEdge:{...ee.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...ee.captions,...n.captions??{}},grid:{...ee.grid,...n.grid??{}},lattice:{...ee.lattice,...n.lattice??{}},tags:{...ee.tags,...n.tags??{}},emphasis:{...ee.emphasis,...n.emphasis??{}},marks:{...ee.marks,...n.marks??{}}}:ee}function Ou(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function Pu(n){return[` --graview-kit-grid: ${n.grid.visible?1:0};`,` --graview-kit-grid-size: ${n.grid.size}px;`,` --graview-kit-lattice: ${n.lattice.visible?1:0};`,` --graview-kit-lattice-size: ${n.lattice.size}px;`,` --graview-kit-tags: ${n.tags.visible?"inline-flex":"none"};`,` --graview-kit-captions: ${n.captions.visible?"block":"none"};`,` --graview-kit-rest: ${n.emphasis.rest};`,` --graview-kit-dim: ${n.emphasis.dim};`,` --graview-kit-flag: "${n.marks.flag.replace(/"/g,"'")}";`].join(`
5
+ `)}function Eu(n,e,t){let r=new Set([e]);for(let[o,i]of t.entries()){let s=n.edge(i);if(!s)return{ok:!1,at:o};let a=s.from,d=s.to==="*"?n.kinds:s.to,u=new Set;for(let l of r){if(a.includes(l))for(let p of d)u.add(p);if(s.to==="*"||d.includes(l))for(let p of a)u.add(p)}if(u.size===0)return{ok:!1,at:o};r=u}return{ok:!0,reached:r}}function zu(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function Cr(n,e,t=2500){return n.held==="socket"?!0:n.until!==void 0?e<Date.parse(n.until):e-Date.parse(n.at)<t}function Mu(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function Nu(n,e,t,r=2500,o){let i=new Map;for(let[s,a]of n)Cr(a,t,r)&&i.set(s,a);for(let s of e){if(!Cr(s,t,r)){i.delete(s.participant);continue}let a=i.get(s.participant);(!a||Date.parse(a.at)<=Date.parse(s.at))&&i.set(s.participant,s)}return o!==void 0&&i.delete(o),i}function Iu(n,e){return!n||!e?n===e:n.participant===e.participant&&n.kind===e.kind&&n.name===e.name&&n.onBehalfOf===e.onBehalfOf&&n.onBehalfOfName===e.onBehalfOfName&&n.until===e.until&&n.held===e.held&&n.hue===e.hue&&n.stop===e.stop&&(n.over??null)===(e.over??null)&&(n.robot?.at??null)===(e.robot?.at??null)&&(n.robot?.mode??null)===(e.robot?.mode??null)}export{Me as a,mi as b,yi as c,dd as d,Ct as e,cn as f,un as g,j as h,qp as i,Hp as j,Fn as k,Jp as l,Yp as m,Xp as n,Lt as o,Qp as p,Ne as q,Cn as r,eh as s,nh as t,th as u,Ai as v,Ri as w,se as x,Ln as y,rh as z,oh as A,I as B,Ad as C,lt as D,ga as E,ju as F,nn as G,ma as H,qr as I,Pe as J,ya as K,ba as L,le as M,xa as N,va as O,wa as P,ka as Q,Sa as R,tn as S,Jr as T,_a as U,pt as V,T as W,Aa as X,U as Y,Ra as Z,rn as _,Oa as $,zn as aa,Mn as ba,ne as ca,Oi as da,Ut as ea,Pi as fa,ln as ga,zi as ha,ig as ia,Yc as ja,ta as ka,Jy as la,Gn as ma,Pd as na,je as oa,Wt as pa,Bn as qa,dg as ra,De as sa,Ie as ta,Zi as ua,Md as va,Er as wa,Y as xa,we as ya,ug as za,qt as Aa,Nd as Ba,O as Ca,hn as Da,C as Ea,Dd as Fa,Vn as Ga,Rg as Ha,Td as Ia,Zd as Ja,Qc as Ka,M as La,L as Ma,ge as Na,me as Oa,Tg as Pa,qi as Qa,Fe as Ra,z as Sa,Ce as Ta,Q as Ua,Bd as Va,Ge as Wa,mc as Xa,yr as Ya,ws as Za,qe as _a,Mm as $a,br as ab,$s as bb,kn as cb,gr as db,Sn as eb,wc as fb,_s as gb,xr as hb,vr as ib,Os as jb,Ms as kb,zr as lb,eu as mb,He as nb,cu as ob,Tr as pb,uu as qb,Qe as rb,Re as sb,fu as tb,pu as ub,ca as vb,la as wb,fa as xb,ku as yb,_u as zb,Au as Ab,yb as Bb,Ru as Cb,Ou as Db,Pu as Eb,Ud as Fb,Kd as Gb,Vd as Hb,Wd as Ib,Ue as Jb,xn as Kb,ae as Lb,Hn as Mb,Ve as Nb,vn as Ob,ur as Pb,wn as Qb,Eu as Rb,Ec as Sb,ys as Tb,zc as Ub,Vs as Vb,Je as Wb,Ar as Xb,Or as Yb,Ic as Zb,de as _b,An as $b,jc as ac,Dc as bc,qs as cc,Tc as dc,Zc as ec,Hs as fc,ot as gc,Ys as hc,Xs as ic,Cc as jc,Lc as kc,Gc as lc,Bc as mc,Qs as nc,Uc as oc,Kc as pc,Vc as qc,Wc as rc,qc as sc,Pr as tc,Hc as uc,Jc as vc,zu as wc,Mu as xc,Nu as yc,Iu as zc};
@@ -0,0 +1 @@
1
+ import{c as b,d as N}from"./chunk.ZS4DJ76C.js";import{a as j,g as Z}from"./chunk.G4WQGTZR.js";import{B as y,Jb as P,Kb as k,La as v,Ma as D,Na as O,db as L,ha as w,hb as M,ib as h,ka as x,pa as A,qa as S,xa as R}from"./chunk.HLLWKSZB.js";var C=n=>n.safeParse?.(void 0).success??!1,I=n=>b(n).shape,F=n=>{let s=b(n);if(y(s)?.type!=="literal")return;let e=y(s)?.values;return e&&e.length===1&&typeof e[0]=="string"?e[0]:void 0};function g(n,s){let e=C(s),o=b(s),i=y(o)?.type,p=L(s);if(p)return{control:"node",name:n,optional:e,kinds:p};if(S(s)){let d=A(n);return{control:"repeat",name:n,optional:e,...d?{of:d}:{}}}if(i==="boolean")return{control:"boolean",name:n,optional:e};let m=w(o);if(m)return{control:"file",name:n,optional:e,...m==="image"?{image:!0}:{}};if(i==="object"){let d=o.shape??{};return{control:"group",name:n,optional:e,fields:Object.entries(d).map(([f,c])=>g(f,c))}}if(i==="union"){let d=y(o)?.options??[],f=d.map(r=>I(r));if(f.every(r=>r!==void 0)){let r=Object.keys(f[0]??{}).find(a=>f.every(l=>F(l?.[a])!==void 0));if(r)return{control:"variant",name:n,optional:e,tag:r,options:d.map((a,l)=>({value:F(f[l]?.[r])??"",fields:Object.entries(f[l]??{}).filter(([u])=>u!==r).map(([u,z])=>g(u,z))}))}}let c=d.map(r=>F(r));return c.every(r=>r!==void 0)?{control:"choice",name:n,optional:e,options:c}:{control:"opaque",name:n,optional:e}}if(i==="array"){let d=y(o)?.element;return d!==void 0?{control:"list",name:n,optional:e,item:g(n,d)}:{control:"opaque",name:n,optional:e}}let t=N(s);return t.type==="text"?{control:"text",name:n,optional:e,...t.long?{long:!0}:{},...x(o)?{app:!0}:{},...j(o)?{markdown:!0}:{},...t.holds?{holds:t.holds}:{}}:t.type==="number"&&t.duration?{control:"text",name:n,optional:e,holds:"duration"}:t.type==="date"?{control:"date",name:n,optional:e,...t.time?{time:!0}:{}}:t.type==="number"?{control:"number",name:n,optional:e,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max},...t.step===void 0?{}:{step:t.step},...t.amount?{amount:t.amount}:{}}:t.type==="choice"?{control:"choice",name:n,optional:e,options:t.options}:{control:"opaque",name:n,optional:e}}function K(n){let s=n.shape;return s?Object.entries(s).map(([e,o])=>g(e,o)):[]}function q(n,s){let e={...s};for(let o of n){let i=s[o.name];i===void 0&&!o.optional&&(o.control==="list"||o.control==="boolean")&&(e[o.name]=o.control==="list"?[]:!1),o.control==="text"&&o.holds&&typeof i=="string"&&(e[o.name]=i.trim()===""?void 0:o.holds==="duration"?Z(i)??i:i.trim()),o.control==="group"&&i!==void 0&&typeof i=="object"&&i!==null&&(e[o.name]=q(o.fields,i))}return e}function T(n,s,e,o){let i=P.keptFrom?.(n,s),p=new Set;if(!i)return p;let m=Object.keys(e.input.shape??{});for(let c of e.creates??[]){let r=i({id:"\0new",kind:c});for(let a of m)r?.(a)&&p.add(a)}let t=o===void 0?void 0:n.graph.getNode(o),d=t&&n.schema.tryDefinition(t.kind),f=t&&i(t);if(d&&f)for(let c of h(e,d))f(c)&&m.includes(c)&&p.add(c);return p}function nn(n,s,e,o){let i=new Set,p=s?.sees??[];if(D(e)||!p.some(k))return i;let m=v(e),t=(r,a)=>{let l=p.filter(u=>u.kinds.includes(r)&&O(u,m));return l.some(k)?a===R||l.some(u=>!k(u)||(u.fields===void 0||u.fields.includes(a))&&!u.hide?.includes(a)):!0},d=Object.keys(o.input.shape??{}),f=new Map,c=(r,a)=>f.set(r,f.get(r)===!0||a);for(let r of o.creates??[]){let a=Object.keys(n.tryDefinition(r)?.fields.shape??{});for(let l of d)a.includes(l)&&c(l,t(r,l))}for(let r of M(n,o)){let a=n.tryDefinition(r);if(a)for(let l of h(o,a))d.includes(l)&&c(l,t(r,l))}for(let[r,a]of f)a||i.add(r);return i}export{K as a,q as b,T as c,nn as d};
@@ -0,0 +1 @@
1
+ import"./chunk.WVUJXDXZ.js";import{i as x}from"./chunk.DAA6XWLF.js";import"./chunk.7DNFXJH3.js";import"./chunk.7PRFYYVM.js";import"./chunk.2NCTM5K2.js";import"./chunk.JU2ZVKMT.js";import"./chunk.G4WQGTZR.js";import"./chunk.HFKMHLJ3.js";import{Aa as N,W as S,ya as f}from"./chunk.HLLWKSZB.js";import"./chunk.AJZBJBMO.js";var k=(n,r,t)=>({untrusted:!0,authoredBy:t.say(r),text:n});function O(n,r){let t;for(let[a,e]of Object.entries(n)){if(typeof e!="string"||a==="id"||a==="kind")continue;let o=r.fieldBy(n.id,a);o&&(t??={...n},t[a]=k(e,o,r))}return t??n}function L(n,r,t){let a=e=>{if(Array.isArray(e))return e.map(a);if(e!==null&&typeof e=="object"&&"id"in e&&"label"in e){let o=e,i=t.recordBy(o.id);return i?{...o,label:k(o.label,i,t)}:o}if(typeof e=="string"){let o=t.recordBy(n);return o?k(e,o,t):e}return e};return Object.fromEntries(Object.entries(r).map(([e,o])=>[e,a(o)]))}function $(n,r){return n.map(t=>{let a=r.recordBy(t.id);return a?{...t,label:k(t.label,a,r)}:t})}function D(n,r){return{...n,nodes:n.nodes.map(t=>O(t,r))}}var E=n=>(JSON.stringify(n)??"null").length,R=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):0;function w(n,r,t,a,e,o=""){let i=n-r-t;return i>0?`and ${i} more ${e}: call ${a} with ${o}offset ${r+t} for the next page.`:void 0}var j=({line:n,...r})=>r;function T(n){let r;for(let[t,a]of Object.entries(n))typeof a!="string"||a.length<=600||(r??={...n},r[t]=`${a.slice(0,600)}\u2026 (cut at ${600} of ${a.length} characters)`);return r??n}function B(n,r,t,a){let e=Math.min(t,Math.max(0,n.length-r)),o=n.slice(r,r+e),i=a(o);for(;e>1&&E(i)>8e3;)e=Math.max(1,Math.floor(e*.75)),o=n.slice(r,r+e),i=a(o);return{page:o,answer:i}}function C(n,r){let t=JSON.stringify(r)??"null";if(t.length<=8e3)return r;let a=`This answer was ${t.length} characters, more than the ${8e3} one read answers, so it is cut. Ask ${n} for less, or use search_graph and get_node to read one thing.`;for(let e=8e3-a.length-40;;){let o={cut:a,partial:t.slice(0,e)},i=E(o)-8e3;if(i<=0)return o;e=Math.max(0,e-i-8)}}function I(n,r){let{matched:t,later:a,...e}=r,o=n.hits.filter(i=>i.about==="node").length;return n.total>o?{...e,more:`and ${n.total-o} more records match: narrow the words, or add kind:<kind>.`}:e}function P(n,r,t){let a=N(t.archived),e={nodes:n.graph.allNodes({archived:a}),edges:n.graph.allEdges({archived:"all"})},o=R(t.offset),i=e.nodes.length,{page:h,answer:u}=B(e.nodes,o,25,d=>{let g=new Set(d.map(s=>s.id)),l=new Set(d.map(s=>s.id)),c=w(i,o,d.length,"get_graph","nodes"),p=s=>l.has(s)||(a==="all"?n.graph.has(s):n.graph.has(s)&&f(n.graph.getNode(s))===a);return{...D({nodes:d.map(T),edges:e.edges.filter(s=>g.has(s.from)&&p(s.to))},r),total:i,...c?{more:c}:{}}});return{data:u,reads:h.map(d=>d.id)}}function U(n,r,t,a){let e=n.graph.getNode(t),o=R(a.offset),i=n.graph.outEdges(t),h=n.graph.inEdges(t),u=i.slice(o,o+20),d=h.slice(o,o+20),g=(s,A)=>{let m=n.graph.getNode(A);return{kind:s,id:A,label:m?S(n.schema.tryDefinition(m.kind),m):A,...f(m)?{archived:!0}:{}}},l=x(n.schema,n.graph,e),c=n.violations().filter(s=>s.nodeIds.includes(t)),p=[w(i.length,o,u.length,"get_node","links out",`id "${t}" and `),w(h.length,o,d.length,"get_node","links in",`id "${t}" and `),c.length>20?`and ${c.length-20} more problems: get_violations lists them.`:void 0].filter(Boolean);return{data:{node:O(T(e),r),...f(e)?{archived:!0}:{},...Object.keys(l.values).length>0?{computed:L(t,l.values,r)}:{},...Object.keys(l.refused).length>0?{uncomputed:l.refused}:{},out:$(u.map(s=>g(s.kind,s.to)),r),in:$(d.map(s=>g(s.kind,s.from)),r),violations:c.slice(0,20).map(j),...p.length>0?{more:p.join(" ")}:{}},reads:[t,...u.map(s=>s.to),...d.map(s=>s.from)]}}function F(n,r){let t=R(r.offset),{page:a,answer:e}=B(n,t,20,o=>{let i=w(n.length,t,o.length,"get_violations","problems");return{violations:o.map(j),total:n.length,...i?{more:i}:{}}});return{data:e,reads:[...new Set(a.flatMap(o=>o.nodeIds))]}}export{P as graphRead,U as nodeRead,I as searchRead,F as violationsRead,C as withinReadChars};
@@ -0,0 +1 @@
1
+ import{F as h,T as d,U as a,W as c,ha as u}from"./chunk.Z56B2JR2.js";import{b as l}from"./chunk.AJZBJBMO.js";var i=l(h(),1);function w(){let e=u();return(0,i.useMemo)(()=>[...new Set(e.flatMap(o=>o.nodeIds))],[e])}function S(){let e=g(),o=d();return(0,i.useMemo)(()=>{if(!o)return e;let n=o.matched;return n.length===0&&e.length===0?[m]:[...new Set([...e,...n])]},[o,e])}function g(){let{store:e,selection:o}=a(),n=c();return(0,i.useMemo)(()=>{if(o.length===0)return[];let r=new Set(o),s=new Set(r);for(let t of e.graph.allEdges())r.has(t.from)&&s.add(t.to),r.has(t.to)&&s.add(t.from);for(let t of e.violations())if(t.subjectId!==void 0&&r.has(t.subjectId))for(let f of t.nodeIds)s.add(f);return[...s]},[e,o,n])}var m="search:nothing";export{w as a,S as b,g as c};
@@ -0,0 +1,17 @@
1
+ import{a as j,b as D}from"./chunk.GZH6PTXN.js";import"./chunk.OWE6OJ4P.js";import"./chunk.3JM2TNDD.js";import"./chunk.COTG2IG5.js";import{a as I}from"./chunk.VPPUTA74.js";import"./chunk.UT6642FC.js";import{a as k,b as V}from"./chunk.MB7LKKUD.js";import"./chunk.DAA6XWLF.js";import"./chunk.7DNFXJH3.js";import"./chunk.7PRFYYVM.js";import"./chunk.2NCTM5K2.js";import"./chunk.JU2ZVKMT.js";import"./chunk.HGAMNIST.js";import"./chunk.ZS4DJ76C.js";import"./chunk.5R66YTET.js";import"./chunk.G4WQGTZR.js";import"./chunk.HFKMHLJ3.js";import"./chunk.GS4T26WW.js";import{F as Q,M as H,ma as x}from"./chunk.Z56B2JR2.js";import{Hb as q,Z as B}from"./chunk.HLLWKSZB.js";import{b}from"./chunk.AJZBJBMO.js";var t=b(Q(),1);var a=b(H(),1);function U(r){let n=[];return r.applied.length>0&&r.intent&&n.push(`${r.intent}.`),r.unchanged.length>0&&n.push(`${r.unchanged.length} already so.`),r.allOrNothing&&n.push("None of it was kept."),n.join(" ")}function ie({store:r,chosen:n,principal:d,context:v,via:S,anchor:E,of:g,onChooseAll:A,onClear:p,onActed:F}){let[K,W]=(0,t.useState)(0);(0,t.useEffect)(()=>r.subscribe(()=>W(e=>e+1)),[r]);let m=n.join(`
2
+ `),{acts:h,withheld:N}=(0,t.useMemo)(()=>j(r,n,{...d?{principal:d}:{},...v?{context:v}:{}}),[r,m,d,v,K]),[L,u]=(0,t.useState)(!1),[l,c]=(0,t.useState)(null),[s,O]=(0,t.useState)(null),w=(0,t.useRef)(null),M=(0,t.useId)(),f=(0,t.useMemo)(()=>[...new Set(n.map(e=>r.graph.getNode(e)?.kind))],[r,m]),_=f.length===1&&f[0]?`${B(r.schema,f[0],n.length)} chosen`:`${n.length} chosen`,P=typeof matchMedia=="function"&&matchMedia("(pointer: coarse), (max-width: 599px)").matches?2:3,C=h.filter(e=>!e.more),G=C.slice(0,P),T=[...C.slice(P),...h.filter(e=>e.more)];(0,t.useEffect)(()=>{c(null),u(!1)},[m]),(0,t.useLayoutEffect)(()=>{let e=w.current;if(!e)return;if(typeof e.showPopover=="function"&&!x(e))try{e.showPopover()}catch{}let i=()=>{V(e,E?.()??null),dispatchEvent(new Event(k))};i(),addEventListener("resize",i),addEventListener("scroll",i,!0);let o=typeof ResizeObserver=="function"?new ResizeObserver(i):null;return o?.observe(e),()=>{if(o?.disconnect(),removeEventListener("resize",i),removeEventListener("scroll",i,!0),e.isConnected&&x(e))try{e.hidePopover()}catch{}dispatchEvent(new Event(k))}},[E]);let y=(0,t.useRef)({asking:l,onClear:p});y.current={asking:l,onClear:p},(0,t.useEffect)(()=>{let e=i=>{if(i.key!=="Escape"||i.defaultPrevented)return;let o=document.activeElement;if(!(!(w.current?.contains(o)??!1)&&(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement&&o.type!=="checkbox"||o instanceof HTMLSelectElement))){if(i.preventDefault(),i.stopPropagation(),y.current.asking){c(null);return}y.current.onClear()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let R=(e,i={})=>{let o=D(r,{mutation:e.mutation,subject:e.subject,args:{...e.args,...i},label:e.label},n,{...d?{author:d}:{},...S?{via:S}:{},...v?{context:v}:{}});c(null),u(!1),O(o.refused.length>0||o.applied.length===0?o:null),F(o.refused.map(z=>z.id))},J=e=>{O(null),u(!1),e.open.length>0?c(e):R(e)},$=e=>(0,a.jsxs)("button",{type:"button",className:"graview-several-act","data-testid":"several-act","data-act":e.id,"data-mutation":e.mutation,...e.destructive?{"data-tone":"warn"}:{},"aria-pressed":l?.id===e.id?!0:void 0,onClick:()=>J(e),children:[e.label,e.open.length>0?"\u2026":""]},e.id);return(0,a.jsxs)("div",{ref:w,popover:"manual",role:"region","aria-label":"The chosen records",className:"graview-several-bar","data-testid":"several-bar","data-graview-foot":"","data-graview-overlay":"","data-graview-popover":"","data-graview-offstage":"",style:X,children:[(0,a.jsx)("style",{children:Y}),(0,a.jsxs)("div",{className:"graview-several-line",children:[(0,a.jsx)("span",{role:"status","aria-live":"polite",className:"graview-several-count","data-testid":"several-count",children:_}),(0,a.jsxs)("div",{role:"group","aria-label":`What to do with the ${n.length} chosen`,className:"graview-several-acts",children:[G.map($),T.length>0?(0,a.jsx)("button",{type:"button",className:"graview-several-act","data-testid":"several-more","aria-expanded":L,"aria-controls":M,onClick:()=>u(e=>!e),children:"More"}):null,A&&g!==void 0&&g>n.length?(0,a.jsxs)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-all",onClick:A,children:["Choose all ",g]}):null,(0,a.jsx)("button",{type:"button",className:"graview-several-quiet","data-testid":"several-clear","aria-keyshortcuts":"Escape",title:"Put the choice down \u2014 Escape",onClick:p,children:"Clear"})]})]}),L?(0,a.jsx)("div",{id:M,role:"group","aria-label":"More",className:"graview-several-acts","data-testid":"several-more-acts",children:T.map($)}):null,h.length===0?(0,a.jsx)("p",{className:"graview-several-said","data-testid":"several-none",children:N.length>0?`Nothing here can be done to all of them by you: ${N[0].message}`:"Nothing can be done to all of these at once."}):null,l?(0,a.jsx)("div",{className:"graview-several-ask",role:"group","aria-label":`${l.label}, for all ${n.length}`,"data-testid":"several-ask",children:(0,a.jsx)(I,{store:r,affordance:l.affordance,onApply:e=>R(l,e),onCancel:()=>c(null)})}):null,s?(0,a.jsxs)("div",{role:"alert",className:"graview-several-said","data-testid":"several-outcome",children:[U(s),s.refused.length>0?(0,a.jsxs)(a.Fragment,{children:[" ",s.refused.length===1?"One was not changed, and is still chosen:":`${s.refused.length} were not changed, and are still chosen:`,(0,a.jsx)("ul",{"data-testid":"several-refused",children:s.refused.map(e=>(0,a.jsxs)("li",{"data-record":e.id,children:["\u201C",e.label,"\u201D \u2014 ",e.message]},e.id))})]}):null]}):null]})}var X={position:"fixed",inset:"auto",margin:0,zIndex:q("toast"),boxSizing:"border-box",width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,overflow:"visible"},Y=`
3
+ .graview-several-bar{display:grid;gap:8px;padding:8px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-float);color:var(--graview-ink);box-shadow:var(--graview-lift-high);font-size:.875rem;line-height:1.4;max-height:70vh;overflow:auto}
4
+ .graview-several-line{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-width:0}
5
+ .graview-several-count{font-weight:600;white-space:nowrap}
6
+ .graview-several-acts{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-width:0}
7
+ .graview-several-act,.graview-several-quiet{min-height:32px;padding:0 12px;border-radius:8px;font:inherit;cursor:pointer;box-shadow:none}
8
+ .graview-several-act{border:1px solid var(--graview-edge);background:transparent;color:var(--graview-ink);font-weight:600}
9
+ .graview-several-act:hover,.graview-several-act[aria-pressed=true],.graview-several-act[aria-expanded=true]{background:color-mix(in srgb,var(--graview-accent) 14%,transparent)}
10
+ .graview-several-act[data-tone=warn]{color:var(--graview-warn)}
11
+ .graview-several-quiet{border:0;background:none;color:var(--graview-ink-muted);text-decoration:underline;text-underline-offset:2px}
12
+ .graview-several-bar :focus-visible{outline:2px solid var(--graview-accent);outline-offset:2px}
13
+ .graview-several-said{margin:0;max-width:52ch;overflow-wrap:anywhere}
14
+ .graview-several-said ul{margin:4px 0 0;padding-left:18px}
15
+ .graview-several-ask{padding:8px 4px 2px;border-top:1px solid var(--graview-edge)}
16
+ @media (pointer: coarse){.graview-several-act,.graview-several-quiet{min-height:44px}}
17
+ `;export{ie as SeveralBar};
@@ -0,0 +1 @@
1
+ import{b as m}from"./chunk.RCLJ4H52.js";import"./chunk.ZEVVWWNA.js";import"./chunk.MOUGB4H6.js";import"./chunk.ONDILMIX.js";import{f as g}from"./chunk.UIIVEQAT.js";import"./chunk.GDA3G4U2.js";import"./chunk.OWE6OJ4P.js";import"./chunk.BKPGDEES.js";import"./chunk.JNGUSAWX.js";import"./chunk.CK7QWLMX.js";import"./chunk.QNHECGMH.js";import"./chunk.KZ2376BD.js";import"./chunk.IZW7DBK4.js";import"./chunk.RKRSRKF3.js";import"./chunk.KC6UZHBM.js";import"./chunk.HONUT6OG.js";import"./chunk.T4LY5QXO.js";import"./chunk.N4FBDA2W.js";import"./chunk.UT6642FC.js";import"./chunk.3G5MQFZK.js";import"./chunk.2CLPRG3I.js";import"./chunk.MB7LKKUD.js";import"./chunk.O42YET3W.js";import"./chunk.Z5V23DQN.js";import"./chunk.OHE5AMHH.js";import"./chunk.OYJSFO3A.js";import"./chunk.HV6I74DF.js";import"./chunk.WVUJXDXZ.js";import"./chunk.DAA6XWLF.js";import"./chunk.7DNFXJH3.js";import"./chunk.7PRFYYVM.js";import"./chunk.2NCTM5K2.js";import"./chunk.JU2ZVKMT.js";import"./chunk.HGAMNIST.js";import"./chunk.OQDETV4X.js";import"./chunk.ZS4DJ76C.js";import"./chunk.5R66YTET.js";import"./chunk.G4WQGTZR.js";import"./chunk.HFKMHLJ3.js";import"./chunk.GS4T26WW.js";import{F as b,M as l}from"./chunk.Z56B2JR2.js";import{tc as n}from"./chunk.HLLWKSZB.js";import{b as t}from"./chunk.AJZBJBMO.js";var y=t(b(),1),a=t(l(),1);function P({store:h,auto:c,brand:r,views:f,presence:i,steering:o,overview:s,scope:d,titleLevel:v=2,props:e}){let u=(0,y.useMemo)(()=>g({scope:`.${d}`}),[d]);return(0,a.jsxs)("div",{"data-embed-content":"",style:c?{flex:"0 0 auto",background:"var(--graview-ground)"}:{flex:"1 1 auto",minHeight:0,overflow:"auto",background:"var(--graview-ground)"},children:[(0,a.jsx)("style",{children:u}),(0,a.jsx)("div",{"data-embed-measure":"",style:{display:"flow-root"},children:(0,a.jsx)(m,{context:{store:h,embedded:!0,...e.bar!==!1?{barAbove:!0}:{},...s?{overview:s}:{},titleLevel:v,views:f,settings:e.app.settings??[],...i?{presence:i}:{},...r?{brand:r}:{},...e.locale?{locale:e.locale}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}},...e.pages?{registry:e.pages}:{},...o?{steering:o}:{},...e.routing==="address"?n(e.basePath)===""?{}:{basename:n(e.basePath)}:{initialPath:e.path??"/"},...e.path!==void 0?{path:e.path}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{}})})]})}export{P as PagesContent};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk.RKRSRKF3.js";import{l as i}from"./chunk.Z56B2JR2.js";import{fc as o}from"./chunk.HLLWKSZB.js";function p(t){let r=t.within??{};return o({...r.sort?{sort:r.sort}:{},...r.filter?{filter:r.filter}:{},...r.group?{group:r.group}:{},...r.q?{q:r.q}:{},...r.archived?{archived:r.archived}:{}})}function c(t,r){let m=a(r),e=t;for(let n of["sort","filter","group","q","archived"])e=i(e,n,m[n]??null);return e}export{p as a,c as b};
@@ -0,0 +1,10 @@
1
+ import"./chunk.GS4T26WW.js";import{M as o,U as n}from"./chunk.Z56B2JR2.js";import"./chunk.HLLWKSZB.js";import{b as t}from"./chunk.AJZBJBMO.js";var a=t(o(),1),d=[["waiting","Waiting"],["active","Under way: darker and taller"],["done","Done: flat and pale"],["flagged","A problem, or past its due date"],["recent","Changed since you were last here"],["own","Yours"]],g=i=>{let e=r=>`color-mix(in oklab,var(--graview-ink) ${r}%,var(--graview-panel))`;return`.graview-map-key{display:grid;gap:4px;padding:2px 4px 8px;margin-bottom:6px;border-bottom:1px solid var(--graview-edge);font-size:.8125rem;color:var(--graview-ink-muted)}
2
+ .graview-map-key>div{display:flex;align-items:center;gap:8px}
3
+ .graview-map-key>div:first-child{color:var(--graview-ink)}
4
+ .graview-map-key i{flex:none;width:14px;height:10px;border-radius:2px;background:${e(i?34:42)}}
5
+ .graview-map-key i[data-graview-mark=active]{height:14px;background:${e(70)}}
6
+ .graview-map-key i[data-graview-mark=done]{height:4px;background:${e(i?13:18)}}
7
+ .graview-map-key i[data-graview-mark=flagged]{background:var(--graview-warn)}
8
+ .graview-map-key i[data-graview-mark=recent]{box-shadow:0 0 3px 1px color-mix(in oklab,var(--graview-accent) 70%,transparent)}
9
+ .graview-map-key i[data-graview-mark=own]{outline:1.4px solid var(--graview-ink)}
10
+ .graview-map-key i[data-graview-mark=more]{width:auto;height:auto;background:none;font-size:.6875rem;font-style:normal}`};function m(){let{scheme:i}=n();return(0,a.jsxs)("div",{className:"graview-map-key","data-testid":"map-key",children:[(0,a.jsx)("style",{children:g(i==="light")}),(0,a.jsx)("div",{children:"The map: a block is a record, in a row by its status"}),d.map(([e,r])=>(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{"data-graview-mark":e,"aria-hidden":"true"}),r]},e)),(0,a.jsxs)("div",{children:[(0,a.jsx)("i",{"data-graview-mark":"more","aria-hidden":"true",children:"+3"}),"More in that row than its plot holds"]})]})}export{m as MapKey};
@@ -0,0 +1,70 @@
1
+ import{Gb as e}from"./chunk.HLLWKSZB.js";var a=`
2
+ .graview-spec{display:flex;flex-direction:column;gap:6px;min-width:0;color:var(--graview-ink)}
3
+
4
+ .graview-spec-row{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px 10px;box-sizing:border-box;max-width:100%;padding:5px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius-sm,8px);background:var(--graview-panel);font-size:.875rem}
5
+ .graview-spec-row[data-selected]{border-color:var(--graview-accent)}
6
+ .graview-spec-row>*{flex:0 0 auto;min-width:0;max-width:100%}
7
+ .graview-spec-row>.graview-spec-title,.graview-spec-row>.graview-spec-text{flex:1 1 9rem;overflow-wrap:anywhere}
8
+ .graview-spec-row>.graview-spec-title{font-size:.9375rem}
9
+ .graview-spec-row>.graview-spec-progress{grid-template-columns:auto minmax(3rem,5rem) auto;align-items:center;column-gap:6px}
10
+ .graview-spec-list[data-as="row"] .graview-spec-row{border-width:0 0 1px;border-radius:0;background:transparent;padding:6px 2px}
11
+ [data-graview-rows] .graview-spec-row{border-width:0;border-radius:0;background:transparent;padding:2px 0}
12
+ [data-graview-rows] .graview-spec-row>.graview-spec-title{font-size:var(--graview-text-body);font-weight:500}
13
+ .graview-spec-page{padding-bottom:14px;margin-bottom:14px;border-bottom:1px solid var(--graview-edge)}
14
+ .graview-spec-title{font-family:var(--graview-font-display,inherit);font-weight:600;font-size:1rem;line-height:1.3;overflow-wrap:anywhere}
15
+ .graview-spec-text{margin:0;font-size:.875rem;line-height:1.45;overflow-wrap:anywhere}
16
+ .graview-spec-text[data-graview-tone]{color:var(--graview-spec-tone)}
17
+
18
+ .graview-spec-badge{align-self:flex-start;display:inline-block;max-width:100%;box-sizing:border-box;padding:1px 8px;border:1px solid currentColor;border-radius:999px;background:var(--graview-panel);color:var(--graview-spec-tone,var(--graview-ink-muted));font-size:.8125rem;font-weight:600;line-height:1.5;overflow-wrap:anywhere}
19
+ .graview-spec-row .graview-spec-badge,.graview-spec-group[data-direction="row"] .graview-spec-badge{align-self:center}
20
+ .graview-spec [data-graview-tone="good"]{--graview-spec-tone:var(--graview-good)}
21
+ .graview-spec [data-graview-tone="bad"]{--graview-spec-tone:var(--graview-bad)}
22
+ .graview-spec [data-graview-tone="warn"]{--graview-spec-tone:var(--graview-warn)}
23
+ .graview-spec [data-graview-tone="accent"]{--graview-spec-tone:var(--graview-accent)}
24
+ .graview-spec [data-graview-tone="neutral"]{--graview-spec-tone:var(--graview-ink-muted)}
25
+ .graview-spec-field{display:flex;flex-wrap:wrap;gap:2px 8px;align-items:baseline;min-width:0;font-size:.875rem;line-height:1.4}
26
+ .graview-spec-label{color:var(--graview-ink-muted)}
27
+ .graview-spec-value{min-width:0;color:var(--graview-ink);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
28
+ .graview-spec-link { position: relative; z-index: ${e.raised}; color: var(--graview-accent); text-decoration: underline; display: inline-flex; align-items: center; min-height: 24px; }
29
+ .graview-spec-progress{display:grid;gap:4px;font-size:.8125rem}
30
+ .graview-spec-progress>.graview-spec-label,.graview-spec-progress>.graview-spec-value{white-space:nowrap}
31
+ .graview-spec-track{display:block;height:6px;border-radius:999px;background:var(--graview-edge);overflow:hidden}
32
+ .graview-spec-fill{display:block;height:100%;background:var(--graview-accent)}
33
+ .graview-spec-group{display:flex;flex-direction:column;gap:6px;min-width:0}
34
+ .graview-spec-group[data-direction="row"]{flex-direction:row;flex-wrap:wrap;align-items:center;gap:6px 10px}
35
+ .graview-spec-row .graview-spec-group{flex:1 1 9rem}
36
+ .graview-spec-divider{width:100%;margin:2px 0;border:0;border-top:1px solid var(--graview-edge)}
37
+ .graview-spec-figure{display:inline-flex;width:22px;height:22px}
38
+ .graview-spec-row[data-graview-tall]{flex-direction:column;flex-wrap:nowrap;align-items:stretch;border-radius:10px;padding:8px 12px}
39
+ .graview-spec-row[data-graview-tall] .graview-spec-badge{align-self:flex-start}
40
+ .graview-spec-home,.graview-spec-place{gap:14px}
41
+ .graview-spec-headline{margin:0;font-family:var(--graview-font-display,inherit);font-weight:600;letter-spacing:-0.01em;line-height:1.15;overflow-wrap:anywhere;font-size:1.125rem}
42
+ .graview-spec-headline[data-level="1"]{font-size:clamp(1.75rem,5vw,2.75rem);line-height:1.05;text-wrap:balance}
43
+ .graview-spec-headline[data-level="2"]{font-size:clamp(1.25rem,3vw,1.625rem);margin-top:8px}
44
+ .graview-spec-number{display:grid;gap:2px;justify-items:start}
45
+ .graview-spec-number-value{font-family:var(--graview-font-display,inherit);font-weight:600;font-size:1.75rem;line-height:1.05;letter-spacing:-0.015em;font-variant-numeric:tabular-nums}
46
+ .graview-spec-card .graview-spec-number-value,.graview-spec-row .graview-spec-number-value{font-size:1.25rem}
47
+ .graview-spec-number .graview-spec-label{font-size:.8125rem}
48
+ .graview-spec-listing { display: grid; gap: 10px; min-width: 0; position: relative; z-index: ${e.raised}; }
49
+ .graview-spec-list-group{display:grid;gap:8px;min-width:0}
50
+ .graview-spec-list-heading{margin:6px 0 0;font-family:var(--graview-font-display,inherit);font-size:1rem;font-weight:600;padding-bottom:4px;border-bottom:1px solid var(--graview-edge-bright,var(--graview-edge))}
51
+ .graview-spec-list{list-style:none;margin:0;padding:0;display:grid;gap:6px;min-width:0}
52
+
53
+ .graview-spec-list[data-as="card"]{grid-template-columns:repeat(auto-fill,minmax(min(100%,15rem),1fr));gap:10px;align-items:start}
54
+ .graview-spec-list[data-as="names"]{display:flex;flex-wrap:wrap;gap:4px 12px}
55
+ .graview-spec-item{position:relative;min-width:0}
56
+ .graview-spec-item-name{font-size:.875rem;font-weight:600}
57
+ .graview-spec-item-link{all:unset;position:absolute;inset:0;min-height:24px;border-radius:10px;cursor:pointer}
58
+ .graview-spec-item-link:hover{background:color-mix(in srgb,var(--graview-accent) 6%,transparent)}
59
+ .graview-spec-item-link:focus-visible{outline:2px solid var(--graview-accent);outline-offset:2px}
60
+ .graview-spec-item .graview-spec-listing { z-index: ${e.raised}; }
61
+ .graview-spec-empty,.graview-spec-more{color:var(--graview-ink-muted)}
62
+ .graview-spec-see-all{position:static;font-weight:600}
63
+
64
+ .graview-spec-card .graview-spec-text,.graview-spec-card .graview-spec-value{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow:hidden;max-height:4.35em}
65
+ .graview-spec-row .graview-spec-text,.graview-spec-row .graview-spec-value{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;line-clamp:1;overflow:hidden;max-height:1.45em}
66
+ .graview-spec-card .graview-spec-text>*,.graview-spec-row .graview-spec-text>*{margin-block:0}
67
+ .graview-spec-row .graview-spec-value,.graview-spec-row .graview-spec-text{white-space:normal !important}
68
+
69
+ .graview-spec-progress>.graview-spec-value{display:inline;-webkit-line-clamp:none;line-clamp:none;max-height:none;overflow:visible;white-space:nowrap !important}
70
+ `;export{a};