graview 0.1.56 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/preview/{chunk.5B4HNQGR.js → chunk.2PWVDUOU.js} +1 -1
  2. package/dist/preview/{chunk.DWMAFMYZ.js → chunk.33PZEW5A.js} +1 -1
  3. package/dist/preview/{chunk.D4LN33J2.js → chunk.3DPTDMJ7.js} +1 -1
  4. package/dist/preview/{chunk.PJCVFYFU.js → chunk.47T3KUAA.js} +1 -1
  5. package/dist/preview/{chunk.AKVBU5K5.js → chunk.4BRM5SGO.js} +1 -1
  6. package/dist/preview/{chunk.NQ4VGKEC.js → chunk.4HFCOMR3.js} +1 -1
  7. package/dist/preview/{chunk.PMPDLE56.js → chunk.4HPP35XQ.js} +1 -1
  8. package/dist/preview/{chunk.USB6B6L3.js → chunk.4JDHBNEA.js} +1 -1
  9. package/dist/preview/{chunk.4EUH6TLG.js → chunk.4K6VAC2S.js} +2 -2
  10. package/dist/preview/{chunk.VDD3RHLB.js → chunk.4L4F47QP.js} +1 -1
  11. package/dist/preview/{chunk.J3YBEZKE.js → chunk.4NPXMYA5.js} +1 -1
  12. package/dist/preview/{chunk.TAIYNHSW.js → chunk.4OP4IEEY.js} +1 -1
  13. package/dist/preview/chunk.4SBYXHCQ.js +1 -0
  14. package/dist/preview/{chunk.QW3QLE53.js → chunk.4UQBMFJZ.js} +1 -1
  15. package/dist/preview/{chunk.MLRPCZVS.js → chunk.4W5GCPAP.js} +1 -1
  16. package/dist/preview/{chunk.NUE5VG4G.js → chunk.4XKRCAJZ.js} +1 -1
  17. package/dist/preview/{chunk.PRV3KYT6.js → chunk.534TBZJ3.js} +2 -2
  18. package/dist/preview/{chunk.2HZGUVB2.js → chunk.53U6E5LD.js} +1 -1
  19. package/dist/preview/{chunk.AQCU6TPV.js → chunk.547FQPYG.js} +1 -1
  20. package/dist/preview/{chunk.N3Q5CPVA.js → chunk.57BKS5KD.js} +1 -1
  21. package/dist/preview/chunk.57KRCHQT.js +1 -0
  22. package/dist/preview/{chunk.6HLKAUWF.js → chunk.5BPRGXIW.js} +1 -1
  23. package/dist/preview/{chunk.E4EN4X5F.js → chunk.5GTOF5D5.js} +1 -1
  24. package/dist/preview/{chunk.KY7QD22S.js → chunk.5IEFTFKQ.js} +1 -1
  25. package/dist/preview/{chunk.IT763BYH.js → chunk.5NZDFT6R.js} +1 -1
  26. package/dist/preview/{chunk.K2JE3PD7.js → chunk.66LWZIY5.js} +1 -1
  27. package/dist/preview/{chunk.QYFZ7AZS.js → chunk.6AH26OL7.js} +2 -2
  28. package/dist/preview/{chunk.EC5IWN74.js → chunk.6SD7YZ4U.js} +2 -2
  29. package/dist/preview/{chunk.N7EEPFYV.js → chunk.72IHABM5.js} +1 -1
  30. package/dist/preview/chunk.7INWDFNG.js +1 -0
  31. package/dist/preview/{chunk.7O6Z3BFR.js → chunk.7IXTNST2.js} +1 -1
  32. package/dist/preview/{chunk.DTSTUC2W.js → chunk.7ML2BWSP.js} +1 -1
  33. package/dist/preview/{chunk.QAIYYIZQ.js → chunk.7UBABS2T.js} +1 -1
  34. package/dist/preview/{chunk.KBL4Y4UN.js → chunk.7VIFAN3O.js} +1 -1
  35. package/dist/preview/chunk.7VZA34T4.js +1 -0
  36. package/dist/preview/{chunk.JQY2UKU6.js → chunk.AD3EC5DU.js} +1 -1
  37. package/dist/preview/{chunk.RDL6652E.js → chunk.BCE6LIDR.js} +1 -1
  38. package/dist/preview/{chunk.Q7X2IVLH.js → chunk.BPEUHOKH.js} +1 -1
  39. package/dist/preview/{chunk.SRC37GNP.js → chunk.BUSFJM6P.js} +1 -1
  40. package/dist/preview/{chunk.FCUDBMGC.js → chunk.BZEJM2PY.js} +1 -1
  41. package/dist/preview/{chunk.22MIRLL6.js → chunk.C5EFUODO.js} +1 -1
  42. package/dist/preview/{chunk.64IKLRUS.js → chunk.C7EJPV2N.js} +1 -1
  43. package/dist/preview/chunk.CMLNBJZG.js +3 -0
  44. package/dist/preview/{chunk.RXYE2DAJ.js → chunk.CUKRUQQ2.js} +1 -1
  45. package/dist/preview/chunk.CXB4BSI4.js +1 -0
  46. package/dist/preview/{chunk.2E6EWVWR.js → chunk.D3LQJXVP.js} +1 -1
  47. package/dist/preview/{chunk.I2C5LPB5.js → chunk.D4EP7FEC.js} +1 -1
  48. package/dist/preview/{chunk.NPAWTPLQ.js → chunk.DBMZ3AQB.js} +1 -1
  49. package/dist/preview/{chunk.YEJ4LNUP.js → chunk.DIFR37EZ.js} +1 -1
  50. package/dist/preview/{chunk.LLOZKUCA.js → chunk.DJ4A76SX.js} +1 -1
  51. package/dist/preview/{chunk.VEOS25PQ.js → chunk.DM5X3JBH.js} +1 -1
  52. package/dist/preview/chunk.DQUISKTC.js +1 -0
  53. package/dist/preview/chunk.DSLGMCB6.js +1 -0
  54. package/dist/preview/chunk.DSWMXM57.js +1 -0
  55. package/dist/preview/{chunk.C2VFDBSG.js → chunk.DWLKJGVT.js} +1 -1
  56. package/dist/preview/{chunk.WMB2NNBD.js → chunk.EQAAKYLA.js} +1 -1
  57. package/dist/preview/{chunk.2YNZVNCA.js → chunk.EXZLG3HK.js} +1 -1
  58. package/dist/preview/{chunk.LP3SHWJG.js → chunk.EZ4NUZWX.js} +1 -1
  59. package/dist/preview/{chunk.E33EJU3Q.js → chunk.EZ4TZUMM.js} +1 -1
  60. package/dist/preview/{chunk.AKW6NR3X.js → chunk.FJTWAU7N.js} +1 -1
  61. package/dist/preview/{chunk.VYW7DSUW.js → chunk.FLMNWVSY.js} +2 -2
  62. package/dist/preview/{chunk.ILSK2E3R.js → chunk.FLVE6IBM.js} +1 -1
  63. package/dist/preview/{chunk.SOTB6C5A.js → chunk.FPGU43SC.js} +1 -1
  64. package/dist/preview/{chunk.K5YLQAFW.js → chunk.FRERJWZJ.js} +1 -1
  65. package/dist/preview/{chunk.D6BMAGPR.js → chunk.G3BDQ6EA.js} +1 -1
  66. package/dist/preview/chunk.GBAUQXXD.js +1 -0
  67. package/dist/preview/{chunk.WPJVMVAL.js → chunk.H5CRRBNU.js} +1 -1
  68. package/dist/preview/{chunk.4KMY24YC.js → chunk.HFSG3F5Z.js} +1 -1
  69. package/dist/preview/chunk.I2NI7CT7.js +1 -0
  70. package/dist/preview/{chunk.T6HG2XIP.js → chunk.I5PSHASU.js} +1 -1
  71. package/dist/preview/{chunk.XGCOWCA2.js → chunk.I636CZE4.js} +1 -1
  72. package/dist/preview/chunk.I6H3HRWT.js +1 -0
  73. package/dist/preview/{chunk.CGM7OER2.js → chunk.IRQOJATD.js} +1 -1
  74. package/dist/preview/chunk.IV7AUO53.js +1 -0
  75. package/dist/preview/{chunk.ONGZ3YQF.js → chunk.IX63LTRQ.js} +1 -1
  76. package/dist/preview/{chunk.JZDKHWRL.js → chunk.JBSW7ZNH.js} +1 -1
  77. package/dist/preview/chunk.JD5HSAMC.js +18 -0
  78. package/dist/preview/{chunk.LKK7VQBA.js → chunk.JETT6ELP.js} +1 -1
  79. package/dist/preview/{chunk.IF4FCQPG.js → chunk.JNNBHD4Z.js} +1 -1
  80. package/dist/preview/{chunk.HFVMGTNL.js → chunk.JQFIZRAZ.js} +2 -2
  81. package/dist/preview/chunk.KNYLY7MH.js +1 -0
  82. package/dist/preview/chunk.KO7IOFNY.js +1 -0
  83. package/dist/preview/{chunk.XY5EVI22.js → chunk.KPIDJYIU.js} +1 -1
  84. package/dist/preview/{chunk.APXYWI3L.js → chunk.KTV24HY7.js} +1 -1
  85. package/dist/preview/{chunk.YL5ZCRHQ.js → chunk.KYOI7BG3.js} +1 -1
  86. package/dist/preview/{chunk.SVAQGVS4.js → chunk.LE2KAR25.js} +1 -1
  87. package/dist/preview/{chunk.VLBY66PB.js → chunk.LHIT3EZD.js} +2 -2
  88. package/dist/preview/{chunk.7Z4USR3Y.js → chunk.LKJ6FD6Y.js} +1 -1
  89. package/dist/preview/chunk.LUIRQ5UF.js +2 -0
  90. package/dist/preview/chunk.LWRXCO2Z.js +1 -0
  91. package/dist/preview/{chunk.AZUTYY2S.js → chunk.M72JKVHP.js} +4 -4
  92. package/dist/preview/{chunk.65Q5MKDW.js → chunk.MAZFQIL5.js} +1 -1
  93. package/dist/preview/{chunk.V3NPUAPB.js → chunk.MBLFZF5R.js} +1 -1
  94. package/dist/preview/{chunk.QNNRSPIJ.js → chunk.MRHPOUA4.js} +1 -1
  95. package/dist/preview/{chunk.BNEOLRQG.js → chunk.MWWOI5PW.js} +1 -1
  96. package/dist/preview/{chunk.4EY6WPSM.js → chunk.N2DM42SG.js} +2 -2
  97. package/dist/preview/chunk.N33WUCAN.js +3 -0
  98. package/dist/preview/{chunk.MFDSWA2W.js → chunk.N5MQARN6.js} +1 -1
  99. package/dist/preview/{chunk.2OX4YI46.js → chunk.NF72Z2HG.js} +1 -1
  100. package/dist/preview/{chunk.TXWCTHMI.js → chunk.NGK6IRV3.js} +1 -1
  101. package/dist/preview/{chunk.2DETYEJM.js → chunk.NL3AJZ3N.js} +1 -1
  102. package/dist/preview/{chunk.GUP7LC5O.js → chunk.NUS5K56R.js} +2 -2
  103. package/dist/preview/{chunk.7NP2I2UP.js → chunk.NX7CR4AE.js} +1 -1
  104. package/dist/preview/{chunk.7RJGEU3Y.js → chunk.NZDWXX6H.js} +1 -1
  105. package/dist/preview/{chunk.QSO5BP2H.js → chunk.O47MN7E5.js} +1 -1
  106. package/dist/preview/chunk.OYUDK3LK.js +1 -0
  107. package/dist/preview/chunk.PF5P5YVD.js +1 -0
  108. package/dist/preview/{chunk.V6X3U3JF.js → chunk.PHC2MI4C.js} +1 -1
  109. package/dist/preview/{chunk.MJMVGW6Z.js → chunk.PQMMISCQ.js} +1 -1
  110. package/dist/preview/{chunk.E4HSSGF7.js → chunk.Q6OZLBNL.js} +1 -1
  111. package/dist/preview/{chunk.AM2YRNOQ.js → chunk.QMYHXMRV.js} +1 -1
  112. package/dist/preview/chunk.QPL3OXW3.js +1 -0
  113. package/dist/preview/{chunk.ZFXHZZHW.js → chunk.QS6YW7UY.js} +1 -1
  114. package/dist/preview/chunk.QUJS63OJ.js +13 -0
  115. package/dist/preview/{chunk.USQNSNIA.js → chunk.RALAID6N.js} +1 -1
  116. package/dist/preview/{chunk.XJFAUOJS.js → chunk.RQX4CQJN.js} +1 -1
  117. package/dist/preview/{chunk.NBLMANHT.js → chunk.RVR6FWAF.js} +1 -1
  118. package/dist/preview/{chunk.O6LDZWLR.js → chunk.S5ECRIG5.js} +1 -1
  119. package/dist/preview/{chunk.CKV2QCH5.js → chunk.SAJLIA5M.js} +1 -1
  120. package/dist/preview/{chunk.IRMO4FUC.js → chunk.TBRXNU6T.js} +1 -1
  121. package/dist/preview/{chunk.MORMTKVR.js → chunk.TVURUMU4.js} +1 -1
  122. package/dist/preview/{chunk.3X3GLNWQ.js → chunk.UBNZDSS7.js} +1 -1
  123. package/dist/preview/chunk.UDCDK7XJ.js +4 -0
  124. package/dist/preview/{chunk.NFU4UM6F.js → chunk.UGOKORIF.js} +1 -1
  125. package/dist/preview/{chunk.CU2NQ5WF.js → chunk.UV3U4FRT.js} +1 -1
  126. package/dist/preview/{chunk.IUQOSPQX.js → chunk.UWQ3I5OW.js} +1 -1
  127. package/dist/preview/chunk.V6FUYRZI.js +1 -0
  128. package/dist/preview/{chunk.DH7M57SE.js → chunk.VDS3IOTK.js} +1 -1
  129. package/dist/preview/{chunk.OBUKZQCZ.js → chunk.VHPGGC2P.js} +1 -1
  130. package/dist/preview/{chunk.FBR4HJ2Q.js → chunk.VSGTNYM2.js} +1 -1
  131. package/dist/preview/{chunk.G3ORIU7C.js → chunk.VW4JAQCH.js} +1 -1
  132. package/dist/preview/{chunk.VSM72NVF.js → chunk.WASWMHND.js} +1 -1
  133. package/dist/preview/chunk.WYPL2QUA.js +1 -0
  134. package/dist/preview/{chunk.UQQAGT3R.js → chunk.XTBS64IT.js} +1 -1
  135. package/dist/preview/chunk.XVN3CQKH.js +2 -0
  136. package/dist/preview/{chunk.D6KF72MZ.js → chunk.Y3EOGXRS.js} +1 -1
  137. package/dist/preview/chunk.Y4KNR76Z.js +1 -0
  138. package/dist/preview/chunk.YDTXCVBU.js +1 -0
  139. package/dist/preview/{chunk.YLMOGGEP.js → chunk.YPP7FSEZ.js} +1 -1
  140. package/dist/preview/{chunk.45VIF2SX.js → chunk.YQXA4WAM.js} +2 -2
  141. package/dist/preview/{chunk.JHFHIG4P.js → chunk.YR75TWDV.js} +1 -1
  142. package/dist/preview/{chunk.AIK3Z25Y.js → chunk.YS5U3DUX.js} +1 -1
  143. package/dist/preview/chunk.Z5UVYOGC.js +1 -0
  144. package/dist/preview/{chunk.5MS2TQFX.js → chunk.ZNXRHOUI.js} +1 -1
  145. package/dist/preview/index.html +50 -50
  146. package/dist/preview/page.js +2 -2
  147. package/package.json +6 -6
  148. package/dist/preview/chunk.2BLRCT3E.js +0 -1
  149. package/dist/preview/chunk.3V2WH6F7.js +0 -1
  150. package/dist/preview/chunk.4YI6656P.js +0 -1
  151. package/dist/preview/chunk.5MSWUTDB.js +0 -1
  152. package/dist/preview/chunk.6Q6BW4QT.js +0 -2
  153. package/dist/preview/chunk.7U2JO7ET.js +0 -3
  154. package/dist/preview/chunk.7Z2PRPYE.js +0 -1
  155. package/dist/preview/chunk.AGTFYPXY.js +0 -1
  156. package/dist/preview/chunk.BT7RLFPO.js +0 -1
  157. package/dist/preview/chunk.DPPT6WAJ.js +0 -2
  158. package/dist/preview/chunk.DVG47BK3.js +0 -1
  159. package/dist/preview/chunk.DZYLH5IM.js +0 -1
  160. package/dist/preview/chunk.E5XNQTEU.js +0 -1
  161. package/dist/preview/chunk.F5RN6YXG.js +0 -4
  162. package/dist/preview/chunk.FOQENWF5.js +0 -1
  163. package/dist/preview/chunk.GNQW4JOG.js +0 -18
  164. package/dist/preview/chunk.HVN2DVP3.js +0 -1
  165. package/dist/preview/chunk.JL4DGITZ.js +0 -1
  166. package/dist/preview/chunk.K4MO22RM.js +0 -1
  167. package/dist/preview/chunk.KMEKMCKG.js +0 -3
  168. package/dist/preview/chunk.LVOVPU64.js +0 -1
  169. package/dist/preview/chunk.MEJUAV3Y.js +0 -1
  170. package/dist/preview/chunk.OYGPNO7A.js +0 -1
  171. package/dist/preview/chunk.RR2IFETZ.js +0 -1
  172. package/dist/preview/chunk.T2RME6XF.js +0 -1
  173. package/dist/preview/chunk.TAJ2R44N.js +0 -1
  174. package/dist/preview/chunk.TQCRFZ53.js +0 -1
  175. package/dist/preview/chunk.UE5YS3GN.js +0 -1
  176. package/dist/preview/chunk.VIQ6EF2O.js +0 -1
  177. package/dist/preview/chunk.XE72DFBV.js +0 -13
