graview 0.1.70 → 0.1.71
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.23DATB5Y.js +1 -0
- package/dist/preview/chunk.2INDKSJI.js +1 -0
- package/dist/preview/chunk.3CLTABGP.js +1 -0
- package/dist/preview/{chunk.4O3STSC4.js → chunk.3RRK6UTN.js} +1 -1
- package/dist/preview/chunk.45HUV56Z.js +1 -0
- package/dist/preview/chunk.4HU2ILFY.js +1 -0
- package/dist/preview/{chunk.M7DJJRFH.js → chunk.4LWWXIM4.js} +1 -1
- package/dist/preview/chunk.4O64QV2Y.js +1 -0
- package/dist/preview/{chunk.KP7HUXH5.js → chunk.4QMAYVPU.js} +1 -1
- package/dist/preview/chunk.4UDST6IF.js +1 -0
- package/dist/preview/{chunk.7TZXDPPO.js → chunk.4YZ2A6SJ.js} +3 -3
- package/dist/preview/{chunk.PAIBRJVZ.js → chunk.4ZEHLUXV.js} +1 -1
- package/dist/preview/{chunk.I7CSRZC2.js → chunk.5EQRIZ6I.js} +1 -1
- package/dist/preview/chunk.5OS4SYHE.js +1 -0
- package/dist/preview/{chunk.ZIGW5VOT.js → chunk.5PQV7GFE.js} +1 -1
- package/dist/preview/{chunk.SSHEFQ4R.js → chunk.5WCSQFS5.js} +1 -1
- package/dist/preview/{chunk.RJ7UV3XI.js → chunk.64K5ELSQ.js} +1 -1
- package/dist/preview/{chunk.2T24FYAO.js → chunk.67S2UWBT.js} +1 -1
- package/dist/preview/{chunk.FXCKKVT5.js → chunk.6A3KTD66.js} +1 -1
- package/dist/preview/chunk.6BBUTKFC.js +23 -0
- package/dist/preview/chunk.6IMRCKB4.js +1 -0
- package/dist/preview/chunk.6L6RUOSF.js +5 -0
- package/dist/preview/{chunk.ZGJUCVT5.js → chunk.6TBQV3NO.js} +1 -1
- package/dist/preview/chunk.6ZRVVRDQ.js +1 -0
- package/dist/preview/{chunk.4VTUC5TF.js → chunk.7FI75ZVE.js} +1 -1
- package/dist/preview/{chunk.NKUNCQB3.js → chunk.7KX36ENH.js} +1 -1
- package/dist/preview/{chunk.JPJHM62B.js → chunk.7LPHWJB4.js} +1 -1
- package/dist/preview/chunk.7MDGPTYF.js +1 -0
- package/dist/preview/{chunk.JEQ6CA5M.js → chunk.7PWLRRUS.js} +2 -2
- package/dist/preview/{chunk.YBQUP3KE.js → chunk.7TACFS7Q.js} +1 -1
- package/dist/preview/{chunk.DIVANC3G.js → chunk.7THS3DLZ.js} +1 -1
- package/dist/preview/{chunk.5W7EGQCQ.js → chunk.7XGU6KVF.js} +2 -2
- package/dist/preview/chunk.7ZLCA3WK.js +1 -0
- package/dist/preview/{chunk.4BSEYZMS.js → chunk.ARGEGV5T.js} +1 -1
- package/dist/preview/{chunk.3KF5RYPW.js → chunk.BSWR5SGX.js} +1 -1
- package/dist/preview/{chunk.BBMX3IIO.js → chunk.BWMPC7LK.js} +1 -1
- package/dist/preview/{chunk.55C7WO4X.js → chunk.CEJIH3CN.js} +1 -1
- package/dist/preview/{chunk.F5756PXX.js → chunk.CEOQY5KS.js} +2 -2
- package/dist/preview/{chunk.NZFO6BM3.js → chunk.CGRX6SDE.js} +1 -1
- package/dist/preview/{chunk.C67TMA4U.js → chunk.CPK6CYKN.js} +1 -1
- package/dist/preview/{chunk.T552MHMU.js → chunk.CVN2XFMF.js} +1 -1
- package/dist/preview/{chunk.MGG5DH2S.js → chunk.D4F6QX5L.js} +1 -1
- package/dist/preview/{chunk.M3HLZX6Q.js → chunk.D6ODKMOV.js} +1 -1
- package/dist/preview/{chunk.RECTEAG4.js → chunk.DDSAFU3B.js} +1 -1
- package/dist/preview/{chunk.UJF6YTEO.js → chunk.DG3YNOH3.js} +1 -1
- package/dist/preview/chunk.DGYWNM5U.js +1 -0
- package/dist/preview/{chunk.NBB5ALVJ.js → chunk.DHO3QZYK.js} +1 -1
- package/dist/preview/{chunk.4QBW46XV.js → chunk.DJGZOPAS.js} +1 -1
- package/dist/preview/{chunk.2MWEYNVH.js → chunk.DX7RGK5G.js} +1 -1
- package/dist/preview/{chunk.CZI6J5CE.js → chunk.EA2KYBBR.js} +1 -1
- package/dist/preview/{chunk.DWMFLLJO.js → chunk.EEGVI266.js} +1 -1
- package/dist/preview/{chunk.BQWMHHAZ.js → chunk.EHLV3LND.js} +2 -2
- package/dist/preview/{chunk.3MPLUSVY.js → chunk.EJC7ACZT.js} +1 -1
- package/dist/preview/{chunk.6NYSB6OZ.js → chunk.EJIQDMLU.js} +1 -1
- package/dist/preview/{chunk.QQUZ5RTQ.js → chunk.EOSN5DWW.js} +1 -1
- package/dist/preview/{chunk.2QALBEWP.js → chunk.EPSYX2SF.js} +1 -1
- package/dist/preview/chunk.EUXAIG73.js +1 -0
- package/dist/preview/{chunk.S4QSZRKH.js → chunk.EZQK23AB.js} +1 -1
- package/dist/preview/{chunk.ZTHZHBVN.js → chunk.F5O3HR7X.js} +1 -1
- package/dist/preview/chunk.F6MY6WJ4.js +1 -0
- package/dist/preview/{chunk.UVMHC6VM.js → chunk.F7KVEWFH.js} +1 -1
- package/dist/preview/{chunk.FJXKQZZS.js → chunk.FIUPDGUZ.js} +1 -1
- package/dist/preview/chunk.FNSVGSZI.js +1 -0
- package/dist/preview/chunk.FOHZPYUV.js +1 -0
- package/dist/preview/chunk.FW6M6GIU.js +32 -0
- package/dist/preview/{chunk.IJVR7ZL7.js → chunk.G5AF5IXL.js} +1 -1
- package/dist/preview/{chunk.SCN6IYDG.js → chunk.G767NLBH.js} +1 -1
- package/dist/preview/{chunk.X7HMTN3Z.js → chunk.GFBE4VNT.js} +1 -1
- package/dist/preview/{chunk.U5Q7EVZQ.js → chunk.GFOZVQBQ.js} +1 -1
- package/dist/preview/{chunk.KJAOJTZZ.js → chunk.GKYJQE5A.js} +1 -1
- package/dist/preview/{chunk.YCMMATFK.js → chunk.GOVRX2YX.js} +1 -1
- package/dist/preview/{chunk.U3CV227I.js → chunk.H33XWGAY.js} +1 -1
- package/dist/preview/{chunk.DGDOZHYK.js → chunk.H4BPTMED.js} +1 -1
- package/dist/preview/chunk.HLKDYI6J.js +1 -0
- package/dist/preview/{chunk.C4LC2UEU.js → chunk.HPFEYMGP.js} +1 -1
- package/dist/preview/{chunk.CLJKQLK2.js → chunk.HT35PAHI.js} +2 -2
- package/dist/preview/{chunk.6VG2LCES.js → chunk.HXRHEPPJ.js} +1 -1
- package/dist/preview/{chunk.LZNHTROY.js → chunk.IXYG65TM.js} +1 -1
- package/dist/preview/chunk.IZDB777E.js +1 -0
- package/dist/preview/{chunk.ZQSV5XVB.js → chunk.JAPTTM6Y.js} +1 -1
- package/dist/preview/{chunk.CUA7F3YJ.js → chunk.JCKIJSW7.js} +1 -1
- package/dist/preview/{chunk.WAIIXXVI.js → chunk.JLNTE5CH.js} +2 -2
- package/dist/preview/{chunk.5FQHZVE3.js → chunk.JNK5WBSU.js} +1 -1
- package/dist/preview/chunk.JREA2XDG.js +1 -0
- package/dist/preview/{chunk.CHG522KL.js → chunk.KBJ3UUER.js} +1 -1
- package/dist/preview/{chunk.VBHV4TLG.js → chunk.KHRS2SKB.js} +1 -1
- package/dist/preview/{chunk.CZUUFO6A.js → chunk.KJPLX72N.js} +1 -1
- package/dist/preview/{chunk.7LAXSQQY.js → chunk.KZUHXOZU.js} +2 -2
- package/dist/preview/{chunk.R65YX332.js → chunk.L3MLGFIS.js} +1 -1
- package/dist/preview/{chunk.RXUL6P7Y.js → chunk.L6P55HFW.js} +1 -1
- package/dist/preview/{chunk.J4NY2K2A.js → chunk.LDWWUKKX.js} +1 -1
- package/dist/preview/{chunk.RIP2SAQ5.js → chunk.LHCGC3K6.js} +1 -1
- package/dist/preview/{chunk.IQCMV5WD.js → chunk.LNKY6MT4.js} +1 -1
- package/dist/preview/chunk.LQ5J6YQW.js +1 -0
- package/dist/preview/{chunk.O2XPLDMM.js → chunk.MEAUTBVM.js} +1 -1
- package/dist/preview/chunk.MEBKTW7H.js +17 -0
- package/dist/preview/{chunk.K6EKSURO.js → chunk.MFMC35ET.js} +1 -1
- package/dist/preview/chunk.MJ4T6YXI.js +1 -0
- package/dist/preview/{chunk.SWY6DIE4.js → chunk.MKJV3BM5.js} +3 -3
- package/dist/preview/chunk.ML4X7VVK.js +1 -0
- package/dist/preview/{chunk.ZOSTOVXR.js → chunk.MM7MLBGB.js} +1 -1
- package/dist/preview/{chunk.NCBUECIW.js → chunk.MQNW3O67.js} +1 -1
- package/dist/preview/{chunk.CVVNHQPO.js → chunk.MT252WP4.js} +1 -1
- package/dist/preview/{chunk.VKQONZKR.js → chunk.MWWNKM3I.js} +1 -1
- package/dist/preview/chunk.N3MXLORL.js +3 -0
- package/dist/preview/{chunk.SUYYDJGZ.js → chunk.NH3VXTGX.js} +1 -1
- package/dist/preview/{chunk.IRPMGHZN.js → chunk.NI4OPHTL.js} +1 -1
- package/dist/preview/chunk.NNGG7RCO.js +1 -0
- package/dist/preview/{chunk.MZSWWMX6.js → chunk.NXHEOHRR.js} +1 -1
- package/dist/preview/{chunk.A5ENJJZN.js → chunk.O5RPSUXV.js} +1 -1
- package/dist/preview/{chunk.CM7EDQ4E.js → chunk.OKHXXIMN.js} +1 -1
- package/dist/preview/chunk.OOQG2AEF.js +1 -0
- package/dist/preview/{chunk.MYR36HW4.js → chunk.OPMGQS5J.js} +1 -1
- package/dist/preview/{chunk.TUVPQLFL.js → chunk.OUF2QFZL.js} +1 -1
- package/dist/preview/{chunk.6QMRDSTD.js → chunk.OVSKPBPS.js} +1 -1
- package/dist/preview/chunk.OYMN3IFX.js +1 -0
- package/dist/preview/{chunk.3HFBHLXC.js → chunk.P43LPXXJ.js} +1 -1
- package/dist/preview/{chunk.FSZQTX3K.js → chunk.PGT4ZQDG.js} +4 -4
- package/dist/preview/{chunk.5IM2X3VT.js → chunk.PQTXM4VY.js} +1 -1
- package/dist/preview/{chunk.U2DZE7A5.js → chunk.Q6GEPVQ7.js} +1 -1
- package/dist/preview/{chunk.HMV4ILAC.js → chunk.QDDDKEBH.js} +1 -1
- package/dist/preview/{chunk.6KYTCEIH.js → chunk.QJJWAYHB.js} +1 -1
- package/dist/preview/{chunk.QAERSZVB.js → chunk.QK4QZVQG.js} +1 -1
- package/dist/preview/{chunk.XAN7QXMQ.js → chunk.QKRQPUCE.js} +1 -1
- package/dist/preview/{chunk.I3ADXJQW.js → chunk.QNWGDG2Z.js} +1 -1
- package/dist/preview/{chunk.NZ5TJKPT.js → chunk.QVBP4UZG.js} +2 -2
- package/dist/preview/{chunk.YTRUZ56A.js → chunk.RDUGUC7R.js} +1 -1
- package/dist/preview/{chunk.TVNY7F64.js → chunk.RHIP2UYE.js} +1 -1
- package/dist/preview/{chunk.PYGNO2AV.js → chunk.RJ7VSWTA.js} +3 -3
- package/dist/preview/{chunk.LEZGBHPZ.js → chunk.RO3D2RNP.js} +1 -1
- package/dist/preview/{chunk.KOVTQCHX.js → chunk.S2BMI23H.js} +1 -1
- package/dist/preview/{chunk.XJ4JYROM.js → chunk.SPJ34VHA.js} +1 -1
- package/dist/preview/{chunk.LZ3HO3HM.js → chunk.T6KOL7TW.js} +1 -1
- package/dist/preview/{chunk.BJ3G7J2Z.js → chunk.T6UJEXFL.js} +3 -2
- package/dist/preview/{chunk.T4QRIJE4.js → chunk.TBEKEHFS.js} +1 -1
- package/dist/preview/chunk.TO3ZKCA2.js +1 -0
- package/dist/preview/{chunk.QILGAV7H.js → chunk.TQ3MNB6K.js} +1 -1
- package/dist/preview/{chunk.F5XWYO5W.js → chunk.TRP66PHK.js} +1 -1
- package/dist/preview/{chunk.QODVFVWE.js → chunk.TSZ2S3VG.js} +1 -1
- package/dist/preview/{chunk.DWPM7AWA.js → chunk.TTM5GQ2U.js} +1 -1
- package/dist/preview/chunk.TUBY6SV3.js +1 -0
- package/dist/preview/{chunk.7QWGIGHM.js → chunk.U5KJQFAP.js} +1 -1
- package/dist/preview/chunk.U6V4KZF5.js +1 -0
- package/dist/preview/chunk.UJ7RTNT4.js +1 -0
- package/dist/preview/{chunk.MR776WQ2.js → chunk.UQZ2P6KD.js} +1 -1
- package/dist/preview/{chunk.OXXZGPJZ.js → chunk.UZKBFI52.js} +1 -1
- package/dist/preview/{chunk.HIJ72QX6.js → chunk.V5JB5UJS.js} +1 -1
- package/dist/preview/{chunk.3I2SGKKF.js → chunk.VDFQFLTU.js} +1 -1
- package/dist/preview/{chunk.I6HIVTXU.js → chunk.VGYG2IBZ.js} +1 -1
- package/dist/preview/chunk.VICBF3MQ.js +2 -0
- package/dist/preview/{chunk.TD2V74XU.js → chunk.VL3YDD7D.js} +1 -1
- package/dist/preview/{chunk.A7JORJJL.js → chunk.VPFUOTY7.js} +1 -1
- package/dist/preview/{chunk.UWEFODVV.js → chunk.VUDNQOOX.js} +1 -1
- package/dist/preview/{chunk.YIDNZTON.js → chunk.VVIQSFM4.js} +1 -1
- package/dist/preview/{chunk.J65CZJIC.js → chunk.W332P5T3.js} +1 -1
- package/dist/preview/{chunk.S6IKR6RD.js → chunk.W3TJF4EH.js} +1 -1
- package/dist/preview/{chunk.7FTATAH2.js → chunk.W5O5F4FT.js} +1 -1
- package/dist/preview/chunk.W6L2VAJG.js +2 -0
- package/dist/preview/{chunk.QG3LV4RH.js → chunk.WGH2P2YL.js} +1 -1
- package/dist/preview/{chunk.KV3N6VRG.js → chunk.WS5ORRGS.js} +1 -1
- package/dist/preview/{chunk.7HNMG6LG.js → chunk.WU6D3SPL.js} +1 -1
- package/dist/preview/{chunk.MSWOETXN.js → chunk.X2UYEA7H.js} +1 -1
- package/dist/preview/{chunk.FBDCHJS2.js → chunk.X45EITTK.js} +1 -1
- package/dist/preview/{chunk.JIEBGUCA.js → chunk.X7U3JMBR.js} +1 -1
- package/dist/preview/chunk.XSM4OTF4.js +1 -0
- package/dist/preview/{chunk.5A5DI36V.js → chunk.XTHSPLZZ.js} +1 -1
- package/dist/preview/{chunk.TS5APXWC.js → chunk.Y5WQD6KV.js} +1 -1
- package/dist/preview/{chunk.3QPMFUMV.js → chunk.YXVUJ3NB.js} +1 -1
- package/dist/preview/{chunk.F5STM4DX.js → chunk.Z22C2JJ4.js} +1 -1
- package/dist/preview/{chunk.BBLA4PSP.js → chunk.Z2BCOZDZ.js} +1 -1
- package/dist/preview/{chunk.BZXJKWNI.js → chunk.Z3TK2LJM.js} +1 -1
- package/dist/preview/chunk.ZGLOXN7O.js +1 -0
- package/dist/preview/{chunk.UJM5EZDM.js → chunk.ZLQIGZXO.js} +1 -1
- package/dist/preview/{chunk.FUTSLXWN.js → chunk.ZONRIOIA.js} +1 -1
- package/dist/preview/{chunk.NTAC5NNE.js → chunk.ZY3NAJDM.js} +1 -1
- package/dist/preview/index.html +55 -55
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2QOB62XU.js +0 -1
- package/dist/preview/chunk.36FKQJFM.js +0 -2
- package/dist/preview/chunk.3A3DCALP.js +0 -1
- package/dist/preview/chunk.3GPYKWAD.js +0 -1
- package/dist/preview/chunk.3ZP6IDUC.js +0 -1
- package/dist/preview/chunk.53HW224Y.js +0 -1
- package/dist/preview/chunk.AW74DZ5V.js +0 -17
- package/dist/preview/chunk.CCCSZRKU.js +0 -1
- package/dist/preview/chunk.DBSSCJQM.js +0 -1
- package/dist/preview/chunk.DW6KXAUM.js +0 -1
- package/dist/preview/chunk.HHQUCFN4.js +0 -1
- package/dist/preview/chunk.HPWMCS3H.js +0 -23
- package/dist/preview/chunk.HRLCDBMO.js +0 -1
- package/dist/preview/chunk.I7ODVOO5.js +0 -1
- package/dist/preview/chunk.IANOWT3Z.js +0 -1
- package/dist/preview/chunk.IFPJPJ4M.js +0 -1
- package/dist/preview/chunk.IUVRJDL3.js +0 -5
- package/dist/preview/chunk.J4CSY2D5.js +0 -2
- package/dist/preview/chunk.JJIKTTXB.js +0 -1
- package/dist/preview/chunk.KDOJC4FX.js +0 -1
- package/dist/preview/chunk.KLZPUTMU.js +0 -1
- package/dist/preview/chunk.LQ2PDW2M.js +0 -32
- package/dist/preview/chunk.MNWP3TPN.js +0 -1
- package/dist/preview/chunk.NILR2BWR.js +0 -1
- package/dist/preview/chunk.NNYKLENL.js +0 -1
- package/dist/preview/chunk.PZHCWMKT.js +0 -1
- package/dist/preview/chunk.QVID5WHS.js +0 -1
- package/dist/preview/chunk.RHV73CBA.js +0 -3
- package/dist/preview/chunk.RP6C2IUM.js +0 -1
- package/dist/preview/chunk.RPHZY7N4.js +0 -1
- package/dist/preview/chunk.UYBSVE2W.js +0 -1
- package/dist/preview/chunk.WMZ2BINI.js +0 -1
- package/dist/preview/chunk.X2RHBTJI.js +0 -1
- package/dist/preview/chunk.X3FPVFFB.js +0 -1
- package/dist/preview/chunk.X4PFLIXB.js +0 -1
- package/dist/preview/chunk.YR7DKU5T.js +0 -1
- package/dist/preview/chunk.ZBK3FCVE.js +0 -1
- package/dist/preview/chunk.ZH5L746C.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as te}from"./chunk.I3ADXJQW.js";import"./chunk.BJUUSIQY.js";import"./chunk.7QWGIGHM.js";import"./chunk.I6HIVTXU.js";import"./chunk.PYGNO2AV.js";import"./chunk.3HFBHLXC.js";import{G as ne,Y as N}from"./chunk.CUA7F3YJ.js";import"./chunk.SDO3U72B.js";import{Dd as $,ma as Q,pa as X,pb as Z,zd as ee}from"./chunk.IUVRJDL3.js";import"./chunk.FQLNBIQ5.js";import{b as P}from"./chunk.AJZBJBMO.js";var D=new WeakMap,we=5e3;function I(n){let e=D.get(n);if(e&&Date.now()-e.at<we)return e.list;let t={at:Date.now(),list:Promise.resolve([])};return t.list=Promise.resolve().then(()=>n.list()).catch(()=>[]).then(o=>t.value=[...o,...(t.value??[]).filter(i=>!o.some(l=>l.id===i.id))]),e?.value&&(t.value=e.value),D.set(n,t),t.list}var oe=n=>D.get(n)?.value;function re(n,e){let t=D.get(n);if(!t)return;let o=i=>[...i.filter(l=>l.id!==e.id),e];t.value&&(t.value=o(t.value)),D.set(n,{at:t.at,list:t.list.then(o),...t.value?{value:t.value}:{}})}function A(n,e){let t=$(n,e);return o=>n.graph.getNode(o)!==void 0&&t(o)}var z=["previewed","accepted","declined","undone","abandoned"],ve=["graph","light","full"],S={words:300,should:300,name:80,records:200,people:20,stages:8,examples:5},Se=365,xe=5e3,be=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");function ie(n,e){if(typeof n!="string")return;let t=n.replace(be," ").replace(/\s+/g," ").trim();return t.length===0?void 0:t.slice(0,e).trimEnd()}function h(n){return typeof n=="string"&&n.length>0&&n.length<=S.name&&/^[\p{L}\p{N}_][\p{L}\p{N}_.:/-]*$/u.test(n)?n:void 0}var W=(n,e)=>Array.isArray(n)?[...new Set(n.flatMap(t=>h(t)??[]))].slice(0,e):[];function ae(n){let e=typeof n.id=="string"?n.id.slice(0,S.name):void 0;return{kind:n.kind,...e!==void 0?{id:e}:{},...n.onBehalfOf?{onBehalfOf:ae(n.onBehalfOf)}:{}}}var le=n=>n?.kind==="visitor"||n?.onBehalfOf?.kind==="visitor",ke=()=>`tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,Oe=new Set(["record","field","selection","list","lens","place","act"]);function Pe(n){let e=n,t=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0?Math.min(1e4,Math.round(o)):0;switch(e?.type){case"act":{let o=h(e.act);return o?{type:"act",act:o,records:t(e.records)}:void 0}case"plan":return{type:"plan",edits:t(e.edits)};case"answer":return{type:"answer"};case"refusal":return{type:"refusal"};case"view":{let o=typeof e.section=="string"?e.section.replace(/\s+/g," ").trim().slice(0,S.name):"";return o?{type:"view",section:o}:void 0}default:return}}function se(n,e,t={}){if(!n||typeof n!="object"||!e||le(e))return;let o=n,i=ie(o.words,S.words),l=Pe(o.decided),d=o.target;if(!i||!l||!d||!Oe.has(String(d.on)))return;let s={on:d.on,...h(d.kind)?{kind:h(d.kind)}:{},...h(d.id)?{id:h(d.id)}:{},...h(d.place)?{place:h(d.place)}:{}},c=o.reading,a=c&&(c.which==="itself"||c.which==="held")&&h(c.kind)?{which:c.which,kind:h(c.kind),records:W(c.records,S.records)}:void 0,g=W(o.people,S.people),f=Array.isArray(o.stages)?o.stages.flatMap(Te=>{let L=Te,V=h(L?.stage),E=L?.ms;return V&&typeof E=="number"&&Number.isFinite(E)&&E>=0?[{stage:V,ms:Math.round(E),...h(L.model)?{model:h(L.model)}:{}}]:[]}).slice(0,S.stages):[],w=z.includes(o.outcome)?o.outcome:"previewed",y=ve.includes(o.slot)?o.slot:void 0,b=o.rating==="up"||o.rating==="down"?o.rating:void 0,k=b==="down"?ie(o.should,S.should):void 0,O=typeof o.ms=="number"&&Number.isFinite(o.ms)&&o.ms>=0?Math.round(o.ms):void 0,r=t.id??h(o.id)??ke(),p=h(o.conversation)??r,m=h(o.follows),Y=h(o.interaction),J=W(o.examples,S.examples);return{id:r,at:t.at??new Date().toISOString(),by:ae(e),words:i,target:s,...a?{reading:a}:{},...g.length>0?{people:g}:{},decided:l,...y?{slot:y}:{},...f.length>0?{stages:f}:{},...O!==void 0?{ms:O}:{},outcome:w,...b?{rating:b}:{},...k?{should:k}:{},conversation:p,...m?{follows:m}:{},...Y?{interaction:Y}:{},...J.length>0?{examples:J}:{}}}function Ae(n,e){let t=e.outcome===void 0||e.outcome==="previewed"||n.outcome==="accepted"&&e.outcome!=="undone"||n.outcome==="undone"||(n.outcome==="declined"||n.outcome==="abandoned")&&e.outcome==="abandoned"?n.outcome:e.outcome,o=e.rating===void 0?n.rating:e.rating??void 0,i=o!=="down"?void 0:e.should===void 0?n.should:e.should??void 0,{rating:l,should:d,...s}=n;return{...s,outcome:t,...o?{rating:o}:{},...i?{should:i}:{},...e.examples?{examples:e.examples}:{},...e.pinned!==void 0?{pinned:e.pinned}:{},...e.excluded!==void 0?{excluded:e.excluded}:{}}}function Ce(n,e={}){let t=(e.now??Date.now())-(e.retentionDays??Se)*864e5,o=new Map;for(let d of n){let s=Date.parse(d.at);Number.isFinite(s)&&s>=t&&!le(d.by)&&o.set(d.id,d)}let i=[...o.values()],l=e.most??xe;return i.length>l?i.slice(i.length-l):i}function H(n,e,t={}){return"add"in e?Ce([...n,e.add],t):"remove"in e?n.filter(o=>o.id!==e.remove):n.map(o=>o.id===e.change?Ae(o,e.with):o)}var C=n=>n.onBehalfOf?C(n.onBehalfOf):n.id!==void 0?`${n.kind}:${n.id}`:`${n.kind}:?`,Re=n=>[...new Set([...n.target.id?[n.target.id]:[],...n.reading?.records??[],...n.people??[]])];function R(n,e){return n.filter(t=>Re(t).every(e))}var B=n=>!n.excluded&&n.rating!=="down"&&n.outcome!=="undone"&&(n.outcome==="accepted"||n.rating==="up"),U=n=>{let e=n.reading?.kind??n.target.kind??"";return n.decided.type==="act"?`act:${n.decided.act}:${e}:${n.reading?.which??""}`:n.decided.type==="plan"?`plan:${e}`:void 0};function De(n,e={}){let t=Math.max(1,e.minPeople??2),o=e.reader?C(e.reader):void 0,i=new Map;for(let l of n){let d=U(l);!d||!B(l)||C(l.by)===o||i.set(d,(i.get(d)??new Set).add(C(l.by)))}return new Set([...i].filter(([,l])=>l.size>=t).map(([l])=>l))}function ce(n,e){return n.filter(t=>(e.rating===void 0||(e.rating==="none"?t.rating===void 0:t.rating===e.rating))&&(e.outcome===void 0||t.outcome===e.outcome)&&(e.kind===void 0||(t.reading?.kind??t.target.kind)===e.kind))}var Le=n=>n.filter(e=>B(e)&&U(e)!==void 0);function ue(n){let e=Le(n).length;return e===0?"Nothing told here teaches suggestions yet: a telling that is accepted or rated \u{1F44D} will.":`Suggestions come from ${e} rated ${e===1?"telling":"tellings"} in this app.`}function ge(n,e=t=>t){switch(n.decided.type){case"act":return`${e(n.decided.act)}, over ${n.decided.records} ${n.decided.records===1?"record":"records"}`;case"plan":return`A plan of ${n.decided.edits} ${n.decided.edits===1?"change":"changes"} to the app`;case"answer":return"An open answer";case"refusal":return"Nothing it could do";case"view":return`A revision of \u201C${n.decided.section}\u201D`}}var G={previewed:"Previewed",accepted:"Accepted",declined:"Declined",undone:"Undone",abandoned:"Closed with nothing done"},Ee=new Set("a an and are as at be by can do does for from has have how i in is it its me my of on or our please the their them these they this those to was we what when where which who why will with you your all each every".split(" "));function de(n){return[...new Set(n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(e=>e.length>1&&!Ee.has(e)).map(e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e))]}function M(n,e,t={}){let o=de(e.words);if(o.length===0)return[];let i=t.reader?C(t.reader):void 0,l=De(n,{...t.reader?{reader:t.reader}:{},...t.minPeople!==void 0?{minPeople:t.minPeople}:{}}),d=n.flatMap(a=>{let g=U(a);if(!g||!B(a)||t.rated&&a.rating!=="up")return[];if(!(i!==void 0&&C(a.by)===i)&&!l.has(g))return[];let w=de(a.words),y=o.filter(p=>w.some(m=>m===p||p.length>=3&&m.startsWith(p))).length;if(y===0)return[];let b=y/new Set([...o,...w]).size,k=e.kind!==void 0&&(a.target.kind===e.kind||a.reading?.kind===e.kind)?.25:e.kind!==void 0?-.25:0,O=e.act!==void 0&&a.decided.type==="act"&&a.decided.act===e.act?.15:0,r=Math.max(0,Math.min(1,b*.6+.25+k+O+(a.pinned?.1:0)));return r>=(t.floor??.35)?[{telling:a,score:r,lesson:g}]:[]});d.sort((a,g)=>g.score-a.score||Number(g.telling.pinned??!1)-Number(a.telling.pinned??!1)||(a.telling.at<g.telling.at?1:-1));let s=new Set,c=[];for(let a of d)if(!s.has(a.lesson)&&(s.add(a.lesson),c.push({telling:a.telling,score:a.score}),c.length>=(t.most??2)))break;return c}function pe(n){return n.map(({telling:e})=>({said:e.words,did:e.decided.type==="act"?`act ${e.decided.act} over ${e.reading?.which==="itself"?"the record itself":"each record it holds"}`:e.decided.type==="plan"?"a plan that changes the app":e.decided.type==="view"?"a revision of a view's section":e.decided.type,...e.reading?{reading:e.reading.which}:{}}))}var x=P(ne(),1),T=P(N(),1);function ye(n,e){if(e.on==="list"||e.on==="lens")return e.kind;let t=te(e)[0];return t?n.graph.getNode(t)?.kind:void 0}function $e(n,e,t,o,i){let l=n?oe(n):void 0;if(!l)return{examples:[],ids:[]};let d=ye(e,i),s=M(R(l,A(e,t)),{words:o,...d?{kind:d}:{}},{reader:t,rated:!0,most:3});return{examples:pe(s),ids:s.map(c=>c.telling.id)}}function Ne(n){let e=new Set((n.stages??[]).map(t=>t.stage));return e.has("thinking")?"full":e.has("light")?"light":e.has("fast")?"graph":(n.usage??[]).some(t=>t.tier==="thinking")?"full":void 0}function Ie(n,e){if(n.interaction.outcome==="failed"||e&&"refused"in e)return{type:"refusal"};if(e&&"question"in e)return e.proposal?{type:"plan",edits:e.parts.length}:{type:"refusal"};let t=n.ghost?.proposals??[];return t.length>0?{type:"act",act:t[0].call.name,records:new Set(t.map(i=>i.record??i.id)).size}:{type:"answer"}}function Me(n,e){let t=new Set;for(let o of e.ghost?.proposals??[])for(let i of Object.values(o.call.args))typeof i=="string"&&i!==o.record&&n.graph.getNode(i)&&t.add(i);return[...t]}function _e(n,e){let{target:t,result:o}=e,i=ye(n,t),l=t.on==="record"||t.on==="field"?t.id:void 0,d=t.on==="lens"||t.on==="place"?t.place:void 0,s=o.reading?{which:o.reading.which,kind:o.reading.kind,records:o.reading.records}:void 0,c=Me(n,o),a=Ne(o.interaction),g=Ie(o,e.plan);return{words:e.words,target:{on:t.on,...i?{kind:i}:{},...l?{id:l}:{},...d?{place:d}:{}},...s?{reading:s}:{},...c.length>0?{people:c}:{},decided:g,...a?{slot:a}:{},...o.interaction.stages?{stages:o.interaction.stages}:{},ms:e.ms,outcome:"previewed",...e.conversation?{conversation:e.conversation}:{},...e.follows?{follows:e.follows}:{},interaction:o.interaction.id,...e.examples&&e.examples.length>0?{examples:e.examples}:{}}}function Fe(n,e,t){if(!n)return;let o=se(e,t);if(o)return re(n,o),Promise.resolve().then(()=>n.add(o)).catch(()=>{}),o}function _(n,e,t){n&&Promise.resolve().then(()=>n.change(e,t)).catch(()=>{})}var We={accepted:"accepted",partly:"accepted",drawn:"accepted",dismissed:"declined"};function ze(n,e,t){let o,i=()=>{let c=n.get().entries.find(g=>g.id===t.interaction);if(!c)return;let a=c.undone?"undone":We[c.outcome];!a||a===o||(o=a,_(e,t.id,{outcome:a}),a==="undone"&&s())},l=n.subscribe(i),d=setTimeout(()=>s(),30*6e4),s=()=>{l(),clearTimeout(d)};return s}function He({told:n,telling:e}){let[t,o]=(0,x.useState)(e.rating),[i,l]=(0,x.useState)(""),[d,s]=(0,x.useState)(!1),c=(0,x.useId)();(0,x.useEffect)(()=>{o(e.rating),l(""),s(!1)},[e.id,e.rating]);let a=f=>{let w=t===f?void 0:f;o(w),s(!1),_(n,e.id,{rating:w??null})},g=()=>{let f=i.trim();!f||t!=="down"||(_(n,e.id,{should:f}),s(!0))};return(0,T.jsxs)("div",{"data-testid":"quick-ask-rating","data-rating":t??"",style:{display:"grid",gap:6},children:[(0,T.jsxs)("div",{role:"group","aria-label":"Was this right?",style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-right","aria-label":"This was right",title:"This was right","aria-pressed":t==="up",onClick:()=>a("up"),style:t==="up"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44D}"})}),(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-wrong","aria-label":"This was wrong",title:"This was wrong","aria-pressed":t==="down",onClick:()=>a("down"),style:t==="down"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44E}"})})]}),t==="down"?(0,T.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,T.jsxs)("label",{htmlFor:c,style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:["What should it have done? ",(0,T.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"(optional)"})]}),(0,T.jsx)("input",{id:c,type:"text","data-testid":"quick-ask-should",value:i,maxLength:300,autoComplete:"off",enterKeyHint:"done",onChange:f=>{l(f.target.value),s(!1)},onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),g())},onBlur:g,style:Be}),d?(0,T.jsx)("span",{role:"status","data-testid":"quick-ask-should-kept",style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:n.keptSays?.trim()||"Kept, to learn from."}):null]}):null]})}var K={display:"inline-grid",placeItems:"center",width:30,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer",opacity:.7},fe={...K,opacity:1,borderColor:"var(--graview-accent)",background:"var(--graview-panel)"},Be={boxSizing:"border-box",width:"100%",height:32,padding:"0 8px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8};var j=n=>n.charAt(0).toUpperCase()+n.slice(1);function me(n,e){if(!e)return;let t=n.graph.getNode(e);if(t)return t.kind;let o=/^(?:kind|aggregate):(.+)$/.exec(e)?.[1];return o&&n.schema.tryDefinition(o)?o:void 0}function he(n,e,t){let o=n.schema;if(e.decided.type==="plan")return j(e.words);if(e.decided.type!=="act")return;let i=e.decided.act,l=n.allMutations().find(y=>y.name===i);if(!l)return;let d=l.title??l.name,s=y=>/\b(?:it|this|them)\b/i.test(d)?d.replace(/\b(?:it|this|them)\b/i,y):`${d} ${y}`,c=t?n.graph.getNode(t):void 0,a=c?Q(o.tryDefinition(c.kind),c):void 0,g=e.reading?.kind??e.target.kind;if(!g||!o.tryDefinition(g))return;if(e.reading?.which==="itself"||!e.reading&&c?.kind===g)return c&&c.kind===g&&a?j(s(a)):void 0;let f=c?new Set([...n.graph.in(c.id),...n.graph.out(c.id)].filter(y=>y.kind===g).map(y=>y.id)).size:me(n,t)===g?n.graph.allNodes().filter(y=>y.kind===g).length:0;if(f===0)return;let w=f===1?(o.tryDefinition(g)?.noun??g).toLowerCase():X(o,g).toLowerCase();return j(s(`the ${f} ${w}${a?` in ${a}`:""}`))}async function Ue(n,e,t){return R(await I(n),A(e,t))}function Ge(n,e,t,o,i,l=4){if(o.trim()==="")return[];let d=me(e,i);return M(n,{words:o,...d?{kind:d}:{}},{reader:t,most:l}).flatMap(({telling:s})=>{let c=he(e,s,i);return c?[{key:`told:${s.id}`,telling:s,label:c}]:[]})}function Ke(n,e,t,o,i=3){let l=new Set,d=[];for(let s of[...n].reverse()){if(d.length>=i)break;if(!(s.rating==="up"||s.outcome==="accepted")||s.by!==void 0&&t.id!==void 0&&s.by.id!==void 0&&s.by.id!==t.id)continue;let c=he(e,s,o);!c||l.has(c.toLowerCase())||(l.add(c.toLowerCase()),d.push({key:`told:${s.id}`,telling:s,label:c}))}return d}var v=P(ne(),1),u=P(N(),1);function je({told:n,store:e,principal:t,onClose:o}){let[i,l]=(0,v.useState)(null),[d,s]=(0,v.useState)({}),c=(0,v.useRef)(null);(0,v.useEffect)(()=>{let r=!0;return Promise.resolve().then(()=>n.list()).then(p=>r&&l(p),()=>r&&l([])),c.current?.focus({preventScroll:!0}),()=>{r=!1}},[n]);let a=(0,v.useMemo)(()=>i?R(i,$(e,t)):[],[i,e,t]),g=(0,v.useMemo)(()=>[...ce(a,d)].sort((r,p)=>r.at<p.at?1:-1),[a,d]),f=(0,v.useMemo)(()=>[...new Set(a.flatMap(r=>r.reading?.kind??r.target.kind??[]))].sort(),[a]),w=r=>e.allMutations().find(p=>p.name===r)?.title??r,y=r=>e.schema.tryDefinition(r)?.plural??r,b=r=>{try{return Z(r.by,{graph:e.graph,schema:e.schema})}catch{return r.by.id??r.by.kind}},k=(r,p)=>{l(m=>m&&H(m,{change:r,with:p})),Promise.resolve().then(()=>n.change(r,p)).catch(()=>{})},O=r=>{l(p=>p&&H(p,{remove:r})),Promise.resolve().then(()=>n.remove(r)).catch(()=>{})};return(0,u.jsxs)("section",{ref:c,tabIndex:-1,"data-testid":"told-panel","data-graview-overlay":"","aria-label":"What Graview has been told",onKeyDown:r=>{r.key==="Escape"&&(r.stopPropagation(),o())},style:qe,children:[(0,u.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,u.jsx)("h2",{style:{margin:0,fontSize:"1rem",fontWeight:600,flex:"1 1 auto"},children:"What Graview has been told"}),(0,u.jsx)("button",{type:"button","data-testid":"told-close",onClick:o,style:F,children:"Close"})]}),(0,u.jsx)("p",{"data-testid":"told-teaching",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:i===null?"Reading what was told\u2026":ue(a)}),(0,u.jsxs)("div",{role:"group","aria-label":"Show only",style:{display:"flex",flexWrap:"wrap",gap:8,fontSize:"0.8125rem"},children:[(0,u.jsxs)("label",{style:q,children:["Rating",(0,u.jsxs)("select",{"data-testid":"told-filter-rating",value:d.rating??"",onChange:r=>s(({rating:p,...m})=>r.target.value?{...m,rating:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),(0,u.jsx)("option",{value:"up",children:"\u{1F44D} Right"}),(0,u.jsx)("option",{value:"down",children:"\u{1F44E} Wrong"}),(0,u.jsx)("option",{value:"none",children:"Not rated"})]})]}),(0,u.jsxs)("label",{style:q,children:["Outcome",(0,u.jsxs)("select",{"data-testid":"told-filter-outcome",value:d.outcome??"",onChange:r=>s(({outcome:p,...m})=>r.target.value?{...m,outcome:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),z.map(r=>(0,u.jsx)("option",{value:r,children:G[r]},r))]})]}),(0,u.jsxs)("label",{style:q,children:["Kind",(0,u.jsxs)("select",{"data-testid":"told-filter-kind",value:d.kind??"",onChange:r=>s(({kind:p,...m})=>r.target.value?{...m,kind:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),f.map(r=>(0,u.jsx)("option",{value:r,children:y(r)},r))]})]})]}),i!==null&&g.length===0?(0,u.jsx)("p",{"data-testid":"told-none",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:a.length===0?"Nothing has been told here yet.":"Nothing told here fits these."}):null,(0,u.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,overflowY:"auto"},children:g.map(r=>(0,u.jsxs)("li",{"data-testid":"told-entry","data-telling":r.id,"data-outcome":r.outcome,"data-rating":r.rating??"","data-excluded":r.excluded?"":void 0,"data-pinned":r.pinned?"":void 0,style:Ye,children:[(0,u.jsxs)("p",{style:{margin:0,fontWeight:550,overflowWrap:"anywhere"},children:["\u201C",r.words,"\u201D"]}),(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem"},children:[ge(r,w)," \xB7 ",G[r.outcome],r.rating?` \xB7 ${r.rating==="up"?"\u{1F44D} right":"\u{1F44E} wrong"}`:"",r.pinned?" \xB7 a good example":"",r.excluded?" \xB7 excluded from suggestions":""]}),r.should?(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",fontStyle:"italic"},children:["Should have: ",r.should]}):null,(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:[b(r)," \xB7 ",(0,u.jsx)("time",{dateTime:r.at,children:new Date(r.at).toLocaleString()}),r.ms!==void 0?` \xB7 ${r.ms<1e3?`${r.ms} ms`:`${(r.ms/1e3).toFixed(1)} s`}`:""]}),(0,u.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[(0,u.jsx)("button",{type:"button","data-testid":"told-pin","aria-pressed":r.pinned===!0,onClick:()=>k(r.id,{pinned:!r.pinned}),style:F,children:r.pinned?"Not a good example":"A good example"}),(0,u.jsx)("button",{type:"button","data-testid":"told-exclude","aria-pressed":r.excluded===!0,onClick:()=>k(r.id,{excluded:!r.excluded}),style:F,children:r.excluded?"Suggest it again":"Exclude from suggestions"}),(0,u.jsx)("button",{type:"button","data-testid":"told-delete",onClick:()=>O(r.id),style:F,children:"Delete"})]})]},r.id))})]})}var qe={position:"absolute",insetBlock:"60px 12px",insetInlineEnd:12,width:"min(440px, calc(100% - 24px))",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:10,padding:14,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",zIndex:ee("popover"),overflow:"hidden"},Ye={display:"grid",gap:4,padding:10,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},F={padding:"2px 10px",minHeight:28,font:"inherit",fontSize:"0.8125rem",borderRadius:8},q={display:"inline-flex",alignItems:"center",gap:4};export{He as RateTelling,je as ToldPanel,_ as changeTelling,$e as examplesHere,Fe as keepTelling,Ue as readToldHere,A as seenOnThisPage,_e as tellingDraftOf,Ke as toldForHere,I as toldListed,Ge as toldSuggestionsFrom,ze as watchTelling};
|
|
1
|
+
import{c as te}from"./chunk.QNWGDG2Z.js";import"./chunk.BJUUSIQY.js";import"./chunk.U5KJQFAP.js";import"./chunk.VGYG2IBZ.js";import"./chunk.RJ7VSWTA.js";import"./chunk.P43LPXXJ.js";import{G as ne,Y as N}from"./chunk.JCKIJSW7.js";import"./chunk.SDO3U72B.js";import{Dd as $,ma as Q,pa as X,pb as Z,zd as ee}from"./chunk.6L6RUOSF.js";import"./chunk.FQLNBIQ5.js";import{b as P}from"./chunk.AJZBJBMO.js";var D=new WeakMap,we=5e3;function I(n){let e=D.get(n);if(e&&Date.now()-e.at<we)return e.list;let t={at:Date.now(),list:Promise.resolve([])};return t.list=Promise.resolve().then(()=>n.list()).catch(()=>[]).then(o=>t.value=[...o,...(t.value??[]).filter(i=>!o.some(l=>l.id===i.id))]),e?.value&&(t.value=e.value),D.set(n,t),t.list}var oe=n=>D.get(n)?.value;function re(n,e){let t=D.get(n);if(!t)return;let o=i=>[...i.filter(l=>l.id!==e.id),e];t.value&&(t.value=o(t.value)),D.set(n,{at:t.at,list:t.list.then(o),...t.value?{value:t.value}:{}})}function A(n,e){let t=$(n,e);return o=>n.graph.getNode(o)!==void 0&&t(o)}var z=["previewed","accepted","declined","undone","abandoned"],ve=["graph","light","full"],S={words:300,should:300,name:80,records:200,people:20,stages:8,examples:5},Se=365,xe=5e3,be=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");function ie(n,e){if(typeof n!="string")return;let t=n.replace(be," ").replace(/\s+/g," ").trim();return t.length===0?void 0:t.slice(0,e).trimEnd()}function h(n){return typeof n=="string"&&n.length>0&&n.length<=S.name&&/^[\p{L}\p{N}_][\p{L}\p{N}_.:/-]*$/u.test(n)?n:void 0}var W=(n,e)=>Array.isArray(n)?[...new Set(n.flatMap(t=>h(t)??[]))].slice(0,e):[];function ae(n){let e=typeof n.id=="string"?n.id.slice(0,S.name):void 0;return{kind:n.kind,...e!==void 0?{id:e}:{},...n.onBehalfOf?{onBehalfOf:ae(n.onBehalfOf)}:{}}}var le=n=>n?.kind==="visitor"||n?.onBehalfOf?.kind==="visitor",ke=()=>`tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,Oe=new Set(["record","field","selection","list","lens","place","act"]);function Pe(n){let e=n,t=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0?Math.min(1e4,Math.round(o)):0;switch(e?.type){case"act":{let o=h(e.act);return o?{type:"act",act:o,records:t(e.records)}:void 0}case"plan":return{type:"plan",edits:t(e.edits)};case"answer":return{type:"answer"};case"refusal":return{type:"refusal"};case"view":{let o=typeof e.section=="string"?e.section.replace(/\s+/g," ").trim().slice(0,S.name):"";return o?{type:"view",section:o}:void 0}default:return}}function se(n,e,t={}){if(!n||typeof n!="object"||!e||le(e))return;let o=n,i=ie(o.words,S.words),l=Pe(o.decided),d=o.target;if(!i||!l||!d||!Oe.has(String(d.on)))return;let s={on:d.on,...h(d.kind)?{kind:h(d.kind)}:{},...h(d.id)?{id:h(d.id)}:{},...h(d.place)?{place:h(d.place)}:{}},c=o.reading,a=c&&(c.which==="itself"||c.which==="held")&&h(c.kind)?{which:c.which,kind:h(c.kind),records:W(c.records,S.records)}:void 0,g=W(o.people,S.people),f=Array.isArray(o.stages)?o.stages.flatMap(Te=>{let L=Te,V=h(L?.stage),E=L?.ms;return V&&typeof E=="number"&&Number.isFinite(E)&&E>=0?[{stage:V,ms:Math.round(E),...h(L.model)?{model:h(L.model)}:{}}]:[]}).slice(0,S.stages):[],w=z.includes(o.outcome)?o.outcome:"previewed",y=ve.includes(o.slot)?o.slot:void 0,b=o.rating==="up"||o.rating==="down"?o.rating:void 0,k=b==="down"?ie(o.should,S.should):void 0,O=typeof o.ms=="number"&&Number.isFinite(o.ms)&&o.ms>=0?Math.round(o.ms):void 0,r=t.id??h(o.id)??ke(),p=h(o.conversation)??r,m=h(o.follows),Y=h(o.interaction),J=W(o.examples,S.examples);return{id:r,at:t.at??new Date().toISOString(),by:ae(e),words:i,target:s,...a?{reading:a}:{},...g.length>0?{people:g}:{},decided:l,...y?{slot:y}:{},...f.length>0?{stages:f}:{},...O!==void 0?{ms:O}:{},outcome:w,...b?{rating:b}:{},...k?{should:k}:{},conversation:p,...m?{follows:m}:{},...Y?{interaction:Y}:{},...J.length>0?{examples:J}:{}}}function Ae(n,e){let t=e.outcome===void 0||e.outcome==="previewed"||n.outcome==="accepted"&&e.outcome!=="undone"||n.outcome==="undone"||(n.outcome==="declined"||n.outcome==="abandoned")&&e.outcome==="abandoned"?n.outcome:e.outcome,o=e.rating===void 0?n.rating:e.rating??void 0,i=o!=="down"?void 0:e.should===void 0?n.should:e.should??void 0,{rating:l,should:d,...s}=n;return{...s,outcome:t,...o?{rating:o}:{},...i?{should:i}:{},...e.examples?{examples:e.examples}:{},...e.pinned!==void 0?{pinned:e.pinned}:{},...e.excluded!==void 0?{excluded:e.excluded}:{}}}function Ce(n,e={}){let t=(e.now??Date.now())-(e.retentionDays??Se)*864e5,o=new Map;for(let d of n){let s=Date.parse(d.at);Number.isFinite(s)&&s>=t&&!le(d.by)&&o.set(d.id,d)}let i=[...o.values()],l=e.most??xe;return i.length>l?i.slice(i.length-l):i}function H(n,e,t={}){return"add"in e?Ce([...n,e.add],t):"remove"in e?n.filter(o=>o.id!==e.remove):n.map(o=>o.id===e.change?Ae(o,e.with):o)}var C=n=>n.onBehalfOf?C(n.onBehalfOf):n.id!==void 0?`${n.kind}:${n.id}`:`${n.kind}:?`,Re=n=>[...new Set([...n.target.id?[n.target.id]:[],...n.reading?.records??[],...n.people??[]])];function R(n,e){return n.filter(t=>Re(t).every(e))}var B=n=>!n.excluded&&n.rating!=="down"&&n.outcome!=="undone"&&(n.outcome==="accepted"||n.rating==="up"),U=n=>{let e=n.reading?.kind??n.target.kind??"";return n.decided.type==="act"?`act:${n.decided.act}:${e}:${n.reading?.which??""}`:n.decided.type==="plan"?`plan:${e}`:void 0};function De(n,e={}){let t=Math.max(1,e.minPeople??2),o=e.reader?C(e.reader):void 0,i=new Map;for(let l of n){let d=U(l);!d||!B(l)||C(l.by)===o||i.set(d,(i.get(d)??new Set).add(C(l.by)))}return new Set([...i].filter(([,l])=>l.size>=t).map(([l])=>l))}function ce(n,e){return n.filter(t=>(e.rating===void 0||(e.rating==="none"?t.rating===void 0:t.rating===e.rating))&&(e.outcome===void 0||t.outcome===e.outcome)&&(e.kind===void 0||(t.reading?.kind??t.target.kind)===e.kind))}var Le=n=>n.filter(e=>B(e)&&U(e)!==void 0);function ue(n){let e=Le(n).length;return e===0?"Nothing told here teaches suggestions yet: a telling that is accepted or rated \u{1F44D} will.":`Suggestions come from ${e} rated ${e===1?"telling":"tellings"} in this app.`}function ge(n,e=t=>t){switch(n.decided.type){case"act":return`${e(n.decided.act)}, over ${n.decided.records} ${n.decided.records===1?"record":"records"}`;case"plan":return`A plan of ${n.decided.edits} ${n.decided.edits===1?"change":"changes"} to the app`;case"answer":return"An open answer";case"refusal":return"Nothing it could do";case"view":return`A revision of \u201C${n.decided.section}\u201D`}}var G={previewed:"Previewed",accepted:"Accepted",declined:"Declined",undone:"Undone",abandoned:"Closed with nothing done"},Ee=new Set("a an and are as at be by can do does for from has have how i in is it its me my of on or our please the their them these they this those to was we what when where which who why will with you your all each every".split(" "));function de(n){return[...new Set(n.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(e=>e.length>1&&!Ee.has(e)).map(e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e))]}function M(n,e,t={}){let o=de(e.words);if(o.length===0)return[];let i=t.reader?C(t.reader):void 0,l=De(n,{...t.reader?{reader:t.reader}:{},...t.minPeople!==void 0?{minPeople:t.minPeople}:{}}),d=n.flatMap(a=>{let g=U(a);if(!g||!B(a)||t.rated&&a.rating!=="up")return[];if(!(i!==void 0&&C(a.by)===i)&&!l.has(g))return[];let w=de(a.words),y=o.filter(p=>w.some(m=>m===p||p.length>=3&&m.startsWith(p))).length;if(y===0)return[];let b=y/new Set([...o,...w]).size,k=e.kind!==void 0&&(a.target.kind===e.kind||a.reading?.kind===e.kind)?.25:e.kind!==void 0?-.25:0,O=e.act!==void 0&&a.decided.type==="act"&&a.decided.act===e.act?.15:0,r=Math.max(0,Math.min(1,b*.6+.25+k+O+(a.pinned?.1:0)));return r>=(t.floor??.35)?[{telling:a,score:r,lesson:g}]:[]});d.sort((a,g)=>g.score-a.score||Number(g.telling.pinned??!1)-Number(a.telling.pinned??!1)||(a.telling.at<g.telling.at?1:-1));let s=new Set,c=[];for(let a of d)if(!s.has(a.lesson)&&(s.add(a.lesson),c.push({telling:a.telling,score:a.score}),c.length>=(t.most??2)))break;return c}function pe(n){return n.map(({telling:e})=>({said:e.words,did:e.decided.type==="act"?`act ${e.decided.act} over ${e.reading?.which==="itself"?"the record itself":"each record it holds"}`:e.decided.type==="plan"?"a plan that changes the app":e.decided.type==="view"?"a revision of a view's section":e.decided.type,...e.reading?{reading:e.reading.which}:{}}))}var x=P(ne(),1),T=P(N(),1);function ye(n,e){if(e.on==="list"||e.on==="lens")return e.kind;let t=te(e)[0];return t?n.graph.getNode(t)?.kind:void 0}function $e(n,e,t,o,i){let l=n?oe(n):void 0;if(!l)return{examples:[],ids:[]};let d=ye(e,i),s=M(R(l,A(e,t)),{words:o,...d?{kind:d}:{}},{reader:t,rated:!0,most:3});return{examples:pe(s),ids:s.map(c=>c.telling.id)}}function Ne(n){let e=new Set((n.stages??[]).map(t=>t.stage));return e.has("thinking")?"full":e.has("light")?"light":e.has("fast")?"graph":(n.usage??[]).some(t=>t.tier==="thinking")?"full":void 0}function Ie(n,e){if(n.interaction.outcome==="failed"||e&&"refused"in e)return{type:"refusal"};if(e&&"question"in e)return e.proposal?{type:"plan",edits:e.parts.length}:{type:"refusal"};let t=n.ghost?.proposals??[];return t.length>0?{type:"act",act:t[0].call.name,records:new Set(t.map(i=>i.record??i.id)).size}:{type:"answer"}}function Me(n,e){let t=new Set;for(let o of e.ghost?.proposals??[])for(let i of Object.values(o.call.args))typeof i=="string"&&i!==o.record&&n.graph.getNode(i)&&t.add(i);return[...t]}function _e(n,e){let{target:t,result:o}=e,i=ye(n,t),l=t.on==="record"||t.on==="field"?t.id:void 0,d=t.on==="lens"||t.on==="place"?t.place:void 0,s=o.reading?{which:o.reading.which,kind:o.reading.kind,records:o.reading.records}:void 0,c=Me(n,o),a=Ne(o.interaction),g=Ie(o,e.plan);return{words:e.words,target:{on:t.on,...i?{kind:i}:{},...l?{id:l}:{},...d?{place:d}:{}},...s?{reading:s}:{},...c.length>0?{people:c}:{},decided:g,...a?{slot:a}:{},...o.interaction.stages?{stages:o.interaction.stages}:{},ms:e.ms,outcome:"previewed",...e.conversation?{conversation:e.conversation}:{},...e.follows?{follows:e.follows}:{},interaction:o.interaction.id,...e.examples&&e.examples.length>0?{examples:e.examples}:{}}}function Fe(n,e,t){if(!n)return;let o=se(e,t);if(o)return re(n,o),Promise.resolve().then(()=>n.add(o)).catch(()=>{}),o}function _(n,e,t){n&&Promise.resolve().then(()=>n.change(e,t)).catch(()=>{})}var We={accepted:"accepted",partly:"accepted",drawn:"accepted",dismissed:"declined"};function ze(n,e,t){let o,i=()=>{let c=n.get().entries.find(g=>g.id===t.interaction);if(!c)return;let a=c.undone?"undone":We[c.outcome];!a||a===o||(o=a,_(e,t.id,{outcome:a}),a==="undone"&&s())},l=n.subscribe(i),d=setTimeout(()=>s(),30*6e4),s=()=>{l(),clearTimeout(d)};return s}function He({told:n,telling:e}){let[t,o]=(0,x.useState)(e.rating),[i,l]=(0,x.useState)(""),[d,s]=(0,x.useState)(!1),c=(0,x.useId)();(0,x.useEffect)(()=>{o(e.rating),l(""),s(!1)},[e.id,e.rating]);let a=f=>{let w=t===f?void 0:f;o(w),s(!1),_(n,e.id,{rating:w??null})},g=()=>{let f=i.trim();!f||t!=="down"||(_(n,e.id,{should:f}),s(!0))};return(0,T.jsxs)("div",{"data-testid":"quick-ask-rating","data-rating":t??"",style:{display:"grid",gap:6},children:[(0,T.jsxs)("div",{role:"group","aria-label":"Was this right?",style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-right","aria-label":"This was right",title:"This was right","aria-pressed":t==="up",onClick:()=>a("up"),style:t==="up"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44D}"})}),(0,T.jsx)("button",{type:"button","data-testid":"quick-ask-wrong","aria-label":"This was wrong",title:"This was wrong","aria-pressed":t==="down",onClick:()=>a("down"),style:t==="down"?fe:K,children:(0,T.jsx)("span",{"aria-hidden":"true",children:"\u{1F44E}"})})]}),t==="down"?(0,T.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,T.jsxs)("label",{htmlFor:c,style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:["What should it have done? ",(0,T.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"(optional)"})]}),(0,T.jsx)("input",{id:c,type:"text","data-testid":"quick-ask-should",value:i,maxLength:300,autoComplete:"off",enterKeyHint:"done",onChange:f=>{l(f.target.value),s(!1)},onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),g())},onBlur:g,style:Be}),d?(0,T.jsx)("span",{role:"status","data-testid":"quick-ask-should-kept",style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:n.keptSays?.trim()||"Kept, to learn from."}):null]}):null]})}var K={display:"inline-grid",placeItems:"center",width:30,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer",opacity:.7},fe={...K,opacity:1,borderColor:"var(--graview-accent)",background:"var(--graview-panel)"},Be={boxSizing:"border-box",width:"100%",height:32,padding:"0 8px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8};var j=n=>n.charAt(0).toUpperCase()+n.slice(1);function me(n,e){if(!e)return;let t=n.graph.getNode(e);if(t)return t.kind;let o=/^(?:kind|aggregate):(.+)$/.exec(e)?.[1];return o&&n.schema.tryDefinition(o)?o:void 0}function he(n,e,t){let o=n.schema;if(e.decided.type==="plan")return j(e.words);if(e.decided.type!=="act")return;let i=e.decided.act,l=n.allMutations().find(y=>y.name===i);if(!l)return;let d=l.title??l.name,s=y=>/\b(?:it|this|them)\b/i.test(d)?d.replace(/\b(?:it|this|them)\b/i,y):`${d} ${y}`,c=t?n.graph.getNode(t):void 0,a=c?Q(o.tryDefinition(c.kind),c):void 0,g=e.reading?.kind??e.target.kind;if(!g||!o.tryDefinition(g))return;if(e.reading?.which==="itself"||!e.reading&&c?.kind===g)return c&&c.kind===g&&a?j(s(a)):void 0;let f=c?new Set([...n.graph.in(c.id),...n.graph.out(c.id)].filter(y=>y.kind===g).map(y=>y.id)).size:me(n,t)===g?n.graph.allNodes().filter(y=>y.kind===g).length:0;if(f===0)return;let w=f===1?(o.tryDefinition(g)?.noun??g).toLowerCase():X(o,g).toLowerCase();return j(s(`the ${f} ${w}${a?` in ${a}`:""}`))}async function Ue(n,e,t){return R(await I(n),A(e,t))}function Ge(n,e,t,o,i,l=4){if(o.trim()==="")return[];let d=me(e,i);return M(n,{words:o,...d?{kind:d}:{}},{reader:t,most:l}).flatMap(({telling:s})=>{let c=he(e,s,i);return c?[{key:`told:${s.id}`,telling:s,label:c}]:[]})}function Ke(n,e,t,o,i=3){let l=new Set,d=[];for(let s of[...n].reverse()){if(d.length>=i)break;if(!(s.rating==="up"||s.outcome==="accepted")||s.by!==void 0&&t.id!==void 0&&s.by.id!==void 0&&s.by.id!==t.id)continue;let c=he(e,s,o);!c||l.has(c.toLowerCase())||(l.add(c.toLowerCase()),d.push({key:`told:${s.id}`,telling:s,label:c}))}return d}var v=P(ne(),1),u=P(N(),1);function je({told:n,store:e,principal:t,onClose:o}){let[i,l]=(0,v.useState)(null),[d,s]=(0,v.useState)({}),c=(0,v.useRef)(null);(0,v.useEffect)(()=>{let r=!0;return Promise.resolve().then(()=>n.list()).then(p=>r&&l(p),()=>r&&l([])),c.current?.focus({preventScroll:!0}),()=>{r=!1}},[n]);let a=(0,v.useMemo)(()=>i?R(i,$(e,t)):[],[i,e,t]),g=(0,v.useMemo)(()=>[...ce(a,d)].sort((r,p)=>r.at<p.at?1:-1),[a,d]),f=(0,v.useMemo)(()=>[...new Set(a.flatMap(r=>r.reading?.kind??r.target.kind??[]))].sort(),[a]),w=r=>e.allMutations().find(p=>p.name===r)?.title??r,y=r=>e.schema.tryDefinition(r)?.plural??r,b=r=>{try{return Z(r.by,{graph:e.graph,schema:e.schema})}catch{return r.by.id??r.by.kind}},k=(r,p)=>{l(m=>m&&H(m,{change:r,with:p})),Promise.resolve().then(()=>n.change(r,p)).catch(()=>{})},O=r=>{l(p=>p&&H(p,{remove:r})),Promise.resolve().then(()=>n.remove(r)).catch(()=>{})};return(0,u.jsxs)("section",{ref:c,tabIndex:-1,"data-testid":"told-panel","data-graview-overlay":"","aria-label":"What Graview has been told",onKeyDown:r=>{r.key==="Escape"&&(r.stopPropagation(),o())},style:qe,children:[(0,u.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,u.jsx)("h2",{style:{margin:0,fontSize:"1rem",fontWeight:600,flex:"1 1 auto"},children:"What Graview has been told"}),(0,u.jsx)("button",{type:"button","data-testid":"told-close",onClick:o,style:F,children:"Close"})]}),(0,u.jsx)("p",{"data-testid":"told-teaching",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:i===null?"Reading what was told\u2026":ue(a)}),(0,u.jsxs)("div",{role:"group","aria-label":"Show only",style:{display:"flex",flexWrap:"wrap",gap:8,fontSize:"0.8125rem"},children:[(0,u.jsxs)("label",{style:q,children:["Rating",(0,u.jsxs)("select",{"data-testid":"told-filter-rating",value:d.rating??"",onChange:r=>s(({rating:p,...m})=>r.target.value?{...m,rating:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),(0,u.jsx)("option",{value:"up",children:"\u{1F44D} Right"}),(0,u.jsx)("option",{value:"down",children:"\u{1F44E} Wrong"}),(0,u.jsx)("option",{value:"none",children:"Not rated"})]})]}),(0,u.jsxs)("label",{style:q,children:["Outcome",(0,u.jsxs)("select",{"data-testid":"told-filter-outcome",value:d.outcome??"",onChange:r=>s(({outcome:p,...m})=>r.target.value?{...m,outcome:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),z.map(r=>(0,u.jsx)("option",{value:r,children:G[r]},r))]})]}),(0,u.jsxs)("label",{style:q,children:["Kind",(0,u.jsxs)("select",{"data-testid":"told-filter-kind",value:d.kind??"",onChange:r=>s(({kind:p,...m})=>r.target.value?{...m,kind:r.target.value}:m),children:[(0,u.jsx)("option",{value:"",children:"Any"}),f.map(r=>(0,u.jsx)("option",{value:r,children:y(r)},r))]})]})]}),i!==null&&g.length===0?(0,u.jsx)("p",{"data-testid":"told-none",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:a.length===0?"Nothing has been told here yet.":"Nothing told here fits these."}):null,(0,u.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,overflowY:"auto"},children:g.map(r=>(0,u.jsxs)("li",{"data-testid":"told-entry","data-telling":r.id,"data-outcome":r.outcome,"data-rating":r.rating??"","data-excluded":r.excluded?"":void 0,"data-pinned":r.pinned?"":void 0,style:Ye,children:[(0,u.jsxs)("p",{style:{margin:0,fontWeight:550,overflowWrap:"anywhere"},children:["\u201C",r.words,"\u201D"]}),(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem"},children:[ge(r,w)," \xB7 ",G[r.outcome],r.rating?` \xB7 ${r.rating==="up"?"\u{1F44D} right":"\u{1F44E} wrong"}`:"",r.pinned?" \xB7 a good example":"",r.excluded?" \xB7 excluded from suggestions":""]}),r.should?(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",fontStyle:"italic"},children:["Should have: ",r.should]}):null,(0,u.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:[b(r)," \xB7 ",(0,u.jsx)("time",{dateTime:r.at,children:new Date(r.at).toLocaleString()}),r.ms!==void 0?` \xB7 ${r.ms<1e3?`${r.ms} ms`:`${(r.ms/1e3).toFixed(1)} s`}`:""]}),(0,u.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[(0,u.jsx)("button",{type:"button","data-testid":"told-pin","aria-pressed":r.pinned===!0,onClick:()=>k(r.id,{pinned:!r.pinned}),style:F,children:r.pinned?"Not a good example":"A good example"}),(0,u.jsx)("button",{type:"button","data-testid":"told-exclude","aria-pressed":r.excluded===!0,onClick:()=>k(r.id,{excluded:!r.excluded}),style:F,children:r.excluded?"Suggest it again":"Exclude from suggestions"}),(0,u.jsx)("button",{type:"button","data-testid":"told-delete",onClick:()=>O(r.id),style:F,children:"Delete"})]})]},r.id))})]})}var qe={position:"absolute",insetBlock:"60px 12px",insetInlineEnd:12,width:"min(440px, calc(100% - 24px))",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:10,padding:14,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",zIndex:ee("popover"),overflow:"hidden"},Ye={display:"grid",gap:4,padding:10,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},F={padding:"2px 10px",minHeight:28,font:"inherit",fontSize:"0.8125rem",borderRadius:8},q={display:"inline-flex",alignItems:"center",gap:4};export{He as RateTelling,je as ToldPanel,_ as changeTelling,$e as examplesHere,Fe as keepTelling,Ue as readToldHere,A as seenOnThisPage,_e as tellingDraftOf,Ke as toldForHere,I as toldListed,Ge as toldSuggestionsFrom,ze as watchTelling};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{g as A}from"./chunk.
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{g as A}from"./chunk.6A3KTD66.js";import{t as F}from"./chunk.RJ7VSWTA.js";import{G as v,J as h,Oa as H,Ta as O,Y as s,ga as k,ia as D}from"./chunk.JCKIJSW7.js";import{a as T}from"./chunk.SDO3U72B.js";import{Ie as I,Je as B,ve as L,zd as R}from"./chunk.6L6RUOSF.js";import{b as i}from"./chunk.AJZBJBMO.js";var E=i(v(),1);var P=i(s(),1),N=F.part((e,o)=>(0,P.jsx)(e.Inbox,{...o}),{quiet:!0});function j(e){let{store:o,whileAway:r,notifications:t,aiDesk:l}=k(),n=D(),d=A(),{entries:c}=h(l),p=O().length>0,y=(0,E.useMemo)(()=>B(o),[o,n,o.log.length,o.stopsServed]);return e>0||p||d>0||y||(r?.tidied??0)>0||(t?.length??0)>0||c.length>0}function G(e){return(0,P.jsx)(N,{...e})}var x=i(s(),1),M=e=>e.tabIndex>=0&&!e.disabled&&e.getClientRects().length>0;function _(e){if(!e)return!1;if(M(e))return e.focus({preventScroll:!1}),!0;let o=[...e.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].find(M);return o?(o.focus(),!0):(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus(),!0)}var K=`.graview-skips{display:contents}
|
|
2
2
|
.graview-skip{position:absolute;width:0;height:0;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
|
|
3
3
|
.graview-skip:focus{width:auto;height:auto;overflow:visible;clip-path:none;padding:6px 12px;border-radius:8px;border:1px solid var(--graview-accent);background:var(--graview-float,var(--graview-panel));color:var(--graview-ink);font:inherit;font-size:.875rem;font-weight:600;box-shadow:var(--graview-lift-high);outline:2px solid var(--graview-accent);outline-offset:1px}
|
|
4
4
|
.graview-skips[data-place=bar] .graview-skip:focus{position:fixed;left:8px;top:6px;z-index:${R("toast")}}
|
|
5
|
-
.graview-skips[data-place=here] .graview-skip:focus{position:static;justify-self:start}`;function W({to:e,place:o="bar"}){return e.length===0?null:(0,x.jsxs)("span",{className:"graview-skips","data-place":o,children:[(0,x.jsx)("style",{children:K}),e.map(r=>(0,x.jsx)("button",{type:"button",className:"graview-skip","data-graview-skip":r.testid,"data-testid":`skip-${r.testid}`,...r.opens?{"data-graview-skip-opens":""}:{},onClick:r.go,children:r.label},r.testid))]})}var m=i(v(),1),w=i(s(),1),$=H(T(()=>(__graviewPreload(import.meta.url,["./chunk.
|
|
5
|
+
.graview-skips[data-place=here] .graview-skip:focus{position:static;justify-self:start}`;function W({to:e,place:o="bar"}){return e.length===0?null:(0,x.jsxs)("span",{className:"graview-skips","data-place":o,children:[(0,x.jsx)("style",{children:K}),e.map(r=>(0,x.jsx)("button",{type:"button",className:"graview-skip","data-graview-skip":r.testid,"data-testid":`skip-${r.testid}`,...r.opens?{"data-graview-skip-opens":""}:{},onClick:r.go,children:r.label},r.testid))]})}var m=i(v(),1),w=i(s(),1),$=H(T(()=>(__graviewPreload(import.meta.url,["./chunk.S2BMI23H.js","./chunk.MWWNKM3I.js","./chunk.6A3KTD66.js","./chunk.U5P23GO7.js","./chunk.RO3D2RNP.js","./chunk.MEAUTBVM.js","./chunk.OKHXXIMN.js","./chunk.NH3VXTGX.js","./chunk.6IMRCKB4.js","./chunk.GFBE4VNT.js","./chunk.RDUGUC7R.js","./chunk.OPMGQS5J.js","./chunk.F7KVEWFH.js","./chunk.QKRQPUCE.js","./chunk.MIE4TJRW.js","./chunk.3CLTABGP.js","./chunk.RD2FSSLV.js","./chunk.CVN2XFMF.js","./chunk.6TBQV3NO.js","./chunk.MT252WP4.js","./chunk.VVIQSFM4.js","./chunk.TQ3MNB6K.js","./chunk.VGYG2IBZ.js","./chunk.RJ7VSWTA.js","./chunk.P43LPXXJ.js","./chunk.JCKIJSW7.js","./chunk.SDO3U72B.js","./chunk.6L6RUOSF.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.4UDST6IF.js")))),q=$.part((e,o)=>{let r=e.RecordInteractions;return(0,w.jsx)(r,{...o})},{quiet:!0});function Q(e,o,r){let t=e.target;return(t.on==="record"||t.on==="field"?t.id===o:t.on==="selection"?t.ids.includes(o):t.on==="act"?t.id===o:!1)||e.offered.some(n=>n.id===`record:${o}`||n.id.startsWith(`fill:${o}:`))||(e.batches??[]).some(n=>r(n).includes(o))}function U({id:e,style:o,headingStyle:r,className:t}){let{ai:l,aiDesk:n,store:d}=k(),{entries:c}=h(n),p=l.off===!0;(0,m.useEffect)(()=>{p||n.load()},[n,p]);let y=d.log.length,g=(0,m.useMemo)(()=>{let b=S=>d.log.all().flatMap(C=>C.batch===S?C.writes:[]);return c.filter(S=>Q(S,e,b))},[c,e,d,y]);return p||g.length===0?null:(0,w.jsx)(m.Suspense,{fallback:null,children:(0,w.jsx)(q,{entries:g,...o?{style:o}:{},...r?{headingStyle:r}:{},...t?{className:t}:{}})})}var u=i(v(),1);var f=i(s(),1),z={textDecorationLine:"underline",textDecorationColor:"color-mix(in srgb, currentColor 50%, transparent)",textDecorationThickness:1,textUnderlineOffset:"0.2em"};function V({children:e,mark:o="\u2192"}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("span",{style:z,children:e}),(0,f.jsx)("span",{"aria-hidden":"true",children:o})]})}var a=i(s(),1);function jr({context:e,stop:o,title:r,label:t,style:l,className:n,children:d,...c}){let p=L(e.views?.arrangement?.()),y=d??(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(V,{mark:"\u2197",children:["In ",p==="Scene"?"the scene":p.replace(/^The /,"the ")]})}),g=t?{"aria-label":t}:{};if(e.overview){let b=e.overview;return(0,a.jsx)("a",{href:o,...c,...g,...r?{title:r}:{},style:l,...n?{className:n}:{},onClick:S=>{S.preventDefault(),b(o)},children:y})}return e.embedded?null:(0,a.jsx)("a",{href:`${e.sceneHref??"/"}${o}`,...c,...g,...r?{title:r}:{},style:l,...n?{className:n}:{},children:y})}function Gr(){return(0,a.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault(),window.location.assign(I(window.location.href))},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function _r(e){let o=(0,u.useRef)(0),r=(0,u.useCallback)(t=>e.subscribe(()=>{o.current+=1,t()}),[e]);return(0,u.useSyncExternalStore)(r,()=>o.current,()=>0)}function Wr(e){return e===void 0?{}:e==="sm"||e==="md"?{"data-size":e}:{style:{"--graview-control-height":typeof e=="number"?`${e}px`:e}}}var $r=(e,o)=>o?`${e} ${o}`:e;export{j as a,G as b,_ as c,W as d,U as e,V as f,jr as g,Gr as h,_r as i,Wr as j,$r as k};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as K}from"./chunk.
|
|
1
|
+
import{q as K}from"./chunk.RJ7VSWTA.js";import"./chunk.P43LPXXJ.js";import{G as R,Y as x,ga as N,ha as $}from"./chunk.JCKIJSW7.js";import"./chunk.SDO3U72B.js";import{Xd as v,Yd as b,Zd as f,de as h,fe as k,qa as g}from"./chunk.6L6RUOSF.js";import"./chunk.FQLNBIQ5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(R(),1);var o=w(x(),1),E=()=>()=>{};function C(e){let n=(0,u.useMemo)(()=>e?.onChange?i=>e.onChange(i):E,[e]),t=()=>e?.current()??b;return(0,u.useSyncExternalStore)(n,t,t)}var D=(e,n)=>e.lens?n.may.lenses:n.may.views;async function p(e,n,t){try{return await n(),!0}catch(i){let r=i?.code,d=typeof r=="string"?r:void 0;return e?.notify({kind:"toast",tone:"bad",sentence:i instanceof Error&&i.message?i.message:t,...d?{code:d}:{}}),!1}}function H(e,n,t,i,r){let d=e.name;return p(r,()=>n==="view"&&d!==void 0?i?t.hide(d):t.show(d):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:i}),i?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function L(e,n,t,i,r){return p(r,()=>t.lens?.({op:"set-lens-hidden",title:e,hidden:i}),i?`\u201C${n}\u201D could not be hidden.`:`\u201C${n}\u201D could not be shown.`)}function V(e,n,t){return p(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function A(e,n,t,i){let r=n==="view"&&e.name!==void 0?e.name:v(e.title),d=await p(i,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return d&&i?.notify({kind:"toast",id:`deleted-view-${r}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void V({name:r,title:e.title},t,i)}}),d}function G(){let e=$(),n=e?.keptViews,t=C(n),i=e?.views;return(0,u.useMemo)(()=>{if(!n||!i)return null;let r=s=>f(s,t,n),d=new Set,c=i.places().filter(s=>{if(!s.hidden||r(s)===null)return!1;let m=`${s.name??""}|${s.title}`;return d.has(m)?!1:(d.add(m),!0)}),l=e?.store.schema,y=t.may.lenses&&n.lens&&l?(i.arrangement?.()?.hide??[]).filter(s=>l.tryDefinition(s)!==void 0).map(s=>({kind:s,title:g(l,s),path:h(l,s)})):[];return{keeper:n,hidden:c,lists:y,removed:t.removed.filter(s=>D(s,t)),how:r}},[n,t,i,e?.store.schema])}function T(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var I=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
|
|
2
2
|
.graview-bar-tidied>.graview-bar-item,.graview-bar-gone{flex:1 1 auto;min-width:0}
|
|
3
3
|
.graview-bar-gone{display:grid;gap:1px;padding:7px 8px;font-size:.875rem;line-height:1.3;overflow-wrap:anywhere;color:var(--graview-ink-muted)}
|
|
4
4
|
.graview-bar-gone small{font-size:.75rem}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as W,e as Oe,f as Be,g as Fe,h as He,i as Ie,j as ze,k as Ke,l as ne,m as Ve}from"./chunk.MGG5DH2S.js";import{a as Ge,c as je}from"./chunk.ZOSTOVXR.js";import{b as De}from"./chunk.HIJ72QX6.js";import{a as Me,b as Pe,c as qe,d as j}from"./chunk.BQWMHHAZ.js";import"./chunk.2QALBEWP.js";import{k as Te,l as Ee}from"./chunk.WAIIXXVI.js";import"./chunk.RECTEAG4.js";import"./chunk.QQUZ5RTQ.js";import"./chunk.BJ3G7J2Z.js";import"./chunk.DIVANC3G.js";import{e as Ce}from"./chunk.KP7HUXH5.js";import{m as $e}from"./chunk.4BSEYZMS.js";import{a as Re,b as Le}from"./chunk.KV3N6VRG.js";import{h as Ae}from"./chunk.FUTSLXWN.js";import{e as be,f as ke}from"./chunk.MZSWWMX6.js";import"./chunk.HJCQ6I3S.js";import"./chunk.4QBW46XV.js";import"./chunk.U5Q7EVZQ.js";import"./chunk.NCBUECIW.js";import"./chunk.2T24FYAO.js";import"./chunk.JEQ6CA5M.js";import{a as me}from"./chunk.O2XPLDMM.js";import"./chunk.CM7EDQ4E.js";import"./chunk.SUYYDJGZ.js";import"./chunk.YR7DKU5T.js";import{a as ye,b as xe,j as Se}from"./chunk.RJ7UV3XI.js";import"./chunk.G4JJXA63.js";import{a as fe}from"./chunk.TBY5IR7C.js";import"./chunk.5IM2X3VT.js";import"./chunk.BIDL7GQD.js";import"./chunk.NKUNCQB3.js";import"./chunk.HMV4ILAC.js";import"./chunk.XAN7QXMQ.js";import"./chunk.XJ4JYROM.js";import"./chunk.XOZU4OFA.js";import"./chunk.CHG522KL.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.ZBK3FCVE.js";import"./chunk.DW6KXAUM.js";import"./chunk.MR776WQ2.js";import"./chunk.WVUJXDXZ.js";import"./chunk.IRPMGHZN.js";import"./chunk.7QWGIGHM.js";import"./chunk.HRLCDBMO.js";import"./chunk.LZNHTROY.js";import"./chunk.36FKQJFM.js";import"./chunk.RHV73CBA.js";import"./chunk.MIE4TJRW.js";import{s as he}from"./chunk.RP6C2IUM.js";import"./chunk.RD2FSSLV.js";import"./chunk.T552MHMU.js";import"./chunk.ZGJUCVT5.js";import"./chunk.CVVNHQPO.js";import{l as ue}from"./chunk.YIDNZTON.js";import"./chunk.QILGAV7H.js";import"./chunk.I6HIVTXU.js";import{G as Ne,t as U}from"./chunk.PYGNO2AV.js";import"./chunk.3HFBHLXC.js";import{$ as we,G as Je,Ta as ae,Ua as Y,Y as ge,ga as I,ia as te,j as le,l as pe,m as ce,r as J,ta as ve}from"./chunk.CUA7F3YJ.js";import"./chunk.SDO3U72B.js";import{L as ie,T as oe,Z as C,ma as re,oa as ee,qa as se,sa as de}from"./chunk.IUVRJDL3.js";import"./chunk.FQLNBIQ5.js";import{b as Z}from"./chunk.AJZBJBMO.js";var o=Z(Je(),1);var e=Z(ge(),1),Ye=560;function Ue(t,n){let[d,g]=(0,o.useState)(0);return(0,o.useEffect)(()=>{let r=t.current;if(!r||!n){g(0);return}let i=0,c=()=>{i=0;let f=r.getBoundingClientRect().bottom;g([...r.querySelectorAll('[data-testid="kind-stop-table"] tbody tr[data-graview-pick]')].filter(S=>S.getBoundingClientRect().top>f-24).length)},b=()=>{i||(i=requestAnimationFrame(c))};c(),r.addEventListener("scroll",b,{passive:!0});let L=typeof ResizeObserver>"u"?null:new ResizeObserver(b);L?.observe(r);let R=r.querySelector('[data-testid="kind-stop-body"]');return R&&L?.observe(R),()=>{r.removeEventListener("scroll",b),L?.disconnect(),i&&cancelAnimationFrame(i)}},[t,n]),d}function Xe({narrow:t,at:n,children:d}){return t?(0,e.jsx)("div",{ref:n,className:"graview-kind-stop-scroll","data-testid":"kind-stop-scroll",children:d}):(0,e.jsx)(e.Fragment,{children:d})}function Ze(t){let[n,d]=(0,o.useState)(!1);return(0,o.useLayoutEffect)(()=>{let g=t.current;if(!g)return;let r=()=>{let c=g.getBoundingClientRect().width;c>0&&d(c<Ye)};if(r(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(r);return i.observe(g),()=>i.disconnect()},[t]),n}var _e="as",et=(t,n)=>`graview:kind-seen:${t}:${n}`;function tt(t){try{return localStorage.getItem(t)}catch{return null}}function at(t,n){try{localStorage.setItem(t,n)}catch{}}var nt=(t,n)=>({...le(ce(t,!1),n),relation:null});function Mt({kind:t,members:n,flagged:d=[],label:g,retired:r=0}){let{store:i,brand:c,principal:b,views:L,view:R}=I(),{go:f}=Y(),S=te(),w=i.schema,$=w.tryDefinition(t),p=g??se(w,t),A=i.today()??ie(),l=n,N=(0,o.useId)(),h=(0,o.useMemo)(()=>Oe(w,t,l,A),[w,t,l,A]),u=R.within?.[_e]==="table"?{shape:"table"}:h,y=Re(R),T=u.shape==="table"&&!y.sort?Be(w,t):void 0,x=T?{...y,sort:T}:y,M=(0,o.useMemo)(()=>new Set(d),[d]),s=(0,o.useMemo)(()=>Ae(l,x,{schema:w,graph:i.graph,flagged:M,today:A}),[l,x,w,i,M,A,S]),k=(0,o.useMemo)(()=>ke(w,be(w,t)),[w,t]),D=L.arrangement?.()?.lists?.[t]?.filters,H=q=>f(Le(R,q)),V=(0,o.useMemo)(()=>({name:c?.name??"app",schema:w,...i.policy?{policy:i.policy}:{}}),[c,w,i]),_=JSON.stringify(Fe(t,u,x)),O=(0,o.useMemo)(()=>{let q=Se(JSON.parse(_),{app:V,sight:xe(V,b)});return ye(q)?void 0:q},[_,V,b]),G=u.shape!=="table"&&O!==void 0,z=(0,o.useRef)(null),P=Ze(z),[K,a]=(0,o.useState)(!1),m=(0,o.useId)(),B=(0,o.useMemo)(()=>fe(i,b),[i,b]),F=(l.length>1||r>0)&&!G?(0,e.jsx)($e,{schema:w,graph:i.graph,kind:t,arrangement:x,onChange:H,offers:k,...D?{filters:D}:{},kept:{shown:s.nodes.length,of:l.length},testId:"kind-arrange",chips:{nodes:l,flagged:M,today:A},...r>0?{past:{count:r,widen:()=>f(Ce(R,!0))}}:{}}):null,E=!!x.query||(x.filter?.length??0)>0,Q=(0,o.useRef)(null),X=Ue(Q,P&&!G);return(0,e.jsxs)("section",{ref:z,"aria-labelledby":N,className:"graview-kind-stop","data-testid":"kind-stop","data-graview-kind-stop":t,"data-graview-shape":u.shape,"data-graview-narrow":P||void 0,children:[(0,e.jsx)("style",{children:ct}),(0,e.jsxs)(Xe,{narrow:P,at:Q,children:[(0,e.jsx)(it,{kind:t,plural:p,count:l.length,headingId:N,description:$?.description,...P?{tools:{open:K,id:m,toggle:()=>a(q=>!q),narrowed:E}}:{}}),P&&K?(0,e.jsxs)("div",{id:m,className:"graview-kind-stop-tools","data-testid":"kind-stop-tools",role:"group","aria-label":`Find, filter and arrange the ${p.toLowerCase()}`,children:[F,l.length>0?(0,e.jsx)(We,{derived:h,shape:u,draft:O,author:!1}):null,(0,e.jsx)(Qe,{kind:t,plural:p})]}):null,(0,e.jsx)(rt,{kind:t,plural:p,members:l,today:A,arrangement:x,onArrange:H,compact:P}),P&&E&&!K?(0,e.jsxs)("p",{className:"graview-kind-stop-narrowed","data-testid":"kind-stop-narrowed",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[C(s.nodes.length)," of ",C(l.length)," shown"]})," ",(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>H({}),children:"Show all"})]}):null,P?null:F,l.length>0&&!P?(0,e.jsx)(We,{derived:h,shape:u,draft:O,author:B}):null,(0,e.jsx)("div",{className:"graview-kind-stop-body","data-testid":"kind-stop-body",children:l.length===0?(0,e.jsx)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-empty",children:"Nothing here yet."}):G?(0,e.jsx)(lt,{draft:O,nodes:l}):s.nodes.length===0?(0,e.jsxs)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-none-kept",children:["None of the ",C(l.length)," ",p.toLowerCase()," ",x.query?`says \u201C${x.query}\u201D`:"is kept by these filters","."," ",(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>H({}),children:"Show them all"})]}):(0,e.jsx)(pt,{kind:t,nodes:s.nodes,groups:s.grouped?s.groups.map(q=>({key:q.key,label:q.label,nodes:q.nodes})):void 0,flagged:M,plural:p,arrangement:x})})]}),X>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-below","data-testid":"kind-stop-below","data-graview-below":X,onClick:()=>Q.current?.scrollBy({top:Math.round(Q.current.clientHeight*.8),behavior:"smooth"}),children:[ee(w,t,X).replace(/^(\S+)\s/,"$1 more ")," below ",(0,e.jsx)("span",{"aria-hidden":"true",children:"\u2193"})]}):null]})}function Qe({kind:t,plural:n}){let{setSelection:d,setMenuAt:g}=I();return(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-quiet","data-testid":"kind-stop-acts","aria-haspopup":"menu","aria-label":`What can be done with the ${n.toLowerCase()}`,onClick:r=>{let i=r.currentTarget.getBoundingClientRect();d([J(t)]),g({x:Math.round(i.left),y:Math.round(i.bottom+4),on:J(t)})},children:"Acts\u2026"})}function it({kind:t,plural:n,count:d,headingId:g,description:r,tools:i}){let{store:c}=I(),b=(0,o.useMemo)(()=>({about:[J(t)]}),[t]),{affordances:L}=Te(b),{apply:R,preview:f}=Ee(),S=(0,o.useMemo)(()=>{let v=u=>c.allMutations().find(y=>y.name===u.mutation)?.creates?.includes(t)??!1;return L.find(u=>!u.destructive&&!u.setsAside&&v(u))},[L,c,t]),[w,$]=(0,o.useState)(!1),[p,A]=(0,o.useState)(null),l=(0,o.useRef)(null),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{let v=N.current;if(!v||v.closest('[data-testid="kind-stop"]')?.contains(document.activeElement))return;let u=!1;try{u=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.matches(":focus-visible")}catch{u=!0}u?delete v.dataset.graviewQuietFocus:v.dataset.graviewQuietFocus="",v.focus({preventScroll:!0})},[t]);let h=(v,u)=>{try{f(v,u),R(v,u),A(null),$(!1),requestAnimationFrame(()=>l.current?.focus())}catch(y){return A(ue(c.schema,c.allMutations(),y)),[]}};return(0,e.jsxs)("header",{className:"graview-kind-stop-head",children:[(0,e.jsxs)("div",{className:"graview-kind-stop-title",children:[(0,e.jsx)("h2",{id:g,ref:N,tabIndex:-1,"data-testid":"kind-stop-title",onKeyDown:v=>delete v.currentTarget.dataset.graviewQuietFocus,onBlur:v=>delete v.currentTarget.dataset.graviewQuietFocus,children:n}),(0,e.jsxs)("p",{"data-testid":"kind-stop-count",children:[ee(c.schema,t,d),r?` \xB7 ${r}`:""]})]}),(0,e.jsxs)("div",{className:"graview-kind-stop-acts",children:[S?(0,e.jsx)("button",{ref:l,type:"button",className:"graview-kind-stop-primary","data-testid":"kind-stop-primary","data-affordance":S.id,"aria-expanded":S.open.length>0?w:void 0,onClick:()=>{A(null),S.open.length===0?h(S):$(v=>!v)},children:S.label}):null,i?(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-more-tools","data-testid":"kind-stop-tools-open","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,"aria-label":`Find, filter, arrange and act on the ${n.toLowerCase()}`,title:"Find, filter, arrange and acts","data-narrowed":i.narrowed||void 0,onClick:i.toggle,children:(0,e.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})}):(0,e.jsx)(Qe,{kind:t,plural:n})]}),w&&S?(0,e.jsx)("div",{className:"graview-kind-stop-ask","data-testid":"kind-stop-ask","aria-label":S.label,role:"group",children:(0,e.jsx)(me,{affordance:S,onApply:v=>h(S,v),onCancel:()=>{$(!1),l.current?.focus()}})}):null,p?(0,e.jsx)("p",{role:"alert",className:"graview-kind-stop-failed","data-testid":"kind-stop-failed",children:p}):null]})}var ot=U.part((t,n)=>(0,e.jsx)(t.ProblemRows,{...n}),{what:"The problems",as:"li"});function rt({kind:t,plural:n,members:d,today:g,arrangement:r,onArrange:i,compact:c=!1}){let{store:b,brand:L,setSelection:R}=I(),f=b.schema,S=ae(),w=(0,o.useMemo)(()=>new Set(d.map(s=>s.id)),[d]),$=(0,o.useMemo)(()=>ze(S,w,s=>b.allInvariants().find(k=>k.name===s)?.label),[S,w,b]),p=(0,o.useMemo)(()=>Ke(f,t,d,g),[f,t,d,g]),A=et(Ne(L,f),t),[l]=(0,o.useState)(()=>tt(A));(0,o.useEffect)(()=>()=>at(A,new Date().toISOString()),[A]);let N=te(),h=(0,o.useMemo)(()=>l?Ve(b.log.all(),t,l,s=>b.graph.getNode(s)?.kind):null,[l,b,t,N]),[v,u]=(0,o.useState)(null),y=s=>i({...r,filter:[...(r.filter??[]).filter(k=>!s?.some(D=>D.key===k.key)),...s??[]]}),T=$.reduce((s,k)=>s+k.violations.length,0),x=[];if(p&&(p.overdue>0||p.soon>0)){let s=p.field;x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-dates",children:[p.overdue>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-fact","data-tone":"warn",onClick:()=>y(ne(p,"overdue",g)),"aria-label":`${C(p.overdue)} overdue \u2014 show only these`,children:[C(p.overdue)," overdue"]}):null,p.soon>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-fact",onClick:()=>y(ne(p,"soon",g)),"aria-label":`${C(p.soon)} in the next 7 days \u2014 show only these`,children:[C(p.soon)," ",p.due?"due":""," in the next 7 days"]}):null,(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" by ",de(f.tryDefinition(t),s).toLowerCase()]})]},"dates"))}let M=(r.filter??[]).some(s=>s.key==="is"&&s.value==="flagged");if($.length>0&&c){let s=$.map(k=>k.label).join(", ");x.push((0,e.jsxs)("li",{className:"graview-kind-stop-problems-line","data-testid":"kind-stop-problems","data-graview-problems":T,children:[(0,e.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),T===1?"1 problem":`${C(T)} problems`]}),(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text graview-kind-stop-rules-said",title:s,children:[" ","\xB7 ",s]}),(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems","aria-pressed":M,"aria-label":M?`Show all the ${n.toLowerCase()}`:`Show only the ${n.toLowerCase()} with a problem`,onClick:()=>M?i({...r,filter:(r.filter??[]).filter(k=>!(k.key==="is"&&k.value==="flagged"))}):y([{key:"is",value:"flagged"}]),children:M?"Show all":"Show"})]},"problems"))}else $.length>0&&x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-problems","data-graview-problems":T,children:[(0,e.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),T===1?"1 problem":`${C(T)} problems`]}),(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" in ",n.toLowerCase(),":"]}),(0,e.jsx)("ul",{className:"graview-kind-stop-rules",children:$.map(s=>(0,e.jsx)(st,{group:s,open:v===s.invariant,onToggle:()=>u(k=>k===s.invariant?null:s.invariant),onPick:k=>R([k])},s.invariant))}),(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems",onClick:()=>y([{key:"is",value:"flagged"}]),children:["Show only the ",n.toLowerCase()," with a problem"]})]},"problems"));if(h&&(h.added>0||h.changed>0)){let s=[h.added>0?`${C(h.added)} added`:"",h.changed>0?`${C(h.changed)} changed`:""].filter(Boolean);x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-since",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["Since you last looked (",oe(l.slice(0,10)),"):"]})," ",s.join(", ")]},"since"))}return x.length===0?null:(0,e.jsx)("ul",{className:"graview-kind-stop-going-on","aria-label":`What is going on in the ${n.toLowerCase()}`,"data-testid":"kind-stop-going-on",children:x})}function st({group:t,open:n,onToggle:d,onPick:g}){let r=(0,o.useId)();return(0,e.jsxs)("li",{"data-graview-rule":t.invariant,children:[(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-rule","aria-expanded":n,"aria-controls":r,onClick:d,onPointerEnter:U.prefetch,onFocus:U.prefetch,children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"graview-kind-stop-chevron","data-open":n||void 0,children:"\u203A"}),t.label," ",(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",C(t.violations.length)]})]}),n?(0,e.jsx)("ol",{id:r,className:"graview-kind-stop-problem-rows","data-testid":"kind-stop-problem-rows",children:(0,e.jsx)(o.Suspense,{fallback:null,children:(0,e.jsx)(ot,{violations:t.violations,pick:i=>{let c=i.subjectId??t.records[0]??i.nodeIds[0];c!==void 0&&g(c)}})})}):null]})}var dt={board:"Board",calendar:"Calendar",table:"Table"};function We({derived:t,shape:n,draft:d,author:g}){let{view:r}=I(),{go:i}=Y(),{keep:c}=Ge(je()),[b,L]=(0,o.useState)(!1),R=t.shape==="table"?[]:[t.shape,"table"];return!g&&R.length===0?null:(0,e.jsxs)("div",{className:"graview-kind-stop-shape","data-testid":"kind-stop-shape",children:[R.length>0?(0,e.jsx)("span",{role:"group","aria-label":"Show as",className:"graview-kind-stop-switch",children:R.map(f=>(0,e.jsx)("button",{type:"button","aria-pressed":n.shape===f,"data-testid":`kind-stop-as-${f}`,onClick:()=>i(pe(r,_e,f===t.shape?null:f)),children:dt[f]},f))}):null,g?(0,e.jsx)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-derived",children:d?`${d.said.replace(/\.$/,"")}, derived from the declaration`:"Derived from the declaration"}):null,d&&g?(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-keep",disabled:b,title:`Keep \u201C${d.title}\u201D as a lens: a place of its own`,onClick:()=>{L(!0),c(d).finally(()=>L(!1))},children:"Keep as a lens"}):null]})}function lt({draft:t,nodes:n}){let d=De(t.drawn);return(0,e.jsx)("div",{className:"graview-kind-stop-lens","data-graview-draft":t.lens.name,children:(0,e.jsx)(we,{mode:"scene",children:(0,e.jsx)(he,{kind:t.kind,view:t.title,children:(0,e.jsx)(d,{nodes:n,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})})}function pt({kind:t,nodes:n,groups:d,flagged:g,plural:r,arrangement:i}){let{store:c,views:b,view:L,selection:R,setSelection:f,setMenuAt:S,principal:w}=I(),{go:$}=Y(),p=c.schema,A=c.graph,l=(0,o.useMemo)(()=>(d?d.flatMap(a=>a.nodes):n).map(a=>a.id),[n,d]),N=Me(l),h=(0,o.useMemo)(()=>c.permittedMutations(w).some(a=>{let m=a.subject?.kinds;return m!==void 0&&(m==="*"||m.includes(t))}),[c,w,t]),v=(0,o.useRef)(null),u=a=>{N.choose(a),requestAnimationFrame(()=>{let m=N.list.current;((a[0]===void 0?null:m?.querySelector(`[data-graview-choose-box="${CSS.escape(a[0])}"]`))??m)?.focus({preventScroll:!0})})},y=N.chosen.length,T=b.lookup(t,{cardinality:"one",fidelity:"glyph"}),x=T!==void 0&&!ve(T)?T:void 0,M=a=>R.includes(a),s=ae(),k=(0,o.useMemo)(()=>He(p,t,n,A),[p,t,n,A]),[D,H]=(0,o.useState)(W);(0,o.useEffect)(()=>H(W),[i.query,i.filter?.length,i.sort?.by,i.group?.by]);let V=p.tryDefinition(t),_=a=>s.filter(m=>m.nodeIds.includes(a)||m.subjectId===a).map(m=>m.message),O=i.sort?.by,G=`${r}${i.sort?`, in order of ${k.find(a=>a.key===O)?.label.toLowerCase()??O}`:""}`,z=D,P=a=>{let m=re(V,a),B=g.has(a.id)?_(a.id):[];return(0,e.jsxs)("tr",{"data-graview-pick":a.id,tabIndex:-1,"data-graview-record":a.id,"data-flagged":B.length>0||void 0,...h?{"data-graview-choose":a.id}:{},children:[h?(0,e.jsx)("td",{className:"graview-choose-at",children:(0,e.jsx)("input",{...N.boxProps(a.id,m),onPointerEnter:j,onFocus:j})}):null,(0,e.jsxs)("th",{scope:"row",className:"graview-kind-stop-name",children:[x?(0,e.jsx)("div",{"data-graview-pick":a.id,className:"graview-kind-stop-own-row",children:(0,e.jsx)(x,{node:a,cardinality:"one",fidelity:"glyph",mode:"scene",selected:M(a.id),...B.length>0?{flagged:[a.id]}:{}})}):(0,e.jsx)("button",{type:"button","data-testid":"kind-stop-row-go",title:`Go to ${m}`,onClick:()=>$(nt(L,a.id)),children:m}),B.length>0?(0,e.jsxs)("span",{className:"graview-kind-stop-flag",title:B.join(" \xB7 "),children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0"}),(0,e.jsx)("span",{className:"graview-kind-stop-hidden",children:`Problem: ${B.join(". ")}`})]}):null]}),k.map(F=>{let E=Ie(p,a,F,A);return(0,e.jsx)("td",{"data-label":F.label,"data-short":E.text.length>0&&E.text.length<=14||void 0,"data-empty":E.text?void 0:"",...E.title?{title:E.title}:{},children:E.text?(0,e.jsx)("span",{children:E.text}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("b",{"aria-hidden":"true",children:"\u2014"}),(0,e.jsx)("i",{className:"graview-kind-stop-hidden",children:"none"})]})},F.key)}),(0,e.jsx)("td",{className:"graview-kind-stop-row-acts",children:(0,e.jsx)("button",{type:"button","data-testid":"kind-stop-row-acts","aria-haspopup":"menu","aria-label":`What can be done with ${m}`,onClick:F=>{let E=F.currentTarget.getBoundingClientRect();f([a.id]),S({x:Math.round(E.left),y:Math.round(E.bottom+4),on:a.id})},children:(0,e.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})})})]},a.id)},K=a=>{let m=a.slice(0,Math.max(0,z));return z-=m.length,m.map(P)};return(0,e.jsxs)("div",{className:"graview-kind-stop-table-at",...h?{...N.listProps,ref:a=>{v.current=a,N.list.current=a},tabIndex:-1,role:"group","aria-label":y>0?`${r}, ${y} chosen`:r,"data-graview-choosable":""}:{},children:[h?(0,e.jsx)("style",{children:Pe}):null,(0,e.jsxs)("table",{className:"graview-kind-stop-table","data-testid":"kind-stop-table",children:[(0,e.jsx)("caption",{className:"graview-kind-stop-hidden",children:G}),(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[h?(0,e.jsx)("td",{className:"graview-choose-at graview-choose-all",children:(0,e.jsx)("input",{type:"checkbox",className:"graview-choose-box","data-testid":"kind-stop-choose-all","aria-label":`Choose all ${C(n.length)} ${r.toLowerCase()}`,checked:y>0&&y===n.length,ref:a=>{a&&(a.indeterminate=y>0&&y<n.length)},onPointerEnter:j,onFocus:j,onChange:()=>y===n.length?N.clear():N.choose(l)})}):null,(0,e.jsx)("th",{scope:"col","aria-sort":O==="label"?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:"Name"}),k.map(a=>(0,e.jsx)("th",{scope:"col","aria-sort":a.about==="field"&&a.key===O?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:a.label},a.key)),(0,e.jsx)("th",{scope:"col",children:(0,e.jsx)("span",{className:"graview-kind-stop-hidden",children:"Acts"})})]})}),d?d.map(a=>z<=0?null:(0,e.jsxs)("tbody",{"data-graview-group":a.key,children:[(0,e.jsx)("tr",{className:"graview-kind-stop-group",children:(0,e.jsxs)("th",{scope:"rowgroup",colSpan:k.length+(h?3:2),children:[a.label," ",(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",C(a.nodes.length)]})]})}),K(a.nodes)]},a.key||"-")):(0,e.jsx)("tbody",{children:K(n)})]}),h?(0,e.jsx)(qe,{store:c,chosen:N.chosen,principal:w,anchor:()=>v.current?.closest('[data-testid="kind-stop"]')??null,of:l.length,onChooseAll:()=>N.choose(l),onClear:N.clear,onActed:u}):null,n.length>D?(0,e.jsxs)("p",{className:"graview-kind-stop-more",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-shown",children:[C(D)," of ",C(n.length)," shown"]})," ",(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-more",onClick:()=>H(a=>a+W),children:["Show ",C(Math.min(W,n.length-D))," more"]})]}):null]})}var ct=`
|
|
1
|
+
import{b as W,e as Oe,f as Be,g as Fe,h as He,i as Ie,j as ze,k as Ke,l as ne,m as Ve}from"./chunk.D4F6QX5L.js";import{a as Ge,c as je}from"./chunk.MM7MLBGB.js";import{b as De}from"./chunk.V5JB5UJS.js";import{a as Me,b as Pe,c as qe,d as j}from"./chunk.EHLV3LND.js";import"./chunk.EPSYX2SF.js";import{k as Te,l as Ee}from"./chunk.JLNTE5CH.js";import"./chunk.DDSAFU3B.js";import"./chunk.EOSN5DWW.js";import"./chunk.T6UJEXFL.js";import"./chunk.7THS3DLZ.js";import{e as Ce}from"./chunk.4QMAYVPU.js";import{m as $e}from"./chunk.ARGEGV5T.js";import{a as Re,b as Le}from"./chunk.WS5ORRGS.js";import{h as Ae}from"./chunk.ZONRIOIA.js";import{e as be,f as ke}from"./chunk.NXHEOHRR.js";import"./chunk.HJCQ6I3S.js";import"./chunk.DJGZOPAS.js";import"./chunk.GFOZVQBQ.js";import"./chunk.MQNW3O67.js";import"./chunk.67S2UWBT.js";import"./chunk.7PWLRRUS.js";import{a as me}from"./chunk.MEAUTBVM.js";import"./chunk.OKHXXIMN.js";import"./chunk.NH3VXTGX.js";import"./chunk.6IMRCKB4.js";import{a as ye,b as xe,j as Se}from"./chunk.64K5ELSQ.js";import"./chunk.G4JJXA63.js";import{a as fe}from"./chunk.TBY5IR7C.js";import"./chunk.PQTXM4VY.js";import"./chunk.BIDL7GQD.js";import"./chunk.7KX36ENH.js";import"./chunk.QDDDKEBH.js";import"./chunk.QKRQPUCE.js";import"./chunk.SPJ34VHA.js";import"./chunk.XOZU4OFA.js";import"./chunk.KBJ3UUER.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.4O64QV2Y.js";import"./chunk.OYMN3IFX.js";import"./chunk.UQZ2P6KD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.NI4OPHTL.js";import"./chunk.U5KJQFAP.js";import"./chunk.FOHZPYUV.js";import"./chunk.IXYG65TM.js";import"./chunk.W6L2VAJG.js";import"./chunk.N3MXLORL.js";import"./chunk.MIE4TJRW.js";import{s as he}from"./chunk.3CLTABGP.js";import"./chunk.RD2FSSLV.js";import"./chunk.CVN2XFMF.js";import"./chunk.6TBQV3NO.js";import"./chunk.MT252WP4.js";import{l as ue}from"./chunk.VVIQSFM4.js";import"./chunk.TQ3MNB6K.js";import"./chunk.VGYG2IBZ.js";import{G as Ne,t as U}from"./chunk.RJ7VSWTA.js";import"./chunk.P43LPXXJ.js";import{$ as we,G as Je,Ta as ae,Ua as Y,Y as ge,ga as I,ia as te,j as le,l as pe,m as ce,r as J,ta as ve}from"./chunk.JCKIJSW7.js";import"./chunk.SDO3U72B.js";import{L as ie,T as oe,Z as C,ma as re,oa as ee,qa as se,sa as de}from"./chunk.6L6RUOSF.js";import"./chunk.FQLNBIQ5.js";import{b as Z}from"./chunk.AJZBJBMO.js";var o=Z(Je(),1);var e=Z(ge(),1),Ye=560;function Ue(t,n){let[d,g]=(0,o.useState)(0);return(0,o.useEffect)(()=>{let r=t.current;if(!r||!n){g(0);return}let i=0,c=()=>{i=0;let f=r.getBoundingClientRect().bottom;g([...r.querySelectorAll('[data-testid="kind-stop-table"] tbody tr[data-graview-pick]')].filter(S=>S.getBoundingClientRect().top>f-24).length)},b=()=>{i||(i=requestAnimationFrame(c))};c(),r.addEventListener("scroll",b,{passive:!0});let L=typeof ResizeObserver>"u"?null:new ResizeObserver(b);L?.observe(r);let R=r.querySelector('[data-testid="kind-stop-body"]');return R&&L?.observe(R),()=>{r.removeEventListener("scroll",b),L?.disconnect(),i&&cancelAnimationFrame(i)}},[t,n]),d}function Xe({narrow:t,at:n,children:d}){return t?(0,e.jsx)("div",{ref:n,className:"graview-kind-stop-scroll","data-testid":"kind-stop-scroll",children:d}):(0,e.jsx)(e.Fragment,{children:d})}function Ze(t){let[n,d]=(0,o.useState)(!1);return(0,o.useLayoutEffect)(()=>{let g=t.current;if(!g)return;let r=()=>{let c=g.getBoundingClientRect().width;c>0&&d(c<Ye)};if(r(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(r);return i.observe(g),()=>i.disconnect()},[t]),n}var _e="as",et=(t,n)=>`graview:kind-seen:${t}:${n}`;function tt(t){try{return localStorage.getItem(t)}catch{return null}}function at(t,n){try{localStorage.setItem(t,n)}catch{}}var nt=(t,n)=>({...le(ce(t,!1),n),relation:null});function Mt({kind:t,members:n,flagged:d=[],label:g,retired:r=0}){let{store:i,brand:c,principal:b,views:L,view:R}=I(),{go:f}=Y(),S=te(),w=i.schema,$=w.tryDefinition(t),p=g??se(w,t),A=i.today()??ie(),l=n,N=(0,o.useId)(),h=(0,o.useMemo)(()=>Oe(w,t,l,A),[w,t,l,A]),u=R.within?.[_e]==="table"?{shape:"table"}:h,y=Re(R),T=u.shape==="table"&&!y.sort?Be(w,t):void 0,x=T?{...y,sort:T}:y,M=(0,o.useMemo)(()=>new Set(d),[d]),s=(0,o.useMemo)(()=>Ae(l,x,{schema:w,graph:i.graph,flagged:M,today:A}),[l,x,w,i,M,A,S]),k=(0,o.useMemo)(()=>ke(w,be(w,t)),[w,t]),D=L.arrangement?.()?.lists?.[t]?.filters,H=q=>f(Le(R,q)),V=(0,o.useMemo)(()=>({name:c?.name??"app",schema:w,...i.policy?{policy:i.policy}:{}}),[c,w,i]),_=JSON.stringify(Fe(t,u,x)),O=(0,o.useMemo)(()=>{let q=Se(JSON.parse(_),{app:V,sight:xe(V,b)});return ye(q)?void 0:q},[_,V,b]),G=u.shape!=="table"&&O!==void 0,z=(0,o.useRef)(null),P=Ze(z),[K,a]=(0,o.useState)(!1),m=(0,o.useId)(),B=(0,o.useMemo)(()=>fe(i,b),[i,b]),F=(l.length>1||r>0)&&!G?(0,e.jsx)($e,{schema:w,graph:i.graph,kind:t,arrangement:x,onChange:H,offers:k,...D?{filters:D}:{},kept:{shown:s.nodes.length,of:l.length},testId:"kind-arrange",chips:{nodes:l,flagged:M,today:A},...r>0?{past:{count:r,widen:()=>f(Ce(R,!0))}}:{}}):null,E=!!x.query||(x.filter?.length??0)>0,Q=(0,o.useRef)(null),X=Ue(Q,P&&!G);return(0,e.jsxs)("section",{ref:z,"aria-labelledby":N,className:"graview-kind-stop","data-testid":"kind-stop","data-graview-kind-stop":t,"data-graview-shape":u.shape,"data-graview-narrow":P||void 0,children:[(0,e.jsx)("style",{children:ct}),(0,e.jsxs)(Xe,{narrow:P,at:Q,children:[(0,e.jsx)(it,{kind:t,plural:p,count:l.length,headingId:N,description:$?.description,...P?{tools:{open:K,id:m,toggle:()=>a(q=>!q),narrowed:E}}:{}}),P&&K?(0,e.jsxs)("div",{id:m,className:"graview-kind-stop-tools","data-testid":"kind-stop-tools",role:"group","aria-label":`Find, filter and arrange the ${p.toLowerCase()}`,children:[F,l.length>0?(0,e.jsx)(We,{derived:h,shape:u,draft:O,author:!1}):null,(0,e.jsx)(Qe,{kind:t,plural:p})]}):null,(0,e.jsx)(rt,{kind:t,plural:p,members:l,today:A,arrangement:x,onArrange:H,compact:P}),P&&E&&!K?(0,e.jsxs)("p",{className:"graview-kind-stop-narrowed","data-testid":"kind-stop-narrowed",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[C(s.nodes.length)," of ",C(l.length)," shown"]})," ",(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>H({}),children:"Show all"})]}):null,P?null:F,l.length>0&&!P?(0,e.jsx)(We,{derived:h,shape:u,draft:O,author:B}):null,(0,e.jsx)("div",{className:"graview-kind-stop-body","data-testid":"kind-stop-body",children:l.length===0?(0,e.jsx)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-empty",children:"Nothing here yet."}):G?(0,e.jsx)(lt,{draft:O,nodes:l}):s.nodes.length===0?(0,e.jsxs)("p",{className:"graview-kind-stop-empty","data-testid":"kind-stop-none-kept",children:["None of the ",C(l.length)," ",p.toLowerCase()," ",x.query?`says \u201C${x.query}\u201D`:"is kept by these filters","."," ",(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link",onClick:()=>H({}),children:"Show them all"})]}):(0,e.jsx)(pt,{kind:t,nodes:s.nodes,groups:s.grouped?s.groups.map(q=>({key:q.key,label:q.label,nodes:q.nodes})):void 0,flagged:M,plural:p,arrangement:x})})]}),X>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-below","data-testid":"kind-stop-below","data-graview-below":X,onClick:()=>Q.current?.scrollBy({top:Math.round(Q.current.clientHeight*.8),behavior:"smooth"}),children:[ee(w,t,X).replace(/^(\S+)\s/,"$1 more ")," below ",(0,e.jsx)("span",{"aria-hidden":"true",children:"\u2193"})]}):null]})}function Qe({kind:t,plural:n}){let{setSelection:d,setMenuAt:g}=I();return(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-quiet","data-testid":"kind-stop-acts","aria-haspopup":"menu","aria-label":`What can be done with the ${n.toLowerCase()}`,onClick:r=>{let i=r.currentTarget.getBoundingClientRect();d([J(t)]),g({x:Math.round(i.left),y:Math.round(i.bottom+4),on:J(t)})},children:"Acts\u2026"})}function it({kind:t,plural:n,count:d,headingId:g,description:r,tools:i}){let{store:c}=I(),b=(0,o.useMemo)(()=>({about:[J(t)]}),[t]),{affordances:L}=Te(b),{apply:R,preview:f}=Ee(),S=(0,o.useMemo)(()=>{let v=u=>c.allMutations().find(y=>y.name===u.mutation)?.creates?.includes(t)??!1;return L.find(u=>!u.destructive&&!u.setsAside&&v(u))},[L,c,t]),[w,$]=(0,o.useState)(!1),[p,A]=(0,o.useState)(null),l=(0,o.useRef)(null),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{let v=N.current;if(!v||v.closest('[data-testid="kind-stop"]')?.contains(document.activeElement))return;let u=!1;try{u=document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.matches(":focus-visible")}catch{u=!0}u?delete v.dataset.graviewQuietFocus:v.dataset.graviewQuietFocus="",v.focus({preventScroll:!0})},[t]);let h=(v,u)=>{try{f(v,u),R(v,u),A(null),$(!1),requestAnimationFrame(()=>l.current?.focus())}catch(y){return A(ue(c.schema,c.allMutations(),y)),[]}};return(0,e.jsxs)("header",{className:"graview-kind-stop-head",children:[(0,e.jsxs)("div",{className:"graview-kind-stop-title",children:[(0,e.jsx)("h2",{id:g,ref:N,tabIndex:-1,"data-testid":"kind-stop-title",onKeyDown:v=>delete v.currentTarget.dataset.graviewQuietFocus,onBlur:v=>delete v.currentTarget.dataset.graviewQuietFocus,children:n}),(0,e.jsxs)("p",{"data-testid":"kind-stop-count",children:[ee(c.schema,t,d),r?` \xB7 ${r}`:""]})]}),(0,e.jsxs)("div",{className:"graview-kind-stop-acts",children:[S?(0,e.jsx)("button",{ref:l,type:"button",className:"graview-kind-stop-primary","data-testid":"kind-stop-primary","data-affordance":S.id,"aria-expanded":S.open.length>0?w:void 0,onClick:()=>{A(null),S.open.length===0?h(S):$(v=>!v)},children:S.label}):null,i?(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-more-tools","data-testid":"kind-stop-tools-open","aria-expanded":i.open,"aria-controls":i.open?i.id:void 0,"aria-label":`Find, filter, arrange and act on the ${n.toLowerCase()}`,title:"Find, filter, arrange and acts","data-narrowed":i.narrowed||void 0,onClick:i.toggle,children:(0,e.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})}):(0,e.jsx)(Qe,{kind:t,plural:n})]}),w&&S?(0,e.jsx)("div",{className:"graview-kind-stop-ask","data-testid":"kind-stop-ask","aria-label":S.label,role:"group",children:(0,e.jsx)(me,{affordance:S,onApply:v=>h(S,v),onCancel:()=>{$(!1),l.current?.focus()}})}):null,p?(0,e.jsx)("p",{role:"alert",className:"graview-kind-stop-failed","data-testid":"kind-stop-failed",children:p}):null]})}var ot=U.part((t,n)=>(0,e.jsx)(t.ProblemRows,{...n}),{what:"The problems",as:"li"});function rt({kind:t,plural:n,members:d,today:g,arrangement:r,onArrange:i,compact:c=!1}){let{store:b,brand:L,setSelection:R}=I(),f=b.schema,S=ae(),w=(0,o.useMemo)(()=>new Set(d.map(s=>s.id)),[d]),$=(0,o.useMemo)(()=>ze(S,w,s=>b.allInvariants().find(k=>k.name===s)?.label),[S,w,b]),p=(0,o.useMemo)(()=>Ke(f,t,d,g),[f,t,d,g]),A=et(Ne(L,f),t),[l]=(0,o.useState)(()=>tt(A));(0,o.useEffect)(()=>()=>at(A,new Date().toISOString()),[A]);let N=te(),h=(0,o.useMemo)(()=>l?Ve(b.log.all(),t,l,s=>b.graph.getNode(s)?.kind):null,[l,b,t,N]),[v,u]=(0,o.useState)(null),y=s=>i({...r,filter:[...(r.filter??[]).filter(k=>!s?.some(D=>D.key===k.key)),...s??[]]}),T=$.reduce((s,k)=>s+k.violations.length,0),x=[];if(p&&(p.overdue>0||p.soon>0)){let s=p.field;x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-dates",children:[p.overdue>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-fact","data-tone":"warn",onClick:()=>y(ne(p,"overdue",g)),"aria-label":`${C(p.overdue)} overdue \u2014 show only these`,children:[C(p.overdue)," overdue"]}):null,p.soon>0?(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-fact",onClick:()=>y(ne(p,"soon",g)),"aria-label":`${C(p.soon)} in the next 7 days \u2014 show only these`,children:[C(p.soon)," ",p.due?"due":""," in the next 7 days"]}):null,(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" by ",de(f.tryDefinition(t),s).toLowerCase()]})]},"dates"))}let M=(r.filter??[]).some(s=>s.key==="is"&&s.value==="flagged");if($.length>0&&c){let s=$.map(k=>k.label).join(", ");x.push((0,e.jsxs)("li",{className:"graview-kind-stop-problems-line","data-testid":"kind-stop-problems","data-graview-problems":T,children:[(0,e.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),T===1?"1 problem":`${C(T)} problems`]}),(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text graview-kind-stop-rules-said",title:s,children:[" ","\xB7 ",s]}),(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems","aria-pressed":M,"aria-label":M?`Show all the ${n.toLowerCase()}`:`Show only the ${n.toLowerCase()} with a problem`,onClick:()=>M?i({...r,filter:(r.filter??[]).filter(k=>!(k.key==="is"&&k.value==="flagged"))}):y([{key:"is",value:"flagged"}]),children:M?"Show all":"Show"})]},"problems"))}else $.length>0&&x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-problems","data-graview-problems":T,children:[(0,e.jsxs)("span",{className:"graview-kind-stop-warn",children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0 "}),T===1?"1 problem":`${C(T)} problems`]}),(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:[" in ",n.toLowerCase(),":"]}),(0,e.jsx)("ul",{className:"graview-kind-stop-rules",children:$.map(s=>(0,e.jsx)(st,{group:s,open:v===s.invariant,onToggle:()=>u(k=>k===s.invariant?null:s.invariant),onPick:k=>R([k])},s.invariant))}),(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-only-problems",onClick:()=>y([{key:"is",value:"flagged"}]),children:["Show only the ",n.toLowerCase()," with a problem"]})]},"problems"));if(h&&(h.added>0||h.changed>0)){let s=[h.added>0?`${C(h.added)} added`:"",h.changed>0?`${C(h.changed)} changed`:""].filter(Boolean);x.push((0,e.jsxs)("li",{"data-testid":"kind-stop-since",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["Since you last looked (",oe(l.slice(0,10)),"):"]})," ",s.join(", ")]},"since"))}return x.length===0?null:(0,e.jsx)("ul",{className:"graview-kind-stop-going-on","aria-label":`What is going on in the ${n.toLowerCase()}`,"data-testid":"kind-stop-going-on",children:x})}function st({group:t,open:n,onToggle:d,onPick:g}){let r=(0,o.useId)();return(0,e.jsxs)("li",{"data-graview-rule":t.invariant,children:[(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-rule","aria-expanded":n,"aria-controls":r,onClick:d,onPointerEnter:U.prefetch,onFocus:U.prefetch,children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"graview-kind-stop-chevron","data-open":n||void 0,children:"\u203A"}),t.label," ",(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",C(t.violations.length)]})]}),n?(0,e.jsx)("ol",{id:r,className:"graview-kind-stop-problem-rows","data-testid":"kind-stop-problem-rows",children:(0,e.jsx)(o.Suspense,{fallback:null,children:(0,e.jsx)(ot,{violations:t.violations,pick:i=>{let c=i.subjectId??t.records[0]??i.nodeIds[0];c!==void 0&&g(c)}})})}):null]})}var dt={board:"Board",calendar:"Calendar",table:"Table"};function We({derived:t,shape:n,draft:d,author:g}){let{view:r}=I(),{go:i}=Y(),{keep:c}=Ge(je()),[b,L]=(0,o.useState)(!1),R=t.shape==="table"?[]:[t.shape,"table"];return!g&&R.length===0?null:(0,e.jsxs)("div",{className:"graview-kind-stop-shape","data-testid":"kind-stop-shape",children:[R.length>0?(0,e.jsx)("span",{role:"group","aria-label":"Show as",className:"graview-kind-stop-switch",children:R.map(f=>(0,e.jsx)("button",{type:"button","aria-pressed":n.shape===f,"data-testid":`kind-stop-as-${f}`,onClick:()=>i(pe(r,_e,f===t.shape?null:f)),children:dt[f]},f))}):null,g?(0,e.jsx)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-derived",children:d?`${d.said.replace(/\.$/,"")}, derived from the declaration`:"Derived from the declaration"}):null,d&&g?(0,e.jsx)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-keep",disabled:b,title:`Keep \u201C${d.title}\u201D as a lens: a place of its own`,onClick:()=>{L(!0),c(d).finally(()=>L(!1))},children:"Keep as a lens"}):null]})}function lt({draft:t,nodes:n}){let d=De(t.drawn);return(0,e.jsx)("div",{className:"graview-kind-stop-lens","data-graview-draft":t.lens.name,children:(0,e.jsx)(we,{mode:"scene",children:(0,e.jsx)(he,{kind:t.kind,view:t.title,children:(0,e.jsx)(d,{nodes:n,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})})}function pt({kind:t,nodes:n,groups:d,flagged:g,plural:r,arrangement:i}){let{store:c,views:b,view:L,selection:R,setSelection:f,setMenuAt:S,principal:w}=I(),{go:$}=Y(),p=c.schema,A=c.graph,l=(0,o.useMemo)(()=>(d?d.flatMap(a=>a.nodes):n).map(a=>a.id),[n,d]),N=Me(l),h=(0,o.useMemo)(()=>c.permittedMutations(w).some(a=>{let m=a.subject?.kinds;return m!==void 0&&(m==="*"||m.includes(t))}),[c,w,t]),v=(0,o.useRef)(null),u=a=>{N.choose(a),requestAnimationFrame(()=>{let m=N.list.current;((a[0]===void 0?null:m?.querySelector(`[data-graview-choose-box="${CSS.escape(a[0])}"]`))??m)?.focus({preventScroll:!0})})},y=N.chosen.length,T=b.lookup(t,{cardinality:"one",fidelity:"glyph"}),x=T!==void 0&&!ve(T)?T:void 0,M=a=>R.includes(a),s=ae(),k=(0,o.useMemo)(()=>He(p,t,n,A),[p,t,n,A]),[D,H]=(0,o.useState)(W);(0,o.useEffect)(()=>H(W),[i.query,i.filter?.length,i.sort?.by,i.group?.by]);let V=p.tryDefinition(t),_=a=>s.filter(m=>m.nodeIds.includes(a)||m.subjectId===a).map(m=>m.message),O=i.sort?.by,G=`${r}${i.sort?`, in order of ${k.find(a=>a.key===O)?.label.toLowerCase()??O}`:""}`,z=D,P=a=>{let m=re(V,a),B=g.has(a.id)?_(a.id):[];return(0,e.jsxs)("tr",{"data-graview-pick":a.id,tabIndex:-1,"data-graview-record":a.id,"data-flagged":B.length>0||void 0,...h?{"data-graview-choose":a.id}:{},children:[h?(0,e.jsx)("td",{className:"graview-choose-at",children:(0,e.jsx)("input",{...N.boxProps(a.id,m),onPointerEnter:j,onFocus:j})}):null,(0,e.jsxs)("th",{scope:"row",className:"graview-kind-stop-name",children:[x?(0,e.jsx)("div",{"data-graview-pick":a.id,className:"graview-kind-stop-own-row",children:(0,e.jsx)(x,{node:a,cardinality:"one",fidelity:"glyph",mode:"scene",selected:M(a.id),...B.length>0?{flagged:[a.id]}:{}})}):(0,e.jsx)("button",{type:"button","data-testid":"kind-stop-row-go",title:`Go to ${m}`,onClick:()=>$(nt(L,a.id)),children:m}),B.length>0?(0,e.jsxs)("span",{className:"graview-kind-stop-flag",title:B.join(" \xB7 "),children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"\u26A0"}),(0,e.jsx)("span",{className:"graview-kind-stop-hidden",children:`Problem: ${B.join(". ")}`})]}):null]}),k.map(F=>{let E=Ie(p,a,F,A);return(0,e.jsx)("td",{"data-label":F.label,"data-short":E.text.length>0&&E.text.length<=14||void 0,"data-empty":E.text?void 0:"",...E.title?{title:E.title}:{},children:E.text?(0,e.jsx)("span",{children:E.text}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("b",{"aria-hidden":"true",children:"\u2014"}),(0,e.jsx)("i",{className:"graview-kind-stop-hidden",children:"none"})]})},F.key)}),(0,e.jsx)("td",{className:"graview-kind-stop-row-acts",children:(0,e.jsx)("button",{type:"button","data-testid":"kind-stop-row-acts","aria-haspopup":"menu","aria-label":`What can be done with ${m}`,onClick:F=>{let E=F.currentTarget.getBoundingClientRect();f([a.id]),S({x:Math.round(E.left),y:Math.round(E.bottom+4),on:a.id})},children:(0,e.jsx)("span",{"aria-hidden":"true",children:"\u22EF"})})})]},a.id)},K=a=>{let m=a.slice(0,Math.max(0,z));return z-=m.length,m.map(P)};return(0,e.jsxs)("div",{className:"graview-kind-stop-table-at",...h?{...N.listProps,ref:a=>{v.current=a,N.list.current=a},tabIndex:-1,role:"group","aria-label":y>0?`${r}, ${y} chosen`:r,"data-graview-choosable":""}:{},children:[h?(0,e.jsx)("style",{children:Pe}):null,(0,e.jsxs)("table",{className:"graview-kind-stop-table","data-testid":"kind-stop-table",children:[(0,e.jsx)("caption",{className:"graview-kind-stop-hidden",children:G}),(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[h?(0,e.jsx)("td",{className:"graview-choose-at graview-choose-all",children:(0,e.jsx)("input",{type:"checkbox",className:"graview-choose-box","data-testid":"kind-stop-choose-all","aria-label":`Choose all ${C(n.length)} ${r.toLowerCase()}`,checked:y>0&&y===n.length,ref:a=>{a&&(a.indeterminate=y>0&&y<n.length)},onPointerEnter:j,onFocus:j,onChange:()=>y===n.length?N.clear():N.choose(l)})}):null,(0,e.jsx)("th",{scope:"col","aria-sort":O==="label"?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:"Name"}),k.map(a=>(0,e.jsx)("th",{scope:"col","aria-sort":a.about==="field"&&a.key===O?i.sort?.direction==="desc"?"descending":"ascending":void 0,children:a.label},a.key)),(0,e.jsx)("th",{scope:"col",children:(0,e.jsx)("span",{className:"graview-kind-stop-hidden",children:"Acts"})})]})}),d?d.map(a=>z<=0?null:(0,e.jsxs)("tbody",{"data-graview-group":a.key,children:[(0,e.jsx)("tr",{className:"graview-kind-stop-group",children:(0,e.jsxs)("th",{scope:"rowgroup",colSpan:k.length+(h?3:2),children:[a.label," ",(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text",children:["\xB7 ",C(a.nodes.length)]})]})}),K(a.nodes)]},a.key||"-")):(0,e.jsx)("tbody",{children:K(n)})]}),h?(0,e.jsx)(qe,{store:c,chosen:N.chosen,principal:w,anchor:()=>v.current?.closest('[data-testid="kind-stop"]')??null,of:l.length,onChooseAll:()=>N.choose(l),onClear:N.clear,onActed:u}):null,n.length>D?(0,e.jsxs)("p",{className:"graview-kind-stop-more",children:[(0,e.jsxs)("span",{className:"graview-kind-stop-quiet-text","data-testid":"kind-stop-shown",children:[C(D)," of ",C(n.length)," shown"]})," ",(0,e.jsxs)("button",{type:"button",className:"graview-kind-stop-link","data-testid":"kind-stop-more",onClick:()=>H(a=>a+W),children:["Show ",C(Math.min(W,n.length-D))," more"]})]}):null]})}var ct=`
|
|
2
2
|
.graview-kind-stop{container-type:inline-size;box-sizing:border-box;height:100%;min-height:0;display:flex;flex-direction:column;gap:10px;padding:16px 18px 12px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius,12px);background:var(--graview-panel);color:var(--graview-ink);box-shadow:var(--graview-lift-low);overflow:auto;overscroll-behavior:contain}
|
|
3
3
|
[data-graview-map-panel] .graview-kind-stop{height:auto;padding:4px 6px 12px;border:0;box-shadow:none;background:none;overflow:visible}
|
|
4
4
|
.graview-kind-stop :focus-visible{outline:2px solid var(--graview-accent);outline-offset:2px}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{G as w,Ta as c,fa as f,ga as h,ia as g}from"./chunk.
|
|
1
|
+
import{G as w,Ta as c,fa as f,ga as h,ia as g}from"./chunk.JCKIJSW7.js";import{b as m}from"./chunk.AJZBJBMO.js";var d=m(w(),1);function j(){let e=c();return(0,d.useMemo)(()=>[...new Set(e.flatMap(n=>n.nodeIds))],[e])}function x(){let e=I(),n=f();return(0,d.useMemo)(()=>{if(!n)return e;let t=n.matched;return t.length===0&&e.length===0?[k]:[...new Set([...e,...t])]},[n,e])}function I(){let{store:e,selection:n}=h(),t=g(),r=c();return(0,d.useMemo)(()=>{if(n.length===0)return v;let u=n.join(`
|
|
2
2
|
`),s=y.get(e);if(s&&s.violations===r&&s.key===u)return s.reached;let a=new Set(n),i=new Set(a);for(let o of e.graph.allEdges())a.has(o.from)&&i.add(o.to),a.has(o.to)&&i.add(o.from);for(let o of r)if(o.subjectId!==void 0&&a.has(o.subjectId))for(let p of o.nodeIds)i.add(p);let l=[...i];return y.set(e,{violations:r,key:u,reached:l}),l},[e,n,t,r])}var v=[],y=new WeakMap,k="search:nothing";export{j as a,x as b,I as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as D}from"./chunk.
|
|
1
|
+
import{e as D}from"./chunk.GFOZVQBQ.js";import{a as T}from"./chunk.U5KJQFAP.js";import{d as A}from"./chunk.VVIQSFM4.js";import{b as O}from"./chunk.TQ3MNB6K.js";import{db as x,ma as S}from"./chunk.6L6RUOSF.js";var _=300,F=14,W=50,M=3,j=2;function N(t,e,d){let s=t.tryDefinition(e)?.fields?.shape;return(s?.[d]===void 0?void 0:T(s[d]))?.type}var C=(t,e)=>Object.keys(t.tryDefinition(e)?.fields?.shape??{}),I=t=>t==="date"||t==="datetime",R=/^(due|dueOn|dueAt|dueDate|deadline|by)$/i,L=/^(date|on|day|when|at|start|starts|startsOn|startsAt|begins|from|sown|scheduled|scheduledFor|planned|plannedFor)$/i,B=/^(done|finished|complete|completed|closed)$/i;function E(t,e){let d=t.tryDefinition(e),s=C(t,e),n=s.filter(l=>I(N(t,e,l)));if(n.length===0)return;let o=d?.fieldRoles??{},i=l=>o[l]!==void 0&&n.includes(o[l])?o[l]:void 0,a=i("start")??i("when")??n.find(l=>R.test(l))??n.find(l=>L.test(l));if(!a)return;let g=i("end")??n.find(l=>l!==a&&/^(end|ends|until|to|finish|finished|harvested|through)$/i.test(l)),u=s.find(l=>B.test(l)&&N(t,e,l)==="boolean");return{field:a,due:R.test(a),...g?{end:g}:{},...u?{done:u}:{}}}function w(t,e){return Math.round((Date.parse(`${e.slice(0,10)}T00:00:00Z`)-Date.parse(`${t.slice(0,10)}T00:00:00Z`))/864e5)}var h=t=>typeof t=="string"&&/^\d{4}-\d{2}-\d{2}/.test(t)?t.slice(0,10):void 0;function Y(t,e,d,s){let n=D(t,e);if(n&&d.length>0&&d.length<=_)return{shape:"board",field:n.field};let o=E(t,e);if(o&&!o.due){let i=r=>{let p=h(r[o.field]),y=h(x(r,o.field,s));return p&&y?w(p,y):0},a=d.map(r=>({from:h(x(r,o.field,s)),to:o.end&&h(r[o.end])?b(h(r[o.end]),i(r)):void 0})).filter(r=>r.from!==void 0).map(r=>({from:r.from,to:r.to&&r.to>r.from?r.to:r.from})),g=`${s.slice(0,7)}-01`,u=b(`${b(g,31).slice(0,7)}-01`,-1),l=a.filter(r=>r.from<=u&&r.to>=g),c=a.map(r=>w(r.from,r.to)).sort((r,p)=>r-p),f=c[Math.floor(c.length/2)]??0;if(l.length>0&&f<=F){let r=b(s,-((new Date(`${s}T00:00:00Z`).getUTCDay()+6)%7)),p=b(r,6),y=l.every(m=>m.from>=r&&m.to<=p);return{shape:"calendar",start:o.field,...o.end?{end:o.end}:{},...o.done?{done:o.done}:{},range:y?"week":"month"}}}return{shape:"table"}}function H(t,e){let d=E(t,e);return d?{by:d.field,direction:d.due?"asc":"desc"}:void 0}function q(t,e,d={}){switch(e.shape){case"board":return{lens:"columns",kind:t,column:e.field};case"calendar":return{lens:"calendar",kind:t,start:e.start,...e.end?{end:e.end}:{},...e.done?{done:e.done}:{},range:e.range};case"table":return{lens:"blocks",kind:t,as:"row",...d.group?.by?{group:d.group.by}:{},...d.sort?{sort:{by:d.sort.by,...d.sort.direction==="desc"?{direction:"desc"}:{}}}:{}}}}var G=60;function z(t,e,d,s){let n=t.tryDefinition(e),o=d.slice(0,G),i=new Map;o.forEach(c=>{let f=S(n,c);A(c,n,{glance:!0,said:[f]}).forEach((r,p)=>{if(r.long||r.files||r.app)return;let y=i.get(r.key);y?y.count++:i.set(r.key,{label:r.label,count:1,at:p})})});let a=Math.max(1,Math.ceil(o.length/3)),g=[...i.entries()].filter(([,c])=>c.count>=a).sort((c,f)=>c[1].at-f[1].at).slice(0,M).map(([c,f])=>({about:"field",key:c,label:f.label})),u=new Map;for(let c of o){let f=new Set;for(let[r,p]of[["out",s.outEdges(c.id)],["in",s.inEdges(c.id)]])for(let y of p){let m=s.getNode(r==="out"?y.to:y.from);if(!m||m.id===c.id)continue;let v=`${y.kind}|${r}`;if(f.has(v))continue;f.add(v);let k=u.get(v);k?k.count++:u.set(v,{edge:y.kind,direction:r,far:m.kind,count:1})}}let l=[...u.entries()].sort((c,f)=>f[1].count-c[1].count).slice(0,j).map(([c,f])=>{let r=O(t,f.direction==="out"?e:f.far,f.edge,f.direction);return{about:"edge",key:c,label:r.charAt(0).toUpperCase()+r.slice(1),edge:f.edge,direction:f.direction}});return[...g,...l]}function J(t,e,d,s){if(d.about==="field"){let i=t.tryDefinition(e.kind);return{text:A(e,i,{excerpt:!0}).find(g=>g.key===d.key)?.value??""}}let o=(d.direction==="out"?s.outEdges(e.id):s.inEdges(e.id)).filter(i=>i.kind===d.edge).map(i=>s.getNode(d.direction==="out"?i.to:i.from)).filter(i=>i!==void 0).map(i=>S(t.tryDefinition(i.kind),i));return o.length===0?{text:""}:o.length===1?{text:o[0]}:{text:`${o[0]} +${o.length-1}`,title:o.join(", ")}}function Q(t,e,d=()=>{}){let s=new Map;for(let n of t){let o=n.nodeIds.filter(a=>e.has(a));if(o.length===0&&!(n.subjectId!==void 0&&e.has(n.subjectId)))continue;let i=s.get(n.invariant)??{invariant:n.invariant,label:d(n.invariant)||n.label||n.message,violations:[],records:new Set};i.violations.push(n);for(let a of o)i.records.add(a);n.subjectId!==void 0&&e.has(n.subjectId)&&i.records.add(n.subjectId),s.set(n.invariant,i)}return[...s.values()].sort((n,o)=>o.violations.length-n.violations.length).map(n=>({invariant:n.invariant,label:n.label,violations:n.violations,records:[...n.records]}))}var $=6;function X(t,e,d,s){let n=E(t,e);if(!n)return;let o=D(t,e),i=u=>{if(n.done!==void 0&&u[n.done]===!0)return!0;if(!o)return!1;let l=o.values.indexOf(String(u[o.field]));return l>=0&&o.tiers[l]==="done"},a=0,g=0;for(let u of d){let l=h(x(u,n.field,s));if(!l||i(u))continue;let c=w(s,l);n.due&&c<0?a++:c>=0&&c<=$&&g++}if(!(a===0&&g===0))return{field:n.field,due:n.due,overdue:a,soon:g}}function b(t,e){return new Date(Date.parse(`${t.slice(0,10)}T00:00:00Z`)+e*864e5).toISOString().slice(0,10)}function ee(t,e,d){return e==="overdue"?[{key:t.field,value:`before:${d}`}]:[{key:t.field,value:`after:${b(d,-1)}`},{key:t.field,value:`before:${b(d,$+1)}`}]}function ne(t,e,d,s){let n=new Set,o=new Set;for(let i of t)if(!(i.at<=d))for(let a of i.primitives)a.op==="add-node"&&a.node?.kind===e?n.add(a.node.id):(a.op==="patch-node"||a.op==="splice-text")&&a.id!==void 0&&s(a.id)===e&&o.add(a.id);for(let i of n)o.delete(i);return{added:[...n].filter(i=>s(i)===e).length,changed:[...o].filter(i=>s(i)===e).length}}export{_ as a,W as b,N as c,E as d,Y as e,H as f,q as g,z as h,J as i,Q as j,X as k,ee as l,ne as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ot}from"./chunk.T6PU3NKP.js";import"./chunk.FUTSLXWN.js";import{e as V,l as ue,n as G,r as st}from"./chunk.MZSWWMX6.js";import{a as ee}from"./chunk.G4JJXA63.js";import"./chunk.5IM2X3VT.js";import{c as nt}from"./chunk.NKUNCQB3.js";import{d as tt}from"./chunk.XJ4JYROM.js";import"./chunk.XOZU4OFA.js";import"./chunk.CHG522KL.js";import"./chunk.MR776WQ2.js";import"./chunk.ZGJUCVT5.js";import"./chunk.CVVNHQPO.js";import{d as et}from"./chunk.YIDNZTON.js";import{b as Ze}from"./chunk.QILGAV7H.js";import"./chunk.I6HIVTXU.js";import{Gb as Ve,Hb as Qe,L as ze,_ as Je,de as Ne,ee as Xe,ma as Ye,pa as qe,ua as Ae,va as F}from"./chunk.IUVRJDL3.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var At="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),Nt=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,St=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,Ot=/^(?:what(?: is|'s| am i looking at| do i see)(?: (?:here|this|on (?:this|the) (?:page|screen)|in view|this place|this page))?|where am i|describe (?:this|here|this place|this page)|tell me about (?:this|here|this place|this page))$/,rt=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ct=/^(?:date|day|when|on|at|the date|the day)$/,jt=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,z=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ft=864e5,he=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),xe=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>xe(he(o)+i*ft),xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",it="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",at="(\\d{1,2})(?:st|nd|rd|th)?",Dt=o=>xt.findIndex(i=>i.startsWith(o.slice(0,3))),dt=o=>Mt.findIndex(i=>o.startsWith(i.toLowerCase()));function Rt(o,i){return Je(o,{year:o.slice(0,4)!==i.slice(0,4)})}function Se(o,i,y){if(o<0||i<1||i>31)return;let f=Number(y.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?xe(j):void 0},p=c(f);if(p)return he(p)<he(y)-183*ft?c(f+1):p}function Oe(o,i,y){let f=new Date(he(i)).getUTCDay(),c=u=>{let S=(f-y+7)%7,w=C(i,-S+u*7);return{from:w,to:C(w,6)}},p=()=>{let u=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:u,to:C(xe(S.getTime()),-1)}},k=u=>u?{from:u,to:u,day:Rt(u,i)}:void 0,j=(u,S)=>{let w=Dt(S);return k(u==="this"||u==="next"?C(c(u==="next"?1:0).from,(w-y+7)%7):u==="last"?C(i,-((f-w+6)%7+1)):C(i,(w-f+7)%7))},J=u=>{let S=C(i,f===0?-1:6-f);return{from:C(S,u*7),to:C(S,u*7+1)}},B="\\b(?:(?:due |for |on |by )(?:the )?)?",P=[[/\b(?:overdue|past due|late)\b/,()=>({overdue:!0,to:C(i,-1)})],[/\b(?:due |for |on )?today\b/,()=>({from:i,to:i})],[/\b(?:due |for |on )?tomorrow\b/,()=>k(C(i,1))],[/\b(?:due |for |on )?yesterday\b/,()=>k(C(i,-1))],[/\b(?:due |for |on )?this week\b/,()=>c(0)],[/\b(?:due |for |on )?next week\b/,()=>c(1)],[/\b(?:due |for |on )?(?:last|previous) week\b/,()=>c(-1)],[/\b(?:due |for |on )?next weekend\b/,()=>J(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>J(0)],[/\b(?:due |for |on )?this month\b/,()=>p()],[new RegExp(`${B}(\\d{4}) (\\d{2}) (\\d{2})\\b`),u=>k(Se(Number(u[2])-1,Number(u[3]),`${u[1]}-01-01`))],[new RegExp(`${B}${at} (?:of )?${it}\\b`),u=>k(Se(dt(u[2]),Number(u[1]),i))],[new RegExp(`${B}${it} (?:the )?${at}\\b`),u=>k(Se(dt(u[1]),Number(u[2]),i))],[new RegExp(`${B}(?:(this|next|last|coming) )?${Wt}\\b`),u=>j(u[1],u[2])]];for(let[u,S]of P){let w=o.match(u);if(!w)continue;let N=S(w);if(N)return{ask:{words:w[0],...N},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function ht(o,i,y={}){let f=y.principal??{kind:"human"},c=o.seenBy(f),p=c.schema,k=y.today??o.today?.()??ze(),j=y.weekStartsOn??1,J=o.kindsKeptFrom(f),B=o.modules.disabledKinds,P=p.kinds.filter(e=>!J.has(e)&&!B.has(e)),u=new Set(P),S=(y.places??[]).filter(e=>e.kind===null||u.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>p.tryDefinition(e),H=e=>Ye(M(e.kind),e),I=e=>qe(p,e),se=e=>S.find(t=>t.kind===e&&t.address===Ne(p,e))?.address??Ne(p,e),ge=e=>Xe(p,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:H(e),address:ge(e),said:`Went to ${H(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},De=()=>({unresolved:!0,say:At}),oe=e=>{let t=M(e.kind),s=et(e,t,{limit:3,excerpt:!0}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${H(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},re=e=>{let t=new Set([G(e),G(z(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(z(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(z($(n.title))))||t.has(G(n.slug));return S.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??S.find(s)},pe=e=>{let t=st(o,e,{principal:f,today:k,limit:6,near:!1,...y.selection?{from:y.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&u.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Re=e=>{let t=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Ee=(e,t)=>{if(rt.has(e))return Le();let s=t?pe(z(e)||e):void 0,n=s?.one&&$(H(s.one))===$(z(e)||e)?void 0:re(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${me(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(z(e)||e);if(r.one){let l=Me(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${oe(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Re(r.picks),moves:[],picks:r.picks};let h=ae(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=I(d.kind),v={to:"kind",kind:d.kind,title:l,address:se(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return De()},me=e=>{if(e.kind===null){let h=P.map(l=>({kind:l,count:w.nodesOfKind(l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${(l.count===1?F(M(l.kind),l.kind):I(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${fe(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=I(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(M(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(y.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:oe(e),moves:[],subject:e.id};let t=S.find(s=>s.slug===y.place)??S.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${me(t)}`,moves:[],subject:t.slug}:{about:"here",say:me({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[I(s),F(M(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ie=(e,t)=>{let s=V(p,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(x=>x.key===l):void 0;if(v)return v}return s.find(d=>["due","deadline","date","when","on","at"].includes(d.key.toLowerCase()))??(s.length===1?s[0]:void 0)},He=e=>{let t=M(e),s=V(p,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>ue(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},Ie=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ct.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},ye=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:p,graph:c.graph,flagged:ye,today:k},ae=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ie(L,g)!==void 0),E=m.filter(L=>{let b=ie(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),U=m.length===1?m:E;if(U.length!==1)return;n=U[0]}if(!n)return;let h=V(p,n).filters,d=[],l=[],v=[],x=[],q=!1,de=[];for(let g=0;g<r.length;g++){let m=r[g],E=g>0&&(r[g-1]==="not"||r[g-1]==="un"),U=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(U&&!E){let b=(U.options??[]).find(O=>$(O)===m);d.push({key:U.key,value:b}),l.push(b);continue}let L=h.find(b=>b.about==="field"&&b.type==="boolean"&&[$(b.key),$(b.label)].some(O=>O===m||O===m.replace(/^un/,"")));if(L){let b=!E&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Pt.has(m)&&!E){let b=He(n);b==="unsayable"?(q=!0,x.push(O=>!ut(p,O))):(d.push(...b.conditions),x.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||de.push(m)}if(r=de,r.some(g=>!te.has(g))||!t&&d.length===0&&x.length===0)return;let T=I(n).toLowerCase(),Q=I(n);if(t){let g=ie(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:se(n),said:`Went to the ${T}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=He(n);m==="unsayable"?(q=!0,x.push(E=>!ut(p,E))):(d.push(...m.conditions),x.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(Ie(t.ask,g))}let R=w.nodesOfKind(n).filter(g=>d.every(m=>ue(be,g,m))&&x.every(m=>m(g))),K=[...l,...v].join(" and "),Y=[...l,T,...v].join(" "),W=R.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:H(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:ye.has(g.id),address:ge(g)})),X=R.length===0?`No ${T} are ${K}.`:`${R.length===1?`One ${F(M(n),n)} is`:`${R.length} ${T} are`} ${K}: ${fe(R.slice(0,6).map(H))}${R.length>6?`, and ${R.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:Y,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${se(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(Y),filter:Z,address:we,said:`Went to the ${Y}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Te=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),I(e)].some(s=>$(s).split(" ").some(n=>Et.has(n))),pt=e=>{let t=[],s=n=>M(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])u.has(h)&&t.push({key:n,direction:"out",far:h,words:ct(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:ct(`${h.inverse??""} ${r}`)});return t},mt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[I(a),F(M(a),a),a].map(A=>({kind:a,name:$(A)}))).filter(a=>a.name.length>0).sort((a,A)=>A.name.length-a.name.length),h=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),x=t==="who"?d.find(Te):d[0];if(!x&&t!=="who")return;let q=d.find(a=>a!==x),de=v.flatMap(a=>[je(a),...lt.has(je(a))?[...lt]:[]]),T=P.filter(a=>q?a===q:a!==x).flatMap(a=>{let A=ie(a,e.split(" "))??V(p,a).filters.find(D=>D.about==="field"&&D.type==="date");return A?pt(a).filter(D=>(x?D.far===x:Te(D.far))&&D.far!==a).map(D=>({kind:a,field:A,relation:D,said:v.length===0||de.some(ve=>D.words.some(vt=>Lt(vt,ve)))})):[]}).filter(a=>a.said);if(T.length===0)return;let Q=T.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),R=T.length===1?T[0]:Q.length===1?Q[0]:void 0;if(!R)return;let{kind:K,field:Y,relation:W}=R,X=[...s.ask.from?[{key:Y.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:Y.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>ue(be,a,A))),we=a=>(W.direction==="out"?c.graph.out(a.id,W.key):c.graph.in(a.id,W.key)).filter(A=>A.kind===W.far&&u.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let D of A)_.some(ve=>ve.id===D.id)||_.push(D)}let m=Ie(s.ask,Y),E=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),U=I(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${U} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${se(K)}?${new URLSearchParams({filter:L}).toString()}`,said:`Went to the ${b}.`};if(Z.length===0)return{about:"related",say:`No ${b}. ${O.said}`,moves:[O]};let le=v.join(" "),yt=l==="was"||l==="were",Ge=a=>yt?a===1?"was":"were":a===1?"is":"are",ce=_.map(H),bt=ce.length>8?[...ce.slice(0,8),`${ce.length-8} more`]:ce,kt=_.length===0?`${E}: nobody ${Ge(1)}${le?` ${le}`:""}.`:`${E}: ${fe(bt)}${le?` ${Ge(_.length)} ${le}`:""}.`,$t=t==="who"&&g.length>0?`${fe(g.slice(0,4).map(H))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",wt=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:H(a),why:{field:W.key,reading:Ze(p,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:ye.has(a.id),address:ge(a)}));return{about:"related",say:[kt,$t,O.said].filter(Boolean).join(" "),moves:[O],picks:wt}},Ke=N.match(jt);if(Ke){let e=Ke[1];if(e&&!rt.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=re(e),r=n?void 0:pe(z(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${oe(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Re(r.picks),moves:[],picks:r.picks}:De()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(y.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:oe(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Qe(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(Ot.test(N))return Le();let _e=mt(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!re(z(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=ae(N);if(e)return e}if(/^open /.test(N)){let e=ae(N);if(e)return e}let Fe=N.match(Nt)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Ee(Fe[1].trim(),!1);let Be=N.match(St);if(Be){let e=Ee(Be[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=re(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Ue=ae(N);return Ue||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Et=new Set(["person","people","user","users","member","members","volunteer","volunteers","gardener","gardeners","player","players","staff","worker","workers","employee","employees","owner","owners","assignee","assignees","helper","helpers","student","students","teacher","teachers","customer","customers","client","clients","contact","contacts","author","authors"]),lt=new Set(["work","cover","staff","assign","do","run","schedul","roster","book","duty","serv","help"]);function je(o){let i=o.toLowerCase().replace(/'s$/,"");for(let y of["ing","ed","es","s"])if(i.length>y.length+2&&i.endsWith(y)){let f=i.slice(0,-y.length);return f.length>3&&f[f.length-1]===f[f.length-2]?f.slice(0,-1):f}return i}function ct(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Lt=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Pt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function ut(o,i){return V(o,i.kind).filters.some(f=>f.about==="field"&&(f.type==="boolean"&&ne.has(f.key.toLowerCase())&&i[f.key]===!0||f.type==="choice"&&typeof i[f.key]=="string"&&ne.has(String(i[f.key]).toLowerCase())))}function fe(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function zt(o,i,y={}){let f=y.scene!==void 0?{...y.pages,scene:y.scene}:y.pages;return[...nt(o,i,f?{pages:f}:{})].map(({first:c,hidden:p,lens:k,...j})=>j)}function gt(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function Jt(o,i,y,f){let c=ht(o,i,gt(y,f));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let p=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...p,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...p,told:k.id};let j=k?tt(o,ot(Ve(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...p,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Yt(o,i,y={}){let f=gt(y),c=[];for(let p of i){let k=typeof p=="string"?p:typeof p=="object"&&p!==null&&typeof p.to=="string"?p.to:void 0;if(!k||k.trim().length===0)continue;let j=ht(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,f);if("moves"in j)for(let J of j.moves)c.some(B=>B.address===J.address)||c.push(J)}return c}export{At as NOTHING_BY_THAT_NAME,gt as askContextOf,Jt as goingFrom,Yt as movesFromNames,zt as placesFromViews,ht as resolveAsk};
|
|
1
|
+
import{a as ot}from"./chunk.T6PU3NKP.js";import"./chunk.ZONRIOIA.js";import{e as V,l as ue,n as G,r as st}from"./chunk.NXHEOHRR.js";import{a as ee}from"./chunk.G4JJXA63.js";import"./chunk.PQTXM4VY.js";import{c as nt}from"./chunk.7KX36ENH.js";import{d as tt}from"./chunk.SPJ34VHA.js";import"./chunk.XOZU4OFA.js";import"./chunk.KBJ3UUER.js";import"./chunk.UQZ2P6KD.js";import"./chunk.6TBQV3NO.js";import"./chunk.MT252WP4.js";import{d as et}from"./chunk.VVIQSFM4.js";import{b as Ze}from"./chunk.TQ3MNB6K.js";import"./chunk.VGYG2IBZ.js";import{Gb as Ve,Hb as Qe,L as ze,_ as Je,de as Ne,ee as Xe,ma as Ye,pa as qe,ua as Ae,va as F}from"./chunk.6L6RUOSF.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var At="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),Nt=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,St=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,Ot=/^(?:what(?: is|'s| am i looking at| do i see)(?: (?:here|this|on (?:this|the) (?:page|screen)|in view|this place|this page))?|where am i|describe (?:this|here|this place|this page)|tell me about (?:this|here|this place|this page))$/,rt=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ct=/^(?:date|day|when|on|at|the date|the day)$/,jt=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,z=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ft=864e5,he=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),xe=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>xe(he(o)+i*ft),xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",it="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",at="(\\d{1,2})(?:st|nd|rd|th)?",Dt=o=>xt.findIndex(i=>i.startsWith(o.slice(0,3))),dt=o=>Mt.findIndex(i=>o.startsWith(i.toLowerCase()));function Rt(o,i){return Je(o,{year:o.slice(0,4)!==i.slice(0,4)})}function Se(o,i,y){if(o<0||i<1||i>31)return;let f=Number(y.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?xe(j):void 0},p=c(f);if(p)return he(p)<he(y)-183*ft?c(f+1):p}function Oe(o,i,y){let f=new Date(he(i)).getUTCDay(),c=u=>{let S=(f-y+7)%7,w=C(i,-S+u*7);return{from:w,to:C(w,6)}},p=()=>{let u=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:u,to:C(xe(S.getTime()),-1)}},k=u=>u?{from:u,to:u,day:Rt(u,i)}:void 0,j=(u,S)=>{let w=Dt(S);return k(u==="this"||u==="next"?C(c(u==="next"?1:0).from,(w-y+7)%7):u==="last"?C(i,-((f-w+6)%7+1)):C(i,(w-f+7)%7))},J=u=>{let S=C(i,f===0?-1:6-f);return{from:C(S,u*7),to:C(S,u*7+1)}},B="\\b(?:(?:due |for |on |by )(?:the )?)?",P=[[/\b(?:overdue|past due|late)\b/,()=>({overdue:!0,to:C(i,-1)})],[/\b(?:due |for |on )?today\b/,()=>({from:i,to:i})],[/\b(?:due |for |on )?tomorrow\b/,()=>k(C(i,1))],[/\b(?:due |for |on )?yesterday\b/,()=>k(C(i,-1))],[/\b(?:due |for |on )?this week\b/,()=>c(0)],[/\b(?:due |for |on )?next week\b/,()=>c(1)],[/\b(?:due |for |on )?(?:last|previous) week\b/,()=>c(-1)],[/\b(?:due |for |on )?next weekend\b/,()=>J(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>J(0)],[/\b(?:due |for |on )?this month\b/,()=>p()],[new RegExp(`${B}(\\d{4}) (\\d{2}) (\\d{2})\\b`),u=>k(Se(Number(u[2])-1,Number(u[3]),`${u[1]}-01-01`))],[new RegExp(`${B}${at} (?:of )?${it}\\b`),u=>k(Se(dt(u[2]),Number(u[1]),i))],[new RegExp(`${B}${it} (?:the )?${at}\\b`),u=>k(Se(dt(u[1]),Number(u[2]),i))],[new RegExp(`${B}(?:(this|next|last|coming) )?${Wt}\\b`),u=>j(u[1],u[2])]];for(let[u,S]of P){let w=o.match(u);if(!w)continue;let N=S(w);if(N)return{ask:{words:w[0],...N},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function ht(o,i,y={}){let f=y.principal??{kind:"human"},c=o.seenBy(f),p=c.schema,k=y.today??o.today?.()??ze(),j=y.weekStartsOn??1,J=o.kindsKeptFrom(f),B=o.modules.disabledKinds,P=p.kinds.filter(e=>!J.has(e)&&!B.has(e)),u=new Set(P),S=(y.places??[]).filter(e=>e.kind===null||u.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>p.tryDefinition(e),H=e=>Ye(M(e.kind),e),I=e=>qe(p,e),se=e=>S.find(t=>t.kind===e&&t.address===Ne(p,e))?.address??Ne(p,e),ge=e=>Xe(p,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:H(e),address:ge(e),said:`Went to ${H(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},De=()=>({unresolved:!0,say:At}),oe=e=>{let t=M(e.kind),s=et(e,t,{limit:3,excerpt:!0}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${H(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},re=e=>{let t=new Set([G(e),G(z(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(z(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(z($(n.title))))||t.has(G(n.slug));return S.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??S.find(s)},pe=e=>{let t=st(o,e,{principal:f,today:k,limit:6,near:!1,...y.selection?{from:y.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&u.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Re=e=>{let t=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Ee=(e,t)=>{if(rt.has(e))return Le();let s=t?pe(z(e)||e):void 0,n=s?.one&&$(H(s.one))===$(z(e)||e)?void 0:re(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${me(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(z(e)||e);if(r.one){let l=Me(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${oe(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Re(r.picks),moves:[],picks:r.picks};let h=ae(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=I(d.kind),v={to:"kind",kind:d.kind,title:l,address:se(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return De()},me=e=>{if(e.kind===null){let h=P.map(l=>({kind:l,count:w.nodesOfKind(l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${(l.count===1?F(M(l.kind),l.kind):I(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${fe(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=I(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(M(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(y.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:oe(e),moves:[],subject:e.id};let t=S.find(s=>s.slug===y.place)??S.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${me(t)}`,moves:[],subject:t.slug}:{about:"here",say:me({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[I(s),F(M(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ie=(e,t)=>{let s=V(p,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(x=>x.key===l):void 0;if(v)return v}return s.find(d=>["due","deadline","date","when","on","at"].includes(d.key.toLowerCase()))??(s.length===1?s[0]:void 0)},He=e=>{let t=M(e),s=V(p,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>ue(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},Ie=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ct.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},ye=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:p,graph:c.graph,flagged:ye,today:k},ae=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ie(L,g)!==void 0),E=m.filter(L=>{let b=ie(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),U=m.length===1?m:E;if(U.length!==1)return;n=U[0]}if(!n)return;let h=V(p,n).filters,d=[],l=[],v=[],x=[],q=!1,de=[];for(let g=0;g<r.length;g++){let m=r[g],E=g>0&&(r[g-1]==="not"||r[g-1]==="un"),U=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(U&&!E){let b=(U.options??[]).find(O=>$(O)===m);d.push({key:U.key,value:b}),l.push(b);continue}let L=h.find(b=>b.about==="field"&&b.type==="boolean"&&[$(b.key),$(b.label)].some(O=>O===m||O===m.replace(/^un/,"")));if(L){let b=!E&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Pt.has(m)&&!E){let b=He(n);b==="unsayable"?(q=!0,x.push(O=>!ut(p,O))):(d.push(...b.conditions),x.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||de.push(m)}if(r=de,r.some(g=>!te.has(g))||!t&&d.length===0&&x.length===0)return;let T=I(n).toLowerCase(),Q=I(n);if(t){let g=ie(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:se(n),said:`Went to the ${T}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=He(n);m==="unsayable"?(q=!0,x.push(E=>!ut(p,E))):(d.push(...m.conditions),x.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(Ie(t.ask,g))}let R=w.nodesOfKind(n).filter(g=>d.every(m=>ue(be,g,m))&&x.every(m=>m(g))),K=[...l,...v].join(" and "),Y=[...l,T,...v].join(" "),W=R.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:H(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:ye.has(g.id),address:ge(g)})),X=R.length===0?`No ${T} are ${K}.`:`${R.length===1?`One ${F(M(n),n)} is`:`${R.length} ${T} are`} ${K}: ${fe(R.slice(0,6).map(H))}${R.length>6?`, and ${R.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:Y,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${se(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(Y),filter:Z,address:we,said:`Went to the ${Y}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Te=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),I(e)].some(s=>$(s).split(" ").some(n=>Et.has(n))),pt=e=>{let t=[],s=n=>M(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])u.has(h)&&t.push({key:n,direction:"out",far:h,words:ct(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:ct(`${h.inverse??""} ${r}`)});return t},mt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[I(a),F(M(a),a),a].map(A=>({kind:a,name:$(A)}))).filter(a=>a.name.length>0).sort((a,A)=>A.name.length-a.name.length),h=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),x=t==="who"?d.find(Te):d[0];if(!x&&t!=="who")return;let q=d.find(a=>a!==x),de=v.flatMap(a=>[je(a),...lt.has(je(a))?[...lt]:[]]),T=P.filter(a=>q?a===q:a!==x).flatMap(a=>{let A=ie(a,e.split(" "))??V(p,a).filters.find(D=>D.about==="field"&&D.type==="date");return A?pt(a).filter(D=>(x?D.far===x:Te(D.far))&&D.far!==a).map(D=>({kind:a,field:A,relation:D,said:v.length===0||de.some(ve=>D.words.some(vt=>Lt(vt,ve)))})):[]}).filter(a=>a.said);if(T.length===0)return;let Q=T.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),R=T.length===1?T[0]:Q.length===1?Q[0]:void 0;if(!R)return;let{kind:K,field:Y,relation:W}=R,X=[...s.ask.from?[{key:Y.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:Y.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>ue(be,a,A))),we=a=>(W.direction==="out"?c.graph.out(a.id,W.key):c.graph.in(a.id,W.key)).filter(A=>A.kind===W.far&&u.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let D of A)_.some(ve=>ve.id===D.id)||_.push(D)}let m=Ie(s.ask,Y),E=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),U=I(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${U} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${se(K)}?${new URLSearchParams({filter:L}).toString()}`,said:`Went to the ${b}.`};if(Z.length===0)return{about:"related",say:`No ${b}. ${O.said}`,moves:[O]};let le=v.join(" "),yt=l==="was"||l==="were",Ge=a=>yt?a===1?"was":"were":a===1?"is":"are",ce=_.map(H),bt=ce.length>8?[...ce.slice(0,8),`${ce.length-8} more`]:ce,kt=_.length===0?`${E}: nobody ${Ge(1)}${le?` ${le}`:""}.`:`${E}: ${fe(bt)}${le?` ${Ge(_.length)} ${le}`:""}.`,$t=t==="who"&&g.length>0?`${fe(g.slice(0,4).map(H))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",wt=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:H(a),why:{field:W.key,reading:Ze(p,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:ye.has(a.id),address:ge(a)}));return{about:"related",say:[kt,$t,O.said].filter(Boolean).join(" "),moves:[O],picks:wt}},Ke=N.match(jt);if(Ke){let e=Ke[1];if(e&&!rt.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=re(e),r=n?void 0:pe(z(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${oe(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Re(r.picks),moves:[],picks:r.picks}:De()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(y.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:oe(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Qe(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(Ot.test(N))return Le();let _e=mt(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!re(z(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=ae(N);if(e)return e}if(/^open /.test(N)){let e=ae(N);if(e)return e}let Fe=N.match(Nt)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Ee(Fe[1].trim(),!1);let Be=N.match(St);if(Be){let e=Ee(Be[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=re(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Ue=ae(N);return Ue||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Et=new Set(["person","people","user","users","member","members","volunteer","volunteers","gardener","gardeners","player","players","staff","worker","workers","employee","employees","owner","owners","assignee","assignees","helper","helpers","student","students","teacher","teachers","customer","customers","client","clients","contact","contacts","author","authors"]),lt=new Set(["work","cover","staff","assign","do","run","schedul","roster","book","duty","serv","help"]);function je(o){let i=o.toLowerCase().replace(/'s$/,"");for(let y of["ing","ed","es","s"])if(i.length>y.length+2&&i.endsWith(y)){let f=i.slice(0,-y.length);return f.length>3&&f[f.length-1]===f[f.length-2]?f.slice(0,-1):f}return i}function ct(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Lt=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Pt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function ut(o,i){return V(o,i.kind).filters.some(f=>f.about==="field"&&(f.type==="boolean"&&ne.has(f.key.toLowerCase())&&i[f.key]===!0||f.type==="choice"&&typeof i[f.key]=="string"&&ne.has(String(i[f.key]).toLowerCase())))}function fe(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function zt(o,i,y={}){let f=y.scene!==void 0?{...y.pages,scene:y.scene}:y.pages;return[...nt(o,i,f?{pages:f}:{})].map(({first:c,hidden:p,lens:k,...j})=>j)}function gt(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function Jt(o,i,y,f){let c=ht(o,i,gt(y,f));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let p=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...p,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...p,told:k.id};let j=k?tt(o,ot(Ve(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...p,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Yt(o,i,y={}){let f=gt(y),c=[];for(let p of i){let k=typeof p=="string"?p:typeof p=="object"&&p!==null&&typeof p.to=="string"?p.to:void 0;if(!k||k.trim().length===0)continue;let j=ht(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,f);if("moves"in j)for(let J of j.moves)c.some(B=>B.address===J.address)||c.push(J)}return c}export{At as NOTHING_BY_THAT_NAME,gt as askContextOf,Jt as goingFrom,Yt as movesFromNames,zt as placesFromViews,ht as resolveAsk};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as Ve}from"./chunk.NKUNCQB3.js";import{c as Be,d as Ie,f as Ge}from"./chunk.CHG522KL.js";import{e as Re,f as Fe,k as Me,l as ne,n as Oe}from"./chunk.IRPMGHZN.js";import{f as Ae}from"./chunk.36FKQJFM.js";import{d as z,e as Ce,k as te}from"./chunk.YIDNZTON.js";import{a as je,d as Pe}from"./chunk.QILGAV7H.js";import{Ac as ye,C as J,L as ce,Md as ke,cd as we,ea as de,ed as be,ee as xe,gc as he,gd as $e,ha as U,ia as ue,la as H,ma as W,na as me,oa as Q,oe as Se,pa as pe,rd as Z,sa as fe,sd as ve,ta as ge,va as _,xe as De,zc as ee}from"./chunk.IUVRJDL3.js";function Ye(t,e,n){let o=t.tryDefinition(e)?.fields.shape,r=J(o?.[n]),a=!1,s=!1;for(;r&&(r.type==="optional"||r.type==="default"||r.type==="nullable"||r.type==="prefault");)(r.type==="optional"||r.type==="nullable")&&(a=!0),(r.type==="default"||r.type==="prefault")&&(s=!0),r=J(r.innerType);if(r?.type!=="enum")return;let p=(r.entries?Object.values(r.entries):r.values??[]).filter(m=>typeof m=="string");return p.length>0?{values:p,empty:a&&!s}:void 0}function E(t,e,n){let o=Ye(t,e,n);if(!o)return[];let r=t.tryDefinition(e),a=o.values.map(s=>({value:s,label:je(r,n,s)}));return o.empty&&a.push({value:null,label:`No ${ge(r,n)}`}),a}function q(t,e,n){let o=t[e];return typeof o=="string"&&n.some(r=>r.value===o)?o:null}function re(t,e,n,o,r=E(t.schema,n.kind,o)){return Ne(t,e,n,o,r).flatMap(a=>a.move?[a.move]:[])}function Ne(t,e,n,o,r=E(t.schema,n.kind,o)){let a=Ke(t.schema,t.allMutations(),n.kind,o,r),s=q(n,o,r),p=_(t.schema.tryDefinition(n.kind),n.kind),m=[];for(let{value:A,label:C,by:R,acts:F}of a){if(A===s)continue;let x,G,V;for(let c of F){let w=R==="step"?{[c.subject.arg]:n.id}:{[c.subject.arg]:n.id,[o]:A},S={name:c.name,args:w};if(!c.input.safeParse(w).success){V??=`${c.title??c.name} asks for more than the ${p} itself.`;continue}let k=t.permits(S,e);if(!k.ok){G??=k.refusal?.message??`You may not ${c.title??c.name}.`;continue}try{he(t.graph,c,w)}catch(f){G??=f instanceof Error?f.message:String(f);continue}x={to:A,call:S,title:c.title??c.name};break}m.push(x?{to:A,label:C,move:x}:{to:A,label:C,why:G??V??`Nothing in this app moves a ${p} to ${C}.`})}return m}function Ke(t,e,n,o,r=E(t,n,o)){let a=Te(t,e,n,o),s=We(t,e,n,o);return r.flatMap(p=>{if(p.value===null)return[];let m=a.filter(A=>A.sets?.[o]===p.value);return[{value:p.value,label:p.label,by:m.length>0?"step":s.length>0?"value":"none",acts:m.length>0?m:s}]})}function Te(t,e,n,o){return e.filter(r=>r.subject!==void 0&&r.derived===void 0&&typeof r.sets?.[o]=="string"&&ee(t,r).includes(n))}function We(t,e,n,o){let r=t.tryDefinition(n);return r?e.filter(a=>{if(!a.subject||!ee(t,a).includes(n)||!ye(a,r).includes(o))return!1;let s=a.input.shape;return s!==void 0&&o in s}).sort((a,s)=>+(a.derived!==void 0)-+(s.derived!==void 0)):[]}var se=(t,e)=>e&&t[e]!==void 0?String(t[e]):"";function Je(t,e,n){let o=c=>t.tryDefinition(c)?e.nodesOfKind(c).filter(w=>H(t.tryDefinition(c),w)):[],r=o(n.rows),a=o(n.columns),s=new Set(r.map(c=>c.id)),p=new Set(a.map(c=>c.id)),m=e.allEdges(),A=[],C=n.link;if(typeof C=="string"){let c=f=>t.tryDefinition(f)?.edges?.[C]?.to,w=(c(n.columns)??[]).some(f=>f===n.rows||f==="*"),S=(c(n.rows)??[]).some(f=>f===n.columns||f==="*"),k=w||!S;for(let f of m){if(f.kind!==C)continue;let j=k?f.to:f.from,i=k?f.from:f.to;s.has(j)&&p.has(i)&&A.push({rowId:j,columnId:i,via:[]})}}else{let c=new Map(C.path.map(S=>[S,new Map]));for(let S of m){let k=c.get(S.kind);if(!k)continue;let f=k.get(S.from);f?f.push(S.to):k.set(S.from,[S.to]);let j=k.get(S.to);j?j.push(S.from):k.set(S.to,[S.from])}let w=new Set;for(let S of a){let k=[{id:S.id,via:[]}];for(let f of C.path){let j=[],i=new Set;for(let v of k)for(let b of c.get(f).get(v.id)??[])i.has(`${v.id}|${b}`)||(i.add(`${v.id}|${b}`),j.push({id:b,via:[...v.via,v.id]}));k=j}for(let f of k){let j=`${f.id}|${S.id}`;!s.has(f.id)||w.has(j)||(w.add(j),A.push({rowId:f.id,columnId:S.id,via:f.via.slice(1)}))}}}let R=n.groupOrder??[],F=c=>R.indexOf(c)===-1?R.length:R.indexOf(c),x=(c,w)=>w==="label"?W(t.tryDefinition(c.kind),c):c[w],G=Z(r,n.sort,x).map(c=>{let w=c;return{node:c,label:W(t.tryDefinition(c.kind),c),group:se(w,n.rowGroup),ref:se(w,n.rowRef)}}).sort((c,w)=>F(c.group)-F(w.group)||(n.sort!==void 0?0:c.ref<w.ref?-1:c.ref>w.ref?1:0)),V=Z(a,n.columnSort,x).map(c=>({node:c,label:W(t.tryDefinition(c.kind),c),group:se(c,n.columnGroup)})).sort((c,w)=>c.group<w.group?-1:c.group>w.group?1:n.columnSort!==void 0?0:c.node.id<w.node.id?-1:c.node.id>w.node.id?1:0);return{rows:G,columns:V,cells:A}}function He(t,e,n){let{rows:o,columns:r,cells:a}=Je(t,e,n),s=(i,v)=>Q(t,i,v),p=i=>Q(t,i,1).replace(/^1 /,""),m=i=>({id:i.id,kind:i.kind,title:W(t.tryDefinition(i.kind),i),parts:[]}),A=i=>{let v=e.getNode(i);if(!v)return null;let b=t.tryDefinition(v.kind),P=W(b,v),N=z(v,b,{limit:3,said:[P],glance:!0}).map(K=>K.alone.startsWith(K.label)?`${K.label.toLowerCase()}${K.alone.slice(K.label.length)}`:K.alone);return[P,...N].join(", ")},C=typeof n.link=="string"?[]:n.link.path.slice(0,-1).flatMap((i,v,b)=>{let P=ke(t,n.columns,b.slice(0,v+1));return P.ok?[...P.reached]:[]}),R=ve(t,n,{rows:o.length,columns:r.length,cells:a.length});if(R)return[{t:"text",text:`${s(n.rows,o.length)} against ${s(n.columns,r.length)}.`},{t:"text",text:R}];let F=[{t:"text",text:`${s(n.rows,o.length)} against ${s(n.columns,r.length)}${C.length>0?`, through ${[...new Set(C)].map(i=>s(i,2).replace(/^2 /,"")).join(" and ")}`:""}${r.length>0?`: ${r.map(i=>i.label).join(", ")}`:""}.`}],x=new Map(r.map(i=>[i.node.id,i.label])),G=new Map(r.map((i,v)=>[i.node.id,v])),V=new Map,c=new Map;for(let i of a){let v=V.get(i.rowId);v?v.push(i):V.set(i.rowId,[i]);let b=c.get(i.columnId);b?b.add(i.rowId):c.set(i.columnId,new Set([i.rowId]))}for(let i of o){let b=[...V.get(i.node.id)??[]].sort((P,N)=>G.get(P.columnId)-G.get(N.columnId)).map(P=>{let N=P.via.map(A).filter(K=>K!==null);return`${x.get(P.columnId)}${N.length>0?` (${N.join("; ")})`:""}`});F.push({t:"field",label:i.label,text:b.length>0?b.join(", "):"none"})}F.push({t:"list",as:"name",columns:1,groups:r.map(i=>{let v=c.get(i.node.id)??new Set,b=o.filter(P=>v.has(P.node.id)).map(P=>m(P.node));return{heading:`${i.label} (${b.length})`,items:b}})});let w=new Set(a.map(i=>i.rowId)),S=new Set(a.map(i=>i.columnId)),k=o.filter(i=>!w.has(i.node.id)),f=r.filter(i=>!S.has(i.node.id)),j=n.rows===n.columns;return k.length>0&&F.push({t:"text",text:`${j?`${k.length} with none across`:`${s(n.rows,k.length)} with no ${p(n.columns)}`}: ${k.map(i=>i.label).join(", ")}.`}),f.length>0&&F.push({t:"text",text:`${j?`${f.length} with none down`:`${s(n.columns,f.length)} on no ${p(n.rows)}`}: ${f.map(i=>i.label).join(", ")}.`}),F}function oe(t,e,n,o={}){let{app:r,blocks:a=n?r?.viewSpecs?.[n.kind]?.[o.slot??"page"]:r?.home}=o;if(!a?.length)return[];let s=o.firstHeading??(n||o.blocks?void 0:1),p=Oe(t,e,n,{...o,money:o.money??r?.brand,firstHeading:s});return n&&!p.node?[]:Fe(typeof a[0]?.t=="string"?a:Re(a),p)}function X(t,e,n){let o=!(e.optional||e.control==="boolean"),r=e.control==="node"&&!e.kinds.includes("*")?e.kinds.map(s=>U(_(t.tryDefinition(s),s))).join(" or "):n(e.name).label,a={name:e.name,label:r,required:o};switch(e.control){case"text":return{...a,input:e.holds==="duration"?"length of time":e.holds??(e.markdown?"Markdown text":e.long?"long text":e.app?"app address":"text")};case"date":return{...a,input:e.time||e.instant?"date and time":"date"};case"number":return{...a,input:e.amount?"amount":"number",...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max}};case"choice":return{...a,input:"choice",choices:(e.options??[]).map(s=>n(e.name).option(s))};case"boolean":return{...a,input:"yes or no"};case"node":return{...a,input:"record",kinds:e.kinds};case"linked":return{...a,input:"record in another app"};case"file":return{...a,input:e.image?"picture":e.video?"video":"file"};case"repeat":return{...a,input:"how it repeats"};case"list":return{...a,input:`list of ${X(t,e.item,n).input}`};case"group":return{...a,input:"group",fields:e.fields.map(s=>X(t,s,n))};case"variant":return{...a,input:"one of",choices:e.options.map(s=>ue(s.value))};default:return{...a,input:"answer"}}}function Ee(t,e,n){let o=Ie(t,e,n),r=t.schema,a=Be(r,n).filter(p=>p.name!==n.subject?.arg&&!o.has(p.name)),s=me(n);return{act:n.name,title:s,submit:s,fields:a.map(p=>X(r,p,m=>te(r,n,m)))}}function Le(t,e){return{act:e.act.name,title:e.title,submit:e.submit,visitor:e.name,fields:e.fields.map(n=>X(t,n,o=>te(t,e.act,o)))}}function Ze(t,e,n){return t.permittedMutations(e).filter(o=>!o.derived&&!o.subject&&(o.creates??[]).includes(n))}function ze(t,e=""){let n=[`${e}Form "${t.title}" (${t.visitor?`the visitor form ${t.visitor}, running `:""}act ${t.act}), button "${t.submit}":`],o=(r,a)=>{for(let s of r){let p=s.choices?`${s.input}: ${s.choices.join(", ")}`:s.kinds?`${s.input} (${s.kinds.join(" or ")})`:s.input,m=s.min!==void 0||s.max!==void 0?`, ${s.min??"\u2026"} to ${s.max??"\u2026"}`:"";n.push(`${a}- ${s.label}${s.required?" *":""} (${s.name}) \u2014 ${p}${m}`),s.fields&&o(s.fields,`${a} `)}};return o(t.fields,`${e} `),t.fields.length===0&&n.push(`${e} (asks nothing)`),n}function _e(t,e){let n=t.viewSpecs??{};return e.filter(o=>o.cardinality==="one"&&o.replaces==="page"&&(n[o.attach]?.page?.length??0)>0).map(o=>{let r=L(t.schema,o.attach,1);return{at:`views.${o.attach}.page`,says:`The view "${o.name}" replaces ${Qe(r)}'s page, so its page slot is never drawn: leave out replaces to draw the slot under the view, or draw what the slot says in the view.`}})}var Qe=t=>`${/^[aeiou]/i.test(t)?"an":"a"} ${t}`,et=240,Ue=10,tt=1160,nt=40,qe=640,rt=3,st=t=>Math.max(1,Math.floor((Math.min(t,tt)-nt+Ue)/(et+Ue)));function ot(t,e,n,o){let{app:r}=o,a=o.width??1440,s=o.today??t.today()??ce(r.brand?.timeZone),p=t.seenBy(e),m=p.schema,A=p.graph,C=Ve(r,o.views?{views:o.views}:{}),R=typeof n=="string"?n.trim():n.slug,F=typeof n=="string"?C.find(l=>l.slug===R||l.title===R||l.address===R):C.find(l=>l.slug===n.slug&&l.kind===n.kind)??n,x=!F&&typeof n=="string"?A.getNode(R):void 0,G=!F&&!x?/^\/?forms\/(.+)$/.exec(R)?.[1]:void 0,V=G!==void 0?Ge(r,G):void 0;if(V)return{ok:!0,description:it(m,V,a)};if(!F&&!x)return{ok:!1,error:`"${R}" is not a place this app has, nor a record this seat can see.`,places:[...C.map(l=>l.slug),...Object.keys(r.forms??{}).map(l=>`forms/${l}`)]};let c=[],w=r.viewSpecs??{},S=st(a),k=(l,h)=>oe(p,null,l,{app:r,today:s,...h}),f=(l,h,M)=>{let d=m.tryDefinition(l.kind),g=W(d,l);if(h==="name")return{id:l.id,kind:l.kind,title:g,parts:[]};if(w[l.kind]?.[h]){let I=k(l,{slot:h}),[B,...O]=I,y=B?.t==="title"||h==="row"&&B?.t==="headline";return{id:l.id,kind:l.kind,title:y?B.text:g,parts:j(y?O:I,M,`views.${l.kind}.${h}`,` (${l.id})`,y?1:0)}}if(h==="row")return{id:l.id,kind:l.kind,title:g,parts:[]};let u=d?.computed?ne(m,A,l):l,T=z(u,d,{limit:3,said:[g],glance:!0,locale:r.brand?.locale,timeZone:r.brand?.timeZone});return{id:l.id,kind:l.kind,title:g,parts:T.map(I=>({t:"text",text:I.alone}))}};function j(l,h,M,d="",g=0){let $=[];return l.forEach((u,T)=>{let I=`${M}.${T+g}`;switch("problem"in u&&u.problem&&c.push({at:`${I}${d}`,says:u.problem}),u.t){case"title":$.push({t:"heading",level:3,text:u.text});return;case"text":$.push({t:"text",text:u.markdown?Pe(u.text):u.runs?ct(u.runs):u.text,...u.tone?{tone:u.tone}:{}});return;case"badge":$.push({t:"badge",text:u.text});return;case"field":case"image":$.push({t:"field",label:u.label,text:u.text});return;case"progress":$.push({t:"progress",label:u.label,text:u.text});return;case"group":$.push(...j(u.blocks,h,`${I}.group`,d));return;case"when":$.push(...j(u.blocks,h,`${I}.show`,d));return;case"divider":case"figure":return;case"headline":$.push({t:"heading",level:u.level,text:u.text});return;case"number":$.push({t:"figure",text:u.text,...u.label?{label:u.label}:{}});return;case"list":{if(u.failed){$.push({t:"text",text:"\u2014"});return}if(u.members.length===0){u.empty&&$.push({t:"list",as:u.as,columns:1,groups:[],empty:u.empty});return}let B=h+1,O=B>rt?"name":u.as,y=(u.groups??[{value:null,members:u.members}]).map(D=>({..."heading"in D&&D.heading?{heading:D.heading,count:(u.everyGroup?.find(Y=>Y.value===D.value)??D).members.length}:{},items:D.members.map(Y=>f(Y,O,B))}));$.push({t:"list",as:O,columns:O==="card"?S:1,groups:y,...u.more>0?{more:u.more}:{}});return}}}),$}let i=[],v,b,P,N=[];if(x){b="record";let l=m.tryDefinition(x.kind),h=W(l,x);P={slug:x.id,title:h,kind:x.kind,address:xe(m,x.kind,x.id)};let M=w[x.kind]?.page,d=o.views?.find(g=>g.attach===x.kind&&g.cardinality==="one");if(d&&i.push({t:"view",name:d.name,...d.title?{title:d.title}:{},...d.replaces==="page"?{replaces:!0}:{},...d.parts?{parts:d.parts}:{}}),d?.replaces==="page")b=`view:${d.name}`,c.push(..._e(r,[d]));else{M&&i.push(...j(k(x,{slot:"page"}),1,`views.${x.kind}.page`));let g=l?.computed?ne(m,A,x):x;for(let $ of Ce(l,z(g,l,{said:[h],locale:r.brand?.locale,timeZone:r.brand?.timeZone}))){$.title&&i.push({t:"heading",level:2,text:$.title});for(let u of $.fields)i.push({t:"field",label:u.label,text:u.value,...u.long?{long:!0}:{},...u.markdown?{markdown:!0}:{}})}}}else{let l=F;P={slug:l.slug,title:l.title,kind:l.kind,address:l.address};let h=l.lens?Se(r).drawn.find(d=>d.as===l.slug&&(l.kind===null||d.kinds.includes(l.kind))):void 0,M=l.kind!==null&&l.view===void 0&&!h?o.views?.find(d=>d.attach===l.kind&&d.cardinality==="many"&&d.replaces==="page"&&!d.hidden):void 0;if(l.kind!==null&&h?.create!==!1&&l.view===void 0&&!M&&(N=Ze(t,e,l.kind).map(d=>Ee(t,e,d))),l.view!==void 0&&!h){let d=o.views?.find(g=>g.name===l.view);b=`view:${l.view}`,i.push({t:"view",name:l.view,title:d?.title??l.title,...typeof d?.flows=="boolean"?{flows:d.flows}:{},...d?.parts?{parts:d.parts}:{}})}else if(l.kind===null){let d=r.brand,g=d?.name??r.name,$=$e(d)?.light,u=$&&be($)?$:void 0;if(v={name:g,...d?.subtitle&&d.subtitleDrawn!==!1?{subtitle:d.subtitle}:{},...u?{logo:{alt:d?.logoAlt??g,...we(u)?{drawn:"inline SVG"}:{drawn:"image",src:u}}}:{}},r.home)b="blocks",i=j(k(null,{}),0,"views.home");else{b="derived";let T=t.kindsKeptFrom(e),I=new Set([...r.pages?.hide??[],...T,...t.modules.disabledKinds]),B=De(m.kinds,r.pages?.order).filter(O=>!I.has(O));i.push({t:"heading",level:1,text:r.name??"Home"});for(let O of B){let y=A.nodesOfKind(O).filter(D=>H(m.tryDefinition(O),D)).length;y>0&&i.push({t:"text",text:`${y} ${L(m,O,y)}`})}}}else if(h?.lens==="blocks")b="lens:blocks",i=j(k(null,{blocks:h.options.blocks??[]}),0,`lenses.${h.index}.options.blocks`);else if(h?.lens==="columns"){b="lens:columns";let d=h.options.bindings??{};for(let g of Object.keys(d)){let $=d[g]?.column;if(!$)continue;let u=E(m,g,$),T=Z(A.nodesOfKind(g).filter(y=>H(m.tryDefinition(g),y)),h.options.sort,(y,D)=>D==="label"?W(m.tryDefinition(y.kind),y):y[D]);Object.keys(d).length>1&&i.push({t:"heading",level:2,text:L(m,g,2).replace(/^./,y=>y.toUpperCase())}),i.push({t:"text",text:`${T.length} ${L(m,g,T.length)} in columns by ${fe(m.tryDefinition(g),$).toLowerCase()}.`});let I=u.map(y=>({column:y,items:T.filter(D=>q(D,$,u)===y.value).map(D=>f(D,"card",1))})).filter(({column:y,items:D})=>y.value!==null||D.length>0).map(({column:y,items:D})=>({heading:`${y.label} (${D.length})`,items:D}));i.push({t:"list",as:"card",columns:1,groups:I});let B=new Map;for(let y of T)for(let D of re(t,e,y,$,u))B.set(D.to,(B.get(D.to)??new Set).add(`"${D.title}"`));let O=u.filter(y=>y.value!==null&&B.has(y.value)).map(y=>`to ${y.label} by ${[...B.get(y.value)].join(" or ")}`);i.push({t:"text",text:O.length>0?`Moves: ${O.join("; ")}.`:"Moves: none for this seat."})}}else if(h?.lens==="coverage")b="lens:coverage",i=He(m,A,h.options);else if(h){b=`lens:${h.lens}`;let d=h.kinds.flatMap(g=>A.nodesOfKind(g).filter($=>H(m.tryDefinition(g),$)));i.push({t:"text",text:`A ${h.lens} of ${d.length} ${h.kinds.map(g=>L(m,g,d.length)).join(" and ")}.`}),i.push({t:"list",as:"name",columns:1,groups:[{items:d.map(g=>f(g,"name",1))}]})}else if(M)b=`view:${M.name}`,i.push({t:"heading",level:1,text:l.title}),i.push({t:"view",name:M.name,...M.title?{title:M.title}:{},replaces:!0,...M.parts?{parts:M.parts}:{}});else{b="derived";let d=A.nodesOfKind(l.kind).filter(g=>H(m.tryDefinition(l.kind),g));i.push({t:"heading",level:1,text:l.title}),d.length===0?i.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${L(m,l.kind,0)} yet.`}):i.push({t:"list",as:"row",columns:1,groups:[{items:d.map(g=>f(g,"row",1))}]})}}let K=e.kind==="system"?"the system":(e.roles??[]).length>0?(e.roles??[]).join(", "):e.kind,Xe=a<qe?"phone":"wide",ae=P.kind===null?at(m,A):[],le={...v?{masthead:v}:{},...ae.length>0?{facts:ae}:{},place:P,seat:K,width:a,variant:Xe,drawnBy:b,parts:i,...N.length>0?{forms:N}:{},problems:c};return{ok:!0,description:{...le,text:ie(le)}}}function it(t,e,n){let o=[{t:"heading",level:1,text:e.title},...e.intro?[{t:"text",text:e.intro}]:[]],r={place:{slug:`forms/${e.name}`,title:e.title,kind:null,address:`/forms/${e.name}`},seat:`a visitor (${e.role})`,width:n,variant:n<qe?"phone":"wide",drawnBy:"form",parts:o,forms:[Le(t,e)],problems:[]};return{...r,text:ie(r)}}function at(t,e){let n=Me(t,e,null),o=r=>Array.isArray(r)?r.map(o).join(", "):r===null?"nothing":typeof r=="boolean"?r?"yes":"no":typeof r=="object"?r.label:String(r);return[...Ae(t)].map(([r,a])=>{let s=a.label??U(r);return Object.hasOwn(n.values,r)?{name:r,label:s,value:o(n.values[r])}:{name:r,label:s,refused:n.refused[r]??"it could not be worked out"}})}function L(t,e,n){let o=t.tryDefinition(e);if(n===1)return o?.noun??e;let r=pe(t,e);return de(r)}function ie(t){let e=[`${t.place.title} (${t.place.address}) \u2014 as ${t.seat}, ${t.width} wide (${t.variant}).`],n=t.masthead;n&&e.push(`Masthead: ${n.logo?`the logo ("${n.logo.alt}", ${n.logo.drawn==="image"?n.logo.src:"inline SVG"}), `:""}${n.name}${n.subtitle?` \u2014 ${n.subtitle}`:""}`);let o=(r,a)=>{for(let s of r)switch(s.t){case"heading":e.push(`${a}${"#".repeat(s.level)} ${s.text}`);break;case"text":e.push(`${a}${s.text}`);break;case"badge":e.push(`${a}[${s.text}]`);break;case"field":case"progress":e.push(`${a}${s.label}: ${s.text}`);break;case"figure":e.push(`${a}${s.text}${s.label?` \u2014 ${s.label}`:""}`);break;case"list":if(s.groups.length===0){s.empty&&e.push(`${a}(${s.empty})`);break}for(let p of s.groups){p.heading&&e.push(`${a}${p.heading}${p.count!==void 0?` (${p.count})`:""}:`);for(let m of p.items)e.push(`${a}${p.heading?" ":""}- ${m.title}`),o(m.parts,`${a}${p.heading?" ":" "}`)}s.as==="card"&&s.columns>1&&e.push(`${a}(cards, ${s.columns} across)`),s.more&&e.push(`${a}and ${s.more} more`);break;case"view":e.push(`${a}[the view "${s.title??s.name}"${s.replaces?", in place of the page":""}${s.flows===!0?", flowing with the page":s.flows===!1?", in a frame of its own":""}]`),s.parts&&o(s.parts,`${a} `);break}};o(t.parts,"");for(let r of t.forms??[])e.push(...ze(r));if(t.facts){e.push("Facts of the whole graph (what fact('<name>') reads):");for(let r of t.facts)e.push(`- ${r.label} (${r.name}): ${r.value??`not worked out \u2014 ${r.refused}`}`)}if(t.videos&&t.videos.length>0){e.push("Videos:");for(let r of t.videos)e.push(`- ${lt(r)}`)}if(t.problems.length>0){e.push("Problems:");for(let r of t.problems)e.push(`- ${r.at}: ${r.says}`)}return e.join(`
|
|
1
|
+
import{b as Ve}from"./chunk.7KX36ENH.js";import{c as Be,d as Ie,f as Ge}from"./chunk.KBJ3UUER.js";import{e as Re,f as Fe,k as Me,l as ne,n as Oe}from"./chunk.NI4OPHTL.js";import{f as Ae}from"./chunk.W6L2VAJG.js";import{d as z,e as Ce,k as te}from"./chunk.VVIQSFM4.js";import{a as je,d as Pe}from"./chunk.TQ3MNB6K.js";import{Ac as ye,C as J,L as ce,Md as ke,cd as we,ea as de,ed as be,ee as xe,gc as he,gd as $e,ha as U,ia as ue,la as H,ma as W,na as me,oa as Q,oe as Se,pa as pe,rd as Z,sa as fe,sd as ve,ta as ge,va as _,xe as De,zc as ee}from"./chunk.6L6RUOSF.js";function Ye(t,e,n){let o=t.tryDefinition(e)?.fields.shape,r=J(o?.[n]),a=!1,s=!1;for(;r&&(r.type==="optional"||r.type==="default"||r.type==="nullable"||r.type==="prefault");)(r.type==="optional"||r.type==="nullable")&&(a=!0),(r.type==="default"||r.type==="prefault")&&(s=!0),r=J(r.innerType);if(r?.type!=="enum")return;let p=(r.entries?Object.values(r.entries):r.values??[]).filter(m=>typeof m=="string");return p.length>0?{values:p,empty:a&&!s}:void 0}function E(t,e,n){let o=Ye(t,e,n);if(!o)return[];let r=t.tryDefinition(e),a=o.values.map(s=>({value:s,label:je(r,n,s)}));return o.empty&&a.push({value:null,label:`No ${ge(r,n)}`}),a}function q(t,e,n){let o=t[e];return typeof o=="string"&&n.some(r=>r.value===o)?o:null}function re(t,e,n,o,r=E(t.schema,n.kind,o)){return Ne(t,e,n,o,r).flatMap(a=>a.move?[a.move]:[])}function Ne(t,e,n,o,r=E(t.schema,n.kind,o)){let a=Ke(t.schema,t.allMutations(),n.kind,o,r),s=q(n,o,r),p=_(t.schema.tryDefinition(n.kind),n.kind),m=[];for(let{value:A,label:C,by:R,acts:F}of a){if(A===s)continue;let x,G,V;for(let c of F){let w=R==="step"?{[c.subject.arg]:n.id}:{[c.subject.arg]:n.id,[o]:A},S={name:c.name,args:w};if(!c.input.safeParse(w).success){V??=`${c.title??c.name} asks for more than the ${p} itself.`;continue}let k=t.permits(S,e);if(!k.ok){G??=k.refusal?.message??`You may not ${c.title??c.name}.`;continue}try{he(t.graph,c,w)}catch(f){G??=f instanceof Error?f.message:String(f);continue}x={to:A,call:S,title:c.title??c.name};break}m.push(x?{to:A,label:C,move:x}:{to:A,label:C,why:G??V??`Nothing in this app moves a ${p} to ${C}.`})}return m}function Ke(t,e,n,o,r=E(t,n,o)){let a=Te(t,e,n,o),s=We(t,e,n,o);return r.flatMap(p=>{if(p.value===null)return[];let m=a.filter(A=>A.sets?.[o]===p.value);return[{value:p.value,label:p.label,by:m.length>0?"step":s.length>0?"value":"none",acts:m.length>0?m:s}]})}function Te(t,e,n,o){return e.filter(r=>r.subject!==void 0&&r.derived===void 0&&typeof r.sets?.[o]=="string"&&ee(t,r).includes(n))}function We(t,e,n,o){let r=t.tryDefinition(n);return r?e.filter(a=>{if(!a.subject||!ee(t,a).includes(n)||!ye(a,r).includes(o))return!1;let s=a.input.shape;return s!==void 0&&o in s}).sort((a,s)=>+(a.derived!==void 0)-+(s.derived!==void 0)):[]}var se=(t,e)=>e&&t[e]!==void 0?String(t[e]):"";function Je(t,e,n){let o=c=>t.tryDefinition(c)?e.nodesOfKind(c).filter(w=>H(t.tryDefinition(c),w)):[],r=o(n.rows),a=o(n.columns),s=new Set(r.map(c=>c.id)),p=new Set(a.map(c=>c.id)),m=e.allEdges(),A=[],C=n.link;if(typeof C=="string"){let c=f=>t.tryDefinition(f)?.edges?.[C]?.to,w=(c(n.columns)??[]).some(f=>f===n.rows||f==="*"),S=(c(n.rows)??[]).some(f=>f===n.columns||f==="*"),k=w||!S;for(let f of m){if(f.kind!==C)continue;let j=k?f.to:f.from,i=k?f.from:f.to;s.has(j)&&p.has(i)&&A.push({rowId:j,columnId:i,via:[]})}}else{let c=new Map(C.path.map(S=>[S,new Map]));for(let S of m){let k=c.get(S.kind);if(!k)continue;let f=k.get(S.from);f?f.push(S.to):k.set(S.from,[S.to]);let j=k.get(S.to);j?j.push(S.from):k.set(S.to,[S.from])}let w=new Set;for(let S of a){let k=[{id:S.id,via:[]}];for(let f of C.path){let j=[],i=new Set;for(let v of k)for(let b of c.get(f).get(v.id)??[])i.has(`${v.id}|${b}`)||(i.add(`${v.id}|${b}`),j.push({id:b,via:[...v.via,v.id]}));k=j}for(let f of k){let j=`${f.id}|${S.id}`;!s.has(f.id)||w.has(j)||(w.add(j),A.push({rowId:f.id,columnId:S.id,via:f.via.slice(1)}))}}}let R=n.groupOrder??[],F=c=>R.indexOf(c)===-1?R.length:R.indexOf(c),x=(c,w)=>w==="label"?W(t.tryDefinition(c.kind),c):c[w],G=Z(r,n.sort,x).map(c=>{let w=c;return{node:c,label:W(t.tryDefinition(c.kind),c),group:se(w,n.rowGroup),ref:se(w,n.rowRef)}}).sort((c,w)=>F(c.group)-F(w.group)||(n.sort!==void 0?0:c.ref<w.ref?-1:c.ref>w.ref?1:0)),V=Z(a,n.columnSort,x).map(c=>({node:c,label:W(t.tryDefinition(c.kind),c),group:se(c,n.columnGroup)})).sort((c,w)=>c.group<w.group?-1:c.group>w.group?1:n.columnSort!==void 0?0:c.node.id<w.node.id?-1:c.node.id>w.node.id?1:0);return{rows:G,columns:V,cells:A}}function He(t,e,n){let{rows:o,columns:r,cells:a}=Je(t,e,n),s=(i,v)=>Q(t,i,v),p=i=>Q(t,i,1).replace(/^1 /,""),m=i=>({id:i.id,kind:i.kind,title:W(t.tryDefinition(i.kind),i),parts:[]}),A=i=>{let v=e.getNode(i);if(!v)return null;let b=t.tryDefinition(v.kind),P=W(b,v),N=z(v,b,{limit:3,said:[P],glance:!0}).map(K=>K.alone.startsWith(K.label)?`${K.label.toLowerCase()}${K.alone.slice(K.label.length)}`:K.alone);return[P,...N].join(", ")},C=typeof n.link=="string"?[]:n.link.path.slice(0,-1).flatMap((i,v,b)=>{let P=ke(t,n.columns,b.slice(0,v+1));return P.ok?[...P.reached]:[]}),R=ve(t,n,{rows:o.length,columns:r.length,cells:a.length});if(R)return[{t:"text",text:`${s(n.rows,o.length)} against ${s(n.columns,r.length)}.`},{t:"text",text:R}];let F=[{t:"text",text:`${s(n.rows,o.length)} against ${s(n.columns,r.length)}${C.length>0?`, through ${[...new Set(C)].map(i=>s(i,2).replace(/^2 /,"")).join(" and ")}`:""}${r.length>0?`: ${r.map(i=>i.label).join(", ")}`:""}.`}],x=new Map(r.map(i=>[i.node.id,i.label])),G=new Map(r.map((i,v)=>[i.node.id,v])),V=new Map,c=new Map;for(let i of a){let v=V.get(i.rowId);v?v.push(i):V.set(i.rowId,[i]);let b=c.get(i.columnId);b?b.add(i.rowId):c.set(i.columnId,new Set([i.rowId]))}for(let i of o){let b=[...V.get(i.node.id)??[]].sort((P,N)=>G.get(P.columnId)-G.get(N.columnId)).map(P=>{let N=P.via.map(A).filter(K=>K!==null);return`${x.get(P.columnId)}${N.length>0?` (${N.join("; ")})`:""}`});F.push({t:"field",label:i.label,text:b.length>0?b.join(", "):"none"})}F.push({t:"list",as:"name",columns:1,groups:r.map(i=>{let v=c.get(i.node.id)??new Set,b=o.filter(P=>v.has(P.node.id)).map(P=>m(P.node));return{heading:`${i.label} (${b.length})`,items:b}})});let w=new Set(a.map(i=>i.rowId)),S=new Set(a.map(i=>i.columnId)),k=o.filter(i=>!w.has(i.node.id)),f=r.filter(i=>!S.has(i.node.id)),j=n.rows===n.columns;return k.length>0&&F.push({t:"text",text:`${j?`${k.length} with none across`:`${s(n.rows,k.length)} with no ${p(n.columns)}`}: ${k.map(i=>i.label).join(", ")}.`}),f.length>0&&F.push({t:"text",text:`${j?`${f.length} with none down`:`${s(n.columns,f.length)} on no ${p(n.rows)}`}: ${f.map(i=>i.label).join(", ")}.`}),F}function oe(t,e,n,o={}){let{app:r,blocks:a=n?r?.viewSpecs?.[n.kind]?.[o.slot??"page"]:r?.home}=o;if(!a?.length)return[];let s=o.firstHeading??(n||o.blocks?void 0:1),p=Oe(t,e,n,{...o,money:o.money??r?.brand,firstHeading:s});return n&&!p.node?[]:Fe(typeof a[0]?.t=="string"?a:Re(a),p)}function X(t,e,n){let o=!(e.optional||e.control==="boolean"),r=e.control==="node"&&!e.kinds.includes("*")?e.kinds.map(s=>U(_(t.tryDefinition(s),s))).join(" or "):n(e.name).label,a={name:e.name,label:r,required:o};switch(e.control){case"text":return{...a,input:e.holds==="duration"?"length of time":e.holds??(e.markdown?"Markdown text":e.long?"long text":e.app?"app address":"text")};case"date":return{...a,input:e.time||e.instant?"date and time":"date"};case"number":return{...a,input:e.amount?"amount":"number",...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max}};case"choice":return{...a,input:"choice",choices:(e.options??[]).map(s=>n(e.name).option(s))};case"boolean":return{...a,input:"yes or no"};case"node":return{...a,input:"record",kinds:e.kinds};case"linked":return{...a,input:"record in another app"};case"file":return{...a,input:e.image?"picture":e.video?"video":"file"};case"repeat":return{...a,input:"how it repeats"};case"list":return{...a,input:`list of ${X(t,e.item,n).input}`};case"group":return{...a,input:"group",fields:e.fields.map(s=>X(t,s,n))};case"variant":return{...a,input:"one of",choices:e.options.map(s=>ue(s.value))};default:return{...a,input:"answer"}}}function Ee(t,e,n){let o=Ie(t,e,n),r=t.schema,a=Be(r,n).filter(p=>p.name!==n.subject?.arg&&!o.has(p.name)),s=me(n);return{act:n.name,title:s,submit:s,fields:a.map(p=>X(r,p,m=>te(r,n,m)))}}function Le(t,e){return{act:e.act.name,title:e.title,submit:e.submit,visitor:e.name,fields:e.fields.map(n=>X(t,n,o=>te(t,e.act,o)))}}function Ze(t,e,n){return t.permittedMutations(e).filter(o=>!o.derived&&!o.subject&&(o.creates??[]).includes(n))}function ze(t,e=""){let n=[`${e}Form "${t.title}" (${t.visitor?`the visitor form ${t.visitor}, running `:""}act ${t.act}), button "${t.submit}":`],o=(r,a)=>{for(let s of r){let p=s.choices?`${s.input}: ${s.choices.join(", ")}`:s.kinds?`${s.input} (${s.kinds.join(" or ")})`:s.input,m=s.min!==void 0||s.max!==void 0?`, ${s.min??"\u2026"} to ${s.max??"\u2026"}`:"";n.push(`${a}- ${s.label}${s.required?" *":""} (${s.name}) \u2014 ${p}${m}`),s.fields&&o(s.fields,`${a} `)}};return o(t.fields,`${e} `),t.fields.length===0&&n.push(`${e} (asks nothing)`),n}function _e(t,e){let n=t.viewSpecs??{};return e.filter(o=>o.cardinality==="one"&&o.replaces==="page"&&(n[o.attach]?.page?.length??0)>0).map(o=>{let r=L(t.schema,o.attach,1);return{at:`views.${o.attach}.page`,says:`The view "${o.name}" replaces ${Qe(r)}'s page, so its page slot is never drawn: leave out replaces to draw the slot under the view, or draw what the slot says in the view.`}})}var Qe=t=>`${/^[aeiou]/i.test(t)?"an":"a"} ${t}`,et=240,Ue=10,tt=1160,nt=40,qe=640,rt=3,st=t=>Math.max(1,Math.floor((Math.min(t,tt)-nt+Ue)/(et+Ue)));function ot(t,e,n,o){let{app:r}=o,a=o.width??1440,s=o.today??t.today()??ce(r.brand?.timeZone),p=t.seenBy(e),m=p.schema,A=p.graph,C=Ve(r,o.views?{views:o.views}:{}),R=typeof n=="string"?n.trim():n.slug,F=typeof n=="string"?C.find(l=>l.slug===R||l.title===R||l.address===R):C.find(l=>l.slug===n.slug&&l.kind===n.kind)??n,x=!F&&typeof n=="string"?A.getNode(R):void 0,G=!F&&!x?/^\/?forms\/(.+)$/.exec(R)?.[1]:void 0,V=G!==void 0?Ge(r,G):void 0;if(V)return{ok:!0,description:it(m,V,a)};if(!F&&!x)return{ok:!1,error:`"${R}" is not a place this app has, nor a record this seat can see.`,places:[...C.map(l=>l.slug),...Object.keys(r.forms??{}).map(l=>`forms/${l}`)]};let c=[],w=r.viewSpecs??{},S=st(a),k=(l,h)=>oe(p,null,l,{app:r,today:s,...h}),f=(l,h,M)=>{let d=m.tryDefinition(l.kind),g=W(d,l);if(h==="name")return{id:l.id,kind:l.kind,title:g,parts:[]};if(w[l.kind]?.[h]){let I=k(l,{slot:h}),[B,...O]=I,y=B?.t==="title"||h==="row"&&B?.t==="headline";return{id:l.id,kind:l.kind,title:y?B.text:g,parts:j(y?O:I,M,`views.${l.kind}.${h}`,` (${l.id})`,y?1:0)}}if(h==="row")return{id:l.id,kind:l.kind,title:g,parts:[]};let u=d?.computed?ne(m,A,l):l,T=z(u,d,{limit:3,said:[g],glance:!0,locale:r.brand?.locale,timeZone:r.brand?.timeZone});return{id:l.id,kind:l.kind,title:g,parts:T.map(I=>({t:"text",text:I.alone}))}};function j(l,h,M,d="",g=0){let $=[];return l.forEach((u,T)=>{let I=`${M}.${T+g}`;switch("problem"in u&&u.problem&&c.push({at:`${I}${d}`,says:u.problem}),u.t){case"title":$.push({t:"heading",level:3,text:u.text});return;case"text":$.push({t:"text",text:u.markdown?Pe(u.text):u.runs?ct(u.runs):u.text,...u.tone?{tone:u.tone}:{}});return;case"badge":$.push({t:"badge",text:u.text});return;case"field":case"image":$.push({t:"field",label:u.label,text:u.text});return;case"progress":$.push({t:"progress",label:u.label,text:u.text});return;case"group":$.push(...j(u.blocks,h,`${I}.group`,d));return;case"when":$.push(...j(u.blocks,h,`${I}.show`,d));return;case"divider":case"figure":return;case"headline":$.push({t:"heading",level:u.level,text:u.text});return;case"number":$.push({t:"figure",text:u.text,...u.label?{label:u.label}:{}});return;case"list":{if(u.failed){$.push({t:"text",text:"\u2014"});return}if(u.members.length===0){u.empty&&$.push({t:"list",as:u.as,columns:1,groups:[],empty:u.empty});return}let B=h+1,O=B>rt?"name":u.as,y=(u.groups??[{value:null,members:u.members}]).map(D=>({..."heading"in D&&D.heading?{heading:D.heading,count:(u.everyGroup?.find(Y=>Y.value===D.value)??D).members.length}:{},items:D.members.map(Y=>f(Y,O,B))}));$.push({t:"list",as:O,columns:O==="card"?S:1,groups:y,...u.more>0?{more:u.more}:{}});return}}}),$}let i=[],v,b,P,N=[];if(x){b="record";let l=m.tryDefinition(x.kind),h=W(l,x);P={slug:x.id,title:h,kind:x.kind,address:xe(m,x.kind,x.id)};let M=w[x.kind]?.page,d=o.views?.find(g=>g.attach===x.kind&&g.cardinality==="one");if(d&&i.push({t:"view",name:d.name,...d.title?{title:d.title}:{},...d.replaces==="page"?{replaces:!0}:{},...d.parts?{parts:d.parts}:{}}),d?.replaces==="page")b=`view:${d.name}`,c.push(..._e(r,[d]));else{M&&i.push(...j(k(x,{slot:"page"}),1,`views.${x.kind}.page`));let g=l?.computed?ne(m,A,x):x;for(let $ of Ce(l,z(g,l,{said:[h],locale:r.brand?.locale,timeZone:r.brand?.timeZone}))){$.title&&i.push({t:"heading",level:2,text:$.title});for(let u of $.fields)i.push({t:"field",label:u.label,text:u.value,...u.long?{long:!0}:{},...u.markdown?{markdown:!0}:{}})}}}else{let l=F;P={slug:l.slug,title:l.title,kind:l.kind,address:l.address};let h=l.lens?Se(r).drawn.find(d=>d.as===l.slug&&(l.kind===null||d.kinds.includes(l.kind))):void 0,M=l.kind!==null&&l.view===void 0&&!h?o.views?.find(d=>d.attach===l.kind&&d.cardinality==="many"&&d.replaces==="page"&&!d.hidden):void 0;if(l.kind!==null&&h?.create!==!1&&l.view===void 0&&!M&&(N=Ze(t,e,l.kind).map(d=>Ee(t,e,d))),l.view!==void 0&&!h){let d=o.views?.find(g=>g.name===l.view);b=`view:${l.view}`,i.push({t:"view",name:l.view,title:d?.title??l.title,...typeof d?.flows=="boolean"?{flows:d.flows}:{},...d?.parts?{parts:d.parts}:{}})}else if(l.kind===null){let d=r.brand,g=d?.name??r.name,$=$e(d)?.light,u=$&&be($)?$:void 0;if(v={name:g,...d?.subtitle&&d.subtitleDrawn!==!1?{subtitle:d.subtitle}:{},...u?{logo:{alt:d?.logoAlt??g,...we(u)?{drawn:"inline SVG"}:{drawn:"image",src:u}}}:{}},r.home)b="blocks",i=j(k(null,{}),0,"views.home");else{b="derived";let T=t.kindsKeptFrom(e),I=new Set([...r.pages?.hide??[],...T,...t.modules.disabledKinds]),B=De(m.kinds,r.pages?.order).filter(O=>!I.has(O));i.push({t:"heading",level:1,text:r.name??"Home"});for(let O of B){let y=A.nodesOfKind(O).filter(D=>H(m.tryDefinition(O),D)).length;y>0&&i.push({t:"text",text:`${y} ${L(m,O,y)}`})}}}else if(h?.lens==="blocks")b="lens:blocks",i=j(k(null,{blocks:h.options.blocks??[]}),0,`lenses.${h.index}.options.blocks`);else if(h?.lens==="columns"){b="lens:columns";let d=h.options.bindings??{};for(let g of Object.keys(d)){let $=d[g]?.column;if(!$)continue;let u=E(m,g,$),T=Z(A.nodesOfKind(g).filter(y=>H(m.tryDefinition(g),y)),h.options.sort,(y,D)=>D==="label"?W(m.tryDefinition(y.kind),y):y[D]);Object.keys(d).length>1&&i.push({t:"heading",level:2,text:L(m,g,2).replace(/^./,y=>y.toUpperCase())}),i.push({t:"text",text:`${T.length} ${L(m,g,T.length)} in columns by ${fe(m.tryDefinition(g),$).toLowerCase()}.`});let I=u.map(y=>({column:y,items:T.filter(D=>q(D,$,u)===y.value).map(D=>f(D,"card",1))})).filter(({column:y,items:D})=>y.value!==null||D.length>0).map(({column:y,items:D})=>({heading:`${y.label} (${D.length})`,items:D}));i.push({t:"list",as:"card",columns:1,groups:I});let B=new Map;for(let y of T)for(let D of re(t,e,y,$,u))B.set(D.to,(B.get(D.to)??new Set).add(`"${D.title}"`));let O=u.filter(y=>y.value!==null&&B.has(y.value)).map(y=>`to ${y.label} by ${[...B.get(y.value)].join(" or ")}`);i.push({t:"text",text:O.length>0?`Moves: ${O.join("; ")}.`:"Moves: none for this seat."})}}else if(h?.lens==="coverage")b="lens:coverage",i=He(m,A,h.options);else if(h){b=`lens:${h.lens}`;let d=h.kinds.flatMap(g=>A.nodesOfKind(g).filter($=>H(m.tryDefinition(g),$)));i.push({t:"text",text:`A ${h.lens} of ${d.length} ${h.kinds.map(g=>L(m,g,d.length)).join(" and ")}.`}),i.push({t:"list",as:"name",columns:1,groups:[{items:d.map(g=>f(g,"name",1))}]})}else if(M)b=`view:${M.name}`,i.push({t:"heading",level:1,text:l.title}),i.push({t:"view",name:M.name,...M.title?{title:M.title}:{},replaces:!0,...M.parts?{parts:M.parts}:{}});else{b="derived";let d=A.nodesOfKind(l.kind).filter(g=>H(m.tryDefinition(l.kind),g));i.push({t:"heading",level:1,text:l.title}),d.length===0?i.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${L(m,l.kind,0)} yet.`}):i.push({t:"list",as:"row",columns:1,groups:[{items:d.map(g=>f(g,"row",1))}]})}}let K=e.kind==="system"?"the system":(e.roles??[]).length>0?(e.roles??[]).join(", "):e.kind,Xe=a<qe?"phone":"wide",ae=P.kind===null?at(m,A):[],le={...v?{masthead:v}:{},...ae.length>0?{facts:ae}:{},place:P,seat:K,width:a,variant:Xe,drawnBy:b,parts:i,...N.length>0?{forms:N}:{},problems:c};return{ok:!0,description:{...le,text:ie(le)}}}function it(t,e,n){let o=[{t:"heading",level:1,text:e.title},...e.intro?[{t:"text",text:e.intro}]:[]],r={place:{slug:`forms/${e.name}`,title:e.title,kind:null,address:`/forms/${e.name}`},seat:`a visitor (${e.role})`,width:n,variant:n<qe?"phone":"wide",drawnBy:"form",parts:o,forms:[Le(t,e)],problems:[]};return{...r,text:ie(r)}}function at(t,e){let n=Me(t,e,null),o=r=>Array.isArray(r)?r.map(o).join(", "):r===null?"nothing":typeof r=="boolean"?r?"yes":"no":typeof r=="object"?r.label:String(r);return[...Ae(t)].map(([r,a])=>{let s=a.label??U(r);return Object.hasOwn(n.values,r)?{name:r,label:s,value:o(n.values[r])}:{name:r,label:s,refused:n.refused[r]??"it could not be worked out"}})}function L(t,e,n){let o=t.tryDefinition(e);if(n===1)return o?.noun??e;let r=pe(t,e);return de(r)}function ie(t){let e=[`${t.place.title} (${t.place.address}) \u2014 as ${t.seat}, ${t.width} wide (${t.variant}).`],n=t.masthead;n&&e.push(`Masthead: ${n.logo?`the logo ("${n.logo.alt}", ${n.logo.drawn==="image"?n.logo.src:"inline SVG"}), `:""}${n.name}${n.subtitle?` \u2014 ${n.subtitle}`:""}`);let o=(r,a)=>{for(let s of r)switch(s.t){case"heading":e.push(`${a}${"#".repeat(s.level)} ${s.text}`);break;case"text":e.push(`${a}${s.text}`);break;case"badge":e.push(`${a}[${s.text}]`);break;case"field":case"progress":e.push(`${a}${s.label}: ${s.text}`);break;case"figure":e.push(`${a}${s.text}${s.label?` \u2014 ${s.label}`:""}`);break;case"list":if(s.groups.length===0){s.empty&&e.push(`${a}(${s.empty})`);break}for(let p of s.groups){p.heading&&e.push(`${a}${p.heading}${p.count!==void 0?` (${p.count})`:""}:`);for(let m of p.items)e.push(`${a}${p.heading?" ":""}- ${m.title}`),o(m.parts,`${a}${p.heading?" ":" "}`)}s.as==="card"&&s.columns>1&&e.push(`${a}(cards, ${s.columns} across)`),s.more&&e.push(`${a}and ${s.more} more`);break;case"view":e.push(`${a}[the view "${s.title??s.name}"${s.replaces?", in place of the page":""}${s.flows===!0?", flowing with the page":s.flows===!1?", in a frame of its own":""}]`),s.parts&&o(s.parts,`${a} `);break}};o(t.parts,"");for(let r of t.forms??[])e.push(...ze(r));if(t.facts){e.push("Facts of the whole graph (what fact('<name>') reads):");for(let r of t.facts)e.push(`- ${r.label} (${r.name}): ${r.value??`not worked out \u2014 ${r.refused}`}`)}if(t.videos&&t.videos.length>0){e.push("Videos:");for(let r of t.videos)e.push(`- ${lt(r)}`)}if(t.problems.length>0){e.push("Problems:");for(let r of t.problems)e.push(`- ${r.at}: ${r.says}`)}return e.join(`
|
|
2
2
|
`)}function lt(t){let e=t.autoplay?"plays as a background, muted and looping, with no controls":"plays with the browser's controls";return`${t.text} (${t.field} of ${t.record}): ${t.source}${t.duration!==void 0?`, ${Math.round(t.duration)} s`:""}, ${t.poster?"with a poster":"no poster"}; ${e}${t.cover?", filling its box":""}; ${t.playable?"playable":`not playable: ${t.why??"it is not a video a browser plays"}`}.`}function ct(t){return t.map((e,n)=>(n===0?"":e.field===void 0&&t[n-1].field===void 0?" \xB7 ":" ")+e.text).join("")}export{E as a,q as b,re as c,Ne as d,Ke as e,Te as f,We as g,oe as h,_e as i,ot as j,ie as k};
|