graview 0.1.28 → 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.
- package/dist/preview/chunk.2643W7FT.js +1 -0
- package/dist/preview/chunk.2CLPRG3I.js +1 -0
- package/dist/preview/chunk.2IZFIORK.js +1 -0
- package/dist/preview/chunk.2NCTM5K2.js +2 -0
- package/dist/preview/{chunk.EYF6ONTA.js → chunk.3G5MQFZK.js} +1 -1
- package/dist/preview/chunk.3JM2TNDD.js +2 -0
- package/dist/preview/chunk.44FVJOK4.js +28 -0
- package/dist/preview/chunk.4GGAPOMK.js +2 -0
- package/dist/preview/chunk.5AT4O4BN.js +1 -0
- package/dist/preview/chunk.5JXUAMKI.js +1 -0
- package/dist/preview/chunk.5R66YTET.js +2 -0
- package/dist/preview/chunk.64P76WK4.js +1 -0
- package/dist/preview/chunk.7D77HEIJ.js +1 -0
- package/dist/preview/chunk.7DNFXJH3.js +1 -0
- package/dist/preview/{chunk.SBHVVJY7.js → chunk.7PRFYYVM.js} +1 -1
- package/dist/preview/chunk.AE5GKL4C.js +1 -0
- package/dist/preview/chunk.ARR75WBP.js +35 -0
- package/dist/preview/chunk.AVUS5LMG.js +3 -0
- package/dist/preview/chunk.BKPGDEES.js +1 -0
- package/dist/preview/chunk.BZ5OJYHU.js +1 -0
- package/dist/preview/chunk.CK7QWLMX.js +1 -0
- package/dist/preview/chunk.COTG2IG5.js +1 -0
- package/dist/preview/chunk.D4GOVA25.js +1 -0
- package/dist/preview/chunk.DAA6XWLF.js +1 -0
- package/dist/preview/chunk.DKTCRFMS.js +1 -0
- package/dist/preview/chunk.DLGTFXGM.js +1 -0
- package/dist/preview/chunk.DN7SN6ZR.js +1 -0
- package/dist/preview/chunk.G4WQGTZR.js +3 -0
- package/dist/preview/chunk.GDA3G4U2.js +6 -0
- package/dist/preview/chunk.GS4T26WW.js +328 -0
- package/dist/preview/chunk.GZH6PTXN.js +1 -0
- package/dist/preview/chunk.HFKMHLJ3.js +1 -0
- package/dist/preview/chunk.HGAMNIST.js +1 -0
- package/dist/preview/chunk.HJCQ6I3S.js +1 -0
- package/dist/preview/chunk.HKBKH7EK.js +1 -0
- package/dist/preview/chunk.HLLWKSZB.js +5 -0
- package/dist/preview/chunk.HONUT6OG.js +1 -0
- package/dist/preview/chunk.HRWLR7T4.js +1 -0
- package/dist/preview/chunk.HV6I74DF.js +1 -0
- package/dist/preview/chunk.IPBXAAQV.js +17 -0
- package/dist/preview/chunk.IWYUFYDJ.js +1 -0
- package/dist/preview/chunk.IZW7DBK4.js +1 -0
- package/dist/preview/chunk.J46KDTEZ.js +10 -0
- package/dist/preview/chunk.JNGUSAWX.js +70 -0
- package/dist/preview/chunk.JU2ZVKMT.js +2 -0
- package/dist/preview/chunk.K4ZUVH2G.js +1 -0
- package/dist/preview/chunk.KC6UZHBM.js +1 -0
- package/dist/preview/chunk.KLITC55P.js +1 -0
- package/dist/preview/chunk.KZ2376BD.js +19 -0
- package/dist/preview/chunk.LYJAVUST.js +1 -0
- package/dist/preview/chunk.MB7LKKUD.js +1 -0
- package/dist/preview/chunk.MOUGB4H6.js +1 -0
- package/dist/preview/chunk.MYFWM572.js +1 -0
- package/dist/preview/chunk.N4FBDA2W.js +1 -0
- package/dist/preview/chunk.O42YET3W.js +1 -0
- package/dist/preview/chunk.O4QPITBD.js +9 -0
- package/dist/preview/{chunk.5BGA2VUS.js → chunk.OGXE2RHC.js} +4 -4
- package/dist/preview/chunk.OHE5AMHH.js +0 -0
- package/dist/preview/chunk.ONGVH3ZM.js +1076 -0
- package/dist/preview/chunk.OQDETV4X.js +1 -0
- package/dist/preview/chunk.OWBEV6FR.js +1 -0
- package/dist/preview/chunk.OWE6OJ4P.js +1 -0
- package/dist/preview/chunk.OYJSFO3A.js +1 -0
- package/dist/preview/chunk.P62SKNJS.js +27 -0
- package/dist/preview/chunk.PA5HYAEO.js +1 -0
- package/dist/preview/{chunk.IDI2BQ7Y.js → chunk.PMEDLEZY.js} +2 -2
- package/dist/preview/chunk.PTXQHHKF.js +1 -0
- package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
- package/dist/preview/chunk.QNHECGMH.js +1 -0
- package/dist/preview/chunk.QSDT2RLY.js +1 -0
- package/dist/preview/chunk.R2D373VG.js +1 -0
- package/dist/preview/chunk.RB4RTBRZ.js +1 -0
- package/dist/preview/chunk.RCLJ4H52.js +116 -0
- package/dist/preview/chunk.RKRSRKF3.js +1 -0
- package/dist/preview/chunk.RWGLKDWH.js +1 -0
- package/dist/preview/chunk.SIL4KD3K.js +1 -0
- package/dist/preview/chunk.SS76EIMI.js +1 -0
- package/dist/preview/{chunk.IKT7JQUW.js → chunk.T4LY5QXO.js} +1 -1
- package/dist/preview/chunk.UIIVEQAT.js +1 -0
- package/dist/preview/chunk.UT6642FC.js +1 -0
- package/dist/preview/chunk.UTHHX2TJ.js +1 -0
- package/dist/preview/chunk.UWNYT7PF.js +1 -0
- package/dist/preview/chunk.V6TK4LHW.js +6 -0
- package/dist/preview/chunk.VNBO2RXD.js +1 -0
- package/dist/preview/chunk.VPPUTA74.js +1 -0
- package/dist/preview/chunk.WKXNBHTL.js +4 -0
- package/dist/preview/chunk.WLRTPFAC.js +1 -0
- package/dist/preview/chunk.X53HI436.js +1 -0
- package/dist/preview/chunk.XAXJHEMD.js +1 -0
- package/dist/preview/chunk.XDYAG276.js +1 -0
- package/dist/preview/chunk.XDZSTIS6.js +88 -0
- package/dist/preview/chunk.XXHNV24G.js +1 -0
- package/dist/preview/chunk.YCA7P5MK.js +1 -0
- package/dist/preview/chunk.YRQZZH5V.js +1 -0
- package/dist/preview/chunk.YUWRZWGX.js +1 -0
- package/dist/preview/chunk.Z2RGLFLS.js +1 -0
- package/dist/preview/chunk.Z56B2JR2.js +25 -0
- package/dist/preview/chunk.Z5V23DQN.js +3 -0
- package/dist/preview/chunk.ZBXOX3W3.js +1 -0
- package/dist/preview/chunk.ZEGSQCSD.js +1 -0
- package/dist/preview/chunk.ZEVVWWNA.js +44 -0
- package/dist/preview/chunk.ZS4DJ76C.js +1 -0
- package/dist/preview/chunk.ZSKP6UQS.js +3 -0
- package/dist/preview/page.js +6 -6
- package/package.json +6 -6
- package/dist/preview/chunk.22H4JXTH.js +0 -8
- package/dist/preview/chunk.25OYH6MY.js +0 -1
- package/dist/preview/chunk.2GBQJXJH.js +0 -19
- package/dist/preview/chunk.2VUG6EAN.js +0 -1
- package/dist/preview/chunk.337WDTG3.js +0 -2
- package/dist/preview/chunk.3HLLQ5CJ.js +0 -1
- package/dist/preview/chunk.46KUPBQC.js +0 -1
- package/dist/preview/chunk.4H7CQE56.js +0 -1
- package/dist/preview/chunk.4HGBVU5B.js +0 -1
- package/dist/preview/chunk.4RO5DA22.js +0 -1
- package/dist/preview/chunk.4TUNX4WM.js +0 -29
- package/dist/preview/chunk.6LJ66MB7.js +0 -1
- package/dist/preview/chunk.6R4EI47C.js +0 -1
- package/dist/preview/chunk.7S22MBNN.js +0 -1
- package/dist/preview/chunk.A73BXXE4.js +0 -3
- package/dist/preview/chunk.AHDOKM4O.js +0 -1
- package/dist/preview/chunk.ARE3MEDN.js +0 -1
- package/dist/preview/chunk.ASFZTYFO.js +0 -1
- package/dist/preview/chunk.BBJZ6O7J.js +0 -1
- package/dist/preview/chunk.BCBH6WJF.js +0 -1
- package/dist/preview/chunk.CAZAB352.js +0 -1
- package/dist/preview/chunk.CY7MDLRS.js +0 -1
- package/dist/preview/chunk.DAVRLRGB.js +0 -1
- package/dist/preview/chunk.DCIC3YHX.js +0 -1
- package/dist/preview/chunk.EW4JFOJY.js +0 -1
- package/dist/preview/chunk.FP27W5MU.js +0 -1
- package/dist/preview/chunk.G2OOBROL.js +0 -1040
- package/dist/preview/chunk.GCKSQ52O.js +0 -1
- package/dist/preview/chunk.GE5EAN36.js +0 -2
- package/dist/preview/chunk.HOPIZMJR.js +0 -2
- package/dist/preview/chunk.IBGO4BUF.js +0 -1
- package/dist/preview/chunk.IH42QTOM.js +0 -1
- package/dist/preview/chunk.ISRS7GOT.js +0 -321
- package/dist/preview/chunk.J6CBMLGR.js +0 -1
- package/dist/preview/chunk.JRCV6HVV.js +0 -1
- package/dist/preview/chunk.KWW3YHQ4.js +0 -23
- package/dist/preview/chunk.MKNXV4TM.js +0 -8
- package/dist/preview/chunk.MRK6QJV5.js +0 -25
- package/dist/preview/chunk.MVNIKZIC.js +0 -1
- package/dist/preview/chunk.N2WTNKEV.js +0 -1
- package/dist/preview/chunk.N7HCALRK.js +0 -61
- package/dist/preview/chunk.NRRUGG22.js +0 -1
- package/dist/preview/chunk.OGL4PHTY.js +0 -1
- package/dist/preview/chunk.PFQFPJ5L.js +0 -16
- package/dist/preview/chunk.PN2H6X7O.js +0 -1
- package/dist/preview/chunk.PWHJHFC4.js +0 -1
- package/dist/preview/chunk.Q3HVA6L4.js +0 -1
- package/dist/preview/chunk.RZLNDVGN.js +0 -107
- package/dist/preview/chunk.SNBIZ3B6.js +0 -1
- package/dist/preview/chunk.TBG2QBOS.js +0 -1
- package/dist/preview/chunk.VR735ZQL.js +0 -1
- package/dist/preview/chunk.VSXCXPK2.js +0 -1
- package/dist/preview/chunk.W3LDQ6B2.js +0 -1
- package/dist/preview/chunk.WCNONCTL.js +0 -6
- package/dist/preview/chunk.WHTNSETN.js +0 -1
- package/dist/preview/chunk.XG67BWH6.js +0 -1
- package/dist/preview/chunk.XRM6WXPW.js +0 -1
- package/dist/preview/chunk.Y5LPZLDE.js +0 -1
- package/dist/preview/chunk.YETBY2LM.js +0 -1
- package/dist/preview/chunk.YSYT3ASK.js +0 -1
- package/dist/preview/chunk.ZEUBAAVQ.js +0 -1
- package/dist/preview/chunk.ZJDRD6PO.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var Qa="JanFebMarAprMayJunJulAugSepOctNovDec",wt=/^\d{4}-\d{2}-\d{2}$/,to=()=>new Date().toISOString().slice(0,10);function Dn(n){let e=wt.test(n)?Qa.slice(+n.slice(5,7)*3-3,+n.slice(5,7)*3):"";return e?`${+n.slice(8)} ${e} ${n.slice(0,4)}`:n}var ed=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function kt(n){return n.includes("-")?n.replace(ed,e=>Dn(e)):n}function un(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 $t(n,e="|"){return n.map(t=>zt(t)).join(e)}function ro(n,e){return typeof e=="bigint"?e.toString():e}var _t=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 oo(n){return new _t(n)}function io(n){return n==null}function Ot(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function so(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 Q(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function ao(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function At(n){return ao(n._zod.def)??n._zod.def.shape}function co(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return Q(this,e,r),r},enumerable:!0,configurable:!0})}function lo(n,e,t){e in n?Q(n,e,t):n[e]=t}function nd(n,e,t,r){let o=At(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?co(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):lo(n,i,r?r(s.value,i):s.value))}}function td(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?co(n,t,()=>e[t]):lo(n,t,r.value))}}function uo(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var Rt="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Fn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Pt(n){if(Fn(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(Fn(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var fo=new Set(["string","number","symbol"]);function fn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function M(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 zt(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function po(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var Zn={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]},Et={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ho(n,e){if(!Pt(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=At(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 Ge(n,uo(n._zod.def,{shape:rd(n,e)}))}function rd(n,e){let t={};return nd(t,n,Reflect.ownKeys(At(n))),td(t,e),t}function ue(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 go(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 ve(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function ln(n){return typeof n=="string"?n:n?.message}function Nt(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function fe(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:ln(n.inst?._zod.def?.error?.(n))??ln(i?.(n))??ln(e?.error?.(n))??ln(t.customError?.(n))??ln(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 od=/[\uD800-\uDBFF]/;function Mt(n){let e=n.length;if(!od.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 It(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function mo(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 pn(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function yo(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):id(n,t,r.value)}}function Pe(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function jt(n,e,t){return Pe(n,e,t,!1)}function id(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:Pe(this,e,t.bind(this))},set(r){Pe(this,e,r)}})}function sd(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var St,xe=!1,ad={configurable:!0,get(){xe=!0}};function re(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&St!==n._zod){St=void 0;return}St=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,ad);let o=xe;xe=!1;try{let i=t(this);return xe?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),xe=xe||o,i}catch(i){throw delete this[e],xe=xe||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function bo(n,e,t,r){let o=sd(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 xo;var Tt={value:void 0,enumerable:!1},vo="captureStackTrace"in Error?Error:null;function dd(n){let e=vo;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return vo=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function O(n,e,t,r){let o={};function i(l){this.def=l,this.constr=f,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(l,p){if(l._zod){if(l._zod.traits.has(n))return}else{Tt.value=new i(p);try{Object.defineProperty(l,"_zod",Tt)}finally{Tt.value=void 0}}if(l._zod.traits.add(n),e(l,p),a){let y=Object.getPrototypeOf(l),m=l._zod.constr.prototype,g=y;for(;g&&g!==m;)g=Object.getPrototypeOf(g);let b=g??y;a.has(b)||(a.add(b),yo(b,s))}let h=f.prototype;for(let y in h)Object.prototype.hasOwnProperty.call(h,y)&&(y in l||(l[y]=h[y].bind(l)))}let c=r?.Parent??Object;class u extends c{}Object.defineProperty(u,"name",{value:n});function f(l){let p=r?.Parent?dd(u):this;d(p,l);let h=p._zod.deferred;if(h){for(let m of h)m();p._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;return y&&y(p),p}return Object.defineProperty(f,"init",{value:d}),Object.defineProperty(f,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(n)}),Object.defineProperty(f,"name",{value:n}),f}var he=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(xo=globalThis).__zod_globalConfig??(xo.__zod_globalConfig={});var Be=globalThis.__zod_globalConfig;function H(n){return n&&Object.assign(Be,n),Be}function cd(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,ro,2)),n.message}function ld(n){this._zod.message=n}var ud={get:cd,set:ld,enumerable:!0,configurable:!0},Ft={value:void 0,enumerable:!1},wo=new WeakSet([Object.prototype,Error.prototype]),ko=(n,e)=>{n.name="$ZodError",Ft.value=e,Object.defineProperty(n,"issues",Ft),Ft.value=void 0,Object.defineProperty(n,"message",ud);let t=Object.getPrototypeOf(n);wo.has(t)||(wo.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})}}))},kf=O("$ZodError",ko),hn=O("$ZodError",ko,void 0,{Parent:Error});var pd=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 he;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(c=>fe(c,s,H())));throw Rt(d,i?.callee??e),d}return a.value};return e},Zt=pd(hn),hd=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(c=>fe(c,s,H())));throw Rt(d,i?.callee??e),d}return a.value};return e},Ct=hd(hn),gd=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 he;return i.issues.length?So(n,i.issues,o):{success:!0,data:i.value}},Lt=gd(hn);function So(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>fe(o,t,H()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var md=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?So(n,i.issues,o):{success:!0,data:i.value}},Gt=md(hn);var _o=/^(?:[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 $o=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Oo=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ao=/^https?$/;var Ro=/^[\s\S]{0,}$/;var Bt=/^-?\d+$/,gn=/^-?\d+(?:\.\d+)?$/,Po=/^(?:true|false)$/i,zo=/^null$/i;var J=O("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var Eo=n=>{let e=n.value;return!io(e)&&e.length!==void 0},Ln={number:"number",bigint:"bigint",object:"date"},No=O("$ZodCheckLessThan",(n,e)=>{J.init(n,e);let t=Ln[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:Ln[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})}}),Mo=O("$ZodCheckGreaterThan",(n,e)=>{J.init(n,e);let t=Ln[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:Ln[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})}}),Io=O("$ZodCheckMultipleOf",(n,e)=>{J.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):so(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})}}),jo=O("$ZodCheckNumberFormat",(n,e)=>{J.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=Zn[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 To=O("$ZodCheckMaxLength",(n,e)=>{var t;J.init(n,e),(t=n._zod.def).when??(t.when=Eo),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?Mt(o):i)<=e.maximum)return;let a=It(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),Do=O("$ZodCheckMinLength",(n,e)=>{var t;J.init(n,e),(t=n._zod.def).when??(t.when=Eo),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?Mt(o):i)>=e.minimum)return;let a=It(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var Ut=O("$ZodCheckStringFormat",(n,e)=>{var t,r;J.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=()=>{})}),Fo=O("$ZodCheckRegex",(n,e)=>{Ut.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 Co={major:4,minor:6,patch:5};var L=O("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=Co;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,c)=>{if(a.memo)return a;let u=ue(a),f;for(let l of d){if(l._zod.def.when){if(go(a)||!l._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,h=l._zod.check(a);if(h instanceof Promise&&c?.async===!1)throw new he;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await h,a.issues.length!==p&&(Nt(a.issues,p,n),u||(u=ue(a,p)))});else{if(a.issues.length===p)continue;Nt(a.issues,p,n),u||(u=ue(a,p))}}return f?f.then(()=>a):a},s=(a,d,c)=>{if(ue(a))return a.aborted=!0,a;let u=i(d,o,c);if(u instanceof Promise){if(c.async===!1)throw new he;return u.then(f=>n._zod.parse(f,c))}return n._zod.parse(u,c)};n._zod.run=(a,d)=>{if(d.skipChecks)return n._zod.parse(a,d);if(d.direction==="backward"){let u=n._zod.parse({value:a.value,issues:[]},{...d,skipChecks:!0});return u instanceof Promise?u.then(f=>s(f,a,d)):s(u,a,d)}let c=n._zod.parse(a,d);if(c instanceof Promise){if(d.async===!1)throw new he;return c.then(u=>i(u,o,d))}return i(c,o,d)}}},{get"~standard"(){return jt(this,"~standard",bd(this))},set"~standard"(n){Pe(this,"~standard",n)}}),Vo=(n,e)=>n.issues.length?{issues:n.issues.map(t=>fe(t,e,H()))}:{value:n.value};async function yd(n,e){let t={async:!0};return Vo(await n._zod.run({value:e,issues:[]},t),t)}function bd(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return Vo(r,t)}catch{}return yd(n,e)},vendor:"zod",version:1}}var Kt=O("$ZodString",(n,e)=>{L.init(n,e),n._zod.pattern=e.pattern??Ro,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}}),Un=O("$ZodStringFormat",(n,e)=>{Ut.init(n,e),Kt.init(n,e)});var Wo=O("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=_o),Un.init(n,e)}),qo=1,Gn=2;function xd(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function vd(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?xd(n)||Gn:wd(n,e)}function wd(n,e){if(!e.normalize&&e.protocol?.source===Ao.source&&!/^https?:\/\//i.test(n))return qo;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??Gn}return new URL(n)}catch{return Gn}}var kd=/[\t\n\r]/g;function Lo(n){return n.replace(kd,"")}function Sd(n,e){return e.lastIndex=0,e.test(n.hostname)}function _d(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var Ho=O("$ZodURL",(n,e)=>{Un.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=vd(r,e);if(o===qo){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===Gn){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=Lo(r);return}e.hostname&&!Sd(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&&!_d(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:Lo(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var Jo=/^[0-9a-zA-Z+/]*={0,2}$/;var Yo=/^[A-Za-z0-9_-]*$/;var Vt=O("$ZodNumber",(n,e)=>{L.init(n,e),n._zod.pattern=gn,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}}),Xo=O("$ZodNumberFormat",(n,e)=>{jo.init(n,e),Vt.init(n,e)}),Qo=O("$ZodBoolean",(n,e)=>{L.init(n,e),n._zod.pattern=Po,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 ei=O("$ZodNull",(n,e)=>{L.init(n,e),n._zod.pattern=zo,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 ni=O("$ZodUnknown",(n,e)=>{L.init(n,e),n._zod.parse=t=>t}),ti=O("$ZodNever",(n,e)=>{L.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function Go(n,e,t){n.issues.length&&e.issues.push(...ve(t,n.issues)),e.value[t]=n.value}var ri=O("$ZodArray",(n,e)=>{L.init(n,e);let t=Be.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 c=i[d],u=e.element._zod.run({value:c,issues:[]},o);if(u instanceof Promise)s.push(u.then(f=>Go(f,r,d)));else if(Go(u,r,d),a&&u.issues.length!==0&&ue(u))break}return s.length?Promise.all(s).then(()=>r):r}});function Bn(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(...ve(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 $d=[];function Od(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:$d,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=po(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function Ad(n,e,t,r,o,i,s){let a=[],d=o.keySet,c=o.catchall._zod,u=c.def.type,f=c.optin,l=c.optout,p=0;for(let h in e){if(s&&t.issues.length!==p){if(ue(t,p))break;p=t.issues.length}if(d.has(h))continue;if(h==="__proto__"){u==="never"&&a.push(h);continue}if(u==="never"){a.push(h);continue}let y=c.run({value:e[h],issues:[]},r);y instanceof Promise?n.push(y.then(m=>Bn(m,t,h,e,f,l))):Bn(y,t,h,e,f,l)}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 oi=O("$ZodObject",(n,e)=>{L.init(n,e);let t=Object.getOwnPropertyDescriptor(e,"shape"),r=t?.get?t.get.raw:e.shape??{};if(r){let c=()=>{let u={...r};return Object.defineProperty(e,"shape",{value:u}),c.raw=u,u};c.raw=r,Object.defineProperty(e,"shape",{get:c})}let o=oo(()=>Od(e));re(n,"propValues",c=>{let u=c.def.shape,f={};for(let l in u){let p=u[l]._zod;if(p.values){Object.prototype.hasOwnProperty.call(f,l)||Q(f,l,new Set);for(let h of p.values)f[l].add(h);p.optin!==void 0&&f[l].add(void 0)}}return f});let i=Fn,s=e.catchall,a,d=Be.memoizer;d?.attach(n),n._zod.parse=(c,u)=>{a??(a=o.value);let f=c.value;if(!i(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:n}),c;c.value=d?d.alloc(n,c,{},u):{};let l=[],p=a.shape,h=u?.abortEarly,y=c.issues.length;for(let m of a.allKeys){if(h&&c.issues.length!==y){if(ue(c,y))break;y=c.issues.length}if(m==="__proto__")continue;let g=p[m],b=g._zod.optin,S=g._zod.optout,v=g._zod.run({value:f[m],issues:[]},u);v instanceof Promise?l.push(v.then(x=>Bn(x,c,m,f,b,S))):Bn(v,c,m,f,b,S)}return s?Ad(l,f,c,u,o.value,n,h===!0):l.length?Promise.all(l).then(()=>c):c}});function Bo(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=>!ue(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=>fe(s,r,H())))}),e)}var ii=O("$ZodUnion",(n,e)=>{L.init(n,e),re(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),re(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),re(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)))}),re(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=>Ot(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=>Bo(a,r,n,o)):Bo(s,r,n,o)}});var si=O("$ZodRecord",(n,e)=>{L.init(n,e);let t=Be.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!Pt(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 u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(d.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let f=e.keyType._zod.run({value:u,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>fe(h,o,H())),input:u,path:[u],inst:n});continue}let l=f.value;if(l==="__proto__")continue;let p=e.valueType._zod.run({value:i[u],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...ve(u,h.issues)),r.value[l]=h.value})):(p.issues.length&&r.issues.push(...ve(u,p.issues)),r.value[l]=p.value)}let c;for(let u in i)if(!d.has(u))if(e.mode==="loose"){if(u==="__proto__")continue;r.value[u]=i[u]}else c=c??[],c.push(u);c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c,continue:!0})}else{r.value=t?t.alloc(n,r,{},o):{};let d;for(let c of Reflect.ownKeys(i)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,c))continue;let u=e.keyType._zod.run({value:c,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&gn.test(c)&&u.issues.length){let h=e.keyType._zod.run({value:Number(c),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(u=h)}if(u.issues.length){e.mode==="loose"?r.value[c]=i[c]:a?(d=d??[],d.push(c)):r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(h=>fe(h,o,H())),input:c,path:[c],inst:n});continue}let l=u.value;if(l==="__proto__")continue;let p=e.valueType._zod.run({value:i[c],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...ve(c,h.issues)),r.value[l]=h.value})):(p.issues.length&&r.issues.push(...ve(c,p.issues)),r.value[l]=p.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 ai=O("$ZodEnum",(n,e)=>{L.init(n,e);let t=un(e.entries),r=new Set(t);n._zod.values=r,re(n,"pattern",o=>{let i=un(o.def.entries).filter(s=>fo.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>fn(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}}),di=O("$ZodLiteral",(n,e)=>{L.init(n,e);let t=new Set(e.values);n._zod.values=t,re(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?fn(i):i?fn(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 Uo(n,e){return n.value=e.issues.length?void 0:e.value,n}var ci=O("$ZodOptional",(n,e)=>{L.init(n,e),re(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",re(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),re(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${Ot(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=>Uo(t,i)):Uo(t,o)}return e.innerType._zod.run(t,r)}});var li=O("$ZodCustom",(n,e)=>{J.init(n,e),L.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=>Ko(i,t,r,n));Ko(o,t,r,n)}});function Ko(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(pn(o))}}var Rd=()=>{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=mo(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 ${zt(i.values[0])}`:`Invalid option: expected one of ${$t(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":""}: ${$t(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 ui(){return{localeError:Rd()}}var fi;var Wt=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 pi(){return new Wt}(fi=globalThis).__zod_globalRegistry??(fi.__zod_globalRegistry=pi());var we=globalThis.__zod_globalRegistry;function hi(n){return n.checks&&(n.checks=[...n.checks]),n}function gi(n,e){return new n(hi({type:"string",...M(e)}))}function mi(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...M(e)})}function yi(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...M(e)})}function bi(n,e){return new n(hi({type:"number",checks:[],...M(e)}))}function xi(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...M(e)})}function vi(n,e){return new n({type:"boolean",...M(e)})}function wi(n,e){return new n({type:"null",...M(e)})}function ki(n){return new n({type:"unknown"})}function Si(n,e){return new n({type:"never",...M(e)})}function _i(n,e){return new No({check:"less_than",...M(e),value:n,inclusive:!0})}function $i(n,e){return new Mo({check:"greater_than",...M(e),value:n,inclusive:!0})}function Nd(n,e){return new Io({check:"multiple_of",...M(e),value:n})}function Md(n,e){return new To({check:"max_length",...M(e),maximum:n})}function mn(n,e){return new Do({check:"min_length",...M(e),minimum:n})}function Id(n,e){return new Fo({check:"string_format",format:"regex",...M(e),pattern:n})}function Oi(n,e,t){return new n({type:"custom",check:"custom",fn:e,...M(t)})}function Ai(n,e){let t=jd(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(pn(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(pn(i))}},n(r.value,r)),e);return t}function jd(n,e){let t=new J({check:"custom",...M(e)});return t._zod.check=n,t}function Ri(n){let e=new J({check:"describe"});return e._zod.onattach=[t=>{let r=we.get(t)??{};we.add(t,{...r,description:n})}],e._zod.check=()=>{},e}function yn(n,...e){for(let t of e)for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&Q(n,r,t[r]);return n}function Kn(n){let e=n?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??we,target:e,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:n?.cycles??"ref",reused:n?.reused??"inline",intersections:[],deferred:[],external:n?.external??void 0}}function C(n,e,t,r,o){let i=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:n,path:r.path,message:o}):e.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(t,i),!0}function I(n,e,t={path:[],schemaPath:[]}){var r;let o=n._zod.def,i=e.seen.get(n);if(i)return i.count++,t.schemaPath.includes(n)&&(i.cycle=t.path),i.schema;let s={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,s),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;let a=n._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,s.schema,u);else{let l=s.schema,p=e.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(n,e,l,u)}let f=n._zod.parent;f&&(s.ref||(s.ref=f),I(f,e,u),e.seen.get(f).isParent=!0)}let d=e.metadataRegistry.get(n);return d&&yn(s.schema,d),e.io==="input"&&B(n)&&(delete s.schema.examples,delete s.schema.default),e.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,e.seen.get(n).schema}function Pi(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function Vn(n,e){let t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");if(n.external&&n.sharedDefsExtractedFor===n.external)return;let r=new Map;for(let s of n.seen.entries()){let a=n.metadataRegistry.get(s[0])?.id;if(a){let d=r.get(a);if(d&&d!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=s=>{let a=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let f=n.external.registry.get(s[0])?.id,l=n.external.uri??(h=>h);if(f)return{ref:l(f)};let p=s[1].defId??s[1].schema.id??`schema${n.counter++}`;return s[1].defId=p,{defId:p,ref:`${l("__shared")}#/${a}/${Pi(p)}`}}let d="#",c=`${d}/${a}/`;if(s[1]===t&&!s[1].schema.id)return{ref:d};let u=s[1].schema.id??`__schema${n.counter++}`;return{defId:u,ref:c+Pi(u)}},i=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:d,defId:c}=o(s);a.def={...a.schema},c&&(a.defId=c);let u=a.schema;for(let f in u)delete u[f];u.$ref=d};if(n.cycles==="throw")for(let s of n.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
2
|
-
|
|
3
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of n.seen.entries()){let a=s[1];if(e===s[0]){i(s);continue}if(n.external){let c=n.external.registry.get(s[0])?.id;if(e!==s[0]&&c){i(s);continue}}if(n.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}a.count>1&&n.reused==="ref"&&i(s)}n.external&&(n.sharedDefsExtractedFor=n.external)}function Mi(n){let e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;let t=[];for(let r of e){if(!r||typeof r!="object")return;Mi(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;t.includes(s)||t.push(s)}}delete n.anyOf,n.type=t.length===1?t[0]:t}var Ii=new Set(["type","properties","required","additionalProperties"]),zi=["oneOf","anyOf"];function Ei(n){let e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function qt(n){let e=[];for(let i of n){if(typeof i!="object"||i.type!=="object")return null;for(let s in i)if(!Ii.has(s))return null;e.push(i)}let t={},r=new Set;for(let i of e){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(t,s))continue;let a=[];for(let c of e){let u=c.properties?.[s]??Ei(c);u!=null&&(a.some(f=>JSON.stringify(f)===JSON.stringify(u))||a.push(u))}let d=a.length===1?a[0]:qt(a)??{allOf:a};Q(t,s,d)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:t};if(r.size&&(o.required=[...r]),e.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of e){let a=Ei(s);a&&!i.some(d=>JSON.stringify(d)===JSON.stringify(a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function Td(n){let e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(let o of Ii)if(o in n)return;let t=e.filter(o=>zi.some(i=>Array.isArray(o[i]))),r=null;if(!t.length)r=qt(e);else{let o=t[0],i=zi.find(d=>Array.isArray(o[d]));if(Object.keys(o).length!==1)return;let s=e.filter(d=>d!==o),a=o[i].map(d=>qt([...s,d]));if(a.some(d=>!d))return;r={[i]:a}}r&&(delete n.allOf,yn(n,r))}function Wn(n,e){let t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=a=>{let d=n.seen.get(a);if(d.ref===null)return;let c=d.def??d.schema,u={...c},f=d.ref;if(d.ref=null,f){r(f);let p=n.seen.get(f),h=p.schema;if(h.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):yn(c,h),yn(c,u),a._zod.parent===f)for(let m in c)m==="$ref"||m==="allOf"||m in u||delete c[m];if(h.$ref&&p.def)for(let m in c)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(c[m])===JSON.stringify(p.def[m])&&delete c[m]}let l=a._zod.parent;if(l&&l!==f){r(l);let p=n.seen.get(l);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}n.override({zodSchema:a,jsonSchema:c,path:d.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(let a of[...n.seen.entries()].reverse())r(a[0]);if(n.target!=="openapi-3.0")for(let a of n.seen.entries())Mi(a[1].def??a[1].schema);for(let a of n.deferred)a();if(n.intersections.length){let a=new Map;for(let d of n.seen.values())for(let c of[d.schema,d.def]){let u=c?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);f?f.push(c):a.set(u,[c])}for(let d of n.intersections)for(let c of a.get(d)??[])Td(c)}}let o={};if(n.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){let a=n.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=n.external.uri(a)}yn(o,t.defId?t.schema:t.def??t.schema);let i=n.metadataRegistry.get(e)?.id;i!==void 0&&o.id===i&&delete o.id;let s=n.external?.defs??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(let a of n.seen.entries()){let d=a[1];d.def&&d.defId&&(d.def.id===d.defId&&delete d.def.id,Q(s,d.defId,d.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Ni(e,"input",n.processors),output:Ni(e,"output",n.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function B(n,e){let t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);let r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return B(r.element,t);if(r.type==="set")return B(r.valueType,t);if(r.type==="lazy")return B(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return B(r.innerType,t);if(r.type==="intersection")return B(r.left,t)||B(r.right,t);if(r.type==="record"||r.type==="map")return B(r.keyType,t)||B(r.valueType,t);if(r.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:B(r.in,t)||B(r.out,t);if(r.type==="object"){for(let o in r.shape)if(B(r.shape[o],t))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(B(o,t))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(B(o,t))return!0;return!!(r.rest&&B(r.rest,t))}return!1}var Ni=(n,e,t={})=>r=>{let{libraryOptions:o,target:i}=r??{},s=Kn({...o??{},target:i,io:e,processors:t});return I(n,s),Vn(s,n),Wn(s,n)};var Ue=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},Ke=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},ji=(n,e)=>{Ue(n,"minimum",e),Ke(n,"maximum",e)},Ci=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},Li=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},Gi=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},Bi=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},Ti=(n,e)=>Ue(n,"minimum",e.minimum),Di=(n,e)=>Ke(n,"maximum",e.maximum),Fi=n=>(e,t)=>{Bi(e,t.format);let[r,o]=n[t.format];Ue(e,"minimum",r),Ke(e,"maximum",o)},Dd={greater_than:(n,e)=>Ue(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>Ke(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>Ci(n,e.value),number_format:Fi(Zn),bigint_format:Fi(Et),min_length:Ti,max_length:Di,length_equals:(n,e)=>ji(n,e.length),min_size:Ti,max_size:Di,size_equals:(n,e)=>ji(n,e.size),string_format:(n,e)=>{Bi(n,e.format),e.pattern&&Li(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>Gi(n,e.mime)};function Ve(n){let e={},t=n._zod.def,r=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(let i of r)Dd[i._zod.def.check]?.(e,i._zod.def);let o=n._zod.bag;o.minimum!==void 0&&Ue(e,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Ue(e,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Ke(e,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Ke(e,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ci(e,o.multipleOf),o.format!==void 0&&(e.format??(e.format=o.format),o.format.includes("int")&&(e.isInt=!0)),o.mime&&Gi(e,o.mime);for(let i of o.patterns??[])Li(e,i);return e}var Fd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Zd=new Map([[Jo,$o],[Yo,Oo]]),Ui=n=>Zd.get(n)??n,Cd=(n,e,t,r)=>{let o=t;o.type="string";let{minimum:i,maximum:s,format:a,patterns:d,contentEncoding:c,laxFormat:u}=Ve(n);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=Fd[a]??a,o.format===""&&delete o.format,(a==="time"||u)&&delete o.format),c&&(o.contentEncoding=c),d&&d.size>0){let f=[...d].map(Ui);f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(l=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},Ld=(n,e,t,r)=>{let o=t,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:d,exclusiveMinimum:c,isInt:u}=Ve(n);o.type=u?"integer":"number";let f=typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY),l=typeof d=="number"&&d<=(s??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(o.minimum=c,o.exclusiveMinimum=!0):o.exclusiveMinimum=c:typeof i=="number"&&(o.minimum=i),l?p?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d:typeof s=="number"&&(o.maximum=s),a){let h=new Set;for(let g of a)Number.isFinite(g)&&g!==0?h.add(Math.abs(g)):C(n,e,o,r,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[y,...m]=h;y!==void 0&&(o.multipleOf=y),m.length&&(o.allOf=[...o.allOf??[],...m.map(g=>({multipleOf:g}))])}},Gd=(n,e,t,r)=>{t.type="boolean"},Bd=(n,e,t,r)=>{C(n,e,t,r,"BigInt cannot be represented in JSON Schema")},Ud=(n,e,t,r)=>{C(n,e,t,r,"Symbols cannot be represented in JSON Schema")},Kd=(n,e,t,r)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},Vd=(n,e,t,r)=>{C(n,e,t,r,"Undefined cannot be represented in JSON Schema")},Wd=(n,e,t,r)=>{C(n,e,t,r,"Void cannot be represented in JSON Schema")},qd=(n,e,t,r)=>{t.not={}},Hd=(n,e,t,r)=>{},Jd=(n,e,t,r)=>{},Yd=(n,e,t,r)=>{C(n,e,t,r,"Date cannot be represented in JSON Schema")},Xd=(n,e,t,r)=>{let o=n._zod.def,i=un(o.entries);if(i.length===0){t.not={};return}i.every(s=>typeof s=="number")&&(t.type="number"),i.every(s=>typeof s=="string")&&(t.type="string"),t.enum=i},Qd=(n,e,t,r)=>{let o=n._zod.def;if(o.values.length===0){t.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(C(n,e,t,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(C(n,e,t,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];t.type=s===null?"null":typeof s,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[s]:t.const=s}else i.every(s=>typeof s=="number")&&(t.type="number"),i.every(s=>typeof s=="string")&&(t.type="string"),i.every(s=>typeof s=="boolean")&&(t.type="boolean"),i.every(s=>s===null)&&(t.type="null"),t.enum=i},ec=(n,e,t,r)=>{C(n,e,t,r,"NaN cannot be represented in JSON Schema")},nc=(n,e,t,r)=>{let o=t,i=n._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},tc=(n,e,t,r)=>{let o=t;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=Ve(n);i!==void 0&&(o.minLength=i),s!==void 0&&(o.maxLength=s),a&&(a.length===0?o.not={}:a.length===1?o.contentMediaType=a[0]:o.anyOf=a.map(d=>({contentMediaType:d})))},rc=(n,e,t,r)=>{t.type="boolean"},oc=(n,e,t,r)=>{C(n,e,t,r,"Custom types cannot be represented in JSON Schema")},ic=(n,e,t,r)=>{C(n,e,t,r,"Function types cannot be represented in JSON Schema")},sc=(n,e,t,r)=>{C(n,e,t,r,"Transforms cannot be represented in JSON Schema")},ac=(n,e,t,r)=>{C(n,e,t,r,"Map cannot be represented in JSON Schema")},dc=(n,e,t,r)=>{C(n,e,t,r,"Set cannot be represented in JSON Schema")},cc=(n,e,t,r)=>{let o=t,i=n._zod.def,{minimum:s,maximum:a}=Ve(n);typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=I(i.element,e,{...r,path:[...r.path,"items"]})};function bn(n){let e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?bn(e.out):e.type==="catch"?bn(e.innerType):n._zod.optin}var lc=(n,e,t,r)=>{let o=t,i=n._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&C(n,e,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let c in s)Q(o.properties,c,I(s[c],e,{...r,path:[...r.path,"properties",c]}));let d=[];for(let c of Object.keys(s)){let u=i.shape[c];(e.io==="input"?bn(u)===void 0:u._zod.optout===void 0)&&d.push(c)}d.length>0&&(o.required=d),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=I(i.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},uc=(n,e,t,r)=>{let o=n._zod.def,i=o.inclusive===!1,s=o.options.map((a,d)=>I(a,e,{...r,path:[...r.path,i?"oneOf":"anyOf",d]}));i?t.oneOf=s:t.anyOf=s},fc=(n,e,t,r)=>{let o=n._zod.def,i=I(o.left,e,{...r,path:[...r.path,"allOf",0]}),s=I(o.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,d=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];t.allOf=d,e.intersections.push(d)},pc=(n,e,t,r)=>{let o=t,i=n._zod.def;o.type="array";let s=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",d=i.items.map((y,m)=>I(y,e,{...r,path:[...r.path,s,m]})),c=i.rest?I(i.rest,e,{...r,path:[...r.path,a,...e.target==="openapi-3.0"?[i.items.length]:[]]}):null,u=i.items.length;for(;u>0;){let y=i.items[u-1];if(!(e.io==="input"?bn(y)!==void 0:y._zod.optout==="optional"))break;u--}let f=i.items.length,l=!i.rest;e.target==="draft-2020-12"?(o.prefixItems=d,l?o.items=!1:c&&(o.items=c),u>0&&(o.minItems=u),l&&(o.maxItems=f)):e.target==="openapi-3.0"?(o.items={anyOf:d},c&&o.items.anyOf.push(c),u>0&&(o.minItems=u),l&&(o.maxItems=f)):(o.items=d,l?o.additionalItems=!1:c&&(o.additionalItems=c),u>0&&(o.minItems=u),l&&(o.maxItems=f));let{minimum:p,maximum:h}=Ve(n);typeof p=="number"&&(o.minItems=p),typeof h=="number"&&(o.maxItems=h)};function Ht(n,e,t){if(e.$ref){if(t.has(e))return e;t.add(e);let h=n.get(e)?.def;if(!h)return e;let y=Ht(n,h,t);return y===h?e:y}for(let h of["anyOf","oneOf"]){let y=e[h];if(!Array.isArray(y))continue;let m=y.map(g=>Ht(n,g,t));m.some((g,b)=>g!==y[b])&&(e={...e,[h]:m})}let r=Array.isArray(e.type)?e.type:[e.type],o=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!o&&!i?.some(h=>typeof h=="number"))return e;let{minimum:s,maximum:a,exclusiveMinimum:d,exclusiveMaximum:c,multipleOf:u,format:f,id:l,...p}=e;return p.enum?p.enum=p.enum.map(h=>typeof h=="number"?String(h):h):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",i||(p.pattern=(r.includes("number")?gn:Bt).source)),p}var Jt=new WeakMap;function hc(n){let e=new Map;for(let r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);let t=new Map;for(let r of Jt.get(n)??[]){let o=n.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||t.has(i))continue;let s=Ht(e,i,new Set);s!==i&&t.set(i,s)}if(t.size)for(let r of n.seen.values())for(let o of[r.schema,r.def]){let i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}var gc=(n,e,t,r)=>{let o=t,i=n._zod.def;o.type="object";let s=i.keyType,a=Ve(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let u=I(i.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let f of a)Q(o.patternProperties,Ui(f).source,u)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){o.propertyNames=I(i.keyType,e,{...r,path:[...r.path,"propertyNames"]});let u=Jt.get(e);u||(u=[],Jt.set(e,u),e.deferred.push(()=>hc(e))),u.push(n)}o.additionalProperties=I(i.valueType,e,{...r,path:[...r.path,"additionalProperties"]})}let d=s._zod.values,c=e.io==="input"&&bn(i.valueType)!==void 0;if(d&&!i.partial&&!c){let u=[...d].filter(f=>typeof f=="string"||typeof f=="number");u.length>0&&(o.required=u.map(String))}},mc=(n,e,t,r)=>{let o=n._zod.def,i=I(o.innerType,e,r),s=e.seen.get(n);e.target==="openapi-3.0"?(s.ref=o.innerType,t.nullable=!0):t.anyOf=[i,{type:"null"}]},yc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType},Yt=Symbol();function Ki(n,e,t,r,o){let i=!1,s=JSON.stringify(n,(a,d)=>typeof d!="bigint"?d:(i=!0,null));return i?(C(e,t,r,o,"BigInt defaults cannot be represented in JSON Schema"),Yt):JSON.parse(s)}var bc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType;let s=Ki(o.defaultValue,n,e,t,r);s!==Yt&&(t.default=s)},xc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);if(i.ref=o.innerType,e.io!=="input")return;let s=Ki(o.defaultValue,n,e,t,r);s!==Yt&&(t._prefault=s)},vc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{C(n,e,t,r,"Dynamic catch values are not supported in JSON Schema");return}t.default=s},wc=(n,e,t,r)=>{let o=n._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=e.io==="input"?i?o.out:o.in:o.out;I(s,e,r);let a=e.seen.get(n);a.ref=s},kc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType,t.readOnly=!0},Sc=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType},_c=(n,e,t,r)=>{let o=n._zod.def;I(o.innerType,e,r);let i=e.seen.get(n);i.ref=o.innerType},$c=(n,e,t,r)=>{let o=n._zod.innerType;I(o,e,r);let i=e.seen.get(n);i.ref=o},Zi={string:Cd,number:Ld,boolean:Gd,bigint:Bd,symbol:Ud,null:Kd,undefined:Vd,void:Wd,never:qd,any:Hd,unknown:Jd,date:Yd,enum:Xd,literal:Qd,nan:ec,template_literal:nc,file:tc,success:rc,custom:oc,function:ic,transform:sc,map:ac,set:dc,array:cc,object:lc,union:uc,intersection:fc,tuple:pc,record:gc,nullable:mc,nonoptional:yc,default:bc,prefault:xc,catch:vc,pipe:wc,readonly:kc,promise:Sc,optional:_c,lazy:$c};function Oc(n,e){if("_idmap"in n){let r=n,o=Kn({...e,processors:Zi}),i={};for(let d of r._idmap.entries()){let[c,u]=d;I(u,o)}let s={},a={registry:r,uri:e?.uri,defs:i};o.external=a;for(let d of r._idmap.entries()){let[c,u]=d;Vn(o,u),Q(s,c,Wn(o,u))}if(Object.keys(i).length>0){let d=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[d]:i}}return{schemas:s}}let t=Kn({...e,processors:Zi});return I(n,t),Vn(t,n),Wn(t,n)}var V=O("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");L.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){Pe(this,"with",n)},parse(n,e){return Zt(this,n,e,{callee:this.parse})},parseAsync(n,e){return Ct(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return Lt(this,n,e)},safeParseAsync(n,e){return Gt(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 Ge(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)}}),Wi=O("ZodMiniString",(n,e)=>{Kt.init(n,e),V.init(n,e)});function se(n){return gi(Wi,n)}var qi=O("ZodMiniStringFormat",(n,e)=>{Un.init(n,e),Wi.init(n,e)}),Pc=O("ZodMiniEmail",(n,e)=>{Wo.init(n,e),qi.init(n,e)});function Eg(n){return mi(Pc,n)}var zc=O("ZodMiniURL",(n,e)=>{Ho.init(n,e),qi.init(n,e)});function Ng(n){return yi(zc,n)}var Hi=O("ZodMiniNumber",(n,e)=>{Vt.init(n,e),V.init(n,e)});function qn(n){return bi(Hi,n)}var Ec=O("ZodMiniNumberFormat",(n,e)=>{Xo.init(n,e),Hi.init(n,e)});function Mg(n){return xi(Ec,n)}var Nc=O("ZodMiniBoolean",(n,e)=>{Qo.init(n,e),V.init(n,e)});function Ig(n){return vi(Nc,n)}var Mc=O("ZodMiniNull",(n,e)=>{ei.init(n,e),V.init(n,e)});function jg(n){return wi(Mc,n)}var Ic=O("ZodMiniUnknown",(n,e)=>{ni.init(n,e),V.init(n,e)});function jc(){return ki(Ic)}var Tc=O("ZodMiniNever",(n,e)=>{ti.init(n,e),V.init(n,e)});function Dc(n){return Si(Tc,n)}var Fc=O("ZodMiniArray",(n,e)=>{ri.init(n,e),V.init(n,e)});function Tg(n,e){return new Fc({type:"array",element:n,...M(e)})}var Xt=O("ZodMiniObject",(n,e)=>{oi.init(n,e),V.init(n,e),bo(n,"shape",t=>t._zod.def.shape,!1)});function Hn(n,e){let t={type:"object",shape:n??{},...M(e)};return new Xt(t)}function Ji(n,e){return new Xt({type:"object",shape:n,catchall:Dc(),...M(e)})}function Dg(n,e){return new Xt({type:"object",shape:n,catchall:jc(),...M(e)})}function Yi(n,e){return ho(n,e)}var Zc=O("ZodMiniUnion",(n,e)=>{ii.init(n,e),V.init(n,e)});function Fg(n,e){return new Zc({type:"union",options:n,...M(e)})}var Vi=O("ZodMiniRecord",(n,e)=>{si.init(n,e),V.init(n,e)});function Zg(n,e,t){return!e||!e._zod?new Vi({type:"record",keyType:se(),valueType:n,...M(e)}):new Vi({type:"record",keyType:n,valueType:e,...M(t)})}var Cc=O("ZodMiniEnum",(n,e)=>{ai.init(n,e),V.init(n,e),n.options=[...n._zod.values]});function Cg(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Cc({type:"enum",entries:t,...M(e)})}var Lc=O("ZodMiniLiteral",(n,e)=>{di.init(n,e),V.init(n,e)});function Xi(n,e){return new Lc({type:"literal",values:Array.isArray(n)?n:[n],...M(e)})}var Gc=O("ZodMiniOptional",(n,e)=>{ci.init(n,e),V.init(n,e)});function We(n){return new Gc({type:"optional",innerType:n})}var Bc=O("ZodMiniCustom",(n,e)=>{li.init(n,e),V.init(n,e)});function Qi(n,e={}){return Oi(Bc,n,e)}function Lg(n,e){return Ai(n,e)}var Gg=Ri;H().localeError||H(ui());var ee=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Uc=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=we.get(n)?.description;return typeof e=="string"?e:void 0};var es=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),Qt=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function er(n){let e=n??{};return es(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&Qt(e.bytes,0)&&Qt(e.width)&&Qt(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)}var ns=n=>n.type.startsWith("image/"),ze=n=>(Array.isArray(n)?n:[n]).filter(er),ts=Symbol.for("@graview/core:file"),Kc=(n,e)=>(Object.defineProperty(ee(n),ts,{value:e,enumerable:!0}),n);function Yn(n){let e=ee(n);return e?.[ts]??(e?.innerType?Yn(e.innerType):void 0)}var Vc=()=>({href:se(),name:se(),type:se(),bytes:qn(),width:We(qn()),height:We(qn()),caption:We(se())});function Um(n){return Kc(Hn(Vc()).check(Qi(e=>er(e)&&(n==="file"||ns(e)),`${n==="image"?"an image":"a file"} the host stored, at a path on this host`)),n)}var ne=n=>n.charAt(0).toUpperCase()+n.slice(1),Xn=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"";function Wc(n,e){return{...e,kind:n,edges:e.edges??{}}}function ke(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??to()):!r.retired.includes(o)}function nr(n,e){let t=new Map,r=new Map;for(let o of n){let i=Z(e(o.kind),o).trim().toLowerCase();r.set(i,[...r.get(i)??[],o])}for(let o of r.values()){if(o.length<2)continue;let i=new Map;for(let s of o)i.set(s.kind,[...i.get(s.kind)??[],s]);for(let[s,a]of i){if(a.length===1){t.set(a[0].id,ae(e(s),s));continue}let d=a.map(p=>new Map(et(p,e(p.kind)).map(h=>[h.key,h.alone]))),c=[...new Set(d.flatMap(p=>[...p.keys()]))],u=p=>d.every(h=>!/\d/.test(h.get(p)??"")),l=[...c.filter(u),...c.filter(p=>!u(p))].find(p=>new Set(d.map(h=>h.get(p)??"")).size===a.length);a.forEach((p,h)=>{let y=l?d[h].get(l):void 0;t.set(p.id,y??p.id)})}}return t}function Z(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function qc(n,e){return n?.describe?n.describe(e):`${e.kind} ${Z(n,e)}`}var Hc=new Set(["id","kind","label"]);function tr(n){return n.title??z(n.name)}function z(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return ne(e)}function rs(n,e,t){let r=n?.display?.format?.[e];return r?r(t):typeof t=="string"?z(t):String(t)}function Jc(n,e,t){let r=n.tryDefinition(e);return`${t} ${t===1?ae(r,e):Ee(n,e).toLowerCase()}`}function Ee(n,e){return n.tryDefinition(e)?.plural??`${z(e).toLowerCase()}s`}function xn(n,e){return ne(Ee(n,e))}function Yc(n,e,t,r){let o=n.tryDefinition(e)?.edges,i=o&&Object.hasOwn(o,t)?o[t]:void 0;return(r==="out"?i?.description:i?.inverse)??z(t).toLowerCase()}function Se(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":z(e))}var Xc=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,Qc=/^(hour|honest|hono[ur]r?|heir)/;function os(n){let e=z(n).toLowerCase();return Qc.test(e)?"an":Xc.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function Qn(n){return`${os(n)} ${z(n).toLowerCase()}`}function ae(n,e){return n?.noun??z(e).toLowerCase()}function el(n,e){if(e.length===0)return!1;let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(^|[\\s\xB7,(/])${t}($|[\\s\xB7,)/])`).test(n)}function et(n,e,t={}){let r=e?.display,o=new Set([...Hc,...r?.hide??[]]),i=(t.said??[]).filter(l=>!!l),s=i.filter(l=>l.endsWith("\u2026")).map(l=>l.replace(/…$/,"").trim()).filter(l=>l.length>12),a=[],d=e?.fieldRoles,c=t.glance?r?.glance??[d?.who,d?.when].filter(l=>!!l):is(r?.page),f=[...new Set([...c,...tl(e),...Object.keys(n)])].filter(l=>Object.hasOwn(n,l)).map(l=>[l,n[l]]);for(let[l,p]of f){if(o.has(l)||p===void 0||p===null)continue;let h=r?.format?.[l],y=h?[]:ze(p);if(y[0]&&t.glance||!y[0]&&typeof p=="object"&&(!Array.isArray(p)||p.some(x=>typeof x=="object"&&x!==null))&&h===void 0)continue;let g=y[0]?y.map(x=>x.caption?`${x.name} \u2014 ${x.caption}`:x.name).join(", "):Array.isArray(p)?p.join(", "):typeof p=="boolean"?p?"Yes":"No":String(p),b=h?h(p):Array.isArray(p)||typeof p=="boolean"?g:typeof p=="string"&&wt.test(p)?Dn(p):typeof p=="string"&&nl(e,l)?rs(e,l,p):g;if(i.includes(b)||s.some(x=>b.startsWith(x))||t.glance&&(typeof p=="string"||typeof p=="number")&&i.some(x=>el(x,b)))continue;let S=Se(e,l),v=typeof p=="number"?`${S} ${b}`:typeof p=="boolean"&&!h?`${S}: ${b.toLowerCase()}`:b;if(a.push({key:l,label:S,value:b,stored:g,alone:v,long:typeof p=="string"&&ss(e,l,b),...y[0]?{files:y}:{}}),t.limit!==void 0&&a.length>=t.limit)break}return a}function nl(n,e){let t=n?.fields?.shape?.[e];for(let r=0;r<6&&t?._zod?.def?.innerType!==void 0;r++)t=t._zod.def.innerType;return t?._zod?.def?.type==="enum"}function tl(n){let e=n?.fields?.shape;return[...Object.keys(e??{}),...Object.keys(n?.computed??{})]}function is(n){return[...n?.fields??[],...(n?.groups??[]).flatMap(e=>e.fields)]}var rl=500,ol=160;function il(n){let e=n;for(let t=0;t<6&&e?._zod?.def?.innerType!==void 0;t++)e=e._zod.def.innerType;return e?._zod?.def?.type==="string"?e._zod.def:void 0}function ss(n,e,t){return il(n?.fields?.shape?.[e])?.checks?.some(o=>o._zod?.def?.check==="max_length"&&(o._zod.def.maximum??0)>rl)?!0:typeof t=="string"&&(t.includes(`
|
|
4
|
-
`)||t.length>ol)}function sl(n,e){let t=n?.display?.page,r=t?.groups??[],o=new Map(e.map(c=>[c.key,c])),i=new Set(is(t)),s=c=>c.flatMap(u=>o.has(u)?[o.get(u)]:[]),a=e.filter(c=>!i.has(c.key));return[{fields:[...s(t?.fields??[]),...r.length>0?[]:a]},...r.map(c=>({title:c.title,fields:s(c.fields)})),...r.length>0?[{title:"Details",fields:a}]:[]].filter(c=>c.fields.length>0)}var de="\0graview:unset",qe=n=>n===void 0||n===de;function vn(n){if(n.op!=="patch-node")return n;let e=t=>Object.fromEntries(Object.entries(t).map(([r,o])=>[r,o===void 0?de:o]));return{...n,before:e(n.before),after:e(n.after)}}function wn(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 rr(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 oe=class extends Error{constructor(t,r){super(r?`${t}
|
|
5
|
-
\u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function al(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new oe(`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,c]of Object.entries(a.edges)){if(c.to!=="*"){for(let f of c.to)if(!r.has(f))throw new oe(`Edge "${d}" on "${a.kind}" points at undeclared kind "${f}"`,`Declared kinds: ${[...r.keys()].join(", ")}`)}let u=o.get(d);u?u.from.push(a.kind):o.set(d,{from:[a.kind],decl:c})}let i=new Map;for(let[a,{from:d,decl:c}]of o){let u=d.map(f=>r.get(f).edges[a].to);i.set(a,{kind:a,from:d,to:u.includes("*")?"*":[...new Set(u.flat())],cardinality:c.cardinality??"many",...c.description===void 0?{}:{description:c.description}})}let s=new Map;for(let a of t)s.set(a.kind,Yi(a.fields,{id:se().check(mn(1)),kind:Xi(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 oe(`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,c){let u=r.get(d)?.edges[a];return u?u.to==="*"||u.to.includes(c):!1},parseNode(a){let d=a?.kind;if(typeof d!="string")throw new oe("Node is missing a `kind`");let c=s.get(d);if(!c)throw new oe(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);return c.parse(a)},__node:void 0}}function T(n){return`${n.kind}\0${n.from}\0${n.to}`}var as={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function ds(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function dl(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 ie(n,e){let t=new Map(n.nodes.map(l=>[l.id,l])),r=new Map(e.nodes.map(l=>[l.id,l])),o=e.nodes.filter(l=>!t.has(l.id)),i=n.nodes.filter(l=>!r.has(l.id)),s=[];for(let l of n.nodes){let p=r.get(l.id);if(!p)continue;let h=dl(l,p);h.length>0&&s.push({before:l,after:p,fields:h})}let a=new Map(n.edges.map(l=>[T(l),l])),d=new Map(e.edges.map(l=>[T(l),l])),c=e.edges.filter(l=>!a.has(T(l))),u=n.edges.filter(l=>!d.has(T(l))),f=new Set;for(let l of o)f.add(l.id);for(let l of i)f.add(l.id);for(let l of s)f.add(l.after.id);for(let l of[...c,...u])f.add(l.from),f.add(l.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:c,removedEdges:u,touched:[...f].sort()}}function cl(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?z(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var F=class extends Error{constructor(t,r){super(r?`${t}
|
|
6
|
-
${r}`:t);this.hint=r;this.name="GraphError"}},Y=class extends F{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}},or="n\0",ir="e\0",U=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;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=ie(t,this.snapshot());return this.emit(r),r}getNode(e){return this.nodes.get(e)}has(e){return this.nodes.has(e)}allNodes(){return[...this.nodes.values()]}count(e){return this.counts.get(e)??0}allEdges(){return[...this.edges.values()]}nodesOfKind(e){return this.allNodes().filter(t=>t.kind===e)}edgesOfKind(e){return this.allEdges().filter(t=>t.kind===e)}out(e,t){return this.resolve(this.outIndex.get(e),t,"to")}in(e,t){return this.resolve(this.inIndex.get(e),t,"from")}neighbors(e){let t=new Map;for(let r of[...this.out(e),...this.in(e)])t.set(r.id,r);return[...t.values()]}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.allNodes(),edges:this.allEdges()}}get size(){return{nodes:this.nodes.size,edges:this.edges.size}}applyPrimitives(e,t={}){let r=this.snapshot();try{for(let i of e)this.applyOne(i,t.restoring===!0,t.inPlace===!0);this.settleOrder()}catch(i){throw this.restore(r),i}let o=ie(r,this.snapshot());return this.emit(o),o}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])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.count(e)+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(or));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(ir));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 Y(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.nodes.delete(o),this.lapse(or+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new Y(e.id,`Cannot patch missing node "${e.id}"`);let i={...o};for(let[a,d]of Object.entries(e.after))qe(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),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(T(e.edge)))throw new Y(T(e.edge),`Cannot remove missing edge ${T(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")continue;let d=o[a];if(!d){delete t[a];continue}let c=d.safeParse(t[a]);c.success&&(c.data===void 0?delete t[a]:t[a]=c.data)}let i=this.failing(t);if(i===void 0)return t;let s=this.failing(e)?.fields??new Set;if([...i.fields].some(a=>r.includes(a)||!s.has(a)))throw this.refusal(t,i.error);return t}failing(e){try{this.schema.parseNode(e);return}catch(t){if(t instanceof oe)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}}}refusal(e,t){if(t instanceof oe)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?Z(i,e):r;return new F(`${s} does not match what ${o} declares`,cl(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new F(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),this.tally(e.kind,1),this.place(or+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 Y(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 F(`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=T(e);this.edges.has(s)||(this.edges.set(s,e),this.place(ir+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=T(e);this.edges.delete(t),this.lapse(ir+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}};var nt=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 ll(n,e){return{...e,name:n}}var tt=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function cs(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof tt,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 He(n,e,t={}){let r=t.context??{},o=t.onUnregistered??"skip",i=new Set(e.map(f=>f.name)),s=[];for(let f of e)f.scope==="graph"&&s.push(...cs(f,()=>f.evaluate({graph:n,subject:void 0,context:r}),void 0));let a=e.filter(f=>f.scope!=="graph"),d=new Map;for(let f of a){let l=f.scope.kind,p=d.get(l);p?p.push(f):d.set(l,[f])}for(let f of n.allNodes()){let l=n.schema.tryDefinition(f.kind),p=l?.requiresInvariant?.(f)??null;if(t.subjectFilter&&!t.subjectFilter(f,r))continue;if(p!==null&&!i.has(p)){if(o==="throw")throw new nt(p,f.id);continue}let h=!ke(l,f,t.today);for(let y of d.get(f.kind)??[]){if(h&&y.judgesPast!==!0)continue;let m=y.scope.match;m&&!m(f)||s.push(...cs(y,()=>y.evaluate({graph:n,subject:f,context:r}),f.id))}}let c=new Set,u=s.filter(f=>{let l=`${f.message}|${[...f.nodeIds].sort().join(",")}`;return c.has(l)?!1:(c.add(l),!0)}).map(f=>{let l=kt(f.message);return l===f.message?f:{...f,message:l}});return sr?sr(n,e,u):u}var sr;function ly(n){sr=n}function ul(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 fl(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 ar=(n,e)=>n==="*"||n.includes(e);function D(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 K=n=>n.kind==="system"&&n.onBehalfOf===void 0,kn=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function ls(n){return Xn(n.map(e=>Qn(z(e).toLowerCase())),"or")}function _e(n,e,t,r,o,i,s={},a){if(!n)return{ok:!0};if(K(e))return{ok:!0};if(e=D(e),o!==void 0){if(_e(n,e,t,r,void 0,i).ok)return{ok:!0};if(o.some(h=>_e(n,e,h,r,void 0,i).ok))return{ok:!0};let f=[t,...o],l=[...new Set(f.flatMap(h=>dr(n,h,r)))].sort(),p=l.length===0?o.length===0?"no declared act creates or changes it, so no role can":"no role can":`${ls(l)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:l,message:us(n,f,r,p,s)}}}let d=!1;for(let f of n.grants){if(!kn(f,e)||!ar(f.mutations,t)||f.kinds!==void 0&&f.kinds!=="*"&&(r===void 0||!f.kinds.includes(r))||f.self&&(i===void 0||e.id===void 0||i!==e.id))continue;let l=f.ownEnd?a?.()??[]:[e.id];if(!l.length||l.some(p=>p!==e.id)){d=!0;continue}return{ok:!0}}let c=dr(n,t,r),u=d?"only on your own end of the link":c.length===0?"no role can":`${ls(c)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:c,message:us(n,[t],r,u,s)}}}function us(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>fs(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${Qn(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function fs(n,e,t){return[...new Set(ps(n,e,t).flatMap(r=>r.describe||[]))]}var ps=(n,e,t)=>n.grants.filter(r=>ar(r.mutations,e)&&(t===void 0||ar(r.kinds??"*",t)));function dr(n,e,t){let r=ps(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function cr(n,e,t){return n?t.filter(r=>{let o=D(e).id;return lr(r).some(i=>_e(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var lr=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];var Je=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};function ur(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function fr(n,e={}){let t=typeof n=="string"?n:n.address,r=ur(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function pl(n,e){let t=ur(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 gs=Symbol.for("@graview/core:node-ref"),hs=n=>typeof n=="object"&&n!==null?n[gs]:void 0;function pr(n="*"){return hl(se().check(mn(1)),n)}function hl(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,gs,{value:t,enumerable:!0,configurable:!0})};return r(n),r(ee(n)),n}function hr(n){if(typeof n!="object"||n===null)return;let e=hs(n);if(e)return e;let t=ee(n),r=hs(t);if(r)return r;let o=t?.innerType;return o?hr(o):void 0}function Ne(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=hr(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}function ms(n){let e=ee(n)?.innerType;return e===void 0?n:ms(e)}var gl={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]},ml=n=>(n?._zod?.def?.checks??[]).map(e=>e._zod?.def).filter(e=>e!==void 0);function Ye(n){let e=ms(n),t=ee(e),r=t?.type,o=ml(e);if(r==="enum")return{type:"choice",options:Object.keys(t?.entries??{})};let i=Yn(e);if(i)return i==="image"?{type:"file",image:!0}:{type:"file"};if(r==="boolean")return{type:"boolean"};if(r==="array"){let s=Ye(t?.element);return s.type==="unknown"?{type:"unknown"}:{type:"several",of:s}}if(r==="number"){let s,a,d;for(let c of o){c.check==="multiple_of"&&typeof c.value=="number"?d=c.value:c.check==="number_format"&&(c.format==="safeint"||c.format==="int32"||c.format==="uint32")&&(d??=1);let u=c.check==="number_format"&&c.format?gl[c.format]:void 0,f=u?u[0]:c.check==="greater_than"&&c.inclusive&&typeof c.value=="number"?c.value:void 0,l=u?u[1]:c.check==="less_than"&&c.inclusive&&typeof c.value=="number"?c.value:void 0;f!==void 0&&(s=s===void 0?f:Math.max(s,f)),l!==void 0&&(a=a===void 0?l:Math.min(a,l))}return{type:"number",...s===void 0?{}:{min:s},...a===void 0?{}:{max:a},...d===void 0?{}:{step:d}}}if(r==="string"){let a=[t?.pattern,...o.map(c=>c.pattern)].filter(c=>c instanceof RegExp).map(c=>c.source);return a.some(c=>c.includes("\\d{4}"))?a.some(c=>c.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"}:o.some(c=>c.check==="max_length"&&typeof c.maximum=="number"&&c.maximum>500)?{type:"text",long:!0}:{type:"text"}}return{type:"unknown"}}function yl(n,e){let t=n?.shape;return!t||!(e in t)?{type:"unknown"}:Ye(t[e])}function bl(n,e){return n.display?.labels?.[e]??z(e)}function bs(n){let e=Ye(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function xl(n,e){let t=new Map,r=n.tryDefinition(e);for(let[o,i]of Object.entries(r?.edges??{}))t.set(o,{key:o,label:i.description?ne(i.description):z(o),about:"edge",far:i.to==="*"?[...n.kinds]:[...i.to]});for(let o of n.definitions)if(o.kind!==e)for(let[i,s]of Object.entries(o.edges??{}))t.has(i)||s.to!=="*"&&!s.to.includes(e)||t.set(i,{key:i,label:s.inverse?ne(s.inverse):z(i),about:"edge",far:[o.kind]});return[...t.values()]}var vl=["current","past","any","flagged","clear"];function xs(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let r=t.retired.map(String);return e.some(o=>o.key===t.field&&r.includes(o.value))}function vs(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let r=new Set(t.display?.hide??[]),o=t.fields.shape??{},i=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],a=[];for(let[f,l]of Object.entries(o)){if(f==="id"||f==="kind"||f==="label"||r.has(f))continue;let p=bs(l);if(!p)continue;let h=bl(t,f),y=p==="choice"?wl(l):p==="boolean"?["true","false"]:void 0,m={key:f,label:h,about:"field",type:p,...y?{options:y}:{}};i.push(m),s.push(m),(p==="boolean"||p==="choice")&&a.push(m),p==="date"&&a.push({...m,buckets:["day","week","month","year","decade"]})}for(let f of xl(n,e))i.push(f),s.push(f),a.push(f);let d={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...vl]:["flagged","clear"]};s.push(d);let c=t.fieldRoles?.order,u=c&&(c in o||c==="label")?{by:c,direction:"asc"}:void 0;return{kind:e,sorts:i,filters:s,groups:a,...u?{natural:u}:{}}}function wl(n){let e=Ye(n);return e.type==="choice"?e.options:[]}var kl=["day","week","month","year","decade"];function ws(n){let e={};if(n.q&&n.q.trim().length>0&&(e.query=n.q),n.sort){let[t,r]=n.sort.split(":");t&&(e.sort={by:t,direction:r==="desc"?"desc":"asc"})}if(n.filter){let t=[];for(let r of n.filter.split(",")){let o=r.indexOf(":");o<=0||t.push({key:r.slice(0,o),value:r.slice(o+1)})}t.length>0&&(e.filter=t)}if(n.group){let[t,r]=n.group.split(":");t&&(e.group={by:t,...kl.includes(r)?{bucket:r}:{}})}return e}var Sl=n=>n,ys=n=>n;function _l(n,e,t){let r=new Map;for(let o of[...n.out(e,t),...n.in(e,t)])r.set(o.id,o);return[...r.values()]}function ks(n,e,t){let r=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return ke(r,ys(e),n.today);case"past":return!ke(r,ys(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let o=r?.fields.shape??{};if(t.key in o){let s=Sl(e)[t.key],a=bs(o[t.key]);if(a==="date"){let[d,c]=t.value.split(":");if(typeof s!="string"||!c)return!1;let u=s.slice(0,10);return d==="before"?u<c:d==="after"?u>c:u===c}if(a==="boolean")return String(s)===t.value;if(a==="number"){let d=t.value.lastIndexOf(":"),c=d>0?t.value.slice(0,d):"",u=Number(t.value.slice(d+1));if(c==="at-most"||c==="at-least")return typeof s!="number"||!Number.isFinite(u)?!1:c==="at-most"?s<=u:s>=u}return String(s)===t.value}let i=_l(n.graph,e.id,t.key);return t.value==="*"?i.length>0:t.value==="none"?i.length===0:i.some(s=>s.id===t.value)}var $l=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 })`,Xe=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?$l(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 Sn(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return gr(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=U.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 Sn(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 gr(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,ops:i,undone:i.every(a=>e.has(a.id))}})}var _n=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=T(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=T(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,Ss(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,Ss(t,e.after));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function Ss(n,e){let t={...n};for(let[r,o]of Object.entries(e))qe(o)?delete t[r]:t[r]=o;return t}var Ol=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"?n.id:void 0;function mr(n,e,t,r){let o=u=>{let f=e.node(u);return f?t.served(f,e.writerOf(u))!==void 0:t.sees?.(u)??!1},i=Ol(n);if(i===void 0){let u=n.edge,f=t.edgeClean(u)&&o(u.from)&&o(u.to);return e.apply(n),{primitives:f?[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),c=d?t.served(d,e.writerOf(i)):void 0;if(!a&&!c)return{primitives:[],faithful:!1};if(!a&&c){let u=e.incident(i).filter(l=>t.edgeClean(l)&&o(l.from===i?l.to:l.from)).map(l=>({op:"add-edge",edge:l})),f=n.op==="add-node"&&c===n.node&&u.length===0;return{primitives:f?[n]:[{op:"add-node",node:c},...u],faithful:f}}if(a&&!c){let u=n.op==="remove-node"&&a===s;return{primitives:u?[n]:[{op:"remove-node",node:a}],faithful:u}}if(n.op==="patch-node"){let u=(l,p)=>h=>h in l==(p!==void 0&&h in p);if(Object.keys(n.after).every(l=>u(a,s)(l)&&u(c,d)(l)))return{primitives:[n],faithful:!0};let f=l=>Object.fromEntries(Object.keys(n.after).map(p=>[p,p in l?l[p]:de]));return{primitives:[{op:"patch-node",id:i,before:f(a),after:f(c)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:c}],faithful:!1}}function _s(n,e,t){if(n.length===0)return[];let r=e.log.all(),o=r[0]?.seq??0,i=n.every(l=>r[l.seq-o]?.id===l.id),s=new _n(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(l=>{let p=D(l.author).id,h=l.primitives.map(y=>mr(y,s,t,()=>p));return{op:l,primitives:h.flatMap(y=>y.primitives),faithful:h.every(y=>y.faithful)}});let a=new Set(n.map(l=>l.seq)),d=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let l of a)l<d&&(d=l),l>c&&(c=l);d-=o,c-=o;let u=Al(r,d,e.present,t),f=u?new _n(e.present,e,u.unversioned):s;for(let l=r.length-1;l>=d;l--){let p=r[l].primitives;for(let h=p.length-1;h>=0;h--)f.undo(p[h])}return Rl(n,r,d,c,a,f,u?.judge??t,e)}function Al(n,e,t,r){let{sees:o,names:i}=r;if(!o||!i)return;let s=new Set,a=new Set,d=new Set,c=(f,l)=>{s.has(f)||a.has(f)||(o(f)?i(l)?(a.add(f),d.delete(f)):d.add(f):(s.add(f),d.delete(f)))};for(let f=e;f<n.length;f++)for(let l of n[f].primitives)l.op==="add-node"||l.op==="remove-node"?c(l.node.id,l.node):l.op==="patch-node"&&(c(l.id,l.before),c(l.id,l.after));for(let f of d){let l=t.getNode(f);l&&i(l)&&(d.delete(f),a.add(f))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(f,l)=>d.has(f.id)?f:s.has(f.id)?void 0:r.served(f,l)}}}function Rl(n,e,t,r,o,i,s,a){let d=new Map;for(let c=t;c<=r;c++){let u=e[c];if(i.begin(u.seq),!o.has(u.seq)){for(let p of u.primitives)i.apply(p);continue}let f=(p,h)=>a.writers?.writerAt(p,h,u.seq+1),l=u.primitives.map(p=>mr(p,i,s,f));d.set(u.seq,{op:u,primitives:l.flatMap(p=>p.primitives),faithful:l.every(p=>p.faithful)})}return n.map(c=>d.get(c.seq))}function $s(n,e,t,r){let o=new _n(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>mr(i,o,t,()=>r).primitives)}var rt="A change you cannot see",As={kind:"system",id:"withheld",name:"Someone"};function Qe(n){return n.withheld===!0}function $n(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 Rs=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&j(r,e));function Ps(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!Rs(r,e)?r:void 0;return{sees:e,shows:e,served:t,servedWith:t,optional:()=>!1,kindOf:()=>{}}}function j(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(j(n[t],e))return!0;return!1}for(let t in n)if(Object.hasOwn(n,t)&&(!e(t)||j(n[t],e)))return!0;return!1}function zs(n,e){let t=r=>!e(r);return n.primitives.some(r=>$n(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&j(n.mutation.args,e)}function Pl(n,e){if($n(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 Rs(t,e.sees)?{op:"remove-node",node:Object.fromEntries(Object.entries(t).filter(([r,o])=>r==="id"||r==="kind"||!j(o,e.sees)))}:n}case"patch-node":{let t=e.kindOf(n.id),r={};for(let[i,s]of Object.entries(n.after))if(!j(s,e.sees))r[i]=s;else if(t!==void 0&&e.optional(t,i))r[i]=de;else return;let o=Object.fromEntries(Object.entries(n.before).filter(([,i])=>!j(i,e.sees)));return{op:"patch-node",id:n.id,before:o,after:r}}case"add-edge":case"remove-edge":return j(n.edge,e.sees)?void 0:n}}function yr(n,e,t){let r=Ps(e),o=i=>r.shows(i)&&Es(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:As,intent:rt,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=Pl(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 $e(n,e){let t=Ps(e);if(t.hides?.()===!1)return[...n];let r=t.pin?.()??t;if(r.timeline){let o={served:(i,s)=>r.servedWith(i,s),edgeClean:i=>!j(i,r.sees),sees:r.sees,names:i=>j(i,r.sees)};return _s(n,r.timeline,o).map(({op:i,primitives:s,faithful:a})=>(!i.withheld&&a?Os(i,r,s):void 0)??yr(i,r,s))}return n.map(o=>(!o.withheld&&!zs(o,r.shows)?Os(o,r):void 0)??yr(o,r))}function Os(n,e,t){if(t&&t.length<n.primitives.length){if(!t.length)return;n={...n,primitives:t,inverse:n.inverse.filter(l=>$n(l).every(e.shows))}}let r=l=>e.sees(l)&&Es(e,l),o=n.reads.filter(r),i=new Set(n.primitives.flatMap($n)),s=n.writes.filter(l=>r(l)||e.sees(l)&&i.has(l)),a=o.length===n.reads.length&&s.length===n.writes.length?n:{...n,reads:o,writes:s},d=e.actor!==void 0&&D(n.author).id===e.actor;if(!d&&n.described?.some(l=>!e.sees(l)))return;if(!j(n,e.sees))return a;let c=new Set,u=l=>{if(typeof l=="string")c.add(l);else if(Array.isArray(l))for(let p of l)u(p);else if(l!==null&&typeof l=="object")for(let[p,h]of Object.entries(l))c.add(p),u(h)};t&&u(t);let f=l=>e.sees(l)||c.has(l);if(!j(a.inverse,f))return d&&n.mutation&&u(n.mutation.args),j({...a,primitives:[],inverse:[]},d?f:e.sees)?void 0:a}function Es(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var Me=class extends F{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function On(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(l=>t.has(l.batch)&&!r.has(l.id)),i=[...n.epochs()].reverse().find(l=>l.horizon);if(i){let l=new Set(n.all().map(h=>h.batch)),p=e.filter(h=>!l.has(h));if(p.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${p.map(h=>`batch ${h}`).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(Qe))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(Qe)?"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(l=>l.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 l of o)for(let p of l.writes)s.add(p);let a=Math.min(...o.map(l=>l.seq)),d=n.epochs().find(l=>l.change!==void 0&&l.seq>a);if(d){let l=o.find(p=>p.seq<d.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${l.intent}": ${l.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 c=[];for(let l of n.all()){if(l.seq<=a||t.has(l.batch)||r.has(l.id))continue;let p=l.reads.filter(h=>s.has(h));p.length>0&&c.push({op:l,overlap:p})}if(c.length===0)return{ok:!0,ops:o};let u=c.filter(l=>!Qe(l.op)).map(l=>`"${l.op.intent}" (op ${l.op.id}, read ${l.overlap.join(", ")})`).join("; ");if(c.some(l=>Qe(l.op)))return{ok:!1,ops:o,blockedBy:c,includeBatches:[],message:`Cannot undo on its own \u2014 ${u?`a later operation depends on it: ${u}; and `:""}a later change you cannot see depends on it, which only somebody who can see it can take back.`};let f=[...new Set(c.map(l=>l.op.batch))];return{ok:!1,ops:o,blockedBy:c,includeBatches:f,message:`Cannot undo on its own \u2014 a later operation depends on it: ${u}. Include ${f.map(l=>`batch ${l}`).join(", ")} to undo them together.`}}function Ns(n){return[...n].sort((e,t)=>t.seq-e.seq).flatMap(e=>e.inverse)}var Is=(n,e)=>`${n}\0${e}`,Ms=new WeakMap;function zl(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(Is(r,o));if(!s)return;let a=0,d=s.length;for(;a<d;){let c=a+d>>1;s[c].seq<i?a=c+1:d=c}return a===0?void 0:s[a-1].by}}}}function El(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=>!qe(n.after[e]))]}function Nl(n,e){let t=n.end,r=D(e.author).id,o=e.undoes!==void 0?n.seqOf.get(e.undoes):void 0,i=[];for(let s of e.primitives){let a=El(s);if(!a)continue;let[d,c]=a;for(let u of c){let f=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,u,o):void 0,l=Is(d,u),p=n.fields.get(l);p||n.fields.set(l,p=[]),p.push({seq:t,by:f}),i.push(l)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function Ml(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 An(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Ms.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&&Ml(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Ms.set(n,o=zl(r));for(let i=o.end;i<t;i++)Nl(o,e[i-r]);return o.writers}var br=new WeakMap;function Il(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 jl(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=D(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 Tl(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 Ie(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=br.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&&Tl(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||br.set(n,o=Il(r,r>0?Dl(n,r)?.creators:void 0));for(let i=o.end;i<t;i++)jl(o,e[i-r]);return o.records}function Dl(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function js(n,e){Ie(n);let t=br.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 Rn(n,e,t,r,o){if(!n?.sees?.length||K(e))return!0;let i=n.sees.filter(s=>s.kinds.includes(t.kind));return i.length===0?!1:(e=D(e),i.some(s=>{if(!kn(s,e))return!1;if(!s.own&&!s.via)return!0;let a=e.id;if(a===void 0)return!1;let d=c=>c.id===a;return s.via?r.out(t.id,s.via).some(d)||r.in(t.id,s.via).some(d):t.id===a||r.out(t.id).some(d)||r.in(t.id).some(d)||o?.creatorOf(t.id)===a}))}var Ts=new Set;function ot(n,e){return K(e)?Ts:n.modules?.disabledKinds??Ts}function ge(n,e){return K(e)?!1:(n.policy?.sees?.length??0)>0||ot(n,e).size>0}function Oe(n,e){return t=>{let r=ot(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=Ie(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&Rn(n.policy,e,i,n.graph,o);let s=o.kindOf(t);return s===void 0?!0:!r.has(s)&&Rn(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o)}}var Fl={out:()=>[],in:()=>[]};function Zl(n,e,t=new Map,r){let o=ot(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=Ie(n.log);return s=>{let a=t.get(s);if(a!==void 0)return a;let d,c=n.graph.getNode(s);if(c)d=!o.has(c.kind)&&Rn(n.policy,e,c,n.graph,i);else{let u=i.kindOf(s);if(u===void 0)return r?.add(s),!0;d=!o.has(u)&&Rn(n.policy,e,{id:s,kind:u},Fl,i)}return t.set(s,d),d}}function Cl(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 Pn(n,e){return Cs(n,e).lens}var vr=()=>({judged:new Map,shown:new Map});function Cs(n,e){let t=Cl(n.schema),r=K(e)?void 0:D(e).id,o=()=>n.log.length??n.log.all().length,i=new WeakMap,s=n.graph,a=(u,f,l,p,h)=>{let y=(k,R)=>{if(!u(k.id))return;let P;for(let te in k)if(!(!Object.hasOwn(k,te)||te==="id"||te==="kind"||!j(k[te],u))&&!(r!==void 0&&R(te)===r)){if(!t(k.kind,te))return;(P??=[]).push(te)}if(!P)return k;let W=P.join("\0"),q=i.get(k);if(q?.without===W)return q.node;let ye=Object.fromEntries(Object.entries(k).filter(([te])=>!P.includes(te)));return i.set(k,{without:W,node:ye}),ye},m=k=>{let R=l();return y(k,P=>f().writerAt(k.id,P,R))},g=new WeakMap,b=h?k=>{let R=g.get(k);return R||g.set(k,R={node:m(k)}),R.node}:m,S=k=>{if(!u(k))return!1;let R=s.getNode(k);return R===void 0||b(R)!==void 0},v=h?.shown??new Map,x=h?k=>{let R=v.get(k);return R===void 0&&v.set(k,R=S(k)),R}:S,w=s.outEdges&&s.inEdges?{present:{getNode:k=>s.getNode(k),outEdges:k=>s.outEdges(k),inEdges:k=>s.inEdges(k)},log:n.log,get writers(){return f()}}:void 0,_={sees:u,shows:x,served:b,servedWith:y,optional:t,kindOf:p,...r!==void 0?{actor:r}:{},...w?{timeline:w}:{},hides:()=>ge(n,e),pin:h?()=>_:()=>d(vr())};return _};function d(u){let f,l=o(),p=Ie(n.log);return a(Zl(n,e,u.judged,u.unnamed),()=>f??=An(n.log),()=>l,h=>s.getNode(h)?.kind??p.kindOf(h),u)}return{lens:a(Oe(n,e),()=>An(n.log),o,u=>s.getNode(u)?.kind??Ie(n.log).kindOf(u)),pinWith:d}}var Ds=new WeakMap,Fs=new WeakMap,Ll=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 Ls(n,e){if(!ge(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...ot(n,e)].sort().join("\0"),s=Gs(e),a=Ds.get(n.log);a||Ds.set(n.log,a=new Map);let d=a.get(s),{pinWith:c}=Cs(n,e),u=Fs.get(n.log);u||Fs.set(n.log,u=new Set);let f=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&f){if(d.length===r)return d.ops;let h=t.slice(d.length-o),y=c(vr()),m=!0,g=Ll(h);for(let b of g){let S=d.judgments.judged.get(b),v=d.judgments.shown.get(b);if(S!==void 0&&y.sees(b)!==S||v!==void 0&&y.shows(b)!==v){m=!1;break}}if(m){for(let b of g)if(u.has(b)){m=!1;break}}if(m){let b=[...d.ops,...$e(h,c(d.judgments))],S={horizon:o,off:i,length:r,last:t.at(-1),ops:b,judgments:d.judgments};return a.set(s,S),b}}let l={...vr(),unnamed:u},p=$e(t,c(l));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:p,judgments:l}),p}function Gl(n,e,t){return(t.subjectId===void 0||!e(t.subjectId)||n.shows(t.subjectId))&&t.nodeIds.every(r=>!e(r)||n.shows(r))&&!j(t,n.sees)}function Bl(n,e,t){if(!ge(n,e))return t;let r=Pn(n,e),o=s=>n.graph.getNode(s)!==void 0||Ie(n.log).kindOf(s)!==void 0,i={...t};if(t.diff){let s=t.diff,a=An(n.log),d=n.log.length??n.log.all().length,c=t.ops?.[0]?.seq??d,u=D(e).id,f=(x,w)=>_=>a.writerAt(x,_,w),l=(x,w)=>r.shows(x.id)?r.servedWith(x,w):void 0,p=(x,w)=>x.flatMap(_=>l(_,w(_.id))??[]),h=x=>r.shows(x.from)&&r.shows(x.to)&&!j(x,r.sees),y=(x,w)=>t.ops?f(x,d):_=>w===void 0||w.includes(_)?u:a.writerAt(x,_,d),m=s.changedNodes.flatMap(x=>{let w=l(x.before,f(x.before.id,c)),_=l(x.after,y(x.after.id,x.fields));return w&&_?[{before:w,after:_,fields:x.fields.filter(k=>k in w||k in _)}]:[]}),g=new Set(s.changedNodes.map(x=>x.after.id)),b=new Map;for(let x of t.ops?.flatMap(w=>w.primitives)??t.primitives??[])x.op!=="patch-node"||g.has(x.id)||b.set(x.id,[...b.get(x.id)??[],...Object.keys(x.after)]);let v=[...b].flatMap(([x,w])=>{let _=n.graph.getNode(x);if(!_)return[];let k=l(_,f(x,c)),R=l(_,y(x,w));return k&&R&&JSON.stringify(k)!==JSON.stringify(R)?[{before:k,after:R,fields:w}]:[]});i.diff={addedNodes:p(s.addedNodes,x=>y(x)),removedNodes:p(s.removedNodes,x=>f(x,c)),changedNodes:[...m,...v],addedEdges:s.addedEdges.filter(h),removedEdges:s.removedEdges.filter(h),touched:[...s.touched.filter(r.shows),...[...b.keys()].filter(x=>r.shows(x)&&!s.touched.includes(x))]}}if(t.ops&&(i.ops=$e(t.ops,r)),t.primitives){let s=i.ops;i.primitives=s?s.flatMap(a=>a.primitives):r.timeline?$s(t.primitives,r.timeline,{served:(a,d)=>r.servedWith(a,d),edgeClean:a=>!j(a,r.sees),sees:r.sees},D(e).id):$e([{id:"",seq:0,batch:"",author:{kind:"system"},intent:"",mutation:null,primitives:t.primitives,inverse:[],reads:[],writes:[],at:""}],r)[0].primitives}return t.reads&&(i.reads=t.reads.filter(s=>r.shows(s)&&o(s))),t.writes&&(i.writes=t.writes.filter(r.shows)),t.intent!==void 0&&j(t.intent,r.sees)&&(i.intent=rt),t.violationsAfter&&Object.assign(i,wr?wr(n,je(n,e),!!t.ops,i.primitives??[]):{introduces:[],resolves:[],violationsAfter:[]}),i}var wr,Jy=n=>void(wr=n);function kr(n,e){return{all:()=>n,undoneIds:()=>Sn(n),epochs:e}}var Zs=new WeakMap;function Gs(n){let e=K(n)?n:D(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?"for":""}`}var xr=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t};function je(n,e){if(!ge(n,e))return n;let t=Gs(e),r=Zs.get(n);r||Zs.set(n,r=new Map);let o=r.get(t);if(o)return o;let i=n.graph,s=Pn(n,e),a=v=>{let x=P=>P===void 0?void 0:v.served(P),w=P=>x(P)!==void 0,_=P=>w(i.getNode(P));return{served:x,seenNode:w,seenId:_,seenEdge:P=>_(P.from)&&_(P.to)&&!j(P,v.sees),servedAll:P=>P.flatMap(W=>x(W)??[])}},{served:d,seenId:c}=a(s),u=()=>a(s.pin?.()??s),f=(v,x)=>{let w=An(n.log),_=s.pin?.()??s,k=v.nodes.flatMap(P=>_.servedWith(P,W=>w.writerAt(P.id,W,x))??[]),R=new Set(k.map(P=>P.id));return{nodes:k,edges:v.edges.filter(P=>R.has(P.from)&&R.has(P.to)&&!j(P,_.sees))}},l=v=>{let x=f(v.base,v.seq);if(!v.creators)return{...v,base:x};let w=new Set(x.nodes.map(k=>k.id)),_=Object.fromEntries(Object.entries(v.creators).filter(([k,R])=>w.has(k)&&!j(R,s.sees)));return{...v,base:x,creators:_}},p=v=>v&&l(v),h=()=>Ls(n,e),y=()=>kr(h(),()=>n.log.epochs()),m=new Proxy(i,{get(v,x){switch(x){case"getNode":return w=>d(v.getNode(w));case"has":return c;case"allNodes":return()=>u().servedAll(v.allNodes());case"nodesOfKind":return w=>u().servedAll(v.nodesOfKind(w));case"count":return w=>u().servedAll(v.nodesOfKind(w)).length;case"allEdges":return()=>v.allEdges().filter(u().seenEdge);case"edgesOfKind":return w=>v.edgesOfKind(w).filter(u().seenEdge);case"out":return(w,_)=>{let k=u();return k.seenId(w)?k.servedAll(v.out(w,_)):[]};case"in":return(w,_)=>{let k=u();return k.seenId(w)?k.servedAll(v.in(w,_)):[]};case"neighbors":return w=>{let _=u();return _.seenId(w)?_.servedAll(v.neighbors(w)):[]};case"outEdges":return(w,_)=>v.outEdges(w,_).filter(u().seenEdge);case"inEdges":return(w,_)=>v.inEdges(w,_).filter(u().seenEdge);case"snapshot":return()=>{let w=v.snapshot(),_=u();return{...w,nodes:_.servedAll(w.nodes),edges:w.edges.filter(_.seenEdge)}};case"size":{let w=u();return{nodes:w.servedAll(v.allNodes()).length,edges:v.allEdges().filter(w.seenEdge).length}}default:return xr(v,x)}}}),g=()=>{let v=h();return gr(v,Sn(v))},b=new Proxy(n.log,{get(v,x){switch(x){case"all":case"toJSON":return()=>[...h()];case"epochs":return()=>v.epochs().map(l);case"lastEpoch":return()=>p(v.lastEpoch());case"live":return()=>{let w=h(),_=Sn(w);return w.filter(k=>!_.has(k.id))};case"get":return w=>h().find(_=>_.id===w);case"opsInBatch":return w=>h().filter(_=>_.batch===w);case"batches":return g;default:return xr(v,x)}}}),S=new Proxy(n,{get(v,x){switch(x){case"graph":return m;case"log":return b;case"snapshot":return m.snapshot;case"batches":return g;case"canUndo":return w=>On(y(),typeof w=="string"?[w]:w);case"violations":return w=>v.violations(w,m).filter(_=>Gl(s,k=>i.has(k),_));case"findings":return()=>v.findings().filter(w=>(w.id.includes("->")?w.id.split("->").map((k,R)=>R===0?k.slice(k.indexOf(":")+1):k):[w.id]).every(k=>!i.has(k)||c(k))&&!j(w,s.sees));case"wouldChange":return w=>v.wouldChange(w,e);case"preview":return(w,_,k)=>v.preview(w,_,{author:e,...k});case"seenBy":return w=>je(v,w);case"seenFor":return e;case"checkpoint":return(...w)=>p(v.checkpoint(...w));default:return xr(v,x)}}});return r.set(t,S),S}var Bs=["full","summary","glyph"];function me(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function ce(n,e){return`/${me(n.tryDefinition(e)?.plural??`${e}s`)}`}function Ul(n,e,t){return`${ce(n,e)}/${encodeURIComponent(t)}`}function zn(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function En(n,e){return e.some(t=>t.as===n.as&&t.kind!==n.kind)}var Te=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function Sr(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function Kl(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,c,u){let f={kind:a,cardinality:d.cardinality,fidelity:d.fidelity,view:c,...u?.title?{title:u.title}:{},...u?.across?{across:u.across}:{},...u?.beside?{beside:!0}:{}};if(r.push(f),u?.beside||e.set(Te(a,d),f),u?.title){let l=me(u.title);e.set(Te(a,d,l),f),d.cardinality==="many"&&!t.some(p=>p.kind===a&&p.as===l)&&t.push({kind:a,title:u.title,as:l,...u.across?{across:u.across}:{}})}return s},places:()=>t,forget(a,d){for(let u of Bs)e.delete(Te(a,{cardinality:"many",fidelity:u},d));let c=t.findIndex(u=>u.kind===a&&u.as===d);return c>=0&&t.splice(c,1),s},lookup(a,d){return e.get(Te(a,d))?.view},resolve(a,d,c){if(c)for(let u of Sr(d.fidelity)){let f=e.get(Te(a,{cardinality:d.cardinality,fidelity:u},c));if(f)return f}for(let u of Sr(d.fidelity)){let f=e.get(Te(a,{cardinality:d.cardinality,fidelity:u}));if(f)return f}if(d.cardinality==="one")for(let u of Sr(d.fidelity)){let f=e.get(Te(a,{cardinality:"many",fidelity:u}));if(f)return f}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}function Or(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function st(n){return Or(n).replace(/ /g,"")}var it=new Map,Vl=5e4;function Ar(n){let e=it.get(n);if(e===void 0){it.size>=Vl&&it.clear();let t=Or(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},it.set(n,e)}return e}var Nn=n=>[...Ar(n).tokens];function De(n,e){if(e.length===0)return;let{whole:t,tokens:r}=Ar(n),o=e.join("");if(t.length===0)return;if(t===o)return"exact";if(e.every(s=>r.some(a=>a.startsWith(s))))return t.startsWith(o)?"prefix":e.every(s=>r.includes(s))?"word":"part"}function $r(n,e,t=48){let r=n.replace(/\s+/g," ").trim();if(r.length<=t)return r;let o=e[0],i=r.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=o?i.search(new RegExp(`(^|[^\\p{L}\\p{N}])${Wl(o)}`,"u")):-1,a=s<0?0:s+(i[s]&&/[\p{L}\p{N}]/u.test(i[s])?0:1),d=Math.max(0,a-Math.floor(t/3));if(d>0){let u=r.lastIndexOf(" ",d);d=u<0?0:u+1}let c=Math.min(r.length,d+t);if(c<r.length){let u=r.indexOf(" ",c);c=u<0||u-c>16?c:u}return`${d>0?"\u2026":""}${r.slice(d,c).trim()}${c<r.length?"\u2026":""}`}var Wl=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ql=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function Ks(n){let e=[],t=[];for(let r of n.trim().split(/\s+/).filter(Boolean)){let o=ql.exec(r);o?t.push({key:o[1],value:o[2]}):e.push(r)}return{words:e.join(" "),conditions:t}}var Us=new WeakMap;function Hl(n,e){let t=Us.get(e);if(t&&t.definition===n)return t.texts;let r=Jl(n,e);return Us.set(e,{definition:n,texts:r}),r}function Jl(n,e){let t=Z(n,e),r=[{field:"label",reading:"Name",text:t}];for(let o of et(e,n,{limit:Number.POSITIVE_INFINITY}))o.key==="label"||o.value===t||typeof e[o.key]!="boolean"&&r.push({field:o.key,reading:o.label,text:o.value});return r}var en={exact:0,prefix:1,word:2,part:3,field:4};function Vs(n,e,t){let r=Nn(t);if(r.length===0)return;let o=Hl(n,e),[i,...s]=o,a=De(i.text,r);if(a)return{field:"label",reading:i.reading,fragment:$r(i.text,r),strength:a};let d=l=>p=>Ar(p.text).tokens.some(h=>h.startsWith(l));if(!r.every(l=>o.some(d(l))))return;let c=Nn(i.text),u=r.find(l=>!c.some(p=>p.startsWith(l)))??r[0],f=s.find(d(u));return{field:f.field,reading:f.reading,fragment:$r(f.text,[u]),strength:"field"}}var Yl=512,Xl=64;function Ws(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-Yl),r=n[n.length-1].seq;for(let o of t){let i=Math.pow(.5,(r-o.seq)/Xl);for(let s of o.writes)e.set(s,(e.get(s)??0)+i)}return e}var Rr=(n,e)=>Ee({tryDefinition:()=>n},e),_r=(n,e)=>ce({tryDefinition:()=>n},e);function Ql(n,e,t){let r=n.tryDefinition(e),o=[{field:"plural",text:Rr(r,e)},{field:"kind",text:z(e)},...r?.noun?[{field:"noun",text:r.noun}]:[]],i;for(let s of o){let a=De(s.text,t);a&&(!i||en[a]<en[i.strength])&&(i={strength:a,...s})}return i}var eu,nu=(n,e)=>(eu??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qs=(n,e)=>n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||nu(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function tu(n,e,t={}){let r=n.schema,o=Ks(e),i=Nn(o.words),s=t.principal??{kind:"human"},a=n.kindsKeptFrom(s),d=n.modules.disabledKinds,c=o.conditions.filter($=>$.key==="kind").map($=>$.value),u=o.conditions.filter($=>$.key==="is").map($=>$.value),f=u.includes("any")||u.includes("past"),l=u.includes("past")&&!u.includes("any")&&!u.includes("current"),p=($,A)=>{let E=st(A),G=r.tryDefinition($);return st($)===E||st(Rr(G,$))===E},h=r.kinds.filter($=>!a.has($)&&!d.has($)&&(t.kinds===void 0||t.kinds.includes($))&&(c.length===0||c.some(A=>p($,A)))),m=o.conditions.filter($=>$.key!=="kind").map($=>({...$,admittedBy:h.filter(A=>vs(r,A).filters.some(E=>E.key===$.key))})),g=m.filter($=>$.key!=="is"),b=u.filter($=>$==="flagged"||$==="clear"||$==="past"),S={kinds:h,past:f},v={hits:[],words:o.words,conditions:m,searched:S,byKind:{},total:0,matched:[]};if(i.length===0&&g.length===0&&b.length===0)return v;let x=t.today,w=t.flagged??new Set(n.violations().flatMap($=>$.nodeIds)),_=t.touched??Ws(n.log.all()),k=new Set;for(let $ of t.from??[]){k.add($);for(let A of n.graph.neighbors($))k.add(A.id)}let R=ge(n,s)?Oe(n,s):void 0,P=$=>fr($,t.basePath===void 0?{}:{basePath:t.basePath}),W={schema:r,graph:n.graph,flagged:w,...x?{today:x}:{}},q=[],ye={};for(let $ of h){let A=r.tryDefinition($),E=m.filter(N=>N.key!=="is"&&N.admittedBy.includes($));if(i.length===0&&E.length===0&&b.length===0)continue;let G=xs(A,E);for(let N of n.graph.nodesOfKind($)){let be=ke(A,N,x);if(!f&&!G&&!be||R&&!R(N.id)||l&&be||!E.every(Xa=>ks(W,N,Xa))||u.includes("flagged")&&!w.has(N.id)||u.includes("clear")&&w.has(N.id))continue;let Re=i.length>0?Vs(A,N,o.words):E[0]?{field:E[0].key,reading:z(E[0].key),fragment:`${E[0].key}:${E[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${b[0]}`,strength:"field"};if(!Re)continue;let Tn=Z(A,N);ye[$]=(ye[$]??0)+1,q.push({hit:{about:"node",id:N.id,kind:$,label:Tn,why:Re,current:be,flagged:w.has(N.id),address:P(`${_r(A,$)}/${encodeURIComponent(N.id)}`)},tier:en[Re.strength],inKind:$===t.inKind?0:1,near:k.has(N.id)?0:1,past:be?0:1,touched:-(_.get(N.id)??0),flagged:w.has(N.id)?0:1,name:Tn,id:N.id})}}let te=$=>$==="exact"||$==="prefix"?-1:en[$],vt=($,A,E,G)=>({hit:$,tier:te(A),inKind:1,near:1,past:0,touched:0,flagged:1,name:E,id:G});if(i.length>0){for(let A of h){let E=Ql(r,A,i);if(!E)continue;let G=xn(r,A),N={field:E.field,reading:E.field==="plural"?"Plural":"Kind",fragment:E.text,strength:E.strength};q.push(vt({about:"kind",kind:A,label:G,why:N,count:ye[A]??0,address:P(_r(r.tryDefinition(A),A))},E.strength,G,`kind:${A}`))}let $=t.places??[];for(let A of $){if(!h.includes(A.kind)||A.across&&a.has(A.across))continue;let E=De(A.title,i);if(!E)continue;let G={field:"title",reading:"Title",fragment:A.title,strength:E},N=En(A,$)?_r(r.tryDefinition(A.kind),A.kind).slice(1):void 0,be=P(zn(A.as,N));q.push(vt({about:"place",kind:A.kind,title:A.title,as:A.as,why:G,address:be},E,A.title,`place:${A.kind}:${A.as}`))}for(let A of n.allInvariants()){let E=A.scope==="graph"?void 0:A.scope.kind;if(E&&!h.includes(E))continue;let G=A.label??z(A.name),N=De(G,i),be=N?void 0:De(z(A.name),i),Re=N??be;if(!Re)continue;let Tn={field:N?"label":"name",reading:N?"Rule":"Name",fragment:N?G:A.name,strength:Re};q.push(vt({about:"rule",name:A.name,label:G,...E?{kind:E}:{},why:Tn},Re,G,`rule:${A.name}`))}}q.sort(qs);let Va=t.limit??50,eo=q.slice(0,Va).map($=>$.hit),Wa=eo.flatMap($=>$.about==="node"?[n.graph.getNode($.id)]:[]).filter(Boolean),no=nr(Wa,$=>r.tryDefinition($)),qa=eo.map($=>$.about==="node"&&no.has($.id)?{...$,apart:no.get($.id)}:$),Ha=Object.values(ye).reduce(($,A)=>$+A,0),Ja=q.flatMap($=>$.hit.about==="node"?[$.hit.id]:[]),Ya=t.subject&&h.includes(String(n.graph.getNode(t.subject)?.kind))?Hs(n,t.subject,o.words,{principal:s}):[];return{hits:[...qa,...Ya],words:o.words,conditions:m,searched:S,byKind:ye,total:Ha,matched:Ja}}function Hs(n,e,t,r={}){let o=n.graph.getNode(e);if(!o)return[];let i=r.principal??{kind:"human"};if(n.kindsKeptFrom(i).has(o.kind))return[];let s=Nn(t),a=Z(n.schema.tryDefinition(o.kind),o),d=[];for(let u of n.allMutations()){let f=u.subject;if(!f||f.kinds!=="*"&&!f.kinds.includes(o.kind)||!n.permits({name:u.name,args:{[f.arg]:o.id}},i).ok)continue;let l=tr(u),p=Nn(l),h=s.filter(g=>p.some(b=>b.startsWith(g))),y=h.length>0?De(l,h):void 0,m=y?{field:"title",reading:"Act",fragment:l,strength:y}:{field:"subject",reading:"On",fragment:a,strength:"field"};d.push({hit:{about:"act",name:u.name,title:l,subject:o.id,why:m,destructive:u.destructive===!0},tier:y?en[y]:en.field+1,inKind:0,near:0,past:u.destructive?1:0,touched:0,flagged:u.pinned?0:1,name:l,id:`act:${u.name}`})}d.sort(qs);let c=d.map(u=>u.hit);return r.limit===void 0?c:c.slice(0,r.limit)}function ru(n,e){let t=e.kinds.map((i,s)=>{let a=Rr(n.tryDefinition(i),i);return s===0?a:a.toLowerCase()}),r=Xn(t)||"Nothing";return e.kinds.some(i=>n.tryDefinition(i)?.lifecycle)?e.past?`${ne(r)}, past ones included.`:`${ne(r)}, current ones; add is:any for past ones.`:`${ne(r)}.`}function Js(n,e,t){let r=[...e?.creates??[],...e?.subject&&e.subject.kinds!=="*"?e.subject.kinds:[]];for(let o of r){let i=n.tryDefinition(o),s=i?.fields?.shape??{};if(!i||!(t in s))continue;let a=i.display?.format?.[t];return{label:i.display?.labels?.[t]??Se(i,t),option:c=>a?a(c):z(c)}}return{label:Se(void 0,t),option:o=>z(o)}}var Fe=class extends F{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"}};function ou(n,e,t){if(t instanceof Fe){let r=e.find(i=>i.name===t.mutation);return`Not yet: ${t.issues.map(i=>{let s=i.path.length>0?Js(n,r,String(i.path[0])).label:void 0;return s?`${s} \u2014 ${i.message.replace(/^./,a=>a.toLowerCase())}`:i.message}).join("; ")}.`}return t instanceof Error?t.message:String(t)}var at={scene:0,overview:10,rail:20,popover:30,dialog:40,toast:50},iu={plots:0,stage:1,tag:2,ties:2,lines:3,tieLabels:4,occupants:6,seatMarks:7,zoom:8,card:10,opened:11},su={under:0,raised:1,over:2},Pr=n=>`--graview-layer-${n}`,au=n=>`var(${Pr(n)}, ${at[n]})`;function du(){return Object.keys(at).map(n=>` ${Pr(n)}: ${at[n]};`).join(`
|
|
7
|
-
`)}var zr=new Set;function Er(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:zr,disabledMutations:zr,disabledInvariants:zr,administered:Ys(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 c of d.kinds??[])o.add(c);for(let c of d.mutations??[])i.add(c);for(let c of d.invariants??[])s.add(c)}for(let a of t){let d=n[a];for(let c of d?.kinds??[])o.delete(c);for(let c of d?.mutations??[])i.delete(c);for(let c of d?.invariants??[])s.delete(c)}return{enabled:t,disabledKinds:o,disabledMutations:i,disabledInvariants:s,administered:Ys(n,t)}}function Ys(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 Xs(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var dt=class{constructor(e){this.graph=e;for(let t of e.allNodes())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=Xs(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=Nr(a.sorted,r);d<a.sorted.length&&a.sorted[d].startsWith(r);d+=1){let c=[...a.ids.get(a.sorted[d])??[]];s.push(...c),a.sorted[d]===r&&i.push(...c)}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=Z(this.graph.schema.tryDefinition(e.kind),e),r=Xs(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(Nr(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=Nr(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function Nr(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 cu(n,e){return e.includes("*")?"record":e.map(t=>ae(n.tryDefinition(t),t)).join(" or ")}function Qs(n,e,t,r){let o=cu(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}.`}}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 ea=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function lu(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(ea),t=n.edges.map(r=>({key:T(r),value:{kind:r.kind,from:r.from,to:r.to}})).sort(ea);return Mr({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function nn(n){return`sha256:${ta(lu(n))}`}function na(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=nn(t),a=U.from(n,i,{validate:o});for(let[y,m]of e.entries())try{a.applyPrimitives(m.primitives)}catch(g){let b=e[y-1];return{ok:!1,expected:nn(a.snapshot()),actual:s,...b?{divergedAfter:b.id}:{},reason:`The log does not fold: op "${m.id}" (${m.intent}) could not be applied. ${g instanceof Error?g.message:String(g)}`}}let d=nn(a.snapshot());if(d===s)return{ok:!0,hash:s};let c=y=>{let m=U.from(n,i,{validate:o});for(let g=0;g<=y;g++)m.applyPrimitives(e[g].primitives);return nn(m.snapshot())},u=y=>{try{let m=U.from(n,t,{validate:o});for(let g=e.length-1;g>y;g--)m.applyPrimitives(e[g].inverse);return nn(m.snapshot())}catch{return}},f=y=>{let m=u(y);return m!==void 0&&m!==c(y)},l=-1,p=e.length-1;for(;l<p;){let y=Math.floor((l+p)/2);f(y)?p=y:l=y+1}let h=p>=0?e[p]:void 0;return{ok:!1,expected:d,actual:s,...h?{divergedAfter:h.id}:{},reason:h?`The graph and the fold of its log part after op "${h.id}" (${h.intent}).`:"The graph and the fold of its log disagree before any op: the base it folds from does not match."}}var uu=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]),fu=new TextEncoder,pu=new Uint32Array(64),hu=new Uint32Array(8),ct=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ta(n){let e=fu.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=hu;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=pu;for(let d=0;d<r.length;d+=64){for(let g=0;g<16;g++)s[g]=o.getUint32(d+g*4);for(let g=16;g<64;g++){let b=s[g-15],S=s[g-2],v=(b>>>7|b<<25)^(b>>>18|b<<14)^b>>>3,x=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10;s[g]=s[g-16]+v+s[g-7]+x>>>0}let c=i[0],u=i[1],f=i[2],l=i[3],p=i[4],h=i[5],y=i[6],m=i[7];for(let g=0;g<64;g++){let b=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),S=p&h^~p&y,v=m+b+S+uu[g]+s[g]>>>0,x=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),w=c&u^c&f^u&f,_=x+w>>>0;m=y,y=h,h=p,p=l+v>>>0,l=f,f=u,u=c,c=v+_>>>0}i[0]=i[0]+c>>>0,i[1]=i[1]+u>>>0,i[2]=i[2]+f>>>0,i[3]=i[3]+l>>>0,i[4]=i[4]+p>>>0,i[5]=i[5]+h>>>0,i[6]=i[6]+y>>>0,i[7]=i[7]+m>>>0}let a="";for(let d=0;d<8;d++){let c=i[d];a+=ct[c>>>24]+ct[c>>>16&255]+ct[c>>>8&255]+ct[c&255]}return a}var Mn=class{constructor(e){this.inner=e}seen=new Set;reads(){return[...this.seen]}mark(e){return e&&this.seen.add(e.id),e}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.mark(this.inner.getNode(e))}has(e){return this.seen.add(e),this.inner.has(e)}allNodes(){return this.markAll(this.inner.allNodes())}allEdges(){return this.markEdges(this.inner.allEdges())}nodesOfKind(e){return this.markAll(this.inner.nodesOfKind(e))}edgesOfKind(e){return this.markEdges(this.inner.edgesOfKind(e))}out(e,t){return this.seen.add(e),this.markAll(this.inner.out(e,t))}in(e,t){return this.seen.add(e),this.markAll(this.inner.in(e,t))}neighbors(e){return this.seen.add(e),this.markAll(this.inner.neighbors(e))}};function gu(n,e){return{...e,name:n}}function Ir(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function ia(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 Ir(n)?[...r,"id"]:r}var ra=(n,e)=>`does not take ${n.map(t=>`"${t}"`).join(", ")}; it takes ${e.length>0?e.map(t=>`"${t}"`).join(", "):"nothing"}`;function mu(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 F("An id must be a non-empty string",`Got ${JSON.stringify(e)}.`);return e}}function yu(n){let{id:e,...t}=n;return t}function oa(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function tn(n,e,t,r={}){let o=Ir(e)?mu(t):void 0,i=o===void 0?t:yu(t),s=ia(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let g=Object.keys(i).filter(b=>!s.includes(b)&&i[b]!==void 0);if(g.length>0)throw new Fe(e.name,[{path:[],message:ra(g,s)}])}let a=e.input.safeParse(i);if(!a.success){let g=Object.keys(e.input.shape??{});throw new Fe(e.name,a.error.issues.map(b=>b.code==="unrecognized_keys"&&g.length>0?{...b,message:ra(b.keys,g)}:b))}let d=a.data,c=new Mn(r.seen??n),u=[],f=new Set,l=g=>c.has(g)||n.has(g)||f.has(g),p={graph:c,schema:n.schema,me:r.me,emit(g){u.push(g)},addNode(g){u.push({op:"add-node",node:g})},removeNode(g){let b=c.getNode(g)&&n.getNode(g);if(!b)throw new Y(g,`Cannot remove missing node "${g}"`);let S=new Map;for(let v of n.outEdges(g))S.set(T(v),v);for(let v of n.inEdges(g))S.set(T(v),v);for(let v of S.values())c.getNode(v.from),c.getNode(v.to),u.push({op:"remove-edge",edge:v});u.push({op:"remove-node",node:b})},patchNode(g,b){let S=c.getNode(g)&&n.getNode(g);if(!S)throw new Y(g,`Cannot patch missing node "${g}"`);let v={},x={};for(let[w,_]of Object.entries(b)){let k=S[w];JSON.stringify(k)===JSON.stringify(_)&&!r.keepUnchanged?.(_)||(v[w]=k,x[w]=_)}Object.keys(x).length!==0&&u.push({op:"patch-node",id:g,before:v,after:x})},addEdge(g){u.push({op:"add-edge",edge:g})},removeEdge(g){u.push({op:"remove-edge",edge:g})},setSingleSource(g,b,S){for(let v of n.inEdges(b,g))c.getNode(v.from),v.from!==S&&u.push({op:"remove-edge",edge:v});n.inEdges(b,g).some(v=>v.from===S)||u.push({op:"add-edge",edge:{kind:g,from:S,to:b}})},freshId(g,b){if(o!==void 0&&!f.has(o)){if(l(o))throw new F(`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 f.add(o),o}let S=b?`${b}:${oa(g)}`:oa(g),v=S;for(let x=2;l(v);x++)v=`${S}-${x}`;return f.add(v),v}};e.apply(p,d);let h=new Set;for(let g of u)switch(g.op){case"add-node":case"remove-node":h.add(g.node.id);break;case"patch-node":h.add(g.id);break;case"add-edge":case"remove-edge":h.add(g.edge.from),h.add(g.edge.to);break}let y=new Mn(r.seen??n),m=e.describe?.(d,y)??`${e.name}(${Object.entries(d).map(([g,b])=>`${g}=${JSON.stringify(b)}`).join(", ")})`;return{primitives:u,reads:[...new Set([...c.reads(),...y.reads()])],...e.describe?{described:y.reads()}:{},writes:[...h],intent:m}}function sa(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function jr(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function Tr(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(Ne(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function aa(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 jr(n,o)){let s=n.tryDefinition(i);if(s)for(let a of Tr(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 da(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=aa(n,e).get(t);return sa(r).filter(i=>!o?.has(i))}var ca=n=>`edit-${n}`;function la(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),jr(n,i).includes(t)&&Tr(i,r).length>0&&o.add(i.name));return[...o]}function lt(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=ca(i);if(t.has(s))continue;let a=da(n,e,i);if(a.length===0)continue;let d=o.fields.shape,c=ae(o,i),u=a.map(f=>Se(o,f).toLowerCase());r.push({name:s,derived:{kind:i,act:"edit"},idempotent:!0,title:`Change the ${c}`,description:`Change what was set when this ${c} was made: ${u.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:a,input:Ji({id:pr([i]),...Object.fromEntries(a.map(f=>[f,We(bu(d[f]))]))}),describe:(f,l)=>{let p=l.getNode(f.id),h=p?Z(o,p):f.id,y=o.display,m=b=>b===b.toUpperCase()?b:b.charAt(0).toLowerCase()+b.slice(1),g=a.filter(b=>f[b]!==void 0).map(b=>{let S=f[b],v=y?.format?.[b],x;try{x=v?String(v(S)):ze(S).length>0?ze(S).map(w=>w.name).join(", "):JSON.stringify(S)}catch{x=JSON.stringify(S)}return`${m(Se(o,b))} \u2192 ${x}`});return`Change ${h}: ${g.join(", ")||"nothing"}`},apply(f,l){let p={};for(let h of a){let y=l[h];y!==void 0&&(p[h]=y)}if(Object.keys(p).length===0)throw new Je(`Nothing to change \u2014 give at least one of ${u.join(", ")} a value.`,"invalid");f.patchNode(l.id,p)}})}return r}function bu(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}var ua=n=>`remove-${n}`;function fa(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function Dr(n,e,t){if(t.derived)return t.derived.act==="edit"?la(n,e,t.derived.kind):fa(e,t.derived.kind)}function pa(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=ua(i);if(t.has(s))continue;let a=ae(o,i);r.push({name:s,derived:{kind:i,act:"remove"},title:`Remove the ${a}`,description:`Take this ${a} out of the graph, with every tie it has. Undo puts it back.`,subject:{kinds:[i],arg:"id"},destructive:!0,idempotent:!0,input:Hn({id:pr([i])}),describe:(d,c)=>{let u=d.id,f=c.getNode(u),l=f?new Set(Object.values(f).flatMap(p=>ze(p).map(h=>h.href))).size:0;return`Remove ${f?Z(o,f):u}${l?` and its ${l} file${l>1?"s":""}`:""}`},apply(d,c){d.removeNode(c.id)}})}return r}function Fr(n,e){return[...lt(n,e),...pa(n,e)]}var rn=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};var ha=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget"];function ga(n,e){try{n.parseNode(e);return}catch(t){let o=(t.issues??[]).flatMap(i=>i.code==="unrecognized_keys"&&i.keys?[...i.keys]:typeof i.path?.[0]=="string"?[i.path[0]]:[]);return[...new Set(o)]}}function xu(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function ut(n,e){try{return Z(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var vu=n=>`${n.kind}:${n.from}->${n.to}`,ft=(n,e)=>n<e?-1:n>e?1:0;function ma(n,e,t={}){let{schema:r}=n,o=[],i=new Map;for(let l of e.nodes)i.has(l.id)||i.set(l.id,l);let s=l=>e.edges.filter(p=>p.from===l||p.to===l),a=l=>({action:"drop",primitives:[...s(l.id).filter(p=>i.has(p.from)&&i.has(p.to)).map(p=>({op:"remove-edge",edge:p})),{op:"remove-node",node:l}]}),d=new Set;for(let l of[...i.values()].sort((p,h)=>ft(p.id,h.id))){if(!r.tryDefinition(l.kind)){d.add(l.id),o.push({code:"kind-unknown",id:l.id,message:`${ut(r,l)} is a kind of record this app no longer has`,repair:a(l)});continue}let p=ga(r,l);if(p===void 0)continue;let h=ut(r,l),y=new Map,m=p.length>0;for(let g of p){if(g==="id"||g==="kind"){m=!1;continue}let b=xu(r,l.kind,g),S=b?b.safeParse(void 0):{success:!0,data:void 0},v=r.tryDefinition(l.kind)?.defaults;!S.success&&b&&v&&Object.hasOwn(v,g)&&(S=b.safeParse(v[g])),S.success?S.data===void 0?y.set(g,{action:"clear",value:de}):y.set(g,{action:"coerce",value:S.data}):m=!1}if(m){let g={...l};for(let[b,S]of y)S.value===de?delete g[b]:g[b]=S.value;ga(r,g)!==void 0&&(m=!1)}if(p.length===0){o.push({code:"node-shape",id:l.id,message:`${h} does not fit what ${l.kind} declares`,repair:a(l)});continue}for(let g of p){let b=y.get(g),S=m&&b?{action:b.action,primitives:[{op:"patch-node",id:l.id,before:{[g]:l[g]===void 0?de:l[g]},after:{[g]:b.value}}]}:a(l);o.push({code:"node-shape",id:l.id,detail:g,message:`${h}: ${z(g)} does not fit what ${l.kind} declares`,repair:S})}}let c=new Set,u=[];for(let l of[...e.edges].sort((p,h)=>ft(T(p),T(h)))){if(c.has(T(l)))continue;c.add(T(l));let p=vu(l),h=i.get(l.from),y=i.get(l.to);if(!h||!y){o.push({code:"edge-dangling",id:p,message:"A link points at a record that is not there",repair:{action:"drop",primitives:[{op:"remove-edge",edge:l}]}});continue}u.push(l),!(d.has(h.id)||d.has(y.id))&&(r.edgeAllowed(l.kind,h.kind,y.kind)||o.push({code:"edge-disallowed",id:p,message:`${ut(r,h)} \u2192 ${ut(r,y)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:l}]}}))}let f=n.invariants??[];if(f.length>0){let l=U.from(r,{nodes:[...i.values()],edges:u},{validate:!1}),p=new Set,h;try{h=He(l,f,t.invariantOptions??{})}catch{h=[{invariant:"rules",status:"could-not-judge",label:"The rules",message:"The rules could not be judged",nodeIds:[],repairs:[]}]}for(let y of h){let m=y.status==="could-not-judge"?"rule-error":y.status==="over-budget"?"rule-budget":void 0;if(!m)continue;let g=y.subjectId??y.invariant,b=`${m}|${g}|${y.invariant}`;p.has(b)||(p.add(b),o.push({code:m,id:g,detail:y.invariant,message:y.message}))}}return o.sort((l,p)=>ha.indexOf(l.code)-ha.indexOf(p.code)||ft(l.id,p.id)||ft(l.detail??"",p.detail??""))}var on=()=>globalThis.__graviewWatch;function ya(n,e,t){let r=on();if(!r?.learn)return;let o=[],i=[],s=[];for(let d of n.definitions){o.push(d.kind),d.noun&&z(d.kind).toLowerCase()!==d.noun.toLowerCase()&&s.push(d.kind);let c=d.fields.shape??{};for(let[f,l]of Object.entries(c)){let p=d.display?.labels?.[f];p!==void 0&&z(f)!==p&&s.push(z(f));let h=l?.def?.entries,y=d.display?.format?.[f];for(let m of h&&typeof h=="object"?Object.values(h):[]){if(typeof m!="string"||(o.push(m),!y))continue;let g=y(m);g!==m&&g.toLowerCase()===m.toLowerCase()&&s.push(m)}}i.push(d.plural??"",d.noun??"",d.description??"");let u=d.fields.shape??{};o.push(...Object.keys(u));for(let f of Object.values(d.display?.labels??{}))i.push(f);for(let[f,l]of Object.entries(d.edges??{}))o.push(f),(l.description||l.inverse)&&s.push(z(f)),i.push(l.description??"",l.inverse??"")}for(let d of e)o.push(d.name),i.push(d.title??"");for(let d of t?.grants??[])d.roles!=="*"&&o.push(...d.roles);o.push(...t?.roles??[]);let a=new Set;for(let d of n.definitions){a.add(d.plural??""),a.add(z(d.noun??d.kind));for(let u of Object.values(d.display?.labels??{}))a.add(u);let c=d.fields.shape??{};for(let[u,f]of Object.entries(c)){let l=d.display?.format?.[u],p=f?.def?.entries;if(!l&&!d.display?.labels?.[u]&&a.add(z(u)),p&&typeof p=="object")for(let h of Object.values(p))a.add(l?l(h):z(String(h)))}}r.learn({ids:o,words:i.filter(Boolean),unsaid:[...new Set(s)].filter(d=>!a.has(d))})}function ba(n){on()?.store?.(n)}function pt(n){n!==void 0&&on()?.learn?.({ids:[n],words:[]})}function xa(n,e){on()?.refused?.({...n,...e===void 0?{}:{author:e}})}function wu(n,e,t){let r=on();if(!r?.unseen||!n.policy?.sees?.length)return;let o=new Set,i=new Set;for(let s of n.graph.allNodes()){let a=n.schema.tryDefinition(s.kind),d=[Z(a,s),...Object.values(s).filter(c=>typeof c=="string"&&/^[^\s@]+@[^\s@]+$/.test(c))];for(let c of d)(n.sees(e,s.id)?i:o).add(c)}r.unseen({words:[...o].filter(s=>s.length>=5&&!i.has(s)),...t?{from:t}:{}})}function ku(n){let e=on();if(!e?.learn)return;let t=[...new Set(n.log.all().map(r=>r.author.id).filter(r=>typeof r=="string"&&n.graph.getNode(r)===void 0))];t.length>0&&e.learn({ids:t,words:[]})}var Zr="preview",X=(n,e)=>e===void 0?{}:{[n]:e},Ze={kind:"human"},va={kind:"system"},ka={kind:"system",id:"modules",name:"Modules"},wa=n=>n.mutation===null&&n.undoes===void 0;function Sa(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var _a=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function $a(n,e,t){let r=_a(n),o=a=>Sa(a,r),i=new Set(e.map(o)),s=new Set(t.map(o));return{introduces:t.filter(a=>!i.has(o(a))),resolves:e.filter(a=>!s.has(o(a)))}}var sn=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"}},ht=class extends F{constructor(t,r){super(`Unknown mutation "${t}"`,`Registered: ${r.join(", ")||"(none)"}`);this.mutation=t;this.name="UnknownMutationError"}};function Su(){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 Cr=class n{schema;graph;log;mutations=new Map;invariants;invariantOptions;policy;intelligence;may=new Map;by;declaredModules;startingModules;projected;nextId;now;validate;mintBatch;batchTag;counter=0;opCount=0;quiet=0;rehearsing=!1;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??Ze,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=Su();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 F(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of Fr(e.schema,e.mutations??[]))this.mutations.set(i.name,i);ya(e.schema,this.mutations.values(),e.policy);let r=X("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=Xe.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?U.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=Xe.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=U.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);this.countPastTheLog(),ba(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:Er(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=Er(this.declaredModules,e).enabled,i=[...r].filter(u=>!o.has(u)),s=[...o].filter(u=>!r.has(u));if(i.length===0&&s.length===0)return;let a=u=>u.map(f=>{let l=this.declaredModules?.[f]?.kinds??[];return l.length>0?l.map(p=>Ee(this.schema,p)).join(", "):f}).join(", "),d=[i.length>0?`Turn off ${a(i)}`:"",s.length>0?`turn on ${a(s)}`:""].filter(Boolean).join("; "),c={id:this.nextId(),seq:this.log.length,batch:t.batch??this.mintBatch("batch"),author:ka,intent:ne(d),mutation:null,primitives:[],inverse:[],reads:[],writes:[],at:this.now(),...X("via",t.via),enabledModules:[...o].sort()};return this.log.append(c),this.notify(as,[c]),c}mutation(e){let t=this.mutations.get(e);if(!t)throw new ht(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new F(`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=>!this.mutationDisabled(e))}viaOf(e){if(e?.derived)return Dr(this.schema,[...this.mutations.values()],e)}moved(e,t){return $a(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=Ze){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 _e(this.policy,t,e.name,this.subjectKindOf(e,t),this.viaOf(o),typeof i=="string"?i:void 0,this.words,()=>{let s=D(t).id,a=this.namedIn(e,!1);try{for(let d of tn(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})}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]]:[],...Ne(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&&xa(e,t),new rn(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>ae(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=va){let r=this.modules.disabledKinds;if(r.size===0||!K(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&&D(e).id};if(e===void 0||!ge(this,e))return t;let r=Oe(this,e);return{...t,seen:je(this,e).graph,keepUnchanged:o=>j(o,r)}}missingFor(e,t=Ze){let r=this.mutations.get(e.name),o=new Set(this.namedIn(e));if(!r||o.size===0)return;let i=je(this,t).graph;for(let s of o)if(!i.has(s))return new Y(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=Ze){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&lr(i).some(s=>_e(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e){return je(this,e)}sees(e,t){return this.graph.has(t)&&Oe(this,e)(t)}labels;resolveRef(e,t,r=Ze){let o=(this.policy?.sees?.length??0)>0,i=f=>!o||this.sees(r,f),s=this.graph.getNode(t);if(this.labels??=new dt(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=a.exact.filter(i),c=d.length>0,u=(c?d:a.prefix.filter(i)).map(f=>({id:f,kind:this.graph.getNode(f).kind,label:this.labels.labelOf(f)??f})).sort((f,l)=>f.label<l.label?-1:f.label>l.label?1:f.id<l.id?-1:1);return u.length===1?{ok:!0,id:u[0].id,label:u[0].label,by:c?"label":"prefix"}:Qs(this.schema,e,t,u)}kindsKeptFrom(e=Ze){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&&!K(e)){let o=new Set(this.permittedMutations(e).flatMap(i=>i.creates??[]));for(let i of this.schema.kinds)!r.some(a=>a.kinds.includes(i)&&kn(a,e)&&(!a.own&&!a.via||e.id!==void 0))&&!o.has(i)&&t.add(i)}return t}permittedMutations(e=Ze){let t=this.allMutations(),r=cr(this.policy,e,t.filter(i=>!i.derived)),o=t.filter(i=>i.derived!==void 0&&_e(this.policy,e,i.name,i.derived.kind,this.viaOf(i),D(e).id).ok);return[...r,...o]}subjectKindOf(e,t=va){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(!(!K(t)&&!Oe(this,t)(i)))return this.graph.getNode(i)?.kind}today(){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}violations(e,t=this.graph){return He(t,this.allInvariants(),{...this.invariantOptions,...e===void 0?{}:{context:e}})}wouldChange(e,t){try{return tn(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=tn(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:U.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:Xe.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${Zr}:${++t}`,mintBatch:()=>Zr,rehearsing:!0}),e}previewPrimitives(e,t){let r=this.violations(t.context),o=U.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=He(o,this.allInvariants(),{...this.invariantOptions,...t.context===void 0?{}:{context: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=[],a=[],d=new Set,c=new Set,u=[],f=this.violations(r),l=this.graph.snapshot(),p=this.log.length;if(this.policy)for(let m of e){let g=this.permits(m,i);g.ok||this.refuse(g.refusal,i.id)}for(let m of e){let g=this.refusesAgent(m,i)??this.namesTurnedOff(m,i);g&&this.refuse(g,i.id)}this.rehearsing||pt(i.id);try{for(let m of e){let g=this.mutation(m.name),b=this.missingFor(m,i);if(b)throw b;let S=tn(this.graph,g,m.args,this.sighted(i));if(S.primitives.length===0)continue;let v={id:this.nextId(),seq:this.log.length,batch:o,author:i,intent:g.describe!==void 0?S.intent:t.intent??S.intent,...X("batchIntent",t.intent),mutation:m,primitives:S.primitives.map(vn),inverse:[...S.primitives].reverse().map(vn).map(wn),reads:S.reads,writes:S.writes,...g.describe!==void 0&&S.described&&S.described.length>0?{described:S.described}:{},at:this.now(),...X("via",t.via)};this.graph.applyPrimitives(v.primitives),this.log.append(v),s.push(v),a.push(...v.primitives);for(let x of v.reads)d.add(x);for(let x of v.writes)c.add(x);u.push(v.intent)}}catch(m){throw this.putBack(l,p),m}let h=ie(l,this.graph.snapshot());this.admitted(t,s,a,h,l,p);let y=this.violations(r);return this.notify(h,s),{batch:o,ops:s,diff:h,primitives:a,reads:[...d],writes:[...c],intent:t.intent??u.join("; "),...this.moved(f,y),violationsAfter:y}}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(c){throw this.graph.load(i),new sn(d,c)}let a=this.log.length;for(let[d,c]of o.entries()){let u={...c,seq:a+d};this.log.append(u),s.push(u)}return this.notify(ie(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 c=a.primitives.map(vn),u={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,...X("batchIntent",a.batchIntent),mutation:a.mutation??null,primitives:c,inverse:a.inverse??[...c].reverse().map(wn),reads:a.reads??[],writes:a.writes??[...new Set(c.flatMap(rr))],at:a.at??this.now(),...X("undoes",a.undoes),...X("via",a.via)};if(r.has(u.id))throw new F(`Op "${u.id}" (${u.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(u.id),u}),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 sn(a,d)}for(let a of i)this.log.append(a);for(let a of i)pt(a.author.id);return this.notify(ie(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=e.map(vn),c=[];if(d.length>0){let l={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:d,inverse:[...d].reverse().map(wn),reads:[],writes:[...new Set(d.flatMap(rr))],at:this.now(),...X("via",t.via)};this.graph.applyPrimitives(l.primitives),this.log.append(l),c.push(l),pt(o.id)}let u=this.violations(),f=ie(s,this.graph.snapshot());return this.notify(f,c),{batch:r,ops:c,diff:f,primitives:d,reads:[],writes:c[0]?.writes??[],intent:a,...this.moved(i,u),violationsAfter:u}}findings(){return ma({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return On(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=Ns(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(wa),...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&&!K(o);if(i){let h=On(kr($e(this.log.all(),Pn(this,o)),()=>this.log.epochs()),r);if(!h.ok)throw new Me(h)}let s=this.canUndo(r);if(!s.ok)throw new Me(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");if(this.policy)for(let h of s.ops){if(!h.mutation)continue;let y=D(h.author).id,m=b=>JSON.stringify(b).includes(JSON.stringify(y)),g=y!==void 0&&y!==D(o).id&&!K(o)&&!m(h.mutation.args)&&m(h.primitives)?{ok:!1,refusal:{mutation:h.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.permits(h.mutation,o);g.ok||this.refuse({...g.refusal,message:`Not permitted to undo "${h.intent}": ${g.refusal.message}`},o.id,!0)}let d=this.graph.snapshot(),c=this.violations(),u=[],f=this.log.length;for(let h of[...s.ops].sort((y,m)=>m.seq-y.seq)){let y={id:this.nextId(),seq:this.log.length,batch:a,author:o,intent:`Undo: ${h.intent}`,...X("batchIntent",t.intent),mutation:null,primitives:h.inverse,inverse:[...h.inverse].reverse().map(wn),reads:h.reads,writes:h.writes,at:this.now(),undoes:h.id,...X("via",t.via)};this.graph.applyPrimitives(y.primitives,{restoring:wa(h)}),this.log.append(y),u.push(y)}let l=ie(d,this.graph.snapshot());this.admitted(t,u,u.flatMap(h=>[...h.primitives]),l,d,f);let p=this.violations();return this.notify(l,u),{batch:a,ops:u,diff:l,primitives:u.flatMap(h=>[...h.primitives]),reads:[...new Set(u.flatMap(h=>[...h.reads]))],writes:[...new Set(u.flatMap(h=>[...h.writes]))],intent:t.intent??u.map(h=>h.intent).join("; "),...this.moved(c,p),violationsAfter:p}}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&&ds(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(y=>t.has(y.batch)),i=r.slice(o<0?r.length:o),s=this.log.horizon+(o<0?r.length:o),a=i.find(y=>!t.has(y.batch));if(a)throw new F(`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 F(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let c=this.graph.snapshot(),u=[],f=[],l=[];this.quiet++;try{for(let m of[...i].reverse())this.graph.applyPrimitives(m.inverse,{restoring:!0,inPlace:!0});this.log.truncate(s);let y=new Set(this.log.all().map(m=>m.id));for(let m of e.confirmed){if(y.has(m.id))continue;try{this.graph.applyPrimitives(m.primitives,{restoring:m.undoes!==void 0})}catch(b){throw new sn(m,b)}let g={...m,seq:this.log.length};this.log.append(g),y.add(m.id),u.push(g)}for(let m of e.pending){let g=i.filter(b=>b.batch===m);if(g.length!==0)try{f.push(...this.replay(m,g))}catch(b){l.push({batch:m,error:b})}}}catch(y){this.log.truncate(s);for(let m of i)this.log.append(m);throw this.graph.load(c),y}finally{this.quiet--}let p=ie(c,this.graph.snapshot()),h=[...u,...f];return this.notify(p,h),{diff:p,confirmed:u,pending:f,refused:l}}adopt(e){let t=new Set(e.drop??[]),r=(e.pending??[]).filter(p=>!t.has(p)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(p=>p.id)),d=new Map(r.map(p=>[p,o.filter(h=>h.batch===p)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,X("horizon",e.horizon));else{let p=e.horizon??0;this.log.replace([],e.epochs??[{seq:p,base:e.snapshot}],{horizon:p})}let c=[],u=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let p of r){let h=d.get(p)??[];if(h.length!==0)try{c.push(...this.replay(p,h))}catch(y){u.push({batch:p,error:y})}}}catch(p){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,p}finally{this.quiet--}let f=this.log.all().filter(p=>!a.has(p.id)&&!c.includes(p)),l=ie(i,this.graph.snapshot());return this.notify(l,[...f,...c]),{diff:l,adopted:f,pending:c,refused:u}}replay(e,t){let r=t[0],o={author:r.author,batch:e,...X("intent",r.batchIntent),...X("via",r.via)};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 F(`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 na(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),c=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,u=t.find(l=>Date.parse(l.at)>c),f=u?u.seq:this.log.length;r=Math.min(a,f)}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 F(`Cannot compact a store that does not verify: ${o.reason}`);let i=this.log.checkpointAt(this.schema,r,{validate:this.validate}),s=js(this.log,r);return Object.keys(s).length>0?{...i,creators:s}:i}compact(e){return this.log.compact(e)}};var gt={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:[]}},Aa=Object.keys(gt),Ra=n=>Object.hasOwn(gt,n);var In=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function Oa(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=ee(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=ee(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function Lr(n){let e=[],t=[],r=[],o=new Set(n.schema.kinds),i=new Set;for(let d of o)for(let c of Object.keys(n.schema.tryDefinition(d)?.edges??{}))i.add(c);let s=d=>Object.keys(n.schema.tryDefinition(d)?.fields.shape??{}),a=new Map;return(n.lenses??[]).forEach((d,c)=>{let u=`lenses.${c}`,f=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,l=(x,w)=>{t.push({index:c,name:d.name,...f?{title:f}:{},why:x}),w&&r.push({severity:"warning",...w})};if(!Ra(d.name)){f?l(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${u}.name`,message:`"${f}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${Aa.join(", ")} \u2014 or register the view yourself and drop the title.`}):l("it is a lens this app wrote, drawn by the app's own views");return}if(!f)return l("it has no title, so it is bindings the checker holds and no place");let p=gt[d.name],h=In(d.options)?d.options:{};if(d.options!==void 0&&!In(d.options))return l("its options are not an object",{code:"lens-options-not-an-object",path:`${u}.options`,message:`"${f}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let x of Object.keys(h))p.options.includes(x)||r.push({severity:"warning",code:"lens-option-unknown",path:`${u}.options.${x}`,message:`The ${d.name} lens takes no option "${x}", so "${f}" ignores it.`,fix:p.options.length===0?`The ${d.name} lens takes no options; drop it.`:`Use one of: ${p.options.join(", ")}.`});let y={};for(let x of p.options)h[x]!==void 0&&(y[x]=h[x]);d.arrangedBy&&(y.arrangedBy=ws(d.arrangedBy));let m=In(d.bindings)?d.bindings:{},g=[],b,S=(x,w,_)=>l(w,{code:"lens-cannot-draw",path:x,message:`"${f}" cannot draw: ${w}.`,fix:_});if(p.binds==="fields"){let x=Object.keys(m).filter(_=>In(m[_])),w=x.filter(_=>!o.has(_));if(x.length===0)return S(`${u}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${p.requiredRoles.map(_=>`"${_}": "<field>"`).join(", ")} } }.`);if(w.length>0)return;if(y.bindings=m,g=x,d.name==="timeline"){let _=h.columns;if(Array.isArray(_))y.columns=_.map(k=>typeof k=="string"?{id:k,label:k}:k);else{let k=x.flatMap(P=>{let W=m[P],q=typeof W.column=="string"?W.column:typeof W.columns=="string"?W.columns:void 0;return q?Oa(n.schema,P,q):[]}),R=[...new Set(k)];if(R.length===0)return S(`${u}.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].');y.columns=R.map(P=>({id:P,label:P.toUpperCase()}))}y.extent===void 0&&(y.extent=1440)}if(d.name==="columns")for(let _ of x){let k=m[_].column;if(typeof k!="string"||!s(_).includes(k))return;if(Oa(n.schema,_,k).length===0)return S(`${u}.bindings.${_}.column`,`its column field "${k}" is not a choice`,`Bind "column" to a choice field of ${_}, like a status.`)}if(d.name==="calendar"&&y.today!==void 0&&!(typeof y.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(y.today)))return S(`${u}.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"&&y.range!==void 0&&!["day","week","month","quarter","year","years","agenda"].includes(y.range))return S(`${u}.options.range`,`its range "${String(y.range)}" is not one a calendar opens at`,"Use one of: day, week, month, quarter, year, agenda.")}else if(p.binds==="entities"){let x=k=>{let R=m[k];if(In(R)){if(typeof R.kind=="string")return R.kind;if(typeof R.edge=="string")return R.edge;if(Array.isArray(R.path))return{path:R.path};if(typeof R.field=="string")return R.field}};for(let k of p.requiredRoles)if(x(k)===void 0)return;let w=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",_=x(w);if(!o.has(_))return;if(d.name==="coverage"){let k=x("columns");if(!o.has(k))return;let R=x("link");if(typeof R=="string"&&!i.has(R))return;Object.assign(y,{rows:_,columns:k,link:R}),k!==_&&(b=k)}else if(d.name==="board"){Object.assign(y,{slots:_,x:x("x"),y:x("y"),fill:x("fill")});for(let k of["x","y"])if(!s(_).includes(y[k]))return}else{Object.assign(y,{regions:_,outline:x("outline")});for(let k of["markers","at","within","nests","regionKind","markerKind"]){let R=x(k);typeof R=="string"&&(y[k]=R)}}g=[_]}else if(d.name==="blocks"){if(!d.on)return S(`${u}.on`,"it does not say which kind it stands on",'Say "on": "<the kind it is a place of>".');if(!Array.isArray(y.blocks)||y.blocks.length===0)return S(`${u}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let x=["user","person","member"].find(w=>o.has(w));if(!d.on&&!x)return S(`${u}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');g=x?[x]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return S(`${u}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(g=[d.on],d.name==="coverage"){let x=[y.rows,y.columns].find(w=>w!==d.on);b=typeof x=="string"?x:void 0}}let v=me(f);if(v.length===0)return S(`${u}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let x of g){let w=`${x}|${v}`;if(a.has(w))return l(`another lens on ${x} is already called "${f}"`,{code:"lens-title-taken",path:`${u}.title`,message:`"${f}" is the title of lenses.${a.get(w)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let x of g)a.set(`${x}|${v}`,c);e.push({index:c,lens:d.name,title:f,as:v,kinds:g,...b?{across:b}:{},options:y})}),{drawn:e,undrawn:t,findings:r}}var _u=6;function $u(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 Ou(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(me));return{kinds:new Set(e.kinds.filter(o=>r.has(me(o))||r.has(ce(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(me(o.title))).map(o=>`${o.kind}|${o.as}`))}}var Gr="overview",Pa=`/places/${Gr}`;function za(n){let e=n?.scene?.trim();return e||"Scene"}function Au(n){let e=n?.pages?.trim();return e||"Pages"}function Ea(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 Na(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=me(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=>ce(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function Ru(n){let e=[];for(let t of Lr(n).drawn)for(let r of t.kinds)e.push({kind:r,title:t.title,as:t.as,...t.across?{across:t.across}:{}});for(let t of n.views?.places?.()??[])e.some(r=>r.kind===t.kind&&r.as===t.as)||e.push(t);return e}function Pu(n){return Ma(n.schema,Ru(n),{...n.pages?{pages:n.pages}:{},lenses:Lr(n).drawn,home:(n.home?.length??0)>0})}function Ma(n,e,t={}){let{pages:r}=t,o=n.kinds,i=e.filter(f=>o.includes(f.kind)),s=Na(r?.first,n,i),a=new Set(r?.hide??[]),d=Ea(o,r?.order),c=[{slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...s?.to==="home"||s===void 0&&t.home?{first:!0}:{}},{slug:Gr,title:za(r),kind:null,cardinality:"many",address:Pa,stop:"#"}],u=[...i].sort((f,l)=>d.indexOf(f.kind)-d.indexOf(l.kind));for(let f of u){let l=t.lenses?.find(h=>h.as===f.as&&h.kinds.includes(f.kind)),p=En(f,i);c.push({slug:f.as,title:f.title,kind:f.kind,cardinality:"many",address:zn(f.as,p?ce(n,f.kind).slice(1):void 0),stop:p?`#focus=aggregate:${f.kind}&in.view=${encodeURIComponent(f.as)}`:`#view=${encodeURIComponent(f.as)}`,...l?{lens:l.lens}:{},...s?.to==="place"&&s.place.kind===f.kind&&s.place.as===f.as?{first:!0}:{}})}for(let f of d)c.push({slug:ce(n,f).slice(1),title:xn(n,f),kind:f,cardinality:"many",address:ce(n,f),stop:`#focus=aggregate:${f}`,...a.has(f)?{hidden:!0}:{},...s?.to==="kind"&&s.kind===f?{first:!0}:{}});return c}function Br(n,e){if(n.onBehalfOf){let{onBehalfOf:i,...s}=n;return`${Br(s,e)}, for ${Br(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 Z(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}function zu(n){if(n===void 0||n==="web"||n.startsWith("ai:"))return;if(n==="api")return"via the API";if(n==="cli")return"via the command line";let[e,...t]=n.split(":"),r=t.join(":");return(e==="mcp"||e==="view")&&r?`via ${r}`:e==="mcp"?"via an agent's tools":`via ${n}`}var Eu=1;function Nu(n){let e=n instanceof Error?n.message:String(n);if(n instanceof rn){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof Y?{reason:"missing",sentence:e}:n instanceof Je?{reason:n.reason,sentence:n.sentence}:n instanceof Me?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var mt=(n,e)=>`${n}\0${e}`;function Kr(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 Ur=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 Kr(r)){let s=mt(o,i);(this.revs.get(s)??-1)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(mt(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=mt(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 Mu(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 Kr(r))e.add(mt(o,i))}return e}var Iu=/^#([0-9a-f]{3,8})$/i,ju=/(rgba?|hsla?)\(([^)]+)\)/gi;function Tu(n){let e=Iu.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 Du(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,c,u,f]=r;return d===void 0||c===void 0||u===void 0?null:{r:d,g:c,b:u,a:f??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...ja(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function Wr(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 qr(n,e,t){return{...ja(n,e,t),a:1}}function ja(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],c=t-r/2;return{r:Math.round((s+c)*255),g:Math.round((a+c)*255),b:Math.round((d+c)*255)}}function an(n){let e=[];for(let t of n.matchAll(ju)){let r=Du(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=Tu(t[0]);r&&e.push(r)}return e}function Hr(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 Vr(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function Ia(n){return .2126*Vr(n.r)+.7152*Vr(n.g)+.0722*Vr(n.b)}function dn(n,e){let[t,r]=[Ia(n),Ia(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}var yt=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,Ta={r:0,g:0,b:0,a:1},bt={r:255,g:255,b:255,a:1};function xt(n){let e=an(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=Wr(e);for(let s of["dark","light"]){let a=n.base[s],d=an(a.ground)[0]??(s==="dark"?Ta:bt),c=Hr(an(a.panel)[0]??bt,d),u=Lu(i,[c,d],s,4.5);u?Math.abs(u.l-i.l)>Cu&&(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(u.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 f=u??i,l=qr(f.h,f.s,f.l),p=n.accentInk?.[s]??(dn(bt,l)>=dn(Ta,l)?"#ffffff":"#000000"),h=dn(an(p)[0]??bt,l);h+.005<4.5&&(r.add(`accentInk (${s})`),o.push(`neither black nor white clears 4.5:1 on the accent (best ${h.toFixed(2)}:1), so text on a filled button has to be given`)),t[s]={...a,accent:yt(l,1),accentDim:yt(l,s==="dark"?.35:.22),accentInk:p,glow:yt(l,s==="dark"?.28:.1),edgeBright:yt(l,Fu(l,c,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let y=an(t[s].warn)[0];y&&Zu(Wr(y).h,f.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 Fu(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(dn(Hr({...n,a:i},e),e)>=r)return i}return 1}function Zu(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var Cu=.3;function Lu(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(c=>dn(qr(n.h,n.s,d),c)>=r))return{...n,l:d}}return null}function Gu(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 Ce=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),Jr="Montserrat",Yr=Object.freeze({display:550,body:450,label:600}),Xr=Object.freeze({display:600,body:400,label:600}),Bu="-0.025em",Uu=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var Da={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:Ce.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},Fa={ground:Ce.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:Ce.ink,inkMuted:Ce.muted,inkFaint:"#626b7d",accent:Ce.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},cn={dark:Da,light:Fa};var Ae=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),Le=Object.freeze({body:`"${Jr}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function Ku(n){let e=n?.shape?.radius??Ae.radius,t=n?.shape?.density??Ae.density;return Object.freeze({radius:e,radiusSmall:Math.max(Ae.radiusSmallFloor,Math.round(e*Ae.radiusSmall)),pad:Math.round(Ae.pad*t),padSmall:Math.round(Ae.padSmall*t),gap:Math.round(Ae.gap*t)})}function Vu(n){let e=n?.typography?.body??Le.body,t=n?.typography?.display??e,o=e===Le.body&&t===Le.body?Yr:Xr,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??Le.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var Wu=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 qu(n){return Wu[n]}function Ca(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var La="http://www.w3.org/2000/svg",Hu=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",La],Ju=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(" ")),Yu=new Set(["title","desc"]),jn="it embeds a page or media",Xu={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:jn,embed:jn,object:jn,audio:jn,video:jn,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},Qu={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function ef(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=Qu[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function nf(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 tf(n,e,t){let r=ef(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===La?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 nf(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var Za=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function Ga(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 p=o.indexOf("-->",4);if(p<0)return"it has a comment that never ends";let h=o.slice(4,p);if(/^-?>/.test(h)||h.includes("--")||h.includes("<!")||h.endsWith("-"))return"it has a comment the page and the picture read differently";r+=p+3;continue}if(/^<!DOCTYPE/i.test(o)){let p=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!p||e.length>0||t)return"it declares XML entities";r+=p[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],c=Xu[d.toLowerCase()];if(c)return c;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(!Ju.has(d))return`it has a <${d}> element, which a picture does not need`;let u=e[e.length-1];if(u&&Yu.has(u))return`it has an element inside a <${u}>, which the page reads as HTML`;let f=a[0].length;for(let p=Za.exec(o.slice(f));p;p=Za.exec(o.slice(f))){let h=tf(d,p[1],p[2]??p[3]??"");if(h)return h;f+=p[0].length}let l=/^\s*(\/?)>/.exec(o.slice(f));if(!l)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(f,f+400))?"it has an event handler (an on\u2026 attribute)":`it is not one SVG: <${d}>'s attributes are not each quoted and apart`;l[1]!=="/"?e.push(d):e.length===0&&(t=!0),r+=f+l[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 Ba(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 Ga(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}function rf(n){return Ba(n?.favicon)}var Ua={"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":Le.mono},of=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],Ka=["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 sf=n=>new Set(n.map(e=>e.toLowerCase()));function af(n){return sf([...of,...Ka]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function df(n){return Ua[n]??n}function jx(n){let e=xt({accent:n,base:cn});return e.ok||!e.missing.every(t=>t.startsWith("warn"))?e:xt({accent:n,base:cn,warn:{light:cn.light.bad,dark:cn.dark.bad}})}var le={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 cf(n){return n?{connectors:{all:{...le.connectors.all,...n.connectors?.all??{}},byEdge:{...le.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...le.captions,...n.captions??{}},grid:{...le.grid,...n.grid??{}},lattice:{...le.lattice,...n.lattice??{}},tags:{...le.tags,...n.tags??{}},emphasis:{...le.emphasis,...n.emphasis??{}},marks:{...le.marks,...n.marks??{}}}:le}function lf(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function uf(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(`
|
|
8
|
-
`)}function ff(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,c=new Set;for(let u of r){if(a.includes(u))for(let f of d)c.add(f);if(s.to==="*"||d.includes(u))for(let f of a)c.add(f)}if(c.size===0)return{ok:!1,at:o};r=c}return{ok:!0,reached:r}}function pf(n){return[...n.mutations??[],...lt(n.schema,n.mutations??[])]}function hf(n){let e=[...n.schema.kinds],t=pf(n),r=new Map,o=new Map;for(let m of t){o.set(m.name,m.creates??[]);let g=Ne(m.input).filter(b=>!b.optional&&!b.kinds.includes("*")).flatMap(b=>b.kinds);r.set(m.name,[...new Set(g)])}let i=new Map;for(let m of e)i.set(m,[]);for(let m of t)for(let g of o.get(m.name)??[])i.get(g)?.push(m.name);let s=new Map,a=new Set;for(let m=0;;m+=1){let g=[];for(let b of t)if((r.get(b.name)??[]).every(v=>a.has(v)))for(let v of o.get(b.name)??[])a.has(v)||g.push(v);if(g.length===0)break;for(let b of g)a.add(b),s.set(b,m)}let d=m=>{let g=i.get(m)??[];if(g.length===0)return[];let b=g.map(S=>r.get(S)??[]).sort((S,v)=>S.length-v.length)[0];return[...new Set(b)].filter(S=>S!==m)},c=new Map,u=m=>{let g=c.get(m);if(g)return g;let b=new Set;c.set(m,b);for(let S of d(m)){b.add(S);for(let v of u(S))b.add(v)}return b.delete(m),b},f=new Map(e.map(m=>[m,0]));for(let m of e)for(let g of u(m))f.set(g,(f.get(g)??0)+1);let l=e.map(m=>({kind:m,madeBy:[...i.get(m)??[]].sort(),needs:[...d(m)].sort(),depth:s.get(m)??null})).sort((m,g)=>(m.depth??Number.MAX_SAFE_INTEGER)-(g.depth??Number.MAX_SAFE_INTEGER)||(f.get(g.kind)??0)-(f.get(m.kind)??0)||m.kind.localeCompare(g.kind)),p=l.filter(m=>m.depth===0).map(m=>m.kind),h=[...new Set(t.filter(m=>(r.get(m.name)??[]).length===0).filter(m=>(o.get(m.name)??[]).length>0).map(m=>m.name))].sort(),y=l.filter(m=>m.depth===null).map(m=>({kind:m.kind,why:m.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${m.needs.map(g=>`"${g}"`).join(", ")}, which nothing can make first`}));return{order:l,roots:p,doors:h,unreachable:y}}function gf(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function Qr(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 mf(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function yf(n,e,t,r=2500,o){let i=new Map;for(let[s,a]of n)Qr(a,t,r)&&i.set(s,a);for(let s of e){if(!Qr(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 bf(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{_i as a,$i as b,Nd as c,Md as d,mn as e,Id as f,Oc as g,se as h,Eg as i,Ng as j,qn as k,Mg as l,Ig as m,jg as n,jc as o,Tg as p,Hn as q,Ji as r,Dg as s,Fg as t,Zg as u,Cg as v,Xi as w,We as x,Qi as y,Lg as z,Gg as A,ee as B,Uc as C,wt as D,to as E,Dn as F,ne as G,Xn as H,er as I,ns as J,ze as K,Yn as L,Um as M,Wc as N,ke as O,nr as P,Z as Q,qc as R,tr as S,z as T,rs as U,Jc as V,Ee as W,xn as X,Yc as Y,Se as Z,Qn as _,ae as $,et as aa,sl as ba,Br as ca,zu as da,al as ea,T as fa,wn as ga,U as ha,ll as ia,tt as ja,ly as ka,ul as la,fl as ma,Eu as na,D as oa,K as pa,_e as qa,Qe as ra,Je as sa,Nu as ta,ur as ua,fr as va,pl as wa,pr as xa,hr as ya,Ne as za,ms as Aa,Ye as Ba,yl as Ca,bl as Da,bs as Ea,xl as Fa,xs as Ga,vs as Ha,wl as Ia,ws as Ja,Sl as Ka,ys as La,_l as Ma,ks as Na,Bl as Oa,Jy as Pa,me as Qa,ce as Ra,Ul as Sa,zn as Ta,En as Ua,Kl as Va,st as Wa,Ks as Xa,Vs as Ya,Ws as Za,tu as _a,Hs as $a,ru as ab,Js as bb,Fe as cb,ou as db,gu as eb,Ir as fb,ia as gb,tn as hb,jr as ib,Tr as jb,aa as kb,Ur as lb,Mu as mb,Gu as nb,Jr as ob,Bu as pb,cn as qb,Le as rb,Ku as sb,Vu as tb,qu as ub,Ca as vb,Ga as wb,Ba as xb,rf as yb,af as zb,df as Ab,jx as Bb,cf as Cb,lf as Db,uf as Eb,iu as Fb,su as Gb,au as Hb,du as Ib,ff as Jb,wu as Kb,ku as Lb,ta as Mb,$a as Nb,sn as Ob,Cr as Pb,gt as Qb,Aa as Rb,Ra as Sb,Lr as Tb,_u as Ub,$u as Vb,Ou as Wb,Gr as Xb,Pa as Yb,za as Zb,Au as _b,Ea as $b,Na as ac,Pu as bc,Ma as cc,hf as dc,gf as ec,mf as fc,yf as gc,bf as hc};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{a as _}from"./chunk.AJZBJBMO.js";var Y=_(u=>{"use strict";var R=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),G=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),Q=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),S=Symbol.iterator;function Z(t){return t===null||typeof t!="object"?null:(t=S&&t[S]||t["@@iterator"],typeof t=="function"?t:null)}var O={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H=Object.assign,g={};function E(t,e,n){this.props=t,this.context=e,this.refs=g,this.updater=n||O}E.prototype.isReactComponent={};E.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};E.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function N(){}N.prototype=E.prototype;function m(t,e,n){this.props=t,this.context=e,this.refs=g,this.updater=n||O}var C=m.prototype=new N;C.constructor=m;H(C,E.prototype);C.isPureReactComponent=!0;var j=Array.isArray;function T(){}var i={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function d(t,e,n){var r=n.ref;return{$$typeof:R,type:t,key:e,ref:r!==void 0?r:null,props:n}}function J(t,e){return d(t.type,e,t.props)}function A(t){return typeof t=="object"&&t!==null&&t.$$typeof===R}function V(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var w=/\/+/g;function v(t,e){return typeof t=="object"&&t!==null&&t.key!=null?V(""+t.key):e.toString(36)}function K(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(T,T):(t.status="pending",t.then(function(e){t.status==="pending"&&(t.status="fulfilled",t.value=e)},function(e){t.status==="pending"&&(t.status="rejected",t.reason=e)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function l(t,e,n,r,o){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var f=!1;if(t===null)f=!0;else switch(s){case"bigint":case"string":case"number":f=!0;break;case"object":switch(t.$$typeof){case R:case U:f=!0;break;case h:return f=t._init,l(f(t._payload),e,n,r,o)}}if(f)return o=o(t),f=r===""?"."+v(t,0):r,j(o)?(n="",f!=null&&(n=f.replace(w,"$&/")+"/"),l(o,e,n,"",function(L){return L})):o!=null&&(A(o)&&(o=J(o,n+(o.key==null||t&&t.key===o.key?"":(""+o.key).replace(w,"$&/")+"/")+f)),e.push(o)),1;f=0;var p=r===""?".":r+":";if(j(t))for(var c=0;c<t.length;c++)r=t[c],s=p+v(r,c),f+=l(r,e,n,s,o);else if(c=Z(t),typeof c=="function")for(t=c.call(t),c=0;!(r=t.next()).done;)r=r.value,s=p+v(r,c++),f+=l(r,e,n,s,o);else if(s==="object"){if(typeof t.then=="function")return l(K(t),e,n,r,o);throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return f}function a(t,e,n){if(t==null)return t;var r=[],o=0;return l(t,r,"","",function(s){return e.call(n,s,o++)}),r}function F(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var P=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},tt={map:a,forEach:function(t,e,n){a(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return a(t,function(){e++}),e},toArray:function(t){return a(t,function(e){return e})||[]},only:function(t){if(!A(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};u.Activity=X;u.Children=tt;u.Component=E;u.Fragment=D;u.Profiler=b;u.PureComponent=m;u.StrictMode=q;u.Suspense=W;u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i;u.__COMPILER_RUNTIME={__proto__:null,c:function(t){return i.H.useMemoCache(t)}};u.cache=function(t){return function(){return t.apply(null,arguments)}};u.cacheSignal=function(){return null};u.cloneElement=function(t,e,n){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var r=H({},t.props),o=t.key;if(e!=null)for(s in e.key!==void 0&&(o=""+e.key),e)!$.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(r[s]=e[s]);var s=arguments.length-2;if(s===1)r.children=n;else if(1<s){for(var f=Array(s),p=0;p<s;p++)f[p]=arguments[p+2];r.children=f}return d(t.type,o,r)};u.createContext=function(t){return t={$$typeof:G,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:z,_context:t},t};u.createElement=function(t,e,n){var r,o={},s=null;if(e!=null)for(r in e.key!==void 0&&(s=""+e.key),e)$.call(e,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(o[r]=e[r]);var f=arguments.length-2;if(f===1)o.children=n;else if(1<f){for(var p=Array(f),c=0;c<f;c++)p[c]=arguments[c+2];o.children=p}if(t&&t.defaultProps)for(r in f=t.defaultProps,f)o[r]===void 0&&(o[r]=f[r]);return d(t,s,o)};u.createRef=function(){return{current:null}};u.forwardRef=function(t){return{$$typeof:B,render:t}};u.isValidElement=A;u.lazy=function(t){return{$$typeof:h,_payload:{_status:-1,_result:t},_init:F}};u.memo=function(t,e){return{$$typeof:Q,type:t,compare:e===void 0?null:e}};u.startTransition=function(t){var e=i.T,n={};i.T=n;try{var r=t(),o=i.S;o!==null&&o(n,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(T,P)}catch(s){P(s)}finally{e!==null&&n.types!==null&&(e.types=n.types),i.T=e}};u.unstable_useCacheRefresh=function(){return i.H.useCacheRefresh()};u.use=function(t){return i.H.use(t)};u.useActionState=function(t,e,n){return i.H.useActionState(t,e,n)};u.useCallback=function(t,e){return i.H.useCallback(t,e)};u.useContext=function(t){return i.H.useContext(t)};u.useDebugValue=function(){};u.useDeferredValue=function(t,e){return i.H.useDeferredValue(t,e)};u.useEffect=function(t,e){return i.H.useEffect(t,e)};u.useEffectEvent=function(t){return i.H.useEffectEvent(t)};u.useId=function(){return i.H.useId()};u.useImperativeHandle=function(t,e,n){return i.H.useImperativeHandle(t,e,n)};u.useInsertionEffect=function(t,e){return i.H.useInsertionEffect(t,e)};u.useLayoutEffect=function(t,e){return i.H.useLayoutEffect(t,e)};u.useMemo=function(t,e){return i.H.useMemo(t,e)};u.useOptimistic=function(t,e){return i.H.useOptimistic(t,e)};u.useReducer=function(t,e,n){return i.H.useReducer(t,e,n)};u.useRef=function(t){return i.H.useRef(t)};u.useState=function(t){return i.H.useState(t)};u.useSyncExternalStore=function(t,e,n){return i.H.useSyncExternalStore(t,e,n)};u.useTransition=function(){return i.H.useTransition()};u.version="19.2.8"});var et=_((st,k)=>{"use strict";k.exports=Y()});var x=_(y=>{"use strict";var nt=Symbol.for("react.transitional.element"),rt=Symbol.for("react.fragment");function M(t,e,n){var r=null;if(n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),"key"in e){n={};for(var o in e)o!=="key"&&(n[o]=e[o])}else n=e;return e=n.ref,{$$typeof:nt,type:t,key:r,ref:e!==void 0?e:null,props:n}}y.Fragment=rt;y.jsx=M;y.jsxs=M});var ut=_((it,I)=>{"use strict";I.exports=x()});export{et as a,ut as b};
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
react/cjs/react.production.js:
|
|
5
|
-
(**
|
|
6
|
-
* @license React
|
|
7
|
-
* react.production.js
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
-
*
|
|
11
|
-
* This source code is licensed under the MIT license found in the
|
|
12
|
-
* LICENSE file in the root directory of this source tree.
|
|
13
|
-
*)
|
|
14
|
-
|
|
15
|
-
react/cjs/react-jsx-runtime.production.js:
|
|
16
|
-
(**
|
|
17
|
-
* @license React
|
|
18
|
-
* react-jsx-runtime.production.js
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
21
|
-
*
|
|
22
|
-
* This source code is licensed under the MIT license found in the
|
|
23
|
-
* LICENSE file in the root directory of this source tree.
|
|
24
|
-
*)
|
|
25
|
-
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as l,H as p,O as k,P as y,c}from"./chunk.4TUNX4WM.js";import"./chunk.7S22MBNN.js";import"./chunk.ONDILMIX.js";import{b as m}from"./chunk.J6CBMLGR.js";import"./chunk.A73BXXE4.js";import"./chunk.N7HCALRK.js";import"./chunk.IKT7JQUW.js";import"./chunk.ISRS7GOT.js";import"./chunk.DCIC3YHX.js";import"./chunk.WHTNSETN.js";import"./chunk.WVUJXDXZ.js";import"./chunk.46KUPBQC.js";import"./chunk.N2WTNKEV.js";import"./chunk.SBHVVJY7.js";import"./chunk.GE5EAN36.js";import"./chunk.337WDTG3.js";import"./chunk.PWHJHFC4.js";import"./chunk.EYF6ONTA.js";import"./chunk.Q3HVA6L4.js";import"./chunk.AHDOKM4O.js";import"./chunk.6R4EI47C.js";import"./chunk.2GBQJXJH.js";import"./chunk.ZJDRD6PO.js";import"./chunk.SNBIZ3B6.js";import"./chunk.6LJ66MB7.js";import{T as s,V as d,ea as g}from"./chunk.NRRUGG22.js";import"./chunk.MKNXV4TM.js";import{a as S,b as f}from"./chunk.MRK6QJV5.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|