@@ -1,4 +1,4 @@
1
- import{a as z,b as Y,d as ee}from"./chunk.AGTFYPXY.js";import"./chunk.FBR4HJ2Q.js";import{ec as J,ga as Q,ja as U,oa as X,sa as _}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function ce(t){let r=t?.indexOf(":")??-1;if(!(!t||r<=0||r===t.length-1))return{relation:t.slice(0,r),record:t.slice(r+1)}}function ne(t,r){if(t.length===0)return!0;let d=`${r.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===r||a===d)}function re(t,r){let d=r.startsWith("image/")?"image":r.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function fe(t,r){let d=new Set(t.map(k=>k.as==="image"?"image/":k.as==="video"?"video/":""));if(d.has("")||r.kinds.length===0)return r.kinds.join(",");let a=[];for(let k of d){let m=r.kinds.filter(l=>l.startsWith(k));a.push(...m.length>0?m:[`${k}*`])}return a.join(",")}var T=t=>t.input?.shape??{},ie=(t,r)=>T(t)[r]?.safeParse(void 0).success===!1;function ae(t,r){let d=new Set(z(t.input).map(a=>a.name));return Object.keys(T(t)).filter(a=>!r.has(a)&&!d.has(a)&&ie(t,a)&&T(t)[a].safeParse("a name").success&&!T(t)[a].safeParse(1).success)}var ue=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,se=(t,r)=>{let d=Number.isFinite(Date.parse(r))?new Date(Date.parse(r)).toISOString():r;return[r,d,d.replace(/\.\d{3}Z$/,"Z"),r.slice(0,10)].find(a=>t.safeParse(a).success)},pe="2026-01-01T00:00:00.000Z";function te(t,r){let d=T(t),a=new Set(ae(t,r)),k=Object.keys(d).filter(l=>!r.has(l)&&!a.has(l)&&ie(t,l)),m=k.filter(l=>se(d[l],pe)!==void 0);return{timed:m,left:k.filter(l=>!m.includes(l))}}function oe(t,r,d,a,k){let m=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return m(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let A=k.files;if(!A||!(A.maxBytes>0))return m("This host takes no files.");let j=R.flatMap(e=>{let n=ee(t,e.kind,e.field);return n?[{field:e.field,...n}]:[]}),w=j.filter(e=>e.as==="file"||A.kinds.length===0||A.kinds.some(n=>n==="*"||n==="*/*"||n.startsWith(e.as==="image"?"image/":"video/")));if(w.length===0)return m(`This host takes none of what ${l}'s ${j.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ce(a.connect);if(a.connect!==void 0&&(!c||k.shown.has(a.connect)))return m(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!k.shown.has(c.record))return m(`data-drop-connect names "${c.record}", which this view was not shown.`);let g=c?t.seenBy(r).graph.getNode(c.record):void 0;if(c&&!g)return m(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),E=c?$(l):!1;if(c&&!E&&!$(g.kind))return m(`Neither a "${l}" nor a "${g.kind}" has the relation "${c.relation}".`);let H=t.allMutations(),F=e=>t.permits(e,r).ok,Z=e=>w.every(n=>Object.hasOwn(T(e),n.field)),V=H.filter(e=>(e.creates??[]).includes(l)&&Z(e)),x=X(t.schema.tryDefinition(l),l),O=U(t.schema,l).toLowerCase(),S=g?Q(t.schema.tryDefinition(g.kind),g):void 0,G=e=>`${e===1?`a ${x}`:`${e} ${O}`}${S?` to ${S}`:""}`,K=e=>`Add ${G(e)}`,L=e=>`Added ${G(e)}.`,B=`Drop to add ${O}${S?` to ${S}`:""}.`,N=(e,n,u,v)=>{let I=new Set(Object.keys(n)),D=_(u.at)??v??new Date().toISOString();for(let C of te(e,I).timed)n[C]=se(T(e)[C],D);for(let C of ae(e,I))n[C]=ue(u.name);return n},q=(e,...n)=>new Set([...w.map(u=>u.field),...n,...z(e.input).map(u=>u.name)]),P=(e,...n)=>te(e,q(e,...n)).left,i=(e,n)=>m(`"${e.title??e.name}" asks for ${n.map(u=>`"${u}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${x}.`),o=(e,n)=>e.list?[n]:n,f={ok:!0,kind:l,fields:w,accept:fe(w,A),...c?{connect:c}:{},intent:K,invite:B,added:L};if(!c){let e=V.find(n=>!n.subject&&F({name:n.name,args:{}}));return e?P(e).length>0?i(e,P(e)):{...f,calls:n=>[{name:e.name,args:N(e,{[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}:m(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(g.kind))&&(e.connects??[]).includes(c.relation)&&F({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return P(s,e).length>0?i(s,P(s,e)):{...f,calls:n=>[{name:s.name,args:N(s,{[e]:c.record,[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}}let p=V.find(e=>!e.subject&&F({name:e.name,args:{}}));if(!p)return m(`This seat may not make a "${l}" here.`);if(P(p).length>0)return i(p,P(p));let y=E?l:g.kind,W=E?g.kind:l,M=H.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let n=e.subject.kinds;if(n!=="*"&&!n.includes(y))return!1;let u=z(e.input).find(v=>v.name!==e.subject.arg&&(v.kinds.includes("*")||v.kinds.includes(W)));return u?F({name:e.name,args:E?{[u.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return m(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let h=M.subject.arg,b=z(M.input).find(e=>e.name!==h&&(e.kinds.includes("*")||e.kinds.includes(W))).name;return{...f,calls:(e,n)=>[{name:p.name,args:N(p,{[e.field]:o(w.find(u=>u.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:E?{[h]:J(n*2),[b]:c.record}:{[h]:c.record,[b]:J(n*2)}}]}}var de=t=>t.type.startsWith("image/"),me=t=>t.type.startsWith("video/"),ge=`
1
+ import{a as z,b as Y,d as ee}from"./chunk.Z5UVYOGC.js";import"./chunk.VSGTNYM2.js";import{ec as J,ga as Q,ja as U,oa as X,sa as _}from"./chunk.DIFR37EZ.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function ce(t){let r=t?.indexOf(":")??-1;if(!(!t||r<=0||r===t.length-1))return{relation:t.slice(0,r),record:t.slice(r+1)}}function ne(t,r){if(t.length===0)return!0;let d=`${r.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===r||a===d)}function re(t,r){let d=r.startsWith("image/")?"image":r.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function fe(t,r){let d=new Set(t.map(k=>k.as==="image"?"image/":k.as==="video"?"video/":""));if(d.has("")||r.kinds.length===0)return r.kinds.join(",");let a=[];for(let k of d){let m=r.kinds.filter(l=>l.startsWith(k));a.push(...m.length>0?m:[`${k}*`])}return a.join(",")}var T=t=>t.input?.shape??{},ie=(t,r)=>T(t)[r]?.safeParse(void 0).success===!1;function ae(t,r){let d=new Set(z(t.input).map(a=>a.name));return Object.keys(T(t)).filter(a=>!r.has(a)&&!d.has(a)&&ie(t,a)&&T(t)[a].safeParse("a name").success&&!T(t)[a].safeParse(1).success)}var ue=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,se=(t,r)=>{let d=Number.isFinite(Date.parse(r))?new Date(Date.parse(r)).toISOString():r;return[r,d,d.replace(/\.\d{3}Z$/,"Z"),r.slice(0,10)].find(a=>t.safeParse(a).success)},pe="2026-01-01T00:00:00.000Z";function te(t,r){let d=T(t),a=new Set(ae(t,r)),k=Object.keys(d).filter(l=>!r.has(l)&&!a.has(l)&&ie(t,l)),m=k.filter(l=>se(d[l],pe)!==void 0);return{timed:m,left:k.filter(l=>!m.includes(l))}}function oe(t,r,d,a,k){let m=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return m(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let A=k.files;if(!A||!(A.maxBytes>0))return m("This host takes no files.");let j=R.flatMap(e=>{let n=ee(t,e.kind,e.field);return n?[{field:e.field,...n}]:[]}),w=j.filter(e=>e.as==="file"||A.kinds.length===0||A.kinds.some(n=>n==="*"||n==="*/*"||n.startsWith(e.as==="image"?"image/":"video/")));if(w.length===0)return m(`This host takes none of what ${l}'s ${j.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ce(a.connect);if(a.connect!==void 0&&(!c||k.shown.has(a.connect)))return m(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!k.shown.has(c.record))return m(`data-drop-connect names "${c.record}", which this view was not shown.`);let g=c?t.seenBy(r).graph.getNode(c.record):void 0;if(c&&!g)return m(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),E=c?$(l):!1;if(c&&!E&&!$(g.kind))return m(`Neither a "${l}" nor a "${g.kind}" has the relation "${c.relation}".`);let H=t.allMutations(),F=e=>t.permits(e,r).ok,Z=e=>w.every(n=>Object.hasOwn(T(e),n.field)),V=H.filter(e=>(e.creates??[]).includes(l)&&Z(e)),x=X(t.schema.tryDefinition(l),l),O=U(t.schema,l).toLowerCase(),S=g?Q(t.schema.tryDefinition(g.kind),g):void 0,G=e=>`${e===1?`a ${x}`:`${e} ${O}`}${S?` to ${S}`:""}`,K=e=>`Add ${G(e)}`,L=e=>`Added ${G(e)}.`,B=`Drop to add ${O}${S?` to ${S}`:""}.`,N=(e,n,u,v)=>{let I=new Set(Object.keys(n)),D=_(u.at)??v??new Date().toISOString();for(let C of te(e,I).timed)n[C]=se(T(e)[C],D);for(let C of ae(e,I))n[C]=ue(u.name);return n},q=(e,...n)=>new Set([...w.map(u=>u.field),...n,...z(e.input).map(u=>u.name)]),P=(e,...n)=>te(e,q(e,...n)).left,i=(e,n)=>m(`"${e.title??e.name}" asks for ${n.map(u=>`"${u}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${x}.`),o=(e,n)=>e.list?[n]:n,f={ok:!0,kind:l,fields:w,accept:fe(w,A),...c?{connect:c}:{},intent:K,invite:B,added:L};if(!c){let e=V.find(n=>!n.subject&&F({name:n.name,args:{}}));return e?P(e).length>0?i(e,P(e)):{...f,calls:n=>[{name:e.name,args:N(e,{[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}:m(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(g.kind))&&(e.connects??[]).includes(c.relation)&&F({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return P(s,e).length>0?i(s,P(s,e)):{...f,calls:n=>[{name:s.name,args:N(s,{[e]:c.record,[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}}let p=V.find(e=>!e.subject&&F({name:e.name,args:{}}));if(!p)return m(`This seat may not make a "${l}" here.`);if(P(p).length>0)return i(p,P(p));let y=E?l:g.kind,W=E?g.kind:l,M=H.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let n=e.subject.kinds;if(n!=="*"&&!n.includes(y))return!1;let u=z(e.input).find(v=>v.name!==e.subject.arg&&(v.kinds.includes("*")||v.kinds.includes(W)));return u?F({name:e.name,args:E?{[u.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return m(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let h=M.subject.arg,b=z(M.input).find(e=>e.name!==h&&(e.kinds.includes("*")||e.kinds.includes(W))).name;return{...f,calls:(e,n)=>[{name:p.name,args:N(p,{[e.field]:o(w.find(u=>u.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:E?{[h]:J(n*2),[b]:c.record}:{[h]:c.record,[b]:J(n*2)}}]}}var de=t=>t.type.startsWith("image/"),me=t=>t.type.startsWith("video/"),ge=`
2
2
  [data-graview-drop-over] { outline: 2px dashed var(--graview-accent, Highlight) !important; outline-offset: 2px !important; background-color: color-mix(in srgb, var(--graview-accent, Highlight) 10%, transparent) !important; }
3
3
  [data-graview-drop-status], [data-graview-drop-refused] { margin: 4px 0 0; font: 0.8125rem/1.4 var(--graview-font-body, system-ui, sans-serif); color: var(--graview-ink-muted, GrayText); }
4
4
  [data-graview-drop-refused] { color: var(--graview-warn, var(--graview-ink, CanvasText)); }
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{a as k,b as q,c as pe}from"./chunk.T2RME6XF.js";import"./chunk.SOTB6C5A.js";import"./chunk.TQCRFZ53.js";import"./chunk.6HLKAUWF.js";import"./chunk.FCUDBMGC.js";import"./chunk.KMEKMCKG.js";import"./chunk.GZHZLJBF.js";import{n as me}from"./chunk.E5XNQTEU.js";import"./chunk.OJGHDWI6.js";import"./chunk.K5YLQAFW.js";import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import"./chunk.7U2JO7ET.js";import"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{G as Le,M as S,O as ue,T as ce,ba as ge,ea as he}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{Uc as de,ma as oe,pa as w,ra as le,ta as E,ua as x,va as se,wa as Y}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import{b as U}from"./chunk.AJZBJBMO.js";var h=U(Le(),1);async function ye(e,n){let i=await createImageBitmap(e);try{let r=Math.min(1,n/Math.max(i.width,i.height)),a=document.createElement("canvas");a.width=Math.max(1,Math.round(i.width*r)),a.height=Math.max(1,Math.round(i.height*r));let l=a.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(i,0,0,a.width,a.height),a}finally{i.close()}}var t=U(ce(),1),Ve=2048,Ie=.85;function _(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function z(e){if(e.type==="application/pdf")return"PDF";let n=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return n?n.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let n=[...new Set(e.map(i=>i==="image/*"?"pictures":i==="video/*"?"videos":i==="*/*"||i==="*"?"any file":`${z({type:i})} files`))];return n.length<=1?n[0]??"no files":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}function Fe(e,n){if(e.length===0)return!0;let i=`${n.split("/")[0]}/*`;return e.some(r=>r==="*"||r==="*/*"||r===n||r===i)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,n,i){let r=e.name||(i.camera?"photo.jpg":"file"),a=e.type||(be({type:"",name:r})?"image/heic":Be(r)??"application/octet-stream"),l=be({type:a,name:r}),u=a.startsWith("image/")||l;if(i.image&&!u)return{refused:`\u201C${r}\u201D isn\u2019t a picture.`};if(i.video)return a.startsWith("video/")?K({blob:e,name:r,type:a},n):{refused:`\u201C${r}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(a)&&(i.camera||e.size>n.maxBytes||e.size>15e5))try{let c=await ye(e,Ve),b=await new Promise(p=>c.toBlob(p,"image/jpeg",Ie));if(b)return K({blob:b,name:l?r.replace(/\.hei[cf]$/i,"")+".jpg":r,type:"image/jpeg",width:c.width,height:c.height},n)}catch{if(l&&!Fe(n.kinds,a))return{refused:`\u201C${r}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let y={};if(u&&!l)try{let c=await createImageBitmap(e);y={width:c.width,height:c.height},c.close()}catch{}return K({blob:e,name:r,type:a,...y},n)}function K(e,n){return Fe(n.kinds,e.type)?e.blob.size>n.maxBytes?{refused:`\u201C${e.name}\u201D is ${_(e.blob.size)}; this host takes files up to ${_(n.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${z(e)} file; this host takes ${ke(n.kinds)}.`}}async function _e(e,n,i,r=!1){let a;try{a=await n.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(a)?i&&!E(a)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:r&&!x(a)?{refused:`The host kept \u201C${e.name}\u201D as ${z(a)}, not as a video.`}:{...a,...a.width===void 0&&e.width?{width:e.width}:{},...a.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function Z(e){let n=S(),i=ue()?.past!=null,[r,a]=(0,h.useState)(!1),l=n?.kept?ze(n,e.href):!0,[,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(y=>y+1)),()=>void(s=!1)},[l]),[l===!1||i&&r,()=>a(!0)]}var J=new WeakMap;function ze(e,n){let i=J.get(e)?.get(n);if(i!==void 0)return i;let r;try{r=e.kept(n)}catch{return!0}if(typeof r=="boolean")return r;let a=J.get(e)??new Map;J.set(e,a);let l=Promise.resolve(r).then(u=>u!==!1,()=>!0);return a.set(n,l),l.then(u=>a.set(n,u)),l}function ee({file:e,style:n}){return(0,t.jsx)("span",{role:"img","aria-label":`${k(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:F,...n},children:"removed later"})}function Q({file:e,size:n=56,style:i}){let r=S(),[a,l]=Z(e);return a?(0,t.jsx)(ee,{file:e,style:{width:n,height:n,flex:"none",...i}}):x(e)?(0,t.jsx)(Ae,{file:e,size:n,...i?{style:i}:{},onError:l}):(0,t.jsx)("img",{onError:l,src:w(r,e.href),alt:k(e),width:n,height:n,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:n,height:n,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...i}})}function $e(e){let[n,i]=(0,h.useState)({}),r=e.duration??n.duration;return[{...r!==void 0?{duration:r}:{},width:e.width??n.width,height:e.height??n.height},u=>{let s=u.currentTarget;i({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,xe=(e,n)=>`${k(e)}, ${se({...n!==void 0?{duration:n}:{}})}`,Oe=(0,t.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,t.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:n,style:i,onError:r}){let a=S(),[l,u]=$e(e),s={width:n,height:n,objectFit:"cover",display:"block",borderRadius:F,background:"var(--graview-edge)"};return(0,t.jsxs)("span",{role:"img","aria-label":xe(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:n,height:n,flex:"none",...i},children:[e.poster?(0,t.jsx)("img",{src:w(a,e.poster),alt:"",width:n,height:n,loading:"lazy",decoding:"async",onError:r,style:s}):(0,t.jsx)("video",{src:w(a,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:n,height:n,onLoadedMetadata:u,onError:r,style:s}),Oe,l.duration!==void 0?(0,t.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:q(l.duration)}):null]})}function Ge({file:e}){let n=S(),[i,r]=Z(e),[a,l]=$e(e);if(i)return(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let u=a.width!==void 0&&a.height!==void 0;return(0,t.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0},children:[(0,t.jsx)("video",{"data-graview-video":e.href,src:w(n,e.href),...e.poster?{poster:w(n,e.poster)}:{},controls:!0,preload:"metadata",playsInline:!0,...u?{width:a.width,height:a.height}:{},"aria-label":xe(e,a.duration),onLoadedMetadata:l,onError:r,style:{display:"block",width:"100%",maxWidth:u?Math.max(a.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:u?`${a.width} / ${a.height}`:"16 / 9",borderRadius:F,background:"#000"},children:e.captions?(0,t.jsx)("track",{kind:"captions",src:w(n,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),(0,t.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...a.duration!==void 0?[q(a.duration)]:[]].join(" \xB7 ")})]})}function Ue({file:e,onOpen:n}){let i=S(),[r,a]=Z(e);return r?(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,t.jsx)("button",{type:"button","aria-label":`Open ${k(e)} full size`,onClick:l=>n(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:w(i,e.href),alt:k(e),loading:"lazy",decoding:"async",onError:a,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})}function X({files:e,label:n}){let i=S(),r=d=>w(i,d.href),a=e.filter(E),l=e.filter(x),u=e.filter(d=>!E(d)&&!x(d)),[s,y]=(0,h.useState)(null),c=(0,h.useRef)(null),b=(0,h.useRef)(null);(0,h.useEffect)(()=>{let d=c.current;s!==null&&d&&!d.open&&d.showModal?.()},[s]);let p=s===null?void 0:a[s];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[a.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:a.map((d,T)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ue,{file:d,onOpen:R=>{b.current=R,y(T)}})},d.href))}):null,l.length>0?(0,t.jsx)("ul",{"data-graview-videos":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:l.map(d=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ge,{file:d})},d.href))}):null,u.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:u.map(d=>(0,t.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,t.jsx)("object",{data:r(d),type:"application/pdf","aria-label":k(d),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:r(d),download:d.name,children:["download ",d.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:r(d),download:d.name,...d.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:d.name}),(0,t.jsxs)("span",{style:P,children:[z(d)," \xB7 ",_(d.bytes)]})]}),d.caption?(0,t.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,p?(0,t.jsx)("dialog",{ref:c,"data-graview-full":p.href,"aria-label":k(p),onClose:()=>{y(null),b.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:r(p),alt:k(p),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:p.caption??p.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:n,several:i,image:r,video:a=!1,label:l,thumbs:u=!0}){let s=S(),y=(0,h.useId)(),c=(0,h.useRef)(null),b=(0,h.useRef)(null),[p,d]=(0,h.useState)(null),[T,R]=(0,h.useState)(null),[te,H]=(0,h.useState)([]),[N,O]=(0,h.useState)(!1),W=r?"image/":a?"video/":void 0,C=s?W?s.kinds.filter(o=>o.startsWith(W)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||C.length>0:!1,Re=!a&&(s?s.kinds.length===0||(r?C:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,L=ne&&(!W||Pe),V=r?"picture":a?"video":"file",ae=i?`${V}s`:`a ${V}`,ie=W?C.length>0?C.join(","):`${W}*`:s?.kinds.join(",")||void 0,We=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,A=(0,h.useRef)(e);A.current=e;let re=(0,h.useRef)(null),I=(0,h.useRef)(null);(0,h.useEffect)(()=>{let o=I.current;if(!o||o.from===e)return;I.current=null;let g=re.current?.children,f=g?.[Math.min(o.at,g.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let D=async(o,g)=>{if(!s||o.length===0)return;let f=i?o:o.slice(0,1),m=[],$=[];f.length<o.length&&$.push(`${l} holds one ${V}, so ${o.slice(1).map(v=>`\u201C${v.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),H([]),R(null);for(let v of f){d(`Sending ${v.name||"the photo"}\u2026`);let G=await je(v,s,{image:r,video:a,camera:g==="camera"});if("refused"in G){$.push(G.refused);continue}let M=await _e(G,s,r,a);"refused"in M?$.push(M.refused):[...i?A.current:[],...m].some(He=>He.href===M.href)?$.push(`\u201C${M.name}\u201D is already here.`):m.push(M)}if(d(null),H($),m.length!==0)try{n(i?[...A.current,...m]:m.slice(-1)),R(`Added ${m.map(v=>v.name).join(", ")}.`)}catch(v){H([...$,v instanceof Error?v.message:String(v)])}},B=(o,g,f)=>{try{I.current=f?{...f,from:e}:null,n(o),R(g)}catch(m){I.current=null,H([m instanceof Error?m.message:String(m)])}},j=o=>o?Array.from(o):[],Me=o=>{let g=j(o.clipboardData?.files);!L||g.length===0||(o.preventDefault(),D(g,"pasted"))},Te=o=>{O(!1),L&&(o.preventDefault(),D(j(o.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${y}-label`,"data-graview-file-editor":"","data-graview-dropping":N?"":void 0,onPaste:Me,onDragOver:o=>{L&&(o.preventDefault(),O(!0))},onDragLeave:()=>O(!1),onDrop:Te,style:{display:"grid",gap:8,minWidth:0,padding:N?6:0,outline:N?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${y}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(i||e.length>1)?(0,t.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,g)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(E(o)||x(o))?(0,t.jsx)(Q,{file:o,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,t.jsx)(we,{file:o,onCaption:f=>B(e.map((m,$)=>$===g?ve(m,f):m),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),i&&g>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>B(e.map((f,m)=>m===g-1?o:m===g?e[g-1]:f),`Moved ${o.name} earlier.`,{at:g-1,what:"move"}),children:"\u2191"}):null,i?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>B(e.filter((f,m)=>m!==g),`Removed ${o.name}.`,{at:g,what:"remove"}),children:"Remove"}):null]},`${g}:${o.href}`))}):e.length===1?(0,t.jsx)(we,{file:e[0],onCaption:o=>B([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,L?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:i,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!i?`Replace the ${V}`:`Choose ${ae}`}),Re?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"camera")}}),We?(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",i?"them":"it"," here \xB7 ",s.kinds.length>0?ke(C.length>0?C:s.kinds):"any file",", up to ",_(s.maxBytes)]})]}):(0,t.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${a?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:p||T?void 0:0},"data-graview-file-status":"",children:p??T??""}),te.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:te.map((o,g)=>(0,t.jsx)("p",{style:{margin:0},children:o},g))}):null]})}var ve=(e,n)=>{let{caption:i,...r}=e;return n?{...r,caption:n}:r};function we({file:e,onCaption:n}){let[i,r]=(0,h.useState)(e.caption??"");(0,h.useEffect)(()=>r(e.caption??""),[e.caption]);let a=()=>{let l=i.trim().slice(0,500);l!==(e.caption??"")&&n(l)};return(0,t.jsx)("input",{type:"text",value:i,placeholder:E(e)||x(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${E(e)||x(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>r(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:n,labelStyle:i,valueStyle:r,style:a,children:l}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...a},children:[(0,t.jsx)("dt",{style:i,children:n}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...r},children:l})]})}function Ce(e){let{nodeId:n,field:i,label:r,files:a}=e,{fields:l,commit:u}=me(n),s=l.find(p=>p.field===i&&p.takesValue),y=s?.shape,c=y?.type==="several"?y.of:y,b=y?.type==="several";return a.length===0&&c?.type!=="file"?null:(0,t.jsxs)(Ee,{...e,children:[(0,t.jsx)(X,{files:a,label:r}),s&&c?.type==="file"?(0,t.jsx)(Se,{value:a,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:r,onChange:p=>{let d=b?p:p[p.length-1];d!==void 0&&u(s,d)}}):null]})}function et(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(Ee,{...e,children:(0,t.jsx)(X,{files:e.files,label:e.label})}):null:(0,t.jsx)(Ce,{...e});case"unfilled":return(0,t.jsx)(Ye,{...e});case"thumb":return(0,t.jsx)(Q,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(Q,{file:e.files[0],size:72}):(0,t.jsx)(X,{files:e.files,label:e.label})}):null;case"control":{let n=(0,t.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:i=>e.onChange(e.several?i:i[i.length-1])});return e.title===void 0?n:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),n]})}}}function Ye({nodeId:e,skip:n,labels:i,labelStyle:r,style:a}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,y=pe(s).filter(c=>!n.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return y.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:y.map(c=>(0,t.jsx)(Ce,{nodeId:e,field:c,label:i?.[c]??oe(s,c),files:[],...r?{labelStyle:r}:{},...a?{style:a}:{}},c))})}export{Se as FilesEditor,Ve as SEND_EDGE,et as drawFiles,ke as kindsWords,je as prepare,_e as send,_ as sizeWords,Fe as takes,z as typeWords};
1
+ import"./chunk.WVUJXDXZ.js";import{a as k,b as q,c as pe}from"./chunk.7INWDFNG.js";import"./chunk.FPGU43SC.js";import"./chunk.V6FUYRZI.js";import"./chunk.5BPRGXIW.js";import"./chunk.BZEJM2PY.js";import"./chunk.CMLNBJZG.js";import"./chunk.GZHZLJBF.js";import{n as me}from"./chunk.QPL3OXW3.js";import"./chunk.OJGHDWI6.js";import"./chunk.FRERJWZJ.js";import"./chunk.RQX4CQJN.js";import"./chunk.LUIRQ5UF.js";import"./chunk.N33WUCAN.js";import"./chunk.JQFIZRAZ.js";import"./chunk.LKJ6FD6Y.js";import{G as Le,M as S,O as ue,T as ce,ba as ge,ea as he}from"./chunk.DBMZ3AQB.js";import"./chunk.SDO3U72B.js";import{Uc as de,ma as oe,pa as w,ra as le,ta as E,ua as x,va as se,wa as Y}from"./chunk.DIFR37EZ.js";import"./chunk.FQLNBIQ5.js";import{b as U}from"./chunk.AJZBJBMO.js";var h=U(Le(),1);async function ye(e,n){let i=await createImageBitmap(e);try{let r=Math.min(1,n/Math.max(i.width,i.height)),a=document.createElement("canvas");a.width=Math.max(1,Math.round(i.width*r)),a.height=Math.max(1,Math.round(i.height*r));let l=a.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(i,0,0,a.width,a.height),a}finally{i.close()}}var t=U(ce(),1),Ve=2048,Ie=.85;function _(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function z(e){if(e.type==="application/pdf")return"PDF";let n=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return n?n.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let n=[...new Set(e.map(i=>i==="image/*"?"pictures":i==="video/*"?"videos":i==="*/*"||i==="*"?"any file":`${z({type:i})} files`))];return n.length<=1?n[0]??"no files":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}function Fe(e,n){if(e.length===0)return!0;let i=`${n.split("/")[0]}/*`;return e.some(r=>r==="*"||r==="*/*"||r===n||r===i)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,n,i){let r=e.name||(i.camera?"photo.jpg":"file"),a=e.type||(be({type:"",name:r})?"image/heic":Be(r)??"application/octet-stream"),l=be({type:a,name:r}),u=a.startsWith("image/")||l;if(i.image&&!u)return{refused:`\u201C${r}\u201D isn\u2019t a picture.`};if(i.video)return a.startsWith("video/")?K({blob:e,name:r,type:a},n):{refused:`\u201C${r}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(a)&&(i.camera||e.size>n.maxBytes||e.size>15e5))try{let c=await ye(e,Ve),b=await new Promise(p=>c.toBlob(p,"image/jpeg",Ie));if(b)return K({blob:b,name:l?r.replace(/\.hei[cf]$/i,"")+".jpg":r,type:"image/jpeg",width:c.width,height:c.height},n)}catch{if(l&&!Fe(n.kinds,a))return{refused:`\u201C${r}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let y={};if(u&&!l)try{let c=await createImageBitmap(e);y={width:c.width,height:c.height},c.close()}catch{}return K({blob:e,name:r,type:a,...y},n)}function K(e,n){return Fe(n.kinds,e.type)?e.blob.size>n.maxBytes?{refused:`\u201C${e.name}\u201D is ${_(e.blob.size)}; this host takes files up to ${_(n.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${z(e)} file; this host takes ${ke(n.kinds)}.`}}async function _e(e,n,i,r=!1){let a;try{a=await n.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(a)?i&&!E(a)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:r&&!x(a)?{refused:`The host kept \u201C${e.name}\u201D as ${z(a)}, not as a video.`}:{...a,...a.width===void 0&&e.width?{width:e.width}:{},...a.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function Z(e){let n=S(),i=ue()?.past!=null,[r,a]=(0,h.useState)(!1),l=n?.kept?ze(n,e.href):!0,[,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(y=>y+1)),()=>void(s=!1)},[l]),[l===!1||i&&r,()=>a(!0)]}var J=new WeakMap;function ze(e,n){let i=J.get(e)?.get(n);if(i!==void 0)return i;let r;try{r=e.kept(n)}catch{return!0}if(typeof r=="boolean")return r;let a=J.get(e)??new Map;J.set(e,a);let l=Promise.resolve(r).then(u=>u!==!1,()=>!0);return a.set(n,l),l.then(u=>a.set(n,u)),l}function ee({file:e,style:n}){return(0,t.jsx)("span",{role:"img","aria-label":`${k(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:F,...n},children:"removed later"})}function Q({file:e,size:n=56,style:i}){let r=S(),[a,l]=Z(e);return a?(0,t.jsx)(ee,{file:e,style:{width:n,height:n,flex:"none",...i}}):x(e)?(0,t.jsx)(Ae,{file:e,size:n,...i?{style:i}:{},onError:l}):(0,t.jsx)("img",{onError:l,src:w(r,e.href),alt:k(e),width:n,height:n,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:n,height:n,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...i}})}function $e(e){let[n,i]=(0,h.useState)({}),r=e.duration??n.duration;return[{...r!==void 0?{duration:r}:{},width:e.width??n.width,height:e.height??n.height},u=>{let s=u.currentTarget;i({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,xe=(e,n)=>`${k(e)}, ${se({...n!==void 0?{duration:n}:{}})}`,Oe=(0,t.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,t.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:n,style:i,onError:r}){let a=S(),[l,u]=$e(e),s={width:n,height:n,objectFit:"cover",display:"block",borderRadius:F,background:"var(--graview-edge)"};return(0,t.jsxs)("span",{role:"img","aria-label":xe(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:n,height:n,flex:"none",...i},children:[e.poster?(0,t.jsx)("img",{src:w(a,e.poster),alt:"",width:n,height:n,loading:"lazy",decoding:"async",onError:r,style:s}):(0,t.jsx)("video",{src:w(a,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:n,height:n,onLoadedMetadata:u,onError:r,style:s}),Oe,l.duration!==void 0?(0,t.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:q(l.duration)}):null]})}function Ge({file:e}){let n=S(),[i,r]=Z(e),[a,l]=$e(e);if(i)return(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let u=a.width!==void 0&&a.height!==void 0;return(0,t.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0},children:[(0,t.jsx)("video",{"data-graview-video":e.href,src:w(n,e.href),...e.poster?{poster:w(n,e.poster)}:{},controls:!0,preload:"metadata",playsInline:!0,...u?{width:a.width,height:a.height}:{},"aria-label":xe(e,a.duration),onLoadedMetadata:l,onError:r,style:{display:"block",width:"100%",maxWidth:u?Math.max(a.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:u?`${a.width} / ${a.height}`:"16 / 9",borderRadius:F,background:"#000"},children:e.captions?(0,t.jsx)("track",{kind:"captions",src:w(n,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),(0,t.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...a.duration!==void 0?[q(a.duration)]:[]].join(" \xB7 ")})]})}function Ue({file:e,onOpen:n}){let i=S(),[r,a]=Z(e);return r?(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,t.jsx)("button",{type:"button","aria-label":`Open ${k(e)} full size`,onClick:l=>n(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:w(i,e.href),alt:k(e),loading:"lazy",decoding:"async",onError:a,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})}function X({files:e,label:n}){let i=S(),r=d=>w(i,d.href),a=e.filter(E),l=e.filter(x),u=e.filter(d=>!E(d)&&!x(d)),[s,y]=(0,h.useState)(null),c=(0,h.useRef)(null),b=(0,h.useRef)(null);(0,h.useEffect)(()=>{let d=c.current;s!==null&&d&&!d.open&&d.showModal?.()},[s]);let p=s===null?void 0:a[s];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[a.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:a.map((d,T)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ue,{file:d,onOpen:R=>{b.current=R,y(T)}})},d.href))}):null,l.length>0?(0,t.jsx)("ul",{"data-graview-videos":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:l.map(d=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ge,{file:d})},d.href))}):null,u.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:u.map(d=>(0,t.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,t.jsx)("object",{data:r(d),type:"application/pdf","aria-label":k(d),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:r(d),download:d.name,children:["download ",d.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:r(d),download:d.name,...d.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:d.name}),(0,t.jsxs)("span",{style:P,children:[z(d)," \xB7 ",_(d.bytes)]})]}),d.caption?(0,t.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,p?(0,t.jsx)("dialog",{ref:c,"data-graview-full":p.href,"aria-label":k(p),onClose:()=>{y(null),b.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:r(p),alt:k(p),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:p.caption??p.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:n,several:i,image:r,video:a=!1,label:l,thumbs:u=!0}){let s=S(),y=(0,h.useId)(),c=(0,h.useRef)(null),b=(0,h.useRef)(null),[p,d]=(0,h.useState)(null),[T,R]=(0,h.useState)(null),[te,H]=(0,h.useState)([]),[N,O]=(0,h.useState)(!1),W=r?"image/":a?"video/":void 0,C=s?W?s.kinds.filter(o=>o.startsWith(W)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||C.length>0:!1,Re=!a&&(s?s.kinds.length===0||(r?C:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,L=ne&&(!W||Pe),V=r?"picture":a?"video":"file",ae=i?`${V}s`:`a ${V}`,ie=W?C.length>0?C.join(","):`${W}*`:s?.kinds.join(",")||void 0,We=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,A=(0,h.useRef)(e);A.current=e;let re=(0,h.useRef)(null),I=(0,h.useRef)(null);(0,h.useEffect)(()=>{let o=I.current;if(!o||o.from===e)return;I.current=null;let g=re.current?.children,f=g?.[Math.min(o.at,g.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let D=async(o,g)=>{if(!s||o.length===0)return;let f=i?o:o.slice(0,1),m=[],$=[];f.length<o.length&&$.push(`${l} holds one ${V}, so ${o.slice(1).map(v=>`\u201C${v.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),H([]),R(null);for(let v of f){d(`Sending ${v.name||"the photo"}\u2026`);let G=await je(v,s,{image:r,video:a,camera:g==="camera"});if("refused"in G){$.push(G.refused);continue}let M=await _e(G,s,r,a);"refused"in M?$.push(M.refused):[...i?A.current:[],...m].some(He=>He.href===M.href)?$.push(`\u201C${M.name}\u201D is already here.`):m.push(M)}if(d(null),H($),m.length!==0)try{n(i?[...A.current,...m]:m.slice(-1)),R(`Added ${m.map(v=>v.name).join(", ")}.`)}catch(v){H([...$,v instanceof Error?v.message:String(v)])}},B=(o,g,f)=>{try{I.current=f?{...f,from:e}:null,n(o),R(g)}catch(m){I.current=null,H([m instanceof Error?m.message:String(m)])}},j=o=>o?Array.from(o):[],Me=o=>{let g=j(o.clipboardData?.files);!L||g.length===0||(o.preventDefault(),D(g,"pasted"))},Te=o=>{O(!1),L&&(o.preventDefault(),D(j(o.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${y}-label`,"data-graview-file-editor":"","data-graview-dropping":N?"":void 0,onPaste:Me,onDragOver:o=>{L&&(o.preventDefault(),O(!0))},onDragLeave:()=>O(!1),onDrop:Te,style:{display:"grid",gap:8,minWidth:0,padding:N?6:0,outline:N?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${y}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(i||e.length>1)?(0,t.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,g)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(E(o)||x(o))?(0,t.jsx)(Q,{file:o,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,t.jsx)(we,{file:o,onCaption:f=>B(e.map((m,$)=>$===g?ve(m,f):m),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),i&&g>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>B(e.map((f,m)=>m===g-1?o:m===g?e[g-1]:f),`Moved ${o.name} earlier.`,{at:g-1,what:"move"}),children:"\u2191"}):null,i?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>B(e.filter((f,m)=>m!==g),`Removed ${o.name}.`,{at:g,what:"remove"}),children:"Remove"}):null]},`${g}:${o.href}`))}):e.length===1?(0,t.jsx)(we,{file:e[0],onCaption:o=>B([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,L?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:i,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!i?`Replace the ${V}`:`Choose ${ae}`}),Re?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"camera")}}),We?(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",i?"them":"it"," here \xB7 ",s.kinds.length>0?ke(C.length>0?C:s.kinds):"any file",", up to ",_(s.maxBytes)]})]}):(0,t.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${a?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:p||T?void 0:0},"data-graview-file-status":"",children:p??T??""}),te.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:te.map((o,g)=>(0,t.jsx)("p",{style:{margin:0},children:o},g))}):null]})}var ve=(e,n)=>{let{caption:i,...r}=e;return n?{...r,caption:n}:r};function we({file:e,onCaption:n}){let[i,r]=(0,h.useState)(e.caption??"");(0,h.useEffect)(()=>r(e.caption??""),[e.caption]);let a=()=>{let l=i.trim().slice(0,500);l!==(e.caption??"")&&n(l)};return(0,t.jsx)("input",{type:"text",value:i,placeholder:E(e)||x(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${E(e)||x(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>r(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:n,labelStyle:i,valueStyle:r,style:a,children:l}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...a},children:[(0,t.jsx)("dt",{style:i,children:n}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...r},children:l})]})}function Ce(e){let{nodeId:n,field:i,label:r,files:a}=e,{fields:l,commit:u}=me(n),s=l.find(p=>p.field===i&&p.takesValue),y=s?.shape,c=y?.type==="several"?y.of:y,b=y?.type==="several";return a.length===0&&c?.type!=="file"?null:(0,t.jsxs)(Ee,{...e,children:[(0,t.jsx)(X,{files:a,label:r}),s&&c?.type==="file"?(0,t.jsx)(Se,{value:a,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:r,onChange:p=>{let d=b?p:p[p.length-1];d!==void 0&&u(s,d)}}):null]})}function et(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(Ee,{...e,children:(0,t.jsx)(X,{files:e.files,label:e.label})}):null:(0,t.jsx)(Ce,{...e});case"unfilled":return(0,t.jsx)(Ye,{...e});case"thumb":return(0,t.jsx)(Q,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(Q,{file:e.files[0],size:72}):(0,t.jsx)(X,{files:e.files,label:e.label})}):null;case"control":{let n=(0,t.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:i=>e.onChange(e.several?i:i[i.length-1])});return e.title===void 0?n:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),n]})}}}function Ye({nodeId:e,skip:n,labels:i,labelStyle:r,style:a}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,y=pe(s).filter(c=>!n.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return y.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:y.map(c=>(0,t.jsx)(Ce,{nodeId:e,field:c,label:i?.[c]??oe(s,c),files:[],...r?{labelStyle:r}:{},...a?{style:a}:{}},c))})}export{Se as FilesEditor,Ve as SEND_EDGE,et as drawFiles,ke as kindsWords,je as prepare,_e as send,_ as sizeWords,Fe as takes,z as typeWords};
@@ -1 +1 @@
1
- import{j as m}from"./chunk.HFVMGTNL.js";import{G as N,T as f,X as y}from"./chunk.NPAWTPLQ.js";import{b as g}from"./chunk.AJZBJBMO.js";var p=g(N(),1);var a=g(f(),1);var R={default:{background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)"},muted:{background:"var(--graview-panel-muted, #f7f5f1)",color:"var(--graview-ink, #1a1a1a)"},warning:{background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)"}},T={color:"var(--graview-ink-muted, #55514a)"},C={color:"var(--graview-ink-faint, #625d55)"};function H(e){let[l,o]=(0,p.useState)(z);return(0,p.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let t=()=>{let i=W(r,parseFloat(getComputedStyle(r).paddingBottom)||0);o(s=>s.overflowing===i.overflowing&&s.above===i.above&&s.below===i.below?s:i)};t();let d=new ResizeObserver(t);d.observe(r);for(let i of r.children)d.observe(i);return r.addEventListener("scroll",t,{passive:!0}),()=>{d.disconnect(),r.removeEventListener("scroll",t)}}),l}var z={overflowing:!1,above:!1,below:!1};function W(e,l=0){let o=e.scrollHeight>e.clientHeight+1,r=e.scrollWidth>e.clientWidth+1;return{overflowing:o||r,above:o&&e.scrollTop>1,below:o&&e.scrollTop+e.clientHeight<e.scrollHeight-l-1}}var A=(0,p.createContext)(null),I=(0,p.createContext)(null);function O({level:e,said:l=!0,style:o,children:r}){if(e===void 0)return(0,a.jsx)("strong",{style:o,...l?{}:{"aria-hidden":!0},children:r});let t=`h${e}`;return(0,a.jsx)(t,{style:{margin:0,...o},children:r})}function E({title:e,subtitle:l,meta:o,selected:r,tone:t="default",children:d,style:i,fit:s=!1,variant:w,heading:b}){let c=(0,p.useRef)(null),{overflowing:v,above:x,below:S}=H(c),P=y(),n=(w??(P==="fullscreen"?"page":"card"))==="page",k=(0,p.useContext)(A),u=(0,p.useContext)(I);return(0,a.jsxs)("div",{"data-graview-primitive":"panel","data-graview-variant":n?"page":"card","data-selected":r||void 0,style:{display:"flex",flexDirection:"column",gap:n?12:"var(--graview-gap, 7px)",height:n||s?"auto":"100%",maxHeight:n?"none":"100%",padding:n?0:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:n?0:"var(--graview-radius, 12px)",border:n?"none":`1px solid ${r?"var(--graview-accent, #2f6f5e)":"var(--graview-edge, #e4e0d8)"}`,boxShadow:n?"none":r?"0 0 0 1px var(--graview-accent-dim), var(--graview-lift-low)":"var(--graview-lift-low)",overflow:n?"visible":"hidden",...R[t],...n?{background:"transparent"}:{},...i},children:[t==="warning"?(0,a.jsx)("span",{"data-graview-broken":"",style:m,children:"Implicated in a problem."}):null,e===void 0||e===k?null:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0},children:[t==="warning"?(0,a.jsx)("span",{"aria-hidden":"true",title:"Implicated in a problem",style:{color:"var(--graview-warn)",flex:"0 0 auto"},children:"\u26A0"}):null,(0,a.jsx)(O,{level:b,said:u===null||e!==u,style:{fontFamily:"var(--graview-font-display, inherit)",fontSize:n?"1.5625rem":"0.9375rem",lineHeight:n?1.15:1.25,fontWeight:n?600:560,letterSpacing:n?"-0.012em":"0.005em",minWidth:0,overflowWrap:"anywhere"},children:e}),o===void 0?null:(0,a.jsx)("span",{style:{marginLeft:"auto",fontSize:"0.75rem",letterSpacing:"0.08em",textTransform:"uppercase",minWidth:0,overflowWrap:"anywhere",...C},children:o})]}),l===void 0?null:(0,a.jsx)("div",{style:{fontSize:n?"0.90625rem":"0.8125rem",lineHeight:1.5,...T},children:l}),(0,a.jsx)("div",{ref:c,className:n?void 0:"graview-scroll",...v&&!n?{tabIndex:0,role:"region",...typeof e=="string"?{"aria-label":e}:{}}:{},style:{display:"flex",flexDirection:"column",gap:n?22:"var(--graview-gap, 7px)",flex:"1 1 auto",...n?{overflow:"visible"}:{marginBottom:"calc(-1 * var(--graview-pad, 15px))",paddingBottom:"var(--graview-pad, 15px)"},...!n&&!v?{overflow:"hidden"}:{}},"data-graview-more-above":x&&!n?"":void 0,"data-graview-more-below":S&&!n?"":void 0,children:d})]})}function h({label:e,hue:l,selected:o,title:r,pickId:t,emphasis:d}){let i=typeof e=="string"?e:void 0,s=l===void 0?void 0:Math.round(l);return(0,a.jsxs)("span",{"data-graview-primitive":"chip","data-selected":o||void 0,"data-graview-pick":t,"data-graview-emphasis":d,title:r??i,style:{cursor:t?"pointer":void 0,display:"inline-flex",alignItems:"center",alignSelf:"flex-start",minHeight:24,boxSizing:"border-box",padding:"3px 9px",borderRadius:6,fontSize:"0.8125rem",lineHeight:1.5,whiteSpace:"nowrap",maxWidth:"min(28ch, 100%)",overflow:"hidden",letterSpacing:"0.01em",border:`1px solid ${o?"var(--graview-accent)":s===void 0?"var(--graview-edge)":`hsl(${s} 55% var(--graview-tint-lightness) / 0.45)`}`,background:s===void 0?"var(--graview-panel-muted)":`hsl(${s} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * 0.65))`,color:"var(--graview-ink, #1a1a1a)",boxShadow:o?"0 0 14px -4px var(--graview-accent)":void 0},children:[s===void 0?null:(0,a.jsx)("span",{"aria-hidden":"true",style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",marginRight:6,background:`hsl(${s} 55% var(--graview-tint-lightness) / 0.9)`}}),(0,a.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function L({items:e,max:l=8,selectedIds:o=[],pick:r=!1}){let t=e.slice(0,l),d=e.length-t.length;return(0,a.jsxs)("div",{"data-graview-primitive":"roster",style:{display:"flex",flexWrap:"wrap",gap:6,alignContent:"flex-start"},children:[t.map(i=>(0,a.jsx)(h,{label:i.label,...i.hue===void 0?{}:{hue:i.hue},...r?{pickId:i.id}:{},...i.emphasis===void 0?{}:{emphasis:i.emphasis},selected:o.includes(i.id)},i.id)),d>0?(0,a.jsx)(h,{label:`+${d} more`}):null]})}function F({label:e,count:l,items:o,onExpand:r,flagged:t,problems:d}){return(0,a.jsx)(E,{title:e,meta:d?(0,a.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[d,(0,a.jsx)("span",{children:l})]}):l,tone:t?"warning":"muted",style:r?{cursor:"zoom-in"}:void 0,children:o&&o.length>0?(0,a.jsx)(L,{items:o,max:6,pick:!0}):null})}export{A as a,I as b,E as c,h as d,L as e,F as f};
1
+ import{j as m}from"./chunk.JQFIZRAZ.js";import{G as N,T as f,X as y}from"./chunk.DBMZ3AQB.js";import{b as g}from"./chunk.AJZBJBMO.js";var p=g(N(),1);var a=g(f(),1);var R={default:{background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)"},muted:{background:"var(--graview-panel-muted, #f7f5f1)",color:"var(--graview-ink, #1a1a1a)"},warning:{background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)"}},T={color:"var(--graview-ink-muted, #55514a)"},C={color:"var(--graview-ink-faint, #625d55)"};function H(e){let[l,o]=(0,p.useState)(z);return(0,p.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let t=()=>{let i=W(r,parseFloat(getComputedStyle(r).paddingBottom)||0);o(s=>s.overflowing===i.overflowing&&s.above===i.above&&s.below===i.below?s:i)};t();let d=new ResizeObserver(t);d.observe(r);for(let i of r.children)d.observe(i);return r.addEventListener("scroll",t,{passive:!0}),()=>{d.disconnect(),r.removeEventListener("scroll",t)}}),l}var z={overflowing:!1,above:!1,below:!1};function W(e,l=0){let o=e.scrollHeight>e.clientHeight+1,r=e.scrollWidth>e.clientWidth+1;return{overflowing:o||r,above:o&&e.scrollTop>1,below:o&&e.scrollTop+e.clientHeight<e.scrollHeight-l-1}}var A=(0,p.createContext)(null),I=(0,p.createContext)(null);function O({level:e,said:l=!0,style:o,children:r}){if(e===void 0)return(0,a.jsx)("strong",{style:o,...l?{}:{"aria-hidden":!0},children:r});let t=`h${e}`;return(0,a.jsx)(t,{style:{margin:0,...o},children:r})}function E({title:e,subtitle:l,meta:o,selected:r,tone:t="default",children:d,style:i,fit:s=!1,variant:w,heading:b}){let c=(0,p.useRef)(null),{overflowing:v,above:x,below:S}=H(c),P=y(),n=(w??(P==="fullscreen"?"page":"card"))==="page",k=(0,p.useContext)(A),u=(0,p.useContext)(I);return(0,a.jsxs)("div",{"data-graview-primitive":"panel","data-graview-variant":n?"page":"card","data-selected":r||void 0,style:{display:"flex",flexDirection:"column",gap:n?12:"var(--graview-gap, 7px)",height:n||s?"auto":"100%",maxHeight:n?"none":"100%",padding:n?0:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:n?0:"var(--graview-radius, 12px)",border:n?"none":`1px solid ${r?"var(--graview-accent, #2f6f5e)":"var(--graview-edge, #e4e0d8)"}`,boxShadow:n?"none":r?"0 0 0 1px var(--graview-accent-dim), var(--graview-lift-low)":"var(--graview-lift-low)",overflow:n?"visible":"hidden",...R[t],...n?{background:"transparent"}:{},...i},children:[t==="warning"?(0,a.jsx)("span",{"data-graview-broken":"",style:m,children:"Implicated in a problem."}):null,e===void 0||e===k?null:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0},children:[t==="warning"?(0,a.jsx)("span",{"aria-hidden":"true",title:"Implicated in a problem",style:{color:"var(--graview-warn)",flex:"0 0 auto"},children:"\u26A0"}):null,(0,a.jsx)(O,{level:b,said:u===null||e!==u,style:{fontFamily:"var(--graview-font-display, inherit)",fontSize:n?"1.5625rem":"0.9375rem",lineHeight:n?1.15:1.25,fontWeight:n?600:560,letterSpacing:n?"-0.012em":"0.005em",minWidth:0,overflowWrap:"anywhere"},children:e}),o===void 0?null:(0,a.jsx)("span",{style:{marginLeft:"auto",fontSize:"0.75rem",letterSpacing:"0.08em",textTransform:"uppercase",minWidth:0,overflowWrap:"anywhere",...C},children:o})]}),l===void 0?null:(0,a.jsx)("div",{style:{fontSize:n?"0.90625rem":"0.8125rem",lineHeight:1.5,...T},children:l}),(0,a.jsx)("div",{ref:c,className:n?void 0:"graview-scroll",...v&&!n?{tabIndex:0,role:"region",...typeof e=="string"?{"aria-label":e}:{}}:{},style:{display:"flex",flexDirection:"column",gap:n?22:"var(--graview-gap, 7px)",flex:"1 1 auto",...n?{overflow:"visible"}:{marginBottom:"calc(-1 * var(--graview-pad, 15px))",paddingBottom:"var(--graview-pad, 15px)"},...!n&&!v?{overflow:"hidden"}:{}},"data-graview-more-above":x&&!n?"":void 0,"data-graview-more-below":S&&!n?"":void 0,children:d})]})}function h({label:e,hue:l,selected:o,title:r,pickId:t,emphasis:d}){let i=typeof e=="string"?e:void 0,s=l===void 0?void 0:Math.round(l);return(0,a.jsxs)("span",{"data-graview-primitive":"chip","data-selected":o||void 0,"data-graview-pick":t,"data-graview-emphasis":d,title:r??i,style:{cursor:t?"pointer":void 0,display:"inline-flex",alignItems:"center",alignSelf:"flex-start",minHeight:24,boxSizing:"border-box",padding:"3px 9px",borderRadius:6,fontSize:"0.8125rem",lineHeight:1.5,whiteSpace:"nowrap",maxWidth:"min(28ch, 100%)",overflow:"hidden",letterSpacing:"0.01em",border:`1px solid ${o?"var(--graview-accent)":s===void 0?"var(--graview-edge)":`hsl(${s} 55% var(--graview-tint-lightness) / 0.45)`}`,background:s===void 0?"var(--graview-panel-muted)":`hsl(${s} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * 0.65))`,color:"var(--graview-ink, #1a1a1a)",boxShadow:o?"0 0 14px -4px var(--graview-accent)":void 0},children:[s===void 0?null:(0,a.jsx)("span",{"aria-hidden":"true",style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",marginRight:6,background:`hsl(${s} 55% var(--graview-tint-lightness) / 0.9)`}}),(0,a.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function L({items:e,max:l=8,selectedIds:o=[],pick:r=!1}){let t=e.slice(0,l),d=e.length-t.length;return(0,a.jsxs)("div",{"data-graview-primitive":"roster",style:{display:"flex",flexWrap:"wrap",gap:6,alignContent:"flex-start"},children:[t.map(i=>(0,a.jsx)(h,{label:i.label,...i.hue===void 0?{}:{hue:i.hue},...r?{pickId:i.id}:{},...i.emphasis===void 0?{}:{emphasis:i.emphasis},selected:o.includes(i.id)},i.id)),d>0?(0,a.jsx)(h,{label:`+${d} more`}):null]})}function F({label:e,count:l,items:o,onExpand:r,flagged:t,problems:d}){return(0,a.jsx)(E,{title:e,meta:d?(0,a.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[d,(0,a.jsx)("span",{children:l})]}):l,tone:t?"warning":"muted",style:r?{cursor:"zoom-in"}:void 0,children:o&&o.length>0?(0,a.jsx)(L,{items:o,max:6,pick:!0}):null})}export{A as a,I as b,E as c,h as d,L as e,F as f};
@@ -1 +1 @@
1
- import{A as S,G,l as O,y as v,z as C}from"./chunk.HFVMGTNL.js";import{G as I,ba as m,c as V,j as y,l as p,m as g,n as u,o as D,v as B,z as E}from"./chunk.NPAWTPLQ.js";import{Bd as R,Cd as T,ka as M,yd as P,zd as k}from"./chunk.YEJ4LNUP.js";import{b as A}from"./chunk.AJZBJBMO.js";var W=A(I(),1);function j(e,t){try{t.length===0?localStorage.removeItem(v(e)):localStorage.setItem(v(e),JSON.stringify(t))}catch{}}function F(e,t){j(e,[...S(e).filter(n=>n.title!==t.title),t])}function H(e,t){j(e,S(e).filter(n=>n.title!==t))}function J(e,t){for(let n of e.places().filter(o=>o.title===t))e.forget?.(n.kind,n.as)}var U=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},N=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function Z(e,t){let n=o=>t.some(r=>r.title===o||r.as===P(o));if(!n(e))return e;for(let o=2;;o++)if(!n(`${e} ${o}`))return`${e} ${o}`}function ie(e){let{store:t,views:n,brand:o,seatTalk:r,onKeepLens:d}=m(),h=(0,W.useContext)(O),L=C(o,t.schema),b=async f=>{let{edit:i}=f;if(f.written&&d)try{await d({op:"remove-lens",title:i.title,on:i.on})}catch{}H(L,i.title),J(n,i.title),h?.dismiss(`kept:${i.title}`),r.setTurns(l=>[...l.map(s=>s.kept&&s.kept.edit.title===i.title&&!s.kept.taken?{...s,kept:{...s.kept,taken:!0}}:s),{role:"seat",text:`Took \u201C${i.title}\u201D back out of the places.`}]);let a=M(t.schema,i.on);e({to:"kind",kind:i.on,title:a,address:k(t.schema,i.on),said:`Went to ${a}.`})};return{keep:async f=>{let i=Z(f.edit.title,n.places()),a={...f.edit,title:i},l=!1,s;if(d)try{({written:l,said:s}=U(await d(a)))}catch{l=!1}l||F(L,N(a)),G(n,t.schema,[N(a)]);let K=n.places(),c=K.find(w=>w.title===i),x=s??(l?`Kept \u201C${i}\u201D as a lens: it is in the places now.`:d?`Kept \u201C${i}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${i}\u201D as your own lens.`),$={edit:a,written:l};r.setDraft(null),r.setTurns(w=>[...w,{role:"seat",text:x,kept:$}]),h?.notify({kind:"toast",id:`kept:${i}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void b($)}}),c&&e({to:"picture",kind:c.kind,as:c.as,title:i,address:R(c.as,T(c,K)?k(t.schema,c.kind).slice(1):void 0),said:`Went to ${i}.`})},takeBack:b}}var q=A(I(),1);function _(e,t){switch(t.to){case"place":return{view:V("#")};case"picture":return{view:u(E(p(e,"filter",null),t.kind,t.as),[])};case"kind":{let n=D(g({...y(e,B(t.kind)),relation:null},!1),!0);return{view:u(p(p(n,"view",null),"filter",t.filter??null),[])}}case"record":return{view:u(y(g(p(p(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function z(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function ae(){let{setView:e,seatTalk:t}=m();return(0,q.useCallback)(n=>{t.get().draft&&t.setDraft(null),z(n.to==="problems"),n.to!=="problems"&&e(o=>{let r=_(o,n);return"view"in r?r.view:o})},[e,t])}export{ie as a,z as b,ae as c};
1
+ import{A as S,G,l as O,y as v,z as C}from"./chunk.JQFIZRAZ.js";import{G as I,ba as m,c as V,j as y,l as p,m as g,n as u,o as D,v as B,z as E}from"./chunk.DBMZ3AQB.js";import{Bd as R,Cd as T,ka as M,yd as P,zd as k}from"./chunk.DIFR37EZ.js";import{b as A}from"./chunk.AJZBJBMO.js";var W=A(I(),1);function j(e,t){try{t.length===0?localStorage.removeItem(v(e)):localStorage.setItem(v(e),JSON.stringify(t))}catch{}}function F(e,t){j(e,[...S(e).filter(n=>n.title!==t.title),t])}function H(e,t){j(e,S(e).filter(n=>n.title!==t))}function J(e,t){for(let n of e.places().filter(o=>o.title===t))e.forget?.(n.kind,n.as)}var U=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},N=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function Z(e,t){let n=o=>t.some(r=>r.title===o||r.as===P(o));if(!n(e))return e;for(let o=2;;o++)if(!n(`${e} ${o}`))return`${e} ${o}`}function ie(e){let{store:t,views:n,brand:o,seatTalk:r,onKeepLens:d}=m(),h=(0,W.useContext)(O),L=C(o,t.schema),b=async f=>{let{edit:i}=f;if(f.written&&d)try{await d({op:"remove-lens",title:i.title,on:i.on})}catch{}H(L,i.title),J(n,i.title),h?.dismiss(`kept:${i.title}`),r.setTurns(l=>[...l.map(s=>s.kept&&s.kept.edit.title===i.title&&!s.kept.taken?{...s,kept:{...s.kept,taken:!0}}:s),{role:"seat",text:`Took \u201C${i.title}\u201D back out of the places.`}]);let a=M(t.schema,i.on);e({to:"kind",kind:i.on,title:a,address:k(t.schema,i.on),said:`Went to ${a}.`})};return{keep:async f=>{let i=Z(f.edit.title,n.places()),a={...f.edit,title:i},l=!1,s;if(d)try{({written:l,said:s}=U(await d(a)))}catch{l=!1}l||F(L,N(a)),G(n,t.schema,[N(a)]);let K=n.places(),c=K.find(w=>w.title===i),x=s??(l?`Kept \u201C${i}\u201D as a lens: it is in the places now.`:d?`Kept \u201C${i}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${i}\u201D as your own lens.`),$={edit:a,written:l};r.setDraft(null),r.setTurns(w=>[...w,{role:"seat",text:x,kept:$}]),h?.notify({kind:"toast",id:`kept:${i}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void b($)}}),c&&e({to:"picture",kind:c.kind,as:c.as,title:i,address:R(c.as,T(c,K)?k(t.schema,c.kind).slice(1):void 0),said:`Went to ${i}.`})},takeBack:b}}var q=A(I(),1);function _(e,t){switch(t.to){case"place":return{view:V("#")};case"picture":return{view:u(E(p(e,"filter",null),t.kind,t.as),[])};case"kind":{let n=D(g({...y(e,B(t.kind)),relation:null},!1),!0);return{view:u(p(p(n,"view",null),"filter",t.filter??null),[])}}case"record":return{view:u(y(g(p(p(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function z(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function ae(){let{setView:e,seatTalk:t}=m();return(0,q.useCallback)(n=>{t.get().draft&&t.setDraft(null),z(n.to==="problems"),n.to!=="problems"&&e(o=>{let r=_(o,n);return"view"in r?r.view:o})},[e,t])}export{ie as a,z as b,ae as c};
@@ -1 +1 @@
1
- import{g as o,l as u}from"./chunk.NPAWTPLQ.js";function c(t,n,i){let e=r=>encodeURIComponent(r);return`${o}${e(t)}:${e(n)}:${e(i)}`}function S(t,n,i){let e=new Set(t.shown??[]);if(i?e.add(n):e.delete(n),e.size===0){let{shown:r,...w}=t;return w}return{...t,shown:[...e].sort()}}function l(t,n){if(n===null||n.trim().length===0){let{q:i,...e}=t;return e}return{...t,q:n}}function p(t){let n=t.q!==void 0&&t.within?.q===t.q;return l(n?u(t,"q",null):t,null)}function h(t,n){if(!n){let{past:i,...e}=t;return e}return{...t,past:!0}}function f(t,n){if(n===null||n.x===0&&n.y===0){let{pan:i,...e}=t;return e}return{...t,pan:n}}function d(t,n,i){let e={...t.pins};return i===null?delete e[n]:e[n]=i,{...t,pins:e}}export{c as a,S as b,l as c,p as d,h as e,f,d as g};
1
+ import{g as o,l as u}from"./chunk.DBMZ3AQB.js";function c(t,n,i){let e=r=>encodeURIComponent(r);return`${o}${e(t)}:${e(n)}:${e(i)}`}function S(t,n,i){let e=new Set(t.shown??[]);if(i?e.add(n):e.delete(n),e.size===0){let{shown:r,...w}=t;return w}return{...t,shown:[...e].sort()}}function l(t,n){if(n===null||n.trim().length===0){let{q:i,...e}=t;return e}return{...t,q:n}}function p(t){let n=t.q!==void 0&&t.within?.q===t.q;return l(n?u(t,"q",null):t,null)}function h(t,n){if(!n){let{past:i,...e}=t;return e}return{...t,past:!0}}function f(t,n){if(n===null||n.x===0&&n.y===0){let{pan:i,...e}=t;return e}return{...t,pan:n}}function d(t,n,i){let e={...t.pins};return i===null?delete e[n]:e[n]=i,{...t,pins:e}}export{c as a,S as b,l as c,p as d,h as e,f,d as g};
@@ -1 +1 @@
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{q as Ie}from"./chunk.7RJGEU3Y.js";import{d as Je,e as Ee,f as je,g as ze}from"./chunk.AKVBU5K5.js";import{a as He}from"./chunk.RDL6652E.js";import{e as X}from"./chunk.IT763BYH.js";import{a as z}from"./chunk.UQQAGT3R.js";import{f as Pe,g as Y,i as De}from"./chunk.DPPT6WAJ.js";import{a as Se}from"./chunk.7U2JO7ET.js";import{Aa as me,Da as K,Eb as ve,Fa as he,Ha as ye,Hb as Ae,Ia as Z,Ib as Oe,Lb as Re,M as pe,Ob as _e,Pa as ge,Qa as be,Rb as C,Ta as we,Zb as Te,_a as W,a as fe,cb as ke,ha as G,md as $e,nc as xe,oc as Me,pc as Ne}from"./chunk.YEJ4LNUP.js";var E=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},j=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},Q=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},Le=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},qe=(n,e)=>{n.multipleOf??=[],n.multipleOf.includes(e)||n.multipleOf.push(e)},Fe=(n,e)=>(n.patterns??=new Set).add(e),st={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function H(n){let e={},{def:t,bag:r}=n._zod,i=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":j(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":qe(e,a.value);break;case"number_format":{Q(e,a.format);let d=st[a.format];d&&(E(e,"minimum",d[0]),j(e,"maximum",d[1]));break}case"bigint_format":Q(e,a.format);break;case"min_length":case"min_size":E(e,"minimum",a.minimum);break;case"max_length":case"max_size":j(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),j(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),j(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Fe(e,a.pattern),(a.format==="base64"||a.format==="base64url")&&(e.contentEncoding=a.format),(a.local||a.precision===-1)&&(e.laxFormat=!0);break;case"mime_type":Le(e,a.mime);break}}r.minimum!==void 0&&E(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&j(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&j(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&qe(e,r.multipleOf),r.format!==void 0&&(e.format??=r.format,r.format.includes("int")&&(e.isInt=!0)),r.mime&&Le(e,r.mime);for(let o of r.patterns??[])Fe(e,o);return e}var dt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function L(n){let e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?L(e.out):e.type==="catch"?L(e.innerType):n._zod.optin}var ct=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function T(n,e=new Set){if(e.has(n))return!1;e.add(n);let t=n._zod.def,r=t.type;return r==="transform"?!0:r==="array"?T(t.element,e):r==="set"?T(t.valueType,e):r==="lazy"?T(t.getter(),e):ct.has(r)?T(t.innerType,e):r==="intersection"?T(t.left,e)||T(t.right,e):r==="record"||r==="map"?T(t.keyType,e)||T(t.valueType,e):r==="pipe"?n._zod.traits.has("$ZodCodec")||T(t.in,e)||T(t.out,e):r==="object"?Object.values(t.shape).some(i=>T(i,e)):r==="union"?t.options.some(i=>T(i,e)):r==="tuple"?t.items.some(i=>T(i,e))||(t.rest?T(t.rest,e):!1):!1}function lt(n){let e=Object.values(n).filter(t=>typeof t=="number");return Object.entries(n).filter(([t])=>e.indexOf(+t)===-1).map(([,t])=>t)}function Be(n){let e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;let t=[];for(let r of e){if(!r||typeof r!="object")return;Be(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;t.includes(o)||t.push(o)}}delete n.anyOf,n.type=t.length===1?t[0]:t}var Ue=new Set(["type","properties","required","additionalProperties"]),We=n=>{let e=n.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ce=(n,e)=>JSON.stringify(n)===JSON.stringify(e);function ee(n){for(let i of n){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!Ue.has(o))return null}let e={},t=new Set;for(let i of n){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(e,o))continue;let a=[];for(let d of n){let s=d.properties?.[o]??We(d);s&&!a.some(b=>Ce(b,s))&&a.push(s)}e[o]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let o of i.required??[])t.add(o)}let r={type:"object",properties:e};if(t.size&&(r.required=[...t]),n.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of n){let a=We(o);a&&!i.some(d=>Ce(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function ut(n){let e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ue)if(i in n)return;let t=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!t.length)r=ee(e);else{let i=t[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[o].map(s=>ee([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete n.allOf,Object.assign(n,r))}function Ve(n){let e=n;for(let y of["anyOf","oneOf"]){let _=e[y];if(!Array.isArray(_))continue;let O=_.map(Ve);O.some((v,m)=>v!==_[m])&&(e={...e,[y]:O})}let t=[e.type].flat(),r=!t.includes("string")&&t.some(y=>y==="number"||y==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!i?.some(y=>typeof y=="number"))return e;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:b,format:f,id:w,...h}=e;return h.enum?h.enum=h.enum.map(y=>typeof y=="number"?String(y):y):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=t.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var B=class{constructor(e,t){this.override=e;this.refs=t}done=new Map;path=[];cyclic=new Map;write(e,t=!1){let r=this.refs.get(e);if(r!==void 0&&!t)return{$ref:r};if(this.path.includes(e))return this.cyclic.has(e)||this.cyclic.set(e,""),{};let i=this.done.get(e);if(i)return i;this.path.push(e);try{let o=this.written(e);return this.done.set(e,o),o}finally{this.path.pop()}}written(e){let t={},r,i=e._zod.toJSONSchema?.();i?Object.assign(t,i):r=this.process(e,t);let o=fe.get(e);if(o)for(let d of Object.keys(o))t[d]=o[d];T(e)&&(delete t.examples,delete t.default),"_prefault"in t&&(t.default??=t._prefault,delete t._prefault);let a=t;if(r){let d=this.write(r);a={...t};for(let s of Object.keys(d))s in t||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Be(a),e._zod.def.type==="intersection"&&ut(a),a}process(e,t){let r=e._zod.def;switch(r.type){case"string":{t.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:b}=H(e);if(typeof i=="number"&&(t.minLength=i),typeof o=="number"&&(t.maxLength=o),a&&(t.format=dt[a]??a,(t.format===""||a==="time"||b)&&delete t.format),s&&(t.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?t.pattern=f[0].source:t.allOf=f.map(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:b}=H(e);if(t.type=b?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?t.exclusiveMinimum=d:typeof i=="number"&&(t.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?t.exclusiveMaximum=s:typeof o=="number"&&(t.maximum=o),a){let[f,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(t.multipleOf=f),w.length&&(t.allOf=[...t.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":t.type="boolean";return;case"null":t.type="null";return;case"never":t.not={};return;case"enum":{let i=lt(r.entries);i.length===0?t.not={}:(i.every(o=>typeof o=="number")&&(t.type="number"),i.every(o=>typeof o=="string")&&(t.type="string"),t.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)t.not={};else if(i.length===1)t.type=i[0]===null?"null":typeof i[0],t.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(t.type=o);i.every(o=>o===null)&&(t.type="null"),t.enum=i}return}case"template_literal":t.type="string",t.pattern=e._zod.pattern.source;return;case"file":{t.type="string",t.format="binary",t.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=H(e);i!==void 0&&(t.minLength=i),o!==void 0&&(t.maxLength=o),a&&(a.length===0?t.not={}:a.length===1?t.contentMediaType=a[0]:t.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=H(e);typeof i=="number"&&(t.minItems=i),typeof o=="number"&&(t.maxItems=o),t.type="array",t.items=this.write(r.element);return}case"object":{let i=r.shape;t.type="object";let o={};t.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>L(i[d])===void 0);a.length>0&&(t.required=a),r.catchall?._zod.def.type==="never"?t.additionalProperties=!1:r.catchall&&(t.additionalProperties=this.write(r.catchall));return}case"union":t[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);t.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;t.type="array",t.prefixItems=i.map(s=>this.write(s)),r.rest?t.items=this.write(r.rest):t.items=!1;let o=i.length;for(;o>0&&L(i[o-1])!==void 0;)o-=1;o>0&&(t.minItems=o),r.rest||(t.maxItems=i.length);let{minimum:a,maximum:d}=H(e);typeof a=="number"&&(t.minItems=a),typeof d=="number"&&(t.maxItems=d);return}case"record":{let i=r.keyType;t.type="object";let o=H(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let b of o)s[b.source]=d;t.patternProperties=s}else t.propertyNames=Ve(this.write(i)),t.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&L(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(t.required=d.map(String))}return}case"nullable":t.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,b)=>typeof b=="bigint"?(a=!0,null):b);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(t[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{t.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return t.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Ge(n,e=()=>{}){let t=n,r=new B(e,new Map),i=r.write(t,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let b of r.cyclic.keys())if(b===t)o.set(b,"#");else{let f=`__schema${a++}`;o.set(b,`#/$defs/${f}`),d.push([b,f])}r=new B(e,o),i=r.write(t,!0);let s={};for(let[b,f]of d)s[f]=r.write(b,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Ke(n){return Ge(n,mt)}var ft={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},pt={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function mt(n){me(n.zodSchema)&&(n.jsonSchema["x-graview-app-link"]=!0);let e=ye(n.zodSchema);if(e&&(n.jsonSchema.type==="string"||n.jsonSchema.type==="array")){n.jsonSchema["x-graview-linked"]={address:e.address,kinds:[...e.kinds],cardinality:e.cardinality};let s=e.kinds.join(" or "),b=`${e.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${e.address}, as "${e.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=n.jsonSchema.description;typeof f=="string"&&f.includes(b)||(n.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${b}`)}if(we(n.zodSchema)&&(n.jsonSchema["x-graview-repeat"]=!0,!n.jsonSchema.type&&!n.jsonSchema.anyOf&&!n.jsonSchema.oneOf&&Object.assign(n.jsonSchema,ht())),Se(n.zodSchema)){n.jsonSchema.contentMediaType="text/markdown";let s=n.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(n.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let t=_e(n.zodSchema);if(t){let s=n.jsonSchema;s["x-graview-type"]=t,t==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=pt[t]}let r=Re(n.zodSchema,!1);if(r){let s=Pe(r);n.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(n.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(n.jsonSchema["x-graview-unit"]=s.unit);let b=n.jsonSchema.description;n.jsonSchema.description=typeof b=="string"&&b.length>0?`${b} ${Y(s)}`:Y(s)}let i=n.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=n.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=ft[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function te(n,e){let t=C(n.input),r=Ke(n.input);if(e&&r.properties){let o=a=>e.includes(a)?e.indexOf(a):e.length;r.properties=Object.fromEntries(Object.entries(r.properties).sort(([a],[d])=>o(a)-o(d)))}let i=r.properties??{};if(Ae(n)){let o=n.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${o} this makes, beginning with its kind (${n.creates.map(a=>`"${a}:"`).join(" or ")}). Refused if the graph already has it; left out, one is minted from the label.`},r.properties=i}Oe(n)&&(r.additionalProperties=!1);for(let o of t){let a=i[o.name];if(!a)continue;let d=o.kinds.includes("*")?"any node kind":o.kinds.join(" | ");a.description=[a.description,`Id of a node (${d}).`].filter(Boolean).join(" ")}return{name:n.name,...n.title===void 0?{}:{title:n.title},description:n.description??n.title??n.name,inputSchema:r,nodeRefs:t}}function ht(){let n={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(t,r)=>({type:"integer",minimum:t,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...be]},interval:e(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ge]},e(-1,31)]}},until:n,count:e(1,1e3),except:{type:"array",maxItems:500,items:n},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function Ze(n){let e=new Set;for(let t=n;t;t=t.onBehalfOf)t.id!==void 0&&e.add(`${t.kind}:${t.id}`);return e}function U(n,e){let t=Ze(e),r=f=>{if(f.kind==="rule")return!1;let w=Ze(f);if(w.size===0)return!1;for(let h of w)if(t.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of n.log.live()){if(f.undoes!==void 0)continue;let w=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let y=h.op==="add-node"?h.node.id:h.op==="patch-node"||h.op==="splice-text"?h.id:void 0;if(y===void 0)continue;let _=h.op==="add-node"?Object.keys(h.node):h.op==="splice-text"?[h.field]:Object.keys(h.after),O=i.get(y);(h.op==="add-node"||!O)&&i.set(y,O=new Map);for(let v of _)v==="id"||v==="kind"||(w?O.set(v,w):O.delete(v))}}return i},a=n.schema,d=new Map,s=(f,w)=>{let h=`${f}\0${w}`,y=d.get(h);if(y===void 0){let _=a.tryDefinition(f)?.fields?.shape;y=_!==void 0&&w in _&&De(_[w]).type==="text",d.set(h,y)}return y},b=f=>n.graph.getNode(f)?.kind;return{prose:s,say:f=>W(f,{graph:n.graph,schema:a}),fieldBy(f,w){let h=b(f);if(!(h===void 0||!s(h,w)))return o().get(f)?.get(w)},recordBy(f){let w=b(f),h=o().get(f);if(w===void 0||!h)return;let y;for(let[_,O]of h)s(w,_)&&(y=O);return y}}}var ne=(n,e,t)=>({untrusted:!0,authoredBy:t.say(e),text:n}),yt="the host's ranker";function Ye(n,e){return{...n,hits:n.hits.map(t=>{if(t.about!=="node")return t;t.why.by==="meaning"&&t.why.matched!==void 0&&(t={...t,why:{...t.why,matched:{untrusted:!0,authoredBy:yt,text:t.why.matched}}});let r=e.recordBy(t.id);if(!r)return t;let i=e.prose(t.kind,t.why.field)?e.fieldBy(t.id,t.why.field):r;return{...t,label:ne(t.label,r,e),...t.apart!==void 0?{apart:ne(t.apart,r,e)}:{},why:i?{...t.why,fragment:ne(t.why.fragment,i,e)}:t.why}})}}var ie=(n,e,t)=>({title:n,readOnlyHint:e,destructiveHint:!1,idempotentHint:t,openWorldHint:!1}),gt={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ie("Notify me when something happens",!1,!1)},bt={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ie("Stop notifying me",!1,!0)},wt={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ie("What I am notified of",!0,!0)},re=[gt,bt,wt];var F=n=>{let e;return()=>e??=n().catch(t=>{throw e=void 0,t})},St=F(()=>(__graviewPreload(import.meta.url,["./chunk.6Q6BW4QT.js","./chunk.DTSTUC2W.js","./chunk.IT763BYH.js","./chunk.T2RME6XF.js","./chunk.SOTB6C5A.js","./chunk.TQCRFZ53.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.DPPT6WAJ.js","./chunk.7U2JO7ET.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7Z2PRPYE.js"))),kt=()=>(__graviewPreload(import.meta.url,["./chunk.UQQAGT3R.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.QAIYYIZQ.js")).catch(()=>{}),vt=async()=>{(await kt())?.judgeWithLines()},q=F(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.T2RME6XF.js","./chunk.SOTB6C5A.js","./chunk.TQCRFZ53.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.7U2JO7ET.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.T6HG2XIP.js"))),At=F(()=>(__graviewPreload(import.meta.url,["./chunk.MLRPCZVS.js","./chunk.G4JJXA63.js","./chunk.64IKLRUS.js","./chunk.DTSTUC2W.js","./chunk.USQNSNIA.js","./chunk.XOZU4OFA.js","./chunk.IT763BYH.js","./chunk.UQQAGT3R.js","./chunk.WVUJXDXZ.js","./chunk.T2RME6XF.js","./chunk.SOTB6C5A.js","./chunk.TQCRFZ53.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.XJFAUOJS.js","./chunk.DPPT6WAJ.js","./chunk.7U2JO7ET.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.UE5YS3GN.js"))),Ot=F(()=>(__graviewPreload(import.meta.url,["./chunk.AQCU6TPV.js","./chunk.6Q6BW4QT.js","./chunk.DTSTUC2W.js","./chunk.RDL6652E.js","./chunk.V3NPUAPB.js","./chunk.IT763BYH.js","./chunk.T2RME6XF.js","./chunk.SOTB6C5A.js","./chunk.TQCRFZ53.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.XJFAUOJS.js","./chunk.DPPT6WAJ.js","./chunk.7U2JO7ET.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.OYGPNO7A.js"))),Rt=F(()=>(__graviewPreload(import.meta.url,["./chunk.2HZGUVB2.js","./chunk.MJMVGW6Z.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.D6BMAGPR.js"))),_t=n=>n.definitions.some(e=>Z(e).size>0),Xe=n=>({value:K(n),label:n.label,...n.describe?{describe:n.describe}:{},...n.card?{card:n.card}:{},fields:n.fields,...n.app?{app:n.app}:{}});async function Tt(n,e,t,r){let i=String(t.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=n.schema.definitions.flatMap(v=>[...Z(v)].map(([m,u])=>({kind:v.kind,name:m,relation:u}))),s=d.filter(v=>v.name===a&&(o===void 0||v.kind===o));if(s.length!==1){let v=d.map(m=>`${m.kind}.${m.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${v}.`}}let{kind:b,name:f,relation:w}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{}},y=typeof t.of=="string"?t.of:void 0;if(y!==void 0){let v=n.graph.getNode(y);if(!v||v.kind!==b)return{ok:!1,error:`No ${b} "${y}".`};let m=he(v[f],w),u=await Promise.all(m.map(S=>Promise.resolve().then(()=>r.resolve(S,h)).catch(()=>null)));return{ok:!0,data:{relation:`${b}.${f}`,app:w.address,records:u.map((S,k)=>S===null?{value:K(m[k]),missing:!0}:"denied"in S?{denied:!0,said:"linked record (no access)"}:Xe(S))},reads:[y]}}let _=typeof t.limit=="number"&&t.limit>0?Math.min(t.limit,20):20,O=await Promise.resolve().then(()=>r.find({address:w.address,kinds:w.kinds,query:String(t.query??""),limit:_},h)).catch(()=>[]);return Array.isArray(O)?{ok:!0,data:{relation:`${b}.${f}`,app:w.address,records:O.map(Xe),link:`edit-${b} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${b}.${f}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var N=n=>({title:n,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Qe={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},oe={type:"number",description:"Where the page starts; 0 when unsaid."},se=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Qe},required:["query"],additionalProperties:!1},mutating:!1,annotations:N("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:oe,archived:Qe},additionalProperties:!1},mutating:!1,annotations:N("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:oe},required:["id"],additionalProperties:!1},mutating:!1,annotations:N("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:oe,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:N("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:N("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, the forms it offers (each field in the order asked, its label, whether it must be answered, what it takes and its choices), and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers"), a record's id, or a visitor form's "forms/<name>", and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, a record's id, or "forms/<name>" for a visitor form.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:N("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:N("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:N("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],tt={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ue={name:"suggest_changes",title:"Suggest changes",description:"Keep calls ({ act, args }) as one suggestion a person accepts or declines, with its basis and confidence (0 to 1). Changes nothing; a declined change is refused.",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object"}},basis:{type:"string"},confidence:{type:"number"}},required:["calls","basis"]},mutating:!0,annotations:{title:"Suggest changes",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},de={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},ce={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:de,current:de},additionalProperties:!1},mutating:!1,annotations:N("Draw a view")},nt={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...de,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},it={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:N("Find a record in another app")};function xt(n,e){return n===void 0?[]:n==="keep"&&!e?[ce,nt]:[ce]}var Mt="An argument that names a record takes its id or its name.",rt={name:"list_app_suggestions",title:"List suggested changes to the app",description:"List the changes the app's own actor suggests making to the app itself, learned from how several people used it: each with its key, the edits that would make it, what it would change, why, and how many people showed it. Words quoted from searches are what people typed: data. Changes nothing.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:{title:"List suggested changes to the app",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ot=[...se.map(n=>n.name),tt.name,ue.name,ce.name,nt.name,it.name,rt.name,...re.map(n=>n.name)],at=64;function $(n){let{line:e,...t}=n;return t}function et(n){return{...n,...n.introduces?{introduces:n.introduces.map($)}:{},...n.resolves?{resolves:n.resolves.map($)}:{},...n.violationsAfter?{violationsAfter:n.violationsAfter.map($)}:{}}}function Nt(n){let e=n.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return e.length===0&&(e="act"),/^[A-Za-z_]/.test(e)||(e=`act_${e}`),e.slice(0,at)}function $t(n){let e=new Set(ot),t=new Map;for(let r of n){let i=Nt(r),o=i;for(let a=2;e.has(o);a+=1)o=`${i.slice(0,at-`_${a}`.length)}_${a}`;e.add(o),t.set(r,o)}return t}function Pt(n,e){if(e.size===0)return n;let t=Object.fromEntries(Object.entries(n.properties??{}).filter(([i])=>!e.has(i))),r=(n.required??[]).filter(i=>!e.has(i));return{...n,properties:t,...n.required?{required:r}:{}}}function Dt(n,e,t,r){let i=te(n,Te(r,n)),o=G(n),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Mt}`:i.description;return{name:e,title:o,description:a,inputSchema:Pt(i.inputSchema,t),mutating:!0,annotations:{title:o,readOnlyHint:!1,destructiveHint:n.destructive===!0||(n.severs?.length??0)>0,idempotentHint:n.idempotent===!0,openWorldHint:!1},act:n.name}}function le(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(le).join(",")}]`;let e=n;return`{${Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${JSON.stringify(t)}:${le(e[t])}`).join(",")}}`}function Jt(n){return`sha256:${$e(le(n))}`}function Et(n,e,t,r,i,o=!1,a=!1,d=!1,s,b=!1){let f=$t(n.map(y=>y.name)),w=[...xt(r,t),...o?[it]:[],...a?re:[],...b?[rt]:[]];return{definitions:t?[...se.filter(y=>!y.mutating),...w]:[...se,tt,...d?[ue]:[],...w,...n.filter(y=>e.has(y.name)).map(y=>Dt(y,f.get(y.name),i(y),s))],names:f}}function On(n,e={}){let t=e.author??{kind:"agent"},r=n.allMutations(),i=new Set(n.permittedMutations(t).map(m=>m.name)),{definitions:o,names:a}=Et(r,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,m=>X(n.schema,n.policy,t,m),_t(n.schema),e.subscriptions!==void 0,Ne(t),n.schema,e.learned!==void 0),d=Jt(o),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},b=m=>pe(s,m),f=m=>{if(!ot.includes(m)){for(let[u,S]of a)if(S===m)return u;return a.has(m)?m:xe(m,a.keys())}},w=m=>{let u=Me(m,a.keys());return u?` Did you mean "${u}"?`:""},h=m=>{let u=o.find(k=>k.name===m)??o.find(k=>k.act===m);if(u)return u;let S=f(m);return S===void 0?void 0:o.find(k=>k.act===S)},y=(m,u)=>{let S=r.find(c=>c.name===m);if(!S)return{args:u,resolved:[]};let k={...u},l=[];for(let c of C(S.input)){let p=k[c.name];if(typeof p!="string"||p.trim()==="")continue;let g=n.resolveRef(c,p,t);if(!g.ok){let A=g.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${c.name}.`:" Nothing was changed.";return{ok:!1,error:`${g.message}${A}`,argument:c.name,candidates:g.candidates}}g.by!=="id"&&(k[c.name]=g.id,l.push({argument:c.name,given:p,id:g.id,label:g.label}))}return{args:k,resolved:l}},_=async(m,u)=>{try{await vt();let S=h(m);if(!S&&m===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!S){let l=f(m);if(l){let c=n.permits({name:l,args:u},t);if(!c.ok)return{ok:!1,error:c.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}".${w(m)} Available: ${o.map(c=>c.name).join(", ")}`}}if(S.mutating&&e.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(S.act!==void 0){let l=y(S.act,u);if("ok"in l)return l;let c=S.act,p=b(()=>z(n,t,n.apply({name:c,args:l.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map($),resolves:p.resolves.map($),...l.resolved.length>0?{resolved:l.resolved}:{}},diff:p.diff}}let k=n.seenBy(t);switch(S.name){case"search_graph":{let l=typeof e.places=="function"?e.places():e.places,c=typeof u.subject=="string"?u.subject:void 0,p=Ie(k,String(u.query??""),{principal:t,rank:e.near,archived:ke(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...l?{places:l}:{},...c?{subject:c,from:[c]}:{}}),g=p.later?await p.later:p;return{ok:!0,data:(await q()).searchRead(g,Ye(g,U(k,t))),reads:g.hits.flatMap(A=>A.about==="node"?[A.id]:[])}}case"get_graph":return{ok:!0,...(await q()).graphRead(k,U(k,t),u)};case"get_node":{let l=String(u.id??""),c=l,p;if(!k.graph.getNode(l)){let A=l.trim()===""?void 0:n.resolveRef({name:"id",kinds:["*"]},l,t);if(A?.ok)c=A.id,p={argument:"id",given:l,id:c,label:A.label};else return A?.reason==="ambiguous"?{ok:!1,error:A.message,argument:"id",candidates:A.candidates}:{ok:!1,error:`No node "${l}".`}}let g=(await q()).nodeRead(k,U(k,t),c,u);return{ok:!0,data:p?{...g.data,resolved:[p]}:g.data,reads:g.reads}}case"describe_place":{let l=e.app??{name:"",schema:n.schema},c=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:p}=await St(),g=p(n,t,String(u.place??""),{app:l,width:c});if(!g.ok)return{ok:!1,error:`${g.error} The places are: ${g.places.join(", ")}.`};let A=new Set,M=I=>{for(let D of I)for(let x of D.groups??[])for(let P of x.items)A.add(P.id),M(P.parts)};return M(g.description.parts),{ok:!0,data:g.description,reads:[...A]}}case"find_linked":return Tt(k,t,u,e.linked);case"draft_view":case"keep_lens":{let l=e.app??{name:"",schema:n.schema};return(await At()).runDraftTool(S.name,u,{app:l,principal:t,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let l=k.violations(u.context);return{ok:!0,...(await q()).violationsRead(l,u)}}case"get_affordances":{let l=u.selection??[];return{ok:!0,data:He(k,l,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:l.filter(p=>k.graph.has(p))}}case"preview_mutation":{let l=String(u.mutation),c=f(l)??l,p=y(c,u.args??{});if("ok"in p)return p;let g=n.missingFor({name:c,args:p.args},t);if(g)return{ok:!1,error:g.message,reason:"missing"};let A=z(n,t,n.preview({name:c,args:p.args},void 0,{author:t})),M=et(A);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let l=String(u.act??""),c=f(l)??l,p=r.find(R=>R.name===c);if(!p||!i.has(c)){let R=p?n.permits({name:c,args:{}},t):void 0;return R&&!R.ok?{ok:!1,error:R.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${l}" this seat may run.${w(l)} Nothing was changed.`,reason:"invalid"}}let g=p.subject;if(!g)return{ok:!1,error:`"${G(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let A=Array.isArray(u.records)?u.records.filter(R=>typeof R=="string"&&R.trim()!==""):[];if(A.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let R of A.slice(0,200)){let J=n.resolveRef({name:g.arg,kinds:g.kinds},R,t);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};M.push(J.id),J.by!=="id"&&I.push({argument:"records",given:R,id:J.id,label:J.label})}let D=y(c,{...u.args??{}});if("ok"in D)return D;let x=(await Ot()).actOnSeveral(n,{mutation:c,subject:g.arg,args:D.args},M,{author:t,...V(e.via)}),P=x.result?z(n,t,x.result):void 0;return{ok:!0,data:{...x.batch?{batch:x.batch,intent:x.intent}:{},applied:x.applied,unchanged:x.unchanged,refused:x.refused.map(R=>({record:R.id,label:R.label,error:R.message,reason:R.reason})),...x.allOrNothing?{keptNone:!0}:{},...P?{introduces:P.introduces.map($),resolves:P.resolves.map($)}:{},...I.length>0||D.resolved.length>0?{resolved:[...I,...D.resolved]}:{}},...P?{diff:P.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let l=await(await Rt()).runSubscriptionTool(S.name,u,{store:n,principal:e.subscriber??t,app:e.app?.name??"app",subscriptions:e.subscriptions});return l.ok?{ok:!0,data:l.data}:{ok:!1,error:l.error}}case"list_app_suggestions":return{ok:!0,data:{suggestions:(await e.learned()).map(({key:c,said:p,why:g,edits:A,evidence:M})=>({key:c,said:p,why:g,edits:A,evidence:M}))}};case"list_suggestions":{let l=Ee(n,t).map(c=>{let p=W(c.author,{graph:k.graph,schema:n.schema});return{id:c.id,intent:c.intent,by:p,at:c.at,about:c.about,...c.lineage?{basis:{untrusted:!0,authoredBy:p,text:c.lineage.basis},...c.lineage.confidence!==void 0?{confidence:c.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:l},reads:[...new Set(l.flatMap(c=>c.about))]}}case"suggest_changes":{let l=u.calls.map(p=>({name:f(p.act)??p.act,args:p.args}));return{ok:!0,data:{suggestion:Je(n,l,{author:t,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"accept_suggestion":case"decline_suggestion":{let l=String(u.suggestion??""),c={author:t,...V(e.via)},p=S.name==="accept_suggestion"?je(n,l,c):ze(n,l,c),g=z(n,t,p);return{ok:!0,data:{batch:g.batch,intent:g.intent,introduces:g.introduces.map($),resolves:g.resolves.map($)},diff:g.diff}}case"undo_batch":{let l=String(u.batch),c=u.include??[],p=k.canUndo([l,...c]);if(!p.ok)return{ok:!1,error:p.message};let g=z(n,t,n.undo([l,...c],{...e.author?{author:e.author}:{}}));return{ok:!0,data:et(g),diff:g.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(S){let{reason:k,wouldNeed:l}=ve(S);return{ok:!1,error:S instanceof Error?S.message:String(S),reason:k,...l?{wouldNeed:l}:{}}}},O=new Set,v=m=>{for(let u of O)u(m)};return{definitions:o,hash:d,...e.author?{author:e.author}:{},onDiff(m){return n.subscribe(m)},onCall(m){return O.add(m),()=>O.delete(m)},async call(m,u){let S=h(m)?.mutating??!1,k={name:m,args:u,mutating:S,at:new Date().toISOString()};v({...k,phase:"running"});let l=p=>(v(p.ok?{...k,phase:"ok",...!S&&p.reads?{reads:p.reads}:{}}:{...k,phase:"failed",error:p.error}),p),c=await _(m,u);return l(c.ok&&!S?{...c,data:(await q()).withinReadChars(m,c.data)}:c)}}}function V(n){let e=typeof n=="function"?n():n;return e?{via:e}:{}}export{le as a,On as b};
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{q as Ie}from"./chunk.NZDWXX6H.js";import{d as Je,e as Ee,f as je,g as ze}from"./chunk.4BRM5SGO.js";import{a as He}from"./chunk.BCE6LIDR.js";import{e as X}from"./chunk.5NZDFT6R.js";import{a as z}from"./chunk.XTBS64IT.js";import{f as Pe,g as Y,i as De}from"./chunk.LUIRQ5UF.js";import{a as Se}from"./chunk.N33WUCAN.js";import{Aa as me,Da as K,Eb as ve,Fa as he,Ha as ye,Hb as Ae,Ia as Z,Ib as Oe,Lb as Re,M as pe,Ob as _e,Pa as ge,Qa as be,Rb as C,Ta as we,Zb as Te,_a as W,a as fe,cb as ke,ha as G,md as $e,nc as xe,oc as Me,pc as Ne}from"./chunk.DIFR37EZ.js";var E=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},j=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},Q=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},Le=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},qe=(n,e)=>{n.multipleOf??=[],n.multipleOf.includes(e)||n.multipleOf.push(e)},Fe=(n,e)=>(n.patterns??=new Set).add(e),st={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function H(n){let e={},{def:t,bag:r}=n._zod,i=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":j(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":qe(e,a.value);break;case"number_format":{Q(e,a.format);let d=st[a.format];d&&(E(e,"minimum",d[0]),j(e,"maximum",d[1]));break}case"bigint_format":Q(e,a.format);break;case"min_length":case"min_size":E(e,"minimum",a.minimum);break;case"max_length":case"max_size":j(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),j(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),j(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Fe(e,a.pattern),(a.format==="base64"||a.format==="base64url")&&(e.contentEncoding=a.format),(a.local||a.precision===-1)&&(e.laxFormat=!0);break;case"mime_type":Le(e,a.mime);break}}r.minimum!==void 0&&E(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&j(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&j(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&qe(e,r.multipleOf),r.format!==void 0&&(e.format??=r.format,r.format.includes("int")&&(e.isInt=!0)),r.mime&&Le(e,r.mime);for(let o of r.patterns??[])Fe(e,o);return e}var dt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function L(n){let e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?L(e.out):e.type==="catch"?L(e.innerType):n._zod.optin}var ct=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function T(n,e=new Set){if(e.has(n))return!1;e.add(n);let t=n._zod.def,r=t.type;return r==="transform"?!0:r==="array"?T(t.element,e):r==="set"?T(t.valueType,e):r==="lazy"?T(t.getter(),e):ct.has(r)?T(t.innerType,e):r==="intersection"?T(t.left,e)||T(t.right,e):r==="record"||r==="map"?T(t.keyType,e)||T(t.valueType,e):r==="pipe"?n._zod.traits.has("$ZodCodec")||T(t.in,e)||T(t.out,e):r==="object"?Object.values(t.shape).some(i=>T(i,e)):r==="union"?t.options.some(i=>T(i,e)):r==="tuple"?t.items.some(i=>T(i,e))||(t.rest?T(t.rest,e):!1):!1}function lt(n){let e=Object.values(n).filter(t=>typeof t=="number");return Object.entries(n).filter(([t])=>e.indexOf(+t)===-1).map(([,t])=>t)}function Be(n){let e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;let t=[];for(let r of e){if(!r||typeof r!="object")return;Be(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;t.includes(o)||t.push(o)}}delete n.anyOf,n.type=t.length===1?t[0]:t}var Ue=new Set(["type","properties","required","additionalProperties"]),We=n=>{let e=n.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ce=(n,e)=>JSON.stringify(n)===JSON.stringify(e);function ee(n){for(let i of n){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!Ue.has(o))return null}let e={},t=new Set;for(let i of n){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(e,o))continue;let a=[];for(let d of n){let s=d.properties?.[o]??We(d);s&&!a.some(b=>Ce(b,s))&&a.push(s)}e[o]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let o of i.required??[])t.add(o)}let r={type:"object",properties:e};if(t.size&&(r.required=[...t]),n.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of n){let a=We(o);a&&!i.some(d=>Ce(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function ut(n){let e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ue)if(i in n)return;let t=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!t.length)r=ee(e);else{let i=t[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[o].map(s=>ee([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete n.allOf,Object.assign(n,r))}function Ve(n){let e=n;for(let y of["anyOf","oneOf"]){let _=e[y];if(!Array.isArray(_))continue;let O=_.map(Ve);O.some((v,m)=>v!==_[m])&&(e={...e,[y]:O})}let t=[e.type].flat(),r=!t.includes("string")&&t.some(y=>y==="number"||y==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!i?.some(y=>typeof y=="number"))return e;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:b,format:f,id:w,...h}=e;return h.enum?h.enum=h.enum.map(y=>typeof y=="number"?String(y):y):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=t.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var B=class{constructor(e,t){this.override=e;this.refs=t}done=new Map;path=[];cyclic=new Map;write(e,t=!1){let r=this.refs.get(e);if(r!==void 0&&!t)return{$ref:r};if(this.path.includes(e))return this.cyclic.has(e)||this.cyclic.set(e,""),{};let i=this.done.get(e);if(i)return i;this.path.push(e);try{let o=this.written(e);return this.done.set(e,o),o}finally{this.path.pop()}}written(e){let t={},r,i=e._zod.toJSONSchema?.();i?Object.assign(t,i):r=this.process(e,t);let o=fe.get(e);if(o)for(let d of Object.keys(o))t[d]=o[d];T(e)&&(delete t.examples,delete t.default),"_prefault"in t&&(t.default??=t._prefault,delete t._prefault);let a=t;if(r){let d=this.write(r);a={...t};for(let s of Object.keys(d))s in t||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Be(a),e._zod.def.type==="intersection"&&ut(a),a}process(e,t){let r=e._zod.def;switch(r.type){case"string":{t.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:b}=H(e);if(typeof i=="number"&&(t.minLength=i),typeof o=="number"&&(t.maxLength=o),a&&(t.format=dt[a]??a,(t.format===""||a==="time"||b)&&delete t.format),s&&(t.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?t.pattern=f[0].source:t.allOf=f.map(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:b}=H(e);if(t.type=b?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?t.exclusiveMinimum=d:typeof i=="number"&&(t.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?t.exclusiveMaximum=s:typeof o=="number"&&(t.maximum=o),a){let[f,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(t.multipleOf=f),w.length&&(t.allOf=[...t.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":t.type="boolean";return;case"null":t.type="null";return;case"never":t.not={};return;case"enum":{let i=lt(r.entries);i.length===0?t.not={}:(i.every(o=>typeof o=="number")&&(t.type="number"),i.every(o=>typeof o=="string")&&(t.type="string"),t.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)t.not={};else if(i.length===1)t.type=i[0]===null?"null":typeof i[0],t.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(t.type=o);i.every(o=>o===null)&&(t.type="null"),t.enum=i}return}case"template_literal":t.type="string",t.pattern=e._zod.pattern.source;return;case"file":{t.type="string",t.format="binary",t.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=H(e);i!==void 0&&(t.minLength=i),o!==void 0&&(t.maxLength=o),a&&(a.length===0?t.not={}:a.length===1?t.contentMediaType=a[0]:t.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=H(e);typeof i=="number"&&(t.minItems=i),typeof o=="number"&&(t.maxItems=o),t.type="array",t.items=this.write(r.element);return}case"object":{let i=r.shape;t.type="object";let o={};t.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>L(i[d])===void 0);a.length>0&&(t.required=a),r.catchall?._zod.def.type==="never"?t.additionalProperties=!1:r.catchall&&(t.additionalProperties=this.write(r.catchall));return}case"union":t[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);t.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;t.type="array",t.prefixItems=i.map(s=>this.write(s)),r.rest?t.items=this.write(r.rest):t.items=!1;let o=i.length;for(;o>0&&L(i[o-1])!==void 0;)o-=1;o>0&&(t.minItems=o),r.rest||(t.maxItems=i.length);let{minimum:a,maximum:d}=H(e);typeof a=="number"&&(t.minItems=a),typeof d=="number"&&(t.maxItems=d);return}case"record":{let i=r.keyType;t.type="object";let o=H(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let b of o)s[b.source]=d;t.patternProperties=s}else t.propertyNames=Ve(this.write(i)),t.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&L(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(t.required=d.map(String))}return}case"nullable":t.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,b)=>typeof b=="bigint"?(a=!0,null):b);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(t[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{t.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return t.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Ge(n,e=()=>{}){let t=n,r=new B(e,new Map),i=r.write(t,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let b of r.cyclic.keys())if(b===t)o.set(b,"#");else{let f=`__schema${a++}`;o.set(b,`#/$defs/${f}`),d.push([b,f])}r=new B(e,o),i=r.write(t,!0);let s={};for(let[b,f]of d)s[f]=r.write(b,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Ke(n){return Ge(n,mt)}var ft={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},pt={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function mt(n){me(n.zodSchema)&&(n.jsonSchema["x-graview-app-link"]=!0);let e=ye(n.zodSchema);if(e&&(n.jsonSchema.type==="string"||n.jsonSchema.type==="array")){n.jsonSchema["x-graview-linked"]={address:e.address,kinds:[...e.kinds],cardinality:e.cardinality};let s=e.kinds.join(" or "),b=`${e.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${e.address}, as "${e.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=n.jsonSchema.description;typeof f=="string"&&f.includes(b)||(n.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${b}`)}if(we(n.zodSchema)&&(n.jsonSchema["x-graview-repeat"]=!0,!n.jsonSchema.type&&!n.jsonSchema.anyOf&&!n.jsonSchema.oneOf&&Object.assign(n.jsonSchema,ht())),Se(n.zodSchema)){n.jsonSchema.contentMediaType="text/markdown";let s=n.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(n.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let t=_e(n.zodSchema);if(t){let s=n.jsonSchema;s["x-graview-type"]=t,t==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=pt[t]}let r=Re(n.zodSchema,!1);if(r){let s=Pe(r);n.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(n.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(n.jsonSchema["x-graview-unit"]=s.unit);let b=n.jsonSchema.description;n.jsonSchema.description=typeof b=="string"&&b.length>0?`${b} ${Y(s)}`:Y(s)}let i=n.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=n.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=ft[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function te(n,e){let t=C(n.input),r=Ke(n.input);if(e&&r.properties){let o=a=>e.includes(a)?e.indexOf(a):e.length;r.properties=Object.fromEntries(Object.entries(r.properties).sort(([a],[d])=>o(a)-o(d)))}let i=r.properties??{};if(Ae(n)){let o=n.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${o} this makes, beginning with its kind (${n.creates.map(a=>`"${a}:"`).join(" or ")}). Refused if the graph already has it; left out, one is minted from the label.`},r.properties=i}Oe(n)&&(r.additionalProperties=!1);for(let o of t){let a=i[o.name];if(!a)continue;let d=o.kinds.includes("*")?"any node kind":o.kinds.join(" | ");a.description=[a.description,`Id of a node (${d}).`].filter(Boolean).join(" ")}return{name:n.name,...n.title===void 0?{}:{title:n.title},description:n.description??n.title??n.name,inputSchema:r,nodeRefs:t}}function ht(){let n={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(t,r)=>({type:"integer",minimum:t,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...be]},interval:e(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ge]},e(-1,31)]}},until:n,count:e(1,1e3),except:{type:"array",maxItems:500,items:n},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function Ze(n){let e=new Set;for(let t=n;t;t=t.onBehalfOf)t.id!==void 0&&e.add(`${t.kind}:${t.id}`);return e}function U(n,e){let t=Ze(e),r=f=>{if(f.kind==="rule")return!1;let w=Ze(f);if(w.size===0)return!1;for(let h of w)if(t.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of n.log.live()){if(f.undoes!==void 0)continue;let w=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let y=h.op==="add-node"?h.node.id:h.op==="patch-node"||h.op==="splice-text"?h.id:void 0;if(y===void 0)continue;let _=h.op==="add-node"?Object.keys(h.node):h.op==="splice-text"?[h.field]:Object.keys(h.after),O=i.get(y);(h.op==="add-node"||!O)&&i.set(y,O=new Map);for(let v of _)v==="id"||v==="kind"||(w?O.set(v,w):O.delete(v))}}return i},a=n.schema,d=new Map,s=(f,w)=>{let h=`${f}\0${w}`,y=d.get(h);if(y===void 0){let _=a.tryDefinition(f)?.fields?.shape;y=_!==void 0&&w in _&&De(_[w]).type==="text",d.set(h,y)}return y},b=f=>n.graph.getNode(f)?.kind;return{prose:s,say:f=>W(f,{graph:n.graph,schema:a}),fieldBy(f,w){let h=b(f);if(!(h===void 0||!s(h,w)))return o().get(f)?.get(w)},recordBy(f){let w=b(f),h=o().get(f);if(w===void 0||!h)return;let y;for(let[_,O]of h)s(w,_)&&(y=O);return y}}}var ne=(n,e,t)=>({untrusted:!0,authoredBy:t.say(e),text:n}),yt="the host's ranker";function Ye(n,e){return{...n,hits:n.hits.map(t=>{if(t.about!=="node")return t;t.why.by==="meaning"&&t.why.matched!==void 0&&(t={...t,why:{...t.why,matched:{untrusted:!0,authoredBy:yt,text:t.why.matched}}});let r=e.recordBy(t.id);if(!r)return t;let i=e.prose(t.kind,t.why.field)?e.fieldBy(t.id,t.why.field):r;return{...t,label:ne(t.label,r,e),...t.apart!==void 0?{apart:ne(t.apart,r,e)}:{},why:i?{...t.why,fragment:ne(t.why.fragment,i,e)}:t.why}})}}var ie=(n,e,t)=>({title:n,readOnlyHint:e,destructiveHint:!1,idempotentHint:t,openWorldHint:!1}),gt={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ie("Notify me when something happens",!1,!1)},bt={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ie("Stop notifying me",!1,!0)},wt={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ie("What I am notified of",!0,!0)},re=[gt,bt,wt];var F=n=>{let e;return()=>e??=n().catch(t=>{throw e=void 0,t})},St=F(()=>(__graviewPreload(import.meta.url,["./chunk.XVN3CQKH.js","./chunk.7ML2BWSP.js","./chunk.5NZDFT6R.js","./chunk.7INWDFNG.js","./chunk.FPGU43SC.js","./chunk.V6FUYRZI.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.LUIRQ5UF.js","./chunk.N33WUCAN.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.GBAUQXXD.js"))),kt=()=>(__graviewPreload(import.meta.url,["./chunk.XTBS64IT.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7UBABS2T.js")).catch(()=>{}),vt=async()=>{(await kt())?.judgeWithLines()},q=F(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.7INWDFNG.js","./chunk.FPGU43SC.js","./chunk.V6FUYRZI.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.N33WUCAN.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.I5PSHASU.js"))),At=F(()=>(__graviewPreload(import.meta.url,["./chunk.4W5GCPAP.js","./chunk.G4JJXA63.js","./chunk.C7EJPV2N.js","./chunk.7ML2BWSP.js","./chunk.RALAID6N.js","./chunk.XOZU4OFA.js","./chunk.5NZDFT6R.js","./chunk.XTBS64IT.js","./chunk.WVUJXDXZ.js","./chunk.7INWDFNG.js","./chunk.FPGU43SC.js","./chunk.V6FUYRZI.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.RQX4CQJN.js","./chunk.LUIRQ5UF.js","./chunk.N33WUCAN.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.57KRCHQT.js"))),Ot=F(()=>(__graviewPreload(import.meta.url,["./chunk.547FQPYG.js","./chunk.XVN3CQKH.js","./chunk.7ML2BWSP.js","./chunk.BCE6LIDR.js","./chunk.MBLFZF5R.js","./chunk.5NZDFT6R.js","./chunk.7INWDFNG.js","./chunk.FPGU43SC.js","./chunk.V6FUYRZI.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.RQX4CQJN.js","./chunk.LUIRQ5UF.js","./chunk.N33WUCAN.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.DSWMXM57.js"))),Rt=F(()=>(__graviewPreload(import.meta.url,["./chunk.53U6E5LD.js","./chunk.PQMMISCQ.js","./chunk.5BPRGXIW.js","./chunk.BZEJM2PY.js","./chunk.CMLNBJZG.js","./chunk.DIFR37EZ.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.G3BDQ6EA.js"))),_t=n=>n.definitions.some(e=>Z(e).size>0),Xe=n=>({value:K(n),label:n.label,...n.describe?{describe:n.describe}:{},...n.card?{card:n.card}:{},fields:n.fields,...n.app?{app:n.app}:{}});async function Tt(n,e,t,r){let i=String(t.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=n.schema.definitions.flatMap(v=>[...Z(v)].map(([m,u])=>({kind:v.kind,name:m,relation:u}))),s=d.filter(v=>v.name===a&&(o===void 0||v.kind===o));if(s.length!==1){let v=d.map(m=>`${m.kind}.${m.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${v}.`}}let{kind:b,name:f,relation:w}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{}},y=typeof t.of=="string"?t.of:void 0;if(y!==void 0){let v=n.graph.getNode(y);if(!v||v.kind!==b)return{ok:!1,error:`No ${b} "${y}".`};let m=he(v[f],w),u=await Promise.all(m.map(S=>Promise.resolve().then(()=>r.resolve(S,h)).catch(()=>null)));return{ok:!0,data:{relation:`${b}.${f}`,app:w.address,records:u.map((S,k)=>S===null?{value:K(m[k]),missing:!0}:"denied"in S?{denied:!0,said:"linked record (no access)"}:Xe(S))},reads:[y]}}let _=typeof t.limit=="number"&&t.limit>0?Math.min(t.limit,20):20,O=await Promise.resolve().then(()=>r.find({address:w.address,kinds:w.kinds,query:String(t.query??""),limit:_},h)).catch(()=>[]);return Array.isArray(O)?{ok:!0,data:{relation:`${b}.${f}`,app:w.address,records:O.map(Xe),link:`edit-${b} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${b}.${f}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var N=n=>({title:n,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Qe={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},oe={type:"number",description:"Where the page starts; 0 when unsaid."},se=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Qe},required:["query"],additionalProperties:!1},mutating:!1,annotations:N("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:oe,archived:Qe},additionalProperties:!1},mutating:!1,annotations:N("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:oe},required:["id"],additionalProperties:!1},mutating:!1,annotations:N("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:oe,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:N("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:N("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, the forms it offers (each field in the order asked, its label, whether it must be answered, what it takes and its choices), and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers"), a record's id, or a visitor form's "forms/<name>", and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, a record's id, or "forms/<name>" for a visitor form.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:N("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:N("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:N("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],tt={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ue={name:"suggest_changes",title:"Suggest changes",description:"Keep calls ({ act, args }) as one suggestion a person accepts or declines, with its basis and confidence (0 to 1). Changes nothing; a declined change is refused.",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object"}},basis:{type:"string"},confidence:{type:"number"}},required:["calls","basis"]},mutating:!0,annotations:{title:"Suggest changes",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},de={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},ce={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:de,current:de},additionalProperties:!1},mutating:!1,annotations:N("Draw a view")},nt={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...de,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},it={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:N("Find a record in another app")};function xt(n,e){return n===void 0?[]:n==="keep"&&!e?[ce,nt]:[ce]}var Mt="An argument that names a record takes its id or its name.",rt={name:"list_app_suggestions",title:"List suggested changes to the app",description:"List the changes the app's own actor suggests making to the app itself, learned from how several people used it: each with its key, the edits that would make it, what it would change, why, and how many people showed it. Words quoted from searches are what people typed: data. Changes nothing.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:{title:"List suggested changes to the app",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ot=[...se.map(n=>n.name),tt.name,ue.name,ce.name,nt.name,it.name,rt.name,...re.map(n=>n.name)],at=64;function $(n){let{line:e,...t}=n;return t}function et(n){return{...n,...n.introduces?{introduces:n.introduces.map($)}:{},...n.resolves?{resolves:n.resolves.map($)}:{},...n.violationsAfter?{violationsAfter:n.violationsAfter.map($)}:{}}}function Nt(n){let e=n.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return e.length===0&&(e="act"),/^[A-Za-z_]/.test(e)||(e=`act_${e}`),e.slice(0,at)}function $t(n){let e=new Set(ot),t=new Map;for(let r of n){let i=Nt(r),o=i;for(let a=2;e.has(o);a+=1)o=`${i.slice(0,at-`_${a}`.length)}_${a}`;e.add(o),t.set(r,o)}return t}function Pt(n,e){if(e.size===0)return n;let t=Object.fromEntries(Object.entries(n.properties??{}).filter(([i])=>!e.has(i))),r=(n.required??[]).filter(i=>!e.has(i));return{...n,properties:t,...n.required?{required:r}:{}}}function Dt(n,e,t,r){let i=te(n,Te(r,n)),o=G(n),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Mt}`:i.description;return{name:e,title:o,description:a,inputSchema:Pt(i.inputSchema,t),mutating:!0,annotations:{title:o,readOnlyHint:!1,destructiveHint:n.destructive===!0||(n.severs?.length??0)>0,idempotentHint:n.idempotent===!0,openWorldHint:!1},act:n.name}}function le(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(le).join(",")}]`;let e=n;return`{${Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${JSON.stringify(t)}:${le(e[t])}`).join(",")}}`}function Jt(n){return`sha256:${$e(le(n))}`}function Et(n,e,t,r,i,o=!1,a=!1,d=!1,s,b=!1){let f=$t(n.map(y=>y.name)),w=[...xt(r,t),...o?[it]:[],...a?re:[],...b?[rt]:[]];return{definitions:t?[...se.filter(y=>!y.mutating),...w]:[...se,tt,...d?[ue]:[],...w,...n.filter(y=>e.has(y.name)).map(y=>Dt(y,f.get(y.name),i(y),s))],names:f}}function On(n,e={}){let t=e.author??{kind:"agent"},r=n.allMutations(),i=new Set(n.permittedMutations(t).map(m=>m.name)),{definitions:o,names:a}=Et(r,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,m=>X(n.schema,n.policy,t,m),_t(n.schema),e.subscriptions!==void 0,Ne(t),n.schema,e.learned!==void 0),d=Jt(o),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},b=m=>pe(s,m),f=m=>{if(!ot.includes(m)){for(let[u,S]of a)if(S===m)return u;return a.has(m)?m:xe(m,a.keys())}},w=m=>{let u=Me(m,a.keys());return u?` Did you mean "${u}"?`:""},h=m=>{let u=o.find(k=>k.name===m)??o.find(k=>k.act===m);if(u)return u;let S=f(m);return S===void 0?void 0:o.find(k=>k.act===S)},y=(m,u)=>{let S=r.find(c=>c.name===m);if(!S)return{args:u,resolved:[]};let k={...u},l=[];for(let c of C(S.input)){let p=k[c.name];if(typeof p!="string"||p.trim()==="")continue;let g=n.resolveRef(c,p,t);if(!g.ok){let A=g.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${c.name}.`:" Nothing was changed.";return{ok:!1,error:`${g.message}${A}`,argument:c.name,candidates:g.candidates}}g.by!=="id"&&(k[c.name]=g.id,l.push({argument:c.name,given:p,id:g.id,label:g.label}))}return{args:k,resolved:l}},_=async(m,u)=>{try{await vt();let S=h(m);if(!S&&m===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!S){let l=f(m);if(l){let c=n.permits({name:l,args:u},t);if(!c.ok)return{ok:!1,error:c.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}".${w(m)} Available: ${o.map(c=>c.name).join(", ")}`}}if(S.mutating&&e.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(S.act!==void 0){let l=y(S.act,u);if("ok"in l)return l;let c=S.act,p=b(()=>z(n,t,n.apply({name:c,args:l.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map($),resolves:p.resolves.map($),...l.resolved.length>0?{resolved:l.resolved}:{}},diff:p.diff}}let k=n.seenBy(t);switch(S.name){case"search_graph":{let l=typeof e.places=="function"?e.places():e.places,c=typeof u.subject=="string"?u.subject:void 0,p=Ie(k,String(u.query??""),{principal:t,rank:e.near,archived:ke(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...l?{places:l}:{},...c?{subject:c,from:[c]}:{}}),g=p.later?await p.later:p;return{ok:!0,data:(await q()).searchRead(g,Ye(g,U(k,t))),reads:g.hits.flatMap(A=>A.about==="node"?[A.id]:[])}}case"get_graph":return{ok:!0,...(await q()).graphRead(k,U(k,t),u)};case"get_node":{let l=String(u.id??""),c=l,p;if(!k.graph.getNode(l)){let A=l.trim()===""?void 0:n.resolveRef({name:"id",kinds:["*"]},l,t);if(A?.ok)c=A.id,p={argument:"id",given:l,id:c,label:A.label};else return A?.reason==="ambiguous"?{ok:!1,error:A.message,argument:"id",candidates:A.candidates}:{ok:!1,error:`No node "${l}".`}}let g=(await q()).nodeRead(k,U(k,t),c,u);return{ok:!0,data:p?{...g.data,resolved:[p]}:g.data,reads:g.reads}}case"describe_place":{let l=e.app??{name:"",schema:n.schema},c=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:p}=await St(),g=p(n,t,String(u.place??""),{app:l,width:c});if(!g.ok)return{ok:!1,error:`${g.error} The places are: ${g.places.join(", ")}.`};let A=new Set,M=I=>{for(let D of I)for(let x of D.groups??[])for(let P of x.items)A.add(P.id),M(P.parts)};return M(g.description.parts),{ok:!0,data:g.description,reads:[...A]}}case"find_linked":return Tt(k,t,u,e.linked);case"draft_view":case"keep_lens":{let l=e.app??{name:"",schema:n.schema};return(await At()).runDraftTool(S.name,u,{app:l,principal:t,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let l=k.violations(u.context);return{ok:!0,...(await q()).violationsRead(l,u)}}case"get_affordances":{let l=u.selection??[];return{ok:!0,data:He(k,l,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:l.filter(p=>k.graph.has(p))}}case"preview_mutation":{let l=String(u.mutation),c=f(l)??l,p=y(c,u.args??{});if("ok"in p)return p;let g=n.missingFor({name:c,args:p.args},t);if(g)return{ok:!1,error:g.message,reason:"missing"};let A=z(n,t,n.preview({name:c,args:p.args},void 0,{author:t})),M=et(A);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let l=String(u.act??""),c=f(l)??l,p=r.find(R=>R.name===c);if(!p||!i.has(c)){let R=p?n.permits({name:c,args:{}},t):void 0;return R&&!R.ok?{ok:!1,error:R.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${l}" this seat may run.${w(l)} Nothing was changed.`,reason:"invalid"}}let g=p.subject;if(!g)return{ok:!1,error:`"${G(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let A=Array.isArray(u.records)?u.records.filter(R=>typeof R=="string"&&R.trim()!==""):[];if(A.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let R of A.slice(0,200)){let J=n.resolveRef({name:g.arg,kinds:g.kinds},R,t);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};M.push(J.id),J.by!=="id"&&I.push({argument:"records",given:R,id:J.id,label:J.label})}let D=y(c,{...u.args??{}});if("ok"in D)return D;let x=(await Ot()).actOnSeveral(n,{mutation:c,subject:g.arg,args:D.args},M,{author:t,...V(e.via)}),P=x.result?z(n,t,x.result):void 0;return{ok:!0,data:{...x.batch?{batch:x.batch,intent:x.intent}:{},applied:x.applied,unchanged:x.unchanged,refused:x.refused.map(R=>({record:R.id,label:R.label,error:R.message,reason:R.reason})),...x.allOrNothing?{keptNone:!0}:{},...P?{introduces:P.introduces.map($),resolves:P.resolves.map($)}:{},...I.length>0||D.resolved.length>0?{resolved:[...I,...D.resolved]}:{}},...P?{diff:P.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let l=await(await Rt()).runSubscriptionTool(S.name,u,{store:n,principal:e.subscriber??t,app:e.app?.name??"app",subscriptions:e.subscriptions});return l.ok?{ok:!0,data:l.data}:{ok:!1,error:l.error}}case"list_app_suggestions":return{ok:!0,data:{suggestions:(await e.learned()).map(({key:c,said:p,why:g,edits:A,evidence:M})=>({key:c,said:p,why:g,edits:A,evidence:M}))}};case"list_suggestions":{let l=Ee(n,t).map(c=>{let p=W(c.author,{graph:k.graph,schema:n.schema});return{id:c.id,intent:c.intent,by:p,at:c.at,about:c.about,...c.lineage?{basis:{untrusted:!0,authoredBy:p,text:c.lineage.basis},...c.lineage.confidence!==void 0?{confidence:c.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:l},reads:[...new Set(l.flatMap(c=>c.about))]}}case"suggest_changes":{let l=u.calls.map(p=>({name:f(p.act)??p.act,args:p.args}));return{ok:!0,data:{suggestion:Je(n,l,{author:t,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"accept_suggestion":case"decline_suggestion":{let l=String(u.suggestion??""),c={author:t,...V(e.via)},p=S.name==="accept_suggestion"?je(n,l,c):ze(n,l,c),g=z(n,t,p);return{ok:!0,data:{batch:g.batch,intent:g.intent,introduces:g.introduces.map($),resolves:g.resolves.map($)},diff:g.diff}}case"undo_batch":{let l=String(u.batch),c=u.include??[],p=k.canUndo([l,...c]);if(!p.ok)return{ok:!1,error:p.message};let g=z(n,t,n.undo([l,...c],{...e.author?{author:e.author}:{}}));return{ok:!0,data:et(g),diff:g.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(S){let{reason:k,wouldNeed:l}=ve(S);return{ok:!1,error:S instanceof Error?S.message:String(S),reason:k,...l?{wouldNeed:l}:{}}}},O=new Set,v=m=>{for(let u of O)u(m)};return{definitions:o,hash:d,...e.author?{author:e.author}:{},onDiff(m){return n.subscribe(m)},onCall(m){return O.add(m),()=>O.delete(m)},async call(m,u){let S=h(m)?.mutating??!1,k={name:m,args:u,mutating:S,at:new Date().toISOString()};v({...k,phase:"running"});let l=p=>(v(p.ok?{...k,phase:"ok",...!S&&p.reads?{reads:p.reads}:{}}:{...k,phase:"failed",error:p.error}),p),c=await _(m,u);return l(c.ok&&!S?{...c,data:(await q()).withinReadChars(m,c.data)}:c)}}}function V(n){let e=typeof n=="function"?n():n;return e?{via:e}:{}}export{le as a,On as b};
@@ -0,0 +1,4 @@
1
+ var l={},R={empty:!0},Ae={id:"text",class:"text",title:"text",lang:"text",dir:{oneOf:["ltr","rtl","auto"]},hidden:"text",tabindex:{oneOf:["-1","0"]},role:"text",style:"style",translate:{oneOf:["yes","no"]},spellcheck:{oneOf:["true","false"]},draggable:{oneOf:["true","false"]},inert:"boolean"},T={div:l,section:l,article:l,aside:l,header:l,footer:l,nav:l,hgroup:l,search:l,address:l,figure:l,figcaption:l,blockquote:l,p:l,pre:l,hr:R,br:R,wbr:R,h1:l,h2:l,h3:l,h4:l,h5:l,h6:l,span:l,strong:l,em:l,b:l,i:l,u:l,s:l,small:l,mark:l,abbr:l,cite:l,q:l,code:l,kbd:l,samp:l,var:l,sub:l,sup:l,dfn:l,bdi:l,bdo:l,ruby:l,rt:l,rp:l,time:{attributes:{datetime:"text"}},data:{attributes:{value:"text"}},del:{attributes:{datetime:"text"}},ins:{attributes:{datetime:"text"}},a:{attributes:{href:"link"}},ul:l,menu:l,dl:l,dt:l,dd:l,ol:{attributes:{start:"number",reversed:"boolean",type:{oneOf:["1","a","A","i","I"]}}},li:{attributes:{value:"number"}},table:l,caption:l,thead:l,tbody:l,tfoot:l,tr:l,colgroup:{attributes:{span:"number"}},col:{attributes:{span:"number"},empty:!0},th:{attributes:{colspan:"number",rowspan:"number",headers:"text",scope:{oneOf:["row","col","rowgroup","colgroup"]},abbr:"text"}},td:{attributes:{colspan:"number",rowspan:"number",headers:"text"}},details:{attributes:{open:"boolean",name:"text"}},summary:l,button:{attributes:{type:{oneOf:["button"]},disabled:"boolean",name:"text",value:"text"}},input:{empty:!0,attributes:{type:{oneOf:["text","search","number","range","checkbox","radio","date","time","datetime-local","month","week","color","email","tel","url"]},name:"text",value:"text",placeholder:"text",min:"text",max:"text",step:"text",checked:"boolean",disabled:"boolean",readonly:"boolean",required:"boolean",maxlength:"number",minlength:"number",size:"number",pattern:"text",multiple:"boolean",inputmode:"text",enterkeyhint:"text"}},select:{attributes:{name:"text",disabled:"boolean",multiple:"boolean",required:"boolean",size:"number"}},option:{attributes:{value:"text",selected:"boolean",disabled:"boolean",label:"text"}},optgroup:{attributes:{label:"text",disabled:"boolean"}},textarea:{attributes:{name:"text",placeholder:"text",rows:"number",cols:"number",disabled:"boolean",readonly:"boolean",required:"boolean",maxlength:"number",minlength:"number",wrap:{oneOf:["soft","hard","off"]}}},label:{attributes:{for:"text"}},fieldset:{attributes:{disabled:"boolean",name:"text"}},legend:l,output:l,meter:{attributes:{value:"number",min:"number",max:"number",low:"number",high:"number",optimum:"number"}},progress:{attributes:{value:"number",max:"number"}},img:{empty:!0,attributes:{src:"image",alt:"text",width:"number",height:"number",decoding:{oneOf:["async","sync","auto"]}}},"graview-video":R},Te=["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-opacity","stroke-miterlimit","opacity","color","display","visibility","transform-origin","clip-path","clip-rule","marker-start","marker-mid","marker-end","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","letter-spacing","text-decoration","paint-order","vector-effect","shape-rendering","pointer-events","stop-color","stop-opacity","overflow","mask","filter","flood-color","flood-opacity","lighting-color","color-interpolation-filters"],_e={id:"text",class:"text",style:"style",lang:"text",role:"text",tabindex:{oneOf:["-1","0"]},transform:"geometry",...Object.fromEntries(Te.map(e=>[e,"css"]))},x={x:"geometry",y:"geometry",width:"geometry",height:"geometry"},A={viewBox:"geometry",preserveAspectRatio:"geometry"},q={oneOf:["userSpaceOnUse","objectBoundingBox"]},Y={oneOf:["R","G","B","A"]},y={...x,in:"text",result:"text"},K={gradientUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]},gradientTransform:"geometry",spreadMethod:{oneOf:["pad","reflect","repeat"]},href:"fragment"},_={svg:{attributes:{...x,...A}},g:l,defs:l,symbol:{attributes:{...x,...A,refX:"geometry",refY:"geometry"}},use:{attributes:{...x,href:"fragment"}},title:l,desc:l,path:{attributes:{d:"geometry",pathLength:"number"}},rect:{attributes:{...x,rx:"geometry",ry:"geometry",pathLength:"number"}},circle:{attributes:{cx:"geometry",cy:"geometry",r:"geometry",pathLength:"number"}},ellipse:{attributes:{cx:"geometry",cy:"geometry",rx:"geometry",ry:"geometry",pathLength:"number"}},line:{attributes:{x1:"geometry",y1:"geometry",x2:"geometry",y2:"geometry",pathLength:"number"}},polyline:{attributes:{points:"geometry",pathLength:"number"}},polygon:{attributes:{points:"geometry",pathLength:"number"}},text:{attributes:{x:"geometry",y:"geometry",dx:"geometry",dy:"geometry",rotate:"geometry",textLength:"geometry",lengthAdjust:{oneOf:["spacing","spacingAndGlyphs"]}}},tspan:{attributes:{x:"geometry",y:"geometry",dx:"geometry",dy:"geometry",rotate:"geometry",textLength:"geometry"}},textPath:{attributes:{href:"fragment",startOffset:"geometry",method:{oneOf:["align","stretch"]},spacing:{oneOf:["auto","exact"]},side:{oneOf:["left","right"]}}},linearGradient:{attributes:{x1:"geometry",y1:"geometry",x2:"geometry",y2:"geometry",...K}},radialGradient:{attributes:{cx:"geometry",cy:"geometry",r:"geometry",fx:"geometry",fy:"geometry",fr:"geometry",...K}},stop:{attributes:{offset:"geometry"}},clipPath:{attributes:{clipPathUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]}}},mask:{attributes:{...x,maskUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]},maskContentUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]}}},pattern:{attributes:{...x,...A,patternUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]},patternContentUnits:{oneOf:["userSpaceOnUse","objectBoundingBox"]},patternTransform:"geometry",href:"fragment"}},marker:{attributes:{...A,markerWidth:"geometry",markerHeight:"geometry",refX:"geometry",refY:"geometry",orient:"geometry",markerUnits:{oneOf:["strokeWidth","userSpaceOnUse"]}}},a:l,filter:{attributes:{...x,filterUnits:q,primitiveUnits:q}},feBlend:{attributes:{...y,in2:"text",mode:"text"}},feColorMatrix:{attributes:{...y,type:{oneOf:["matrix","saturate","hueRotate","luminanceToAlpha"]},values:"geometry"}},feComponentTransfer:{attributes:y},...Object.fromEntries(["feFuncR","feFuncG","feFuncB","feFuncA"].map(e=>[e,{attributes:{type:{oneOf:["identity","table","discrete","linear","gamma"]},tableValues:"geometry",slope:"number",intercept:"number",amplitude:"number",exponent:"number",offset:"number"}}])),feComposite:{attributes:{...y,in2:"text",operator:{oneOf:["over","in","out","atop","xor","lighter","arithmetic"]},k1:"number",k2:"number",k3:"number",k4:"number"}},feDisplacementMap:{attributes:{...y,in2:"text",scale:"number",xChannelSelector:Y,yChannelSelector:Y}},feDropShadow:{attributes:{...y,dx:"number",dy:"number",stdDeviation:"geometry"}},feFlood:{attributes:y},feGaussianBlur:{attributes:{...y,stdDeviation:"geometry",edgeMode:{oneOf:["duplicate","wrap","none"]}}},feMerge:{attributes:y},feMergeNode:{attributes:{in:"text"}},feMorphology:{attributes:{...y,operator:{oneOf:["erode","dilate"]},radius:"geometry"}},feOffset:{attributes:{...y,dx:"number",dy:"number"}},feTurbulence:{attributes:{...x,result:"text",type:{oneOf:["fractalNoise","turbulence"]},baseFrequency:"geometry",numOctaves:"number",seed:"number",stitchTiles:{oneOf:["stitch","noStitch"]}}}};var Z=["alert","alertdialog","dialog","banner","main","navigation","contentinfo","complementary","search","form","application","status","log","marquee","timer"],rt=["region"],E={nav:"div",header:"div",footer:"div",aside:"div",search:"div",output:"span"},J={section:["aria-label","title"]},ot=["aria-labelledby","aria-describedby"];function Pe(e){return/^aria-[a-z]+$/.test(e)}function $e(e){return/^data-[a-z0-9][a-z0-9_.-]*$/.test(e)}var Q=["all","display","position","top","right","bottom","left","inset","inset-block","inset-inline","inset-block-start","inset-block-end","inset-inline-start","inset-inline-end","width","height","min-width","min-height","max-width","max-height","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin","margin-top","margin-right","margin-bottom","margin-left","margin-block","margin-inline","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end","padding","padding-top","padding-right","padding-bottom","padding-left","padding-block","padding-inline","padding-block-start","padding-block-end","padding-inline-start","padding-inline-end","box-sizing","overflow","overflow-x","overflow-y","overflow-wrap","float","clear","z-index","aspect-ratio","object-fit","object-position","vertical-align","isolation","contain","container","container-type","container-name","content-visibility","flex","flex-direction","flex-wrap","flex-flow","flex-grow","flex-shrink","flex-basis","order","grid","grid-template","grid-template-columns","grid-template-rows","grid-template-areas","grid-auto-columns","grid-auto-rows","grid-auto-flow","grid-area","grid-column","grid-row","grid-column-start","grid-column-end","grid-row-start","grid-row-end","gap","row-gap","column-gap","align-items","align-content","align-self","justify-items","justify-content","justify-self","place-items","place-content","place-self","columns","column-count","column-width","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-fill","color","background","background-color","background-image","background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode","border","border-top","border-right","border-bottom","border-left","border-block","border-inline","border-block-start","border-block-end","border-inline-start","border-inline-end","border-width","border-style","border-color","border-top-width","border-right-width","border-bottom-width","border-left-width","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-color","border-right-color","border-bottom-color","border-left-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","border-start-start-radius","border-start-end-radius","border-end-start-radius","border-end-end-radius","border-collapse","border-spacing","outline","outline-width","outline-style","outline-color","outline-offset","box-shadow","opacity","visibility","mix-blend-mode","filter","backdrop-filter","clip-path","accent-color","caret-color","color-scheme","appearance","-webkit-appearance","mask-image","mask-size","mask-position","mask-repeat","mask-origin","mask-clip","mask-composite","mask-mode","mask-type","-webkit-mask","-webkit-mask-image","-webkit-mask-size","-webkit-mask-position","-webkit-mask-repeat","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-composite","font","font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-variant-numeric","font-variant-caps","font-variant-ligatures","font-feature-settings","font-variation-settings","font-kerning","font-optical-sizing","font-size-adjust","font-synthesis","line-height","letter-spacing","word-spacing","text-align","text-align-last","text-indent","text-transform","text-decoration","text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-underline-position","text-shadow","text-overflow","text-wrap","text-wrap-mode","text-wrap-style","white-space","white-space-collapse","word-break","line-break","hyphens","tab-size","direction","unicode-bidi","writing-mode","text-orientation","text-rendering","-webkit-font-smoothing","-webkit-line-clamp","-webkit-box-orient","line-clamp","-webkit-text-fill-color","-webkit-background-clip","-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","list-style","list-style-type","list-style-position","content","quotes","counter-reset","counter-increment","counter-set","table-layout","caption-side","empty-cells","transform","transform-origin","transform-box","transform-style","translate","rotate","scale","perspective","perspective-origin","backface-visibility","transition","transition-property","transition-duration","transition-timing-function","transition-delay","transition-behavior","animation","animation-name","animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state","animation-composition","will-change","animation-timeline","animation-range","animation-range-start","animation-range-end","scroll-timeline","scroll-timeline-name","scroll-timeline-axis","view-timeline","view-timeline-name","view-timeline-axis","view-timeline-inset","timeline-scope","cursor","pointer-events","user-select","-webkit-user-select","touch-action","resize","scroll-behavior","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","scroll-snap-type","scroll-snap-align","scroll-snap-stop","scroll-margin","scroll-padding","scrollbar-width","scrollbar-color","scrollbar-gutter","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-opacity","stroke-miterlimit","stop-color","stop-opacity","clip-rule","marker","marker-start","marker-mid","marker-end","paint-order","vector-effect","shape-rendering","text-anchor","dominant-baseline","alignment-baseline","r","cx","cy","rx","ry","x","y","d","mask","flood-color","flood-opacity","lighting-color","color-interpolation-filters"],ee=["var","env","calc","min","max","clamp","round","mod","rem","abs","sign","sin","cos","tan","asin","acos","atan","atan2","pow","sqrt","hypot","log","exp","rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","color-mix","light-dark","linear-gradient","radial-gradient","conic-gradient","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","translate","translatex","translatey","translatez","translate3d","rotate","rotatex","rotatey","rotatez","rotate3d","scale","scalex","scaley","scalez","scale3d","skew","skewx","skewy","matrix","matrix3d","perspective","cubic-bezier","steps","linear","repeat","minmax","fit-content","blur","brightness","contrast","drop-shadow","grayscale","hue-rotate","invert","saturate","sepia","opacity","circle","ellipse","inset","polygon","path","xywh","rect","counter","counters","scroll","view"],te=["fill","stroke","clip-path","mask","marker","marker-start","marker-mid","marker-end","filter"],ne=["media","supports","container","keyframes"],re={position:["static","relative","absolute","sticky"],all:[],appearance:["auto","none","menulist-button","textfield"],"-webkit-appearance":["auto","none","menulist-button","textfield"]},oe=["host","host-context","slotted","part","backdrop","picker","view-transition","view-transition-group","view-transition-image-pair","view-transition-old","view-transition-new"],ie=["-webkit-details-marker"],P=64e3,D=4e3,ae=1e5,O=512e3,it=1e4,at="http://www.w3.org/1999/xhtml",st="http://www.w3.org/2000/svg",Ne=new Map(Object.keys(_).map(e=>[e.toLowerCase(),e]));function se(e){return Ne.get(e.toLowerCase())}function le(e,r,n){let t=n.toLowerCase(),i=e==="html"?[T[r]?.attributes,Ae]:[_[r]?.attributes,_e],o=e==="svg"&&t==="xlink:href"?"href":t;for(let a of i)if(a){for(let[u,c]of Object.entries(a))if(u.toLowerCase()===o)return{name:u,kind:c}}if(Pe(t)||$e(t))return{name:t,kind:"text"}}var f=e=>e>=48&&e<=57,ue=e=>f(e)||e>=65&&e<=70||e>=97&&e<=102,F=e=>e>=65&&e<=90||e>=97&&e<=122,X=e=>e>=128,$=e=>F(e)||X(e)||e===95,de=e=>$(e)||f(e)||e===45,ce=e=>e===10,k=e=>e===10||e===9||e===32,Le=e=>e>=0&&e<=8||e===11||e>=14&&e<=31||e===127,b=-1;function ze(e){let r=[];for(let n=0;n<e.length;n+=1){let t=e.codePointAt(n);t>65535&&(n+=1),t===13?(e.charCodeAt(n+1)===10&&(n+=1),t=10):t===12?t=10:(t===0||t>=55296&&t<=57343)&&(t=65533),r.push(t)}return r}function Me(e){let r=ze(e),n=0,t=(s=0)=>n+s<r.length?r[n+s]:b,i=[],o=(s,d)=>s===92&&d!==10&&d!==b,a=(s,d,g)=>s===45?$(d)||d===45||o(d,g):$(s)?!0:o(s,d),u=(s,d,g)=>s===43||s===45?f(d)||d===46&&f(g):f(s===46?d:s),c=()=>{let s=t();if(n+=1,s===b)return 65533;if(ue(s)){let d=String.fromCodePoint(s);for(;d.length<6&&ue(t());)d+=String.fromCodePoint(t()),n+=1;k(t())&&(n+=1);let g=parseInt(d,16);return g===0||g>=55296&&g<=57343||g>1114111?65533:g}return s},p=()=>{let s="";for(;;){let d=t();if(de(d))s+=String.fromCodePoint(d),n+=1;else if(o(d,t(1)))n+=1,s+=String.fromCodePoint(c());else return s}},m=()=>{let s="";for((t()===43||t()===45)&&(s+=String.fromCodePoint(r[n++]));f(t());)s+=String.fromCodePoint(r[n++]);if(t()===46&&f(t(1)))for(s+=String.fromCodePoint(r[n++],r[n++]);f(t());)s+=String.fromCodePoint(r[n++]);if((t()===69||t()===101)&&(f(t(1))||(t(1)===43||t(1)===45)&&f(t(2))))for(s+=String.fromCodePoint(r[n++]),f(t())||(s+=String.fromCodePoint(r[n++]));f(t());)s+=String.fromCodePoint(r[n++]);return s},C=()=>{let s=m();return a(t(),t(1),t(2))?{type:"dimension",repr:s,unit:p()}:t()===37?(n+=1,{type:"percentage",repr:s}):{type:"number",repr:s}},h=()=>{for(;;){let s=t();if(n+=1,s===41||s===b)return;o(s,t())&&c()}},Oe=()=>{let s="";for(;k(t());)n+=1;for(;;){let d=t();if(n+=1,d===41)return{type:"url",value:s};if(d===b)return{type:"url",value:s};if(k(d)){for(;k(t());)n+=1;return t()===41||t()===b?(t()===41&&(n+=1),{type:"url",value:s}):(h(),{type:"bad-url"})}if(d===34||d===39||d===40||Le(d))return h(),{type:"bad-url"};if(d===92){if(o(d,t()))s+=String.fromCodePoint(c());else return h(),{type:"bad-url"};continue}s+=String.fromCodePoint(d)}},j=()=>{let s=p();if(s.toLowerCase()==="url"&&t()===40){for(n+=1;k(t())&&k(t(1));)n+=1;let d=k(t())?t(1):t();return d===34||d===39?{type:"function",value:s}:Oe()}return t()===40?(n+=1,{type:"function",value:s}):{type:"ident",value:s}},Re=s=>{let d="";for(;;){let g=t();if(n+=1,g===s||g===b)return{type:"string",value:d};if(ce(g))return n-=1,{type:"bad-string"};if(g===92){if(t()===b)continue;if(ce(t())){n+=1;continue}d+=String.fromCodePoint(c());continue}d+=String.fromCodePoint(g)}};for(;;){for(;t()===47&&t(1)===42;){for(n+=2;t()!==b&&!(t()===42&&t(1)===47);)n+=1;t()!==b&&(n+=2)}let s=t();if(s===b)return i;if(k(s)){for(;k(t());)n+=1;i.push({type:"whitespace"});continue}switch(n+=1,s){case 34:case 39:i.push(Re(s));continue;case 35:if(de(t())||o(t(),t(1))){let d=a(t(),t(1),t(2));i.push({type:"hash",value:p(),id:d})}else i.push({type:"delim",value:"#"});continue;case 40:i.push({type:"("});continue;case 41:i.push({type:")"});continue;case 43:case 46:u(s,t(),t(1))?(n-=1,i.push(C())):i.push({type:"delim",value:String.fromCodePoint(s)});continue;case 44:i.push({type:","});continue;case 45:u(s,t(),t(1))?(n-=1,i.push(C())):t()===45&&t(1)===62?(n+=2,i.push({type:"CDC"})):a(s,t(),t(1))?(n-=1,i.push(j())):i.push({type:"delim",value:"-"});continue;case 58:i.push({type:":"});continue;case 59:i.push({type:";"});continue;case 60:t()===33&&t(1)===45&&t(2)===45?(n+=3,i.push({type:"CDO"})):i.push({type:"delim",value:"<"});continue;case 64:a(t(),t(1),t(2))?i.push({type:"at-keyword",value:p()}):i.push({type:"delim",value:"@"});continue;case 91:i.push({type:"["});continue;case 92:o(s,t())?(n-=1,i.push(j())):i.push({type:"delim",value:"\\"});continue;case 93:i.push({type:"]"});continue;case 123:i.push({type:"{"});continue;case 125:i.push({type:"}"});continue;default:f(s)?(n-=1,i.push(C())):$(s)?(n-=1,i.push(j())):i.push({type:"delim",value:String.fromCodePoint(s)})}}}var ye={"{":"}","[":"]","(":")"},be=32,U=class{constructor(r){this.tokens=r}i=0;peek(){return this.tokens[this.i]}next(){return this.tokens[this.i++]}};function he(e,r){let n=e.next();return n.type==="{"||n.type==="["||n.type==="("?{type:"block",open:n.type,value:pe(e,ye[n.type],r+1)}:n.type==="function"?{type:"func",name:n.value,value:pe(e,")",r+1)}:n}function pe(e,r,n){let t=[];for(;;){let i=e.peek();if(!i)return t;if(i.type===r)return e.next(),t;if(n>be){e.next(),t.push({type:"bad-string"});continue}t.push(he(e,n))}}function v(e,r){let n=[],t=0;for(;t<e.length;){let i=e[t];if(i.type==="whitespace"||r&&(i.type==="CDO"||i.type==="CDC")){t+=1;continue}if(i.type==="at-keyword"){let u=[];t+=1;let c;for(;t<e.length;){let p=e[t];if(t+=1,p.type===";")break;if(p.type==="block"&&p.open==="{"){c=p.value;break}u.push(p)}n.push({type:"at-rule",name:i.value,prelude:u,...c?{block:c}:{}});continue}let o=[],a;for(;t<e.length;){let u=e[t];if(t+=1,u.type==="block"&&u.open==="{"){a=u.value;break}o.push(u)}a&&n.push({type:"qualified",prelude:o,block:a})}return n}function H(e){let r=[],n=0;for(;n<e.length;){let t=e[n];if(t.type==="whitespace"||t.type===";"){n+=1;continue}if(t.type==="at-keyword"){let o=(()=>{for(let a=n+1;a<e.length;a+=1){let u=e[a];if(u.type===";"||u.type==="block"&&u.open==="{")return a+1}return e.length})();r.push(...v(e.slice(n,o),!1)),n=o;continue}if(t.type==="ident"){let o=n+1;for(;e[o]?.type==="whitespace";)o+=1;if(e[o]?.type===":"){let a=o+1;for(;a<e.length&&e[a].type!==";";)a+=1;let u=xe(t.value,e.slice(o+1,a));if(u.value.some(c=>c.type==="block"&&c.open==="{")){let c=e.findIndex((p,m)=>m>n&&p.type==="block"&&p.open==="{");r.push(...v(e.slice(n,c+1),!1)),n=c+1;continue}r.push(u),n=a+1;continue}}let i=n;for(;i<e.length&&!(e[i].type==="block"&&e[i].open==="{")&&e[i].type!==";";)i+=1;i<e.length&&e[i].type==="block"&&r.push(...v(e.slice(n,i+1),!1)),n=i+1}return r}function xe(e,r){let n=[...r];for(;n[0]?.type==="whitespace";)n.shift();for(;n.at(-1)?.type==="whitespace";)n.pop();let t=!1,o=n.length-1;if(n[o]?.type==="ident"&&n[o].value.toLowerCase()==="important"){for(o-=1;n[o]?.type==="whitespace";)o-=1;let a=n[o];if(a?.type==="delim"&&a.value==="!")for(t=!0,n.length=o;n.at(-1)?.type==="whitespace";)n.pop()}return{type:"declaration",name:e,value:n,important:t}}function W(e){let r=new U(Me(e)),n=[];for(;r.peek();)n.push(he(r,0));return n}function N(e){let r="",n=[...e].map(t=>t.codePointAt(0));return n.forEach((t,i)=>{t===0?r+="\uFFFD":t>=1&&t<=31||t===127||i===0&&f(t)||i===1&&f(t)&&n[0]===45?r+=`\\${t.toString(16)} `:i===0&&t===45&&n.length===1?r+="\\-":X(t)||t===45||t===95||f(t)||F(t)?r+=String.fromCodePoint(t):r+=`\\${String.fromCodePoint(t)}`}),r}function L(e){let r="";for(let n of e){let t=n.codePointAt(0);X(t)||t===45||t===95||f(t)||F(t)?r+=n:t>=1&&t<=31||t===127?r+=`\\${t.toString(16)} `:r+=`\\${n}`}return r}function I(e){let r='"';for(let n of e){let t=n.codePointAt(0);t===0?r+="\uFFFD":t>=1&&t<=31||t===127||t===60||t===62?r+=`\\${t.toString(16)} `:t===34||t===92?r+=`\\${n}`:r+=n}return`${r}"`}function je(e){let r=L(e);return/^[eE]([0-9]|[+-][0-9])/.test(e)?`\\${e.codePointAt(0).toString(16)} ${L(e.slice(1))}`:r}var fe=e=>{switch(e.type){case"ident":case"url":case"bad-url":case"number":case"percentage":case"dimension":case"CDC":case"hash":case"at-keyword":return e.type;case"func":case"function":return"function";case"block":return e.open==="("?"(":"other";case"(":return"(";case"delim":return`delim${e.value}`;default:return"other"}};function De(e,r){let n=["ident","function","url","bad-url","delim-","number","percentage","dimension","CDC"];return e==="ident"?[...n,"("].includes(r):e==="at-keyword"||e==="hash"||e==="dimension"||e==="delim#"||e==="delim-"?n.includes(r):e==="number"?["ident","function","url","bad-url","number","percentage","dimension","delim%"].includes(r):e==="delim@"?["ident","function","url","bad-url","delim-","CDC"].includes(r):e==="delim."||e==="delim+"?["number","percentage","dimension"].includes(r):e==="delim/"?r==="delim*":!1}function Ve(e){switch(e.type){case"whitespace":return" ";case"ident":return N(e.value);case"at-keyword":return`@${N(e.value)}`;case"hash":return`#${L(e.value)}`;case"string":return I(e.value);case"url":return`url(${I(e.value)})`;case"delim":return e.value==="\\"?`\\
2
+ `:e.value;case"CDO":return"<!--";case"CDC":return"-->";case"number":return e.repr;case"percentage":return`${e.repr}%`;case"dimension":return`${e.repr}${je(e.unit)}`;case"func":return`${N(e.name)}(${S(e.value)})`;case"block":return`${e.open}${S(e.value)}${ye[e.open]}`;case":":case";":case",":case"[":case"]":case"(":case")":case"{":case"}":return e.type;default:return""}}function S(e){let r="",n;for(let t of e)t.type==="whitespace"&&n?.type==="whitespace"||(n&&De(fe(n),fe(t))&&(r+="/**/"),r+=Ve(t),n=t);return r}var Ue=new Set(Q),ke=new Set(ee),me=new Set(te),Ie=new Set(ne),Be=new Set(oe),Ge=new Set(ie),ge=/^#[A-Za-z_][A-Za-z0-9_.:-]*$/,w=e=>e.replace(/[A-Z]/g,r=>r.toLowerCase()),Fe=e=>w(e);function B(e,r,n){let t=[];for(let i of r){if(i.type==="bad-url"||i.type==="bad-string"){n({reason:"unreadable",...e?{name:e}:{}});return}if(i.type==="url"){if(e&&me.has(e)&&ge.test(i.value)){t.push({type:"func",name:"url",value:[{type:"string",value:i.value}]});continue}n({reason:"url",...e?{name:e}:{}});return}if(i.type==="func"){let o=w(i.name);if(o==="url"||o==="src"){let u=i.value.filter(p=>p.type!=="whitespace"),c=u[0];if(o==="url"&&u.length===1&&c?.type==="string"&&e&&me.has(e)&&ge.test(c.value)){t.push({type:"func",name:"url",value:[{type:"string",value:c.value}]});continue}n({reason:"url",...e?{name:e}:{}});return}if(!ke.has(o)){n({reason:"function",name:o});return}let a=B(e,i.value,n);if(!a)return;o==="var"?t.push({type:"whitespace"},{type:"func",name:o,value:a},{type:"whitespace"}):t.push({type:"func",name:o,value:a});continue}if(i.type==="block"){if(i.open==="{"||i.open==="("&&t.at(-1)?.type==="ident"){n({reason:"unreadable",...e?{name:e}:{}});return}let o=B(e,i.value,n);if(!o)return;t.push({type:"block",open:i.open,value:o});continue}if(i.type==="at-keyword"||i.type==="CDO"||i.type==="CDC"||i.type==="{"||i.type==="}"||i.type===";"||i.type==="delim"&&i.value==="\\"){n({reason:"unreadable",...e?{name:e}:{}});return}t.push(i)}return t}var Xe=/^(animation|transition|scroll-behavior)/;function M(e,r,n=!1){let t=e.name.startsWith("--"),i=t?e.name:Fe(e.name);if(!t&&!Ue.has(i)){r({reason:"property",name:i});return}let o=re[i];if(o){let c=e.value.filter(C=>C.type!=="whitespace"),p=c[0],m=c.length===1&&p?.type==="ident"?w(p.value):void 0;if(!m||![...o,"inherit","initial","unset","revert"].includes(m)){r({reason:"value",name:i});return}return`${i}: ${m}${e.important?" !important":""}`}let a=B(t?void 0:i,e.value,r);if(!a)return;let u=S(a).trim();return`${t?`--${L(e.name.slice(2))}`:i}: ${u}${e.important&&!(n&&Xe.test(i))?" !important":""}`}function we(e,r){let n=t=>{for(let i=0;i<t.length;i+=1){let o=t[i];if(i>0&&t[i-1].type===":"&&(o.type==="ident"||o.type==="func")){let u=w(o.type==="ident"?o.value:o.name);if(Be.has(u)||(u.startsWith("-webkit-")||u.startsWith("-moz-"))&&!Ge.has(u))return r({reason:"selector",name:u}),!1}if(o.type==="url"||o.type==="bad-url"||o.type==="bad-string"||o.type==="at-keyword"||o.type==="CDO"||o.type==="CDC"||o.type==="block"&&o.open==="{")return r({reason:"unreadable",name:"selector"}),!1;if(o.type==="func"&&!n(o.value)||o.type==="block"&&!n(o.value))return!1}return!0};return n(e)}function V(e,r,n){let t=[];for(let i of H(e))if(i.type==="declaration"){let o=M(i,r);o&&t.push(`${o};`)}else{let o=z(i,r,n+1,"style");o&&t.push(o)}return t.join(" ")}function He(e,r,n){let t=i=>i.every(o=>{if(o.type==="url"||o.type==="bad-url"||o.type==="bad-string"||o.type==="block"&&o.open==="{")return n({reason:o.type==="url"?"url":"unreadable",name:`@${r}`}),!1;if(o.type==="func"){let a=w(o.name);return r==="supports"&&a==="selector"?we(o.value,n):ke.has(a)?t(o.value):(n({reason:"function",name:a}),!1)}if(o.type==="block"){if(r==="supports"){let a=H(o.value);if(a.length===1&&a[0].type==="declaration")return M(a[0],n)!==void 0}return t(o.value)}return!0});return t(e)?S(e).trim():void 0}function G(e){return e.map((r,n)=>{let t=e[n-1],i=t?.type===":"||t?.type==="delim"&&(t.value==="."||t.value==="|");return r.type==="ident"&&!i&&Object.prototype.hasOwnProperty.call(E,w(r.value))?{type:"block",open:"[",value:[{type:"ident",value:"data-graview-as"},{type:"delim",value:"="},{type:"string",value:w(r.value)}]}:r.type==="func"?{type:"func",name:r.name,value:G(r.value)}:r.type==="block"&&r.open==="("?{type:"block",open:"(",value:G(r.value)}:r})}function z(e,r,n,t){if(n>be){r({reason:"unreadable",name:"nesting"});return}if(e.type==="qualified"){if(t==="keyframes"){if(!e.prelude.every(m=>m.type==="whitespace"||m.type===","||m.type==="percentage"||m.type==="ident"&&["from","to"].includes(w(m.value)))){r({reason:"unreadable",name:"keyframe"});return}return`${S(e.prelude).trim()} { ${V(e.block,r,n)} }`}if(!we(e.prelude,r))return;let c=S(G(e.prelude)).trim();if(c===""){r({reason:"unreadable",name:"selector"});return}return`${c} { ${V(e.block,r,n)} }`}let i=w(e.name),o=i==="-webkit-keyframes"?"keyframes":i;if(!Ie.has(o)||t==="keyframes"){r({reason:"at-rule",name:`@${i}`});return}if(!e.block){r({reason:"unreadable",name:`@${i}`});return}if(o==="keyframes"){if(t!=="sheet"){r({reason:"at-rule",name:"@keyframes"});return}let c=e.prelude.filter(h=>h.type!=="whitespace"),p=c[0];if(c.length!==1||!p||p.type!=="ident"&&p.type!=="string"){r({reason:"unreadable",name:"@keyframes"});return}let m=v(e.block,!1).map(h=>z(h,r,n+1,"keyframes")).filter(h=>h!==void 0);return`@keyframes ${p.type==="ident"?N(p.value):I(p.value)} { ${m.join(" ")} }`}let a=He(e.prelude,o,r);if(a===void 0)return;let u=t==="style"?V(e.block,r,n):v(e.block,!1).map(c=>z(c,r,n+1,"sheet")).filter(c=>c!==void 0).join(" ");return`@${o} ${a} { ${u} }`}function We(e,r=P){let n=[];if(e.length>r)return{css:"",refused:[{reason:"size"}]};let t=o=>void n.push(o);return{css:v(W(e),!0).map(o=>z(o,t,0,"sheet")).filter(o=>o!==void 0).join(`
3
+ `),refused:n}}function dt(e,r=P){let n=[],t=[],i=0;for(let o of e){if(i+o.length>r){t.push({reason:"size"});continue}i+=o.length;let a=We(o,r);a.css&&n.push(a.css),t.push(...a.refused)}return{css:n.join(`
4
+ `),refused:t}}function Ce(e,r=P){let n=[];if(e.length>r)return{css:"",refused:[{reason:"size"}]};let t=o=>void n.push(o),i=[];for(let o of H(W(e))){if(o.type!=="declaration"){t({reason:"unreadable",name:"a rule in a style attribute"});continue}let a=M(o,t,!0);a&&i.push(a)}return{css:i.join("; "),refused:n}}function ve(e,r){let n,t=M(xe(e,W(r)),i=>n??=i);return t===void 0||n?{refused:n??{reason:"unreadable",name:e}}:{value:t.slice(t.indexOf(":")+1).trim()}}function mt(e,r){if(r==="svg"){let t=se(e);return t?{namespace:"svg",name:t}:{refused:{reason:"element",element:e}}}let n=e.toLowerCase();return n==="svg"?{namespace:"svg",name:"svg"}:Object.prototype.hasOwnProperty.call(T,n)?Object.prototype.hasOwnProperty.call(E,n)?{namespace:"html",name:E[n],as:n}:{namespace:"html",name:n}:{refused:{reason:"element",element:e}}}function gt(e,r){return(e==="html"?T[r]:_[r])?.empty===!0}var qe=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/,Ye=/^[0-9A-Za-z\s.,+\-%()]*$/,Ke=/^#[A-Za-z_][A-Za-z0-9_.:-]*$/,Ze=/^data:image\/(png|gif|jpeg|webp|avif|bmp|svg\+xml)(;[A-Za-z0-9=._+-]+)*,/i,Je=/^\/graview\/assets\/[0-9a-f]{64}\.(png|gif|jpe?g|webp|avif|svg|ico)$/,Se=/\/graview\/assets\/[0-9a-f]{64}\.(png|gif|jpe?g|webp|avif|svg|ico)$/,Qe=/^\/(?!\/)(?!(?:.*\/)?\.\.?(?:\/|$))(?!.*%(?:2e|2f|5c))[^\\\s?#"'<>]*$/i;function et(e,r){if(Je.test(e))return e;let n=e;if(/^https?:\/\//i.test(e))try{let t=new URL(e);if(r==="null"||t.origin!==r||t.username!==""||t.password!==""||t.search!==""||t.hash!=="")return;n=e.slice(t.origin.length)}catch{return}if(Qe.test(n))return Se.exec(n)?.[0]}function yt(e,r={},n){let t=e.length>120?`${e.slice(0,119)}\u2026`:e,i=Ee(r.origins),o=Se.exec(e.split(/[?#]/)[0])?.[0],a=n!==void 0&&n>O?` It is a data: image of ${n.toLocaleString("en-US")} characters, more than the ${O.toLocaleString("en-US")} a view's own data: image may be. A picture on a record is drawn at any size by the src the host hands the view (pictures in its manifest), used as it was handed.`:o?r.assets?` It is the app's own image only by its path, or under the app's base on this page's origin: write it as its path, ${o}.`:" This host has not said where the app's own images live (asset, on the view's definition), so a view here cannot draw one by its path.":/^https:\/\//i.test(e)?i.length>0?` Its origin is not one the host lists for images (${i.join(", ")}).`:" The host lists no origin a view's images may come from (images.origins, on the view's definition).":"",u=["a data: image",...r.assets?["the app's own image by the path add_image answered (/graview/assets/<sha256>.<ext>)"]:[],"a picture on a record (pictures in its manifest)",...i.length>0?[`an https: image from ${i.join(", ")}`]:[]];return`The image "${t}" was not drawn.${a} A view here shows ${u.slice(0,-1).join(", ")} or ${u[u.length-1]}.`}function Ee(e){return(e??[]).flatMap(r=>{try{let n=new URL(r);return n.protocol==="https:"&&n.hostname!==""&&n.username===""&&n.password===""?[n.origin]:[]}catch{return[]}})}function tt(e,r){if(!(!r||r.length===0||!/^https:\/\//i.test(e)))try{let n=new URL(e);return n.protocol!=="https:"||n.username!==""||n.password!==""?void 0:Ee(r).includes(n.origin)?n.href:void 0}catch{return}}function bt(e,r,n,t,i){let o=le(e,r,n);if(!o)return{refused:{reason:"attribute",element:r,name:n}};if(e==="html"&&J[r]?.includes(o.name))return{refused:{reason:"attribute",element:r,name:n}};if(t===null)return{name:o.name,value:null};let a=nt(o.name,o.kind,t,i);return"refused"in a?{refused:{...a.refused,element:r,...o.kind==="image"&&a.refused.reason==="url"?{address:t.slice(0,200),...t.length>O?{length:t.length}:{}}:{},...o.kind==="link"?{address:t.slice(0,200)}:{}}}:o.name==="role"&&a.value.split(/\s+/).some(u=>Z.includes(u.toLowerCase()))?{refused:{reason:"value",element:r,name:n}}:o.name==="aria-live"&&!["polite","off"].includes(a.value.toLowerCase())?{refused:{reason:"value",element:r,name:n}}:{name:o.name,value:a.value,...a.dropped?{dropped:a.dropped.map(u=>({reason:u.reason==="url"?"url":"css",element:r,name:o.name,css:u}))}:{}}}function nt(e,r,n,t){let i=(o,a)=>({refused:{reason:o,name:e,...a?{css:a}:{}}});if(r==="geometry")return n.length>ae||!Ye.test(n)||/url/i.test(n)?i("value"):{value:n};if(r==="image"){let o=t.picture?.(n);if(o!==void 0)return{value:o};if(n.length>O)return i("url");if(Ze.test(n))return{value:n};if(n.startsWith(`blob:${t.origin}/`)&&/^blob:[^\s"'<>]+$/.test(n))return{value:n};let a=t.asset?et(n,t.origin):void 0;if(a!==void 0){let c=t.asset(a);if(c)return{value:c}}let u=tt(n,t.imageOrigins);return u?{value:u}:i("url")}if(r==="link"){let o=t.link?.(n);return o===void 0?i("url"):{value:o}}if(n.length>D)return i("value");if(typeof r=="object"){let o=r.oneOf.find(a=>a.toLowerCase()===n.toLowerCase());return o===void 0?i("value"):{value:o}}switch(r){case"text":return{value:n};case"number":return qe.test(n.trim())&&Number.isFinite(Number(n))?{value:n.trim()}:i("value");case"boolean":return{value:""};case"fragment":return Ke.test(n)?{value:n}:i("url");case"style":{let o=Ce(n,D);return o.refused.length>0&&o.css===""?i(o.refused[0].reason==="url"?"url":"css",o.refused[0]):{value:o.css,...o.refused.length>0?{dropped:o.refused}:{}}}case"css":{let o=ve(e,n);return"refused"in o?i(o.refused.reason==="url"?"url":"css",o.refused):{value:o.value}}}}export{rt as a,ot as b,it as c,at as d,st as e,dt as f,mt as g,gt as h,yt as i,bt as j};