tricot 0.0.1 → 0.0.2

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 (99) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas/assets/{abnfDiagram-WEYOIA3C-CkvKK8YW.js → abnfDiagram-WEYOIA3C-D_3EtYyY.js} +1 -1
  3. package/dist/canvas/assets/{architecture-WOLXFQ4H-DkTZhXsX.js → architecture-WOLXFQ4H-CNOO52kd.js} +1 -1
  4. package/dist/canvas/assets/{architectureDiagram-ZHVYKT53-D03vtDRz.js → architectureDiagram-ZHVYKT53-lBYqdNkj.js} +1 -1
  5. package/dist/canvas/assets/{blockDiagram-RJAE7QA3-ClhjJGi8.js → blockDiagram-RJAE7QA3-nyVHPSk9.js} +1 -1
  6. package/dist/canvas/assets/{c4Diagram-XDPPPE54-DtL6ydla.js → c4Diagram-XDPPPE54-cD9txCLb.js} +1 -1
  7. package/dist/canvas/assets/channel-I1sbw6a8.js +1 -0
  8. package/dist/canvas/assets/{chunk-2E7WHVMD-BjKI2q8S.js → chunk-2E7WHVMD-DSCYrP5D.js} +1 -1
  9. package/dist/canvas/assets/{chunk-55XCU76K-CvtY1-ZJ.js → chunk-55XCU76K-D4EXRr0U.js} +1 -1
  10. package/dist/canvas/assets/{chunk-7S6XSTFO-DDv33qEN.js → chunk-7S6XSTFO-CGWM3r9f.js} +1 -1
  11. package/dist/canvas/assets/{chunk-AQDTSKZB-DtlvoldN.js → chunk-AQDTSKZB-BorQNuc7.js} +1 -1
  12. package/dist/canvas/assets/{chunk-DSNLSHJZ-BFvSD6Sg.js → chunk-DSNLSHJZ-DJHGHKVr.js} +1 -1
  13. package/dist/canvas/assets/{chunk-HAGFOTED-nnwhNY8-.js → chunk-HAGFOTED-DrEGbLXf.js} +1 -1
  14. package/dist/canvas/assets/{chunk-HNE4Q36P-BnG_tdfU.js → chunk-HNE4Q36P-7U5SJLeY.js} +1 -1
  15. package/dist/canvas/assets/{chunk-NQOKRVIF-CCbkrWl0.js → chunk-NQOKRVIF-DTNZadno.js} +1 -1
  16. package/dist/canvas/assets/{chunk-UHW7PFBP-CA3tNzJ3.js → chunk-UHW7PFBP-CbE5Jzvg.js} +1 -1
  17. package/dist/canvas/assets/{chunk-VQ5W62QI-DjaHlbpW.js → chunk-VQ5W62QI-K3Kh3v_p.js} +1 -1
  18. package/dist/canvas/assets/{chunk-WQQL4CDK-D0hvZxqh.js → chunk-WQQL4CDK-COzd17uX.js} +1 -1
  19. package/dist/canvas/assets/chunk-XXDRQBXY-CaMdJWQP.js +1 -0
  20. package/dist/canvas/assets/{chunk-YZO67HFG-DHeiZehr.js → chunk-YZO67HFG-BxV8PpHv.js} +1 -1
  21. package/dist/canvas/assets/{chunk-ZAUX2LTX-AuFSGuK2.js → chunk-ZAUX2LTX-N0CHdlVz.js} +1 -1
  22. package/dist/canvas/assets/{chunk-ZCHMQSOR-Cl58-GNR.js → chunk-ZCHMQSOR-zeafUjpn.js} +1 -1
  23. package/dist/canvas/assets/{classDiagram-v2-4MYWR3UA-DZtVdg28.js → classDiagram-v2-4MYWR3UA-Hvvc0Z5z.js} +1 -1
  24. package/dist/canvas/assets/{cose-bilkent-JH36ORCC-DRZodgHH.js → cose-bilkent-JH36ORCC-BHH57wZb.js} +1 -1
  25. package/dist/canvas/assets/cynefin-EF2NZ3EQ-BLZeevha.js +1 -0
  26. package/dist/canvas/assets/{cynefinDiagram-WF24UDRP-tSV7rZTE.js → cynefinDiagram-WF24UDRP-DcBq_eWM.js} +1 -1
  27. package/dist/canvas/assets/{dagre-NK4GIZVX-BoUs8R6c.js → dagre-NK4GIZVX-Cijvcguq.js} +1 -1
  28. package/dist/canvas/assets/{diagram-CBK3MWTC-CShLnQiV.js → diagram-CBK3MWTC-B2A6XrPd.js} +1 -1
  29. package/dist/canvas/assets/{diagram-I5XIIV2D-BFFrtOXg.js → diagram-I5XIIV2D-bZURkpE7.js} +1 -1
  30. package/dist/canvas/assets/{diagram-ODIL2UCW-ChXvBoFb.js → diagram-ODIL2UCW-IP547iQ6.js} +1 -1
  31. package/dist/canvas/assets/{diagram-PFBEJUXE-Cz5EOU5J.js → diagram-PFBEJUXE-aS8DG6-4.js} +1 -1
  32. package/dist/canvas/assets/{diagram-RJA3I4VV-yvxfMgx3.js → diagram-RJA3I4VV-zY5MuDSR.js} +1 -1
  33. package/dist/canvas/assets/{diagram-TYUNFSNR-B6LIObJY.js → diagram-TYUNFSNR-B3nerWk2.js} +1 -1
  34. package/dist/canvas/assets/{ebnfDiagram-V4P3TTPT-BTkb18PM.js → ebnfDiagram-V4P3TTPT-DgRadxbh.js} +1 -1
  35. package/dist/canvas/assets/{erDiagram-KYQIGQAA-BIblBx4Z.js → erDiagram-KYQIGQAA-dvWUXrD4.js} +1 -1
  36. package/dist/canvas/assets/{eventmodeling-K75KTNOO-CvVJseOX.js → eventmodeling-K75KTNOO-jzFwuc9b.js} +1 -1
  37. package/dist/canvas/assets/flowDiagram-IUGLLWBU-Vs84qJLC.js +1 -0
  38. package/dist/canvas/assets/{ganttDiagram-R7GPNTJY-CfYCIMyT.js → ganttDiagram-R7GPNTJY-DP6wLffx.js} +1 -1
  39. package/dist/canvas/assets/gitGraph-VSP46ZUC-FvxVMqH9.js +1 -0
  40. package/dist/canvas/assets/{gitGraphDiagram-PDYL7XHY-D7ctyGM3.js → gitGraphDiagram-PDYL7XHY-BPBKv4UK.js} +1 -1
  41. package/dist/canvas/assets/index-MgC2fGp9.js +103 -0
  42. package/dist/canvas/assets/index-bltLAfdr.css +1 -0
  43. package/dist/canvas/assets/info-OHQRW6UA-CnTN2dPe.js +1 -0
  44. package/dist/canvas/assets/{infoDiagram-MVDRKAX5-nVR1Wuq1.js → infoDiagram-MVDRKAX5-CY5YF8CW.js} +1 -1
  45. package/dist/canvas/assets/{ishikawaDiagram-HPEHV2GE-CZ6cEozT.js → ishikawaDiagram-HPEHV2GE-BJJjIJn5.js} +1 -1
  46. package/dist/canvas/assets/{journeyDiagram-BOSHW7O7-D0ChNzur.js → journeyDiagram-BOSHW7O7-SsXzs88l.js} +1 -1
  47. package/dist/canvas/assets/{kanban-definition-FNSA4HC5-BQX5oSRG.js → kanban-definition-FNSA4HC5-cdeRNo2o.js} +1 -1
  48. package/dist/canvas/assets/{line-BpdAl23-.js → line-BR2n8Nk4.js} +1 -1
  49. package/dist/canvas/assets/{linear-DPDFY6tx.js → linear-fljUQPXC.js} +1 -1
  50. package/dist/canvas/assets/{mermaid-parser.core--Y0hpmIt.js → mermaid-parser.core-CyflrFl5.js} +3 -3
  51. package/dist/canvas/assets/{mermaid.core-CsGeJ437.js → mermaid.core-DBd9VEEZ.js} +4 -4
  52. package/dist/canvas/assets/{mindmap-definition-6OY57UG3-BkBpxEG9.js → mindmap-definition-6OY57UG3-D2cu_ZTc.js} +1 -1
  53. package/dist/canvas/assets/packet-JDAUHWVQ-yaYO4cp5.js +1 -0
  54. package/dist/canvas/assets/{pegDiagram-ECIUJNBX-DuMILqC7.js → pegDiagram-ECIUJNBX-BcjXQQD6.js} +1 -1
  55. package/dist/canvas/assets/pie-XZMESJXO-cztCBI0v.js +1 -0
  56. package/dist/canvas/assets/{pieDiagram-GNMPY74T-DlXwdptO.js → pieDiagram-GNMPY74T-CrqNQajy.js} +1 -1
  57. package/dist/canvas/assets/{quadrantDiagram-D57K4MC3-Cm0ItFD1.js → quadrantDiagram-D57K4MC3-AXTAhi9U.js} +1 -1
  58. package/dist/canvas/assets/radar-ABXABTNO-CbHQvfsD.js +1 -0
  59. package/dist/canvas/assets/railroad-I3PHUGI6-B0oHQTAZ.js +1 -0
  60. package/dist/canvas/assets/{railroad-abnf-LNEFI6M7-c41jTPZO.js → railroad-abnf-LNEFI6M7-BBGt3_q2.js} +1 -1
  61. package/dist/canvas/assets/{railroad-ebnf-DWYD2UWJ-DQP1QDSQ.js → railroad-ebnf-DWYD2UWJ-ixu4lUxo.js} +1 -1
  62. package/dist/canvas/assets/{railroad-peg-JR7BVNR7-C1IBSHmp.js → railroad-peg-JR7BVNR7-CIX3eq1Z.js} +1 -1
  63. package/dist/canvas/assets/{railroadDiagram-Y72NRBL7-B9uAMQDK.js → railroadDiagram-Y72NRBL7-DeCWgQz5.js} +1 -1
  64. package/dist/canvas/assets/{requirementDiagram-EQYSW5RA-CMHcUPPI.js → requirementDiagram-EQYSW5RA-C4gXUvln.js} +1 -1
  65. package/dist/canvas/assets/{sankeyDiagram-SY24JHO5-DufhzgOJ.js → sankeyDiagram-SY24JHO5-CbMzM3uf.js} +1 -1
  66. package/dist/canvas/assets/{sequenceDiagram-BLEHNHQU-MSVqrEvn.js → sequenceDiagram-BLEHNHQU-CzijdEGb.js} +1 -1
  67. package/dist/canvas/assets/{src-C3R7ySEG.js → src-B5Y2JrIY.js} +1 -1
  68. package/dist/canvas/assets/{stateDiagram-v2-A6IESKWZ-BDSMSpBW.js → stateDiagram-v2-A6IESKWZ-CfwZBSP7.js} +1 -1
  69. package/dist/canvas/assets/{swimlanes-B3ENRKFQ-AFjoAwpd.js → swimlanes-B3ENRKFQ-BSsYg9m-.js} +1 -1
  70. package/dist/canvas/assets/swimlanesDiagram-AYQRV4AK-DUXorK0t.js +8 -0
  71. package/dist/canvas/assets/{timeline-definition-JXYKGLGB-CfA9MTDy.js → timeline-definition-JXYKGLGB-DW4DRHsM.js} +1 -1
  72. package/dist/canvas/assets/treeView-D4JQ5SDB-C3JqYPrF.js +1 -0
  73. package/dist/canvas/assets/treemap-SAJKECNS-C-h8cYwi.js +1 -0
  74. package/dist/canvas/assets/{usecaseDiagram-WPOLBNNX-Cc6WisEf.js → usecaseDiagram-WPOLBNNX-DRrQYFd8.js} +1 -1
  75. package/dist/canvas/assets/{vennDiagram-Q3Y3IDCW-D3WngNEg.js → vennDiagram-Q3Y3IDCW-DlRzTf21.js} +1 -1
  76. package/dist/canvas/assets/{viewer-BaxYd8Fo.js → viewer-DfqWyEfI.js} +1 -1
  77. package/dist/canvas/assets/wardley-7MLQ67FV-Cy1YJVOj.js +1 -0
  78. package/dist/canvas/assets/{wardleyDiagram-IVAIDKWA-DKWBZz5i.js → wardleyDiagram-IVAIDKWA-B6ONQrQu.js} +1 -1
  79. package/dist/canvas/assets/{xychartDiagram-4URNHDU4-BhnzRhXc.js → xychartDiagram-4URNHDU4-kz3gj_5i.js} +1 -1
  80. package/dist/canvas/index.html +2 -2
  81. package/dist/cli/command.js +304 -300
  82. package/hooks/tricot-approve.mjs +53 -11
  83. package/package.json +2 -2
  84. package/dist/canvas/assets/channel-DRLcYYiR.js +0 -1
  85. package/dist/canvas/assets/chunk-XXDRQBXY-Bg2ExrhT.js +0 -1
  86. package/dist/canvas/assets/cynefin-EF2NZ3EQ-Clnz5u6l.js +0 -1
  87. package/dist/canvas/assets/flowDiagram-IUGLLWBU-DVpB4d93.js +0 -1
  88. package/dist/canvas/assets/gitGraph-VSP46ZUC-Cit8ODu4.js +0 -1
  89. package/dist/canvas/assets/index-354nVOc5.js +0 -105
  90. package/dist/canvas/assets/index-hW9r01Xp.css +0 -1
  91. package/dist/canvas/assets/info-OHQRW6UA-PyEgngMG.js +0 -1
  92. package/dist/canvas/assets/packet-JDAUHWVQ-Bz3vh45c.js +0 -1
  93. package/dist/canvas/assets/pie-XZMESJXO-f2NWqr47.js +0 -1
  94. package/dist/canvas/assets/radar-ABXABTNO-D4fqD9aS.js +0 -1
  95. package/dist/canvas/assets/railroad-I3PHUGI6-DDKXQRXI.js +0 -1
  96. package/dist/canvas/assets/swimlanesDiagram-AYQRV4AK-CYKKFazU.js +0 -8
  97. package/dist/canvas/assets/treeView-D4JQ5SDB-7QR5QkG0.js +0 -1
  98. package/dist/canvas/assets/treemap-SAJKECNS-C9vPlOOC.js +0 -1
  99. package/dist/canvas/assets/wardley-7MLQ67FV-djPzhq5M.js +0 -1
@@ -0,0 +1,103 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DBd9VEEZ.js","assets/chunk-DSNLSHJZ-DJHGHKVr.js","assets/src-B5Y2JrIY.js","assets/rolldown-runtime-XKyaHtl9.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-HNE4Q36P-7U5SJLeY.js","assets/chunk-ZAUX2LTX-N0CHdlVz.js","assets/chunk-HAGFOTED-DrEGbLXf.js","assets/chunk-UHW7PFBP-CbE5Jzvg.js","assets/chunk-AQDTSKZB-BorQNuc7.js","assets/chunk-YZO67HFG-BxV8PpHv.js","assets/chunk-7S6XSTFO-CGWM3r9f.js","assets/dist-Dce-2YbA.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-WQQL4CDK-COzd17uX.js","assets/line-BR2n8Nk4.js","assets/array-BifhSqXX.js","assets/path-fybaL0A-.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var L=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function R(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,L)}catch(e){L(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function z(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else R(z.bind(null,e))}var B={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=B,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=z,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=R,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),i=n(((e,t)=>{t.exports=r()})),a=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var a={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),c=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(a(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),I=Symbol.for(`react.forward_ref`),L=Symbol.for(`react.suspense`),R=Symbol.for(`react.suspense_list`),z=Symbol.for(`react.memo`),B=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),V=Symbol.for(`react.legacy_hidden`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.for(`react.view_transition`),re=Symbol.for(`react.recoverable`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var oe=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case L:return`Suspense`;case R:return`SuspenseList`;case ee:return`Activity`;case ne:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case I:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case z:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case B:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var H=Array.isArray,U=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function de(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?fp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=fp(t),e=pp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,fe(ge,e)),t=pe.current;var n=pp(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),lh._currentValue=G)}var K,xe;function Se(e){if(K===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);K=t&&t[1]||``,xe=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+K+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ce=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Se(n):``}function Te(e,t){switch(e.tag){case 26:case 27:case 5:return Se(e.type);case 16:return Se(`Lazy`);case 13:return e.child!==t&&t!==null?Se(`Suspense Fallback`):Se(`Suspense`);case 19:return Se(`SuspenseList`);case 0:case 15:return we(e.type,!1);case 11:return we(e.type.render,!1);case 1:return we(e.type,!0);case 31:return Se(`Activity`);case 30:return Se(`ViewTransition`);default:return``}}function Ee(e){try{var t=``,n=null;do t+=Te(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var De=Object.prototype.hasOwnProperty,Oe=t.unstable_scheduleCallback,ke=t.unstable_cancelCallback,Ae=t.unstable_shouldYield,je=t.unstable_requestPaint,Me=t.unstable_now,Ne=t.unstable_getCurrentPriorityLevel,Pe=t.unstable_ImmediatePriority,Fe=t.unstable_UserBlockingPriority,Ie=t.unstable_NormalPriority,Le=t.unstable_LowPriority,Re=t.unstable_IdlePriority,ze=t.log,Be=t.unstable_setDisableYieldValue,Ve=null,He=null;function Ue(e){if(typeof ze==`function`&&Be(e),He&&typeof He.setStrictMode==`function`)try{He.setStrictMode(Ve,e)}catch{}}var We=Math.clz32?Math.clz32:qe,Ge=Math.log,Ke=Math.LN2;function qe(e){return e>>>=0,e===0?32:31-(Ge(e)/Ke|0)|0}var Je=256,Ye=262144,Xe=4194304;function Ze(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ze(n))):i=Ze(o):i=Ze(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ze(n))):i=Ze(o)):i=Ze(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function $e(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function et(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-We(n),i=1<<r;t|=e[r],n&=~i}return t}function tt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function nt(){var e=Xe;return Xe<<=1,!(Xe&62914560)&&(Xe=4194304),e}function rt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function it(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function at(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-We(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&ot(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function ot(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-We(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function st(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-We(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function ct(e,t){var n=t&-t;return n=n&42?1:lt(n),(n&(e.suspendedLanes|t))===0?n:0}function lt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ut(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function dt(){var e=W.p;return e===0?(e=window.event,e===void 0?32:Th(e.type)):e}function ft(e,t){var n=W.p;try{return W.p=e,t()}finally{W.p=n}}var pt=Math.random().toString(36).slice(2),mt=`__reactFiber$`+pt,ht=`__reactProps$`+pt,gt=`__reactContainer$`+pt,_t=`__reactEvents$`+pt,vt=`__reactListeners$`+pt,yt=`__reactHandles$`+pt,bt=`__reactResources$`+pt,xt=`__reactMarker$`+pt,St=`__reactLoad$`+pt;function Ct(e){delete e[mt],delete e[ht],delete e[vt],delete e[yt]}function wt(e){var t;if(t=e[mt])return t;for(var n=e.parentNode;n;){if(t=n[gt]||n[mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[mt])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function Tt(e){if(e=e[mt]||e[gt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Et(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(a(33))}function Dt(e){var t=e[bt];return t||=e[bt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Ot(e){e[xt]=!0}function kt(e){e[St]=void 0}var At=new Set,jt={};function Mt(e,t){Nt(e,t),Nt(e+`Capture`,t)}function Nt(e,t){for(jt[e]=t,e=0;e<t.length;e++)At.add(t[e])}var Pt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Ft={},It={};function Lt(e){return De.call(It,e)?!0:De.call(Ft,e)?!1:Pt.test(e)?It[e]=!0:(Ft[e]=!0,!1)}var Rt=!1;function zt(){var e=Rt;return Rt=!1,e}function Bt(e,t,n){if(Lt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Vt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Ht(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Ut(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Wt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Gt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Kt(e){if(!e._valueTracker){var t=Wt(e)?`checked`:`value`;e._valueTracker=Gt(e,t,``+e[t])}}function qt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Wt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var Jt=/[\n"\\]/g;function Yt(e){return e.replace(Jt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Xt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Ut(t)):e.value!==``+Ut(t)&&(e.value=``+Ut(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Qt(e,Ut(n)):o===`number`&&e.value==t?Qt(e,Ut(e.value)):Qt(e,Ut(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Ut(s):e.removeAttribute(`name`)}function Zt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Kt(e);return}n=n==null?``:``+Ut(n),t=t==null?n:``+Ut(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Kt(e)}function Qt(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function $t(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Ut(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function en(e,t,n){t!=null&&(t=``+Ut(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Ut(n)}function tn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(a(92));if(H(r)){if(1<r.length)throw Error(a(93));r=r[0]}n=r}n??=``,t=n}n=Ut(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Kt(e)}function nn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var rn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function an(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||rn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function on(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(a(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Rt=!0);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&(an(e,i,r),Rt=!0)}else for(var o in t)t.hasOwnProperty(o)&&an(e,o,t[o])}function sn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var cn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),ln=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function un(e){return ln.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function dn(){}var fn=null;function pn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var mn=null,hn=null;function gn(e){var t=Tt(e);if(t&&(e=t.stateNode)){var n=e[ht]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Yt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[ht]||null;if(!i)throw Error(a(90));Xt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&qt(r)}break a;case`textarea`:en(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&$t(e,!!n.multiple,t,!1)}}}var _n=!1;function vn(e,t,n){if(_n)return e(t,n);_n=!0;try{return e(t)}finally{if(_n=!1,(mn!==null||hn!==null)&&(Rd(),mn&&(t=mn,e=hn,hn=mn=null,gn(t),e)))for(t=0;t<e.length;t++)gn(e[t])}}function yn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ht]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(a(231,t,typeof n));return n}var bn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,xn=!1;if(bn)try{var Sn={};Object.defineProperty(Sn,"passive",{get:function(){xn=!0}}),window.addEventListener(`test`,Sn,Sn),window.removeEventListener(`test`,Sn,Sn)}catch{xn=!1}var Cn=null,wn=null,Tn=null;function En(){if(Tn)return Tn;var e,t=wn,n=t.length,r,i=`value`in Cn?Cn.value:Cn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Tn=i.slice(e,1<r?1-r:void 0)}function Dn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function On(){return!0}function kn(){return!1}function An(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?On:kn,this.isPropagationStopped=kn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=On)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=On)},persist:function(){},isPersistent:On}),t}var jn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Mn=An(jn),Nn=D({},jn,{view:0,detail:0}),Pn=An(Nn),Fn,In,Ln,Rn=D({},Nn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Yn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Ln&&(Ln&&e.type===`mousemove`?(Fn=e.screenX-Ln.screenX,In=e.screenY-Ln.screenY):In=Fn=0,Ln=e),Fn)},movementY:function(e){return`movementY`in e?e.movementY:In}}),zn=An(Rn),Bn=An(D({},Rn,{dataTransfer:0})),Vn=An(D({},Nn,{relatedTarget:0})),Hn=An(D({},jn,{animationName:0,elapsedTime:0,pseudoElement:0})),Un=An(D({},jn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Wn=An(D({},jn,{data:0})),Gn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Kn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},qn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Jn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=qn[e])?!!t[e]:!1}function Yn(){return Jn}var Xn=An(D({},Nn,{key:function(e){if(e.key){var t=Gn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Dn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Kn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Yn,charCode:function(e){return e.type===`keypress`?Dn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Dn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Zn=An(D({},Rn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Qn=An(D({},jn,{submitter:0})),$n=An(D({},Nn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Yn})),er=An(D({},jn,{propertyName:0,elapsedTime:0,pseudoElement:0})),tr=An(D({},Rn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),nr=An(D({},jn,{newState:0,oldState:0,source:0})),rr=[9,13,27,32],ir=bn&&`CompositionEvent`in window,ar=null;bn&&`documentMode`in document&&(ar=document.documentMode);var or=bn&&`TextEvent`in window&&!ar,sr=bn&&(!ir||ar&&8<ar&&11>=ar),cr=` `,lr=!1;function ur(e,t){switch(e){case`keyup`:return rr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function dr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var fr=!1;function pr(e,t){switch(e){case`compositionend`:return dr(t);case`keypress`:return t.which===32?(lr=!0,cr):null;case`textInput`:return e=t.data,e===cr&&lr?null:e;default:return null}}function mr(e,t){if(fr)return e===`compositionend`||!ir&&ur(e,t)?(e=En(),Tn=wn=Cn=null,fr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return sr&&t.locale!==`ko`?null:t.data;default:return null}}var hr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function gr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!hr[e.type]:t===`textarea`}function _r(e,t,n,r){mn?hn?hn.push(r):hn=[r]:mn=r,t=Yf(t,`onChange`),0<t.length&&(n=new Mn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var vr=null,yr=null;function br(e){Vf(e,0)}function xr(e){if(qt(Et(e)))return e}function Sr(e,t){if(e===`change`)return t}var Cr=!1;if(bn){var wr;if(bn){var Tr=`oninput`in document;if(!Tr){var Er=document.createElement(`div`);Er.setAttribute(`oninput`,`return;`),Tr=typeof Er.oninput==`function`}wr=Tr}else wr=!1;Cr=wr&&(!document.documentMode||9<document.documentMode)}function Dr(){vr&&(vr.detachEvent(`onpropertychange`,Or),yr=vr=null)}function Or(e){if(e.propertyName===`value`&&xr(yr)){var t=[];_r(t,yr,e,pn(e)),vn(br,t)}}function kr(e,t,n){e===`focusin`?(Dr(),vr=t,yr=n,vr.attachEvent(`onpropertychange`,Or)):e===`focusout`&&Dr()}function Ar(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return xr(yr)}function jr(e,t){if(e===`click`)return xr(t)}function Mr(e,t){if(e===`input`||e===`change`)return xr(t)}function Nr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Pr=typeof Object.is==`function`?Object.is:Nr;function Fr(e,t){if(Pr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!De.call(t,i)||!Pr(e[i],t[i]))return!1}return!0}function Ir(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Lr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Rr(e,t){var n=Lr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Lr(n)}}function zr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?zr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Br(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ir(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ir(e.document)}return t}function Vr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Hr=bn&&`documentMode`in document&&11>=document.documentMode,Ur=null,Wr=null,Gr=null,Kr=!1;function q(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kr||Ur==null||Ur!==Ir(r)||(r=Ur,`selectionStart`in r&&Vr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gr&&Fr(Gr,r)||(Gr=r,r=Yf(Wr,`onSelect`),0<r.length&&(t=new Mn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Ur)))}function qr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Jr={animationend:qr(`Animation`,`AnimationEnd`),animationiteration:qr(`Animation`,`AnimationIteration`),animationstart:qr(`Animation`,`AnimationStart`),transitionrun:qr(`Transition`,`TransitionRun`),transitionstart:qr(`Transition`,`TransitionStart`),transitioncancel:qr(`Transition`,`TransitionCancel`),transitionend:qr(`Transition`,`TransitionEnd`)},Yr={},Xr={};bn&&(Xr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Jr.animationend.animation,delete Jr.animationiteration.animation,delete Jr.animationstart.animation),`TransitionEvent`in window||delete Jr.transitionend.transition);function Zr(e){if(Yr[e])return Yr[e];if(!Jr[e])return e;var t=Jr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Xr)return Yr[e]=t[n];return e}var Qr=Zr(`animationend`),$r=Zr(`animationiteration`),ei=Zr(`animationstart`),ti=Zr(`transitionrun`),ni=Zr(`transitionstart`),ri=Zr(`transitioncancel`),ii=Zr(`transitionend`),ai=new Map,oi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);oi.push(`scrollEnd`);function si(e,t){ai.set(e,t),Mt(t,[e])}var ci=0;function li(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=yd.identifierPrefix;var n=ci++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function ui(e){if(e==null||typeof e==`string`)return e;var t=null,n=Dd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function di(e,t){return e=ui(e),t=ui(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var fi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},pi=[],mi=0,hi=0;function gi(){for(var e=mi,t=hi=mi=0;t<e;){var n=pi[t];pi[t++]=null;var r=pi[t];pi[t++]=null;var i=pi[t];pi[t++]=null;var a=pi[t];if(pi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&bi(n,i,a)}}function _i(e,t,n,r){pi[mi++]=e,pi[mi++]=t,pi[mi++]=n,pi[mi++]=r,hi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function vi(e,t,n,r){return _i(e,t,n,r),xi(e)}function yi(e,t){return _i(e,null,null,t),xi(e)}function bi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-We(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function xi(e){if(50<Od)throw Od=0,kd=null,Error(a(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Si={};function Ci(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wi(e,t,n,r){return new Ci(e,t,n,r)}function Ti(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ei(e,t){var n=e.alternate;return n===null?(n=wi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Di(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Oi(e,t,n,r,i,o){var s=0;if(r=e,typeof r==`function`)Ti(r)&&(s=1);else if(typeof r==`string`)s=Ym(e,n,pe.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ee:return e=wi(31,n,t,i),e.elementType=ee,e.lanes=o,e;case j:return ki(n.children,i,o,t);case M:s=8,i|=24;break;case N:return e=wi(12,n,t,i|2),e.elementType=N,e.lanes=o,e;case L:return e=wi(13,n,t,i),e.elementType=L,e.lanes=o,e;case R:return e=wi(19,n,t,i),e.elementType=R,e.lanes=o,e;case V:case ne:return e=i|32,e=wi(30,n,t,e),e.elementType=ne,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case F:s=10;break a;case P:s=9;break a;case I:s=11;break a;case z:s=14;break a;case B:s=16,r=null;break a}s=29,n=Error(a(130,e===null?`null`:typeof e,``)),r=null}return t=wi(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function ki(e,t,n,r){return e=wi(7,e,r,t),e.lanes=n,e}function Ai(e,t,n){return e=wi(6,e,null,t),e.lanes=n,e}function ji(e){var t=wi(18,null,null,0);return t.stateNode=e,t}function Mi(e,t,n){return t=wi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ni=new WeakMap;function Pi(e,t){if(typeof e==`object`&&e){var n=Ni.get(e);return n===void 0?(t={value:e,source:t,stack:Ee(t)},Ni.set(e,t),t):n}return{value:e,source:t,stack:Ee(t)}}var Fi=[],Ii=0,Li=null,Ri=0,zi=[],Bi=0,Vi=null,Hi=1,Ui=``;function Wi(e,t){Fi[Ii++]=Ri,Fi[Ii++]=Li,Li=e,Ri=t}function Gi(e,t,n){zi[Bi++]=Hi,zi[Bi++]=Ui,zi[Bi++]=Vi,Vi=e;var r=Hi;e=Ui;var i=32-We(r)-1;r&=~(1<<i),n+=1;var a=32-We(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Hi=1<<32-We(t)+i|n<<i|r,Ui=a+e}else Hi=1<<a|n<<i|r,Ui=e}function Ki(e){e.return!==null&&(Wi(e,1),Gi(e,1,0))}function qi(e){for(;e===Li;)Li=Fi[--Ii],Fi[Ii]=null,Ri=Fi[--Ii],Fi[Ii]=null;for(;e===Vi;)Vi=zi[--Bi],zi[Bi]=null,Ui=zi[--Bi],zi[Bi]=null,Hi=zi[--Bi],zi[Bi]=null}function Ji(e,t){zi[Bi++]=Hi,zi[Bi++]=Ui,zi[Bi++]=Vi,Hi=t.id,Ui=t.overflow,Vi=e}var Yi=null,Xi=null,Zi=!1,Qi=null,$i=!1,ea=Error(a(519));function ta(e){throw sa(Pi(Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ea}function na(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[mt]=e,t[ht]=r,n){case`dialog`:Hf(`cancel`,t),Hf(`close`,t);break;case`iframe`:case`object`:case`embed`:Hf(`load`,t);break;case`video`:case`audio`:for(n=0;n<zf.length;n++)Hf(zf[n],t);break;case`source`:Hf(`error`,t);break;case`img`:case`image`:case`link`:Hf(`error`,t),Hf(`load`,t);break;case`details`:Hf(`toggle`,t);break;case`input`:Hf(`invalid`,t),Zt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Hf(`invalid`,t);break;case`textarea`:Hf(`invalid`,t),tn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||tp(t.textContent,n)?(r.popover!=null&&(Hf(`beforetoggle`,t),Hf(`toggle`,t)),r.onScroll!=null&&Hf(`scroll`,t),r.onScrollEnd!=null&&Hf(`scrollend`,t),r.onClick!=null&&(t.onclick=dn),t=!0):t=!1,t||ta(e,!0)}function ra(e){for(Yi=e.return;Yi;)switch(Yi.tag){case 5:case 31:case 13:$i=!1;return;case 27:case 3:$i=!0;return;default:Yi=Yi.return}}function ia(e){if(e!==Yi)return!1;if(!Zi)return ra(e),Zi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||hp(e.type,e.memoizedProps)),n=!n),n&&Xi&&ta(e),ra(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Xi=pm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Xi=pm(e)}else t===27?(t=Xi,wp(e.type)?(e=fm,fm=null,Xi=e):Xi=t):Xi=Yi?dm(e.stateNode.nextSibling):null;return!0}function aa(){Xi=Yi=null,Zi=!1}function oa(){var e=Qi;return e!==null&&(dd===null?dd=e:dd.push.apply(dd,e),Qi=null),e}function sa(e){Qi===null?Qi=[e]:Qi.push(e)}var ca=ue(null),la=null,ua=null;function da(e,t,n){fe(ca,t._currentValue),t._currentValue=n}function fa(e){e._currentValue=ca.current,de(ca)}function pa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function ma(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){var s=i.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),pa(o.return,n,e),r||(s=null);break a}o=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(a(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),pa(s,n,e),s=null}else i.tag===13&&i.memoizedState!==null&&i.memoizedState.dehydrated===null?(i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),pa(i.return,n,e),s=i.child,s=s===null?null:s.sibling):s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function ha(e,t,n,r){e=null;for(var i=t,o=!1;i!==null;){if(!o){if(i.flags&524288)o=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(a(387));if(s=s.memoizedProps,s!==null){var c=i.type;Pr(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===ge.current){if(s=i.alternate,s===null)throw Error(a(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[lh]:e.push(lh))}i=i.return}return e!==null&&ma(t,e,n,r),t.flags|=262144,e!==null}function ga(e){for(e=e.firstContext;e!==null;){if(!Pr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function _a(e){la=e,ua=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function va(e){return ba(la,e)}function ya(e,t){return la===null&&_a(e),ba(e,t)}function ba(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ua===null){if(e===null)throw Error(a(308));ua=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ua=ua.next=t;return n}var xa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Sa=t.unstable_scheduleCallback,Ca=t.unstable_NormalPriority,wa={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ta(){return{controller:new xa,data:new Map,refCount:0}}function Ea(e){e.refCount--,e.refCount===0&&Sa(Ca,function(){e.controller.abort()})}function Da(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Oa=null;function ka(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Aa=null,ja=0,Ma=0,Na=null;function Pa(e,t){if(Aa===null){var n=Aa=[];ja=0,Ma=Pf(),Na={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ja++,t.then(Fa,Fa),t}function Fa(){if(--ja===0&&(Oa=null,Aa!==null)){Na!==null&&(Na.status=`fulfilled`);var e=Aa;Aa=null,Ma=0,Na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ia(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var La=U.S;U.S=function(e,t){if(md=Me(),typeof t==`object`&&t&&typeof t.then==`function`&&Pa(e,t),Oa!==null)for(var n=bf;n!==null;)Da(n,Oa),n=n.next;if(n=e.types,n!==null){for(var r=bf;r!==null;)Da(r,n),r=r.next;if(Ma!==0){r=Oa,r===null&&(r=Oa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}La!==null&&La(e,t)};var Ra=ue(null);function za(){var e=Ra.current;return e===null?Yu.pooledCache:e}function Ba(e,t){t===null?fe(Ra,Ra.current):fe(Ra,t.pool)}function Va(){var e=za();return e===null?null:{parent:wa._currentValue,pool:e}}var Ha=Error(a(460)),Ua=Error(a(474)),Wa=Error(a(542)),Ga={then:function(){}};function Ka(e){return e=e.status,e===`fulfilled`||e===`rejected`}function qa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(dn,dn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Za(e),e===void 0&&!(`reason`in t)?Error(a(600)):e;default:if(typeof t.status==`string`)t.then(dn,dn);else{if(e=Yu,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Za(e),e}throw Ya=t,Ha}}function Ja(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ya=e,Ha):e}}var Ya=null;function Xa(){if(Ya===null)throw Error(a(459));var e=Ya;return Ya=null,e}function Za(e){if(e===Ha||e===Wa)throw Error(a(483))}var Qa=null,$a=0;function eo(e){var t=$a;return $a+=1,Qa===null&&(Qa=[]),qa(Qa,e,t)}function to(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function no(e,t){throw t.$$typeof===O?Error(a(525)):(e=Object.prototype.toString.call(t),Error(a(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function ro(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=Ei(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ai(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===j?(e=d(e,t,n.props.children,r,n.key),to(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===B&&Ja(a)===t.type)?(t=i(t,n.props),to(t,n),t.return=e,t):(t=Oi(n.type,n.key,n.props,null,e.mode,r),to(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Mi(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=ki(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ai(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Oi(t.type,t.key,t.props,null,e.mode,n),to(n,t),n.return=e,n;case A:return t=Mi(t,e.mode,n),t.return=e,t;case B:return t=Ja(t),f(e,t,n)}if(H(t)||ae(t))return t=ki(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,eo(t),n);if(t.$$typeof===F)return f(e,ya(e,t),n);no(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case B:return n=Ja(n),p(e,t,n,r)}if(H(n)||ae(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,eo(n),r);if(n.$$typeof===F)return p(e,t,ya(e,n),r);no(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case B:return r=Ja(r),m(e,t,n,r,i)}if(H(r)||ae(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,eo(r),i);if(r.$$typeof===F)return m(e,t,n,ya(t,r),i);no(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Zi&&Wi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Zi&&Wi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Zi&&Wi(i,h),l}function g(i,s,c,l){if(c==null)throw Error(a(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),Zi&&Wi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Zi&&Wi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),Zi&&Wi(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===j&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case k:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),to(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===B&&Ja(l)===r.type){n(e,r.sibling),c=i(r,o.props),to(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=ki(o.props.children,e.mode,c,o.key),to(c,o),c.return=e,e=c):(c=Oi(o.type,o.key,o.props,null,e.mode,c),to(c,o),c.return=e,e=c)}return s(e);case A:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Mi(o,e.mode,c),c.return=e,e=c}return s(e);case B:return o=Ja(o),_(e,r,o,c)}if(H(o))return h(e,r,o,c);if(ae(o)){if(l=ae(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,eo(o),c);if(o.$$typeof===F)return _(e,r,ya(e,o),c);no(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Ai(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{$a=0;var i=_(e,t,n,r);return Qa=null,i}catch(t){if(t===Ha||t===Wa)throw t;var a=wi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var io=ro(!0),ao=ro(!1),oo=!1;function so(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function co(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function lo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function uo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ju&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=xi(e),bi(e,null,n),t}return _i(e,r,t,n),xi(e)}function fo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,st(e,n)}}function po(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mo=!1;function ho(){if(mo){var e=Na;if(e!==null)throw e}}function go(e,t,n,r){mo=!1;var i=e.updateQueue;oo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Zu&f)===f:(r&f)===f){f!==0&&f===Ma&&(mo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:oo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ad|=o,e.lanes=o,e.memoizedState=d}}function _o(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function vo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)_o(n[e],t)}var yo=ue(null),bo=ue(0);function xo(e,t){e=rd,fe(bo,e),fe(yo,t),rd=e|t.baseLanes}function So(){fe(bo,rd),fe(yo,yo.current)}function Co(){rd=bo.current,de(yo),de(bo)}var wo=ue(null),To=null;function Eo(e){var t=e.alternate;fe(jo,jo.current&1),fe(wo,e),To===null&&(t===null||yo.current!==null||t.memoizedState!==null)&&(To=e)}function Do(e){fe(jo,jo.current),fe(wo,e),To===null&&(To=e)}function Oo(e){e.tag===22?(fe(jo,jo.current),fe(wo,e),To===null&&(To=e)):ko()}function ko(){fe(jo,jo.current),fe(wo,wo.current)}function Ao(e){de(wo),To===e&&(To=null),de(jo)}var jo=ue(0);function Mo(e,t){fe(wo,wo.current),fe(jo,t)}function No(e){de(jo),de(wo),To===e&&(To=null)}function Po(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cm(n)||lm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Fo=0,Io=null,Lo=null,Ro=null,zo=!1,Bo=!1,Vo=!1,Ho=0,Uo=0,Wo=null,Go=0;function Ko(){throw Error(a(321))}function qo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Pr(e[n],t[n]))return!1;return!0}function Jo(e,t,n,r,i,a){return Fo=a,Io=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,U.H=e===null||e.memoizedState===null?dc:fc,Vo=!1,a=n(r,i),Vo=!1,Bo&&(a=Xo(t,n,r,i)),Yo(e),a}function Yo(e){U.H=uc;var t=Lo!==null&&Lo.next!==null;if(Fo=0,Ro=Lo=Io=null,zo=!1,Uo=0,Wo=null,t)throw Error(a(300));e===null||kc||(e=e.dependencies,e!==null&&ga(e)&&(kc=!0))}function Xo(e,t,n,r){Io=e;var i=0;do{if(Bo&&(Wo=null),Uo=0,Bo=!1,25<=i)throw Error(a(301));if(i+=1,Ro=Lo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}U.H=pc,o=t(n,r)}while(Bo);return o}function Zo(){var e=U.H,t=e.useState()[0];return t=typeof t.then==`function`?is(t):t,e=e.useState()[0],(Lo===null?null:Lo.memoizedState)!==e&&(Io.flags|=1024),t}function Qo(){var e=Ho!==0;return Ho=0,e}function $o(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function es(e){if(zo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}zo=!1}Fo=0,Ro=Lo=Io=null,Bo=!1,Uo=Ho=0,Wo=null}function ts(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ro===null?Io.memoizedState=Ro=e:Ro=Ro.next=e,Ro}function ns(){if(Lo===null){var e=Io.alternate;e=e===null?null:e.memoizedState}else e=Lo.next;var t=Ro===null?Io.memoizedState:Ro.next;if(t!==null)Ro=t,Lo=e;else{if(e===null)throw Io.alternate===null?Error(a(467)):Error(a(310));Lo=e,e={memoizedState:Lo.memoizedState,baseState:Lo.baseState,baseQueue:Lo.baseQueue,queue:Lo.queue,next:null},Ro===null?Io.memoizedState=Ro=e:Ro=Ro.next=e}return Ro}function rs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function is(e){var t=Uo;return Uo+=1,Wo===null&&(Wo=[]),e=qa(Wo,e,t),t=Io,(Ro===null?t.memoizedState:Ro.next)===null&&(t=t.alternate,U.H=t===null||t.memoizedState===null?dc:fc),e}function as(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return is(e);if(e.$$typeof===re)return;if(e.$$typeof===F)return va(e)}throw Error(a(438,String(e)))}function os(e){var t=null,n=Io.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Io.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=rs(),Io.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=te;return t.index++,n}function ss(e,t){return typeof t==`function`?t(e):t}function cs(e){return ls(ns(),Lo,e)}function ls(e,t,n){var r=e.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=n;var i=e.baseQueue,o=r.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,r.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Fo&f)===f:(Zu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ma&&(d=!0);else if((Fo&p)===p){u=u.next,p===Ma&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Io.lanes|=p,ad|=p;f=u.action,Vo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Io.lanes|=f,ad|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Pr(o,e.memoizedState)&&(kc=!0,d&&(n=Na,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function us(e){var t=ns(),n=t.queue;if(n===null)throw Error(a(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);Pr(o,t.memoizedState)||(kc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function ds(e,t,n){var r=Io,i=ns(),o=Zi;if(o){if(n===void 0)throw Error(a(407));n=n()}else n=t();var s=!Pr((Lo||i).memoizedState,n);if(s&&(i.memoizedState=n,kc=!0),i=i.queue,Is(ms.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||s||Ro!==null&&!!(Ro.memoizedState.tag&1),js(e?9:8,{destroy:void 0},ps.bind(null,r,i,n,t),null),e){if(r.flags|=2048,Yu===null)throw Error(a(349));o||Fo&127||fs(r,t,n)}return n}function fs(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Io.updateQueue,t===null?(t=rs(),Io.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ps(e,t,n,r){t.value=n,t.getSnapshot=r,hs(t)&&gs(e)}function ms(e,t,n){return n(function(){hs(t)&&gs(e)})}function hs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Pr(e,n)}catch{return!0}}function gs(e){var t=yi(e,2);t!==null&&Nd(t,e,2)}function _s(e){var t=ts();if(typeof e==`function`){var n=e;if(e=n(),Vo){Ue(!0);try{n()}finally{Ue(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:e},t}function vs(e,t,n,r){return e.baseState=n,ls(e,Lo,typeof r==`function`?r:ss)}function ys(e,t,n,r,i){if(sc(e))throw Error(a(485));if(e=t.action,e!==null){var o={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};U.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,bs(t,o)):(o.next=n.next,t.pending=n.next=o)}}function bs(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=U.T,o={};o.types=a===null?null:a.types,U.T=o;try{var s=n(i,r),c=U.S;c!==null&&c(o,s),xs(e,t,s)}catch(n){Cs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),U.T=a}}else try{a=n(i,r),xs(e,t,a)}catch(n){Cs(e,t,n)}}function xs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ss(e,t,n)},function(n){return Cs(e,t,n)}):Ss(e,t,n)}function Ss(e,t,n){t.status=`fulfilled`,t.value=n,ws(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,bs(e,n)))}function Cs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ws(t),t=t.next;while(t!==r)}e.action=null}function ws(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ts(e,t){return t}function Es(e,t){if(Zi){var n=Yu.formState;if(n!==null){a:{var r=Io;if(Zi){if(Xi){b:{for(var i=Xi,a=$i;i.nodeType!==8;)if(!a||(i=dm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Xi=dm(i.nextSibling),r=i.data===`F!`;break a}}ta(r)}r=!1}r&&(t=n[0])}}return n=ts(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:t},n.queue=r,n=ic.bind(null,Io,r),r.dispatch=n,r=_s(!1),a=oc.bind(null,Io,!1,r.queue),r=ts(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ys.bind(null,Io,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ds(e){return Os(ns(),Lo,e)}function Os(e,t,n){if(t=ls(e,t,Ts)[0],e=cs(ss)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=is(t)}catch(e){throw e===Ha?Wa:e}else r=t;t=ns();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Io.flags|=2048,js(9,{destroy:void 0},ks.bind(null,i,n),null)),[r,a,e]}function ks(e,t){e.action=t}function As(e){var t=ns(),n=Lo;if(n!==null)return Os(t,n,e);ns(),t=t.memoizedState,n=ns();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function js(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Io.updateQueue,t===null&&(t=rs(),Io.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ms(){return ns().memoizedState}function Ns(e,t,n,r){var i=ts();Io.flags|=e,i.memoizedState=js(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ps(e,t,n,r){var i=ns();r=r===void 0?null:r;var a=i.memoizedState.inst;Lo!==null&&r!==null&&qo(r,Lo.memoizedState.deps)?i.memoizedState=js(t,a,n,r):(Io.flags|=e,i.memoizedState=js(1|t,a,n,r))}function Fs(e,t){Ns(8390656,8,e,t)}function Is(e,t){Ps(2048,8,e,t)}function Ls(e){Io.flags|=4;var t=Io.updateQueue;if(t===null)t=rs(),Io.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Rs(e){var t=ns().memoizedState;return Ls({ref:t,nextImpl:e}),function(){if(Ju&2)throw Error(a(440));return t.impl.apply(void 0,arguments)}}function zs(e,t){return Ps(4,2,e,t)}function Bs(e,t){return Ps(4,4,e,t)}function Vs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Hs(e,t,n){n=n==null?null:n.concat([e]),Ps(4,4,Vs.bind(null,t,e),n)}function Us(){}function Ws(e,t){var n=ns();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&qo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Gs(e,t){var n=ns();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&qo(t,r[1]))return r[0];if(r=e(),Vo){Ue(!0);try{e()}finally{Ue(!1)}}return n.memoizedState=[r,t],r}function Ks(e,t,n){return n===void 0||Fo&1073741824&&!(Zu&261930)?e.memoizedState=t:(e.memoizedState=n,e=jd(),Io.lanes|=e,ad|=e,n)}function qs(e,t,n,r){return Pr(n,t)?n:yo.current===null?!(Fo&106)||Fo&1073741824&&!(Zu&261930)?(kc=!0,e.memoizedState=n):(e=jd(),Io.lanes|=e,ad|=e,t):(e=Ks(e,n,r),Pr(e,t)||(kc=!0),e)}function Js(e,t,n,r,i){var a=W.p;W.p=a!==0&&8>a?a:8;var o=U.T,s={};s.types=o===null?null:o.types,U.T=s,oc(e,!1,t,n);try{var c=i(),l=U.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ac(e,t,Ia(c,r),Ad(e)):ac(e,t,r,Ad(e))}catch(n){ac(e,t,{then:function(){},status:`rejected`,reason:n},Ad())}finally{W.p=a,o!==null&&s.types!==null&&(o.types=s.types),U.T=o}}function Ys(){}function Xs(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=Zs(e).queue;Js(e,i,t,G,n===null?Ys:function(){return Qs(e),n(r)})}function Zs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:G},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Qs(e){var t=Zs(e);t.next===null&&(t=e.alternate.memoizedState),ac(e,t.next.queue,{},Ad())}function $s(){return va(lh)}function ec(){return ns().memoizedState}function tc(){return ns().memoizedState}function nc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ad();e=lo(n);var r=uo(t,e,n);r!==null&&(Nd(r,t,n),fo(r,t,n)),t={cache:Ta()},e.payload=t;return}t=t.return}}function rc(e,t,n){var r=Ad();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},sc(e)?cc(t,n):(n=vi(e,t,n,r),n!==null&&(Nd(n,e,r),lc(n,t,r)))}function ic(e,t,n){ac(e,t,n,Ad())}function ac(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(sc(e))cc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Pr(s,o))return _i(e,t,i,0),Yu===null&&gi(),!1}catch{}if(n=vi(e,t,i,r),n!==null)return Nd(n,e,r),lc(n,t,r),!0}return!1}function oc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},sc(e)){if(t)throw Error(a(479))}else t=vi(e,n,r,2),t!==null&&Nd(t,e,2)}function sc(e){var t=e.alternate;return e===Io||t!==null&&t===Io}function cc(e,t){Bo=zo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function lc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,st(e,n)}}var uc={readContext:va,use:as,useCallback:Ko,useContext:Ko,useEffect:Ko,useImperativeHandle:Ko,useLayoutEffect:Ko,useInsertionEffect:Ko,useMemo:Ko,useReducer:Ko,useRef:Ko,useState:Ko,useDebugValue:Ko,useDeferredValue:Ko,useTransition:Ko,useSyncExternalStore:Ko,useId:Ko,useHostTransitionStatus:Ko,useFormState:Ko,useActionState:Ko,useOptimistic:Ko,useMemoCache:Ko,useCacheRefresh:Ko,useEffectEvent:Ko},dc={readContext:va,use:as,useCallback:function(e,t){return ts().memoizedState=[e,t===void 0?null:t],e},useContext:va,useEffect:Fs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ns(4194308,4,Vs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ns(4194308,4,e,t)},useInsertionEffect:function(e,t){Ns(4,2,e,t)},useMemo:function(e,t){var n=ts();t=t===void 0?null:t;var r=e();if(Vo){Ue(!0);try{e()}finally{Ue(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ts();if(n!==void 0){var i=n(t);if(Vo){Ue(!0);try{n(t)}finally{Ue(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=rc.bind(null,Io,e),[r.memoizedState,e]},useRef:function(e){var t=ts();return e={current:e},t.memoizedState=e},useState:function(e){e=_s(e);var t=e.queue,n=ic.bind(null,Io,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Us,useDeferredValue:function(e,t){return Ks(ts(),e,t)},useTransition:function(){var e=_s(!1);return e=Js.bind(null,Io,e.queue,!0,!1),ts().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Io,i=ts();if(Zi){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),Yu===null)throw Error(a(349));Zu&127||fs(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Fs(ms.bind(null,r,o,e),[e]),r.flags|=2048,js(9,{destroy:void 0},ps.bind(null,r,o,n,t),null),n},useId:function(){var e=ts(),t=Yu.identifierPrefix;if(Zi){var n=Ui,r=Hi;n=(r&~(1<<32-We(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ho++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Go++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:$s,useFormState:Es,useActionState:Es,useOptimistic:function(e){var t=ts();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=oc.bind(null,Io,!0,n),n.dispatch=t,[e,t]},useMemoCache:os,useCacheRefresh:function(){return ts().memoizedState=nc.bind(null,Io)},useEffectEvent:function(e){var t=ts(),n={impl:e};return t.memoizedState=n,function(){if(Ju&2)throw Error(a(440));return n.impl.apply(void 0,arguments)}}},fc={readContext:va,use:as,useCallback:Ws,useContext:va,useEffect:Is,useImperativeHandle:Hs,useInsertionEffect:zs,useLayoutEffect:Bs,useMemo:Gs,useReducer:cs,useRef:Ms,useState:function(){return cs(ss)},useDebugValue:Us,useDeferredValue:function(e,t){return qs(ns(),Lo.memoizedState,e,t)},useTransition:function(){var e=cs(ss)[0],t=ns().memoizedState;return[typeof e==`boolean`?e:is(e),t]},useSyncExternalStore:ds,useId:ec,useHostTransitionStatus:$s,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){return vs(ns(),Lo,e,t)},useMemoCache:os,useCacheRefresh:tc,useEffectEvent:Rs},pc={readContext:va,use:as,useCallback:Ws,useContext:va,useEffect:Is,useImperativeHandle:Hs,useInsertionEffect:zs,useLayoutEffect:Bs,useMemo:Gs,useReducer:us,useRef:Ms,useState:function(){return us(ss)},useDebugValue:Us,useDeferredValue:function(e,t){var n=ns();return Lo===null?Ks(n,e,t):qs(n,Lo.memoizedState,e,t)},useTransition:function(){var e=us(ss)[0],t=ns().memoizedState;return[typeof e==`boolean`?e:is(e),t]},useSyncExternalStore:ds,useId:ec,useHostTransitionStatus:$s,useFormState:As,useActionState:As,useOptimistic:function(e,t){var n=ns();return Lo===null?(n.baseState=e,[e,n.queue.dispatch]):vs(n,Lo,e,t)},useMemoCache:os,useCacheRefresh:tc,useEffectEvent:Rs};function mc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var hc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=lo(r);i.payload=t,n!=null&&(i.callback=n),t=uo(e,i,r),t!==null&&(Nd(t,e,r),fo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=lo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=uo(e,i,r),t!==null&&(Nd(t,e,r),fo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ad(),r=lo(n);r.tag=2,t!=null&&(r.callback=t),t=uo(e,r,n),t!==null&&(Nd(t,e,n),fo(t,e,n))}};function gc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Fr(n,r)||!Fr(i,a):!0}function _c(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&hc.enqueueReplaceState(t,t.state,null)}function vc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function yc(e){fi(e)}function bc(e){console.error(e)}function xc(e){fi(e)}function Sc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Cc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function wc(e,t,n){return n=lo(n),n.tag=3,n.payload={element:null},n.callback=function(){Sc(e,t)},n}function Tc(e){return e=lo(e),e.tag=3,e}function Ec(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Cc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Cc(t,n,r),typeof i!=`function`&&(_d===null?_d=new Set([this]):_d.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Dc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ha(t,n,i,!0),n=wo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return To===null?Gd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===Ga?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),mf(e,r,i)),!1;case 22:return n.flags|=65536,r===Ga?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),mf(e,r,i)),!1}throw Error(a(435,n.tag))}return mf(e,r,i),Gd(),!1}if(Zi)return t=wo.current,t===null?(r!==ea&&(t=Error(a(423),{cause:r}),sa(Pi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Pi(r,n),i=wc(e.stateNode,r,i),po(e,i),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==ea&&(e=Error(a(422),{cause:r}),sa(Pi(e,n)))),!1;var o=Error(a(520),{cause:r});if(o=Pi(o,n),ud===null?ud=[o]:ud.push(o),id!==4&&(id=2),t===null)return!0;r=Pi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=wc(n.stateNode,r,e),po(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(_d===null||!_d.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Tc(i),Ec(i,e,n,r),po(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Oc=Error(a(461)),kc=!1;function Ac(e,t,n,r){t.child=e===null?ao(t,null,n,r):io(t,e.child,n,r)}function jc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return _a(t),r=Jo(e,t,n,o,a,i),s=Qo(),e!==null&&!kc?($o(e,t,i),il(e,t,i)):(Zi&&s&&Ki(t),t.flags|=1,Ac(e,t,r,i),t.child)}function Mc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ti(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Nc(e,t,a,r,i)):(e=Oi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!al(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Fr:n,n(o,r)&&e.ref===t.ref)return il(e,t,i)}return t.flags|=1,e=Ei(a,r),e.ref=t.ref,e.return=t,t.child=e}function Nc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Fr(a,r)&&e.ref===t.ref){if(kc=!1,t.pendingProps=r=a,al(e,i))e.flags&131072&&(kc=!0);else return t.lanes=e.lanes,il(e,t,i)}}return Vc(e,t,n,r,i)}function Pc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Ic(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ba(t,a===null?null:a.cachePool),a===null?So():xo(t,a),Oo(t);else return r=t.lanes=536870912,Ic(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ba(t,null),So(),ko()):(Ba(t,a.cachePool),xo(t,a),ko(),t.memoizedState=null);return Ac(e,t,i,n),t.child}function Fc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Ic(e,t,n,r,i){var a=za();return a=a===null?null:{parent:wa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ba(t,null),So(),Oo(t),e!==null&&ha(e,t,r,!0),t.childLanes=i,null}function Lc(e,t){return t=Xc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Rc(e,t,n){return io(t,e.child,null,n),e=Lc(t,t.pendingProps),e.flags|=2,Ao(t),t.memoizedState=null,e}function zc(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if(Zi){if(r.mode===`hidden`)return e=Lc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Fc(null,e);if(Do(t),(e=Xi)?(e=sm(e,$i),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Vi===null?null:{id:Hi,overflow:Ui},retryLane:536870912,hydrationErrors:null},n=ji(e),n.return=t,t.child=n,Yi=t,Xi=null)):e=null,e===null)throw ta(t);return t.lanes=536870912,null}return Lc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Do(t),i){if(t.flags&256)t.flags&=-257,t=Rc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(a(558))}else if(kc||ha(e,t,n,!1),i=(n&e.childLanes)!==0,kc||i){if(yo.current===null){if(r=Yu,r!==null&&(s=ct(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,yi(e,s),Nd(r,e,s),Oc;Gd()}t=Rc(e,t,n)}else e=o.treeContext,Xi=dm(s.nextSibling),Yi=t,Zi=!0,Qi=null,$i=!1,e!==null&&Ji(t,e),t=Lc(t,r),t.flags|=134221824;return t}return e=Ei(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Bc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(a(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Vc(e,t,n,r,i){return _a(t),n=Jo(e,t,n,r,void 0,i),r=Qo(),e!==null&&!kc?($o(e,t,i),il(e,t,i)):(Zi&&r&&Ki(t),t.flags|=1,Ac(e,t,n,i),t.child)}function Hc(e,t,n,r,i,a){return _a(t),t.updateQueue=null,n=Xo(t,r,n,i),Yo(e),r=Qo(),e!==null&&!kc?($o(e,t,a),il(e,t,a)):(Zi&&r&&Ki(t),t.flags|=1,Ac(e,t,n,a),t.child)}function Uc(e,t,n,r,i){if(_a(t),t.stateNode===null){var a=Si,o=n.contextType;typeof o==`object`&&o&&(a=va(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=hc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},so(t),o=n.contextType,a.context=typeof o==`object`&&o?va(o):Si,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(mc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&hc.enqueueReplaceState(a,a.state,null),go(t,r,a,i),ho(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=vc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Si,typeof u==`object`&&u&&(o=va(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&_c(t,a,r,o),oo=!1;var f=t.memoizedState;a.state=f,go(t,r,a,i),ho(),l=t.memoizedState,s||f!==l||oo?(typeof d==`function`&&(mc(t,n,d,r),l=t.memoizedState),(c=oo||gc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,co(e,t),o=t.memoizedProps,u=vc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Si,typeof l==`object`&&l&&(c=va(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&_c(t,a,r,c),oo=!1,f=t.memoizedState,a.state=f,go(t,r,a,i),ho();var p=t.memoizedState;o!==d||f!==p||oo||e!==null&&e.dependencies!==null&&ga(e.dependencies)?(typeof s==`function`&&(mc(t,n,s,r),p=t.memoizedState),(u=oo||gc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ga(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Bc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=io(t,e.child,null,i),t.child=io(t,null,n,i)):Ac(e,t,n,i),t.memoizedState=a.state,e=t.child):e=il(e,t,i),e}function Wc(e,t,n,r){return aa(),t.flags|=256,Ac(e,t,n,r),t.child}var Gc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Kc(e){return{baseLanes:e,cachePool:Va()}}function qc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cd),e}function Jc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(jo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(Zi){if(i?Eo(t):ko(),(e=Xi)?(e=sm(e,$i),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Vi===null?null:{id:Hi,overflow:Ui},retryLane:536870912,hydrationErrors:null},n=ji(e),n.return=t,t.child=n,Yi=t,Xi=null)):e=null,e===null)throw ta(t);return t.lanes=lm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(ko(),i=t.mode,a=Xc({mode:`hidden`,children:a},i),r=ki(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Kc(n),r.childLanes=qc(e,o,n),t.memoizedState=Gc,Fc(null,r)):(Eo(t),Yc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Qc(e,t,a,o,r,c,s,n)}return i?(ko(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Ei(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=ki(i,a,n,null),i.flags|=2):i=Ei(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Fc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Kc(n):(a=i.cachePool,a===null?a=Va():(s=wa._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=qc(e,o,n),t.memoizedState=Gc,Fc(e.child,r)):(Eo(t),n=e.child,e=n.sibling,n=Ei(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Yc(e,t){return t=Xc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Xc(e,t){return e=wi(22,e,null,t),e.lanes=0,e}function Zc(e,t,n){return io(t,e.child,null,n),e=Yc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Qc(e,t,n,r,i,o,s,c){if(n)return t.flags&256?(Eo(t),t.flags&=-257,Zc(e,t,c)):t.memoizedState===null?(ko(),o=i.fallback,s=t.mode,i=Xc({mode:`visible`,children:i.children},s),o=ki(o,s,c,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,io(t,e.child,null,c),i=t.child,i.memoizedState=Kc(c),i.childLanes=qc(e,r,c),t.memoizedState=Gc,Fc(null,i)):(ko(),t.child=e.child,t.flags|=128,null);if(Eo(t),lm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(i=Error(a(419)),i.stack=``,i.digest=r,sa({value:i,source:null,stack:null})),Zc(e,t,c)}if(kc||ha(e,t,c,!1),r=(c&e.childLanes)!==0,kc||r){if(yo.current!==null)return Zc(e,t,c);if(r=Yu,r!==null&&(i=ct(r,c),i!==0&&i!==s.retryLane))throw s.retryLane=i,yi(e,i),Nd(r,e,i),Oc;return cm(o)||Gd(),Zc(e,t,c)}return cm(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,Xi=dm(o.nextSibling),Yi=t,Zi=!0,Qi=null,$i=!1,e!==null&&Ji(t,e),t=Yc(t,i.children),t.flags|=134221824,t)}function $c(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),pa(e.return,t,n)}function el(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Po(n)===null&&(t=e),e=e.sibling}return t}function tl(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function nl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function J(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=jo.current;if(t.flags&128)return Mo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Mo(t,o),i===`backwards`&&e!==null?(nl(e),Ac(e,t,r,n),nl(e)):Ac(e,t,r,n),r=Zi?Ri:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&$c(e,n,t);else if(e.tag===19)$c(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=el(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,nl(t)),tl(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Po(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}tl(t,!0,n,null,a,r);break;case`together`:tl(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=el(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),tl(t,!1,i,n,a,r)}return t.child}function rl(e,t,n){var r=t.pendingProps;return da(t,t.type,r.value),Ac(e,t,r.children,n),t.child}function il(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ad|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ha(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(a(153));if(t.child!==null){for(e=t.child,n=Ei(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ei(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function al(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ga(e)))}function ol(e,t,n){switch(t.tag){case 3:_e(t,t.stateNode.containerInfo),da(t,wa,e.memoizedState.cache),aa();break;case 27:case 5:ye(t);break;case 4:_e(t,t.stateNode.containerInfo);break;case 10:da(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Do(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Eo(t),t.flags|=128,null;r=ha(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Jc(e,t,n):(Eo(t),e=il(e,t,n),e===null?null:e.sibling)}Eo(t);break;case 19:if(t.flags&128)return J(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(ha(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return J(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Mo(t,jo.current),r)break;return null;case 22:return t.lanes=0,Pc(e,t,n,t.pendingProps);case 24:da(t,wa,e.memoizedState.cache)}return il(e,t,n)}function sl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)kc=!0;else{if(!al(e,n)&&!(t.flags&128))return kc=!1,ol(e,t,n);kc=!!(e.flags&131072)}}else kc=!1,Zi&&t.flags&1048576&&Gi(t,Ri,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ja(t.elementType),t.type=e,typeof e==`function`)Ti(e)?(r=vc(e,r),t.tag=1,t=Uc(null,t,e,r,n)):(t.tag=0,t=Vc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===I){t.tag=11,t=jc(null,t,e,r,n);break a}if(i===z){t.tag=14,t=Mc(null,t,e,r,n);break a}if(i===F){t.tag=10,t.type=e,t=rl(null,t,n);break a}}throw t=se(e)||e,Error(a(306,t,``))}}return t;case 0:return Vc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=vc(r,t.pendingProps),Uc(e,t,r,i,n);case 3:a:{if(_e(t,t.stateNode.containerInfo),e===null)throw Error(a(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,co(e,t),go(t,r,null,n);var s=t.memoizedState;if(r=s.cache,da(t,wa,r),r!==o.cache&&ma(t,[wa],n,!0),ho(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Wc(e,t,r,n);break a}if(r!==i){i=Pi(Error(a(424)),t),sa(i),t=Wc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Xi=dm(e.firstChild),Yi=t,Zi=!0,Qi=null,$i=!0,n=ao(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(aa(),r===i){t=il(e,t,n);break a}Ac(e,t,r,n)}t=t.child}return t;case 26:return Bc(e,t),e===null?(n=Fm(t.type,null,t.pendingProps,null))?t.memoizedState=n:Zi||(t.stateNode=mp(t.type,t.pendingProps,he.current,t)):t.memoizedState=Fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ye(t),e===null&&Zi&&(r=t.stateNode=_m(t.type,t.pendingProps,he.current),Yi=t,$i=!0,i=Xi,wp(t.type)?(fm=i,Xi=dm(r.firstChild)):Xi=i),Ac(e,t,t.pendingProps.children,n),Bc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Zi&&((i=r=Xi)&&(r=am(r,t.type,t.pendingProps,$i),r===null?i=!1:(t.stateNode=r,Yi=t,Xi=dm(r.firstChild),$i=!1,i=!0)),i||ta(t)),ye(t),i=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,hp(i,o)?r=null:s!==null&&hp(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=Jo(e,t,Zo,null,null,n),lh._currentValue=i),Bc(e,t),Ac(e,t,r,n),t.child;case 6:return e===null&&Zi&&((e=n=Xi)&&(n=om(n,t.pendingProps,$i),n===null?e=!1:(t.stateNode=n,Yi=t,Xi=null,e=!0)),e||ta(t)),null;case 13:return Jc(e,t,n);case 4:return _e(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=io(t,null,r,n):Ac(e,t,r,n),t.child;case 11:return jc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Bc(e,t),Ac(e,t,r,n),t.child;case 8:return Ac(e,t,t.pendingProps.children,n),t.child;case 12:return Ac(e,t,t.pendingProps.children,n),t.child;case 10:return rl(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,_a(t),i=va(i),r=r(i),t.flags|=1,Ac(e,t,r,n),t.child;case 14:return Mc(e,t,t.type,t.pendingProps,n);case 15:return Nc(e,t,t.type,t.pendingProps,n);case 19:return J(e,t,n);case 31:return zc(e,t,n);case 22:return Pc(e,t,n,t.pendingProps);case 24:return _a(t),r=va(wa),e===null?(i=za(),i===null&&(i=Yu,o=Ta(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},so(t),da(t,wa,i)):((e.lanes&n)!==0&&(co(e,t),go(t,null,null,n),ho()),i=e.memoizedState,o=t.memoizedState,i.parent===r?(r=o.cache,da(t,wa,r),r!==i.cache&&ma(t,[wa],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),da(t,wa,r))),Ac(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:Zi&&Ki(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Bc(e,t),Ac(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(a(156,t.tag))}function cl(e){e.flags|=4}function ll(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Xm(t,r):Xm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Hd())e.flags|=8192;else throw Ya=Ga,Ua}}else e.flags&=-16777217}function ul(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Zm(t)){if(Hd())e.flags|=8192;else throw Ya=Ga,Ua}}function dl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:nt(),e.lanes|=t,ld|=t)}function fl(e,t){if(!Zi)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function pl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function ml(e,t,n){var r=t.pendingProps;switch(qi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pl(t),null;case 1:return pl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),fa(wa),ve(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ia(t)?cl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,oa())),pl(t),null;case 26:var i=t.type,o=t.memoizedState;return e===null?(cl(t),o===null?(pl(t),ll(t,i,null,r,n)):(pl(t),ul(t,o))):o?o===e.memoizedState?(pl(t),t.flags&=-16777217):(cl(t),pl(t),ul(t,o)):(e=e.memoizedProps,e!==r&&cl(t),pl(t),ll(t,i,e,r,n)),null;case 27:if(be(t),n=he.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return pl(t),t.subtreeFlags&=-33554433,null}e=pe.current,ia(t)?na(t,e):(e=_m(i,r,n),t.stateNode=e,cl(t))}return pl(t),t.subtreeFlags&=-33554433,null;case 5:if(be(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return pl(t),t.subtreeFlags&=-33554433,null}if(o=pe.current,ia(t))na(t,o);else{var s=dp(he.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[mt]=t,o[ht]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(ip(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&cl(t)}}return pl(t),t.subtreeFlags&=-33554433,ll(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=he.current,ia(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Yi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[mt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||tp(e.nodeValue,n)),e||ta(t,!0)}else e=dp(e).createTextNode(r),e[mt]=t,t.stateNode=e}return pl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ia(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[mt]=t}else aa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;pl(t),e=!1}else n=oa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ao(t),t):(Ao(t),null);if(t.flags&128)throw Error(a(558))}return pl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ia(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[mt]=t}else aa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;pl(t),i=!1}else i=oa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Ao(t),t):(Ao(t),null)}return Ao(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),dl(t,t.updateQueue),pl(t),null);case 4:return ve(),e===null&&Gf(t.stateNode.containerInfo),t.flags|=67108864,pl(t),null;case 10:return fa(t.type),pl(t),null;case 19:if(No(t),r=t.memoizedState,r===null)return pl(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)fl(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Po(e),o!==null){for(t.flags|=128,fl(r,!1),e=o.updateQueue,t.updateQueue=e,dl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Di(n,e),n=n.sibling;return Mo(t,jo.current&1|2),Zi&&Wi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Me()>hd&&(t.flags|=128,i=!0,fl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Po(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,dl(t,e),fl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!Zi)return pl(t),null}else 2*Me()-r.renderingStartTime>hd&&n!==536870912&&(t.flags|=128,i=!0,fl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Me(),e.sibling=null,o=jo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||Zi?Mo(t,o):(n=o,fe(wo,t),fe(jo,n),To===null&&(To=t)),Zi&&Wi(t,r.treeForkCount),e}return pl(t),null;case 22:case 23:return Ao(t),Co(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(pl(t),t.subtreeFlags&6&&(t.flags|=8192)):pl(t),n=t.updateQueue,n!==null&&dl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&de(Ra),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),fa(wa),pl(t),null;case 25:return null;case 30:return t.flags|=33554432,pl(t),null}throw Error(a(156,t.tag))}function hl(e,t){switch(qi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return fa(wa),ve(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return be(t),null;case 31:if(t.memoizedState!==null){if(Ao(t),t.alternate===null)throw Error(a(340));aa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ao(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));aa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return No(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ve(),null;case 10:return fa(t.type),null;case 22:case 23:return Ao(t),Co(),e!==null&&de(Ra),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return fa(wa),null;case 25:return null;default:return null}}function gl(e,t){switch(qi(t),t.tag){case 3:fa(wa),ve();break;case 26:case 27:case 5:be(t);break;case 4:ve();break;case 31:t.memoizedState!==null&&Ao(t);break;case 13:Ao(t);break;case 19:No(t);break;case 10:fa(t.type);break;case 22:case 23:Ao(t),Co(),e!==null&&de(Ra);break;case 24:fa(wa)}}function _l(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){pf(t,t.return,e)}}function vl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){pf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){pf(t,t.return,e)}}function yl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{vo(t,n)}catch(t){pf(e,e.return,t)}}}function bl(e,t,n){n.props=vc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pf(e,t,n)}}function xl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=li(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Ip(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Lp(e);h(e.child,!1,em,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){pf(e,t,n)}}function Sl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){pf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){pf(e,t,n)}else n.current=null}}function Cl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)nm(e.stateNode,t[n])}function wl(e){for(var t=e.return;t!==null&&(Dl(t)&&nm(e.stateNode,t.stateNode),!El(t));)t=t.return}function Tl(e){for(var t=e.return;t!==null&&(Dl(t)&&rm(e.stateNode,t.stateNode),!El(t));)t=t.return}function El(e){return e.tag===5||e.tag===3||e.tag===27}function Dl(e){return e&&e.tag===7&&e.stateNode!==null}function Ol(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pf(e,e.return,t)}}function kl(e,t,n){try{var r=e.stateNode;op(r,e.type,n,t),r[ht]=t}catch(t){pf(e,e.return,t)}}function Al(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wp(e.type)||e.tag===4}function jl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Al(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&wp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ml(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=dn)),Cl(e,r),Rt=!0;else if(i!==4&&(i===27&&(Cl(e,r),r=null,wp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Ml(e,t,n,r),e=e.sibling;e!==null;)Ml(e,t,n,r),e=e.sibling}function Nl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),Cl(e,r),Rt=!0;else if(i!==4&&(i===27&&(Cl(e,r),r=null,wp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Nl(e,t,n,r),e=e.sibling;e!==null;)Nl(e,t,n,r),e=e.sibling}function Pl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ip(t,r,n),t[mt]=e,t[ht]=n}catch(t){pf(e,e.return,t)}}var Fl=!1,Il=null;function Ll(e){(e.tag===30||e.subtreeFlags&33554432)&&(Fl=!0)}var Rl=null;function zl(){var e=Rl;return Rl=null,e}var Bl=0;function Vl(e,t,n,r,i){return Bl=0,Y(e.child,t,n,r,i)}function Y(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Ap(o);r.push(s),s.view&&(a=!0)}else a||Ap(o).view&&(a=!0);Fl=!0,Dp(o,Bl===0?t:t+`_`+Bl,n),Bl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Y(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function X(e,t){for(;e!==null;)e.tag===5?Op(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||X(e.child,t),e=e.sibling}function Hl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Hl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(a(544));var n=t.name;t=di(t.default,t.share),t!==`none`&&(Vl(e,n,t,null,!1)||X(e.child,!1))}e=e.sibling}}function Ul(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=li(r,n),a=di(r.default,n.paired?r.share:r.enter);a===`none`?Hl(e):Vl(e,i,a,null,!1)?(Hl(e),n.paired||t||Md(e,r.onEnter)):X(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Ul(e,t),e=e.sibling;else Hl(e)}function Wl(e){if(Il!==null&&Il.size!==0){var t=Il;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=di(n.default,n.share);if(a!==`none`&&(Vl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Md(e,n.onShare)):X(e.child,!1)),t.delete(r),t.size===0)break}}}Wl(e)}e=e.sibling}}}function Gl(e){if(e.tag===30){var t=e.memoizedProps,n=li(t,e.stateNode),r=Il===null?void 0:Il.get(n),i=di(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Vl(e,n,i,null,!1)?r===void 0?Md(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Il.delete(n),Md(e,t.onShare)):X(e.child,!1)),Il!==null&&Wl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Gl(e),e=e.sibling;else Il!==null&&Wl(e)}function Kl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=li(t,e.stateNode);t=di(t.default,t.update),e.flags&=-5,t!==`none`&&Vl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Kl(e);e=e.sibling}}function ql(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,X(e.child,!1))}ql(e)}e=e.sibling}}function Jl(e){if(e.tag===30)e.stateNode.paired=null,X(e.child,!1),ql(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Jl(e),e=e.sibling;else ql(e)}function Yl(e){for(e=e.child;e!==null;)e.tag===30?X(e.child,!1):e.subtreeFlags&33554432&&Yl(e),e=e.sibling}function Xl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Bl<a.length){var l=a[Bl],u=Ap(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Dp(c,Bl===0?n:n+`_`+Bl,i),s&&e.flags&4||(Rl===null&&(Rl=[]),Rl.push(c,Bl===0?r:r+`_`+Bl,t.memoizedProps)),Bl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Xl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Zl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=li(n,r),a=di(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(jp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Bl=0,i=Xl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Md(e,n.onUpdate))}else e.subtreeFlags&33554432&&Zl(e,t);e=e.sibling}}var Ql=!1,$l=!1,eu=!1,tu=!1,nu=typeof WeakSet==`function`?WeakSet:Set,ru=null,iu=!1,au=!1,ou=!1,su=!1;function cu(e,t,n){if(e=e.containerInfo,lp=vh,e=Br(e),Vr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(up={focusedElem:e,selectionRange:r},vh=!1,n=(n&335544064)===n,ru=t,t=n?9270:1024;ru!==null;){if(e=ru,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Gl(r[a]);if(e.alternate===null&&e.flags&2)n&&Ll(e),lu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Gl(r),lu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Ll(e),lu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,ru=r):(n&&Kl(e),lu(n))}}Il=null}function lu(e){for(;ru!==null;){var t=ru,n=e,r=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(i&1024&&r!==null){n=void 0,i=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=vc(t.type,i);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){pf(t,t.return,e)}}break;case 3:if(i&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)im(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:im(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=li(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=di(i.default,i.update),i!==`none`&&Vl(r,n,i,r.memoizedState=[],!0));break;default:if(i&1024)throw Error(a(163))}if(r=t.sibling,r!==null){r.return=t.return,ru=r;break}ru=t.return}}function uu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Au(e,n),r&4&&_l(5,n);break;case 1:if(Au(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){pf(n,n.return,e)}else{var i=vc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pf(n,n.return,e)}}}r&64&&yl(n),r&512&&xl(n,n.return);break;case 3:if(Au(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{vo(e,t)}catch(e){pf(n,n.return,e)}}break;case 27:t===null&&r&4&&Pl(n);case 26:case 5:Au(e,n),t===null&&r&4&&Ol(n),r&512&&xl(n,n.return);break;case 12:Au(e,n);break;case 31:Au(e,n),r&4&&yu(e,n);break;case 13:Au(e,n),r&4&&bu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=_f.bind(null,n),um(e,n))));break;case 22:if(r=n.memoizedState!==null||Ql,!r){var a=t!==null&&t.memoizedState!==null||$l;t=Ql,i=$l,Ql=r,($l=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Mu(e,n,r)):Au(e,n),Ql=t,$l=i}break;case 30:Au(e,n),r&512&&xl(n,n.return);break;case 7:r&512&&xl(n,n.return);default:Au(e,n)}}function du(e,t){for(e=e.child;e!==null;)fu(e,t),e=e.sibling}function fu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){pf(e,e.return,t)}pu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Rt=!0}catch(t){pf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Ep(s,!0):Ep(e.stateNode,!1)}catch(t){pf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&du(e,t);break;default:du(e,t)}}function pu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:fu(n,r);break a;case 22:n.memoizedState===null&&pu(n,r);break a;default:pu(n,r)}}e=e.sibling}}function mu(e){var t=e.alternate;t!==null&&(e.alternate=null,mu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ct(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var hu=null,gu=!1;function _u(e,t,n){for(n=n.child;n!==null;)vu(e,t,n),n=n.sibling}function vu(e,t,n){if(He&&typeof He.onCommitFiberUnmount==`function`)try{He.onCommitFiberUnmount(Ve,n)}catch{}switch(n.tag){case 26:$l||Sl(n,t),_u(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!$l&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:$l||Sl(n,t),Tl(n);var r=hu,i=gu;wp(n.type)&&(hu=n.stateNode,gu=!1),_u(e,t,n),vm(n.stateNode,n.type,n.memoizedProps),hu=r,gu=i;break;case 5:$l||Sl(n,t),Tl(n);case 6:if(n.tag===6&&Tl(n),r=hu,i=gu,hu=null,_u(e,t,n),hu=r,gu=i,hu!==null){if(gu)try{(hu.nodeType===9?hu.body:hu.nodeName===`HTML`?hu.ownerDocument.body:hu).removeChild(n.stateNode),Rt=!0}catch(e){pf(n,t,e)}else try{hu.removeChild(n.stateNode),Rt=!0}catch(e){pf(n,t,e)}}break;case 18:hu!==null&&(gu?(e=hu,Tp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wh(e)):Tp(hu,n.stateNode));break;case 4:r=hu,i=gu,hu=n.stateNode.containerInfo,gu=!0,_u(e,t,n),hu=r,gu=i;break;case 0:case 11:case 14:case 15:vl(2,n,t),$l||vl(4,n,t),_u(e,t,n);break;case 1:$l||(Sl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&bl(n,t,r)),_u(e,t,n);break;case 21:_u(e,t,n);break;case 22:$l=(r=$l)||n.memoizedState!==null,_u(e,t,n),$l=r;break;case 30:Sl(n,t),_u(e,t,n);break;case 7:$l||Sl(n,t),_u(e,t,n);break;default:_u(e,t,n)}}function yu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wh(e)}catch(e){pf(t,t.return,e)}}}function bu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wh(e)}catch(e){pf(t,t.return,e)}}function xu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nu),t;default:throw Error(a(435,e.tag))}}function Su(e,t){var n=xu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=vf.bind(null,e,t);t.then(r,r)}})}function Cu(e,t,n){var r=t.deletions;if(r!==null)for(var i=0;i<r.length;i++){var o=r[i],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(wp(l.type)){hu=l.stateNode,gu=!1;break a}break;case 5:hu=l.stateNode,gu=!1;break a;case 3:case 4:hu=l.stateNode.containerInfo,gu=!0;break a}l=l.return}if(hu===null)throw Error(a(160));vu(s,c,o),hu=null,gu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Tu(t,e,n),t=t.sibling}var wu=null;function Tu(e,t,n){var r=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(i&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}Cu(t,e,n),Eu(e),i&4&&(vl(3,e,e.return),_l(3,e),vl(5,e,e.return));break;case 1:Cu(t,e,n),Eu(e),i&512&&($l||r===null||Sl(r,r.return)),i&64&&Ql&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=wu,Cu(t,e,n),Eu(e),i&512&&($l||r===null||Sl(r,r.return)),i&4){if(i=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(Ql)e.stateNode=mp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,i=o.ownerDocument||o;b:switch(t){case`title`:r=i.getElementsByTagName(`title`)[0],(!r||r[xt]||r[mt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=i.createElement(t),i.head.insertBefore(r,i.querySelector(`head > title`))),ip(r,t,n),r[mt]=e,Ot(r),t=r;break a;case`link`:if(o=qm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;case`meta`:if(o=qm(`meta`,`content`,i).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;default:throw Error(a(468,t))}r[mt]=e,Ot(r),t=r}e.stateNode=t}}else Ql||Jm(o,e.type,e.stateNode)}else e.stateNode=Hm(o,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&kl(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||$l||t.parentNode.removeChild(t)):i.count--,n===null?Ql||Jm(o,e.type,e.stateNode):Hm(o,n,e.memoizedProps))}break;case 27:Cu(t,e,n),Eu(e),i&512&&($l||r===null||Sl(r,r.return)),r!==null&&i&4&&kl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=eu,eu=!1,Cu(t,e,n),eu=o,Eu(e),i&512&&($l||r===null||Sl(r,r.return)),e.flags&32){t=e.stateNode;try{nn(t,``),Rt=!0}catch(t){pf(e,e.return,t)}}i&4&&e.stateNode!=null&&(t=e.memoizedProps,kl(e,t,r===null?t:r.memoizedProps)),i&1024&&(tu=!0);break;case 6:if(Cu(t,e,n),Eu(e),i&4){if(e.stateNode===null)throw Error(a(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Rt=!0}catch(t){pf(e,e.return,t)}}break;case 3:if(Rt=!1,Km=null,o=wu,wu=Sm(t.containerInfo),Cu(t,e,n),wu=o,Eu(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Wh(t.containerInfo)}catch(t){pf(e,e.return,t)}tu&&(tu=!1,Du(e)),Rt=!1;break;case 4:i=eu,eu=Ql,r=zt(),o=wu,wu=Sm(e.stateNode.containerInfo),Cu(t,e,n),Eu(e),wu=o,Rt&&au&&(ou=!0),Rt=r,eu=i;break;case 12:Cu(t,e,n),Eu(e);break;case 31:Cu(t,e,n),Eu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Su(e,t)));break;case 13:Cu(t,e,n),Eu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(pd=Me()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Su(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Ql,l=$l,u=eu;Ql=c||o,eu=u||o,$l=l||s,Cu(t,e,n),$l=l,eu=u,Ql=c,Eu(e),i&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||Ql||$l||(t=s||$l,n=Ql,r=$l,Ql=o||Ql,$l=t,ju(e,2),Ql=n,$l=r),!o&&eu||du(e,o)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Su(e,n))));break;case 19:Cu(t,e,n),Eu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Su(e,t)));break;case 30:i&512&&($l||r===null||Sl(r,r.return)),i=zt(),o=au,s=(n&335544064)===n,c=e.memoizedProps,au=s&&di(c.default,c.update)!==`none`,Cu(t,e,n),Eu(e),s&&r!==null&&Rt&&(e.flags|=4),au=o,Rt=i;break;case 21:break;case 7:i&512&&($l||r===null||Sl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Cu(t,e,n),Eu(e)}}function Eu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Al(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(Dl(i)){var o=i.stateNode;r===null?r=[o]:r.push(o)}if(El(i))break;i=i.return}var s=r;if(n==null)throw Error(a(160));switch(n.tag){case 27:var c=n.stateNode;Nl(e,jl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(nn(l,``),n.flags&=-33),Nl(e,jl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Ml(e,jl(e),u,s);break;default:throw Error(a(161))}}catch(t){pf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Du(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Du(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,vh=!0,t.reset(),vh=!1),e=e.sibling}}function Ou(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)ku(t,e),t=t.sibling;else Zl(t,!1)}function ku(e,t){var n=e.alternate;if(n===null)Ul(e,!1);else switch(e.tag){case 3:if(su=iu=!1,zl(),Ou(t,e),!iu&&!ou){if(e=Rl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Op(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),su=!0}Rl=null;break;case 5:Ou(t,e);break;case 4:r=iu,iu=!1,Ou(t,e),iu&&(ou=!0),iu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Ou(t,e):Ul(e,!1));break;case 30:r=iu,i=zl(),iu=!1,Ou(t,e),iu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=li(a,o),o=li(n.memoizedProps,o);var s=di(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Bl=0,t=Xl(e,n,t,o,s,a,!0),Bl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Md(e,e.memoizedProps.onUpdate),Rl=i):i!==null&&(i.push.apply(i,Rl),Rl=i),iu=e.flags&32?!0:r;break;default:Ou(t,e)}}function Au(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)uu(e,t.alternate,t),t=t.sibling}function ju(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:vl(4,n,n.return),ju(n,r);break;case 1:Sl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&bl(n,n.return,i),ju(n,r);break;case 27:r&2&&vm(n.stateNode,n.type,n.memoizedProps);case 5:Sl(n,n.return),n.tag!==5&&n.tag!==27||Tl(n),ju(n,r);break;case 6:Tl(n);break;case 26:Sl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||$l||i.parentNode.removeChild(i),ju(n,r);break;case 22:n.memoizedState===null&&ju(n,r);break;case 30:Sl(n,n.return),ju(n,r);break;case 7:Sl(n,n.return);default:ju(n,r)}e=e.sibling}}function Mu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Mu(i,a,n),_l(4,a);break;case 1:if(Mu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){pf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)_o(l[i],c)}catch(e){pf(r,r.return,e)}}s&&o&64&&yl(a),xl(a,a.return);break;case 27:n&2&&Pl(a);case 5:a.tag!==5&&a.tag!==27||wl(a),Mu(i,a,n),s&&r===null&&o&4&&Ol(a),xl(a,a.return);break;case 6:wl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Ql||Jm(Sm(c.ownerDocument),a.type,c),Mu(i,a,n),s&&r===null&&o&4&&Ol(a),xl(a,a.return);break;case 12:Mu(i,a,n);break;case 31:Mu(i,a,n),s&&o&4&&yu(i,a);break;case 13:Mu(i,a,n),s&&o&4&&bu(i,a);break;case 22:a.memoizedState===null&&Mu(i,a,n),xl(a,a.return);break;case 30:Mu(i,a,n),xl(a,a.return);break;case 7:xl(a,a.return);default:Mu(i,a,n)}t=t.sibling}}function Nu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Ea(n))}function Pu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ea(e))}function Z(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Fu(e,t,n,r),t=t.sibling;else i&&Yl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Jl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Z(e,t,n,r),a&2048&&_l(9,t);break;case 1:Z(e,t,n,r);break;case 3:Z(e,t,n,r),i&&su&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Ea(a)));break;case 12:if(a&2048){Z(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){pf(t,t.return,e)}}else Z(e,t,n,r);break;case 31:Z(e,t,n,r);break;case 13:Z(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Jl(t),o._visibility&2?Z(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Jl(s),o._visibility&2?Z(e,t,n,r):Lu(e,t)),a&2048&&Nu(s,t);break;case 24:Z(e,t,n,r),a&2048&&Pu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(X(a.child,!0),X(t.child,!0))),Z(e,t,n,r);break;default:Z(e,t,n,r)}}function Iu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Iu(a,o,s,c,i),_l(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Iu(a,o,s,c,i)):u._visibility&2?Iu(a,o,s,c,i):Lu(a,o),i&&l&2048&&Nu(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Pu(o.alternate,o);break;default:Iu(a,o,s,c,i)}t=t.sibling}}function Lu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Lu(n,r),i&2048&&Nu(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Pu(r.alternate,r);break;default:Lu(n,r)}t=t.sibling}}var Ru=8192;function zu(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)Bu(e,t,n),e=e.sibling}function Bu(e,t,n){switch(e.tag){case 26:zu(e,t,n),e.flags&Ru&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&$m(n,e)):eh(n,wu,e.memoizedState,e.memoizedProps));break;case 5:zu(e,t,n),e.flags&Ru&&(e=e.stateNode,(t&335544128)===t&&$m(n,e));break;case 3:case 4:var r=wu;wu=Sm(e.stateNode.containerInfo),zu(e,t,n),wu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ru,Ru=16777216,zu(e,t,n),Ru=r):zu(e,t,n));break;case 30:if((e.flags&Ru)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Il===null&&(Il=new Map),Il.set(r,i)}zu(e,t,n);break;default:zu(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&vl(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:vl(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;ru!==null;){var n=ru;switch(n.tag){case 0:case 11:case 15:vl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Ea(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,ru=r;else a:for(n=e;ru!==null;){r=ru;var i=r.sibling,a=r.return;if(mu(r),r===n){ru=null;break a}if(i!==null){i.return=a,ru=i;break a}ru=a}}}var Ku={getCacheForType:function(e){var t=va(wa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return va(wa).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,Ju=0,Yu=null,Xu=null,Zu=0,Qu=0,$u=null,ed=!1,td=!1,nd=!1,rd=0,id=0,ad=0,od=0,sd=0,cd=0,ld=0,ud=null,dd=null,fd=!1,pd=0,md=0,hd=1/0,gd=null,_d=null,vd=0,yd=null,bd=null,xd=0,Sd=0,Cd=null,wd=null,Td=null,Ed=null,Dd=null,Od=0,kd=null;function Ad(){return Ju&2&&Zu!==0?Zu&-Zu:U.T===null?dt():Pf()}function jd(){if(cd===0){if(!(Zu&536870912)||Zi){var e=Ye;Ye<<=1,!(Ye&3932160)&&(Ye=262144),cd=e}else cd=536870912}return e=wo.current,e!==null&&(e.flags|=32),cd}function Md(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Ip(li(e.memoizedProps,n))),Ed===null&&(Ed=[]),Ed.push(t.bind(null,r))}}function Nd(e,t,n){(e===Yu&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)&&(Bd(e,0),Ld(e,Zu,cd,!1)),it(e,n),Ju&2&&e===Yu||(e===Yu&&(!(Ju&2)&&(od|=n),id===4&&Ld(e,Zu,cd,!1)),Ef(e))}function Pd(e,t,n){if(Ju&6)throw Error(a(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||$e(e,t),i=r?Jd(e,t):Kd(e,t,!0),o=r;do{if(i===0){td&&!r&&Ld(e,t,0,!1);break}if(n=e.current.alternate,o&&!Id(n))i=Kd(e,t,!1),o=!1;else{if(i===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=ud;var l=c.current.memoizedState.isDehydrated;if(l&&(Bd(c,s).flags|=256),s=Kd(c,s,!1),s!==2&&s!==6){if(nd&&!l){c.errorRecoveryDisabledLanes|=o,od|=o,i=4;break a}o=dd,dd=i,o!==null&&(dd===null?dd=o:dd.push.apply(dd,o))}i=s}if(o=!1,i!==2)continue}}if(i===1){Bd(e,0),Ld(e,t,0,!0);break}a:{switch(r=e,o=i,o){case 0:case 1:throw Error(a(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Ld(r,t,cd,!ed);break a;case 2:dd=null;break;case 3:case 5:break;default:throw Error(a(329))}if((t&62914560)===t&&(i=pd+300-Me(),10<i)){if(Ld(r,t,cd,!ed),Qe(r,0,!0)!==0)break a;xd=t,r.timeoutHandle=vp(Fd.bind(null,r,n,dd,gd,fd,t,cd,od,ld,ed,o,`Throttled`,-0,0),i);break a}Fd(r,n,dd,gd,fd,t,cd,od,ld,ed,o,null,-0,0)}break}}while(1);Ef(e)}function Fd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dn},Il=null,Bu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ih.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?pd-Me():(a&4194048)===a?md-Me():0,m=nh(d,m),m!==null)?(xd=a,e.cancelPendingCommit=m(tf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Ld(e,a,o,!l)):tf(e,t,a,n,r,i,o,s,c,l,u,d)}function Id(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Pr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ld(e,t,n,r){t=et(e,t),t&=~sd,t&=~od,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-We(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&ot(e,n,t)}function Rd(){return Ju&6?!0:(Df(0,!1),!1)}function zd(){if(Xu!==null){if(Qu===0)var e=Xu.return;else e=Xu,ua=la=null,es(e),Qa=null,$a=0,e=Xu;for(;e!==null;)gl(e.alternate,e),e=e.return;Xu=null}}function Bd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,yp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),xd=0,zd(),Yu=e,Xu=n=Ei(e.current,null),Zu=t,Qu=0,$u=null,ed=!1,td=$e(e,t),nd=!1,ld=cd=sd=od=ad=id=0,dd=ud=null,fd=!1,rd=et(e,t),gi(),n}function Vd(e,t){Io=null,U.H=uc,t===Ha||t===Wa?(t=Xa(),Qu=3):t===Ua?(t=Xa(),Qu=4):Qu=t===Oc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,Xu===null&&(id=1,Sc(e,Pi(t,e.current)))}function Hd(){var e=wo.current;return e===null?!0:(Zu&4194048)===Zu?To===null:(Zu&62914560)===Zu||Zu&536870912?e===To:!1}function Ud(){var e=U.H;return U.H=uc,e===null?uc:e}function Wd(){var e=U.A;return U.A=Ku,e}function Gd(){id=4,ed||(Zu&4194048)!==Zu&&wo.current!==null||(td=!0),!(ad&134217727)&&!(od&134217727)||Yu===null||Ld(Yu,Zu,cd,!1)}function Kd(e,t,n){var r=Ju;Ju|=2;var i=Ud(),a=Wd();(Yu!==e||Zu!==t)&&(gd=null,Bd(e,t)),t=!1;var o=id;a:do try{if(Qu!==0&&Xu!==null){var s=Xu,c=$u;switch(Qu){case 8:zd(),o=6;break a;case 3:case 2:case 9:case 6:wo.current===null&&(t=!0);var l=Qu;if(Qu=0,$u=null,Qd(e,s,c,l),n&&td){o=0;break a}break;default:l=Qu,Qu=0,$u=null,Qd(e,s,c,l)}}qd(),o=id;break}catch(t){Vd(e,t)}while(1);return t&&e.shellSuspendCounter++,ua=la=null,Ju=r,U.H=i,U.A=a,Xu===null&&(Yu=null,Zu=0,gi()),o}function qd(){for(;Xu!==null;)Xd(Xu)}function Jd(e,t){var n=Ju;Ju|=2;var r=Ud(),i=Wd();Yu!==e||Zu!==t?(gd=null,hd=Me()+500,Bd(e,t)):td=$e(e,t);a:do try{if(Qu!==0&&Xu!==null){t=Xu;var o=$u;b:switch(Qu){case 1:Qu=0,$u=null,Qd(e,t,o,1);break;case 2:case 9:if(Ka(o)){Qu=0,$u=null,Zd(t);break}t=function(){Qu!==2&&Qu!==9||Yu!==e||(Qu=7),Ef(e)},o.then(t,t);break a;case 3:Qu=7;break a;case 4:Qu=5;break a;case 7:Ka(o)?(Qu=0,$u=null,Zd(t)):(Qu=0,$u=null,Qd(e,t,o,7));break;case 5:var s=null;switch(Xu.tag){case 26:s=Xu.memoizedState;case 5:case 27:var c=Xu;if(s?Zm(s):c.stateNode.complete){Qu=0,$u=null;var l=c.sibling;if(l!==null)Xu=l;else{var u=c.return;u===null?Xu=null:(Xu=u,$d(u))}break b}}Qu=0,$u=null,Qd(e,t,o,5);break;case 6:Qu=0,$u=null,Qd(e,t,o,6);break;case 8:zd(),id=6;break a;default:throw Error(a(462))}}Yd();break}catch(t){Vd(e,t)}while(1);return ua=la=null,U.H=r,U.A=i,Ju=n,Xu===null?(Yu=null,Zu=0,gi(),id):0}function Yd(){for(;Xu!==null&&!Ae();)Xd(Xu)}function Xd(e){var t=sl(e.alternate,e,rd);e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Zd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Hc(n,t,t.pendingProps,t.type,void 0,Zu);break;case 11:t=Hc(n,t,t.pendingProps,t.type.render,t.ref,Zu);break;case 5:es(t);var r=t;r===Yi&&(Zi?(ra(r),r.tag===5&&r.stateNode!=null&&(Xi=r.stateNode)):(ra(r),Zi=!0));default:gl(n,t),t=Xu=Di(t,rd),t=sl(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Qd(e,t,n,r){ua=la=null,es(t),Qa=null,$a=0;var i=t.return;try{if(Dc(e,i,t,n,Zu)){id=1,Sc(e,Pi(n,e.current)),Xu=null;return}}catch(t){if(i!==null)throw Xu=i,t;id=1,Sc(e,Pi(n,e.current)),Xu=null;return}t.flags&32768?(Zi||r===1?e=!0:td||Zu&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=wo.current,r!==null&&r.tag===13&&(r.flags|=16384))),ef(t,e)):$d(t)}function $d(e){var t=e;do{if(t.flags&32768){ef(t,ed);return}e=t.return;var n=ml(t.alternate,t,rd);if(n!==null){Xu=n;return}if(t=t.sibling,t!==null){Xu=t;return}Xu=t=e}while(t!==null);id===0&&(id=5)}function ef(e,t){do{var n=hl(e.alternate,e);if(n!==null){n.flags&=32767,Xu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Xu=e;return}Xu=e=n}while(e!==null);id=6,Xu=null}function tf(e,t,n,r,i,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do uf();while(vd!==0);if(Ju&6)throw Error(a(327));if(t!==null){if(t===e.current)throw Error(a(177));e===Yu&&(Xu=Yu=null,Zu=0),bd=t,yd=e,xd=n,Cd=i,wd=r,nf(e,t,n,s,c,l,f)}}function nf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Sd=s,s|=hi,at(e,n,s,r,i,a),Ed=null,(n&335544064)===n?(Dd=ka(e),r=10262):(Dd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,yf(Ie,function(){return df(),null})):(e.callbackNode=null,e.callbackPriority=0),Fl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=U.T,U.T=null,i=W.p,W.p=2,a=Ju,Ju|=4;try{cu(e,t,n)}finally{Ju=a,W.p=i,U.T=r}}vd=1,Fl?Td=Pp(o,e.containerInfo,Dd,of,sf,af,cf,df,rf,null,null):(of(),sf(),cf())}function rf(e){if(vd!==0){var t=yd.onRecoverableError;t(e,{componentStack:null})}}function af(){vd===3&&(vd=0,ku(bd,yd),vd=4)}function of(){if(vd===1){vd=0;var e=yd,t=bd,n=xd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=U.T,U.T=null;var i=W.p;W.p=2;var a=Ju;Ju|=4;try{au=ou=!1,Tu(t,e,n),n=up;var o=Br(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&zr(s.ownerDocument.documentElement,s)){if(c!==null&&Vr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Rr(s,h),v=Rr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vh=!!lp,up=lp=null}finally{Ju=a,W.p=i,U.T=r}}e.current=t,vd=2}}function sf(){if(vd===2){vd=0;var e=yd,t=bd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=U.T,U.T=null;var r=W.p;W.p=2;var i=Ju;Ju|=4;try{uu(e,t.alternate,t)}finally{Ju=i,W.p=r,U.T=n}}vd=3}}function cf(){if(vd===4||vd===3){vd=0;var e=Td;Td=null,je();var t=yd,n=bd,r=xd,i=wd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?vd=5:(vd=0,bd=yd=null,lf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(_d=null),ut(r),n=n.stateNode,He&&typeof He.onCommitFiberRoot==`function`)try{He.onCommitFiberRoot(Ve,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=U.T,a=W.p,W.p=2,U.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{U.T=n,W.p=a}}if(i=Ed,o=Dd,Dd=null,i!==null&&(Ed=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);xd&3&&uf(),Ef(t),a=t.pendingLanes,r&261930&&a&42?t===kd?Od++:(Od=0,kd=t):(Od=0,kd=null),Df(0,!1)}}function lf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ea(t)))}function uf(){return Td!==null&&(Td.skipTransition(),Td=null),of(),sf(),cf(),df()}function df(){if(vd!==5)return!1;var e=yd,t=Sd;Sd=0;var n=ut(xd),r=U.T,i=W.p;try{W.p=32>n?32:n,U.T=null,n=Cd,Cd=null;var o=yd,s=xd;if(vd=0,bd=yd=null,xd=0,Ju&6)throw Error(a(331));var c=Ju;if(Ju|=4,Uu(o.current),Fu(o,o.current,s,n),Ju=c,Df(0,!1),He&&typeof He.onPostCommitFiberRoot==`function`)try{He.onPostCommitFiberRoot(Ve,o)}catch{}return!0}finally{W.p=i,U.T=r,lf(e,t)}}function ff(e,t,n){t=Pi(n,t),t=wc(e.stateNode,t,2),e=uo(e,t,2),e!==null&&(it(e,2),Ef(e))}function pf(e,t,n){if(e.tag===3)ff(e,e,n);else for(;t!==null;){if(t.tag===3){ff(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(_d===null||!_d.has(r))){e=Pi(n,e),n=Tc(2),r=uo(t,n,2),r!==null&&(Ec(n,r,t,e),it(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(nd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Yu===e&&(Zu&n)===n&&(id===4||id===3&&(Zu&62914560)===Zu&&300>Me()-pd?Ju&2?sd|=n:Bd(e,0):sd|=n,ld===Zu&&(ld=0)),Ef(e)}function gf(e,t){t===0&&(t=nt()),e=yi(e,t),e!==null&&(it(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Oe(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-We(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Zu,a=Qe(r,r===Yu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||$e(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&_p()&&(e=Tf);for(var t=Me(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}vd!==0&&vd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-We(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=tt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yu,n=Zu,n=Qe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ke(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||$e(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ke(r),ut(n)){case 2:case 8:n=Fe;break;case 32:n=Ie;break;case 268435456:n=Re;break;default:n=Ie}return r=jf.bind(null,e),n=Oe(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ke(r),e.callbackPriority=2,e.callbackNode=null,2}function jf(e,t){if(vd!==0&&vd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(uf()&&e.callbackNode!==n)return null;var r=Zu;return r=Qe(e,e===Yu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pd(e,r,t),Af(e,Me()),e.callbackNode!=null&&e.callbackNode===n?jf.bind(null,e):null)}function Mf(e,t){if(uf())return null;Pd(e,t,!0)}function Nf(){Sp(function(){Ju&6?Oe(Pe,Of):kf()})}function Pf(){if(Tf===0){var e=Ma;e===0&&(e=Je,Je<<=1,!(Je&261888)&&(Je=256)),Tf=e}return Tf}function Ff(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:un(e)}function If(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ff((i[ht]||null).action),o=r.submitter;o&&(t=(t=o[ht]||null)?Ff(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Mn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Tf!==0){var e=new FormData(i,o);Xs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Xs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Lf=0;Lf<oi.length;Lf++){var Rf=oi[Lf];si(Rf.toLowerCase(),`on`+(Rf[0].toUpperCase()+Rf.slice(1)))}si(Qr,`onAnimationEnd`),si($r,`onAnimationIteration`),si(ei,`onAnimationStart`),si(`dblclick`,`onDoubleClick`),si(`focusin`,`onFocus`),si(`focusout`,`onBlur`),si(ti,`onTransitionRun`),si(ni,`onTransitionStart`),si(ri,`onTransitionCancel`),si(ii,`onTransitionEnd`),Nt(`onMouseEnter`,[`mouseout`,`mouseover`]),Nt(`onMouseLeave`,[`mouseout`,`mouseover`]),Nt(`onPointerEnter`,[`pointerout`,`pointerover`]),Nt(`onPointerLeave`,[`pointerout`,`pointerover`]),Mt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Mt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Mt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Mt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Mt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Mt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var zf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Bf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(zf));function Vf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){fi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){fi(e)}i.currentTarget=null,a=c}}}}function Hf(e,t){var n=t[_t];n===void 0&&(n=t[_t]=new Set);var r=e+`__bubble`;n.has(r)||(Kf(t,e,2,!1),n.add(r))}function Uf(e,t,n){var r=0;t&&(r|=4),Kf(n,e,r,t)}var Wf=`_reactListening`+Math.random().toString(36).slice(2);function Gf(e){if(!e[Wf]){e[Wf]=!0,At.forEach(function(t){t!==`selectionchange`&&(Bf.has(t)||Uf(t,!1,e),Uf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Wf]||(t[Wf]=!0,Uf(`selectionchange`,!1,t))}}function Kf(e,t,n,r){switch(Th(t)){case 2:var i=yh;break;case 8:i=bh;break;default:i=xh}n=i.bind(null,t,n,e),i=void 0,!xn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function qf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=wt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}vn(function(){var r=a,i=pn(n),o=[];a:{var s=ai.get(e);if(s!==void 0){var c=Mn,u=e;switch(e){case`keypress`:if(Dn(n)===0)break a;case`keydown`:case`keyup`:c=Xn;break;case`focusin`:u=`focus`,c=Vn;break;case`focusout`:u=`blur`,c=Vn;break;case`beforeblur`:case`afterblur`:c=Vn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=zn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Bn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=$n;break;case Qr:case $r:case ei:c=Hn;break;case ii:c=er;break;case`scroll`:case`scrollend`:c=Pn;break;case`wheel`:c=tr;break;case`copy`:case`cut`:case`paste`:c=Un;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=Zn;break;case`submit`:c=Qn;break;case`toggle`:case`beforetoggle`:c=nr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=yn(m,p),g!=null&&d.push(Jf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,c&&n!==fn&&(u=n.relatedTarget||n.fromElement)&&(wt(u)||u[gt]))break a;(s||c)&&(u=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,s?(c=n.relatedTarget||n.toElement,s=r,c=c?wt(c):null,c!==null&&(f=l(c),d=c.tag,c!==f||d!==5&&d!==27&&d!==6)&&(c=null)):(s=null,c=r),s!==c&&(d=zn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Zn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:Et(s),h=c==null?u:Et(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,wt(i)===r&&(d=new d(p,m+`enter`,c,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&c?E(s,c,Xf):null,s!==null&&Zf(o,u,s,d,!1),c!==null&&f!==null&&Zf(o,f,c,d,!0)))}a:{if(s=r?Et(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var _=Sr;else if(gr(s)){if(Cr)_=Mr;else{_=Ar;var v=kr}}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&sn(r.elementType)&&(_=Sr):_=jr;if(_&&=_(e,r)){_r(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?Et(r):window,e){case`focusin`:(gr(v)||v.contentEditable===`true`)&&(Ur=v,Wr=r,Gr=null);break;case`focusout`:Gr=Wr=Ur=null;break;case`mousedown`:Kr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Kr=!1,q(o,n,i);break;case`selectionchange`:if(Hr)break;case`keydown`:case`keyup`:q(o,n,i)}var y;if(ir)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else fr?ur(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(sr&&n.locale!==`ko`&&(fr||b!==`onCompositionStart`?b===`onCompositionEnd`&&fr&&(y=En()):(Cn=i,wn=`value`in Cn?Cn.value:Cn.textContent,fr=!0)),v=Yf(r,b),0<v.length&&(b=new Wn(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=dr(n),y!==null&&(b.data=y)))),(y=or?pr(e,n):mr(e,n))&&(b=Yf(r,`onBeforeInput`),0<b.length&&(v=new Wn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),If(o,e,r,n,i)}Vf(o,t)})}function Jf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Yf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=yn(e,n),i!=null&&r.unshift(Jf(e,i,a)),i=yn(e,t),i!=null&&r.push(Jf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Xf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Zf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=yn(n,a),l!=null&&o.unshift(Jf(n,l,c))):i||(l=yn(n,a),l!=null&&o.push(Jf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Qf=/\r\n?/g,$f=/\u0000|\uFFFD/g;function ep(e){return(typeof e==`string`?e:``+e).replace(Qf,`
10
+ `).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||nn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&nn(e,``+r);else return;break;case`className`:Vt(e,`class`,r);break;case`tabIndex`:Vt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Vt(e,n,r);break;case`style`:on(e,r,o);return;case`data`:if(t!==`object`){Vt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=un(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=un(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=dn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=un(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Bt(e,`popover`,r);break;case`xlinkActuate`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ht(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ht(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ht(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ht(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Bt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=cn.get(n)||n,Bt(e,n,r);else return}Rt=!0}function rp(e,t,n,r,i,o){switch(n){case`style`:on(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)nn(e,r);else if(typeof r==`number`||typeof r==`bigint`)nn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=dn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!jt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),o=n.slice(2,i?n.length-7:void 0),t=e[ht]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,i);break a}Rt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Bt(e,n,r)}return}Rt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:np(e,t,o,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=o=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(a(137,t));break;default:np(e,t,r,d,n,null)}}Zt(e,o,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&$t(e,!!r,n,!0):$t(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),o=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(a(91));break;default:np(e,t,s,c,n,null)}tn(e,r,i,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:np(e,t,u,r,n,null)}return;default:if(sn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Rt=!0),o=m;break;case`name`:m!==f&&(Rt=!0),i=m;break;case`checked`:m!==f&&(Rt=!0),u=m;break;case`defaultChecked`:m!==f&&(Rt=!0),d=m;break;case`value`:m!==f&&(Rt=!0),s=m;break;case`defaultValue`:m!==f&&(Rt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(a(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}Xt(e,s,c,l,u,d,o,i);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||np(e,t,o,null,r,l)}for(i in r)if(o=r[i],l=n[i],r.hasOwnProperty(i)&&(o!=null||l!=null))switch(i){case`value`:o!==l&&(Rt=!0),p=o;break;case`defaultValue`:o!==l&&(Rt=!0),c=o;break;case`multiple`:o!==l&&(Rt=!0),s=o;default:o!==l&&np(e,t,i,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?$t(e,!!n,n?[]:``,!1):$t(e,!!n,t,!0)):$t(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case`value`:i!==o&&(Rt=!0),p=i;break;case`defaultValue`:i!==o&&(Rt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(a(91));break;default:i!==o&&np(e,t,s,i,r,o)}en(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Rt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(a(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(sn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[mt]=r,n[ht]=t,ip(n,e,t),Ot(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[xt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=wt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(a(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[xt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(a(452));return e;case`head`:if(e=t.head,!e)throw Error(a(453));return e;case`body`:if(e=t.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===dn&&(e.onclick=null),Ct(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ct(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=W.d;W.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Tt(e);t!==null&&t.tag===5&&t.type===`form`?Qs(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=Yt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Ot(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+Yt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Yt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Yt(n.imageSizes)+`"]`)):i+=`[href="`+Yt(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[St]=!0,o.onload=o.onerror=function(){kt(o)}),Ot(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Yt(r)+`"][href="`+Yt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Ot(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=Dt(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Ot(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=Dt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Ot(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=Dt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Ot(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=he.current)?Sm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=Dt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var o=Dt(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Lm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=bm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,o)),zm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=Dt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Im(e){return`href="`+Yt(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[St]){r.loading=1;return}}else t=e.createElement(`link`),t[St]=!0,t.onload=t.onerror=kt.bind(null,t),ip(t,`link`,n),Ot(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+Yt(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Yt(n.href)+`"]`);if(r)return t.instance=r,Ot(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ot(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var o=e.querySelector(Lm(i));if(o)return t.state.loading|=4,t.instance=o,Ot(o),o;r=Rm(n),(i=bm.get(i))&&Wm(r,i),o=(e.ownerDocument||e).createElement(`link`),Ot(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(o,`link`,r),t.state.loading|=4,Um(o,n.precedence,e),t.instance=o;case`script`:return o=Bm(n.src),(i=e.querySelector(Vm(o)))?(t.instance=i,Ot(i),i):(r=n,(i=bm.get(o))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Ot(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[xt]||a[mt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ot(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Ot(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:F,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=rt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rt(0),this.hiddenUpdates=rt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=wi(3,null,null,t),e.current=a,a.stateNode=e,t=Ta(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},so(a),e}function fh(e){return e?(e=Si,e):Si}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=lo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=uo(e,r,t),n!==null&&(Nd(n,e,t),fo(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=yi(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=lt(t);var n=yi(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=U.T;U.T=null;var a=W.p;try{W.p=2,xh(e,t,n,r)}finally{W.p=a,U.T=i}}function bh(e,t,n,r){var i=U.T;U.T=null;var a=W.p;try{W.p=8,xh(e,t,n,r)}finally{W.p=a,U.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Tt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ze(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-We(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Me()+500,Df(0,!1))}}break;case 31:case 13:s=yi(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=pn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=wt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ne()){case Pe:return 2;case Fe:return 8;case Ie:case Le:return 32;case Re:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Tt(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=wt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,ft(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,ft(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);fn=r,n.target.dispatchEvent(r),fn=null}else return t=Tt(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Tt(n);a!==null&&(e.splice(t,3),t-=3,Xs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ht]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ht]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(a(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[gt]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=dt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(a(527,Jh,`19.3.1`));W.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(a(188)):(e=Object.keys(e).join(`,`),Error(a(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:U,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{Ve=Xh.inject(Yh),He=Xh}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(a(299));var n=!1,r=``,i=yc,o=bc,c=xc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,o,c,Gh),e[gt]=t.current,Gf(e),new Kh(t)}})),u=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=l()})),d=t(i(),1),f=u(),p=`TRICOT_TOKEN`,m=e=>e?`powershell`:`posix`,h=/^[\w@%+:,./-][\w@%+=:,./-]*$/,g=/[$`\\"!]/,_=/^[\w+:./\\-][\w+=:./\\@-]*$/,v=/['‘’‚‛]/g,y=e=>`'${e.replace(v,e=>e+e)}'`;function b(e,t=`posix`){return t===`powershell`?_.test(e)?e:y(e):h.test(e)?e:g.test(e)?`'${e.replaceAll(`'`,`'\\''`)}'`:`"${e}"`}function x(e,t=`posix`){let n=e.map(e=>b(e,t)).join(` `);return t===`powershell`&&n.startsWith(`'`)?`& ${n}`:n}function S(e,t,n=`posix`){return n===`powershell`?`$env:${e} = ${y(t)}`:`export ${e}=${b(t)}`}function C(e,t,n){let r=e.indexOf(`?`),i=r<0?e:e.slice(0,r),a=[t&&`agent`,n&&`token`].filter(Boolean),o=r<0?[]:e.slice(r+1).split(`&`).filter(e=>e&&!a.includes(e.split(`=`)[0])),s=[t&&`agent=${encodeURIComponent(t)}`,n&&`token=${encodeURIComponent(n)}`],c=[...o,...s].filter(Boolean).join(`&`);return c?`${i}?${c}`:i}function w(e,t=`posix`){return S(p,e,t)}function T(e,{token:t,scope:n=`user`}={}){return[`claude`,`mcp`,`add`,`--scope`,n,`--transport`,`http`,`tricot`,e,...t?[`--header`,`Authorization: Bearer ${t}`]:[]]}function E(e,t={}){return x(T(e,t),t.shell)}function D(e,t,n){return t?[w(t,n),x(e,n)]:[x(e,n)]}function O(e,t){let n=[`codex`,`mcp`,`add`,`tricot`,`--url`,e];return t?[...n,`--bearer-token-env-var`,p]:n}function k(e,t,n){return D(O(e,t),t,n)}function A(e,t){let n=[`pi`,`mcp`,`add`,`tricot`,`--url`,e];return t?[...n,`--bearer-token-env-var`,p]:n}function j(e,t,n){return D(A(e,t),t,n)}var M=3e5;function N(e,t){return{type:`http`,url:e,timeout:M,...t?{headers:{Authorization:`Bearer \${${p}}`}}:{}}}var P=`~/.omp/agent/mcp.json`;function F(e,t){let n=[`gemini`,`mcp`,`add`,`--scope`,`user`,`--transport`,`http`];return t?[...n,`--header`,`Authorization: Bearer \${${p}}`,`tricot`,e]:[...n,`tricot`,e]}function I(e,t,n){return D(F(e,t),t,n)}function L(e,t){let n=[`grok`,`mcp`,`add`,`--scope`,`user`,`--transport`,`http`];return t?[...n,`--header`,`Authorization: Bearer \${${p}}`,`tricot`,e]:[...n,`tricot`,e]}function R(e,t,n){return D(L(e,t),t,n)}var z=`~/.copilot/mcp-config.json`;function B(e,t){let n=[`copilot`,`mcp`,`add`,`--transport`,`http`,`--timeout`,String(M)];return t?[...n,`--header`,`Authorization: Bearer \${${p}}`,`tricot`,e]:[...n,`tricot`,e]}function ee(e,t,n){return D(B(e,t),t,n)}function V(e,t){return{type:`remote`,url:e,timeout:M,...t?{headers:{Authorization:`Bearer {env:${p}}`}}:{}}}var te=`~/.config/opencode/opencode.json`,ne=`~/.config/goose/config.yaml`,re=`%APPDATA%\\Block\\goose\\config\\config.yaml`;function ie(e,t){return{name:`tricot`,type:`streamable_http`,uri:e,enabled:!0,timeout:M/1e3,...t?{env_keys:[p],headers:{Authorization:`Bearer \${${p}}`}}:{}}}var ae=`~/.hermes/config.yaml`;function oe(e,t){return{url:e,timeout:M/1e3,...t?{headers:{Authorization:`Bearer \${${p}}`}}:{}}}var se=`OMP also reads Claude Code's servers. Without an entry of its own named tricot it borrows that one, and shows on the board as "Claude".`;function H(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function U(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function W(e){return e.activity.actors.filter(e=>e.actor.kind===`human`).map(e=>({name:e.actor.name,lastActive:e.at}))}function G(e){return e.length<=2?e.join(` and `):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`}function ce(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} s`;let n=Math.floor(t/60);if(n<10)return t%60?`${n} min ${t%60} s`:`${n} min`;if(n<60)return`${n} min`;let r=Math.floor(n/60);return n%60?`${r} h ${n%60} min`:`${r} h`}var le=/(?:[\w.@~+-]+\/)+[\w.@~+-]+/;function ue(e){let t=le.exec(e);if(!t)return;let n=t.index+t[0].length,r=t.index+t[0].lastIndexOf(`/`)+1,i=e.slice(r,n),a=/.{1,5}(?:\.[\w-]{1,8})?$/.exec(i)[0];return{lead:e.slice(0,t.index),dirs:e.slice(t.index,r),head:i.slice(0,i.length-a.length),tail:a,after:e.slice(n)}}function de(e,t){return e.trim()===t}var fe={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`,ultra:`Ultra`,auto:`Auto`},pe=(...e)=>e.map(e=>({id:e,label:fe[e]??e})),me=/[\u0000-\u001f\u007f-\u009f]/;function he(e){if(me.test(e))return`A model's name can't hold a line break or another control character.`;if(e.startsWith(`-`))return`"${e}" can't be a model's name: it starts with -, so the agent would read it as an option.`;if(e.length>120)return`A model's name is at most 120 characters.`}var ge=(e,t)=>(e.model??``)===(t.model??``)&&(e.effort??``)===(t.effort??``),_e=(e,t)=>e.startsOn?.models.find(e=>e.id===t)?.label??t,ve=(e,t)=>e.startsOn?.levels?.find(e=>e.id===t)?.label??t;function ye(e,t){if(!t.model&&!t.effort)return;let n=t.model?_e(e,t.model):`Default`;return t.effort?`${n} · ${ve(e,t.effort).toLowerCase()}`:n}function be(e,t,n){if(!t)return;let r=ye(e,t)??`its own settings`;return ge(t,n)?`Running on ${r}`:`On ${r} till it restarts`}var K={},xe={id:`claude`,name:`Claude Code`,boardName:`Claude`,command:`claude`,install:{commands:[`curl -fsSL https://claude.ai/install.sh | bash`,`npm install -g @anthropic-ai/claude-code`],windows:[`irm https://claude.ai/install.ps1 | iex`,`winget install Anthropic.ClaudeCode`,`npm install -g @anthropic-ai/claude-code`],more:`https://code.claude.com/docs/en/setup`},cliOrder:1,connect:{how:`command`,words:(e,t)=>T(e,{token:t}),lines:(e,t,n)=>[E(e,{token:t,shell:n})],settings:`~/.claude.json`,readsToken:!1,remove:[`claude`,`mcp`,`remove`,`tricot`],list:`claude mcp list`,get:[`claude`,`mcp`,`get`,`tricot`]},panel:{intro:[`Run once in a terminal; Claude Code then has the board in every session.`]},usage:{shares:`plan`,source:`claude-statusline`,listPrices:!0,quiet:(e,t)=>t?`Claude Code shares its plan limits on Pro and Max plans, after a session’s first reply.`:`No usage from Claude yet. Claude Code shares it after a session’s first reply, on Pro and Max plans.`},startsOn:{models:[{id:`opus`,label:`Opus`},{id:`sonnet`,label:`Sonnet`},{id:`haiku`,label:`Haiku`},{id:`fable`,label:`Fable`}],levels:pe(`low`,`medium`,`high`,`xhigh`,`max`)},perMessage:{via:`subagent`,models:[`opus`,`sonnet`,`haiku`,`fable`]},skills:`skills`,approvals:!0,...K},Se={id:`codex`,name:`Codex`,boardName:`Codex`,command:`codex`,install:{commands:[`npm install -g @openai/codex`,`curl -fsSL https://chatgpt.com/codex/install.sh | sh`],windows:[`powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"`,`npm install -g @openai/codex`],more:`https://github.com/openai/codex`},cliOrder:2,connect:{how:`command`,words:O,lines:k,settings:`~/.codex/config.toml`,readsToken:!0,remove:[`codex`,`mcp`,`remove`,`tricot`],list:`codex mcp list`,get:[`codex`,`mcp`,`get`,`tricot`]},panel:{intro:[`Run once in a terminal; Codex then has the board in every session.`],note:[`Codex asks before each board tool unless you approve them for this server in its settings. It shows on the board as “Codex”.`]},usage:{shares:`plan`,source:`codex-rollout`,quiet:(e,t)=>t?void 0:`No usage from ${e} yet: it comes at the end of its next turn.`},startsOn:{models:[`gpt-6.1-sol`,`gpt-6.1-terra`,`gpt-6-astra`,`gpt-6-luna`].map(e=>({id:e,label:e})),levels:pe(`low`,`medium`,`high`,`xhigh`,`max`,`ultra`)},skills:`prompts`,approvals:!0,...K},Ce={id:`copilot`,name:`Copilot CLI`,boardName:`Copilot`,command:`copilot`,install:{commands:[`npm install -g @github/copilot`,`brew install --cask copilot-cli`,`curl -fsSL https://gh.io/copilot-install | bash`],windows:[`winget install GitHub.Copilot`,`npm install -g @github/copilot`],more:`https://docs.github.com/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli`},connect:{how:`command`,words:B,lines:ee,settings:z,readsToken:!0,remove:[`copilot`,`mcp`,`remove`,`tricot`],list:`copilot mcp list`,get:[`copilot`,`mcp`,`get`,`tricot`]},panel:{intro:[`Run once in a terminal; Copilot CLI then has the board in every session.`],note:[`Copilot CLI asks before each board tool unless you allow them: `,{code:`copilot --allow-tool=tricot`},` allows them all. It shows on the board as “Copilot”.`]},usage:{shares:`none`,notShared:`Copilot keeps its usage to itself: see /usage in Copilot.`},startsOn:{models:[{id:`auto`,label:`Auto`},...[`claude-sonnet-5.5`,`claude-opus-5.5`,`claude-haiku-5.5`,`gpt-6.1-sol`,`gpt-6.1-terra`,`gpt-6-astra`,`gpt-6-luna`,`gpt-5.3-codex`,`gemini-3.8-flash`].map(e=>({id:e,label:e}))],levels:pe(`low`,`medium`,`high`,`xhigh`,`max`)},skills:`skills`,...K},we=/^[A-Za-z][\w-]*$/,Te=new Set([`true`,`false`,`null`,`yes`,`no`,`on`,`off`,`y`,`n`]),Ee=e=>typeof e==`object`&&!!e;function De(e){if(typeof e==`string`)return we.test(e)&&!Te.has(e.toLowerCase())?e:JSON.stringify(e);if(typeof e==`number`&&!Number.isFinite(e))throw Error(`YAML has no text for a number that is not finite.`);return e==null?`null`:String(e)}var Oe=e=>we.test(e)&&!Te.has(e.toLowerCase())?e:JSON.stringify(e),ke=e=>Array.isArray(e)?e.length===0:Object.values(e).every(e=>e===void 0);function Ae(e,t){let n=` `.repeat(t);return Array.isArray(e)?e.flatMap(e=>{if(!Ee(e)||ke(e))return[`${n}- ${je(e)}`];let[r,...i]=Ae(e,t+2);return[`${n}- ${r.slice(t+2)}`,...i]}):Object.entries(e).flatMap(([e,r])=>r===void 0?[]:!Ee(r)||ke(r)?[`${n}${Oe(e)}: ${je(r)}`]:[`${n}${Oe(e)}:`,...Ae(r,t+2)])}function je(e){return Ee(e)?Array.isArray(e)?`[]`:`{}`:De(e)}function Me(e){return Ee(e)&&!ke(e)?Ae(e,0).join(`
11
+ `):je(e)}function Ne(e,t){let n={[e.section]:{[e.name]:t}};return`${e.format===`json`?JSON.stringify(n,null,2):Pe(n).join(`
12
+ `)}\n`}var Pe=e=>Me(e).split(`
13
+ `),Fe=`tricot`;function Ie(e){let t={format:e.format,section:e.section,name:Fe};return{how:`file`,...e,entry:(n,r)=>Ne(t,e.value(n,r)).trimEnd()}}var Le={id:`cursor`,name:`Cursor`,boardName:`Cursor`,command:`cursor`,install:{commands:[],more:`https://cursor.com/downloads`},cantStart:`Tricot connects Cursor through its shared settings; starting a Cursor session is not implemented`,connect:Ie({file:`~/.cursor/mcp.json`,format:`json`,section:`mcpServers`,value:(e,t)=>({url:e,...t?{headers:{Authorization:`Bearer \${env:${p}}`}}:{}})}),panel:{intro:[`Add this to `,{code:`~/.cursor/mcp.json`},` (merge into `,{code:`mcpServers`},` if it exists), or `,{code:`.cursor/mcp.json`},` in a project. Cursor editor and CLI share this configuration.`],note:[`Enable or approve Tricot in Cursor if prompted; in the CLI use `,{code:`agent mcp enable tricot`},`. For a token-protected board, set TRICOT_TOKEN in the environment Cursor runs from. It shows on the board as “Cursor”. Tricot does not yet support Cursor live steps or usage reporting.`]},usage:{shares:`none`,notShared:`Cursor usage is not reported to Tricot.`},skills:`skills`,liveSteps:!1,...K},Re={id:`gemini`,name:`Gemini CLI`,boardName:`Gemini`,command:`gemini`,install:{commands:[`npm install -g @google/gemini-cli`,`brew install gemini-cli`],more:`https://github.com/google-gemini/gemini-cli`},cantStart:`it adds a server only from a settings file`,cliOrder:4,connect:{how:`command`,words:F,lines:I,settings:`~/.gemini/settings.json`,readsToken:!0,remove:[`gemini`,`mcp`,`remove`,`--scope`,`user`,`tricot`],list:`gemini mcp list`},panel:{intro:[`Run once in a terminal; Gemini CLI then has the board in every session.`],note:[`Without `,{code:`--scope user`},` it would be for one project. Gemini CLI asks before each board tool unless you add `,{code:`--trust`},`. It shows on the board as “Gemini”.`]},usage:{shares:`none`,notShared:`Gemini keeps its quota to itself: see /stats in Gemini.`},startsOn:{models:[{id:`auto`,label:`Auto`},...[`gemini-2.5-pro`,`gemini-3.5-flash`,`gemini-3.1-flash-lite`].map(e=>({id:e,label:e}))]},skills:`skills and commands`,...K},ze={id:`goose`,name:`Goose`,boardName:`Goose`,command:`goose`,install:{commands:[`curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash`,`brew install block-goose-cli`],windows:[`Invoke-WebRequest -Uri "https://raw.githubusercontent.com/aaif-goose/goose/main/download_cli.ps1" -OutFile "download_cli.ps1"; .\\download_cli.ps1`],more:`https://goose-docs.ai/docs/getting-started/installation`},cliOrder:7,cantStart:`its flag for one session names the server after the board's address and can't send the board's token`,connect:Ie({file:ne,format:`yaml`,section:`extensions`,value:ie,agentWrites:!0}),panel:{intro:[`Goose has no command for this: `,{code:`goose configure`},` only asks questions. Add the entry under `,{code:`extensions`},` in `,{code:ne},` (merge it in if the file exists; on Windows the file is `,{code:re},`). Goose Desktop reads the same file.`],note:[`It shows on the board as “Goose”.`],firstRunBlock:!0},usage:{shares:`none`,notShared:`Goose keeps its usage to itself: it can show its cost in its own session (GOOSE_CLI_SHOW_COST).`},skills:`skills`,...K},Be={id:`grok`,name:`Grok Build`,boardName:`Grok`,command:`grok`,install:{commands:[`curl -fsSL https://x.ai/cli/install.sh | bash`],windows:[`irm https://x.ai/cli/install.ps1 | iex`],more:`https://x.ai/cli`},cantStart:`it adds a server only from a config file`,connect:{how:`command`,words:L,lines:R,settings:`~/.grok/config.toml`,readsToken:!0,remove:[`grok`,`mcp`,`remove`,`--scope`,`user`,`tricot`],list:`grok mcp list`},panel:{intro:[`Run once in a terminal; Grok Build then has the board in every session.`],note:[`With `,{code:`--scope project`},` instead it is kept to one project, in its `,{code:`.grok/config.toml`},`. It shows on the board as “Grok”.`]},usage:{shares:`none`,notShared:`Grok keeps its usage allowance to itself: see /usage in Grok.`},startsOn:{models:[]},skills:`skills`,...K},Ve={id:`hermes`,name:`Hermes Agent`,boardName:`Hermes`,command:`hermes`,install:{commands:[`curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash`],windows:[`iex (irm https://hermes-agent.nousresearch.com/install.ps1)`],more:`https://hermes-agent.nousresearch.com/docs/getting-started/installation`},cliOrder:8,cantStart:`it adds a server only to its config file`,connect:Ie({file:ae,format:`yaml`,section:`mcp_servers`,value:oe,agentWrites:!0}),panel:{intro:[`Hermes has no command for this that Tricot can run: `,{code:`hermes mcp add`},` connects, then asks questions. Add the entry under `,{code:`mcp_servers`},` in `,{code:ae},` (merge it in if the file exists).`],note:[`It shows on the board as “Hermes”. In a session that is already open, `,{code:`/reload-mcp`},` loads it.`],firstRunBlock:!0},usage:{shares:`none`,notShared:`Hermes keeps its usage to itself: see /usage in Hermes.`},startsOn:{models:[]},skills:`skills`,...K},He={id:`omp`,name:`OMP`,boardName:`OMP`,command:`omp`,install:{commands:[`curl -fsSL https://omp.sh/install | sh -s -- --binary`],windows:[`irm https://omp.sh/install.ps1 | iex`],more:`https://github.com/can1357/oh-my-pi`},cliOrder:6,connect:Ie({file:P,format:`json`,section:`mcpServers`,value:N}),panel:{intro:[`OMP has no command for this. Add the entry to `,{code:P},` (merge it into `,{code:`mcpServers`},` if the file exists), or to `,{code:`.omp/mcp.json`},` for one project.`],note:[se],firstRunBlock:!0},usage:{shares:`tokens`,source:`omp`},startsOn:{models:[{id:`opus`,label:`Opus`},{id:`sonnet`,label:`Sonnet`},{id:`haiku`,label:`Haiku`},{id:`fable`,label:`Fable`}],levels:pe(`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`auto`)},skills:`skills`,...K},Ue={id:`opencode`,name:`OpenCode`,boardName:`OpenCode`,command:`opencode`,install:{commands:[`curl -fsSL https://opencode.ai/install | bash`,`npm install -g opencode-ai`],windows:[`npm install -g opencode-ai`,`scoop install opencode`,`choco install opencode`],more:`https://opencode.ai/docs/`},cliOrder:3,connect:Ie({file:te,format:`json`,section:`mcp`,value:V}),panel:{intro:[`Add the entry to `,{code:te},` (merge it into `,{code:`mcp`},` if the file exists), or to `,{code:`opencode.json`},` in a project. OpenCode 1 and 2 both read it.`],note:[`OpenCode 1 adds a server only by asking questions; `,{code:`tricot connect opencode`},` also prints OpenCode 2's one-line command. It shows on the board as “OpenCode”.`]},usage:{shares:`tokens`,source:`opencode`},startsOn:{models:[]},skills:`skills and commands`,...K},We={id:`pi`,name:`Pi`,boardName:`Pi`,command:`pi`,install:{commands:[`curl -fsSL https://pi.dev/install.sh | sh`,`npm install -g --ignore-scripts @earendil-works/pi-coding-agent`],windows:[`powershell -c "irm https://pi.dev/install.ps1 | iex"`,`npm install -g --ignore-scripts @earendil-works/pi-coding-agent`],more:`https://pi.dev/docs/latest/quickstart`},cliOrder:5,connect:{how:`command`,words:A,lines:j,settings:`~/.pi/agent/mcp.json`,readsToken:!0,remove:[`pi`,`mcp`,`remove`,`tricot`],list:`pi mcp list`},panel:{intro:[`Run once in a terminal; Pi then has the board in every session.`],note:[`Pi reaches the board's tools through its codemode tool. Add `,{code:`--exposure direct`},` to list them to the model instead. It shows on the board as “Pi”.`]},usage:{shares:`tokens`,source:`pi`},startsOn:{models:[{id:`opus`,label:`Opus`},{id:`sonnet`,label:`Sonnet`},{id:`haiku`,label:`Haiku`},{id:`fable`,label:`Fable`}],levels:pe(`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`)},skills:`skills`,...K},Ge=()=>[xe,Se,We,He,Re,Ue,ze,Ve,Be,Ce,Le],Ke;function qe(){return Ke??=Ge()}function Je(e){return qe().find(t=>t.id===e)}var Ye=()=>qe()[0];function Xe(e){return(e.tool?Je(e.tool):void 0)??qe().find(t=>U(t.boardName,e.name))}var Ze=e=>qe().find(t=>t.usage.source===e),Qe=`other`;function $e(e,t){let n={[Qe]:e};for(let{id:r,boardName:i,connect:a}of qe()){let o=C(e,i);n[r]=a.how===`command`?a.lines(o,void 0,t).join(`
14
+ `):a.entry(o)}return n}var et=1e3,tt=1e3,nt=(e,t)=>typeof e==`string`&&e.trim()!==``&&e.length<=t,rt=(e,t)=>{if(e===void 0)return{};if(!(typeof e!=`string`||e.length>t))return e.trim()?{words:e.trim()}:{}};function it(e){let t=ut(e),n=rt(t.description,et);if(nt(t.label,120)&&n)return{label:t.label,...n.words&&{description:n.words}}}function at(e){let t=ut(e),n=rt(t.header,60);if(!nt(t.question,1e3)||!n||!Array.isArray(t.options)||t.options.length===0||t.options.length>8||t.multiSelect!==void 0&&typeof t.multiSelect!=`boolean`)return;let r=t.options.map(it);if(!(r.some(e=>!e)||new Set(r.map(e=>e.label)).size!==r.length))return{question:t.question,...n.words&&{header:n.words},multiSelect:t.multiSelect===!0,options:r}}function ot(e){let{questions:t}=ut(e);if(!Array.isArray(t)||t.length===0||t.length>4)return;let n=t.map(at);if(!(n.some(e=>!e)||new Set(n.map(e=>e.question)).size!==n.length))return n}function st(e){if(!e.sealed&&e.canAnswer&&e.harness===`claude`&&e.tool===`AskUserQuestion`)return ot(e.input)}var ct=e=>e.join(`, `);function lt(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}var ut=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:{},dt=e=>typeof e==`string`&&e!==``?e:void 0;function ft(e,t){let n=dt(e.file_path)??dt(e.notebook_path)??dt(e.path);if(!n)return;let r=t?.replace(/[\\/]+$/,``);return r&&n.startsWith(`${r}/`)?n.slice(r.length+1):n}var pt=new Set([`Bash`,`shell`,`exec_command`,`local_shell`,`unified_exec`]);function mt(e,t){if(!pt.has(e))return;let n=t.command??t.cmd;return Array.isArray(n)&&n.every(e=>typeof e==`string`)?n.join(` `):dt(n)}function ht(e){if(e.sealed)return`Let this browser act for you to see what it asks`;let t=ut(e.input),n=ft(t,e.cwd),r=e.cwd?` in ${lt(e.cwd)}`:``,i=/^mcp__(.+?)__(.+)$/.exec(e.tool);if(e.tool===`AskUserQuestion`){let t=ot(e.input)?.length??1;return t===1?`Ask you a question`:`Ask you ${t} questions`}if(i)return`Use ${i[1]}: ${i[2].replace(/_/g,` `)}`;if(mt(e.tool,t)!==void 0||pt.has(e.tool))return`Run a command${r}`;switch(e.tool){case`Edit`:case`MultiEdit`:case`NotebookEdit`:return n?`Edit ${n}`:`Edit a file${r}`;case`Write`:return n?`Write ${n}`:`Write a file${r}`;case`apply_patch`:return`Change files${r}`;case`Read`:return n?`Read ${n}`:`Read a file${r}`;case`WebFetch`:return`Fetch a web page`;case`WebSearch`:return`Search the web`;default:return`Use ${e.tool.replace(/_/g,` `)}`}}function gt(e){if(e.sealed)return{text:``,more:[]};let t=ut(e.input),n=mt(e.tool,t);if(n!==void 0)return{text:n,more:Object.entries(t).filter(([e])=>e!==`command`&&e!==`cmd`&&e!==`description`).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`)};if(e.tool===`apply_patch`){let e=dt(t.command)??dt(t.patch)??dt(t.input);if(e!==void 0)return{text:e,more:[]}}let r;try{r=JSON.stringify(e.input,null,2)??String(e.input)}catch{r=String(e.input)}return{text:r,more:[]}}var _t=e=>`${e.agent}${e.role?` (${e.role} subagent)`:``} ${st(e)?`asks you`:`is waiting for your OK`}`;function vt(e){let t=[...new Set(e)];return t.length===0?``:t.length>2?`⏸ ${t.length} agents need you`:`⏸ ${G(t)} need${t.length===1?`s`:``} you`}var yt=(e,t)=>e.filter(e=>e.board===void 0||e.board===t);function bt(e){let t=[...new Set(e.map(e=>e.agent))];if(t.length!==0)return t.length>2?`${t.length} agents are waiting for your OK.`:`${G(t)} ${t.length===1?`is`:`are`} waiting for your OK.`}function xt(e){if(e.sealed)return{title:`${e.agent} needs your OK`,body:`Let this browser act for you to see what it asks, and answer.`};let t=st(e);return{title:`${e.agent} needs your OK`,body:H(`${ht(e)}: ${t?t.map(e=>e.question).join(` `):gt(e).text}`,180)}}var St=class{kind;card;constructor(e,t){this.kind=e,this.card=t}get id(){return this.card.id}get number(){return this.kind.number(this.card)}get title(){return this.kind.title(this.card)}get comments(){return this.kind.comments(this.card)}get canvas(){return this.kind.canvas(this.card)}get status(){return this.kind.status?.(this.card)}get statusWords(){return this.kind.statusWords?.(this.card)??this.status}get fromThread(){return this.kind.fromThread?.(this.card)}get createdBy(){return this.kind.createdBy?.(this.card)}get heading(){return this.kind.heading?.(this.card)}get workedBy(){return this.kind.workedBy?.(this.card)}get followedBy(){return this.kind.followedBy?.(this.card)}get inBacklog(){return this.kind.backlog?.(this.card)??!1}setFromThread(e){this.kind.setFromThread?.(this.card,e)}blockNote(e){return this.kind.blockNote?.(this.card,e)}get label(){return`${this.kind.mark}${this.number}`}get named(){return this.kind.named?.(this.card)??`${this.label} "${H(this.title)}"`}get statusWord(){return this.kind.statusWord?.(this.card)??this.status}get settled(){return this.kind.settled?.(this.card)??!1}get options(){return this.kind.options?.(this.card)}get reactionAbout(){return this.kind.reactionAbout?.(this.card)??{[this.kind.kind]:this.id}}get link(){return Nt({kind:this.kind.kind,id:this.id})}},Ct=[],wt=()=>Ct,Tt=e=>Ct.find(t=>t.kind===e),Et=(e,t)=>e[t.list]??[];function Dt(e,t){let n=Tt(t);return n?Et(e,n).map(e=>new St(n,e)):[]}function Ot(e){return Ct.flatMap(t=>Et(e,t).map(e=>new St(t,e)))}function kt(e,t,n){let r=Tt(t),i=r&&Et(e,r).find(e=>e.id===n);return r&&i?new St(r,i):void 0}function At(e,t){for(let n of Ct){let r=Et(e,n).find(e=>e.id===t);if(r)return new St(n,r)}}function jt(e,t){let n=t;for(let t of Ct){let r=n[`${t.kind}Id`];if(typeof r==`string`&&r)return kt(e,t.kind,r)}}function Mt(e){let t=e;return wt().flatMap(({kind:e})=>{let n=t[`${e}Id`];return typeof n==`string`&&n?[{kind:e,id:n}]:[]})}var Nt=({kind:e,id:t})=>({[`${e}Id`]:t}),Pt=e=>Mt(e);function Ft(e){let t=e;for(let e of Ct){let n=t[e.kind];if(n)return new St(e,n)}}var It=e=>Pt(e)[0];function Lt(e,t){let n=e[`${t}Id`];return typeof n==`string`&&n?n:void 0}function Rt(e,t,n){for(let{kind:r,id:i}of Pt(e)){let e=kt(t,r,i),a=e?.comments.find(n);if(e&&a)return{card:e,comment:a}}}var zt=[`bar`,`line`,`area`,`stacked-bar`,`pie`],Bt={bar:`Bar`,line:`Line`,area:`Area`,"stacked-bar":`Stacked bar`,pie:`Pie`},Vt=/^([+\-−]?)\s*([$€£¥₹]?)\s*(\d{1,3}(?:,\d{3})+|\d+)?(\.\d+)?\s*(%?)$/;function Ht(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;let t=String(e??``).replace(/[  ]/g,` `).trim();if(!t)return null;let n=Vt.exec(t);if(!n||!n[3]&&!n[4])return;let r=Number(`${(n[3]??`0`).replace(/,/g,``)}${n[4]??``}`);return n[1]===`-`||n[1]===`−`?-r:r}var Ut=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();function Wt(e){let t=e.rows.map(e=>e[0]??``),n=e.columns.slice(1).map((t,n)=>({name:t,values:e.rows.map(e=>Ht(e[n+1]??``)??null)}));return{kind:e.kind,categories:t,series:n,unit:e.unit,highlight:e.highlight?t.indexOf(e.highlight):-1}}var Gt=`−`,Kt=/^[$€£¥₹]$/;function qt(e){return e?Kt.test(e)?`prefix`:e===`%`||e===`‰`||e===`°`?`tight`:e.length<=3?`spaced`:`caption`:`none`}function Jt(e,t=!1){let n=Math.abs(e),r=t&&n>=1e3?new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:2}).format(n):new Intl.NumberFormat(`en-US`,{maximumFractionDigits:n>=100?1:2}).format(n);return e<0&&r!==`0`?`${Gt}${r}`:r}function Yt(e,t,n){let r=qt(t);return r===`none`||r===`caption`&&!n?e:r===`prefix`?e.startsWith(Gt)?`${Gt}${t}${e.slice(1)}`:`${t}${e}`:r===`tight`?`${e}${t}`:`${e} ${t}`}function Xt(e,t){return e===null?`no value`:Yt(Jt(e),t,!0)}function Zt(e,t){return Yt(Jt(e,!0),t,!1)}function Qt(e){let t=e*100;return`${t>0&&t<1?`<1`:Jt(Math.round(t*(t<10?10:1))/(t<10?10:1))}%`}function $t(e,t,n=5,r=!1){if(!Number.isFinite(e)||!Number.isFinite(t))return[0,1];e>t&&([e,t]=[t,e]),e===t&&(e===0?t=1:e>0?e=0:t=0);let i=(t-e)/Math.max(1,n),a=10**Math.floor(Math.log10(i)),o=i/a,s=(o<=1?1:o<=2?2:o<=2.5?2.5:o<=5?5:10)*a;r&&(s=s<1?1:s===2.5?2:s);let c=Math.max(0,-Math.floor(Math.log10(s))+1),l=e=>Number(e.toFixed(c))||0,u=Math.floor(e/s+1e-9),d=Math.ceil(t/s-1e-9),f=[];for(let e=u;e<=d;e++)f.push(l(e*s));return f}function en(e){let t=e.series.flatMap(e=>e.values).filter(e=>e!==null);if(e.kind===`stacked-bar`){let t=e.categories.map((t,n)=>e.series.reduce((e,t)=>e+Math.max(0,t.values[n]??0),0));return{min:0,max:Math.max(0,...t)}}if(t.length===0)return{min:0,max:1};let n=Math.min(...t),r=Math.max(...t);return e.kind===`line`&&n>0&&n>r*.5||e.kind===`line`&&r<0&&r<n*.5?{min:n,max:r}:{min:Math.min(0,n),max:Math.max(0,r)}}var tn=11,nn=13,rn=24,an=2,on=4;function sn(e,t=tn){let n=0;for(let t of e)n+=/[A-Z%@MW]/.test(t)?.68:/[il.,:;'|!\s]/.test(t)?.3:.56;return n*t}function cn(e,t,n=tn){if(sn(e,n)<=t)return e;for(let r=Math.min(e.length-1,Math.ceil(t/(n*.3)));r>=3;r--){let i=`${e.slice(0,r).trimEnd()}…`;if(sn(i,n)<=t)return i}return null}var ln=e=>Math.round(e*10)/10;function un(e,t,n,r,i){let a=Math.max(0,Math.min(on,n/2,r));return a===0||r<=0?`M${ln(e)} ${ln(t)}h${ln(n)}v${ln(r)}h${ln(-n)}Z`:i?`M${ln(e)} ${ln(t+r)}V${ln(t+a)}A${ln(a)} ${ln(a)} 0 0 1 ${ln(e+a)} ${ln(t)}H${ln(e+n-a)}A${ln(a)} ${ln(a)} 0 0 1 ${ln(e+n)} ${ln(t+a)}V${ln(t+r)}Z`:`M${ln(e)} ${ln(t)}V${ln(t+r-a)}A${ln(a)} ${ln(a)} 0 0 0 ${ln(e+a)} ${ln(t+r)}H${ln(e+n-a)}A${ln(a)} ${ln(a)} 0 0 0 ${ln(e+n)} ${ln(t+r-a)}V${ln(t)}Z`}function dn(e,t){return{width:e,height:t,plot:{x:0,y:0,w:e,h:t},zero:t,ticks:[],axis:[],bands:[],bars:[],lines:[],slices:[],labels:[],markers:[],barWidth:0}}function fn(e,t){let n=Math.max(0,Math.floor(t.width)),r=Math.max(0,Math.floor(t.height));return n<80||r<60||e.categories.length===0?dn(n,r):e.kind===`pie`?yn(e,n,r):mn(e,n,r)}function pn(e,t){if(e.highlight>=0)return e.highlight;let n=-1;return t.forEach((e,r)=>{Number.isFinite(e)&&(n===-1||e>t[n])&&(n=r)}),n}function mn(e,t,n){let{categories:r,series:i,unit:a,kind:o}=e,s=r.length,c=o===`line`||o===`area`,l=qt(a),u=l===`caption`?30:16,d=Math.max(20,n-u-24),f=en(e),p=i.every(e=>e.values.every(e=>e===null||Number.isInteger(e))),m=$t(f.min,f.max,Math.max(2,Math.min(6,Math.round(d/44))),p);m.length>3&&f.max>0&&m.at(-1)-f.max>(m[1]-m[0])*.6&&(m=m.slice(0,-1));let h=m[0],g=Math.max(m.at(-1),f.max),_=m.map(e=>Zt(e,a)),v=Math.ceil(Math.max(16,..._.map(e=>sn(e)))+10),y=[];c&&i.length<=4&&i.forEach((e,t)=>{let n=e.values.findLastIndex(e=>e!==null);if(n===-1)return;let r=Zt(e.values[n],a);y.push({series:t,point:n,text:i.length===1?r:`${e.name} ${r}`})});let b=y.length?Math.max(...y.map(e=>sn(e.text)))+24:0,x=y.length>0&&t-v-b>=t*.55,S=x?Math.ceil(b):12,C={x:v,y:u,w:Math.max(20,t-v-S),h:d},w=e=>C.y+C.h-(e-h)/(g-h||1)*C.h,T={width:t,height:n,plot:C,zero:w(Math.min(g,Math.max(h,0))),ticks:m.map((e,t)=>({value:e,y:w(e),label:_[t]})),...l===`caption`?{caption:{x:0,y:u-18,text:a}}:{},axis:[],bands:[],bars:[],lines:[],slices:[],labels:[],markers:[],barWidth:0},E=C.w/s,D=c?Math.min(14,C.w/10):0,O=c?s>1?(C.w-2*D)/(s-1):0:E,k=e=>c?s>1?C.x+D+e*O:C.x+C.w/2:C.x+E*(e+.5);return T.bands=r.map((e,t)=>{if(!c)return{category:t,x:C.x+E*t,w:E,cx:k(t)};let n=t===0?C.x:(k(t-1)+k(t))/2;return{category:t,x:n,w:(t===s-1?C.x+C.w:(k(t)+k(t+1))/2)-n,cx:k(t)}}),T.axis=hn(r,k,c&&s>1?O:E,t),c?_n(e,T,k,w,x?y:[]):gn(e,T,E,w),T}function hn(e,t,n,r){let i=e.length,a=Math.max(...e.map(e=>sn(e))),o=1;for(;o<i&&o*n<Math.min(a,84)+8;)o++;let s=Math.max(24,o*n-8),c=[];for(let n=0;n<i;n+=o){let i=cn(e[n],s);if(!i)continue;let a=sn(i)/2,o=t(n);o-a<2?c.push({category:n,x:2,text:i,anchor:`start`}):o+a>r-2?c.push({category:n,x:r-2,text:i,anchor:`end`}):c.push({category:n,x:o,text:i,anchor:`middle`})}return c}function gn(e,t,n,r){let{categories:i,series:a,unit:o,kind:s}=e,{plot:c,zero:l}=t,u=s===`stacked-bar`,d=u?1:a.length,f=n*.72,p=an,m=Math.min(rn,(f-(d-1)*p)/d);m<3&&(p=+(f/d>=3),m=Math.max(1,(f-(d-1)*p)/d)),t.barWidth=m;let h=d*m+(d-1)*p,g=i.map((e,t)=>u?a.reduce((e,n)=>e+(n.values[t]??0),0):Math.max(...a.map(e=>e.values[t]??-1/0)));i.forEach((e,i)=>{let o=c.x+n*i+(n-h)/2;if(u){let e=a.map((e,t)=>({series:t,value:e.values[i]??0})).filter(e=>e.value>0),s=0;e.forEach((a,l)=>{let u=r(s);s+=a.value;let d=r(s),f=l===e.length-1,p=l>0&&u-d>3?u-an:u,h=Math.max(.5,p-d),g=f?c.y:d-an/2,_=l===0?u+2:u+an/2,v={x:c.x+n*i,y:g,w:n,h:Math.max(8,_-g)};v.h===8&&_-g<8&&(v.y=(g+_)/2-4),t.bars.push({category:i,series:a.series,value:a.value,x:o,y:d,w:m,h,end:d,path:f?un(o,d,m,h,!0):`M${ln(o)} ${ln(d)}h${ln(m)}v${ln(h)}h${ln(-m)}Z`,hit:v})})}else a.forEach((e,a)=>{let s=e.values[i];if(s===null)return;let u=o+a*(m+p),f=r(s),h=s>=0,g=Math.min(l,f),_=Math.abs(f-l),v={y:Math.max(0,c.y-14),h:c.h+Math.min(c.y,14)+4},y=d===1?{x:c.x+n*i,w:n,...v}:{x:u-p/2,w:m+p,...v};t.bars.push({category:i,series:a,value:s,x:u,y:g,w:m,h:_,end:f,path:un(u,g,m,_,h),hit:y})})});let _=pn(e,g);if(_<0)return;let v=t.bars.filter(e=>e.category===_);if(v.length===0)return;let y=u?g[_]:Math.max(...v.map(e=>e.value)),b=u?v.at(-1):v.find(e=>e.value===y),x=!u&&y<0,S=Zt(y,o),C=Math.min(t.width-sn(S)/2-2,Math.max(sn(S)/2+2,u?b.x+m/2:b.x+b.w/2)),w=x?b.y+b.h+13:b.end-6;t.labels.push({x:C,y:Math.max(11,w),text:S,anchor:`middle`,strong:!0,series:u?void 0:b.series})}function _n(e,t,n,r,i){let{series:a,unit:o,kind:s}=e,{plot:c}=t,l=t.zero;for(let[e,i]of a.entries()){let a=[],o=[],c=[];i.values.forEach((e,t)=>{if(e===null){c.length&&o.push(c),c=[];return}let i={category:t,x:n(t),y:r(e),value:e};a.push(i),c.push(i)}),c.length&&o.push(c);let u=o.filter(e=>e.length>1).map(e=>e.map((e,t)=>`${t?`L`:`M`}${ln(e.x)} ${ln(e.y)}`).join(``)).join(``),d=s===`area`?o.filter(e=>e.length>1).map(e=>`${e.map((e,t)=>`${t?`L`:`M`}${ln(e.x)} ${ln(e.y)}`).join(``)}L${ln(e.at(-1).x)} ${ln(l)}L${ln(e[0].x)} ${ln(l)}Z`).join(``):void 0;t.lines.push({series:e,points:a,path:u,...d===void 0?{}:{area:d},lone:o.filter(e=>e.length===1).map(e=>e[0])})}let u=i.map(e=>{let n=t.lines[e.series].points.find(t=>t.category===e.point);return{end:e,point:n,y:n.y+4}}).sort((e,t)=>e.y-t.y);for(let e=1;e<u.length;e++)u[e].y=Math.max(u[e].y,u[e-1].y+nn);let d=u.length?u.at(-1).y-(c.y+c.h+4):0;if(d>0)for(let e of u)e.y-=d;for(let e=u.length-2;e>=0;e--)u[e].y=Math.min(u[e].y,u[e+1].y-nn);let f=e=>Math.abs(e.y-4-e.point.y)>2,p=u.some(f)?18:9;for(let e of u){let n=e.point.x+p;t.markers.push({series:e.end.series,x:e.point.x,y:e.point.y}),t.labels.push({x:n,y:e.y,text:e.end.text,anchor:`start`,series:e.end.series,...f(e)?{leader:{x1:e.point.x+6,y1:e.point.y,x2:n-3,y2:e.y-4}}:{}})}if(a.length!==1){if(e.highlight<0)return;for(let n of t.lines){let r=n.points.find(t=>t.category===e.highlight);r&&t.markers.push({series:n.series,x:r.x,y:r.y})}return}let m=pn(e,a[0].values.map(e=>e??-1/0)),h=t.lines[0].points.find(e=>e.category===m);if(!h||i.some(e=>e.point===m))return;let g=Zt(h.value,o),_=sn(g)/2;t.markers.push({series:0,x:h.x,y:h.y}),t.labels.push({x:Math.min(t.width-_-2,Math.max(_+2,h.x)),y:Math.max(11,h.y-9),text:g,anchor:`middle`,strong:!0,series:0})}function vn(e,t,n,r,i,a){let o=a-i>=Math.PI*2-1e-6,s=(n,r)=>`${ln(e+n*Math.cos(r))} ${ln(t+n*Math.sin(r))}`;if(o){let e=i+Math.PI;return`M${s(n,i)}A${ln(n)} ${ln(n)} 0 1 1 ${s(n,e)}A${ln(n)} ${ln(n)} 0 1 1 ${s(n,i)}ZM${s(r,i)}A${ln(r)} ${ln(r)} 0 1 0 ${s(r,e)}A${ln(r)} ${ln(r)} 0 1 0 ${s(r,i)}Z`}let c=+(a-i>Math.PI);return`M${s(n,i)}A${ln(n)} ${ln(n)} 0 ${c} 1 ${s(n,a)}L${s(r,a)}A${ln(r)} ${ln(r)} 0 ${c} 0 ${s(r,i)}Z`}function yn(e,t,n){let r=e.series[0]?.values??[],i=r.reduce((e,t)=>e+Math.max(0,t??0),0),a=dn(t,n);if(i<=0)return a;let o=t/2,s=n/2,c=Math.max(24,Math.min(t/2-56,n/2-22)),l=c*.6,u=-Math.PI/2;r.forEach((e,t)=>{if(!e||e<=0)return;let n=e/i*Math.PI*2,r=u,d=u+n;u=d;let f=(r+d)/2,p=(c+l)/2;a.slices.push({category:t,value:e,share:e/i,path:vn(o,s,c,l,r,d),hit:vn(o,s,c+6,Math.max(0,l-6),r,d),mid:{x:o+p*Math.cos(f),y:s+p*Math.sin(f)}})}),a.ring={cx:o,cy:s,r:c,inner:l,total:Zt(i,e.unit),caption:qt(e.unit)===`caption`?`${e.unit} in all`:`in all`};let d=pn(e,r.map(e=>e??-1/0)),f=a.slices.find(e=>e.category===d);if(f){let e=a.slices.indexOf(f),t=a.slices.slice(0,e).reduce((e,t)=>e+t.share,0),n=-Math.PI/2+(t+f.share/2)*Math.PI*2,r=Math.cos(n),i=o+(c+10)*r,l=s+(c+10)*Math.sin(n)+4;a.labels.push({x:i,y:l,text:Qt(f.share),anchor:r>.25?`start`:r<-.25?`end`:`middle`,strong:!0})}return a}function bn(e,t){let n=e.series[0]?.values??[],r=n.reduce((e,t)=>e+Math.max(0,t??0),0),i=n[t]??0;return r>0&&i>0?Qt(i/r):`0%`}function xn(e,t,n){let r=e.rows.findIndex(e=>e[0]===t);if(r===-1&&(r=e.rows.findIndex(e=>Ut(e[0]??``,t))),r===-1)return null;if(n===void 0)return{row:r,series:null};let i=Sn(e,n);return i===null?null:{row:r,series:i}}function Sn(e,t){let n=e.columns.findIndex((e,n)=>n>0&&e===t);return n===-1&&(n=e.columns.findIndex((e,n)=>n>0&&Ut(e,t))),n===-1?null:n-1}function Cn(e,t){return`${H(e.columns[t+1]||`series ${t+1}`,40)} series`}function wn(e,t,n){let r=H(e.rows[t]?.[0]||`row ${t+1}`,60),i=e.columns.length>2;if(n===null&&i)return r;let a=n??0,o=Xt(Ht(e.rows[t]?.[a+1]??``)??null,e.unit);return i?`${r} · ${H(e.columns[a+1],40)}: ${o}`:`${r}: ${o}`}var Tn={w:780,h:400};function En(){return{blocks:[],groups:[],links:[],pins:[]}}function Dn(e){let t=Eo(e.type);return t.named?.(e)||(e.title?`${e.type} "${H(e.title,50)}"`:t.untitled?.(e)??`untitled ${e.type}`)}function On(e){return`${Dn(e)} is ${/^[aeiou]/.test(e.type)?`an`:`a`} ${e.type}`}function kn(e,t=50){return e.title?`"${H(e.title,t)}"`:Dn(e)}function An(e,t){return{...e,title:t.title,type:t.type,...Eo(t.type).fromSnapshot(t,e)}}var jn={type:`chart`,label:`Chart`,defaultSize:{w:480,h:330},fromSnapshot:e=>{let{kind:t,columns:n,rows:r,unit:i,subtitle:a,highlight:o}=e;return{kind:t,columns:n,rows:r,unit:i,subtitle:a,highlight:o}},pins:{anchor:K.anchor,part:K.part,parts:{point:{lost:`no longer there`,drawn:!0,askedTo:`change the chart's data`,missing:e=>`Points are pinned in charts; ${On(e)}.`}},place(e,t){if(t.anchor.kind!==`point`)return;let{category:n,series:r}=t.anchor;if(n===void 0){let t=r===void 0?null:Sn(e,r);return t===null?null:{kind:`point`,row:null,series:t}}let i=xn(e,n,r);return i&&{kind:`point`,...i}}},...K},Mn=2097152;function Nn(e){return e.reduce((e,t)=>({files:e.files+1,additions:e.additions+t.additions,deletions:e.deletions+t.deletions}),{files:0,additions:0,deletions:0})}function Pn(e,t){return`+${e.toLocaleString(`en-US`)} −${t.toLocaleString(`en-US`)}`}var Fn=[/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|go\.sum)$/,/\.lock$/,/(^|\/)dist\//,/\.min\.(js|css)$/,/\.map$/,/(^|\/)__snapshots__\//,/\.snap$/];function In(e){return Fn.some(t=>t.test(e))}function Ln(e){return e.hunks.reduce((e,t)=>e+t.lines.length,0)}function Rn(e,t=[]){let n=new Set(t.filter(t=>e.some(e=>e.path===t)));for(let t of e){if(n.size>=3)break;t.hunks.length&&!In(t.path)&&Ln(t)<=150&&n.add(t.path)}return n}function zn(e,t=[]){return t.length===0?e:[...t.flatMap(t=>e.filter(e=>e.path===t)),...e.filter(e=>!t.includes(e.path))]}function Bn(e,t,n=12){if(e.length<=n)return e;let r=Math.max(0,n-e.filter(e=>t.has(e.path)).length);return e.filter(e=>t.has(e.path)||r-->0)}function Vn(e){let[t,n]=[e.oldStart,e.newStart];return e.lines.map(e=>{let r=e.slice(1);switch(e[0]){case`+`:return{kind:`add`,text:r,new:n++};case`-`:return{kind:`del`,text:r,old:t++};case`\\`:return{kind:`note`,text:e.slice(1).trim()};default:return{kind:`context`,text:r,old:t++,new:n++}}})}function Hn(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.kind===`context`)t.push({left:r,right:r}),n++;else if(r.kind===`note`){let i=e[n-1];t.push({left:i?.kind===`add`?void 0:r,right:i?.kind===`del`?void 0:r}),n++}else{let r=[],i=[];for(;e[n]?.kind===`del`;)r.push(e[n++]);let a=e[n]?.kind===`note`&&r.length?e[n++]:void 0;for(;e[n]?.kind===`add`;)i.push(e[n++]);let o=a?[...r,a]:r;for(let e=0;e<Math.max(o.length,i.length);e++)t.push({left:o[e],right:i[e]})}}return t}function Un(e){return e.replace(/\s+/g,` `).trim().slice(0,1e3)}function Wn(e,t,n){for(let r of e.hunks)for(let e of Vn(r))if(e[t]===n)return e.text}function Gn(e,t){return e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)}function Kn(e,t,n,r,i){let a=Gn(e,t);if(!a)return null;let o=null;for(let e of a.hunks)for(let t of Vn(e)){let e=t[n];e!==void 0&&Un(t.text)===i&&(o===null||Math.abs(e-r)<Math.abs(o-r))&&(o=e)}return o===null?null:{file:a.path,line:o}}var qn=class extends Error{},Jn=[{name:`TypeScript`,colour:`js`,extensions:[`ts`,`tsx`,`mts`,`cts`]},{name:`JavaScript`,colour:`js`,extensions:[`js`,`jsx`,`mjs`,`cjs`],aliases:[`node`]},{name:`JSON`,colour:`json`,extensions:[`json`,`jsonc`,`json5`]},{name:`CSS`,colour:`css`,extensions:[`css`]},{name:`SCSS`,colour:`scss`,extensions:[`scss`],aliases:[`sass`]},{name:`Less`,colour:`scss`,extensions:[`less`]},{name:`HTML`,colour:`html`,extensions:[`html`,`htm`]},{name:`XML`,colour:`html`,extensions:[`xml`]},{name:`SVG`,colour:`html`,extensions:[`svg`]},{name:`Vue`,colour:`html`,extensions:[`vue`]},{name:`Svelte`,colour:`html`,extensions:[`svelte`]},{name:`Python`,colour:`python`,extensions:[`py`,`pyi`]},{name:`Go`,colour:`go`,extensions:[`go`],aliases:[`golang`]},{name:`Rust`,colour:`rust`,extensions:[`rs`]},{name:`Shell`,colour:`shell`,extensions:[`sh`,`bash`,`zsh`],aliases:[`bash`,`zsh`]},{name:`Markdown`,extensions:[`md`,`markdown`,`mdx`]},{name:`YAML`,extensions:[`yml`,`yaml`]},{name:`TOML`,extensions:[`toml`]},{name:`SQL`,extensions:[`sql`]},{name:`Java`,extensions:[`java`]},{name:`Kotlin`,extensions:[`kt`,`kts`]},{name:`Swift`,extensions:[`swift`]},{name:`C`,extensions:[`c`,`h`]},{name:`C++`,extensions:[`cpp`,`cc`,`cxx`,`hpp`,`hh`],aliases:[`cplusplus`]},{name:`C#`,extensions:[`cs`],aliases:[`csharp`]},{name:`Ruby`,extensions:[`rb`],files:[`Gemfile`,`Rakefile`]},{name:`PHP`,extensions:[`php`]},{name:`Dockerfile`,extensions:[`dockerfile`],files:[`Dockerfile`]},{name:`Makefile`,extensions:[`mk`],files:[`Makefile`]},{name:`Plain text`,extensions:[`txt`,`log`],aliases:[`text`,`plain`]}];function Yn(e){let t=e.split(/[\\/]/).pop()??``,n=Jn.find(e=>e.files?.includes(t));if(n)return n;let r=t.lastIndexOf(`.`);if(r<=0)return;let i=t.slice(r+1).toLowerCase();return Jn.find(e=>e.extensions.includes(i))}function Xn(e){let t=e.trim().toLowerCase().replace(/^\./,``);if(t)return Jn.find(e=>e.name.toLowerCase()===t||e.aliases?.includes(t)||e.extensions.includes(t))}function Zn(e){return e.language?Xn(e.language)??{name:e.language,extensions:[]}:Yn(e.path)}function Qn(e){let t=e.split(`
15
+ `).map(e=>e.endsWith(`\r`)?e.slice(0,-1):e);return t.length>1&&t.at(-1)===``&&t.pop(),t}function $n(e,t=Qn(e.text).length){let n=e.start??1,r=n+t-1;return{first:n,last:r,total:e.total??(n===1?r:void 0)}}var er=e=>e.toLocaleString(`en-US`);function tr([e,t]){return e===t?String(e):`${e}–${t}`}function nr(e,t){let{first:n,last:r,total:i}=$n(e,t);return n===1&&i===r?`${er(r)} line${r===1?``:`s`}`:`lines ${tr([n,r])}${i?` of ${er(i)}`:``}`}function rr(e,t=60){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function ir(e,t,n){let r=e.start??1,i=null;return Qn(e.text).forEach((e,a)=>{let o=r+a;Un(e)===n&&(i===null||Math.abs(o-t)<Math.abs(i-t))&&(i=o)}),i}function ar(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<56320&&n+1<e.length?(t+=4,n++):t+=3}return t}function or(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function sr(e){if(e.includes(`\0`))return!0;let t=e.slice(0,8e3),n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);(r<32&&r!==9&&r!==10&&r!==12&&r!==13&&r!==27||r===65533)&&n++}return t.length>0&&n/t.length>.1}function cr(e,t=`The text`){if(!e.trim())throw new qn(`${t} is empty. A code block needs the file's text, or the lines that matter.`);let n=ar(e);if(n>1048576)throw new qn(`${t} is ${or(n)}; a code block holds at most 1 MB. Send the lines that matter, with start (the first line's number) and total (the file's line count).`);if(sr(e))throw new qn(`${t} looks like a binary file, not text. Code blocks hold source and other text files.`);return e}function lr(e){let t=[];for(let[n,r]of[...e].sort((e,t)=>e[0]-t[0]||e[1]-t[1])){let e=t.at(-1);e&&n<=e[1]+1?e[1]=Math.max(e[1],r):t.push([n,r])}return t}var ur=4;function dr(e,t={}){let{first:n,last:r}=$n(e,t.count),i=r-n+1;if(t.all||i<=60)return[{kind:`lines`,from:n,to:r}];let a=[...e.highlight?.length?e.highlight.map(([e,t])=>[e-3,t+3]):[[n,n+40-1]],...(t.keep??[]).map(e=>[e-1,e+1]),...t.opened??[]].flatMap(([e,t])=>t<n||e>r?[]:[[Math.max(e,n),Math.min(t,r)]]),o=[];for(let[e,t]of lr(a)){let n=o.at(-1);n&&e-n[1]-1<ur?n[1]=t:o.push([e,t])}o.length&&o[0][0]-n<ur&&(o[0][0]=n),o.length&&r-o[o.length-1][1]<ur&&(o[o.length-1][1]=r);let s=[],c=n;for(let[e,t]of o)e>c&&s.push({kind:`fold`,from:c,to:e-1}),s.push({kind:`lines`,from:e,to:t}),c=t+1;return c<=r&&s.push({kind:`fold`,from:c,to:r}),s}function fr(e,t,n){let r=t.filter(e=>e.kind===`lines`),{first:i,last:a,total:o}=$n(e,n);return r.length!==1||r[0].from===i&&r[0].to===a?nr(e,n):`lines ${tr([r[0].from,r[0].to])}${o?` of ${er(o)}`:``}`}var pr=19.2,mr=40,hr=24,gr=7.3;function _r(e){let t=Qn(e.text),n=dr(e,{count:t.length}),r=e.start??1,i=0,a=0;for(let e of n)if(e.kind!==`fold`){i+=e.to-e.from+1;for(let n=e.from;n<=e.to;n++)a=Math.max(a,t[n-r].replace(/\t/g,` `).length)}let o=r+t.length-1,s=n.length-n.filter(e=>e.kind===`lines`).length+ +(r>1)+ +((e.total??0)>o),c=String(Math.max(o,e.total??0)).length,l=Math.round(mr+i*pr+s*hr+8),u=Math.round(c*gr+30+a*gr+24);return{w:Math.min(820,Math.max(460,u)),h:Math.min(560,Math.max(120,l))}}var vr=e=>e.last&&e.last>e.line?`${e.line}–${e.last}`:`${e.line}`;function yr({anchor:e,quote:t}){let n=vr(e);return`${e.file?`${e.file}:${n}`:`${n.includes(`–`)?`lines`:`line`} ${n}`}${e.side===`old`?` (old)`:``} · ${t?`“${t}”`:`a blank line`}`}var br={name:({anchor:e})=>{let t=e.last&&e.last>e.line?`lines`:`line`;return`${e.side===`old`?`old `:``}${t} ${vr(e)}${e.file?` of ${e.file}`:``}`},quote:yr,detail:yr,lost:`no longer there`,answeredOn:`the line`,where:e=>e.quote?` ("${H(e.quote,80)}")`:` (a blank line)`},xr={type:`code`,label:`Code`,defaultSize:{w:640,h:420},titled:!1,named:e=>e.path?`code "${rr(e.path)}"`:`untitled code`,sizeFor:e=>_r(e),fromSnapshot:e=>{let{path:t,text:n,language:r,start:i,total:a,highlight:o,commit:s}=e;return{path:t,text:n,language:r,start:i,total:a,highlight:o,commit:s}},pins:{anchor:K.anchor,part:K.part,parts:{line:{...br,askedTo:`change the code`}},place(e,t){if(t.anchor.kind!==`line`)return;let n=ir(e,t.anchor.line,t.quote);if(n===null)return null;let{last:r}=t.anchor,i=(e.start??1)+Qn(e.text).length-1;return{kind:`line`,file:e.path,line:n,side:`new`,...r&&r>t.anchor.line?{last:Math.min(i,n+r-t.anchor.line)}:{}}}},...K},Sr={type:`comparison`,label:`Comparison`,defaultSize:{w:520,h:340},fromSnapshot:()=>({}),...K},Cr=/^(?:flowchart|flowchart-elk|graph)\b(?:[ \t]+(?:TB|TD|BT|RL|LR))?[ \t]*;?/,wr=/^(?:classDef|class|style|linkStyle|click|direction)[ \t]|^(?:accTitle|accDescr)[ \t]*[:{]|^end\b/,Tr=/^(?:[\p{L}\p{N}_$]|\.(?![-=])|-(?![-.>=]))+/u,Er=[[`(((`,[`)))`]],[`((`,[`))`]],[`([`,[`])`]],[`[[`,[`]]`]],[`[(`,[`)]`]],[`{{`,[`}}`]],[`[/`,[`/]`,`\\]`]],[`[\\`,[`\\]`,`/]`]],[`[`,[`]`]],[`(`,[`)`]],[`{`,[`}`]],[`>`,[`]`]]],Dr=/^(?:[<ox]?(?:-{2,}[>ox]|-{3,}|={2,}[>ox]|={3,}|-\.+-[>ox]?)|~{3,})/,Or=/^[<ox]?(?:--|==|-\.)[ \t]*([^-=.>\s].*?)[ \t]*(?:-{2,}[>ox]|-{3,}|={2,}[>ox]|={3,}|\.-+[>ox]?)/,kr={quot:`"`,amp:`&`,lt:`<`,gt:`>`,nbsp:` `};function Ar(e){let t=e.trim();for(let e of[`"`,"`"])t.length>=2&&t.startsWith(e)&&t.endsWith(e)&&(t=t.slice(1,-1));return t.replace(/<br\s*\/?>/gi,` `).replace(/<\/?[a-z][^>]*>/gi,``).replace(/#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t))).replace(/[#&](quot|amp|lt|gt|nbsp);/g,(e,t)=>kr[t]).replace(/\s+/g,` `).trim()}function jr(e){let t=e.replace(/^\s*---\n[\s\S]*?\n---[ \t]*\n/,``).split(`
16
+ `).filter(e=>!/^\s*%%/.test(e));for(;t.length&&!t[0].trim();)t.shift();let n=t[0]?.trim().match(Cr);if(!n)return null;t[0]=t[0].trim().slice(n[0].length);let r=new Map,i=[],a=new Set,o=new Set,s=(e,t,n,r)=>{let a=i.filter(n=>n.from===e&&n.to===t).length,s=r&&!i.some(e=>e.id===r)?r:`L_${e}_${t}_${a===0?0:a+1}`;r&&o.add(r),i.push({id:s,from:e,to:t,n:a,...n?{label:n}:{}})};for(let e of t){let t=0,n=()=>e.slice(t),i=()=>{for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++},o=()=>{let i=n().match(Tr)?.[0];if(!i)return null;t+=i.length,r.has(i)||r.set(i,i);let a=Er.find(([e])=>n().startsWith(e));if(a){let[n,o]=a,s=t+n.length,c=null;if(e[s]===`"`){let t=e.indexOf(`"`,s+1);t>0&&(c=e.slice(s,t+1),s=t+1)}let l=o.map(t=>[e.indexOf(t,s),t.length]).filter(([e])=>e>=0);if(l.length===0)return null;let[u,d]=l.reduce((e,t)=>t[0]<e[0]?t:e);r.set(i,Ar(c??e.slice(s,u))||i),t=u+d}let o=n().match(/^:::[\w-]+/);if(o&&(t+=o[0].length),n().startsWith(`@{`)){let n=e.indexOf(`}`,t);if(n<0)return null;let a=e.slice(t+2,n).match(/\blabel\s*:\s*(?:"([^"]*)"|'([^']*)'|([^,]+))/);a&&r.set(i,Ar(a[1]??a[2]??a[3])||i),t=n+1}return i},c=()=>{let n=[];for(;;){i();let r=o();if(!r)return null;if(n.push(r),i(),e[t]!==`&`)return n;t++}},l=()=>{let e=n().match(/^([^\s"@&;|]+)@(?=[-=~.<ox])/);e&&(t+=e[0].length);let r=n().match(Dr),i=r?null:n().match(Or),a=r??i;if(!a)return null;t+=a[0].length;let o=i?Ar(i[1]):void 0,s=n().match(/^[ \t]*\|([^|]*)\|/);return s&&(o=Ar(s[1]),t+=s[0].length),{label:o||void 0,id:e?.[1]}};for(;t<e.length;){if(i(),e[t]===`;`){t++;continue}if(t>=e.length||wr.test(n()))break;let r=n().match(/^subgraph\b[ \t]*/);if(r){let n=e.slice(t+r[0].length).match(Tr)?.[0];n&&a.add(n);break}let o=null,u=null;for(;;){let e=c();if(!e)break;if(o&&u)for(let t of o)for(let n of e){let r=t===o[o.length-1]&&n===e[0];s(t,n,u.label,r?u.id:void 0)}i();let t=l();if(!t)break;o=e,u=t}if(i(),e[t]!==`;`)break}}return{nodes:[...r].filter(([e])=>!a.has(e)&&!o.has(e)).map(([e,t])=>({id:e,label:t})),arrows:i}}function Mr(e,t,n){return e?.nodes.find(e=>e.id===t)??(n?e?.nodes.find(e=>e.label===n):void 0)}function Nr(e,t){let n=t=>H(Mr(e,t)?.label??t,40);return`${n(t.from)} → ${n(t.to)}`}var Pr=e=>`Only diagrams have nodes and arrows; ${On(e)}.`,Fr={type:`diagram`,label:`Diagram`,defaultSize:{w:440,h:320},fromSnapshot:e=>({source:e.source}),pins:{anchor:K.anchor,part:K.part,parts:{node:{name:e=>`node "${H(e.quote,80)}"`,lost:`node removed`,drawn:!0,askedTo:`change the diagram's source`,where:e=>` (id ${e.anchor.nodeId})`,missing:Pr},arrow:{name:e=>`arrow "${e.quote}"`,lost:`arrow removed`,drawn:!0,askedTo:`change the diagram's source`,where(e){let{from:t,to:n,label:r,n:i}=e.anchor,a=i?`, occurrence ${i+1}`:``;return` (${t} --> ${n}${r?`, text "${r}"`:``}${a})`},missing:Pr}},place(e,t){let{anchor:n}=t;if(n.kind===`node`){let t=Mr(jr(e.source),n.nodeId,n.label);return t?{kind:`node`,nodeId:t.id}:null}if(n.kind!==`arrow`)return;let r=jr(e.source)?.arrows.filter(e=>e.from===n.from&&e.to===n.to)??[],i=n.label&&r.find(e=>e.label===n.label)||r[Math.min(n.n,r.length-1)];return i?{kind:`arrow`,arrowId:i.id}:null}},...K},Ir={type:`diff`,label:`Diff`,defaultSize:{w:760,h:560},untitled:e=>`diff of ${e.files.length} file${e.files.length===1?``:`s`}`,fromSnapshot:e=>({patch:e.patch,files:e.files,focus:e.focus}),pins:{anchor:K.anchor,parts:{line:{...br,missing:e=>`Lines are pinned in diffs and code blocks; ${On(e)}.`}},place(e,t){if(t.anchor.kind!==`line`)return;let n=Kn(e.files,t.anchor.file,t.anchor.side,t.anchor.line,t.quote);return n&&{kind:`line`,...n,side:t.anchor.side}}},...K},Lr={w:380,h:300},Rr={w:26,h:78},zr=1100;function Br(e){return e.width>=1600?e.width/2:e.width}function Vr(e,t){return{w:Math.round(t+Rr.w),h:Math.round(t*e.height/e.width+Rr.h)}}function Hr(e){return Vr(e,Br(e))}function Ur(e,t={}){if(!e||!(e.width>0)||!(e.height>0))return Lr;if(t.w!==void 0&&t.h===void 0)return Vr(e,Math.max(1,t.w-Rr.w));if(t.h!==void 0&&t.w===void 0)return{w:Vr(e,Math.max(1,t.h-Rr.h)*e.width/e.height).w,h:Math.round(t.h)};let n=Lr.w-Rr.w,r=Math.min(Math.max(Br(e),n),zr-Rr.w),i=zr-Rr.h;return r*e.height/e.width>i&&(r=Math.max(n,i*e.width/e.height)),Vr(e,r)}var Wr=e=>String(Math.round(e*1e3)/1e3),Gr={type:`image`,label:`Image`,defaultSize:Lr,untitled:e=>e.caption?`image "${H(e.caption,40)}"`:void 0,refText:e=>[e.caption],sizeFor:(e,t)=>e.naturalWidth&&e.naturalHeight?Ur({width:e.naturalWidth,height:e.naturalHeight},t):Lr,fromSnapshot:(e,t)=>({assetId:e.assetId,caption:e.caption,...t.type===`image`&&t.assetId===e.assetId?{}:{naturalWidth:void 0,naturalHeight:void 0}}),pins:{anchor:K.anchor,part:K.part,parts:{box:{lost:`image changed`,same:(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,drawn:!0,askedTo:`make a new version of the image`,where:({anchor:e})=>` (x ${Wr(e.x)}, y ${Wr(e.y)}, w ${Wr(e.w)}, h ${Wr(e.h)})`,missing:e=>`Boxes are drawn on images; ${On(e)}.`}},place:(e,t)=>t.anchor.kind===`box`?{...t.anchor}:void 0},...K},Kr=e=>({method:`GET`,path:e}),q=e=>({method:`POST`,path:e}),qr=e=>({method:`DELETE`,path:e});function Jr(e,...t){let[n,r]=t,i=e.path.replace(/:(\w+)/g,(t,r)=>{let i=n?.[r];if(i===void 0)throw Error(`${e.method} ${e.path} needs ${r}.`);return encodeURIComponent(String(i))}),a=r===void 0?``:new URLSearchParams(r).toString();return a?`${i}?${a}`:i}var Yr={token:q(`/api/connectors/figma/token`),file:Kr(`/api/connectors/figma/files/:fileId`),bringIn:q(`/api/connectors/figma/frames`),refresh:q(`/api/connectors/figma/images/:blockId/refresh`)},Xr=`file_content:read`,Zr=`file_comments:read`,Qr=`allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox`,$r=`${Qr} allow-presentation`,ei={file:`Figma file`,design:`Figma design`,proto:`Figma prototype`},ti={id:`figma`,hosts:[`figma.com`],embeds:`Figma`,read(e,t){let n=t[0]===`community`&&t[1]===`file`&&/^\d+$/.test(t[2]??``)?`Figma community file`:Object.hasOwn(ei,t[0]??``)&&/^[A-Za-z0-9]+$/.test(t[1]??``)?ei[t[0]]:void 0;return n?{kind:`Figma`,name:n,site:`Figma`,mark:`figma`,embed:{url:`https://www.figma.com/embed?embed_host=tricot&url=${encodeURIComponent(e.href)}`,sandbox:Qr,allow:`fullscreen; clipboard-write`,referrer:`no-referrer`,size:{w:640,h:480},blocked:`Figma won't show this inside the board in this browser. Open it in Figma.`}}:null}},ni=/^[A-Za-z0-9]{6,64}$/,ri=/^(\d{1,12})[-:](\d{1,12})$/;function ii(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname.replace(/^www\./,``)!==`figma.com`||t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.pathname.split(`/`).filter(Boolean);if(![`file`,`design`,`proto`].includes(n[0]??``))return null;let r=n[2]===`branch`&&n[3]?n[3]:n[1];if(!r||!ni.test(r))return null;let i=ri.exec(t.searchParams.get(`node-id`)??``);return i?{fileKey:r,nodeId:`${i[1]}:${i[2]}`}:{fileKey:r}}function ai(e){return e.nodeId?`${e.fileKey}:${e.nodeId}`:e.fileKey}var oi={w:400,h:260},si={id:`figma`,hosts:ti.hosts,read(e,t){let n=ii(e.href),r=n&&ti.read(e,t);return r?{...r,fileId:ai(n),card:oi}:null}},ci={id:`figma`,name:`Figma`,scopes:{[Xr]:{label:`See the Figma files your token can open, and their frames as pictures`,agent:`Figma frames`},[Zr]:{label:`Read the comments on those files`,agent:`Figma comments`}},identity:{scopes:[],email:[]},sources:[si],routes:Yr,agent:K.agent},li={device:Kr(`/api/connectors/github/device`),startDevice:q(`/api/connectors/github/device/start`),pollDevice:q(`/api/connectors/github/device/poll`),cancelDevice:q(`/api/connectors/github/device/cancel`),token:q(`/api/connectors/github/token`),repos:Kr(`/api/connectors/github/repos`),card:Kr(`/api/connectors/github/cards/:owner/:repo/:kind/:number`),showChanges:q(`/api/connectors/github/blocks/:blockId/diff`),bringInFile:q(`/api/connectors/github/blocks/:blockId/file`)},ui=`github:contents`,di=`github:pull_requests`,fi=`github:issues`,pi=`github:checks`,mi=new Set([`about`,`apps`,`codespaces`,`collections`,`customer-stories`,`enterprise`,`explore`,`features`,`issues`,`login`,`marketplace`,`new`,`notifications`,`orgs`,`organizations`,`pricing`,`pulls`,`search`,`settings`,`sponsors`,`topics`,`trending`]),hi={id:`github`,hosts:[`github.com`],read(e,t){let[n=``,r=``,i,a]=t,o=r.replace(/\.git$/,``);if(!/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(n)||mi.has(n.toLowerCase())||!/^[\w.-]+$/.test(o)||o===`.`||o===`..`)return null;let s=`${n}/${o}`;if(a!==void 0&&/^\d+$/.test(a)&&(i===`pull`||i===`issues`)){let e=`${s} #${a}`,t=i===`pull`;return{kind:`GitHub`,what:t?`pull request`:`issue`,ref:e,name:e,site:`GitHub`,mark:t?`github-pull`:`github-issue`}}return{kind:`GitHub`,what:i?void 0:`repository`,ref:s,name:s,site:`GitHub`,mark:`github-repo`}}},gi=/^#L(\d+)(?:C\d+)?(?:-L(\d+)(?:C\d+)?)?$/;function _i(e){try{return decodeURIComponent(e)}catch{return e}}function vi(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`||t.hostname.replace(/^www\./,``)!==`github.com`)return null;let n=t.pathname.split(`/`).filter(Boolean);if(!hi.read(t,n))return null;let[r,i,a,...o]=n,s=i.replace(/\.git$/,``);if((a===`pull`||a===`issues`)&&/^\d+$/.test(o[0]??``))return{kind:a===`pull`?`pull`:`issue`,owner:r,repo:s,number:Number(o[0])};if(a===`blob`&&o.length>=2){let e=gi.exec(t.hash),n=e?Number(e[1]):0,i=e?.[2]?Number(e[2]):n,a=n>=1&&i>=1?[Math.min(n,i),Math.max(n,i)]:void 0;return{kind:`file`,owner:r,repo:s,refPath:o.map(_i),...a?{lines:a}:{}}}return null}var yi=e=>`${e.owner}/${e.repo}/${e.kind}/${e.number}`,bi={w:400,h:100},xi={id:`github`,hosts:hi.hosts,read(e,t){let n=hi.read(e,t);if(!n)return null;let r=vi(e.href);return r?r.kind===`file`?{...n,name:r.refPath.slice(1).join(`/`)||n.name}:{...n,fileId:yi(r),card:bi}:n}},Si={id:`github`,name:`GitHub`,scopes:{[ui]:{label:`See the files in the repositories Tricot is installed on`,agent:`files`},[di]:{label:`See pull requests and what they change`,agent:`pull requests`},[fi]:{label:`See issues`,agent:`issues`},[pi]:{label:`See check results and commit statuses`,agent:`checks`}},identity:{scopes:[],email:[]},sources:[xi],routes:li,agent:K.agent};function Ci(e,t){let{anchor:n}=t;if(n.kind!==`doc`||e.type!==`link`)return;if(n.gone)return null;let r=(e.docDraft?.revision===n.revision?e.docDraft:void 0)?.edits.find(e=>e.id===n.paragraph);return n.paragraph.startsWith(`n`)?r?.op===`add`?{kind:`doc`,paragraph:n.paragraph}:null:r?.op===`delete`?null:{kind:`doc`,paragraph:n.paragraph}}var wi={file:Kr(`/api/connectors/google/files/:fileId`),picker:q(`/api/connectors/google/picker`),chosen:q(`/api/connectors/google/chosen`),doc:Kr(`/api/connectors/google/docs/:blockId`),docDraft:q(`/api/connectors/google/docs/:blockId/draft`),docDiscard:q(`/api/connectors/google/docs/:blockId/discard`),docSave:q(`/api/connectors/google/docs/:blockId/save`),docPins:q(`/api/connectors/google/docs/:blockId/pins`),docResolve:q(`/api/connectors/google/docs/:blockId/resolve`)},Ti=`https://www.googleapis.com/auth/drive.file`,Ei=`https://www.googleapis.com/auth/drive.metadata.readonly`,Di=`https://www.googleapis.com/auth/userinfo.email`,Oi=`https://www.googleapis.com/auth/documents`,ki=`Google won't show this inside the board in this browser. Open it in Google, or publish it to view here read-only.`,Ai={document:{kind:`Google Docs`,name:`Google Doc`,mark:`google-docs`,size:{w:640,h:620},published:`pub?embedded=true`},spreadsheets:{kind:`Google Sheets`,name:`Google Sheet`,mark:`google-sheets`,size:{w:760,h:500},published:`pubhtml?widget=true&headers=false`},presentation:{kind:`Google Slides`,name:`Google Slides`,mark:`google-slides`,size:{w:640,h:460},published:`embed`}},ji={id:`google`,hosts:[`docs.google.com`],embeds:`Google Docs, Sheets and Slides`,read(e,t){let n=Object.hasOwn(Ai,t[0]??``)?Ai[t[0]]:void 0;if(!n)return null;let r=1;if(t[r]===`u`&&/^\d+$/.test(t[r+1]??``)&&(r+=2),t[r]!==`d`)return null;let i=t[r+1]===`e`,a=t[i?r+2:r+1];if(!a||!/^[\w-]{10,}$/.test(a))return null;let o=`https://docs.google.com/${t[0]}/d/${i?`e/${a}`:a}`;return{kind:n.kind,name:n.name,site:`Google`,mark:n.mark,fileId:i?void 0:a,...n.mark===`google-docs`&&!i?{editable:!0}:{},embed:{url:`${o}/${i?n.published:`preview`}`,sandbox:Qr,referrer:`no-referrer`,size:n.size,blocked:ki}}}},Mi={id:`google`,name:`Google`,scopes:{openid:{label:`Know which Google account you signed in with`,agent:`account`},email:{label:`See your email address`,agent:`email address`},[Di]:{label:`See your email address`,agent:`email address`},[Ti]:{label:`See and edit the Google Docs you choose, and only those`,agent:`Google Docs people choose`},[Ei]:{label:`See the names of your Drive files and when they were last edited`,agent:`Drive file names and dates`},[Oi]:{label:`See and edit your Google Docs`,agent:`Google Docs, read and write`}},identity:{scopes:[`openid`,`email`,Di],email:[`email`,Di]},sources:[ji],routes:wi,pins:{kind:`doc`,place:Ci,name:e=>`"${H(e.quote,80)}"`,quote:e=>`“${e.quote}”`,lost:`paragraph removed`,askedTo:`edit the draft`,anchor:K.pins?.anchor,where:K.pins?.where,label:K.pins?.label,missing:K.pins?.missing,seen:K.pins?.seen,ask:K.pins?.ask},agent:K.agent,link:K.link,store:K.store},Ni={key:q(`/api/connectors/linear/key`),issue:Kr(`/api/connectors/linear/issues/:identifier`)},Pi=`read`,Fi=/^[A-Za-z][A-Za-z0-9]{0,9}-\d{1,9}$/;function Ii(e){let t=e.trim();return Fi.test(t)?t.toUpperCase():null}function Li(e){return e[1]===`issue`?Ii(e[2]??``):null}var Ri={w:400,h:100},zi={id:`linear`,hosts:[`linear.app`],read(e,t){let n=Li(t);return n?{kind:`Linear`,what:`issue`,ref:n,name:n,site:`Linear`,mark:`linear`,fileId:n,card:Ri}:null}},Bi={id:`linear`,name:`Linear`,scopes:{[Pi]:{label:`See the issues, projects and teams your Linear account can see`,agent:`issues`}},identity:{scopes:[],email:[]},sources:[zi],routes:Ni,agent:K.agent},Vi={thread:Kr(`/api/connectors/slack/threads/:channel/:ts`)},Hi=`channels:history`,Ui=`groups:history`,Wi=`users:read`,Gi=`chat:write`,Ki=[`*.slack.com`],qi=/^[CGD][A-Z0-9]{7,14}$/,Ji=/^\d{10}\.\d{6}$/,Yi=/^p(\d{10})(\d{6})$/,Xi=/^[a-z0-9][a-z0-9.-]*$/,Zi=new Set([`app`,`api`,`files`,`hooks`,`status`,`join`,`edgeapi`,`slackb`,`www`]);function Qi(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.replace(/\.$/,``);if(!n.endsWith(`.slack.com`))return null;let r=n.slice(0,-10);if(!Xi.test(r)||Zi.has(r))return null;let[i,a,o,...s]=t.pathname.split(`/`).filter(Boolean);return i!==`archives`||!a||!qi.test(a)?null:{url:t,channel:a,message:o,more:s.length>0}}function $i(e){let t=Qi(e),n=Yi.exec(t?.message??``);if(!t||t.more||!n)return null;let r=`${n[1]}.${n[2]}`,i=t.url.searchParams.get(`thread_ts`),a=i&&Ji.test(i)&&i!==r?i:void 0;return{channel:t.channel,ts:r,...a?{threadTs:a}:{}}}var ea=e=>`${e.channel}/${e.threadTs??e.ts}`,ta={w:400,h:170},na={id:`slack`,hosts:Ki,read(e){let t=$i(e.href);return t?{kind:`Slack`,what:t.threadTs?`thread`:`message`,name:`Slack thread`,site:`Slack`,mark:`slack`,fileId:ea(t),card:ta}:null}},ra={id:`slack`,name:`Slack`,scopes:{[Hi]:{label:`Read the messages in the public channels whose threads you link`,agent:`threads in public channels`},[Ui]:{label:`Read the messages in the private channels whose threads you link`,agent:`threads in private channels`},[Wi]:{label:`See people's names, to say who wrote a message`,agent:`who wrote them`},[Gi]:{label:`Post a message as you, only when you choose to share something`,agent:`posting by people only`}},identity:{scopes:[],email:[]},sources:[na],routes:Vi,agent:K.agent},ia=()=>[Mi,ci,Si,ra,Bi],aa;function oa(){return aa??=ia()}function sa(e){return oa().find(t=>t.pins?.kind===e)}var ca={id:`loom`,hosts:[`loom.com`],embeds:`Loom`,read(e,t){if(t[0]!==`share`&&t[0]!==`embed`)return null;let n=/(?:^|-)([0-9a-f]{32})$/.exec(t[1]??``)?.[1];return n?{kind:`Loom`,name:`Loom video`,site:`Loom`,mark:`loom`,embed:{url:`https://www.loom.com/embed/${n}`,sandbox:$r,allow:`fullscreen; picture-in-picture`,referrer:`no-referrer`,size:{w:560,h:400},blocked:`Loom won't play this inside the board in this browser. Open it in Loom.`}}:null}};function la(e){let t=e?/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(e):null;if(!t)return 0;let[,n=`0`,r=`0`,i=`0`]=t;return Number(n)*3600+Number(r)*60+Number(i)}var ua={id:`youtube`,hosts:[`youtube.com`,`m.youtube.com`,`youtube-nocookie.com`,`youtu.be`],embeds:`YouTube`,read(e,t){let n=t[0]===`shorts`,r=e.hostname.replace(/^www\./,``)===`youtu.be`?t[0]:t[0]===`watch`?e.searchParams.get(`v`):[`shorts`,`live`,`embed`].includes(t[0]??``)?t[1]:void 0;if(!r||!/^[\w-]{11}$/.test(r))return null;let i=la(e.searchParams.get(`t`)??e.searchParams.get(`start`));return{kind:`YouTube`,name:`YouTube video`,site:`YouTube`,mark:`youtube`,embed:{url:`https://www.youtube-nocookie.com/embed/${r}${i?`?start=${i}`:``}`,sandbox:$r,allow:`fullscreen; picture-in-picture; encrypted-media`,referrer:`strict-origin`,size:n?{w:380,h:700}:{w:560,h:400},blocked:`YouTube won't play this inside the board in this browser. Open it on YouTube.`}}}},da=()=>[...oa().flatMap(e=>(e.sources??[]).map(t=>({source:t,connector:e.id}))),...[ti,ua,ca,hi].map(e=>({source:e}))],fa;function pa(){return fa??=da()}function ma(e,t){return e.some(e=>e.startsWith(`*.`)?t.endsWith(e.slice(1)):e===t)}function ha(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.replace(/^www\./,``),r=t.pathname.split(`/`).filter(Boolean);for(let{source:e,connector:i}of pa()){if(!ma(e.hosts,n))continue;let a=e.read(t,r);if(a)return i?{...a,connector:i}:a}return null}function ga(e){return e.what?`${e.kind} ${e.what}`:e.kind}var _a={w:300,h:90};function va(e){let t=ha(e);return t?t.card?t.card:{w:t.editable?480:400,h:_a.h}:_a}function ya(e){let t;try{t=new URL(e.trim())}catch{return null}return t.protocol===`http:`||t.protocol===`https:`?t.href:null}function ba(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function xa(e){try{let{host:t,pathname:n,search:r,hash:i}=new URL(e);return`${t.replace(/^www\./,``)}${n}`.replace(/\/+$/,``)+r+i}catch{return e}}var Sa={type:`link`,label:`Link`,defaultSize:_a,untitled:e=>`link "${H(xa(e.url),50)}"`,sizeFor:e=>va(e.url),fromSnapshot:e=>({url:e.url}),pins:{anchor:K.anchor,place:(e,t)=>sa(t.anchor.kind)?.pins?.place(e,t),whole:{word:`card`,quote:e=>xa(e.url)}},...K},Ca=class extends Error{code;constructor(e,t=`invalid`){super(e),this.code=t}},wa=2e5,Ta=5e3,Ea=64,Da=256,Oa=32,ka=1e4,Aa=[`Scene`,`Group`,`Object3D`,`Mesh`,`InstancedMesh`,`SkinnedMesh`,`Bone`,`LOD`,`Line`,`LineLoop`,`LineSegments`,`Points`,`Sprite`,`AmbientLight`,`DirectionalLight`,`HemisphereLight`,`PointLight`,`SpotLight`,`RectAreaLight`,`LightProbe`,`PerspectiveCamera`,`OrthographicCamera`],ja=new Set([`Mesh`,`InstancedMesh`,`SkinnedMesh`,`Line`,`LineLoop`,`LineSegments`,`Points`]),Ma=[`BoxGeometry`,`CapsuleGeometry`,`CircleGeometry`,`ConeGeometry`,`CylinderGeometry`,`DodecahedronGeometry`,`EdgesGeometry`,`ExtrudeGeometry`,`IcosahedronGeometry`,`LatheGeometry`,`OctahedronGeometry`,`PlaneGeometry`,`PolyhedronGeometry`,`RingGeometry`,`ShapeGeometry`,`SphereGeometry`,`TetrahedronGeometry`,`TorusGeometry`,`TorusKnotGeometry`,`TubeGeometry`,`WireframeGeometry`,`BufferGeometry`],Na=[`MeshStandardMaterial`,`MeshPhysicalMaterial`,`MeshBasicMaterial`,`MeshLambertMaterial`,`MeshPhongMaterial`,`MeshToonMaterial`,`MeshNormalMaterial`,`MeshMatcapMaterial`,`MeshDepthMaterial`,`MeshDistanceMaterial`,`LineBasicMaterial`,`LineDashedMaterial`,`PointsMaterial`,`SpriteMaterial`,`ShadowMaterial`],Pa=new Set([`ShaderMaterial`,`RawShaderMaterial`]),Fa=[`color`,`emissive`,`specular`,`sheenColor`,`specularColor`,`attenuationColor`],Ia=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,La=/^data:image\/(?:png|jpeg|gif|webp|avif);base64,/i,Ra=/^(?:[a-z][a-z0-9+.-]*:\/\/|\/\/)/i,za=`{"metadata":{"version":4.6,"type":"Object"},"geometries":[{"uuid":"g1","type":"BoxGeometry","width":1,"height":1,"depth":1}],"materials":[{"uuid":"m1","type":"MeshStandardMaterial","color":"#3b6fd6"}],"object":{"type":"Scene","children":[{"type":"Mesh","name":"Crate","geometry":"g1","material":"m1","position":[0,0.5,0]}]}}`,Ba=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Va=e=>Array.isArray(e)?e:[],Ha=e=>`"${H(String(e),40)}"`,Ua=e=>`${e.slice(0,6).join(`, `)}${e.length>6?` …`:``}`,Wa=(e,t)=>typeof e.name==`string`&&e.name?`Object ${Ha(e.name)}`:`The ${String(e.type??`object`)} at ${t}`,Ga=(e,t,n)=>`${t} ${typeof e.uuid==`string`?Ha(e.uuid):n+1}`,Ka=new Map;function qa(e){let t=Ka.get(e);if(t)return t;if(!e.trim())throw new Ca(`A scene needs its three.js JSON, as Object3D.toJSON() writes it.`);if(e.length>2e5)throw new Ca(`A scene holds up to ${wa.toLocaleString(`en-US`)} characters; this one has ${e.length.toLocaleString(`en-US`)}. Use parametric geometries (BoxGeometry and the like) rather than vertex arrays, and keep pictures small.`);let n;try{n=JSON.parse(e)}catch(e){throw new Ca(`The scene isn't valid JSON: ${e.message.replace(/\.$/,``)}.`)}let r=Ba(n);if(!r)throw new Ca(`The scene is JSON but not a three.js scene: it is an object with object (its root) and the geometries and materials that uses.`);let i=Ja(r);Ka.size>=16&&Ka.delete(Ka.keys().next().value);let a={json:r,facts:i};return Ka.set(e,a),a}function Ja(e){let t=Ba(e.metadata)?.type;if(t!==void 0&&t!==`Object`)throw new Ca(`The scene's metadata says it is ${Ha(t)}; a scene is "Object", as Object3D.toJSON() writes it.`);Ya(e);let n=new Set;Va(e.geometries).forEach((e,t)=>{let r=Ba(e);if(!r||typeof r.uuid!=`string`||!r.uuid)throw new Ca(`Geometry ${t+1} needs a uuid: meshes name their geometry by it.`);if(!Ma.includes(r.type))throw new Ca(`${Ga(r,`Geometry`,t)} has type ${Ha(r.type)}: a geometry is one of ${Ua(Ma)} or BufferGeometry.`);for(let[e,n]of Object.entries({...r,...Ba(r.options)})){let i=/detail/i.test(e)?Oa:/segments|steps/i.test(e)?Da:1/0;if(typeof n==`number`&&n>i)throw new Ca(`${Ga(r,`Geometry`,t)} asks for ${n} ${e}; at most ${i} are drawn.`)}n.add(r.uuid)});let r=new Set;Va(e.materials).forEach((e,t)=>{let n=Ba(e);if(!n||typeof n.uuid!=`string`||!n.uuid)throw new Ca(`Material ${t+1} needs a uuid: meshes name their material by it.`);if(Pa.has(n.type))throw new Ca(`${Ga(n,`Material`,t)} is a ${n.type}: the board doesn't run shader code. Use MeshStandardMaterial or another built-in material.`);if(!Na.includes(n.type))throw new Ca(`${Ga(n,`Material`,t)} has type ${Ha(n.type)}: a material is one of ${Ua(Na)}.`);for(let e of Fa){let r=n[e];if(!(r===void 0||Number.isInteger(r)&&r>=0&&r<=16777215||typeof r==`string`&&Ia.test(r)))throw new Ca(`${Ga(n,`Material`,t)} has ${e} ${JSON.stringify(r)}: a colour is "#ff8800", or a number (0xff8800 is 16746496).`)}r.add(n.uuid)});for(let t of Va(e.images)){let e=Ba(t);for(let t of[e?.url].flat())if(typeof t==`string`&&!La.test(t))throw new Ca(`The scene's picture ${Ha(t)} isn't embedded, and the board fetches nothing from elsewhere: give it as a data: URL (data:image/png;base64,…).`)}let i=Ba(e.object);if(!i)throw new Ca(`The scene has no object, its root: e.g. { "type": "Scene", "children": [ … ] }.`);let a={objects:0,meshes:0,lights:0,cameras:0,geometries:n.size,materials:r.size,textures:Va(e.textures).length,animations:Va(e.animations).length,named:[]},o=[{node:i,path:`object`,depth:0}];for(;o.length>0;){let{node:e,path:t,depth:i}=o.pop(),s=Ba(e);if(!s)throw new Ca(`${t} isn't an object: each child is { "type": …, … }.`);if(i>Ea)throw new Ca(`The scene nests objects more than ${Ea} deep.`);if(++a.objects>Ta)throw new Ca(`A scene holds up to ${Ta.toLocaleString(`en-US`)} objects.`);let c=s.type;if(!Aa.includes(c))throw new Ca(`${Wa(s,t)} has type ${Ha(c)}: an object is one of Mesh, Group, Scene, a light (PointLight, DirectionalLight…) or a camera.`);for(let e of[`position`,`scale`,`rotation`]){let n=s[e];if(n!==void 0&&!(Array.isArray(n)&&n.length>=3&&n.slice(0,3).every(e=>typeof e==`number`&&Number.isFinite(e))))throw new Ca(`${Wa(s,t)} has ${e} ${H(JSON.stringify(n),40)}: it is [x, y, z].`)}if(c===`InstancedMesh`&&!(Number.isInteger(s.count)&&s.count>=0&&s.count<=ka))throw new Ca(`${Wa(s,t)} has count ${H(JSON.stringify(s.count),20)}: an InstancedMesh draws from 0 to ${ka.toLocaleString(`en-US`)} copies.`);if(ja.has(c)&&!n.has(s.geometry))throw new Ca(`${Wa(s,t)} uses geometry ${Ha(s.geometry)}, which isn't among the scene's geometries.`);for(let e of[s.material].flat())if(e!==void 0&&!r.has(e))throw new Ca(`${Wa(s,t)} uses material ${Ha(e)}, which isn't among the scene's materials.`);if(c.includes(`Mesh`)&&a.meshes++,(c.endsWith(`Light`)||c===`LightProbe`)&&a.lights++,c.endsWith(`Camera`)&&a.cameras++,typeof s.name==`string`&&s.name.trim()&&i>0&&a.named.push({name:s.name,type:c,...typeof s.uuid==`string`&&s.uuid?{uuid:s.uuid}:{}}),s.children!==void 0&&!Array.isArray(s.children))throw new Ca(`${Wa(s,t)} has children that aren't a list.`);let l=Va(s.children);for(let e=l.length-1;e>=0;e--)o.push({node:l[e],path:`${t}.children[${e}]`,depth:i+1})}return a}function Ya(e){let t=[e];for(;t.length>0;){let e=t.pop();if(typeof e==`string`){if(Ra.test(e))throw new Ca(`The scene names ${Ha(e)}, and the board fetches nothing from elsewhere: a scene brings what it uses with it.`)}else e&&typeof e==`object`&&t.push(...Object.values(e))}}function Xa(e,t,n){return(t?e.named.find(e=>e.uuid===t):void 0)??(n===void 0?void 0:e.named.find(e=>e.name===n))}var Za=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function Qa(e){let t=[Za(e.meshes,`mesh`,`meshes`),e.lights&&Za(e.lights,`light`),e.cameras&&Za(e.cameras,`camera`)],n=[Za(e.geometries,`geometry`,`geometries`),Za(e.materials,`material`),e.textures&&Za(e.textures,`texture`),e.animations&&Za(e.animations,`animation`)];return`${Za(e.objects,`object`)}: ${t.filter(Boolean).join(`, `)}; ${n.filter(Boolean).join(`, `)}`}function $a(e,t){return Math.max(0,...e.flatMap(e=>e.blockId===t&&e.anchor.kind===`spot`?[e.anchor.n]:[]))+1}var eo=(e,t)=>`spot ${e}${t?` on "${H(t,60)}"`:``}`;function to(e){if(e.includes(`
17
+ `))return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function no(e){try{return qa(e).facts}catch{return}}var ro={type:`scene`,label:`3D scene`,defaultSize:{w:460,h:400},untitled:e=>{let t=no(e.scene)?.named[0];return t?`scene "${H(t.name,40)}"`:void 0},fromSnapshot:e=>({scene:e.scene}),pins:{anchor:K.anchor,part:K.part,parts:{spot:{lost:`object removed`,same:(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z&&e.name===t.name,drawn:!0,askedTo:`change the scene`,where({anchor:e}){let t=e=>String(Number(e.toPrecision(3))+0),n=`x ${t(e.x)}, y ${t(e.y)}, z ${t(e.z)}`;return e.name?` (at ${n} on the object${e.object?`, uuid ${e.object}`:``})`:` (at ${n} in the scene)`},missing:e=>`Spots are pinned on 3D scenes; ${On(e)}.`}},place(e,t){if(t.anchor.kind!==`spot`)return;if(t.anchor.name===void 0)return{...t.anchor};let n=no(e.scene);return n&&Xa(n,t.anchor.object,t.anchor.name)?{...t.anchor}:null}},...K},io={w:520,h:420};function ao(e){let t=e.trim();if(!t||/^[a-z][a-z\d+.-]*:/i.test(t)||t.startsWith(`//`)||/[\0\r\n]/.test(t))return null;let n;try{n=new URL(t.startsWith(`/`)?t:`/${t}`,`http://site.invalid`)}catch{return null}let r=`${n.pathname}${n.search}`;return r.length<=300?r:null}function oo(e){if(e.title)return e.title;if(e.folder)return e.folder.split(/[\\/]/).filter(Boolean).at(-1)??e.folder;try{return new URL(e.url??``).host}catch{return`website`}}function so(e){if(e.folder)return`folder ${e.folder}`;try{return`dev server ${new URL(e.url??``).host}`}catch{return`no source`}}function co(e,t){return e.pages?.find(e=>e.path===t)?.title}var lo={h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,p:`paragraph`,a:`link`,button:`button`,img:`image`,picture:`image`,svg:`picture`,video:`video`,li:`list item`,ul:`list`,ol:`list`,dl:`list`,nav:`navigation`,header:`header`,footer:`footer`,section:`section`,article:`article`,aside:`aside`,main:`main content`,form:`form`,input:`field`,textarea:`field`,select:`field`,label:`label`,blockquote:`quote`,figure:`figure`,figcaption:`caption`,table:`table`,tr:`table row`,td:`table cell`,th:`table cell`,code:`code`,pre:`code`};function uo(e){return lo[e.toLowerCase()]??`element`}function fo(e){return e.replace(/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069]/g,` `).replace(/["“”„‟«»〝〞"]/g,`'`).replace(/\s+/g,` `).trim()}function po(e){return H(fo(e),160)}var mo=`(?:#[A-Za-z][\\w-]{0,99}|[a-z][a-z\\d-]{0,40}(?::nth-of-type\\([1-9]\\d{0,4}\\))?)`;RegExp(`^${mo}(?: > ${mo}){0,40}$`);function ho(e,t,n){let r=po(t);return r?`${uo(e)} “${H(r,80)}”`:`${uo(e)} ${H(n,80)}`}function go(e,t){return e?t?`${e}, line ${t}`:e:``}var _o={type:`site`,label:`Website`,defaultSize:io,untitled:e=>`site "${H(oo(e),50)}"`,fromSnapshot:e=>({...e.folder?{folder:e.folder}:{url:e.url},page:e.page}),pins:{anchor:K.anchor,part:K.part,parts:{site:{name:e=>`${e.quote} on ${e.anchor.page===`/`?`the home page`:`page ${e.anchor.page}`}`,lost:`no longer on the page`,same:(e,t)=>e.page===t.page&&e.selector===t.selector,askedTo:`change the site's file`,where:({anchor:e})=>` (${H(e.selector,100)}${e.file?`; ${go(H(e.file,120),e.line)}`:``})`,missing:e=>`Elements are pinned on websites; ${On(e)}.`}},place:(e,t)=>t.anchor.kind===`site`?{kind:`site`,page:t.anchor.page,selector:t.anchor.selector}:void 0},...K},vo={type:`note`,label:`Note`,defaultSize:{w:300,h:200},untitled:e=>e.text.trim()?`note "${H(e.text,40)}"`:void 0,refText:e=>[e.text],fromSnapshot:e=>({text:e.text}),pins:{anchor:K.anchor,part:K.part,parts:{text:{name:e=>`"${H(e.quote,80)}"`,quote:e=>`“${e.quote}”`,lost:`text changed`,words:!0,askedTo:`rewrite the note's text`,missing:e=>`Words are pinned in notes; ${On(e)}.`}},place(e,t){if(t.anchor.kind!==`text`)return;let n=Jo(qo(e.text),t.quote,t.anchor);return n&&{kind:`text`,...n}}},...K};function yo(e,t,n){for(let r=0;r<=Math.max(e,t-e);r++)for(let i of r===0?[e]:[e-r,e+r])if(i>=0&&i<=t&&n(i))return i;return null}function bo(e,t){let n=null;if(t.columns){let r=t.columns[1]-t.columns[0]+1,i=yo(t.columns[0],e.columns.length-r,n=>t.headers.every((t,r)=>e.columns[n+r]===t));if(i===null)return null;n=[i,i+r-1]}let r=null;if(t.rows){let i=t.rows[1]-t.rows[0]+1,a=n?.[0]??0,o=yo(t.rows[0],e.rows.length-i,n=>t.cells.every((t,r)=>t.every((t,i)=>e.rows[n+r][a+i]===t)));if(o===null)return null;r=[o,o+i-1]}return{kind:`cells`,rows:r,columns:n}}var xo={type:`table`,label:`Table`,defaultSize:{w:460,h:260},refText:e=>[...e.columns,...e.rows.flat()],fromSnapshot:e=>({columns:e.columns,rows:e.rows}),pins:{anchor:K.anchor,part:K.part,parts:{cells:{lost:`cells changed`,drawn:!0,askedTo:`change the table`,missing:e=>`Only tables have cells; ${On(e)}.`}},place:(e,t)=>t.anchor.kind===`cells`?bo(e,t.anchor):void 0},...K},So=()=>[vo,xo,Gr,Fr,Sr,Sa,Ir,xr,jn,ro,_o],Co;function wo(){return Co??=So()}function To(e){return wo().find(t=>t.type===e)}function Eo(e){let t=To(e);if(!t)throw Error(`Unknown block type "${e}".`);return t}function Do(e,t){let n=sa(e)?.pins;if(n)return n;let r=e;return(t&&Eo(t.type).pins?.parts?.[r])??wo().find(e=>e.pins?.parts?.[r])?.pins?.parts?.[r]}function Oo(e){return(e.pages??[]).filter(e=>!jo(e)).sort((e,t)=>e.rank-t.rank)}function ko(e){return jo(e)?Ao:`Sketchbook page "${H(e.title,60)}"`}var Ao=`Files`,jo=e=>e.files===!0,Mo=e=>e.pages?.find(jo);function No(e){if(!e)return;if(!e.asked)return`Made by ${e.name}`;let t=e.tool?Je(e.tool)?.name:void 0;return`${t?`Asked in ${t}`:`Asked of ${e.name}`}: “${e.asked}”`}function Po(e,t){let n=e?.agent?.name;return!n||t?.agent?t??null:{...t??{name:`General`},agent:n}}function Fo(e,t){return e.pages?.find(e=>e.id===t||[e.canvas.blocks,e.canvas.groups,e.canvas.links,e.canvas.pins].some(e=>e.some(e=>e.id===t)))}var Io=32,Lo=new Set([`*`,`_`,"`",`~`]);function Ro(e){let t=``,n=[],r=!0;for(let i=0;i<e.length;i++){let a=e[i];if(Lo.has(a))continue;let o=/\s/.test(a);o&&r||(r=o,t+=o?` `:a,n.push(i))}return{text:t,from:n}}function zo(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}function Bo(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Vo(e){return e.replace(/\s+/g,` `).trim()}function Ho(e,t,n={}){let r=Ro(t).text.trim();if(!r)return null;let i=Ro(e),{prefix:a=``,suffix:o=``,occurrence:s}=n,c=null,l=0;for(let e=i.text.indexOf(r);e!==-1;e=i.text.indexOf(r,e+1)){if(s!==void 0){if(++l<s)continue;c={at:e,score:0};break}let t=i.text.slice(Math.max(0,e-Io),e),n=i.text.slice(e+r.length,e+r.length+Io),u=zo(t,a)+Bo(n,o);(!c||u>c.score)&&(c={at:e,score:u})}return c?{start:i.from[c.at],end:i.from[c.at+r.length-1]+1}:null}function Uo(e,t,n){let r=Vo(e.slice(t,n));if(!Ro(r).text.trim())return null;let i=Ro(e),a=i.from.findIndex(n=>n>=t&&!/\s/.test(e[n])),o=i.from.length-1;for(;o>=0&&(i.from[o]>=n||/\s/.test(e[i.from[o]]));)o--;return a===-1||o<a?null:{quote:r,prefix:i.text.slice(Math.max(0,a-Io),a),suffix:i.text.slice(o+1,o+1+Io)}}var Wo={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:` `,copy:`©`,reg:`®`,trade:`™`,hellip:`…`,mdash:`—`,ndash:`–`,larr:`←`,rarr:`→`};function Go(e,t){let n=t.startsWith(`#x`)||t.startsWith(`#X`)?parseInt(t.slice(2),16):t.startsWith(`#`)?Number(t.slice(1)):NaN;return Number.isNaN(n)?Wo[t]??e:n>0&&n<=1114111?String.fromCodePoint(n):e}function Ko(e){return e.replace(/!\[([^\]]*)\]\(\s*<?([^\s)>]*)>?[^)]*\)/g,(e,t,n)=>t||n).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/<((?:https?|mailto):[^>\s]+)>/g,`$1`).replace(/<\/?[a-z][^>]*>/gi,``).replace(/\\([!-/:-@[-`{-~])/g,`$1`).replace(/&(#\d{1,7}|#[xX][\da-fA-F]{1,6}|[a-zA-Z]{2,8});/g,Go)}function qo(e){return Ko(e.split(`
18
+ `).filter(e=>!/^\s*(```|~~~)/.test(e)&&!/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(e)&&!/^\s{0,3}=+\s*$/.test(e)).filter(e=>!/^\s{0,3}\[[^\]]+\]:\s*\S/.test(e)).filter(e=>!(/^[\s|:-]*$/.test(e)&&e.includes(`|`)&&e.includes(`-`))).map(e=>e.replace(/^\s{0,3}(>\s?)+/,``).replace(/^\s*(#{1,6}\s+|(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?)/,``)).join(`
19
+ `).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`))}function Jo(e,t,n={}){let r=Ho(e,t,n);if(r)return r;let i=Ko(t);return i===t?null:Ho(e,i,n)}function Yo(e,t){return t.anchor.kind===`block`?{kind:`block`}:Eo(e.type).pins?.place?.(e,t)??null}function Xo(e){return e&&Eo(e.type).pins?.whole?.word||`block`}function Zo(e,t){return e.anchor.kind===`block`?`the whole ${Xo(t)}`:Do(e.anchor.kind,t)?.name?.(e)??e.quote}function Qo(e,t){if(e.anchor.kind===`block`)return`${e.quote} · the whole ${Xo(t)}`;let n=Do(e.anchor.kind,t)?.quote;if(n)return n(e);let r=t?t.title||Eo(t.type).label:``,i=Zo(e,t);return r?`${r} · ${i}`:i}function $o(e,t){return Do(e.anchor.kind,t)?.lost??`text changed`}function es(e,t,n){if(e.kind!==t.kind)return!1;let r=Do(e.kind,n)?.same;return r?r(e,t):JSON.stringify(e)===JSON.stringify(t)}function ts(e,t){if(t.discussion)return null;let n=jt(e,t);return n?{ref:n.label,status:n.statusWord??``,title:n.title,done:n.settled}:null}function ns(e){return[{canvas:e.canvas},...Ot(e).map(e=>({canvas:e.canvas,[e.kind.kind]:e.card})),...(e.pages??[]).map(e=>({canvas:e.canvas,page:e}))]}function rs(e){return[{canvas:e.canvas},...(e.pages??[]).map(e=>({canvas:e.canvas,page:e}))]}function is(e,t){if(t)for(let n of rs(e)){let e=n.canvas.pins.find(e=>e.id===t);if(e)return{...n,pin:e}}}function as(e,t){if(!e.discussion)return[];let n=Ft(t);return n?n.comments.filter(t=>t.pin?.id===e.id):e.discussion.thread??[]}function os(e){let t=e.heading??`${e.label} "${H(e.title,80)}"${e.status?`: ${e.status}`:``}.`;return{key:`${e.kind.kind}:${e.id}`,items:e.comments,noun:`comment`,read:`get_${e.kind.kind}`,heading:t}}function ss(e,t){return{key:`thread:${e.id}`,items:e.messages,noun:`message`,read:`get_thread`,heading:t}}function cs(e,t){let n=is(e,t.id)?.page,r=n?`get_canvas(page_id: ${n.id})`:`get_canvas(board_id: ${e.id})`;return{key:`pin:${t.id}`,items:t.discussion?.thread??[],noun:`comment`,read:r}}function ls(e,t){let n=e.commentId;if(!n)return;let r=e=>{let t=e?.items.find(e=>e.id===n);return e&&t?{discussion:e,said:t}:void 0};if(It(e)){let r=Rt(e,t,e=>e.id===n);return r&&{discussion:os(r.card),said:r.comment}}if(e.type.startsWith(`thread_`)){let n=t.threads?.find(t=>t.id===e.itemId);return r(n&&ss(n))}let i=is(t,e.itemId)?.pin;return r(i&&cs(t,i))}var us=/[\p{L}\p{N}_.\/+\-[\]]/u,ds=/[\p{L}\p{N}_-]/u,fs=/^(?:$|[\s,;.!?)\]}"'”’…]|:(?:$|\s))/u,ps=(e,t,n)=>{let r=t;for(;r<e.length&&n.test(e[r]);)r++;return r};function ms(e,t){if(e[t]!==`:`)return;let n=ps(e,t+1,us);for(;n>t+1&&e[n-1]===`.`;)n--;let r=e.slice(t+1,n),i=n,a=``;if(e[n]===`:`){let t=ps(e,n+1,ds);a=e.slice(n+1,t),a&&(i=t)}if((r||a)&&fs.test(e.slice(i)))return{tag:{...r&&{model:r},...a&&{effort:a}},end:i}}function hs(e){return!e?.model&&!e?.effort?``:e.effort?`:${e.model??``}:${e.effort}`:`:${e.model}`}function gs(e,t){if(!e?.perMessage)return[];if(t===`level`)return(e.startsOn?.levels??[]).map(e=>e.id);let n=e.perMessage.models;return(e.startsOn?.models??[]).map(e=>e.id).filter(e=>!n||n.some(t=>t.toLowerCase()===e.toLowerCase()))}function _s(e,t){return e.author.kind===`agent`?t(e.mentions).filter(t=>!U(t,e.author.name)):[]}function vs(e,t){let n=e.slice(e.findLastIndex(e=>e.author.kind===`human`)+1);if(!n.some(e=>e.held))return;let r=[];for(let e of n){let n=_s(e,t);if(n.length)for(let t of[e.author.name,...n])r.some(e=>U(e,t))||r.push(t)}return r}function ys(e){return`${G(e)} have gone back and forth here; they'll wait for a person before tagging each other again.`}var bs=[{name:`General`},{name:`Legal`,brief:`Review licences, terms of service and privacy. Flag each risk, say how serious it is, and cite your source.`},{name:`Design`,brief:`Look at it as a product designer: flows, clarity and visuals. Show mocks or screenshots rather than describe them.`},{name:`Performance`,brief:`Measure before you claim. Give numbers and profiles, and what each fix would cost.`},{name:`Security`,brief:`Look for ways it could be misused or leak data. Be concrete: where it happens, and how to fix it.`},{name:`Architect`,brief:`Look at it as a software architect: how it is structured, where the boundaries are, and how it will grow. Prefer designs that stay extensible and fit the codebase's own conventions. Name the trade-offs and what a later change would cost, and draw a diagram when it helps.`},{name:`Marketing`,brief:`Look at it as a marketer: who it is for, what to say and where to say it. Give concrete copy, channels and ways to measure each, and say what you are unsure of rather than inventing numbers.`}],xs=/^\s*\^([\p{L}\p{N}](?:[\p{L}\p{N}_-]*[\p{L}\p{N}])?)(?![\p{L}\p{N}_-])/u;function Ss(e){if(typeof e!=`string`)return;let t=xs.exec(e);if(!t)return;let n=t[1],r=bs.find(e=>e.name.toLowerCase()===n.toLowerCase());return r?{lens:r}:{unknown:n}}function Cs(e,t){return e.deletedCards?.find(e=>e.id===t)}function ws(e){return/^v\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1)}function Ts(e,t){return Mo(e)?.canvas.blocks.find(e=>e.type===`code`&&e.path===t)}function Es(e,t,n){let r=Mo(e),i=Ts(e,t);if(!r||!i)return;let a=r.canvas.pins.filter(e=>e.blockId===i.id).flatMap(e=>e.discussion?.thread??[]).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));for(let e of a){let t=e.author.kind===`agent`?[e.author.name]:e.mentions??[];for(let e of t){let t=n.find(t=>U(t,e));if(t)return t}}}var Ds=e=>!!(e&&jo(e));function Os(e,t){let n=t.pageId?e.pages?.find(e=>e.id===t.pageId):void 0,r=t.blockIds?.[0];if(!n||!r||!Ds(n))return;let i=n.canvas.blocks.find(e=>e.id===r);return{page:n,blockId:r,...i?.type===`code`&&{path:i.path}}}var ks=(e,t=48)=>rr(e,t);function As(e){return e.path?`Files · ${ks(e.path)}`:`Files`}var js={canvas:{name:`Board`,placeholder:`Ask agents for a view of the project…`,tab:!0},threads:{name:`Threads`,placeholder:`What do you want to work through?`}},Ms={},Ns=e=>Ms[e]??js[e],Ps=e=>Ns(e)?.name,Fs=e=>Ns(e)?.placeholder??``;function Is(e,t){return Ns(e)?.question&&t===0?`question`:`thread`}var Ls=e=>`${e} block${e===1?``:`s`}`;function Rs(e,t){return e.threads?.findLast(e=>e.groupId===t)}var zs=(e,t)=>Ot(e).filter(e=>e.fromThread?.id===t.id);function Bs(e,t){let n=zs(e,t);return Object.fromEntries(wt().map(({kind:e})=>[`${e}Ids`,n.filter(t=>t.kind.kind===e).map(e=>e.id)]))}var Vs=[`👍`,`👎`,`👀`],Hs={"👍":`Thumbs up`,"👎":`Thumbs down`,"👀":`Eyes`},Us=[`👍`,`👎`],Ws=e=>t=>t.by.kind===e.kind&&U(t.by.name,e.name);function Gs(e,t,n){return!!e.reactions?.some(e=>e.emoji===t&&Ws(n)(e))}function Ks(e,t){return!!e.reactions?.some(e=>U(e.by.name,t))}function qs(e,t){return!!e.reactions?.some(e=>Us.includes(e.emoji)&&U(e.by.name,t))}function Js(e){return Us.includes(e)}function Ys(e){return Vs.flatMap(t=>{let n=(e??[]).filter(e=>e.emoji===t);return n.length?[{emoji:t,reactions:n}]:[]})}var Xs=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Zs=e=>new RegExp(String.raw`(?<![\p{L}\p{N}_&#])(${e.map(Xs).join(`|`)})([1-9]\d{0,5})(?![\p{L}\p{N}_…]|[.,]\p{N})`,`gu`),Qs=new Set([`code`,`pre`,`kbd`,`samp`,`a`]);function $s(e){let t=new Map;for(let{kind:n,marks:r}of e)for(let e of r){if(t.has(e))throw Error(`Two kinds of reference are written with ${e}.`);t.set(e,n)}let n=[...t.keys()].sort((e,t)=>t.length-e.length),r=n.length?Zs(n):null,i=(e,n)=>{let i=[];if(!r)return i;for(let a of e.matchAll(r)){let e=t.get(a[1]),r=Number(a[2]);n(e,r)&&i.push({kind:e,number:r,start:a.index,end:a.index+a[0].length})}return i},a=(e,t)=>{let n=[],r=0;for(let a of i(e,t))a.start>r&&n.push(e.slice(r,a.start)),n.push(a),r=a.end;return r<e.length&&n.push(e.slice(r)),n};return{find:i,split:a,rehype:({known:e})=>t=>{let n=t=>{t.children=t.children.flatMap(t=>{if(t.type===`element`&&!Qs.has(t.tagName)&&n(t),t.type!==`text`)return[t];let r=t.value;return a(r,e).map(e=>typeof e==`string`?{type:`text`,value:e}:{type:`element`,tagName:`a`,properties:{dataRef:`${e.kind}:${e.number}`},children:[{type:`text`,value:r.slice(e.start,e.end)}]})})};n(t)}}}function ec(e){let t=typeof e==`string`?e.match(/^([a-z][a-z0-9_-]*):(\d+)$/i):null;return t?{kind:t[1],number:Number(t[2])}:null}var tc=class{all=[];scan;add(e){if(this.find(e.id))throw Error(`There are two kinds of reference named ${e.id}.`);if(e.marks.length===0)throw Error(`The kind of reference ${e.id} has no mark to be written with.`);for(let t of e.marks){let n=this.all.find(e=>e.marks.includes(t));if(n)throw Error(`The kinds of reference ${n.id} and ${e.id} are both written with ${t}.`)}this.all.push(e),this.scan=void 0}kinds(){return this.all}find(e){return this.all.find(t=>t.id===e)}scanner(){if(this.all.length!==0)return this.scan??=$s(this.all.map(({id:e,marks:t})=>({kind:e,marks:t})))}label(e,t){let n=this.find(e)?.marks[0];return n===void 0?void 0:`${n}${t}`}},nc={blocks:300,text:2e4,columns:20,rows:300,cell:2e3,items:300,itemText:500,title:120,url:2e3,pins:500,pages:100,asked:300,quote:1e3,pinnedCells:200,prompt:2e3,area:60,focus:50,boardTitle:200,goal:2e3,standing:1500,comment:1e4,message:1e4,request:500,lensName:24,lensBrief:300,note:2e3,longNote:4e3,rationale:4e3,reason:500,optionLabel:200,optionDescription:4e3,options:26,criterion:120,criteria:12,askNames:10,name:60,taskTitle:200,taskDetail:4e3,taskLink:500,noCommit:300,tasks:50,backlogCards:5,revision:200,affects:12,affectWhy:200,revisit:50,pinContext:200,moves:500,syncBlocks:1e3,skills:300,skillName:60,skillDescription:200,skillInstructions:8e3,tricotSkills:100,step:160,stepId:120},rc=nc.message;function ic(e,t=[],n=[]){let r=Cc(e,t,n).replace(/\s+/g,` `).trim().split(/(?<=[.?!])\s/)[0];if(r=r.charAt(0).toUpperCase()+r.slice(1),r.length<=100)return r;let i=r.slice(0,99),a=i.lastIndexOf(` `);return`${(a>50?i.slice(0,a):i).replace(/[\s,.;:-]+$/,``)}…`}function ac(e){let t=e.messages[0];if(e.general||!t||!e.title.endsWith(`…`))return e.title;let n=ic(t.body,t.mentions??[]);return n.length>e.title.length&&n.startsWith(e.title.slice(0,-1))?n:e.title}var oc=nc.lensName,sc=nc.lensBrief;function cc(e){return bs.find(t=>U(t.name,e.trim()))}function lc(e,t,n){let r=cc(e);return r?.name===`General`&&!n?null:{name:r?.name??e,...!r&&t?{brief:t}:{},...n?{agent:n}:{}}}function uc(e,t,n){let r=jc(e,n.mentions);return r.length||n.author.kind!==`human`||n.mentions?.length?r:t.lens?.agent?[t.lens.agent]:[]}function dc(e,t){let n={kind:`gone`,ref:t};if(t.kind===`comment`){let r=t.on?At(e,t.on):void 0,i=r?.comments.find(e=>e.id===t.id);return r&&i?{kind:`comment`,comment:i,on:r}:n}if(t.kind===`block`)return fc(e,t.id)??n;let r=kt(e,t.kind,t.id);return r?{kind:r.kind.kind,card:r}:n}function fc(e,t){let n=e.canvas.blocks.find(e=>e.id===t);if(n)return{kind:`block`,block:n};for(let n of Ot(e)){let e=n.canvas.blocks.find(e=>e.id===t);if(e)return{kind:`block`,block:e,on:n}}for(let n of e.pages??[]){let e=n.canvas.blocks.find(e=>e.id===t);if(e)return{kind:`block`,block:e,page:n}}}function pc(e,t){let n=e=>e.kind===t.kind&&e.id===t.id;return e.messages.some(e=>e.refs?.some(n))||!!e.pending?.some(n)}function mc(e,t,n){let r=Cs(e,t.id),i=r&&n(r.kind,r.number);return i?`${i}, since deleted`:`a ${t.kind===`block`||n(t.kind,0)?t.kind:`card`} since removed`}function hc(e,t){let n=t.messages.findLastIndex(e=>e.author.kind===`human`);if(n<0)return;let r=t.messages[n],i=t.messages.slice(n+1).filter(e=>e.author.kind===`agent`),a=e=>i.some(t=>U(t.author.name,e))||qs(r,e),o=uc(e,t,r);if(o.length){let e=o.filter(e=>!a(e));return e.length?{message:r,agents:e}:void 0}let s=r.reactions?.some(e=>e.by.kind===`agent`&&qs(r,e.by.name));if(!(Mc(e,r.mentions).length||i.length||s))return{message:r,agents:[]}}function gc(e,t=[]){let n=[],r=e=>{let t=e.trim();t&&!n.some(e=>U(e,t))&&n.push(t)};t.forEach(r);for(let{actor:t}of e.activity.actors)t.kind===`agent`&&r(t.name);return n}function _c(e,t,n){if(!n)return`not connected`;if(n.state===`away`)return`not checking`;if(n.state===`listening`||n.state===`asleep`)return n.state;let r=n.focus&&kt(e,n.focus.kind,n.focus.id),i=r?.kind.workedBy?r:void 0,a=Ot(e).find(e=>e.workedBy?.kind===`agent`&&U(e.workedBy.name,t)),o=i??a;return o?`working on ${o.label}`:`working`}function vc(e){return W(e).map(e=>e.name)}var yc=/[\p{L}\p{N}_.@/-]/u,bc=/[\p{L}\p{N}_]/u;function xc(e,t,n=[]){let r=[...new Set(t.map(e=>e.trim()).filter(Boolean))].sort((e,t)=>t.length-e.length);if(r.length===0)return[];let i=[];for(let t=e.indexOf(`@`);t>=0;t=e.indexOf(`@`,t+1)){if(t>0&&yc.test(e[t-1]))continue;let a=e.slice(t+1).toLowerCase(),o=r.find(n=>a.startsWith(n.toLowerCase())&&!bc.test(e[t+1+n.length]??``));if(!o)continue;let s=t+1+o.length,c=n.some(e=>U(e,o))?ms(e,s):void 0;i.push({name:o,start:t,end:c?.end??s,...c&&{tag:c.tag}}),t=(c?.end??s)-1}return i}function Sc(e,t){let n=[];for(let{name:r}of xc(e,t))n.some(e=>U(e,r))||n.push(r);return n}function Cc(e,t,n=[]){let r=e.trimStart();for(;;){let[e]=xc(r,t,n);if(!e||e.start!==0)break;r=r.slice(e.end).replace(/^[\s,:;-]+/,``)}return r.trim()?r:e}function wc(e,t,n=[]){let r=[],i=e.trimStart();for(;;){let[e]=xc(i,t,n);if(!e||e.start!==0)break;r.push(e.name),i=i.slice(e.end).replace(/^[\s,:;-]+/,``)}return{names:r,rest:i}}var Tc=/(?:^|[^\p{L}\p{N}_.@/-])@([\p{L}\p{N}_.\- ]{0,30})$/u,Ec=/(?:^|\s)\/([\w.:-]{0,60})$/;function Dc(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n.startsWith(r)||n.split(/\s+/).some(e=>e.startsWith(r))}function Oc(e,t,n,r=``){let i=e.slice(t.at+1+t.query.length),a=`@${n}${r}${i.startsWith(` `)?``:` `}`;return{text:e.slice(0,t.at)+a+i,caret:t.at+a.length+ +!!i.startsWith(` `)}}function kc(e,t,n,r,i){let a=e.slice(0,t.at).replace(/[ \t]+$/,``),o=e.slice(t.at+1+t.query.length).replace(/^[ \t]+/,``),{rest:s}=wc(a&&o?`${a} ${o}`:a+o,i),c=`@${n} /${r} `;return{text:c+s,caret:c.length}}function Ac(e,t){let n=xc(e,t);if(n.length===0)return{question:e.trim()};let r=e.slice(0,n[0].start).replace(/[\s,;:–—-]+$/,``).trim();if(!r){let t=``,i=0;for(let{start:r,end:a}of n)t+=e.slice(i,r),i=a;t+=e.slice(i),r=t.replace(/\s+/g,` `).replace(/[\s,;:–—-]+([.?!]|$)/g,`$1`).replace(/ ([,;:])/g,`$1`).replace(/^[\s,.;:–—-]+/,``)}return{question:r,comment:e.slice(n[0].start).trim()}}function jc(e,t){if(!t?.length)return[];let n=vc(e);return t.filter(e=>!n.some(t=>U(t,e)))}function Mc(e,t){if(!t?.length)return[];let n=vc(e);return t.filter(e=>n.some(t=>U(t,e)))}function Nc(e,t,n){let r=e=>e.author.kind===`human`&&U(e.author.name,n);return!n||r(e)||!e.mentions?.some(e=>U(e,n))||qs(e,n)?!1:!t.slice(t.indexOf(e)+1).some(r)}var Pc=new Set([`code`,`pre`,`kbd`,`samp`,`a`]);function Fc({names:e,agents:t=[]}){return n=>{if(e.length===0)return;let r=n=>{n.children=n.children.flatMap(n=>{if(n.type===`element`&&!Pc.has(n.tagName)&&r(n),n.type!==`text`)return[n];let i=[],a=0;for(let r of xc(n.value,e,t))r.start>a&&i.push({type:`text`,value:n.value.slice(a,r.start)}),i.push({type:`element`,tagName:`span`,properties:{className:[`mention`],dataMention:r.name},children:[{type:`text`,value:n.value.slice(r.start,r.end)}]}),a=r.end;return i.length===0?[n]:(a<n.value.length&&i.push({type:`text`,value:n.value.slice(a)}),i)})};r(n)}}var Ic=36e5,Lc=24*Ic,Rc=168*Ic,zc=(e,t)=>e.author.kind===`human`&&U(e.author.name,t);function Bc(e,t){return e.messages.slice(e.messages.findIndex(e=>e.id===t)+1)}function Vc(e,t,n,r){let i=t.messages.at(-1);if(!i||i.author.kind!==`agent`||!Bc(t,r).includes(i))return!1;let a=Mc(e,i.mentions);if(a.length)return a.some(e=>U(e,n));let o=t.messages.filter(e=>e.author.kind===`human`);return o.length===0||o.some(e=>zc(e,n))}function Hc(e,t,n){return Bc(e,n).some(e=>!zc(e,t))}function Uc(e,t){return Gc(e,t,[...t.messages.flatMap(e=>e.refs??[]),...t.pending??[]]).labels}function Wc(e){let t=(e,t)=>e===1?`a ${t}`:`${e} ${t}s`,n=e.filter(e=>e.startsWith(`#`)).length,r=e.filter(e=>/^T\d/.test(e)).length,i=Number(e.find(e=>/^\d+ blocks?$/.test(e))?.split(` `)[0]??0),a=[n?t(n,`question`):``,r?t(r,`task`):``].filter(Boolean),o=[a.length?`made ${a.join(` and `)}`:``,i?`added ${t(i,`block`)}`:``].filter(Boolean);return o.length?o.join(`, `):void 0}function Gc(e,t,n){let r=new Set,i=[],a=[],o=0;for(let s of n){let n=`${s.kind}:${s.id}`;if(r.has(n))continue;if(r.add(n),s.kind===`block`){dc(e,s).kind===`block`&&(o+=1);continue}let c=kt(e,s.kind,s.id);c?.fromThread?.id===t.id&&(i.push(c.label),a.push(c.id))}return o&&i.push(`${o} block${o===1?``:`s`}`),{labels:i,ids:a}}function Kc(e,t){if(e.general)return Ps(`canvas`);let n=t&&Os(t,e);return n?As(n):e.pageId?e.blockIds?.length?`Sketchbook · ${Ls(e.blockIds.length)}`:`Sketchbook`:e.door&&e.door!==`threads`?Ps(e.door):void 0}function qc(e,t,n){return!hc(e,t)&&n-Date.parse(t.updatedAt)>=(Uc(e,t).length?Lc:Rc)}var Jc=(e,t)=>t.thread.updatedAt.localeCompare(e.thread.updatedAt);function Yc(e,t,n,r){let i={waiting:[],recent:[],earlier:[]};for(let a of e.threads??[]){let o=n?.[a.id],s=!!n&&Vc(e,a,t,o),c={thread:a,waiting:s,unread:!!n&&Hc(a,t,o),tag:Kc(a,e),made:Uc(e,a)};s?i.waiting.push(c):qc(e,a,r)?i.earlier.push(c):i.recent.push(c)}return i.waiting.sort(Jc),i.recent.sort(Jc),i.earlier.sort(Jc),i}function Xc(e,t,n){return n?(e.threads??[]).filter(r=>Vc(e,r,t,n[r.id])).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)):[]}function Zc(e,t){let n=new Set((e.threads??[]).filter(e=>e.startedBy.kind===`human`&&U(e.startedBy.name,t)||e.messages.some(e=>zc(e,t))).map(e=>e.id));return Ot(e).filter(e=>e.createdBy?.kind===`agent`&&e.fromThread&&n.has(e.fromThread.id)).map(e=>e.id)}var Qc=[`comment_added`,`thread_started`,`thread_replied`];function $c(e,t,n,r){let i=new Set(Xc(e,n,r).map(e=>e.id)),a=new Map;for(let o of t){if(!Qc.includes(o.type)||o.held)continue;let t=ls(o,e);if(!t)continue;let{discussion:s,said:c}=t,l=tl(e,o);if(!l||l.kind===`thread`&&(i.has(l.thread.id)||!el(l.thread,c,r))||c.held||c.author.kind===`human`&&U(c.author.name,n)||Ks(c,n))continue;let u=c.mentions?.some(e=>U(e,n));if(!u&&Mc(e,c.mentions).length>0)continue;let d=s.items.slice(0,s.items.indexOf(c)).some(e=>e.author.kind===`human`&&U(e.author.name,n));(u||d)&&(a.delete(s.key),a.set(s.key,{key:s.key,event:o,said:c,why:u?`mention`:`reply`,place:l}))}return[...a.values()].reverse()}function el(e,t,n){if(!n)return!1;let r=e.messages.findIndex(t=>t.id===n[e.id]);return e.messages.findIndex(e=>e.id===t.id)>r}function tl(e,t){if(t.type.startsWith(`thread_`)){let n=e.threads?.find(e=>e.id===t.itemId);return n&&{kind:`thread`,thread:n}}let n=is(e,t.itemId);return n?.page&&{kind:`pin`,pinId:n.pin.id,page:n.page}}function nl(e){return e.aliases?.[0]??e.id}var J={info:Kr(`/api/info`),chooseFolder:q(`/api/folders/choose`),instance:Kr(`/api/instance`),update:Kr(`/api/update`),startUpdate:q(`/api/update`),checkForUpdates:q(`/api/update/check`),stop:q(`/api/stop`),boards:Kr(`/api/boards`),needs:Kr(`/api/needs`),createBoard:q(`/api/boards`),board:Kr(`/api/boards/:boardId`),updateBoard:q(`/api/boards/:boardId`),archiveBoard:q(`/api/boards/:boardId/archive`),unarchiveBoard:q(`/api/boards/:boardId/unarchive`),deleteBoard:q(`/api/boards/:boardId/delete`),boardLive:Kr(`/api/boards/:boardId/live`),boardEvents:Kr(`/api/boards/:boardId/events`),boardStream:Kr(`/api/boards/:boardId/stream`),wakes:q(`/api/boards/:boardId/wakes`),listen:q(`/api/boards/:boardId/listen`),boardSearch:Kr(`/api/boards/:boardId/search`),projectFiles:Kr(`/api/boards/:boardId/files`),projectFile:Kr(`/api/boards/:boardId/files/read`),projectSearch:Kr(`/api/boards/:boardId/files/search`),projectImage:Kr(`/api/boards/:boardId/files/image`),projectFileBlock:q(`/api/boards/:boardId/files/block`),projectFileWrite:q(`/api/boards/:boardId/files/write`),search:Kr(`/api/search`),requestSync:q(`/api/boards/:boardId/sync`),cancelSync:q(`/api/boards/:boardId/sync/cancel`),askAgents:q(`/api/boards/:boardId/requests`),cancelRequest:q(`/api/boards/:boardId/requests/:requestId/cancel`),boardThreads:Kr(`/api/boards/:boardId/threads`),startThread:q(`/api/boards/:boardId/threads`),askInGeneral:q(`/api/boards/:boardId/threads/general`),thread:Kr(`/api/threads/:threadId`),postToThread:q(`/api/threads/:threadId/messages`),setThreadLens:q(`/api/threads/:threadId/lens`),reactToThreadMessage:q(`/api/threads/:threadId/messages/:commentId/reactions`),reactToPinComment:q(`/api/canvas/pins/:pinId/comments/:commentId/reactions`),addPage:q(`/api/boards/:boardId/pages`),updatePage:q(`/api/pages/:pageId`),deletePage:q(`/api/pages/:pageId/delete`),askOnPage:q(`/api/pages/:pageId/requests`),addBlock:q(`/api/canvas/blocks`),updateBlock:q(`/api/canvas/blocks/:id`),deriveBlock:q(`/api/canvas/blocks/:id/chart`),blockVersions:Kr(`/api/canvas/blocks/:id/versions`),blockVersion:Kr(`/api/canvas/blocks/:id/versions/:rev`),deleteVersion:q(`/api/canvas/blocks/:id/versions/:rev/delete`),deleteEarlierVersions:q(`/api/canvas/blocks/:id/versions/delete`),restoreBlock:q(`/api/canvas/blocks/:id/restore`),pinComment:q(`/api/canvas/blocks/:id/pins/comment`),pinToCard:q(`/api/canvas/blocks/:id/pins`),commentOnPin:q(`/api/canvas/pins/:id/comments`),resolvePin:q(`/api/canvas/pins/:id/resolve`),moveItems:q(`/api/canvas/move`),pasteBlocks:q(`/api/canvas/paste`),addGroup:q(`/api/canvas/groups`),renameGroup:q(`/api/canvas/groups/:id`),addLink:q(`/api/canvas/links`),relabelLink:q(`/api/canvas/links/:id`),removeItem:q(`/api/canvas/items/:id/delete`),restoreItem:q(`/api/canvas/items/:id/restore`),uploadAsset:q(`/api/assets`),asset:Kr(`/api/assets/:id`),siteAddress:Kr(`/api/sites/:blockId`),startPairing:q(`/api/pairing`),pairingBeat:q(`/api/pairing/:id/beat`),endPairing:q(`/api/pairing/:id/end`),stepsStream:Kr(`/api/steps/stream`),recordStep:q(`/api/agents/:name/steps`),liveSteps:Kr(`/api/live-steps`),previewLiveSteps:q(`/api/live-steps/:agent/preview`),applyLiveSteps:q(`/api/live-steps/:agent/apply`),agents:Kr(`/api/agents`),recordUsage:q(`/api/agents/:name/usage`),agentUsage:Kr(`/api/agents/:name/usage`),toolCosts:Kr(`/api/tool-costs`),agentRules:Kr(`/api/agent-rules`),setAgentRule:q(`/api/agent-rules/:agent`),addSkill:q(`/api/skills`),editSkill:q(`/api/skills/:skillId`),deleteSkill:q(`/api/skills/:skillId/delete`),registerHost:q(`/api/approvals/hosts`),hostHeartbeat:q(`/api/approvals/hosts/heartbeat`),hostRelease:q(`/api/approvals/hosts/release`),requestApproval:q(`/api/agents/:name/approvals`),waitForApproval:q(`/api/approvals/:id/wait`),withdrawApproval:q(`/api/approvals/:id/withdraw`),approvals:Kr(`/api/approvals`),approvalsStream:Kr(`/api/approvals/stream`),answerApproval:q(`/api/approvals/:id/answer`),askToBeLetIn:q(`/api/seats/admissions`),admission:Kr(`/api/seats/admissions/:id`),admissions:Kr(`/api/seats/admissions`),answerAdmission:q(`/api/seats/admissions/:id/answer`),seats:Kr(`/api/seats`),seatTicket:q(`/api/seats/ticket`),seatBeat:q(`/api/seats/beat`),seatRelease:q(`/api/seats/release`),removeSeat:q(`/api/seats/:id/remove`),takeLease:q(`/api/leases`),beatLease:q(`/api/leases/:id`),releaseLease:qr(`/api/leases/:id`),connectors:Kr(`/api/connectors`),startConnector:q(`/api/connectors/:id/start`),connectorCallback:Kr(`/api/connectors/:id/callback`),disconnectConnector:q(`/api/connectors/:id/disconnect`)},rl=`Tricot-Seat`,il=`Tricot-Time`,al=`Tricot-Signature`,ol=`ticket`;function sl(e){return[`tricot-seat-1`,e.method.toUpperCase(),e.path,e.bodyHash,String(e.time),String(e.counter),e.seat].join(`
20
+ `)}function cl(e,t){return`${e}.${t}`}var ll=`tricot-seat`,ul=`seat`,dl=`this`,fl=1e3,pl=()=>typeof crypto<`u`&&!!crypto.subtle&&typeof indexedDB<`u`,ml;function hl(){return ml??=new Promise((e,t)=>{let n=indexedDB.open(ll,1);n.onupgradeneeded=()=>n.result.createObjectStore(ul),n.onsuccess=()=>e(n.result),n.onerror=()=>{ml=void 0,t(n.error??Error(`This browser couldn't open its store for Tricot.`))}}),ml}async function gl(e){let t=await hl();return new Promise((n,r)=>{let i=t.transaction(ul,`readwrite`),a=i.objectStore(ul),o,s=a.get(dl);s.onsuccess=()=>{let t=e(s.result);o=t.result,t.keep&&a.put(t.keep,dl)},i.oncomplete=()=>n(o),i.onerror=()=>r(i.error??Error(`This browser couldn't keep its key for Tricot.`)),i.onabort=()=>r(i.error??Error(`This browser couldn't keep its key for Tricot.`))})}var _l=()=>gl(e=>({result:e}));async function vl(){let e=await _l();if(e)return e;let t=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!1,[`sign`,`verify`]),n=await crypto.subtle.exportKey(`jwk`,t.publicKey),r={keys:t,publicKey:{kty:`EC`,crv:`P-256`,x:n.x,y:n.y},counter:0};return gl(e=>e?{result:e}:{keep:r,result:r})}async function yl(){if(pl())try{return(await _l())?.seat}catch{return}}var bl=new Set,xl=()=>bl.forEach(e=>e()),Sl=null;function Cl(){return Sl===null&&(Sl=typeof window>`u`||typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(`tricot-seat`),Sl&&(Sl.onmessage=xl)),Sl}async function wl(e){await gl(t=>t?{keep:{...t,seat:e},result:void 0}:{result:void 0}),xl(),Cl()?.postMessage(`changed`)}var Tl=()=>wl(void 0);function El(e){return Cl(),bl.add(e),()=>bl.delete(e)}var Dl=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function Ol(e,t,n=``){if(!pl())return;let r=await gl(e=>e?.seat?{keep:{...e,counter:e.counter+1},result:{...e,counter:e.counter+1}}:{result:void 0});if(!r?.seat)return;let i=new URL(t,location.origin),a=Dl(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n))),o=Date.now(),s=sl({method:e,path:i.pathname+i.search,bodyHash:a,time:o,counter:r.counter,seat:r.seat}),c=Dl(await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},r.keys.privateKey,new TextEncoder().encode(s)));return{[rl]:r.seat,[il]:String(o),[al]:cl(r.counter,c)}}var kl,Al=new Set,jl=e=>{kl=e,Al.forEach(e=>e())},Ml={get:()=>kl,subscribe(e){return Al.add(e),()=>Al.delete(e)},dismiss:()=>{Pl=!0,jl(void 0)}},Nl,Pl=!1,Fl=async e=>await e.json().catch(()=>({}));function Il(){return Nl??=(async()=>{Pl=!1,jl({state:`asking`});try{if(!pl())return jl({state:`failed`,error:`This browser can't hold a key for Tricot here: open Tricot at http://127.0.0.1 on the computer it runs on.`}),!1;let e=await vl(),t=await fetch(Jr(J.askToBeLetIn),{method:J.askToBeLetIn.method,headers:{"Content-Type":`application/json`},body:JSON.stringify({publicKey:e.publicKey})}),n=await Fl(t);if(t.status===200&&n.state===`admitted`&&n.seat)return await wl(n.seat),jl(void 0),!0;if(!t.ok||!n.id||!n.code)return jl({state:`failed`,error:n.error??`Tricot couldn't ask (${t.status}).`}),!1;for(jl({state:`waiting`,code:n.code,expiresAt:n.expiresAt??``,...n.first&&{first:!0}});;){if(await new Promise(e=>setTimeout(e,fl)),Pl)return!1;let e;try{let t=await fetch(Jr(J.admission,{id:n.id}),{cache:`no-store`});if(t.status===404)return jl({state:`expired`}),!1;e=await Fl(t)}catch{continue}if(e.state===`admitted`&&e.seat)return await wl(e.seat),jl(void 0),!0;if(e.state===`denied`)return jl({state:`denied`,...e.by&&{by:e.by}}),!1;if(e.state===`expired`)return jl({state:`expired`}),!1}}catch(e){return jl({state:`failed`,error:e.message}),!1}finally{Nl=void 0}})(),Nl}async function Ll(e){if(!await yl())return e;let t=await Ol(J.seatTicket.method,Jr(J.seatTicket),`{}`);if(!t)return e;try{let n=await fetch(Jr(J.seatTicket),{method:J.seatTicket.method,headers:{"Content-Type":`application/json`,...t},body:`{}`}),r=await n.json().catch(()=>({}));if(n.status===403&&r.code===`seat_gone`&&await Tl(),!n.ok||!r.ticket)return e;let i=new URL(e,location.origin);return i.searchParams.set(ol,r.ticket),i.pathname+i.search}catch{return e}}var Rl=class{url;onopen=null;onerror=null;source;listeners=[];closed=!1;opening=0;stopListening;constructor(e){this.url=e,this.stopListening=El(()=>this.open()),this.open()}get readyState(){return this.closed?2:this.source?.readyState??0}addEventListener(e,t){this.listeners.push([e,t]),this.source?.addEventListener(e,t)}close(){this.closed=!0,this.stopListening(),this.source?.close()}open(){let e=++this.opening;Ll(this.url).then(t=>{if(this.closed||e!==this.opening)return;this.source?.close();let n=new EventSource(t);this.source=n,n.onopen=e=>this.onopen?.(e),n.onerror=e=>this.onerror?.(e);for(let[e,t]of this.listeners)n.addEventListener(e,t);n.addEventListener(`seat`,e=>{let t={};try{t=JSON.parse(e.data)}catch{return}t.stale&&n===this.source&&this.open()})})}},zl=new class{list=[];shown=[];answered=new Set;listeners=new Set;set(e){this.list=e,this.answered=new Set([...this.answered].filter(t=>e.some(e=>e.id===t))),this.tell()}drop(e){this.answered.add(e),this.tell()}get=()=>this.shown;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));tell(){this.shown=this.list.filter(e=>!this.answered.has(e.id));for(let e of this.listeners)e()}};async function Bl(e,t,n,r){let i=n?JSON.stringify(n):void 0,a=async n=>{let a=await fetch(t,{method:e,headers:{...i&&{"Content-Type":`application/json`},...n},body:i,signal:r});return{response:a,data:await a.json().catch(()=>({}))}},{response:o,data:s}=await a();for(let n=0;o.status===403&&(s.code===`seat_needed`||s.code===`seat_gone`)&&n<2;n++){s.code===`seat_gone`&&await Tl();let n=await Ol(e,t,i??``);if(!n&&await Il()&&(n=await Ol(e,t,i??``)),!n)break;({response:o,data:s}=await a(n))}if(!o.ok){let e=Error(s.error??`Request failed (${o.status})`);throw e.status=o.status,typeof s.code==`string`&&(e.code=s.code),e}return s}var Vl=e=>(...t)=>Bl(`GET`,Jr(e,...t)),Y=e=>(t,...n)=>Bl(`POST`,Jr(e,...n),t),X={info:()=>Vl(J.info)(),update:()=>Vl(J.update)(),startUpdate:e=>Y(J.startUpdate)({version:e}),checkForUpdates:()=>Y(J.checkForUpdates)(void 0),boards:()=>Vl(J.boards)(),needs:(e,t)=>Vl(J.needs)(void 0,{name:e,seen:JSON.stringify(t)}),agents:e=>Vl(J.agents)(void 0,e?{board:e}:void 0),agentUsage:(e,t)=>Vl(J.agentUsage)({name:e},{...t.board&&{board:t.board},day:String(t.day),week:String(t.week)}),agentRules:()=>Vl(J.agentRules)(),setAgentRule:(e,t)=>Y(J.setAgentRule)(t,{agent:e}),addSkill:(e,t)=>Y(J.addSkill)({actor:e,...t}),editSkill:(e,t,n)=>Y(J.editSkill)({actor:t,...n},{skillId:e}),deleteSkill:(e,t)=>Y(J.deleteSkill)({actor:t},{skillId:e}),liveSteps:()=>Vl(J.liveSteps)(),previewLiveSteps:(e,t,n)=>Y(J.previewLiveSteps)({actor:t,...n},{agent:e}),applyLiveSteps:(e,t,n)=>Y(J.applyLiveSteps)({actor:t,...n},{agent:e}),answerApproval:(e,t,n)=>Y(J.answerApproval)({actor:t,...n},{id:e}),seats:()=>Vl(J.seats)(),removeSeat:(e,t)=>Y(J.removeSeat)({actor:t},{id:e}),admissions:()=>Vl(J.admissions)(),answerAdmission:(e,t,n)=>Y(J.answerAdmission)({actor:t,allow:n},{id:e}),board:e=>Vl(J.board)({boardId:e}),live:e=>Vl(J.boardLive)({boardId:e}),events:(e,{unseenBy:t,...n})=>{let r=new URLSearchParams(Object.entries({...n,unseen_by:t}).flatMap(([e,t])=>t===void 0?[]:[[e,String(t)]]));return Vl(J.boardEvents)({boardId:e},r)},projectFiles:e=>Vl(J.projectFiles)({boardId:e}),projectFile:(e,t,n)=>Vl(J.projectFile)({boardId:e},{path:t,...n?{lines:n}:{}}),searchProjectFiles:(e,{q:t,matchCase:n,word:r,regex:i},a)=>Bl(`GET`,Jr(J.projectSearch,{boardId:e},{q:t,...n&&{case:`1`},...r&&{word:`1`},...i&&{regex:`1`}}),void 0,a),projectFileBlock:(e,t,n)=>Y(J.projectFileBlock)({actor:t,path:n},{boardId:e}),writeProjectFile:(e,t,n,r,i)=>Y(J.projectFileWrite)({actor:t,path:n,text:r,base:i},{boardId:e}),chooseFolder:()=>Y(J.chooseFolder)({}),createBoard:(e,t,n,r)=>Y(J.createBoard)({actor:e,title:t,goal:n,folder:r}),updateBoard:(e,t,n)=>Y(J.updateBoard)({actor:t,...n},{boardId:e}),archiveBoard:(e,t,n)=>Y(n?J.archiveBoard:J.unarchiveBoard)({actor:t},{boardId:e}),deleteBoard:(e,t,n)=>Y(J.deleteBoard)({actor:t,confirm:n},{boardId:e}),requestSync:(e,t,n)=>Y(J.requestSync)({actor:t,blockIds:n},{boardId:e}),cancelSync:(e,t)=>Y(J.cancelSync)({actor:t},{boardId:e}),askAgents:(e,t,n)=>Y(J.askAgents)({actor:t,text:n},{boardId:e}),cancelRequest:(e,t,n)=>Y(J.cancelRequest)({actor:n},{boardId:e,requestId:t}),threads:e=>Vl(J.boardThreads)({boardId:e}),thread:e=>Vl(J.thread)({threadId:e}),startThread:(e,t,n,r,i,a,o,s,c)=>Y(J.startThread)({actor:t,body:n,lens:r,door:i,messageLens:a,pageId:o,blockIds:s,file:c},{boardId:e}),postToThread:(e,t,n,r)=>Y(J.postToThread)({actor:t,body:n,messageLens:r},{threadId:e}),setThreadLens:(e,t,n)=>Y(J.setThreadLens)({actor:t,lens:n},{threadId:e}),search:(e,t,n)=>{let r=new URLSearchParams({q:t});return n.kinds?.length&&r.set(`kinds`,n.kinds.join(`,`)),(n.all||!e)&&r.set(`all`,`1`),n.open&&r.set(`open`,`1`),e?Vl(J.boardSearch)({boardId:e},r):Vl(J.search)(void 0,r)},reactInThread:(e,t,n,r,i)=>Y(J.reactToThreadMessage)({actor:n,emoji:r,...i?{remove:i}:{}},{threadId:e,commentId:t}),reactOnPin:(e,t,n,r,i)=>Y(J.reactToPinComment)({actor:n,emoji:r,...i?{remove:i}:{}},{pinId:e,commentId:t}),addPage:(e,t,n)=>Y(J.addPage)({actor:t,title:n},{boardId:e}),renamePage:(e,t,n)=>Y(J.updatePage)({actor:t,title:n},{pageId:e}),movePage:(e,t,n)=>Y(J.updatePage)({actor:t,after:n},{pageId:e}),deletePage:(e,t)=>Y(J.deletePage)({actor:t},{pageId:e}),addBlock:(e,t,n)=>Y(J.addBlock)({actor:t,...e,...n}),updateBlock:(e,t,n)=>Y(J.updateBlock)({actor:t,...n},{id:e}),deriveBlock:(e,t)=>Y(J.deriveBlock)({actor:t},{id:e}),blockVersions:e=>Vl(J.blockVersions)({id:e}),blockVersion:(e,t)=>Vl(J.blockVersion)({id:e,rev:t}),restoreBlock:(e,t,n,r)=>Y(J.restoreBlock)({actor:t,rev:n,blockRev:r},{id:e}),deleteVersion:(e,t,n)=>Y(J.deleteVersion)({actor:t},{id:e,rev:n}),deleteEarlierVersions:(e,t)=>Y(J.deleteEarlierVersions)({actor:t},{id:e}),moveItems:(e,t,n)=>Y(J.moveItems)({actor:t,...e,moves:n}),pasteBlocks:(e,t,n)=>Y(J.pasteBlocks)({actor:t,...e,...n}),addGroup:(e,t,n)=>Y(J.addGroup)({actor:t,...e,...n}),renameGroup:(e,t,n)=>Y(J.renameGroup)({actor:t,title:n},{id:e}),addLink:(e,t,n)=>Y(J.addLink)({actor:e,from:t,to:n}),relabelLink:(e,t,n)=>Y(J.relabelLink)({actor:t,label:n},{id:e}),pinComment:(e,t,n)=>Y(J.pinComment)({actor:t,...n},{id:e}),commentOnPin:(e,t,n)=>Y(J.commentOnPin)({actor:t,body:n},{id:e}),resolvePin:(e,t,n)=>Y(J.resolvePin)({actor:t,resolved:n},{id:e}),startPairing:(e,t)=>Y(J.startPairing)({actor:e,...t}),pairingBeat:(e,t,n)=>Y(J.pairingBeat)({actor:t,active:n},{id:e}),endPairing:(e,t)=>Y(J.endPairing)({actor:t},{id:e}),leavePairing:(e,t)=>void fetch(Jr(J.endPairing,{id:e}),{method:`POST`,keepalive:!0,headers:{"Content-Type":`application/json`},body:JSON.stringify({actor:t})}).catch(()=>void 0),removeItem:(e,t)=>Y(J.removeItem)({actor:t},{id:e}),restoreItem:(e,t)=>Y(J.restoreItem)({actor:t},{id:e}),uploadImage:async e=>{let t=await fetch(Jr(J.uploadAsset),{method:J.uploadAsset.method,headers:{"Content-Type":e.type},body:e}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`Upload failed (${t.status})`);let r=typeof n.width==`number`&&typeof n.height==`number`?{width:n.width,height:n.height}:null;return{assetId:n.assetId,size:r}},connectors:()=>Vl(J.connectors)(),startConnector:(e,t)=>Y(J.startConnector)(t?{permissions:t}:{},{id:e}),disconnectConnector:e=>Y(J.disconnectConnector)({},{id:e})},Hl=new class{list=[];shown=[];answered=new Set;listeners=new Set;set(e){this.list=e,this.answered=new Set([...this.answered].filter(t=>e.some(e=>e.id===t))),this.tell()}drop(e){this.answered.add(e),this.tell()}get=()=>this.shown;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));tell(){this.shown=this.list.filter(e=>!this.answered.has(e.id));for(let e of this.listeners)e()}};function Ul(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Wl(e,t){return e.taken||e.interactive||!Ul(e)?!1:!t||t.moved<=4&&!t.selected}var Gl=[`a[href]`,`area[href]`,`button`,`input`,`select`,`textarea`,`label`,`summary`,`[contenteditable]:not([contenteditable="false"])`,`[tabindex]:not([tabindex^="-"])`,...[`button`,`link`,`tab`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`combobox`,`textbox`,`searchbox`,`treeitem`].map(e=>`[role="${e}"]`),`.card`,`.dt-row`,`.dt-fold`,`.react-flow__node`,`.react-flow__edge`,`.react-flow__handle`,`.react-flow__nodesselection`,`.chat-bar`].join(`, `);function Kl(e,t){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(Gl)!==null||t!==void 0&&ql(e,t.x,t.y)}function ql(e,t,n){let r=e===e.ownerDocument.documentElement?{left:0,top:0}:e.getBoundingClientRect(),{clientLeft:i,clientTop:a,clientWidth:o,clientHeight:s}=e;return o>0&&t>=r.left+i+o||s>0&&n>=r.top+a+s}function Jl(){let e=typeof getSelection==`function`?getSelection():null;return e&&!e.isCollapsed?e.toString():``}function Yl(e,t){let[n,r]=(0,d.useState)(()=>{try{let t=localStorage.getItem(e);if(t!==null)return t===`1`}catch{}return t()});return[n,(0,d.useCallback)(t=>{r(t);try{localStorage.setItem(e,t?`1`:`0`)}catch{}},[e])]}function Xl(e){return e instanceof Element&&!!e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`)}function Zl(e,t,n,r,i=!1){(0,d.useEffect)(()=>{if(!e)return;i||Ql.add(n);let a=e=>{i||eu.add(e);let a=e.target;n.current?.contains(a)||r?.current?.contains(a)||a.closest?.(`.mention-menu`)||t(!1,e)},o=e=>{e.key===`Escape`&&(i||eu.add(e),t(!0,e))};return document.addEventListener(`mousedown`,a,!0),document.addEventListener(`keydown`,o),()=>{Ql.delete(n),document.removeEventListener(`mousedown`,a,!0),document.removeEventListener(`keydown`,o)}},[e,t,n,r,i])}var Ql=new Set,$l=[],eu=new WeakSet,tu=new WeakSet;function nu(e){for(let t of Ql)if(t!==e)return!0;return!1}function ru(e){return Ql.size>0||eu.has(e)||typeof document<`u`&&document.querySelector(`[aria-modal="true"]`)!==null}function iu(e,t){(0,d.useEffect)(()=>{if(e)return $l.push(t),()=>void $l.splice($l.indexOf(t),1)},[e,t])}function au(e,t){return t.defaultPrevented||tu.has(t)||ru(t)||$l.at(-1)!==e?!1:(tu.add(t),!0)}function ou(e,t){let n=e.target,r={button:e.button,metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,interactive:Kl(n,{x:e.clientX,y:e.clientY}),taken:ru(e)||!!n.closest?.(`.popover[open]`)};if(!Wl(r))return null;let i=Jl();return su(n=>{let a=n.type===`mouseup`?Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY):1/0,o=Jl();t(Wl(r,{moved:a,selected:o!==``&&o!==i}))})}function su(e){let t,n=[`mouseup`,`dragend`],r=()=>n.forEach(e=>window.removeEventListener(e,i,{capture:!0})),i=n=>{r(),t=setTimeout(()=>e(n))};return n.forEach(e=>window.addEventListener(e,i,{capture:!0})),()=>{r(),clearTimeout(t)}}function cu(e,t,n){if(n!==0){if(e===`ArrowDown`||e===`ArrowRight`)return(t+1)%n;if(e===`ArrowUp`||e===`ArrowLeft`)return t<0?n-1:(t-1+n)%n;if(e===`Home`)return 0;if(e===`End`)return n-1}}function lu(){let[e,t]=(0,d.useState)(!1),n=(0,d.useRef)(null),r=(0,d.useRef)(null),i=(0,d.useRef)(null),a=(0,d.useCallback)(e=>{t(!1),e&&r.current?.focus()},[]);return Zl(e,a,n),(0,d.useEffect)(()=>{e&&uu(i.current)[0]?.focus()},[e]),{open:e,setOpen:t,close:a,root:n,button:r,menu:i,onKeyDown:e=>{if(e.key===`Tab`)return e.preventDefault(),a(!0);let t=uu(i.current),n=!e.metaKey&&!e.ctrlKey&&!e.altKey&&e.key.length===1?t.find(t=>t.getAttribute(`aria-keyshortcuts`)===e.key.toUpperCase()):void 0;if(n)return e.preventDefault(),n.click();let r=cu(e.key,t.indexOf(document.activeElement),t.length);r!==void 0&&(e.preventDefault(),t[r].focus())}}}function uu(e){return[...e?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]]}function du(e){let[,t]=(0,d.useState)(0);(0,d.useEffect)(()=>{let n=setInterval(()=>t(e=>e+1),e);return()=>clearInterval(n)},[e])}function fu(){let[e,t]=(0,d.useState)(()=>document.visibilityState===`hidden`);return(0,d.useEffect)(()=>{let e=()=>t(document.visibilityState===`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}function pu(e,t,n,r){(0,d.useEffect)(()=>{if(!t)return;let i=e.current?.querySelector(n);i&&(i.focus(),r())})}var mu=(0,d.createContext)(!1);function hu(){return(0,d.useContext)(mu)}var gu=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),_u=n(((e,t)=>{t.exports=gu()}));function vu(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var yu=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bu=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xu={};function Su(e,t){return((t||xu).jsx?bu:yu).test(e)}var Cu=/[ \t\n\f\r]/g;function wu(e){return typeof e==`object`?e.type===`text`&&Tu(e.value):Tu(e)}function Tu(e){return e.replace(Cu,``)===``}var Eu=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Eu.prototype.normal={},Eu.prototype.property={},Eu.prototype.space=void 0;function Du(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Eu(n,r,t)}function Ou(e){return e.toLowerCase()}var ku=class{constructor(e,t){this.attribute=t,this.property=e}};ku.prototype.attribute=``,ku.prototype.booleanish=!1,ku.prototype.boolean=!1,ku.prototype.commaOrSpaceSeparated=!1,ku.prototype.commaSeparated=!1,ku.prototype.defined=!1,ku.prototype.mustUseProperty=!1,ku.prototype.number=!1,ku.prototype.overloadedBoolean=!1,ku.prototype.property=``,ku.prototype.spaceSeparated=!1,ku.prototype.space=void 0;var Au=e({boolean:()=>Mu,booleanish:()=>Nu,commaOrSpaceSeparated:()=>Lu,commaSeparated:()=>Iu,number:()=>Z,overloadedBoolean:()=>Pu,spaceSeparated:()=>Fu}),ju=0,Mu=Ru(),Nu=Ru(),Pu=Ru(),Z=Ru(),Fu=Ru(),Iu=Ru(),Lu=Ru();function Ru(){return 2**++ju}var zu=Object.keys(Au),Bu=class extends ku{constructor(e,t,n,r){let i=-1;if(super(e,t),Vu(this,`space`,r),typeof n==`number`)for(;++i<zu.length;){let e=zu[i];Vu(this,zu[i],(n&Au[e])===Au[e])}}};Bu.prototype.defined=!0;function Vu(e,t,n){n&&(e[t]=n)}function Hu(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Bu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ou(r)]=r,n[Ou(a.attribute)]=r}return new Eu(t,n,e.space)}var Uu=Hu({properties:{ariaActiveDescendant:null,ariaAtomic:Nu,ariaAutoComplete:null,ariaBusy:Nu,ariaChecked:Nu,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:Fu,ariaCurrent:null,ariaDescribedBy:Fu,ariaDetails:null,ariaDisabled:Nu,ariaDropEffect:Fu,ariaErrorMessage:null,ariaExpanded:Nu,ariaFlowTo:Fu,ariaGrabbed:Nu,ariaHasPopup:null,ariaHidden:Nu,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fu,ariaLevel:Z,ariaLive:null,ariaModal:Nu,ariaMultiLine:Nu,ariaMultiSelectable:Nu,ariaOrientation:null,ariaOwns:Fu,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:Nu,ariaReadOnly:Nu,ariaRelevant:null,ariaRequired:Nu,ariaRoleDescription:Fu,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:Nu,ariaSetSize:Z,ariaSort:null,ariaValueMax:Z,ariaValueMin:Z,ariaValueNow:Z,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Wu(e,t){return t in e?e[t]:t}function Gu(e,t){return Wu(e,t.toLowerCase())}var Ku=Hu({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Iu,acceptCharset:Fu,accessKey:Fu,action:null,allow:null,allowFullScreen:Mu,allowPaymentRequest:Mu,allowUserMedia:Mu,alpha:Mu,alt:null,as:null,async:Mu,autoCapitalize:null,autoComplete:Fu,autoFocus:Mu,autoPlay:Mu,blocking:Fu,capture:null,charSet:null,checked:Mu,cite:null,className:Fu,closedBy:null,colorSpace:null,cols:Z,colSpan:Z,command:null,commandFor:null,content:null,contentEditable:Nu,controls:Mu,controlsList:Fu,coords:Z|Iu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Mu,defer:Mu,dir:null,dirName:null,disabled:Mu,download:Pu,draggable:Nu,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Mu,formTarget:null,headers:Fu,height:Z,hidden:Pu,high:Z,href:null,hrefLang:null,htmlFor:Fu,httpEquiv:Fu,id:null,imageSizes:null,imageSrcSet:null,inert:Mu,inputMode:null,integrity:null,is:null,isMap:Mu,itemId:null,itemProp:Fu,itemRef:Fu,itemScope:Mu,itemType:Fu,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Mu,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:Mu,muted:Mu,name:null,nonce:null,noModule:Mu,noValidate:Mu,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Mu,optimum:Z,pattern:null,ping:Fu,placeholder:null,playsInline:Mu,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Mu,referrerPolicy:null,rel:Fu,required:Mu,reversed:Mu,rows:Z,rowSpan:Z,sandbox:Fu,scope:null,scoped:Mu,seamless:Mu,selected:Mu,shadowRootClonable:Mu,shadowRootCustomElementRegistry:Mu,shadowRootDelegatesFocus:Mu,shadowRootMode:null,shadowRootSerializable:Mu,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:Nu,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Z,step:null,style:null,tabIndex:Z,target:null,title:null,translate:null,type:null,typeMustMatch:Mu,useMap:null,value:Nu,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fu,axis:null,background:null,bgColor:null,border:Z,borderColor:null,bottomMargin:Z,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Mu,declare:Mu,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:Mu,noHref:Mu,noShade:Mu,noWrap:Mu,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:Nu,standby:null,summary:null,text:null,topMargin:Z,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Z,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Mu,disablePictureInPicture:Mu,disableRemotePlayback:Mu,exportParts:Iu,part:Fu,prefix:null,property:null,results:Z,security:null,unselectable:null},space:`html`,transform:Gu}),qu=Hu({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Lu,accentHeight:Z,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Z,amplitude:Z,arabicForm:null,ascent:Z,attributeName:null,attributeType:null,azimuth:Z,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Z,by:null,calcMode:null,capHeight:Z,className:Fu,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Z,diffuseConstant:Z,direction:null,display:null,dur:null,divisor:Z,dominantBaseline:null,download:Mu,dx:null,dy:null,edgeMode:null,editable:null,elevation:Z,enableBackground:null,end:null,event:null,exponent:Z,externalResourcesRequired:null,fill:null,fillOpacity:Z,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Iu,g2:Iu,glyphName:Iu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Z,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Z,horizOriginX:Z,horizOriginY:Z,id:null,ideographic:Z,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Z,k:Z,k1:Z,k2:Z,k3:Z,k4:Z,kernelMatrix:Lu,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Z,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Z,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Z,overlineThickness:Z,paintOrder:null,panose1:null,path:null,pathLength:Z,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fu,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Lu,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Lu,rev:Lu,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Lu,requiredFeatures:Lu,requiredFonts:Lu,requiredFormats:Lu,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Z,specularExponent:Z,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Z,strikethroughThickness:Z,string:null,stroke:null,strokeDashArray:Lu,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Z,strokeOpacity:Z,strokeWidth:null,style:null,surfaceScale:Z,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Lu,tabIndex:Z,tableValues:null,target:null,targetX:Z,targetY:Z,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Lu,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Z,underlineThickness:Z,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Z,values:null,vAlphabetic:Z,vMathematical:Z,vectorEffect:null,vHanging:Z,vIdeographic:Z,version:null,vertAdvY:Z,vertOriginX:Z,vertOriginY:Z,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Z,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Wu}),Ju=Hu({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Yu=Hu({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Gu}),Xu=Hu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Zu={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Qu=/[A-Z]/g,$u=/-[a-z]/g,ed=/^data[-\w.:]+$/i;function td(e,t){let n=Ou(t),r=t,i=ku;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ed.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace($u,rd);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!$u.test(e)){let n=e.replace(Qu,nd);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Bu}return new i(r,t)}function nd(e){return`-`+e.toLowerCase()}function rd(e){return e.charAt(1).toUpperCase()}var id=Du([Uu,Ku,Ju,Yu,Xu],`html`),ad=Du([Uu,qu,Ju,Yu,Xu],`svg`);function od(e){return e.join(` `).trim()}var sd=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
21
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),cd=n(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var i=r(sd());function a(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=(0,i.default)(e),a=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:i}=e;a?t(r,i,e):i&&(n||={},n[r]=i)}),n}})),ld=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),ud=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(cd()),i=ld();function a(e,t){var n={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a})),dd=pd(`end`),fd=pd(`start`);function pd(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function md(e){let t=fd(e),n=dd(e);if(t&&n)return{start:t,end:n}}function hd(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?_d(e.position):`start`in e||`end`in e?_d(e):`line`in e||`column`in e?gd(e):``}function gd(e){return vd(e&&e.line)+`:`+vd(e&&e.column)}function _d(e){return gd(e&&e.start)+`-`+gd(e&&e.end)}function vd(e){return e&&typeof e==`number`?e:1}var yd=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=hd(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};yd.prototype.file=``,yd.prototype.name=``,yd.prototype.reason=``,yd.prototype.message=``,yd.prototype.stack=``,yd.prototype.column=void 0,yd.prototype.line=void 0,yd.prototype.ancestors=void 0,yd.prototype.cause=void 0,yd.prototype.fatal=void 0,yd.prototype.place=void 0,yd.prototype.ruleId=void 0,yd.prototype.source=void 0;var bd=t(ud(),1),xd={}.hasOwnProperty,Sd=new Map,Cd=/[A-Z]/g,wd=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Td=new Set([`td`,`th`]),Ed=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Dd(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Rd(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Ld(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?ad:id,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Od(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Od(e,t,n){if(t.type===`element`)return kd(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Ad(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Md(e,t,n);if(t.type===`mdxjsEsm`)return jd(e,t);if(t.type===`root`)return Nd(e,t,n);if(t.type===`text`)return Pd(e,t)}function kd(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=ad,e.schema=i),e.ancestors.push(t);let a=Wd(e,t.tagName,!1),o=zd(e,t),s=Vd(e,t);return wd.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!wu(e)})),Fd(e,o,a,t),Id(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ad(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Gd(e,t.position)}function jd(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Gd(e,t.position)}function Md(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=ad,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Wd(e,t.name,!0),o=Bd(e,t),s=Vd(e,t);return Fd(e,o,a,t),Id(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Nd(e,t,n){let r={};return Id(r,Vd(e,t)),e.create(t,e.Fragment,r,n)}function Pd(e,t){return t.value}function Fd(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Id(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Ld(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Rd(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=fd(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function zd(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&xd.call(t.properties,i)){let a=Hd(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Td.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Bd(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Gd(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Gd(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Vd(e,t){let n=[],r=-1,i=e.passKeys?new Map:Sd;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Od(e,a,o);s!==void 0&&n.push(s)}return n}function Hd(e,t,n){let r=td(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vu(n):od(n)),r.property===`style`){let t=typeof n==`object`?n:Ud(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Kd(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Zu[r.property]||r.property:r.attribute,n]}}function Ud(e,t){try{return(0,bd.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new yd("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Ed+`#cannot-parse-style-attribute`,r}}function Wd(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Su(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Su(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return xd.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Gd(e)}function Gd(e,t){let n=new yd("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Ed+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Kd(e){let t={},n;for(n in e)xd.call(e,n)&&(t[qd(n)]=e[n]);return t}function qd(e){let t=e.replace(Cd,Jd);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Jd(e){return`-`+e.toLowerCase()}var Yd={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Xd={};function Zd(e,t){let n=t||Xd;return Qd(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function Qd(e,t,n){if(ef(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return $d(e.children,t,n)}return Array.isArray(e)?$d(e,t,n):``}function $d(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Qd(e[i],t,n);return r.join(``)}function ef(e){return!!(e&&typeof e==`object`)}var tf=document.createElement(`i`);function nf(e){let t=`&`+e+`;`;tf.innerHTML=t;let n=tf.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function rf(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function af(e,t){return e.length>0?(rf(e,e.length,0,t),e):t}var of={}.hasOwnProperty;function sf(e){let t={},n=-1;for(;++n<e.length;)cf(t,e[n]);return t}function cf(e,t){let n;for(n in t){let r=(of.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){of.call(r,a)||(r[a]=[]);let e=i[a];lf(r[a],Array.isArray(e)?e:e?[e]:[])}}}function lf(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);rf(e,0,0,r)}function uf(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function df(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var ff=wf(/[A-Za-z]/),pf=wf(/[\dA-Za-z]/),mf=wf(/[#-'*+\--9=?A-Z^-~]/);function hf(e){return e!==null&&(e<32||e===127)}var gf=wf(/\d/),_f=wf(/[\dA-Fa-f]/),vf=wf(/[!-/:-@[-`{-~]/);function yf(e){return e!==null&&e<-2}function bf(e){return e!==null&&(e<0||e===32)}function xf(e){return e===-2||e===-1||e===32}var Sf=wf(/\p{P}|\p{S}/u),Cf=wf(/\s/);function wf(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Tf(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&pf(e.charCodeAt(n+1))&&pf(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Ef(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return xf(r)?(e.enter(n),s(r)):t(r)}function s(r){return xf(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function Df(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&xf(t)?(e.enter(r),c(t)):l(t)}function c(t){return xf(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var Of={tokenize:kf};function kf(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Ef(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return yf(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Af=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){jf(this,e,t,n,!1)}addBefore(e,t,n){jf(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function jf(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var Mf={tokenize:Pf},Nf={tokenize:Ff};function Pf(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new Af;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Nf,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Nf,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return yf(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new Af;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ff(e,t,n){return Ef(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function If(e){if(e===null||bf(e)||Cf(e))return 1;if(Sf(e))return 2}function Lf(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Rf={name:`attention`,resolveAll:zf,tokenize:Bf};function zf(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};Vf(o,-a),Vf(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=af(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=af(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=af(r,Lf(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=af(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=af(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),rf(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Bf(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=If(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=If(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Vf(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Hf={name:`autolink`,tokenize:Uf};function Uf(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return ff(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||pf(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||pf(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||hf(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):mf(t)?(e.consume(t),l):n(t)}function u(e){return pf(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||pf(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Wf={partial:!0,tokenize:Gf};function Gf(e,t,n){return r;function r(t){return xf(t)?Ef(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||yf(e)?t(e):n(e)}}var Kf={continuation:{tokenize:Jf},exit:Yf,name:`blockQuote`,tokenize:qf};function qf(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return xf(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Jf(e,t,n){let r=this;return i;function i(t){return xf(t)?Ef(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Kf,t,n)(r)}}function Yf(e){e.exit(`blockQuote`)}var Xf={name:`characterEscape`,tokenize:Zf};function Zf(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return vf(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Qf={name:`characterReference`,tokenize:$f};function $f(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=pf,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=_f,u):(e.enter(`characterReferenceValue`),a=7,o=gf,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===pf&&!nf(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var ep={partial:!0,tokenize:tp};function tp(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var np={concrete:!0,name:`codeFenced`,tokenize:rp};function rp(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),xf(t)?Ef(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||yf(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(ep,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||yf(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):xf(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Ef(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||yf(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||yf(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&xf(t)?Ef(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||yf(t)?e.check(ep,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||yf(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),xf(t)?Ef(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),xf(t)?Ef(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||yf(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var ip={name:`codeIndented`,tokenize:op},ap={partial:!0,tokenize:sp};function op(e,t,n){return r;function r(t){return e.enter(`codeIndented`),Df(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):yf(t)?e.attempt(ap,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||yf(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function sp(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):yf(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):Df(e,t,a,`linePrefix`,4,4)(o)}function a(e){return yf(e)?i(e):n(e)}}var cp={name:`codeText`,previous:up,resolve:lp,tokenize:dp};function lp(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function up(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function dp(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):yf(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||yf(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var fp=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&pp(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),pp(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),pp(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);pp(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);pp(this.left,t.reverse())}}}};function pp(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function mp(e){let t={},n=-1,r,i,a,o,s,c,l,u=new fp(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,hp(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return rf(e,0,1/0,u.slice(0)),!l}function hp(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var gp={resolve:vp,tokenize:yp},_p={partial:!0,tokenize:bp};function vp(e){return mp(e),e}function yp(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):yf(t)?e.check(_p,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function bp(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Ef(e,a,`linePrefix`)}function a(i){if(i===null||yf(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function xp(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||hf(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||yf(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||bf(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||hf(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Sp(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):yf(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||yf(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!xf(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Cp(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):yf(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Ef(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||yf(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function wp(e,t){let n;return r;function r(i){return yf(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):xf(i)?Ef(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Tp={name:`definition`,tokenize:Dp},Ep={partial:!0,tokenize:Op};function Dp(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Sp.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=df(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return bf(t)?wp(e,l)(t):l(t)}function l(t){return xp(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Ep,d,d)(t)}function d(t){return xf(t)?Ef(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||yf(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Op(e,t,n){return r;function r(t){return bf(t)?wp(e,i)(t):n(t)}function i(t){return Cp(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return xf(t)?Ef(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||yf(e)?t(e):n(e)}}var kp={name:`hardBreakEscape`,tokenize:Ap};function Ap(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return yf(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var jp={name:`headingAtx`,resolve:Mp,tokenize:Np};function Mp(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};rf(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Np(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||bf(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||yf(n)?(e.exit(`atxHeading`),t(n)):xf(n)?Ef(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||bf(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Pp=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Fp=[`pre`,`script`,`style`,`textarea`],Ip={concrete:!0,name:`htmlFlow`,resolveTo:Rp,tokenize:zp},Lp={partial:!0,tokenize:Bp};function Rp(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function zp(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):ff(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):ff(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return ff(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||bf(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Fp.includes(l)?(i=1,r.interrupt?t(s):O(s)):Pp.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||pf(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return xf(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||ff(t)?(e.consume(t),b):xf(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||pf(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):xf(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):xf(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||yf(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||bf(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||xf(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||yf(t)?O(t):xf(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):yf(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Lp,R,k)(t)):t===null||yf(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(ep,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||yf(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Fp.includes(n)?(e.consume(t),L):O(t)}return ff(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||yf(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function Bp(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Wf,t,n)}}var Vp={name:`htmlText`,tokenize:Hp};function Hp(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):ff(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):ff(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):yf(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):yf(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):yf(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):yf(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return ff(t)?(e.consume(t),S):n(t)}function S(t){return t===45||pf(t)?(e.consume(t),S):C(t)}function C(t){return yf(t)?(o=C,N(t)):xf(t)?(e.consume(t),C):M(t)}function w(t){return t===45||pf(t)?(e.consume(t),w):t===47||t===62||bf(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||ff(t)?(e.consume(t),E):yf(t)?(o=T,N(t)):xf(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||pf(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):yf(t)?(o=D,N(t)):xf(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):yf(t)?(o=O,N(t)):xf(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):yf(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||bf(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||bf(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return xf(t)?Ef(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Up={name:`labelEnd`,resolveAll:qp,resolveTo:Jp,tokenize:Yp},Wp={tokenize:Xp},Gp={tokenize:Zp},Kp={tokenize:Qp};function qp(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&rf(e,0,e.length,n),e}function Jp(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=af(o,e.slice(i+1,i+r+3)),o=af(o,[[`enter`,l,t]]),o=af(o,Lf(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=af(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=af(o,e.slice(a+1)),o=af(o,[[`exit`,s,t]]),rf(e,i,e.length,o),e}function Yp(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(df(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Wp,u,o?u:d)(t):t===91?e.attempt(Gp,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Kp,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function Xp(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return bf(t)?wp(e,a)(t):a(t)}function a(t){return t===41?u(t):xp(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return bf(t)?wp(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Cp(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return bf(t)?wp(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Zp(e,t,n){let r=this;return i;function i(t){return Sp.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(df(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Qp(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var $p={name:`labelStartImage`,resolveAll:Up.resolveAll,tokenize:em};function em(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var tm={name:`labelStartLink`,resolveAll:Up.resolveAll,tokenize:nm};function nm(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var rm={name:`lineEnding`,tokenize:im};function im(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Ef(e,t,`linePrefix`)}}var am={name:`thematicBreak`,tokenize:om};function om(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||yf(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),xf(t)?Ef(e,s,`whitespace`)(t):s(t))}}var sm={continuation:{tokenize:dm},exit:pm,name:`list`,tokenize:um},cm={partial:!0,tokenize:mm},lm={partial:!0,tokenize:fm};function um(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:gf(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(am,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return gf(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Wf,r.interrupt?n:u,e.attempt(cm,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return xf(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function dm(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Wf,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ef(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!xf(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(lm,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ef(e,e.attempt(sm,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function fm(e,t,n){let r=this;return Ef(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function pm(e){e.exit(this.containerState.type)}function mm(e,t,n){let r=this;return Ef(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!xf(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var hm={name:`setextUnderline`,resolveTo:gm,tokenize:_m};function gm(e,t){let n=new Af,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function _m(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),xf(t)?Ef(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||yf(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var vm={tokenize:ym};function ym(e){let t=this,n=e.attempt(Wf,r,e.attempt(this.parser.constructs.flowInitial,i,Ef(e,e.attempt(this.parser.constructs.flow,i,e.attempt(gp,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var bm={resolveAll:wm()},xm=Cm(`string`),Sm=Cm(`text`);function Cm(e){return{resolveAll:wm(e===`text`?Tm:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function wm(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Tm(e,t){let n=new Af,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var Em=e({attentionMarkers:()=>Pm,contentInitial:()=>Om,disable:()=>Fm,document:()=>Dm,flow:()=>Am,flowInitial:()=>km,insideSpan:()=>Nm,string:()=>jm,text:()=>Mm}),Dm={42:sm,43:sm,45:sm,48:sm,49:sm,50:sm,51:sm,52:sm,53:sm,54:sm,55:sm,56:sm,57:sm,62:Kf},Om={91:Tp},km={[-2]:ip,[-1]:ip,32:ip},Am={35:jp,42:am,45:[hm,am],60:Ip,61:hm,95:am,96:np,126:np},jm={38:Qf,92:Xf},Mm={[-5]:rm,[-4]:rm,[-3]:rm,33:$p,38:Qf,42:Rf,60:[Hf,Vp],91:tm,92:[kp,Xf],93:Up,95:Rf,96:cp},Nm={null:[Rf,bm]},Pm={null:[42,95]},Fm={null:[]};function Im(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=af(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Lf(a,l.events,l),l.events):[]}function f(e,t){return Rm(p(e),t)}function p(e){return Lm(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){yf(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&rf(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Lm(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Rm(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
22
+ `;break;case-3:o=`\r
23
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function zm(e){let t={constructs:sf([Em,...(e||{}).extensions||[]]),content:n(Of),defined:[],document:n(Mf),flow:n(vm),lazy:{},string:n(xm),text:n(Sm)};return t;function n(e){return n;function n(n){return Im(t,e,n)}}}function Bm(e){for(;!mp(e););return e}var Vm=/[\0\t\n\r]/g;function Hm(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){Vm.lastIndex=c;let n=Vm.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Um=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wm(e){return e.replace(Um,Gm)}function Gm(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return uf(n.slice(t?2:1),t?16:10)}return nf(n)||e}var Km={}.hasOwnProperty;function qm(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Jm(n)(Bm(zm(n).document().write(Hm()(e,t,!0))))}function Jm(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ue),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(W),blockQuote:o(ae),characterEscape:E,characterReference:E,codeFenced:o(oe),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(oe,s),codeText:o(se,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(H),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(U),hardBreakEscape:o(G),hardBreakTrailing:o(G),htmlFlow:o(ce,s),htmlFlowData:E,htmlText:o(ce,s),htmlTextData:E,image:o(le),label:s,link:o(ue),listItem:o(fe),listItemValue:p,listOrdered:o(de,f),listUnordered:o(de),paragraph:o(pe),reference:B,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(W),strong:o(me),thematicBreak:o(ge)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ie,autolinkProtocol:re,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:te,characterReference:ne,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:I,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ee,resourceDestinationString:L,resourceTitleString:R,resource:z,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};Xm(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),Km.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||Qm).call(o,void 0,e[0])}for(r.position={start:Ym(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Ym(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Ym(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+hd({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Qm).call(this,e,r[0])),n.position.end=Ym(e.end)}function d(){return Zd(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=df(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=he(),n.position={start:Ym(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Ym(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Ym(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Wm(t),n.identifier=df(t).toLowerCase()}function I(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function R(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function z(){this.data.inReference=void 0}function B(){this.data.referenceType=`collapsed`}function ee(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=df(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function te(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=uf(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=nf(t);let i=this.stack[this.stack.length-1];i.value+=r}function ne(e){let t=this.stack.pop();t.position.end=Ym(e.end)}function re(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ie(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ae(){return{type:`blockquote`,children:[],position:void 0}}function oe(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function se(){return{type:`inlineCode`,value:``,position:void 0}}function H(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function U(){return{type:`emphasis`,children:[],position:void 0}}function W(){return{type:`heading`,depth:0,children:[],position:void 0}}function G(){return{type:`break`,position:void 0}}function ce(){return{type:`html`,value:``,position:void 0}}function le(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ue(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function de(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function fe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function pe(){return{type:`paragraph`,children:[],position:void 0}}function me(){return{type:`strong`,children:[],position:void 0}}function he(){return{type:`text`,value:``,position:void 0}}function ge(){return{type:`thematicBreak`,position:void 0}}}function Ym(e){return{line:e.line,column:e.column,offset:e.offset}}function Xm(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Xm(e,r):Zm(e,r)}}function Zm(e,t){let n;for(n in t)if(Km.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function Qm(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+hd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hd({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+hd({start:t.start,end:t.end})+`) is still open`)}function $m(e){let t=this;t.parser=n;function n(n){return qm(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function eh(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function th(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
24
+ `}]}function nh(e,t){let n=t.value?t.value+`
25
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function rh(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ih(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ah(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=Tf(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function oh(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sh(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ch(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function lh(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ch(e,t);let i={src:Tf(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function uh(e,t){let n={src:Tf(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function dh(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function fh(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ch(e,t);let i={href:Tf(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function ph(e,t){let n={href:Tf(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function mh(e,t,n){let r=e.all(t),i=n?hh(n):gh(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
26
+ `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
27
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function hh(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=gh(n[r])}return t}function gh(e){return e.spread??e.children.length>1}function _h(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function vh(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yh(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function bh(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xh(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=fd(t.children[1]),o=dd(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Sh(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Ch(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var wh=9,Th=32;function Eh(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Dh(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Dh(t.slice(i),i>0,!1)),a.join(``)}function Dh(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===wh||t===Th;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===wh||t===Th;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Oh(e,t){let n={type:`text`,value:Eh(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function kh(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Ah={blockquote:eh,break:th,code:nh,delete:rh,emphasis:ih,footnoteReference:ah,heading:oh,html:sh,imageReference:lh,image:uh,inlineCode:dh,linkReference:fh,link:ph,listItem:mh,list:_h,paragraph:vh,root:yh,strong:bh,table:xh,tableCell:Ch,tableRow:Sh,text:Oh,thematicBreak:kh,toml:jh,yaml:jh,definition:jh,footnoteDefinition:jh};function jh(){}var{defineProperty:Mh}=Object,Nh=typeof self==`object`?self:globalThis,Ph=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Nh[e](t)},Fh=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?Mh(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof Nh[e]==`function`?Ph(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(Ph(a,o),i)};return r},Ih=e=>Fh(new Map,e)(0),Lh=``,{toString:Rh}={},{keys:zh,is:Bh}=Object,Vh=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Rh.call(e).slice(8,-1);switch(n){case`Array`:return[1,Lh];case`Object`:return[2,Lh];case`Date`:return[3,Lh];case`RegExp`:return[4,Lh];case`Map`:return[5,Lh];case`Set`:return[6,Lh];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},Hh=([e,t])=>e===0&&(t===`function`||t===`symbol`),Uh=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=Vh(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&Bh(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of zh(o))(e||!Hh(Vh(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?Lh:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(Hh(Vh(n))||Hh(Vh(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!Hh(Vh(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},Wh=(e,{json:t,lossy:n}={})=>{let r=[];return Uh(!(t||n),!!t,new Map,r)(e),r},Gh=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Ih(Wh(e,t)):structuredClone(e):(e,t)=>Ih(Wh(e,t));function Kh(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function qh(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function Jh(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||Kh,r=e.options.footnoteBackLabel||qh,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=Tf(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...Gh(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
28
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
29
+ `}]}}var Yh=(function(e){if(e==null)return eg;if(typeof e==`function`)return $h(e);if(typeof e==`object`)return Array.isArray(e)?Xh(e):Zh(e);if(typeof e==`string`)return Qh(e);throw Error(`Expected function, string, or object as test`)});function Xh(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Yh(e[n]);return $h(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Zh(e){let t=e;return $h(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Qh(e){return $h(t);function t(t){return t&&t.type===e}}function $h(e){return t;function t(t,n,r){return!!(tg(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function eg(){return!0}function tg(e){return typeof e==`object`&&!!e&&`type`in e}function ng(e){return e}var rg=[],ig=`skip`;function ag(e,t,n,r){if(!e||typeof e!=`object`)throw Error("Unexpected value `"+e+"` for `tree`, expected node");let i=!0,a,o,s,c;if(typeof n==`function`||n&&typeof n==`object`?(a=t,o=n,r&&(i=!1)):(o=t,n&&(i=!1)),typeof o==`function`)s=o;else if(o&&typeof o==`object`){if(o.enter!==null&&o.enter!==void 0){if(typeof o.enter==`function`)s=o.enter;else throw Error("Unexpected value `"+o.enter+"` for `visitors.enter`, expected optional visitor")}if(typeof o.exit==`function`)c=o.exit;else throw Error("Unexpected value `"+o.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw Error("Unexpected value `"+o+"` for `enter` or `visitors`, expected visitor or object with visitors");let l=Yh(a),u=i?1:-1;d(e,void 0,[])();function d(e,t,n){let r=e&&typeof e==`object`?e:{};if(typeof r.type==`string`){let t=typeof r.tagName==`string`?r.tagName:typeof r.name==`string`?r.name:void 0;Object.defineProperty(o,"name",{value:`node (`+ng(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=rg;if(s&&r&&(o=og(s(e,n,t)),o[0]===!1))return o;if(`children`in e&&e.children){let t=e;if(t.children&&o[0]!==`skip`){let e=(i?-1:t.children.length)+u,r=[...n,t];for(;e>-1&&e<t.children.length;){let n=t.children[e],i=d(n,e,r)();if(i[0]===!1)return i;e=typeof i[1]==`number`?i[1]:e+u}}}if(c&&r){let r=og(c(e,n,t));if(r[0]===`skip`)throw Error("Unexpected value `"+r[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(r[0]===!1||typeof r[1]==`number`)return r}return o}}}function og(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?rg:[e]}function sg(e,t,n,r){let i,a,o;typeof n==`function`||n&&typeof n==`object`?(i=t,a=n,o=r):(a=t,o=n),typeof a==`function`?ag(e,i,lg(a),o):ag(e,i,cg(a),o)}function cg(e){return!e||typeof e!=`object`?e:{enter:typeof e.enter==`function`?lg(e.enter):e.enter,exit:typeof e.exit==`function`?lg(e.exit):e.exit}}function lg(e){return t;function t(t,n,r){return e(t,r,n[n.length-1])}}var ug={}.hasOwnProperty,dg={};function fg(e,t){let n=t||dg,r=new Map,i=new Map,a={all:s,applyData:mg,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Ah,...n.handlers},one:o,options:n,patch:pg,wrap:gg};return sg(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(ug.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=Gh(n);return r.children=a.all(e),r}return Gh(e)}return(a.options.unknownHandler||hg)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=_g(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=_g(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function pg(e,t){e.position&&(t.position=md(e))}function mg(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,Gh(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function hg(e,t){let n=t.data||{},r=`value`in t&&!(ug.call(n,`hProperties`)||ug.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function gg(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
30
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
31
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
32
+ `}),n}function _g(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function vg(e,t){let n=fg(e,t),r=n.one(e,void 0),i=Jh(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
33
+ `},i)),a}function yg(e,t){return e&&`run`in e?async function(n,r){let i=vg(n,{file:r,...t});await e.run(i,r)}:function(n,r){return vg(n,{file:r,...e||t})}}function bg(e){if(e)throw e}var xg=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Sg(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Cg(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?wg(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function wg(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Tg={basename:Eg,dirname:Dg,extname:Og,join:kg,sep:`/`};function Eg(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Mg(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Dg(e){if(Mg(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Og(e){Mg(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function kg(...e){let t=-1,n;for(;++t<e.length;)Mg(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Ag(n)}function Ag(e){Mg(e);let t=e.codePointAt(0)===47,n=jg(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function jg(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Mg(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Ng={cwd:Pg};function Pg(){return`/`}function Fg(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Ig(e){if(typeof e==`string`)e=new URL(e);else if(!Fg(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Lg(e)}function Lg(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Rg=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],zg=class{constructor(e){let t;t=e?Fg(e)?{path:e}:typeof e==`string`||Ug(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Ng.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Rg.length;){let e=Rg[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Rg.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Tg.basename(this.path):void 0}set basename(e){Vg(e,`basename`),Bg(e,`basename`),this.path=Tg.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Tg.dirname(this.path):void 0}set dirname(e){Hg(this.basename,`dirname`),this.path=Tg.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Tg.extname(this.path):void 0}set extname(e){if(Bg(e,`extname`),Hg(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Tg.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Fg(e)&&(e=Ig(e)),Vg(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Tg.basename(this.path,this.extname):void 0}set stem(e){Vg(e,`stem`),Bg(e,`stem`),this.path=Tg.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new yd(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Bg(e,t){if(e&&e.includes(Tg.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Tg.sep+"`")}function Vg(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Hg(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Ug(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Wg=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Gg=t(xg(),1),Kg={}.hasOwnProperty,qg=new class e extends Wg{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Cg()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Gg.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(Xg(`data`,this.frozen),this.namespace[e]=t,this):Kg.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Xg(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=$g(e),n=this.parser||this.Parser;return Jg(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Jg(`process`,this.parser||this.Parser),Yg(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=$g(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);t_(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Jg(`processSync`,this.parser||this.Parser),Yg(`processSync`,this.compiler||this.Compiler),this.process(e,r),Qg(`processSync`,`process`,t),n;function r(e,r){t=!0,bg(e),n=r}}run(e,t,n){Zg(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=$g(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Qg(`runSync`,`run`,n),r;function i(e,t){bg(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=$g(t),r=this.compiler||this.Compiler;return Yg(`stringify`,r),Zg(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(Xg(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Gg.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Sg(o)&&Sg(r)&&(r=(0,Gg.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Jg(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Yg(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function Xg(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Zg(e){if(!Sg(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Qg(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function $g(e){return e_(e)?e:new zg(e)}function e_(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function t_(e){return typeof e==`string`||n_(e)}function n_(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Q=_u(),r_=[],i_={allowDangerousHtml:!0},a_=/^(https?|ircs?|mailto|xmpp)$/i,o_=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function s_(e){let t=c_(e),n=l_(e);return u_(t.runSync(t.parse(n),n),e)}function c_(e){let t=e.rehypePlugins||r_,n=e.remarkPlugins||r_,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...i_}:i_;return qg().use($m).use(n).use(yg,r).use(t)}function l_(e){let t=e.children||``,n=new zg;return typeof t==`string`?n.value=t:``+t,n}function u_(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||d_;for(let e of o_)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return sg(e,l),Dd(e,{Fragment:Q.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Q.jsx,jsxs:Q.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Yd)if(Object.hasOwn(Yd,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Yd[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function d_(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||a_.test(e.slice(0,t))?e:``}function f_(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function p_(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function m_(e,t,n){let r=Yh((n||{}).ignore||[]),i=h_(t),a=-1;for(;++a<i.length;)ag(e,o);function o(e,t,n){if(e.type===`text`&&typeof n==`number`)return s(e,t,n);if(r(e,n,t[t.length-1]))return ig}function s(e,t,n){let r=t[t.length-1],o=i[a][0],s=i[a][1],c=0,l=!1,u=[];o.lastIndex=0;let d=o.exec(e.value);for(;d;){let n=d.index,r={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,r);if(typeof i==`string`&&(i=i.length>0?{type:`text`,value:i}:void 0),i===!1)o.lastIndex=n+1;else{if(c!==n&&f({type:`text`,value:e.value.slice(c,n)}),Array.isArray(i))for(let e of i)f(e);else i&&f(i);c=n+d[0].length,l=!0}if(!o.global)break;d=o.exec(e.value)}return l?(c<e.value.length&&f({type:`text`,value:e.value.slice(c)}),r.children.splice(n,1,...u)):u=[e],n+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function h_(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([g_(e[0]),__(e[1])])}return t}function g_(e){return typeof e==`string`?new RegExp(p_(e),`g`):e}function __(e){return typeof e==`function`?e:function(){return e}}var v_=`phrasing`,y_=[`autolink`,`link`,`image`,`label`];function b_(){return{transforms:[O_],enter:{literalAutolink:S_,literalAutolinkEmail:C_,literalAutolinkHttp:C_,literalAutolinkWww:C_},exit:{literalAutolink:D_,literalAutolinkEmail:E_,literalAutolinkHttp:w_,literalAutolinkWww:T_}}}function x_(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:v_,notInConstruct:y_},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:v_,notInConstruct:y_},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:v_,notInConstruct:y_}]}}function S_(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function C_(e){this.config.enter.autolinkProtocol.call(this,e)}function w_(e){this.config.exit.autolinkProtocol.call(this,e)}function T_(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function E_(e){this.config.exit.autolinkEmail.call(this,e)}function D_(e){this.exit(e)}function O_(e){m_(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,k_],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,A_]],{ignore:[`link`,`linkReference`]})}function k_(e,t,n,r,i){let a=``;if(!N_(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!j_(n)))return!1;let o=M_(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function A_(e,t,n,r){return!N_(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function j_(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function M_(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=f_(e,`(`),a=f_(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function N_(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Cf(n)||Sf(n))&&(!t||n!==47)}U_.peek=H_;function P_(){this.buffer()}function F_(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function I_(){this.buffer()}function L_(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function R_(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=df(this.sliceSerialize(e)).toLowerCase(),n.label=t}function z_(e){this.exit(e)}function B_(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=df(this.sliceSerialize(e)).toLowerCase(),n.label=t}function V_(e){this.exit(e)}function H_(){return`[`}function U_(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function W_(){return{enter:{gfmFootnoteCallString:P_,gfmFootnoteCall:F_,gfmFootnoteDefinitionLabelString:I_,gfmFootnoteDefinition:L_},exit:{gfmFootnoteCallString:R_,gfmFootnoteCall:z_,gfmFootnoteDefinitionLabelString:B_,gfmFootnoteDefinition:V_}}}function G_(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:U_},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
34
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?q_:K_))),s(),o}}function K_(e,t,n){return t===0?e:q_(e,t,n)}function q_(e,t,n){return(n?``:` `)+e}var J_=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];$_.attention=ev,$_.peek=tv;function Y_(){return{canContainEols:[`delete`],enter:{strikethrough:Z_},exit:{strikethrough:Q_}}}function X_(){return{handlers:{delete:$_},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:J_}]}}function Z_(e){this.enter({type:`delete`,children:[],position:void 0},e)}function Q_(e){this.exit(e)}function $_(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function ev(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function tv(){return`~`}function nv(e){return e.length}function rv(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nv,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=iv(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=av(r[d]);else{let e=av(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding===!1||n.alignDelimiters===!1&&i===``||n.delimiterStart===!1&&!d||r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
35
+ `)}function iv(e){return e==null?``:String(e)}function av(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}var ov=Yh([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function sv(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),cv);return i(),o}function cv(e,t,n){return`>`+(n?``:` `)+e}function lv(e,t){return uv(e,t.inConstruct,!0)&&!uv(e,t.notInConstruct,!1)}function uv(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function dv(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
36
+ `&&!e.before&&!e.after&&lv(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
37
+ `}function fv(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function pv(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function mv(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function hv(e,t,n,r){let i=mv(n),a=e.value||``;if(pv(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,gv);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(fv(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
38
+ `,encode:["`"],...o.current()})),t()}return u+=o.move(`
39
+ `),a&&(u+=o.move(a+`
40
+ `)),u+=o.move(s),c(),u}function gv(e,t,n){return(n?``:` `)+e}function _v(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function vv(e,t,n,r){let i=_v(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
41
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function yv(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function bv(e){let t=e.codePointAt(0);return t===void 0?``:String.fromCodePoint(t)}function xv(e){let t=e.codePointAt(e.length-2);return t!==void 0&&t>65535?e.slice(-2):e.slice(-1)}function Sv(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Cv(e,t,n){let r=If(e),i=If(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function wv(e){if(e.charCodeAt(0)!==60)return;let t=e.charCodeAt(1);if(t===33){let t=e.charCodeAt(2);return t===45?2:t===91?5:ff(t)?4:void 0}if(t===63)return 3;let n=t===47,r=n?2:1,i=r,a=e.charCodeAt(i);if(!ff(a))return;for(;a===45||pf(a);)a=e.charCodeAt(++i);let o=e.slice(r,i).toLowerCase();return!n&&a!==47&&Fp.includes(o)?1:Pp.includes(o)?6:7}var Tv=new Map([[`*`,!1],[`_`,!0]]);function Ev(e,t,n){let r=new Set;for(let i of e){let e=n.get(i);if(e&&i.attention&&t.some(e=>e.attention===i.attention))for(let t of e.tokens)r.add(t.attention)}let i=[];for(let t of e)t.attention&&r.delete(t.attention)&&i.push(t.attention);return i.reverse(),i}function Dv(e,t,n){let r=[],i=new Map,a=new Map,o=0;for(;o<e.length;){if(!e[o].attention){o++;continue}let s=e[o].value.charAt(0),c=Tv.get(s),l=o+1;for(;l<e.length&&e[l].attention&&e[l].value.charAt(0)===s;)l++;let u=o?e[o-1].value:t,d=If(u.charCodeAt(u.length-1)),f=If((l<e.length?e[l].value:n).charCodeAt(0)),p=!f||f===2&&!!d,m=!d||d===2&&!!f,h={tokens:e.slice(o,l),markers:[],start:0,end:0,open:c?p&&(!!d||!m):p,close:c?m&&(!!f||!p):m,split:c!==void 0};for(let e of h.tokens){i.set(e,[...h.tokens]),a.set(e,h);let t=e.value.length;for(;t--;)h.markers.push(e)}h.end=h.markers.length,r.push(h),o=l}for(Av(r,i),o=-1;++o<e.length;){let t=i.get(e[o]);if(t)return{attention:Ev(e,t,a),index:o}}}function Ov(e,t){let n=e[t?0:e.length-1];if(!n||n.attention)return;let r=t?bv(n.value):xv(n.value),i=Sv(r.codePointAt(0));if(t)n.value=i+n.value.slice(r.length);else{let e=n.value.slice(0,n.value.length-r.length),t=0;for(;e.charCodeAt(e.length-1-t)===92;)t++;t%2&&(e+=`\\`),n.value=e+i}}function kv(e,t,n,r,i){for(let a of n.attention){let o=t.get(a)||a.sequences[0];for(let s of a.sequences){if(s===o)continue;let c=new Map(t);c.set(a,s);let l=Pv(e,c,r,i),u=Dv(l,r,i);if(!u||u.index>n.index)return{chosen:c,mistake:u,tokens:l}}}}function Av(e,t){let n=new Map;for(let r of e){let e=r.tokens[0].value.charAt(0),i=n.get(e);i||(i=[],n.set(e,i));let a=r.close?i.length:0;for(;a--&&r.start<r.end;){let e=i[a],n=e.end-e.start,o=r.end-r.start;if(r.split?(e.close||r.open)&&o%3&&!((n+o)%3):n!==e.markers.length||n!==o)continue;let s=r.split?n>1&&o>1?2:1:o,c=e.markers.slice(e.end-s,e.end),l=r.markers.slice(r.start,r.start+s),u=c[0],d=l[0];if(u===c[s-1]&&u.value.length===s&&d===l[s-1]&&d.value.length===s&&u.attention===d.attention)t.delete(u),t.delete(d);else{let e=[...new Set([...c,...l])];for(let n of e){let r=t.get(n);r&&r.push(...e)}}e.end-=s,r.start+=s,e.start===e.end&&i.splice(a,1),a=i.length}r.open&&r.start<r.end&&i.push(r)}}function jv(e,t,n){if(t.length===0)throw Error("Cannot serialize `"+e+"` as attention without markers, expected one or more markers");if(n.length===0)throw Error("Cannot serialize `"+e+"` as attention without sizes, expected one or more sizes");for(let t of n)if(!Number.isSafeInteger(t)||t<1)throw Error("Cannot serialize `"+e+"` as attention with `"+t+"` as size, expected positive integer");let r=[];for(let i of t){if(i.length!==1)throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected a single ascii character");if(!vf(i.charCodeAt(0)))throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected ascii punctuation");for(let e of n)r.push(i.repeat(e))}return r}function Mv(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before;r.push(-1);let c=t.createTracker(n);for(;++o<i.length;){let l=i[o],u;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),u=n?bv(n(i[o+1],e,t,{before:``,after:``,...c.current()})):``}else u=n.after;let d=a[a.length-1];typeof d==`string`&&(s===`\r`||s===`
42
+ `)&&l.type===`html`&&wv(l.value)!==7&&(a[a.length-1]=d.replace(/(\r?\n|\r)$/,` `),s=` `,c=t.createTracker(n),c.move(Fv(a,n.before,n.after)));let f=t.handle.handlers[l.type];if(f&&f.attention){let e=Nv(l,f.attention,t,c);a.push(e),s=xv(e.sequences[0])}else{let n=t.handle(l,e,t,{...c.current(),after:u,before:s});if(!n)continue;c.move(n),a.push(n),s=xv(n)}}return r.pop(),a}function Nv(e,t,n,r){let{construct:i,markers:a,sizes:o}=t(e,n),s=jv(e.type,a,o),c=s[0],l=n.enter(i);r.move(c);let u=Mv(e,n,{...r.current(),before:c,after:c});return r.move(Fv(u,c,c)),r.move(c),l(),{children:u,sequences:s}}function Pv(e,t,n,r){let i=[],a,o=xv(n),s=-1;for(;++s<e.length;){let n=e[s];if(typeof n==`string`){let e={value:n,attention:void 0};a&&a===bv(n)&&Ov([e],!0),a=void 0,i.push(e),e.value&&(o=xv(e.value));continue}let c=t.get(n)||n.sequences[0],l=c.charAt(0),u=e[s+1],d=o,f=bv(u===void 0?r:typeof u==`string`?u:t.get(u)||u.sequences[0]),p=Pv(n.children,t,c,c),m=p.length>0?p[0].value:``,h=Cv(d.charCodeAt(d.length-1),m.charCodeAt(0),l);h.inside&&Ov(p,!0);let g=p.length>0?xv(p[p.length-1].value):``,_=Cv(f.charCodeAt(0),g.charCodeAt(g.length-1),l);_.inside&&Ov(p,!1),h.outside&&d!==`
43
+ `&&d!==`\r`&&Ov(i,!1),_.outside&&(a=f),i.push({value:c,attention:n},...p,{value:c,attention:n}),o=c.charAt(c.length-1)}return i}function Fv(e,t,n){let r=new Map,i=Pv(e,r,t,n),a=i,o=Dv(a,t,n);for(;o;){let s=kv(e,r,o,t,n);if(!s){a=i;break}r=s.chosen,a=s.tokens,o=s.mistake}let s=``;for(let e of a)s+=e.value;return s}Iv.attention=Lv,Iv.peek=Rv;function Iv(e,t,n,r){let i=n.enter(`phrasing`),a=Fv([Nv(e,Lv,n,n.createTracker(r))],r.before,r.after);return i(),a}function Lv(e,t){return{construct:`emphasis`,markers:yv(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function Rv(e,t,n){return n.options.emphasis||`*`}function zv(e,t){let n=!1;return sg(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&Zd(e)&&(t.options.setext||n))}function Bv(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(zv(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
44
+ `,after:`
45
+ `});return r(),t(),o+`
46
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
47
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
48
+ `,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=Sv(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Vv.peek=Hv;function Vv(e){return e.value||``}function Hv(){return`<`}Uv.peek=Wv;function Uv(e,t,n,r){let i=_v(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Wv(){return`!`}Gv.peek=Kv;function Gv(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Kv(){return`!`}qv.peek=Jv;function qv(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Jv(){return"`"}function Yv(e,t){let n=Zd(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}Xv.peek=Zv;function Xv(e,t,n,r){let i=_v(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(Yv(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,{before:l,after:`](`,...o.current()});l+=o.move(u),c(),l+=o.move(`](`);let d=/[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
49
+ `||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:typeof p==`string`?` `:`)`,...o.current()}))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Zv(e,t,n){return Yv(e,n)?`<`:`[`}Qv.peek=$v;function Qv(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function $v(){return`[`}function ey(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ty(e){let t=ey(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function ny(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ry(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function iy(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?ny(n):ey(n),s=e.ordered?o===`.`?`)`:`.`:ty(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),ry(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function ay(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function oy(e,t,n,r){let i=ay(n),a=n.bulletCurrent||ey(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function sy(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function cy(e,t,n,r){if(!e.children.some(function(e){return ov(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function ly(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}uy.attention=dy,uy.peek=fy;function uy(e,t,n,r){let i=n.enter(`phrasing`),a=Fv([Nv(e,dy,n,n.createTracker(r))],r.before,r.after);return i(),a}function dy(e,t){return{construct:`strong`,markers:ly(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function fy(e,t,n){return n.options.strong||`*`}function py(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function my(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function hy(e,t,n){let r=(ry(n)+(n.options.ruleSpaces?` `:``)).repeat(my(n));return n.options.ruleSpaces?r.slice(0,-1):r}var gy={blockquote:sv,break:dv,code:hv,definition:vv,emphasis:Iv,hardBreak:dv,heading:Bv,html:Vv,image:Uv,imageReference:Gv,inlineCode:qv,link:Xv,linkReference:Qv,list:iy,listItem:oy,paragraph:sy,root:cy,strong:uy,text:py,thematicBreak:hy};function _y(){return{enter:{table:vy,tableData:Sy,tableHeader:Sy,tableRow:by},exit:{codeText:Cy,table:yy,tableData:xy,tableHeader:xy,tableRow:xy}}}function vy(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function yy(e){this.exit(e),this.data.inTable=void 0}function by(e){this.enter({type:`tableRow`,children:[]},e)}function xy(e){this.exit(e)}function Sy(e){this.enter({type:`tableCell`,children:[]},e)}function Cy(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,wy));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function wy(e,t){return t===`|`?t:e}function Ty(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
50
+ `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
51
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return rv(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=gy.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Ey(){return{exit:{taskListCheckValueChecked:Oy,taskListCheckValueUnchecked:Oy,paragraph:ky}}}function Dy(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Ay}}}function Oy(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function ky(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Ay(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=gy.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function jy(){return[b_(),W_(),Y_(),_y(),Ey()]}function My(e){return{extensions:[x_(),G_(e),X_(),Ty(e),Dy()]}}var Ny={tokenize:qy,partial:!0},Py={tokenize:Jy,partial:!0},Fy={tokenize:Yy,partial:!0},Iy={tokenize:Xy,partial:!0},Ly={tokenize:Zy,partial:!0},Ry={name:`wwwAutolink`,tokenize:Gy,previous:Qy},zy={name:`protocolAutolink`,tokenize:Ky,previous:$y},By={name:`emailAutolink`,tokenize:Wy,previous:eb},Vy={};function Hy(){return{text:Vy}}for(var Uy=48;Uy<123;)Vy[Uy]=By,Uy++,Uy===58?Uy=65:Uy===91&&(Uy=97);Vy[43]=By,Vy[45]=By,Vy[46]=By,Vy[95]=By,Vy[72]=[By,zy],Vy[104]=[By,zy],Vy[87]=[By,Ry],Vy[119]=[By,Ry];function Wy(e,t,n){let r=this,i,a;return o;function o(t){return!tb(t)||!eb.call(r,r.previous)||nb(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return tb(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ly,u,l)(t):t===45||t===95||pf(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&ff(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Gy(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Qy.call(r,r.previous)||nb(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Ny,e.attempt(Py,e.attempt(Fy,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Ky(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&$y.call(r,r.previous)&&!nb(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(ff(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||hf(t)||bf(t)||Cf(t)||Sf(t)?n(t):e.attempt(Py,e.attempt(Fy,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function qy(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Jy(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Iy,c,s)(t):t===null||bf(t)||Cf(t)||t!==45&&Sf(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Yy(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Iy,t,a)(o):o===null||bf(o)||Cf(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Xy(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||bf(o)||Cf(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||bf(e)||Cf(e)?t(e):r(e)}function a(e){return ff(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):ff(t)?(e.consume(t),o):n(t)}}function Zy(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return pf(e)?n(e):t(e)}}function Qy(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||bf(e)}function $y(e){return!ff(e)}function eb(e){return!(e===47||tb(e))}function tb(e){return e===43||e===45||e===46||e===95||pf(e)}function nb(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var rb={tokenize:db,partial:!0};function ib(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:cb,continuation:{tokenize:lb},exit:ub}},text:{91:{name:`gfmFootnoteCall`,tokenize:sb},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:ab,resolveTo:ob}}}}function ab(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=df(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ob(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function sb(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||bf(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(df(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return bf(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function cb(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||bf(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=df(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return bf(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Ef(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function lb(e,t,n){return e.check(Wf,t,e.attempt(rb,t,n))}function ub(e){e.exit(`gfmFootnoteDefinition`)}function db(e,t,n){let r=this;return Ef(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function fb(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&rf(o,o.length,0,Lf(s,e.slice(r+1,n),t)),rf(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),rf(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=If(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=If(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var pb=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){mb(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function mb(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function hb(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function gb(){return{flow:{null:{name:`table`,tokenize:_b,resolveAll:vb}}}}function _b(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):yf(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):xf(t)?Ef(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||bf(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,xf(t)?Ef(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return xf(t)?Ef(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||yf(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return xf(t)?Ef(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||yf(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||yf(n)?(e.exit(`tableRow`),t(n)):xf(n)?Ef(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||bf(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function vb(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new pb;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(bb(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=yb(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=yb(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=yb(f,t,o,i,n,d)):(o[0]=o[1],d=yb(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&bb(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=hb(t.events,n))}return e}function yb(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},xb(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=xb(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=xb(t.events,n[2]),a=xb(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},xb(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function bb(e,t,n,r,i){let a=[],o=xb(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function xb(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Sb={name:`tasklistCheck`,tokenize:wb};function Cb(){return{text:{91:Sb}}}function wb(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return bf(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return yf(r)?t(r):xf(r)?e.check({tokenize:Tb},t,n)(r):n(r)}}function Tb(e,t,n){return Ef(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Eb(e){return sf([Hy(),ib(),fb(e),gb(),Cb()])}var Db={};function Ob(e){let t=this,n=e||Db,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Eb(n)),a.push(jy()),o.push(My(n))}var kb=class extends tc{picker;pickWith(e){if(this.picker)throw Error(`There are two # lists.`);this.picker=e}list(){return this.picker}},Ab=(0,d.createContext)(null);function jb(){return(0,d.useContext)(Ab)}var Mb=new kb;function Nb({board:e,kinds:t=Mb,children:n}){let r=(0,d.useMemo)(()=>{let n=new Map(t.kinds().map(t=>[t.id,t.on(e)])),r=(e,t)=>{let r=n.get(e);return!(!r||!r.card(t)&&r.deletedBy(t)===void 0)},i=t.list(),a=i?.on(e);return{known:r,scanner:t.scanner(),card:(e,t)=>n.get(e)?.card(t),deletedBy:(e,t)=>n.get(e)?.deletedBy(t),label:(e,n)=>t.label(e,n),picker:i&&a&&{name:i.name,read:i.read,pick:a}}},[e,t]);return(0,Q.jsx)(Ab.Provider,{value:r,children:n})}function Pb(e){let{kind:t,number:n,inert:r,children:i}=e,a=jb(),o=a?.card(t,n),s=i??a?.label(t,n)??`${t} ${n}`,c=o?void 0:a?.deletedBy(t,n);if(c!==void 0)return(0,Q.jsx)(`span`,{className:`ref-chip ref-deleted${r?` is-inert`:``}`,title:`Deleted by ${c}, for good`,children:s});if(!o)return(0,Q.jsx)(Q.Fragment,{children:s});let l={className:`ref-chip ${o.marker}${r?` is-inert`:``} nodrag nopan`,title:`${o.title} · ${o.status}`,onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation()};if(r){let e=e=>{e.stopPropagation(),o.open()};return(0,Q.jsx)(`span`,{...l,onClick:e,children:s})}return(0,Q.jsx)(`a`,{...l,href:o.href,draggable:!1,onClick:e=>e.stopPropagation(),children:s})}var Fb=[`blockQuote`,`codeFenced`,`codeIndented`,`definition`,`gfmFootnoteDefinition`,`headingAtx`,`htmlFlow`,`list`,`setextUnderline`,`table`,`thematicBreak`];function Ib(){let e=this.data();(e.micromarkExtensions??=[]).push({disable:{null:Fb}})}var Lb=[Ob],Rb=[Ob,Ib];function zb(e={}){let t=(n,r)=>{n.children.forEach((i,a)=>{if(i.type!==`element`)return;if(i.tagName!==`img`)return t(i,r||i.tagName===`a`);let o=String(i.properties.src??``);if(i.properties.dataBeside||e.shows?.(o))return;let s={type:`text`,value:String(i.properties.alt??``)||o};n.children[a]=r?s:{type:`element`,tagName:`a`,properties:{href:o},children:[s]}})};return e=>t(e,!1)}var Bb=e=>e!==``&&!/^([a-z][a-z0-9+.-]*:|[#/?])/i.test(e);function Vb(e){let t=n=>{for(let r of n.children){if(r.type!==`element`)continue;let n=String(r.properties[r.tagName===`img`?`src`:`href`]??``),i=Bb(n)?r.tagName===`img`?e.picture(n):r.tagName===`a`?e.link(n):void 0:void 0;i&&r.tagName===`img`&&(r.properties={...r.properties,src:i,dataBeside:!0}),i&&r.tagName===`a`&&(r.properties={...r.properties,href:i,dataHere:!0}),t(r)}};return e=>t(e)}var Hb=e=>e.startsWith(Jr(J.asset,{id:``}))||/^data:/i.test(e),Ub={x:0,y:0},Wb=e=>Ub={x:e.clientX,y:e.clientY},Gb=e=>e.detail>0&&Math.abs(e.clientX-Ub.x)+Math.abs(e.clientY-Ub.y)>4;function Kb(e,t){e.preventDefault(),Gb(e)||e.currentTarget.closest(`.md`)?.querySelector(`#${CSS.escape(t)}`)?.scrollIntoView({block:`nearest`})}function qb({node:e,...t}){let n=ec(t[`data-ref`]);if(n)return(0,Q.jsx)(Pb,{...n,children:t.children});let r=t.href??``;return t[`data-here`]?(0,Q.jsx)(`a`,{...t,draggable:!1,onMouseDown:Wb,onClick:e=>Gb(e)&&e.preventDefault()}):r.startsWith(`#`)?(0,Q.jsx)(`a`,{...t,draggable:!1,onMouseDown:Wb,onClick:e=>Kb(e,r.slice(1))}):(0,Q.jsx)(`a`,{...t,draggable:!1,target:`_blank`,rel:`noreferrer`,onMouseDown:Wb,onClick:e=>Gb(e)&&e.preventDefault()})}var Jb={p:({children:e})=>(0,Q.jsx)(Q.Fragment,{children:e})};function Yb(){let e=t=>{for(let n of t.children){if(n.type!==`element`)continue;let t=n.properties.className;if(n.tagName===`li`&&Array.isArray(t)&&t.includes(`task-list-item`)&&n.position){let e=n.children.find(e=>e.type===`element`),r=e?.tagName===`input`?e:e?.tagName===`p`?e.children.find(e=>e.type===`element`&&e.tagName===`input`):void 0;r?.type===`element`&&(r.properties.dataTaskLine=n.position.start.line,r.properties.checked&&(n.properties.className=[...t,`is-done`]))}e(n)}};return t=>e(t)}var Xb=(0,d.createContext)(void 0);function Zb({node:e,...t}){let n=(0,d.useContext)(Xb),r=Number(t[`data-task-line`]);if(!n||t.type!==`checkbox`||!r)return(0,Q.jsx)(`input`,{...t});let i=!!t.checked;return(0,Q.jsx)(`input`,{type:`checkbox`,className:`task-box nodrag`,checked:i,onChange:e=>n(r,e.currentTarget.checked),onDoubleClick:e=>e.stopPropagation()})}function Qb({children:e,inline:t=!1,onTick:n,beside:r,rehypePlugins:i,components:a}){let o=jb(),s=t?[zb]:[Yb,[zb,{shows:Hb}]];r&&s.unshift([Vb,r]),o?.scanner&&s.push([o.scanner.rehype,{known:o.known}]);let c=(0,Q.jsx)(s_,{remarkPlugins:t?Rb:Lb,rehypePlugins:[...s,...i??[]],components:{a:qb,...t?Jb:{input:Zb},...a},children:e});return t?(0,Q.jsx)(`span`,{className:`md-inline`,children:c}):(0,Q.jsx)(`div`,{className:`md`,children:(0,Q.jsx)(Xb.Provider,{value:n,children:c})})}function $b(e){return(0,Q.jsx)(Qb,{...e,inline:!0})}function ex(e){let t=Math.max(0,(Date.now()-Date.parse(e))/1e3);if(t<45)return`just now`;let n=t/60;if(n<60)return`${Math.round(n)}m ago`;let r=n/60;if(r<24)return`${Math.round(r)}h ago`;let i=r/24;return i<7?`${Math.round(i)}d ago`:new Date(e).toLocaleDateString()}function tx(e){let t=(Date.now()-Date.parse(e))/36e5;return t>=24&&t<48?`yesterday`:ex(e)}var nx={"arrow-right":(0,Q.jsx)(`path`,{d:`M3 8h10M9 4l4 4-4 4`}),"arrow-left":(0,Q.jsx)(`path`,{d:`M13 8H3M7 4 3 8l4 4`}),"arrow-up":(0,Q.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-up-left":(0,Q.jsx)(`path`,{d:`M11.5 11.5 4.5 4.5M4.5 10V4.5H10`}),"chevron-down":(0,Q.jsx)(`path`,{d:`m4.5 6.25 3.5 3.5 3.5-3.5`}),"chevron-left":(0,Q.jsx)(`path`,{d:`M9.75 4.5 6.25 8l3.5 3.5`}),expand:(0,Q.jsx)(`path`,{d:`M9.5 2.75h3.75V6.5M13.25 2.75 9 7M6.5 13.25H2.75V9.5M2.75 13.25 7 9`}),contract:(0,Q.jsx)(`path`,{d:`M12.75 7.25H8.75V3.25M8.75 7.25l4.5-4.5M3.25 8.75h4v4M7.25 8.75l-4.5 4.5`}),external:(0,Q.jsx)(`path`,{d:`M7 4.5H4.5a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V9M9.5 3.5h3v3M12.5 3.5l-5 5`}),plus:(0,Q.jsx)(`path`,{d:`M8 3v10M3 8h10`}),x:(0,Q.jsx)(`path`,{d:`m4.5 4.5 7 7m0-7-7 7`}),edit:(0,Q.jsx)(`path`,{d:`M3 13l.6-2.7 7-7a1.45 1.45 0 0 1 2.1 2.1l-7 7ZM9.4 4.6l2 2`}),check:(0,Q.jsx)(`path`,{d:`m3.5 8.5 3 3 6-7`}),sync:(0,Q.jsx)(`path`,{d:`M2.75 7.25A5.3 5.3 0 0 1 12.4 5M12.75 2.25V5H10M13.25 8.75A5.3 5.3 0 0 1 3.6 11M3.25 13.75V11H6`}),bell:(0,Q.jsx)(`path`,{d:`M4 11.5h8l-1-1.5V7a3 3 0 0 0-6 0v3l-1 1.5ZM6.8 13.5a1.3 1.3 0 0 0 2.4 0`}),search:(0,Q.jsx)(`path`,{d:`M7 11.5a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9ZM10.25 10.25 13.5 13.5`}),canvas:(0,Q.jsx)(`path`,{d:`M3.75 2.75h8.5a1 1 0 0 1 1 1v8.5a1 1 0 0 1-1 1h-8.5a1 1 0 0 1-1-1v-8.5a1 1 0 0 1 1-1ZM5.5 5.5h2.25v2.25H5.5ZM8.5 9h2v1.5h-2Z`}),"panel-left":(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{className:`icon-fill`,d:`M3.75 2.75h2.5v10.5h-2.5a1 1 0 0 1-1-1v-8.5a1 1 0 0 1 1-1Z`,fill:`currentColor`,stroke:`none`}),(0,Q.jsx)(`path`,{d:`M3.75 2.75h8.5a1 1 0 0 1 1 1v8.5a1 1 0 0 1-1 1h-8.5a1 1 0 0 1-1-1v-8.5a1 1 0 0 1 1-1ZM6.25 2.75v10.5`})]}),"panel-right":(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{className:`icon-fill`,d:`M9.75 2.75h2.5a1 1 0 0 1 1 1v8.5a1 1 0 0 1-1 1h-2.5Z`,fill:`currentColor`,stroke:`none`}),(0,Q.jsx)(`path`,{d:`M3.75 2.75h8.5a1 1 0 0 1 1 1v8.5a1 1 0 0 1-1 1h-8.5a1 1 0 0 1-1-1v-8.5a1 1 0 0 1 1-1ZM9.75 2.75v10.5`})]}),comment:(0,Q.jsx)(`path`,{d:`M3 4.25c0-.7.55-1.25 1.25-1.25h7.5c.7 0 1.25.55 1.25 1.25v5.5c0 .7-.55 1.25-1.25 1.25H7.5L4.75 13.25V11h-.5C3.55 11 3 10.45 3 9.75Z`}),more:(0,Q.jsx)(`path`,{d:`M3.5 8h.01M8 8h.01M12.5 8h.01`,strokeWidth:`2.2`}),details:(0,Q.jsx)(`path`,{d:`M3 4.5h10M3 8h10M3 11.5h6`}),archive:(0,Q.jsx)(`path`,{d:`M2.5 3.5h11v3h-11ZM3.5 6.5v6h9v-6M6.5 9h3`}),link:(0,Q.jsx)(`path`,{d:`M6.7 9.3a2.9 2.9 0 0 0 4.1 0l2.2-2.2a2.9 2.9 0 0 0-4.1-4.1l-.9.9M9.3 6.7a2.9 2.9 0 0 0-4.1 0L3 8.9A2.9 2.9 0 0 0 7.1 13l.9-.9`}),partly:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5`}),(0,Q.jsx)(`path`,{d:`M8 3a5 5 0 0 1 0 10Z`,fill:`currentColor`,stroke:`none`})]}),star:(0,Q.jsx)(`path`,{d:`m8 2 1.8 3.7 4 .6-2.9 2.8.7 4L8 11.2 4.4 13.1l.7-4-2.9-2.8 4-.6Z`,fill:`currentColor`,strokeWidth:`1`}),sun:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`}),(0,Q.jsx)(`path`,{d:`M8 1.5v1.5M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1.06 1.06M11.54 11.54l1.06 1.06M3.4 12.6l1.06-1.06M11.54 4.46l1.06-1.06`})]}),moon:(0,Q.jsx)(`path`,{d:`M13.5 9.6A5.75 5.75 0 0 1 6.4 2.5a5.75 5.75 0 1 0 7.1 7.1Z`}),"knitted-plug":(0,Q.jsx)(`path`,{d:`M6.25 1.5v2.25M9.75 1.5v2.25M4.75 3.75h6.5v1.5a3.25 3.25 0 0 1-6.5 0ZM8 8.5v1.75c0 3.35 3.4 3.75 3.6 1.35.09-.9-.39-1.44-1.09-1.57M6.16 12.85c-1.05.84-2.36 1.43-3.91 1.4`}),thread:(0,Q.jsx)(`path`,{d:`M4.5 1.75h7a1 1 0 0 1 0 2h-7a1 1 0 0 1 0-2ZM4.5 12.25h7a1 1 0 0 1 0 2h-7a1 1 0 0 1 0-2ZM5.25 3.75v8.5M10.75 3.75v8.5M5.25 6.25l5.5-1.25M5.25 8.75l5.5-1.25M5.25 11.25l5.5-1.25M10.75 8.5c.9 0 1.2.8 2 .8.55 0 .9-.35 1.1-.7`}),react:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M10.9 5.6A5 5 0 1 0 12 9`}),(0,Q.jsx)(`path`,{d:`M5 10.6a2.6 2.6 0 0 0 4 0`}),(0,Q.jsx)(`path`,{d:`M5.3 7.6h.01M8.7 7.6h.01`,strokeWidth:`2`}),(0,Q.jsx)(`path`,{d:`M13 1.75v3.5M11.25 3.5h3.5`})]}),globe:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,Q.jsx)(`path`,{d:`M2.5 8h11M8 2.5c1.55 1.5 2.35 3.35 2.35 5.5S9.55 12 8 13.5C6.45 12 5.65 10.15 5.65 8S6.45 4 8 2.5Z`})]}),desktop:(0,Q.jsx)(`path`,{d:`M2.75 3h10.5a.75.75 0 0 1 .75.75v6.5a.75.75 0 0 1-.75.75H2.75a.75.75 0 0 1-.75-.75v-6.5A.75.75 0 0 1 2.75 3ZM5.75 13.5h4.5M8 11v2.5`}),phone:(0,Q.jsx)(`path`,{d:`M5.25 1.75h5.5a1 1 0 0 1 1 1v10.5a1 1 0 0 1-1 1h-5.5a1 1 0 0 1-1-1V2.75a1 1 0 0 1 1-1ZM7.25 12h1.5`}),pause:(0,Q.jsx)(`path`,{d:`M6 4v8M10 4v8`}),trash:(0,Q.jsx)(`path`,{d:`M3 4.5h10M6.25 4.5V3.25h3.5V4.5M4.5 4.5l.55 8.1a1 1 0 0 0 1 .9h3.9a1 1 0 0 0 1-.9l.55-8.1M6.75 7v4M9.25 7v4`}),code:(0,Q.jsx)(`path`,{d:`M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5M9 3 7 13`}),note:(0,Q.jsx)(`path`,{d:`M4 2.5h5.25L12 5.25v8.25H4ZM9 2.75V5.5h2.75M6 8.5h4M6 11h2.5`}),diagram:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`2`,y:`2.5`,width:`5`,height:`4`,rx:`1`}),(0,Q.jsx)(`rect`,{x:`9`,y:`9.5`,width:`5`,height:`4`,rx:`1`}),(0,Q.jsx)(`path`,{d:`M4.5 6.5v3.5a1.5 1.5 0 0 0 1.5 1.5h3`})]}),image:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,Q.jsx)(`circle`,{cx:`5.75`,cy:`6.5`,r:`1.1`}),(0,Q.jsx)(`path`,{d:`m2.5 12 3.5-3.5 2.5 2.5 2-2 3 3`})]}),table:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`}),(0,Q.jsx)(`path`,{d:`M2 6h12M2 9.75h12M6.5 6v7.5`})]}),chart:(0,Q.jsx)(`path`,{d:`M2.5 13.5h11M4.5 13.5V9M8 13.5V4.5M11.5 13.5V7`}),scene:(0,Q.jsx)(`path`,{d:`M8 1.75 13.5 4.75v6.5L8 14.25 2.5 11.25v-6.5ZM2.5 4.75 8 7.75l5.5-3M8 7.75v6.5`}),comparison:(0,Q.jsx)(`path`,{d:`M8 2.5v11M5.5 13.5h5M3 5h10M3 5 1.5 9M3 5l1.5 4M1.5 9a1.5 1.5 0 0 0 3 0M13 5l-1.5 4M13 5l1.5 4M11.5 9a1.5 1.5 0 0 0 3 0`}),folder:(0,Q.jsx)(`path`,{d:`M2.5 4.75a1 1 0 0 1 1-1h2.85l1.4 1.6h4.75a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1Z`}),pages:(0,Q.jsx)(`path`,{d:`M5.75 2.75h5.5a1 1 0 0 1 1 1v7M4.25 4.75h5.5a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-5.5a1 1 0 0 1-1-1v-6.5a1 1 0 0 1 1-1Z`}),group:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`1.75`,y:`2.25`,width:`12.5`,height:`11.5`,rx:`2`,strokeDasharray:`1.5 2.25`}),(0,Q.jsx)(`rect`,{x:`4.5`,y:`5`,width:`3.25`,height:`3`,rx:`.75`}),(0,Q.jsx)(`rect`,{x:`8.25`,y:`8`,width:`3.25`,height:`3`,rx:`.75`})]})};function $({name:e,className:t}){return(0,Q.jsx)(`svg`,{className:t?`icon ${t}`:`icon`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:nx[e]})}function rx(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return t}function ix({actor:e,showName:t=!0,title:n}){let r=e.kind===`human`?{"--hue":rx(e.name)}:void 0;return(0,Q.jsxs)(`span`,{className:`actor actor-${e.kind}`,title:n??`${e.name} (${e.kind})`,children:[(0,Q.jsx)(`span`,{className:`actor-mark`,style:r,"aria-hidden":!0,children:e.name.charAt(0).toUpperCase()}),t&&(0,Q.jsx)(`span`,{className:`actor-name`,children:e.name})]})}function ax({text:e,block:t}){let[n,r]=(0,d.useState)(!1);return(0,Q.jsxs)(`div`,{className:t?`copyline is-block`:`copyline`,children:[(0,Q.jsx)(`code`,{children:e}),(0,Q.jsx)(`button`,{className:`btn btn-quiet btn-small`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}},children:n?`Copied`:`Copy`})]})}function ox({className:e,children:t}){let n=(0,d.useRef)(null),[r,i]=(0,d.useState)(!1),a=(0,d.useCallback)(()=>{let e=n.current;e&&(e.open=!1,e.contains(document.activeElement)&&e.querySelector(`summary`)?.focus())},[]);return Zl(r,a,n),(0,Q.jsx)(`details`,{ref:n,className:e?`popover ${e}`:`popover`,onToggle:e=>i(e.currentTarget.open),children:typeof t==`function`?t(a):t})}function sx({size:e}){return(0,Q.jsx)(`svg`,{className:`board-mark`,width:e,height:e,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,Q.jsxs)(`g`,{transform:`rotate(45 8 8)`,children:[(0,Q.jsx)(`path`,{d:`M1.5 5H9.25M12.75 5H14.5M1.5 11H3.25M6.75 11H14.5`,fill:`none`,stroke:`var(--brand-warp)`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,Q.jsx)(`path`,{d:`M5 1.5V3.25M5 6.75V14.5M11 1.5V9.25M11 12.75V14.5`,fill:`none`,stroke:`var(--brand-weft)`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,Q.jsx)(`rect`,{x:`6.75`,y:`6.75`,width:`2.5`,height:`2.5`,rx:`0.5`,fill:`var(--text)`})]})})}function cx({small:e=!1}){return(0,Q.jsxs)(`span`,{className:`brand-lockup${e?` brand-lockup-small`:``}`,children:[(0,Q.jsx)(sx,{size:e?22:30}),(0,Q.jsx)(`span`,{className:`brand-text`,children:(0,Q.jsx)(`span`,{className:`wordmark`,children:`Tricot`})})]})}var lx=e=>Pt(e).at(-1),ux=class{all=[];words;panelWords;requestCardsOf;add(e){if(this.find(e.id))throw Error(`There are two kinds of card named ${e.id}.`);this.all.push(e)}wordPinsWith(e){if(this.words)throw Error(`There are two sets of words for the pin menu.`);this.words=e}wordAgentPanelWith(e){if(this.panelWords)throw Error(`There are two sets of words for the agents panel.`);this.panelWords=e}requestCardsWith(e){if(this.requestCardsOf)throw Error(`There are two renderers of the cards a request made.`);this.requestCardsOf=e}requestCards(e){return this.requestCardsOf?.(e)??null}noWork(e){return this.panelWords?.noWork(e)??`${e} has nothing claimed right now.`}activityRows(){return this.panelWords?.activityRows??[]}kinds(){return this.all}find(e){return this.all.find(t=>t.id===e)}byId(e,t,n){return this.find(e)?.byId?.(t,n)}pinActions(e){return this.all.flatMap(t=>t.pin?.(e)??[])}pinWords(e){return this.words?.(e)}reaction(e){for(let t of this.all){let n=t.react?.(e);if(n)return n}}question(){return this.all.find(e=>e.question)?.question}workCard(e,t){return this.find(e)?.workCard?.(t)??null}hasWork(){return this.all.some(e=>e.work)}async work(e){return(await Promise.all(this.all.map(t=>t.work?.(e)??[]))).flat()}},dx=new ux,fx=(0,d.createContext)(dx);function px({kinds:e,children:t}){return(0,Q.jsx)(fx.Provider,{value:e,children:t})}function mx(){return(0,d.useContext)(fx)}function hx(e){let{href:t,className:n,title:r,onClick:i,children:a}=e;return t===void 0?(0,Q.jsx)(`span`,{className:n,title:r,children:a}):(0,Q.jsx)(`a`,{className:n,href:t,title:r,onClick:i,children:a})}var gx=`tricot:notify`,_x=typeof window<`u`&&`Notification`in window,vx=null;function yx(){vx??=new AudioContext,vx.resume()}function bx(){if(!vx)return;let e=vx.currentTime;[659.25,880].forEach((t,n)=>{let r=vx.createOscillator(),i=vx.createGain();r.type=`sine`,r.frequency.value=t;let a=e+n*.14;i.gain.setValueAtTime(0,a),i.gain.linearRampToValueAtTime(.08,a+.02),i.gain.exponentialRampToValueAtTime(1e-4,a+.35),r.connect(i).connect(vx.destination),r.start(a),r.stop(a+.4)})}function xx(){try{return localStorage.getItem(gx)===`1`}catch{return!1}}function Sx(e){try{localStorage.setItem(gx,e?`1`:`0`)}catch{}}var Cx=()=>_x&&xx()&&Notification.permission===`granted`;async function wx(){if(!_x)return!1;yx();let e=(Notification.permission==="default"?await Notification.requestPermission():Notification.permission)===`granted`;return Sx(e),e&&bx(),e}var Tx=()=>bx(),Ex=_x,Dx=`Tricot`;function Ox({page:e,replies:t,needsYou:n,hidden:r}){let i=H(e??``,60),a=i?`${i} · ${Dx}`:Dx;if(!r)return a;let o=n?i?`${n} · ${i}`:n:a;return t>0?`(${t}) ${o}`:o}var kx={page:void 0,replies:0,needsYou:``},Ax=new class{parts={...kx,hidden:!1};listeners=new Set;set(e){this.parts={...this.parts,...e};for(let e of this.listeners)e()}title=()=>Ox(this.parts);subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))};function jx(e,t){(0,d.useEffect)(()=>{let n={};return n[e]=t,Ax.set(n),()=>{let t={};t[e]=kx[e],Ax.set(t)}},[e,t])}var Mx={labels:[],other:!1,words:``};function Nx(e,t){let n=e.options.map(e=>e.label).filter(e=>t.labels.includes(e));return t.other&&t.words.trim()&&n.push(t.words.trim()),n.length?ct(n):void 0}function Px({id:e,questions:t,busy:n,onSend:r,onTerminal:i,onDecline:a}){let[o,s]=(0,d.useState)(()=>t.map(()=>Mx)),c=(e,t)=>s(n=>n.map((n,r)=>r===e?t(n):n)),l=t.map((e,t)=>Nx(e,o[t])),u=l.every(e=>e!==void 0),f=()=>{u&&r(Object.fromEntries(t.map((e,t)=>[e.question,l[t]])))};return(0,Q.jsxs)(`form`,{className:`approval-questions`,onSubmit:e=>{e.preventDefault(),f()},children:[t.map((t,r)=>{let i=o[r],a=`question-${e}-${r}`,s=t.multiSelect?`checkbox`:`radio`;return(0,Q.jsxs)(`fieldset`,{className:`approval-question`,disabled:n,children:[(0,Q.jsxs)(`legend`,{className:`approval-question-text`,children:[t.header&&(0,Q.jsx)(`span`,{className:`approval-question-header`,children:t.header}),t.question,t.multiSelect&&(0,Q.jsx)(`span`,{className:`faint`,children:` (pick any)`})]}),t.options.map(e=>{let n=i.labels.includes(e.label);return(0,Q.jsxs)(`label`,{className:`approval-option${n?` is-picked`:``}`,children:[(0,Q.jsx)(`input`,{type:s,name:a,checked:n,onChange:()=>c(r,r=>t.multiSelect?{...r,labels:n?r.labels.filter(t=>t!==e.label):[...r.labels,e.label]}:{labels:[e.label],other:!1,words:r.words})}),(0,Q.jsxs)(`span`,{className:`approval-option-text`,children:[(0,Q.jsx)(`span`,{className:`approval-option-label`,children:e.label}),e.description&&(0,Q.jsx)(`span`,{className:`approval-option-description`,children:e.description})]})]},e.label)}),(0,Q.jsxs)(`label`,{className:`approval-option${i.other?` is-picked`:``}`,children:[(0,Q.jsx)(`input`,{type:s,name:a,checked:i.other,onChange:()=>c(r,e=>t.multiSelect?{...e,other:!e.other}:{labels:[],other:!0,words:e.words})}),(0,Q.jsxs)(`span`,{className:`approval-option-text`,children:[(0,Q.jsx)(`span`,{className:`approval-option-label`,children:`Other`}),(0,Q.jsx)(`input`,{type:`text`,className:`input approval-other`,"aria-label":`Your own answer to “${t.question}”`,placeholder:`Your own answer`,value:i.words,maxLength:tt,onChange:e=>c(r,n=>({...n,words:e.target.value,other:!0,labels:t.multiSelect?n.labels:[]}))})]})]})]},t.question)}),(0,Q.jsxs)(`div`,{className:`approval-actions`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-small`,disabled:n||!u,children:`Send answer`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:i,disabled:n,title:`Leave it to the agent's terminal, which asks there`,children:`Answer in the terminal`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:a,disabled:n,title:`Say no to the agent, and why if you like`,children:`Decline…`})]})]})}function Fx(){return(0,d.useSyncExternalStore)(Hl.subscribe,Hl.get)}function Ix(e){(0,d.useEffect)(()=>{if(!e)return;let t=new Rl(Jr(J.approvalsStream));return t.addEventListener(`approvals`,e=>Hl.set(JSON.parse(e.data))),t.addEventListener(`admissions`,e=>zl.set(JSON.parse(e.data))),()=>t.close()},[e])}var Lx=new Map,Rx=new Set,zx=0,Bx=e=>(Rx.add(e),()=>Rx.delete(e));function Vx(){return(0,d.useSyncExternalStore)(Bx,()=>zx),new Set(Lx.keys())}function Hx(e,t){let n=Math.max(0,Math.floor((t-Date.parse(e))/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=String(n%60).padStart(2,`0`);return r?`${r}:${String(i).padStart(2,`0`)}:${a}`:`${i}:${a}`}function Ux({since:e}){let[t,n]=(0,d.useState)(()=>Date.now());return(0,d.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,Q.jsx)(`span`,{className:`approval-time`,title:`Asked at ${new Date(e).toLocaleTimeString()}`,children:Hx(e,t)})}function Wx({approval:e,name:t,toast:n=!1}){let r=mx(),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null),p=(0,d.useRef)(null),{text:m,more:h}=gt(e),g=st(e),_=!!e.forSession?.length;(0,d.useEffect)(()=>{i&&p.current?.focus()},[i]);let v=async n=>{l(!0),f(null);try{await X.answerApproval(e.id,t,n),Hl.drop(e.id)}catch(t){let n=t.status;f(t.message),l(!1),n===404&&setTimeout(()=>Hl.drop(e.id),2500)}},y=e=>{e.preventDefault(),v({behavior:`deny`,...o.trim()&&{reason:o.trim()}})},b=e.on,x=b?.card&&e.card?r.byId(e.card.kind,b.board,e.card.id)?.href:void 0;return e.sealed?(0,Q.jsx)(Kx,{approval:e,toast:n,cardLink:x}):(0,Q.jsxs)(`section`,{className:`approval${n?` is-toast`:``}`,"data-approval":e.id,"aria-label":_t(e),children:[(0,Q.jsxs)(`header`,{className:`approval-head`,children:[(0,Q.jsx)($,{name:`pause`,className:`approval-mark`}),(0,Q.jsx)(`span`,{className:`approval-who`,children:_t(e)}),(0,Q.jsx)(Ux,{since:e.at})]}),g?(0,Q.jsx)(`div`,{hidden:i,children:(0,Q.jsx)(Px,{id:e.id,questions:g,busy:c,onSend:e=>void v({behavior:`allow`,answers:e}),onTerminal:()=>void v({behavior:`terminal`}),onDecline:()=>a(!0)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`approval-what`,children:ht(e)}),(0,Q.jsx)(Gx,{text:m,more:h})]}),e.description&&(0,Q.jsxs)(`p`,{className:`approval-why`,children:[`“`,e.description,`”`]}),n&&b&&(0,Q.jsx)(`p`,{className:`approval-where`,children:x?(0,Q.jsxs)(`a`,{href:x,title:b.cardTitle,children:[b.card,` on `,b.title]}):(0,Q.jsxs)(Q.Fragment,{children:[`On `,b.title]})}),i?(0,Q.jsxs)(`form`,{className:`approval-deny`,onSubmit:y,children:[(0,Q.jsxs)(`label`,{className:`approval-deny-label`,htmlFor:`deny-${e.id}`,children:[`Tell `,e.agent,` why `,(0,Q.jsx)(`span`,{className:`faint`,children:`(optional; it reads this)`})]}),(0,Q.jsxs)(`div`,{className:`approval-deny-row`,children:[(0,Q.jsx)(`input`,{id:`deny-${e.id}`,ref:p,className:`input approval-reason`,value:o,maxLength:500,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),a(!1))},placeholder:g?`Not now: I'll decide that myself`:`Use npm run build instead`,disabled:c}),(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-small approval-deny-button`,disabled:c,children:`Deny`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>a(!1),disabled:c,children:`Back`})]})]}):g?null:(0,Q.jsxs)(`div`,{className:`approval-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,onClick:()=>void v({behavior:`allow`}),disabled:c,children:`Allow`}),_&&(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>void v({behavior:`allow`,session:!0}),disabled:c,children:`Allow for this session`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>a(!0),disabled:c,children:`Deny…`})]}),_&&!i&&!g&&(0,Q.jsxs)(`p`,{className:`approval-session`,children:[`For this session also allows `,(0,Q.jsx)(`span`,{className:`approval-rules`,children:e.forSession.join(`, `)}),`, until `,e.agent,` ends it.`]}),u&&(0,Q.jsx)(`p`,{className:`error approval-error`,role:`alert`,children:u})]})}function Gx({text:e,more:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`pre`,{className:`approval-input`,tabIndex:0,"aria-label":`What it asks to run, as sent`,children:e}),t.length>0&&(0,Q.jsx)(`ul`,{className:`approval-more`,"aria-label":`Sent with it`,children:t.map(e=>(0,Q.jsx)(`li`,{children:e},e))})]})}function Kx({approval:e,toast:t,cardLink:n}){let[r,i]=(0,d.useState)(!1),a=e.on;return(0,Q.jsxs)(`section`,{className:`approval is-sealed${t?` is-toast`:``}`,"data-approval":e.id,"aria-label":_t(e),children:[(0,Q.jsxs)(`header`,{className:`approval-head`,children:[(0,Q.jsx)($,{name:`pause`,className:`approval-mark`}),(0,Q.jsx)(`span`,{className:`approval-who`,children:_t(e)}),(0,Q.jsx)(Ux,{since:e.at})]}),(0,Q.jsx)(`p`,{className:`approval-what`,children:`This browser can’t see what it asks until you let it act for you. It takes one keypress in Tricot’s terminal, or one click in a browser you’ve let in, once.`}),t&&a&&(0,Q.jsx)(`p`,{className:`approval-where`,children:n?(0,Q.jsxs)(`a`,{href:n,title:a.cardTitle,children:[a.card,` on `,a.title]}):(0,Q.jsxs)(Q.Fragment,{children:[`On `,a.title]})}),(0,Q.jsx)(`div`,{className:`approval-actions`,children:(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,disabled:r,onClick:()=>{i(!0),Il().finally(()=>i(!1))},children:`Let this browser in`})})]})}function qx(e){let t=document.querySelector(`[data-approval="${CSS.escape(e)}"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;t.scrollIntoView({block:`nearest`,behavior:n?`auto`:`smooth`}),t.querySelector(`.approval-actions .btn`)?.focus({preventScroll:!0})}function Jx({name:e}){let t=Fx(),n=Vx(),r=t.filter(e=>!n.has(e.id));return r.length===0?null:(0,Q.jsxs)(`div`,{className:`approval-toasts`,role:`region`,"aria-label":`Agents waiting for your OK`,children:[r.map(t=>(0,Q.jsx)(Wx,{approval:t,name:e,toast:!0},t.id)),(0,Q.jsx)(Yx,{})]})}function Yx(){let[e,t]=(0,d.useState)(Cx);return e||!Ex||Notification.permission===`denied`?null:(0,Q.jsxs)(`button`,{type:`button`,className:`link-button approval-notify`,onClick:()=>void wx().then(t),title:`A system notification when an agent waits for your OK while Tricot is in the background`,children:[(0,Q.jsx)($,{name:`bell`}),` Notify me when an agent needs me`]})}function Xx(){let e=Fx();if(e.length===0)return null;let t=[...new Set(e.map(e=>e.agent))],n=t.length===1?`${t[0]} needs your OK`:`${t.length} agents need your OK`;return(0,Q.jsxs)(`button`,{type:`button`,className:`chat-approval`,onClick:()=>qx(e[0].id),title:e.map(e=>`${_t(e)}: ${ht(e)}`).join(`
52
+ `),children:[(0,Q.jsx)($,{name:`pause`}),(0,Q.jsx)(`span`,{className:`chat-approval-text`,children:n})]})}function Zx(){let e=mx(),t=Fx(),n=fu(),r=(0,d.useRef)(null);jx(`needsYou`,vt(t.map(e=>e.agent))),(0,d.useEffect)(()=>{let i=new Set(t.map(e=>e.id)),a=r.current;if(r.current=i,!a||!n||!Cx())return;let o=t.filter(e=>!a.has(e.id));for(let t of o.slice(-3)){let n=xt(t),r=new Notification(n.title,{body:n.body,tag:`approval-${t.id}`});r.onclick=()=>{window.focus();let n=t.on&&t.card?e.byId(t.card.kind,t.on.board,t.card.id):void 0;n&&(location.hash=n.href),r.close()}}o.length&&Tx()},[t,n,e])}var Qx=c();function $x(){let e=(0,d.useSyncExternalStore)(Ml.subscribe,Ml.get);if((0,d.useEffect)(()=>{if(!e)return;let t=e=>e.key===`Escape`&&Ml.dismiss();return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),!e)return null;let t=(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>Ml.dismiss(),autoFocus:!0,children:`Close`});return(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`seat-scrim`,children:(0,Q.jsxs)(`section`,{className:`seat-dialog seat-prompt`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`seat-title`,"aria-describedby":`seat-lead`,children:[(0,Q.jsx)(`h2`,{id:`seat-title`,children:`Let this browser act for you`}),e.state===`asking`&&(0,Q.jsx)(`p`,{id:`seat-lead`,className:`seat-lead`,children:`Asking Tricot…`}),e.state===`waiting`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{id:`seat-lead`,className:`seat-lead`,children:[`Press `,(0,Q.jsx)(`kbd`,{children:`y`}),` in the terminal where Tricot runs, or run `,(0,Q.jsx)(`code`,{children:`tricot access`}),`. It shows this code:`]}),(0,Q.jsx)(`p`,{className:`seat-code`,"aria-label":`Code ${e.code.split(``).join(` `)}`,children:e.code}),(0,Q.jsx)(`p`,{className:`seat-note`,children:e.first?`This is the first browser, so any Tricot terminal can let it in. After this, only browsers and terminals you’ve let in can let others in.`:`Or allow it from a browser you’ve already let in.`}),(0,Q.jsx)(`p`,{className:`seat-note seat-faint`,children:`It’s once for this browser. Answering agents, approving commits, deciding and the like need it, so a program that pretends to be this page can’t do them as you.`}),(0,Q.jsxs)(`div`,{className:`seat-actions`,children:[(0,Q.jsxs)(`span`,{className:`seat-waiting`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`seat-dot`,"aria-hidden":`true`}),` Waiting for you there`]}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>Ml.dismiss(),children:`Not now`})]})]}),e.state===`denied`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{id:`seat-lead`,className:`seat-lead`,children:[`It was denied`,e.by?` ${e.by}`:``,`, so nothing was done.`]}),(0,Q.jsx)(`div`,{className:`seat-actions`,children:t})]}),e.state===`expired`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{id:`seat-lead`,className:`seat-lead`,children:`Nobody allowed it in time, so nothing was done. Try again when you’re at Tricot’s terminal.`}),(0,Q.jsx)(`div`,{className:`seat-actions`,children:t})]}),e.state===`failed`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{id:`seat-lead`,className:`seat-lead error`,role:`alert`,children:e.error}),(0,Q.jsx)(`div`,{className:`seat-actions`,children:t})]})]})}),document.body)}function eS(){return(0,d.useSyncExternalStore)(zl.subscribe,zl.get)}function tS({admission:e,name:t}){let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(null),o=e.kind===`terminal`,s=async n=>{r(!0),a(null);try{await X.answerAdmission(e.id,t,n),zl.drop(e.id)}catch(e){a(e.message),r(!1)}};return(0,Q.jsxs)(`section`,{className:`admission`,"aria-label":o?`A terminal asks to answer for you`:`A browser asks to act for you`,children:[(0,Q.jsxs)(`header`,{className:`admission-head`,children:[(0,Q.jsx)($,{name:`desktop`,className:`admission-mark`}),(0,Q.jsx)(`span`,{children:o?`Let this terminal answer for you?`:`A browser wants to act for you`})]}),(0,Q.jsxs)(`p`,{children:[e.label,`, code `,(0,Q.jsx)(`strong`,{className:`admission-code`,children:e.code}),`. Allow it only if the `,o?`terminal`:`browser`,` you’re using shows this code.`]}),(0,Q.jsxs)(`div`,{className:`admission-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,onClick:()=>void s(!0),disabled:n,children:`Allow`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>void s(!1),disabled:n,children:`Deny`})]}),i&&(0,Q.jsx)(`p`,{className:`error admission-error`,role:`alert`,children:i})]})}function nS({name:e}){let t=eS();return t.length?(0,Q.jsx)(`div`,{className:`admission-banners`,role:`region`,"aria-label":`Asking to act for you`,children:t.map(t=>(0,Q.jsx)(tS,{admission:t,name:e},t.id))}):null}function rS({name:e,onClose:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!0;return X.seats().then(t=>e&&r(t),t=>e&&a(t.message)),()=>{e=!1}},[]),(0,d.useEffect)(()=>{let e=e=>e.key===`Escape`&&t();return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]);let c=async t=>{s(t.id),a(null);try{r(await X.removeSeat(t.id,e))}catch(e){a(e.message)}finally{s(null)}};return!n&&!i?null:(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`seat-scrim`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,Q.jsxs)(`section`,{className:`seat-dialog seats-panel`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`seats-title`,children:[(0,Q.jsx)(`h2`,{id:`seats-title`,children:`Your browsers and terminals`}),(0,Q.jsx)(`p`,{className:`seat-note`,children:`These act for you: answering agents, approving commits, deciding and the like. Anything else that reaches Tricot can only comment and shape the board.`}),n&&(0,Q.jsx)(`ul`,{className:`seats-list`,children:n.map(e=>(0,Q.jsxs)(`li`,{className:`seats-row`,children:[(0,Q.jsx)($,{name:e.kind===`terminal`?`code`:`desktop`,className:`seats-mark`}),(0,Q.jsxs)(`div`,{className:`seats-main`,children:[(0,Q.jsxs)(`p`,{className:`seats-label`,children:[e.label,e.you&&(0,Q.jsx)(`span`,{className:`seats-you`,children:`This browser`})]}),(0,Q.jsxs)(`p`,{className:`seats-meta`,children:[`Let in `,ex(e.admittedAt),` `,e.admittedBy,e.lastUsedAt?` · last used ${ex(e.lastUsedAt)}`:` · not used yet`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small seats-remove`,onClick:()=>void c(e),disabled:o!==null,"aria-label":`Remove ${e.label}`,children:o===e.id?`Removing…`:`Remove`})]},e.id))}),i&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:i}),(0,Q.jsx)(`div`,{className:`seat-actions`,children:(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:t,children:`Done`})})]})}),document.body)}var iS={scratch:`sketchbook`,files:`files`},aS=e=>encodeURIComponent(e),oS=e=>e?decodeURIComponent(e):void 0,sS=[{pattern:/^\/overview\/p\/([^/]+)/,read:e=>({pinId:oS(e[1])})},{pattern:/^\/sketchbook\/([^/?]+)/,read:e=>({view:`scratch`,pageId:oS(e[1])})},{pattern:/^\/sketchbook/,read:()=>({view:`scratch`})},{pattern:/^\/files(?![^/?])(?:\?path=([^&]*)(&pair)?(?:&line=(\d+))?)?/,read:e=>{let t=oS(e[1]),n=Number(e[3]);return{view:`files`,...t?{file:t}:{},...t&&e[2]?{pair:!0}:{},...t&&n>0?{line:n}:{}}}}],cS={connectors:{pattern:/^#\/connectors(?:\?from=([^&]+))?/,read:e=>({page:`connectors`,from:oS(e[1])}),link:e=>e?`#/connectors?from=${aS(e)}`:`#/connectors`},board:{pattern:/^#\/b\/([^/]+)/,read:(e,t)=>{let n=decodeURIComponent(e[1]),r=(e.input??``).slice(e[0].length);for(let e of[...sS,...t]){let t=e.pattern.exec(r);if(t)return{page:`board`,boardId:n,...e.read(t)}}return{page:`board`,boardId:n,landing:!0}},link:(e,t)=>`#/b/${aS(e)}${t?`/${iS[t]}`:``}`,files:(e,t,n,r)=>`#/b/${aS(e)}/${iS.files}${t?`?path=${aS(t)}${n?`&pair`:``}${r?`&line=${r}`:``}`:``}`,pin:(e,t)=>`#/b/${aS(e)}/overview/p/${aS(t)}`,scratchPage:(e,t)=>`#/b/${aS(e)}/${iS.scratch}/${aS(t)}`},home:{pattern:/^/,read:()=>({page:`home`}),link:()=>`#/`}};function lS(e,t=[]){for(let n of Object.values(cS)){let r=e.match(n.pattern);if(r)return n.read(r,t)}return{page:`home`}}var uS={newBoard:/\?new$/,ask:/\?ask$/},dS={home:cS.home.link,newBoard:()=>`${cS.home.link()}?new`,connectors:cS.connectors.link,board:cS.board.link,context:e=>`#/b/${aS(e)}/overview/context`,askAgents:e=>`${dS.context(e)}?ask`,pin:cS.board.pin,page:cS.board.scratchPage,files:cS.board.files},fS=(e,t)=>e.replace(/^#\/b\/[^/]+/,cS.board.link(t)),pS={nameGate:`Your name is attached to what you add, so everyone can see who did what.`},mS=class{views=[];pages=[];landing;sessionHook;headerControls;strip;feedSlot;homeSlots;searchSlot;wordsSet;boardContextSlot;agentWorkSlot;refKindsSet;noRefKinds=new kb;add(e){if([e.id,...Object.keys(e.also??{})].some(e=>this.find(e)))throw Error(`There are two views of a board named ${e.id}.`);if(e.before&&!this.views.some(t=>t.id===e.before))throw Error(`The view ${e.id} goes before ${e.before}, which is not registered.`);this.views.push(e)}addCardPage(e){if(this.pages.some(t=>t.kind===e.kind))throw Error(`There are two pages of cards named ${e.kind}.`);this.pages.push(e)}landOn(e){if(this.landing)throw Error(`There are two landing views.`);this.landing=e}withSession(e){if(this.sessionHook)throw Error(`There are two sessions of a board.`);this.sessionHook=e}withHeaderControls(e){if(this.headerControls)throw Error(`There are two sets of header controls.`);this.headerControls=e}withNeedsStrip(e){if(this.strip)throw Error(`There are two strips of what needs you.`);this.strip=e}withFeed(e){if(this.feedSlot)throw Error(`There are two feeds.`);this.feedSlot=e}withHome(e){if(this.homeSlots)throw Error(`There are two sets of slots on Home.`);this.homeSlots=e}withSearch(e){if(this.searchSlot)throw Error(`There are two search slots.`);this.searchSlot=e}withWords(e){if(this.wordsSet)throw Error(`There are two sets of page words.`);this.wordsSet=e}withBoardContext(e){if(this.boardContextSlot)throw Error(`There are two sets of tools for the board's own canvas.`);this.boardContextSlot=e}withAgentWork(e){if(this.agentWorkSlot)throw Error(`There are two renderers of what an agent is working on.`);this.agentWorkSlot=e}withRefKinds(e){if(this.refKindsSet)throw Error(`There are two sets of reference kinds.`);this.refKindsSet=e}find(e){return e===void 0?void 0:this.views.find(t=>t.id===e||Object.hasOwn(t.also??{},e))}landingView(){return this.find(this.landing)??this.tabs()[0]??this.views[0]}linkTo(e,t){let n=this.find(t);return n&&(Object.hasOwn(n.also??{},t)?n.also[t](e):n.link(e))}viewAt(e){return this.find(e)??this.landingView()}tabs(){let e=[];for(let t of this.views.filter(e=>e.label!==void 0)){let n=t.before?e.findIndex(e=>e.id===t.before):-1;n>=0?e.splice(n,0,t):e.push(t)}return e}pieces(){return[...this.views.flatMap(e=>e.address??[]),...this.pages.flatMap(e=>e.address??[])]}doors(){return this.views.filter(e=>e.door)}cardPages(){return this.pages}useSession(e){return this.sessionHook?.(e)}controls(e){return this.headerControls?.(e)}needsStrip(e){return this.strip?.(e)}feed(){return this.feedSlot}home(){return this.homeSlots}search(){return this.searchSlot}words(){return this.wordsSet??pS}boardContext(){return this.boardContextSlot}agentWork(){return this.agentWorkSlot}refKinds(){return this.refKindsSet??this.noRefKinds}},hS=new mS,gS=(0,d.createContext)(hS);function _S({views:e,children:t}){return(0,Q.jsx)(gS.Provider,{value:e,children:t})}function vS(){return(0,d.useContext)(gS)}var yS=`tricot:address-replaced`;function bS(e){return window.addEventListener(`hashchange`,e),window.addEventListener(yS,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(yS,e)}}function xS(){return lS((0,d.useSyncExternalStore)(bS,()=>location.hash),vS().pieces())}var SS=e=>location.hash=e,CS={home:()=>SS(dS.home()),board:e=>SS(dS.board(e)),scratch:e=>SS(dS.board(e,`scratch`)),page:(e,t)=>SS(dS.page(e,t)),files:(e,t,n)=>SS(dS.files(e,t,!1,n)),pin:(e,t)=>SS(dS.pin(e,t))};function wS(e){let t=lS(location.hash);t.page===`board`&&t.pinId&&TS(e?dS.page(t.boardId,e):dS.context(t.boardId))}function TS(e){location.hash!==e&&(history.replaceState(history.state,``,`${location.pathname}${location.search}${e}`),window.dispatchEvent(new Event(yS)))}var ES=e=>e.test(location.hash);function DS(e){e.test(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}${location.hash.replace(e,``)}`)}var OS=36e5,kS=2e3,AS=[`listening`,`asleep`,`working`,`away`],jS=e=>AS.indexOf(e);function MS(e){let t=e,n=wt().find(e=>t[e.kind]);return n&&new St(n,t[n.kind])}function NS(e,t,n){if(n.paired)return;if(n.author?.kind===`agent`){let t=_s({author:n.author,mentions:n.mentions},t=>jc(e,t));return t.length&&!n.held?t:void 0}let r=jc(e,n.mentions);if(r.length)return r;if(Mc(e,n.mentions).length)return;if(`thread`in t)return t.thread.lens?.agent?[t.thread.lens.agent]:[];let i=MS(t)?.followedBy;return i?[i]:[]}function PS({board:e,where:t,said:n,after:r,agents:i,steps:a}){let o=NS(e,t,n);if(!o)return;let s=r.filter(e=>e.author.kind===`agent`),c=e=>s.some(t=>U(t.author.name,e))||qs(n,e),l=o.filter(e=>!c(e));if(o.length&&l.length===0||!o.length&&(s.length||n.reactions?.some(e=>e.by.kind===`agent`&&Js(e.emoji))))return{state:`replied`};let u=Date.parse(n.at),d=MS(t),f=d&&{kind:d.kind.kind,id:d.id},p=`thread`in t?t.thread.id:void 0,m=e=>!!(f&&e&&e.kind===f.kind&&e.id===f.id),h=e=>p?e.thread===p:`boardContext`in t?!e.card&&!e.thread:m(e.card),g=(n.reactions??[]).filter(e=>e.by.kind===`agent`&&e.emoji===`👀`),_=(o.length?l:$S([...i.filter(e=>e.state!==`away`).map(e=>e.name),...g.map(e=>e.by.name),...a.filter(h).map(e=>e.agent)])).map(t=>{let n=i.find(e=>U(e.name,t)),r=QS(a.filter(e=>U(e.agent,t)&&h(e)&&!e.done&&Date.parse(e.at)>=u-kS));if(r)return{rank:6,delivery:{state:`working`,agent:r.agent,step:r}};if(n&&n.state!==`listening`&&n.state!==`asleep`&&m(n.focus)&&Date.parse(n.lastSeen)>=u-kS)return{rank:5,delivery:{state:`working`,agent:n.name}};let o=n?.focus&&!m(n.focus)?kt(e,n.focus.kind,n.focus.id)?.label:void 0,s=g.find(e=>U(e.by.name,t));if(s){let e=Date.parse(s.at)-kS,r=a.some(n=>U(n.agent,t)&&n.done&&!n.role&&Date.parse(n.at)>=e),i=(n?.state===`listening`&&!n.focus||n?.state===`asleep`)&&Date.parse(n.lastSeen)>Date.parse(s.at)+kS,c=r||i;return{rank:c?3:4,delivery:{state:`seen`,agent:n?.name??s.by.name,at:s.at,...o&&{on:o},...c&&{idle:!0}}}}if(!n||n.state===`away`)return{rank:0};if(n.state===`asleep`)return{rank:2,delivery:{state:`delivered`,agents:[n.name],listening:!1,asleep:[n.name]}};let c=n.state===`listening`;return{rank:c?2:1,delivery:{state:`delivered`,agents:[n.name],listening:c,...o&&!c&&{on:o}}}}),v=_.reduce((e,t)=>t.rank>e.rank?t:e,{rank:0}),y=e=>_.flatMap(t=>t.delivery?.state===`delivered`&&e(t.delivery)?t.delivery.agents:[]),b=y(e=>e.listening),x=y(e=>!!e.asleep?.length);if(v.delivery?.state===`delivered`&&b.length+x.length>0)return{state:`delivered`,agents:[...b,...x],listening:b.length>0,...x.length&&{asleep:x}};if(v.delivery)return v.delivery;let S=ZS(e,i,o.length?l:void 0);return o.length?{state:`waiting`,agents:l,...S&&{last:S}}:i.length?{state:`waiting`,agents:[],...S&&{last:S}}:{state:`nobody`}}function FS(e,t){switch(e.state){case`replied`:return;case`working`:return e.step?`${e.agent} · ${GS(e.step)}`:`${e.agent} is taking a look`;case`seen`:return`Seen by ${e.agent}${e.on?` · now on ${e.on}`:``}`;case`delivered`:{let[t]=e.agents;if(e.listening||e.asleep?.length){let t=e=>e.length===1?`is`:`are`,n=e.agents.filter(t=>!e.asleep?.includes(t)),r=e.asleep??[];return`Delivered · ${[...n.length?[`${G(n)} ${t(n)} listening`]:[],...r.length?[`${G(r)} ${t(r)} asleep: Tricot wakes ${r.length===1?`it`:`them`}`]:[]].join(`; `)}`}return`Delivered · ${t} is ${e.on?`on ${e.on}`:`working`}`}case`waiting`:{let{agents:n,last:r}=e;return n.length?`Waiting for ${G(n)} · ${r?`last seen ${eC(r.at,t)}`:`not listening`}`:`Waiting for an agent${r?` · ${r.name} was last seen ${eC(r.at,t)}`:``}`}case`nobody`:return`No agent is listening on this board`}}var IS=`Start listening on Tricot`;function LS(e,t){if(e?.state===`waiting`)return e.agents[0]??e.last?.name??t[0];if(e?.state===`nobody`)return t[0]}function RS(e,t){if(t.length!==0)return`${e[0]??t[0]} isn't listening here`}function zS(e){if(e.length!==0)return e.length>2?`${e.length} agents`:e.join(` and `)}function BS(e,t){if(e.lens?.agent)return e.lens.agent;let n=e.messages.findLast(e=>e.author.kind===`agent`);return n?n.author.name:t.length===1?t[0]:void 0}function VS(e,t){let n=BS(e,t);return n?`Reply to ${n}…`:`Reply…`}function HS(e,t){return`${e} isn't listening${t.state===`nobody`?` yet`:``}.`}function US(e,t){return t?`In ${t}, say:`:`Say to ${e}:`}function WS(e,t,n){return`${HS(e,n)} ${US(e,t)} “${IS}”`}function GS(e){return e.narration?`“${e.text}”`:e.ended&&e.ms!==void 0&&e.ms>=1e3?`${e.text} (${ce(e.ms)})`:e.text}function KS(e,t){switch(e.state){case`working`:return!e.step||t(e.step)?`working`:`resting`;case`seen`:return e.idle||!t({agent:e.agent,text:`Seen`,at:e.at})?`resting`:`casting`;default:return}}function qS(e,t){if(e===`casting`||e===`working`)return t??(e===`casting`?`cast`:`knit`)}function JS(e,t){return e!==void 0&&t?.state===`replied`}function YS(e,t,n){return`${e}\nAsked ${ce(Math.max(0,n-Date.parse(t.at)))} ago`}function XS(e,t){return t-Date.parse(e.at)<OS}function ZS(e,t,n){let r=e=>!n||n.some(t=>U(t,e));return[...t.filter(e=>r(e.name)).map(e=>({name:e.name,at:e.lastSeen})),...e.activity.actors.filter(e=>e.actor.kind===`agent`&&r(e.actor.name)).map(e=>({name:e.actor.name,at:e.at}))].reduce((e,t)=>!e||Date.parse(t.at)>Date.parse(e.at)?t:e,void 0)}function QS(e){return e.reduce((e,t)=>!e||Date.parse(t.at)>Date.parse(e.at)?t:e,void 0)}function $S(e){return e.filter((t,n)=>e.findIndex(e=>U(e,t))===n)}function eC(e,t){let n=Math.max(0,(t-Date.parse(e))/1e3);if(n<45)return`just now`;let r=Math.round(n/60);if(r<60)return`${Math.max(1,r)} min ago`;let i=Math.round(r/60);return i<24?`${i} h ago`:`${Math.round(i/24)} d ago`}function tC(e,t=0){let n=e.agent?.name??`agents`;if(t>0){let r=t===1?`this block`:`these ${t} blocks`;return{placeholder:`Talk ${r} through with ${n}…`,label:`Start a thread with ${n} about ${r} on Sketchbook page ${e.title}`}}return{placeholder:`Ask ${n} about this page…`,label:`Ask ${n} about Sketchbook page ${e.title}`}}function nC(e,t){let n=t??`agents`;return{placeholder:`Ask ${n} about ${ks(e)}…`,label:`Ask ${n} about ${e} in Files`}}var rC=`tricot:look-at-board`,iC=!1,aC=e=>e instanceof Element&&!!e.closest(`.board-layout > :first-child`);function oC(){if(iC)return;iC=!0;let e=e=>{aC(e.target)&&window.dispatchEvent(new Event(rC))};for(let t of[`pointermove`,`wheel`,`scroll`,`keydown`])document.addEventListener(t,e,{capture:!0,passive:!0})}function sC(){window.dispatchEvent(new Event(rC))}var cC=1800;function lC(e,t){let n=(0,d.useRef)(null),[r,i]=(0,d.useState)(new Set),[a,o]=(0,d.useState)(new Set),s=(0,d.useRef)(new Map);e&&n.current?.board!==nl(e)&&(n.current={board:nl(e),ids:new Set(Ot(e).map(e=>e.id))});let c=(e?Zc(e,t):[]).filter(e=>!n.current?.ids.has(e)&&!r.has(e)).join(),l=(0,d.useMemo)(()=>new Set(c?c.split(`,`):[]),[c]);return(0,d.useEffect)(()=>oC(),[]),(0,d.useEffect)(()=>()=>s.current.forEach(clearTimeout),[]),{held:l,fading:a,seen:(0,d.useCallback)((e,t=!0)=>{i(t=>t.has(e)?t:new Set([...t,e])),t&&(o(t=>new Set([...t,e])),clearTimeout(s.current.get(e)),s.current.set(e,setTimeout(()=>{s.current.delete(e),o(t=>{let n=new Set(t);return n.delete(e),n})},cC)))},[])}}var uC=e=>t=>jc(e,t);function dC({board:e,said:t,className:n}){let r=_s(t,uC(e));if(r.length===0)return null;let i=G(r);return(0,Q.jsxs)(`span`,{className:n?`said-to ${n}`:`said-to`,title:`${t.author.name} to ${i}`,children:[(0,Q.jsx)($,{name:`arrow-right`,className:`said-to-arrow`}),(0,Q.jsx)(`span`,{className:`said-to-sr`,children:`to `}),(0,Q.jsx)(`span`,{className:`said-to-name`,children:i})]})}function fC(e,t){let n=t.findLastIndex(t=>_s(t,uC(e)).length>0);return n>=0&&!t[n].held?n:-1}function pC({board:e,items:t,className:n=`loop-line`}){let r=vs(t,uC(e));return r?(0,Q.jsx)(`p`,{className:n,children:ys(r)}):null}function mC(e){return e.problem?`Can't read ${e.where}`:e.state===`on`?`On · ${e.name}, ${e.scope}`:e.state===`partly`?`Partly set up · ${e.name}, ${e.scope}`:e.found?`Off`:`Not installed on this machine`}var hC=e=>`tricot steps on --agent ${e.id}`;function gC(e){let t=Ye();return{command:`${hC(t)} --name "${e}"`,others:qe().flatMap(e=>e===t||e.liveSteps===!1?[]:[e.id])}}function _C(e,t){let n=e.trim().toLowerCase(),r=e=>n===e||n.startsWith(e)&&!/[a-z0-9]/.test(n[e.length]);return t.find(t=>t.sendsAs&&U(t.sendsAs,e))??t.find(t=>U(t.agentName,e)||U(t.name,e)||U(t.id,e))??t.find(e=>r(e.agentName.toLowerCase())||r(e.name.toLowerCase()))}function vC(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=!0;return X.liveSteps().then(n=>e&&t(n),()=>e&&t(void 0)),()=>{e=!1}},[n]),{report:e,reload:(0,d.useCallback)(()=>r(e=>e+1),[])}}function yC(e){return e.split("`").map((e,t)=>t%2?(0,Q.jsx)(`code`,{children:e},t):e)}function bC({name:e,person:t,steps:n}){let{report:r,reload:i}=n,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),l=(0,d.useRef)(null),u=(0,d.useId)(),f=(0,d.useId)();if(!r)return null;let p=_C(e,r.agents);if(!p){let{command:t,others:n}=gC(e);return(0,Q.jsxs)(`section`,{className:`live-steps`,"aria-labelledby":u,children:[(0,Q.jsxs)(`div`,{className:`live-steps-text`,children:[(0,Q.jsx)(`span`,{className:`live-steps-title`,id:u,children:`Live steps`}),(0,Q.jsxs)(`span`,{className:`live-steps-state`,children:[`Tricot can't tell which tool `,e,` runs in, so there is no switch here.`]})]}),(0,Q.jsxs)(`p`,{className:`live-steps-line`,children:[`From a terminal: `,(0,Q.jsx)(`code`,{children:t}),` (or `,n.join(`, `),`).`]})]})}let m=p.state===`on`,h=!p.found&&p.state===`off`,g=!r.canChange||h||!!p.problem,_=t=>{c(null),o({action:t,name:t===`on`?e:void 0})};return(0,Q.jsxs)(`section`,{className:`live-steps`,"aria-labelledby":u,children:[(0,Q.jsxs)(`div`,{className:`live-steps-row`,children:[(0,Q.jsxs)(`div`,{className:`live-steps-text`,children:[(0,Q.jsx)(`span`,{className:`live-steps-title`,id:u,children:`Live steps`}),(0,Q.jsx)(`span`,{className:`live-steps-state${m?` is-on`:``}`,id:f,children:mC(p)})]}),(0,Q.jsx)(`button`,{ref:l,type:`button`,role:`switch`,className:`live-switch`,"aria-checked":m,"aria-labelledby":u,"aria-describedby":f,disabled:g,onClick:()=>_(m?`off`:`on`),children:(0,Q.jsx)(`span`,{className:`live-switch-thumb`,"aria-hidden":!0})})]}),!r.canChange&&r.why&&(0,Q.jsx)(`p`,{className:`live-steps-line`,children:r.why}),p.problem&&(0,Q.jsx)(`p`,{className:`live-steps-line`,children:p.problem}),p.state===`partly`&&p.missing&&(0,Q.jsxs)(`p`,{className:`live-steps-line`,children:[`Missing `,p.missing.join(`, `),`. Turning it on mends it.`]}),p.trust&&p.state!==`off`&&(0,Q.jsxs)(`p`,{className:`live-steps-line is-needs-you`,children:[(0,Q.jsxs)(`strong`,{children:[p.trust,`.`]}),` Open /hooks in `,p.name,` and trust Tricot's hook; Tricot can't see whether you have.`]}),p.alsoInProject&&(0,Q.jsx)(`p`,{className:`live-steps-line`,children:p.state===`off`?(0,Q.jsxs)(`span`,{children:[`Also set up in `,(0,Q.jsx)(`code`,{children:p.alsoInProject}),` from earlier, so steps show from that project.`]}):(0,Q.jsxs)(`span`,{children:[`Also set up in `,(0,Q.jsx)(`code`,{children:p.alsoInProject}),` from earlier; steps still show once.`,` `,!g&&(0,Q.jsx)(`button`,{type:`button`,className:`live-steps-link`,onClick:()=>{c(null),o({action:`off`,scope:`project`})},children:`Tidy up`})]})}),s&&(0,Q.jsx)(`p`,{className:`live-steps-done`,role:`status`,children:s.summary}),a&&(0,Q.jsx)(TC,{agent:p,person:t,change:a,onCancel:()=>{o(null),l.current?.focus()},onDone:e=>{o(null),c(e),i(),l.current?.focus()}})]})}var xC={write:`Adds`,add:`Adds`,replace:`Adds`,remove:`Removes`,delete:`Removes`};function SC({file:e}){return(0,Q.jsxs)(`li`,{className:`live-file`,children:[(0,Q.jsxs)(`div`,{className:`live-file-head`,children:[(0,Q.jsx)(`span`,{className:`live-file-does`,children:xC[e.does]}),(0,Q.jsx)(`code`,{className:`live-file-path`,children:e.path})]}),(0,Q.jsxs)(`p`,{className:`live-file-what`,children:[e.what,e.same&&(0,Q.jsx)(`span`,{className:`live-file-same`,children:` · there already, not written again`})]})]})}function CC({files:e}){let t=e.filter(e=>e.lines&&!e.same);return t.length?(0,Q.jsxs)(`details`,{className:`live-lines`,children:[(0,Q.jsx)(`summary`,{children:`Show the exact lines`}),t.map(e=>(0,Q.jsxs)(`div`,{className:`live-lines-file`,children:[(0,Q.jsxs)(`p`,{children:[e.does===`remove`||e.does===`delete`?`Out of`:`In`,` `,(0,Q.jsx)(`code`,{children:e.path})]}),(0,Q.jsx)(`pre`,{className:`live-file-lines`,tabIndex:0,"aria-label":`The lines for ${e.path}`,children:e.lines})]},`${e.does}:${e.path}`))]}):null}var wC=`button:not(:disabled), input:not(:disabled), summary, [tabindex]:not([tabindex="-1"])`;function TC({agent:e,person:t,change:n,onCancel:r,onDone:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(0),m=(0,d.useRef)(null),h=(0,d.useId)(),g=n.action===`on`,_=n.scope===`project`,v=e.alsoInProject??`the project`;(0,d.useEffect)(()=>{let r=!0;return o(null),X.previewLiveSteps(e.id,t,n).then(e=>r&&o(e),e=>r&&c(e.message)),()=>{r=!1}},[e.id,t,n,f]),(0,d.useEffect)(()=>{m.current?.focus()},[]);let y=async()=>{if(a&&!l){u(!0),c(null);try{i(await X.applyLiveSteps(e.id,t,{...n,fingerprint:a.fingerprint}))}catch(e){c(e.message),u(!1),e.status===409&&p(e=>e+1)}}},b=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),l||r();return}if(e.key!==`Tab`||!m.current)return;let t=[...m.current.querySelectorAll(wC)];if(!t.length)return;let[n,i]=[t[0],t[t.length-1]];e.shiftKey&&(document.activeElement===n||document.activeElement===m.current)?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())},x=a?.unchanged,S=_?`Tidy up ${v}?`:`Turn ${n.action} live steps for ${e.name}?`,C=_?`${e.name}'s steps are on for every project, so the hook ${v} got earlier isn't needed. Tricot takes out only its own lines there; every other setting stays as it is.`:g?e.approvals?`${e.name} then shows what it is doing, one line per step, on the card it works on, in every project${e.usage?`, and passes on its plan usage, numbers only, for its panel`:``}. Its permission prompts come to the board too, with the command or change it asks about, for you to answer there. Tricot changes only what is listed here, and steps carry no file contents, command output or prompts.`:e.usage?`${e.name} then shows what it is doing, one line per step, on the card it works on, in every project, and passes on its plan usage, numbers only, for its panel. Tricot changes only what is listed here, and sends no file contents, command output or prompts.`:`${e.name} then shows what it is doing, one line per step, on the card it works on, in every project. Tricot adds a small hook to ${e.name}'s own settings and changes nothing else. It sends no file contents, command output or prompts.`:`${e.name} stops sending its steps${e.approvals?`, and its permission prompts go back to the terminal`:``}. Tricot takes out only what it added; every other setting stays as it is.`;return(0,Q.jsx)(`div`,{className:`live-sheet-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!l&&r(),children:(0,Q.jsxs)(`div`,{className:`live-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":h,ref:m,tabIndex:-1,onKeyDown:b,children:[(0,Q.jsxs)(`div`,{className:`live-sheet-body`,children:[(0,Q.jsx)(`h3`,{id:h,children:S}),(0,Q.jsx)(`p`,{className:`live-sheet-lede`,children:C}),a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`live-sheet-meta`,children:[a.sendsAs&&(0,Q.jsxs)(Q.Fragment,{children:[`Its steps show as `,(0,Q.jsx)(`strong`,{children:a.sendsAs}),`.`,` `]}),x?g?`It is set up like this already.`:`There is nothing of Tricot's to take out.`:null]}),(0,Q.jsx)(`ul`,{className:`live-files`,children:a.files.map(e=>(0,Q.jsx)(SC,{file:e},`${e.does}:${e.path}`))}),(0,Q.jsx)(CC,{files:a.files}),a.notes.map(e=>(0,Q.jsx)(`p`,{className:`live-sheet-note`,children:yC(e)},e))]}):!s&&(0,Q.jsx)(`p`,{className:`live-sheet-meta`,children:`Reading what is there now…`}),s&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:s})]}),(0,Q.jsxs)(`div`,{className:`live-sheet-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:r,disabled:l,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:!a||l,onClick:()=>void y(),children:l?`Writing…`:_?`Tidy up`:g?`Turn on`:`Turn off`})]})]})})}function EC({tool:e}){let{report:t}=vC(),n=t?.agents.find(t=>t.id===e);return!n||!n.found||n.state===`on`||n.problem?null:(0,Q.jsxs)(`p`,{className:`connect-hint`,children:[(0,Q.jsx)(`span`,{className:`connect-hint-mark`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[n.state===`partly`?`${n.name}'s live steps are partly set up`:`No live steps for ${n.name} yet`,`: run `,(0,Q.jsx)(`code`,{children:hC(n)}),`, or use the switch in its panel.`]})]})}var DC=Xe,OC=e=>!(!e?.startsOn||e.cantStart),kC=(e,t)=>U(e.boardName,t)?t:e.name,AC={one:264,two:336};function jC(e){let{kind:t,name:n,rule:r,runsOn:i,onSet:a,under:o}=e,[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null),u=ye(t,r),f=kC(t,n),p=(0,d.useCallback)((e=!1)=>{c(!1),e&&l.current?.focus()},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{ref:l,type:`button`,className:`assignee-chip agent-rule-chip${u?``:` is-any`}`,"aria-haspopup":`dialog`,"aria-expanded":s,title:u?`${f} starts on ${u}. Change it.`:`${f} starts on its own settings. Choose a model${t.startsOn?.levels?.length?` and thinking level`:``}.`,onClick:()=>c(!s),onKeyDown:e=>{e.key===`Escape`&&s&&(e.preventDefault(),e.stopPropagation(),p())},children:[(0,Q.jsx)(`span`,{className:`agent-rule-chip-label`,children:u??`Its own settings`}),(0,Q.jsx)(`svg`,{className:`assignee-caret`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`m4.5 6.5 3.5 3.5 3.5-3.5`})})]}),s&&(0,Q.jsx)(MC,{kind:t,owner:f,rule:r,runsOn:i,anchor:l,under:o,onSet:a,onClose:p})]})}function MC(e){let{kind:t,owner:n,rule:r,runsOn:i,anchor:a,under:o,onSet:s,onClose:c}=e,l=t.startsOn?.models??[],u=t.startsOn?.levels??[],f=u.length?AC.two:AC.one,p=(0,d.useRef)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(null),S=r.model&&!l.some(e=>e.id===r.model)?r.model:void 0;(0,d.useLayoutEffect)(()=>{let e=a.current?.getBoundingClientRect();if(!e)return;let t=Math.max(8,Math.min(e.right-f,window.innerWidth-f-8)),n=Math.max(e.bottom,o?.current?.getBoundingClientRect().bottom??0)+6,r=p.current?.offsetHeight??320;h(n+r<window.innerHeight?{left:t,top:n}:{left:t,bottom:window.innerHeight-e.top+6}),(p.current?.querySelector(`[aria-checked="true"]`)??p.current)?.focus({preventScroll:!0})},[a,o,f]);let C=(0,d.useCallback)(()=>c(),[c]);Zl(!0,C,p,a),(0,d.useEffect)(()=>{let e=e=>!p.current?.contains(e.target)&&c();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,C),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,C)}},[c,C]);let w=async e=>{if(!v){y(!0),x(null);try{await s(e)}catch(e){x(e.message)}finally{y(!1)}}},T=e=>{e.preventDefault();let t=g.trim();if(!t)return;let n=he(t);if(n)return x(n);_(``),w({...r,model:t})},E=e=>{if(e.key===`Escape`)return e.preventDefault(),e.stopPropagation(),c(!0);let t=e.target;if(t.tagName===`INPUT`)return;let n=t.closest(`[role="group"]`),r=[...n?.querySelectorAll(`[role="menuitemradio"]`)??[]];if(e.key===`ArrowLeft`||e.key===`ArrowRight`){let t=[...p.current?.querySelectorAll(`[role="group"]`)??[]],r=t[(t.indexOf(n)+(e.key===`ArrowRight`?1:t.length-1))%t.length];if(!r||r===n)return;e.preventDefault(),(r.querySelector(`[aria-checked="true"]`)??r.querySelector(`[role="menuitemradio"]`))?.focus();return}let i=cu(e.key,r.indexOf(t),r.length);i!==void 0&&(e.preventDefault(),r[i].focus())},D=(e,t,n,r)=>(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,className:`assignee-option agent-rule-option${t?` is-chosen`:``}`,disabled:v,onClick:n,children:[(0,Q.jsx)(`span`,{className:`agent-rule-option-label`,children:e}),t&&(0,Q.jsx)($,{name:`check`,className:`agent-rule-check`})]},r),O=i&&(ye(t,i)??`its own settings`);return(0,Qx.createPortal)((0,Q.jsxs)(`div`,{ref:p,className:`assignee-menu agent-rule-menu`,role:`dialog`,"aria-label":`${n} starts on`,tabIndex:-1,style:{left:m?.left??-9999,top:m?.top,bottom:m?.bottom,width:f,visibility:m?void 0:`hidden`},onKeyDown:E,onPointerDown:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`agent-rule-title`,children:[n,` starts on`]}),(0,Q.jsxs)(`div`,{className:`agent-rule-columns${u.length?` is-two`:``}`,children:[(0,Q.jsxs)(`div`,{className:`agent-rule-column`,role:`group`,"aria-label":`Model`,children:[(0,Q.jsx)(`div`,{className:`assignee-menu-head`,children:`Model`}),D(`Default`,!r.model,()=>void w({...r,model:void 0}),`default`),l.map(e=>D(e.label,r.model===e.id,()=>void w({...r,model:e.id}),e.id)),S&&D(S,!0,()=>{},`own:${S}`),(0,Q.jsx)(`form`,{className:`agent-rule-own`,onSubmit:T,children:(0,Q.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:l.length?`Another model…`:`A model, as it names one…`,"aria-label":`A model for ${n}, by name`,spellCheck:!1,autoComplete:`off`,disabled:v})})]}),u.length>0&&(0,Q.jsxs)(`div`,{className:`agent-rule-column`,role:`group`,"aria-label":`Thinking`,children:[(0,Q.jsx)(`div`,{className:`assignee-menu-head`,children:`Thinking`}),D(`Default`,!r.effort,()=>void w({...r,effort:void 0}),`default`),u.map(e=>D(e.label,r.effort===e.id,()=>void w({...r,effort:e.id}),e.id))]})]}),b&&(0,Q.jsx)(`p`,{className:`agent-rule-error`,role:`alert`,children:b}),(0,Q.jsxs)(`p`,{className:`agent-rule-foot`,children:[O&&(0,Q.jsxs)(Q.Fragment,{children:[`Running now on `,(0,Q.jsx)(`strong`,{children:O}),`.`,` `]}),`A change takes effect the next time `,n,` starts; Default passes nothing.`]})]}),document.body)}qe().flatMap(e=>e.usage.source??[]);var NC=e=>e===void 0?void 0:Je(e)?.usage.shares,PC=e=>Ze(e)?.id??e;function FC(e,t){if(NC(e)===`none`)return Je(e)?.usage.notShared??`${t} keeps its usage to itself.`;if(NC(e)===`tokens`)return`${t} shares tokens and cost, not plan limits.`}var IC=6e4,LC=60*IC,RC=24*LC;function zC(e){let t=e.id.startsWith(`7d:`)?e.id.slice(3):void 0,n=e.minutes,r;return r=n===10080?`Weekly`:n!==void 0&&n%1440==0?`${n/1440}-day`:n!==void 0&&n%60==0?`${n/60}-hour`:n===void 0?e.id===`5h`?`5-hour`:`Weekly`:`${n}-minute`,t?`${r} · ${t}`:r}function BC(e,t){let n=e-t;if(n<=0)return;if(n<IC)return`under a minute`;if(n<LC)return`${Math.ceil(n/IC)}m`;if(n<RC){let e=Math.floor(n/LC),t=Math.floor(n%LC/IC);return t?`${e}h ${t}m`:`${e}h`}let r=Math.floor(n/RC),i=Math.floor(n%RC/LC);return i?`${r}d ${i}h`:`${r}d`}var VC=e=>`${e>0&&e<1?`<1`:Math.round(e)}%`;function HC(e,t){let n=BC(e.resetsAt,t);return`${VC(e.usedPercent)} used${n?` · resets in ${n}`:``}`}var UC=(e,t)=>(e??[]).filter(e=>e.resetsAt>t),WC=e=>e>=95?`at`:e>=80?`near`:`ok`;function GC(e,t,n={}){if(t-e<3e5)return;let r=n.timeZone?{timeZone:n.timeZone}:{},i=new Date(e).toLocaleTimeString(n.locale,{hour:`numeric`,minute:`2-digit`,...r}),a=e=>new Date(e).toLocaleDateString(n.locale,r);if(a(e)===a(t))return`as of ${i}`;let o=new Date(e).toLocaleDateString(n.locale,{weekday:`short`,...r});return t-e<6*RC?`as of ${o} ${i}`:`as of ${a(e)}`}function KC(e){return e<1e3?String(Math.round(e)):e<1e6?`${qC((e/1e3).toFixed(+(e<1e4)))}k`:`${qC((e/1e6).toFixed(+(e<1e7)))}M`}var qC=e=>e.replace(/\.0$/,``),JC=e=>e>0&&e<.01?`under $0.01`:`$${e.toFixed(2)}`,YC=e=>`${e.charAt(0).toUpperCase()}${e.slice(1).replace(/_/g,` `)} plan`;function XC(e){if(e<=0)return`none`;if(e<IC)return`under a minute`;let t=Math.floor(e/LC),n=Math.round(e%LC/IC);return t?n?`${t}h ${n}m`:`${t}h`:`${n}m`}function ZC(e){let t=[`${KC(e.input)} in`,`${KC(e.output)} out`];return e.cacheRead&&t.push(`${KC(e.cacheRead)} from cache`),e.reasoning&&t.push(`${KC(e.reasoning)} reasoning`),`${KC(e.total)} tokens · ${t.join(`, `)}`}function QC(e){let t=new Date(e);t.setHours(0,0,0,0);let n=new Date(t);return n.setDate(n.getDate()-(n.getDay()+6)%7),{day:t.getTime(),week:n.getTime()}}var $C=3e4,ew=15e3;function tw(e,t){let[n,r]=(0,d.useState)(null),i=`${e}:${t??``}`;return(0,d.useEffect)(()=>{let n=!0,a=()=>{let{day:a,week:o}=QC(Date.now());X.agentUsage(e,{board:t,day:a,week:o}).then(e=>n&&r({key:i,value:e}),()=>n&&r(e=>e??{key:i,value:{}}))};a();let o=setInterval(a,$C);return()=>{n=!1,clearInterval(o)}},[e,t,i]),n?.key===i?n.value:null}function nw(){let[e,t]=(0,d.useState)(()=>Date.now());return(0,d.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),ew);return()=>clearInterval(e)},[]),e}function rw(e,t,n,r){let i=NC(r),a=t?.name??e;if(r===void 0)return n?void 0:`Tricot can't tell which tool ${e} runs in, so it has no usage to show.`;if(i===`none`||i===`tokens`){let e=FC(r,a);return i===`none`||n?e:t&&t.state===`on`?`${e} They show here after its next turn.`:`${e} Turn on live steps to see them here.`}if(t?.usage===`replaced`)return`Your status line changed since Tricot set it up, so ${t.agentName}'s plan usage stopped coming. To have both, turn live steps off and on again: Tricot's status line then shows your new one.`;if(t&&t.state!==`on`)return t.state===`partly`?`Turn live steps on again to see ${t.agentName}'s plan usage here.`:`Turn on live steps to see ${t.agentName}'s plan usage here.`;if(!n?.windows?.length)return Je(r)?.usage.quiet?.(a,!!n)}function iw({name:e,board:t,liveSteps:n}){let r=tw(e,t?.id),i=nw(),a=(0,d.useId)();if(r===null||n===null)return null;let o=r.usage,s=n?_C(e,n.agents):void 0,c=o?PC(o.source):s?.id,l=UC(o?.windows,i),u=o&&GC(l.length?o.windowsAt??o.at:o.at,i),f=[o?.plan&&YC(o.plan),u].filter(Boolean).join(` · `),p=rw(e,s,o,c),m=o?aw(o):[];return(0,Q.jsxs)(`section`,{className:`agent-usage`,"aria-labelledby":a,children:[(0,Q.jsxs)(`div`,{className:`agent-usage-head`,children:[(0,Q.jsx)(`span`,{className:`agent-usage-title`,id:a,children:`Usage`}),f&&(0,Q.jsx)(`span`,{className:`agent-usage-meta`,children:f})]}),l.length>0&&(0,Q.jsx)(`ul`,{className:`usage-windows`,children:l.map(e=>{let t=zC(e),n=WC(e.usedPercent);return(0,Q.jsxs)(`li`,{className:`usage-window is-${n}`,children:[(0,Q.jsxs)(`div`,{className:`usage-window-line`,children:[(0,Q.jsx)(`span`,{className:`usage-window-name`,children:t}),(0,Q.jsx)(`span`,{className:`usage-window-text`,children:HC(e,i)})]}),(0,Q.jsx)(`div`,{className:`usage-bar`,role:`meter`,"aria-label":`${t} window used`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(e.usedPercent)),"aria-valuetext":HC(e,i),children:(0,Q.jsx)(`span`,{className:`usage-bar-fill`,style:{width:`${Math.min(100,Math.max(0,e.usedPercent))}%`}})})]},e.id)})}),m.length>0&&(0,Q.jsx)(`ul`,{className:`usage-extras`,children:m.map(e=>(0,Q.jsx)(`li`,{children:e},e))}),p&&(0,Q.jsx)(`p`,{className:`usage-quiet`,children:p}),r.activity&&(0,Q.jsx)(sw,{activity:r.activity})]})}function aw(e){let t=[];return e.tokens&&t.push(`${ZC(e.tokens)}, this session`),e.costUsd!==void 0&&t.push(Ze(e.source)?.usage.listPrices?`${JC(e.costUsd)} this session, at list prices`:`${JC(e.costUsd)} this session`),e.context&&t.push(`Context ${VC(e.context.usedPercent)} full, of ${KC(e.context.window)} tokens`),t}var ow=[[`comments`,`Comments and replies`],[`workingMs`,`Time working`]];function sw({activity:e}){let t=[...mx().activityRows(),...ow],n=(e,t)=>t===`workingMs`?XC(e.workingMs):String(e[t]);return(0,Q.jsxs)(`table`,{className:`usage-board`,children:[(0,Q.jsxs)(`caption`,{children:[`On `,e.board.title]}),(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{}),(0,Q.jsx)(`th`,{scope:`col`,children:`Today`}),(0,Q.jsx)(`th`,{scope:`col`,children:`This week`})]})}),(0,Q.jsx)(`tbody`,{children:t.map(([t,r])=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`row`,children:r}),(0,Q.jsx)(`td`,{children:n(e.today,t)}),(0,Q.jsx)(`td`,{children:n(e.week,t)})]},t))})]})}function cw(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=!0;return X.agents().then(n=>e&&t(n),()=>e&&t(e=>e??[])),()=>{e=!1}},[n]),{agents:e,reload:(0,d.useCallback)(()=>r(e=>e+1),[])}}function lw(){let[e,t]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let e=!0;return X.agentRules().then(n=>e&&t(n.rules),()=>e&&t({})),()=>{e=!1}},[]),{rules:e,set:(0,d.useCallback)(async(e,n)=>{let r=await X.setAgentRule(e,{model:n.model??null,effort:n.effort??null});t(r.rules)},[])}}function uw(e,t=!1){if(e.state===`absent`)return`not connected`;let n=t&&e.board?` on ${e.board.title}`:``;return e.state===`idle`?`idle, last seen ${ex(e.lastSeen)}${n}`:`${e.state}${n}`}var dw=e=>`${e.skills.length} skill${e.skills.length===1?``:`s`}`;function fw({onOpen:e}){let{agents:t}=cw();return t===null?null:(0,Q.jsxs)(`div`,{className:`user-agents`,children:[(0,Q.jsx)(`div`,{className:`user-agents-head`,children:`Agents`}),t.length===0?(0,Q.jsx)(`p`,{className:`user-agents-empty`,children:`No agent has connected yet. Once one has, its skills are here, and type / in a comment or a thread to call them.`}):t.map(t=>(0,Q.jsxs)(`button`,{type:`button`,className:`user-agent`,onClick:()=>e(t.name),"aria-haspopup":`dialog`,children:[(0,Q.jsx)(ix,{actor:{kind:`agent`,name:t.name},showName:!1}),(0,Q.jsxs)(`span`,{className:`user-agent-text`,children:[(0,Q.jsx)(`span`,{className:`user-agent-name`,children:t.name}),(0,Q.jsxs)(`span`,{className:`user-agent-state`,children:[(0,Q.jsx)(`span`,{className:`user-agent-dot is-${t.state}`,"aria-hidden":!0}),uw(t)]})]}),(0,Q.jsxs)(`span`,{className:`user-agent-count`,children:[dw(t),` ›`]})]},t.name))]})}function pw({name:e,person:t,onClose:n}){let{agents:r,reload:i}=cw(),a=r?.find(t=>U(t.name,e)),[o,s]=(0,d.useState)(`skills`),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=vC(),{rules:f,set:p}=lw(),m=mx().hasWork()?[`skills`,`work`,`activity`]:[`skills`,`activity`],h=DC(a??{name:e}),g=OC(h)&&f!==null?h:void 0,_=g&&f?.[g.id]||{},v=g&&be(g,a?.runsOn,_);(0,d.useEffect)(()=>{c.current?.focus();let e=e=>e.key===`Escape`&&!e.defaultPrevented&&n();return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let y=a?.reportedAt?`skills reported ${ex(a.reportedAt)}`:`hasn't reported its skills`;return(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`agent-scrim`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,Q.jsxs)(`aside`,{className:`agent-panel`,ref:c,role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, an agent`,tabIndex:-1,children:[(0,Q.jsxs)(`header`,{className:`agent-head`,ref:l,children:[(0,Q.jsx)(ix,{actor:{kind:`agent`,name:e},showName:!1}),(0,Q.jsxs)(`div`,{className:`agent-head-text`,children:[(0,Q.jsx)(`h2`,{children:a?.name??e}),(0,Q.jsxs)(`p`,{children:[a&&(0,Q.jsx)(`span`,{className:`user-agent-dot is-${a.state}`,"aria-hidden":!0}),a?uw(a,!0):`Loading…`,` · `,y]}),v&&(0,Q.jsx)(`p`,{className:`agent-head-runs`,children:v})]}),g&&(0,Q.jsx)(jC,{kind:g,name:a?.name??e,rule:_,runsOn:a?.runsOn,onSet:e=>p(g.id,e),under:l}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small agent-close`,onClick:n,"aria-label":`Close`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(bC,{name:a?.name??e,person:t,steps:u}),r!==null&&(0,Q.jsx)(iw,{name:a?.name??e,board:a?.board,liveSteps:u.report}),(0,Q.jsx)(`div`,{className:`agent-tabs`,role:`tablist`,"aria-label":`${e}`,children:m.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e,className:o===e?`is-active`:``,onClick:()=>s(e),children:e===`skills`?`Skills${a?` ${a.skills.length}`:``}`:e===`work`?`Working on`:`Activity`},e))}),(0,Q.jsx)(`div`,{className:`agent-body`,children:a?o===`skills`?(0,Q.jsx)(hw,{agent:a,person:t,onChange:i}):o===`work`?(0,Q.jsx)(vw,{agent:a,onOpen:n}):(0,Q.jsx)(bw,{agent:a,onOpen:n}):(0,Q.jsx)(`p`,{className:`agent-empty`,children:r===null?`Loading…`:`${e} isn't known to Tricot.`})})]})}),document.body)}function mw(e,t){return e.tricot?e.tricot.agent?`Tricot skill · just for ${t}`:`Tricot skill · works with every agent`:`its own`}function hw({agent:e,person:t,onChange:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(null),s=r.trim().toLowerCase(),c=e.skills.filter(e=>!s||e.name.toLowerCase().includes(s)||e.description.toLowerCase().includes(s)),l=()=>{o(null),n()};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{className:`agent-search`,type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:`Search skills…`,"aria-label":`Search ${e.name}'s skills`,spellCheck:!1}),e.skills.length===0?(0,Q.jsxs)(`p`,{className:`agent-empty`,children:[e.name,` has not reported any skills. A Tricot skill you add below works with it all the same.`]}):c.length===0?(0,Q.jsxs)(`p`,{className:`agent-empty`,children:[`No skill matches “`,r.trim(),`”.`]}):(0,Q.jsx)(`ul`,{className:`agent-skills`,children:c.map(n=>n.tricot&&a===n.tricot.id?(0,Q.jsx)(`li`,{className:`agent-skill is-editing`,children:(0,Q.jsx)(gw,{agent:e.name,person:t,skill:n,onDone:l,onCancel:()=>o(null)})},`tricot:${n.tricot.id}`):(0,Q.jsxs)(`li`,{className:`agent-skill`,children:[(0,Q.jsxs)(`div`,{className:`agent-skill-line`,children:[(0,Q.jsxs)(`code`,{children:[`/`,n.name,n.call&&` (Tricot)`]}),(0,Q.jsx)(`span`,{className:`agent-skill-tag${n.tricot?` is-tricot`:``}`,children:mw(n,e.name)}),n.tricot&&(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small agent-skill-edit`,onClick:()=>o(n.tricot.id),"aria-label":`Edit /${n.name}`,children:`Edit`})]}),(0,Q.jsx)(`p`,{className:`agent-skill-desc`,title:n.description,children:n.description}),n.call&&(0,Q.jsxs)(`p`,{className:`agent-skill-note`,children:[e.name,` has its own /`,n.name,`, which is what that calls. Call this one as /`,n.call,`.`]})]},`${n.tricot?`tricot`:`own`}:${n.name}`))}),a===`new`?(0,Q.jsx)(`div`,{className:`agent-add is-open`,children:(0,Q.jsx)(gw,{agent:e.name,person:t,onDone:l,onCancel:()=>o(null)})}):(0,Q.jsxs)(`button`,{type:`button`,className:`agent-add`,onClick:()=>o(`new`),children:[(0,Q.jsx)($,{name:`plus`}),` Add a skill`]})]})}function gw({agent:e,person:t,skill:n,onDone:r,onCancel:i}){let a=n?.tricot,[o,s]=(0,d.useState)(n?.name??``),[c,l]=(0,d.useState)(n?.description??``),[u,f]=(0,d.useState)(a?.instructions??``),[p,m]=(0,d.useState)(!!a?.agent),[h,g]=(0,d.useState)(!1),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),x=o.trim()!==``&&c.trim()!==``&&u.trim()!==``,S=async e=>{g(!0),b(null);try{await e(),r()}catch(e){b(e.message),g(!1)}};return(0,Q.jsxs)(`form`,{className:`agent-form`,onSubmit:n=>{if(n.preventDefault(),!x||h)return;let r={name:o.trim(),description:c.trim(),instructions:u,agent:p?e:``};S(()=>a?X.editSkill(a.id,t,r):X.addSkill(t,r))},children:[(0,Q.jsx)(`div`,{className:`agent-form-head`,children:a?`Edit /${n.name}`:`Add a skill`}),(0,Q.jsxs)(`label`,{className:`agent-field`,children:[(0,Q.jsx)(`span`,{children:`Name`}),(0,Q.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`One word, e.g. weekly-summary`,autoFocus:!0,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`agent-field`,children:[(0,Q.jsx)(`span`,{children:`What it does, in one line`}),(0,Q.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Write release notes from the last commits`})]}),(0,Q.jsxs)(`label`,{className:`agent-field`,children:[(0,Q.jsx)(`span`,{children:`Instructions the agent follows when you call it`}),(0,Q.jsx)(`textarea`,{value:u,onChange:e=>f(e.target.value),rows:5,placeholder:`Read the commits since the last tag, group them by area, and write the notes in plain language…`})]}),(0,Q.jsxs)(`div`,{className:`agent-field`,children:[(0,Q.jsx)(`span`,{children:`Who it is for`}),(0,Q.jsxs)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Who it is for`,children:[(0,Q.jsx)(`button`,{type:`button`,className:p?``:`is-active`,"aria-pressed":!p,onClick:()=>m(!1),children:`Every agent`}),(0,Q.jsxs)(`button`,{type:`button`,className:p?`is-active`:``,"aria-pressed":p,onClick:()=>m(!0),children:[`Just `,e]})]})]}),(0,Q.jsxs)(`p`,{className:`agent-form-note`,children:[`Saved in Tricot and sent with the request, so it works with any agent. Nothing is written into `,e,`'s own settings.`]}),y&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:y}),_?(0,Q.jsxs)(`div`,{className:`agent-form-actions`,children:[(0,Q.jsxs)(`span`,{className:`small`,children:[`Delete /`,n?.name,` for `,a?.agent?a.agent:`every agent`,`?`]}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:h,onClick:()=>v(!1),children:`Keep it`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small agent-delete`,disabled:h,onClick:()=>void S(()=>X.deleteSkill(a.id,t)),children:`Delete`})]}):(0,Q.jsxs)(`div`,{className:`agent-form-actions`,children:[a&&(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-small agent-delete`,onClick:()=>v(!0),children:[(0,Q.jsx)($,{name:`trash`}),` Delete`]}),(0,Q.jsx)(`span`,{className:`row-spacer`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:i,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-small${x?` btn-primary`:``}`,disabled:!x||h,children:a?`Save`:p?`Add for ${e}`:`Add for every agent`})]})]})}function _w(e,t){let[n,r]=(0,d.useState)({key:t,value:null,error:null});return(0,d.useEffect)(()=>{let n=!0;return e().then(e=>n&&r({key:t,value:e,error:null}),e=>n&&r({key:t,value:null,error:e.message})),()=>{n=!1}},[t]),n.key===t?n:{value:null,error:null}}function vw({agent:e,onOpen:t}){let n=mx(),{value:r,error:i}=_w(()=>n.work(e.name),e.name);return i?(0,Q.jsx)(`p`,{className:`error agent-empty`,children:i}):r?r.length===0?(0,Q.jsx)(`p`,{className:`agent-empty`,children:n.noWork(e.name)}):(0,Q.jsx)(`ul`,{className:`agent-rows`,children:r.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:e.href,onClick:t,className:`agent-row`,children:[(0,Q.jsxs)(`span`,{className:`agent-row-title`,children:[(0,Q.jsx)(`span`,{className:`agent-row-ref`,children:e.ref}),` `,e.title]}),(0,Q.jsx)(`span`,{className:`agent-row-meta`,children:e.meta})]})},e.id))}):(0,Q.jsx)(`p`,{className:`agent-empty`,children:`Loading…`})}var yw=30;function bw({agent:e,onOpen:t}){let n=mx(),r=e.board,{value:i,error:a}=_w(()=>r?X.events(r.id,{actor:e.name,limit:yw}):Promise.resolve(null),`${e.name}:${r?.id??``}`);if(!r)return(0,Q.jsxs)(`p`,{className:`agent-empty`,children:[e.name,` hasn't been on a board since Tricot started, so there is no activity to show yet.`]});if(a)return(0,Q.jsx)(`p`,{className:`error agent-empty`,children:a});if(!i)return(0,Q.jsx)(`p`,{className:`agent-empty`,children:`Loading…`});if(i.events.length===0)return(0,Q.jsxs)(`p`,{className:`agent-empty`,children:[e.name,` hasn't done anything on `,r.title,` yet.`]});let o=e=>{let t=lx(e);return(t&&n.byId(t.kind,r.id,t.id)?.href)??dS.board(r.id)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`agent-activity-head`,children:[`On `,r.title,`, newest first`,i.total>i.events.length?` (${i.events.length} of ${i.total})`:``]}),(0,Q.jsx)(`ul`,{className:`agent-rows`,children:i.events.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:o(e),onClick:t,className:`agent-row`,children:[(0,Q.jsx)(`span`,{className:`agent-row-title`,children:e.summary}),(0,Q.jsx)(`span`,{className:`agent-row-meta`,children:ex(e.at)})]})},e.seq))})]})}function xw(e,t){return x([`tricot`,e,...t?[`--board`,t]:[]])}var Sw=m(typeof navigator<`u`&&/Win/.test(navigator.platform)),Cw=`tricot:connect-tool`,ww=e=>e===`other`||qe().some(t=>t.id===e);function Tw({parts:e}){return(0,Q.jsx)(Q.Fragment,{children:e.map((e,t)=>typeof e==`string`?e:(0,Q.jsx)(`code`,{children:e.code},t))})}function Ew({boardId:e}){let[t,n]=(0,d.useState)(),[r,i]=(0,d.useState)(()=>{try{let e=localStorage.getItem(Cw);return ww(e)?e:Ye().id}catch{return Ye().id}});(0,d.useEffect)(()=>{X.info().then(e=>n(e.mcpUrl),()=>{})},[]);let a=e=>{i(e);try{localStorage.setItem(Cw,e)}catch{}};if(!t)return null;let o=$e(t,Sw),s=[...qe().map(e=>({key:e.id,label:e.name})),{key:Qe,label:`Other`}],c=Je(r);return(0,Q.jsxs)(`div`,{className:`connect`,children:[(0,Q.jsx)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Agent tool`,children:s.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:r===e.key?`is-active`:``,"aria-pressed":r===e.key,onClick:()=>a(e.key),children:e.label},e.key))}),c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:(0,Q.jsx)(Tw,{parts:c.panel.intro})}),(0,Q.jsx)(ax,{block:c.connect.how===`file`,text:o[c.id]}),c.panel.note&&(0,Q.jsx)(`p`,{className:`muted small`,children:(0,Q.jsx)(Tw,{parts:c.panel.note})}),!c.cantStart&&(0,Q.jsx)(Dw,{agent:c.id,name:c.name,boardId:e})]}),r===`other`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Any MCP client (Streamable HTTP): point it at this address.`}),(0,Q.jsx)(ax,{text:o.other}),(0,Q.jsxs)(`p`,{className:`muted small`,children:[`Add `,(0,Q.jsx)(`code`,{children:`?agent=Name`}),` to label the agent on the board.`]})]}),r!==`other`&&(0,Q.jsx)(EC,{tool:r}),e&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Then tell your agent which board to work on:`}),(0,Q.jsx)(ax,{text:e})]})]})}function Dw({agent:e,name:t,boardId:n}){return(0,Q.jsxs)(`p`,{className:`muted small connect-session`,children:[`Or start `,t,` with the board for one session, its settings left alone: `,(0,Q.jsx)(`code`,{children:xw(e,n)})]})}var Ow={listening:{label:`listening`,meaning:()=>`Waiting on the board, so it sees what you do right away.`},asleep:{label:`asleep`,meaning:()=>`Its turn is over, so it spends nothing while it waits. Tricot wakes it in its terminal as soon as something on the board needs it.`},working:{label:`working`,meaning:e=>`Busy with a step; it sees what you do when it next checks the board (last checked ${ex(e)}).`},away:{label:`not checking`,meaning:e=>`Last checked the board ${ex(e)}; nudge it in its session if you're waiting on it.`}},kw=`Tricot typed a wake into its terminal, but its turn didn't start: look at its terminal. Tricot tries again when something new needs it.`,Aw=150;function jw({live:e,agents:t=[],work:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=(0,d.useRef)(null),s=(0,d.useRef)(!1),c=(0,d.useRef)(void 0);if((0,d.useEffect)(()=>()=>clearTimeout(c.current),[]),Zl(r,(0,d.useCallback)(e=>{e&&a.current?.contains(document.activeElement)&&o.current?.focus(),i(!1)},[]),a),!e)return(0,Q.jsx)(`div`,{className:`live`,title:`Reconnecting…`,children:(0,Q.jsxs)(`span`,{className:`live-label`,children:[(0,Q.jsx)(`span`,{className:`live-dot`}),` Offline`]})});let l=e=>{clearTimeout(c.current),c.current=setTimeout(()=>i(e),Aw)},u=()=>a.current?.contains(document.activeElement)??!1,f=[...t].sort((e,t)=>jS(e.state)-jS(t.state)),p=f[0]?.state??`listening`,m=t.length===0?`No agents`:t.length===1?`${t[0].name} · ${Ow[t[0].state].label}`:`${t.length} agents`;return(0,Q.jsxs)(`div`,{className:`live`,ref:a,onMouseEnter:()=>{s.current=!0,l(!0)},onMouseLeave:()=>{s.current=!1,u()?clearTimeout(c.current):l(!1)},onFocus:()=>{clearTimeout(c.current),i(!0)},onBlur:e=>{!s.current&&!a.current?.contains(e.relatedTarget)&&i(!1)},children:[(0,Q.jsxs)(`button`,{ref:o,type:`button`,className:`live-label live-on live-${p}`,"aria-expanded":r,onClick:()=>i(!0),children:[(0,Q.jsx)(`span`,{className:`live-dot`}),(0,Q.jsx)(`span`,{className:`live-words`,children:m})]}),r&&(0,Q.jsx)(`div`,{className:`live-card`,role:`group`,"aria-label":`Agents on this board`,children:t.length===0?(0,Q.jsx)(`p`,{className:`live-card-empty`,children:`No agent has used this board in the last 5 minutes.`}):(0,Q.jsx)(`ul`,{className:`live-agents`,children:f.map(e=>(0,Q.jsxs)(`li`,{className:`live-agent`,children:[(0,Q.jsxs)(`div`,{className:`live-agent-head`,children:[(0,Q.jsx)(ix,{actor:{kind:`agent`,name:e.name}}),(0,Q.jsxs)(`span`,{className:`live-state live-${e.state}`,children:[(0,Q.jsx)(`span`,{className:`live-dot`}),Ow[e.state].label]})]}),(0,Q.jsx)(`p`,{className:`live-agent-meaning`,children:e.stuck?kw:Ow[e.state].meaning(e.lastSeen)}),n?.(e)]},e.name))})})]})}var Mw=45e3,Nw=12e4,Pw=15e3,Fw=6e5,Iw=72e4;function Lw(e){return e.done?[Pw]:e.running?[Fw,Iw]:[Mw,Nw]}function Rw(e,t){let n=Math.max(0,t-Date.parse(e.at)),[r,i]=Lw(e);return i===void 0?n<r?`dim`:void 0:n<r?`live`:n<i?`dim`:void 0}function zw(e,t){let n=Math.max(0,t-Date.parse(e.at)),r=Lw(e).find(e=>e>n);return r===void 0?1/0:r-n}var Bw=class{steps=[];listeners=new Set;set(e){this.steps=e;for(let e of this.listeners)e()}get=()=>this.steps;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))},Vw=(0,d.createContext)(null),Hw=Vw.Provider,Uw=[],Ww={get:()=>Uw,subscribe:()=>()=>{}};function Gw(){let e=(0,d.useContext)(Vw)??Ww;return(0,d.useSyncExternalStore)(e.subscribe,e.get)}var Kw=e=>e===`live`?`working`:`resting`,qw=e=>GS(e);function Jw({text:e,className:t=``}){let n=ue(e);return n?(0,Q.jsxs)(`span`,{className:`${t} step-text`,children:[(0,Q.jsx)(`span`,{className:`step-lead`,children:n.lead}),(0,Q.jsx)(`span`,{className:`step-dirs`,children:n.dirs}),n.head&&(0,Q.jsx)(`span`,{className:`step-head`,children:n.head}),(0,Q.jsx)(`span`,{className:`step-tail`,children:n.tail}),n.after&&(0,Q.jsx)(`span`,{className:`step-after`,children:n.after})]}):(0,Q.jsx)(`span`,{className:t,children:e})}function Yw(e){let[t,n]=(0,d.useState)(()=>Date.now()),r=Math.max(t,Date.now()),i=e?zw(e,r):1/0;return(0,d.useEffect)(()=>{if(!Number.isFinite(i))return;let e=setTimeout(()=>n(Date.now()),i+50);return()=>clearTimeout(e)},[i,e]),r}var Xw=class{byBoard=new Map;listeners=new Set;set(e,t){t.length?this.byBoard.set(e,t):this.byBoard.delete(e);for(let e of this.listeners)e()}clear(){this.byBoard=new Map;for(let e of this.listeners)e()}of=e=>this.byBoard.get(e)??Uw;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))},Zw=(0,d.createContext)(null),Qw=Zw.Provider;function $w(){let[e]=(0,d.useState)(()=>new Xw);return(0,d.useEffect)(()=>{let t=new Rl(Jr(J.stepsStream));return t.onopen=()=>e.clear(),t.addEventListener(`steps`,t=>{let{board:n,steps:r}=JSON.parse(t.data);e.set(n,r)}),t.addEventListener(`approvals`,e=>Hl.set(JSON.parse(e.data))),t.addEventListener(`admissions`,e=>zl.set(JSON.parse(e.data))),()=>t.close()},[e]),e}var eT={of:()=>Uw,subscribe:()=>()=>{}};function tT(e,t){let n=new Map;for(let r of e){let e=r.agent.toLowerCase(),i=n.get(e);Rw(r,t)&&(!i||Date.parse(r.at)>Date.parse(i.at))&&n.set(e,r)}return n}function nT(e,t,n){let r=tT(t,n);for(let t of e){let e=r.get(t.toLowerCase());if(e)return e}return[...r.values()].sort((e,t)=>Date.parse(t.at)-Date.parse(e.at))[0]}function rT(e){let t=(0,d.useContext)(Zw)??eT;return(0,d.useSyncExternalStore)(t.subscribe,()=>t.of(e))}var iT=`M4.06 2.4C4.01 2.28 3.87 1.9 3.74 1.7C3.62 1.51 3.45 1.34 3.28 1.22C3.11 1.11 2.92 1.03 2.73 1.01C2.54 0.98 2.34 1.01 2.16 1.07C1.98 1.14 1.79 1.26 1.64 1.41C1.49 1.56 1.34 1.77 1.24 1.99C1.13 2.22 1.05 2.49 1.01 2.78C0.97 3.06 0.96 3.38 1 3.69C1.04 4.01 1.11 4.34 1.23 4.67C1.35 4.99 1.51 5.32 1.71 5.62C1.91 5.92 2.15 6.21 2.42 6.47C2.69 6.72 3 6.96 3.32 7.15C3.65 7.34 4.01 7.5 4.37 7.6C4.74 7.71 5.13 7.78 5.51 7.79C5.88 7.81 6.28 7.78 6.65 7.7C7.02 7.63 7.4 7.5 7.74 7.34C8.08 7.18 8.41 6.97 8.7 6.74C8.99 6.51 9.26 6.23 9.49 5.94C9.71 5.66 9.9 5.33 10.05 5.02C10.2 4.7 10.31 4.36 10.37 4.04C10.44 3.72 10.46 3.4 10.45 3.1C10.44 2.8 10.38 2.51 10.3 2.26C10.21 2.01 10.09 1.78 9.95 1.6C9.82 1.41 9.64 1.26 9.47 1.17C9.3 1.07 9.1 1.01 8.91 1C8.72 0.99 8.52 1.03 8.34 1.11C8.16 1.2 7.98 1.33 7.84 1.5C7.69 1.67 7.56 1.88 7.46 2.12C7.37 2.36 7.3 2.64 7.27 2.94C7.25 3.23 7.26 3.55 7.31 3.87C7.36 4.18 7.45 4.52 7.58 4.84C7.72 5.16 7.89 5.49 8.11 5.78C8.32 6.08 8.57 6.36 8.85 6.61C9.13 6.85 9.45 7.08 9.79 7.25C10.12 7.43 10.49 7.57 10.86 7.66C11.23 7.75 11.62 7.8 12 7.8C12.38 7.8 12.77 7.75 13.14 7.66C13.51 7.57 13.87 7.43 14.21 7.25C14.54 7.08 14.86 6.85 15.14 6.61C15.42 6.36 15.68 6.08 15.89 5.78C16.1 5.49 16.28 5.16 16.41 4.84C16.55 4.52 16.64 4.18 16.69 3.87C16.74 3.55 16.75 3.23 16.72 2.94C16.7 2.64 16.63 2.36 16.53 2.12C16.44 1.88 16.3 1.67 16.16 1.5C16.01 1.33 15.83 1.2 15.65 1.11C15.48 1.03 15.28 0.99 15.09 1C14.9 1.01 14.7 1.07 14.53 1.17C14.35 1.26 14.18 1.41 14.04 1.6C13.9 1.78 13.78 2.01 13.7 2.26C13.62 2.51 13.56 2.8 13.55 3.1C13.53 3.4 13.56 3.72 13.62 4.04C13.69 4.36 13.8 4.7 13.94 5.02C14.09 5.33 14.28 5.66 14.51 5.94C14.73 6.23 15 6.51 15.29 6.74C15.58 6.97 15.92 7.18 16.26 7.34C16.6 7.5 16.97 7.63 17.35 7.7C17.72 7.78 18.11 7.81 18.49 7.79C18.87 7.78 19.26 7.71 19.62 7.6C19.99 7.5 20.35 7.34 20.67 7.15C21 6.96 21.31 6.72 21.58 6.47C21.85 6.21 22.09 5.92 22.29 5.62C22.48 5.32 22.65 4.99 22.76 4.67C22.88 4.34 22.96 4.01 23 3.69C23.03 3.38 23.03 3.06 22.99 2.78C22.95 2.49 22.86 2.22 22.76 1.99C22.65 1.77 22.51 1.56 22.36 1.41C22.2 1.26 22.02 1.14 21.84 1.07C21.66 1.01 21.45 0.98 21.27 1.01C21.08 1.03 20.88 1.11 20.71 1.22C20.54 1.34 20.38 1.51 20.25 1.7C20.12 1.9 19.99 2.28 19.94 2.4`,aT=e=>(document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)),oT=()=>document.visibilityState===`hidden`;function sT({state:e,leaving:t=!1}){let n=(0,d.useSyncExternalStore)(aT,oT,()=>!1),[r,i]=(0,d.useState)(()=>qS(e,void 0)),a=qS(e,r);return a!==r&&i(a),e?(0,Q.jsx)(`span`,{className:`stitch is-${a?`working`:e}${a===`cast`?` is-cast-on`:``}${t?` is-leaving`:``}${n?` is-paused`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`svg`,{viewBox:`0 0 24 8.8`,children:(0,Q.jsx)(`path`,{className:`stitch-yarn`,d:iT,pathLength:100})})}):null}var cT=(0,d.createContext)([]),lT=cT.Provider,uT=()=>(0,d.useContext)(cT);function dT(e){let[t,...n]=e.agents;if(t&&t.state!==`away`)return{now:t,others:n.length};let r=t?{name:t.name,at:t.lastSeen}:e.lastAgent;return r?{last:r}:null}function fT(){let e=mx().hasWork();return t=>e?t.on:void 0}function pT(e,t){return e.state===`working`?t?`working on ${t}`:`working`:e.state===`listening`||e.state===`asleep`?e.state:`not checking`}var mT=new class{items=[];posts=new Map;keys=new Map;listeners=new Set;next=0;get=()=>this.items;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));keyOf=e=>this.keys.get(e);send(e,t,n,r,i){let a={key:`out-${Date.now().toString(36)}-${this.next++}`,place:e,body:t,...i&&{lens:i},at:new Date().toISOString(),known:n,state:`sending`};return this.posts.set(a.key,r),this.update([...this.items,a]),this.attempt(a.key),a}retry(e){this.find(e)&&this.find(e).state===`failed`&&(this.change(e,{state:`sending`,error:void 0}),this.attempt(e))}remove(e){let t=this.find(e);if(t)return this.posts.delete(e),this.update(this.items.filter(t=>t.key!==e)),t}arrived(e,t){t&&this.keys.set(t.id,e),this.change(e,{state:`sent`,...t&&{id:t.id},...t?.place&&{place:t.place}})}async attempt(e){let t=this.posts.get(e);if(t)try{this.arrived(e,await t(e))}catch(t){let n=t instanceof TypeError?`couldn't reach Tricot`:t instanceof Error?t.message:String(t);this.change(e,{state:`failed`,error:n})}}find(e){return this.items.find(t=>t.key===e)}change(e,t){this.find(e)&&this.update(this.items.map(n=>n.key===e?{...n,...t}:n))}update(e){this.items=e;for(let e of this.listeners)e()}};function hT(e){let t=(0,d.useSyncExternalStore)(mT.subscribe,mT.get);return(0,d.useMemo)(()=>t.filter(t=>t.place===e),[t,e])}function gT(e,t,n,r,i=mT.keyOf){let a=new Map,o=[];for(let r of t){let t=e=>!a.has(e.id)&&e.author.kind===`human`&&U(e.author.name,n),i=r.id?e.find(e=>e.id===r.id):e.findLast(e=>t(e)&&!r.known.includes(e.id)&&e.body.trim()===r.body.trim());i?a.set(i.id,r):o.push(r)}return[...e.map(e=>{let t=a.get(e.id);return{item:e,key:t?.key??i(e.id)??e.id,...t&&{outgoing:t}}}),...o.map(e=>({item:r(e),key:e.key,outgoing:e}))]}function _T(e){let t=e.outgoing;if(t&&e.item.id===t.key&&t.state!==`sent`)return t.state}function vT(e){return e.flatMap(e=>e.outgoing&&e.item.id!==e.outgoing.key&&e.outgoing.state!==`sending`?[e.outgoing.key]:[])}function yT(e,t,n,r){let i=e.filter(e=>e.author.kind===`human`&&U(e.author.name,n)&&!t.includes(e.id)),a=i.findLast(e=>e.body.trim()===r.trim())??i.at(-1);return a&&{id:a.id}}var bT,xT;function ST(){return bT??=X.liveSteps().then(e=>xT=e.installedAgents??e.agents,()=>xT=null),bT}function CT(){let[e,t]=(0,d.useState)(xT);return(0,d.useEffect)(()=>{let e=!0;return ST().then(n=>e&&t(n)),()=>{e=!1}},[]),e}var wT=new Set,TT,ET,DT=1e4;function OT(){X.agents().then(e=>{let t=e.filter(e=>e.state!==`absent`).map(e=>e.name);if(!(TT&&t.join(`
53
+ `)===TT.join(`
54
+ `))){TT=t;for(let e of wT)e()}},()=>{})}function kT(e){return wT.add(e),wT.size===1&&(OT(),ET=setInterval(OT,DT)),()=>{wT.delete(e),wT.size===0&&clearInterval(ET)}}function AT(){return(0,d.useSyncExternalStore)(kT,()=>TT)}function jT(e,t){return t?_C(e,t)?.name:void 0}function MT({agent:e,tool:t,quiet:n=!1}){let[r,i]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),1500);return()=>clearTimeout(e)},[r]);let a=()=>navigator.clipboard.writeText(IS).then(()=>i(!0),()=>{});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{"aria-hidden":n||void 0,children:[US(e,t),` `,(0,Q.jsx)(`q`,{className:`say-phrase`,children:IS})]}),` `,(0,Q.jsx)(`button`,{type:`button`,className:`delivery-action say-copy`,onClick:()=>void a(),title:`Copy “${IS}”`,children:r?`Copied`:`Copy`})]})}var NT=5e3;function PT({board:e,where:t,said:n,after:r,onItsWay:i,outgoing:a,onEdit:o,onConnect:s,children:c}){let l=hu(),u=uT(),f=Gw(),[p,m]=(0,d.useState)(()=>Date.now()),h=Math.max(p,Date.now()),g=f.filter(e=>Rw(e,h)||e.done),_=i||l||!XS(n,h)?void 0:PS({board:e,where:t,said:n,after:r,agents:u,steps:g}),v=_&&FS(_,h),y=!!v;(0,d.useEffect)(()=>{if(!y)return;let e=setInterval(()=>m(Date.now()),NT);return()=>clearInterval(e)},[y]);let b=_&&v?{delivery:_,words:v,title:YS(v,n,h),busy:KS(_,e=>Rw(e,h)===`live`)}:void 0,x=(0,d.useRef)(void 0),[S,C]=(0,d.useState)(void 0),w=_?.state===`replied`;(0,d.useLayoutEffect)(()=>{let e=x.current;if(!w||!e||!JS(e.busy,_))return;C(e);let t=setTimeout(()=>C(void 0),320);return()=>{clearTimeout(t),C(void 0)}},[w]),(0,d.useLayoutEffect)(()=>{x.current=b});let T=null;if(i===`failed`&&a)T=(0,Q.jsxs)(`p`,{className:`delivery is-failed`,role:`alert`,title:a.error,children:[(0,Q.jsxs)(`span`,{className:`delivery-text`,children:[`Not sent`,a.error?`: ${a.error}`:``]}),(0,Q.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>mT.retry(a.key),children:`Retry`}),o&&(0,Q.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>{mT.remove(a.key),o(a.body,a.lens)},children:`Edit`})]});else if(i===`sending`)T=(0,Q.jsxs)(`p`,{className:`delivery is-sending`,children:[(0,Q.jsx)(`span`,{className:`delivery-text`,children:`Sending…`}),(0,Q.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:`Sending`})]});else if(b){let e=()=>m(Date.now());T=b.delivery.state===`nobody`||b.delivery.state===`waiting`?(0,Q.jsx)(IT,{shown:b,said:n,at:h,onHover:e,onConnect:s}):(0,Q.jsx)(FT,{shown:b,onHover:e,onConnect:s})}else S&&w&&(T=(0,Q.jsx)(FT,{shown:S,leaving:!0}));return T?(0,Q.jsxs)(`div`,{className:`said-foot`,children:[c,T]}):(0,Q.jsx)(Q.Fragment,{children:c})}function FT({shown:{delivery:e,words:t,title:n,busy:r},leaving:i=!1,onHover:a,onConnect:o}){let s=e.state===`working`;return(0,Q.jsxs)(`p`,{className:`delivery is-${e.state}${i?` is-leaving`:``}`,title:n,onPointerEnter:a,children:[(0,Q.jsx)(`span`,{className:`delivery-text`,"aria-hidden":!0,children:(0,Q.jsx)(Jw,{text:t})},t),(0,Q.jsx)(sT,{state:r,leaving:i}),e.state===`nobody`&&(0,Q.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>{o?.(),LT()},children:`Connect one`}),(0,Q.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:s?`${e.agent} is working on it`:t})]})}function IT({shown:e,said:t,at:n,onHover:r,onConnect:i}){let a=AT(),o=CT();if(a===void 0||o===void 0)return null;let s=LS(e.delivery,a);if(!s)return(0,Q.jsx)(FT,{shown:e,onHover:r,onConnect:i});let c=jT(s,o),l=WS(s,c,e.delivery);return(0,Q.jsxs)(`p`,{className:`delivery is-unheard`,title:YS(l,t,n),onPointerEnter:r,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:HS(s,e.delivery)}),` `,(0,Q.jsx)(MT,{agent:s,tool:c,quiet:!0}),(0,Q.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:l})]})}function LT(){let e=document.querySelector(`details.connect-popover`);e&&(e.open=!0,e.querySelector(`summary`)?.focus())}var RT=/(?:^|\s)\^([\p{L}\p{N}_-]{0,30})$/u;function zT(e){let t=e.match(RT);return t?{at:e.length-t[1].length-1,query:t[1]}:null}function BT(e){let t=Ss(e);return t&&(`lens`in t?t.lens.name:t.unknown)}var VT=e=>BT(`^${e}`)?.length===e.length;function HT(e,t){let n=t.toLowerCase(),r=e.filter(e=>Dc(e.name,t));return[...r.filter(e=>e.name.toLowerCase().startsWith(n)),...r.filter(e=>!e.name.toLowerCase().startsWith(n))]}function UT(e,t){let n=[];if(t.length===0)return n;for(let r=e.indexOf(`^`);r>=0;r=e.indexOf(`^`,r+1)){if(r>0&&!/\s/.test(e[r-1]))continue;let i=BT(e.slice(r)),a=i&&t.find(e=>e.toLowerCase()===i.toLowerCase());a&&(n.push({name:a,start:r,end:r+1+a.length}),r+=a.length)}return n}function WT(e,t){let n=``,r=0;for(let{start:i,end:a}of UT(e,t))for(n+=e.slice(r,i),r=a,i===0&&/[,:;]/.test(e[r]??``)&&r++;/[ \t]/.test(e[r]??``);)r++;return n+e.slice(r)}function GT(e,t){let n=UT(e,t).at(-1)?.name;return{body:WT(e,t).trim(),...n&&{lens:n}}}function KT(e,t,n,r){let i=WT(e.slice(0,t.at),r),a=WT(e.slice(t.at+1+t.query.length),r),o=`^${n}${a.startsWith(` `)?``:` `}`;return{text:i+o+a,caret:i.length+o.length+ +!!a.startsWith(` `)}}var qT=RegExp(`^/(${`^[A-Za-z0-9][\\w.:-]*$`.slice(1,-1)})(?=\\s|$)`);function JT(e,t,n){let r=t.map(e=>e.agent),{names:i,rest:a}=wc(e,[...n,...r],r),o=qT.exec(a);if(!o)return;let s=i.filter(e=>t.some(t=>U(t.agent,e)));if(i.length>0&&s.length===0)return;let c=i.length>0?t.filter(e=>s.some(t=>U(e.agent,t))):t,l=e=>i.length>0||!e.tricot||e.tricot.agent!==void 0,u=e=>e.skills.find(e=>U(e.call??e.name,o[1])&&l(e)),d=c.filter(u);if(d.length===0)return;let f=d.filter(e=>u(e).tricot),p=u(d[0]),m=e.length-a.length;return{skill:{name:p.call??p.name,args:a.slice(o[0].length).trim(),agents:d.map(e=>e.agent),...f.length?{tricot:{instructions:u(f[0]).tricot.instructions,agents:f.map(e=>e.agent)}}:{}},start:m,end:m+o[0].length}}[...AS.map(e=>e===`away`?`idle`:e)];function YT({name:e}){let t=`/${e}`.toLowerCase(),n=e=>{for(let r=0;r<e.children.length;r++){let i=e.children[r];if(i.type===`element`){if(!(i.tagName===`span`&&Array.isArray(i.properties?.className)&&i.properties.className.includes(`mention`))&&n(i))return!0}else if(i.type===`text`){let n=/^[\s,:;-]*/.exec(i.value)[0].length;if(n===i.value.length)continue;let a=i.value.slice(n,n+t.length),o=i.value[n+t.length];if(a.toLowerCase()===t&&!(o&&/[\w.:-]/.test(o))){let o=[];n&&o.push({type:`text`,value:i.value.slice(0,n)}),o.push({type:`element`,tagName:`span`,properties:{className:[`skill-chip`]},children:[{type:`text`,value:a}]}),n+t.length<i.value.length&&o.push({type:`text`,value:i.value.slice(n+t.length)}),e.children.splice(r,1,...o)}return!0}}return!1};return e=>{n(e)}}function XT(e){let t=cc(e?.name??`General`);return`lens-${t?t.name.toLowerCase():`own`}`}var ZT=`No lens: agents answer as they see fit.`,QT=bs.map(({name:e,brief:t})=>({name:e,brief:t??ZT,tone:XT({name:e}),...e===`General`&&{current:!0}})),$T=e=>!!(e?.perMessage&&e.startsOn);function eE(e,t,n){let r=gs(e,t),i=nE(t,n),a=r.findIndex(e=>e===i);return a<0?[void 0,...r]:r.map((e,t)=>t===a?void 0:e)}function tE(e,t,n,r,i){let a=eE(e,t,n);return a[(Math.max(0,a.indexOf(r))+i+a.length)%a.length]}var nE=(e,t)=>e===`model`?t.model:t.effort,rE=(e,t,n)=>t===`model`?_e(e,n):ve(e,n),iE=(e,t,n)=>{let r=nE(t,n);return r?rE(e,t,r):`Default`};function aE(e,t,n,r){return r?{words:rE(e,t,r),set:!0}:{words:iE(e,t,n),set:!1}}function oE(e,t,n){return eE(e,t,n).map(r=>r?{value:r,words:rE(e,t,r)}:nE(t,n)?{value:r,words:iE(e,t,n),note:`default`}:{value:r,words:`Default`})}var sE=e=>e.startsOn?.levels?.length?[`model`,`level`]:[`model`],cE=e=>e===`model`?`Model for this message`:`Thinking for this message`,lE=(e,t)=>`@${e}${hs(t)}`;function uE(e,t,n,r){let i=t===`model`?`Model`:`Thinking`;if(r)return`${i} for this message: ${rE(e,t,r)}`;let a=nE(t,n);return a?`${i}: ${rE(e,t,a)}, its rule`:`${i}: its own`}var dE=(0,d.createContext)({boardId:``,me:``,agents:[],people:[]});function fE(){return(0,d.useContext)(dE)}function pE({board:e,me:t,children:n}){let r=(0,d.useMemo)(()=>{let n=e.presence??[],r=gc(e,n.map(e=>e.name)).map(t=>{let r=n.find(e=>U(e.name,t));return{name:t,state:_c(e,t,r),present:!!r,rank:r?jS(r.state):AS.length}});r.sort((e,t)=>e.rank-t.rank);let i=vc(e).filter(e=>!U(e,t));return{boardId:e.id,me:t,agents:r.map(({rank:e,...t})=>t),people:i}},[e,t]);return(0,Q.jsx)(dE.Provider,{value:r,children:n})}function mE({comment:e}){let{people:t,me:n}=fE(),r=e.mentions??[],i=r.filter(e=>!U(e,n)&&!t.some(t=>U(t,e))),a=[];return r.length&&a.push([Fc,{names:r,agents:i}]),e.skill&&a.push([YT,{name:e.skill.name}]),(0,Q.jsx)(Qb,{rehypePlugins:a.length?a:void 0,children:e.body})}function hE({lens:e}){return e?(0,Q.jsxs)(`span`,{className:`lens-chip ${XT(e)}`,title:`Asked agents to answer this comment through the ${e.name} lens`,children:[`^`,e.name]}):null}function gE({via:e}){return e?(0,Q.jsxs)(`span`,{className:`tag tag-via`,title:`Made by running /${e}, as a person asked`,children:[`via /`,e]}):null}function _E({comment:e,thread:t}){let{me:n}=fE();return Nc(e,t,n)?(0,Q.jsx)(`span`,{className:`tag tag-asked`,children:`asks you`}):null}var vE=[`box-sizing`,`width`,`border-top-width`,`border-right-width`,`border-bottom-width`,`border-left-width`,`padding-top`,`padding-right`,`padding-bottom`,`padding-left`,`font-family`,`font-size`,`font-weight`,`font-style`,`line-height`,`letter-spacing`,`word-spacing`,`text-transform`,`text-indent`,`tab-size`];function yE(e,t){let n=getComputedStyle(e),r=document.createElement(`div`);for(let e of vE)r.style.setProperty(e,n.getPropertyValue(e));Object.assign(r.style,{position:`fixed`,visibility:`hidden`,top:`0`,left:`0`,whiteSpace:e instanceof HTMLTextAreaElement?`pre-wrap`:`pre`,overflowWrap:`break-word`}),r.textContent=e.value.slice(0,t);let i=document.createElement(`span`);i.textContent=`@`,r.append(i),document.body.append(r);let a=e.getBoundingClientRect(),o=parseFloat(n.lineHeight)||parseFloat(n.fontSize)*1.4,s={left:a.left+i.offsetLeft-e.scrollLeft,top:a.top+i.offsetTop-e.scrollTop,height:o};return r.remove(),s}var bE=280,xE=380,SE=36,CE=400,wE=320,TE=380,EE=320,DE=460,OE=34,kE=(e,t)=>e.row===t?e:{row:t,cell:null};function AE(e){return e.present?e.state:`runs next time ${e.name} connects`}function jE(e,t,n,r){let i=fE(),a=jb()?.picker,o=a?.read,s=(0,d.useRef)(null),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)([]),[p,m]=(0,d.useState)({}),[h,g]=(0,d.useState)({cell:null}),[_,v]=(0,d.useState)(0),y=(0,d.useRef)(null),[b,x]=(0,d.useState)(null),S=(0,d.useRef)(null),C=(0,d.useMemo)(()=>(r??[]).map(e=>e.name),[r]),w=C.length>0,T=(0,d.useCallback)(()=>{let e=s.current;if(!e||e.selectionStart!==e.selectionEnd||document.activeElement!==e)return l(null);let t=e.selectionStart??0,r=e.value.slice(0,t),i=r.match(Tc),a=!i&&o?o(r):null,c=!i&&!a&&n?r.match(Ec):null,u=!i&&!a&&!c&&w?zT(r):null,d=i?{trigger:`@`,at:t-i[1].length-1,query:i[1]}:a?{trigger:`#`,...a}:c?{trigger:`/`,at:t-c[1].length-1,query:c[1]}:u?{trigger:`^`,...u}:null;if(!d||d.at===y.current)return l(null);y.current=null,l(e=>e?.trigger===d.trigger&&e.at===d.at&&e.query===d.query?e:d)},[n,o,w]),E=c?.trigger===`/`,D=c?.trigger===`@`;(0,d.useEffect)(()=>{if(!E&&!D)return;let e=!0;return X.agents(i.boardId||void 0).then(t=>e&&f(t),()=>{}),D&&X.agentRules().then(t=>e&&m(t.rules),()=>{}),()=>{e=!1}},[E,D,i.boardId]);let O=c?.trigger===`#`,k=(0,d.useMemo)(()=>{if(!c)return[];if(c.trigger===`#`)return(a?.pick(c.query)??[]).map(e=>({kind:`card`,card:e}));if(c.trigger===`^`)return HT(r??[],c.query).map(e=>({kind:`lens`,lens:e}));let e=c.query.toLowerCase();if(c.trigger===`/`){let t=t=>t.toLowerCase().startsWith(e);return u.flatMap(n=>n.skills.filter(t=>(t.call??t.name).toLowerCase().includes(e)).sort((e,n)=>Number(t(n.call??n.name))-Number(t(e.call??e.name))).map(e=>({kind:`skill`,agent:n.name,name:e.name,description:e.description,present:n.present,tricot:!!e.tricot,call:e.call??e.name})))}let t=e=>Xe({name:e,tool:u.find(t=>U(t.name,e))?.tool});return[...i.agents.filter(t=>Dc(t.name,e)).map(e=>({kind:`agent`,name:e.name,state:e.state,agent:t(e.name)})),...i.people.filter(t=>Dc(t,e)).map(e=>({kind:`person`,name:e}))].slice(0,8)},[c,i,u,a,r]),A=!!c&&k.length>0,j=Math.min(_,Math.max(k.length-1,0));(0,d.useEffect)(()=>{v(0),g({cell:null})},[c?.trigger,c?.at,c?.query]);let M=A?k[j]:void 0,N=M?.kind===`agent`&&$T(M.agent)?M:void 0,P=e=>p[e.id]??{},F=e=>h.row===e?{model:h.model,effort:h.effort}:{},I=N&&h.row===N.name?h.cell:null,L=I&&h.open?I:null,R=(e,t)=>{e!==j&&(v(e),g(e=>t?{cell:null}:{...e,cell:null,open:!1}))},z=e=>()=>{h.open||R(e,!1)},B=c?.trigger===`^`,ee=!E&&!O&&!B&&k.some(e=>e.kind===`agent`),V=ee&&k.some(e=>e.kind===`agent`&&$T(e.agent)),te=E?CE:O?TE:B?DE:ee?xE:bE;(0,d.useLayoutEffect)(()=>{if(!A||!c||!s.current)return x(null);let e=s.current.getBoundingClientRect(),t=yE(s.current,c.at),n=Math.max(e.left,Math.min(t.left-6,e.right-te)),r=Math.max(8,Math.min(n,window.innerWidth-te-8)),i=e.bottom+4,a=E?wE:O?Math.min(EE,64+k.length*32):B?40+k.length*34+OE:40+k.length*34+(V?SE:0);x(i+a<window.innerHeight?{left:r,top:i}:{left:r,bottom:window.innerHeight-e.top+4})},[A,c,k.length,E,O,B,V,te]),(0,d.useLayoutEffect)(()=>{A&&S.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`})},[A,j,b]);let ne=(0,d.useMemo)(()=>[...i.agents.map(e=>e.name),...u.map(e=>e.name)],[i,u]),re=(0,d.useMemo)(()=>[...ne,...i.people,...i.me?[i.me]:[]],[ne,i]),ie=n=>{let r=s.current;if(!r||!c)return;let i,a;if(n.kind===`skill`)({text:i,caret:a}=kc(e,c,n.agent,n.call,re));else if(n.kind===`lens`)({text:i,caret:a}=KT(e,c,n.lens.name,C));else if(n.kind===`card`){let t=e.slice(c.at+1+c.query.length),r=`${n.card.label}${t.startsWith(` `)?``:` `}`;i=e.slice(0,c.at)+r+t,a=c.at+r.length+ +!!t.startsWith(` `)}else{let t=n.kind===`agent`&&$T(n.agent)?hs(F(n.name)):``;({text:i,caret:a}=Oc(e,c,n.name,t))}t(i),l(null),requestAnimationFrame(()=>{r.focus(),r.setSelectionRange(a,a)})},ae=e=>e===`model`?`model`:`effort`,oe=(e,t)=>{if(!N?.agent)return;let{name:n,agent:r}=N;g(i=>{let a=kE(i,n);return{...a,cell:e,[ae(e)]:tE(r,e,P(r),a[ae(e)],t)}})},se=(e,t,n)=>{t!==j&&v(t),g(t=>t.open&&t.cell===n&&t.row===e.name?{...t,cell:null,open:!1}:{...kE(t,e.name),cell:n,open:!0})},H=(e,t,n)=>g(r=>({...kE(r,e),cell:null,open:!1,[ae(t)]:n})),W=()=>g(e=>({...e,cell:null,open:!1})),G=e=>{if(!A||e.metaKey||e.ctrlKey||e.altKey)return!1;let t=N?.agent?sE(N.agent):[],n=I?t.indexOf(I):-1;if(e.key===`ArrowRight`&&N&&t.length)g(e=>({...kE(e,N.name),cell:t[Math.min(n+1,t.length-1)],open:!1}));else if(e.key===`ArrowLeft`&&I)g(e=>({...e,cell:n>0?t[n-1]:null,open:!1}));else if((e.key===`ArrowDown`||e.key===`ArrowUp`)&&I)oe(I,e.key===`ArrowDown`?1:-1);else if(e.key===`ArrowDown`||e.key===`ArrowUp`)R((j+(e.key===`ArrowDown`?1:k.length-1))%k.length,!0);else if(e.key===`Enter`||e.key===`Tab`)ie(k[j]);else if(e.key===`Escape`&&L)W();else if(e.key===`Escape`&&I)g({cell:null});else if(e.key===`Escape`)y.current=c.at,l(null);else return!1;return e.preventDefault(),e.stopPropagation(),!0},ce=(e,t)=>{let n=e.agent,r=P(n),i=F(e.name),a=t===j;return(0,Q.jsx)(`span`,{className:`mention-tag-cells`,children:sE(n).map(o=>{let s=i[ae(o)],{words:c,set:l}=aE(n,o,r,s),u=a&&L===o;return(0,Q.jsxs)(`button`,{type:`button`,tabIndex:-1,id:`mention-${t}-${o}`,className:`mention-tag-cell${l?` is-set`:``}${a&&I===o&&!u?` is-focus`:``}`,"aria-label":uE(n,o,r,s),"aria-haspopup":`listbox`,"aria-expanded":u,onClick:n=>{n.stopPropagation(),se(e,t,o)},children:[(0,Q.jsx)(`span`,{className:`mention-tag-words`,children:c}),(0,Q.jsx)(`svg`,{className:`assignee-caret`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`m4.5 6.5 3.5 3.5 3.5-3.5`})})]},o)})})},le=()=>{if(!L||!N?.agent)return null;let{name:e,agent:t}=N;return(0,Q.jsx)(ME,{anchor:`mention-${j}-${L}`,name:cE(L),choices:oE(t,L,P(t)),value:F(e)[ae(L)],onPick:t=>H(e,L,t)})},ue=(e,t)=>(0,Q.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===j,className:`mention-option${t===j?` is-active`:``}${e.kind===`agent`&&ee?` has-tag`:``}`,onMouseEnter:z(t),onClick:()=>ie(e),children:[(0,Q.jsx)(ix,{actor:{kind:e.kind===`agent`?`agent`:`human`,name:e.name},title:e.name}),e.state&&(0,Q.jsx)(`span`,{className:`mention-state`,children:e.state}),e.kind===`agent`&&($T(e.agent)?ce(e,t):(0,Q.jsx)(`span`,{className:`mention-tag-note`,children:`its own model`}))]},`${e.kind}:${e.name}`),de=()=>{if(!V)return null;if(!N?.agent)return(0,Q.jsx)(`div`,{className:`mention-tag-foot`,"aria-live":`polite`,children:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`↵`}),`mention`]})});let e=!!(P(N.agent).model||P(N.agent).effort),t=F(N.name),n=!!(t.model||t.effort),r=!(!I||L);return(0,Q.jsxs)(`div`,{className:`mention-tag-foot`,"aria-live":`polite`,children:[r&&(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`↑`}),(0,Q.jsx)(`kbd`,{children:`↓`}),`change`]}),r||n?(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`↵`}),`writes `,(0,Q.jsx)(`code`,{children:lE(N.name,t)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`↵`}),`mention`,e?`, on its rule`:``]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`→`}),`model and thinking`]})]})]})},fe=(e,t)=>{let n=u.find(t=>t.name===e.agent),r=t===0||k[t-1].agent!==e.agent;return(0,Q.jsxs)(`div`,{children:[r&&(0,Q.jsxs)(`div`,{className:`mention-menu-head skill-head${n.present?``:` is-away`}`,children:[(0,Q.jsx)(`span`,{className:`skill-agent`,children:e.agent}),(0,Q.jsx)(`span`,{className:`skill-agent-note`,children:AE(n)})]}),(0,Q.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===j,className:`mention-option skill-option${t===j?` is-active`:``}${e.present?``:` is-away`}`,onMouseEnter:()=>v(t),onClick:()=>ie(e),children:[(0,Q.jsxs)(`span`,{className:`skill-name`,title:e.call===e.name?void 0:`Called as /${e.call}, as ${e.agent} has its own /${e.name}`,children:[`/`,e.name,e.call!==e.name&&` (Tricot)`]}),(0,Q.jsx)(`span`,{className:`skill-desc`,children:e.description}),e.tricot&&(0,Q.jsx)(`span`,{className:`skill-tricot`,children:`Tricot skill`})]})]},`${e.agent}:${e.tricot?`tricot`:`own`}:${e.name}`)},pe=(e,t)=>{let{card:n}=e,{label:r}=n;return(0,Q.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===j,className:`mention-option hash-option${t===j?` is-active`:``}`,onMouseEnter:()=>v(t),onClick:()=>ie(e),title:`${r} · ${n.title} · ${n.status}`,children:[(0,Q.jsx)(`span`,{className:`hash-option-ref ${n.marker}`,children:r}),(0,Q.jsx)(`span`,{className:`hash-option-title`,children:n.title}),(0,Q.jsx)(`span`,{className:`mention-state`,children:n.status})]},r)},me=(e,t)=>{let{lens:n}=e;return(0,Q.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===j,className:`mention-option lens-option${t===j?` is-active`:``}`,onMouseEnter:()=>v(t),onClick:()=>ie(e),title:`${n.name}: ${n.brief}${n.current?` (the thread's lens now)`:``}`,children:[(0,Q.jsx)(`span`,{className:`lens-option-name ${n.tone}`,children:n.name}),(0,Q.jsx)(`span`,{className:`lens-option-brief`,children:n.brief}),n.current&&(0,Q.jsx)(`span`,{className:`lens-option-now`,"aria-label":`The thread's lens now`,children:(0,Q.jsx)($,{name:`check`})})]},n.name)},he=k.filter(e=>e.kind===`agent`||e.kind===`person`),ge=k.filter(e=>e.kind===`card`),_e=he.filter(e=>e.kind===`agent`),ve=he.filter(e=>e.kind===`person`),ye=A&&b?(0,Q.jsx)(`div`,{ref:S,className:`mention-menu${E?` skill-menu`:O?` hash-menu`:B?` lens-menu-list`:``}`,role:`listbox`,"aria-label":E?`Call a skill`:O?a?.name??`Link a card`:B?`Pick a lens for this message`:`Mention someone`,style:{left:b.left,top:b.top,bottom:b.bottom,width:te},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClickCapture:e=>{if(!h.open)return;let t=e.target.closest(`.mention-tag-cell`);t&&t.id.startsWith(`mention-${j}-`)||(e.stopPropagation(),W())},children:E?(0,Q.jsxs)(Q.Fragment,{children:[k.map((e,t)=>fe(e,t)),(0,Q.jsx)(`div`,{className:`skill-foot`,children:`A message that starts with a skill asks that agent to run it.`})]}):B?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mention-menu-head`,children:`Lens for this message`}),k.map((e,t)=>me(e,t)),(0,Q.jsx)(`div`,{className:`lens-foot`,children:r===QT?`Only this comment goes through it.`:`Only this message goes through it. The thread keeps its lens.`})]}):O?(0,Q.jsx)(Q.Fragment,{children:ge.map((e,t)=>(0,Q.jsxs)(d.Fragment,{children:[e.card.group&&e.card.group!==ge[t-1]?.card.group&&(0,Q.jsx)(`div`,{className:`mention-menu-head`,children:e.card.group}),pe(e,t)]},e.card.label))}):(0,Q.jsxs)(Q.Fragment,{children:[_e.length>0&&(0,Q.jsx)(`div`,{className:`mention-menu-head`,children:`Agents on this board`}),_e.map((e,t)=>ue(e,t)),ve.length>0&&(0,Q.jsx)(`div`,{className:`mention-menu-head`,children:`People`}),ve.map((e,t)=>ue(e,_e.length+t)),de()]})}):null,be=ye?(0,Qx.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[ye,le()]}),document.body):null,K=(0,d.useMemo)(()=>{let t=xc(e,re,ne).map(e=>[e.start,e.end]);for(let n of UT(e,C))t.push([n.start,n.end,r?.find(e=>e.name===n.name)?.tone]);if(n&&u.length){let n=JT(e,u.map(e=>({agent:e.name,skills:e.skills,reportedAt:e.reportedAt??``})),re);n&&t.push([n.start,n.end])}return A&&c&&c.trigger!==`/`&&!t.some(([e])=>e===c.at)&&t.push([c.at,c.at+1+c.query.length]),t.sort((e,t)=>e[0]-t[0])},[e,re,ne,u,n,A,c,r,C]),xe=L&&N?.agent?oE(N.agent,L,P(N.agent)).findIndex(e=>e.value===F(N.name)[ae(L)]):-1,Se=xe>=0?`mention-${j}-${L}-${xe}`:`mention-${j}`;return{field:s,read:T,onKey:G,menu:be,marks:K,close:()=>l(null),aria:{"aria-autocomplete":`list`,"aria-expanded":A,"aria-activedescendant":A?Se:void 0}}}function ME({anchor:e,name:t,choices:n,value:r,onPick:i}){let a=(0,d.useRef)(null),[o,s]=(0,d.useState)(null);return(0,d.useLayoutEffect)(()=>{let t=document.getElementById(e)?.getBoundingClientRect(),n=a.current;if(!t||!n)return;let r=Math.max(8,Math.min(t.right-n.offsetWidth,window.innerWidth-n.offsetWidth-8)),i=t.bottom+4;s(i+n.offsetHeight<window.innerHeight-8?{left:r,top:i}:{left:r,bottom:window.innerHeight-t.top+4})},[e]),(0,Q.jsxs)(`div`,{ref:a,className:`mention-menu mention-tag-list`,role:`listbox`,"aria-label":t,style:{left:o?.left??-9999,top:o?.top,bottom:o?.bottom,visibility:o?void 0:`hidden`},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`mention-menu-head`,"aria-hidden":!0,children:t}),n.map((t,n)=>{let a=t.value===r;return(0,Q.jsxs)(`div`,{id:`${e}-${n}`,role:`option`,"aria-selected":a,className:`mention-tag-choice${a?` is-chosen`:``}`,onClick:()=>i(t.value),children:[(0,Q.jsx)(`span`,{className:`mention-tag-choice-words`,children:t.words}),t.note&&(0,Q.jsx)(`span`,{className:`mention-tag-choice-note`,children:t.note}),(0,Q.jsx)(`span`,{className:`mention-tag-check`,children:a&&(0,Q.jsx)($,{name:`check`})})]},t.value??``)})]})}var NE=[`padding-top`,`padding-right`,`padding-bottom`,`padding-left`,`border-top-width`,`border-right-width`,`border-bottom-width`,`border-left-width`,`border-radius`,`font-family`,`font-size`,`font-weight`,`font-style`,`line-height`,`letter-spacing`,`word-spacing`,`text-indent`,`tab-size`];function PE({value:e,marks:t,field:n}){let r=(0,d.useRef)(null);(0,d.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;let i=getComputedStyle(e);for(let e of NE)t.style.setProperty(e,i.getPropertyValue(e));t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft});let i=[],a=0;for(let[n,r,o]of t)n<a||(i.push(e.slice(a,n),(0,Q.jsx)(`mark`,{className:o?`lens-mark ${o}`:void 0,children:e.slice(n,r)},n)),a=r);return i.push(e.slice(a),`​`),(0,Q.jsx)(`span`,{ref:r,className:`mention-backdrop`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{children:i})})}var FE=e=>{let t=e.currentTarget.previousElementSibling;t&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)};function IE(e,t){return(0,d.useCallback)(n=>{e.current=n,typeof t==`function`?t(n):t&&(t.current=n)},[e,t])}function LE({value:e,onValue:t,onKeyDown:n,ref:r,rows:i,skills:a=!1,lenses:o,...s}){let c=jE(e,t,a,o),l=IE(c.field,r),u=c.marks.length>0;return(0,Q.jsxs)(`span`,{className:`mention-field${u?` has-marks`:``}`,children:[u&&(0,Q.jsx)(PE,{value:e,marks:c.marks,field:c.field}),(0,Q.jsx)(`textarea`,{...s,...c.aria,ref:l,rows:i,value:e,onChange:e=>{t(e.target.value),c.read()},onSelect:c.read,onBlur:c.close,onScroll:FE,onKeyDown:e=>c.onKey(e)||n?.(e)}),c.menu]})}function RE({value:e,onValue:t,onKeyDown:n,ref:r,skills:i=!1,lenses:a,...o}){let s=jE(e,t,i,a),c=IE(s.field,r),l=s.marks.length>0;return(0,Q.jsxs)(`span`,{className:`mention-field mention-line${l?` has-marks`:``}`,children:[l&&(0,Q.jsx)(PE,{value:e,marks:s.marks,field:s.field}),(0,Q.jsx)(`input`,{...o,...s.aria,ref:c,value:e,onChange:e=>{t(e.target.value),s.read()},onSelect:s.read,onBlur:s.close,onScroll:FE,onKeyDown:e=>s.onKey(e)||n?.(e)}),s.menu]})}var zE=2;function BE(e,t){return`threadId`in e?(t,n,r,i)=>X.reactInThread(e.threadId,t,n,r,i):`pinId`in e?(t,n,r,i)=>X.reactOnPin(e.pinId,t,n,r,i):t.reaction(e)}function VE({item:e,place:t,name:n}){let r=hu(),i=mx(),a={kind:`human`,name:n},o=e.author.kind===`human`&&U(e.author.name,n),s=BE(t,i),c=!r&&!o&&!!n&&!!s,[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(null),m=Ys(e.reactions),h=async t=>{if(!l&&c&&s){u(!0),p(null);try{await s(e.id,n,t,Gs(e,t,a))}catch(e){p(e.message)}finally{u(!1)}}};return m.length===0&&!c?null:(0,Q.jsxs)(`div`,{className:`reactions`,children:[m.map(({emoji:t,reactions:n})=>{let r=Gs(e,t,a),i=`${Hs[t]} from ${HE(n,n.length)}${r&&c?`. Yours: press to take it back`:``}`,o=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`reaction-emoji`,"aria-hidden":!0,children:t}),(0,Q.jsx)(`span`,{className:`reaction-names`,children:HE(n,zE)})]});return c?(0,Q.jsx)(`button`,{type:`button`,className:`reaction${r?` is-mine`:``}`,"aria-pressed":r,"aria-label":i,title:UE(t,n),disabled:l,onClick:()=>void h(t),children:o},t):(0,Q.jsx)(`span`,{className:`reaction${r?` is-mine`:``}`,role:`img`,"aria-label":i,title:UE(t,n),children:o},t)}),c&&(0,Q.jsx)(WE,{item:e,me:a,busy:l,onPick:e=>void h(e)}),f&&(0,Q.jsx)(`span`,{className:`reactions-error`,role:`alert`,children:f})]})}function HE(e,t){let n=e.map(e=>e.by.name),r=n.length-t;return r>0?`${n.slice(0,t).join(`, `)} +${r}`:n.join(`, `)}function UE(e,t){return[`${e} ${Hs[e]}`,...t.map(e=>`${e.by.name}, ${ex(e.at)}`)].join(`
55
+ `)}function WE({item:e,me:t,busy:n,onPick:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null),s=(0,d.useRef)(null),c=(0,d.useRef)(null),l=(0,d.useCallback)(e=>{a(!1),e&&s.current?.focus()},[]);return Zl(i,l,o),(0,d.useEffect)(()=>{i&&c.current?.querySelector(`button`)?.focus()},[i]),(0,Q.jsxs)(`span`,{className:`reaction-adder`,ref:o,children:[(0,Q.jsx)(`button`,{ref:s,type:`button`,className:`reaction-add`,"aria-label":`Add a reaction`,title:`Add a reaction`,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),children:(0,Q.jsx)($,{name:`react`})}),i&&(0,Q.jsx)(`div`,{className:`reaction-picker`,role:`menu`,"aria-label":`Reactions`,ref:c,onKeyDown:e=>{if(e.key===`Tab`)return e.preventDefault(),l(!0);let t=[...c.current?.querySelectorAll(`button`)??[]],n=cu(e.key,t.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),t[n]?.focus())},children:Vs.map(i=>{let a=Gs(e,i,t);return(0,Q.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":a,"aria-label":Hs[i],title:a?`${Hs[i]}: take yours back`:Hs[i],tabIndex:-1,disabled:n,onClick:()=>{r(i),l(!0)},children:i},i)})})]})}typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent);function GE(e){let t=fE();return[...t.agents.map(e=>e.name),...t.people,e]}var KE=`tricot:focus-pin`,qE=e=>`comment-${e}`;function JE(e,t=12){let n=e.flatMap(e=>document.getElementById(qE(e))??[]);if(n.length===0)t>0&&setTimeout(()=>JE(e,t-1),120);else{n[0].scrollIntoView({behavior:`smooth`,block:`center`});for(let e of n)e.classList.remove(`is-flash`),e.offsetWidth,e.classList.add(`is-flash`)}}function YE(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=YE(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var XE={value:()=>{}};function ZE(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new QE(n)}function QE(e){this._=e}function $E(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}QE.prototype=ZE.prototype={constructor:QE,on:function(e,t){var n=this._,r=$E(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=eD(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=tD(n[i],e.name,t);else if(t==null)for(i in n)n[i]=tD(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new QE(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function eD(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function tD(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=XE,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var nD={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function rD(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),nD.hasOwnProperty(t)?{space:nD[t],local:e}:e}function iD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function aD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function oD(e){var t=rD(e);return(t.local?aD:iD)(t)}function sD(){}function cD(e){return e==null?sD:function(){return this.querySelector(e)}}function lD(e){typeof e!=`function`&&(e=cD(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new ZO(r,this._parents)}function uD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function dD(){return[]}function fD(e){return e==null?dD:function(){return this.querySelectorAll(e)}}function pD(e){return function(){return uD(e.apply(this,arguments))}}function mD(e){e=typeof e==`function`?pD(e):fD(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new ZO(r,i)}function hD(e){return function(){return this.matches(e)}}function gD(e){return function(t){return t.matches(e)}}var _D=Array.prototype.find;function vD(e){return function(){return _D.call(this.children,e)}}function yD(){return this.firstElementChild}function bD(e){return this.select(e==null?yD:vD(typeof e==`function`?e:gD(e)))}var xD=Array.prototype.filter;function SD(){return Array.from(this.children)}function CD(e){return function(){return xD.call(this.children,e)}}function wD(e){return this.selectAll(e==null?SD:CD(typeof e==`function`?e:gD(e)))}function TD(e){typeof e!=`function`&&(e=hD(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new ZO(r,this._parents)}function ED(e){return Array(e.length)}function DD(){return new ZO(this._enter||this._groups.map(ED),this._parents)}function OD(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}OD.prototype={constructor:OD,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function kD(e){return function(){return e}}function AD(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new OD(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function jD(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new OD(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function MD(e){return e.__data__}function ND(e,t){if(!arguments.length)return Array.from(this,MD);var n=t?jD:AD,r=this._parents,i=this._groups;typeof e!=`function`&&(e=kD(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=PD(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new ZO(o,r),o._enter=s,o._exit=c,o}function PD(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function FD(){return new ZO(this._exit||this._groups.map(ED),this._parents)}function ID(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function LD(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new ZO(s,this._parents)}function RD(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function zD(e){e||=BD;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new ZO(i,this._parents).order()}function BD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function VD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function HD(){return Array.from(this)}function UD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function WD(){let e=0;for(let t of this)++e;return e}function GD(){return!this.node()}function KD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function qD(e){return function(){this.removeAttribute(e)}}function JD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function YD(e,t){return function(){this.setAttribute(e,t)}}function XD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ZD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function QD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function $D(e,t){var n=rD(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?JD:qD:typeof t==`function`?n.local?QD:ZD:n.local?XD:YD)(n,t))}function eO(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tO(e){return function(){this.style.removeProperty(e)}}function nO(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rO(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function iO(e,t,n){return arguments.length>1?this.each((t==null?tO:typeof t==`function`?rO:nO)(e,t,n??``)):aO(this.node(),e)}function aO(e,t){return e.style.getPropertyValue(t)||eO(e).getComputedStyle(e,null).getPropertyValue(t)}function oO(e){return function(){delete this[e]}}function sO(e,t){return function(){this[e]=t}}function cO(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function lO(e,t){return arguments.length>1?this.each((t==null?oO:typeof t==`function`?cO:sO)(e,t)):this.node()[e]}function uO(e){return e.trim().split(/^|\s+/)}function dO(e){return e.classList||new fO(e)}function fO(e){this._node=e,this._names=uO(e.getAttribute(`class`)||``)}fO.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function pO(e,t){for(var n=dO(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function mO(e,t){for(var n=dO(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function hO(e){return function(){pO(this,e)}}function gO(e){return function(){mO(this,e)}}function _O(e,t){return function(){(t.apply(this,arguments)?pO:mO)(this,e)}}function vO(e,t){var n=uO(e+``);if(arguments.length<2){for(var r=dO(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?_O:t?hO:gO)(n,t))}function yO(){this.textContent=``}function bO(e){return function(){this.textContent=e}}function xO(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function SO(e){return arguments.length?this.each(e==null?yO:(typeof e==`function`?xO:bO)(e)):this.node().textContent}function CO(){this.innerHTML=``}function wO(e){return function(){this.innerHTML=e}}function TO(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function EO(e){return arguments.length?this.each(e==null?CO:(typeof e==`function`?TO:wO)(e)):this.node().innerHTML}function DO(){this.nextSibling&&this.parentNode.appendChild(this)}function OO(){return this.each(DO)}function kO(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function AO(){return this.each(kO)}function jO(e){var t=typeof e==`function`?e:oD(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function MO(){return null}function NO(e,t){var n=typeof e==`function`?e:oD(e),r=t==null?MO:typeof t==`function`?t:cD(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function PO(){var e=this.parentNode;e&&e.removeChild(this)}function FO(){return this.each(PO)}function IO(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function LO(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RO(e){return this.select(e?LO:IO)}function zO(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function BO(e){return function(t){e.call(this,t,this.__data__)}}function VO(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function HO(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function UO(e,t,n){return function(){var r=this.__on,i,a=BO(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function WO(e,t,n){var r=VO(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}}else{for(s=t?UO:HO,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function GO(e,t,n){var r=eO(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function KO(e,t){return function(){return GO(this,e,t)}}function qO(e,t){return function(){return GO(this,e,t.apply(this,arguments))}}function JO(e,t){return this.each((typeof t==`function`?qO:KO)(e,t))}function*YO(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var XO=[null];function ZO(e,t){this._groups=e,this._parents=t}function QO(){return new ZO([[document.documentElement]],XO)}function $O(){return this}ZO.prototype=QO.prototype={constructor:ZO,select:lD,selectAll:mD,selectChild:bD,selectChildren:wD,filter:TD,data:ND,enter:DD,exit:FD,join:ID,merge:LD,selection:$O,order:RD,sort:zD,call:VD,nodes:HD,node:UD,size:WD,empty:GD,each:KD,attr:$D,style:iO,property:lO,classed:vO,text:SO,html:EO,raise:OO,lower:AO,append:jO,insert:NO,remove:FO,clone:RO,datum:zO,on:WO,dispatch:JO,[Symbol.iterator]:YO};function ek(e){return typeof e==`string`?new ZO([[document.querySelector(e)]],[document.documentElement]):new ZO([[e]],XO)}function tk(e){let t;for(;t=e.sourceEvent;)e=t;return e}function nk(e,t){if(e=tk(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var rk={passive:!1},ik={capture:!0,passive:!1};function ak(e){e.stopImmediatePropagation()}function ok(e){e.preventDefault(),e.stopImmediatePropagation()}function sk(e){var t=e.document.documentElement,n=ek(e).on(`dragstart.drag`,ok,ik);`onselectstart`in t?n.on(`selectstart.drag`,ok,ik):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function ck(e,t){var n=e.document.documentElement,r=ek(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,ok,ik),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var lk=e=>()=>e;function uk(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}uk.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function dk(e){return!e.ctrlKey&&!e.button}function fk(){return this.parentNode}function pk(e,t){return t??{x:e.x,y:e.y}}function mk(){return navigator.maxTouchPoints||`ontouchstart`in this}function hk(){var e=dk,t=fk,n=pk,r=mk,i={},a=ZE(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,rk).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(ek(n.view).on(`mousemove.drag`,m,ik).on(`mouseup.drag`,h,ik),sk(n.view),ak(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(ok(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){ek(e.view).on(`mousemove.drag mouseup.drag`,null),ck(e.view,l),ok(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(ak(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(ok(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(ak(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=nk(l||r,t),p,m,h;if((h=n.call(e,new uk(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=nk(l||a,t),_=o}u.call(r,e,new uk(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:lk(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:lk(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:lk(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:lk(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function gk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _k(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vk(){}var yk=.7,bk=1/yk,xk=`\\s*([+-]?\\d+)\\s*`,Sk=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Ck=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,wk=/^#([0-9a-f]{3,8})$/,Tk=RegExp(`^rgb\\(${xk},${xk},${xk}\\)$`),Ek=RegExp(`^rgb\\(${Ck},${Ck},${Ck}\\)$`),Dk=RegExp(`^rgba\\(${xk},${xk},${xk},${Sk}\\)$`),Ok=RegExp(`^rgba\\(${Ck},${Ck},${Ck},${Sk}\\)$`),kk=RegExp(`^hsl\\(${Sk},${Ck},${Ck}\\)$`),Ak=RegExp(`^hsla\\(${Sk},${Ck},${Ck},${Sk}\\)$`),jk={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};gk(vk,Ik,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mk,formatHex:Mk,formatHex8:Nk,formatHsl:Pk,formatRgb:Fk,toString:Fk});function Mk(){return this.rgb().formatHex()}function Nk(){return this.rgb().formatHex8()}function Pk(){return Yk(this).formatHsl()}function Fk(){return this.rgb().formatRgb()}function Ik(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=wk.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Lk(t):n===3?new Vk(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Rk(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Rk(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Tk.exec(e))?new Vk(t[1],t[2],t[3],1):(t=Ek.exec(e))?new Vk(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Dk.exec(e))?Rk(t[1],t[2],t[3],t[4]):(t=Ok.exec(e))?Rk(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kk.exec(e))?Jk(t[1],t[2]/100,t[3]/100,1):(t=Ak.exec(e))?Jk(t[1],t[2]/100,t[3]/100,t[4]):jk.hasOwnProperty(e)?Lk(jk[e]):e===`transparent`?new Vk(NaN,NaN,NaN,0):null}function Lk(e){return new Vk(e>>16&255,e>>8&255,e&255,1)}function Rk(e,t,n,r){return r<=0&&(e=t=n=NaN),new Vk(e,t,n,r)}function zk(e){return e instanceof vk||(e=Ik(e)),e?(e=e.rgb(),new Vk(e.r,e.g,e.b,e.opacity)):new Vk}function Bk(e,t,n,r){return arguments.length===1?zk(e):new Vk(e,t,n,r??1)}function Vk(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gk(Vk,Bk,_k(vk,{brighter(e){return e=e==null?bk:bk**+e,new Vk(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yk:yk**+e,new Vk(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Vk(Kk(this.r),Kk(this.g),Kk(this.b),Gk(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hk,formatHex:Hk,formatHex8:Uk,formatRgb:Wk,toString:Wk}));function Hk(){return`#${qk(this.r)}${qk(this.g)}${qk(this.b)}`}function Uk(){return`#${qk(this.r)}${qk(this.g)}${qk(this.b)}${qk((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wk(){let e=Gk(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Kk(this.r)}, ${Kk(this.g)}, ${Kk(this.b)}${e===1?`)`:`, ${e})`}`}function Gk(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qk(e){return e=Kk(e),(e<16?`0`:``)+e.toString(16)}function Jk(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Zk(e,t,n,r)}function Yk(e){if(e instanceof Zk)return new Zk(e.h,e.s,e.l,e.opacity);if(e instanceof vk||(e=Ik(e)),!e)return new Zk;if(e instanceof Zk)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Zk(o,s,c,e.opacity)}function Xk(e,t,n,r){return arguments.length===1?Yk(e):new Zk(e,t,n,r??1)}function Zk(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gk(Zk,Xk,_k(vk,{brighter(e){return e=e==null?bk:bk**+e,new Zk(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yk:yk**+e,new Zk(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Vk(eA(e>=240?e-240:e+120,i,r),eA(e,i,r),eA(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Zk(Qk(this.h),$k(this.s),$k(this.l),Gk(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Gk(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Qk(this.h)}, ${$k(this.s)*100}%, ${$k(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Qk(e){return e=(e||0)%360,e<0?e+360:e}function $k(e){return Math.max(0,Math.min(1,e||0))}function eA(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var tA=e=>()=>e;function nA(e,t){return function(n){return e+n*t}}function rA(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function iA(e,t){var n=t-e;return n?nA(e,n>180||n<-180?n-360*Math.round(n/360):n):tA(isNaN(e)?t:e)}function aA(e){return(e=+e)==1?oA:function(t,n){return n-t?rA(t,n,e):tA(isNaN(t)?n:t)}}function oA(e,t){var n=t-e;return n?nA(e,n):tA(isNaN(e)?t:e)}var sA=(function e(t){var n=aA(t);function r(e,t){var r=n((e=Bk(e)).r,(t=Bk(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=oA(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function cA(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function lA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function uA(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=yA(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function dA(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function fA(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function pA(e,t){var n={},r={},i;for(i in typeof e==`object`&&e||(e={}),typeof t==`object`&&t||(t={}),t)i in e?n[i]=yA(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var mA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,hA=new RegExp(mA.source,`g`);function gA(e){return function(){return e}}function _A(e){return function(t){return e(t)+``}}function vA(e,t){var n=mA.lastIndex=hA.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=mA.exec(e))&&(i=hA.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:fA(r,i)})),n=hA.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?_A(c[0].x):gA(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function yA(e,t){var n=typeof t,r;return t==null||n===`boolean`?tA(t):(n===`number`?fA:n===`string`?(r=Ik(t))?(t=r,sA):vA:t instanceof Ik?sA:t instanceof Date?dA:lA(t)?cA:Array.isArray(t)?uA:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?pA:fA)(e,t)}var bA=180/Math.PI,xA={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function SA(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*bA,skewX:Math.atan(c)*bA,scaleX:o,scaleY:s}}var CA;function wA(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?xA:SA(t.a,t.b,t.c,t.d,t.e,t.f)}function TA(e){return e==null||(CA||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),CA.setAttribute(`transform`,e),!(e=CA.transform.baseVal.consolidate()))?xA:(e=e.matrix,SA(e.a,e.b,e.c,e.d,e.e,e.f))}function EA(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:fA(e,i)},{i:c-2,x:fA(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:fA(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:fA(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:fA(e,n)},{i:s-2,x:fA(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var DA=EA(wA,`px, `,`px)`,`deg)`),OA=EA(TA,`, `,`)`,`)`),kA=1e-12;function AA(e){return((e=Math.exp(e))+1/e)/2}function jA(e){return((e=Math.exp(e))-1/e)/2}function MA(e){return((e=Math.exp(2*e))-1)/(e+1)}var NA=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<kA)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=AA(y),c=s/(n*g)*(i*MA(t*r+y)-jA(y));return[a+c*d,o+c*f,s*i/AA(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),PA=0,FA=0,IA=0,LA=1e3,RA,zA,BA=0,VA=0,HA=0,UA=typeof performance==`object`&&performance.now?performance:Date,WA=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function GA(){return VA||=(WA(KA),UA.now()+HA)}function KA(){VA=0}function qA(){this._call=this._time=this._next=null}qA.prototype=JA.prototype={constructor:qA,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?GA():+n)+(t==null?0:+t),!this._next&&zA!==this&&(zA?zA._next=this:RA=this,zA=this),this._call=e,this._time=n,$A()},stop:function(){this._call&&(this._call=null,this._time=1/0,$A())}};function JA(e,t,n){var r=new qA;return r.restart(e,t,n),r}function YA(){GA(),++PA;for(var e=RA,t;e;)(t=VA-e._time)>=0&&e._call.call(void 0,t),e=e._next;--PA}function XA(){VA=(BA=UA.now())+HA,PA=FA=0;try{YA()}finally{PA=0,QA(),VA=0}}function ZA(){var e=UA.now(),t=e-BA;t>LA&&(HA-=t,BA=e)}function QA(){for(var e,t=RA,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:RA=n);zA=e,$A(r)}function $A(e){PA||(FA&&=clearTimeout(FA),e-VA>24?(e<1/0&&(FA=setTimeout(XA,e-UA.now()-HA)),IA&&=clearInterval(IA)):(IA||=(BA=UA.now(),setInterval(ZA,LA)),PA=1,WA(XA)))}function ej(e,t,n){var r=new qA;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var tj=ZE(`start`,`end`,`cancel`,`interrupt`),nj=[];function rj(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;sj(e,n,{name:t,index:r,group:i,on:tj,tween:nj,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ij(e,t){var n=oj(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function aj(e,t){var n=oj(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function oj(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function sj(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=JA(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return ej(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(ej(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function cj(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n)(r=n[o]).name===t?(i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]):a=!1;a&&delete e.__transition}}function lj(e){return this.each(function(){cj(this,e)})}function uj(e,t){var n,r;return function(){var i=aj(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function dj(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=aj(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function fj(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=oj(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?uj:dj)(n,e,t))}function pj(e,t,n){var r=e._id;return e.each(function(){var e=aj(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return oj(e,r).value[t]}}function mj(e,t){var n;return(typeof t==`number`?fA:t instanceof Ik?sA:(n=Ik(t))?(t=n,sA):vA)(e,t)}function hj(e){return function(){this.removeAttribute(e)}}function gj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _j(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function vj(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function yj(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function bj(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function xj(e,t){var n=rD(e),r=n===`transform`?OA:mj;return this.attrTween(e,typeof t==`function`?(n.local?bj:yj)(n,r,pj(this,`attr.`+e,t)):t==null?(n.local?gj:hj)(n):(n.local?vj:_j)(n,r,t))}function Sj(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Cj(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function wj(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Cj(e,i)),n}return i._value=t,i}function Tj(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Sj(e,i)),n}return i._value=t,i}function Ej(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=rD(e);return this.tween(n,(r.local?wj:Tj)(r,t))}function Dj(e,t){return function(){ij(this,e).delay=+t.apply(this,arguments)}}function Oj(e,t){return t=+t,function(){ij(this,e).delay=t}}function kj(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Dj:Oj)(t,e)):oj(this.node(),t).delay}function Aj(e,t){return function(){aj(this,e).duration=+t.apply(this,arguments)}}function jj(e,t){return t=+t,function(){aj(this,e).duration=t}}function Mj(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Aj:jj)(t,e)):oj(this.node(),t).duration}function Nj(e,t){if(typeof t!=`function`)throw Error();return function(){aj(this,e).ease=t}}function Pj(e){var t=this._id;return arguments.length?this.each(Nj(t,e)):oj(this.node(),t).ease}function Fj(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();aj(this,e).ease=n}}function Ij(e){if(typeof e!=`function`)throw Error();return this.each(Fj(this._id,e))}function Lj(e){typeof e!=`function`&&(e=hD(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new fM(r,this._parents,this._name,this._id)}function Rj(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new fM(o,this._parents,this._name,this._id)}function zj(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Bj(e,t,n){var r,i,a=zj(t)?ij:aj;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Vj(e,t){var n=this._id;return arguments.length<2?oj(this.node(),n).on.on(e):this.each(Bj(n,e,t))}function Hj(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Uj(){return this.on(`end.remove`,Hj(this._id))}function Wj(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=cD(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,rj(l[f],t,n,f,l,oj(u,n)));return new fM(a,this._parents,t,n)}function Gj(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=fD(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=oj(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&rj(p,t,n,h,f,m);a.push(f),o.push(u)}return new fM(a,o,t,n)}var Kj=QO.prototype.constructor;function qj(){return new Kj(this._groups,this._parents)}function Jj(e,t){var n,r,i;return function(){var a=aO(this,e),o=(this.style.removeProperty(e),aO(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Yj(e){return function(){this.style.removeProperty(e)}}function Xj(e,t,n){var r,i=n+``,a;return function(){var o=aO(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Zj(e,t,n){var r,i,a;return function(){var o=aO(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),aO(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Qj(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=aj(this,e),l=c.on,u=c.value[a]==null?s||=Yj(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function $j(e,t,n){var r=(e+=``)==`transform`?DA:mj;return t==null?this.styleTween(e,Jj(e,r)).on(`end.style.`+e,Yj(e)):typeof t==`function`?this.styleTween(e,Zj(e,r,pj(this,`style.`+e,t))).each(Qj(this._id,e)):this.styleTween(e,Xj(e,r,t),n).on(`end.style.`+e,null)}function eM(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function tM(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&eM(e,a,n)),r}return a._value=t,a}function nM(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,tM(e,t,n??``))}function rM(e){return function(){this.textContent=e}}function iM(e){return function(){var t=e(this);this.textContent=t??``}}function aM(e){return this.tween(`text`,typeof e==`function`?iM(pj(this,`text`,e)):rM(e==null?``:e+``))}function oM(e){return function(t){this.textContent=e.call(this,t)}}function sM(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&oM(r)),t}return r._value=e,r}function cM(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,sM(e))}function lM(){for(var e=this._name,t=this._id,n=pM(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=oj(c,t);rj(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new fM(r,this._parents,e,n)}function uM(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=aj(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var dM=0;function fM(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function pM(){return++dM}var mM=QO.prototype;fM.prototype={constructor:fM,select:Wj,selectAll:Gj,selectChild:mM.selectChild,selectChildren:mM.selectChildren,filter:Lj,merge:Rj,selection:qj,transition:lM,call:mM.call,nodes:mM.nodes,node:mM.node,size:mM.size,empty:mM.empty,each:mM.each,on:Vj,attr:xj,attrTween:Ej,style:$j,styleTween:nM,text:aM,textTween:cM,remove:Uj,tween:fj,delay:kj,duration:Mj,ease:Pj,easeVarying:Ij,end:uM,[Symbol.iterator]:mM[Symbol.iterator]};function hM(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var gM={time:null,delay:0,duration:250,ease:hM};function _M(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function vM(e){var t,n;e instanceof fM?(t=e._id,e=e._name):(t=pM(),(n=gM).time=GA(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&rj(c,e,t,l,o,n||_M(c,t));return new fM(r,this._parents,e,t)}QO.prototype.interrupt=lj,QO.prototype.transition=vM;var yM=e=>()=>e;function bM(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function xM(e,t,n){this.k=e,this.x=t,this.y=n}xM.prototype={constructor:xM,scale:function(e){return e===1?this:new xM(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xM(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var SM=new xM(1,0,0);CM.prototype=xM.prototype;function CM(e){for(;!e.__zoom;)if(!(e=e.parentNode))return SM;return e.__zoom}function wM(e){e.stopImmediatePropagation()}function TM(e){e.preventDefault(),e.stopImmediatePropagation()}function EM(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function DM(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function OM(){return this.__zoom||SM}function kM(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function AM(){return navigator.maxTouchPoints||`ontouchstart`in this}function jM(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function MM(){var e=EM,t=DM,n=jM,r=kM,i=AM,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=NA,l=ZE(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,OM).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,OM),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(SM.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new xM(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new xM(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new xM(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=ek(this.that).datum();l.call(e,this.that,new bM(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=nk(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],cj(this),s.start();TM(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=ek(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=nk(t,i),l=t.clientX,u=t.clientY;sk(t.view),wM(t),a.mouse=[c,this.__zoom.invert(c)],cj(this),a.start();function d(e){if(TM(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=nk(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),ck(e.view,a.moved),TM(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=nk(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);TM(r),s>0?ek(this).transition().duration(s).call(x,d,c,r):ek(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(wM(t),s=0;s<i;++s)c=r[s],l=nk(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),cj(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(TM(e),s=0;s<a;++s)c=i[s],l=nk(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(wM(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=nk(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=ek(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:yM(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:yM(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:yM(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:yM([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var NM={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},PM=[[-1/0,-1/0],[1/0,1/0]],FM=[`Enter`,` `,`Escape`],IM={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},LM;(function(e){e.Strict=`strict`,e.Loose=`loose`})(LM||={});var RM;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(RM||={});var zM;(function(e){e.Partial=`partial`,e.Full=`full`})(zM||={});var BM={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},VM;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(VM||={});var HM;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(HM||={});var UM;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(UM||={});var WM={[UM.Left]:UM.Right,[UM.Right]:UM.Left,[UM.Top]:UM.Bottom,[UM.Bottom]:UM.Top},GM=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,KM=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),qM=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),JM=(e,t=[0,0])=>{let{width:n,height:r}=ON(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},YM=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):qM(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,cN(e,fN(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?uN(r):{x:0,y:0,width:0,height:0}},XM=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=cN(n,fN(e)),r=!0)}),r?uN(n):{x:0,y:0,width:0,height:0}},ZM=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=mN(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},QM=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function $M(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=ON(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function eN({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=TN(XM($M(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function tN({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,NM.error005());else{let{width:e,height:t}=ON(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&DN(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=DN(d)?iN(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,NM.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function nN({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=QM(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var rN=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),iN=(e={x:0,y:0},t,n)=>({x:rN(e.x,t[0][0],t[1][0]-(n?.width??0)),y:rN(e.y,t[0][1],t[1][1]-(n?.height??0))});function aN(e,t,n){let{width:r,height:i}=ON(n),{x:a,y:o}=n.internals.positionAbsolute;return iN(e,[[a,o],[a+r,o+i]],t)}var oN=(e,t,n)=>e<t?rN(Math.abs(e-t),1,t)/t:e>n?-rN(Math.abs(e-n),1,t)/t:0,sN=(e,t,n=15,r=40)=>[oN(e.x,r,t.width-r)*n,oN(e.y,r,t.height-r)*n],cN=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),lN=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),uN=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),dN=(e,t=[0,0])=>{let{x:n,y:r}=qM(e)?e.internals.positionAbsolute:JM(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},fN=(e,t=[0,0])=>{let{x:n,y:r}=qM(e)?e.internals.positionAbsolute:JM(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pN=(e,t)=>uN(cN(lN(e),lN(t))),mN=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},hN=(e,t)=>mN(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),gN=e=>_N(e.width)&&_N(e.height)&&_N(e.x)&&_N(e.y),_N=e=>!isNaN(e)&&isFinite(e),vN=(e,t)=>(e,t)=>{},yN=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bN=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?yN(s,o):s},xN=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function SN(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function CN(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=SN(e,n),i=SN(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=SN(e.top??e.y??0,n),i=SN(e.bottom??e.y??0,n),a=SN(e.left??e.x??0,t),o=SN(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function wN(e,t,n,r,i,a){let{x:o,y:s}=xN(e,[t,n,r]),{x:c,y:l}=xN({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var TN=(e,t,n,r,i,a)=>{let o=CN(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=rN(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=wN(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},EN=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function DN(e){return e!=null&&e!==`parent`}function ON(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function kN(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function AN(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function jN(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function MN(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function NN(e){return{...IM,...e||{}}}function PN(e){return e===null?null:e?`valid`:`invalid`}function FN(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=VN(e),s=bN({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?yN(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var IN=e=>({width:e.offsetWidth,height:e.offsetHeight}),LN=e=>e?.getRootNode?.()||window?.document,RN=[`INPUT`,`SELECT`,`TEXTAREA`];function zN(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?RN.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var BN=e=>`clientX`in e,VN=(e,t)=>{let n=BN(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},HN=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...IN(t)}})};function UN({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function WN(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function GN({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case UM.Left:return[t-WN(t-r,a),n];case UM.Right:return[t+WN(r-t,a),n];case UM.Top:return[t,n-WN(n-i,a)];case UM.Bottom:return[t,n+WN(i-n,a)]}}function KN({sourceX:e,sourceY:t,sourcePosition:n=UM.Bottom,targetX:r,targetY:i,targetPosition:a=UM.Top,curvature:o=.25}){let[s,c]=GN({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=GN({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=UN({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function qN({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function JN({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function YN({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=cN(fN(e),fN(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),hN({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},uN(a))>0}var XN=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ZN=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),QN=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,NM.error006()),t;let r=n.getEdgeId||XN,i;return i=GM(e)?{...e}:{...e,id:r(e)},ZN(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function $N({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=qN({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var eP={[UM.Left]:{x:-1,y:0},[UM.Right]:{x:1,y:0},[UM.Top]:{x:0,y:-1},[UM.Bottom]:{x:0,y:1}},tP=({source:e,sourcePosition:t=UM.Bottom,target:n})=>t===UM.Left||t===UM.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nP=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function rP({source:e,sourcePosition:t=UM.Bottom,target:n,targetPosition:r=UM.Top,center:i,offset:a,stepPosition:o}){let s=eP[t],c=eP[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=tP({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=qN({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function iP(e,t,n,r){let i=Math.min(nP(e,t)/2,nP(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function aP({sourceX:e,sourceY:t,sourcePosition:n=UM.Bottom,targetX:r,targetY:i,targetPosition:a=UM.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=rP({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=iP(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function oP(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function sP(e){let{sourceNode:t,targetNode:n}=e;if(!oP(t)||!oP(n))return null;let r=t.internals.handleBounds||cP(t.handles),i=n.internals.handleBounds||cP(n.handles),a=uP(r?.source??[],e.sourceHandle),o=uP(e.connectionMode===LM.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,NM.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||UM.Bottom,c=o?.position||UM.Top,l=lP(t,a,s),u=lP(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function cP(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function lP(e,t,n=UM.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??ON(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case UM.Top:return{x:i+o/2,y:a};case UM.Right:return{x:i+o,y:a+s/2};case UM.Bottom:return{x:i+o/2,y:a+s};case UM.Left:return{x:i,y:a+s/2}}}function uP(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function dP(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function fP(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=dP(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}function pP(e,t,n,r,i){let a=.5;i===`start`?a=0:i===`end`&&(a=1);let o=[(e.x+e.width*a)*t.zoom+t.x,e.y*t.zoom+t.y-r],s=[-100*a,-100];switch(n){case UM.Right:o=[(e.x+e.width)*t.zoom+t.x+r,(e.y+e.height*a)*t.zoom+t.y],s=[0,-100*a];break;case UM.Bottom:o[1]=(e.y+e.height)*t.zoom+t.y+r,s[1]=0;break;case UM.Left:o=[e.x*t.zoom+t.x-r,(e.y+e.height*a)*t.zoom+t.y],s=[-100,-100*a]}return`translate(${o[0]}px, ${o[1]}px) translate(${s[0]}%, ${s[1]}%)`}var mP=1e3,hP=10,gP={nodeOrigin:[0,0],nodeExtent:PM,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},_P={...gP,checkEquality:!0};function vP(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function yP(e,t,n){let r=vP(gP,n);for(let n of e.values())if(n.parentId)wP(n,e,t,r);else{let e=iN(JM(n,r.nodeOrigin),DN(n.extent)?n.extent:r.nodeExtent,ON(n));n.internals.positionAbsolute=e}}function bP(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function xP(e){return e===`manual`}function SP(e,t,n,r={}){let i=vP(_P,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!xP(i.zIndexMode)?mP:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=iN(JM(u,i.nodeOrigin),DN(u.extent)?u.extent:i.nodeExtent,ON(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:bP(u,e),z:TP(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}e.measured!==void 0&&e.measured.width!==void 0&&e.measured.height!==void 0||e.hidden||(c=!1),u.parentId&&wP(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function CP(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wP(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=vP(gP,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}CP(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*hP),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=EP(e,u,o,s,a&&!xP(c)?mP:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function TP(e,t,n){let r=_N(e.zIndex)?e.zIndex:0;return xP(n)?r:r+(e.selected?t:0)}function EP(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ON(e),l=JM(e,n),u=DN(e.extent)?iN(l,e.extent,c):l,d=iN({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=aN(d,c,t));let f=TP(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function DP(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=pN(a.get(n.parentId)?.expandedRect??dN(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ON(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function OP(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=IN(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=DN(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=aN(h,s,n))}else m&&(h=iN(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:HN(`source`,r.nodeElement,p,d,e.id),target:HN(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&wP(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:dN(g,i)}))}}if(f.length>0){let e=DP(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function kP({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function AP(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function jP(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;AP(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),AP(`target`,s,c,e,i,o),t.set(r.id,r)}}function MP(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:MP(n,t):!1}function NP(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function PP(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!MP(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function FP({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function IP({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=yN(a,t);return{x:o.x-a.x,y:o.y-a.y}}function LP({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=ek(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?lN(XM(s)):null,x=v&&l?IP({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:yN(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=tN({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=FP({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=sN(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,m&&y||o||!b||i.get(b)?.selected||_(),y&&m&&b&&e?.(b);let v=FN(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=PP(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=FP({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=hk().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=FN(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=VN(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=FN(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=VN(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=VN(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=FP({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!NP(t,`.${g}`,v))&&(!_||NP(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function RP(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())hN(i,dN(e))>0&&r.push(e);return r}var zP=250;function BP(e,t,n,r){let i=[],a=1/0,o=RP(e,n,t+zP);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=lP(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function VP(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...lP(o,c,c.position,!0)}:c}function HP(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function UP(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var WP=()=>!0;function GP(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=WP,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=LN(e.target),E=0,D,{x:O,y:k}=VN(e),A=HP(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=VP(i,A,r,c,t);if(!N)return;let P=VN(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=sN(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},ee=c.get(i),V={inProgress:!0,isValid:null,from:lP(ee,B,UM.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:ee,to:P,toHandle:null,toPosition:WM[B.position],toNode:null,pointer:P};function te(){M=!0,y(V),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function ne(e){if(!M){let{x:t,y:n}=VN(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){re(e);return}let a=b();P=VN(e,j),D=BP(bN(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=KP(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=UP(!!D,s.isValid);let u=c.get(i),f=u?lP(u,B,UM.Left,!0):V.from,p={...V,from:f,isValid:L,to:s.toHandle&&L?xN({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:WM[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),V=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=V,r={...n,toPosition:V.toHandle?V.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function KP(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=WP,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=VN(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=HP(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===LM.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=VP(t,e,a,u,n,!0)}return _}var qP={onPointerDown:GP,isValid:KP};function JP({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=ek(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&EN()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=MM().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:nk}}var YP=e=>({x:e.x,y:e.y,zoom:e.k}),XP=({x:e,y:t,zoom:n})=>SM.translate(e,t).scale(n),ZP=(e,t)=>e.target.closest(`.${t}`),QP=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$P=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,eF=(e,t=0,n=$P,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},tF=e=>{let t=e.ctrlKey&&EN()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nF({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(ZP(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=nk(u),t=d*2**tF(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===RM.Vertical?0:u.deltaX*f,m=i===RM.Horizontal?0:u.deltaY*f;!EN()&&u.shiftKey&&i!==RM.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=YP(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function rF({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=ZP(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function iF({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=YP(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function aF({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&QP(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,YP(a.transform))}}function oF({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&QP(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=YP(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function sF({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(ZP(f,`${u}-flow__node`)||ZP(f,`${u}-flow__edge`)||ZP(f,`${u}-flow__selection`)||ZP(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||ZP(f,c)&&h||ZP(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function cF({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=MM().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=ek(e).call(f);y({x:i.x,y:i.y,zoom:rN(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(tF);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yA:NA).transform(eF(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!_N(D)||D<0?0:D);let A=k?nF({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):rF({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=iF({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=aF({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=oF({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=sF({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=XP(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=XP(e);return await g(n,t),n}function x(e){if(p){let t=XP(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?CM(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yA:NA).scaleTo(eF(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?yA:NA).scaleBy(eF(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!_N(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var lF;(function(e){e.Line=`line`,e.Handle=`handle`})(lF||={});var uF=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],dF=[`top`,`right`,`bottom`,`left`];function fF({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function pF(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function mF(e,t){return Math.max(0,t-e)}function hF(e,t){return Math.max(0,e-t)}function gF(e,t,n){return Math.max(0,t-e,e-n)}function _F(e,t){return e?!t:t}function vF(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=gF(E,h,g),j=gF(D,_,v);if(o){let e=0,t=0;c&&w<0?e=mF(y+w+O,o[0][0]):!c&&w>0&&(e=hF(y+E+O,o[1][0])),l&&T<0?t=mF(b+T+k,o[0][1]):!l&&T>0&&(t=hF(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=hF(y+w,s[0][0]):!c&&w<0&&(e=mF(y+E,s[1][0])),l&&T>0?t=hF(b+T,s[0][1]):!l&&T<0&&(t=mF(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=gF(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?hF(b+k+E/C,o[1][1])*C:mF(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?mF(b+E/C,s[1][1])*C:hF(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=gF(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?hF(y+D*C+O,o[1][0])/C:mF(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?mF(y+D*C,s[1][0])/C:hF(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(_F(c,l)?-w:w)/C:w=(_F(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var yF={width:0,height:0,x:0,y:0},bF={...yF,pointerX:0,pointerY:0,aspectRatio:1};function xF(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function SF({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=ek(e),o={controlDirection:pF(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...yF},h={...bF};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:pF(e)};let g,_=null,v=[],y,b,x,S=hk().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=FN(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=DN(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=xF(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=FN(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=vF(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=fF({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,I),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var CF=n((e=>{var t=i();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),wF=n(((e,t)=>{t.exports=CF()})),TF=n((e=>{var t=i(),n=wF();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),EF=t(n(((e,t)=>{t.exports=TF()}))(),1),DF=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},o=t=e(r,i,a);return a},OF=e=>e?DF(e):DF,{useDebugValue:kF}=d.default,{useSyncExternalStoreWithSelector:AF}=EF.default,jF=e=>e;function MF(e,t=jF,n){let r=AF(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return kF(r),r}var NF=(e,t)=>{let n=OF(e),r=(e,r=t)=>MF(n,e,r);return Object.assign(r,n),r},PF=(e,t)=>e?NF(e,t):NF;function FF(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var IF=(0,d.createContext)(null),LF=IF.Provider,RF=NM.error001(`react`);function zF(e,t){let n=(0,d.useContext)(IF);if(n===null)throw Error(RF);return MF(n,e,t)}function BF(){let e=(0,d.useContext)(IF);if(e===null)throw Error(RF);return(0,d.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var VF={display:`none`},HF={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},UF=`react-flow__node-desc`,WF=`react-flow__edge-desc`,GF=`react-flow__aria-live`,KF=e=>e.ariaLiveMessage,qF=e=>e.ariaLabelConfig;function JF({rfId:e}){let t=zF(KF);return(0,Q.jsx)(`div`,{id:`${GF}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:HF,children:t})}function YF({rfId:e,disableKeyboardA11y:t}){let n=zF(qF);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{id:`${UF}-${e}`,style:VF,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,Q.jsx)(`div`,{id:`${WF}-${e}`,style:VF,children:n[`edge.a11yDescription.default`]}),!t&&(0,Q.jsx)(JF,{rfId:e})]})}var XF=(0,d.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,Q.jsx)(`div`,{className:YE([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});XF.displayName=`Panel`;var ZF=`https://reactflow.dev?utm_source=attribution`;function QF({proOptions:e,position:t=`bottom-right`}){return(0,d.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,Q.jsx)(XF,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${ZF}`,children:(0,Q.jsx)(`a`,{href:ZF,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var $F=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},eI=e=>e.id;function tI(e,t){return FF(e.selectedNodes.map(eI),t.selectedNodes.map(eI))&&FF(e.selectedEdges.map(eI),t.selectedEdges.map(eI))}function nI({onSelectionChange:e}){let t=BF(),{selectedNodes:n,selectedEdges:r}=zF($F,tI);return(0,d.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var rI=e=>!!e.onSelectionChangeHandlers;function iI({onSelectionChange:e}){let t=zF(rI);return e||t?(0,Q.jsx)(nI,{onSelectionChange:e}):null}var aI=[0,0],oI={x:0,y:0,zoom:1},sI=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],cI=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),lI={translateExtent:PM,nodeOrigin:aI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function uI(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=zF(cI,FF),l=BF();(0,d.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=lI,s()}),[]);let u=(0,d.useRef)(lI);return(0,d.useEffect)(()=>{for(let s of sI){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:NN(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},sI.map(t=>e[t])),null}function dI(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function fI(e){let[t,n]=(0,d.useState)(e===`system`?null:e);return(0,d.useEffect)(()=>{if(e!==`system`){n(e);return}let t=dI(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?dI()?.matches?`dark`:`light`:t}var pI=typeof document<`u`?document:null;function mI(e=null,t={target:pI,actInsideInputWithModifier:!0}){let[n,r]=(0,d.useState)(!1),i=(0,d.useRef)(!1),a=(0,d.useRef)(new Set([])),[o,s]=(0,d.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
56
+ `).replace(`
57
+
58
+ `,`
59
+ +`).split(`
60
+ `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,d.useEffect)(()=>{let n=t?.target??pI,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&zN(e))return!1;let n=gI(e.code,s);if(a.current.add(e[n]),hI(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=gI(e.code,s);hI(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function hI(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function gI(e,t){return t.includes(e)?`code`:`key`}var _I=()=>{let e=BF();return(0,d.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=TN(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return bN(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=xN(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function vI(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)yI(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function yI(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function bI(e,t){return vI(e,t)}function xI(e,t){return vI(e,t)}function SI(e,t){return{id:e,type:`select`,selected:t}}function CI(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);(a.selected!==void 0||e)&&a.selected!==e&&(n&&(a.selected=e),r.push(SI(a.id,e)))}return r}function wI({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function TI(e){return{id:e.id,type:`remove`}}var EI=vN(`React Flow`,`https://reactflow.dev/`);function DI(e,t,n={}){return QN(e,t,{...n,onError:n.onError??EI})}var OI=e=>KM(e),kI=e=>GM(e);function AI(e){return(0,d.forwardRef)(e)}var jI=typeof window<`u`?d.useLayoutEffect:d.useEffect;function MI(e){let[t,n]=(0,d.useState)(BigInt(0)),[r]=(0,d.useState)(()=>NI(()=>n(e=>e+BigInt(1))));return jI(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function NI(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var PI=(0,d.createContext)(null);function FI({children:e}){let t=BF(),n=MI((0,d.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=wI({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=MI((0,d.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(wI({items:s,lookup:o}))},[])),i=(0,d.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,Q.jsx)(PI.Provider,{value:i,children:e})}function II(){let e=(0,d.useContext)(PI);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var LI=e=>!!e.panZoom;function RI(){let e=_I(),t=BF(),n=II(),r=zF(LI),i=(0,d.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=OI(e)?e:n.get(e.id),a=i.parentId?AN(i.position,i.measured,i.parentId,n,r):i.position;return dN({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&OI(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&kI(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await nN({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(TI);o?.(f),c(e)}if(m){let e=d.map(TI);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=gN(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=dN(s?r:a),l=hN(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=gN(e)?e:a(e);if(!r)return!1;let i=hN(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return YM(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??MN();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,d.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var zI=e=>e.selected,BI=typeof window<`u`?window:void 0;function VI({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=BF(),{deleteElements:r}=RI(),i=mI(e,{actInsideInputWithModifier:!1}),a=mI(t,{target:BI});(0,d.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(zI),edges:e.filter(zI)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,d.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function HI(e){let t=BF();(0,d.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=IN(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,NM.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var UI={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},WI=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function GI({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=RM.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:f,maxZoom:p,zoomActivationKeyCode:m,preventScrolling:h=!0,children:g,noWheelClassName:_,noPanClassName:v,onViewportChange:y,isControlledViewport:b,paneClickDistance:x,selectionOnDrag:S}){let C=BF(),w=(0,d.useRef)(null),{userSelectionActive:T,lib:E,connectionInProgress:D}=zF(WI,FF),O=mI(m),k=(0,d.useRef)();HI(w);let A=(0,d.useCallback)(e=>{y?.({x:e[0],y:e[1],zoom:e[2]}),b||C.setState({transform:e})},[y,b]);return(0,d.useEffect)(()=>{if(w.current){k.current=cF({domNode:w.current,minZoom:f,maxZoom:p,translateExtent:u,viewport:l,onDraggingChange:e=>C.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=C.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=C.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=C.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=k.current.getViewport();return C.setState({panZoom:k.current,transform:[e,t,n],domNode:w.current.closest(`.react-flow`)}),()=>{k.current?.destroy()}}},[]),(0,d.useEffect)(()=>{k.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:h,noPanClassName:v,userSelectionActive:T,noWheelClassName:_,lib:E,onTransformChange:A,connectionInProgress:D,selectionOnDrag:S,paneClickDistance:x})},[e,t,n,r,i,a,o,s,c,O,h,v,T,_,E,A,D,S,x]),(0,Q.jsx)(`div`,{className:`react-flow__renderer`,ref:w,style:UI,children:g})}var KI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qI(){let{userSelectionActive:e,userSelectionRect:t}=zF(KI,FF);return e&&t?(0,Q.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var JI=(e,t)=>n=>{n.target===t.current&&e?.(n)},YI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function XI({isSelecting:e,selectionKeyPressed:t,selectionMode:n=zM.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){let _=(0,d.useRef)(0),v=BF(),{userSelectionActive:y,elementsSelectable:b,dragging:x,panBy:S,autoPanSpeed:C}=zF(YI,FF),w=b&&(e||y),T=(0,d.useRef)(null),E=(0,d.useRef)(),D=(0,d.useRef)(new Set),O=(0,d.useRef)(new Set),k=(0,d.useRef)(!1),A=(0,d.useRef)(!1),j=(0,d.useRef)({x:0,y:0}),M=(0,d.useRef)(!1),N=e=>{A.current||k.current||v.getState().connection.inProgress?(A.current=!1,k.current=!1):(l?.(e),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1}))},P=e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():u?.(e)},F=f?e=>f(e):void 0,I=e=>{A.current&&=(e.stopPropagation(),!1)},L=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=v.getState();if(E.current=i?.getBoundingClientRect(),!E.current)return;let s=n.target===T.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),A.current=!1;let{x:c,y:l}=VN(n.nativeEvent,E.current),u=bN({x:c,y:l},a);v.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function R(e,t){let{userSelectionRect:r}=v.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=v.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=xN(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=D.current,g=O.current;D.current=new Set(ZM(a,m,i,n===zM.Partial,!0).map(e=>e.id)),O.current=new Set;let _=u?.selectable??!0;for(let e of D.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??_)&&O.current.add(e)}}jN(h,D.current)||c(CI(a,D.current,!0)),jN(g,O.current)||l(CI(o,O.current)),v.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!i||!E.current)return;let[e,t]=sN(j.current,E.current,C);S({x:e,y:t}).then(e=>{if(!A.current||!e){_.current=requestAnimationFrame(z);return}let{x:t,y:n}=j.current;R(t,n),_.current=requestAnimationFrame(z)})}let B=()=>{cancelAnimationFrame(_.current),_.current=0,M.current=!1};(0,d.useEffect)(()=>()=>B(),[]);let ee=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=v.getState();if(!E.current||!n)return;let{x:o,y:c}=VN(e.nativeEvent,E.current);j.current={x:o,y:c};let l=xN({x:n.startX,y:n.startY},r);if(!A.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}A.current=!0,M.current||=(z(),!0),R(o,c)},V=e=>{w?e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!y&&e.target===T.current&&v.getState().userSelectionRect&&N?.(e),v.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(c?.(e),v.setState({nodesSelectionActive:D.current.size>0})),B()):e.target===T.current&&v.getState().connection.inProgress&&(k.current=!0)},te=e=>{e.target?.releasePointerCapture?.(e.pointerId),B()},ne=r===!0||Array.isArray(r)&&r.includes(0);return(0,Q.jsxs)(`div`,{className:YE([`react-flow__pane`,{draggable:ne,dragging:x,selection:e}]),onClick:w?void 0:JI(N,T),onContextMenu:JI(P,T),onWheel:JI(F,T),onPointerEnter:w?void 0:p,onPointerMove:w?ee:m,onPointerUp:V,onPointerCancel:w?te:void 0,onPointerDownCapture:w?L:void 0,onClickCapture:w?I:void 0,onPointerLeave:h,ref:T,style:UI,children:[g,(0,Q.jsx)(qI,{})]})}function ZI({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);l?(t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])):c?.(`012`,NM.error012(e))}function QI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=BF(),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)();return(0,d.useEffect)(()=>{if(!t)return u.current=LP({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{ZI({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,d.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var $I=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function eL(){let e=BF();return(0,d.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=$I(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=yN(t,i));let{position:a,positionAbsolute:s}=tN({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var tL=(0,d.createContext)(null),nL=tL.Provider;tL.Consumer;var rL=()=>(0,d.useContext)(tL),iL=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),aL=(0,d.createContext)(null);function oL({children:e}){let t=zF(iL,FF);return(0,Q.jsx)(aL.Provider,{value:t,children:e})}function sL(){let e=(0,d.useContext)(aL);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var cL={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},lL=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return cL;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===LM.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function uL({type:e=`source`,position:t=UM.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=BF(),_=rL(),{connectOnClick:v,noPanClassName:y,rfId:b}=sL(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=zF(lL(_,m,e),FF);_||g.getState().onError?.(`010`,NM.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(DI(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=BN(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();qP.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,Q.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:YE([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=LN(t.target),h=n||c,{connection:v,isValid:y}=qP.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var dL=(0,d.memo)(AI(uL));function fL({data:e,isConnectable:t,sourcePosition:n=UM.Bottom}){return(0,Q.jsxs)(Q.Fragment,{children:[e?.label,(0,Q.jsx)(dL,{type:`source`,position:n,isConnectable:t})]})}function pL({data:e,isConnectable:t,targetPosition:n=UM.Top,sourcePosition:r=UM.Bottom}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(dL,{type:`target`,position:n,isConnectable:t}),e?.label,(0,Q.jsx)(dL,{type:`source`,position:r,isConnectable:t})]})}function mL(){return null}function hL({data:e,isConnectable:t,targetPosition:n=UM.Top}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(dL,{type:`target`,position:n,isConnectable:t}),e?.label]})}var gL={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},_L={input:fL,default:pL,output:hL,group:mL};function vL(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var yL=e=>{let{width:t,height:n,x:r,y:i}=XM(e.nodeLookup,{filter:e=>!!e.selected});return{width:_N(t)?t:null,height:_N(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function bL({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=BF(),{width:i,height:a,transformString:o,userSelectionActive:s}=zF(yL,FF),c=eL(),l=(0,d.useRef)(null);(0,d.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(QI({nodeRef:l,disabled:!u}),!u)return null;let f=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,Q.jsx)(`div`,{className:YE([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,Q.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(gL,e.key)&&(e.preventDefault(),c({direction:gL[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var xL=typeof window<`u`?window:void 0,SL=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function CL({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=zF(SL,FF),z=mI(l,{target:xL}),B=mI(h,{target:xL}),ee=B||w,V=B||b,te=u&&ee!==!0,ne=z||R||te;return VI({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,Q.jsx)(GI,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:V,panActivationKeyPressed:B,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&ee,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:te,children:(0,Q.jsxs)(XI,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:ee,autoPanOnSelection:T,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:te,children:[e,L&&(0,Q.jsx)(bL,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}CL.displayName=`FlowRenderer`;var wL=(0,d.memo)(CL),TL=e=>t=>e?ZM(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function EL(e){return zF((0,d.useCallback)(TL(e),[e]),FF)}var DL=e=>e.updateNodeInternals;function OL(){let e=zF(DL),[t]=(0,d.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,d.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function kL({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=BF(),a=(0,d.useRef)(null),o=(0,d.useRef)(null),s=(0,d.useRef)(e.sourcePosition),c=(0,d.useRef)(e.targetPosition),l=(0,d.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,d.useEffect)(()=>{!a.current||e.hidden||u&&o.current===a.current||(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,d.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,d.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function AL({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=zF(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},FF),S=y.type||`default`,C=g?.[S]||_L[S];C===void 0&&(v?.(`003`,NM.error003(S)),S=`default`,C=g?.default||_L.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=BF(),k=kN(y),A=kL({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=QI({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=eL();if(y.hidden)return null;let N=ON(y),P=vL(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,ee=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&ZI({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},V=t=>{if(!(zN(t.nativeEvent)||m)){if(FM.includes(t.key)&&T){let n=t.key===`Escape`;ZI({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(gL,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:gL[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(ZM(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,Q.jsx)(`div`,{className:YE([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:ee,onDoubleClick:B,onKeyDown:D?V:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${UF}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,Q.jsx)(nL,{value:e,children:(0,Q.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var jL=(0,d.memo)(AL),ML=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function NL(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=zF(ML,FF),a=EL(e.onlyRenderVisibleElements),o=OL();return(0,Q.jsx)(`div`,{className:`react-flow__nodes`,style:UI,children:a.map(a=>(0,Q.jsx)(jL,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}NL.displayName=`NodeRenderer`;var PL=(0,d.memo)(NL);function FL(e){return zF((0,d.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&YN({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),FF)}var IL=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,Q.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},LL=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,Q.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},RL={[HM.Arrow]:IL,[HM.ArrowClosed]:LL};function zL(e){let t=BF();return(0,d.useMemo)(()=>Object.prototype.hasOwnProperty.call(RL,e)?RL[e]:(t.getState().onError?.(`009`,NM.error009(e)),null),[e])}var BL=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=zL(t);return c?(0,Q.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,Q.jsx)(c,{color:n,strokeWidth:o})}):null},VL=({defaultColor:e,rfId:t})=>{let n=zF(e=>e.edges),r=zF(e=>e.defaultEdgeOptions),i=(0,d.useMemo)(()=>fP(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,Q.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,Q.jsx)(`defs`,{children:i.map(e=>(0,Q.jsx)(BL,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};VL.displayName=`MarkerDefinitions`;var HL=(0,d.memo)(VL);function UL({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[f,p]=(0,d.useState)({x:1,y:0,width:0,height:0}),m=YE([`react-flow__edge-textwrapper`,l]),h=(0,d.useRef)(null);return(0,d.useEffect)(()=>{if(h.current){let e=h.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,Q.jsxs)(`g`,{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?`visible`:`hidden`,...u,children:[i&&(0,Q.jsx)(`rect`,{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,Q.jsx)(`text`,{className:`react-flow__edge-text`,y:f.height/2,dy:`0.3em`,ref:h,style:r,children:n}),c]}):null}UL.displayName=`EdgeText`;var WL=(0,d.memo)(UL);function GL({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{...u,d:e,fill:`none`,className:YE([`react-flow__edge-path`,u.className])}),l?(0,Q.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&_N(t)&&_N(n)?(0,Q.jsx)(WL,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function KL({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===UM.Left||e===UM.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function qL({sourceX:e,sourceY:t,sourcePosition:n=UM.Bottom,targetX:r,targetY:i,targetPosition:a=UM.Top}){let[o,s]=KL({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=KL({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=UN({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function JL(e){return(0,d.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=qL({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,Q.jsx)(GL,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var YL=JL({isInternal:!1}),XL=JL({isInternal:!0});YL.displayName=`SimpleBezierEdge`,XL.displayName=`SimpleBezierEdgeInternal`;function ZL(e){return(0,d.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=UM.Bottom,targetPosition:m=UM.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=aP({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,Q.jsx)(GL,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var QL=ZL({isInternal:!1}),$L=ZL({isInternal:!0});QL.displayName=`SmoothStepEdge`,$L.displayName=`SmoothStepEdgeInternal`;function eR(e){return(0,d.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,Q.jsx)(QL,{...n,id:r,pathOptions:(0,d.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var tR=eR({isInternal:!1}),nR=eR({isInternal:!0});tR.displayName=`StepEdge`,nR.displayName=`StepEdgeInternal`;function rR(e){return(0,d.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=$N({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,Q.jsx)(GL,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var iR=rR({isInternal:!1}),aR=rR({isInternal:!0});iR.displayName=`StraightEdge`,aR.displayName=`StraightEdgeInternal`;function oR(e){return(0,d.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=UM.Bottom,targetPosition:s=UM.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=KN({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,Q.jsx)(GL,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var sR=oR({isInternal:!1}),cR=oR({isInternal:!0});sR.displayName=`BezierEdge`,cR.displayName=`BezierEdgeInternal`;var lR={default:cR,straight:aR,step:nR,smoothstep:$L,simplebezier:XL},uR={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},dR=(e,t,n)=>n===UM.Left?e-t:n===UM.Right?e+t:e,fR=(e,t,n)=>n===UM.Top?e-t:n===UM.Bottom?e+t:e,pR=`react-flow__edgeupdater`;function mR({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,Q.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:YE([pR,`${pR}-${s}`]),cx:dR(t,r,e),cy:fR(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function hR({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=BF(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;qP.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(e===!0||e===`source`)&&(0,Q.jsx)(mR,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,Q.jsx)(mR,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function gR({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,rfId:h,edgeTypes:g,noPanClassName:_,onError:v,disableKeyboardA11y:y}){let b=zF(t=>t.edgeLookup.get(e)),x=zF(e=>e.defaultEdgeOptions);b=x?{...x,...b}:b;let S=b.type||`default`,C=g?.[S]||lR[S];C===void 0&&(v?.(`011`,NM.error011(S)),S=`default`,C=g?.default||lR.default);let w=!!(b.focusable||t&&b.focusable===void 0),T=f!==void 0&&(b.reconnectable||n&&b.reconnectable===void 0),E=!!(b.selectable||r&&b.selectable===void 0),D=(0,d.useRef)(null),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(!1),M=BF(),{zIndex:N=b.zIndex,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z}=zF((0,d.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return uR;let i=sP({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:v}),a=JN({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||uR,zIndex:a}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex,v]),FF),B=(0,d.useMemo)(()=>b.markerStart?`url('#${dP(b.markerStart,h)}')`:void 0,[b.markerStart,h]),ee=(0,d.useMemo)(()=>b.markerEnd?`url('#${dP(b.markerEnd,h)}')`:void 0,[b.markerEnd,h]);if(b.hidden||P===null||F===null||I===null||L===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=M.getState();E&&(M.setState({nodesSelectionActive:!1}),b.selected&&a?(r({nodes:[],edges:[b]}),D.current?.blur()):n([e])),i&&i(t,b)},te=a?e=>{a(e,{...b})}:void 0,ne=o?e=>{o(e,{...b})}:void 0,re=s?e=>{s(e,{...b})}:void 0,ie=c?e=>{c(e,{...b})}:void 0,ae=l?e=>{l(e,{...b})}:void 0;return(0,Q.jsx)(`svg`,{style:{zIndex:N},children:(0,Q.jsxs)(`g`,{className:YE([`react-flow__edge`,`react-flow__edge-${S}`,b.className,_,{selected:b.selected,animated:b.animated,inactive:!E&&!i,updating:O,selectable:E}]),onClick:V,onDoubleClick:te,onContextMenu:ne,onMouseEnter:re,onMouseMove:ie,onMouseLeave:ae,onKeyDown:w?t=>{if(!y&&FM.includes(t.key)&&E){let{unselectNodesAndEdges:n,addSelectedEdges:r}=M.getState();t.key===`Escape`?(D.current?.blur(),n({edges:[b]})):r([e])}}:void 0,tabIndex:w?0:void 0,role:b.ariaRole??(w?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":w?`${WF}-${h}`:void 0,ref:D,...b.domAttributes,children:[!A&&(0,Q.jsx)(C,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:E,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:B,markerEnd:ee,pathOptions:`pathOptions`in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),T&&(0,Q.jsx)(hR,{edge:b,isReconnectable:T,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,setUpdateHover:k,setReconnecting:j})]})})}var _R=(0,d.memo)(gR),vR=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function yR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=zF(vR,FF),b=FL(t);return(0,Q.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,Q.jsx)(HL,{defaultColor:e,rfId:n}),b.map(e=>(0,Q.jsx)(_R,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}yR.displayName=`EdgeRenderer`;var bR=(0,d.memo)(yR),xR=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function SR({children:e}){let t=BF(),n=(0,d.useRef)(null),[r]=(0,d.useState)(()=>t.getState().transform);return jI(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=xR(r)))};return r(),t.subscribe(r)},[t]),(0,Q.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:xR(r)},children:e})}function CR(e){let t=RI(),n=(0,d.useRef)(!1);(0,d.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var wR=e=>e.panZoom?.syncViewport;function TR(e){let t=zF(wR),n=BF();return(0,d.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function ER(e){return e.connection.inProgress?{...e.connection,to:bN(e.connection.to,e.transform)}:{...e.connection}}function DR(e){return e?t=>e(ER(t)):ER}function OR(e){return zF(DR(e),FF)}var kR=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function AR({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=zF(kR,FF);return a&&i&&c?(0,Q.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,Q.jsx)(`g`,{className:YE([`react-flow__connection`,PN(s)]),children:(0,Q.jsx)(jR,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var jR=({style:e,type:t=VM.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=OR();if(!i)return;if(n)return(0,Q.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:PN(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case VM.Bezier:[m]=KN(h);break;case VM.SimpleBezier:[m]=qL(h);break;case VM.Step:[m]=aP({...h,borderRadius:0});break;case VM.SmoothStep:[m]=aP(h);break;default:[m]=$N(h)}return(0,Q.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};jR.displayName=`ConnectionLine`;var MR={};function NR(e=MR){(0,d.useRef)(e),BF(),(0,d.useEffect)(()=>{},[e])}function PR(){BF(),(0,d.useRef)(!1),(0,d.useEffect)(()=>{},[])}function FR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:ee,onPaneMouseEnter:V,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ie,paneClickDistance:ae,nodeClickDistance:oe,onEdgeContextMenu:se,onEdgeMouseEnter:H,onEdgeMouseMove:U,onEdgeMouseLeave:W,reconnectRadius:G,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,viewport:_e,onViewportChange:ve,nodesDraggable:ye}){return NR(e),NR(t),PR(),CR(n),TR(_e),(0,Q.jsx)(wL,{onPaneClick:ee,onPaneMouseEnter:V,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:re,paneClickDistance:ae,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,onViewportChange:ve,isControlledViewport:!!_e,children:(0,Q.jsxs)(SR,{children:[(0,Q.jsx)(bR,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:T,onEdgeContextMenu:se,onEdgeMouseEnter:H,onEdgeMouseMove:U,onEdgeMouseLeave:W,reconnectRadius:G,defaultMarkerColor:M,noPanClassName:pe,disableKeyboardA11y:me,rfId:ge}),(0,Q.jsx)(AR,{style:h,type:m,component:g,containerStyle:_}),(0,Q.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,Q.jsx)(PL,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:oe,onlyRenderVisibleElements:T,noPanClassName:pe,noDragClassName:de,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,nodesDraggable:ye}),(0,Q.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}FR.displayName=`GraphView`;var IR=(0,d.memo)(FR),LR=vN(`React Flow`,`https://reactflow.dev/`),RR=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??PM;jP(h,g,_);let{nodesInitialized:x}=SP(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=TN(XM(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:PM,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:LM.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...BM},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:LR,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:IM,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},zR=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>PF((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await eN({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...RR({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=SP(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();jP(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=OP(e,n,r,i,a,o,l);d&&(yP(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=lP(e,o.fromHandle,UM.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=DP(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(bI(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(xI(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?i(e.map(e=>SI(e,!0))):(i(CI(r,new Set([...e]),!0)),a(CI(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?a(e.map(e=>SI(e,!0))):(a(CI(n,new Set([...e]))),i(CI(r,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(SI(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(SI(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,SI(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,SI(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(SP(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return kP({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...BM}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...RR()})}},Object.is);function BR({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:f,zIndexMode:p,children:m}){let[h]=(0,d.useState)(()=>zR({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:f,zIndexMode:p}));return(0,Q.jsx)(LF,{value:h,children:(0,Q.jsx)(FI,{children:(0,Q.jsx)(oL,{children:m})})})}function VR({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:m}){return(0,d.useContext)(IF)?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(BR,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:e})}var HR={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function UR({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:p,onConnect:m,onConnectStart:h,onConnectEnd:g,onClickConnectStart:_,onClickConnectEnd:v,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onSelectionChange:A,onSelectionDragStart:j,onSelectionDrag:M,onSelectionDragStop:N,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onBeforeDelete:L,connectionMode:R,connectionLineType:z=VM.Bezier,connectionLineStyle:B,connectionLineComponent:ee,connectionLineContainerStyle:V,deleteKeyCode:te=`Backspace`,selectionKeyCode:ne=`Shift`,selectionOnDrag:re=!1,selectionMode:ie=zM.Full,panActivationKeyCode:ae=`Space`,multiSelectionKeyCode:oe=EN()?`Meta`:`Control`,zoomActivationKeyCode:se=EN()?`Meta`:`Control`,snapToGrid:H,snapGrid:U,onlyRenderVisibleElements:W=!1,selectNodesOnDrag:G,nodesDraggable:ce,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:fe=aI,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he=!0,defaultViewport:ge=oI,minZoom:_e=.5,maxZoom:ve=2,translateExtent:ye=PM,preventScrolling:be=!0,nodeExtent:K,defaultMarkerColor:xe=`#b1b1b7`,zoomOnScroll:Se=!0,zoomOnPinch:Ce=!0,panOnScroll:we=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:Ee=RM.Free,zoomOnDoubleClick:De=!0,panOnDrag:Oe=!0,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe=1,nodeClickDistance:Ie=0,children:Le,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke=10,onNodesChange:qe,onEdgesChange:Je,noDragClassName:Ye=`nodrag`,noWheelClassName:Xe=`nowheel`,noPanClassName:Ze=`nopan`,fitView:Qe,fitViewOptions:$e,connectOnClick:et,attributionPosition:tt,proOptions:nt,defaultEdgeOptions:rt,elevateNodesOnSelect:it=!0,elevateEdgesOnSelect:at=!1,disableKeyboardA11y:ot=!1,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanOnSelection:lt=!0,autoPanSpeed:ut,connectionRadius:dt,isValidConnection:ft,onError:pt,style:mt,id:ht,nodeDragThreshold:gt,connectionDragThreshold:_t,viewport:vt,onViewportChange:yt,width:bt,height:xt,colorMode:St=`light`,debug:Ct,onScroll:wt,ariaLabelConfig:Tt,zIndexMode:Et=`basic`,...Dt},Ot){let kt=ht||`1`,At=fI(St),jt=(0,d.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),wt?.(e)},[wt]);return(0,Q.jsx)(`div`,{"data-testid":`rf__wrapper`,...Dt,onScroll:jt,style:{...mt,...HR},ref:Ot,className:YE([`react-flow`,i,At]),id:ht,role:`application`,children:(0,Q.jsxs)(VR,{nodes:e,edges:t,width:bt,height:xt,fitView:Qe,fitViewOptions:$e,minZoom:_e,maxZoom:ve,nodeOrigin:fe,nodeExtent:K,zIndexMode:Et,children:[(0,Q.jsx)(uI,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:h,onConnectEnd:g,onClickConnectStart:_,onClickConnectEnd:v,nodesDraggable:ce,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he,elevateNodesOnSelect:it,elevateEdgesOnSelect:at,minZoom:_e,maxZoom:ve,nodeExtent:K,onNodesChange:qe,onEdgesChange:Je,snapToGrid:H,snapGrid:U,connectionMode:R,translateExtent:ye,connectOnClick:et,defaultEdgeOptions:rt,fitView:Qe,fitViewOptions:$e,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onSelectionDrag:M,onSelectionDragStart:j,onSelectionDragStop:N,onMove:u,onMoveStart:f,onMoveEnd:p,noPanClassName:Ze,nodeOrigin:fe,rfId:kt,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanSpeed:ut,onError:pt,connectionRadius:dt,isValidConnection:ft,selectNodesOnDrag:G,nodeDragThreshold:gt,connectionDragThreshold:_t,onBeforeDelete:L,debug:Ct,ariaLabelConfig:Tt,zIndexMode:Et}),(0,Q.jsx)(IR,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:o,connectionLineType:z,connectionLineStyle:B,connectionLineComponent:ee,connectionLineContainerStyle:V,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ie,deleteKeyCode:te,multiSelectionKeyCode:oe,panActivationKeyCode:ae,zoomActivationKeyCode:se,onlyRenderVisibleElements:W,defaultViewport:ge,translateExtent:ye,minZoom:_e,maxZoom:ve,preventScrolling:be,zoomOnScroll:Se,zoomOnPinch:Ce,zoomOnDoubleClick:De,panOnScroll:we,panOnScrollSpeed:Te,panOnScrollMode:Ee,panOnDrag:Oe,autoPanOnSelection:lt,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe,nodeClickDistance:Ie,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke,defaultMarkerColor:xe,noDragClassName:Ye,noWheelClassName:Xe,noPanClassName:Ze,rfId:kt,disableKeyboardA11y:ot,nodeExtent:K,viewport:vt,onViewportChange:yt,nodesDraggable:ce}),(0,Q.jsx)(iI,{onSelectionChange:A}),Le,(0,Q.jsx)(QF,{proOptions:nt,position:tt}),(0,Q.jsx)(YF,{rfId:kt,disableKeyboardA11y:ot})]})})}var WR=AI(UR),GR=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function KR({children:e}){let t=zF(GR);return t?(0,Qx.createPortal)(e,t):null}NM.error014();function qR(e){return zF((0,d.useCallback)(t=>t.nodeLookup.get(e),[e]),FF)}function JR({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,Q.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:YE([`react-flow__background-pattern`,n,r])})}function YR({radius:e,className:t}){return(0,Q.jsx)(`circle`,{cx:e,cy:e,r:e,className:YE([`react-flow__background-pattern`,`dots`,t])})}var XR;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(XR||={});var ZR={[XR.Dots]:1,[XR.Lines]:1,[XR.Cross]:6},QR=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function $R({id:e,variant:t=XR.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let f=(0,d.useRef)(null),{transform:p,patternId:m}=zF(QR,FF),h=r||ZR[t],g=t===XR.Dots,_=t===XR.Cross,v=Array.isArray(n)?n:[n,n],y=[v[0]*p[2]||1,v[1]*p[2]||1],b=h*p[2],x=Array.isArray(a)?a:[a,a],S=_?[b,b]:y,C=[x[0]*p[2]+S[0]/2,x[1]*p[2]+S[1]/2],w=`${m}${e||``}`;return(0,Q.jsxs)(`svg`,{className:YE([`react-flow__background`,l]),style:{...c,...UI,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:f,"data-testid":`rf__background`,children:[(0,Q.jsx)(`pattern`,{id:w,x:p[0]%y[0],y:p[1]%y[1],width:y[0],height:y[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${C[0]},-${C[1]})`,children:g?(0,Q.jsx)(YR,{radius:b/2,className:u}):(0,Q.jsx)(JR,{dimensions:S,lineWidth:i,variant:t,className:u})}),(0,Q.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}$R.displayName=`Background`;var ez=(0,d.memo)($R);function tz(){return(0,Q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,Q.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function nz(){return(0,Q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,Q.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function rz(){return(0,Q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,Q.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function iz(){return(0,Q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Q.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function az(){return(0,Q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Q.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function oz({children:e,className:t,...n}){return(0,Q.jsx)(`button`,{type:`button`,className:YE([`react-flow__controls-button`,t]),...n,children:e})}var sz=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function cz({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=BF(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=zF(sz,FF),{zoomIn:y,zoomOut:b,fitView:x}=RI();return(0,Q.jsxs)(XF,{className:YE([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oz,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,Q.jsx)(tz,{})}),(0,Q.jsx)(oz,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,Q.jsx)(nz,{})})]}),n&&(0,Q.jsx)(oz,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,Q.jsx)(rz,{})}),r&&(0,Q.jsx)(oz,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,Q.jsx)(az,{}):(0,Q.jsx)(iz,{})}),u]})}cz.displayName=`Controls`;var lz=(0,d.memo)(cz);function uz({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,Q.jsx)(`rect`,{className:YE([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var dz=(0,d.memo)(uz),fz=e=>e.nodes.map(e=>e.id),pz=e=>e instanceof Function?e:()=>e;function mz({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=dz,onClick:o}){let s=zF(fz,FF),c=pz(t),l=pz(e),u=pz(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,Q.jsx)(Q.Fragment,{children:s.map(e=>(0,Q.jsx)(gz,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function hz({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=zF(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=ON(r);return{node:r,x:i,y:a,width:o,height:s}},FF);return!l||l.hidden||!kN(l)?null:(0,Q.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var gz=(0,d.memo)(hz),_z=(0,d.memo)(mz),vz=200,yz=150,bz=e=>!e.hidden,xz=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?pN(XM(e.nodeLookup,{filter:bz}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Sz=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Cz=(e,t)=>Sz(e.viewBB,t.viewBB)&&Sz(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,wz=`react-flow__minimap-desc`;function Tz({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:f,position:p=`bottom-right`,onClick:m,onNodeClick:h,pannable:g=!1,zoomable:_=!1,ariaLabel:v,inversePan:y,zoomStep:b=1,offsetScale:x=5}){let S=BF(),C=(0,d.useRef)(null),{boundingRect:w,panZoom:T,viewBB:E,rfId:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=zF(xz,Cz),M=e?.width??vz,N=e?.height??yz,P=w.width/M,F=w.height/N,I=Math.max(P,F),L=I*M,R=I*N,z=x*I,B=w.x-(L-w.width)/2-z,ee=w.y-(R-w.height)/2-z,V=L+z*2,te=R+z*2,ne=`${wz}-${D}`,re=(0,d.useRef)(0),ie=(0,d.useRef)();re.current=I,(0,d.useEffect)(()=>{let e=S.getState().panZoom;if(C.current&&e)return ie.current=JP({domNode:C.current,panZoom:e,getTransform:()=>S.getState().transform,getViewScale:()=>re.current}),()=>{ie.current?.destroy()}},[T]),(0,d.useEffect)(()=>{ie.current?.update({translateExtent:O,width:k,height:A,inversePan:y,pannable:g,zoomStep:b,zoomable:_})},[g,_,y,b,O,k,A]);let ae=m?e=>{let[t,n]=ie.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,oe=(0,d.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;h?.(e,n)},[h]),se=h?oe:void 0,H=v??j[`minimap.ariaLabel`];return(0,Q.jsx)(XF,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f==`number`?f*I:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:YE([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,Q.jsxs)(`svg`,{width:M,height:N,viewBox:`${B} ${ee} ${V} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ne,ref:C,onClick:ae,children:[H&&(0,Q.jsx)(`title`,{id:ne,children:H}),(0,Q.jsx)(_z,{onClick:se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,Q.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${B-z},${ee-z}h${V+z*2}v${te+z*2}h${-V-z*2}z
61
+ M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Tz.displayName=`MiniMap`,(0,d.memo)(Tz);var Ez=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Dz={[lF.Line]:`right`,[lF.Handle]:`bottom-right`};function Oz({nodeId:e,position:t,variant:n=lF.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:m=!0,shouldResize:h,onResizeStart:g,onResize:_,onResizeEnd:v}){let y=rL(),b=typeof e==`string`?e:y,x=BF(),S=(0,d.useRef)(null),C=n===lF.Handle,w=zF((0,d.useCallback)(Ez(C&&m),[C,m]),FF),T=(0,d.useRef)(null),E=t??Dz[n];(0,d.useEffect)(()=>{if(S.current&&b)return T.current||=SF({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=DP([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...AN({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:p?p===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:f,resizeDirection:p,onResizeStart:g,onResize:_,onResizeEnd:v,shouldResize:h}),()=>{T.current?.destroy()}},[E,s,c,l,u,f,g,_,v,h]);let D=E.split(`-`);return(0,Q.jsx)(`div`,{className:YE([`react-flow__resize-control`,`nodrag`,...D,n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}var kz=(0,d.memo)(Oz);function Az({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:r,lineClassName:i,lineStyle:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,autoScale:f=!0,shouldResize:p,onResizeStart:m,onResize:h,onResizeEnd:g}){return t?(0,Q.jsxs)(Q.Fragment,{children:[dF.map(t=>(0,Q.jsx)(kz,{className:i,style:a,nodeId:e,position:t,variant:lF.Line,color:o,minWidth:s,minHeight:c,maxWidth:l,maxHeight:u,onResizeStart:m,keepAspectRatio:d,autoScale:f,shouldResize:p,onResize:h,onResizeEnd:g},t)),uF.map(t=>(0,Q.jsx)(kz,{className:n,style:r,nodeId:e,position:t,color:o,minWidth:s,minHeight:c,maxWidth:l,maxHeight:u,onResizeStart:m,keepAspectRatio:d,autoScale:f,shouldResize:p,onResize:h,onResizeEnd:g},t))]}):null}var jz=e=>e.domNode?.querySelector(`.react-flow__renderer`);function Mz({children:e}){let t=zF(jz);return t?(0,Qx.createPortal)(e,t):null}var Nz=(e,t)=>e?.internals.positionAbsolute.x!==t?.internals.positionAbsolute.x||e?.internals.positionAbsolute.y!==t?.internals.positionAbsolute.y||e?.measured.width!==t?.measured.width||e?.measured.height!==t?.measured.height||e?.selected!==t?.selected||e?.internals.z!==t?.internals.z,Pz=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e)if(Nz(r,t.get(n)))return!1;return!0},Fz=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2],selectedNodesCount:e.nodes.filter(e=>e.selected).length});function Iz({nodeId:e,children:t,className:n,style:r,isVisible:i,position:a=UM.Top,offset:o=10,align:s=`center`,...c}){let l=rL(),u=zF((0,d.useCallback)(t=>(Array.isArray(e)?e:[e||l||``]).reduce((e,n)=>{let r=t.nodeLookup.get(n);return r&&e.set(r.id,r),e},new Map),[e,l]),Pz),{x:f,y:p,zoom:m,selectedNodesCount:h}=zF(Fz,FF);if(!(typeof i==`boolean`?i:u.size===1&&u.values().next().value?.selected&&h===1)||!u.size)return null;let g=XM(u),_=Array.from(u.values()),v=Math.max(..._.map(e=>e.internals.z+1)),y={position:`absolute`,transform:pP(g,{x:f,y:p,zoom:m},a,o,s),zIndex:v,...r};return(0,Q.jsx)(Mz,{children:(0,Q.jsx)(`div`,{style:y,className:YE([`react-flow__node-toolbar`,n]),...c,"data-id":_.reduce((e,t)=>`${e}${t.id} `,``).trim(),children:t})})}var Lz=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`#`)),Rz=e=>e.replace(/^(?:[ \t]*\r?\n)+/,``).trimEnd();function zz(e){return{links:Lz(e.getData(`text/uri-list`)),text:Rz(e.getData(`text/plain`))}}function Bz(e,t){let n=e.filter(e=>e.clips?.accepts(t));return n.find(e=>!e.clips.fallback)??n[0]}function Vz(e){let t=e,n=t&&(t.nodeType===1?t:t.parentElement);return!!n?.closest(`input, textarea, select`)||!!n?.isContentEditable}var Hz=e=>[...e.dataTransfer?.types??[]],Uz=e=>e.includes(`text/uri-list`)&&!e.includes(`Files`),Wz=e=>e.includes(`text/plain`)&&!e.includes(`text/uri-list`)&&!e.includes(`Files`),Gz=`application/x-tricot-blocks`,Kz=`tricot-blocks`;function qz(e){return JSON.stringify({tricot:Kz,ids:e})}function Jz(e){let t;try{t=JSON.parse(e.getData(Gz))}catch{return null}let{tricot:n,ids:r}=t??{};return n!==Kz||!Array.isArray(r)||r.length===0||!r.every(e=>typeof e==`string`)?null:{ids:r}}var Yz=(e,t)=>[e,...t].map(e=>e.join(` `)).join(`
62
+ `);function Xz(e,t){return t.map(t=>[t.title,e.find(e=>e.type===t.type)?.copyText?.(t)].filter(Boolean).join(`
63
+ `)).filter(Boolean).join(`
64
+
65
+ `)}function Zz(e){return e.owner?{[e.owner.kind]:e.owner.card}:{}}var Qz=(0,d.createContext)(null);function $z(){let e=(0,d.useContext)(Qz);if(!e)throw Error(`useCanvas outside a canvas`);return e}function eB(e){let{value:t,placeholder:n,onCommit:r,className:i=``,display:a}=e,{readOnly:o}=$z(),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(!1);if(o)return(0,Q.jsx)(`span`,{className:`editable ${i}`,children:a??t});if(!s)return(0,Q.jsx)(`span`,{className:`editable ${i}`,onDoubleClick:e=>{e.stopPropagation(),l.current=!1,c(!0)},title:`Double-click to edit`,children:t?a??t:(0,Q.jsx)(`span`,{className:`placeholder`,children:n})});let u=e=>{c(!1),!l.current&&e.value!==t&&r(e.value)};return(0,Q.jsx)(`input`,{autoFocus:!0,className:`editable-input nodrag ${i}`,defaultValue:t,placeholder:n,onBlur:e=>u(e.currentTarget),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(l.current=!0,e.currentTarget.blur())}})}var tB=/[.!?…]+["'”’)\]]*(?=\s|$)|\n/g;function nB(e,t){let n=Math.max(0,Math.min(e.length,t)),r=(t,n)=>{for(;t<n&&/\s/.test(e[t]);)t++;for(;n>t&&/\s/.test(e[n-1]);)n--;return n>t?{start:t,end:n}:null},i=0;for(let t of e.matchAll(tB)){let e=t[0]===`
66
+ `?t.index:t.index+t[0].length;if(n<=e)return r(i,e);i=t.index+t[0].length}return r(i,e.length)}function rB(e,t){let[n,r]=e<=t?[e,t]:[t,e];return r>n?{line:n,last:r}:{line:n}}var iB=e=>Math.min(1,Math.max(0,e)),aB=e=>Math.round(e*1e4)/1e4;function oB(e,t){let[n,r]=[iB(Math.min(e.x,t.x)),iB(Math.max(e.x,t.x))],[i,a]=[iB(Math.min(e.y,t.y)),iB(Math.max(e.y,t.y))];return{x:aB(n),y:aB(i),w:aB(r-n),h:aB(a-i)}}function sB(e,t,n=.06){let r=n*Math.min(t.width,t.height),i=Math.min(1,r/t.width),a=Math.min(1,r/t.height),o=Math.min(1-i,Math.max(0,iB(e.x)-i/2)),s=Math.min(1-a,Math.max(0,iB(e.y)-a/2));return{x:aB(o),y:aB(s),w:aB(i),h:aB(a)}}function cB(e,t,n=8){return e.w*t.width<n||e.h*t.height<n}function lB(e,t,n,r=10){let i=Math.max(12,Math.min(e.x,t.w-n.width-12)),a=e.y+e.h+r,o=t.h-a-12,s=e.y-r-12,c=()=>({left:i,top:Math.max(12,Math.min(a,t.h-n.height-12)),above:!1}),l=()=>({left:i,top:Math.max(e.y-r,Math.min(n.height+12,t.h-12)),above:!0});if(n.height<=o)return c();if(n.height<=s)return l();let u=Math.max(12,Math.min(e.y,t.h-n.height-12));return t.w-(e.x+e.w+r)-12>=n.width?{left:e.x+e.w+r,top:u,above:!1}:e.x-r-12>=n.width?{left:e.x-r-n.width,top:u,above:!1}:s>o?l():c()}function uB(e){if(e.length===0)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.w)),i=Math.max(...e.map(e=>e.y+e.h));return{x:t,y:n,w:r-t,h:i-n}}function dB(e,t){let n=(e,t)=>[Math.max(0,Math.min(e,t)),Math.max(0,e,t)];return e[0]<0?{columns:n(e[1],t[1])}:e[1]<0?{rows:n(e[0],t[0])}:{rows:n(e[0],t[0]),columns:n(e[1],t[1])}}function fB(e,[t,n]){let r=!e.rows||t>=e.rows[0]&&t<=e.rows[1],i=!e.columns||n>=e.columns[0]&&n<=e.columns[1];return t<0?n>=0&&!e.rows&&i:n<0?!e.columns&&r:r&&i}function pB(e,t,n){return t===null?e.category===null&&e.series===n:e.category===null?n!==null&&e.series===n:e.category===t&&(e.series===null||n===null||e.series===n)}var mB={type:`chart`,kind:`bar`,columns:[`Team`,`Tasks done`],rows:[[`Design`,`8`],[`Web`,`13`],[`Server`,`11`],[`Docs`,`5`]]},hB=e=>`var(--series-${e%8+1})`,gB=new Map,_B=new Set;function vB(e){gB.set(e,`data`);for(let e of _B)e()}function yB(e){return[(0,d.useSyncExternalStore)(e=>(_B.add(e),()=>_B.delete(e)),()=>gB.get(e)??`chart`),t=>{gB.set(e,t);for(let e of _B)e()}]}function bB({block:e,frozen:t}){let n=$z(),[r,i]=yB(e.id),a=`${Bt[e.kind]} chart`;return(0,Q.jsxs)(Q.Fragment,{children:[n.readOnly||t?(0,Q.jsx)(`span`,{className:`chart-kind`,children:a}):(0,Q.jsxs)(`span`,{className:`chart-kind is-menu nodrag`,onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`select`,{value:e.kind,onChange:t=>n.updateBlock(e,{kind:t.target.value}),"aria-label":`Kind of chart`,title:`Kind of chart`,children:zt.map(e=>(0,Q.jsxs)(`option`,{value:e,children:[Bt[e],` chart`]},e))}),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:a}),(0,Q.jsx)(`svg`,{className:`chart-kind-caret`,viewBox:`0 0 8 8`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`M1.5 3 4 5.5 6.5 3`})})]}),(0,Q.jsx)(`span`,{className:`chart-switch nodrag`,role:`radiogroup`,"aria-label":`Show`,onDoubleClick:e=>e.stopPropagation(),children:[`chart`,`data`].map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,className:r===e?`is-on`:void 0,onClick:()=>i(e),title:e===`chart`?`The chart`:`The numbers it is drawn from, as a table`,children:e===`chart`?`Chart`:`Data`},e))})]})}function xB({block:e,selected:t,placed:n}){let[r]=yB(e.id);return r===`data`?(0,Q.jsx)(AB,{block:e,selected:t}):(0,Q.jsx)(EB,{block:e,placed:n})}function SB(e){let[t,n]=(0,d.useState)({width:0,height:0});return(0,d.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=Math.round(t.clientWidth),r=Math.round(t.clientHeight);n(t=>t.width===e&&t.height===r?t:{width:e,height:r})};r();let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function CB(e,t,n){if(e.slices.length){let n=e.slices.find(e=>e.category===t);return n?n.mid:null}if(e.bars.length){let r=e.bars.filter(e=>e.category===t&&(n===null||e.series===n));if(r.length===0)return null;let i=r.reduce((e,t)=>Math.min(t.y,t.end)<Math.min(e.y,e.end)?t:e);return n===null&&r.length>1?{x:e.bands[t].cx,y:Math.min(i.y,i.end)}:{x:i.x+i.w/2,y:i.end}}let r=e.lines.flatMap(e=>n===null||e.series===n?e.points.filter(e=>e.category===t):[]);return r.length===0?null:r.reduce((e,t)=>t.y<e.y?t:e)}function wB(e,t,n,r){if(t.category===void 0){let i=t.series===void 0?null:Sn(e,t.series);return i===null?null:{id:n,category:null,series:i,draft:r}}let i=xn(e,t.category,t.series);return i&&{id:n,category:i.row,series:i.series,draft:r}}function TB(e,t,n){if(t===null)return n===null||n+1>=e.columns.length?null:{blockId:e.id,part:{kind:`point`,series:e.columns[n+1]},quote:Cn(e,n)};let r=e.columns.length>2?n:null;return{blockId:e.id,part:{kind:`point`,category:e.rows[t]?.[0]??``,...r===null?{}:{series:e.columns[r+1]}},quote:wn(e,t,r)}}function EB({block:e,placed:t}){let n=$z(),r=n.draft?.blockId===e.id&&n.draft.part.kind===`point`?n.draft.part:null,i=r&&wB(e,r,`draft`,!0),a=[...t.flatMap(({pin:e,place:t})=>t?.kind===`point`?[{id:e.id,category:t.row,series:t.series,draft:!1}]:[]),...i&&i.category!==null?[i]:[]];return(0,Q.jsx)(DB,{block:e,marks:a,pinnable:!n.readOnly,onPick:(t,r)=>{let i=TB(e,t,r);i&&n.startPin(i)}})}function DB(e){let{block:t,marks:n,pinnable:r,onPick:i,full:a=!1,onOpen:o}=e,s=(0,d.useMemo)(()=>Wt(t),[t]),c=(0,d.useRef)(null),l=SB(c),u=(0,d.useMemo)(()=>fn(s,l),[s,l]),[f,p]=(0,d.useState)(null),m=s.series.length>1,h=s.kind===`pie`,g=s.kind===`line`||s.kind===`area`,_=e=>s.highlight>=0&&e!==s.highlight,v=n.filter(e=>e.category!==null),y=(e,t,r=`points`)=>{if(!a)return{className:``};let i=n.filter(n=>pB(n,e,t));if(i.length===0)return{className:``};let o=i.some(e=>e.draft)?` is-asking`:` is-pinned`,s=i.filter(e=>r===`points`?e.category!==null:r===`series`&&e.category===null);return{className:`${o}${i.some(e=>e.open)?` is-open`:``}`,...s.length>0&&{"data-pair-anchor":s.map(e=>e.id).join(` `)}}},b=(e,t)=>a=>{if(a.shiftKey||a.metaKey||a.ctrlKey)return;if(r){a.stopPropagation(),i(e,m||e===null?t:null);return}let s=o&&n.find(n=>!n.draft&&pB(n,e,t));s&&(a.stopPropagation(),o(s.id))},x=(e,t)=>()=>p({category:e,series:t}),S=()=>p(null),C=e=>{let t=s.categories.length;if(e.key===`ArrowRight`||e.key===`ArrowLeft`){e.preventDefault(),e.stopPropagation();let n=e.key===`ArrowRight`?1:-1;p(e=>({category:e?(e.category+n+t)%t:n>0?0:t-1,series:null}))}else e.key===`Enter`&&f&&r?(e.preventDefault(),e.stopPropagation(),i(f.category,m?f.series:null)):e.key===`Escape`&&p(null)},{plot:w}=u,T=`${Bt[s.kind]} chart of ${s.series.map(e=>e.name).join(`, `)}${t.columns[0]?` by ${t.columns[0]}`:``}`,E=e=>h?[e,null]:[null,e];return(0,Q.jsxs)(`div`,{className:`chart is-${s.kind}`,children:[(0,Q.jsx)(OB,{block:t,model:s,...a&&{marked:e=>y(...E(e),h?`none`:`series`),pick:e=>b(...E(e)),pinnable:r}}),(0,Q.jsxs)(`div`,{ref:c,className:`chart-frame nopan`,tabIndex:0,"aria-label":`${T}. Arrow keys read the values; the Data tab shows them all.`,onKeyDown:C,onBlur:S,onPointerLeave:S,children:[u.width>0&&(0,Q.jsxs)(`svg`,{className:`chart-svg`,width:u.width,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,role:`img`,"aria-label":T,children:[!h&&(0,Q.jsxs)(`g`,{"aria-hidden":!0,children:[u.ticks.map(e=>(0,Q.jsx)(`line`,{className:`chart-grid`,x1:w.x,x2:w.x+w.w,y1:e.y,y2:e.y},e.value)),u.ticks.length>0&&(0,Q.jsx)(`line`,{className:`chart-baseline`,x1:w.x,x2:w.x+w.w,y1:u.zero,y2:u.zero}),u.ticks.map(e=>(0,Q.jsx)(`text`,{className:`chart-tick`,x:w.x-8,y:e.y+3.5,textAnchor:`end`,children:e.label},e.value)),u.caption&&(0,Q.jsx)(`text`,{className:`chart-tick`,x:u.caption.x,y:u.caption.y,children:u.caption.text}),u.axis.map(e=>(0,Q.jsx)(`text`,{className:`chart-axis`,x:e.x,y:w.y+w.h+16,textAnchor:e.anchor,children:e.text},e.category)),f&&!g&&u.bands[f.category]&&(0,Q.jsx)(`rect`,{className:`chart-band`,x:u.bands[f.category].x,y:w.y,width:u.bands[f.category].w,height:w.h})]}),u.lines.map(e=>{let{className:t,...n}=y(null,e.series,`none`);return(0,Q.jsxs)(`g`,{children:[e.area&&(0,Q.jsx)(`path`,{className:`chart-area`,d:e.area,style:{fill:hB(e.series)}}),(0,Q.jsx)(`path`,{className:`chart-line${t}`,d:e.path,style:{stroke:hB(e.series)},...n}),e.lone.map(t=>(0,Q.jsx)(`circle`,{className:`chart-dot`,cx:t.x,cy:t.y,r:3,style:{fill:hB(e.series)}},t.category))]},e.series)}),u.bars.map(e=>{let{className:t,...n}=y(e.category,e.series);return(0,Q.jsx)(`path`,{className:`chart-bar${_(e.category)?` is-faded`:``}${f?.category===e.category&&(f.series===null||f.series===e.series)?` is-hover`:``}${t}`,d:e.path,style:{fill:hB(e.series)},...n},`${e.category}-${e.series}`)}),u.slices.map(e=>{let{className:t,...n}=y(e.category,null);return(0,Q.jsx)(`path`,{className:`chart-slice${_(e.category)?` is-faded`:``}${f?.category===e.category?` is-hover`:``}${t}`,d:e.path,style:{fill:hB(e.category)},...n},e.category)}),u.ring&&(0,Q.jsxs)(`g`,{"aria-hidden":!0,children:[(0,Q.jsx)(`text`,{className:`chart-total`,x:u.ring.cx,y:u.ring.cy+2,textAnchor:`middle`,children:u.ring.total}),(0,Q.jsx)(`text`,{className:`chart-tick`,x:u.ring.cx,y:u.ring.cy+17,textAnchor:`middle`,children:u.ring.caption})]}),g&&f&&u.bands[f.category]&&(0,Q.jsxs)(`g`,{"aria-hidden":!0,children:[(0,Q.jsx)(`line`,{className:`chart-crosshair`,x1:u.bands[f.category].cx,x2:u.bands[f.category].cx,y1:w.y,y2:w.y+w.h}),u.lines.flatMap(e=>e.points.filter(e=>e.category===f.category).map(t=>(0,Q.jsx)(`circle`,{className:`chart-marker`,cx:t.x,cy:t.y,r:4,style:{fill:hB(e.series)}},e.series)))]}),u.markers.map(e=>(0,Q.jsx)(`circle`,{className:`chart-marker`,cx:e.x,cy:e.y,r:4,style:{fill:hB(e.series)}},`${e.series}-${e.x}`)),(0,Q.jsx)(`g`,{"aria-hidden":!0,children:u.labels.map((e,t)=>(0,Q.jsxs)(`g`,{children:[e.leader&&(0,Q.jsx)(`line`,{className:`chart-leader`,x1:e.leader.x1,y1:e.leader.y1,x2:e.leader.x2,y2:e.leader.y2}),(0,Q.jsx)(`text`,{className:e.strong?`chart-label is-strong`:`chart-label`,x:e.x,y:e.y,textAnchor:e.anchor,children:e.text})]},t))}),v.map(e=>{let t=CB(u,e.category,e.series);return t?(0,Q.jsx)(`circle`,{className:`chart-pin ${e.draft?`is-draft`:`is-linked`}${e.open?` is-open`:``}`,cx:t.x,cy:t.y,r:a?5.5:4.5,"data-pin-draft":e.draft?``:void 0,"data-pair-anchor":a?e.id:void 0},e.id):null}),(0,Q.jsxs)(`g`,{className:r?`chart-hits is-pinnable`:`chart-hits`,children:[u.bars.map(e=>(0,Q.jsx)(`rect`,{x:e.hit.x,y:e.hit.y,width:e.hit.w,height:e.hit.h,onPointerEnter:x(e.category,m?e.series:null),onClick:b(e.category,e.series)},`${e.category}-${e.series}`)),u.slices.map(e=>(0,Q.jsx)(`path`,{d:e.hit,onPointerEnter:x(e.category,null),onClick:b(e.category,null)},e.category)),g&&u.bands.map(e=>(0,Q.jsx)(`rect`,{x:e.x,y:w.y,width:e.w,height:w.h,onPointerEnter:x(e.category,null),onClick:b(e.category,null)},e.category)),g&&m&&u.lines.flatMap(e=>e.points.map(t=>(0,Q.jsx)(`circle`,{cx:t.x,cy:t.y,r:12,onPointerEnter:x(t.category,e.series),onClick:b(t.category,e.series)},`${e.series}-${t.category}`)))]})]}),f&&(0,Q.jsx)(kB,{model:s,layout:u,hover:f})]})]})}function OB(e){let{block:t,model:n,marked:r,pick:i,pinnable:a}=e,o=n.kind===`pie`,s=n.kind===`line`?`is-line`:``,c=o?n.categories.map((e,t)=>({name:e,i:t,note:bn(n,t)})):n.series.length>1?n.series.map((e,t)=>({name:e.name,i:t,note:``})):[];return c.length===0&&!t.subtitle?null:(0,Q.jsxs)(`div`,{className:`chart-top${c.length?``:` is-subtitle-only`}`,children:[c.length>0&&(0,Q.jsx)(`ul`,{className:`chart-legend${a?` is-pinnable`:``}`,"aria-label":`Legend`,children:c.map(e=>{let t=n.highlight>=0&&o&&e.i!==n.highlight?` is-faded`:``,{className:c=``,...l}=r?.(e.i)??{},u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`i`,{className:`chart-key ${s}`,style:{background:hB(e.i)},"aria-hidden":!0}),e.name,e.note&&(0,Q.jsx)(`span`,{className:`chart-legend-note`,children:e.note})]});return(0,Q.jsx)(`li`,{className:`${t}${c}`.trim()||void 0,...l,children:i?(0,Q.jsx)(`button`,{type:`button`,className:`chart-legend-pick`,onClick:i(e.i),title:a?`Ask about ${o?`this part`:`this whole series`}`:void 0,children:u}):u},e.i)})}),t.subtitle&&(0,Q.jsx)(`p`,{className:`chart-subtitle`,children:t.subtitle})]})}function kB({model:e,layout:t,hover:n}){let{category:r}=n,i=e.kind===`pie`,a=e.kind===`line`||e.kind===`area`,o=t=>e.series[t]?.values[r]??null,s;if(i)s=[{key:r,value:Xt(o(0),e.unit),name:bn(e,r)}];else if(a||n.series===null){let t=e.series.map((e,t)=>t);a&&t.sort((e,t)=>(o(t)??-1/0)-(o(e)??-1/0)),s=t.map(t=>({key:t,value:Xt(o(t),e.unit),name:e.series.length>1?e.series[t].name:void 0,strong:n.series===t}))}else s=[{key:n.series,value:Xt(o(n.series),e.unit),name:e.series.length>1?e.series[n.series].name:void 0}];if(e.kind===`stacked-bar`&&e.series.length>1){let t=e.series.reduce((e,t)=>e+(t.values[r]??0),0);s.push({key:-1,value:Xt(t,e.unit),name:`in all`})}let c=CB(t,r,a?null:n.series)??{x:t.bands[r]?.cx??t.width/2,y:t.plot.y},l=30+s.length*19,u=c.x+14+170>t.width,d=Math.max(2,Math.min(c.y-18,t.height-l-2));return(0,Q.jsxs)(`div`,{className:`chart-tip`,role:`status`,style:{left:u?c.x-14:c.x+14,top:d,transform:u?`translateX(-100%)`:void 0},children:[(0,Q.jsx)(`p`,{className:`chart-tip-head`,children:e.categories[r]||`Row ${r+1}`}),s.map(e=>(0,Q.jsxs)(`p`,{className:e.strong?`chart-tip-row is-on`:`chart-tip-row`,children:[e.key>=0&&(0,Q.jsx)(`i`,{className:`chart-key is-line`,style:{background:hB(e.key)},"aria-hidden":!0}),(0,Q.jsx)(`b`,{children:e.value}),e.name&&(0,Q.jsx)(`span`,{children:e.name})]},e.key))]})}function AB({block:e,selected:t}){let n=$z(),r=t&&!n.readOnly,i=(t,r)=>n.updateBlock(e,{columns:t,rows:r}),a=(t,n,r)=>{t<0?i(e.columns.map((e,t)=>t===n?r:e),e.rows):i(e.columns,e.rows.map((e,i)=>i===t?e.map((e,t)=>t===n?r:e):e))},o=()=>i([...e.columns,`Series ${e.columns.length}`],e.rows.map(e=>[...e,``])),s=t=>i(e.columns.filter((e,n)=>n!==t),e.rows.map(e=>e.filter((e,n)=>n!==t)));return(0,Q.jsxs)(`div`,{className:`block-table-wrap chart-data`,children:[(0,Q.jsxs)(`table`,{className:`block-table nopan`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[e.columns.map((t,n)=>(0,Q.jsxs)(`th`,{className:n?`is-number`:void 0,children:[(0,Q.jsx)(eB,{value:t,placeholder:n?`Series`:`Category`,onCommit:e=>a(-1,n,e)}),r&&n>0&&e.columns.length>2&&(0,Q.jsx)(`button`,{className:`cell-remove nodrag`,onClick:()=>s(n),title:`Remove series`,"aria-label":`Remove series`,children:(0,Q.jsx)($,{name:`x`})})]},n)),r&&e.columns.length<9&&(0,Q.jsx)(`th`,{className:`table-add-col`,children:(0,Q.jsx)(`button`,{className:`nodrag`,onClick:o,title:`Add a series`,"aria-label":`Add a series`,children:(0,Q.jsx)($,{name:`plus`})})})]})}),(0,Q.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,Q.jsxs)(`tr`,{children:[t.map((e,t)=>(0,Q.jsx)(`td`,{className:t?`is-number`:void 0,children:(0,Q.jsx)(eB,{value:e,placeholder:``,onCommit:e=>a(n,t,e)})},t)),r&&e.rows.length>1&&(0,Q.jsx)(`td`,{className:`table-row-remove`,children:(0,Q.jsx)(`button`,{className:`nodrag`,onClick:()=>i(e.columns,e.rows.filter((e,t)=>t!==n)),title:`Remove row`,"aria-label":`Remove row`,children:(0,Q.jsx)($,{name:`x`})})})]},n))})]}),r&&(0,Q.jsxs)(`button`,{className:`block-add nodrag`,onClick:()=>i(e.columns,[...e.rows,e.columns.map(()=>``)]),children:[(0,Q.jsx)($,{name:`plus`}),` Row`]}),e.unit&&(0,Q.jsxs)(`p`,{className:`chart-data-unit`,children:[`Numbers in `,e.unit]})]})}var jB=null;function MB(e){jB?.(!1);let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.body.appendChild(document.createElement(`div`));n.dataset.confirmDialog=``;let r=(0,f.createRoot)(n),i=e=>e.stopPropagation();for(let e of[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`,`touchstart`,`touchend`])n.addEventListener(e,i);return new Promise(i=>{let a=e=>{jB===a&&(jB=null,r.unmount(),n.remove(),!e&&t?.isConnected&&t.focus(),i(e))};jB=a,(0,Qx.flushSync)(()=>r.render((0,Q.jsx)(NB,{...e,onAnswer:a})))})}function NB({title:e,detail:t,confirmLabel:n,cancelLabel:r=`Cancel`,danger:i,onAnswer:a}){let o=(0,d.useRef)(null),s=(0,d.useRef)(null),c=(0,d.useRef)(null);return(0,d.useEffect)(()=>{s.current?.focus();let e=e=>{if(e.stopPropagation(),!(e.type!==`keydown`||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),a(!1);else if(e.key===`Enter`)e.preventDefault(),a(document.activeElement===c.current);else if(e.key===`Tab`){let t=[...o.current?.querySelectorAll(`button`)??[]];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?0:(n+(e.shiftKey?-1:1)+t.length)%t.length].focus()}}},t=e=>{o.current&&!o.current.contains(e.target)&&s.current?.focus()};for(let t of[`keydown`,`keyup`,`keypress`])window.addEventListener(t,e,!0);return window.addEventListener(`focusin`,t,!0),()=>{for(let t of[`keydown`,`keyup`,`keypress`])window.removeEventListener(t,e,!0);window.removeEventListener(`focusin`,t,!0)}},[a]),(0,Q.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&a(!1),children:(0,Q.jsxs)(`div`,{ref:o,className:`delete-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,"aria-describedby":t?`confirm-dialog-detail`:void 0,children:[(0,Q.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),t&&(0,Q.jsx)(`p`,{id:`confirm-dialog-detail`,children:t}),(0,Q.jsxs)(`div`,{className:`delete-actions`,children:[(0,Q.jsx)(`button`,{ref:s,type:`button`,className:`btn`,onClick:()=>a(!1),children:r}),(0,Q.jsx)(`button`,{ref:c,type:`button`,className:i?`btn btn-danger`:`btn btn-primary`,onClick:()=>a(!0),children:n})]})]})})}function PB(e,t){let n=`${t} comment${t===1?``:`s`}`;return MB({title:`Unpin ${e}?`,detail:`${e===`these words`?`Their`:`Its`} thread of ${n} is removed with the pin.`,confirmLabel:`Unpin and remove thread`,danger:!0})}var FB=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,IB=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function LB(e){let{quote:t,style:n,above:r,text:i,busy:a,error:o,agent:s,does:c,example:l,onText:u,onSubmit:f,onClose:p}=e,m=(0,d.useRef)(null),h=!i.trim(),g=(0,d.useRef)(i);return g.current=i,(0,d.useEffect)(()=>{let e=e=>{!m.current?.contains(e.target)&&!g.current.trim()&&p()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[p]),(0,Q.jsxs)(`div`,{ref:m,className:`pin-prompt pair-ask${r?` is-above`:``}`,style:n,role:`dialog`,"aria-label":`Ask about this part`,onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!h&&!a&&f(!0))},children:[(0,Q.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,Q.jsx)(`p`,{className:`pin-prompt-quote`,children:t}),(0,Q.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:p,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(LE,{skills:!0,lenses:QT,rows:2,value:i,placeholder:s?`Ask ${s} to change it (${l}), or leave a note`:`Ask an agent to change it (${l}), or leave a note; @ to pick an agent`,"aria-label":`What should change here?`,autoFocus:!0,onValue:u}),o&&(0,Q.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,Q.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:h||a,onClick:()=>f(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:h||a,onClick:()=>f(!1),children:`Add a note`}),(0,Q.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${FB}+Enter asks ${s??`an agent`}`,children:FB===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,Q.jsxs)(`p`,{className:`pin-prompt-hint`,children:[s??`An agent`,` `,c,` and replies here`,s?`, with its steps on the pin as it works`:``,`. A note just stays on the part.`]})]})}function RB(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=$z(),s=as(t,Zz(o)),c=t.discussion?.resolved,l=s.some(e=>e.ask),u=!c&&s.at(-1)?.author.kind===`human`,d=!c&&!n&&o.newItems.has(t.id),f=[`pin-chip`,`is-comment`,`pair-pin-chip`,l&&`is-ask`,c&&`is-done`,i&&`is-lost`,d&&`is-new`,n&&`is-open`],p=l?`Asked agents to change`:`Notes on`,m=c?`, resolved by ${c.by.name}`:l&&u?`, waiting for an agent`:``;return(0,Q.jsxs)(`span`,{className:f.filter(Boolean).join(` `),"data-chip-pin":t.id,"data-pin-skip":``,onMouseDown:e=>e.stopPropagation(),onMouseUp:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} ${t.quote}: ${IB(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,Q.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,Q.jsx)($,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,Q.jsx)($,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,Q.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await PB(`this part`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin ${t.quote}`,title:`Unpin. Its thread goes with it.`,children:(0,Q.jsx)($,{name:`x`})})]})}var zB=`draft`;function BB(e,t,n=0){let r=new Set([n,n+e]);for(let i of t)for(let t of[i.start,i.end])t>n&&t<n+e&&r.add(t);let i=[...r].sort((e,t)=>e-t);return i.slice(0,-1).map((e,n)=>{let r=i[n+1];return{start:e,end:r,covering:t.filter(t=>t.start<=e&&t.end>=r)}})}function VB(e,t){return e.some(e=>e.id===`draft`)?`pin-mark is-draft`:t&&e.some(e=>e.id===t)?`pin-mark is-focus`:`pin-mark`}var HB=new Set([`p`,`li`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`blockquote`,`pre`,`td`,`th`]);function UB({marks:e,focus:t,chips:n=!0,ids:r=!1}){return i=>{if(e.length===0)return;let a=[],o=``,s=(e,t)=>{for(let n of e.children)n.type===`text`?(a.push({node:n,parent:e,block:t,start:o.length}),o+=n.value):n.type===`element`&&s(n,HB.has(n.tagName)?n:t)};s(i,i);let c=e.flatMap(e=>{let t=Jo(o,e.quote,e);return t?[{id:e.id,...t}]:[]});if(c.length===0)return;let l=new Map;for(let{node:e,parent:i,block:o,start:s}of a){let a=BB(e.value.length,c,s).map(i=>{let a=e.value.slice(i.start-s,i.end-s);if(i.covering.length===0||!a.trim())return{type:`text`,value:a};for(let e of i.covering)n&&e.end===i.end&&e.id!==`draft`&&l.set(o,[...l.get(o)??[],e.id]);let c=i.covering.some(e=>e.id===zB);return{type:`element`,tagName:`mark`,properties:{className:VB(i.covering,t).split(` `),dataPinDraft:c||void 0,dataPins:r?i.covering.map(e=>e.id).join(` `):void 0},children:[{type:`text`,value:a}]}});i.children.splice(i.children.indexOf(e),1,...a)}for(let[e,t]of l)for(let n of t)e.children.push({type:`element`,tagName:`mark`,properties:{dataChip:n},children:[]})}}function WB({node:e,children:t,...n}){let{pins:r}=$z(),i=n,a=i[`data-chip`];if(a){let e=[...r.values()].flat().find(e=>e.id===a);return e?(0,Q.jsx)(KB,{pin:e}):null}return(0,Q.jsx)(`mark`,{className:n.className,"data-pin-draft":i[`data-pin-draft`]?``:void 0,children:t})}function GB({text:e,marks:t,focus:n}){return t.length===0?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(Q.Fragment,{children:BB(e.length,t).map(t=>{let r=e.slice(t.start,t.end);if(t.covering.length===0)return(0,Q.jsx)(`span`,{children:r},t.start);let i=t.covering.some(e=>e.id===zB);return(0,Q.jsx)(`mark`,{className:VB(t.covering,n),"data-pin-draft":i?``:void 0,children:r},t.start)})})}function KB({pin:e,part:t,lost:n}){let{board:r,readOnly:i,removeItem:a,focusPin:o}=$z(),s=mx(),c=ts(r,e);if(e.discussion)return(0,Q.jsx)(JB,{pin:e,part:t,lost:n});if(!c)return null;let[l]=Mt(e),u=l&&s.byId(l.kind,r.id,l.id),d=[`pin-chip`,`nodrag`,`nopan`,c.done&&`is-done`,n&&`is-lost`,o===e.id&&`is-focus`],f=`${c.ref}: ${c.title}${n?` (pinned ${Do(e.anchor.kind)?.words?`words`:`part`} changed since)`:``}`,p=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-dot`,"aria-hidden":!0}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-part`,children:t}),n&&(0,Q.jsx)(`span`,{className:`pin-chip-lost`,children:n}),(0,Q.jsx)($,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,Q.jsx)(`span`,{className:`pin-chip-ref`,children:c.ref}),(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:c.status})]});return(0,Q.jsxs)(`span`,{className:d.filter(Boolean).join(` `),"data-pin-skip":``,"data-chip-pin":e.id,onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[u?(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-open`,onClick:()=>u.open(),title:f,children:p}):(0,Q.jsx)(`span`,{className:`pin-chip-open`,title:f,children:p}),!i&&(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:()=>a(e.id),"aria-label":`Unpin ${t??`“${e.quote}”`} from ${c.ref}`,title:`Unpin. ${c.ref} stays.`,children:(0,Q.jsx)($,{name:`x`})})]})}var qB=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function JB({pin:e,part:t,lost:n}){let r=$z(),{readOnly:i,removeItem:a,focusPin:o,newItems:s,thread:c}=r,l=as(e,Zz(r)),u=!!e.discussion?.thread,d=e.discussion?.resolved,f=c===e.id,p=u&&!d&&!f&&s.has(e.id),m=[`pin-chip`,`is-comment`,`nodrag`,`nopan`,d&&`is-done`,n&&`is-lost`,p&&`is-new`,f&&`is-open`,o===e.id&&`is-focus`],h=u?`${qB(l.length,`comment`)} on this part${d?`, resolved by ${d.by.name}`:``}`:`${qB(l.length,`comment`)} on this part in the discussion`;return(0,Q.jsxs)(`span`,{className:m.filter(Boolean).join(` `),"data-pin-skip":``,"data-chip-pin":e.id,onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:()=>u?r.openThread(e.id):JE(l.map(e=>e.id)),title:u?h:`${h}. Show ${l.length===1?`it`:`them`}.`,"aria-expanded":u?f:void 0,children:[t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-part`,children:t}),n&&(0,Q.jsx)(`span`,{className:`pin-chip-lost`,children:n}),(0,Q.jsx)($,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,Q.jsx)($,{name:d?`check`:`comment`,className:`pin-chip-icon`}),(0,Q.jsx)(`span`,{className:`pin-chip-ref`,children:l.length}),d&&(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}),p&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!i&&(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{u&&l.length&&!await PB(`this part`,l.length)||a(e.id)},"aria-label":`Unpin ${t??`“${e.quote}”`}`,title:u?`Unpin. Its thread goes with it.`:`Unpin. Its comments stay in the discussion.`,children:(0,Q.jsx)($,{name:`x`})})]})}function YB({block:e,placed:t}){let n=t.filter(({pin:t,place:n})=>!n||Do(t.anchor.kind,e)?.drawn||t.anchor.kind===`block`&&!Eo(e.type).pins?.whole);return n.length===0?null:(0,Q.jsx)(`div`,{className:`pin-strip`,"data-pin-skip":``,children:n.map(({pin:t,place:n})=>(0,Q.jsx)(KB,{pin:t,part:Zo(t,e),lost:n?void 0:$o(t,e)},t.id))})}function XB(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest(`[data-pin-skip]`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),n=[];for(;t.nextNode();)n.push(t.currentNode);return n}function ZB(e,t,n){let r=document.createRange();r.setStart(t,n);let i=0;for(let a of e){if(a===t)return i+n;if(r.comparePoint(a,a.length)>0)return i;i+=a.length}return i}function QB(e,t){let n=XB(e),r=n.map(e=>e.data).join(``),i=ZB(n,t.startContainer,t.startOffset),a=ZB(n,t.endContainer,t.endOffset),o=a>i?Uo(r,i,a):null;return o&&{kind:`text`,...o}}function $B(e){return e.shiftKey||e.metaKey||e.ctrlKey?null:e.target?.closest?.(`[data-pin-text][data-block-id]`)??null}function eV(e,t){if(!e?.isConnected||!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);return n.intersectsNode(e)?QB(e,n):null}function tV(e){let t=XB(e);return{text:t.map(e=>e.data).join(``),at:(e,n)=>ZB(t,e,n)}}function nV(){let e=(0,d.useRef)(void 0);return(0,d.useEffect)(()=>()=>clearTimeout(e.current),[]),{later:t=>{clearTimeout(e.current),e.current=setTimeout(t,240)},cancel:()=>clearTimeout(e.current)}}function rV({part:e,block:t}){return(0,Q.jsx)(Q.Fragment,{children:Qo(e,t)})}var iV=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,aV={id:`comment`,label:`Comment`,does:`comments`},oV={placeholder:`A comment on this part`,label:`Comment`,hint:``,line:`Click a line to comment on it`,becomes:`a comment`};function sV(){let e=mx().pinWords(null)??oV;return{line:e.line??oV.line,becomes:e.becomes??oV.becomes}}function cV(e,t){let n=e.pinActions({card:t});return{offered:n,acts:[...n.filter(e=>!e.afterComment),aV,...n.filter(e=>e.afterComment)]}}function lV(e){let{draft:t,block:n,name:r,style:i,above:a,onChange:o,onClose:s,onCommented:c}=e,l=$z(),u=mx(),f=Ft(Zz(l))?.kind.kind??null,{offered:p,acts:m}=cV(u,f),h=u.pinWords(f)??oV,g=m[0],_=(0,d.useRef)(null),v=(0,d.useRef)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(null),D=!y.trim(),O=n?BY(n.type).PinScope:void 0,k=(0,d.useRef)(y);k.current=y,(0,d.useEffect)(()=>{let e=e=>{!_.current?.contains(e.target)&&!k.current.trim()&&s()},t=e=>e.key===`Escape`&&s();return document.addEventListener(`mousedown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e,!0),document.removeEventListener(`keydown`,t)}},[s]),(0,d.useEffect)(()=>{v.current?.focus({preventScroll:!0})},[t]);let A=async e=>{if(!(D||C)){w(!0),E(null);try{if(e.make)await e.make(t.blockId,r,{part:t.part,text:y,ready:x});else{let{pin:e,comment:n}=await X.pinComment(t.blockId,r,{part:t.part,body:y});c(e,n)}s()}catch(e){E(e.message),w(!1)}}};return(0,Q.jsxs)(`div`,{ref:_,className:`pin-prompt nodrag nopan nowheel${a?` is-above`:``}`,style:i,role:`dialog`,"aria-label":`Pin this part`,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),A(g))},children:[(0,Q.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,Q.jsx)(`p`,{className:`pin-prompt-quote`,children:(0,Q.jsx)(rV,{part:{anchor:t.part,quote:t.quote},block:n})}),(0,Q.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:s,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),n&&O&&(0,Q.jsx)(O,{draft:t,block:n,onChange:o}),(0,Q.jsx)(LE,{skills:!0,lenses:QT,ref:v,rows:2,value:y,placeholder:h.placeholder,"aria-label":h.label,onValue:e=>{b(e),E(null)},onKeyDown:e=>{let n=e.currentTarget;e.key===`c`&&(e.metaKey||e.ctrlKey)&&n.selectionStart===n.selectionEnd&&navigator.clipboard?.writeText(t.quote).catch(()=>{})}}),T&&(0,Q.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:T}),(0,Q.jsxs)(`div`,{className:`pin-prompt-actions${m.length>2?` is-three`:``}`,children:[m.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small${e===g?` btn-primary`:``}`,disabled:D||C,onClick:()=>void A(e),children:e.label},e.id)),p.some(e=>e.ready)&&(0,Q.jsxs)(`label`,{className:`pin-ready`,title:h.ready?.title,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),h.ready?.label??`Ready now`]}),(0,Q.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${iV}+Enter ${g.does}`,children:iV===`⌘`?`⌘↵`:`Ctrl ↵`})]}),h.hint&&(0,Q.jsx)(`p`,{className:`pin-prompt-hint`,children:h.hint})]})}function uV(e){let{pin:t,block:n,name:r,style:i,above:a,inline:o,onClose:s,onHeight:c,live:l,address:u}=e,f=$z(),{readOnly:p,pins:m}=f,h=(0,d.useRef)(null),g=(0,d.useRef)(null),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(null),C=as(t,Zz(f)),w=!!t.discussion?.thread,T=t.discussion?.resolved,E=(m.get(t.blockId)??[]).filter(e=>e!==t&&!e.discussion&&es(e.anchor,t.anchor,n)),D=!T&&C.at(-1)?.author.kind===`human`,O=C.some(e=>e.ask),k=(0,d.useRef)(_);k.current=_,(0,d.useEffect)(()=>{if(o)return;let e=e=>{let n=e.target;h.current?.contains(n)||n.closest?.(`[data-chip-pin="${CSS.escape(t.id)}"]`)||k.current.trim()||s()},n=e=>e.key===`Escape`&&s();return document.addEventListener(`mousedown`,e,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`mousedown`,e,!0),document.removeEventListener(`keydown`,n)}},[s,t.id,o]),(0,d.useEffect)(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[C.length]),(0,d.useLayoutEffect)(()=>{h.current&&c?.(h.current.offsetHeight)});let A=async(e,t)=>{if(!y){b(!0),S(null);try{await e(),t?.()}catch(e){S(e.message)}finally{b(!1)}}},j=()=>_.trim()&&void A(()=>X.commentOnPin(t.id,r,u?u(_):_),()=>v(``));return(0,Q.jsxs)(`div`,{ref:h,className:`pin-prompt pin-thread nodrag nopan nowheel${a?` is-above`:``}${T?` is-resolved`:``}${o?` is-inline`:``}`,style:i,role:o?`region`:`dialog`,"aria-label":`Comments on this part`,onMouseDown:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,Q.jsx)(`p`,{className:`pin-prompt-quote`,children:(0,Q.jsx)(rV,{part:t,block:n})}),(0,Q.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:s,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(`ol`,{className:`pin-thread-comments`,ref:g,children:C.map(e=>(0,Q.jsxs)(`li`,{className:`pin-thread-comment comment-${e.author.kind}`,children:[(0,Q.jsxs)(`div`,{className:`comment-head`,children:[(0,Q.jsx)(ix,{actor:e.author}),` `,(0,Q.jsx)(`span`,{className:`faint small`,children:ex(e.createdAt)}),e.ask&&(0,Q.jsx)(`span`,{className:`pin-thread-ask`,children:`Asked agents`}),(0,Q.jsx)(hE,{lens:e.lens}),(0,Q.jsx)(gE,{via:e.via}),(0,Q.jsx)(_E,{comment:e,thread:C})]}),(0,Q.jsx)(mE,{comment:e}),(0,Q.jsx)(VE,{item:e,place:{pinId:t.id},name:r})]},e.id))}),(()=>{let e=D&&(0,Q.jsx)(`p`,{className:`pin-thread-note`,children:O?`Agents see this request in their updates, ${Do(t.anchor.kind,n)?.askedTo??`act on it`} and reply here.`:`Agents see this in their updates and reply here.`});return l?l(e):e})(),E.length>0&&(0,Q.jsxs)(`div`,{className:`pin-thread-also`,children:[(0,Q.jsx)(`span`,{children:`Pinned here too`}),E.map(e=>(0,Q.jsx)(KB,{pin:e},e.id))]}),T&&(0,Q.jsxs)(`p`,{className:`pin-thread-resolved`,children:[(0,Q.jsx)($,{name:`check`}),` Resolved by `,T.by.name,` `,ex(T.at)]}),!p&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(LE,{skills:!0,lenses:QT,rows:2,value:_,placeholder:T?`Reply to reopen it`:`Reply (${iV===`⌘`?`⌘↵`:`Ctrl ↵`} to send)`,"aria-label":`Reply`,onValue:e=>{v(e),S(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),j())}}),x&&(0,Q.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:x}),(0,Q.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,disabled:!_.trim()||y,onClick:j,children:`Reply`}),w&&(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:y,onClick:()=>void A(()=>X.resolvePin(t.id,r,!T),T?void 0:s),title:T?`Open the thread again`:`Mark the thread resolved: its chip goes quiet`,children:T?`Reopen`:`Resolve`})]})]})]})}var dV=e=>`of`in e;function fV(e,t,n,r){let i=$z(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),f=a&&n&&dV(n)?n:null,p=(0,d.useCallback)(()=>{n&&r&&(u(null),o(t=>t??{base:e,text:dV(n)?n.of(e):``}))},[n,r,e]),m=(0,d.useCallback)(()=>{o(null),u(null)},[]),h=(0,d.useRef)(null),g=(0,d.useCallback)(async()=>{if(h.current)return h.current;if(!a||!n)return!0;if(!dV(n))return o(null),!0;let{base:r,text:i}=a;if(i===n.of(r))return o(null),u(null),!0;let s=n.check?.(i);if(s)return u(s),!1;if(e.rev!==r.rev)return!1;let l=(async()=>{c(!0);try{return await X.updateBlock(e.id,t,{...n.patch(i),rev:r.rev}),o(null),u(null),!0}catch(e){return e.status!==409&&u(e.message),!1}finally{c(!1),h.current=null}})();return h.current=l,l},[a,n,e,t]);(0,d.useEffect)(()=>{r||o(null)},[r]);let _=f&&a&&e.rev!==a.base.rev?e.updatedBy.name:null,v=(0,d.useCallback)(()=>o(t=>t&&{...t,base:e}),[e]),y=(0,d.useCallback)(()=>{n&&dV(n)&&o({base:e,text:n.of(e)}),u(null)},[n,e]),b=(0,d.useCallback)(e=>{o(t=>t&&{...t,text:e}),u(null)},[]),x=null;return a&&n&&(x=dV(n)?(0,Q.jsx)(mV,{edit:n,block:e,text:a.text,onText:b,onEnter:()=>void g()}):n.live({block:e,save:t=>i.updateBlock(e,t)})),{on:!!a,live:!!(a&&n&&!dV(n)),text:a?.text??``,saving:s,error:l,theirs:_,start:p,stop:g,discard:m,keepMine:v,takeTheirs:y,setText:b,editor:x}}var pV=250;function mV({edit:e,block:t,text:n,onText:r,onEnter:i}){let[a,o]=(0,d.useState)(n);(0,d.useEffect)(()=>{let e=setTimeout(()=>o(n),pV);return()=>clearTimeout(e)},[n]);let s=e.single?(0,Q.jsx)(`input`,{autoFocus:!0,className:`piece-edit-input`,value:n,placeholder:e.placeholder,"aria-label":e.label,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&i()}):(0,Q.jsx)(`textarea`,{autoFocus:!0,className:`piece-edit-text${e.code?` is-code`:``}`,value:n,placeholder:e.placeholder,spellCheck:!e.code,"aria-label":e.label,onChange:e=>r(e.target.value)});return(0,Q.jsxs)(`div`,{className:`piece-edit${e.preview?` has-preview`:``}${e.single?` is-single`:``}`,children:[(0,Q.jsxs)(`div`,{className:`piece-edit-field`,children:[(0,Q.jsx)(`span`,{className:`piece-edit-label`,children:e.label}),s]}),e.preview&&(0,Q.jsxs)(`div`,{className:`piece-edit-preview`,"aria-label":`Preview`,children:[(0,Q.jsx)(`span`,{className:`piece-edit-label`,children:`Preview`}),(0,Q.jsx)(`div`,{className:`piece-edit-shown`,children:e.preview(a,t)})]})]})}var hV=6e4,gV=2e3;function _V(e,t,n){return xc(e,[...n,t]).length>0?e:`@${t} ${e.trimStart()}`}function vV(e,t){return!!e.mentions?.some(e=>U(e,t))||/\?["”’)\]]*\s*$/.test(e.body.trim())}function yV(e,t,n){let r=Date.parse(n.startedAt)-gV,i=[];for(let a of e){if(a.blockId!==n.blockId||!a.discussion)continue;let e=as(a,t),o=e.filter(e=>e.author.kind===`human`&&U(e.author.name,n.person)&&Date.parse(e.createdAt)>=r&&e.mentions?.some(e=>U(e,n.agent)));if(o.length===0)continue;let s=o.at(-1),c=e.slice(e.indexOf(s)+1),l=c.filter(e=>e.author.kind===`agent`),u=l.findLast(e=>U(e.author.name,n.agent))??l.at(-1),d=u&&!c.slice(c.indexOf(u)+1).some(e=>e.author.kind===`human`),f=d?vV(u,n.person)?`waiting`:`done`:a.discussion.resolved?`done`:`working`;i.push({pin:a,asked:o[0],latest:s,state:f,...d&&{reply:u}})}return i.sort((e,t)=>Date.parse(e.asked.createdAt)-Date.parse(t.asked.createdAt))}var bV=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function xV(e){if(e.length===0)return`no requests`;let t=e.filter(e=>e.state===`done`).length;return`${bV(e.length,`request`)}, ${t} done, ${e.length-t} open`}function SV(e,t){return e.state===`working`&&e.step?`${e.agent} is on it · ${GS(e.step)}`:FS(e,t)}function CV(e){return H(Cc(e.asked.body,e.asked.mentions??[]),120)}var wV=5e3;function TV(e){let t=$z(),n=uT(),r=Gw(),[i,a]=(0,d.useState)(()=>Date.now()),o=as(e,Zz(t)),s=Math.max(i,Date.now()),c=o.findLastIndex(e=>e.author.kind===`human`),l=c>=0?o[c]:void 0,u=t.owner?{[t.owner.kind]:t.owner.card}:{boardContext:!0},f=r.filter(e=>Rw(e,s)||e.done),p=l&&!t.readOnly&&XS({at:l.createdAt},s)?PS({board:t.board,where:u,said:{id:l.id,author:l.author,at:l.createdAt,mentions:l.mentions,reactions:l.reactions,held:l.held,paired:l.paired},after:o.slice(c+1),agents:n,steps:f}):void 0,m=p&&SV(p,s);if((0,d.useEffect)(()=>{if(!m)return;let e=setInterval(()=>a(Date.now()),wV);return()=>clearInterval(e)},[!!m]),p&&m&&l)return{delivery:p,words:m,said:l,busy:KS(p,e=>Rw(e,s)===`live`)}}function EV({pin:e,fallback:t=null}){let n=TV(e);if(!n)return(0,Q.jsx)(Q.Fragment,{children:t});let{delivery:r,words:i,busy:a,said:o}=n,s=r.state===`working`;return(0,Q.jsxs)(`p`,{className:`delivery pin-live is-${r.state}`,title:YS(i,{at:o.createdAt},Date.now()),children:[(0,Q.jsx)(`span`,{className:`delivery-text`,"aria-hidden":!0,children:(0,Q.jsx)(Jw,{text:i})},i),(0,Q.jsx)(sT,{state:a}),(0,Q.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:s?`${r.agent} is working on it`:i})]})}function DV(e){if(e.status!==`backlog`)return e.assignee?e.assignee:e.claimedBy?.kind===`agent`&&e.status!==`todo`?e.claimedBy.name:void 0}function OV(e,t){let n=[],r=e=>{e&&!n.some(t=>U(t,e))&&n.push(e)};t.task&&r(DV(t.task));let i=e.author.kind===`agent`?e.author.name:void 0;for(let n of t.threads??[])pc(n,{kind:`block`,id:e.id})&&r(n.lens?.agent??i);return n}function kV({agents:e,picked:t,named:n=[],last:r}){let i=t=>t?e.find(e=>U(e.name,t)):void 0,a=i(t);if(a)return a.name;let o=n.length===1?i(n[0]):void 0;if(o)return o.name;for(let t of[`listening`,`asleep`,`working`]){let n=e.filter(e=>e.state===t);if(n.length)return(n.find(e=>r&&U(e.name,r))??n[0]).name}return e[0]?.name??null}var AV=`tricot:pair-agent`;function jV(){try{return localStorage.getItem(AV)}catch{return null}}function MV(e){try{localStorage.setItem(AV,e)}catch{}}function NV(e,t,n,r={}){let i=$z(),{board:a,owner:o}=i,s=i.readOnly||!!r.readOnly,c=uT(),[l,u]=(0,d.useState)(`browse`),[f,p]=(0,d.useState)(null),[m]=(0,d.useState)(jV),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),y=(0,d.useRef)(null);y.current=h;let b=(0,d.useRef)(!1),[x,S]=(0,d.useState)(!1),C=(0,d.useRef)(`browse`),w=(0,d.useRef)(!1),T=(0,d.useMemo)(()=>gc(a,c.map(e=>e.name)).map(e=>{let t=c.find(t=>U(t.name,e));return t?{name:t.name,state:t.state,lastSeen:t.lastSeen}:{name:e,state:`unseen`}}),[a,c]),E=a.threads,D=kV({agents:T,picked:f,named:(0,d.useMemo)(()=>OV(e,{task:o?.card,threads:E}),[e,o,E]),last:m}),O=(0,d.useCallback)(async e=>{let n=y.current;if(n){y.current=null,g(null);try{let{summary:r}=await X.endPairing(n.id,t);v(e(r))}catch{v(e())}}},[t]),k=(0,d.useCallback)(async r=>{try{let i=await X.startPairing(t,{blockId:e.id,part:n,agent:r});if(C.current!==`pair`)return void X.endPairing(i.id,t).catch(()=>void 0);y.current=i,g(i),p(i.agent),MV(i.agent)}catch(e){v(`Couldn't start pairing with ${r}: ${e.message}`)}},[t,e.id,n]),A=(0,d.useCallback)(e=>{if(s)return;let t=e??D;if(e&&(p(e),MV(e)),u(`pair`),C.current=`pair`,v(null),!t||b.current)return;let n=y.current;n&&U(n.agent,t)||(b.current=!0,S(!0),(async()=>{n&&await O(e=>e??null),await k(t),b.current=!1,S(!1)})())},[s,D,O,k]),j=(0,d.useCallback)(()=>{u(`browse`),C.current=`browse`,O(e=>e??null)},[O]);(0,d.useEffect)(()=>{if(!h)return;let e=()=>w.current=!0;document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0);let n=setInterval(()=>{let e=w.current;w.current=!1,X.pairingBeat(h.id,t,e).catch(e=>{e.status===404&&y.current?.id===h.id&&(y.current=null,g(null),u(`browse`),C.current=`browse`,v(`Pairing with ${h.agent} ended: nothing was asked for a while, or it moved to another tab.`))})},hV),r=()=>y.current&&X.leavePairing(y.current.id,t);return window.addEventListener(`pagehide`,r),()=>{clearInterval(n),document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pagehide`,r)}},[h,t]),(0,d.useEffect)(()=>()=>{C.current=`browse`,y.current&&X.leavePairing(y.current.id,t),y.current=null},[t]);let M=i.pins.get(e.id),N=(0,d.useMemo)(()=>h?yV(M??[],Zz({owner:o}),h):[],[h,M,o]),P=(0,d.useMemo)(()=>T.map(e=>e.name),[T]);return{mode:l,agent:D,agents:T,session:h,requests:N,note:_,readOnly:s,busy:x,pair:A,browse:j,dismissNote:()=>v(null),address:(0,d.useCallback)(e=>l===`pair`&&D?_V(e,D,P):e,[l,D,P])}}function PV({pairing:e,open:t,onOpen:n}){let{requests:r,agent:i,session:a}=e,o=i??`an agent`;return(0,Q.jsxs)(`aside`,{className:`pair-list`,"aria-label":`Asked while pairing`,children:[(0,Q.jsxs)(`div`,{className:`pair-list-head`,children:[(0,Q.jsx)(`h3`,{children:`This session`}),r.length>0&&(0,Q.jsx)(`span`,{className:`faint small`,children:xV(r)})]}),r.length===0?(0,Q.jsx)(`p`,{className:`pair-list-empty`,children:a||!i?`Point at any part and ask ${o}. What you ask shows here, with what ${o} is doing about it.`:`Starting a session with ${o}…`}):(0,Q.jsx)(`ol`,{className:`pair-requests`,children:r.map((e,r)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,className:`pair-request is-${e.state}${e.pin.id===t?` is-open`:``}`,onClick:()=>n(e.pin),children:[(0,Q.jsx)(`span`,{className:`pair-request-n`,children:r+1}),(0,Q.jsxs)(`span`,{className:`pair-request-main`,children:[(0,Q.jsx)(`span`,{className:`pair-request-text`,children:CV(e)}),(0,Q.jsx)(`span`,{className:`pair-request-part`,children:H(e.pin.quote,60)}),(0,Q.jsx)(FV,{request:e,agent:o})]})]})},e.pin.id))})]})}function FV({request:e,agent:t}){return e.state===`done`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`pair-request-state is-done`,children:[(0,Q.jsx)($,{name:`check`}),` Done`]}),e.reply&&(0,Q.jsx)(`span`,{className:`pair-request-reply`,children:H(e.reply.body,90)})]}):e.state===`waiting`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pair-request-state is-waiting`,children:(0,Q.jsx)(`span`,{className:`tag tag-waiting`,children:`Waiting on you`})}),e.reply&&(0,Q.jsx)(`span`,{className:`pair-request-reply`,children:H(e.reply.body,90)})]}):(0,Q.jsx)(IV,{request:e,agent:t})}function IV({request:e,agent:t}){let n=TV(e.pin);return(0,Q.jsxs)(`span`,{className:`pair-request-state is-working`,children:[(0,Q.jsx)(sT,{state:n?.busy}),(0,Q.jsx)(Jw,{text:n?.words??`Sent to ${t}`})]})}var LV={current:null},RV=()=>nu(LV),zV={listening:`listening`,asleep:`asleep`,working:`working`,away:`not checking`,unseen:`not on the board now`};function BV(e,t){switch(e?.state){case`listening`:return`${t} is listening, so it picks up each request at once.`;case`asleep`:return`${t} is asleep: Tricot wakes it for each request, and it picks it up within a few seconds.`;case`working`:return`${t} is busy; it picks up your requests as soon as it next checks the board.`;default:return`${t} isn't checking the board now: your requests wait for it. Say “Start listening on Tricot” in its session.`}}function VV(e){let{pairing:t,edit:n,label:r,icon:i,title:a,from:o,fromTitle:s,browse:c,pairHint:l,pairBand:u,band:f,controls:p,open:m,onOpenRequest:h,onClose:g,className:_,foot:v,children:y}=e,b=t.mode===`pair`;return(0,d.useEffect)(()=>{let e=e=>{e.key!==`Backspace`&&e.key!==`Delete`||Xl(e.target)||e.stopPropagation()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Q.jsxs)(`div`,{className:`pair-shell nowheel nodrag nopan${b?` is-pairing`:``}${_?` ${_}`:``}`,role:`dialog`,"aria-modal":`true`,"aria-label":r,children:[(0,Q.jsxs)(`header`,{className:`pair-bar`,children:[(0,Q.jsx)(`span`,{className:`pair-icon`,"aria-hidden":!0,children:i}),(0,Q.jsxs)(`div`,{className:`pair-title`,children:[(0,Q.jsx)(`h2`,{children:a}),(0,Q.jsx)(`p`,{className:`muted small`,title:s,children:o})]}),!t.readOnly&&(0,Q.jsx)(HV,{pairing:t,edit:n,browse:c,pairHint:l}),p&&(0,Q.jsx)(`div`,{className:`pair-controls`,children:p}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet pair-close`,onClick:g,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),b&&(0,Q.jsx)(`div`,{className:`pair-band`,role:`status`,children:u}),t.note&&(0,Q.jsxs)(`div`,{className:`pair-band is-note`,role:`status`,children:[(0,Q.jsx)(`span`,{children:t.note}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-band-close`,onClick:t.dismissNote,"aria-label":`Dismiss`,children:(0,Q.jsx)($,{name:`x`})})]}),f,(0,Q.jsxs)(`div`,{className:`pair-main`,children:[(0,Q.jsx)(`div`,{className:`pair-body`,children:y}),b&&(0,Q.jsx)(PV,{pairing:t,open:m,onOpen:h})]}),v]})}function HV({pairing:e,edit:t,browse:n,pairHint:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null);Zl(i,(0,d.useCallback)(()=>a(!1),[]),o);let s=e.mode===`pair`,c=!!t?.on,l=!s&&!c,{agent:u}=e,f=e.agents.find(e=>e.name===u),p=n=>{if(!t?.on)return e.pair(n);t.stop().then(t=>t&&e.pair(n))};return(0,Q.jsxs)(`div`,{className:`pair-modes`,role:`group`,"aria-label":`Mode`,ref:o,children:[(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${l?` is-on`:``}`,"aria-pressed":l,onClick:()=>t?.on?void t.stop():e.browse(),title:n.hint,children:n.label}),t&&(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${c?` is-on`:``}`,"aria-pressed":c,onClick:()=>!c&&t.start(),title:t.hint,children:`Edit`}),(0,Q.jsxs)(`span`,{className:`pair-mode pair-mode-pair${s?` is-on`:``}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`pair-mode-main`,"aria-pressed":s,disabled:e.busy,onClick:()=>p(),title:u?`${r} ${BV(f,u)}`:r,children:[u&&(0,Q.jsx)(`span`,{className:`live-dot pair-dot live-${f?.state??`away`}`,"aria-hidden":!0}),u?`Pair with ${u}`:`Pair`]}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode-pick`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-label":`Choose the agent to pair with`,title:`Choose the agent to pair with`,disabled:e.busy,onClick:()=>a(e=>!e),children:(0,Q.jsx)($,{name:`chevron-down`})})]}),i&&(0,Q.jsx)(UV,{pairing:e,onPick:e=>{a(!1),p(e)}})]})}function UV({pairing:e,onPick:t}){let{agents:n,agent:r}=e;return(0,Q.jsxs)(`div`,{className:`pair-picker`,role:`menu`,"aria-label":`Pair with`,children:[n.length===0?(0,Q.jsx)(`p`,{className:`pair-picker-empty`,children:`No agent has been on this board yet. Connect one, and it shows here.`}):(0,Q.jsx)(`ul`,{children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.name===r,className:`pair-picker-agent`,onClick:()=>t(e.name),children:[(0,Q.jsx)(ix,{actor:{kind:`agent`,name:e.name}}),(0,Q.jsxs)(`span`,{className:`live-state live-${e.state===`unseen`?`away`:e.state}`,children:[(0,Q.jsx)(`span`,{className:`live-dot`}),zV[e.state],e.state===`away`&&e.lastSeen?` · ${ex(e.lastSeen)}`:``]}),(0,Q.jsx)(`span`,{className:`pair-picker-check`,"aria-hidden":!0,children:e.name===r&&(0,Q.jsx)($,{name:`check`})})]})},e.name))}),(0,Q.jsx)(`p`,{className:`pair-picker-foot`,children:`Your requests go straight to the agent you pick, and its steps show on each pin as it works.`})]})}var WV=340,GV=230,KV=300,qV=3200,JV=`draft`;function YV(e,t){let n=e.querySelectorAll(`[data-pair-anchor~="${CSS.escape(t)}"]`);if(n.length===0)return null;let r=e.getBoundingClientRect();return uB([...n].flatMap(e=>{let t=e.getBoundingClientRect();return t.width||t.height?[{x:t.left-r.left,y:t.top-r.top,w:t.width,h:t.height}]:[]}))}function XV(e,t){let[n,r]=(0,d.useState)({rect:null,size:{w:0,h:0}});return(0,d.useLayoutEffect)(()=>{if(!t)return r(e=>e.rect?{...e,rect:null}:e);let n=0,i=()=>{let a=e.current;if(a){let e=YV(a,t),n={w:a.clientWidth,h:a.clientHeight};r(t=>((e,t)=>e&&t?e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h:e===t)(t.rect,e)&&t.size.w===n.w&&t.size.h===n.h?t:{rect:e,size:n})}n=requestAnimationFrame(i)};return i(),()=>cancelAnimationFrame(n)},[e,t]),n}function ZV(e){let{block:t,name:n,version:r,pinId:i,part:a,label:o,icon:s,title:c,from:l,fromTitle:u,browse:f,it:p,point:m,does:h,example:g,controls:_,className:v,body:y,edit:b,onClose:x}=e,S=$z(),{seeItem:C}=S,w=(0,d.useMemo)(()=>r?An(t,r):t,[t,r]),T=NV(t,n,a,{readOnly:!!r}),E=T.mode===`pair`,D=(0,d.useRef)(null),[O,k]=(0,d.useState)(null),[A,j]=(0,d.useState)(``),[M,N]=(0,d.useState)(!1),[P,F]=(0,d.useState)(null),[I,L]=(0,d.useState)(i??null),[R,z]=(0,d.useState)(null),[B,ee]=(0,d.useState)(KV),V=fV(t,n,b,!!b&&!T.readOnly),te=(0,d.useRef)(V.on);te.current=V.on;let ne=(0,d.useCallback)(()=>{T.mode===`pair`&&T.browse(),k(null),L(null),V.start()},[T,V]),re=(0,d.useCallback)(()=>{V.stop().then(e=>e&&x())},[V,x]),ie=S.pins.get(t.id),ae=(0,d.useMemo)(()=>{if(r)return[];let e=(ie??[]).filter(e=>e.discussion&&e.anchor.kind!==`block`);return R&&!e.some(e=>e.id===R.id)?[...e,R]:e},[ie,R,r]);(0,d.useEffect)(()=>{R&&ie?.some(e=>e.id===R.id)&&z(null)},[ie,R]);let oe=(0,d.useMemo)(()=>ae.map(e=>({pin:e,place:Yo(w,e)})),[ae,w]),se=(0,d.useMemo)(()=>oe.filter(({pin:e,place:t})=>t&&(!e.discussion?.resolved||e.id===I)),[oe,I]),H=(0,d.useMemo)(()=>oe.filter(({pin:e,place:t})=>!t&&(!e.discussion?.resolved||e.id===I)).map(({pin:e})=>e),[oe,I]);(0,d.useEffect)(()=>{E||(k(null),j(``))},[E]);let[U,W]=(0,d.useState)(null),G=(0,d.useRef)(t.rev);(0,d.useEffect)(()=>{if(t.rev===G.current)return;G.current=t.rev;let e=t.updatedBy;e.kind===`human`&&e.name===n||te.current||W(`${e.name} changed ${p}: showing the new version, where you were.`)},[t.rev]),(0,d.useEffect)(()=>{if(!U)return;let e=setTimeout(()=>W(null),qV);return()=>clearTimeout(e)},[U]);let ce=(0,d.useCallback)(()=>{k(null),j(``)},[]),le=(0,d.useCallback)(e=>{k(e),F(null),L(null)},[]),ue=(0,d.useCallback)(e=>{L(t=>t===e?null:e),k(null),C(e)},[C]),de=(0,d.useCallback)(e=>{requestAnimationFrame(()=>{(D.current?.querySelector(`[data-pair-anchor~="${CSS.escape(e)}"]`)??D.current?.querySelector(`[data-chip-pin="${CSS.escape(e)}"]`))?.scrollIntoView({block:`center`,inline:`nearest`,behavior:`smooth`})})},[]);(0,d.useEffect)(()=>{i&&(L(i),de(i))},[i,de]);let fe=e=>{L(e.id),k(null),C(e.id),de(e.id)};(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||RV()||(V.on?V.live&&Xl(e.target)||V.stop():O?ce():I?L(null):x())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,I,x,ce,V]);let pe=async e=>{if(O&&A.trim()&&!M){N(!0),F(null);try{let r=e?T.address(A):A,{pin:i}=await X.pinComment(t.id,n,{part:O.part,body:r,ask:e});z(i),L(i.id),k(null),j(``)}catch(e){F(e.message)}finally{N(!1)}}},me=ae.find(e=>e.id===I),he=me&&se.some(({pin:e})=>e.id===me.id)?me:void 0,ge=me&&H.includes(me)?me:void 0,_e=XV(D,O?JV:null),ve=XV(D,he?he.id:null),ye=O&&_e.rect&&lB(_e.rect,_e.size,{width:WV,height:GV}),be=he&&ve.rect&&lB(ve.rect,ve.size,{width:WV,height:B}),K=e=>t=>(0,Q.jsx)(EV,{pin:e,fallback:t}),xe=T.agent,Se=T.agents.find(e=>e.name===xe),Ce=!!b&&!T.readOnly;return(0,Q.jsxs)(VV,{pairing:T,edit:Ce&&b?{on:V.on,hint:b.hint,start:ne,stop:V.stop}:void 0,className:`piece-view${v?` ${v}`:``}`,label:o,icon:s,title:c,from:l,fromTitle:u,browse:f,pairHint:`Point at any part to ask the agent to change it, or to leave a note on it.`,pairBand:(0,Q.jsxs)(Q.Fragment,{children:[xe?`Pairing with ${xe}: ${m} to ask ${xe} to change it, or to leave a note.`:`${m[0].toUpperCase()}${m.slice(1)} to leave a note on it or ask an agent to change it.`,xe?` ${BV(Se,xe)}`:``]}),band:V.on?(0,Q.jsx)(QV,{hand:V,it:p,back:f.label}):U&&(0,Q.jsx)(`div`,{className:`pair-band is-changed`,role:`status`,children:U}),controls:V.on?void 0:_,open:I,onOpenRequest:fe,onClose:re,children:[(0,Q.jsxs)(`div`,{className:`piece-stage${E?` is-pointing`:``}${V.on?` is-editing`:``}`,ref:D,onDoubleClick:e=>{!Ce||b?.doubleClick===!1||V.on||E||e.target.closest(`a, button, input, textarea, select, [data-chip-pin], .pair-pin-chip, .pin-thread, .pin-prompt`)||(window.getSelection()?.removeAllRanges(),ne())},children:[V.on?V.editor:y({block:w,placed:r?[]:se,pointing:E,chosen:O,open:I,pick:le,openPin:ue}),(0,Q.jsxs)(`div`,{className:`piece-layer`,hidden:V.on,children:[he&&be&&(0,Q.jsx)(uV,{pin:he,block:w,name:n,above:be.above,style:{left:be.left,top:be.top,width:WV},onClose:()=>L(null),onHeight:ee,live:K(he),address:T.address},he.id),O&&ye&&(0,Q.jsx)(LB,{quote:Qo({anchor:O.part,quote:O.quote},w),style:{left:ye.left,top:ye.top,width:WV},above:ye.above,text:A,busy:M,error:P,agent:T.agent,does:h,example:g,onText:e=>{j(e),F(null)},onSubmit:e=>void pe(e),onClose:ce},JSON.stringify(O.part))]})]}),H.length>0&&!V.on&&(0,Q.jsxs)(`footer`,{className:`piece-apart`,children:[(0,Q.jsxs)(`div`,{className:`piece-apart-chips`,children:[(0,Q.jsx)(`span`,{className:`faint small`,children:`No longer where they were`}),H.map(e=>(0,Q.jsx)(RB,{pin:e,open:e.id===I,part:Zo(e,w),lost:$o(e,w),onToggle:()=>ue(e.id)},e.id))]}),ge&&(0,Q.jsx)(uV,{inline:!0,pin:ge,block:w,name:n,onClose:()=>L(null),live:K(ge),address:T.address},ge.id)]})]})}function QV({hand:e,it:t,back:n}){return e.theirs?(0,Q.jsxs)(`div`,{className:`pair-band is-conflict`,role:`alert`,children:[(0,Q.jsxs)(`span`,{children:[e.theirs,` changed `,t,` while you were editing. Keep yours to save it over their change, or take theirs to start again from it.`]}),(0,Q.jsxs)(`span`,{className:`pair-band-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:e.takeTheirs,children:`Take theirs`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,onClick:e.keepMine,children:`Keep yours`})]})]}):(0,Q.jsxs)(`div`,{className:`pair-band is-editing${e.error?` is-error`:``}`,role:`status`,children:[(0,Q.jsx)(`span`,{children:e.error??(e.saving?`Saving…`:e.live?`Editing on your own: each change saves as you make it. ${n} or Esc goes back.`:`Editing on your own: it saves as you go back to ${n}, or press Esc.`)}),!e.live&&(0,Q.jsx)(`span`,{className:`pair-band-actions`,children:(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-quiet`,onClick:e.discard,disabled:e.saving,children:`Discard changes`})})]})}var $V=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function eH({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=r?.part.kind===`point`?wB(e,r.part,JV,!0):null,c=[...t.flatMap(({pin:e,place:t})=>t?.kind===`point`?[{id:e.id,category:t.row,series:t.series,draft:!1,open:e.id===i}]:[]),...s?[s]:[]];return(0,Q.jsxs)(`div`,{className:`chart-full-wrap`,children:[(0,Q.jsx)(`div`,{className:`piece-sheet chart-full${n?` is-pointing`:``}`,children:(0,Q.jsx)(DB,{block:e,marks:c,pinnable:n,full:!0,onPick:(t,n)=>{let r=TB(e,t,n);r&&a(r)},onOpen:o})}),t.length>0&&(0,Q.jsx)(`div`,{className:`chart-full-chips`,children:t.map(({pin:t})=>(0,Q.jsx)(RB,{pin:t,open:t.id===i,part:Zo(t,e),onToggle:()=>o(t.id)},t.id))})]})}function tH(e){if(e.kind===`pie`)return`click a slice, or its name in the legend,`;let t=e.kind===`line`||e.kind===`area`?`a point`:`a bar`;return e.columns.length>2?`click ${t}, or a series in the legend,`:`click ${t}`}function nH({block:e,save:t}){return(0,Q.jsxs)(`div`,{className:`piece-edit has-preview chart-edit`,children:[(0,Q.jsxs)(`div`,{className:`piece-edit-field`,children:[(0,Q.jsxs)(`label`,{className:`piece-edit-label chart-edit-kind`,children:[`Kind`,(0,Q.jsx)(`select`,{value:e.kind,onChange:e=>t({kind:e.target.value}),children:zt.map(e=>(0,Q.jsxs)(`option`,{value:e,children:[Bt[e],` chart`]},e))})]}),(0,Q.jsx)(`div`,{className:`piece-edit-shown chart-edit-data`,children:(0,Q.jsx)(AB,{block:e,selected:!0})})]}),(0,Q.jsxs)(`div`,{className:`piece-edit-preview`,children:[(0,Q.jsx)(`span`,{className:`piece-edit-label`,children:`Preview`}),(0,Q.jsx)(`div`,{className:`piece-edit-shown chart-edit-plot`,children:(0,Q.jsx)(DB,{block:e,marks:[],pinnable:!1,full:!0,onPick:()=>{}})})]})]})}function rH({block:e,name:t,version:n,pinId:r,onClose:i}){let a=e.columns.length-1,o=[`${Bt[e.kind]} chart`,`${$V(e.rows.length,`category`,`categories`)}${a>1?`, ${$V(a,`series`,`series`)}`:``}`,e.unit&&`in ${e.unit}`].filter(Boolean).join(` · `);return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`chart`,className:`chart-full-view`,label:`Chart ${e.title??``}`.trim(),icon:(0,Q.jsx)($,{name:`chart`}),title:e.title||`Chart`,from:o,browse:{label:`View`,hint:`Look at it on your own; click a marked part to see what was said about it`},it:`the chart`,point:tH(e),does:`changes the chart's data`,example:`make it 12, say`,body:e=>(0,Q.jsx)(eH,{...e}),edit:{hint:`Edit its kind and its numbers by hand (or double-click it while viewing)`,live:({block:e,save:t})=>(0,Q.jsx)(nH,{block:e,save:t})},onClose:i})}function iH({block:e,viewing:t}){let n=$z();return(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to see it large or pair with an agent on its bars and points (Enter)`,children:`Open`})}var aH={type:`chart`,copyText:e=>Yz(e.columns,e.rows),Body:xB,Head:({block:e,frozen:t})=>(0,Q.jsx)(bB,{block:e,frozen:t}),Tools:iH,overlay:{Component:rH,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Chart`,icon:`chart`,add:()=>({content:mB,title:`New chart`})},added:e=>vB(e.id)};function oH({what:e,as:t,about:n}){return(0,Q.jsx)(`div`,{className:`canvas-drop`,"aria-hidden":!0,children:(0,Q.jsxs)(`div`,{className:`canvas-drop-card`,children:[(0,Q.jsxs)(`p`,{className:`canvas-drop-what`,children:[`Drop to add `,e,` as `,t]}),n&&(0,Q.jsx)(`p`,{className:`canvas-drop-about`,children:n})]})})}function sH(e,t){let[n,r]=(0,d.useState)(!1);return{onDragEnter:n=>r(e&&t.matches(Hz(n))&&!Vz(n.target)),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},clear:()=>r(!1),overlay:n&&(0,Q.jsx)(oH,{what:t.what,as:t.as})}}var cH=e=>new Set(e.split(/\s+/).filter(Boolean)),lH={lineComments:[`//`],blockComment:[`/*`,`*/`],numbers:!0},uH={js:{...lH,quotes:`'"\``,keywords:cH(`
67
+ abstract as async await break case catch class const continue debugger declare default delete do else enum export
68
+ extends false finally for from function get if implements import in instanceof interface keyof let namespace new null
69
+ of private protected public readonly return satisfies set static super switch this throw true try type typeof
70
+ undefined var void while yield string number boolean unknown never any bigint symbol object`)},json:{...lH,quotes:`"`,keywords:cH(`true false null`)},css:{blockComment:[`/*`,`*/`],lineComments:[],quotes:`'"`,units:!0,numbers:!0,keywords:cH(`important inherit initial unset none auto`)},scss:{blockComment:[`/*`,`*/`],lineComments:[`//`],quotes:`'"`,units:!0,numbers:!0,keywords:cH(`important inherit initial unset none auto`)},html:{blockComment:[`<!--`,`-->`],lineComments:[],quotes:`'"`,tags:!0,keywords:cH(``)},python:{lineComments:[`#`],quotes:`'"`,numbers:!0,keywords:cH(`
71
+ and as assert async await break class continue def del elif else except False finally for from global if import in
72
+ is lambda None nonlocal not or pass raise return self True try while with yield match case`)},go:{...lH,quotes:`"'\``,keywords:cH(`
73
+ break case chan const continue default defer else fallthrough false for func go goto if import interface iota map nil
74
+ package range return select struct switch true type var string int int64 int32 uint byte rune bool error float64 any`)},rust:{...lH,quotes:`"`,charLiterals:!0,keywords:cH(`
75
+ as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub
76
+ ref return self Self static struct super trait true type unsafe use where while Some None Ok Err Option Result String
77
+ Vec i32 i64 u8 u32 u64 usize isize f32 f64 bool str char`)},shell:{lineComments:[`#`],hashAtWordStart:!0,quotes:`'"`,numbers:!0,keywords:cH(`
78
+ if then else elif fi for while until do done case esac in function return export local readonly set unset shift exit
79
+ source alias echo cd`)}};function dH(e){return fH(Yn(e))}function fH(e){return e?.colour&&uH[e.colour]||null}var pH=/0[xX][\da-fA-F_]+n?|0[oO][0-7_]+n?|0[bB][01_]+n?|\d[\d_]*(?:\.\d+)?(?:[eE][+-]?\d+)?n?/y,mH=/#[\da-fA-F]{3,8}\b|\d*\.?\d+(?:%|[a-zA-Z]+)?/y,hH=/[A-Za-z_$][\w$]*/y,gH=/@[\w-]+/y,_H=/<\/?[A-Za-z][\w:-]*/y,vH=/'(?:\\.|[^\\'])'/y;function yH(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}var bH=(e,t)=>t===0||!/[\w$]/.test(e[t-1]);function xH(e,t,n={inComment:!1}){if(!t)return[{text:e}];let r=[],i=``,a=(e,t)=>{i&&r.push({text:i}),i=``,e&&r.push({text:e,kind:t})},o=0,s=r=>{let[,i]=t.blockComment,s=e.indexOf(i,r);n.inComment=s===-1;let c=s===-1?e.length:s+i.length;a(e.slice(o,c),`com`),o=c};if(n.inComment&&t.blockComment)s(0);else if(t.blockComment?.[0]===`/*`&&/^\s*\*(\s|\/|$)/.test(e))return a(e,`com`),r;for(;o<e.length;){let n=e[o];if(t.blockComment&&e.startsWith(t.blockComment[0],o))s(o+t.blockComment[0].length);else{if(t.lineComments.some(t=>e.startsWith(t,o))&&(!t.hashAtWordStart||o===0||/\s/.test(e[o-1]))){a(e.slice(o),`com`),o=e.length;break}if(t.charLiterals&&n===`'`){let t=yH(vH,e,o);t?(a(t,`str`),o+=t.length):(i+=n,o++)}else if(t.quotes.includes(n)){let t=o+1;for(;t<e.length&&e[t]!==n;)t+=e[t]===`\\`?2:1;t=Math.min(t+1,e.length),a(e.slice(o,t),`str`),o=t}else{if(t.tags&&n===`<`){let t=yH(_H,e,o);if(t){let e=t.replace(/^<\/?/,``);i+=t.slice(0,t.length-e.length),a(e,`kw`),o+=t.length;continue}}if(t.units&&(n===`@`||n===`#`||/[\d.]/.test(n))&&bH(e,o)){let t=yH(n===`@`?gH:mH,e,o);if(t){a(t,n===`@`?`kw`:`num`),o+=t.length;continue}}if(t.numbers&&!t.units&&/\d/.test(n)&&bH(e,o)){let t=yH(pH,e,o);a(t,`num`),o+=t.length}else if(/[A-Za-z_$]/.test(n)&&bH(e,o)){let n=yH(hH,e,o);t.keywords.has(n)?a(n,`kw`):i+=n,o+=n.length}else i+=n,o++}}}return i&&r.push({text:i}),r}var SH=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function CH({tokens:e,note:t}){return(0,Q.jsx)(`span`,{className:t?`diff-text is-note`:`diff-text`,children:e.map((e,t)=>e.kind?(0,Q.jsx)(`span`,{className:`tok-${e.kind}`,children:e.text},t):e.text)})}function wH(e){let t=$z(),n=nV(),r=sV(),i=(0,d.useRef)({x:0,y:0}),a=!t.readOnly;return{pinnable:a,handlers:{onMouseDown:e=>i.current={x:e.clientX,y:e.clientY},onClick:r=>{let o=r.target.closest(`[data-line]`);if(!a||!o||r.shiftKey||r.metaKey||r.ctrlKey)return;r.stopPropagation();let s=Math.abs(r.clientX-i.current.x)+Math.abs(r.clientY-i.current.y)>4;if(r.detail!==1||s)return;let c=e(o);c&&n.later(()=>t.startPin(c))},onDoubleClickCapture:n.cancel,title:a?r.line:void 0}}}function TH({pins:e,numbers:t,where:n}){let r=$z();return(0,Q.jsx)(`div`,{className:`diff-thread nodrag nopan`,"data-pin-skip":``,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(`div`,{className:`diff-thread-card`,children:[e.map(e=>{if(!e.discussion)return null;let i=as(e,Zz(r));if(i.length===0)return null;let[a,...o]=i,s=o.length>3?o.length-2:0;return(0,Q.jsxs)(`div`,{className:`diff-comments`,children:[(0,Q.jsxs)(`p`,{className:`diff-comment-head`,children:[(0,Q.jsx)(`span`,{className:`diff-pin-n`,children:t.get(e.id)??`•`}),(0,Q.jsx)(`b`,{children:a.author.name}),` `,(0,Q.jsxs)(`span`,{className:`diff-comment-where`,children:[`· on `,n]})]}),(0,Q.jsx)(`p`,{className:`diff-comment-body`,children:H(qo(a.body),600)}),s>0&&(0,Q.jsx)(`p`,{className:`diff-comment-more`,children:SH(s,`more reply`)}),o.slice(s).map(e=>(0,Q.jsxs)(`p`,{className:`diff-comment-reply`,children:[(0,Q.jsx)(`b`,{children:e.author.name}),` · `,H(qo(e.body),300)]},e.id))]},e.id)}),(0,Q.jsx)(`div`,{className:`diff-thread-chips`,children:e.map(e=>(0,Q.jsx)(KB,{pin:e},e.id))})]})})}var EH=e=>e.toLocaleString(`en-US`),DH=(e,t)=>`${EH(e)} ${t}${e===1?``:`s`}`,OH={all:!1,opened:[]},kH=new Map,AH=new Set;function jH(e){return[(0,d.useSyncExternalStore)(e=>(AH.add(e),()=>AH.delete(e)),()=>kH.get(e)??OH),t=>{kH.set(e,t);for(let e of AH)e()}]}function MH(e,t){let n=(0,d.useMemo)(()=>Qn(e.text),[e.text]),[r,i]=jH(e.id),a=t.flatMap(({place:e})=>e?.kind===`line`?[e.line]:[]).join(`,`);return{lines:n,segments:(0,d.useMemo)(()=>dr(e,{keep:a?a.split(`,`).map(Number):[],opened:r.opened,all:r.all,count:n.length}),[e,a,r,n.length]),state:r,setState:i}}var NH=e=>/^[0-9a-f]{12,}$/i.test(e)?e.slice(0,7):e;function PH({block:e,placed:t,frozen:n}){let{lines:r,segments:i,state:a,setState:o}=MH(e,t),s=Zn(e),c=i.some(e=>e.kind===`fold`),l=[s?.name,fr(e,i,r.length),e.commit&&`at ${NH(e.commit)}`].filter(Boolean).join(` · `);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(FH,{block:e,frozen:n}),(0,Q.jsx)(`span`,{className:`code-meta`,title:e.commit?`${l.replace(NH(e.commit),e.commit)}`:l,children:l}),(0,Q.jsxs)(`span`,{className:`code-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(IH,{text:e.text}),c&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o({all:!0,opened:[]}),title:`Show all ${DH(r.length,`line`)}`,children:`Show all`}),a.all&&r.length>60&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(OH),title:`Fold it back to the lines that matter`,children:`Fold`})]})]})}function FH({block:e,frozen:t}){let n=$z(),[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(!1),o=e.path||(0,Q.jsx)(`span`,{className:`placeholder`,children:`Untitled`});if(t||n.readOnly)return(0,Q.jsx)(`span`,{className:`code-path`,title:e.path,children:o});if(!r)return(0,Q.jsx)(`button`,{type:`button`,className:`code-path is-editable nodrag`,title:e.path?`${e.path}. Click to change its path`:`Click to give its path, e.g. src/core/store.ts`,onClick:()=>{a.current=!1,i(!0)},onDoubleClick:e=>e.stopPropagation(),children:o});let s=t=>{i(!1);let r=t.value.trim();!a.current&&r!==e.path&&n.updateBlock(e,{path:r})};return(0,Q.jsx)(`input`,{autoFocus:!0,className:`editable-input code-path-input nodrag`,defaultValue:e.path,placeholder:`src/core/store.ts`,"aria-label":`The file's path`,size:Math.max(18,e.path.length+4),onFocus:e=>e.currentTarget.select(),onBlur:e=>s(e.currentTarget),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(a.current=!0,e.currentTarget.blur())}})}function IH({text:e}){let[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>n(!1),1500);return()=>clearTimeout(e)},[t]);let r=async()=>{try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}n(!0)};return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void r(),title:`Copy the text`,children:t?`Copied`:`Copy`})}function LH(e,t,n){let r=Math.max(e,...n.flatMap(({pin:e,place:n})=>n?.kind===`line`&&n.last&&t.includes(e)?[n.last]:[]));return r>e?`lines ${e}–${r}`:`line ${e}`}function RH({block:e,placed:t}){let n=$z(),r=(0,d.useRef)(null),{lines:i,segments:a,setState:o,state:s}=MH(e,t),c=e.start??1,l=c+i.length-1,u=Math.max(...a.map(e=>e.kind===`lines`?e.to:c)),f=(0,d.useMemo)(()=>fH(Zn(e)),[e]),p=(0,d.useMemo)(()=>{let e={inComment:!1};return i.slice(0,u-c+1).map(t=>xH(t,f,e))},[i,f,u,c]),{byLine:m,numbers:h,spans:g}=(0,d.useMemo)(()=>{let e=new Map,n=[];for(let{pin:r,place:i}of t)i?.kind===`line`&&(e.set(i.line,[...e.get(i.line)??[],r]),i.last&&n.push([i.line,i.last]));let r=new Map;for(let t of[...e.keys()].sort((e,t)=>e-t))for(let n of e.get(t))r.set(n.id,r.size+1);return{byLine:e,numbers:r,spans:n}},[t]),_=t.find(({pin:e,place:t})=>e.id===n.focusPin&&t?.kind===`line`);(0,d.useLayoutEffect)(()=>{if(!_||!r.current)return;let e=r.current.querySelector(`[data-pin-ids~="${CSS.escape(_.pin.id)}"]`),t=r.current.closest(`.block-body`);if(!e||!t)return;let n=t.getBoundingClientRect().height/t.offsetHeight||1,i=(e.getBoundingClientRect().top-t.getBoundingClientRect().top)/n;t.scrollTop+=i-t.clientHeight/3},[_]);let{pinnable:v,handlers:y}=wH(t=>{let n=Number(t.dataset.line);return{blockId:e.id,part:{kind:`line`,file:e.path,line:n,side:`new`},quote:Un(i[n-c]??``)}}),b=n.draft?.blockId===e.id&&n.draft.part.kind===`line`?n.draft.part.line:null,x=t=>!!e.highlight?.some(([e,n])=>t>=e&&t<=n),S=e=>o({all:!1,opened:[...s.opened,[e.from,e.to]]}),C=()=>o({all:!0,opened:[]}),w=(e,r)=>Array.from({length:r-e+1},(r,a)=>{let o=e+a,s=m.get(o)??[],l=[`diff-row`,`is-code`,x(o)&&`is-hl`,(s.length>0||g.some(([e,t])=>o>=e&&o<=t))&&`is-pinned`,b===o&&`is-draft`,s.some(e=>e.id===n.focusPin)&&`is-focus`];return(0,Q.jsxs)(d.Fragment,{children:[(0,Q.jsxs)(`div`,{className:l.filter(Boolean).join(` `),"data-side":`new`,"data-line":o,"data-pin-draft":b===o?``:void 0,"data-pin-ids":s.length?s.map(e=>e.id).join(` `):void 0,children:[(0,Q.jsx)(`span`,{className:`diff-num`,children:o}),(0,Q.jsx)(CH,{tokens:p[o-c]??[{text:i[o-c]}]})]}),s.length>0&&(0,Q.jsx)(TH,{pins:s,numbers:h,where:LH(o,s,t)})]},o)});return(0,Q.jsxs)(`div`,{className:`diff code-view`,ref:r,children:[(0,Q.jsx)(YB,{block:e,placed:t}),(0,Q.jsx)(`div`,{className:`diff-code nodrag${v?` is-pinnable`:``}`,...y,children:(0,Q.jsxs)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${String(Math.max(l,e.total??0)).length}ch`},children:[c>1&&(0,Q.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,DH(c-1,`line`),` above, not in this block`]}),a.map(e=>e.kind===`lines`?(0,Q.jsx)(d.Fragment,{children:w(e.from,e.to)},`l${e.from}`):(0,Q.jsxs)(`p`,{className:`code-fold`,"data-pin-skip":``,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(e),title:`Show lines ${EH(e.from)}–${EH(e.to)}`,children:[`⋯ `,DH(e.to-e.from+1,`line`),e.from===c?` above`:e.to===l?` below`:``]}),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Q.jsx)(`button`,{type:`button`,onClick:C,children:`Show all`})]},`f${e.from}`)),e.total!==void 0&&e.total>l&&(0,Q.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,DH(e.total-l,`line`),` below, not in this block`]})]})})]})}function zH(e){let{toggle:t,onAdd:n,onCancel:r}=e,[i,a]=(0,d.useState)(``),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(null);Zl(!i.trim()&&!o.trim(),r,u,t);let f=o.trim()?Yn(o.trim()):void 0,p=i?Qn(i).length:0,m=[f?.name??(o.trim()&&`No colours for this kind of file`),p>0&&DH(p,`line`)].filter(Boolean).join(` · `),h=e=>{e?.preventDefault();try{cr(i)}catch(e){l(e.message.replace(/ Send the lines that matter.*$/,` Paste the lines that matter.`));return}n({type:`code`,path:o.trim(),text:i})};return(0,Q.jsxs)(`form`,{ref:u,className:`add-link add-code nodrag nopan nowheel`,onSubmit:h,onKeyDown:e=>e.key===`Escape`&&r(),children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`span`,{className:`field-label`,children:`Code`}),(0,Q.jsx)(`textarea`,{autoFocus:!0,value:i,spellCheck:!1,placeholder:`Paste a file, or the lines that matter`,onChange:e=>{a(e.target.value),l(null)},onKeyDown:e=>(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&h()})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsxs)(`span`,{className:`field-label`,children:[`File name `,(0,Q.jsx)(`span`,{className:`faint`,children:`(optional, for its colours)`})]}),(0,Q.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`e.g. src/core/store.ts`})]}),m&&(0,Q.jsx)(`p`,{className:`add-code-about`,children:m}),c&&(0,Q.jsx)(`p`,{className:`error`,children:c}),(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!i.trim(),children:`Add code`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:r,children:`Cancel`})]})]})}var BH=e=>e.startsWith(`image/`);async function VH(e){if(e.size>1048576)throw Error(`${e.name} is ${or(e.size)}: a Code block holds files up to 1 MB.`);let t=Error(`${e.name} isn't a text file, so it can't be a Code block. Drop source code or other text.`),n=new Uint8Array(await e.arrayBuffer());if(n.includes(0))throw t;let r;try{r=new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{throw t}if(sr(r))throw t;if(!r.trim())throw Error(`${e.name} is empty.`);return r}async function HH(e){let t=Yn(e.name)?.name;try{return[t,DH(Qn(await VH(e)).length,`line`)].filter(Boolean).join(` · `)}catch(t){return t.message.replace(`${e.name} `,`It `).replace(/ Drop source code or other text\.$/,``)}}function UH(e){let[t,n]=(0,d.useState)(null),r=(0,d.useRef)(new WeakMap);return{drop:t,onDragEnter:t=>{if(!e||!t.dataTransfer.types.includes(`Files`))return;let i=[...t.dataTransfer.items].filter(e=>e.kind===`file`&&!BH(e.type)),a=[...t.dataTransfer.files].filter(e=>!BH(e.type)),o=Math.max(i.length,a.length);if(o===0)return n(null);let s=o===1?a[0]:void 0;if(n(e=>({count:o,name:s?.name,about:e?.name===s?.name?e?.about:void 0})),!s)return;let c=r.current.get(s);c||r.current.set(s,c=HH(s)),c.then(e=>n(t=>t&&t.name===s.name?{...t,about:e}:t))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||n(null)},clear:()=>n(null)}}function WH({drop:e}){let t=e.name?(0,Q.jsx)(`b`,{children:e.name}):e.count===1?`the file`:`${e.count} files`;return(0,Q.jsx)(oH,{what:t,as:e.count===1?`a Code block`:`Code blocks`,about:e.about})}var GH=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,KH=e=>/^[0-9a-f]{12,}$/i.test(e)?e.slice(0,7):e;function qH({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=(0,d.useMemo)(()=>Qn(e.text),[e.text]),c=e.start??1,l=c+s.length-1,u=(0,d.useMemo)(()=>fH(Zn(e)),[e]),f=(0,d.useMemo)(()=>{let e={inComment:!1};return s.map(t=>xH(t,u,e))},[s,u]),{onLine:p,chipsOn:m}=(0,d.useMemo)(()=>{let e=new Map,n=new Map;for(let{pin:r,place:i}of t)if(i?.kind===`line`){for(let t=i.line;t<=(i.last??i.line);t++)e.set(t,[...e.get(t)??[],r.id]);n.set(i.line,[...n.get(i.line)??[],r])}return{onLine:e,chipsOn:n}},[t]),[h,g]=(0,d.useState)(null),_=(0,d.useRef)(h);_.current=h;let v=e=>{let t=e.target.closest(`[data-line]`);return t?Number(t.dataset.line):null};(0,d.useEffect)(()=>{if(!h)return;let t=()=>{let t=_.current&&rB(_.current.from,_.current.to);if(g(null),!t)return;let n=Un(s[t.line-c]??``);a({blockId:e.id,part:{kind:`line`,file:e.path,line:t.line,side:`new`,...t.last?{last:t.last}:{}},quote:n})};return document.addEventListener(`mouseup`,t),()=>document.removeEventListener(`mouseup`,t)},[!!h]);let y=r?.part.kind===`line`?{from:r.part.line,to:r.part.last??r.part.line}:null,b=h?rB(h.from,h.to):y?{line:y.from,last:y.to}:null,x=e=>!!(b&&e>=b.line&&e<=(b.last??b.line)),S=t=>!!e.highlight?.some(([e,n])=>t>=e&&t<=n);return(0,Q.jsx)(`div`,{className:`piece-scroll code-full-scroll`,children:(0,Q.jsx)(`div`,{className:`piece-sheet code-full-sheet`,children:(0,Q.jsx)(`div`,{className:`diff code-view code-full${n?` is-pointing`:``}`,children:(0,Q.jsx)(`div`,{className:`diff-code${n?` is-pinnable`:``}`,onMouseDown:e=>{if(!n||e.button!==0)return;let t=v(e);t!==null&&(e.preventDefault(),g({from:t,to:t}))},onMouseOver:e=>{if(!_.current)return;let t=v(e);t!==null&&t!==_.current.to&&g({..._.current,to:t})},title:n?`Click a line, or drag over several, to ask about them`:void 0,children:(0,Q.jsxs)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${String(Math.max(l,e.total??0)).length}ch`},children:[c>1&&(0,Q.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,GH(c-1,`line`),` above, not in this block`]}),s.map((e,t)=>{let n=c+t,r=p.get(n)??[],a=x(n),l=[...r,...a?[JV]:[]].join(` `),u=[`diff-row`,`is-code`,S(n)&&`is-hl`,r.length>0&&`is-pinned`,r.includes(i??``)&&`is-open`,a&&`is-draft`],h=m.get(n)??[];return(0,Q.jsx)(d.Fragment,{children:(0,Q.jsxs)(`div`,{className:u.filter(Boolean).join(` `),"data-line":n,"data-pair-anchor":l||void 0,children:[(0,Q.jsx)(`span`,{className:`diff-num`,children:n}),(0,Q.jsx)(CH,{tokens:f[t]??[{text:s[t]}]}),h.length>0&&(0,Q.jsx)(`span`,{className:`code-full-chips`,children:h.map(e=>(0,Q.jsx)(RB,{pin:e,open:e.id===i,onToggle:()=>o(e.id)},e.id))})]})},n)}),e.total!==void 0&&e.total>l&&(0,Q.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,GH(e.total-l,`line`),` below, not in this block`]})]})})})})})}function JH({block:e,name:t,version:n,pinId:r,onClose:i}){let a=Zn(e),o=Qn(e.text).length,s=[a?.name??`Code`,e.start&&e.start>1?nr(e,o):GH(o,`line`),e.commit&&`at ${KH(e.commit)}`].filter(Boolean).join(` · `),c=e.path?rr(e.path,48):``;return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`code`,className:`code-full-view`,label:`Code ${e.path||`block`}`,icon:(0,Q.jsx)($,{name:`code`}),title:e.path||`Untitled code`,from:s,fromTitle:e.commit?`${s.replace(KH(e.commit),e.commit)}`:void 0,browse:{label:`Read`,hint:`Read it, and select code to copy`},it:`the code`,point:`click a line, or drag over several,`,does:c?`changes the code (and ${c} in its repository, if it has it)`:`changes the code`,example:`rename it, say`,body:e=>(0,Q.jsx)(qH,{...e}),onClose:i})}function YH(e,t,n){let r=_r(e);return t.add(e,{at:n&&{x:n.x+r.w/2-60,y:n.y+r.h/2-18},size:r})}async function XH(e,t,n){for(let[r,i]of e.entries())try{let e=await VH(i);await YH({type:`code`,path:i.name,text:e},t,n&&{x:n.x+r*40,y:n.y+r*40})}catch(e){t.report(e)}}function ZH({toggle:e,context:t,close:n}){return(0,Q.jsx)(zH,{toggle:e,onAdd:e=>{n(),YH(e,t)},onCancel:n})}function QH(e){let{drop:t,onDragEnter:n,onDragLeave:r,clear:i}=UH(e);return{onDragEnter:n,onDragLeave:r,clear:i,overlay:t&&(0,Q.jsx)(WH,{drop:t})}}function $H({block:e,viewing:t}){let n=$z();return(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to read it all or pair with an agent on its lines (Enter)`,children:`Open`})}var eU={type:`code`,copyText:e=>e.text,Body:({block:e,placed:t})=>(0,Q.jsx)(RH,{block:e,placed:t}),Title:({block:e,placed:t,frozen:n})=>(0,Q.jsx)(PH,{block:e,placed:t,frozen:n}),ownPins:!0,Tools:$H,overlay:{Component:JH,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Code`,icon:`code`,Form:ZH,toggles:!0},files:{accepts:e=>!BH(e.type),add:XH,useDrop:QH}};function tU(e){let t=$z(),[n,r]=(0,d.useState)(!1),i=(0,d.useRef)(!1),{autoEditId:a,clearAutoEdit:o}=t;return(0,d.useEffect)(()=>{a===e&&(i.current=!1,r(!0),o())},[a,o,e]),{editing:n,start:()=>{t.readOnly||(i.current=!1,r(!0))},finish:(e,t,n)=>{r(!1),!i.current&&e!==t&&n(e)},cancel:()=>{i.current=!0}}}var nU={mark:WB};function rU(e,t){return Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4}function iU(e){return e.shiftKey||e.metaKey||e.ctrlKey}function aU(e,t,n){return e?.blockId===t&&e.part.kind===n?e.part:null}function oU(e,t,n){return Math.min((e.width-n.pad*2)/t.width,(e.height-n.pad*2)/t.height,n.fitMax)}var sU=(e,t,n)=>Math.min(oU(e,t,n),n.actual);function cU(e){let t=typeof window<`u`&&window.devicePixelRatio||1;return Math.round(e*t)/t}var lU=.4;function uU(e,t,n,r,i=!1){let a=Math.min(r.maxScale,Math.max(sU(t,n,r),e.scale)),o=(e,t,n)=>{if(i&&t<=n)return(n-t)/2;let r=n*lU;return Math.min(Math.max(0,n-t)+r,Math.max(Math.min(0,n-t)-r,e))};return{...e,scale:a,x:cU(o(e.x,n.width*a,t.width)),y:cU(o(e.y,n.height*a,t.height))}}var dU=1.25,fU=80,pU=4e3,mU=4;function hU(e){try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}var gU=`Arrow keys move it, plus and minus zoom, 0 fits it.`;function _U(e,t){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)({scale:1,x:0,y:0,fitted:!0}),[c,l]=(0,d.useState)(!0),u=(0,d.useRef)({view:o,stage:i,natural:e,rules:t});u.current={view:o,stage:i,natural:e,rules:t},(0,d.useLayoutEffect)(()=>{if(!n)return;let e=()=>a(e=>e?.width===n.clientWidth&&e.height===n.clientHeight?e:{width:n.clientWidth,height:n.clientHeight});e();let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(e)});return r.observe(n),()=>{cancelAnimationFrame(t),r.disconnect()}},[n]);let[f,p]=[e?.width??0,e?.height??0];(0,d.useLayoutEffect)(()=>{if(!i||!f||!p)return;let e={width:f,height:p},t=u.current.rules;s(n=>n.fitted?uU({scale:oU(i,e,t),x:0,y:0,fitted:!0},i,e,t,!0):uU(n,i,e,t))},[i,f,p]);let m=(0,d.useCallback)((e,t,n=!1)=>{let{stage:r,natural:i,rules:a}=u.current;if(!r||!i)return;let o=t??{x:r.width/2,y:r.height/2},c=Math.min(a.maxScale,Math.max(sU(r,i,a),e));s(e=>{let t=(o.x-e.x)/e.scale,s=(o.y-e.y)/e.scale;return uU({scale:c,x:o.x-t*c,y:o.y-s*c,fitted:!1},r,i,a,n)}),l(!1)},[]),h=(0,d.useCallback)((e,t)=>{let{stage:n,natural:r,rules:i}=u.current;n&&r&&s(a=>uU({...a,x:a.x+e,y:a.y+t},n,r,i))},[]),g=(0,d.useCallback)((e,t)=>{let{stage:n,natural:r,rules:i}=u.current;n&&r&&(e===`fit`?s(uU({scale:oU(n,r,i),x:0,y:0,fitted:!0},n,r,i,!0)):m((e===`actual`?1:2)*i.actual,t,!0))},[m]);(0,d.useEffect)(()=>{if(!n)return;let e=e=>{let t=n.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},t=t=>{if(t.target.closest(`.pin-prompt, .pin-thread`))return;t.preventDefault();let r=t.deltaMode===1?16:t.deltaMode===2?n.clientHeight:1,i=(Math.abs(t.deltaY)>=Math.abs(t.deltaX)?t.deltaY:t.deltaX)*r;m(u.current.view.scale*Math.exp(-i*(t.ctrlKey?.01:.002)),e(t))},r=1,i=e=>{e.preventDefault(),r=u.current.view.scale},a=t=>{t.preventDefault();let n=t;m(r*n.scale,e(n))};return n.addEventListener(`wheel`,t,{passive:!1}),n.addEventListener(`gesturestart`,i),n.addEventListener(`gesturechange`,a),()=>{n.removeEventListener(`wheel`,t),n.removeEventListener(`gesturestart`,i),n.removeEventListener(`gesturechange`,a)}},[n,m]),(0,d.useEffect)(()=>{if(!n)return;let e=e=>{if(Xl(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let{stage:t}=u.current,n=e.shiftKey&&t?Math.max(fU,Math.min(t.width,t.height)*.8):fU,r={ArrowLeft:()=>h(n,0),ArrowRight:()=>h(-n,0),ArrowUp:()=>h(0,n),ArrowDown:()=>h(0,-n),"+":()=>m(u.current.view.scale*dU),"=":()=>m(u.current.view.scale*dU),"-":()=>m(u.current.view.scale/dU),_:()=>m(u.current.view.scale/dU),0:()=>g(`fit`),1:()=>g(`actual`),2:()=>g(`double`)}[e.key];r&&(r(),e.preventDefault()),(r||e.key===`Backspace`||e.key===`Delete`)&&e.stopPropagation()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,h,g,m]),(0,d.useEffect)(()=>{n?.focus({preventScroll:!0})},[n]),(0,d.useEffect)(()=>{let e=setTimeout(()=>l(!1),pU);return()=>clearTimeout(e)},[]);let{actual:_}=t,v=i&&e?oU(i,e,t):1,y=(e,t)=>Math.abs(e-t)<.001,b=o.fitted||y(o.scale,v)?`fit`:y(o.scale,_)?`actual`:y(o.scale,2*_)?`double`:null,x=!!(i&&e&&(e.width*o.scale>i.width+.5||e.height*o.scale>i.height+.5)),S=`${Math.round(o.scale/_*100)}%`;return{stageRef:r,natural:e,view:o,sheet:e?{left:o.x,top:o.y,width:e.width*o.scale,height:e.height*o.scale}:null,active:b,fit:v,actual:_,pannable:x,percent:S,hint:c,setHint:l,zoomTo:m,panBy:h,show:g}}function vU(e){let{view:t,panBy:n,zoomTo:r,setHint:i}=e,[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(new Map),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=(0,d.useRef)(!1),f=e=>{if(e.button===0&&!e.target.closest(`button, a, input, textarea, select, .pin-prompt, .pin-thread`)&&(s.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),s.current.size===1&&(l.current={x:e.clientX,y:e.clientY},u.current=!1),s.current.size===2)){let[n,r]=[...s.current.values()];c.current={distance:Math.hypot(n.x-r.x,n.y-r.y),scale:t.scale},u.current=!0,hU(e)}},p=e=>{let t=s.current.get(e.pointerId);if(!t)return;let a={x:e.clientX,y:e.clientY};if(s.current.set(e.pointerId,a),s.current.size===2&&c.current){let[t,n]=[...s.current.values()],i=e.currentTarget.getBoundingClientRect(),a={x:(t.x+n.x)/2-i.left,y:(t.y+n.y)/2-i.top};r(c.current.scale*(Math.hypot(t.x-n.x,t.y-n.y)/c.current.distance),a)}else if(s.current.size===1){if(u.current)n(a.x-t.x,a.y-t.y);else{let r=l.current??t;if(Math.hypot(a.x-r.x,a.y-r.y)<mU)return;u.current=!0,hU(e),o(!0),i(!1),n(a.x-r.x,a.y-r.y)}}},m=e=>{s.current.delete(e.pointerId),s.current.size<2&&(c.current=null),s.current.size===0&&o(!1)};return{dragging:a,handlers:{onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:m,onClickCapture:e=>{u.current&&(u.current=!1,e.stopPropagation(),e.preventDefault())}}}}function yU({zoom:e,labels:t}){let{active:n,percent:r,show:i}=e;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`zoom-percent`,title:`Zoom`,children:r}),(0,Q.jsx)(`div`,{className:`pair-segments`,role:`radiogroup`,"aria-label":`Zoom`,children:[`fit`,`actual`,`double`].map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e,className:n===e?`is-on`:void 0,title:t[e].title,onClick:()=>i(e),children:t[e].label},e))})]})}function bU({zoom:e,children:t}){return(0,Q.jsx)(`p`,{className:`zoom-hint${e.hint?``:` is-gone`}`,"aria-hidden":!0,children:t})}function xU(e){return e.id.match(/flowchart-(.+)-\d+$/)?.[1]}function SU(e,t){if(`nodeId`in t)return[...e.querySelectorAll(`g.node`)].filter(e=>xU(e)===t.nodeId);let n=CSS.escape(t.arrowId);return[...e.querySelectorAll(`path[data-edge="true"][data-id="${n}"], g.label[data-id="${n}"]`)]}function CU(e,t,n){let r=n.closest(`g.node`);if(r){let n=e.nodes.find(e=>e.id===xU(r));return n?{blockId:t,part:{kind:`node`,nodeId:n.id},quote:n.label}:null}let i=n.closest(`[data-id]`)?.getAttribute(`data-id`),a=e.arrows.find(e=>e.id===i);return a?{blockId:t,part:{kind:`arrow`,from:a.from,to:a.to,n:a.n},quote:Nr(e,a)}:null}function wU(e,t){(0,d.useLayoutEffect)(()=>{if(!e||!t)return;let n=[...e.querySelectorAll(`path[data-edge="true"]`)].map(e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return t.setAttribute(`d`,e.getAttribute(`d`)??``),t.setAttribute(`class`,`pin-hit`),t.setAttribute(`data-id`,e.getAttribute(`data-id`)??``),e.after(t),t});return()=>n.forEach(e=>e.remove())},[e,t])}var TU=[{id:`light`,label:`Light`,base:`light`},{id:`dark`,label:`Dark`,base:`dark`}];function EU(e){return TU.find(t=>t.id===e)}function DU(e){return EU(e?`dark`:`light`)}var OU=`tricot:theme`,kU=window.matchMedia(`(prefers-color-scheme: dark)`),AU=new Set;function jU(){return DU(kU.matches)}var MU=(()=>{try{return EU(localStorage.getItem(OU))??null}catch{return null}})(),NU=MU??jU();function PU(e){NU=e,document.documentElement.dataset.theme=e.id;for(let e of AU)e()}PU(NU),kU.addEventListener(`change`,()=>{MU||PU(jU())});function FU(e){MU=e===jU()?null:e;try{MU?localStorage.setItem(OU,MU.id):localStorage.removeItem(OU)}catch{}PU(e)}function IU(){return(0,d.useSyncExternalStore)(e=>(AU.add(e),()=>AU.delete(e)),()=>NU)}var LU={FORBID_TAGS:[`style`,`img`,`image`,`picture`,`source`,`video`,`audio`,`track`,`input`]},RU=[`secure`,`securityLevel`,`startOnLoad`,`maxTextSize`,`suppressErrorRendering`,`maxEdges`,`dompurifyConfig`];function zU(e,t){return{startOnLoad:!1,securityLevel:`strict`,secure:RU,dompurifyConfig:LU,theme:e===`dark`?`dark`:`neutral`,fontFamily:t}}var BU=`modulepreload`,VU=function(e){return`/`+e},HU={},UU=function(e){return e.pathname.endsWith(`.css`)},WU=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},GU=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=VU(t,n);let r=s(t),i=UU(r);return WU(HU,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:BU,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},KU=null,qU=null,JU=Promise.resolve(),YU=0;function XU(){return KU??=GU(async()=>{let{default:e}=await import(`./mermaid.core-DBd9VEEZ.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])).then(({default:e})=>e),KU}function ZU(e,t){let n=JU.then(async()=>{let n=await XU();if(qU!==t){let e=getComputedStyle(document.documentElement).getPropertyValue(`--font`).trim();n.initialize(zU(t,e)),qU=t}await n.parse(e);let{svg:r}=await n.render(`mermaid-${++YU}`,e);return r});return JU=n.catch(()=>{}),n}function QU({source:e,onRender:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),o=IU().base,s=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{t?.(n&&!i?s.current?.querySelector(`svg`)??null:null)},[n,i,t]),(0,d.useEffect)(()=>{let t=!1;return ZU(e,o).then(e=>{t||(r(e),a(void 0))},e=>{if(t)return;let n=e instanceof Error?e.message:String(e);a(n.split(`
80
+ `).slice(0,4).join(`
81
+ `))}),()=>{t=!0}},[e,o]),i?(0,Q.jsx)(`pre`,{className:`mermaid-error`,children:i}):n?(0,Q.jsx)(`div`,{ref:s,className:`mermaid`,dangerouslySetInnerHTML:{__html:n}}):(0,Q.jsx)(`p`,{className:`placeholder`,children:`Rendering diagram…`})}var $U={actual:1,fitMax:1.8,maxScale:8,pad:28},eW={fit:{label:`Fit`,title:`The whole diagram (0)`},actual:{label:`100%`,title:`The diagram at the size Mermaid draws it (1)`},double:{label:`200%`,title:`Twice that size (2)`}};function tW({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o,sizing:s}){let{zoom:c,setNatural:l}=s,u=vU(c),f=(0,d.useMemo)(()=>jr(e.source),[e.source]),[p,m]=(0,d.useState)(null);wU(p,!!f);let h=(0,d.useCallback)(e=>{let t=e?.viewBox.baseVal;l(t?.width&&t.height?{width:t.width,height:t.height}:null),m(e)},[l]);(0,d.useLayoutEffect)(()=>{if(!p||!f)return;let n=[],a=(e,t,r,i=!1)=>{for(let a of e){a.classList.add(`pin-part`,`is-${t}`),i&&a.classList.add(`is-open`),t===`draft`&&a.setAttribute(`data-pin-draft`,``);let e=a.getAttribute(`data-pair-anchor`);a.setAttribute(`data-pair-anchor`,e?`${e} ${r}`:r),n.push(a)}};for(let{pin:e,place:n}of t)(n?.kind===`node`||n?.kind===`arrow`)&&a(SU(p,n),`linked`,e.id,e.id===i);let o=r?.blockId===e.id?r.part:null;if(o?.kind===`node`&&a(SU(p,o),`draft`,JV),o?.kind===`arrow`){let e=f.arrows.find(e=>e.from===o.from&&e.to===o.to&&e.n===(o.n??0));e&&a(SU(p,{arrowId:e.id}),`draft`,JV)}return()=>{for(let e of n)e.classList.remove(`pin-part`,`is-draft`,`is-linked`,`is-open`),e.removeAttribute(`data-pin-draft`),e.removeAttribute(`data-pair-anchor`)}},[p,f,t,r,i,e.id]);let g=r=>{if(!f)return;let i=CU(f,e.id,r.target);if(!i)return;if(n)return a(i);let s=t.find(({place:e})=>{if(i.part.kind===`node`)return e?.kind===`node`&&e.nodeId===i.part.nodeId;if(i.part.kind!==`arrow`||e?.kind!==`arrow`)return!1;let{from:t,to:n,n:r=0}=i.part;return f.arrows.find(i=>i.id===e.arrowId&&i.from===t&&i.to===n&&i.n===r)!==void 0});s&&o(s.pin.id)},_=u.dragging?` is-dragging`:c.pannable?` is-pannable`:``,v=e.title||`Diagram`;return(0,Q.jsxs)(`div`,{className:`diagram-full-wrap`,children:[(0,Q.jsxs)(`div`,{ref:c.stageRef,className:`zoom-stage diagram-full-stage${_}`,tabIndex:0,"aria-label":`${v} at ${c.percent}. ${gU}`,...u.handlers,children:[(0,Q.jsx)(`div`,{className:`zoom-sheet block-diagram diagram-full${c.sheet?``:` is-unsized`}${n&&f?` is-pinnable`:``}${t.length?` has-pins`:``}`,style:c.sheet??void 0,onClick:g,title:n?f?`Click a box, an arrow or its label to ask about it`:`Only a flowchart’s boxes and arrows can be pointed at`:void 0,children:(0,Q.jsx)(QU,{source:e.source,onRender:h})}),c.sheet&&(0,Q.jsx)(bU,{zoom:c,children:n?`Click a box or an arrow to ask about it · drag to pan · scroll to zoom`:`Scroll or pinch to zoom · drag to pan`})]}),t.length>0&&(0,Q.jsx)(`div`,{className:`diagram-full-chips`,children:t.map(({pin:t})=>(0,Q.jsx)(RB,{pin:t,open:t.id===i,part:Zo(t,e),onToggle:()=>o(t.id)},t.id))})]})}function nW({block:e,name:t,version:n,pinId:r,onClose:i}){let a=jr(e.source),o=e.source.trim().split(/\s/)[0]||`Mermaid`,s=a?`Flowchart · ${a.nodes.length} boxes, ${a.arrows.length} arrows`:`Mermaid ${o}`,[c,l]=(0,d.useState)(null),u=(0,d.useCallback)(e=>l(t=>t&&e&&t.width===e.width&&t.height===e.height?t:e),[]),f=_U(c,$U),p={zoom:f,setNatural:u};return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`diagram`,className:`diagram-full-view`,label:`Diagram ${e.title??``}`.trim(),icon:(0,Q.jsx)($,{name:`diagram`}),title:e.title||`Diagram`,from:s,browse:{label:`View`,hint:`Look at it on your own, zooming and panning; click a marked part to see what was said about it`},it:`the diagram`,point:`click a box, an arrow or its label`,does:`changes the diagram's source`,example:`call it Retry later, say`,controls:c?(0,Q.jsx)(yU,{zoom:f,labels:eW}):void 0,body:e=>(0,Q.jsx)(tW,{...e,sizing:p}),edit:{hint:`Edit its Mermaid source by hand (or double-click it while viewing)`,label:`Mermaid source`,code:!0,of:e=>e.source,patch:e=>({source:e}),check:e=>e.trim()?null:`A diagram needs its Mermaid source: write some, or discard your changes.`,preview:e=>e.trim()?(0,Q.jsx)(QU,{source:e}):(0,Q.jsx)(`p`,{className:`placeholder`,children:`Nothing to draw yet.`})},onClose:i})}function rW({block:e,placed:t}){let n=$z(),r=tU(e.id),i=(0,d.useMemo)(()=>jr(e.source),[e.source]),[a,o]=(0,d.useState)(null),s=nV(),c=(0,d.useRef)({x:0,y:0}),l=!!i&&!n.readOnly,u=n.draft?.blockId===e.id?n.draft.part:null;return wU(a,l),(0,d.useLayoutEffect)(()=>{if(!a||!i)return;let e=[],n=(t,n)=>{for(let r of t)r.classList.add(`pin-part`,`is-${n}`),n===`draft`&&r.setAttribute(`data-pin-draft`,``),e.push(r)};for(let{place:e}of t)(e?.kind===`node`||e?.kind===`arrow`)&&n(SU(a,e),`linked`);if(u?.kind===`node`&&n(SU(a,u),`draft`),u?.kind===`arrow`){let e=i.arrows.find(e=>e.from===u.from&&e.to===u.to&&e.n===u.n);e&&n(SU(a,{arrowId:e.id}),`draft`)}return()=>{for(let t of e)t.classList.remove(`pin-part`,`is-draft`,`is-linked`),t.removeAttribute(`data-pin-draft`)}},[a,i,t,u]),r.editing?(0,Q.jsx)(`textarea`,{autoFocus:!0,spellCheck:!1,className:`block-editor block-editor-code nodrag`,defaultValue:e.source,onBlur:t=>{let i=t.currentTarget.value;i.trim()?r.finish(i,e.source,t=>n.updateBlock(e,{source:t})):r.cancel()},onKeyDown:e=>{e.key===`Escape`&&(r.cancel(),e.currentTarget.blur())}}):(0,Q.jsx)(`div`,{className:`block-diagram${l?` is-pinnable`:``}`,onMouseDown:e=>c.current={x:e.clientX,y:e.clientY},onClick:t=>{if(!l||!i||iU(t))return;let r=CU(i,e.id,t.target);r&&(t.stopPropagation(),t.detail!==1||rU(t,c.current)||s.later(()=>n.startPin(r)))},onDoubleClickCapture:s.cancel,onDoubleClick:r.start,title:l?`Click a node or an arrow to pin it. Double-click to edit the Mermaid source`:`Double-click to edit the Mermaid source`,children:(0,Q.jsx)(QU,{source:e.source,onRender:o})})}function iW({block:e,viewing:t}){let n=$z();return(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to see it large or pair with an agent on its boxes and arrows (Enter)`,children:`Open`})}var aW={type:`diagram`,copyText:e=>e.source,Body:rW,Tools:iW,overlay:{Component:nW,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Diagram`,icon:`diagram`,add:()=>({content:{type:`diagram`,source:`flowchart LR
82
+ A[Start] --> B[Next]`}})},added:(e,t)=>t.edit(e.id)},oW=400,sW=`tricot:diff-view`,cW=new Set,lW=(()=>{try{return localStorage.getItem(sW)===`split`?`split`:`unified`}catch{return`unified`}})();function uW(){return[(0,d.useSyncExternalStore)(e=>(cW.add(e),()=>cW.delete(e)),()=>lW),e=>{lW=e;try{localStorage.setItem(sW,e)}catch{}for(let e of cW)e()}]}var dW=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function fW({block:e}){let[t,n]=uW(),r=(0,d.useMemo)(()=>Nn(e.files),[e.files]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`diff-stat`,title:`${Pn(r.additions,r.deletions)} in ${dW(r.files,`file`)}`,children:[(0,Q.jsxs)(`span`,{className:`diff-plus`,children:[`+`,r.additions.toLocaleString(`en-US`)]}),` `,(0,Q.jsxs)(`span`,{className:`diff-minus`,children:[`−`,r.deletions.toLocaleString(`en-US`)]}),(0,Q.jsxs)(`span`,{className:`diff-stat-files`,children:[` · `,dW(r.files,`file`)]})]}),(0,Q.jsx)(`span`,{className:`diff-switch nodrag`,role:`radiogroup`,"aria-label":`Show the diff`,onDoubleClick:e=>e.stopPropagation(),children:[`unified`,`split`].map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,className:t===e?`is-on`:void 0,onClick:()=>n(e),title:e===`unified`?`Old and new lines in one column`:`Old lines on the left, new on the right`,children:e===`unified`?`Unified`:`Split`},e))})]})}var pW=(e,t,n)=>`${e}\n${t}\n${n}`;function mW({block:e,placed:t}){let n=(0,d.useMemo)(()=>e.files.map(e=>e.path).join(`
83
+ `),[e.files]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(YB,{block:e,placed:t}),(0,Q.jsx)(hW,{block:e,placed:t},n)]})}function hW({block:e,placed:t}){let n=$z(),[r]=uW(),i=(0,d.useRef)(null),a=(0,d.useMemo)(()=>t.flatMap(({pin:e,place:t})=>t?.kind===`line`?[{pin:e,place:t}]:[]),[t]),o=(0,d.useMemo)(()=>new Set(a.map(e=>e.place.file)),[a]),[s,c]=(0,d.useState)(()=>new Set([...Rn(e.files,e.focus),...o])),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(()=>new Set),m=(0,d.useMemo)(()=>zn(e.files,e.focus),[e.files,e.focus]),{bySpot:h,numbers:g}=(0,d.useMemo)(()=>{let e=new Map;for(let{pin:t,place:n}of a){let r=pW(n.file,n.side,n.line);e.set(r,[...e.get(r)??[],t])}let t=new Map;for(let n of m)if(a.some(e=>e.place.file===n.path))for(let r of n.hunks)for(let i of Vn(r))for(let r of[pW(n.path,`old`,i.old),pW(n.path,`new`,i.new)])for(let n of e.get(r)??[])t.has(n.id)||t.set(n.id,t.size+1);return{bySpot:e,numbers:t}},[a,m]),_=a.find(e=>e.pin.id===n.focusPin);(0,d.useEffect)(()=>{_&&!s.has(_.place.file)&&c(e=>new Set(e).add(_.place.file))},[_,s]),(0,d.useLayoutEffect)(()=>{if(!_||!i.current)return;let e=i.current.querySelector(`[data-pin-ids~="${CSS.escape(_.pin.id)}"]`),t=i.current.closest(`.block-body`);if(!e||!t)return;let n=t.getBoundingClientRect().height/t.offsetHeight||1,r=(e.getBoundingClientRect().top-t.getBoundingClientRect().top)/n;t.scrollTop+=r-t.clientHeight/3},[_,s]);let v=(0,d.useMemo)(()=>new Set([...s,...e.focus??[],...o]),[s,e.focus,o]),y=l?m:Bn(m,v),b=Math.max(1,...e.files.map(e=>e.additions+e.deletions)),x=e.files.filter(e=>e.omitted).length,S=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,Q.jsxs)(`div`,{className:`diff is-${r}`,ref:i,children:[x>0&&(0,Q.jsxs)(`p`,{className:`diff-note`,children:[`The patch is over `,2,` MB, so `,x===1?`one big file is`:`${x} of its biggest files are`,` listed without `,x===1?`its`:`their`,` changes.`]}),y.map(t=>(0,Q.jsx)(vW,{block:e,file:t,open:s.has(t.path),onToggle:()=>S(t.path),biggest:b,view:r,whole:f.has(t.path)||o.has(t.path),onWhole:()=>p(e=>new Set(e).add(t.path)),bySpot:h,numbers:g},t.path)),y.length<e.files.length&&(0,Q.jsxs)(`button`,{type:`button`,className:`diff-more nodrag`,onClick:()=>u(!0),children:[dW(e.files.length-y.length,`more file`),` · Show all`]})]})}function gW({file:e,biggest:t}){let n=e.additions+e.deletions,r=n===0?0:Math.max(1,Math.round(5*n/t)),i=n===0?0:Math.round(r*e.additions/n);return(0,Q.jsx)(`span`,{className:`diff-bar`,"aria-hidden":!0,children:Array.from({length:5},(e,t)=>(0,Q.jsx)(`i`,{className:t<i?`is-add`:t<r?`is-del`:void 0},t))})}var _W={added:`new`,deleted:`deleted`,renamed:`renamed`,binary:`binary`,modified:null};function vW(e){let{file:t,open:n,onToggle:r,biggest:i}=e,a=In(t.path),o=[_W[t.status],a&&`generated`,t.omitted&&`too big to show`].filter(Boolean),s=t.oldPath?`${t.oldPath} → ${t.path}`:t.path;return(0,Q.jsxs)(`section`,{className:`diff-file${n?` is-open`:``}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`diff-file-head`,onClick:r,onDoubleClick:e=>e.stopPropagation(),"aria-expanded":n,title:n?`Close ${t.path}`:`Open ${t.path}`,children:[(0,Q.jsx)(`span`,{className:`diff-chevron`,"aria-hidden":!0,children:`›`}),(0,Q.jsx)(`span`,{className:`diff-path`,children:s}),o.map(e=>(0,Q.jsx)(`span`,{className:`diff-tag is-${e.split(` `)[0]}`,children:e},e)),(0,Q.jsx)(`span`,{className:`diff-file-count`,children:t.status===`binary`?``:(0,Q.jsxs)(Q.Fragment,{children:[t.additions>0&&(0,Q.jsxs)(`span`,{className:`diff-plus`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),t.deletions>0&&(0,Q.jsxs)(`span`,{className:`diff-minus`,children:[` −`,t.deletions.toLocaleString(`en-US`)]})]})}),(0,Q.jsx)(gW,{file:t,biggest:i})]}),n&&(0,Q.jsx)(bW,{...e})]})}function yW(e){return e.omitted?`Its changes were left out to keep this diff under ${Math.round(Mn/1024/1024)} MB.`:e.status===`binary`?`A binary file: its changes aren’t shown.`:e.status===`renamed`?`Renamed, with nothing changed inside.`:`Nothing changed in its text (only its mode).`}function bW(e){let{block:t,file:n,view:r,whole:i,onWhole:a,bySpot:o,numbers:s}=e,c=$z(),{pinnable:l,handlers:u}=wH(e=>{let r=e.dataset.side,i=Number(e.dataset.line),a=Wn(n,r,i)??``;return{blockId:t.id,part:{kind:`line`,file:n.path,line:i,side:r},quote:Un(a)}}),f=Ln(n),p=(0,d.useMemo)(()=>{let e=dH(n.path),t=i?1/0:oW,r=[];for(let i of n.hunks){if(t<=0)break;let n={inComment:!1},a=Vn(i).slice(0,t).map(t=>({row:t,tokens:t.kind===`note`?[{text:t.text}]:xH(t.text,e,n)}));t-=a.length;let o=new Map(a.map(({row:e,tokens:t})=>[e,t]));r.push({hunk:i.header,rows:a,pairs:Hn(a.map(e=>e.row)),tokensOfRow:o})}return r},[n,i]);if(n.hunks.length===0)return(0,Q.jsx)(`p`,{className:`diff-empty`,children:yW(n)});let m=String(Math.max(...n.hunks.map(e=>Math.max(e.oldStart+e.oldLines,e.newStart+e.newLines)))).length,h=c.draft?.blockId===t.id&&c.draft.part.kind===`line`?c.draft.part:null,g=(e,t)=>!!(h&&h.file===n.path&&h.side===e&&h.line===t),_=(e,t)=>t===void 0?[]:o.get(pW(n.path,e,t))??[],v=(e,t,n)=>e.length>0&&(0,Q.jsx)(TH,{pins:e,numbers:s,where:`${t===`old`?`old line`:`line`} ${n}`},`t${t}${n}`),y=p.reduce((e,t)=>e+t.rows.length,0);return(0,Q.jsxs)(`div`,{className:`diff-code nodrag${l?` is-pinnable`:``}`,...u,children:[(0,Q.jsx)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${m}ch`},children:p.map(({hunk:e,rows:t,pairs:n,tokensOfRow:i},a)=>(0,Q.jsxs)(d.Fragment,{children:[(0,Q.jsx)(`div`,{className:`diff-hunk`,children:e}),r===`unified`?t.map(({row:e,tokens:t},n)=>{let r=e.kind===`del`?`old`:`new`,i=e[r],a=[..._(`old`,e.old),...e.kind===`context`?_(`new`,e.new):_(r,i)],o=[...new Set(a)],s=[`diff-row`,`is-${e.kind}`,o.length>0&&`is-pinned`,g(r,i)&&`is-draft`,o.some(e=>e.id===c.focusPin)&&`is-focus`];return(0,Q.jsxs)(d.Fragment,{children:[(0,Q.jsxs)(`div`,{className:s.filter(Boolean).join(` `),"data-side":e.kind===`note`?void 0:r,"data-line":e.kind===`note`?void 0:i,"data-pin-draft":g(r,i)?``:void 0,"data-pin-ids":o.length?o.map(e=>e.id).join(` `):void 0,children:[(0,Q.jsx)(`span`,{className:`diff-num`,children:e.old}),(0,Q.jsx)(`span`,{className:`diff-num`,children:e.new}),(0,Q.jsx)(`span`,{className:`diff-mark`,children:xW[e.kind]}),(0,Q.jsx)(CH,{tokens:t,note:e.kind===`note`})]}),i!==void 0&&v(o,r,i)]},n)}):n.map(({left:e,right:t},n)=>{let r=e=>e&&i.get(e)||[],a=e&&e.kind!==`note`?_(`old`,e.old):[],o=t&&t.kind!==`note`?_(`new`,t.new):[],s=[...new Set([...a,...o])],l=[`diff-row`,`is-pair`,s.length>0&&`is-pinned`,s.some(e=>e.id===c.focusPin)&&`is-focus`],u=t?.new??e?.old;return(0,Q.jsxs)(d.Fragment,{children:[(0,Q.jsxs)(`div`,{className:l.filter(Boolean).join(` `),"data-pin-ids":s.length?s.map(e=>e.id).join(` `):void 0,children:[(0,Q.jsx)(SW,{row:e,side:`old`,tokens:r(e),draft:g(`old`,e?.old)}),(0,Q.jsx)(SW,{row:t,side:`new`,tokens:r(t),draft:g(`new`,t?.new)})]}),u!==void 0&&v(s,t?.new===void 0?`old`:`new`,u)]},n)})]},a))}),y<f&&(0,Q.jsxs)(`button`,{type:`button`,className:`diff-more`,onClick:a,children:[`Show all `,f.toLocaleString(`en-US`),` lines`]})]})}var xW={add:`+`,del:`−`,context:``,note:``};function SW({row:e,side:t,tokens:n,draft:r}){if(!e)return(0,Q.jsx)(`span`,{className:`diff-half is-blank`});let i=e.kind===`note`?void 0:e[t];return(0,Q.jsxs)(`span`,{className:`diff-half is-${e.kind}${r?` is-draft`:``}`,"data-side":i===void 0?void 0:t,"data-line":i,"data-pin-draft":r?``:void 0,children:[(0,Q.jsx)(`span`,{className:`diff-num`,children:i}),(0,Q.jsx)(`span`,{className:`diff-mark`,children:xW[e.kind]}),(0,Q.jsx)(CH,{tokens:n,note:e.kind===`note`})]})}var CW={type:`diff`,copyText:e=>e.patch,Body:({block:e,placed:t})=>(0,Q.jsx)(mW,{block:e,placed:t}),Head:({block:e})=>(0,Q.jsx)(fW,{block:e}),ownPins:!0};function wW(e,t){return Math.max(0,...e.flatMap(e=>e.blockId===t&&e.anchor.kind===`box`?[e.anchor.n]:[]))+1}var TW={id:`figma`,marks:{figma:{tile:`#1e1e1e`,dark:!0,glyph:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M16 7h-3a3 3 0 0 0 0 6h3Z`,fill:`#f24e1e`}),(0,Q.jsx)(`path`,{d:`M16 7h3a3 3 0 0 1 0 6h-3Z`,fill:`#ff7262`}),(0,Q.jsx)(`path`,{d:`M16 13h-3a3 3 0 0 0 0 6h3Z`,fill:`#a259ff`}),(0,Q.jsx)(`circle`,{cx:`19`,cy:`16`,r:`3`,fill:`#1abcfe`}),(0,Q.jsx)(`path`,{d:`M13 19h3v3a3 3 0 1 1-3-3Z`,fill:`#0acf83`})]})}}},EW=`tricot:connectors`,DW=new Set,OW=!1;function kW(e){return!!(e&&typeof e==`object`&&e.type===`tricot:connector`)}function AW(e){if(!OW){OW=!0;let e=e=>{if(kW(e)){NW.clear(),LW();for(let t of DW)t(e)}};try{new BroadcastChannel(EW).onmessage=t=>e(t.data)}catch{}window.addEventListener(`message`,t=>t.origin===location.origin&&e(t.data))}return DW.add(e),()=>DW.delete(e)}var jW=12e4,MW=6e4,NW=new Map,PW=new Set,FW=new Set;function IW(){NW.clear(),LW()}function LW(){for(let e of FW)e()}function RW(e,t){let n=NW.get(e);PW.has(e)||n&&Date.now()-n.at<(n.file?jW:MW)||(PW.add(e),t().then(t=>NW.set(e,{at:Date.now(),file:t}),()=>NW.set(e,{at:Date.now(),file:n?.file??null})).finally(()=>{PW.delete(e),LW()}))}function zW(e){FW.add(e);let t=AW(()=>{});return()=>{FW.delete(e),t()}}function BW(e){let t=e?.fileId,n=e?.connector?yq(e.connector)?.fileInfo:void 0,r=t&&n&&e?.connector?`${e.connector}:${t}`:void 0,i=(0,d.useSyncExternalStore)(zW,()=>r?NW.get(r)?.file??null:null);return(0,d.useEffect)(()=>{if(!r||!t||!n)return;let e=()=>RW(r,()=>n(t));return e(),window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[r,t,i]),i}function VW(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;if(Date.now()-t.getTime()<6048e5)return`edited ${ex(e)}`;let n=t.getFullYear()===new Date().getFullYear();return`edited ${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:n?void 0:`numeric`})}`}var HW=2e4,UW=new Map,WW=new Set;function GW(){UW.clear(),IW();for(let e of WW)e()}var KW={card(e){let t=UW.get(e);if(t&&Date.now()-t.at<HW)return t.answer;let n=Vl(Yr.file)({fileId:e});return UW.set(e,{at:Date.now(),answer:n}),n.catch(()=>UW.delete(e)),n},connect:e=>Y(Yr.token)({token:e}),bringIn:(e,t)=>Y(Yr.bringIn)({actor:t,blockId:e}),refresh:(e,t)=>Y(Yr.refresh)({actor:t},{blockId:e})};function qW(e){let[t,n]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!e)return;let t=!0,r=()=>{KW.card(e).then(r=>t&&n({fileId:e,answer:r}),r=>t&&n({fileId:e,answer:{file:null,problem:{code:`error`,message:r.message}}}))};return r(),WW.add(r),window.addEventListener(`focus`,r),()=>{t=!1,WW.delete(r),window.removeEventListener(`focus`,r)}},[e]),t&&t.fileId===e?t.answer:null}function JW(e,t,n){let r=t?`frame`:`file`;return e===`not_connected`?`Connect Figma to see this ${r} here.`:e===`needs_sign_in`||e===`token_refused`?`Figma needs a new token before it can show this.`:n??`Figma isn't showing this ${r} right now.`}function YW({block:e,source:t}){let n=$z(),r=qW(t.fileId),[i,a]=(0,d.useState)(!1);if(!t.fileId)return null;let o=r?.file,s=o?o.frame:t.fileId.includes(`:`),c=[`not_connected`,`needs_sign_in`,`token_refused`].includes(r?.problem?.code??``);return(0,Q.jsxs)(`div`,{className:`figma-card nodrag`,children:[(0,Q.jsx)(`div`,{className:`figma-card-preview`,children:o?.thumbnail?(0,Q.jsx)(`img`,{src:Jr(J.asset,{id:o.thumbnail}),alt:`Preview of ${o.name}`,draggable:!1}):r?(0,Q.jsx)(`p`,{className:`faint small`,children:JW(r.problem?.code,s,r.problem?.message)}):(0,Q.jsx)(`p`,{className:`faint small`,children:`Loading the preview…`})}),(0,Q.jsxs)(`div`,{className:`figma-card-actions`,children:[o&&s&&(0,Q.jsxs)(`span`,{className:`faint small figma-card-file`,children:[`In `,o.fileName]}),c&&(0,Q.jsx)(`a`,{className:`btn btn-small btn-primary`,href:dS.connectors(n.board.id),children:`Connect Figma`}),o&&s&&!n.readOnly&&(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:i,onClick:()=>n.perform(async t=>{a(!0);try{await KW.bringIn(e.id,t)}finally{a(!1)}}),title:`Add a picture of this frame to the canvas, kept as it is now`,children:i?`Bringing it in…`:`Bring in this frame`})]})]})}function XW({block:e,viewing:t}){let n=$z(),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1);return n.readOnly?null:(0,Q.jsx)(`button`,{onClick:()=>n.perform(async t=>{i(!0),o(!1);try{let{changed:n}=await KW.refresh(e.id,t);n||(o(!0),setTimeout(()=>o(!1),3e3))}finally{i(!1)}}),disabled:r||t!==null,title:t?`Go back to the current version to refresh it`:`Draw this frame again from Figma. This picture is kept as an earlier version`,children:r?`Refreshing…`:a?`Already up to date`:`Refresh`})}function ZW({status:e,onChange:t}){let[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(null),c=async e=>{e.preventDefault(),a(!0),s(null);try{let{connector:e}=await KW.connect(n);r(``),t(e),GW()}catch(e){s(e.message)}finally{a(!1)}};return(0,Q.jsxs)(`section`,{className:`connector-section`,children:[(0,Q.jsx)(`h3`,{children:e.state===`needs_sign_in`?`Paste a new Figma token`:`Paste your Figma token`}),(0,Q.jsx)(`p`,{className:`muted small`,children:`In Figma, open Settings → Security → Personal access tokens and make a token with read-only access (Current user, File content, Comments).`}),(0,Q.jsxs)(`form`,{className:`figma-token`,onSubmit:e=>void c(e),children:[(0,Q.jsx)(`input`,{type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`figd_…`,"aria-label":`Figma token`,value:n,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:i||!n.trim(),children:i?`Checking…`:`Connect Figma`})]}),(0,Q.jsx)(`p`,{className:`faint small`,children:`The token stays on this computer and is sent only to Figma.`}),o&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:o})]})}function QW(){let{tile:e,glyph:t}=TW.marks.figma;return(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var $W={id:`figma`,Mark:QW,serves:`Figma files and frames`,setup:{intro:`Figma needs nothing set up: paste a token.`,files:[]},signOutHint:`you can delete the token in Figma, under Settings → Security.`,removedNote:`Disconnected here. The token still works until you delete it in Figma, under Settings → Security → Personal access tokens.`,accessNote:()=>`Read-only: Tricot never changes a Figma file. It can open what your token allows; make a new token in Figma to change that.`,SignIn:ZW,fileInfo:async e=>{let{file:t}=await KW.card(e);return t&&{name:t.name,modifiedTime:t.modifiedTime}},LinkCard:YW,ImageTools:XW},eG={stroke:`#fff`,strokeWidth:1.75,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`},tG=`M12 9h9.5v14H12a1.5 1.5 0 0 1-1.5-1.5v-11A1.5 1.5 0 0 1 12 9ZM10.5 20.5A1.5 1.5 0 0 1 12 19h9.5`,nG={id:`github`,marks:{github:{tile:`#1f2328`,dark:!0,glyph:(0,Q.jsxs)(`g`,{...eG,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`10`,r:`2`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`22`,r:`2`}),(0,Q.jsx)(`circle`,{cx:`21`,cy:`14`,r:`2`}),(0,Q.jsx)(`path`,{d:`M12 12v8M21 16c0 3-4 3-9 4`})]})},"github-pull":{tile:`#1f2328`,dark:!0,glyph:(0,Q.jsxs)(`g`,{...eG,children:[(0,Q.jsx)(`circle`,{cx:`11`,cy:`10`,r:`2`}),(0,Q.jsx)(`circle`,{cx:`11`,cy:`22`,r:`2`}),(0,Q.jsx)(`circle`,{cx:`21`,cy:`22`,r:`2`}),(0,Q.jsx)(`path`,{d:`M11 12v8M21 20v-6a3 3 0 0 0-3-3h-3.5M16 9l-1.75 2L16 13`})]})},"github-issue":{tile:`#1f2328`,dark:!0,glyph:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`16`,cy:`16`,r:`6.5`,...eG}),(0,Q.jsx)(`circle`,{cx:`16`,cy:`16`,r:`1.6`,fill:`#fff`})]})},"github-repo":{tile:`#1f2328`,dark:!0,glyph:(0,Q.jsx)(`path`,{d:tG,...eG})}}},rG={open:`Open`,closed:`Closed`,merged:`Merged`,draft:`Draft`};function iG(e){let t=[e.passing&&`${e.passing} passing`,e.failing&&`${e.failing} failing`,e.pending&&`${e.pending} pending`].filter(Boolean);return t.length?t.join(`, `):`no checks`}var aG={device:()=>Vl(li.device)(),startDevice:()=>Y(li.startDevice)({}),pollDevice:()=>Y(li.pollDevice)({}),cancelDevice:()=>Y(li.cancelDevice)({}),useToken:e=>Y(li.token)({token:e}),repos:(e=!1)=>Vl(li.repos)(void 0,e?{fresh:`1`}:void 0),card:(e,t=!1)=>{let[n,r,i,a]=e.split(`/`);return Vl(li.card)({owner:n,repo:r,kind:i,number:a},t?{fresh:`1`}:void 0)},showChanges:(e,t)=>Y(li.showChanges)({actor:t},{blockId:e}),bringInFile:(e,t)=>Y(li.bringInFile)({actor:t},{blockId:e})},oG=6e4,sG=new Map,cG=new Map,lG=new Set,uG=()=>lG.forEach(e=>e());function dG(e,t=!1){let n=sG.get(e),r=cG.get(e);if(r)return r;if(!t&&n&&Date.now()-n.at<oG)return Promise.resolve(n.answer);let i=aG.card(e,t).then(t=>(sG.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return cG.set(e,i),uG(),i.finally(()=>{cG.delete(e),uG()}),i}function fG(){sG.clear(),uG()}var pG=e=>(lG.add(e),()=>void lG.delete(e));function mG(e){let t=(0,d.useSyncExternalStore)(pG,()=>e?sG.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(pG,()=>e?cG.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;dG(e);let t=()=>void dG(e);return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[e]);let r=(0,d.useCallback)(()=>e?dG(e,!0):Promise.resolve(null),[e]);return{card:t?.card,problem:t?.problem,busy:n,refresh:r}}function hG({block:e}){let t=(0,d.useMemo)(()=>vi(e.url),[e.url]);return t?t.kind===`file`?(0,Q.jsx)(SG,{block:e,target:t}):(0,Q.jsx)(xG,{block:e,target:t}):null}function gG({passing:e,failing:t,pending:n}){return e+t+n===0?`No checks`:t?`${t} failing`:n?`${n} pending`:`${e} passing`}function _G({checks:e}){let t=e.passing+e.failing+e.pending,n=e.failing?`failing`:e.pending?`pending`:t?`passing`:`none`;return(0,Q.jsxs)(`span`,{className:`gh-checks is-${n}`,title:`Checks on the latest commit: ${iG(e)}`,children:[(0,Q.jsx)(`span`,{className:`gh-dot`,"aria-hidden":!0}),gG(e)]})}function vG({card:e}){return(0,Q.jsx)(`span`,{className:`gh-state is-${e.state}`,children:rG[e.state]})}function yG(e){let t=$z(),[n,r]=(0,d.useState)(`idle`);return{state:n,start:()=>{r(`working`),t.perform(async t=>{try{await e(t),r(`done`)}catch(e){throw r(`idle`),e}})},canAdd:!t.readOnly}}var bG={not_installed:`Tricot can't see it yet`,needs_sign_in:`GitHub needs you to sign in again`,not_found:`GitHub can't find this`};function xG({block:e,target:t}){let{card:n,problem:r,busy:i,refresh:a}=mG(yi(t)),o=yG(t=>aG.showChanges(e.id,t));if(!n&&!r)return i?(0,Q.jsx)(`p`,{className:`gh-details faint`,children:`Looking it up on GitHub…`}):null;if(r){if(r.code===`not_connected`)return null;let e=bG[r.code]??r.message;return(0,Q.jsxs)(`p`,{className:`gh-details gh-problem is-${r.code}`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`gh-problem-text`,title:r.message,children:e}),r.code===`not_installed`&&r.installUrl&&(0,Q.jsxs)(`a`,{className:`btn btn-small nodrag`,href:r.installUrl,target:`_blank`,rel:`noreferrer`,title:r.message,children:[`Install Tricot on `,t.owner,`/`,t.repo,(0,Q.jsx)($,{name:`external`})]}),r.code===`needs_sign_in`&&(0,Q.jsx)(`a`,{className:`btn btn-small nodrag`,href:dS.connectors(),children:`Sign in again`})]})}return n?(0,Q.jsxs)(`div`,{className:`gh-details nodrag`,children:[(0,Q.jsx)(vG,{card:n}),(0,Q.jsx)(`span`,{className:`gh-by`,title:`${n.repo} #${n.number}, by ${n.author}`,children:n.author}),n.checks&&(0,Q.jsx)(_G,{checks:n.checks}),(0,Q.jsx)(`span`,{className:`gh-spacer`}),n.kind===`pull`&&o.canAdd&&(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:o.state!==`idle`,onClick:o.start,title:`Add this pull request's changes to the canvas, as a diff beside the card`,children:o.state===`done`?`Changes added`:o.state===`working`?`Adding…`:`Show the changes`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet gh-refresh`,disabled:i,onClick:()=>void a(),title:`Look it up on GitHub again`,"aria-label":`Refresh from GitHub`,children:(0,Q.jsx)($,{name:`sync`})})]}):null}function SG({block:e,target:t}){let n=yG(t=>aG.bringInFile(e.id,t)),r=t.lines&&(t.lines[0]===t.lines[1]?`line ${t.lines[0]}`:`lines ${t.lines[0]}–${t.lines[1]}`);return n.canAdd?(0,Q.jsxs)(`div`,{className:`gh-details nodrag`,children:[(0,Q.jsx)(`span`,{className:`gh-by`,children:r?`Highlights ${r}`:`A file on GitHub`}),(0,Q.jsx)(`span`,{className:`gh-spacer`}),(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:n.state!==`idle`,onClick:n.start,title:`Add this file to the canvas as code, at the commit the link names`,children:n.state===`done`?`File brought in`:n.state===`working`?`Bringing in…`:`Bring in this file`})]}):null}var CG=30;function wG(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),s=(0,d.useCallback)(e=>{o(!0),aG.repos(e).then(e=>{n(e),i(null)},e=>i(e.message)).finally(()=>o(!1))},[]);(0,d.useEffect)(()=>{s(!1);let e=()=>s(!0);return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[s]);let c=t?.via!==`token`;return(0,Q.jsxs)(`section`,{className:`connector-section`,children:[(0,Q.jsx)(`h3`,{children:c?`Repositories Tricot is installed on`:`Repositories this token covers`}),r&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:r}),t&&t.repos.length===0&&!r&&(0,Q.jsx)(`p`,{className:`muted small`,children:c?`Tricot isn't installed on any repository yet, so it can only read public ones. Install it on the repositories you want it to read.`:`This token covers no repositories.`}),t&&t.repos.length>0&&(0,Q.jsxs)(`ul`,{className:`gh-repos`,children:[t.repos.slice(0,CG).map(e=>(0,Q.jsxs)(`li`,{title:e.private?`Private`:`Public`,children:[e.fullName,e.private&&(0,Q.jsx)(`span`,{className:`gh-private`,children:` · private`})]},e.fullName)),t.repos.length>CG&&(0,Q.jsxs)(`li`,{className:`faint`,children:[`and `,t.repos.length-CG,` more`]}),t.truncated&&(0,Q.jsx)(`li`,{className:`faint`,children:`and more not listed`})]}),(0,Q.jsxs)(`div`,{className:`row`,children:[c&&(t?.installUrl?(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:t.installUrl,target:`_blank`,rel:`noreferrer`,children:[`Install on your repos`,(0,Q.jsx)($,{name:`external`})]}):(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:t?.manageUrl??`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:[`Manage installations on GitHub`,(0,Q.jsx)($,{name:`external`})]})),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:a,onClick:()=>s(!0),children:`Refresh the list`})]})]})}var TG=`https://github.com/settings/personal-access-tokens/new`;function EG({onChange:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=(0,d.useRef)(e);l.current=e,(0,d.useEffect)(()=>{aG.device().then(({device:e})=>n(e),()=>{})},[]),(0,d.useEffect)(()=>{if(!t)return;let e=!1,r,a=t=>{r=setTimeout(async()=>{try{let t=await aG.pollDevice();if(e)return;if(t.state===`pending`)return a(t.interval);n(null),t.state===`connected`?(fG(),l.current(t.connector)):i(t.message)}catch(t){if(e)return;n(null),i(t.message)}},t*1e3+250)};return a(t.interval),()=>{e=!0,clearTimeout(r)}},[t?.userCode]);let u=async()=>{o(!0),i(null);try{n((await aG.startDevice()).device)}catch(e){i(e.message)}finally{o(!1)}},f=()=>{n(null),aG.cancelDevice().catch(()=>{})},p=async()=>{o(!0),i(null);try{let{connector:t}=await aG.useToken(s);c(``),fG(),e(t)}catch(e){i(e.message)}finally{o(!1)}};return(0,Q.jsxs)(`section`,{className:`connector-section gh-signin`,children:[t?(0,Q.jsxs)(`div`,{className:`gh-code`,role:`status`,children:[(0,Q.jsx)(`p`,{className:`muted small`,children:`Type this code on GitHub to let Tricot in:`}),(0,Q.jsx)(`p`,{className:`gh-code-digits`,"aria-label":`Your code is ${t.userCode.split(``).join(` `)}`,children:t.userCode}),(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsxs)(`a`,{className:`btn btn-primary btn-small`,href:t.verificationUri,target:`_blank`,rel:`noreferrer`,children:[`Open `,t.verificationUri.replace(/^https?:\/\//,``),(0,Q.jsx)($,{name:`external`})]}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:f,children:`Cancel`})]}),(0,Q.jsxs)(`span`,{className:`connector-waiting`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Waiting for you to allow it on GitHub…`]})]}):(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:a,onClick:()=>void u(),children:`Connect GitHub`}),(0,Q.jsx)(`span`,{className:`faint small`,children:`You get a code to type on github.com. Nothing is saved until you allow it there.`})]}),!t&&(0,Q.jsxs)(`details`,{className:`gh-token`,children:[(0,Q.jsx)(`summary`,{children:`Use a personal token instead`}),(0,Q.jsxs)(`p`,{className:`muted small`,children:[`Make a fine-grained token on GitHub with read-only access to Contents, Pull requests, Issues, Checks and Commit statuses, on the repositories you want Tricot to read, and paste it here.`,` `,(0,Q.jsx)(`a`,{href:TG,target:`_blank`,rel:`noreferrer`,children:`Make a token`})]}),(0,Q.jsx)(`input`,{type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`github_pat_…`,"aria-label":`Personal access token`,value:s,onChange:e=>c(e.target.value)}),(0,Q.jsx)(`div`,{className:`row`,children:(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:a||!s.trim(),onClick:()=>void p(),children:`Use this token`})})]}),r&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}function DG(){let{tile:e,glyph:t}=nG.marks.github;return(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var OG={id:`github`,Mark:DG,serves:`Pull requests, issues and files`,setup:{intro:`GitHub needs nothing set up: Tricot signs in with its own GitHub App.`,files:[]},signOutHint:`remove Tricot at github.com/settings/apps/authorizations, or delete the personal token at github.com/settings/tokens.`,removedNote:`Disconnected here. GitHub keeps the grant until you remove it at github.com/settings/apps/authorizations; a personal token works until you delete it at github.com/settings/tokens.`,accessNote:()=>`Read-only on the repositories Tricot is installed on (or a token covers): it can't change anything on GitHub. It never reads your other repositories.`,SignIn:EG,Panel:wG,LinkCard:hG,fileInfo:async e=>{let t=await dG(e);return t?.card?{name:t.card.title,modifiedTime:t.card.updatedAt}:null}},kG={driveFile:e=>Vl(wi.file)({fileId:e}),pickerConfig:()=>Y(wi.picker)({}),chosen:e=>Y(wi.chosen)({fileIds:e}),googleDoc:(e,t)=>Vl(wi.doc)({blockId:e},{actor:t}),editDocDraft:(e,t,n,r)=>Y(wi.docDraft)({actor:t,revision:n,changes:r},{blockId:e}),discardDocDraft:(e,t)=>Y(wi.docDiscard)({actor:t},{blockId:e}),saveDocDraft:(e,t)=>Y(wi.docSave)({actor:t},{blockId:e}),resolveDocConflict:(e,t,n,r)=>Y(wi.docResolve)({actor:t,conflict:n,keep:r},{blockId:e}),pinDocWords:(e,t,n)=>Y(wi.docPins)({actor:t,...n},{blockId:e})},AG=`https://apis.google.com/js/api.js`,jG=`application/vnd.google-apps.document`,MG;function NG(){return MG??=new Promise((e,t)=>{let n=window,r=()=>{MG=void 0,t(Error(`Google's chooser couldn't load. Check your connection and try again.`))},i=()=>{if(!n.gapi)return r();n.gapi.load(`picker`,{callback:()=>n.google?.picker?e(n.google.picker):r(),onerror:r})};if(n.gapi)return i();let a=document.createElement(`script`);a.src=AG,a.async=!0,a.onload=i,a.onerror=r,document.head.append(a)}),MG}var PG=()=>({loadApi:NG,origin:`${location.protocol}//${location.host}`});async function FG(e,t={},n=PG()){let r=await n.loadApi(),i=new r.DocsView(r.ViewId.DOCUMENTS).setMimeTypes(jG).setMode(r.DocsViewMode.LIST).setIncludeFolders(!1);return t.fileIds?.length&&i.setFileIds(t.fileIds.join(`,`)),new Promise(a=>{let o=new r.PickerBuilder().addView(i).setOAuthToken(e.accessToken).setOrigin(n.origin).setTitle(t.title??`Choose the Google Docs Tricot may use`).setCallback(e=>{e.action===r.Action.PICKED?a((e.docs??[]).flatMap(e=>e.id&&e.url?[{id:e.id,name:e.name??`Google Doc`,url:e.url}]:[])):e.action===r.Action.CANCEL&&a([])});e.appId&&(o=o.setAppId(e.appId)),e.apiKey&&(o=o.setDeveloperKey(e.apiKey)),t.multiple&&(o=o.enableFeature(r.Feature.MULTISELECT_ENABLED)),o.build().setVisible(!0)})}async function IG(e={}){let t=await FG(await kG.pickerConfig(),e);return t.length&&(await kG.chosen(t.map(e=>e.id)),IW()),t}function LG({status:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(null);if(e.state!==`connected`||!e.access.some(e=>e.scope===`https://www.googleapis.com/auth/drive.file`&&e.granted))return null;let s=async()=>{n(!0),o(null);try{let e=await IG({multiple:!0});e.length&&i(e)}catch(e){o(e.message)}finally{n(!1)}};return(0,Q.jsxs)(`section`,{className:`connector-section`,children:[(0,Q.jsx)(`h3`,{children:`Google Docs Tricot may use`}),(0,Q.jsx)(`p`,{className:`muted small`,children:`Tricot sees only the Google Docs you choose, nothing else in your Drive. Choose them here, from Add → Link on a board, or when a doc's card asks.`}),(0,Q.jsx)(`div`,{className:`row`,children:(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:t,onClick:()=>void s(),children:t?`Choosing…`:`Choose Google Docs`})}),r.length>0&&(0,Q.jsxs)(`p`,{className:`muted small`,role:`status`,children:[`Tricot may now use `,r.map(e=>e.name).join(`, `),`. Add a link to `,r.length===1?`it`:`them`,` on a board to edit`,` `,r.length===1?`it`:`them`,` in Tricot.`]}),a&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:a})]})}var RG={NORMAL_TEXT:`Text`,TITLE:`Title`,SUBTITLE:`Subtitle`,HEADING_1:`Heading 1`,HEADING_2:`Heading 2`,HEADING_3:`Heading 3`,HEADING_4:`Heading 4`,HEADING_5:`Heading 5`,HEADING_6:`Heading 6`};function zG(e,t){let n=new Map((t?.edits??[]).filter(e=>e.op!==`add`).map(e=>[e.id,e])),r=(t?.edits??[]).filter(e=>e.op===`add`),i=new Map(r.map(e=>[e.after,e])),a=[],o=new Set,s=e=>{for(let t=i.get(e);t&&!o.has(t.id);t=i.get(t.id))o.add(t.id),a.push({id:t.id,text:t.text,style:t.style??`NORMAL_TEXT`,...t.list?{list:{ordered:t.list===`numbered`,level:0}}:{},state:`added`,by:t.by,at:t.at})};s(``);for(let t of e){let e=n.get(t.id),{start:r,end:i,...o}=t;e?e.op===`edit`?a.push({...o,text:e.text,state:`changed`,was:t.text,by:e.by,at:e.at}):a.push({...o,state:`removed`,was:t.text,by:e.by,at:e.at}):a.push({...o,state:`same`}),s(t.id)}for(let e of r)o.has(e.id)||s(e.after);return a}function BG(e){let t=new Map;for(let n of e?.edits??[]){let e=`${n.by.kind}:${n.by.name}`,r=t.get(e)??{by:n.by,count:0};r.count++,t.set(e,r)}return[...t.values()].sort((e,t)=>t.count-e.count)}function VG(e){let t=new Map,n=new Map,r;for(let i of e){if(i.state===`removed`||!i.list?.ordered){i.state!==`removed`&&!i.list&&n.clear(),r=i.state===`removed`?r:i;continue}let e=`${i.list.id??r?.list?.id??`new`}:${i.list.level}`,a=(n.get(e)??0)+1;n.set(e,a),t.set(i.id,a),r=i}return t}var HG={id:`loom`,marks:{loom:{tile:`#625df5`,glyph:(0,Q.jsx)(`path`,{d:`M16 8v4.5M16 19.5V24M8 16h4.5M19.5 16H24M10.3 10.3l3.2 3.2M18.5 18.5l3.2 3.2M10.3 21.7l3.2-3.2M18.5 13.5l3.2-3.2`,...eG,strokeWidth:2.25})}}},UG={id:`youtube`,marks:{youtube:{tile:`#ff0000`,glyph:(0,Q.jsx)(`path`,{d:`M13 10.75v10.5L22 16Z`,fill:`#fff`,stroke:`#fff`,strokeWidth:1,strokeLinejoin:`round`})}}},WG=()=>[TW,UG,HG,nG],GG,KG={tile:`#5d5866`,glyph:null};function qG(e){return GG??=Object.assign({},...vq().map(e=>e.marks??{}),...WG().map(e=>e.marks)),GG[e]??KG}function JG({mark:e}){let{tile:t,dark:n,glyph:r}=e;return(0,Q.jsx)(`span`,{className:n?`source-mark is-dark`:`source-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:t}),r]})})}function YG({mark:e}){return(0,Q.jsx)(JG,{mark:qG(e)})}var XG=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,ZG=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function QG(e){let{words:t,style:n,above:r,text:i,busy:a,error:o,agent:s,onText:c,onSubmit:l,onClose:u}=e,f=(0,d.useRef)(null),p=!i.trim(),m=(0,d.useRef)(i);return m.current=i,(0,d.useEffect)(()=>{let e=e=>{!f.current?.contains(e.target)&&!m.current.trim()&&u()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[u]),(0,Q.jsxs)(`div`,{ref:f,className:`pin-prompt doc-ask${r?` is-above`:``}`,style:n,role:`dialog`,"aria-label":`Ask about these words`,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!p&&!a&&l(!0))},children:[(0,Q.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,Q.jsxs)(`p`,{className:`pin-prompt-quote`,children:[`“`,t.quote,`”`]}),(0,Q.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:u,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(LE,{skills:!0,lenses:QT,rows:2,value:i,placeholder:s?`Ask ${s} to… (e.g. make this shorter, rewrite for a customer)`:`Ask an agent to… (e.g. make this shorter, rewrite for a customer); @ to pick one`,"aria-label":`What should an agent do with these words?`,onValue:c}),o&&(0,Q.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,Q.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:p||a,onClick:()=>l(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:p||a,onClick:()=>l(!1),children:`Comment`}),(0,Q.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${XG}+Enter asks ${s??`an agent`}`,children:XG===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,Q.jsxs)(`p`,{className:`pin-prompt-hint`,children:[s?`${s} edits the draft and replies here, with its steps on the pin as it works.`:`An agent edits the draft and replies here.`,` Comment just leaves a note.`]})]})}function $G(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=$z(),s=as(t,Zz(o)),c=t.discussion?.resolved,l=s.some(e=>e.ask),u=!c&&s.at(-1)?.author.kind===`human`,d=!c&&!n&&o.newItems.has(t.id),f=[`pin-chip`,`is-comment`,`doc-pin-chip`,l&&`is-ask`,c&&`is-done`,i&&`is-lost`,d&&`is-new`,n&&`is-open`],p=l?`Asked agents to edit`:`Comments on`,m=c?`, resolved by ${c.by.name}`:l&&u?`, waiting for an agent`:``;return(0,Q.jsxs)(`span`,{className:f.filter(Boolean).join(` `),"data-doc-chip":t.id,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} “${t.quote}”: ${ZG(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,Q.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,Q.jsx)($,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,Q.jsx)($,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,Q.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await PB(`these words`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin “${t.quote}”`,title:`Unpin. Its thread goes with it.`,children:(0,Q.jsx)($,{name:`x`})})]})}function eK({block:e}){let t=$z(),n=(t.pins.get(e.id)??[]).filter(e=>e.anchor.kind===`doc`&&e.discussion&&!e.discussion.resolved);if(n.length===0)return null;let r=n.filter(e=>t.newItems.has(e.id)),i=n.filter(e=>as(e,Zz(t)).some(e=>e.ask)).length,a=[i&&`${ZG(i,`request`)} to agents`,n.length-i&&ZG(n.length-i,`comment thread`)].filter(Boolean).join(` and `);return(0,Q.jsxs)(`button`,{type:`button`,className:`block-link-threads nodrag${r.length?` is-new`:``}`,onClick:()=>t.openOverlay(e.id,{pinId:(r[0]??n[0]).id}),onDoubleClick:e=>e.stopPropagation(),title:`${a} on paragraphs of this doc${r.length?`, with new replies`:``}. Open it there.`,children:[(0,Q.jsx)($,{name:i?`edit`:`comment`}),n.length,r.length>0&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]})}var tK=`tricot:docs-save-noted`,nK=700,rK=240;function iK(){try{return localStorage.getItem(tK)===`1`}catch{return!1}}function aK(e,t){return`${e} ${t}${e===1?``:`s`}`}function oK(e){let t=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let e=t.current;e&&(e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`)},[e.value]),(0,Q.jsx)(`textarea`,{ref:n=>{t.current=n,e.inputRef(n)},rows:1,className:e.className,value:e.value,"aria-label":e.label,"data-paragraph":e.paragraph,spellCheck:!0,onChange:t=>e.onChange(t.target.value),onBlur:e.onBlur,onKeyDown:e.onKeyDown,onMouseDown:e.onMouseDown})}function sK({actor:e,me:t}){return e.kind!==`human`||e.name.trim().toLowerCase()!==t.trim().toLowerCase()?(0,Q.jsx)(ix,{actor:e}):(0,Q.jsxs)(`span`,{className:`actor actor-human`,title:`${e.name} (you)`,children:[(0,Q.jsx)(ix,{actor:e,showName:!1,title:`${e.name} (you)`}),(0,Q.jsx)(`span`,{className:`actor-name`,children:`You`})]})}function cK({block:e,name:t,pinId:n,onClose:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(new Map),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(iK),D=(0,d.useRef)(new Map),O=(0,d.useRef)(null),k=(0,d.useRef)(new Map),A=(0,d.useRef)(Promise.resolve()),j=(0,d.useRef)(p);j.current=p;let M=$z(),{seeItem:N}=M,[P,F]=(0,d.useState)(null),[I,L]=(0,d.useState)(``),[R,z]=(0,d.useState)(!1),[B,ee]=(0,d.useState)(null),[V,te]=(0,d.useState)(null),[ne,re]=(0,d.useState)(n??null),[ie,ae]=(0,d.useState)(null),oe=(0,d.useRef)(null),se=(0,d.useRef)(null),H=NV(e,t,`doc`),U=H.mode===`pair`?H.agent:null,W=BW((0,d.useMemo)(()=>ha(e.url),[e.url])),G=e.title||i?.doc.title||W?.name||`Google Doc`,ce=u&&u.from===e.docDraft?u.draft:e.docDraft,le=(0,d.useCallback)(async()=>{try{let n=await kG.googleDoc(e.id,t);return a(n),s(null),!0}catch(e){let t=e;return s({message:t.message,code:t.code}),!1}},[e.id,t]);(0,d.useEffect)(()=>{le()},[le]);let ue=e.docDraft?.revision;(0,d.useEffect)(()=>{i&&ue&&ue!==i.doc.revision&&le()},[ue,i,le]),(0,d.useEffect)(()=>{if(!c)return;let e=AW(e=>{e.id===`google`&&(e.ok?le().then(e=>e&&l(null)):(l(null),v(e.message??`The sign-in failed.`)))}),t=setInterval(()=>void le().then(e=>e&&l(null)),2500);return()=>{e(),clearInterval(t)}},[c,le]),(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||RV()||(P?F(null):ne?re(null):C||r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,C,P,ne]),(0,d.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>v(null),6e3);return()=>clearTimeout(e)},[_]);let de=(0,d.useMemo)(()=>i?zG(i.doc.paragraphs,ce):[],[i,ce]),fe=(0,d.useMemo)(()=>VG(de),[de]),pe=M.pins.get(e.id),me=(0,d.useMemo)(()=>{let e=(pe??[]).filter(e=>e.anchor.kind===`doc`&&e.discussion);return ie&&!e.some(e=>e.id===ie.id)?[...e,ie]:e},[pe,ie]);(0,d.useEffect)(()=>{ie&&pe?.some(e=>e.id===ie.id)&&ae(null)},[pe,ie]);let{byRow:he,gone:ge}=(0,d.useMemo)(()=>{let e=new Map,t=[];if(!i)return{byRow:e,gone:t};let n=new Set(de.map(e=>e.id));for(let r of me){let a=r.anchor;a.gone||a.revision===i.doc.revision&&!n.has(a.paragraph)?r.discussion?.resolved&&r.id!==ne||t.push(r):a.revision===i.doc.revision&&e.set(a.paragraph,[...e.get(a.paragraph)??[],r])}return{byRow:e,gone:t}},[me,de,i,ne]),_e=e=>{re(t=>t===e?null:e),N(e)},ve=e=>{re(e.id),N(e.id),requestAnimationFrame(()=>{let t=oe.current?.querySelector(`[data-doc-chip="${CSS.escape(e.id)}"]`);(t?.closest(`.doc-row, .doc-gone`)??t)?.scrollIntoView({block:`center`,behavior:`smooth`})})},ye=e=>t=>(0,Q.jsx)(EV,{pin:e,fallback:t}),be=(0,d.useRef)(!1);(0,d.useEffect)(()=>{n&&(re(n),be.current=!1)},[n]),(0,d.useEffect)(()=>{if(!n||be.current||!i)return;let e=oe.current?.querySelector(`[data-doc-chip="${CSS.escape(n)}"]`);e&&(be.current=!0,(e.closest(`.doc-row, .doc-gone`)??e).scrollIntoView({block:`start`}),N(n))}),(0,d.useEffect)(()=>{if(!i)return;let e=e=>{let t=se.current;se.current=null,t&&e.button===0&&setTimeout(()=>{let e=t.dataset.paragraph,{selectionStart:n,selectionEnd:r,value:a}=t,o=e&&r>n?Uo(a,n,r):null;o&&(F({paragraph:e,revision:i.doc.revision,...o}),ee(null))},0)};return document.addEventListener(`mouseup`,e),()=>document.removeEventListener(`mouseup`,e)},[i]),(0,d.useLayoutEffect)(()=>{if(!P)return te(null);let e=oe.current,t=[...(e?.querySelector(`[data-row="${CSS.escape(P.paragraph)}"]`))?.querySelectorAll(`[data-pin-draft]`)??[]].flatMap(e=>[...e.getClientRects()]);if(!e||t.length===0)return;let n=e.getBoundingClientRect(),r=Math.min(380,n.width-24),i=Math.max(12,Math.min(t[0].left-n.left-12,n.width-r-12)),a=t.at(-1).bottom-n.top+8,o=a+rK>n.height&&t[0].top-n.top>rK;te({left:i,width:r,above:o,top:o?t[0].top-n.top-8:a})},[P,de,p]),(0,d.useEffect)(()=>{V&&oe.current?.querySelector(`.doc-ask`)?.scrollIntoView({block:`nearest`})},[V]);let K=(0,d.useCallback)(()=>F(null),[]),xe=(e,t)=>{let n=[];for(let r of he.get(e.id)??[]){if(r.discussion?.resolved&&r.id!==ne)continue;let e=Ho(t,r.quote,r.anchor);e&&n.push({id:r.id,...e})}let r=P?.paragraph===e.id?Ho(t,P.quote,P):null;return r&&n.push({id:zB,...r}),n},Se=(0,d.useMemo)(()=>BG(ce),[ce]),Ce=ce?.edits.length??0,we=ce?.conflicts??[];(0,d.useLayoutEffect)(()=>{let e=O.current,t=e&&D.current.get(e.id);if(!e||!t)return;O.current=null,t.focus();let n=e.at===`start`?0:t.value.length;t.setSelectionRange(n,n)});let Te=(0,d.useCallback)(n=>{if(!i)return Promise.resolve(void 0);let r=A.current.then(async()=>{let r=e.docDraft;try{let a=await kG.editDocDraft(e.id,t,i.doc.revision,n);return f({draft:a.draft,from:r}),S(null),a}catch(e){let t=e;v(t.message),t.status===409&&le();return}});return A.current=r,r},[i,e.id,e.docDraft,t,le]),Ee=(0,d.useCallback)(e=>{clearTimeout(k.current.get(e)),k.current.delete(e);let t=j.current.get(e);return t===void 0?Promise.resolve():Te([{kind:`text`,id:e,text:t}]).then(n=>{n&&m(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})},[Te]),De=()=>Promise.all([...j.current.keys()].map(e=>Ee(e))),Oe=(e,t)=>{P?.paragraph===e&&!I.trim()&&F(null),m(n=>new Map(n).set(e,t)),clearTimeout(k.current.get(e)),k.current.set(e,setTimeout(()=>void Ee(e),nK))};(0,d.useEffect)(()=>()=>k.current.forEach(e=>clearTimeout(e)),[]);let ke=(e,t)=>n=>{let r=n.currentTarget;if(n.key===`Enter`&&!n.shiftKey&&!n.nativeEvent.isComposing){n.preventDefault();let t=r.value,i=r.selectionStart??t.length,a=t.slice(0,i),o=t.slice(r.selectionEnd??i);clearTimeout(k.current.get(e.id)),k.current.delete(e.id),m(t=>{let n=new Map(t);return n.delete(e.id),n});let s=[];(a!==e.text||j.current.has(e.id))&&s.push({kind:`text`,id:e.id,text:a}),s.push({kind:`add`,after:e.id,text:o,list:e.list?e.list.ordered?`numbered`:`bullet`:null}),Te(s).then(e=>{let t=e?.added[0];t&&(O.current={id:t,at:`start`})})}else if(n.key===`Backspace`&&r.value===``&&r.selectionStart===0){n.preventDefault();let r=de.slice(0,t).findLast(e=>e.state!==`removed`&&!e.locked);r&&(O.current={id:r.id,at:`end`}),Te([{kind:`delete`,id:e.id}])}},Ae=async()=>{let e=window.open(``,`_blank`);v(null),l({});try{let{url:t}=await X.startConnector(`google`);e&&(e.location.href=t),l({url:t,blocked:!e})}catch(t){e?.close(),l(null),v(t.message)}},je=async()=>{let t=ha(e.url)?.fileId;v(null),b(!0);try{let e=await IG({fileIds:t?[t]:void 0,title:`Choose "${G}"`});e.length&&t&&!e.some(e=>e.id===t)?v(`That's another doc. Choose "${G}" to open it here.`):e.length&&await le()}catch(e){v(e.message)}finally{b(!1)}},Me=async()=>{g(`save`),v(null);try{await De(),await A.current;let n=await kG.saveDocDraft(e.id,t);if(n.outcome===`saved`){S({paragraphs:n.paragraphs,at:new Date().toISOString()}),f({draft:void 0,from:e.docDraft});try{localStorage.setItem(tK,`1`)}catch{}E(!0),await le()}else f({draft:n.draft,from:e.docDraft}),await le()}catch(e){v(e.message)}finally{g(null)}},Ne=async()=>{g(`discard`);try{await kG.discardDocDraft(e.id,t),f({draft:void 0,from:e.docDraft}),m(new Map),w(!1),await le()}catch(e){v(e.message)}finally{g(null)}},Pe=async n=>{if(P&&I.trim()&&!R){z(!0),ee(null);try{await Ee(P.paragraph),await A.current;let{pin:r}=await kG.pinDocWords(e.id,t,{...P,body:n?H.address(I):I,ask:n});ae(r),re(r.id),F(null),L(``)}catch(e){ee(e.message)}finally{z(!1)}}},Fe=async(n,r)=>{try{let{draft:i}=await kG.resolveDocConflict(e.id,t,n.id,r);f({draft:i??void 0,from:e.docDraft})}catch(e){v(e.message)}},Ie=(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:e.url,target:`_blank`,rel:`noreferrer`,children:[`Open in Google`,(0,Q.jsx)($,{name:`external`})]}),Le;Le=o&&!i?(0,Q.jsx)(pK,{problem:o,title:G,waiting:c,choosing:y,error:_,onAllow:Ae,onChoose:()=>void je(),onCancelWait:()=>l(null),onRetry:le,openInGoogle:Ie}):i?we.length?(0,Q.jsx)(fK,{conflicts:we,draft:ce,me:t,onResolve:Fe}):(0,Q.jsxs)(`div`,{className:`doc-page`,ref:oe,children:[de.map((n,r)=>{let i=p.get(n.id)??n.text,a=he.get(n.id)??[],o=a.find(e=>e.id===ne);return(0,Q.jsx)(dK,{row:n,number:fe.get(n.id),me:t,text:i,marks:xe(n,i),focus:ne,chips:a.map(e=>(0,Q.jsx)($G,{pin:e,open:e.id===ne,lost:n.state===`removed`?`paragraph removed`:void 0,onToggle:()=>_e(e.id)},e.id)),after:o&&(0,Q.jsx)(uV,{inline:!0,pin:o,block:e,name:t,onClose:()=>re(null),live:ye(o),address:H.address},o.id),onPress:e=>{e.button===0&&(se.current=e.currentTarget)},onType:e=>Oe(n.id,e),onBlur:()=>void Ee(n.id),onKeyDown:ke(n,r),inputRef:e=>e?D.current.set(n.id,e):D.current.delete(n.id),onRemove:()=>void Te([{kind:`delete`,id:n.id}]),onRestore:()=>{m(e=>{let t=new Map(e);return t.delete(n.id),t}),Te([{kind:`restore`,id:n.id}])},onFormat:(e,t)=>void Te([{kind:`format`,id:n.id,style:e,list:t}])},n.id)}),ge.length>0&&(0,Q.jsxs)(`div`,{className:`doc-gone`,children:[(0,Q.jsxs)(`div`,{className:`doc-gone-chips`,children:[(0,Q.jsx)(`span`,{className:`faint small`,children:`No longer in the doc`}),ge.map(e=>(0,Q.jsx)($G,{pin:e,open:e.id===ne,part:`“${e.quote.length>40?`${e.quote.slice(0,39)}…`:e.quote}”`,lost:`paragraph removed`,onToggle:()=>_e(e.id)},e.id))]}),ge.some(e=>e.id===ne)&&(0,Q.jsx)(uV,{inline:!0,pin:ge.find(e=>e.id===ne),block:e,name:t,onClose:()=>re(null),live:ye(ge.find(e=>e.id===ne)),address:H.address},ne)]}),(0,Q.jsxs)(`button`,{className:`doc-add`,onClick:()=>{let e=de.findLast(e=>e.state!==`removed`);Te([{kind:`add`,after:e?.id??``,text:``}]).then(e=>{e?.added[0]&&(O.current={id:e.added[0],at:`start`})})},children:[(0,Q.jsx)($,{name:`plus`}),` Add a paragraph`]}),P&&V&&(0,Q.jsx)(QG,{words:P,style:{left:V.left,top:V.top,width:V.width},above:V.above,text:I,busy:R,error:B,agent:U,onText:e=>{L(e),ee(null)},onSubmit:e=>void Pe(e),onClose:K},`${P.paragraph}:${P.quote}`)]}):(0,Q.jsxs)(`div`,{className:`doc-editor-state`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Opening from Google…`]});let Re=H.agents.find(e=>e.name===H.agent);return(0,Q.jsx)(VV,{pairing:H,className:`doc-editor`,label:`Edit ${G}`,icon:(0,Q.jsx)(YG,{mark:`google-docs`}),title:G,from:`Google Doc · ${i?ce?`draft in Tricot, from the version of ${ex(i.doc.pulledAt)}`:`as Google has it, ${ex(i.doc.pulledAt)}`:`in Tricot`}`,browse:{label:`Read`,hint:`Read and edit the draft on your own; select words to ask agents or comment`},pairHint:`Select words to ask the agent to change them in the draft, or to comment.`,pairBand:H.agent?`Pairing with ${H.agent}: select words to ask ${H.agent} to change them; ${H.agent} edits the draft and replies on the pin. ${BV(Re,H.agent)}`:`Select words to ask an agent to change them, or to comment.`,controls:Ie,open:ne,onOpenRequest:ve,onClose:r,foot:(0,Q.jsxs)(Q.Fragment,{children:[i&&!we.length&&(0,Q.jsxs)(`footer`,{className:`doc-editor-foot`,children:[Ce>0&&!T&&(0,Q.jsxs)(`p`,{className:`doc-note`,children:[(0,Q.jsx)(`strong`,{children:`Saving changes only the paragraphs marked here.`}),` Inside a changed paragraph, formatting can simplify: new words take the style around them, and a link or chip in the changed part goes. Tables, images and comments elsewhere stay as they are.`]}),_&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:_}),(0,Q.jsx)(`div`,{className:`doc-editor-actions`,children:C?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`small`,children:[`Discard `,aK(Ce,`change`),`? Google's doc stays as it is.`]}),(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:h!==null,onClick:Ne,children:`Discard`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>w(!1),children:`Keep editing`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`faint small doc-editor-hint`,children:`Enter adds a paragraph · Shift+Enter breaks a line`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:!Ce||h!==null,onClick:()=>w(!0),children:`Discard draft`}),(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:!Ce||h!==null,onClick:Me,children:h===`save`?`Saving to Google…`:Ce?`Save to Google · ${aK(Ce,`paragraph`)} changed`:`Nothing to save yet`})]})})]}),i&&we.length>0&&_&&(0,Q.jsx)(`footer`,{className:`doc-editor-foot`,children:(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:_})})]}),band:i&&(Se.length>0||x||ce?.rebased)&&(0,Q.jsx)(`div`,{className:`doc-editor-band`,children:x&&!Ce?(0,Q.jsxs)(`span`,{className:`doc-saved`,role:`status`,children:[(0,Q.jsx)($,{name:`check`}),` Saved `,aK(x.paragraphs,`paragraph`),` to Google · `,ex(x.at),`. The rest of the doc is as it was.`]}):(0,Q.jsxs)(Q.Fragment,{children:[Se.length>0&&(0,Q.jsxs)(`span`,{className:`doc-authors`,children:[(0,Q.jsx)(`span`,{className:`faint`,children:`Changes in this draft`}),Se.map(e=>(0,Q.jsxs)(`span`,{className:`doc-author`,children:[(0,Q.jsx)(sK,{actor:e.by,me:t}),(0,Q.jsx)(`span`,{className:`doc-author-count`,children:e.count})]},`${e.by.kind}:${e.by.name}`))]}),ce?.rebased&&!we.length&&(0,Q.jsxs)(`span`,{className:`doc-rebased`,children:[`Moved onto the latest version from Google`,ce.rebased.theirs?` (${aK(ce.rebased.theirs,`paragraph`)} changed there)`:``,`. Check it, then save again.`]})]})}),children:(0,Q.jsx)(`div`,{className:`doc-editor-body`,children:Le})})}var lK={TITLE:`is-title`,SUBTITLE:`is-subtitle`,HEADING_1:`is-h1`,HEADING_2:`is-h2`,HEADING_3:`is-h3`,HEADING_4:`is-h4`,HEADING_5:`is-h4`,HEADING_6:`is-h4`},uK=[{value:`text`,label:`Text`,style:`NORMAL_TEXT`,list:null},{value:`h1`,label:`Heading 1`,style:`HEADING_1`,list:null},{value:`h2`,label:`Heading 2`,style:`HEADING_2`,list:null},{value:`h3`,label:`Heading 3`,style:`HEADING_3`,list:null},{value:`bullet`,label:`Bulleted`,style:`NORMAL_TEXT`,list:`bullet`},{value:`numbered`,label:`Numbered`,style:`NORMAL_TEXT`,list:`numbered`}];function dK(e){let{row:t,number:n,me:r,text:i,marks:a,chips:o}=e,s=lK[t.style]??``;if(t.locked)return(0,Q.jsx)(`div`,{className:`doc-row is-locked`,children:(0,Q.jsxs)(`div`,{className:`doc-locked`,children:[(0,Q.jsxs)(`span`,{className:`doc-locked-label`,children:[t.locked,`: edit in Google`]}),(t.detail||t.text)&&(0,Q.jsx)(`span`,{className:`faint small doc-locked-detail`,children:[t.detail,t.text].filter(Boolean).join(` · `)})]})});let c=t.list?t.list.ordered?`${n??1}.`:`•`:null,l=t.list?.level??0,u=t.state===`changed`||t.state===`same`&&i!==t.text,d=t.state===`same`&&u?`changed`:t.state,f=uK.find(e=>e.style===t.style&&(e.list??void 0)===(t.list?t.list.ordered?`numbered`:`bullet`:void 0));return(0,Q.jsxs)(`div`,{className:`doc-row is-${d}`,"data-row":t.id,children:[(0,Q.jsxs)(`div`,{className:`doc-text`,style:{paddingLeft:t.list?22+l*22:0},children:[c&&(0,Q.jsx)(`span`,{className:`doc-list-mark`,style:{left:l*22},children:c}),t.state===`removed`?(0,Q.jsx)(`p`,{className:`doc-removed ${s}`,children:t.was||` `}):(0,Q.jsxs)(`div`,{className:`doc-field`,children:[a.length>0&&(0,Q.jsx)(`div`,{className:`doc-input doc-marks ${s}`,"aria-hidden":!0,children:(0,Q.jsx)(GB,{text:i,marks:a,focus:e.focus})}),(0,Q.jsx)(oK,{className:`doc-input ${s}`,value:i,paragraph:t.id,label:`${RG[t.style]??`Paragraph`} ${t.id}`,onChange:e.onType,onBlur:e.onBlur,onKeyDown:e.onKeyDown,onMouseDown:e.onPress,inputRef:e.inputRef})]}),t.state===`changed`&&t.was!==void 0&&(0,Q.jsxs)(`p`,{className:`doc-was`,title:`As the doc has it in Google`,children:[(0,Q.jsx)(`span`,{className:`doc-was-label`,children:`In Google:`}),` `,t.was||`(empty)`]})]}),(0,Q.jsxs)(`div`,{className:`doc-meta`,children:[o,d!==`same`&&(0,Q.jsx)(`span`,{className:`doc-state is-${d}`,children:d===`changed`?`Edited`:d===`added`?`New`:`Removed`}),t.by&&(0,Q.jsx)(sK,{actor:t.by,me:r}),t.state===`added`&&(0,Q.jsx)(`select`,{className:`doc-style`,value:f?.value??`text`,onChange:t=>{let n=uK.find(e=>e.value===t.target.value);e.onFormat(n.style,n.list)},"aria-label":`Paragraph style`,children:uK.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsxs)(`span`,{className:`doc-actions`,children:[(t.state===`changed`||t.state===`removed`)&&(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:e.onRestore,title:`Back to how the doc has it`,children:t.state===`removed`?`Restore`:`Undo`}),t.state!==`removed`&&(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet doc-remove`,onClick:e.onRemove,title:`Remove this paragraph`,"aria-label":`Remove this paragraph`,children:(0,Q.jsx)($,{name:`x`})})]})]}),e.after&&(0,Q.jsx)(`div`,{className:`doc-row-after`,children:e.after})]})}function fK(e){let{conflicts:t,draft:n,me:r,onResolve:i}=e,a=n.edits.length;return(0,Q.jsxs)(`div`,{className:`doc-conflicts`,children:[(0,Q.jsxs)(`div`,{className:`doc-conflict-intro`,role:`status`,children:[(0,Q.jsx)(`h3`,{children:`Someone edited this doc in Google since the draft began`}),(0,Q.jsxs)(`p`,{children:[`Nothing was saved, and nothing was overwritten. `,t.length===1?`One paragraph was`:`${t.length} paragraphs were`,` changed on both sides: choose which version to keep`,t.length===1?``:` for each`,`. `,a>0&&`The draft's ${aK(a,`other change`)} carried over onto the latest version.`]})]}),t.map(e=>(0,Q.jsxs)(`article`,{className:`doc-conflict`,children:[(0,Q.jsxs)(`p`,{className:`faint small doc-conflict-was`,children:[`Was: `,(0,Q.jsx)(`span`,{children:e.was||`(empty)`})]}),(0,Q.jsxs)(`div`,{className:`doc-conflict-sides`,children:[(0,Q.jsxs)(`div`,{className:`doc-side is-theirs`,children:[(0,Q.jsx)(`span`,{className:`doc-side-label`,children:`In Google now`}),(0,Q.jsx)(`p`,{className:e.theirs===void 0?`is-gone`:void 0,children:e.theirs??`Removed in Google`}),(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i(e,`theirs`),children:`Take theirs`})]}),(0,Q.jsxs)(`div`,{className:`doc-side is-mine`,children:[(0,Q.jsxs)(`span`,{className:`doc-side-label`,children:[`Your draft · `,(0,Q.jsx)(sK,{actor:e.by,me:r})]}),(0,Q.jsx)(`p`,{className:e.mine===void 0?`is-gone`:void 0,children:e.mine??`Removed in the draft`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-primary`,onClick:()=>i(e,`mine`),children:`Keep mine`})]})]})]},e.id))]})}function pK(e){let{problem:t,title:n,waiting:r,choosing:i,error:a,onAllow:o,onChoose:s,onCancelWait:c,onRetry:l,openInGoogle:u}=e,d=t.code?{no_docs_permission:{heading:`Connect Google again`,action:`Connect Google again`},not_connected:{heading:`Connect Google to edit this doc`,action:`Connect Google`},needs_sign_in:{heading:`Sign in to Google again`,action:`Sign in again`}}[t.code]:void 0,f=t.code===`not_picked`;return(0,Q.jsxs)(`div`,{className:`doc-access`,children:[(0,Q.jsx)(`span`,{className:`doc-access-mark`,"aria-hidden":!0,children:(0,Q.jsx)($,{name:d||f?`edit`:`x`})}),(0,Q.jsx)(`h3`,{children:f?`Choose this doc in Google once`:d?.heading??(t.code===`not_set_up`?`Set up Google first`:`Can't open this doc`)}),f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Choose `,(0,Q.jsx)(`strong`,{children:n}),` in Google once to let Tricot open it.`]}),(0,Q.jsxs)(`ul`,{className:`doc-access-points`,children:[(0,Q.jsx)(`li`,{children:`Tricot can open only the Google Docs you choose, never the rest of your Drive.`}),(0,Q.jsx)(`li`,{children:`Tricot changes a doc only when someone presses Save, and only the paragraphs edited here.`}),(0,Q.jsx)(`li`,{children:`Agents can read a doc and suggest edits in the draft. They can't save.`})]})]}):(0,Q.jsx)(`p`,{children:t.message}),r?(0,Q.jsxs)(`div`,{className:`row doc-access-actions`,children:[(0,Q.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),r.blocked?`The browser didn't open a new tab. Open Google to sign in, then come back here.`:`Finish on the Google tab…`]}),r.url&&(0,Q.jsxs)(`a`,{className:`btn btn-small${r.blocked?` btn-primary`:``}`,href:r.url,target:`_blank`,rel:`noreferrer`,children:[r.blocked?`Open Google`:`Open it again`,` `,(0,Q.jsx)($,{name:`external`})]}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:c,children:`Cancel`})]}):(0,Q.jsxs)(`div`,{className:`row doc-access-actions`,children:[f&&(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:i,onClick:s,children:i?`Choosing…`:`Choose in Google`}),d&&(0,Q.jsx)(`button`,{className:`btn btn-primary`,onClick:o,children:d.action}),t.code===`not_set_up`&&(0,Q.jsx)(`a`,{className:`btn btn-primary`,href:dS.connectors(),children:`Go to Connectors`}),!d&&!f&&t.code!==`not_set_up`&&(0,Q.jsx)(`button`,{className:`btn`,onClick:l,children:`Try again`}),!d&&!f&&u]}),a&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:a})]})}var mK=[[`#0f9d58`,`M7.25 3.215a789.828 789.861 0 0 0-3.63 6.319L0 15.868l1.89 3.298 1.885 3.297 3.62-6.335 3.618-6.33-1.88-3.287C8.1 4.704 7.255 3.22 7.25 3.214z`],[`#f4b400`,`M12.01 1.485c-2.082 0-3.754.02-3.743.047.01.02 1.708 3.001 3.774 6.62l3.76 6.574h3.76c2.081 0 3.753-.02 3.742-.047-.005-.02-1.708-3.001-3.775-6.62l-3.76-6.574z`],[`#4285f4`,`M9.509 15.868l-.203.348c-.114.198-.96 1.672-1.88 3.287a423.93 423.948 0 0 1-1.698 2.97c-.01.026 3.24.042 7.222.042h7.244l1.796-3.157c.992-1.734 1.85-3.23 1.906-3.323l.104-.167h-7.249z`]],hK={"google-docs":{tile:`#1a73e8`,glyph:(0,Q.jsx)(`path`,{d:`M10.5 11h11M10.5 15h11M10.5 19h11M10.5 23h6.5`,...eG,strokeWidth:2})},"google-sheets":{tile:`#188038`,glyph:(0,Q.jsx)(`path`,{d:`M9.5 9.5h13v13h-13ZM9.5 14h13M9.5 18.25h13M14.25 9.5v13`,...eG})},"google-slides":{tile:`#f4b400`,glyph:(0,Q.jsx)(`rect`,{x:`9`,y:`11`,width:`14`,height:`10`,rx:`1.5`,fill:`#fff`})},"google-forms":{tile:`#7248b9`,glyph:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M14.5 11h7.5M14.5 16h7.5M14.5 21h7.5`,...eG,strokeWidth:2}),(0,Q.jsx)(`circle`,{cx:`10.5`,cy:`11`,r:`1.5`,fill:`#fff`}),(0,Q.jsx)(`circle`,{cx:`10.5`,cy:`16`,r:`1.5`,fill:`#fff`}),(0,Q.jsx)(`circle`,{cx:`10.5`,cy:`21`,r:`1.5`,fill:`#fff`})]})},"google-drive":{tile:`var(--mark-tile)`,glyph:(0,Q.jsx)(`g`,{transform:`translate(7 7) scale(0.75)`,children:mK.map(([e,t])=>(0,Q.jsx)(`path`,{d:t,fill:e},e))})},google:{tile:`var(--mark-tile)`,glyph:(0,Q.jsxs)(`g`,{fill:`none`,strokeWidth:`3`,children:[(0,Q.jsx)(`path`,{d:`M23 16a7 7 0 0 1-2.5 5.36`,stroke:`#4285f4`}),(0,Q.jsx)(`path`,{d:`M16.5 16H23`,stroke:`#4285f4`}),(0,Q.jsx)(`path`,{d:`M20.5 21.36A7 7 0 0 1 10.64 20.5`,stroke:`#34a853`}),(0,Q.jsx)(`path`,{d:`M10.64 20.5a7 7 0 0 1 0-9`,stroke:`#fbbc05`}),(0,Q.jsx)(`path`,{d:`M10.64 11.5a7 7 0 0 1 10.72 0`,stroke:`#ea4335`})]})}};function gK(){let{tile:e,glyph:t}=hK.google;return(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var _K={id:`google`,Mark:gK,serves:`Google Docs you choose`,setup:{intro:`Tricot signs in with an OAuth client from your own Google Cloud project, so your sign-in stays between you and Google.`,files:[`client_secret_….json`,`google-client.json`]},signOutHint:`you can remove it in your Google account, under third-party connections.`,Panel:LG,chooser:{label:`Choose a Google Doc`,async choose(){let[e]=await IG({title:`Choose a Google Doc to link`});return e?{url:e.url}:null}},accessNote:({access:e})=>{let t=t=>e.find(e=>e.scope===t)?.granted;return t(`https://www.googleapis.com/auth/drive.file`)===!1?t(`https://www.googleapis.com/auth/documents`)||t(`https://www.googleapis.com/auth/drive.metadata.readonly`)?`This sign-in is the earlier kind: it sees the names of all your Drive files and can edit any of your Google Docs. Connect again to switch to only the docs you choose.`:`It can't open any Google Docs yet. Connect again and allow the docs you choose.`:`It opens only the Google Docs you choose, and changes one only when someone presses Save: just the paragraphs edited. The rest of your Drive stays out of sight.`},fileInfo:async e=>(await kG.driveFile(e)).file,marks:hK,editor:{title:`Edit this doc's text here, then save the changes to Google`,Editor:cK,Threads:eK,draft(e){let{docDraft:t}=e;if(!t)return null;let n=t.edits.length;return t.conflicts?.length?`draft waiting on a choice`:`draft, ${n} change${n===1?``:`s`}`},opensPin:e=>e.anchor.kind===`doc`}};function vK(e,t,n){let r=(32-n)/2;return(0,Q.jsx)(`path`,{d:e,fill:t,transform:`translate(${r} ${r}) scale(${n/24})`})}var yK=`var(--mark-tile)`,bK={tile:yK,glyph:vK(`m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z`,`#fc6d26`,18)},xK={tile:yK,glyph:vK(`M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z`,`#000`,18)},SK={tile:`#5e6ad2`,glyph:vK(`M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z`,`#fff`,16)},CK={tile:`#4a154b`,dark:!0,glyph:(0,Q.jsx)(`path`,{d:`M13.5 9v14M18.5 9v14M9 13.5h14M9 18.5h14`,...eG,strokeWidth:2.25})},wK={tile:`#0052cc`,glyph:vK(`M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.005-1.005zm5.723-5.756H5.736a5.215 5.215 0 0 0 5.215 5.214h2.129v2.058a5.218 5.218 0 0 0 5.215 5.214V6.758a1.001 1.001 0 0 0-1.001-1.001zM23.013 0H11.455a5.215 5.215 0 0 0 5.215 5.215h2.129v2.057A5.215 5.215 0 0 0 24 12.483V1.005A1.001 1.001 0 0 0 23.013 0Z`,`#fff`,16)},TK={tile:`#172b4d`,dark:!0,glyph:vK(`M.87 18.257c-.248.382-.53.875-.763 1.245a.764.764 0 0 0 .255 1.04l4.965 3.054a.764.764 0 0 0 1.058-.26c.199-.332.454-.763.733-1.221 1.967-3.247 3.945-2.853 7.508-1.146l4.957 2.337a.764.764 0 0 0 1.028-.382l2.364-5.346a.764.764 0 0 0-.382-1 599.851 599.851 0 0 1-4.965-2.361C10.911 10.97 5.224 11.185.87 18.257zM23.131 5.743c.249-.405.531-.875.764-1.25a.764.764 0 0 0-.256-1.034L18.675.404a.764.764 0 0 0-1.058.26c-.195.335-.451.763-.734 1.225-1.966 3.246-3.945 2.85-7.508 1.146L4.437.694a.764.764 0 0 0-1.027.382L1.046 6.422a.764.764 0 0 0 .382 1c1.039.49 3.105 1.467 4.965 2.361 6.698 3.246 12.392 3.029 16.738-4.04z`,`#fff`,16)},EK={tile:`#000`,dark:!0,glyph:vK(`m12 1.608 12 20.784H0Z`,`#fff`,15)},DK={tile:`#cb3837`,glyph:vK(`M5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z`,`#fff`,28)},OK={tile:yK,glyph:vK(`M15.725 0l-1.72 1.277 6.39 8.588 1.716-1.277L15.725 0zm-3.94 3.418l-1.369 1.644 8.225 6.85 1.369-1.644-8.225-6.85zm-3.15 4.465l-.905 1.94 9.702 4.517.904-1.94-9.701-4.517zm-1.85 4.86l-.44 2.093 10.473 2.201.44-2.092-10.473-2.203zM1.89 15.47V24h19.19v-8.53h-2.133v6.397H4.021v-6.396H1.89zm4.265 2.133v2.13h10.66v-2.13H6.154Z`,`#f58025`,18)},kK={tile:`#000`,dark:!0,glyph:vK(`m21.538 1.1-6.745 21.8h-2.77L18.77 1.1ZM24 1.1v21.8h-2.462V1.1Zm-12 0v21.8H9.538V1.1Zm-2.462 0L2.77 22.9H0L6.746 1.1Z`,`#fff`,16)},AK={tile:yK,glyph:vK(`M12.09 13.119c-.936 1.932-2.217 4.548-2.853 5.728-.616 1.074-1.127.931-1.532.029-1.406-3.321-4.293-9.144-5.651-12.409-.251-.601-.441-.987-.619-1.139-.181-.15-.554-.24-1.122-.271C.103 5.033 0 4.982 0 4.898v-.455l.052-.045c.924-.005 5.401 0 5.401 0l.051.045v.434c0 .119-.075.176-.225.176l-.564.031c-.485.029-.727.164-.727.436 0 .135.053.33.166.601 1.082 2.646 4.818 10.521 4.818 10.521l.136.046 2.411-4.81-.482-1.067-1.658-3.264s-.318-.654-.428-.872c-.728-1.443-.712-1.518-1.447-1.617-.207-.023-.313-.05-.313-.149v-.468l.06-.045h4.292l.113.037v.451c0 .105-.076.15-.227.15l-.308.047c-.792.061-.661.381-.136 1.422l1.582 3.252 1.758-3.504c.293-.64.233-.801.111-.947-.07-.084-.305-.22-.812-.24l-.201-.021c-.052 0-.098-.015-.145-.051-.045-.031-.067-.076-.067-.129v-.427l.061-.045c1.247-.008 4.043 0 4.043 0l.059.045v.436c0 .121-.059.178-.193.178-.646.03-.782.095-1.023.439-.12.186-.375.589-.646 1.039l-2.301 4.273-.065.135 2.792 5.712.17.048 4.396-10.438c.154-.422.129-.722-.064-.895-.197-.172-.346-.273-.857-.295l-.42-.016c-.061 0-.105-.014-.152-.045-.043-.029-.072-.075-.072-.119v-.436l.059-.045h4.961l.041.045v.437c0 .119-.074.18-.209.18-.648.03-1.127.18-1.443.421-.314.255-.557.616-.736 1.067 0 0-4.043 9.258-5.426 12.339-.525 1.007-1.053.917-1.503-.031-.571-1.171-1.773-3.786-2.646-5.71l.053-.036z`,`#000`,20)},jK={gitlab:bK,notion:xK,linear:SK,slack:CK,jira:wK,confluence:TK,vercel:EK,npm:DK,stackOverflow:OK,mdn:kK,wikipedia:AK},MK={document:hK[`google-docs`],spreadsheets:hK[`google-sheets`],presentation:hK[`google-slides`],forms:hK[`google-forms`],file:hK[`google-drive`]},NK={"github.com":nG.marks.github,"githubusercontent.com":nG.marks.github,"gitlab.com":bK,"figma.com":TW.marks.figma,"google.com":hK.google,"docs.google.com":e=>{let t=e.pathname.split(`/`)[1]??``;return Object.hasOwn(MK,t)?MK[t]:hK.google},"drive.google.com":hK[`google-drive`],"sheets.google.com":hK[`google-sheets`],"slides.google.com":hK[`google-slides`],"forms.google.com":hK[`google-forms`],"forms.gle":hK[`google-forms`],"youtube.com":UG.marks.youtube,"youtu.be":UG.marks.youtube,"youtube-nocookie.com":UG.marks.youtube,"loom.com":HG.marks.loom,"notion.so":xK,"notion.com":xK,"notion.site":xK,"linear.app":SK,"slack.com":CK,"atlassian.net":e=>/^\/wiki(\/|$)/i.test(e.pathname)?TK:wK,"vercel.com":EK,"npmjs.com":DK,"npmjs.org":DK,"stackoverflow.com":OK,"developer.mozilla.org":kK,"wikipedia.org":AK};function PK(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.replace(/\.$/,``).split(`.`);for(let e=0;e<n.length;e++){let r=n.slice(e).join(`.`);if(!Object.hasOwn(NK,r))continue;let i=NK[r];return typeof i==`function`?i(t):i}return null}var FK={useKey:e=>Y(Ni.key)({key:e}),card:(e,t=!1)=>Vl(Ni.issue)({identifier:e},t?{fresh:`1`}:void 0)},IK=6e4,LK=new Map,RK=new Map,zK=new Set,BK=!1,VK=()=>zK.forEach(e=>e());function HK(){LK.clear(),VK()}function UK(e,t=!1){BK||(BK=!0,AW(HK));let n=LK.get(e),r=RK.get(e);if(r)return r;if(!t&&n&&Date.now()-n.at<IK)return Promise.resolve(n.answer);let i=FK.card(e,t).then(t=>(LK.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return RK.set(e,i),VK(),i.finally(()=>{RK.delete(e),VK()}),i}var WK=e=>(zK.add(e),()=>void zK.delete(e));function GK(e){let t=(0,d.useSyncExternalStore)(WK,()=>e?LK.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(WK,()=>e?RK.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;UK(e);let t=()=>void UK(e);return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[e]);let r=(0,d.useCallback)(()=>e?UK(e,!0):Promise.resolve(null),[e]);return{card:t?.card,problem:t?.problem,busy:n,refresh:r}}var KK={needs_sign_in:`Linear needs you to sign in again`,not_found:`Linear can't find this issue`};function qK({card:e}){return(0,Q.jsx)(`span`,{className:`lin-state is-${e.status.kind||`unstarted`}`,children:e.status.name})}function JK({source:e}){let{card:t,problem:n,busy:r,refresh:i}=GK(e.fileId);return!t&&!n?r?(0,Q.jsx)(`p`,{className:`lin-details faint`,children:`Looking it up on Linear…`}):null:n?n.code===`not_connected`?null:(0,Q.jsxs)(`p`,{className:`lin-details lin-problem is-${n.code}`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`lin-problem-text`,title:n.message,children:KK[n.code]??n.message}),n.code===`needs_sign_in`&&(0,Q.jsx)(`a`,{className:`btn btn-small nodrag`,href:dS.connectors(),children:`Sign in again`})]}):t?(0,Q.jsxs)(`div`,{className:`lin-details nodrag`,children:[(0,Q.jsx)(qK,{card:t}),(0,Q.jsx)(`span`,{className:`lin-who`,title:`${t.identifier} in ${t.team}: ${t.assignee?`assigned to ${t.assignee}`:`not assigned`}`,children:t.assignee??`Unassigned`}),t.priority!==`No priority`&&(0,Q.jsx)(`span`,{className:`lin-priority`,children:t.priority}),(0,Q.jsx)(`span`,{className:`lin-spacer`}),(0,Q.jsx)(`span`,{className:`lin-id`,children:t.identifier}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet lin-refresh`,disabled:r,onClick:()=>void i(),title:`Look it up on Linear again`,"aria-label":`Refresh from Linear`,children:(0,Q.jsx)($,{name:`sync`})})]}):null}var YK=`https://linear.app/settings/account/security`;function XK({onChange:e,lead:t}){let[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(null),c=async t=>{t.preventDefault(),a(!0),s(null);try{let{connector:t}=await FK.useKey(n);r(``),HK(),e(t)}catch(e){s(e.message)}finally{a(!1)}};return(0,Q.jsxs)(`form`,{className:`lin-key`,onSubmit:e=>void c(e),children:[(0,Q.jsxs)(`p`,{className:`muted small`,children:[t,` `,(0,Q.jsx)(`a`,{href:YK,target:`_blank`,rel:`noreferrer`,children:`Make a key`})]}),(0,Q.jsxs)(`div`,{className:`lin-key-row`,children:[(0,Q.jsx)(`input`,{type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`lin_api_…`,"aria-label":`Linear API key`,value:n,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:i||!n.trim(),children:i?`Checking…`:`Use this key`})]}),(0,Q.jsx)(`p`,{className:`faint small`,children:`The key stays on this computer and is sent only to Linear.`}),o&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:o})]})}function ZK({status:e,onChange:t}){let n=e.clientSource===`built-in`,[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(r)return AW(e=>{e.id===`linear`&&(e.ok||o(e.message??`The sign-in failed.`),i(null))})},[r]);let s=async()=>{let e=window.open(``,`_blank`);o(null),i({});try{let{url:t}=await X.startConnector(`linear`);e&&(e.location.href=t),i({url:t,blocked:!e})}catch(t){e?.close(),i(null),o(t.message)}},c=e.state===`needs_sign_in`;return(0,Q.jsxs)(`section`,{className:`connector-section lin-signin`,children:[n&&(0,Q.jsx)(`div`,{className:`lin-connect`,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),r.blocked?`The browser didn't open a new tab. Open Linear to sign in, then come back here.`:`Finish signing in on the Linear tab…`]}),r.url&&(0,Q.jsxs)(`a`,{className:`btn btn-small${r.blocked?` btn-primary`:``}`,href:r.url,target:`_blank`,rel:`noreferrer`,children:[r.blocked?`Open Linear`:`Open it again`,(0,Q.jsx)($,{name:`external`})]}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>i(null),children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>void s(),children:c?`Connect again`:`Connect Linear`}),(0,Q.jsx)(`span`,{className:`faint small`,children:`Opens Linear in a new tab. Nothing is saved until you allow it there.`})]})}),a&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:a}),n?(0,Q.jsxs)(`details`,{className:`lin-details-key`,children:[(0,Q.jsx)(`summary`,{children:`Use a personal API key instead`}),(0,Q.jsx)(XK,{onChange:t,lead:`Make a key in Linear, under Settings → Security & access → Personal API keys, with read-only access, and paste it here.`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h3`,{children:c?`Paste a new Linear API key`:`Paste your Linear API key`}),(0,Q.jsx)(XK,{onChange:t,lead:`In Linear, open Settings → Security & access → Personal API keys and make a key with read-only access.`})]})]})}var QK=jK.linear;function $K(){return(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:QK.tile}),QK.glyph]})})}var eq={id:`linear`,Mark:$K,serves:`Linear issues`,setup:{intro:`Linear needs nothing set up: sign in, or paste a personal API key.`,files:[]},signOutHint:`you can remove Tricot under Applications in your Linear account settings, or delete the personal API key under Security & access.`,removedNote:`Disconnected here. A personal API key works until you delete it in Linear, under Security & access in your account settings.`,accessNote:()=>`Read-only: Tricot only reads issues, and never changes anything in Linear. A personal API key reaches what its owner can see; make it read-only in Linear to be sure.`,SignIn:ZK,LinkCard:JK,marks:{linear:QK},fileInfo:async e=>{let t=await UK(e);return t?.card?{name:t.card.title,modifiedTime:t.card.updatedAt}:null}},tq=e=>e===0?`No replies`:e===1?`1 reply`:`${e} replies`,nq={thread:(e,t=!1)=>{let[n,r]=e.split(`/`);return Vl(Vi.thread)({channel:n,ts:r},t?{fresh:`1`}:void 0)}},rq=6e4,iq=new Map,aq=new Map,oq=new Set,sq=()=>oq.forEach(e=>e());function cq(e,t=!1){let n=iq.get(e),r=aq.get(e);if(r)return r;if(!t&&n?.answer.thread&&Date.now()-n.at<rq)return Promise.resolve(n.answer);let i=nq.thread(e,t).then(t=>(iq.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return aq.set(e,i),sq(),i.finally(()=>{aq.delete(e),sq()}),i}function lq(){iq.clear(),sq()}var uq=e=>(oq.add(e),()=>void oq.delete(e));function dq(e){let t=(0,d.useSyncExternalStore)(uq,()=>e?iq.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(uq,()=>e?aq.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;cq(e);let t=()=>void cq(e);window.addEventListener(`focus`,t);let n=AW(t=>{t.id===`slack`&&(lq(),cq(e))});return()=>{window.removeEventListener(`focus`,t),n()}},[e]);let r=(0,d.useCallback)(()=>e?cq(e,!0):Promise.resolve(null),[e]);return{thread:t?.thread,problem:t?.problem,busy:n,refresh:r}}var fq={not_connected:`Connect Slack to see this thread here.`,needs_sign_in:`Slack needs you to sign in again.`,not_found:`Slack can't show this thread to this sign-in.`,missing_scope:`Slack didn't let Tricot read this.`};function pq({source:e}){let t=$z(),{thread:n,problem:r,busy:i,refresh:a}=dq(e.fileId);if(!e.fileId)return null;if(!n&&!r)return(0,Q.jsx)(`p`,{className:`slack-card faint small`,children:i?`Looking it up on Slack…`:``});if(r){let e=r.code===`not_connected`||r.code===`needs_sign_in`;return(0,Q.jsxs)(`p`,{className:`slack-card slack-problem nodrag`,role:`status`,title:r.message,children:[(0,Q.jsx)(`span`,{className:`slack-problem-text`,children:fq[r.code]??r.message}),e&&(0,Q.jsx)(`a`,{className:`btn btn-small btn-primary`,href:dS.connectors(t.board.id),children:r.code===`not_connected`?`Connect Slack`:`Sign in again`})]})}return n?(0,Q.jsxs)(`div`,{className:`slack-card nodrag`,children:[(0,Q.jsxs)(`p`,{className:`slack-head`,children:[(0,Q.jsx)(`strong`,{className:`slack-author`,title:n.author,children:n.author}),(0,Q.jsx)(`span`,{className:`faint`,title:new Date(n.postedAt).toLocaleString(),children:ex(n.postedAt)})]}),(0,Q.jsx)(`p`,{className:`slack-text`,children:n.text||`A message with no text.`}),(0,Q.jsxs)(`p`,{className:`slack-foot`,children:[(0,Q.jsx)(`span`,{className:`slack-replies${n.replies?` has-replies`:``}`,children:tq(n.replies)}),n.latestReplyAt&&n.replies>0&&(0,Q.jsxs)(`span`,{className:`faint`,children:[`last reply `,ex(n.latestReplyAt)]}),(0,Q.jsx)(`span`,{className:`slack-spacer`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet slack-refresh`,disabled:i,onClick:()=>void a(),title:`Look it up on Slack again`,"aria-label":`Refresh from Slack`,children:(0,Q.jsx)($,{name:`sync`})})]})]}):null}function mq(){let{tile:e,glyph:t}=jK.slack;return(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,Q.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var hq={id:`slack`,Mark:mq,serves:`Threads you link`,setup:{intro:`Tricot Studio's Slack app isn't built into this copy of Tricot yet. To use Slack now, make an app of your own, once:`,files:[`slack-client.json`]},signOutHint:`remove Tricot from your workspace's apps in Slack.`,accessNote:()=>`It signs in as you and reads the threads you link. It posts only when you choose to share something, never for an agent: agents can read a linked thread; they can't post to Slack.`,LinkCard:pq,marks:{slack:jK.slack},fileInfo:async e=>{let t=await cq(e);return t?.thread?{name:`Thread by ${t.thread.author}`}:null}},gq=()=>[_K,$W,OG,hq,eq],_q;function vq(){return _q??=gq()}function yq(e){return vq().find(t=>t.id===e)}function bq(e){return e?.connector?yq(e.connector):void 0}var xq={fit:{label:`Fit`,title:`The whole picture (0)`},actual:{label:`Actual size`,title:`Each pixel of the picture on one pixel of the screen, as sharp as it gets (1)`},double:{label:`200%`,title:`Twice the actual size (2)`}},Sq=()=>({actual:1/(window.devicePixelRatio||1),fitMax:1,maxScale:8,pad:24});function Cq(e){let t=Jr(J.asset,{id:e.assetId}),n=e.naturalWidth&&e.naturalHeight?{width:e.naturalWidth,height:e.naturalHeight}:null,[r,i]=(0,d.useState)(null);return{src:t,setLoaded:i,zoom:_U(r?.src===t?r.size:n,(0,d.useMemo)(Sq,[]))}}function wq({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o,picturing:s}){let c=$z(),{src:l,setLoaded:u,zoom:f}=s,{natural:p,view:m,sheet:h,active:g,fit:_,actual:v,pannable:y,percent:b,setHint:x,show:S}=f,C=vU(f),[w,T]=(0,d.useState)(null),E=(0,d.useRef)(null),D=(0,d.useRef)(null),O=wW(c.pins.get(e.id)??[],e.id),k=e.title||e.caption||`Image`,A=e=>{let t=E.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},j=e=>{e.button===0&&(n&&p&&E.current?(e.currentTarget.setPointerCapture(e.pointerId),D.current=A(e),T(oB(D.current,D.current)),x(!1)):C.handlers.onPointerDown(e))},M=e=>{if(D.current)return T(oB(D.current,A(e)));C.handlers.onPointerMove(e)},N=t=>{if(D.current){let n=D.current;if(D.current=null,T(null),!p)return;let r={width:p.width*m.scale,height:p.height*m.scale},i=oB(n,A(t)),o=cB(i,r)?sB(n,p):i;if(o.w<=0||o.h<=0)return;a({blockId:e.id,part:{kind:`box`,...o},quote:`box ${O}`})}else C.handlers.onPointerUp(t)},P=r?.part.kind===`box`?r.part:null,F=[...t.flatMap(({pin:e,place:t})=>t?.kind===`box`?[{key:e.id,box:t,n:t.n,pin:e}]:[]),...w?[{key:`drawing`,box:w,n:O,pin:void 0}]:P?[{key:JV,box:P,n:O,pin:void 0}]:[]],I=n?` is-pointing`:C.dragging?` is-dragging`:y?` is-pannable`:` is-fitted`;return(0,Q.jsxs)(`div`,{className:`image-full`,children:[(0,Q.jsxs)(`div`,{ref:f.stageRef,className:`zoom-stage image-viewer-stage${I}`,tabIndex:0,"aria-label":`${k} at ${b}. ${gU}`,onPointerDown:j,onPointerMove:M,onPointerUp:N,onPointerCancel:e=>{D.current=null,T(null),N(e)},onClickCapture:C.handlers.onClickCapture,onDoubleClick:e=>{if(n)return;let t=e.currentTarget.getBoundingClientRect(),r={x:e.clientX-t.left,y:e.clientY-t.top};g===`fit`?S(_<v-.001?`actual`:`double`,r):S(`fit`)},children:[(0,Q.jsxs)(`div`,{ref:E,className:`zoom-sheet image-viewer-sheet`,style:h??{visibility:`hidden`},children:[(0,Q.jsx)(`img`,{src:l,alt:e.caption??e.title??``,width:p?.width,height:p?.height,draggable:!1,onLoad:e=>{let{naturalWidth:t,naturalHeight:n}=e.currentTarget;t&&n&&u({src:l,size:{width:t,height:n}})}}),F.map(({key:e,box:t,n,pin:r})=>(0,Q.jsx)(`div`,{className:`pin-box image-full-box ${r?`is-linked`:`is-draft`}${r&&r.id===i?` is-open`:``}`,"data-pair-anchor":r?r.id:e===`draft`?JV:void 0,style:{left:`${t.x*100}%`,top:`${t.y*100}%`,width:`${t.w*100}%`,height:`${t.h*100}%`},children:r?(0,Q.jsx)(`button`,{type:`button`,className:`pin-box-n`,onPointerDown:e=>e.stopPropagation(),onClick:()=>o(r.id),"aria-label":`Box ${n}: what was said about it`,title:`Box ${n}: what was said about it`,children:n}):(0,Q.jsx)(`span`,{className:`pin-box-n`,children:n})},e))]}),(0,Q.jsx)(bU,{zoom:f,children:n?`Drag a box round a part, or click a spot · scroll to zoom`:`Scroll or pinch to zoom · drag to pan`})]}),t.length>0&&(0,Q.jsx)(`div`,{className:`image-full-chips`,children:t.map(({pin:e})=>(0,Q.jsx)(RB,{pin:e,open:e.id===i,part:e.quote,onToggle:()=>o(e.id)},e.id))})]})}function Tq({block:e,name:t,version:n,pinId:r,onClose:i}){let a=Cq(n?An(e,n):e),{zoom:o,src:s}=a,c=e.title||e.caption||`Image`,l=n?n.rev:e.versionCount?e.rev:null,u=[`Image`,o.natural&&`${o.natural.width} × ${o.natural.height}`,l!==null&&`v${l}`].filter(Boolean).join(` · `);return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`image`,className:`image-full-view`,label:`${c}, full size`,icon:(0,Q.jsx)($,{name:`image`}),title:c,from:u,browse:{label:`View`,hint:`Zoom and pan on your own`},it:`the image`,point:`drag a box round a part, or click a spot,`,does:`makes a new version of the image`,example:`make the button blue, say`,controls:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yU,{zoom:o,labels:xq}),(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:s,target:`_blank`,rel:`noreferrer`,children:[`Open in a tab`,(0,Q.jsx)($,{name:`external`})]})]}),body:e=>(0,Q.jsx)(wq,{...e,picturing:a}),edit:{hint:`Edit its caption`,doubleClick:!1,label:`Caption`,single:!0,placeholder:`Add a caption`,of:e=>e.caption??``,patch:e=>({caption:e}),preview:(e,t)=>(0,Q.jsxs)(`figure`,{className:`image-edit-figure`,children:[(0,Q.jsx)(`img`,{src:s,alt:e||t.title||``,draggable:!1}),e.trim()&&(0,Q.jsx)(`figcaption`,{children:(0,Q.jsx)($b,{children:e})})]})},onClose:i})}var Eq=8;function Dq(e){let{assetId:t,naturalWidth:n,naturalHeight:r}=e,i=n&&r?{width:n,height:r}:null,[a,o]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(n&&r)return;let e=new Image;return e.onload=()=>e.naturalWidth&&o({assetId:t,size:{width:e.naturalWidth,height:e.naturalHeight}}),e.src=Jr(J.asset,{id:t}),()=>{e.onload=null}},[t,n,r]),i??(a?.assetId===t?a.size:null)}function Oq(e){let{block:t,shown:n,viewing:r}=e,i=$z(),a=Dq(n),o=a&&Hr(a),s=o!==null&&Math.abs(o.w-t.w)<=1&&Math.abs(o.h-t.h)<=1,c=t.origin&&yq(t.origin.connector)?.ImageTools;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>i.openOverlay(t.id,{version:r??void 0}),title:`See the picture at full size, or pair with an agent on it (Enter)`,children:`View`}),(0,Q.jsx)(`button`,{onClick:()=>o&&i.setSize(t.id,o),disabled:!o||s,title:a?s?`The picture already shows at its natural size`:`Size the block to show the picture at its natural size (${a.width} × ${a.height} pixels${Br(a)<a.width?`, shown at half: a 2x screenshot`:``})`:`Reading the picture…`,children:`Natural size`}),c&&(0,Q.jsx)(c,{block:t,viewing:r})]})}function kq({block:e,placed:t}){let n=$z(),r=(0,d.useRef)(null),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),c=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),u=aU(n.draft,e.id,`box`),f=wW(t.map(({pin:e})=>e),e.id);(0,d.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let{naturalWidth:t,naturalHeight:n,clientWidth:r,clientHeight:i,offsetLeft:o,offsetTop:s}=e;if(!t||!n)return a(null);let c=Math.min(r/t,i/n),[l,u]=[t*c,n*c];a({left:o+(r-l)/2,top:s+(i-u)/2,width:l,height:u})};t();let n=new ResizeObserver(t);return n.observe(e),e.addEventListener(`load`,t),()=>{n.disconnect(),e.removeEventListener(`load`,t)}},[e.assetId]);let p=e=>{let t=e.currentTarget.getBoundingClientRect(),n=e=>Math.min(1,Math.max(0,e));return{x:n((e.clientX-t.left)/t.width),y:n((e.clientY-t.top)/t.height)}},m=e=>{let t=c.current??e;return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}},h=[...t.flatMap(({pin:e,place:t})=>t?.kind===`box`?[{key:e.id,box:t,n:t.n,draft:!1}]:[]),...o?[{key:`drawing`,box:o,n:f,draft:!0}]:u?[{key:zB,box:u,n:f,draft:!0}]:[]];return(0,Q.jsxs)(`figure`,{className:`block-image`,children:[(0,Q.jsxs)(`div`,{className:`block-image-stage`,onDoubleClick:()=>n.openOverlay(e.id),children:[(0,Q.jsx)(`img`,{ref:r,src:Jr(J.asset,{id:e.assetId}),alt:e.caption??e.title??``,draggable:!1}),i&&(0,Q.jsx)(`div`,{className:`image-pins nodrag nopan${n.readOnly?``:` is-pinnable`}`,style:i,title:n.readOnly?`Double-click to see it at full size`:`Drag a box around a part to pin it. Double-click to see it at full size`,onPointerDown:e=>{l.current={x:e.clientX,y:e.clientY},n.readOnly||e.button!==0||(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),c.current=p(e),s(m(c.current)))},onPointerMove:e=>c.current&&s(m(p(e))),onPointerUp:t=>{if(!c.current)return;let r=m(p(t)),i=t.currentTarget.getBoundingClientRect();c.current=null,s(null),r.w*i.width<Eq||r.h*i.height<Eq||n.startPin({blockId:e.id,part:{kind:`box`,...r},quote:`box ${f}`})},onPointerCancel:()=>{c.current=null,s(null)},onClick:e=>!iU(e)&&rU(e,l.current)&&e.stopPropagation(),children:h.map(({key:e,box:t,n:r,draft:i})=>(0,Q.jsx)(`div`,{className:`pin-box ${i?`is-draft`:`is-linked`}${e===n.focusPin?` is-focus`:``}`,"data-pin-draft":e===`draft`?``:void 0,style:{left:`${t.x*100}%`,top:`${t.y*100}%`,width:`${t.w*100}%`,height:`${t.h*100}%`},children:(0,Q.jsx)(`span`,{className:`pin-box-n`,children:r})},e))})]}),(0,Q.jsx)(`figcaption`,{children:(0,Q.jsx)(eB,{value:e.caption??``,placeholder:`Add a caption`,display:(0,Q.jsx)($b,{children:e.caption??``}),onCommit:t=>n.updateBlock(e,{caption:t})})})]})}async function Aq(e,t){if(t)return Ur(t);try{let t=await createImageBitmap(e),n=Ur({width:t.width,height:t.height});return t.close(),n}catch{return Ur(null)}}async function jq(e,t,n){for(let[r,i]of e.entries())try{let{assetId:e,size:a}=await X.uploadImage(i),o=n?{x:n.x+r*40,y:n.y+r*40}:void 0;await t.add({type:`image`,assetId:e},{at:o,size:await Aq(i,a)})}catch(e){t.report(e)}}var Mq={type:`image`,copyText:e=>e.caption,Body:kq,Tools:Oq,still:!0,menu:{label:`Image`,icon:`image`,pick:{accept:`image/png,image/jpeg,image/gif,image/webp`}},files:{accepts:e=>e.type.startsWith(`image/`),paste:!0,add:jq},activate:(e,t)=>t.openOverlay(e.id),overlay:{Component:Tq,refocus:!0}};function Nq(){let[e,t]=(0,d.useState)(new Set);return(0,d.useEffect)(()=>{let e=()=>X.connectors().then(e=>t(new Set(e.filter(e=>e.state===`connected`).map(e=>e.id))),()=>{});return e(),AW(()=>void e())},[]),e}function Pq({onPick:e,onBusy:t}){let n=Nq(),[r,i]=(0,d.useState)(null),a=vq().flatMap(e=>e.chooser&&n.has(e.id)?[e.chooser]:[]);if(a.length===0)return null;let o=async n=>{i(null),t(!0);try{let t=await n.choose();t&&e(t.url)}catch(e){i(e.message)}finally{t(!1)}};return(0,Q.jsxs)(`div`,{className:`add-link-choose`,children:[a.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>void o(e),children:e.label},e.label)),(0,Q.jsx)(`span`,{className:`faint small`,children:`or paste an address`}),r&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}var Fq=12e3;function Iq(e){let{embed:t,url:n,site:r,title:i}=e,[a,o]=(0,d.useState)(`loading`),[s,c]=(0,d.useState)(0),l=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=l.current;if(!e)return;o(`loading`);let t,n=new IntersectionObserver(([e])=>{e?.isIntersecting&&!t&&(t=setTimeout(()=>o(e=>e===`loading`?`slow`:e),Fq))});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[t.url,s]);let u=(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:n,target:`_blank`,rel:`noreferrer`,children:[`Open in `,r,(0,Q.jsx)($,{name:`external`})]});return(0,Q.jsxs)(`div`,{className:`link-frame nodrag nowheel`,children:[(0,Q.jsxs)(`div`,{className:`link-frame-stage is-${a}`,ref:l,children:[a===`loading`&&(0,Q.jsxs)(`span`,{className:`link-frame-wait`,children:[`Loading from `,r,`…`]}),(0,Q.jsx)(`iframe`,{src:t.url,title:i,sandbox:t.sandbox,allow:t.allow,allowFullScreen:t.allow?.includes(`fullscreen`),referrerPolicy:t.referrer,loading:`lazy`,onLoad:()=>o(`loaded`)},s),a===`slow`&&(0,Q.jsx)(`div`,{className:`link-frame-note`,role:`status`,children:(0,Q.jsxs)(`div`,{className:`link-frame-banner`,children:[(0,Q.jsx)(`p`,{children:t.blocked}),(0,Q.jsxs)(`div`,{className:`row`,children:[u,(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>c(e=>e+1),children:`Try again`})]})]})})]}),(0,Q.jsxs)(`p`,{className:`link-frame-help`,children:[`Doesn't load?`,` `,(0,Q.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,children:[`Open in `,r]})]})]})}function Lq(e){let t=e.trim();return ya(/^[a-z][a-z\d+.-]*:(?!\d)/i.test(t)?t:`https://${t}`)}function Rq({url:e}){let t=PK(e);return t?(0,Q.jsx)(JG,{mark:t}):(0,Q.jsx)(`span`,{className:`site-icon`,"aria-hidden":!0,children:(0,Q.jsx)($,{name:`link`})})}function zq(e){let{block:t,editing:n,setEditing:r,badges:i}=e,a=$z(),o=(0,d.useMemo)(()=>ha(t.url),[t.url]),s=BW(o),c=bq(o),l=c?.editor;if(n&&!a.readOnly)return(0,Q.jsx)(Bq,{block:t,onDone:()=>r(!1)});let u=o?.embed,f=!!(t.open&&u),p=t.title||s?.name||o?.name||xa(t.url),m=s?.modifiedTime?VW(s.modifiedTime):``,[h,g]=o?o.ref&&t.title?[o.ref,o.what]:[ga(o),m||ba(t.url)]:[ba(t.url)],_=!!(l&&o?.editable)&&!a.readOnly,v=l?.draft(t)??null,y=_&&l&&(0,Q.jsx)(l.Threads,{block:t}),b=_&&l&&(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a.openOverlay(t.id),title:l.title,children:`Edit in Tricot`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`block-head block-link${f?` is-open`:c?.LinkCard?` has-card`:``}`,onDoubleClick:()=>!a.readOnly&&r(!0),title:a.readOnly?void 0:`Double-click to edit`,children:[o?(0,Q.jsx)(YG,{mark:o.mark}):(0,Q.jsx)(Rq,{url:t.url}),(0,Q.jsxs)(`div`,{className:`block-link-text`,children:[(0,Q.jsx)(`a`,{className:`block-link-title nodrag`,href:t.url,target:`_blank`,rel:`noreferrer`,title:s&&s.name!==p?`${s.name}\n${t.url}`:t.url,onDoubleClick:e=>e.stopPropagation(),children:p}),(0,Q.jsxs)(`span`,{className:`block-link-host`,children:[y,v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`block-link-lead block-link-draft`,children:v[0].toUpperCase()+v.slice(1)}),(0,Q.jsxs)(`span`,{className:`block-link-rest`,children:[` · `,h]})]}):g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`block-link-lead`,children:h}),(0,Q.jsxs)(`span`,{className:`block-link-rest`,children:[` · `,g]})]}):h]})]}),u&&!a.readOnly&&(0,Q.jsx)(`div`,{className:`block-link-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>a.openLink(t,!1),children:`Collapse`}),b||(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:t.url,target:`_blank`,rel:`noreferrer`,children:[`Open in `,o.site,(0,Q.jsx)($,{name:`external`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[b,(0,Q.jsx)(`button`,{className:`btn btn-small${_?` btn-quiet`:``}`,onClick:()=>a.openLink(t,!0),children:`Open here`})]})}),i]}),!f&&o&&c?.LinkCard&&(0,Q.jsx)(c.LinkCard,{block:t,source:o}),f&&u&&(0,Q.jsx)(Iq,{embed:u,url:t.url,site:o.site,title:p},u.url)]})}function Bq({block:e,onDone:t}){let n=$z(),[r,i]=(0,d.useState)(e.url),[a,o]=(0,d.useState)(e.title??``),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(!1),u=i=>{if(l.current)return;let o=Lq(r);if(i&&!o)return c(!0);if(l.current=!0,t(),!i||!o)return;let s=o!==e.url,u=a.trim()!==(e.title??``);(s||u)&&n.updateBlock(e,{url:s?o:void 0,title:u?a:void 0})};return(0,Q.jsxs)(`div`,{className:`block-link-editor nodrag`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(Lq(r)!==null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u(!0)),e.key===`Escape`&&u(!1)},children:[(0,Q.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>{i(e.target.value),c(!1)},placeholder:`https://…`,"aria-label":`Address`,"aria-invalid":s,title:s?`Enter an http or https address`:void 0}),(0,Q.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Title (optional)`,"aria-label":`Title`})]})}function Vq({block:e,editing:t,setEditing:n}){let r=$z(),{becomes:i}=sV();return t?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>r.startPin({blockId:e.id,part:{kind:`block`},quote:e.title||xa(e.url)}),title:`Pin this card to ${i}`,children:`Pin`}),(0,Q.jsx)(`button`,{onClick:()=>n(!0),children:`Edit`})]})}function Hq(e){let{toggle:t,onAdd:n,onCancel:r}=e,[i,a]=(0,d.useState)(e.address),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(!1),p=(0,d.useRef)(null);return Zl(!i.trim()&&!o.trim()&&!u,r,p,t),(0,Q.jsxs)(`form`,{ref:p,className:`add-link nodrag nopan nowheel`,onSubmit:e=>{e.preventDefault();let t=Lq(i);t?n(t,o.trim()):l(!0)},onKeyDown:e=>e.key===`Escape`&&r(),children:[(0,Q.jsx)(Pq,{onBusy:f,onPick:e=>n(e,``)}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`span`,{className:`field-label`,children:`Address`}),(0,Q.jsx)(`input`,{autoFocus:!e.address,value:i,onChange:e=>{a(e.target.value),l(!1)},placeholder:`https://…`,"aria-invalid":c})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsxs)(`span`,{className:`field-label`,children:[`Title `,(0,Q.jsx)(`span`,{className:`faint`,children:`(optional)`})]}),(0,Q.jsx)(`input`,{autoFocus:!!e.address,value:o,onChange:e=>s(e.target.value),placeholder:`e.g. Design file`})]}),c&&(0,Q.jsx)(`p`,{className:`error`,children:`Enter an http:// or https:// address.`}),(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!i.trim(),children:`Add link`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:r,children:`Cancel`})]})]})}function Uq({initial:e,toggle:t,context:n,close:r}){return(0,Q.jsx)(Hq,{address:e??``,toggle:t,onAdd:(e,t)=>{r(),n.add({type:`link`,url:e},{title:t})},onCancel:r})}var Wq=e=>[...new Set(e.links.flatMap(e=>ya(e)??[]))];async function Gq(e,t,n){for(let[r,i]of Wq(e).entries())await t.add({type:`link`,url:i},{at:n&&{x:n.x+r*40,y:n.y+r*40}})}function Kq({block:e,name:t,pinId:n,onClose:r}){let i=bq(ha(e.url))?.editor;return i?(0,Q.jsx)(i.Editor,{block:e,name:t,pinId:n,onClose:r}):null}var qq={type:`link`,copyText:e=>e.url,Body:()=>null,Card:({block:e,editing:t,setEditing:n,badges:r})=>(0,Q.jsx)(zq,{block:e,editing:t,setEditing:n,badges:r}),Tools:Vq,overlay:{Component:Kq,changes:!0},opensOnPin:(e,t)=>!!bq(ha(e.url))?.editor?.opensPin(t),menu:{label:`Link`,icon:`link`,Form:Uq,paste:e=>/^https?:\/\/\S+$/i.test(e)?ya(e):null},clips:{accepts:e=>Wq(e).length>0,add:Gq,useDrop:e=>sH(e,{matches:Uz,what:`the link`,as:`a Link card`})}},Jq;function Yq(){return Jq??=GU(()=>import(`./viewer-DfqWyEfI.js`),[]).catch(e=>{throw Jq=void 0,e}),Jq}var Xq=new Map,Zq=new Map,Qq=e=>Zq.get(e)?.();function $q(e){try{return qa(e).facts}catch{return null}}function eJ(e,t){let[n,r]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let n=e.current;if(!n||!t)return;let i=new IntersectionObserver(([e])=>r(e.isIntersecting),{rootMargin:`160px`});return i.observe(n),()=>i.disconnect()},[e,t]),n&&t}var tJ=Math.PI/12;function nJ({block:e,selected:t,placed:n}){let r=$z(),i=tU(e.id),a=(0,d.useRef)(null),o=(0,d.useRef)(null),s=(0,d.useRef)(null),c=(0,d.useRef)(new Map),l=(0,d.useRef)({x:0,y:0}),u=nV(),[f,p]=(0,d.useState)(0),[m,h]=(0,d.useState)(`waiting`),g=eJ(a,!i.editing),_=zF(e=>e.transform[2]),v=$q(e.scene),y=e.id;(0,d.useEffect)(()=>(Zq.set(e.id,i.start),()=>void Zq.delete(e.id)),[e.id,i.start]);let b=aU(r.draft,e.id,`spot`),x=$a(n.map(({pin:e})=>e),e.id),S=[...n.flatMap(({pin:e,place:t})=>t?.kind===`spot`?[{key:e.id,point:[t.x,t.y,t.z],object:t.object,name:t.name,n:t.n,draft:!1,pin:e,view:t.view}]:[]),...b?[{key:zB,point:[b.x,b.y,b.z],object:b.object,name:rJ(v,b.object),n:x,draft:!0,view:b.view}]:[]],C=(0,d.useRef)(S);C.current=S;let w=(0,d.useCallback)(()=>{let e=s.current;if(e?.shown)for(let t of C.current){let n=c.current.get(t.key),r=e.locate(t);if(!n||!r)continue;let i=e.project(r,t.key);n.style.transform=`translate(${i.x}px, ${i.y}px)`,n.classList.toggle(`is-behind`,i.behind)}},[]),T=(0,d.useCallback)(()=>{let e=s.current;e?.shown&&(e.occlude(C.current.flatMap(t=>{let n=e.locate(t);return n?[{key:t.key,point:n}]:[]})),w(),Xq.set(y,e.view()))},[w,y]);(0,d.useEffect)(()=>{if(!g||!o.current)return;let e=o.current,t=!0,n=null;return h(`loading`),Yq().then(({SceneViewer:r,WebGLMissing:i})=>{if(t){try{n=new r(e,w,T)}catch(e){h(e instanceof i?`no-webgl`:{error:e.message});return}s.current=n,p(e=>e+1)}},e=>t&&h({error:`three.js didn't load (${e?.message??`no connection`}).`})),()=>{t=!1,n?.dispose(),s.current=null}},[g,w,T]),(0,d.useEffect)(()=>{let t=s.current;if(!f||!t)return;let n=!0;return t.show(e.scene,Xq.get(y)).then(()=>n&&h(`shown`),e=>n&&h({error:e?.message||`three.js could not make it`})),()=>{n=!1}},[f,e.scene,y]),(0,d.useEffect)(()=>{let e=o.current;if(!e||m!==`shown`)return;let t=new ResizeObserver(()=>s.current?.resize(_));t.observe(e);let n=setTimeout(()=>s.current?.resize(_),200);return()=>{t.disconnect(),clearTimeout(n)}},[m,_]),(0,d.useEffect)(()=>{s.current&&(s.current.zoomable=t)},[t,m]);let E=S.map(e=>`${e.key}@${e.point.join(`,`)}@${e.name??``}`).join(` `);(0,d.useEffect)(()=>{m===`shown`&&T()},[E,m,T,e.scene]);let D=S.find(e=>!e.draft&&(e.key===r.thread||e.key===r.focusPin));(0,d.useEffect)(()=>{let e=s.current;if(!D||!e?.shown)return;let t=e.locate(D);D.view?e.setView(D.view):t&&e.setView(e.viewOf(t))},[D?.key,m]);let O=(t,n)=>{let i=s.current,a=i?.pick(t,n);if(!i||!a)return!1;let o=a.object&&v?Xa(v,a.object.uuid,a.object.name):void 0,[c,l,u]=o?a.local:a.world,d=o?o.uuid??o.name:void 0,f={kind:`spot`,...d?{object:d}:{},x:c,y:l,z:u,view:i.view()};return r.startPin({blockId:e.id,part:f,quote:eo(x,o?.name)}),!0},k=e=>{let t=s.current;if(!t?.shown||e.metaKey||e.ctrlKey||e.altKey)return;let n={ArrowLeft:()=>t.turn(-tJ,0),ArrowRight:()=>t.turn(tJ,0),ArrowUp:()=>t.turn(0,-tJ),ArrowDown:()=>t.turn(0,tJ),"+":()=>t.zoom(!0),"=":()=>t.zoom(!0),"-":()=>t.zoom(!1),0:()=>t.reset(),Enter:()=>!r.readOnly&&O(.5,.5)}[e.key];n&&(e.preventDefault(),e.stopPropagation(),n())};if(i.editing)return(0,Q.jsx)(sJ,{block:e,edit:i});let A=m===`shown`,j=r.readOnly?`Drag to turn it; select the block to zoom with the wheel. Arrow keys turn it, + and − zoom, 0 resets.`:`Drag to turn it, click an object to comment on a spot of it, double-click to edit its JSON. Select the block to zoom with the wheel. Arrow keys turn it, + and − zoom, 0 resets, Enter pins the middle.`;return(0,Q.jsxs)(`div`,{ref:a,className:`scene-stage nodrag nopan${t?` nowheel`:``}${A&&!r.readOnly?` is-pinnable`:``}`,tabIndex:0,role:`application`,"aria-roledescription":`3D scene`,"aria-label":`${v?`three.js scene of ${Qa(v)}`:`three.js scene`}. ${j}`,title:A?j:void 0,onKeyDown:k,onPointerDown:e=>{l.current={x:e.clientX,y:e.clientY}},onClick:e=>{if(rU(e,l.current))return e.stopPropagation();if(!A||r.readOnly||iU(e)||e.detail!==1||!o.current)return;let t=o.current.getBoundingClientRect(),[n,i]=[(e.clientX-t.left)/t.width,(e.clientY-t.top)/t.height];s.current?.pick(n,i)&&(e.stopPropagation(),u.later(()=>O(n,i)))},onDoubleClickCapture:u.cancel,onDoubleClick:e=>{e.stopPropagation(),i.start()},children:[(0,Q.jsx)(`div`,{ref:o,className:`scene-view`}),A&&(0,Q.jsx)(`div`,{className:`scene-spots`,children:S.map(e=>(0,Q.jsx)(aJ,{spot:e,style:iJ(s.current,e),focus:e.key===r.focusPin,markers:c.current,onOpen:e.pin?.discussion?.thread?()=>r.openThread(e.pin.id):void 0},e.key))}),A&&(0,Q.jsx)(`button`,{type:`button`,className:`scene-reset`,title:`Reset the view (0)`,"aria-label":`Reset the view`,onClick:e=>{e.stopPropagation(),s.current?.reset()},onDoubleClick:e=>e.stopPropagation(),children:(0,Q.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`M3.5 6.5A4.75 4.75 0 1 1 3.4 9.6M3.25 3.5v3h3`})})}),!A&&(0,Q.jsx)(oJ,{facts:v,shown:m})]})}function rJ(e,t){return t!==void 0&&e?Xa(e,t,t)?.name:void 0}function iJ(e,t){let n=e?.shown?e.locate(t):null;if(!e||!n)return{visibility:`hidden`};let r=e.project(n,t.key);return{transform:`translate(${r.x}px, ${r.y}px)`}}function aJ(e){let{spot:t,style:n,focus:r,markers:i,onOpen:a}=e,o=[`scene-spot`,t.draft?`is-draft`:`is-linked`,r&&`is-focus`,a&&`is-open-able`],s=`Spot ${t.n}${t.name?` on "${t.name}"`:``}`;return(0,Q.jsx)(`span`,{ref:e=>{e?i.set(t.key,e):i.delete(t.key)},className:o.filter(Boolean).join(` `),style:n,"data-pin-draft":t.key===`draft`?``:void 0,title:a?`${s}: open its comments`:s,onClick:a&&(e=>{e.stopPropagation(),a()}),children:(0,Q.jsx)(`span`,{className:`scene-spot-n`,children:t.n})})}function oJ({facts:e,shown:t}){let n=e?`three.js scene of ${Qa(e)}`:`three.js scene`;return t===`no-webgl`?(0,Q.jsxs)(`div`,{className:`scene-standing`,role:`note`,children:[(0,Q.jsx)(`p`,{children:`This browser can't draw 3D scenes: WebGL is off or unavailable.`}),(0,Q.jsx)(`p`,{className:`scene-standing-about`,children:n})]}):typeof t==`object`?(0,Q.jsxs)(`div`,{className:`scene-standing`,role:`alert`,children:[(0,Q.jsxs)(`p`,{className:`scene-error`,children:[`The scene couldn't be drawn: `,t.error]}),(0,Q.jsx)(`p`,{className:`scene-standing-about`,children:`Double-click to edit its JSON.`})]}):(0,Q.jsx)(`div`,{className:`scene-standing`,"aria-busy":t===`loading`,children:(0,Q.jsx)(`p`,{className:`scene-standing-about`,children:t===`loading`?`Drawing the scene…`:n})})}function sJ({block:e,edit:t}){let n=$z(),[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1),o=to(e.scene);return(0,Q.jsxs)(`div`,{className:`scene-source`,children:[(0,Q.jsx)(`textarea`,{autoFocus:!0,spellCheck:!1,className:`block-editor block-editor-code nodrag nowheel`,defaultValue:o,"aria-label":`The scene's three.js JSON`,"aria-invalid":r?!0:void 0,onChange:()=>i(null),onBlur:r=>{let s=r.currentTarget.value;if(a.current||s===o||!s.trim())t.cancel(),t.finish(s,e.scene,()=>{});else{try{qa(s)}catch(e){i(e.message);return}t.finish(s,e.scene,t=>n.updateBlock(e,{scene:t}))}},onKeyDown:e=>{e.key===`Escape`&&(a.current=!0,e.currentTarget.blur())}}),r&&(0,Q.jsxs)(`p`,{className:`scene-source-error`,role:`alert`,children:[r,` Put it right and click away to save, or press Esc in the field to discard the edit.`]})]})}var cJ=3600;function lJ(e,t){let n=e?.shown?e.locate(t):null;if(!e||!n)return{visibility:`hidden`};let r=e.project(n,t.key);return{transform:`translate(${r.x}px, ${r.y}px)`}}var uJ=(e,t)=>t!==void 0&&e?Xa(e,t,t)?.name:void 0;function dJ({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=$z(),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=(0,d.useRef)(new Map),f=(0,d.useRef)({x:0,y:0}),p=(0,d.useRef)(void 0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(`loading`),[v,y]=(0,d.useState)(null),b=$q(e.scene),x=$a(s.pins.get(e.id)??[],e.id),S=r?.part.kind===`spot`?r.part:null,C=[...t.flatMap(({pin:e,place:t})=>t?.kind===`spot`?[{key:e.id,point:[t.x,t.y,t.z],object:t.object,name:t.name,n:t.n,draft:!1,view:t.view}]:[]),...S?[{key:JV,point:[S.x,S.y,S.z],object:S.object,name:uJ(b,S.object),n:x,draft:!0}]:[]],w=(0,d.useRef)(C);w.current=C;let T=(0,d.useCallback)(()=>{let e=l.current;if(e?.shown)for(let t of w.current){let n=u.current.get(t.key),r=e.locate(t);if(!n||(n.style.visibility=r?``:`hidden`,!r))continue;let i=e.project(r,t.key);n.style.transform=`translate(${i.x}px, ${i.y}px)`,n.classList.toggle(`is-behind`,i.behind)}},[]),E=(0,d.useCallback)(()=>{let e=l.current;e?.shown&&(e.occlude(w.current.flatMap(t=>{let n=e.locate(t);return n?[{key:t.key,point:n}]:[]})),T(),p.current=e.view())},[T]);(0,d.useEffect)(()=>{let e=c.current;if(!e)return;let t=!0,n=null;Yq().then(({SceneViewer:r,WebGLMissing:i})=>{if(t){try{n=new r(e,T,E)}catch(e){_(e instanceof i?`no-webgl`:{error:e.message});return}n.zoomable=!0,l.current=n,h(e=>e+1)}},e=>t&&_({error:`three.js didn't load (${e?.message??`no connection`}).`}));let r=new ResizeObserver(()=>l.current?.resize());return r.observe(e),()=>{t=!1,r.disconnect(),n?.dispose(),l.current=null}},[T,E]),(0,d.useEffect)(()=>{let t=l.current;if(!m||!t)return;let n=!0;return t.show(e.scene,p.current).then(()=>{n&&(_(`shown`),t.resize(),E())},e=>n&&_({error:e?.message||`three.js could not make it`})),()=>{n=!1}},[m,e.scene,E]);let D=C.map(e=>`${e.key}@${e.point.join(`,`)}@${e.name??``}`).join(` `);(0,d.useEffect)(()=>{g===`shown`&&E()},[D,g,E]);let O=C.find(e=>!e.draft&&e.key===i);(0,d.useEffect)(()=>{let e=l.current;if(!O||!e?.shown)return;let t=e.locate(O);O.view?e.setView(O.view):t&&e.setView(e.viewOf(t))},[O?.key,g]),(0,d.useEffect)(()=>{if(!v)return;let e=setTimeout(()=>y(null),cJ);return()=>clearTimeout(e)},[v]);let k=t=>{let r=l.current;if(!n||!r?.shown||!c.current||rU(t,f.current))return;let i=c.current.getBoundingClientRect(),o=r.pick((t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);if(!o)return;let s=o.object&&b?Xa(b,o.object.uuid,o.object.name):void 0;if(!s)return y(`That part has no name, so there is nothing to ask about it by: click a named object.`);let[u,d,p]=o.local;a({blockId:e.id,part:{kind:`spot`,object:s.uuid??s.name,x:u,y:d,z:p,view:r.view()},quote:eo(x,s.name)})},A=g===`shown`;return(0,Q.jsxs)(`div`,{className:`scene-full-wrap`,children:[(0,Q.jsxs)(`div`,{className:`scene-stage scene-full${n?` is-pointing`:``}`,onPointerDown:e=>{f.current={x:e.clientX,y:e.clientY}},onClick:k,title:n?`Click a named object to ask about it; drag to turn the scene`:`Drag to turn it, the wheel zooms`,children:[(0,Q.jsx)(`div`,{ref:c,className:`scene-view`}),A&&(0,Q.jsx)(`div`,{className:`scene-spots`,children:C.map(e=>(0,Q.jsx)(`span`,{ref:t=>{t?u.current.set(e.key,t):u.current.delete(e.key)},className:`scene-spot ${e.draft?`is-draft`:`is-linked is-open-able`}${e.key===i?` is-open`:``}`,style:lJ(l.current,e),"data-pair-anchor":e.key,"data-pin-draft":e.draft?``:void 0,title:`Spot ${e.n}${e.name?` on "${e.name}"`:``}${e.draft?``:`: open what was said about it`}`,onClick:e.draft?void 0:t=>{t.stopPropagation(),o(e.key)},children:(0,Q.jsx)(`span`,{className:`scene-spot-n`,children:e.n})},e.key))}),A&&(0,Q.jsx)(`button`,{type:`button`,className:`scene-reset`,title:`Back to the whole scene`,"aria-label":`Reset the view`,onClick:e=>{e.stopPropagation(),l.current?.reset()},children:(0,Q.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`M3.5 6.5A4.75 4.75 0 1 1 3.4 9.6M3.25 3.5v3h3`})})}),!A&&(0,Q.jsxs)(`div`,{className:`scene-standing`,role:typeof g==`object`?`alert`:void 0,"aria-busy":g===`loading`,children:[g===`no-webgl`?(0,Q.jsx)(`p`,{children:`This browser can't draw 3D scenes: WebGL is off or unavailable.`}):typeof g==`object`?(0,Q.jsxs)(`p`,{className:`scene-error`,children:[`The scene couldn't be drawn: `,g.error]}):(0,Q.jsx)(`p`,{className:`scene-standing-about`,children:`Drawing the scene…`}),b&&(0,Q.jsxs)(`p`,{className:`scene-standing-about`,children:[`three.js scene of `,Qa(b)]})]}),v&&(0,Q.jsx)(`p`,{className:`scene-full-note`,role:`status`,children:v})]}),t.length>0&&(0,Q.jsx)(`div`,{className:`scene-full-chips`,children:t.map(({pin:t})=>(0,Q.jsx)(RB,{pin:t,open:t.id===i,part:Zo(t,e),onToggle:()=>o(t.id)},t.id))})]})}function fJ(e){if(!e.trim())return`A scene needs its JSON: write some, or discard your changes.`;try{return qa(e),null}catch(e){return`${e.message} Put it right, or discard your changes.`}}function pJ({block:e,name:t,version:n,pinId:r,onClose:i}){let a=$q(e.scene),o=a?.named.length??0,s=a?`3D scene · ${o===1?`1 named object`:`${o.toLocaleString(`en-US`)} named objects`} · ${Qa(a)}`:`3D scene`;return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`scene`,className:`scene-full-view`,label:`3D scene ${e.title??``}`.trim(),icon:(0,Q.jsx)($,{name:`scene`}),title:e.title||(a?.named[0]?`Scene "${a.named[0].name}"`:`3D scene`),from:s,browse:{label:`View`,hint:`Turn it and zoom on your own; click a spot to see what was said about it`},it:`the scene`,point:`click a named object`,does:`changes the scene`,example:`make it taller, say`,body:e=>(0,Q.jsx)(dJ,{...e}),edit:{hint:`Edit its three.js JSON by hand (or double-click it while viewing)`,label:`The scene's three.js JSON`,code:!0,of:e=>to(e.scene),patch:e=>({scene:e}),check:fJ},onClose:i})}function mJ({block:e,viewing:t}){let n=$z();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to look at it large or pair with an agent on its objects (Enter)`,children:`Open`}),!t&&(0,Q.jsx)(`button`,{onClick:()=>Qq(e.id),title:`Edit the scene's three.js JSON (or double-click it)`,children:`Edit JSON`})]})}var hJ={type:`scene`,Body:nJ,Tools:mJ,still:!0,overlay:{Component:pJ,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`3D scene`,icon:`scene`,add:()=>({content:{type:`scene`,scene:to(za)},title:`New scene`})}},gJ=e=>{let t=e;return!!t&&[t.x,t.y,t.w,t.h].every(e=>typeof e==`number`&&Number.isFinite(e))},_J=(e,t=2e3)=>typeof e==`string`&&e.length<=t,vJ=e=>typeof e==`string`&&ao(e)===e,yJ=e=>Array.isArray(e)&&e.length<=500&&e.every(e=>_J(e,40));function bJ(e,t,n){if(!t||e.source!==t||e.origin!==n)return null;let r=e.data;if(!r||typeof r!=`object`||r.tricot!==`site`)return null;switch(r.type){case`ready`:return vJ(r.page)&&_J(r.title,400)&&typeof r.scrollY==`number`?r:null;case`rects`:{let e=r.pins;return e&&typeof e==`object`&&Object.values(e).every(e=>e===null||gJ(e))&&(r.chosen===null||gJ(r.chosen))&&typeof r.scrollY==`number`?r:null}case`found`:return vJ(r.page)&&yJ(r.found)&&yJ(r.lost)?r:null;case`select`:{let e=r.element,t=e&&_J(e.selector,500)&&_J(e.tag,40)&&_J(e.text)&&gJ(e.rect),n=e&&(e.file===void 0||_J(e.file,400))&&(e.line===void 0||Number.isInteger(e.line));return t&&n?r:null}case`changed`:return typeof r.scrollY==`number`?r:null;default:return null}}var xJ=`allow-scripts allow-same-origin allow-forms allow-popups`;async function SJ(e){try{return{address:await Vl(J.siteAddress)({blockId:e})}}catch(e){return{error:e.message}}}function CJ(e){let[t,n]=(0,d.useState)({}),[r,i]=(0,d.useState)(!1);(0,d.useEffect)(()=>{let t=!0;return SJ(e).then(e=>t&&n(e)),()=>{t=!1}},[e]);let a=t.address?.origin;return(0,d.useEffect)(()=>{if(!a)return;let e=e=>{e.effectiveDirective===`frame-src`&&e.blockedURI.startsWith(a)&&i(!0)};return document.addEventListener(`securitypolicyviolation`,e),()=>document.removeEventListener(`securitypolicyviolation`,e)},[a]),{...t,blocked:r}}var wJ=`tricot:site-changed`,TJ=e=>window.dispatchEvent(new CustomEvent(wJ,{detail:e})),EJ=(e,t)=>`${e.origin}${t.startsWith(`/`)?t:`/${t}`}`;function DJ(e,t,n){let r=(0,d.useRef)(n);r.current=n,(0,d.useEffect)(()=>{if(!t)return;let n=n=>{let i=bJ(n,e.current?.contentWindow,t);i&&r.current(i)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)},[e,t])}function OJ(e,t,n){t&&e?.contentWindow?.postMessage({...n,tricot:`site`},t)}function kJ(e,t){return e.flatMap(e=>e.anchor.kind===`site`&&e.anchor.page===t&&e.discussion?[{id:e.id,selector:e.anchor.selector,tag:e.anchor.tag,text:e.anchor.text}]:[])}var AJ=class extends d.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`A website on the board failed to show:`,e)}render(){if(!this.state.failed)return this.props.children;let{onClose:e}=this.props;return(0,Q.jsxs)(`div`,{className:`site-failed nodrag${e?` is-full`:``}`,role:`alert`,children:[(0,Q.jsx)(`p`,{children:`This website couldn't be shown here.`}),(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>this.setState({failed:!1}),children:`Try again`}),e&&(0,Q.jsxs)(`button`,{className:`btn btn-small btn-quiet`,onClick:e,children:[(0,Q.jsx)($,{name:`x`}),` Close`]})]})]})}},jJ=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,MJ=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function NJ(e){let{element:t,style:n,above:r,text:i,busy:a,error:o,agent:s,onText:c,onSubmit:l,onClose:u}=e,f=(0,d.useRef)(null),p=!i.trim(),m=(0,d.useRef)(i);return m.current=i,(0,d.useEffect)(()=>{let e=e=>{!f.current?.contains(e.target)&&!m.current.trim()&&u()};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[u]),(0,Q.jsxs)(`div`,{ref:f,className:`pin-prompt site-ask${r?` is-above`:``}`,style:n,role:`dialog`,"aria-label":`Ask about this part of the page`,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!p&&!a&&l(!0))},children:[(0,Q.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,Q.jsx)(`p`,{className:`pin-prompt-quote`,children:ho(t.tag,t.text,t.selector)}),(0,Q.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:u,"aria-label":`Close`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(LE,{skills:!0,lenses:QT,rows:2,value:i,placeholder:s?`Ask ${s} to change it (make this shorter, say), or leave a note`:`Ask an agent to change it (make this shorter, say), or leave a note; @ to pick an agent`,"aria-label":`What should change here?`,autoFocus:!0,onValue:c}),o&&(0,Q.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,Q.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:p||a,onClick:()=>l(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:p||a,onClick:()=>l(!1),children:`Add a note`}),(0,Q.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${jJ}+Enter asks ${s??`an agent`}`,children:jJ===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,Q.jsxs)(`p`,{className:`pin-prompt-hint`,children:[s??`An agent`,` changes the site's `,t.file?`file (${t.file}${t.line?`, line ${t.line}`:``})`:`files`,` and replies here`,s?`, with its steps on the pin as it works`:``,`. A note just stays on the element.`]})]})}function PJ(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=$z(),s=as(t,Zz(o)),c=t.discussion?.resolved,l=s.some(e=>e.ask),u=!c&&s.at(-1)?.author.kind===`human`,d=!c&&!n&&o.newItems.has(t.id),f=[`pin-chip`,`is-comment`,`site-pin-chip`,l&&`is-ask`,c&&`is-done`,i&&`is-lost`,d&&`is-new`,n&&`is-open`],p=l?`Asked agents to change`:`Notes on`,m=c?`, resolved by ${c.by.name}`:l&&u?`, waiting for an agent`:``;return(0,Q.jsxs)(`span`,{className:f.filter(Boolean).join(` `),"data-chip-pin":t.id,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} the ${t.quote}: ${MJ(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,Q.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,Q.jsx)($,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,Q.jsx)($,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,Q.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,Q.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,Q.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await PB(`this element`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin the ${t.quote}`,title:`Unpin. Its thread goes with it.`,children:(0,Q.jsx)($,{name:`x`})})]})}function FJ({blockId:e}){let t=$z(),n=(t.pins.get(e)??[]).filter(e=>e.anchor.kind===`site`&&e.discussion&&!e.discussion.resolved);if(n.length===0)return null;let r=n.filter(e=>t.newItems.has(e.id)),i=n.filter(e=>as(e,Zz(t)).some(e=>e.ask)).length,a=[i&&`${MJ(i,`request`)} to agents`,n.length-i&&MJ(n.length-i,`note`)].filter(Boolean).join(` and `);return(0,Q.jsxs)(`button`,{type:`button`,className:`block-link-threads nodrag${r.length?` is-new`:``}`,onClick:()=>t.openOverlay(e,{pinId:(r[0]??n[0]).id}),onDoubleClick:e=>e.stopPropagation(),title:`${a} on this website${r.length?`, with new replies`:``}. Open it there.`,children:[(0,Q.jsx)($,{name:i?`edit`:`comment`}),n.length,r.length>0&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]})}function IJ(e,t,{gap:n,more:r,least:i}){if(e.reduce((e,t,r)=>e+(r?n:0)+t.width,0)<=t)return{shown:e.length,squeeze:!1};let a=0,o=0;for(let[i,s]of e.entries()){let e=a+(i?n:0)+s.width;if(e+n+r>t)break;a=e,o=i+1}for(;o>0&&e[o-1].heading;)o--;if(e.slice(0,o).some(e=>!e.heading))return{shown:o,squeeze:!1};let s=e.findIndex(e=>!e.heading);if(s<0)return{shown:0,squeeze:!1};let c=e.slice(0,s).reduce((e,t)=>e+t.width+n,0),l=e.slice(s+1).some(e=>!e.heading)?n+r:0;return c+i+l<=t?{shown:s+1,squeeze:!0}:{shown:0,squeeze:!1}}var LJ=96,RJ=14,zJ=e=>`pin`in e,BJ=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function VJ({groups:e,open:t}){let n=$z(),r=(0,d.useRef)(null),i=(0,d.useRef)(null),[a,o]=(0,d.useState)({shown:1/0,squeeze:!1}),s=e.flatMap(e=>[{heading:e.label},...e.pins]),c=s.filter(zJ).length,l=n.readOnly?0:RJ,u=(0,d.useRef)(()=>{});u.current=()=>{let e=r.current,t=i.current;if(!e||!t)return;let[n,...a]=[...t.children];if(!n)return;let s=e=>e.getBoundingClientRect().width,c=IJ(a.map(e=>({width:s(e),heading:e.classList.contains(`site-view-apart-heading`)})),s(e)-l,{gap:parseFloat(getComputedStyle(t).columnGap)||0,more:s(n),least:LJ});o(e=>e.shown===c.shown&&e.squeeze===c.squeeze?e:c)};let f=s.map(e=>zJ(e)?e.pin.id:`#${e.heading}`).join(`|`);(0,d.useLayoutEffect)(()=>u.current(),[f,l]),(0,d.useEffect)(()=>{let e=new ResizeObserver(()=>u.current());return r.current&&e.observe(r.current),i.current&&e.observe(i.current),()=>e.disconnect()},[]);let p=s.slice(0,a.shown),m=s.slice(a.shown).filter(zJ),h=e.map(e=>({label:e.label,pins:e.pins.filter(e=>m.includes(e))})).filter(e=>e.pins.length>0),g=m.some(e=>e.pin.id===t),_=m.some(e=>e.pin.id!==t&&!e.pin.discussion?.resolved&&n.newItems.has(e.pin.id)),v=(e,n)=>zJ(e)?(0,Q.jsx)(PJ,{pin:e.pin,open:e.pin.id===t,part:e.part,lost:e.lost,onToggle:()=>(n??(e=>e.onToggle()))(e)},e.pin.id):(0,Q.jsx)(`span`,{className:`faint small site-view-apart-heading`,children:e.heading},`#${e.heading}`);return(0,Q.jsxs)(`div`,{className:`site-view-apart-row`,ref:r,children:[(0,Q.jsx)(`div`,{className:`site-view-apart-chips${a.squeeze?` is-squeezed`:``}`,children:p.map(e=>v(e))}),m.length>0&&(0,Q.jsx)(ox,{className:`site-view-apart-more`,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`summary`,{className:`site-view-apart-more-button${g?` is-open`:``}`,title:`${BJ(m.length,`more pinned element`)}${_?`, with new replies`:``}`,children:[m.length,` more`,_&&(0,Q.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),(0,Q.jsx)(`div`,{className:`popover-body site-view-apart-list`,children:h.map(t=>(0,Q.jsxs)(`section`,{"aria-label":t.label,children:[(0,Q.jsx)(`h3`,{className:`faint small site-view-apart-heading`,children:t.label}),(0,Q.jsx)(`ul`,{children:t.pins.map(t=>(0,Q.jsx)(`li`,{children:v(t,t=>{e(),t.onToggle()})},t.pin.id))})]},t.label))})]})}),(0,Q.jsx)(`div`,{className:`site-view-apart-copy`,"aria-hidden":!0,inert:!0,children:(0,Q.jsxs)(`div`,{className:`site-view-apart-copy-line`,ref:i,children:[(0,Q.jsxs)(`span`,{className:`site-view-apart-more-button`,children:[c,` more`,(0,Q.jsx)(`span`,{className:`pin-chip-new`})]}),s.map(e=>v(e))]})})]})}var HJ=390,UJ=340,WJ=230,GJ={count:12,ms:5e3},KJ=1500,qJ=1500,JJ=3e3,YJ=e=>e===`/`?`Home page`:e;function XJ(e,t,n,r){if(n)return{left:t.w+16,top:Math.max(8,Math.min(e.y,t.h-r-8)),above:!1};let i=Math.max(12,Math.min(e.x,t.w-UJ-12)),a=e.y+e.h+10,o=a+r>t.h&&e.y-10>r;return{left:i,top:o?e.y-10:Math.min(a,Math.max(12,t.h-60)),above:o}}function ZJ({block:e,name:t,pinId:n,pinAsked:r,onClose:i}){let a=$z(),{seeItem:o,readOnly:s}=a,{address:c,error:l,blocked:u}=CJ(e.id),f=c?.origin,p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=NV(e,t,`site`),g=h.mode===`pair`,[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(e.page),[x,S]=(0,d.useState)(e.pages?.find(t=>t.path===e.page)?.title??``),[C,w]=(0,d.useState)({page:e.page,n:0,scrollY:0}),[T,E]=(0,d.useState)({}),[D,O]=(0,d.useState)([]),[k,A]=(0,d.useState)(null),[j,M]=(0,d.useState)(null),[N,P]=(0,d.useState)(``),[F,I]=(0,d.useState)(!1),[L,R]=(0,d.useState)(null),[z,B]=(0,d.useState)(n??null),[ee,V]=(0,d.useState)(null),[te,ne]=(0,d.useState)({w:0,h:0}),[re,ie]=(0,d.useState)(null),ae=(0,d.useRef)(!1),oe=(0,d.useRef)({restored:!1}),se=(0,d.useRef)([]),H=(0,d.useRef)(0),U=(0,d.useRef)(void 0);(0,d.useEffect)(()=>()=>clearTimeout(U.current),[]),(0,d.useEffect)(()=>{ae.current=!1,oe.current={restored:!1}},[C]);let W=a.pins.get(e.id),G=(0,d.useMemo)(()=>{let e=(W??[]).filter(e=>e.anchor.kind===`site`&&e.discussion);return ee&&!e.some(e=>e.id===ee.id)?[...e,ee]:e},[W,ee]);(0,d.useEffect)(()=>{ee&&W?.some(e=>e.id===ee.id)&&V(null)},[W,ee]);let ce=(0,d.useMemo)(()=>G.filter(e=>e.anchor.kind===`site`&&e.anchor.page===y),[G,y]),le=(0,d.useMemo)(()=>G.filter(e=>e.anchor.kind===`site`&&e.anchor.page!==y&&(!e.discussion?.resolved||e.id===z)),[G,y,z]),ue=(0,d.useMemo)(()=>kJ(ce,y),[ce,y]),de=JSON.stringify(ue);(0,d.useEffect)(()=>{let e=m.current;if(!e)return;let t=new ResizeObserver(()=>ne({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[c]);let fe=(0,d.useRef)(null),pe=e=>{fe.current={id:e,until:Date.now()+JJ},OJ(p.current,f,{type:`reveal`,id:e})},me=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!n)return;B(n);let e=G.find(e=>e.id===n),t=e?.anchor.kind===`site`?e.anchor.page:y;t===y?ae.current?pe(n):me.current=n:(me.current=n,ae.current=!1,w(e=>({page:t,n:e.n+1,scrollY:0})))},[n,r]);let he=(n,r)=>{clearTimeout(U.current),s||(U.current=setTimeout(()=>{let i=e.pages?.find(e=>e.path===n)?.title;(n!==e.page||r&&r!==i)&&X.updateBlock(e.id,t,{page:n,pageTitle:r}).catch(()=>void 0)},KJ))};DJ(p,c?.origin,t=>{switch(t.type){case`ready`:{let e=Date.now();if(se.current=[...se.current.filter(t=>e-t<GJ.ms),e],se.current.length>GJ.count)break;let n=t.page!==y;ae.current=!0,b(t.page),S(t.title),n&&(A(null),E({}),O([])),OJ(p.current,f,{type:`mode`,edit:g}),OJ(p.current,f,{type:`pins`,pins:kJ(G,t.page)}),OJ(p.current,f,{type:`watch`}),oe.current.restored||(oe.current.restored=!0,C.scrollY&&OJ(p.current,f,{type:`scrollTo`,y:C.scrollY})),he(t.page,t.title);break}case`rects`:{E(t.pins),M(t.chosen);let e=fe.current;if(!e)break;let n=t.pins[e.id],r=m.current?.clientHeight??0,i=n&&n.w>0&&n.y<r&&n.y+n.h>0;!n||i||Date.now()>e.until?fe.current=null:OJ(p.current,f,{type:`reveal`,id:e.id});break}case`found`:O(t.lost),me.current&&t.found.includes(me.current)&&(pe(me.current),me.current=null);break;case`select`:if(s||k&&N.trim())break;A(t.element),M(t.element.rect),R(null),B(null);break;case`changed`:{let n=Date.now();if(n-H.current<qJ)break;H.current=n,ie(n),TJ(e.id),w(e=>({page:y,n:e.n+1,scrollY:t.scrollY}));break}}}),(0,d.useEffect)(()=>{ae.current&&OJ(p.current,f,{type:`mode`,edit:g}),g||(A(null),P(``),OJ(p.current,f,{type:`choose`,selector:null}))},[g]),(0,d.useEffect)(()=>{ae.current&&OJ(p.current,f,{type:`pins`,pins:JSON.parse(de)})},[de]),(0,d.useEffect)(()=>{if(!re)return;let e=setTimeout(()=>ie(null),2400);return()=>clearTimeout(e)},[re]);let ge=(0,d.useCallback)(()=>{A(null),P(``),OJ(p.current,f,{type:`choose`,selector:null})},[f]);(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||RV()||(k?ge():z?B(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[k,z,i,ge]);let _e=()=>{ae.current=!1,w(e=>({page:y,n:e.n+1,scrollY:0}))},ve=e=>{e.anchor.kind===`site`&&(B(e.id),o(e.id),me.current=e.id,ae.current=!1,w(t=>({page:e.anchor.page,n:t.n+1,scrollY:0})))},ye=e=>{B(t=>t===e?null:e),A(null),o(e)},be=e=>{if(e.anchor.kind===`site`){if(e.anchor.page!==y)return ve(e);B(e.id),A(null),o(e.id),pe(e.id)}},K=async n=>{if(k&&N.trim()&&!F){I(!0),R(null);try{let{selector:r,tag:i,text:a,file:o,line:s}=k,c=n?h.address(N):N,{pin:l}=await X.pinComment(e.id,t,{part:{kind:`site`,page:y,selector:r,tag:i,text:a,file:o,line:s},body:c,ask:n});V(l),B(l.id),A(null),P(``),OJ(p.current,f,{type:`choose`,selector:null})}catch(e){R(e.message)}finally{I(!1)}}},xe=e.title||x||oo(e),Se=G.find(e=>e.id===z),Ce=Se&&Se.anchor.kind===`site`&&Se.anchor.page===y?T[Se.id]:null,we=ce.filter(e=>(D.includes(e.id)||e.anchor.gone)&&(!e.discussion?.resolved||e.id===z)),Te=k&&j&&XJ(j,te,_,WJ),Ee=Se&&Ce?XJ(Ce,te,_,260):null,De=c&&EJ(c,C.page),Oe=e=>t=>(0,Q.jsx)(EV,{pin:e,fallback:t}),ke;ke=l?(0,Q.jsx)(`div`,{className:`site-view-state`,role:`status`,children:(0,Q.jsx)(`p`,{children:l})}):u?(0,Q.jsxs)(`div`,{className:`site-view-state`,role:`status`,children:[(0,Q.jsx)(`p`,{children:`Tricot started showing websites after this page opened. Load the page again to show this one.`}),(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>location.reload(),children:`Load again`})]}):!c||!De?(0,Q.jsxs)(`div`,{className:`site-view-state`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Opening the website…`]}):(0,Q.jsx)(`div`,{className:`site-view-stage${_?` is-phone`:``}`,children:(0,Q.jsxs)(`div`,{className:`site-view-screen`,ref:m,style:_?{width:HJ}:void 0,children:[(0,Q.jsx)(`iframe`,{ref:p,name:`tricot-site`,src:De,title:xe,sandbox:xJ,referrerPolicy:`strict-origin-when-cross-origin`,onLoad:()=>{ae.current||E({})}},`${C.page}:${C.n}`),(0,Q.jsxs)(`div`,{className:`site-view-marks`,"aria-hidden":!1,children:[ce.map(e=>{let t=T[e.id];if(!t||e.discussion?.resolved&&e.id!==z)return null;let n=e.id===z;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`site-pin-mark${n?` is-open`:``}`,style:{left:t.x-3,top:t.y-3,width:t.w+6,height:t.h+6}}),(0,Q.jsx)(`span`,{className:`site-pin`,style:{left:Math.min(t.x+t.w,te.w-8),top:Math.max(t.y,12)},children:(0,Q.jsx)(PJ,{pin:e,open:n,onToggle:()=>ye(e.id)})})]},e.id)}),Se&&Ee&&(0,Q.jsx)(uV,{pin:Se,block:e,name:t,above:Ee.above,style:{left:Ee.left,top:Ee.top,width:UJ},onClose:()=>B(null),live:Oe(Se),address:h.address},Se.id),k&&Te&&(0,Q.jsx)(NJ,{element:k,style:{left:Te.left,top:Te.top,width:UJ},above:Te.above,text:N,busy:F,error:L,agent:h.agent,onText:e=>{P(e),R(null)},onSubmit:e=>void K(e),onClose:ge},k.selector)]})]})});let Ae=[...we,...le],je=Se&&Ae.includes(Se)?Se:void 0,Me=h.agent,Ne=h.agents.find(e=>e.name===Me);return(0,Q.jsxs)(VV,{pairing:h,className:`site-view`,label:`Website ${xe}`,icon:(0,Q.jsx)($,{name:`globe`}),title:xe,from:`${YJ(y)} · ${e.folder?`folder ${oo({...e,title:void 0})}`:so(e)}`,fromTitle:e.folder??e.url,browse:{label:`Browse`,hint:`Scroll, click and move between pages`},pairHint:`Pick any part of the page to ask the agent to change it, or to leave a note on it.`,pairBand:(0,Q.jsxs)(Q.Fragment,{children:[Me?`Pairing with ${Me}: click any part of the page to ask ${Me} to change it, or to leave a note.`:`Click any part of the page to leave a note on it or ask an agent to change it.`,` `,`Links don't open; switch to Browse to move around.`,Me?` ${BV(Ne,Me)}`:``]}),band:re&&(0,Q.jsx)(`div`,{className:`pair-band is-changed`,role:`status`,children:`The site's files changed: reloaded where you were.`}),controls:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`pair-segments`,role:`group`,"aria-label":`Width`,children:[(0,Q.jsx)(`button`,{className:_?``:`is-on`,"aria-pressed":!_,onClick:()=>v(!1),"aria-label":`Desktop width`,title:`Desktop width`,children:(0,Q.jsx)($,{name:`desktop`})}),(0,Q.jsx)(`button`,{className:_?`is-on`:``,"aria-pressed":_,onClick:()=>v(!0),"aria-label":`Phone width`,title:`Phone width (${HJ}px)`,children:(0,Q.jsx)($,{name:`phone`})})]}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:_e,"aria-label":`Reload`,title:`Reload the page`,children:(0,Q.jsx)($,{name:`sync`})}),c&&(0,Q.jsxs)(`a`,{className:`btn btn-small`,href:EJ(c,y),target:`_blank`,rel:`noreferrer`,children:[`Open in a tab`,(0,Q.jsx)($,{name:`external`})]})]}),open:z,onOpenRequest:be,onClose:i,children:[(0,Q.jsx)(`div`,{className:`site-view-body`,children:ke}),Ae.length>0&&(0,Q.jsxs)(`footer`,{className:`site-view-apart`,children:[(0,Q.jsx)(VJ,{open:z,groups:[{label:`No longer on this page`,pins:we.map(e=>({pin:e,part:e.quote,lost:`not found`,onToggle:()=>ye(e.id)}))},{label:`On other pages`,pins:le.map(e=>({pin:e,part:`${YJ(e.anchor.page)} · ${e.quote}`,onToggle:()=>ve(e)}))}].filter(e=>e.pins.length>0)}),je&&(0,Q.jsx)(`div`,{className:`site-view-apart-thread`,children:(0,Q.jsx)(uV,{inline:!0,pin:je,block:e,name:t,onClose:()=>B(null),live:Oe(je),address:h.address},je.id)})]})]})}var QJ=1280;function $J({block:e,onTitle:t,onOpen:n}){let{address:r,error:i,blocked:a}=CJ(e.id),o=(0,d.useRef)(null),s=(0,d.useRef)(null),[c,l]=(0,d.useState)({w:0,h:0}),[u,f]=(0,d.useState)(0);(0,d.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(()=>l({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]),(0,d.useEffect)(()=>{let t=t=>t.detail===e.id&&f(e=>e+1);return window.addEventListener(wJ,t),()=>window.removeEventListener(wJ,t)},[e.id]),DJ(s,r?.origin,e=>{e.type===`ready`&&t(e.title)});let p=c.w?c.w/QJ:0;return(0,Q.jsx)(`div`,{className:`site-preview`,ref:o,onDoubleClick:n,title:`Double-click to open it`,children:i||a?(0,Q.jsx)(`p`,{className:`site-preview-note`,children:i??`Load the page again to show this website.`}):r&&p>0?(0,Q.jsx)(`iframe`,{ref:s,name:`tricot-site-preview`,src:EJ(r,e.page),title:`${oo(e)}, scaled down`,sandbox:xJ,tabIndex:-1,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`,style:{width:QJ,height:c.h/p,transform:`scale(${p})`}},`${e.page}:${u}`):(0,Q.jsx)(`span`,{className:`site-preview-note`,children:`Opening the website…`})})}function eY({block:e,badges:t}){let n=$z(),[r,i]=(0,d.useState)(``),a=()=>n.openOverlay(e.id),o=e.folder?`Folder`:`Dev server`,s=e.folder?oo({...e,title:void 0}):e.url?new URL(e.url).host:``,c=r||co(e,e.page)||oo(e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`block-head block-link block-site`,children:[(0,Q.jsx)(`span`,{className:`site-icon`,"aria-hidden":!0,children:(0,Q.jsx)($,{name:`globe`})}),(0,Q.jsxs)(`div`,{className:`block-link-text`,children:[(0,Q.jsx)(eB,{className:`block-link-title`,value:e.title||c,placeholder:`Untitled`,onCommit:t=>n.updateBlock(e,{title:t})}),(0,Q.jsxs)(`span`,{className:`block-link-host`,children:[(0,Q.jsx)(FJ,{blockId:e.id}),(0,Q.jsx)(`span`,{className:`block-link-lead`,children:o}),(0,Q.jsxs)(`span`,{className:`block-link-rest`,children:[` `,`· `,s,` · `,e.page===`/`?`home page`:e.page]})]})]}),(0,Q.jsx)(`div`,{className:`block-link-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:a,title:`Open the website over the canvas, to browse it and pin notes on it`,children:`Open`})}),t]}),(0,Q.jsx)($J,{block:e,onTitle:i,onOpen:a})]})}function tY({block:e,viewing:t}){let n=$z(),{becomes:r}=sV();return t?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id),children:`Open`}),(0,Q.jsx)(`button`,{onClick:()=>n.startPin({blockId:e.id,part:{kind:`block`},quote:e.title||oo(e)}),title:`Pin this website to ${r}`,children:`Pin`})]})}function nY(e){let t=e.trim();return t?t.startsWith(`/`)||t.startsWith(`~`)?{folder:t}:{url:/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`http://${t}`}:null}function rY({toggle:e,context:t,close:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null);return Zl(!r.trim()&&!a.trim(),n,l,e),(0,Q.jsxs)(`form`,{ref:l,className:`add-link add-site nodrag nopan nowheel`,onSubmit:e=>{e.preventDefault();let i=nY(r);if(!i)return c(!0);n(),t.add({type:`site`,...i},{title:a.trim(),size:{w:520,h:420}})},onKeyDown:e=>e.key===`Escape`&&n(),children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`span`,{className:`field-label`,children:`Folder or local address`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>{i(e.target.value),c(!1)},placeholder:`~/my-site or localhost:3000`,"aria-invalid":s})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsxs)(`span`,{className:`field-label`,children:[`Title `,(0,Q.jsx)(`span`,{className:`faint`,children:`(optional)`})]}),(0,Q.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Marketing site`})]}),s&&(0,Q.jsx)(`p`,{className:`error`,children:`Give a folder on this computer, or a dev server's address such as localhost:3000.`}),(0,Q.jsx)(`p`,{className:`faint small`,children:`Shown live, from an address of its own: its scripts can't reach the board.`}),(0,Q.jsxs)(`div`,{className:`row`,children:[(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!r.trim(),children:`Add website`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:n,children:`Cancel`})]})]})}function iY(e){let{block:t}=e;return(0,d.useEffect)(()=>()=>{TJ(t.id)},[t.id]),(0,Q.jsx)(AJ,{onClose:e.onClose,children:(0,Q.jsx)(ZJ,{...e})})}var aY={type:`site`,copyText:e=>e.url??e.folder,Body:()=>null,Card:e=>(0,Q.jsx)(AJ,{children:(0,Q.jsx)(eY,{...e})}),Tools:tY,overlay:{Component:iY},opensOnPin:(e,t)=>t.anchor.kind===`site`,activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Website`,icon:`globe`,Form:rY}},oY=/^((?:[ \t]*>[ \t]?)*[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]{1,4})+)\[([ \txX])\](?=[ \t]|$)/,sY=/^(?:[ \t]*>[ \t]?)*[ \t]*(`{3,}|~{3,})(.*)$/,cY=e=>e.endsWith(`\r`)?e.slice(0,-1):e;function lY(e,t){let n=cY(e),r=oY.exec(n);if(!r)return null;let i=n.slice(r[0].length).trim();return!i&&t?null:{lead:r[1],done:r[2]===`x`||r[2]===`X`,text:i}}function uY(e){let t=e.split(`
84
+ `),n=[],r=null;return t.forEach((e,i)=>{let a=sY.exec(cY(e));if(r){a&&a[1][0]===r[0]&&a[1].length>=r.length&&!a[2].trim()&&(r=null);return}if(a&&!(a[1][0]==="`"&&a[2].includes("`"))){r=a[1];return}let o=lY(e,i===t.length-1);o&&n.push({line:i+1,...o})}),n}function dY(e){let t=uY(e);return{done:t.filter(e=>e.done).length,total:t.length}}function fY(e,t,n){let r=e.split(`
85
+ `),i=t-1;if(!Number.isInteger(i)||i<0||i>=r.length)return null;let a=lY(r[i],!1);if(!a)return null;if(a.done===n)return e;let o=a.lead.length+1;return r[i]=`${r[i].slice(0,o)}${n?`x`:` `}${r[i].slice(o+1)}`,r.join(`
86
+ `)}function pY(e,t,n){let r=uY(e).filter(e=>e.text===t.text);return r.length===0?null:fY(e,r.reduce((e,n)=>Math.abs(n.line-t.line)<Math.abs(e.line-t.line)?n:e).line,n)}function mY(e,t){let n=document.caretPositionFromPoint?.(e,t);if(n)return{node:n.offsetNode,offset:n.offset};let r=document.caretRangeFromPoint?.(e,t);return r?{node:r.startContainer,offset:r.startOffset}:null}function hY({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=(0,d.useRef)(null),c=r?.part.kind===`text`?r.part:null,l=[...t.flatMap(({pin:e,place:t})=>t&&e.anchor.kind===`text`?[{id:e.id,quote:e.quote,prefix:e.anchor.prefix,suffix:e.anchor.suffix}]:[]),...c?[{id:zB,quote:c.quote,prefix:c.prefix,suffix:c.suffix}]:[]],u=(0,d.useMemo)(()=>({mark:({node:e,children:r,...a})=>{let s=a,c=s[`data-chip`];if(c){let e=t.find(e=>e.pin.id===c)?.pin;return e?(0,Q.jsx)(RB,{pin:e,open:e.id===i,onToggle:()=>o(e.id)}):null}let l=String(s[`data-pins`]??``),u=l.split(` `).filter(e=>e&&e!==`draft`);return(0,Q.jsx)(`mark`,{className:`${a.className??``}${u.includes(i??``)?` is-open`:``}`,"data-pair-anchor":l||void 0,onClick:()=>{!n&&u.length&&window.getSelection()?.isCollapsed!==!1&&o(u[0])},children:r})}}),[t,i,o,n]);return(0,Q.jsx)(`div`,{className:`piece-scroll note-full-scroll`,children:(0,Q.jsx)(`div`,{className:`piece-sheet note-full-sheet`,children:e.text.trim()?(0,Q.jsx)(`div`,{ref:s,className:`note-full${n?` is-pointing`:``}`,"data-pin-text":``,onMouseUp:t=>{let r=s.current;if(!n||t.button!==0||!r)return;let i=window.getSelection();if(i&&!i.isCollapsed&&i.rangeCount){let t=i.getRangeAt(0);if(!r.contains(t.commonAncestorContainer))return;let n=QB(r,t);if(!n)return;i.removeAllRanges(),a({blockId:e.id,part:n,quote:n.quote});return}let o=mY(t.clientX,t.clientY);if(!o||!r.contains(o.node)||(o.node.parentElement?.closest(`[data-pin-skip]`)??null))return;let{text:c,at:l}=tV(r),u=nB(c,l(o.node,o.offset)),d=u&&Uo(c,u.start,u.end);d&&a({blockId:e.id,part:{kind:`text`,...d},quote:d.quote})},title:n?`Click a sentence, or select any words, to ask about them`:void 0,children:(0,Q.jsx)(Qb,{rehypePlugins:[[UB,{marks:l,ids:!0}]],components:u,children:e.text})}):(0,Q.jsx)(`p`,{className:`note-full-empty placeholder`,children:`This note is empty.`})})})}function gY({block:e,name:t,version:n,pinId:r,onClose:i}){let{done:a,total:o}=dY(e.text),s=e.title||H(qo(e.text.split(`
87
+ `).find(e=>e.trim())??``).trim(),60)||`Note`,c=[o?`Note · ${a} of ${o} done`:`Note`,`changed by ${e.updatedBy.name} ${ex(e.updatedAt)}`].join(` · `);return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`note`,className:`note-full-view`,label:`Note ${s}`,icon:(0,Q.jsx)($,{name:`note`}),title:s,from:c,browse:{label:`Read`,hint:`Read it, and select words to copy`},it:`the note`,point:`click a sentence, or select any words,`,does:`rewrites the note`,example:`say it plainly, say`,body:e=>(0,Q.jsx)(hY,{...e}),edit:{hint:`Edit its Markdown by hand (or double-click it while reading)`,label:`Markdown`,placeholder:`Write in Markdown`,of:e=>e.text,patch:e=>({text:e}),preview:e=>e.trim()?(0,Q.jsx)(Qb,{children:e}):(0,Q.jsx)(`p`,{className:`placeholder`,children:`Nothing written yet.`})},onClose:i})}function _Y({block:e,placed:t}){let n=$z(),r=tU(e.id),i=aU(n.draft,e.id,`text`),a=(0,d.useRef)({x:0,y:0}),o=[...t.flatMap(({pin:e,place:t})=>t&&e.anchor.kind===`text`?[{id:e.id,quote:e.quote,prefix:e.anchor.prefix,suffix:e.anchor.suffix}]:[]),...i?[{id:zB,quote:i.quote,prefix:i.prefix,suffix:i.suffix}]:[]];return r.editing?(0,Q.jsx)(`textarea`,{autoFocus:!0,className:`block-editor nodrag`,defaultValue:e.text,placeholder:`Markdown`,onBlur:t=>r.finish(t.currentTarget.value,e.text,t=>n.updateBlock(e,{text:t})),onKeyDown:e=>{e.key===`Escape`&&(r.cancel(),e.currentTarget.blur())}}):e.text.trim()?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`block-note nopan`,"data-pin-text":``,"data-block-id":e.id,onDoubleClick:r.start,onMouseDown:e=>a.current={x:e.clientX,y:e.clientY},onClick:e=>!iU(e)&&rU(e,a.current)&&e.stopPropagation(),children:(0,Q.jsx)(Qb,{rehypePlugins:[[UB,{marks:o,focus:n.focusPin}]],components:nU,onTick:n.readOnly?void 0:(t,r)=>{let i=fY(e.text,t,r);if(i===null||i===e.text)return;let a=uY(e.text).find(e=>e.line===t);n.updateBlock(e,{text:i},a&&(e=>{let t=e.type===`note`?pY(e.text,a,r):null;return t===null||e.type!==`note`||t===e.text?null:{text:t}}))},children:e.text})}),(0,Q.jsx)(YB,{block:e,placed:t})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`block-note`,onDoubleClick:r.start,children:(0,Q.jsx)(`p`,{className:`placeholder`,children:`Double-click to write`})}),(0,Q.jsx)(YB,{block:e,placed:t})]})}function vY({block:e}){let{done:t,total:n}=dY(e.text);return n===0?null:(0,Q.jsxs)(`span`,{className:`note-progress`,title:`${t} of ${n} tasks done`,children:[t,` of `,n,` done`]})}function yY({block:e,viewing:t}){let n=$z();return(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to read it or pair with an agent on its words (Enter)`,children:`Open`})}var bY={type:`note`,copyText:e=>e.text,Body:_Y,Head:vY,ownPins:!0,Tools:yY,overlay:{Component:gY,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Note`,icon:`note`,add:()=>({content:{type:`note`,text:``}})},clips:{accepts:e=>e.text!==``,fallback:!0,add:(e,t,n)=>t.add({type:`note`,text:e.text},{at:n}),useDrop:e=>sH(e,{matches:Wz,what:`the text`,as:`a Note`})},added:(e,t)=>!e.text&&t.edit(e.id)};function xY(e,t,n){let r=t=>H(e.rows[t]?.[0]||`row ${t+1}`,40),i=t=>H(e.columns[t]||`column ${t+1}`,40),a=(e,t)=>e===t?e:`${e}–${t}`;if(t&&n){if(t[0]===t[1]&&n[0]===n[1]){let a=`${i(n[0])}: ${H(e.rows[t[0]][n[0]],80)||`(empty)`}`;return n[0]===0?a:`${r(t[0])} · ${a}`}return`${a(r(t[0]),r(t[1]))} · ${a(i(n[0]),i(n[1]))}`}return t?`${a(r(t[0]),r(t[1]))} ${t[0]===t[1]?`row`:`rows`}`:n?`${a(i(n[0]),i(n[1]))} ${n[0]===n[1]?`column`:`columns`}`:`the whole table`}function SY(e,[t,n]){let r=!e.rows||t>=e.rows[0]&&t<=e.rows[1];return(!e.columns||n>=e.columns[0]&&n<=e.columns[1])&&(t<0?!e.rows:r)}function CY(e){let t=$z(),n=nV(),[r,i]=(0,d.useState)(null),a=(0,d.useRef)(r);a.current=r;let o=t=>{let{rows:n,columns:r}=wY(t);return n?{blockId:e.id,part:{kind:`cells`,rows:n,columns:r},quote:xY(e,n,r),cells:{rows:n,columns:r}}:{blockId:e.id,part:{kind:`cells`,columns:r},quote:xY(e,void 0,r)}},s=e=>{a.current=e,i(e)},c=()=>{let e=a.current;if(!e)return;let r=o(e),i=e.from[0]===e.to[0]&&e.from[1]===e.to[1],c=()=>{s(null),t.startPin(r)};i?n.later(c):c()};return{drag:r,start:e=>r=>{let i=r.target;t.readOnly||r.button!==0||iU(r)||i.closest(`a, input, button, textarea`)||(r.preventDefault(),n.cancel(),s({from:e,to:e}),document.addEventListener(`mouseup`,c,{once:!0}))},enter:e=>()=>{let t=a.current;t&&t.from[0]<0==e[0]<0&&s({...t,to:e})},cancel:()=>{n.cancel(),s(null)}}}function wY({from:e,to:t}){let n=[Math.min(e[1],t[1]),Math.max(e[1],t[1])];return e[0]<0?{columns:n}:{rows:[Math.min(e[0],t[0]),Math.max(e[0],t[0])],columns:n}}function TY(e){let{block:t,selected:n,placed:r,pinnable:i=!0}=e,a=$z(),o=n&&!a.readOnly,s=CY(t),c=aU(a.draft,t.id,`cells`),l=r.flatMap(({place:e})=>e?.kind===`cells`?[e]:[]),u=e=>{if(!i)return{};let t=s.drag?SY(wY(s.drag),e):!!(c&&SY(c,e)),n=l.some(t=>SY(t,e));return{className:t?`pin-cell is-draft`:n?`pin-cell is-linked`:void 0,"data-pin-draft":t?``:void 0,onMouseDown:s.start(e),onMouseEnter:s.enter(e),onDoubleClickCapture:s.cancel,onClick:e=>!a.readOnly&&!iU(e)&&e.stopPropagation()}},d=(e,n)=>a.updateBlock(t,{columns:e,rows:n}),f=(e,n,r)=>{e<0?d(t.columns.map((e,t)=>t===n?r:e),t.rows):d(t.columns,t.rows.map((t,i)=>i===e?t.map((e,t)=>t===n?r:e):t))},p=()=>d([...t.columns,`Column ${t.columns.length+1}`],t.rows.map(e=>[...e,``])),m=e=>d(t.columns.filter((t,n)=>n!==e),t.rows.map(t=>t.filter((t,n)=>n!==e)));return(0,Q.jsxs)(`div`,{className:`block-table-wrap`,children:[(0,Q.jsxs)(`table`,{className:`block-table nopan`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[t.columns.map((e,n)=>(0,Q.jsxs)(`th`,{...u([-1,n]),children:[(0,Q.jsx)(eB,{value:e,placeholder:`Column`,display:(0,Q.jsx)($b,{children:e}),onCommit:e=>f(-1,n,e)}),o&&t.columns.length>1&&(0,Q.jsx)(`button`,{className:`cell-remove nodrag`,onClick:()=>m(n),title:`Remove column`,"aria-label":`Remove column`,children:(0,Q.jsx)($,{name:`x`})})]},n)),o&&(0,Q.jsx)(`th`,{className:`table-add-col`,children:(0,Q.jsx)(`button`,{className:`nodrag`,onClick:p,title:`Add column`,"aria-label":`Add column`,children:(0,Q.jsx)($,{name:`plus`})})})]})}),(0,Q.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,Q.jsxs)(`tr`,{children:[e.map((e,t)=>(0,Q.jsx)(`td`,{...u([n,t]),children:(0,Q.jsx)(eB,{value:e,placeholder:``,display:(0,Q.jsx)($b,{children:e}),onCommit:e=>f(n,t,e)})},t)),o&&(0,Q.jsx)(`td`,{className:`table-row-remove`,children:(0,Q.jsx)(`button`,{className:`nodrag`,onClick:()=>d(t.columns,t.rows.filter((e,t)=>t!==n)),title:`Remove row`,"aria-label":`Remove row`,children:(0,Q.jsx)($,{name:`x`})})})]},n))})]}),(o||t.rows.length===0&&!a.readOnly)&&(0,Q.jsxs)(`button`,{className:`block-add nodrag`,onClick:()=>d(t.columns,[...t.rows,t.columns.map(()=>``)]),children:[(0,Q.jsx)($,{name:`plus`}),` Row`]})]})}var EY=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function DY(e){let t=e.target.closest(`[data-cell]`);if(!t?.dataset.cell)return null;let[n,r]=t.dataset.cell.split(`,`).map(Number);return[n,r]}function OY({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=(0,d.useMemo)(()=>t.flatMap(({pin:e,place:t})=>t?.kind===`cells`?[{id:e.id,range:t}]:[]),[t]),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(c);u.current=c;let f=c?dB(c.from,c.to):r?.part.kind===`cells`?r.part:null,p=t=>({blockId:e.id,part:{kind:`cells`,...t},quote:xY(e,t.rows,t.columns)});(0,d.useEffect)(()=>{if(!c)return;let e=()=>{let e=u.current;l(null),e&&a(p(dB(e.from,e.to)))};return document.addEventListener(`mouseup`,e),()=>document.removeEventListener(`mouseup`,e)},[!!c]);let m=(e,t)=>{let n=s.filter(({range:t})=>fB(t,e)).map(({id:e})=>e),r=!!(f&&fB(f,e)),a=[...n,...r?[JV]:[]].join(` `),o=[t,r?`pin-cell is-draft`:n.length?`pin-cell is-linked`:``,n.includes(i??``)&&`is-open`];return{"data-cell":e.join(`,`),"data-pair-anchor":a||void 0,"data-pin-draft":r?``:void 0,className:o.filter(Boolean).join(` `)||void 0}},h=e=>{if(!n||e.button!==0)return;let t=DY(e);!t||t[0]<0&&t[1]<0||e.target.closest(`a`)||(e.preventDefault(),l({from:t,to:t}))},g=e=>{let t=u.current,n=t&&DY(e);t&&n&&(n[0]!==t.to[0]||n[1]!==t.to[1])&&l({...t,to:n})},_=e=>{if(n||window.getSelection()?.isCollapsed===!1)return;let t=DY(e),r=t&&s.find(({range:e})=>fB(e,t));r&&o(r.id)},v=n?`Click a cell, or drag over several; drag over the columns’ names or the rows’ numbers for whole columns or rows`:void 0;return(0,Q.jsxs)(`div`,{className:`piece-scroll table-full-scroll`,children:[(0,Q.jsx)(`div`,{className:`piece-sheet table-full-sheet`,children:e.columns.length===0?(0,Q.jsx)(`p`,{className:`table-full-empty placeholder`,children:`This table is empty.`}):(0,Q.jsxs)(`table`,{className:`block-table table-full${n?` is-pointing`:``}`,onMouseDown:h,onMouseOver:g,onClick:_,title:v,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{className:`table-full-corner`,"aria-hidden":!0}),e.columns.map((e,t)=>(0,Q.jsx)(`th`,{scope:`col`,...m([-1,t]),children:(0,Q.jsx)($b,{children:e})},t))]})}),(0,Q.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`row`,...m([t,-1],`table-full-num`),children:t+1}),e.map((e,n)=>(0,Q.jsx)(`td`,{...m([t,n]),children:(0,Q.jsx)($b,{children:e})},n))]},t))})]})}),t.length>0&&(0,Q.jsx)(`div`,{className:`table-full-chips`,children:t.map(({pin:t})=>(0,Q.jsx)(RB,{pin:t,open:t.id===i,part:Zo(t,e),onToggle:()=>o(t.id)},t.id))})]})}function kY({block:e,name:t,version:n,pinId:r,onClose:i}){let a=`Table · ${EY(e.rows.length,`row`)}, ${EY(e.columns.length,`column`)}`;return(0,Q.jsx)(ZV,{block:e,name:t,version:n,pinId:r,part:`table`,className:`table-full-view`,label:`Table ${e.title??``}`.trim(),icon:(0,Q.jsx)($,{name:`table`}),title:e.title||`Table`,from:a,browse:{label:`Read`,hint:`Read it, and select text to copy`},it:`the table`,point:`click a cell, or drag over a range, a row or a column,`,does:`changes the table`,example:`make it 3, say`,body:e=>(0,Q.jsx)(OY,{...e}),edit:{hint:`Edit its cells, and add or remove rows and columns, by hand (or double-click it while reading)`,live:({block:e})=>(0,Q.jsx)(`div`,{className:`piece-scroll`,children:(0,Q.jsx)(`div`,{className:`piece-sheet piece-edit-sheet table-edit-sheet`,children:(0,Q.jsx)(TY,{block:e,selected:!0,placed:[],pinnable:!1})})})},onClose:i})}function AY({block:e,viewing:t}){let n=$z();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>n.openOverlay(e.id,{version:t??void 0}),title:`Open it full screen, to read it all or pair with an agent on its cells, rows and columns (Enter)`,children:`Open`}),(0,Q.jsx)(`button`,{onClick:()=>n.perform(t=>X.deriveBlock(e.id,t)),title:`Make a bar chart of this table's numbers, next to it`,children:`Make a chart`})]})}function jY(e,t,n){if(!e.cells)return e;let{rows:r,columns:i}=e.cells,a=n===`rows`?{kind:`cells`,rows:r}:n===`columns`?{kind:`cells`,columns:i}:{kind:`cells`,rows:r,columns:i};return{...e,part:a,quote:xY(t,a.rows,a.columns)}}function MY(e){return e.kind===`cells`?e.rows&&e.columns?`cells`:e.rows?`rows`:`columns`:`cells`}function NY({draft:e,block:t,onChange:n}){if(!e.cells)return null;let r=MY(e.part),i=e=>!!(e&&e[0]!==e[1]),a=[{value:`cells`,label:i(e.cells.rows)||i(e.cells.columns)?`Cells`:`Cell`},{value:`rows`,label:i(e.cells.rows)?`Rows`:`Row`},{value:`columns`,label:i(e.cells.columns)?`Columns`:`Column`}];return(0,Q.jsx)(`div`,{className:`pin-scope`,role:`radiogroup`,"aria-label":`Pin`,children:a.map(i=>(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===i.value,className:r===i.value?`is-on`:void 0,onClick:()=>n(jY(e,t,i.value)),children:i.label},i.value))})}var PY={type:`table`,copyText:e=>Yz(e.columns,e.rows),Body:TY,Tools:AY,PinScope:NY,overlay:{Component:kY,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Table`,icon:`table`,add:()=>({content:{type:`table`,columns:[`Column 1`,`Column 2`],rows:[[``,``]]}})}};function FY(e,t,n){let r=e=>{let r=t.indexOf(n(e));return r===-1?t.length:r};return e.map((e,t)=>({item:e,index:t})).sort((e,t)=>r(e.item)-r(t.item)||e.index-t.index).map(({item:e})=>e)}var IY=()=>[bY,PY,Mq,aW,qq,CW,eU,aH,hJ,aY],LY,RY=[];function zY(){return LY??=[...IY(),...RY]}function BY(e){let t=zY().find(t=>t.type===e);if(!t)throw Error(`No web half for block type "${e}".`);return t}var VY=[`note`,`table`,`diagram`,`code`,`chart`,`image`,`link`,`comparison`];function HY(){return FY(zY().filter(e=>e.menu),VY,e=>e.type)}var UY=140,WY=16,GY=120;function KY({icon:e,label:t,title:n,name:r,menuLabel:i,className:a,rows:o,autoFocus:s,onButtonKeyDown:c,children:l,after:u}){let{open:f,setOpen:p,close:m,root:h,button:g,menu:_,onKeyDown:v}=lu(),y=qY(f);(0,d.useEffect)(()=>{f&&_.current?.querySelector(`[data-menu-start]`)?.focus()},[f,_]);let b=e=>{if(e.key!==`Escape`)return v(e);e.stopPropagation(),m(!0)},x=Math.min(WY,GY/Math.max(1,o-1));return(0,Q.jsxs)(`div`,{className:a?`toolbar-add ${a}`:`toolbar-add`,ref:h,children:[(0,Q.jsxs)(`button`,{ref:g,type:`button`,onClick:()=>f?m(!0):p(!0),onKeyDown:c,"aria-haspopup":`menu`,"aria-expanded":f,"aria-label":r,title:n,autoFocus:s,children:[(0,Q.jsx)(`span`,{className:`toolbar-add-plus`,"aria-hidden":!0,children:(0,Q.jsx)($,{name:e})}),(0,Q.jsx)(`span`,{className:`toolbar-add-label`,children:t}),(0,Q.jsx)($,{name:`chevron-down`,className:`toolbar-add-chevron`})]}),(f||y)&&(0,Q.jsx)(`div`,{className:`menu-panel add-menu nodrag nopan nowheel${f?``:` is-leaving`}`,role:f?`menu`:void 0,"aria-label":f?i:void 0,"aria-hidden":!f||void 0,inert:!f,ref:f?_:void 0,onKeyDown:f?b:void 0,children:(0,Q.jsx)(`div`,{className:`add-menu-core`,role:`none`,children:l({open:f,close:m,enter:e=>({"--enter-delay":`${Math.round(e*x)}ms`})})})}),u]})}function qY(e){let[t,n]=(0,d.useState)(e),[r,i]=(0,d.useState)(!1);return e!==t&&(n(e),i(!e&&!JY())),(0,d.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),UY);return()=>clearTimeout(e)},[r]),r}var JY=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function YY({owner:e,context:t,toggleOf:n,setForm:r,addGroup:i}){let a=(0,d.useRef)(new Map),o=HY().filter(t=>!t.menu.only||t.menu.only===e);return(0,Q.jsx)(KY,{icon:`plus`,label:`Add`,title:`Add to the canvas`,menuLabel:`Add to the canvas`,rows:o.length+2,after:HY().flatMap(e=>e.menu&&`pick`in e.menu?[(0,Q.jsx)(`input`,{ref:t=>void a.current.set(e.type,t),type:`file`,accept:e.menu.pick.accept,multiple:!0,hidden:!0,onChange:n=>{e.files.add([...n.target.files??[]],t),n.target.value=``}},e.type)]:[]),children:({open:e,close:s,enter:c})=>{let l=e=>()=>{s(!0),e()},u=(t,n,r,i,a,o)=>(0,Q.jsx)(`button`,{ref:e?o:void 0,type:`button`,role:e?`menuitem`:void 0,tabIndex:-1,className:`menu-item is-line add-menu-item`,style:c(t),onClick:a,children:(0,Q.jsxs)(`span`,{className:`add-menu-row`,children:[(0,Q.jsx)($,{name:r,className:`add-menu-icon`}),i]})},n);return(0,Q.jsxs)(Q.Fragment,{children:[o.map((e,i)=>{let o=e.menu;return`add`in o?u(i,e.type,o.icon,o.label,l(()=>{let{content:e,title:n}=o.add();t.add(e,{title:n})})):`Form`in o?u(i,e.type,o.icon,o.label,l(()=>r(t=>t?.type===e.type?o.toggles?null:t:{type:e.type})),n(e.type)):u(i,e.type,o.icon,o.label,l(()=>a.current.get(e.type)?.click()))}),(0,Q.jsx)(`div`,{role:`separator`,className:`menu-rule add-menu-rule`,style:c(o.length)}),u(o.length+1,`group`,`group`,`Group`,l(()=>void i()))]})}})}nc.request;var XY=48,ZY=[{label:`Architecture view`,text:`Get me an architecture view of the project`},{label:`What's left to build`,text:`What's left to build?`},{label:`Risks and open questions`,text:`List the risks and open questions`},{label:`Timeline so far`,text:`Draw a timeline of the project so far`}],QY=[/^(?:please|pls|hey|hi|ok|okay|so|now|and)\b[\s,:]*/i,/^(?:can|could|would|will) (?:you|we|someone|an agent)\b\s*/i,/^(?:i'd|i would|we'd|we would) (?:like|love)\b(?: to (?:see|have|get)\b)?\s*/i,/^(?:i|we) (?:want|need)\b(?: to (?:see|have|get)\b)?\s*/i,/^let'?s\b\s*/i,/^help (?:me|us)\b(?: to\b)?\s*/i],$Y=/^(?:get|give|show|make|find|bring|fetch|draw|build|create|generate|write|produce|prepare|sketch|draft|compile|summari[sz]e|outline|describe|list|explain|map(?: out)?|put together|lay out|pull together|add|do)\b\s*(?:(?:me|us)\b\s*)?/i,eX=/^(?:a|an|the|some)\b\s+/i,tX=/\s+(?:of|for|on|about|in) (?:the|this|our) (?:project|board|app|codebase|repo|work)(?=$|[\s,.;:!?])/gi,nX=/(?:[\s,.;:!?]+|\s+(?:please|for (?:me|us)|thanks|thank you))+$/i;function rX(e,t=[]){let n=Cc(e,t,t).replace(/\s+/g,` `).trim(),r=n.split(/(?<=[.?!])\s/)[0],i=r;for(let e=``;e!==i;){e=i;for(let e of QY)i=i.replace(e,``)}if(i=i.replace($Y,``).replace(eX,``).replace(tX,``).replace(nX,``).trim(),i||=r.replace(/[\s.?!]+$/,``)||n,i=i.charAt(0).toUpperCase()+i.slice(1),i.length<=XY)return i;let a=i.slice(0,47),o=a.lastIndexOf(` `);return`${(o>XY/2?a.slice(0,o):a).replace(/[\s,.;:-]+$/,``)}…`}function iX(e,t){if(!t.pageId)return{canvas:e.canvas};let n=e.pages?.find(e=>e.id===t.pageId);return n&&{canvas:n.canvas,page:n}}function aX(e,t){return iX(e,t)?.canvas.groups.find(e=>e.id===t.groupId)}function oX(e){return e.status===`open`||e.status===`working`}function sX(e,t){return e.requests?.findLast(e=>e.groupId===t)}var cX=`tricot:open-thread`;function lX(e,t){window.dispatchEvent(new CustomEvent(cX,{detail:{id:e,thread:t}}))}function uX({board:e,name:t}){let n=RI(),[r,i,a]=zF(e=>e.transform),o=zF(e=>e.width),s=zF(e=>e.height),c=e=>e.x*a+r>o||e.y*a+i>s||(e.x+e.w)*a+r<0||(e.y+e.h)*a+i<0,l=(e.requests??[]).filter(e=>oX(e)&&!e.pageId).flatMap(t=>{let r=e.canvas.groups.find(e=>e.id===t.groupId);return r?c(r)?[{request:t,show:()=>void n.fitView({nodes:[{id:r.id}],duration:400,maxZoom:1,padding:.2})}]:[]:[{request:t}]});if(l.length===0)return null;let u=l.length-3;return(0,Q.jsxs)(`div`,{className:`ask-pending`,role:`status`,children:[u>0&&(0,Q.jsxs)(`span`,{className:`ask-pending-more`,children:[u,` more waiting`]}),l.slice(-3).map(({request:n,show:r})=>(0,Q.jsx)(dX,{board:e,request:n,name:t,onShow:r},n.id))]})}function dX(e){let{board:t,request:n,name:r,empty:i,readOnly:a,onShow:o}=e,[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),f=aX(t,n),p=e.title??(0,Q.jsx)(`span`,{className:`request-title`,children:f?.title??rX(n.text,n.mentions)}),m=n.takenBy,h=n.status===`open`?`waiting for ${n.mentions?.length?G(n.mentions):`an agent`}`:n.status===`working`?`${m.name} is working on it`:n.status===`done`?`by ${m.name}`:`cancelled`,g=[`${n.by.name} asked ${ex(n.at)}: “${n.text}”`,n.status===`done`&&`${m.name} finished it ${ex(n.doneAt)}${n.note?`: “${n.note}”`:``}`,n.status===`cancelled`&&`Cancelled ${ex(n.doneAt)}`].filter(Boolean).join(`
88
+ `);return(0,Q.jsxs)(`span`,{className:`request-chip is-${n.status}`,children:[(0,Q.jsxs)(`span`,{className:`request-pill`,title:g,children:[n.status===`open`&&(0,Q.jsx)(`span`,{className:`request-dot`,"aria-hidden":!0}),n.status===`working`&&(0,Q.jsx)(`span`,{className:`looking-mark`,"aria-hidden":!0,children:m.name.charAt(0).toUpperCase()}),n.status===`done`&&(0,Q.jsx)(ix,{actor:m,showName:!1,title:g}),(0,Q.jsxs)(`span`,{className:`request-text`,children:[p,` · asked by ${n.by.name} · ${h}`]}),n.status===`working`&&(0,Q.jsx)(sT,{state:`casting`})]}),o&&(0,Q.jsx)(`button`,{type:`button`,className:`request-action nodrag`,onClick:o,children:`Show`}),oX(n)&&!a&&(0,Q.jsx)(`button`,{type:`button`,className:`request-action nodrag`,disabled:s,onClick:()=>{c(!0),X.cancelRequest(t.id,n.id,r).then(()=>u(null),e=>u(e.message)).finally(()=>c(!1))},title:`Stop this request; anything added so far stays`,children:`Cancel`}),l&&(0,Q.jsx)(`span`,{className:`request-error`,role:`alert`,children:l}),n.status===`working`&&i&&(0,Q.jsxs)(`span`,{className:`request-ghost`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{}),(0,Q.jsx)(`span`,{}),(0,Q.jsx)(`span`,{})]})]})}function fX({thread:e,title:t}){let n=`Started by ${e.startedBy.name} ${ex(e.startedAt)}: “${e.title}”`;return(0,Q.jsxs)(`span`,{className:`request-chip is-done is-thread`,children:[(0,Q.jsxs)(`span`,{className:`request-pill`,title:n,children:[(0,Q.jsx)($,{name:`thread`}),(0,Q.jsxs)(`span`,{className:`request-text`,children:[t,` · from a thread`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`request-action nodrag`,onClick:()=>lX(e.id,e),title:`Open the thread these came from`,children:`Open thread`})]})}function pX(e){return(0,Q.jsx)(Q.Fragment,{children:mx().requestCards(e)})}var mX=`tricot:focus-block`,hX=null;function gX(e,t){hX={kind:e,id:t,at:Date.now()},window.dispatchEvent(new Event(mX))}var _X=e=>gX(`block`,e),vX=e=>gX(`pin`,e);function yX(e,t,n){let[r,i]=(0,d.useState)(0);(0,d.useEffect)(()=>{let e=()=>i(e=>e+1);return window.addEventListener(mX,e),()=>window.removeEventListener(mX,e)},[]),(0,d.useEffect)(()=>{hX&&Date.now()-hX.at>1e4&&(hX=null);let r=hX;if(!r||!(r.kind===`block`?e.blocks.some(e=>e.id===r.id):e.pins.some(e=>e.id===r.id)))return;let i=()=>{if(r.kind===`block`)return t(r.id);let i=e.pins.find(e=>e.id===r.id);return!i||n(i)},a,o=e=>{a=setTimeout(()=>{hX===r&&(i()||e===0?hX=null:o(e-1))},100)};return o(30),()=>clearTimeout(a)},[r,e,t,n])}function bX(e){let[t,n]=(0,d.useState)(!1);return{nodes:(0,d.useMemo)(()=>t?e.map(e=>e.type===`frame`?{...e,selectable:!1}:e):e,[e,t]),onPointerDownCapture:e=>{let t=e.target.classList.contains(`react-flow__pane`);e.button===0&&(t||e.shiftKey)&&n(!0)},onPointerUpCapture:()=>n(!1),onPointerCancelCapture:()=>n(!1)}}function xX(e,t,n){(0,d.useEffect)(()=>{if(!n)return;let r=n=>{if(!n.clipboardData||Vz(n.target)||window.getSelection()?.isCollapsed===!1)return;let r=new Set(t),i=e.groups.filter(e=>r.has(e.id)),a=e.blocks.filter(e=>r.has(e.id)||e.groupId&&i.some(t=>t.id===e.groupId));(a.length||i.length)&&(n.preventDefault(),n.clipboardData.setData(Gz,qz([...i,...a].map(e=>e.id))),n.clipboardData.setData(`text/plain`,Xz(zY(),a)))};return document.addEventListener(`copy`,r),()=>document.removeEventListener(`copy`,r)},[e,t,n])}function SX(e){let t=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{let n=n=>void(t.current=!!e.current?.contains(n.target)),r=()=>void(t.current=!1),i=()=>void setTimeout(r);return window.addEventListener(`dragstart`,n,!0),window.addEventListener(`dragend`,r,!0),window.addEventListener(`drop`,i,!0),window.addEventListener(`pointerdown`,r,!0),()=>{window.removeEventListener(`dragstart`,n,!0),window.removeEventListener(`dragend`,r,!0),window.removeEventListener(`drop`,i,!0),window.removeEventListener(`pointerdown`,r,!0)}},[e]),t}function CX({wrapper:e,flow:t,context:n,readOnly:r,clips:i,openForm:a,pasteBlocks:o}){let s=SX(e),c=zY().flatMap(e=>[...e.files?.useDrop?[e.files.useDrop(!r)]:[],...e.clips?.useDrop?[e.clips.useDrop(!r&&i)]:[]]);(0,d.useEffect)(()=>{let e=e=>{if(r||Vz(e.target))return;let t=e.clipboardData,s=t&&Jz(t);if(s){if(!i)return;e.preventDefault();let r=zz(t),a=Bz(zY(),r);o(s).then(e=>{!e&&a&&a.clips.add(r,n)});return}let c=[...t?.files??[]],l=zY().find(e=>e.files?.paste&&c.some(e.files.accepts));if(l){e.preventDefault(),l.files.add(c.filter(l.files.accepts),n);return}let u=t?.getData(`text/plain`).trim()??``;for(let t of HY()){let n=t.menu&&`Form`in t.menu?t.menu.paste?.(u):null;if(n){e.preventDefault(),a(t.type,n);return}}if(!t||!i||c.length)return;let d=zz(t),f=Bz(zY(),d);f&&(e.preventDefault(),f.clips.add(d,n))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)});let l=e=>!r&&i&&!s.current&&!Vz(e.target);return{dropProps:{onDragOver:e=>{if(r||s.current)return;let t=Hz(e);(t.includes(`Files`)||l(e)&&(Uz(t)||Wz(t)))&&e.preventDefault()},onDragEnter:e=>{s.current||c.forEach(t=>t.onDragEnter(e))},onDragLeave:e=>c.forEach(t=>t.onDragLeave(e)),onDrop:e=>{for(let e of c)e.clear();if(r||s.current)return;let i=t.screenToFlowPosition({x:e.clientX,y:e.clientY}),a=[...e.dataTransfer.files];if(a.length){e.preventDefault();for(let e of zY()){let t=e.files?a.filter(e.files.accepts):[];e.files&&t.length&&e.files.add(t,n,i)}return}if(!l(e))return;let o=zz(e.dataTransfer),u=Bz(zY(),o);u&&(e.preventDefault(),u.clips.add(o,n,i))}},overlays:c.map((e,t)=>(0,Q.jsx)(d.Fragment,{children:e.overlay},t))}}function wX(){let e=zF(e=>e.userSelectionActive);return(0,Q.jsx)(XF,{position:`bottom-left`,className:e?`canvas-hint is-lit`:`canvas-hint`,children:`Hold Space to move`})}function TX(e){let{block:t,viewing:n,onView:r,onDelete:i}=e,[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=(0,d.useRef)(null),g=(0,d.useRef)(null);Zl(a,(0,d.useCallback)(()=>o(!1),[]),m),(0,d.useEffect)(()=>{if(!a)return;let e=!0;return X.blockVersions(t.id).then(t=>e&&(c(t.versions),u(null)),t=>e&&u(t.message)),()=>{e=!1}},[a,t.id,t.rev,t.versionCount]),(0,d.useEffect)(()=>{if(n===null)return;let e=!0;return X.blockVersions(t.id).then(t=>e&&!t.versions.some(e=>e.rev===n)&&r(null),()=>void 0),()=>{e=!1}},[t.id,t.versionCount]),(0,d.useEffect)(()=>{if(g.current===null||!h.current)return;let e=[...h.current.querySelectorAll(`.version-delete`)];(e[Math.min(g.current,e.length-1)]??h.current.querySelector(`.version-item`))?.focus(),g.current=null},[s]);let _=e=>{e===t.rev?(r(null),o(!1)):X.blockVersion(t.id,e).then(e=>{r(e),o(!1)},e=>u(e.message))},v=s?.filter(e=>e.rev!==t.rev).length??0,y=async e=>{if(!i||f)return;let t=h.current?[...h.current.querySelectorAll(`.version-delete`)].indexOf(document.activeElement):-1;p(!0);let a=await i(e);p(!1),a&&(n!==null&&(e===void 0||e===n)&&r(null),e===void 0||v===1?(m.current?.closest(`.react-flow__node`)?.focus(),o(!1)):(t>=0&&(g.current=t),c(t=>t&&t.filter(t=>t.rev!==e))))};return t.versionCount?(0,Q.jsxs)(`span`,{className:`block-version-wrap nodrag nopan`,ref:m,onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`button`,{className:`block-version${n===null?``:` is-viewing`}`,onClick:()=>o(!a),"aria-expanded":a,title:`Version ${t.rev}. ${t.versionCount} earlier ${t.versionCount===1?`version`:`versions`}: click to see them`,children:[`v`,n??t.rev]}),a&&(0,Q.jsxs)(`div`,{className:`menu-panel version-menu nowheel`,role:`menu`,"aria-label":`Earlier versions of this block`,ref:h,children:[(0,Q.jsx)(`p`,{className:`version-menu-title`,children:`Earlier versions of this block`}),s?.map(e=>{let r=e.rev===t.rev,a=n===null?r:e.rev===n;return(0,Q.jsxs)(`div`,{className:`version-row`,role:`none`,children:[(0,Q.jsxs)(`button`,{role:`menuitem`,className:`menu-item version-item${a?` is-shown`:``}`,"aria-current":a||void 0,title:e.change?`${e.by.name} ${e.change}`:void 0,onClick:()=>_(e.rev),children:[(0,Q.jsxs)(`strong`,{children:[`v`,e.rev,` · `,r?`now`:ex(e.at)]}),(0,Q.jsx)(`span`,{children:e.by.name})]}),i&&!r&&(0,Q.jsx)(`button`,{role:`menuitem`,className:`version-delete`,disabled:f,"aria-label":`Delete version ${e.rev}`,title:`Delete v${e.rev}`,onClick:()=>void y(e.rev),children:(0,Q.jsx)($,{name:`x`})})]},e.rev)}),i&&v>0&&(0,Q.jsxs)(`div`,{className:`version-menu-foot`,role:`none`,children:[(0,Q.jsxs)(`span`,{children:[v,` earlier`]}),(0,Q.jsx)(`button`,{role:`menuitem`,className:`version-delete-all`,disabled:f,onClick:()=>void y(),children:v===1?`Delete the earlier version`:`Delete all earlier versions`})]}),(0,Q.jsxs)(`p`,{className:`version-menu-note`,children:[s||l?`Click one to view it; Restore makes it current.`:`Loading…`,i&&v>0&&(0,Q.jsxs)(`span`,{"aria-hidden":`true`,children:[` `,(0,Q.jsx)($,{name:`x`}),` deletes it.`]})]}),l&&(0,Q.jsx)(`p`,{className:`menu-error error`,role:`alert`,children:l})]})]}):null}function EX(e){let{block:t,version:n,onDone:r}=e,i=$z(),[a,o]=(0,d.useState)(!1);return(0,Q.jsxs)(`div`,{className:`version-band nodrag`,role:`status`,children:[(0,Q.jsxs)(`span`,{title:`Made ${ex(n.at)} by ${n.by.name}. Read-only.`,children:[`Viewing v`,n.rev]}),(0,Q.jsxs)(`span`,{className:`version-band-actions`,children:[!i.readOnly&&(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:a,onClick:async()=>{o(!0);let e=await i.restoreBlock(t,n.rev);o(!1),e&&r()},title:`Make v${n.rev} the current version; v${t.rev} is kept`,children:`Restore`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:r,children:`Back to latest`})]})]})}var DX=[];function OX({id:e,data:t,selected:n}){let{block:r}=t,i=$z(),a=i.boardContext,o=OR(e=>e.inProgress),s=i.evidence.find(e=>e.id===r.optionId),c=!!(i.highlightOption&&r.optionId===i.highlightOption),l=i.newItems.has(e),[u,f]=(0,d.useState)(!1),p=BY(r.type),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(null),v=(0,d.useMemo)(()=>g?An(r,g):r,[g,r]),y=(0,d.useMemo)(()=>({...i,readOnly:!0,draft:null,openOverlay:e=>i.openOverlay(e,{version:g??void 0})}),[i,g]),{seeItem:b}=i;(0,d.useEffect)(()=>{n&&l&&b(e)},[n,l,b,e]);let x=i.pins.get(r.id)??DX,S=(0,d.useMemo)(()=>x.map(e=>({pin:e,place:Yo(r,e)})),[x,r]),C=S.filter(({pin:e,place:t})=>t&&e.anchor.kind===`block`).map(({pin:e})=>e),w=i.draft?.blockId===r.id&&i.draft.part.kind===`block`,T=zF(e=>e.nodes.filter(e=>e.selected&&e.type===`block`).map(e=>e.id).join(`,`)),E=T.includes(`,`),D=E&&T.split(`,`).includes(r.id)?T.split(`,`):[r.id],O=p.still?``:` nowheel`,k=[`block`,`block-type-${r.type}`,n&&`is-selected`,c&&`is-highlighted`,s&&`is-pinned`,l&&`is-new`,C.length>0&&`is-pin-linked`,w&&`is-pin-draft`,m&&`is-resizing`,g&&`is-viewing-version`],A=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(TX,{block:r,viewing:g?.rev??null,onView:_,onDelete:i.readOnly?void 0:e=>i.deleteVersions(r,e)}),l&&(0,Q.jsx)(`span`,{className:`block-new`,title:`Changed by ${r.updatedBy.name} since you last looked`,children:`new`}),s&&(0,Q.jsx)(`span`,{className:`block-pin${s.outdated?` is-outdated`:``}`,title:`Evidence for ${s.id}) ${s.label}${s.outdated?` (outdated)`:``}`,children:s.id}),a?a.slot.blockMarks({board:i.board,name:i.viewer,block:r}):(0,Q.jsx)(ix,{actor:r.updatedBy,showName:!1})]});return(0,Q.jsxs)(`div`,{className:k.filter(Boolean).join(` `),"data-pin-draft":w?``:void 0,children:[(0,Q.jsx)(Az,{isVisible:n&&!i.readOnly,minWidth:160,minHeight:90,lineClassName:`resize-line`,handleClassName:`resize-handle`,onResizeStart:()=>h(!0),onResizeEnd:(t,n)=>{h(!1),i.resize(e,n)}}),(0,Q.jsxs)(Iz,{isVisible:n&&!i.readOnly,position:UM.Top,align:`end`,className:`node-toolbar`,children:[i.evidence.length>0&&(0,Q.jsxs)(`select`,{value:r.optionId??``,onChange:e=>i.updateBlock(r,{optionId:e.target.value||null}),title:`Pin as evidence for an option`,children:[(0,Q.jsx)(`option`,{value:``,children:`Not pinned to an option`}),i.evidence.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[`Evidence for `,e.id,`) `,e.label,e.outdated?` (outdated)`:``]},e.id))]}),p.Tools&&(0,Q.jsx)(p.Tools,{block:r,shown:v,viewing:g,editing:u,setEditing:f}),a&&!E&&a.slot.blockTool({...a.tools,block:r}),i.keep&&(0,Q.jsx)(`button`,{onClick:()=>i.keep.run(D),title:i.keep.words.blockTitle(D.length),children:i.keep.words.label}),(0,Q.jsx)(`button`,{onClick:()=>i.removeItem(e),children:`Delete`})]}),p.Card?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qz.Provider,{value:g?y:i,children:(0,Q.jsx)(p.Card,{block:v,editing:u&&!g,setEditing:f,badges:(0,Q.jsxs)(Q.Fragment,{children:[!g&&C.map(e=>(0,Q.jsx)(KB,{pin:e},e.id)),A]})})}),g&&(0,Q.jsx)(EX,{block:r,version:g,onDone:()=>_(null)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`header`,{className:`block-head`,children:[(0,Q.jsx)(`span`,{className:`block-kind`,children:Eo(r.type).label}),p.Title?(0,Q.jsx)(p.Title,{block:v,placed:g?[]:S,frozen:!!g}):g?(0,Q.jsx)(`span`,{className:`editable block-title`,children:v.title||(0,Q.jsx)(`span`,{className:`placeholder`,children:`Untitled`})}):(0,Q.jsx)(eB,{className:`block-title`,value:r.title??``,placeholder:`Untitled`,onCommit:e=>i.updateBlock(r,{title:e})}),p.Head&&(0,Q.jsx)(p.Head,{block:v,placed:g?[]:S,frozen:!!g}),A]}),g&&(0,Q.jsx)(EX,{block:r,version:g,onDone:()=>_(null)}),g?(0,Q.jsx)(Qz.Provider,{value:y,children:(0,Q.jsx)(`div`,{className:`block-body${O}`,children:(0,Q.jsx)(p.Body,{block:v,selected:!1,placed:[]},`v${g.rev}`)})}):(0,Q.jsxs)(`div`,{className:`block-body${O}`,children:[(0,Q.jsx)(p.Body,{block:r,selected:n,placed:S}),!p.ownPins&&(0,Q.jsx)(YB,{block:r,placed:S})]})]}),(0,Q.jsx)(dL,{type:`source`,position:UM.Right,className:`block-handle`,title:`Drag to link`}),(0,Q.jsx)(dL,{type:`target`,position:UM.Left,isConnectableStart:!1,className:`block-target${o?` is-active`:``}`})]})}var kX=e=>wt().reduce((t,{kind:n})=>t+(e[`${n}Ids`]?.length??0),0);function AX({id:e,data:t,selected:n}){let r=$z(),i=r.boardContext,a=r.owner?void 0:sX(r.board,e),o=r.owner||a?void 0:Rs(r.board,e),s=a??(o?Bs(r.board,o):void 0),c=s?kX(s):0,l=(0,Q.jsx)(eB,{className:`frame-title`,value:t.group.title,placeholder:`Group name`,onCommit:t=>t.trim()&&r.renameGroup(e,t)});return(0,Q.jsxs)(`div`,{className:`frame${n?` is-selected`:``}${a?` is-request is-${a.status}`:``}${o?` is-thread`:``}`,children:[(0,Q.jsx)(Az,{isVisible:n&&!r.readOnly,minWidth:240,minHeight:140,lineClassName:`resize-line`,handleClassName:`resize-handle`,onResizeEnd:(t,n)=>r.resize(e,n)}),(0,Q.jsxs)(Iz,{isVisible:n&&!r.readOnly,position:UM.Top,align:`end`,className:`node-toolbar`,children:[r.keep&&t.members>0&&(0,Q.jsx)(`button`,{onClick:()=>r.keep.run(r.board.pages?.flatMap(e=>e.canvas.blocks).filter(t=>t.groupId===e).map(e=>e.id)??[]),title:r.keep.words.groupTitle,children:r.keep.words.label}),(0,Q.jsx)(`button`,{onClick:()=>r.removeItem(e),title:`Blocks inside stay on the canvas`,children:`Ungroup`})]}),(0,Q.jsxs)(`header`,{className:`frame-head`,children:[a?(0,Q.jsx)(dX,{board:r.board,request:a,name:r.viewer,title:l,empty:t.members===0&&c===0,readOnly:r.readOnly}):o?(0,Q.jsx)(fX,{thread:o,title:l}):l,(t.members>0||c===0)&&(0,Q.jsx)(`span`,{className:`frame-count`,children:t.members}),i&&!r.readOnly&&t.members>0&&i.slot.groupTool({...i.tools,group:t.group})]}),s&&c>0&&(0,Q.jsx)(pX,{board:r.board,request:s})]})}function jX(e,t){let n=e.measured.width??0,r=e.measured.height??0,i=e.internals.positionAbsolute.x+n/2,a=e.internals.positionAbsolute.y+r/2,o=t.x-i,s=t.y-a;if(o===0&&s===0)return{x:i,y:a};let c=1/Math.max(Math.abs(o)/(n/2),Math.abs(s)/(r/2));return{x:i+o*c,y:a+s*c}}function MX(e){return{x:e.internals.positionAbsolute.x+(e.measured.width??0)/2,y:e.internals.positionAbsolute.y+(e.measured.height??0)/2}}function NX({id:e,source:t,target:n,markerEnd:r,data:i,selected:a}){let o=$z(),s=qR(t),c=qR(n),[l,u]=(0,d.useState)(!1),f=(0,d.useRef)(!1);if(!s||!c)return null;let p=jX(s,MX(c)),m=jX(c,MX(s)),[h,g,_]=$N({sourceX:p.x,sourceY:p.y,targetX:m.x,targetY:m.y}),v=i?.link.label??``;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(GL,{id:e,path:h,markerEnd:r,className:a?`link-path is-selected`:`link-path`}),(v||a&&!o.readOnly||l)&&(0,Q.jsx)(KR,{children:(0,Q.jsx)(`div`,{className:`link-label nodrag nopan${a?` is-selected`:``}`,style:{transform:`translate(-50%, -50%) translate(${g}px, ${_}px)`},onDoubleClick:()=>{o.readOnly||(f.current=!1,u(!0))},children:l?(0,Q.jsx)(`input`,{autoFocus:!0,defaultValue:v,placeholder:`e.g. contradicts`,onBlur:t=>{u(!1),!f.current&&t.currentTarget.value!==v&&o.relabelLink(e,t.currentTarget.value)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(f.current=!0,e.currentTarget.blur())}}):v||(0,Q.jsx)(`span`,{className:`placeholder`,children:`Double-click to label`})})})]})}var PX=null,FX=new Set;function IX(e){let t=PX&&e&&PX.pageId===e.pageId&&PX.blockIds.join(`,`)===e.blockIds.join(`,`)&&PX.names.join(`
89
+ `)===e.names.join(`
90
+ `);if(t||!PX&&!e)t&&(PX=e);else{PX=e;for(let e of FX)e()}}var LX=e=>(FX.add(e),()=>void FX.delete(e));function RX(e){let t=(0,d.useSyncExternalStore)(LX,()=>PX);return e&&t?.pageId===e&&t.blockIds.length?t:null}var zX=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),BX=zX?`⌘Z`:`Ctrl Z`;function VX(e){if(e.length===1)return`Deleted ${e[0].label}`;let t=new Set(e.map(e=>e.kind));return`Deleted ${e.length} ${t.size===1?`${e[0].kind}s`:`items`}`}function HX(e,t){let[n,r]=(0,d.useState)(null),i=(0,d.useRef)(!1),a=(0,d.useCallback)(e=>r({key:Date.now(),deleted:e}),[]),o=(0,d.useCallback)(n=>{(async()=>{let r=[];for(let i of n)try{r.push((await X.removeItem(i,e)).deleted)}catch(e){t(e)}r.length&&a(r)})()},[e,t,a]),s=n&&`deleted`in n?n.deleted:null,c=(0,d.useCallback)(async()=>{if(!s||i.current)return;i.current=!0,r(null);let n=[];for(let r of[...s].reverse())try{let{notes:t}=await X.restoreItem(r.id,e);t.length&&n.push(`${ws(r.label)} is back; ${t.join(`; `)}.`)}catch(e){t(e)}i.current=!1,n.length&&r({key:Date.now(),note:n.join(` `)})},[s,e,t]);UX(!!s,c);let l=e=>r(t=>t?.key===e?null:t);return{remove:o,removed:a,toast:n&&(0,Q.jsx)(WX,{text:`deleted`in n?VX(n.deleted):n.note,onUndo:`deleted`in n?()=>void c():void 0,onGone:()=>l(n.key)},n.key)}}function UX(e,t){(0,d.useEffect)(()=>{if(!e)return;let n=e=>{e.key.toLowerCase()!==`z`||e.altKey||e.shiftKey||!(zX?e.metaKey:e.ctrlKey)||Xl(e.target)||(e.preventDefault(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function WX({text:e,onUndo:t,onGone:n}){let r=(0,d.useRef)(null);return JX(r,n),(0,Q.jsxs)(`div`,{ref:r,className:`undo-toast${t?``:` is-note`}`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`undo-toast-text`,children:e}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`undo-toast-undo`,onClick:t,children:`Undo`}),(0,Q.jsx)(`kbd`,{className:`undo-toast-key`,"aria-label":`or press ${BX}`,children:BX})]}),(0,Q.jsx)(`button`,{type:`button`,className:`undo-toast-close`,onClick:n,"aria-label":`Dismiss`,title:`Dismiss (Esc)`,children:(0,Q.jsx)($,{name:`x`})}),(0,Q.jsx)(`span`,{className:`undo-toast-bar`,"aria-hidden":`true`,children:(0,Q.jsx)(`i`,{onAnimationEnd:n})})]})}var GX=`[role="dialog"], [role="alertdialog"]`,KX=e=>ru(e)||document.querySelector(GX)!==null,qX=[];function JX(e,t){let n=(0,d.useRef)(t);n.current=t,(0,d.useEffect)(()=>{qX.push(e);let t=new WeakSet,r=e=>{e.key===`Escape`&&KX(e)&&t.add(e)},i=r=>{r.key!==`Escape`||r.defaultPrevented||t.has(r)||Xl(r.target)||qX.at(-1)!==e||(r.preventDefault(),n.current())},a=document.documentElement;return window.addEventListener(`keydown`,r,!0),a.addEventListener(`keydown`,i),()=>{qX.splice(qX.indexOf(e),1),window.removeEventListener(`keydown`,r,!0),a.removeEventListener(`keydown`,i)}},[e])}var YX={block:OX,frame:AX},XX={link:NX},ZX={hideAttribution:!0},QX=4e3;function $X(e){let t=new Map;for(let n of e.blocks)n.groupId&&t.set(n.groupId,(t.get(n.groupId)??0)+1);return[...e.groups.map(e=>({id:e.id,type:`frame`,position:{x:e.x,y:e.y},width:e.w,height:e.h,data:{group:e,members:t.get(e.id)??0}})),...e.blocks.map(e=>({id:e.id,type:`block`,position:{x:e.x,y:e.y},width:e.w,height:e.h,parentId:e.groupId,dragHandle:`.block-head`,data:{block:e}}))]}function eZ(e){return e.links.map(e=>({id:e.id,source:e.from,target:e.to,type:`link`,data:{link:e},markerEnd:{type:HM.ArrowClosed,width:16,height:16,color:`var(--muted)`}}))}var tZ=new Set,nZ=[],rZ={maxZoom:1,padding:.15},iZ={maxZoom:1,padding:{x:.15,top:.15,bottom:`120px`}},aZ=[`Meta`,`Control`,`Shift`],oZ=[1,2],sZ=`Space`,cZ=()=>{},lZ=380,uZ=230,dZ=320,fZ=2400;function pZ(e,t,n,r=lZ,i=0,a=!1){let o=t.map(e=>e.getBoundingClientRect()),s={left:Math.min(...o.map(e=>e.left)),right:Math.max(...o.map(e=>e.right)),top:Math.min(...o.map(e=>e.top)),bottom:Math.max(...o.map(e=>e.bottom))},c=e.getBoundingClientRect(),l=Math.min(r,c.width-24),u=Math.max(12,Math.min(s.left-c.left-12,c.width-l-12)),d=s.bottom-c.top+10,f=c.height-i-12-d,p=s.top-c.top-22;if(a&&n>f&&p<n){let e=Math.max(12,Math.min(s.top-c.top,c.height-i-12-n)),t=s.right-c.left+12;if(t+l<=c.width-12)return{left:t,width:l,top:e,above:!1};let r=s.left-c.left-12-l;if(r>=12)return{left:r,width:l,top:e,above:!1}}let m=n>f&&(a?p>=n:p>f);return{left:u,width:l,top:m?s.top-c.top-10:Math.max(12,Math.min(d,c.height-i-12-n)),above:m}}var mZ={width:420,height:40},hZ=96;function gZ(e,t){let n=e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`);if(!n)return null;let r=[...n.querySelectorAll(`[data-pin-draft]`)];return pZ(e,r.length?r:[n],uZ)}function _Z(e,t,n){let r=e.querySelector(`[data-chip-pin="${CSS.escape(t)}"]`);return r?pZ(e,[r],n):null}function vZ(e){return(0,Q.jsx)(BR,{children:(0,Q.jsx)(yZ,{...e})})}function yZ(e){let{board:t,page:n,name:r,emptyNote:i,evidence:a=nZ,highlightOption:o=null,newItems:s=tZ,onSeeItem:c=cZ,covered:l=!1,lead:u,opens:f,onClosed:p}=e,m=e.owner?.kind,h=e.owner?.card,g=(0,d.useMemo)(()=>m&&h?{kind:m,card:h}:void 0,[m,h]),_=h?.canvas??n?.canvas??t.canvas,v=!g,y=h?.id,b=n?.id,x=(0,d.useMemo)(()=>m&&y?{[`${m}Id`]:y}:b?{pageId:b}:{boardId:t.id},[t.id,m,y,b]),S=hu(),C=RI(),w=(0,d.useRef)(null),T=(0,d.useRef)(new Map),[E,D]=(0,d.useState)(()=>$X(_)),[O,k]=(0,d.useState)(()=>eZ(_)),[A,j]=(0,d.useState)(null),[M,N]=(0,d.useState)(null),[P,F]=(0,d.useState)(null),[I,L]=(0,d.useState)(null),[R,z]=(0,d.useState)(null),[B,ee]=(0,d.useState)(null),[V,te]=(0,d.useState)(dZ),[ne,re]=(0,d.useState)(null),[ie,ae]=(0,d.useState)(null),oe=zF(e=>e.transform),[se,H]=(0,d.useState)(null),U=IU(),W=(0,d.useRef)(new Map),G=(0,d.useCallback)(e=>H(e instanceof Error?e.message:String(e)),[]),{remove:ce,removed:le,toast:ue}=HX(r,G),de=(0,d.useCallback)(async(e,n,i)=>{try{await X.updateBlock(e.id,r,{...n,rev:e.rev})}catch(n){if(!i||n.status!==409)throw n;let a=ns(await X.board(t.id)).flatMap(({canvas:e})=>e.blocks).find(t=>t.id===e.id),o=a&&i(a);o&&await X.updateBlock(e.id,r,{...o,rev:a.rev})}},[t.id,r]);(0,d.useEffect)(()=>{if(!se)return;let e=setTimeout(()=>H(null),4e3);return()=>clearTimeout(e)},[se]);let fe=e=>{let t=Date.now()+QX;for(let n of e)W.current.set(n,t)};(0,d.useEffect)(()=>{let e=Date.now();D(t=>{let n=new Map(t.map(e=>[e.id,e]));return $X(_).map(t=>{let r=n.get(t.id);return r?r.dragging||r.resizing||(W.current.get(t.id)??0)>e?{...t,position:r.position,width:r.width,height:r.height,parentId:r.parentId,selected:r.selected,dragging:r.dragging,resizing:r.resizing}:{...t,selected:r.selected}:t})}),k(e=>{let t=new Set(e.filter(e=>e.selected).map(e=>e.id));return eZ(_).map(e=>t.has(e.id)?{...e,selected:!0}:e)})},[_]);let pe=(0,d.useCallback)(e=>D(t=>bI(e,t)),[]),me=(0,d.useCallback)(e=>k(t=>xI(e,t)),[]),he=vS().boardContext(),ge=!g&&!n,_e=ge&&!S,ve=(0,d.useMemo)(()=>E.filter(e=>e.selected&&e.type===`block`).map(e=>e.id),[E]),ye=(0,d.useCallback)(e=>{let t=new Set(e);D(e=>e.map(e=>!!e.selected===t.has(e.id)?e:{...e,selected:t.has(e.id)}))},[]),be=(0,d.useCallback)(()=>ye([]),[ye]),K=(0,d.useMemo)(()=>({board:t,name:r,select:ye,report:G}),[t,r,ye,G]),xe=!!n&&!S,Se=(0,d.useMemo)(()=>{if(!xe)return``;let e=new Set(E.filter(e=>e.selected).map(e=>e.id));return _.blocks.filter(t=>e.has(t.id)||t.groupId&&e.has(t.groupId)).map(e=>e.id).join(`,`)},[xe,E,_]),Ce=(0,d.useMemo)(()=>Se?Se.split(`,`):[],[Se]),we=(0,d.useMemo)(()=>{let e=new Set(Ce);return _.blocks.filter(t=>e.has(t.id)).map(e=>kn(e,60)).join(`
91
+ `)},[Ce,_]),Te=n?.id;(0,d.useEffect)(()=>{if(Te)return IX(Ce.length?{pageId:Te,blockIds:Ce,names:we.split(`
92
+ `),clear:be}:null),()=>IX(null)},[Te,Ce,we,be]);let[Ee,De]=(0,d.useState)(null),[Oe,ke]=(0,d.useState)(null),Ae=(0,d.useRef)(!1);(0,d.useEffect)(()=>{Ee&&Ee.blockIds.join(`,`)!==Se&&De(null)},[Ee,Se]);let je=he?.keep,Me=(0,d.useCallback)(e=>{let t=new Set(e),r=_.blocks.filter(e=>t.has(e.id)).map(e=>e.id);n&&je&&!Ae.current&&r.length!==0&&(Ae.current=!0,je.run({...K,page:n,blockIds:r}).then(e=>{De(e),ye(e.blockIds)},G).finally(()=>{Ae.current=!1}))},[n,je,_,K,G,ye]),Ne=(0,d.useCallback)(e=>{let t=C.getInternalNode(e);if(!t)return null;let{x:n,y:r}=t.internals.positionAbsolute;return{x:n,y:r,w:t.measured.width??t.width??0,h:t.measured.height??t.height??0}},[C]),Pe=(0,d.useCallback)(e=>{for(let t of C.getNodes()){if(t.type!==`frame`)continue;let n=Ne(t.id);if(n&&e.x>=n.x&&e.x<=n.x+n.w&&e.y>=n.y&&e.y<=n.y+n.h)return{id:t.id,...n}}return null},[C,Ne]),Fe=(0,d.useCallback)((e,t,n)=>{let i=n.map(e=>{if(e.type!==`block`)return{id:e.id,x:e.position.x,y:e.position.y};let t=Ne(e.id),n=Pe({x:t.x+t.w/2,y:t.y+t.h/2});return n?{id:e.id,x:t.x-n.x,y:t.y-n.y,groupId:n.id}:{id:e.id,x:t.x,y:t.y,groupId:null}}),a=new Map(i.map(e=>[e.id,e]));D(e=>e.map(e=>{let t=a.get(e.id);return!t||e.type!==`block`?e:{...e,parentId:t.groupId??void 0,position:{x:t.x,y:t.y}}})),fe(i.map(e=>e.id)),X.moveItems(x,r,i).catch(G)},[Ne,Pe,x,r,G]),Ie=(0,d.useCallback)((e,t)=>{let n=[{id:e,x:t.x,y:t.y,w:t.width,h:t.height}];for(let t of C.getNodes().filter(t=>t.parentId===e))n.push({id:t.id,x:t.position.x,y:t.position.y});fe(n.map(e=>e.id)),X.moveItems(x,r,n).catch(G)},[C,x,r,G]),Le=(0,d.useCallback)((e,t)=>{let n=C.getNode(e);n&&(D(n=>n.map(n=>n.id===e?{...n,width:t.w,height:t.h}:n)),Ie(e,{x:n.position.x,y:n.position.y,width:t.w,height:t.h}))},[C,Ie]),[Re,ze]=(0,d.useState)(null),Be=(0,d.useRef)(0),Ve=(0,d.useCallback)((e,t={})=>{let n=_.blocks.find(t=>t.id===e),r=n&&BY(n.type).overlay;r&&!(S&&r.changes)&&ze({blockId:e,...t,...t.pinId?{pinAsked:++Be.current}:{}})},[_,S]),He=(0,d.useCallback)(()=>{let e=Re?.blockId,t=e&&_.blocks.find(t=>t.id===e);ze(null),e&&e===f&&p?.(),e&&t&&BY(t.type).overlay?.refocus&&(w.current?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`))?.focus({preventScroll:!0})},[Re,_,f,p]),Ue=(0,d.useRef)(void 0);(0,d.useEffect)(()=>{f&&Ue.current!==f&&_.blocks.some(e=>e.id===f)&&(Ue.current=f,Re||Ve(f))},[f,_,Re,Ve]),(0,d.useEffect)(()=>{Re&&!_.blocks.some(e=>e.id===Re.blockId)&&ze(null)},[Re,_]);let We=(0,d.useRef)(!1),Ge=e=>{let t=e.target;if(!t.classList.contains(`react-flow__node`))return;let n=_.blocks.find(e=>e.id===t.dataset.id),r=n&&BY(n.type).activate;n&&r&&(e.preventDefault(),(e.key===`Enter`||e.type===`keyup`&&!We.current)&&r(n,ft))},Ke=e=>{e.key===` `&&(We.current=e.repeat),(e.key===`Enter`||e.key===` `)&&Ge(e)},qe=e=>{e.key===` `&&Ge(e)},Je=()=>{We.current=!0},Ye=bX(E),Xe=mI(l?null:sZ),Ze=(0,d.useCallback)(async({nodes:e,edges:t})=>{let n=new Set(e.filter(e=>e.selected).map(e=>e.id)),r=t.filter(e=>e.selected&&!n.has(e.source)&&!n.has(e.target));return ce([...n,...r.map(e=>e.id)]),!1},[ce]),Qe=(0,d.useCallback)(({source:e,target:t})=>{e&&t&&e!==t&&X.addLink(r,e,t).catch(G)},[r,G]),$e=()=>{let e=w.current.getBoundingClientRect();return C.screenToFlowPosition({x:e.left+e.width/2,y:e.top+e.height/2})},et=(e,t)=>{let n=e.x-t.w/2,r=e.y-t.h/2,i=(e,t)=>C.getNodes().some(n=>{let r=Ne(n.id);return r&&Math.abs(r.x-e)<24&&Math.abs(r.y-t)<24});for(let e=0;e<20&&i(n,r);e++)n+=32,r+=32;let a=Pe(e);return a?{x:Math.round(n-a.x),y:Math.round(r-a.y),groupId:a.id}:{x:Math.round(n),y:Math.round(r)}},tt={add:async(e,t={})=>{let{at:n,title:i}=t,a=Eo(e.type),o=t.size??a.sizeFor?.(e,{})??a.defaultSize;try{let t=et(n??$e(),o),a=await X.addBlock(x,r,{content:e,title:i,...t,w:o.w,h:o.h});BY(e.type).added?.(a,{edit:j})}catch(e){G(e)}},report:G},nt=e=>{let t=T.current.get(e);return t||T.current.set(e,t=(0,d.createRef)()),t},rt=async()=>{try{let{x:e,y:t}=et($e(),Tn);await X.addGroup(x,r,{title:`New group`,x:e,y:t,w:Tn.w,h:Tn.h})}catch(e){G(e)}},{dropProps:it,overlays:at}=CX({wrapper:w,flow:C,context:tt,readOnly:S||l,clips:!Re,openForm:(e,t)=>N({type:e,initial:t}),pasteBlocks:async({ids:e})=>{try{return await X.pasteBlocks(x,r,{ids:e,at:$e()}),!0}catch(e){return G(e),e.status!==404}}});xX(_,(0,d.useMemo)(()=>E.filter(e=>e.selected).map(e=>e.id),[E]),!Re&&!l),(0,d.useEffect)(()=>{let e=null,t=!1,n=n=>{let r=n.target,i=!!(r&&w.current?.contains(r));e=i?$B(n):null,t=i&&n.button===0&&!!r?.classList?.contains(`react-flow__pane`);let a=window.getSelection();t&&a&&!a.isCollapsed&&a.removeAllRanges()},r=()=>{t=!1},i=e=>{t&&e.preventDefault()},a=t=>{let n=e;if(e=null,S||!n||t.button!==0||t.detail>1||t.target?.closest?.(`input, textarea, .pin-prompt`)||n.closest(`.is-viewing-version`))return;let r=window.getSelection(),i=eV(n,r);i&&(r?.removeAllRanges(),F({blockId:n.dataset.blockId,part:i,quote:i.quote}))};return document.addEventListener(`pointerdown`,n,!0),document.addEventListener(`pointerup`,r,!0),document.addEventListener(`pointercancel`,r,!0),document.addEventListener(`selectstart`,i,!0),document.addEventListener(`mouseup`,a),()=>{document.removeEventListener(`pointerdown`,n,!0),document.removeEventListener(`pointerup`,r,!0),document.removeEventListener(`pointercancel`,r,!0),document.removeEventListener(`selectstart`,i,!0),document.removeEventListener(`mouseup`,a)}},[S]),(0,d.useLayoutEffect)(()=>{L(P&&w.current?gZ(w.current,P.blockId):null)},[P,oe,_]),(0,d.useEffect)(()=>{P&&!_.blocks.some(e=>e.id===P.blockId)&&F(null)},[P,_]);let ot=(0,d.useCallback)(()=>F(null),[]);(0,d.useLayoutEffect)(()=>{ee(R&&w.current?_Z(w.current,R,V):null)},[R,oe,_,V]),(0,d.useEffect)(()=>{R&&!_.pins.some(e=>e.id===R)&&z(null),ne&&_.pins.some(e=>e.id===ne)&&(z(ne),re(null))},[R,ne,_]);let st=(0,d.useCallback)(()=>z(null),[]),ct=!!Ee&&!P&&!R&&!Re&&!E.some(e=>e.dragging);(0,d.useLayoutEffect)(()=>{let e=w.current;if(!ct||!Ee||!e)return ke(null);let t=Ee.blockIds.flatMap(t=>e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`)??[]);ke(t.length?pZ(e,t,mZ.height,mZ.width,hZ,!0):null)},[ct,Ee,oe,E]);let lt=(0,d.useCallback)(e=>{F(null),z(t=>t===e?null:e),c(e)},[c]);(0,d.useEffect)(()=>{let e=e=>{let t=_.pins.find(t=>t.id===e.detail);if(!t)return;let n=_.blocks.find(e=>e.id===t.blockId);n&&BY(n.type).opensOnPin?.(n,t)&&Ve(n.id,{pinId:t.id}),C.fitView({nodes:[{id:t.blockId}],duration:400,maxZoom:1,padding:.3}),ae(null),requestAnimationFrame(()=>ae(t.id))};return window.addEventListener(KE,e),()=>window.removeEventListener(KE,e)},[_,C,Ve]),(0,d.useEffect)(()=>{if(!ie)return;let e=setTimeout(()=>ae(null),fZ);return()=>clearTimeout(e)},[ie]),yX(_,(0,d.useCallback)(e=>C.getInternalNode(e)?.measured.width?(C.fitView({nodes:[{id:e}],duration:400,maxZoom:1,padding:.3}),ye([e]),!0):!1,[C,ye]),(0,d.useCallback)(e=>{let t=_.blocks.find(t=>t.id===e.blockId);if(!t)return!0;let n=!!C.getInternalNode(t.id)?.measured.width,r=()=>void C.fitView({nodes:[{id:t.id}],duration:400,maxZoom:1,padding:.3});return BY(t.type).opensOnPin?.(t,e)||Re?.blockId===t.id&&!Re.version?(n&&r(),c(e.id),Ve(t.id,{pinId:e.id}),!0):n?(r(),c(e.id),ze(null),ae(null),requestAnimationFrame(()=>ae(e.id)),e.discussion&&(F(null),z(e.id)),!0):!1},[_,C,c,Ve,Re]));let ut=(0,d.useCallback)((e,t)=>{e.discussion?.thread?re(e.id):JE([t.id])},[]),dt=(0,d.useMemo)(()=>{let e=new Map;for(let t of _.pins)e.set(t.blockId,[...e.get(t.blockId)??[],t]);return e},[_]),ft=(0,d.useMemo)(()=>({board:t,owner:g,evidence:a,viewer:r,readOnly:S,highlightOption:o,autoEditId:A,clearAutoEdit:()=>j(null),updateBlock:(e,t,n)=>void de(e,t,n).catch(G),restoreBlock:(e,t)=>X.restoreBlock(e.id,r,t,e.rev).then(()=>!0,e=>(G(e),!1)),deleteVersions:(e,t)=>(t===void 0?X.deleteEarlierVersions(e.id,r):X.deleteVersion(e.id,r,t)).then(({deleted:e})=>(le([e]),!0),e=>(G(e),!1)),openLink:(e,t)=>void X.updateBlock(e.id,r,{open:t}).catch(G),openOverlay:Ve,newItems:s,seeItem:c,resize:Ie,setSize:Le,renameGroup:(e,t)=>void X.renameGroup(e,r,t).catch(G),relabelLink:(e,t)=>void X.relabelLink(e,r,t).catch(G),removeItem:e=>ce([e]),perform:e=>void e(r).catch(G),pins:dt,draft:P,startPin:e=>{S||(z(null),F(e))},focusPin:ie,thread:R,openThread:lt,boardContext:he&&ge?{slot:he,tools:K}:void 0,keep:xe&&je?{words:je,run:Me}:void 0}),[t,g,a,n,S,o,A,r,G,Ie,s,c,dt,P,ie,R,lt,he,ge,K,xe,je,Me,ce,le,Le,Ve,de]),pt=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(YY,{owner:m,context:tt,toggleOf:nt,setForm:N,addGroup:rt}),M&&(()=>{let e=BY(M.type).menu;return!e||!(`Form`in e)?null:(0,Q.jsx)(e.Form,{initial:M.initial,toggle:nt(M.type),context:tt,close:()=>N(null)},M.initial??``)})()]}),mt=!S,ht=_.blocks.length===0&&_.groups.length===0,gt=i??(n?`A canvas for “${n.title}”, to think it through with agents.`:void 0),_t=R?_.pins.find(e=>e.id===R):void 0,vt=Re?_.blocks.find(e=>e.id===Re.blockId):void 0,yt=vt&&BY(vt.type).overlay;return(0,Q.jsx)(Qz.Provider,{value:ft,children:(0,Q.jsxs)(`div`,{ref:w,className:S?`canvas is-read-only`:`canvas`,...it,onKeyDown:Ke,onKeyUp:qe,onPointerDownCapture:e=>{Je(),Ye.onPointerDownCapture(e)},onPointerUpCapture:Ye.onPointerUpCapture,onPointerCancelCapture:Ye.onPointerCancelCapture,onWheelCapture:Je,children:[(0,Q.jsxs)(WR,{nodes:Ye.nodes,edges:O,nodeTypes:YX,edgeTypes:XX,onNodesChange:pe,onEdgesChange:me,onNodeDragStop:Fe,onBeforeDelete:Ze,onConnect:Qe,isValidConnection:e=>e.source!==e.target,colorMode:U.base,fitView:!0,fitViewOptions:v?iZ:rZ,minZoom:.15,maxZoom:4,panOnScroll:!0,panOnDrag:oZ,panActivationKeyCode:l?null:sZ,selectionOnDrag:!0,selectionMode:zM.Partial,zoomOnDoubleClick:!1,multiSelectionKeyCode:aZ,nodesDraggable:!S&&!Xe,nodesConnectable:!S,deleteKeyCode:S||l?null:[`Backspace`,`Delete`],proOptions:ZX,children:[(0,Q.jsx)(ez,{variant:XR.Dots,gap:22,size:1.2}),(0,Q.jsx)(lz,{showInteractive:!1,fitViewOptions:v?iZ:rZ}),(0,Q.jsx)(wX,{}),(u!==void 0||mt)&&(0,Q.jsxs)(XF,{position:`top-left`,className:`canvas-toolbar is-add`,children:[u,mt&&(u===void 0?pt:(0,Q.jsx)(`div`,{className:`canvas-toolbar-add`,children:pt}))]}),(se||_e||ue)&&(0,Q.jsxs)(XF,{position:`bottom-center`,className:`canvas-bottom`,children:[se&&(0,Q.jsx)(`div`,{className:`canvas-error`,role:`alert`,children:se}),ue,he&&_e&&ve.length>1&&he.selection({...K,blockIds:ve}),_e&&(0,Q.jsx)(uX,{board:t,name:r})]})]}),P&&I&&(0,Q.jsx)(lV,{draft:P,block:_.blocks.find(e=>e.id===P.blockId),name:r,style:{left:I.left,top:I.top,width:I.width},above:I.above,onChange:F,onClose:ot,onCommented:ut}),_t&&B&&(0,Q.jsx)(uV,{pin:_t,block:_.blocks.find(e=>e.id===_t.blockId),name:r,style:{left:B.left,top:B.top,width:B.width},above:B.above,onClose:st,onHeight:te},_t.id),ct&&Ee&&Oe&&Ee.notice({style:{left:Oe.left,top:Oe.top,maxWidth:Oe.width},above:Oe.above}),Re&&vt&&yt&&!(S&&yt.changes)&&(0,Q.jsx)(yt.Component,{block:vt,name:r,version:Re.version,pinId:Re.pinId,pinAsked:Re.pinAsked,onClose:He},vt.id),at,ht&&(0,Q.jsxs)(`div`,{className:`canvas-empty`,children:[gt&&(0,Q.jsx)(`p`,{children:gt}),!S&&(0,Q.jsxs)(`p`,{className:`muted small`,children:[`Add a block above, paste a screenshot, a web address or some text, or drop an image, a code file, a link or some text. Drag from a block's right edge to link it. Agents add blocks with `,(0,Q.jsx)(`code`,{children:`add_block`}),`.`]})]})]})})}function bZ(e){let{docked:t,value:n,onValue:r,onSend:i,placeholder:a,label:o,sendLabel:s,busy:c,field:l,lenses:u,threads:d,context:f,error:p}=e,m=!!(u?GT(n,u.map(e=>e.name)).body:n.trim())&&!c;return(0,Q.jsxs)(`form`,{className:`chat-bar${t?` is-docked`:``}`,onSubmit:e=>{e.preventDefault(),m&&i()},"aria-label":`Talk to agents`,children:[d&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,ref:d.button,className:`chat-threads`,onClick:d.onOpen,"aria-expanded":d.open,"aria-haspopup":`dialog`,"aria-label":d.count?`Threads: ${d.count} waiting on you`:`Threads`,title:d.count?`${d.count} thread${d.count===1?``:`s`} waiting on you`:`Threads`,children:[(0,Q.jsx)($,{name:`thread`}),d.count>0&&(0,Q.jsx)(`span`,{className:`chat-count`,"aria-hidden":!0,children:d.count})]}),(0,Q.jsx)(`span`,{className:`chat-sep`,"aria-hidden":!0})]}),f&&(0,Q.jsxs)(`span`,{className:`chat-context`,title:f.title,children:[(0,Q.jsx)($,{name:`group`}),(0,Q.jsx)(`span`,{className:`chat-context-label`,children:f.label}),(0,Q.jsx)(`button`,{type:`button`,className:`chat-context-remove`,onClick:f.onRemove,"aria-label":`Leave out ${f.label}`,title:`Leave them out (deselects them)`,children:(0,Q.jsx)($,{name:`x`})})]}),(0,Q.jsx)(RE,{skills:!0,lenses:u,ref:l,className:`chat-input`,value:n,onValue:r,onKeyDown:e=>{e.key===`Escape`&&!t&&l.current?.blur()},maxLength:rc,placeholder:a,"aria-label":o}),(0,Q.jsx)(Xx,{}),(0,Q.jsx)(xZ,{quiet:t}),(0,Q.jsx)(`button`,{type:`submit`,className:`chat-send${m?` is-ready`:``}`,disabled:!m,"aria-label":s,title:`${s} (Enter)`,children:(0,Q.jsx)($,{name:`arrow-up`})}),p&&(0,Q.jsx)(`p`,{className:`error chat-error`,role:`alert`,children:p})]})}function xZ({quiet:e}){let t=uT(),n=t.filter(e=>e.state!==`away`),r=n.map(e=>e.name);if(r.length===0)return(0,Q.jsx)(SZ,{onBoard:t.map(e=>e.name)});if(e)return null;let i=n.map(e=>e.state===`listening`?`${e.name} is listening: it sees what you send right away`:e.state===`asleep`?`${e.name} is asleep: Tricot wakes it for what you send`:`${e.name} is between steps: it sees what you send when it next checks the board`).join(`
93
+ `);return(0,Q.jsxs)(`span`,{className:`chat-who`,title:i,children:[(0,Q.jsx)(`span`,{className:`chat-who-dot`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`chat-who-text`,children:zS(r)})]})}function SZ({onBoard:e}){let t=uT(),n=AT(),r=CT(),i=mx().question()?.note;if(n===void 0||r===void 0)return null;let a=RS(e,n);if(a){let t=e[0]??n[0],i=`${US(t,jT(t,r))} “${IS}”.`;return(0,Q.jsx)(`span`,{className:`chat-who is-none`,title:`${t} isn't listening on this board, so what you send waits until it is. ${i}`,children:(0,Q.jsx)(`span`,{className:`chat-who-text`,children:a})})}let o=t.length?`${G(t.map(e=>e.name))} last checked the board ${ex(t[0].lastSeen)}. `:`No agent is on this board right now. `;return(0,Q.jsxs)(`span`,{className:`chat-who is-none`,title:`${o}What you send waits in a thread until one connects${i?`; ${i}`:``}.`,children:[(0,Q.jsx)(`span`,{className:`chat-who-text`,children:`No agent listening`}),(0,Q.jsx)(`button`,{type:`button`,className:`chat-connect`,onClick:LT,children:`Connect one`})]})}var CZ=90,wZ=420,TZ=`::view-transition-image-pair(chat-bar)`,EZ=0;function DZ(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function OZ(){let e=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--dock-pace`));return e>0?e:1}function kZ(e,t,n){let r=document.documentElement,i=++EZ,a=()=>i===EZ,o=()=>{a()&&delete r.dataset.dockBox},s=()=>{a()&&(delete r.dataset.dockMove,delete r.dataset.dockLeaving,delete r.dataset.dockPlain,delete r.dataset.dockBox,delete r.dataset.dockRest)},c=()=>{(0,Qx.flushSync)(t),n()},l=()=>{if(!a())return;if(delete r.dataset.dockLeaving,r.dataset.dockMove=e,typeof document.startViewTransition!=`function`){r.dataset.dockPlain=``,c(),setTimeout(s,wZ*OZ());return}document.activeElement?.closest(`.chat-bar`)?delete r.dataset.dockRest:r.dataset.dockRest=``;let t=document.startViewTransition(()=>{r.dataset.dockBox=``,c()});t.ready.then(()=>{let e=document.getAnimations().find(e=>e.effect?.pseudoElement===TZ);e?e.finished.then(o,o):o()},o),t.finished.finally(()=>{o(),setTimeout(s,40)}).catch(()=>{})};e===`close`&&!DZ()?(r.dataset.dockLeaving=``,setTimeout(l,CZ*OZ())):l()}var AZ={open:!1,page:`thread`,selected:null,newLens:null,drafts:{}},jZ=`stays`;function MZ(e,t,n,r,i=jZ){return!n||n.board===t?{state:e,list:!1}:!n.open||i===`closes`?{state:{...e,open:!1},list:!1}:e.open&&e.page===`thread`&&e.selected&&r(e.selected)?{state:e,list:!1}:{state:{...e,open:!0,page:`new`},list:!0}}var NZ=`No lens: agents answer as they see fit.`;function PZ(e){let t=e?.name??`General`,n=e&&!cc(e.name)&&VT(e.name)?[{name:e.name,brief:e.brief}]:[];return[...bs,...n].map(({name:e,brief:n})=>({name:e,brief:n??NZ,tone:XT({name:e}),...U(e,t)&&{current:!0}}))}function FZ(e,t){let n=cc(e);return n?{name:n.name}:t?.brief&&U(t.name,e)?{name:t.name,brief:t.brief}:void 0}var IZ=8,LZ=6;function RZ(e,t,n){let r=Math.max(0,Math.min(t.width,n.width-16)),i=Math.max(8,Math.min(e.left-LZ,n.width-8-r)),a=Math.max(8,e.bottom+IZ),o=Math.max(0,n.height-8-a),s=Math.max(8,n.height-e.top+IZ),c=Math.max(0,n.height-8-s);return t.height<=o||o>=c?{left:i,width:r,top:a,maxHeight:o}:{left:i,width:r,bottom:s,maxHeight:c}}var zZ=`Agents answer as they see fit.`;function BZ({lens:e,children:t}){return(0,Q.jsx)(`span`,{className:`lens-chip ${XT(e)}`,children:t??e?.name??`General`})}function VZ(e){let{lens:t,readOnly:n,onPick:r,label:i,note:a}=e,[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(null),m=(0,d.useId)(),h=t?.name??`General`,g=(0,Q.jsx)(BZ,{lens:t,children:i??h}),_=(0,d.useCallback)((e=!0)=>{s(!1),e&&f.current?.focus()},[]);Zl(o,_,u);let v=c?.width;return(0,d.useLayoutEffect)(()=>{if(!o)return;let e=()=>{let e=f.current?.getBoundingClientRect();if(!e)return;let t={width:window.innerWidth,height:window.innerHeight};l(RZ(e,{width:380,height:HZ(p.current)},t))};return e(),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[o,v]),n?g:(0,Q.jsxs)(`span`,{className:`lens-anchor`,ref:u,onKeyDown:e=>{o&&e.key===`Escape`&&(e.stopPropagation(),_())},children:[(0,Q.jsx)(`button`,{ref:f,type:`button`,className:`lens-pick`,"aria-expanded":o,"aria-controls":o?m:void 0,"aria-label":`${i??`${h} lens`}, change it`,title:`Change the lens`,onClick:()=>s(!o),children:g}),o&&c&&(0,Q.jsx)(KZ,{id:m,root:p,lens:t,generalLine:a,place:c,onPick:e=>{_(),r(e)}})]})}function HZ(e){return e?e.scrollHeight+e.offsetHeight-e.clientHeight:0}function UZ(e){let{lens:t,onPick:n}=e;return(0,Q.jsxs)(`div`,{className:`lens-line`,children:[(0,Q.jsx)(VZ,{lens:t,label:`${t?.name??`General`} lens`,onPick:n}),(0,Q.jsx)(WZ,{lens:t})]})}function WZ({lens:e,className:t}){return e?.agent?(0,Q.jsxs)(`span`,{className:t,title:`Messages that @-mention nobody go to ${e.agent}`,children:[e.agent,` answers`]}):null}var GZ=`Name it, and say how agents should answer.`;function KZ(e){let{id:t,root:n,lens:r,generalLine:i,place:a,onPick:o}=e,{agents:s}=fE(),c=r?.name??`General`,l=!cc(c),[u,f]=(0,d.useState)(l),[p,m]=(0,d.useState)(l?c:``),[h,g]=(0,d.useState)(l?r?.brief??``:``),[_,v]=(0,d.useState)(r?.agent??``),[y,b]=(0,d.useState)(null),x=!!(p.trim()&&h.trim())&&!cc(p),S=[...s.map(e=>e.name),...r?.agent&&!s.some(e=>U(e.name,r.agent))?[r.agent]:[]],C=u?``:c,w=y??C,T=w===``?GZ:cc(w)?.brief??i??zZ;(0,d.useEffect)(()=>{l||n.current?.querySelector(`[aria-checked="true"]`)?.focus()},[l]);let E=e=>{let t={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!t)return;e.preventDefault();let n=[...e.currentTarget.querySelectorAll(`[role="radio"]`)];n[(n.indexOf(document.activeElement)+t+n.length)%n.length]?.focus()},D=e=>({onMouseEnter:()=>b(e),onMouseLeave:()=>b(null),onFocus:()=>b(e),onBlur:()=>b(null)});return(0,Q.jsxs)(`div`,{id:t,ref:n,className:`lens-menu`,tabIndex:-1,style:a,children:[(0,Q.jsxs)(`div`,{className:`lens-pills`,role:`radiogroup`,"aria-label":`Lens`,onKeyDown:E,children:[bs.map(e=>{let t=C===e.name;return(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,tabIndex:t?0:-1,className:`lens-pill`,onClick:()=>o(lc(e.name,void 0,_||void 0)),...D(e.name),children:(0,Q.jsxs)(BZ,{lens:e,children:[e.name,t&&(0,Q.jsx)($,{name:`check`,className:`lens-check`})]})},e.name)}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":u,tabIndex:u?0:-1,className:`lens-pill`,onClick:()=>f(!0),...D(``),children:(0,Q.jsxs)(BZ,{lens:{name:``},children:[`Your own`,u&&(0,Q.jsx)($,{name:`check`,className:`lens-check`})]})})]}),(0,Q.jsx)(`p`,{className:`lens-menu-brief`,"aria-live":`polite`,children:T}),u&&(0,Q.jsxs)(`form`,{className:`lens-form`,onSubmit:e=>{e.preventDefault(),x&&o(lc(p.trim(),h.trim(),_||void 0))},children:[(0,Q.jsx)(`input`,{value:p,maxLength:oc,onChange:e=>m(e.target.value),placeholder:`Name, e.g. Pricing`,"aria-label":`Lens name`,autoFocus:!0}),(0,Q.jsx)(`textarea`,{rows:2,value:h,maxLength:sc,onChange:e=>g(e.target.value),placeholder:`How agents should answer, in a sentence or two`,"aria-label":`Lens brief`}),(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-small`,disabled:!x,children:`Use this lens`})]}),(0,Q.jsxs)(`label`,{className:`lens-agent`,children:[(0,Q.jsx)(`span`,{children:`Who answers`}),(0,Q.jsxs)(`select`,{value:_,onChange:e=>{v(e.target.value),u||o(lc(c,void 0,e.target.value||void 0))},children:[(0,Q.jsx)(`option`,{value:``,children:`Any agent, the first to reply`}),S.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})]})}var qZ=5;function JZ(e){let{groups:t,name:n,current:r,readOnly:i,docked:a,onOpen:o,onNew:s,onDelete:c,onClose:l,toggle:u}=e,f=(0,d.useRef)(null),[p,m]=(0,d.useState)(!1);Zl(!0,l,f,u),(0,d.useEffect)(()=>{let e=f.current,t=r&&e?.querySelector(`[data-thread="${CSS.escape(r)}"] .tl-open`)||e?.querySelector(`.tl-open`);(t??e?.querySelector(`.tl-new`))?.focus({preventScroll:!0}),t?.scrollIntoView({block:`nearest`})},[]);let h=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...f.current?.querySelectorAll(`.tl-open`)??[]],n=t.indexOf(document.activeElement),r=t[n<0?0:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length];r&&(e.preventDefault(),r.focus())},{waiting:g,recent:_,earlier:v}=t,y=g.length+_.length+v.length===0,b=p?v:v.slice(0,qZ),x=(e,t=!1)=>(0,Q.jsx)(YZ,{entry:e,name:n,compact:t,current:e.thread.id===r,readOnly:i,onOpen:()=>o(e.thread.id),onDelete:()=>c(e.thread)},e.thread.id);return(0,Q.jsxs)(`div`,{className:`threads-pop${a?` is-docked`:``}`,ref:f,role:`dialog`,"aria-label":`Threads`,onKeyDown:h,children:[(0,Q.jsxs)(`header`,{className:`tl-head`,children:[(0,Q.jsx)(`h2`,{className:`tl-heading`,children:`Threads`}),!i&&(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn-small tl-new`,onClick:s,children:[(0,Q.jsx)($,{name:`plus`}),` New thread`]})]}),(0,Q.jsxs)(`div`,{className:`tl-body`,children:[y&&(0,Q.jsx)(`p`,{className:`tl-empty`,children:i?`No threads.`:`No threads yet. What you send from the bar starts one, wherever you are.`}),g.length>0&&(0,Q.jsxs)(`section`,{className:`tl-group is-waiting`,"aria-label":`Waiting on you`,children:[(0,Q.jsx)(`h3`,{className:`tl-group-head`,children:`Waiting on you`}),(0,Q.jsx)(`ol`,{className:`tl-rows`,children:g.map(e=>x(e))})]}),_.length>0&&(0,Q.jsxs)(`section`,{className:`tl-group`,"aria-label":`Recent`,children:[(g.length>0||v.length>0)&&(0,Q.jsx)(`h3`,{className:`tl-group-head`,children:`Recent`}),(0,Q.jsx)(`ol`,{className:`tl-rows`,children:_.map(e=>x(e))})]}),v.length>0&&(0,Q.jsxs)(`section`,{className:`tl-group is-earlier`,"aria-label":`Earlier`,children:[(0,Q.jsx)(`h3`,{className:`tl-group-head`,title:`Threads that made what they were for and have been quiet a day, or quiet a week`,children:`Earlier`}),(0,Q.jsx)(`ol`,{className:`tl-rows`,children:b.map(e=>x(e,!0))}),v.length>b.length&&(0,Q.jsxs)(`button`,{type:`button`,className:`link-button tl-more`,onClick:()=>m(!0),children:[`Show `,v.length-b.length,` more`]})]})]})]})}function YZ(e){let{entry:t,name:n,compact:r,current:i,readOnly:a,onOpen:o,onDelete:s}=e,{thread:c,waiting:l,unread:u}=t,d=ac(c),f=c.messages.at(-1),p=Wc(t.made),{people:m,me:h}=fE(),g=p&&(0,Q.jsx)(`span`,{className:`tl-made`,children:p});return(0,Q.jsxs)(`li`,{className:`tl-row${r?` is-compact`:``}${l?` is-waiting`:``}${i?` is-current`:``}`,"data-thread":c.id,children:[(0,Q.jsx)(ix,{actor:c.startedBy,showName:!1}),(0,Q.jsxs)(`button`,{type:`button`,className:`tl-open`,onClick:o,"aria-current":i||void 0,"aria-label":`${d}${l?`, waiting on you`:u?`, new replies`:``}`,children:[(0,Q.jsx)(`span`,{className:`tl-title`,children:d}),r?g:(0,Q.jsxs)(`span`,{className:`tl-meta`,children:[f&&(0,Q.jsx)(`span`,{className:`tl-last`,children:XZ(f,n,e=>!U(e,h)&&!m.some(t=>U(t,e)))}),g]})]}),(0,Q.jsxs)(`span`,{className:`tl-end`,children:[l?(0,Q.jsx)(`span`,{className:`tl-turn`,"aria-hidden":!0}):u&&(0,Q.jsx)(`span`,{className:`new-dot`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`tl-time`,title:new Date(c.updatedAt).toLocaleString(),children:r?QZ(c.updatedAt):ZZ(c.updatedAt)})]}),!a&&(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn-small tl-delete`,onClick:s,"aria-label":`Delete thread: ${d}`,children:[(0,Q.jsx)($,{name:`trash`}),` Delete`]})]})}function XZ(e,t,n){let r=e.author.kind===`human`&&U(e.author.name,t)?`You`:e.author.name,i=e.mentions??[];return`${r}: ${H(Cc(e.body,i,i.filter(n)),140)}`}function ZZ(e){let t=Math.max(0,(Date.now()-Date.parse(e))/6e4);return t<1?`now`:t<60?`${Math.round(t)}m`:t<1440?`${Math.round(t/60)}h`:t<2880?`yesterday`:QZ(e)}function QZ(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var $Z=`tricot:threads-seen:`,eQ=new Map,tQ=new Set;function nQ(e){if(eQ.has(e))return eQ.get(e);let t=null;try{let n=localStorage.getItem($Z+e);t=n===null?null:JSON.parse(n)}catch{t=null}return eQ.set(e,t),t}function rQ(e,t){eQ.set(e,t);try{localStorage.setItem($Z+e,JSON.stringify(t))}catch{}for(let e of tQ)e()}function iQ(e){tQ.add(e);let t=t=>{t.key?.startsWith($Z)&&(eQ.delete(t.key.slice(20)),e())};return window.addEventListener(`storage`,t),()=>{tQ.delete(e),window.removeEventListener(`storage`,t)}}function aQ(e){let t=e?nl(e):``,n=(0,d.useSyncExternalStore)(iQ,()=>t?nQ(t):null),r=e?.threads;return(0,d.useEffect)(()=>{t&&!nQ(t)&&rQ(t,Object.fromEntries((r??[]).flatMap(e=>e.messages.length?[[e.id,e.messages.at(-1).id]]:[])))},[t,r]),{seen:n,markSeen:(0,d.useCallback)(e=>{let n=e.messages.at(-1)?.id,r=t&&nQ(t)||{};t&&n&&r[e.id]!==n&&rQ(t,{...r,[e.id]:n})},[t])}}var oQ=`local-`,sQ=e=>!!e?.id.startsWith(oQ);function cQ(e,t,n){let r=Sc(e.body,n);return{id:e.key,author:{kind:`human`,name:t},body:e.body,at:e.at,...e.lens&&{lens:e.lens},...r.length&&{mentions:r}}}var lQ=[],uQ=null;function dQ(e,t,n){!n||lQ.includes(n.boardId)?lX(e,t):(uQ={id:e,thread:t},location.hash=n.href)}var fQ=ZY.find(e=>e.label===`Risks and open questions`)?.text??``,pQ=new Map,mQ=null;function hQ({board:e,name:t,door:n,page:r,file:i,onSeeItem:a}){let o=hu(),s=e.threads??[],{seen:c,markSeen:l}=aQ(e),u=(0,d.useMemo)(()=>Yc(e,t,c,Date.now()),[e,t,c]),f=uT(),p=mx().question(),m=f.filter(e=>e.state!==`away`).map(e=>e.name),h=GE(t),[g]=(0,d.useState)(()=>n===`canvas`&&ES(uS.ask)),[_]=(0,d.useState)(()=>MZ(pQ.get(e.id)??AZ,e.id,mQ,e=>s.some(t=>t.id===e))),[v,y]=(0,d.useState)(()=>{let e=_.state;return g?{...e,open:!1,drafts:{...e.drafts,bar:fQ}}:e});(0,d.useEffect)(()=>{pQ.set(e.id,v)},[e.id,v]);let b=(0,d.useCallback)(e=>{y(t=>({...t,...typeof e==`function`?e(t):e}))},[]),{open:x,page:S,selected:C,newLens:w,drafts:T}=v,[E,D]=(0,d.useState)(null),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(null),M=(0,d.useCallback)(e=>j(e instanceof Error?e.message:String(e)),[]),{remove:N,toast:P}=HX(t,M),F=(0,d.useRef)(null),[I,L]=(0,d.useState)(()=>_.list&&!g),R=(0,d.useRef)(null),z=(0,d.useRef)(!1),B=(0,d.useRef)(`bar`),ee=(0,d.useRef)(new Map),V=(0,d.useCallback)(()=>{let e=F.current;return e&&document.activeElement===e?[e.selectionStart??e.value.length,e.selectionEnd??e.value.length]:null},[]),te=(0,d.useCallback)(()=>{let e=V();e&&ee.current.set(B.current,e)},[V]),ne=(0,d.useCallback)((e=!1,t=!0)=>{let n=F.current;if(!n)return;if(t&&n.focus({preventScroll:!0}),e)return n.select();let r=n.value.length,[i,a]=ee.current.get(B.current)??[r,r];ee.current.delete(B.current),n.setSelectionRange(Math.min(i,r),Math.min(a,r))},[]),re=(0,d.useCallback)((e=!1)=>requestAnimationFrame(()=>ne(e)),[ne]),ie=(0,d.useRef)(null),ae=(0,d.useRef)(!1),oe=(0,d.useCallback)((e,t,n=!0)=>{e&&(ie.current?.(),ie.current=null,ae.current=!1),te(),e===z.current?(t(),n&&re()):kZ(e?`open`:`close`,t,()=>ne(!1,n))},[te,ne,re]);(0,d.useEffect)(()=>{g&&(DS(uS.ask),ne(!0),re(!0))},[g,re,ne]);let se=(0,d.useCallback)((e,t)=>oe(!0,()=>{t&&D(t),j(null),L(!1),b({open:!0,page:`thread`,selected:e})}),[b,oe]);(0,d.useEffect)(()=>{let t=e.id;lQ.push(t),uQ&&=(se(uQ.id,uQ.thread),null);let n=e=>{let{id:t,thread:n}=e.detail;se(t,n)};return window.addEventListener(cX,n),()=>{lQ.splice(lQ.indexOf(t),1),window.removeEventListener(cX,n)}},[se,e.id]);let H=S===`thread`?s.find(e=>e.id===C)??(E?.id===C?E:void 0):void 0,W=x&&(S===`new`||!!H);z.current=W,(0,d.useEffect)(()=>{W||sC()},[W]);let G=(0,d.useCallback)(()=>oe(!1,()=>b({open:!1})),[b,oe]),ce=(0,d.useRef)(null),le=(0,d.useCallback)((e,t)=>{if(e){au(ce,t)&&G();return}let n=V(),r=ou(t,e=>{ie.current=null,e&&z.current?(n&&ee.current.set(B.current,n),oe(!1,()=>b({open:!1}),!1)):ae.current=!1});r&&(ae.current=!0,ie.current?.(),ie.current=r)},[G,V,oe,b]);iu(W,ce),Zl(W&&!I,le,ce,void 0,!0),W||(ae.current=!1),(0,d.useEffect)(()=>()=>{ie.current?.();let t=pQ.get(e.id);ae.current&&t&&pQ.set(e.id,{...t,open:!1}),mQ={board:e.id,open:z.current&&!ae.current}},[e.id]);let ue=H?.messages.at(-1)?.id;(0,d.useEffect)(()=>{W&&H&&!sQ(H)&&(l(H),a?.(H.id))},[W,H?.id,ue,l,a]);let de=()=>{j(null),L(e=>!e)},fe=(0,d.useCallback)(e=>{L(!1),e&&R.current?.focus()},[]),pe=()=>oe(!0,()=>{j(null),L(!1),b({open:!0,page:`new`})}),me=e=>se(e),he=e=>{j(null),e.id===C&&S===`thread`&&W&&oe(!1,()=>b({open:!1})),N([e.id])},ge=(e,n)=>{j(null),X.setThreadLens(e.id,t,n).catch(M)},_e=W&&S===`thread`?void 0:W&&S===`new`?`threads`:n,ve=_e===void 0?H.id:_e===`threads`?`new`:`bar`,ye=!W&&n===`threads`?r:void 0,be=RX(ye?.id),K=ye&&tC(ye,be?.blockIds.length),xe=!W&&n===`threads`&&!r?i:void 0,Se=(0,d.useMemo)(()=>xe&&Es(e,xe.named,gc(e,f.map(e=>e.name))),[e,xe,f]),Ce=xe&&nC(xe.path,Se);B.current=ve;let we=T[ve]??``,Te=(e,t)=>b(n=>({drafts:{...n.drafts,[e]:t}})),Ee=_e?Is(_e,m.length):`reply`,De=Ee===`question`&&!p?`thread`:Ee,Oe=(n,r,i,a,o,s,c)=>{let u=new Date().toISOString(),d={kind:`human`,name:t},f=o?Po(o,i):c&&Se?Po({agent:{name:Se}},i):i,p={id:`${oQ}${Date.now().toString(36)}`,title:ic(n,Sc(n,h)),door:r,...o&&{pageId:o.id},...o&&s?.length&&{blockIds:s},startedBy:d,startedAt:u,updatedAt:u,messages:[],...f&&{lens:f}},m=null;mT.send(`thread:${p.id}`,n,[],async u=>{let d=await X.startThread(e.id,t,n,i??void 0,r,a,o?.id,s,c),f={id:d.messages[0].id,place:`thread:${d.id}`};return m=d,mT.arrived(u,f),l(d),D(e=>e?.id===p.id?d:e),b(e=>e.selected===p.id?{selected:d.id}:{}),f},a),ee.current.delete(r===`threads`?`new`:`bar`),oe(!0,()=>{let e=m??p;D(e),b(t=>({open:!0,page:`thread`,selected:e.id,drafts:{...t.drafts,[r===`threads`?`new`:`bar`]:``},...r===`threads`&&{newLens:null}}))})},ke=async(n,r)=>{let{question:i,comment:a}=Ac(r,h.filter(e=>!U(e,t)));if(i){k(!0);try{let r=await n.post(e.id,t,{question:i,comment:a},()=>Te(`bar`,``));r&&j(r)}catch(e){M(e)}finally{k(!1)}}},Ae=W&&S===`thread`?H?.lens:W&&S===`new`?w??void 0:void 0,je=(0,d.useMemo)(()=>De===`question`?void 0:PZ(Ae),[De,Ae]),Me=()=>{let e=we.trim(),{body:n,lens:r}=je?GT(e,je.map(e=>e.name)):{body:e,lens:void 0},i=r?FZ(r,Ae):void 0;if(!n||O)return;if(j(null),!_e){if(!H||sQ(H))return;let e=H.messages.map(e=>e.id);mT.send(`thread:${H.id}`,n,e,async()=>yT((await X.postToThread(H.id,t,n,i)).messages,e,t,n),i),Te(H.id,``);return}if(De===`question`&&p)return void ke(p,n);let a=_e===`threads`&&ye&&be?be:void 0;Oe(n,_e,_e===`threads`?w:null,i,ye,a?.blockIds,_e===`threads`?xe?.path:void 0),a?.clear()},Ne=(e,t)=>{let r=t?`^${t.name} ${e}`:e;if(sQ(H)){let e=H?.door??n,t=e=>()=>{D(null),b(e)};e===`threads`?oe(!0,t(e=>({page:`new`,newLens:H?.lens??null,drafts:{...e.drafts,new:r}}))):oe(!1,t(e=>({open:!1,drafts:{...e.drafts,bar:r}})))}else H&&(Te(H.id,r),re())},Pe=u.waiting.length,Fe=u.waiting.filter(e=>e.thread.id!==H?.id).length,Ie=K??Ce,Le=_e?Ie?Ie.placeholder:_e===`threads`&&w?`What do you want to work through in ${w.name}?`:Fs(_e):VS(H,m),Re=o?null:(0,Q.jsx)(bZ,{docked:W,value:we,onValue:e=>Te(ve,e),onSend:Me,placeholder:Le,label:_e?Ie?Ie.label:_e===`threads`?`Start a new thread`:`Talk to agents from ${Ps(_e)??_e}`:`Reply in ${H.title}`,sendLabel:De===`reply`?`Send`:De===`question`?`Post as a question`:be?`Start a thread about these blocks`:Ce?`Start a thread about this file`:`Start a thread`,busy:O||sQ(H),field:F,lenses:je,threads:W?void 0:{count:Pe,open:I,onOpen:de,button:R},context:be?{label:`${be.blockIds.length} block${be.blockIds.length===1?``:`s`}`,title:`What the thread you start is about:\n${be.names.join(`
94
+ `)}`,onRemove:()=>{be.clear(),re()}}:void 0,error:W?null:A}),ze=I&&(0,Q.jsx)(JZ,{groups:u,name:t,current:W?H?.id:void 0,readOnly:o,docked:W,onOpen:me,onNew:pe,onDelete:he,onClose:fe,toggle:R});if(!W)return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`chat-float`,children:[ze,Re??(0,Q.jsxs)(`button`,{type:`button`,className:`chat-threads-only`,ref:R,onClick:de,"aria-expanded":I,"aria-haspopup":`dialog`,children:[(0,Q.jsx)($,{name:`thread`}),` Threads`]})]}),P&&(0,Q.jsx)(`div`,{className:`threads-toast`,children:P})]});let Be=(0,Q.jsx)(`button`,{type:`button`,className:`dock-close`,onClick:G,"aria-label":`Close the conversation`,title:`Close (Esc)`,children:(0,Q.jsx)($,{name:`x`})});return(0,Q.jsxs)(`aside`,{className:`thread-dock`,ref:ce,"aria-label":`Threads`,children:[(0,Q.jsxs)(`header`,{className:`dock-head`,children:[(0,Q.jsxs)(`button`,{type:`button`,ref:R,className:`dock-back`,onClick:de,"aria-expanded":I,"aria-haspopup":`dialog`,"aria-label":`All threads${Fe?`, ${Fe} waiting on you`:``}`,children:[(0,Q.jsx)($,{name:`arrow-left`}),` Threads`,Fe>0&&(0,Q.jsx)(`span`,{className:`dock-count`,"aria-hidden":!0,children:Fe})]}),Be]}),ze,A&&(0,Q.jsx)(`p`,{className:`error threads-error`,role:`alert`,children:A}),S===`thread`&&H&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_Q,{board:e,thread:H,readOnly:o||sQ(H),onPick:e=>ge(H,e)}),(0,Q.jsx)(vQ,{board:e,thread:H,name:t,onOpen:gQ,onEdit:Ne})]}),S===`new`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`dock-title`,children:(0,Q.jsx)(`h2`,{className:`dock-heading`,children:`New thread`})}),!o&&(0,Q.jsx)(UZ,{lens:w??void 0,onPick:e=>b({newLens:e})}),(0,Q.jsx)(vQ,{board:e,thread:void 0,name:t,onOpen:gQ,onEdit:Ne})]}),Re&&(0,Q.jsx)(`div`,{className:`dock-foot`,children:Re}),P&&(0,Q.jsx)(`div`,{className:`threads-toast`,children:P})]})}var gQ=()=>{};function _Q(e){let{board:t,thread:n,readOnly:r,onPick:i}=e,a=Uc(t,n),o=Kc(n,t),s=vS().boardContext()?.generalThread;return(0,Q.jsxs)(`div`,{className:`dock-title`,children:[(0,Q.jsx)(`h2`,{className:`dock-heading`,title:ac(n),children:ac(n)}),(0,Q.jsxs)(`div`,{className:`dock-meta`,children:[o&&(0,Q.jsx)(`span`,{className:`dock-door`,children:o}),a.map(e=>(0,Q.jsxs)(`span`,{className:`dock-made`,children:[`→ `,e]},e)),(0,Q.jsxs)(`span`,{className:`dock-when`,title:new Date(n.startedAt).toLocaleString(),children:[`started `,ex(n.startedAt)]}),(0,Q.jsx)(VZ,{lens:n.lens,readOnly:r,onPick:i,label:`${n.lens?.name??`General`} lens`,note:n.general?s:void 0})]})]})}function vQ(e){let{board:t,thread:n,name:r,onOpen:i,onEdit:a}=e,o=hu(),s=(0,d.useRef)(null),c=GE(r),l=gT(n?.messages??[],hT(`thread:${n?.id??``}`),r,e=>cQ(e,r,c)),u=vT(l).join();(0,d.useEffect)(()=>{for(let e of u?u.split(`,`):[])mT.remove(e)},[u]);let f=(0,d.useRef)(null);f.current?.id!==n?.id&&(f.current={id:n?.id,ids:new Set(n?.messages.map(e=>e.id))});let p=e=>e.author.kind===`human`&&U(e.author.name,r),m=l.findLastIndex(e=>e.item.author.kind===`human`),h=m>=0&&p(l[m].item)?m:-1,g=n?fC(t,n.messages):-1,_=g>=0?n.messages[g].id:void 0,v=h>=0?l[h]:void 0,y=!!(v&&n&&(_T(v)||XS(v.item,Date.now())&&(v.outgoing||hc(t,n)?.message.id===v.item.id))),b=l.reduce((e,t)=>e+1+(t.item.refs?.length??0),0)+(n?.pending?.length??0);(0,d.useLayoutEffect)(()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[n?.id,b]);let x=new Map;for(let{by:e,...t}of n?.pending??[]){let n=x.get(e.name)??{by:e,refs:[]};n.refs.push(t),x.set(e.name,n)}return(0,Q.jsxs)(`div`,{className:`threads-conversation`,ref:s,"aria-label":n?`Thread: ${ac(n)}`:`New thread`,role:`region`,children:[n?(0,Q.jsxs)(`ol`,{className:`thread-messages`,children:[l.map((e,o)=>{let s=e.item,c=_T(e),u=s.id===e.outgoing?.key,d=u||sQ(n)?null:(0,Q.jsx)(VE,{item:s,place:{threadId:n.id},name:r}),p=s.author.kind===`agent`&&!f.current.ids.has(s.id),m=c===`sending`?` is-sending`:c===`failed`?` is-unsent`:``;return(0,Q.jsxs)(`li`,{id:u?void 0:qE(s.id),className:`thread-message${p?` is-arriving`:``}${m}`,onAnimationEnd:e=>e.currentTarget.classList.remove(`is-flash`),children:[(0,Q.jsx)(ix,{actor:s.author,showName:!1}),(0,Q.jsxs)(`div`,{className:`thread-message-main`,children:[(0,Q.jsxs)(`div`,{className:`thread-message-head`,children:[(0,Q.jsx)(`strong`,{children:s.author.name}),(0,Q.jsx)(dC,{board:t,said:s}),s.lens&&(0,Q.jsx)(yQ,{lens:s.lens,thread:n}),(0,Q.jsx)(`span`,{className:`thread-message-time`,title:new Date(s.at).toLocaleString(),children:ex(s.at)}),(0,Q.jsx)(gE,{via:s.via})]}),(0,Q.jsx)(mE,{comment:s}),s.refs?.length?(0,Q.jsx)(xQ,{board:t,refs:s.refs,onOpen:i}):null,c||o===h||s.id===_?(0,Q.jsx)(PT,{board:t,where:{thread:n},said:s,after:l.slice(o+1).map(e=>e.item),onItsWay:c,outgoing:e.outgoing,onEdit:a,onConnect:i,children:d}):d]})]},e.key)}),[...x.values()].map(({by:e,refs:n})=>(0,Q.jsxs)(`li`,{className:`thread-message`,children:[(0,Q.jsx)(ix,{actor:e,showName:!1}),(0,Q.jsxs)(`div`,{className:`thread-message-main`,children:[(0,Q.jsxs)(`div`,{className:`thread-message-head`,children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.jsx)(`span`,{className:`thread-message-time`,children:`made, ahead of a reply`})]}),(0,Q.jsx)(xQ,{board:t,refs:n,onOpen:i})]})]},`ahead:${e.name}`))]}):o?(0,Q.jsx)(`p`,{className:`threads-intro`,children:`No threads.`}):(0,Q.jsx)(`p`,{className:`threads-intro`,children:`Start a thread to work something through with agents. @ an agent to ask that one.`}),n&&(0,Q.jsx)(pC,{board:t,items:n.messages,className:`threads-quiet`}),!o&&!y&&(0,Q.jsx)(bQ,{board:t,thread:n})]})}function yQ({lens:e,thread:t}){let n=t.lens?`, in place of the thread's ${t.lens.name} lens`:``,r=e.name===`General`?`Asked agents to answer without a lens`:`Asked agents to answer through the ${e.name} lens`;return(0,Q.jsx)(`span`,{className:`thread-message-lens`,title:`${r}, for this message alone${n}.`,children:(0,Q.jsxs)(BZ,{lens:e,children:[`^`,e.name]})})}function bQ({board:e,thread:t}){let n=uT().filter(e=>e.state!==`away`),r=t?hc(e,t):void 0;if(n.length===0)return(0,Q.jsx)(`p`,{className:`threads-quiet`,children:`No agent listening. What you write waits until an agent connects.`});if(!r)return null;let i=r.agents;return i.length&&!i.some(e=>n.some(t=>U(t.name,e)))?(0,Q.jsxs)(`p`,{className:`threads-quiet`,children:[G(i),` `,i.length===1?`isn't`:`aren't`,` listening. It waits until `,i.length===1?`it connects`:`they connect`,`.`]}):(0,Q.jsxs)(`p`,{className:`threads-quiet`,children:[`Waiting for `,i.length?G(i):`an agent`,` to reply.`]})}function xQ({board:e,refs:t,onOpen:n}){return(0,Q.jsx)(`ul`,{className:`work-cards`,"aria-label":`What it led to`,children:t.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(SQ,{board:e,item:t,onOpen:n})},`${t.kind}:${t.id}`))})}function SQ({board:e,item:t,onOpen:n}){let r=mx(),i=jb(),a=vS().boardContext()?.name??`board`,o=dc(e,t);if(`card`in o)return r.workCard(o.kind,{board:e,id:o.card.id,onOpen:n});switch(o.kind){case`block`:{let{block:t,on:i,page:s}=o,c=t.title??Dn(t).replace(/^\w+ "(.*)"$/,`$1`),l=i?`${i.label}'s canvas`:s?`Sketchbook page “${s.title}”`:a,u=i?r.byId(i.kind.kind,e.id,i.id)?.href:s?dS.page(e.id,s.id):dS.context(e.id);return(0,Q.jsxs)(hx,{className:`work-card is-row`,href:u,title:`${c}, on the ${l}`,onClick:()=>{_X(t.id),n()},children:[(0,Q.jsxs)(`span`,{className:`work-meta`,children:[(0,Q.jsx)($,{name:`canvas`}),t.type.charAt(0).toUpperCase()+t.type.slice(1)]}),(0,Q.jsx)(`span`,{className:`work-title`,children:c}),(0,Q.jsxs)(`span`,{className:`work-where`,children:[`on the `,l]})]})}case`comment`:{let{comment:t,on:i}=o,a=r.byId(i.kind.kind,e.id,i.id)?.href;return(0,Q.jsxs)(hx,{className:`work-card`,href:a,onClick:()=>{JE([t.id]),n()},children:[(0,Q.jsxs)(`span`,{className:`work-meta`,children:[(0,Q.jsx)($,{name:`comment`}),`Comment on `,i.label]}),(0,Q.jsx)(`span`,{className:`work-quote`,children:H(t.body.replace(/\s+/g,` `),160)})]})}case`gone`:return(0,Q.jsx)(`span`,{className:`work-card is-gone`,children:CQ(mc(e,t,(e,t)=>i?.label(e,t)))})}}var CQ=e=>e.charAt(0).toUpperCase()+e.slice(1),wQ=3;function TQ(e){let t=fu(),n=(0,d.useRef)(Date.now()),r=(0,d.useRef)(new Set);(0,d.useEffect)(()=>{if(Cx())return window.addEventListener(`pointerdown`,yx,{once:!0}),()=>window.removeEventListener(`pointerdown`,yx)},[]),(0,d.useEffect)(()=>{let i=e.filter(e=>!r.current.has(e.key)&&Date.parse(e.at)>=n.current);for(let t of e)r.current.add(t.key);if(i.length!==0&&t&&Cx()){for(let e of i.slice(0,wQ))try{let t=new Notification(e.title,{body:e.body,tag:e.key});t.onclick=()=>{window.focus(),e.open(),t.close()}}catch{}Tx()}},[e,t])}function EQ(){let e=(0,d.useId)(),[t,n]=(0,d.useState)(Cx),[r,i]=(0,d.useState)(null),a=async e=>{if(i(null),!e){Sx(!1),n(!1);return}let t=await wx();n(t),t||i(Notification.permission===`denied`?`This browser is blocking notifications from Tricot. Allow them in its site settings, then switch this on again.`:`The browser did not allow notifications, so they stay off.`)};return(0,Q.jsxs)(`div`,{className:`bell-notify`,children:[(0,Q.jsxs)(`label`,{className:`bell-switch`,htmlFor:e,children:[(0,Q.jsx)(`input`,{id:e,type:`checkbox`,role:`switch`,checked:t,disabled:!Ex,onChange:e=>void a(e.target.checked)}),(0,Q.jsx)(`span`,{children:`Sound and desktop notifications`})]}),(0,Q.jsx)(`p`,{className:`bell-note`,children:Ex?`When something here needs you and this tab is in the background.`:`This browser cannot show desktop notifications.`}),r&&(0,Q.jsx)(`p`,{className:`bell-note bell-refused`,role:`alert`,children:r})]})}function DQ({board:e,name:t,away:n}){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(null),o=(0,d.useCallback)(()=>i(!1),[]);Zl(r,o,a);let{seen:s}=aQ(e),c=(0,d.useMemo)(()=>Xc(e,t,s),[e,t,s]),l=(0,d.useMemo)(()=>$c(e,n.events,t,s),[e,n.events,t,s]),u=nl(e),f=Fx(),p=(0,d.useMemo)(()=>yt(f,u),[f,u]),m=c.length+l.length+p.length,h=(0,d.useCallback)(({event:t,place:r})=>{t.itemId&&n.markSeen(t.itemId),r.kind===`thread`?dQ(r.thread.id,r.thread):CS.pin(e.id,r.pinId)},[n,e.id]);TQ((0,d.useMemo)(()=>[...c.map(e=>{let t=e.messages.at(-1);return{key:`thread:${e.id}:${t.id}`,at:t.at,title:`${t.author.name} replied in ${H(e.title,60)}`,body:H(t.body,140),open:()=>dQ(e.id,e)}}),...l.map(e=>({key:`comment:${e.said.id}`,at:e.event.at,title:`${e.said.author.name} ${e.why===`mention`?`mentioned you`:`replied to you`}`,body:H(e.said.body,140),open:()=>h(e)}))],[c,l,h]));let g=m===0?`Notifications: nothing new`:`Notifications: ${m} new`,_=e=>()=>{o(),e()};return(0,Q.jsxs)(`div`,{className:`inbox bell`,ref:a,children:[(0,Q.jsxs)(`button`,{className:`inbox-button${m?` has-new`:``}`,onClick:()=>i(!r),"aria-expanded":r,"aria-haspopup":`dialog`,"aria-label":g,title:g,children:[(0,Q.jsx)($,{name:`bell`}),m>0&&(0,Q.jsx)(`span`,{className:`inbox-count`,children:m})]}),r&&(0,Q.jsxs)(`div`,{className:`inbox-panel`,role:`dialog`,"aria-label":`Notifications`,children:[(0,Q.jsxs)(`div`,{className:`bell-sections`,children:[m===0&&(0,Q.jsx)(`p`,{className:`inbox-empty`,children:`Nothing new for you.`}),p.length>0&&(0,Q.jsx)(OQ,{title:`Agents waiting for your OK`,children:p.map(e=>(0,Q.jsx)(AQ,{approval:e,onOpen:_(()=>qx(e.id))},e.id))}),c.length>0&&(0,Q.jsx)(OQ,{title:`Threads waiting on you`,children:c.map(e=>(0,Q.jsx)(jQ,{thread:e,onOpen:_(()=>dQ(e.id,e))},e.id))}),l.length>0&&(0,Q.jsx)(OQ,{title:`New mentions and replies`,children:l.map(e=>(0,Q.jsx)(MQ,{item:e,onOpen:_(()=>h(e))},e.key))})]}),(0,Q.jsx)(EQ,{})]})]})}function OQ({title:e,children:t}){return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`bell-heading`,children:e}),(0,Q.jsx)(`ol`,{className:`inbox-list`,children:t})]})}function kQ({actor:e,subject:t,meta:n,onOpen:r,children:i}){return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{className:`inbox-item is-for-you`,onClick:r,children:[(0,Q.jsx)(ix,{actor:e,showName:!1}),(0,Q.jsxs)(`span`,{className:`inbox-text`,children:[(0,Q.jsx)(`span`,{className:`inbox-subject`,children:t}),(0,Q.jsx)(`span`,{children:i}),(0,Q.jsx)(`span`,{className:`inbox-meta`,children:(0,Q.jsx)(`span`,{children:n})})]})]})})}function AQ({approval:e,onOpen:t}){let n=e.on?.title;return(0,Q.jsxs)(kQ,{actor:{kind:`agent`,name:e.agent},subject:_t(e),meta:`${ex(e.at)} · answer at the foot of the page`,onOpen:t,children:[ht(e),n&&(0,Q.jsxs)(`span`,{className:`faint`,children:[` · `,n]})]})}function jQ({thread:e,onOpen:t}){let n=e.messages.at(-1);return(0,Q.jsxs)(kQ,{actor:n.author,subject:e.title,meta:ex(n.at),onOpen:t,children:[(0,Q.jsx)(`strong`,{children:n.author.name}),` `,H(n.body,140)]})}function MQ({item:e,onOpen:t}){let{said:n,event:r,why:i,place:a}=e,o=a.kind===`thread`?a.thread.title:ko(a.page);return(0,Q.jsxs)(kQ,{actor:n.author,subject:o,meta:`${i===`mention`?`Mentioned you`:`Replied to you`} · ${ex(r.at)}`,onOpen:t,children:[(0,Q.jsx)(`strong`,{children:n.author.name}),` `,H(n.body,140)]})}var NQ=`tricot:boards`;function PQ(e=NQ){let t=new Set,n=null;try{n=new BroadcastChannel(e),n.onmessage=()=>r()}catch{}function r(){for(let e of[...t])e()}return{notify:()=>{n?.postMessage(`changed`),r()},listen:e=>(t.add(e),()=>t.delete(e)),close:()=>n?.close()}}var FQ,IQ=()=>FQ??=PQ(),LQ=()=>IQ().notify(),RQ=e=>IQ().listen(e);async function zQ(e,t,n){let r=await X.updateBoard(e,t,n);return LQ(),r}async function BQ(e,t,n){let r=await X.archiveBoard(e,t,n);return LQ(),r}function VQ(e,t){let n=t.title.trim(),r=t.goal.trim();if(!n)return{error:`A board needs a title.`};let i={};return n!==e.title&&(i.title=n),r!==(e.goal??``)&&(i.goal=r),Object.keys(i).length?{patch:i}:null}var HQ=e=>e?`Edit the goal…`:`Add a goal…`;function UQ(e){return e.archived?[`rename`,`goal`,`connectors`,`unarchive`,`delete`]:[`rename`,`goal`,`connectors`,`archive`]}function WQ(e,t){let n=new Set(t),r=new Set([...e].filter(e=>n.has(e)));return r.size===e.size?e:r}var GQ=()=>({actors:[]}),KQ=(e,t)=>e.kind===t.kind&&U(e.name,t.name),qQ=[];function JQ(e,t,n=qQ){let r=e.actors.findIndex(e=>KQ(e.actor,t.actor));r>=0&&e.actors.splice(r,1),e.actors.unshift({actor:t.actor,at:t.at});for(let r of n)r(e,t)}var YQ=[`task_reordered`,`comment_reacted`],XQ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ZQ={page:`pages`,thread:`threads`,request:`requests`,deletion:`deleted`},QQ=e=>Object.hasOwn(ZQ,e)?ZQ[e]:Tt(e)?.list,$Q={block:`blocks`,group:`groups`,link:`links`,pin:`pins`},e$=class{copied=new WeakSet;object(e,t){let n=e[t];if(XQ(n)&&this.copied.has(n))return n;let r=XQ(n)?{...n}:{};return this.copied.add(r),e[t]=r,r}list(e,t){let n=e[t];if(Array.isArray(n)&&this.copied.has(n))return n;let r=Array.isArray(n)?[...n]:[];return this.copied.add(r),e[t]=r,r}item(e,t){return this.copied.has(e[t])||(e[t]={...e[t]},this.copied.add(e[t])),e[t]}},t$=(e,t)=>e.findIndex(e=>e.id===t);function n$(e,t){let n={...e};for(let[e,r]of Object.entries(t.set??{}))n[e]=r;for(let e of t.unset??[])delete n[e];for(let[e,{from:r,items:i}]of Object.entries(t.append??{})){let t=Array.isArray(n[e])?n[e]:[];if(t.length===r)n[e]=[...t,...i];else if(t.length<r+i.length)return null}return n}var r$=e=>e===`page`?`pages`:Tt(e)?.list;function i$(e,t,n){if(n===`board`)return e.object(t,`canvas`);let[r,i]=n.split(/:(.*)/s),a=r$(r);if(!a)return;let o=e.list(t,a),s=t$(o,i);return s<0?void 0:e.object(e.item(o,s),`canvas`)}function a$(e,t,n){if(!n.owner){let r=QQ(n.kind);return r?e.list(t,r):void 0}let r=i$(e,t,n.owner),i=$Q[n.kind];return r&&i?e.list(r,i):void 0}function o$(e,t){return r$(e.kind)?{...e.body,id:e.id,canvas:t?.canvas??En()}:e.body}function s$(e){let t=e??GQ(),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?[...r]:XQ(r)?{...r}:r;return n}function c$(e,t){if(t.reload)return null;let n={...e},r=new e$,i=(t.events??[]).filter(t=>t.seq>e.seq);if(i.length){let t=s$(e.activity);for(let e of i)JQ(t,e);n.activity=t}Object.assign(n,t.head);for(let e of t.gone??[])delete n[e];n.seq=Math.max(e.seq,t.seq),n.ver=t.ver;for(let e of t.del??[]){let t=a$(r,n,e),i=t?t$(t,e.id):-1;t&&i>=0&&t.splice(i,1)}let a=[...t.put??[]].sort((e,t)=>Number(!!e.owner)-Number(!!t.owner)||e.pos-t.pos);for(let e of a){let t=a$(r,n,e);if(!t)return null;let i=t$(t,e.id);i>=0?t[i]=o$(e,t[i]):t.splice(Math.min(e.pos,t.length),0,o$(e,void 0))}for(let e of t.patch??[]){let t=a$(r,n,e),i=t?t$(t,e.id):-1,a=t&&i>=0?n$(t[i],e):null;if(!t||!a)return null;t[i]=a}return n}function l$(e){let t=[e.canvas,...Ot(e).map(e=>e.canvas),...(e.pages??[]).map(e=>e.canvas)],n=e=>t.reduce((t,n)=>t+(n?.[e]?.length??0),0);return{...Object.fromEntries(wt().map(({kind:t,list:n})=>[n,Dt(e,t).length])),pages:e.pages?.length??0,threads:e.threads?.length??0,requests:e.requests?.length??0,deleted:e.deleted?.length??0,blocks:n(`blocks`),groups:n(`groups`),links:n(`links`),pins:n(`pins`)}}var u$=(e,t)=>Object.keys(e).every(n=>e[n]===t[n]);function d$(e,t){let{unseenBy:n,...r}=t;for(let[t,n]of Object.entries(r))if(n!==void 0&&e[t]!==n)return!1;return!(n!==void 0&&(YQ.includes(e.type)||e.actor.kind===`human`&&U(e.actor.name,n)))}var f$=500,p$=1e3,m$=class{events=[];base=-1;top=-1;reset(e){this.events=[],this.base=this.top=e}push(e,t){if(!(this.base<0)){for(let t of e??[])t.seq>this.top&&this.events.push(t);if(this.top=Math.max(this.top,t),this.events.length>p$){let e=this.events.splice(0,this.events.length-p$);this.base=e[e.length-1].seq}}}since(e,t){if(!(this.base<0||e<this.base||t>this.top))return this.events.filter(n=>n.seq>e&&n.seq<=t)}},h$=new Map;function g$(e){let t=h$.get(e);return t||h$.set(e,t=new m$),t}async function _$(e,t,n){return g$(e).since(t,n)??v$(e,t)}async function v$(e,t){let n=[];for(;;){let r=await X.events(e,{since:n.at(-1)?.seq??t,limit:f$});if(n.push(...r.events),!r.more)return n}}var y$=`tricot:seen:`,b$=e=>`${y$}${e}`;function x$(e){try{let t=localStorage.getItem(b$(e));return t===null?null:Number(t)}catch{return null}}function S$(){let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(!n?.startsWith(y$))continue;let r=Number(localStorage.getItem(n));Number.isInteger(r)&&r>=0&&(e[n.slice(12)]=r)}}catch{}return e}function C$(e){try{localStorage.removeItem(b$(e))}catch{}}function w$(e,t){try{localStorage.setItem(b$(e),String(t))}catch{}}var T$=18e5,E$=e=>`tricot:visit:${e}`;function D$(e){try{let t=JSON.parse(sessionStorage.getItem(E$(e))??`null`);return t&&Number.isInteger(t.seq)?t:null}catch{return null}}function O$(e,t){try{sessionStorage.setItem(E$(e),JSON.stringify(t))}catch{}}function k$(e,t){let n=D$(e),r=n&&(n.leftAt===void 0||Date.now()-n.leftAt<T$)?Math.min(n.seq,t):t;return O$(e,{seq:r}),r}function A$(e){let t=D$(e);t&&O$(e,{seq:t.seq,leftAt:Date.now()})}function j$(e,t){let n=e?nl(e):void 0,r=(0,d.useRef)(0),[i,a]=(0,d.useState)(null),o=i&&i.boardId===n?i.seq:null,[s,c]=(0,d.useState)(null),l=s&&s.boardId===n?s.seq:null,[u,f]=(0,d.useState)(new Set);(0,d.useEffect)(()=>{r.current=e?.seq??0},[e]),(0,d.useEffect)(()=>{if(!e||nl(e)!==n||o!==null)return;let t=x$(n)??e.seq;a({boardId:n,seq:t}),c({boardId:n,seq:k$(n,t)})},[e,n,o]),(0,d.useEffect)(()=>{if(!n)return;let e=()=>{w$(n,r.current),A$(n)},t=()=>{if(document.visibilityState===`hidden`)return e();let t=x$(n)??r.current;a({boardId:n,seq:t}),c({boardId:n,seq:k$(n,t)}),f(new Set)};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,e),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,e)}},[n]);let p=`${n}|${l}`,[m,h]=(0,d.useState)({scope:``,events:[]}),g=(0,d.useRef)(m);g.current=m;let _=e?.seq,v=(0,d.useRef)({scope:``,seq:0});(0,d.useEffect)(()=>{if(!n||l===null||_===void 0)return;let e=!1,t=g.current.scope===p?g.current.events:[],r=v.current.scope===p?v.current.seq:l;return _$(n,r,_).then(n=>{if(e)return;v.current={scope:p,seq:_};let r=n.filter(e=>e.seq>(t.at(-1)?.seq??0));(r.length||g.current.scope!==p)&&h({scope:p,events:[...t,...r]})}).catch(()=>{}),()=>{e=!0}},[n,l,_,p]);let y=(0,d.useMemo)(()=>m.scope===p?m.events:[],[m,p]),b=(0,d.useMemo)(()=>o===null?[]:y.filter(e=>e.seq>o&&d$(e,{unseenBy:t})),[y,o,t]),x=(0,d.useMemo)(()=>new Set(b.map(e=>e.seq)),[b]),S=(0,d.useCallback)(e=>{if(!x.has(e.seq))return!1;let t=lx(e)?.id??e.itemId;return!t||!u.has(t)},[x,u]),C=(0,d.useMemo)(()=>b.filter(S),[b,S]),w=(0,d.useMemo)(()=>new Set(C.flatMap(e=>{let t=Lt(e,`decision`);return t&&!Lt(e,`task`)?[t]:[]})),[C]),T=(0,d.useMemo)(()=>new Set(b.flatMap(e=>e.itemId&&!u.has(e.itemId)?[e.itemId]:[])),[b,u]),E=(0,d.useMemo)(()=>{let t=new Set;for(let n of C){let r=e&&n.type===`canvas_changed`&&n.itemId?Fo(e,n.itemId):void 0;r&&t.add(r.id)}return t},[C,e]),D=C.some(t=>t.type===`canvas_changed`&&!Lt(t,`decision`)&&!(e&&t.itemId&&Fo(e,t.itemId))),O=e?.createdAt,k=M$(n,o,O),A=M$(n,l===o?null:l,O),j=l===o?k:A;return{events:C,isNew:S,decisions:w,items:T,boardCanvasChanged:D,pagesChanged:E,sinceAt:k,visit:(0,d.useMemo)(()=>({events:y,sinceAt:j}),[y,j]),markSeen:(0,d.useCallback)(e=>{f(t=>t.has(e)?t:new Set([...t,e]))},[]),markAllSeen:(0,d.useCallback)(()=>{n&&(w$(n,r.current),a({boardId:n,seq:r.current}),f(new Set))},[n])}}function M$(e,t,n){let[r,i]=(0,d.useState)({scope:``,at:null});return(0,d.useEffect)(()=>{if(!e||t===null||n===void 0)return;let r=`${e}|${t}`;if(t===0)return i({scope:r,at:n});let a=!1;return X.events(e,{since:t-1,limit:1}).then(e=>!a&&i({scope:r,at:e.events[0]?.seq===t?e.events[0].at:null})).catch(()=>{}),()=>{a=!0}},[e,t,n]),r.scope===`${e}|${t}`?r.at:null}var N$=`tricot:needs-dismissed`;function P$(e,t=!0){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!t)return;let n=!1,i=()=>X.needs(e,S$()).then(e=>{n||(r(e),a(null))},e=>!n&&a(e.message));i();let o=setInterval(i,5e3);window.addEventListener(`focus`,i),window.addEventListener(N$,i);let s=RQ(i);return()=>{n=!0,clearInterval(o),window.removeEventListener(`focus`,i),window.removeEventListener(N$,i),s()}},[e,t]),{report:n,error:i}}var F$=5e4,I$=1e4,L$=3e3,R$=300,z$=2,B$=e=>e.status===404,V$=class{session;board;source;heardAt=Date.now();loading=!1;again=!1;stopped=!1;watchdog;retry;constructor(e){this.session=e,this.board=e.held??null}start(){this.watchdog=setInterval(()=>{Date.now()-this.heardAt>F$&&this.reconnect()},I$),this.board?.ver===void 0?this.reload():this.connect(this.board.ver)}stop(){this.stopped=!0,clearInterval(this.watchdog),clearTimeout(this.retry),this.source?.close()}recheck(){this.stopped||(this.source?.readyState===z$&&this.reconnect(),this.verify())}async reload(){if(this.loading)this.again=!0;else{this.loading=!0,this.source?.close(),this.source=void 0;try{let e=await this.session.fetchBoard();if(this.stopped)return;this.session.feed(e).reset(e.seq),this.board=e,this.session.onBoard(e),this.session.onError(null),e.ver!==void 0&&this.connect(e.ver)}catch(e){if(this.stopped)return;if(this.board&&B$(e))return this.gone();this.session.onError(e.message),this.retry=setTimeout(()=>void this.reload(),L$)}finally{this.loading=!1,this.again&&!this.stopped&&(this.again=!1,this.reload())}}}connect(e){this.source?.close(),this.heardAt=Date.now();let t=this.session.open(Jr(J.boardStream,{boardId:this.session.boardId},{since:String(e)}));this.source=t,t.onopen=()=>this.session.onLive(!0),t.onerror=()=>{this.session.onLive(!1),t.readyState===z$&&!this.stopped&&(this.retry=setTimeout(()=>this.reconnect(),L$),this.verify())};let n=(e,n)=>t.addEventListener(e,e=>{t===this.source&&(this.heardAt=Date.now(),n(JSON.parse(e.data)))});n(`hello`,()=>{}),n(`change`,e=>this.change(e)),n(`presence`,e=>this.presence(e)),n(`steps`,e=>this.session.onSteps?.(e)),n(`approvals`,e=>this.session.onApprovals?.(e)),n(`admissions`,e=>this.session.onAdmissions?.(e)),n(`ping`,e=>this.compare(e)),n(`reset`,()=>void this.reload()),n(`deleted`,()=>this.gone())}gone(){this.stopped||(this.stop(),this.session.onDeleted())}reconnect(){clearTimeout(this.retry),this.board?.ver===void 0?this.reload():this.connect(this.board.ver)}change(e){let t=this.board;if(!t||t.ver===void 0||e.ver<=t.ver)return;if(e.ver!==t.ver+1)return this.reconnect();let n=c$(t,e);n?(this.session.feed(n).push(e.events,e.seq),this.board=n,this.session.onBoard(n)):this.reload()}presence(e){this.board&&(this.board={...this.board,presence:e},this.session.onBoard(this.board))}compare(e){let t=this.board;if(t&&t.ver!==void 0){if(e.ver>t.ver)return this.reconnect();e.ver===t.ver&&!this.agrees(e,t)&&this.verify()}}agrees(e,t){return e.seq===t.seq&&u$(e.tally,l$(t))}async verify(){for(let e=0;e<2;e++){let t;try{t=await this.session.fetchLive()}catch(e){return B$(e)?this.gone():void 0}let n=this.board;if(this.stopped||!n||n.ver===void 0)return;if(t.ver>n.ver)return this.reconnect();if(t.ver<n.ver||this.agrees(t,n))return;e===0&&await new Promise(e=>setTimeout(e,R$))}this.reload()}};function H$(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null),[u]=(0,d.useState)(()=>new Bw);return(0,d.useEffect)(()=>{u.set([]);let t=l.current?.id===e?l.current:null;l.current=t,n(t),i(null),c(!1);let r=new V$({boardId:e,held:t,feed:e=>g$(nl(e)),fetchBoard:()=>X.board(e),fetchLive:()=>X.live(e),open:e=>new Rl(e),onBoard:e=>{l.current=e,n(e)},onError:i,onLive:o,onDeleted:()=>c(!0),onSteps:e=>u.set(e),onApprovals:e=>Hl.set(e),onAdmissions:e=>zl.set(e)}),a=()=>document.visibilityState===`visible`&&r.recheck();return document.addEventListener(`visibilitychange`,a),window.addEventListener(`focus`,a),window.addEventListener(`online`,a),r.start(),()=>{document.removeEventListener(`visibilitychange`,a),window.removeEventListener(`focus`,a),window.removeEventListener(`online`,a),r.stop()}},[e,u]),{board:t&&(t.id===e||t.aliases?.includes(e))?t:null,error:r,live:a,deleted:s,steps:u}}function U$(){let[e,t]=(0,d.useState)(null),n=(0,d.useCallback)(()=>{X.boards().then(t,()=>{})},[]);return(0,d.useEffect)(()=>{n();let e=setInterval(n,5e3);window.addEventListener(`focus`,n);let t=RQ(n);return()=>{clearInterval(e),window.removeEventListener(`focus`,n),t()}},[n]),{boards:e,refresh:n}}var W$={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`},G$=e=>{let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``},K$=e=>W$[G$(e)];function q$(e){let t=G$(e);if(t===`md`||t===`markdown`)return`markdown`;if(t===`mmd`||t===`mermaid`)return`mermaid`;if(t===`csv`||t===`tsv`)return`table`;if(W$[t])return`image`}var J$=e=>q$(e)!==`image`||G$(e)===`svg`;function Y$(e,t=`,`){let n=[],r=[],i=``,a=!1;for(let o=0;o<e.length;o++){let s=e[o];a?s===`"`&&e[o+1]===`"`?(i+=`"`,o++):s===`"`?a=!1:i+=s:s===`"`&&i===``?a=!0:s===t?(r.push(i),i=``):s===`
95
+ `||s===`\r`?(s===`\r`&&e[o+1]===`
96
+ `&&o++,r.push(i),n.push(r),r=[],i=``):i+=s}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function X$({board:e,name:t,onClose:n}){let r=(0,d.useId)(),i=(0,d.useRef)(null),[a,o]=(0,d.useState)(e.folder??``),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(!1),m=async()=>{p(!0),u(null);try{let{folder:e}=await X.chooseFolder();e&&o(e)}catch(e){u(e.message)}finally{p(!1),i.current?.querySelector(`input`)?.focus()}};return(0,d.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&!s&&(e.preventDefault(),n()),e.key!==`Tab`)return;let t=[...i.current?.querySelectorAll(`input:not([disabled]), button:not([disabled])`)??[]],r=t[0],a=t.at(-1);e.shiftKey&&document.activeElement===r?(e.preventDefault(),a?.focus()):!e.shiftKey&&document.activeElement===a&&(e.preventDefault(),r?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,n]),(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!s&&n(),children:(0,Q.jsxs)(`form`,{ref:i,className:`delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${r}-title`,onSubmit:async r=>{if(r.preventDefault(),!s){c(!0);try{await zQ(e.id,t,{folder:a.trim()||null}),n()}catch(e){u(e.message),c(!1),i.current?.querySelector(`input`)?.focus()}}},children:[(0,Q.jsx)(`h2`,{id:`${r}-title`,children:`Project folder`}),(0,Q.jsx)(`p`,{children:`The folder this board is about, on this computer.`}),(0,Q.jsx)(`label`,{className:`delete-label`,htmlFor:`${r}-folder`,children:`Folder`}),(0,Q.jsxs)(`div`,{className:`folder-field`,children:[(0,Q.jsx)(`input`,{id:`${r}-folder`,value:a,onChange:e=>{o(e.target.value),u(null)},onFocus:e=>e.currentTarget.select(),placeholder:`~/code/my-project`,autoFocus:!0,autoComplete:`off`,spellCheck:!1,readOnly:s,"aria-describedby":`${r}-hint`,"aria-invalid":!!l}),(0,Q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void m(),disabled:s||f,title:`Open this computer's folder dialog`,children:f?`Choosing…`:`Choose…`})]}),(0,Q.jsx)(`p`,{id:`${r}-hint`,children:`Choose it, or type a full path or ~/… inside your home folder. Leave empty to remove it.`}),l&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:l}),(0,Q.jsxs)(`div`,{className:`delete-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,disabled:s,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:s,children:`Save`})]})]})}),document.body)}var Z$=e=>e.slice(e.lastIndexOf(`/`)+1);function Q$(e,t){let n=0;for(let r of t){if(n=e.indexOf(r,n),n<0)return!1;n++}return!0}function $$(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.toLowerCase(),i=Z$(r);if(i===n)return 100;if(i.startsWith(n))return 90;if(i.includes(n))return 70;if(r.includes(n))return 50;if(!n.includes(`/`)&&Q$(i,n))return 30;if(Q$(r,n))return 10}var e1=50;function t1(e,t){let n=e.flatMap(e=>{let n=$$(e.path,t);return n===void 0?[]:[{file:e,score:n}]});return n.some(e=>e.score>=e1)?n.filter(e=>e.score>=e1):n}function n1(e,t,n,r){let i=e.filter(e=>(n!==`week`||e.week)&&(n!==`board`||r.has(e.path)));return t.trim()?t1(i,t).map(e=>e.file):i}function r1(e,t,n){return t1(e,t).sort((e,t)=>t.score-e.score||e.file.path.length-t.file.path.length||(e.file.path<t.file.path?-1:1)).slice(0,n).map(e=>e.file)}function i1(e){let t={name:``,path:``,folders:[],files:[],count:0},n=new Map([[``,t]]),r=e=>{let t=n.get(e);if(t)return t;let i=e.lastIndexOf(`/`),a=r(i<0?``:e.slice(0,i)),o={name:e.slice(i+1),path:e,folders:[],files:[],count:0};return a.folders.push(o),n.set(e,o),o};for(let t of e){let e=t.path.lastIndexOf(`/`);r(e<0?``:t.path.slice(0,e)).files.push(t)}let i=e=>(e.folders.sort((e,t)=>e.name<t.name?-1:1),e.files.sort((e,t)=>Z$(e.path)<Z$(t.path)?-1:1),e.count=e.files.length+e.folders.reduce((e,t)=>e+i(t),0),e.count);return i(t),t}function a1(e){let t=e.split(`/`).slice(0,-1);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function o1(e,t){let n=new Map,r=(e,r)=>{if(t&&!e.startsWith(t))return;let i=e.slice(t.length),a=n.get(i);a?a.some(e=>e.blockId===r.blockId)||a.push(r):n.set(i,[r])},i=(e,t)=>{for(let n of e?.blocks??[])if(n.type===`code`)r(n.path,{kind:`code`,blockId:n.id,title:s1(n),on:t});else if(n.type===`diff`)for(let e of n.files)r(e.path,{kind:`diff`,blockId:n.id,title:s1(n),on:t})};i(e.canvas,{context:!0});for(let t of e.pages??[])i(t.canvas,t.files?{files:!0,pageId:t.id}:{pageId:t.id,title:t.title});for(let{kind:t}of[...wt()].reverse())for(let n of Dt(e,t))i(n.canvas,{[`${t}Id`]:n.id,number:n.number,title:n.title});return n}var s1=e=>e.title||(e.type===`code`?e.path:`Diff`);function c1(e,t){let n;try{n=decodeURIComponent(t.replace(/[?#].*$/,``))}catch{return}if(!n)return;let r=e.split(`/`).slice(0,-1);for(let e of n.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!r.length)return;r.pop()}else r.push(e)}return r.length?r.join(`/`):void 0}var l1=2e3;function u1({board:e,file:t,kind:n,text:r}){return n===`markdown`?(0,Q.jsx)(d1,{board:e,file:t,text:r}):n===`mermaid`?(0,Q.jsx)(`div`,{className:`files-diagram`,children:(0,Q.jsx)(QU,{source:r})}):(0,Q.jsx)(p1,{file:t,text:r})}function d1({board:e,file:t,text:n}){let r=(0,d.useMemo)(()=>({picture:n=>{let r=c1(t,n);return r&&K$(r)?Jr(J.projectImage,{boardId:e.id},{path:r}):void 0},link:n=>{let r=c1(t,n);return r?dS.files(e.id,r):void 0}}),[e.id,t]);return(0,Q.jsx)(`article`,{className:`files-doc`,children:(0,Q.jsx)(Qb,{beside:r,children:n})})}var f1=/^[-+]?[\d.,]+%?$|^[-+]?[$£€]\s?[\d.,]+$/;function p1({file:e,text:t}){let n=(0,d.useMemo)(()=>Y$(t,e.toLowerCase().endsWith(`.tsv`)?` `:`,`),[t,e]);if(!n.length)return(0,Q.jsxs)(`p`,{className:`files-note`,children:[e,` is empty.`]});let[r,...i]=n,a=Math.max(...n.map(e=>e.length)),o=e=>Array.from({length:a},(t,n)=>e[n]??``),s=o(r).map((e,t)=>i.length>0&&i.every(e=>!e[t]||f1.test(e[t].trim()))&&i.some(e=>e[t]));return(0,Q.jsxs)(`div`,{className:`files-table`,children:[(0,Q.jsxs)(`table`,{className:`block-table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:o(r).map((e,t)=>(0,Q.jsx)(`th`,{className:s[t]?`is-number`:void 0,children:e},t))})}),(0,Q.jsx)(`tbody`,{children:i.slice(0,l1).map((e,t)=>(0,Q.jsx)(`tr`,{children:o(e).map((e,t)=>(0,Q.jsx)(`td`,{className:s[t]?`is-number`:void 0,children:e},t))},t))})]}),(0,Q.jsxs)(`p`,{className:`files-table-count`,children:[i.length.toLocaleString(`en-US`),` `,i.length===1?`row`:`rows`,` · `,a,` `,a===1?`column`:`columns`,i.length>l1&&`, the first ${l1.toLocaleString(`en-US`)} shown`]})]})}function m1({board:e,file:t,stamp:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),l=Jr(J.projectImage,{boardId:e.id},{path:t,v:n}),u=t.slice(t.lastIndexOf(`/`)+1),f=()=>fetch(l).then(e=>e.json()).then(e=>c(e.error??`${u} couldn't be shown.`)).catch(()=>c(`${u} couldn't be shown.`));return s?(0,Q.jsx)(`p`,{className:`files-note is-error`,children:s}):(0,Q.jsxs)(`figure`,{className:`files-picture${a?` is-actual`:``}`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`files-picture-frame`,onClick:()=>o(!a),title:a?`Fit it to the space`:`Show it at its actual size`,"aria-label":a?`Fit ${u}`:`${u} at actual size`,children:(0,Q.jsx)(`img`,{src:l,alt:u,draggable:!1,onLoad:e=>i({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>void f(),style:a&&r?{width:t.toLowerCase().endsWith(`.svg`)?r.width:r.width/(window.devicePixelRatio||1)}:void 0})}),r&&(0,Q.jsxs)(`figcaption`,{children:[r.width,` × `,r.height,a?` · actual size`:``]})]})}var h1=250,g1=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`,_1=e=>e.slice(e.lastIndexOf(`/`)+1);function v1(e,t,n){let[r,i]=(0,d.useState)({searching:!1}),{q:a,matchCase:o,word:s,regex:c}=t;return(0,d.useEffect)(()=>{if(!n||!a){i({searching:!1});return}let t=new AbortController;i(e=>({...e,searching:!0,failed:void 0}));let r=window.setTimeout(()=>{X.searchProjectFiles(e,{q:a,matchCase:o,word:s,regex:c},t.signal).then(e=>!t.signal.aborted&&i({result:e,searching:!1}),e=>!t.signal.aborted&&i({searching:!1,failed:e.message}))},h1);return()=>{window.clearTimeout(r),t.abort()}},[e,n,a,o,s,c]),r}function y1({text:e,marks:t}){let n=[],r=0;return t.forEach(([t,i],a)=>{t>r&&n.push(e.slice(r,t)),n.push((0,Q.jsx)(`mark`,{children:e.slice(t,i)},a)),r=i}),r<e.length&&n.push(e.slice(r)),(0,Q.jsx)(Q.Fragment,{children:n})}function b1({board:e,query:t,search:n,file:r,line:i}){let{result:a,searching:o,failed:s}=n;if(!t)return(0,Q.jsx)(`p`,{className:`files-note`,children:`Type to search inside the files, as an editor's Find in Files does. Any case, unless you match it.`});if(s)return(0,Q.jsx)(`p`,{className:`files-note is-error`,children:s});if(a?.invalid)return(0,Q.jsxs)(`p`,{className:`files-note is-error`,children:[`That isn't a regular expression: `,a.invalid,`.`]});if(!a)return(0,Q.jsx)(`p`,{className:`files-note`,children:`Searching…`});let c=a.files.length>0;return(0,Q.jsxs)(`div`,{className:`files-found${o?` is-stale`:``}`,children:[(0,Q.jsx)(`p`,{className:`files-count`,role:`status`,title:`${g1(a.searched,`file`)} searched${a.skipped?`, ${g1(a.skipped,`file`)} left out as pictures, binary or over 1 MB`:``}`,children:o?`Searching…`:c?`${g1(a.matches,`match`,`matches`)} in ${g1(a.files.length,`file`)}`:`No matches`}),!o&&a.partial===`matches`&&(0,Q.jsxs)(`p`,{className:`files-note`,children:[`Showing the first `,200 .toLocaleString(`en-US`),` matches. Narrow the search to see the rest.`]}),!o&&a.partial===`time`&&(0,Q.jsxs)(`p`,{className:`files-note`,children:[`The search stopped early (it took over `,4,` seconds, or a regular expression took too long on a file), so these are the matches found so far.`]}),!o&&a.truncated&&(0,Q.jsxs)(`p`,{className:`files-note`,children:[`This project has more than `,2e4.toLocaleString(`en-US`),` files: only the first ones, by path, were searched.`]}),a.files.map(t=>(0,Q.jsxs)(`section`,{className:`files-hit`,children:[(0,Q.jsxs)(`a`,{className:`files-hit-file${t.path===r&&!i?` is-picked`:``}`,href:dS.files(e.id,t.path),title:t.path,children:[(0,Q.jsx)(`span`,{className:`files-name`,children:_1(t.path)}),(0,Q.jsx)(`span`,{className:`files-dir`,children:t.path.slice(0,-_1(t.path).length)||`./`}),(0,Q.jsx)(`span`,{className:`files-n`,children:t.lines.length})]}),t.lines.map(n=>(0,Q.jsxs)(`a`,{className:`files-hit-line${t.path===r&&n.line===i?` is-picked`:``}`,href:dS.files(e.id,t.path,!1,n.line),children:[(0,Q.jsx)(`i`,{children:n.line}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(y1,{text:n.text,marks:n.marks})})]},n.line))]},t.path))]})}var x1=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),S1=x1?`⌘P`:`Ctrl P`,C1=x1?`Meta+P`:`Control+P`,w1=x1?`⌘⇧F`:`Ctrl Shift F`,T1=x1?`Meta+Shift+F`:`Control+Shift+F`,E1=`tricot:find-file`,D1=x1?`⌘\\`:`Ctrl \\`,O1=x1?`Meta+\\`:`Control+\\`,k1=e=>e.key===`\\`&&!e.altKey&&!e.shiftKey&&(x1?e.metaKey:e.ctrlKey),A1;function j1(){let e=A1;return A1=void 0,e}var M1=0;function N1(e,t){(0,d.useEffect)(()=>{if(!t)return;let n=t=>{let n=t.key.toLowerCase();if(t.altKey||!(x1?t.metaKey:t.ctrlKey))return;let r=n===`p`&&!t.shiftKey?`file`:n===`f`&&t.shiftKey?`text`:void 0;r&&(t.preventDefault(),A1=r,window.dispatchEvent(new Event(E1)),r!==`file`&&M1||CS.files(e))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function P1(e){(0,d.useEffect)(()=>{M1++;let t=j1();t&&e(t);let n=()=>{let t=j1();t&&e(t)};return window.addEventListener(E1,n),()=>{M1--,window.removeEventListener(E1,n)}},[e])}var F1=1500,I1=4e3,L1=300,R1=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,z1=e=>e.slice(e.lastIndexOf(`/`)+1),B1=e=>e.folder,V1={modified:{mark:`M`,words:`Changed since the last commit`},added:{mark:`A`,words:`New, added to the next commit`},untracked:{mark:`U`,words:`New, git doesn't track it yet`},renamed:{mark:`R`,words:`Renamed since the last commit`}};function H1({board:e,name:t,file:n,pair:r,line:i,onShown:a}){let o=B1(e),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(`all`),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(``),[S,C]=(0,d.useState)({}),[w,T]=(0,d.useState)(new Set),E=hu(),[D,O]=(0,d.useState)(!1),k=(0,d.useRef)(null),A=(0,d.useRef)(null),j=(0,d.useRef)(null),[M,N]=Yl(`tricot:files-tree`,()=>!0),[P,F]=Yl(`tricot:files-side`,()=>!0),[I,L]=(0,d.useState)(!1),R=M||I;P1((0,d.useCallback)(e=>{y(e===`text`),L(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>j.current?.select()))},[])),(0,d.useEffect)(()=>{let e=e=>{if(!k1(e))return;e.preventDefault();let t=!(M||P);N(t),F(t),L(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[M,P,N,F]);let z=(0,d.useCallback)(()=>{p(!0),u(null),X.projectFiles(e.id).then(c,e=>u(e.message)).finally(()=>p(!1))},[e.id]);(0,d.useEffect)(()=>{o?z():c(null)},[o,z]);let B=(0,d.useRef)(o);(0,d.useEffect)(()=>{B.current!==o&&(B.current=o,c(null),h(``),x(``),_(`all`),T(new Set),n&&CS.files(e.id))},[o,n,e.id]);let ee=s?.git?.prefix??``,V=n&&ee&&n.startsWith(ee)&&!s?.files.some(e=>e.path===n)?n.slice(ee.length):n,te=(0,d.useMemo)(()=>o1(e,s?.git?.prefix??``),[e,s]);(0,d.useEffect)(()=>{V&&L(!1)},[V]),(0,d.useEffect)(()=>{A.current?.querySelector(`.is-picked`)?.scrollIntoView({block:`nearest`})},[V,s]);let ne=s?.files??[],re=v1(e.id,{q:b,...S},!!o&&v),ie=(0,d.useMemo)(()=>n1(ne,m,g,te),[ne,m,g,te]),ae=(0,d.useMemo)(()=>i1(ie),[ie]),oe=(0,d.useMemo)(()=>({all:ne.length,week:ne.filter(e=>e.week).length,board:ne.filter(e=>te.has(e.path)).length}),[ne,te]),se=m.trim()!==``||g!==`all`,H=e=>se||w.has(e)||V!==void 0&&a1(V).includes(e),U=t=>T(n=>{let r=new Set(n);return H(t)&&!se?(r.delete(t),V&&a1(V).includes(t)&&CS.files(e.id)):r.add(t),r}),W=D&&(0,Q.jsx)(X$,{board:e,name:t,onClose:()=>{O(!1),k.current?.focus()}});if(!o)return(0,Q.jsxs)(`section`,{className:`files`,"aria-label":`Project files`,children:[(0,Q.jsxs)(`div`,{className:`files-empty`,children:[(0,Q.jsx)($,{name:`folder`}),(0,Q.jsx)(`h2`,{children:`This board has no project folder yet`}),E?(0,Q.jsx)(`p`,{children:`This board is archived, so a folder can't be chosen until it is unarchived. Its files then show here, to read and to open on a Sketchbook page.`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Choose the folder this board is about, or start Tricot inside the project's folder: a board made there takes it. Its files then show here, to read and to open on a Sketchbook page.`}),(0,Q.jsx)(`button`,{className:`btn btn-primary`,ref:k,onClick:()=>O(!0),children:`Choose project folder…`})]})]}),W]});let G=V?ne.find(e=>e.path===V):void 0;return(0,Q.jsxs)(`section`,{className:`files`,"aria-label":`Project files`,children:[(0,Q.jsxs)(`header`,{className:`files-title`,children:[(0,Q.jsx)(`h2`,{children:`Files`}),(0,Q.jsxs)(`span`,{className:`files-where`,title:s?.folder??o,children:[s?.folder??o,s?.git?.branch&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,s.git.branch]}),s?.git&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,s.git.clean?`clean`:`changes not committed`]}),s&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,R1(s.files.length,`file`),s.truncated?` (the first ones)`:``]})]}),(0,Q.jsxs)(`button`,{className:`btn btn-quiet btn-small files-reload`,onClick:z,disabled:f,title:`Read the folder again`,children:[(0,Q.jsx)($,{name:`sync`}),f?`Reading…`:`Reload`]}),!E&&(0,Q.jsxs)(`button`,{className:`btn btn-quiet btn-small files-change`,ref:k,onClick:()=>O(!0),title:`Choose another project folder for this board, or remove it`,children:[(0,Q.jsx)($,{name:`folder`}),`Change folder…`]}),(0,Q.jsxs)(`span`,{className:`files-panels`,role:`group`,"aria-label":`Panels`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`icon-button${R?` is-on`:``}`,"aria-pressed":R,"aria-keyshortcuts":O1,onClick:()=>{N(!R),L(!1)},title:`${R?`Hide`:`Show`} the files (${D1} for both panels)`,"aria-label":R?`Hide the files`:`Show the files`,children:(0,Q.jsx)($,{name:`panel-left`})}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button${P?` is-on`:``}`,"aria-pressed":P,"aria-keyshortcuts":O1,onClick:()=>F(!P),title:`${P?`Hide`:`Show`} On the board (${D1} for both panels)`,"aria-label":P?`Hide On the board`:`Show On the board`,children:(0,Q.jsx)($,{name:`panel-right`})})]})]}),(0,Q.jsxs)(`div`,{className:`files-body${G||V?` has-file`:``}${R?``:` no-tree`}${P?``:` no-side`}`,children:[(0,Q.jsxs)(`aside`,{className:`files-list`,"aria-label":`The project's files`,children:[(0,Q.jsxs)(`div`,{className:`pair-modes files-scope`,role:`group`,"aria-label":`Search`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${v?``:` is-on`}`,"aria-pressed":!v,onClick:()=>y(!1),title:`Find a file by its name`,children:`File names`}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${v?` is-on`:``}`,"aria-pressed":v,"aria-keyshortcuts":T1,onClick:()=>y(!0),title:`Find text inside the files (${w1})`,children:`Inside files`})]}),(0,Q.jsxs)(`label`,{className:`files-find`,children:[(0,Q.jsx)($,{name:`search`}),(0,Q.jsx)(`input`,{type:`search`,value:v?b:m,placeholder:v?`Search inside the files…`:`Find a file…`,"aria-label":v?`Search inside the files`:`Find a file`,"data-files-find":!0,ref:j,onChange:e=>(v?x:h)(e.target.value),onKeyDown:t=>{let n=v?b:m;if(t.key===`Escape`&&n)t.preventDefault(),(v?x:h)(``);else if(t.key===`Enter`&&v){let t=re.result?.files[0];t&&!re.searching&&CS.files(e.id,t.path,t.lines[0].line)}else t.key===`Enter`&&ie.length&&CS.files(e.id,(m.trim()?r1(ie,m,1)[0]:ie[0]).path)}})]}),v?(0,Q.jsx)(`div`,{className:`files-filters`,role:`group`,"aria-label":`Match`,children:[[`matchCase`,`Match case`,`Only text in the same case`],[`word`,`Whole word`,`Only whole words`],[`regex`,`Regex`,`Read it as a regular expression`]].map(([e,t,n])=>(0,Q.jsx)(`button`,{className:`files-filter${S[e]?` is-on`:``}`,"aria-pressed":!!S[e],title:n,onClick:()=>C({...S,[e]:!S[e]}),children:t},e))}):(0,Q.jsx)(`div`,{className:`files-filters`,role:`group`,"aria-label":`Show`,children:[[`all`,`All`,oe.all],[`week`,`This week`,oe.week],[`board`,`On the board`,oe.board]].map(([e,t,n])=>(0,Q.jsxs)(`button`,{className:`files-filter${g===e?` is-on`:``}`,"aria-pressed":g===e,onClick:()=>_(e),children:[t,` `,(0,Q.jsx)(`b`,{children:n.toLocaleString(`en-US`)})]},e))}),!v&&se&&s&&(0,Q.jsx)(`p`,{className:`files-count`,children:ie.length?`${R1(ie.length,`file`)} ${m.trim()?`match “${m.trim()}”`:`shown`}`:`No file matches`}),(0,Q.jsx)(`div`,{className:`files-rows`,role:v?`region`:`tree`,"aria-label":v?`What was found`:`Folders and files`,ref:A,children:v?(0,Q.jsx)(b1,{board:e,query:b,search:re,file:V,line:i}):l?(0,Q.jsxs)(`div`,{className:`files-note is-error`,children:[(0,Q.jsx)(`p`,{children:l}),(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:z,children:`Try again`})]}):s?(0,Q.jsx)(U1,{folder:ae,depth:0,board:e,picked:V,places:te,isOpen:H,toggle:U,budget:{left:F1}}):(0,Q.jsxs)(`p`,{className:`files-note`,children:[`Reading `,o,`…`]})})]}),V?(0,Q.jsx)(G1,{board:e,name:t,file:V,line:i,listed:G,places:te.get(V)??[],onSaved:z,pairNow:!!r,onShown:a},V):(0,Q.jsx)(W1,{board:e,files:ne,listed:!!s})]}),W]})}function U1(e){let{folder:t,depth:n,board:r,picked:i,places:a,isOpen:o,toggle:s,budget:c}=e,l={paddingLeft:10+n*16},u=[];for(let r of t.folders){if(c.left--<=0)break;let t=o(r.path);u.push((0,Q.jsxs)(`div`,{role:`treeitem`,"aria-expanded":t,children:[(0,Q.jsxs)(`button`,{className:`files-row is-folder`,style:l,onClick:()=>s(r.path),children:[(0,Q.jsx)($,{name:`chevron-down`,className:t?`files-twist is-open`:`files-twist`}),(0,Q.jsx)($,{name:`folder`,className:`files-folder`}),(0,Q.jsx)(`span`,{className:`files-name`,children:r.name}),(0,Q.jsx)(`span`,{className:`files-n`,children:r.count.toLocaleString(`en-US`)})]}),t&&(0,Q.jsx)(`div`,{role:`group`,children:(0,Q.jsx)(U1,{...e,folder:r,depth:n+1})})]},`d:${r.path}`))}for(let e of t.files){if(c.left--<=0)break;let t=e.status&&V1[e.status];u.push((0,Q.jsxs)(`a`,{role:`treeitem`,"aria-selected":e.path===i,className:`files-row${e.path===i?` is-picked`:``}`,style:{paddingLeft:10+n*16+15},href:dS.files(r.id,e.path),children:[(0,Q.jsx)($,{name:`note`,className:`files-file`}),(0,Q.jsx)(`span`,{className:`files-name`,children:z1(e.path)}),(0,Q.jsxs)(`span`,{className:`files-marks`,children:[t&&(0,Q.jsx)(`span`,{className:`files-status is-${e.status}`,title:t.words,children:t.mark}),a.has(e.path)&&(0,Q.jsx)(`span`,{className:`files-onboard`,title:`On the board`})]})]},`f:${e.path}`))}return n===0&&c.left<=0&&u.push((0,Q.jsx)(`p`,{className:`files-note`,children:`More files than fit here: find one by name.`},`more`)),(0,Q.jsx)(Q.Fragment,{children:u})}function W1({board:e,files:t,listed:n}){let r=(0,d.useMemo)(()=>t.filter(e=>e.week).sort((e,t)=>Number(!!t.status)-Number(!!e.status)||Date.parse(t.last?.at??`0`)-Date.parse(e.last?.at??`0`)).slice(0,10),[t]);return(0,Q.jsxs)(`div`,{className:`files-lately`,children:[(0,Q.jsx)(`h3`,{children:n?`Changed lately`:` `}),n&&!r.length&&(0,Q.jsx)(`p`,{className:`files-note`,children:`Nothing changed this week. Pick a file at the left to read it here.`}),(0,Q.jsx)(`ul`,{children:r.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:dS.files(e.id,t.path),children:[(0,Q.jsx)(`span`,{className:`files-name`,children:z1(t.path)}),(0,Q.jsx)(`span`,{className:`files-dir`,children:t.path.slice(0,-z1(t.path).length)||`./`}),(0,Q.jsx)(`span`,{className:`files-when`,children:t.status?V1[t.status].words:t.last?`${t.last.by} · ${ex(t.last.at)}`:``})]})},t.path))}),n&&(0,Q.jsx)(`p`,{className:`files-hint`,children:`Pick a file to read it, then open it on a Sketchbook page to work on it, alone or with an agent.`})]})}function G1({board:e,name:t,file:n,line:r,listed:i,places:a,onSaved:o,pairNow:s,onShown:c}){let l=mx(),u=vS().boardContext()?.name.toLowerCase()??`board`,[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(`read`),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(``),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(!1),O=q$(n),k=J$(n),[A,j]=(0,d.useState)(O&&!r?`preview`:`source`),M=(0,d.useRef)(null),N=(0,d.useRef)(void 0),P=(0,d.useCallback)(()=>(k?X.projectFile(e.id,n):Promise.resolve(null)).then(e=>(p(e),h(null),e),e=>(h(e.message),null)),[e.id,n,k]);(0,d.useEffect)(()=>{P()},[P]);let F=f?.named;(0,d.useEffect)(()=>{if(F)return c?.({path:n,named:F}),()=>c?.(void 0)},[n,F,c]);let I=(0,d.useMemo)(()=>f?Qn(f.text):[],[f]),L=r?r-(f?.start??1):-1,R=L>=I1?L-L1:0,z=(0,d.useMemo)(()=>{let e=fH(Zn({path:n})),t={inComment:!1},r=L>=I1?L+L1+1:I1;return I.slice(R,r).map(n=>xH(n,e,t))},[I,n,L,R]);(0,d.useEffect)(()=>{r&&j(`source`)},[r]),(0,d.useEffect)(()=>{if(!r||!f||g!==`read`||A!==`source`||N.current===`${n}:${r}`)return;let e=M.current?.querySelector(`[data-line="${r}"]`);e&&(N.current=`${n}:${r}`,e.scrollIntoView({block:`center`}))},[r,f,g,A,n]);let B=Gw(),ee=Date.now(),V=B.filter(e=>e.text.includes(z1(n))&&Rw(e,ee)),te=g===`edit`,ne=te&&f!==null&&b!==f.text,re=()=>{f&&(x(f.text),T(null),_(`edit`))},ie=async()=>ne&&!await MB({title:`Drop your changes to ${z1(n)}?`,detail:`They aren't saved to the file.`,confirmLabel:`Drop them`,cancelLabel:`Keep editing`,danger:!0})?!1:(_(`read`),T(null),!0),ae=async e=>{(!te||await ie())&&j(e)},oe=e=>g===`read`&&A===e,se=async()=>{if(f&&!S&&ne){C(!0),T(null);try{let{file:r}=await X.writeProjectFile(e.id,t,n,b,f.hash);p(r),_(`read`),D(!0),window.setTimeout(()=>D(!1),2500),o()}catch(e){e.status===409?T(e.message):h(e.message)}finally{C(!1)}}},H=(0,d.useCallback)(async()=>{C(!0),h(null);try{let{block:r,pageId:i}=await X.projectFileBlock(e.id,t,n);y({pageId:i,blockId:r.id}),_(`pair`)}catch(e){h(e.message)}finally{C(!1)}},[e.id,t,n]),U=(0,d.useCallback)(()=>{_(`read`),y(null),P()},[P]),W=(0,d.useRef)(s);(0,d.useEffect)(()=>{W.current&&f&&(W.current=!1,H())},[f,H]),(0,d.useEffect)(()=>{if(g!==`pair`)return;let r=window.setInterval(()=>void X.projectFileBlock(e.id,t,n).catch(()=>void 0),4e3);return()=>window.clearInterval(r)},[g,e.id,t,n]);let G=v?e.pages?.find(e=>e.id===v.pageId):void 0,ce=async e=>{e&&await navigator.clipboard?.writeText(b).catch(()=>void 0);let t=await P();t&&x(t.text),T(null)},le=n.split(`/`);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`files-preview`,children:[g!==`pair`&&(0,Q.jsxs)(`div`,{className:`files-head`,children:[(0,Q.jsxs)(`span`,{className:`files-crumbs`,title:n,children:[le.slice(0,-1).map((e,t)=>(0,Q.jsxs)(`span`,{children:[e,` / `]},t)),(0,Q.jsx)(`b`,{children:le[le.length-1]})]}),E&&(0,Q.jsx)(`span`,{className:`files-saved`,children:`Saved`}),te&&(0,Q.jsxs)(`span`,{className:`files-actions`,children:[(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void ie(),disabled:S,children:`Cancel`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-primary`,onClick:()=>void se(),disabled:S||!ne,title:`Save it over the file (⌘S)`,children:S?`Saving…`:`Save`})]}),k&&(0,Q.jsxs)(`div`,{className:`pair-modes files-modes`,role:`group`,"aria-label":`Mode`,children:[O?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${oe(`preview`)?` is-on`:``}`,"aria-pressed":oe(`preview`),onClick:()=>void ae(`preview`),title:q1[O],children:`Preview`}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${oe(`source`)?` is-on`:``}`,"aria-pressed":oe(`source`),onClick:()=>void ae(`source`),title:`Its text, line by line`,children:`Source`})]}):(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${g===`read`?` is-on`:``}`,"aria-pressed":g===`read`,onClick:()=>te&&void ie(),title:`Read the file`,children:`Read`}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode${te?` is-on`:``}`,"aria-pressed":te,onClick:()=>!te&&re(),disabled:!f,title:`Edit the file itself, and save it over it`,children:`Edit`}),(0,Q.jsx)(`button`,{type:`button`,className:`pair-mode`,"aria-pressed":!1,onClick:()=>void H(),disabled:!f||S||te,title:`Pair with an agent on it: point at lines and ask; the agent changes the file`,children:`Pair`})]})]}),w&&(0,Q.jsxs)(`div`,{className:`files-band is-conflict`,role:`alert`,children:[(0,Q.jsx)(`span`,{children:w}),(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void ce(!0),children:`Copy my edit, then reload`}),(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void ce(!1),children:`Reload`})]}),g===`pair`?(0,Q.jsx)(`div`,{className:`files-pair`,children:v&&G?(0,Q.jsx)(vZ,{board:e,page:G,name:t,opens:v.blockId,onClosed:U}):(0,Q.jsxs)(`p`,{className:`files-note`,children:[`Opening `,z1(n),` to pair on…`]})}):te?(0,Q.jsx)(K1,{value:b,onChange:x,onSave:()=>void se(),label:`Edit ${n}`}):(0,Q.jsx)(`div`,{ref:M,className:`files-code${O&&A===`preview`?` is-preview is-${O}`:``}`,tabIndex:0,"aria-label":O&&A===`preview`?`${n}, drawn`:`The text of ${n}`,children:m?(0,Q.jsx)(`p`,{className:`files-note is-error`,children:m}):O===`image`&&A===`preview`?(0,Q.jsx)(m1,{board:e,file:n,stamp:`${i?.size??``}-${f?.hash.slice(0,8)??``}`}):f?O&&O!==`image`&&A===`preview`?(0,Q.jsx)(u1,{board:e,file:n,kind:O,text:f.text}):(0,Q.jsxs)(`pre`,{children:[R>0&&(0,Q.jsxs)(`span`,{className:`files-line is-more`,children:[R1(R,`line`),` before these.`]}),z.map((e,t)=>{let n=R+t;return(0,Q.jsxs)(`span`,{className:`files-line${f.start+n===r?` is-hit`:``}`,"data-line":f.start+n,children:[(0,Q.jsx)(`i`,{children:f.start+n}),(0,Q.jsx)(CH,{tokens:e.length?e:[{text:I[n]}]}),`
97
+ `]},n)}),I.length>R+z.length&&(0,Q.jsxs)(`span`,{className:`files-line is-more`,children:[R1(I.length-R-z.length,`more line`),` after these.`]})]}):(0,Q.jsxs)(`p`,{className:`files-note`,children:[`Reading `,z1(n),`…`]})})]}),(0,Q.jsxs)(`aside`,{className:`files-side`,"aria-label":`${z1(n)} on the board`,children:[(0,Q.jsx)(`h4`,{children:`On the board`}),a.length?a.map(t=>(0,Q.jsxs)(hx,{className:`files-place`,href:J1(l,e,t,n),children:[(0,Q.jsx)($,{name:t.kind===`code`?`code`:`details`}),(0,Q.jsxs)(`span`,{children:[t.title,(0,Q.jsx)(`small`,{children:Y1(t,u)})]})]},t.blockId)):(0,Q.jsx)(`p`,{className:`files-note`,children:`Not on the board yet.`}),V.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h4`,{children:`Now`}),V.map(e=>(0,Q.jsxs)(`p`,{className:`files-now`,children:[(0,Q.jsx)(`span`,{className:`files-agent`,children:e.agent[0]}),(0,Q.jsxs)(`span`,{children:[e.agent,` · `,qw(e)]}),(0,Q.jsx)(sT,{state:Kw(Rw(e,ee)??`dim`)})]},e.agent))]}),(0,Q.jsx)(`h4`,{children:`Lately`}),i?.status&&(0,Q.jsxs)(`p`,{className:`files-note`,children:[V1[i.status].words,`.`]}),i?.last?(0,Q.jsxs)(`p`,{className:`files-note`,children:[(0,Q.jsx)(`b`,{children:i.last.subject}),(0,Q.jsx)(`br`,{}),i.last.by,` · `,ex(i.last.at),` · `,i.last.commit]}):!i?.status&&(0,Q.jsx)(`p`,{className:`files-note`,children:`No recent commit changed it.`}),f?.total||I.length?(0,Q.jsx)(`p`,{className:`files-note`,children:R1(f?.total??I.length,`line`)}):null]})]})}function K1({value:e,onChange:t,onSave:n,label:r}){let i=(0,d.useRef)(null),a=(0,d.useMemo)(()=>e.split(`
98
+ `).length,[e]),o=(0,d.useMemo)(()=>Array.from({length:a},(e,t)=>t+1).join(`
99
+ `),[a]);return(0,Q.jsxs)(`div`,{className:`files-editor`,children:[(0,Q.jsx)(`pre`,{className:`files-gutter`,ref:i,"aria-hidden":!0,children:o}),(0,Q.jsx)(`textarea`,{autoFocus:!0,spellCheck:!1,value:e,"aria-label":r,onChange:e=>t(e.target.value),onScroll:e=>{i.current&&(i.current.scrollTop=e.currentTarget.scrollTop)},onKeyDown:r=>{if(r.key.toLowerCase()===`s`&&(r.metaKey||r.ctrlKey))r.preventDefault(),n();else if(r.key===`Tab`&&!r.shiftKey&&!r.altKey&&!r.metaKey&&!r.ctrlKey){r.preventDefault();let n=r.currentTarget,{selectionStart:i,selectionEnd:a}=n;t(e.slice(0,i)+` `+e.slice(a)),requestAnimationFrame(()=>n.setSelectionRange(i+2,i+2))}}})]})}var q1={markdown:`As it reads, as a note does`,mermaid:`The diagram, as a diagram block draws it`,table:`As a table`,image:`The picture`};function J1(e,t,n,r){let i=n.on;return`files`in i?dS.files(t.id,r,!0):`pageId`in i?dS.page(t.id,i.pageId):`taskId`in i?e.byId(`task`,t.id,i.taskId)?.href:`decisionId`in i?e.byId(`decision`,t.id,i.decisionId)?.href:dS.context(t.id)}function Y1(e,t){let n=e.on,r=e.kind===`code`?`Code block`:`Diff`;return`files`in n?`Where you pair on it, in Files`:`pageId`in n?`${r} on “${n.title}”`:`taskId`in n?`${r} on T${n.number} ${n.title}`:`decisionId`in n?`${r} on #${n.number} ${n.title}`:`${r} on the ${t}`}var X1=`tricot:recent-boards`;function Z1(e,t,n=[]){let r=new Set([t,...n]);return[t,...e.filter(e=>!r.has(e))].slice(0,50)}function Q1(e,t){let n=new Map(t.map((e,t)=>[e,t])),r=e=>n.get(e.id)??t.length;return[...e].sort((e,t)=>r(e)-r(t)||t.updatedAt.localeCompare(e.updatedAt))}function $1(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=e=>n.every(t=>e.toLowerCase().includes(t)),i=e.filter(e=>r(`${e.title}\n${e.goal??``}`));return[...i.filter(e=>r(e.title)),...i.filter(e=>!r(e.title))]}function e0(){try{let e=JSON.parse(localStorage.getItem(X1)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function t0(e,t){return e.filter(e=>!t.includes(e))}function n0(e){try{localStorage.setItem(X1,JSON.stringify(t0(e0(),e)))}catch{}}function r0(e,t){try{localStorage.setItem(X1,JSON.stringify(Z1(e0(),e,t)))}catch{}}function i0(e){C$(e.aliases?.[0]??e.id),n0([e.id,...e.aliases??[]])}function a0({board:e,name:t,onClose:n,onDeleted:r}){let[i,a]=(0,d.useState)(``),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=de(i,e.title);return(0,d.useEffect)(()=>{let e=e=>e.key===`Escape`&&!o&&n();return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,o]),(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!o&&n(),children:(0,Q.jsxs)(`form`,{className:`delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-title`,onSubmit:n=>{n.preventDefault(),u&&!o&&(s(!0),X.deleteBoard(e.id,t,i).then(()=>{i0(e),LQ(),r()},e=>{l(e.message),s(!1)}))},children:[(0,Q.jsxs)(`h2`,{id:`delete-title`,children:[`Delete “`,e.title,`”?`]}),(0,Q.jsx)(`p`,{children:`This deletes the board and everything on it for good. It can’t be undone. Archiving is how to keep a board: leave this one archived if you might want it back.`}),(0,Q.jsx)(`label`,{className:`delete-label`,htmlFor:`delete-confirm`,children:`Type the board’s name to confirm`}),(0,Q.jsx)(`input`,{id:`delete-confirm`,autoFocus:!0,value:i,onChange:e=>{a(e.target.value),l(null)},placeholder:e.title,autoComplete:`off`,spellCheck:!1}),c&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:c}),(0,Q.jsxs)(`div`,{className:`delete-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,disabled:o,children:`Keep it archived`}),(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-danger`,disabled:!u||o,children:`Delete board`})]})]})}),document.body)}var o0=`tricot:name`;function s0(){let[e,t]=(0,d.useState)(()=>{try{return localStorage.getItem(o0)??``}catch{return``}});return[e,(0,d.useCallback)(e=>{t(e);try{e?localStorage.setItem(o0,e):localStorage.removeItem(o0)}catch{}},[])]}function c0({onSubmit:e}){let[t,n]=(0,d.useState)(``),{nameGate:r}=vS().words();return(0,Q.jsx)(`div`,{className:`gate`,children:(0,Q.jsxs)(`form`,{className:`gate-card`,onSubmit:n=>{n.preventDefault(),t.trim()&&e(t.trim())},children:[(0,Q.jsx)(cx,{}),(0,Q.jsx)(`h1`,{children:`What should agents call you?`}),(0,Q.jsx)(`p`,{className:`muted`,children:r}),(0,Q.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`Your name`,maxLength:60}),(0,Q.jsx)(`button`,{className:`btn btn-primary`,disabled:!t.trim(),children:`Continue`})]})})}var l0=(0,d.createContext)({name:``,rename:()=>{}});function u0(){return(0,d.useContext)(l0)}function d0({children:e}){let[t,n]=s0(),r=(0,d.useCallback)(()=>n(``),[n]),i=(0,d.useMemo)(()=>({name:t,rename:r}),[t,r]);return t?(0,Q.jsxs)(l0.Provider,{value:i,children:[e(t),(0,Q.jsx)(Jx,{name:t}),(0,Q.jsx)(nS,{name:t}),(0,Q.jsx)($x,{}),(0,Q.jsx)(f0,{})]}):(0,Q.jsx)(c0,{onSubmit:n})}function f0(){return Zx(),p0(),null}function p0(){(0,d.useEffect)(()=>{let e=()=>{let e=Ax.title();document.title!==e&&(document.title=e)},t=()=>Ax.set({hidden:document.visibilityState===`hidden`}),n=Ax.subscribe(e);return t(),document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t),n()}},[])}var m0=`If the new version changes how boards are stored, it keeps a copy of them first.`;function h0(e){let{checked:t}=e;return`newer`in t?{kind:`newer`,version:t.newer.version}:`error`in t?{kind:`failed`,reason:t.error}:{kind:`latest`}}function g0(e){return e.status===409&&e.message?{kind:`refused`,words:e.message}:e.status===void 0?{kind:`failed`,reason:`Tricot itself isn't answering`}:{kind:`failed`,reason:e.message||`Tricot answered ${e.status}`}}function _0(e){switch(e.kind){case`checking`:return`Checking…`;case`latest`:return`You're on the latest version.`;case`newer`:return`Tricot ${e.version} is out.`;case`failed`:return`Couldn't check: ${e.reason.trim().replace(/[\s.]+$/,``)}. Try again later.`;case`refused`:return e.words}}var v0=`tricot:update-skipped`,y0=`tricot:update-failure-seen`,b0=`tricot:updating`,x0=`tricot:updated`,S0=6e5,C0=1e3,w0=48e4,T0={get(e,t){try{return e?.getItem(t)??void 0}catch{return}},set(e,t,n){try{n===void 0?e?.removeItem(t):e?.setItem(t,n)}catch{}}},E0=()=>typeof localStorage>`u`?void 0:localStorage,D0=()=>typeof sessionStorage>`u`?void 0:sessionStorage;function O0(e){try{return e?JSON.parse(e):void 0}catch{return}}var k0={state:null,skipped:T0.get(E0(),v0),failureSeen:T0.get(E0(),y0),justUpdated:O0(T0.get(D0(),x0)),waiting:O0(T0.get(D0(),b0))},A0=new Set,j0;function M0(e){k0={...k0,...e};for(let e of A0)e()}function N0(){X.update().then(e=>{M0({state:e,loadedAs:k0.loadedAs??e.current}),e.updating&&!k0.waiting&&M0({waiting:{release:e.available??{version:e.updating},from:e.current,since:Date.now()}}),k0.waiting&&z0()},()=>{})}function P0(e){return A0.add(e),A0.size===1&&(N0(),j0=setInterval(N0,S0),window.addEventListener(`focus`,N0)),()=>{A0.delete(e),A0.size===0&&(clearInterval(j0),window.removeEventListener(`focus`,N0))}}function F0(){return(0,d.useSyncExternalStore)(P0,()=>k0)}var I0=!1;async function L0(e){let t=k0.state?.current??``;M0({error:void 0});try{let n=await X.startUpdate(e.version),r={release:e,from:t,since:Date.now()};T0.set(D0(),b0,JSON.stringify(r)),M0({state:n,waiting:r}),z0()}catch(e){M0({error:e.message}),N0()}}async function R0(){try{let e=await fetch(Jr(J.update),{cache:`no-store`,signal:AbortSignal.timeout(3e3)});return e.ok?await e.json():void 0}catch{return}}async function z0(){if(!I0){I0=!0;try{for(;;){let e=k0.waiting;if(!e)return;Date.now()-e.since>w0&&M0({waiting:{...e,slow:!0}}),await new Promise(e=>setTimeout(e,C0));let t=await R0();if(t){if(t.current===e.release.version){T0.set(D0(),b0,void 0),T0.set(D0(),x0,JSON.stringify(e.release)),location.reload();return}if(t.failed?.version===e.release.version){T0.set(D0(),b0,void 0),M0({state:t,waiting:void 0});return}M0({state:t})}}}finally{I0=!1}}}function B0(e){T0.set(E0(),v0,e),M0({skipped:e})}async function V0(){try{let{checked:e,...t}=await X.checkForUpdates();return M0({state:t,loadedAs:k0.loadedAs??t.current}),`newer`in e&&k0.skipped===e.newer.version&&(T0.set(E0(),v0,void 0),M0({skipped:void 0})),h0({checked:e})}catch(e){return g0(e)}}var H0=3e3,U0=0;function W0(){M0({reveal:Date.now()}),U0===0&&CS.home()}function G0(e,t){(0,d.useEffect)(()=>(U0++,()=>{U0--}),[]),(0,d.useEffect)(()=>{e===void 0||Date.now()-e>H0||t()&&M0({reveal:void 0})})}function K0(e){T0.set(E0(),y0,e.at),M0({failureSeen:e.at})}function q0(){T0.set(D0(),x0,void 0),M0({justUpdated:void 0})}function J0(e){let{state:t}=e;return e.waiting?{kind:`updating`,version:e.waiting.release.version,slow:!!e.waiting.slow,how:t?.how}:t?t.updating?{kind:`updating`,version:t.updating,slow:!1,how:t.how}:t.failed&&t.failed.at!==e.failureSeen?{kind:`failed`,failure:t.failed,current:t.current}:e.justUpdated&&e.justUpdated.version===t.current?{kind:`updated`,release:e.justUpdated}:e.loadedAs&&t.current!==e.loadedAs?{kind:`moved`,version:t.current}:t.available&&t.available.version!==e.skipped?{kind:`available`,release:t.available,current:t.current,how:t.how,error:e.error}:null:null}var Y0={npm:`npm is installing it`,brew:`Homebrew is upgrading it`,npx:`npx is fetching it`};function X0({shown:e}){switch(e.kind){case`updating`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`update-text`,children:[(0,Q.jsx)(`p`,{className:`update-title`,children:(0,Q.jsxs)(`strong`,{children:[`Updating to Tricot `,e.version,`…`]})}),(0,Q.jsx)(`p`,{className:`update-fine`,children:e.slow?`It's taking longer than it should. What happened is in update.log, in Tricot's data folder.`:`${e.how?.self?`${Y0[e.how.via]}, then `:``}Tricot restarts on the same address. This page reconnects by itself.`})]}),(0,Q.jsx)(`span`,{className:`update-busy`,"aria-hidden":!0,children:(0,Q.jsx)(sT,{state:`working`})})]});case`failed`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`update-text`,children:[(0,Q.jsxs)(`p`,{className:`update-title`,children:[(0,Q.jsxs)(`strong`,{children:[`The update to Tricot `,e.failure.version,` didn't finish.`]}),` You're on `,e.current,`.`]}),(0,Q.jsx)(`p`,{className:`update-fine`,children:e.failure.message}),(0,Q.jsxs)(`p`,{className:`update-fine`,children:[`What happened is in `,(0,Q.jsx)(`code`,{children:e.failure.log}),`.`]})]}),(0,Q.jsx)(`div`,{className:`update-actions`,children:(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>K0(e.failure),children:`OK`})})]});case`updated`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`update-text`,children:[(0,Q.jsx)(`p`,{className:`update-title`,children:(0,Q.jsxs)(`strong`,{children:[`You're on Tricot `,e.release.version,` now.`]})}),e.release.notes&&(0,Q.jsx)(`p`,{className:`update-notes`,children:e.release.notes}),(0,Q.jsx)(Z0,{release:e.release})]}),(0,Q.jsx)(`div`,{className:`update-actions`,children:(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:q0,children:`OK`})})]});case`moved`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`update-text`,children:(0,Q.jsxs)(`p`,{className:`update-title`,children:[(0,Q.jsxs)(`strong`,{children:[`Tricot is now `,e.version,`.`]}),` Reload to use it.`]})}),(0,Q.jsx)(`div`,{className:`update-actions`,children:(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,onClick:()=>location.reload(),children:`Reload`})})]});case`available`:return(0,Q.jsx)(Q0,{shown:e})}}function Z0({release:e}){return e.link?(0,Q.jsxs)(`a`,{className:`update-link`,href:e.link,target:`_blank`,rel:`noreferrer`,children:[`What's new in `,e.version,(0,Q.jsx)($,{name:`external`})]}):null}function Q0({shown:e}){let{release:t,current:n,how:r,error:i}=e,[a,o]=(0,d.useState)(!1),s=r&&!r.self?r:void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`update-text`,children:[(0,Q.jsxs)(`p`,{className:`update-title`,children:[(0,Q.jsxs)(`strong`,{children:[`Tricot `,t.version,` is out.`]}),` You have `,n,`.`]}),t.notes&&(0,Q.jsx)(`p`,{className:`update-notes`,children:t.notes}),(0,Q.jsx)(Z0,{release:t}),s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`update-fine`,children:s.why}),(0,Q.jsx)(`code`,{className:`update-command`,children:s.command}),s.restart&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`update-fine`,children:`Then restart Tricot on it:`}),(0,Q.jsx)(`code`,{className:`update-command`,children:s.restart})]}),(0,Q.jsx)(`p`,{className:`update-fine`,children:m0})]}):(0,Q.jsxs)(`p`,{className:`update-fine`,children:[`Update installs it, and Tricot restarts on the same address; this page reconnects by itself. `,m0]}),i&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:i})]}),(0,Q.jsxs)(`div`,{className:`update-actions`,children:[s?(0,Q.jsx)($0,{text:s.command}):(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:a,onClick:()=>{o(!0),L0(t).finally(()=>o(!1))},children:`Update`}),(0,Q.jsx)(`button`,{className:`btn btn-quiet btn-small`,onClick:()=>B0(t.version),title:`Hides it until a newer version is out`,children:`Skip this version`})]})]})}function $0({text:e}){let[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>n(!1),1500);return()=>clearTimeout(e)},[t]);let r=()=>navigator.clipboard.writeText(e).then(()=>n(!0),()=>{});return(0,Q.jsx)(`button`,{className:`btn btn-primary btn-small`,onClick:()=>void r(),children:t?`Copied`:`Copy the update command`})}function e2(){let e=F0(),t=J0(e),n=(0,d.useRef)(null);return G0(e.reveal,()=>n.current?(n.current.scrollIntoView({block:`nearest`}),n.current.focus(),!0):!1),t?(0,Q.jsxs)(`section`,{ref:n,tabIndex:-1,className:`update-notice is-${t.kind}`,"aria-label":`Tricot update`,"aria-live":`polite`,children:[(0,Q.jsx)($,{name:t.kind===`updated`?`check`:`arrow-up`,className:`update-icon`}),(0,Q.jsx)(X0,{shown:t})]}):null}function t2(e){switch(e.kind){case`updating`:return`Updating to ${e.version}…`;case`failed`:return`Update didn't finish`;case`updated`:return`Updated to ${e.release.version}`;case`moved`:return`Tricot ${e.version}: reload`;case`available`:return`Tricot ${e.release.version} is out`}}function n2(){let e=F0(),t=J0(e),n=(0,d.useRef)(null);if(G0(e.reveal,()=>{let e=n.current?.closest(`details`);return e?(e.open=!0,n.current.focus(),!0):!1}),!t)return null;let r=t2(t);return(0,Q.jsxs)(ox,{className:`update-chip`,children:[(0,Q.jsxs)(`summary`,{className:`update-chip-button is-${t.kind}`,title:r,children:[t.kind===`updating`?(0,Q.jsx)(sT,{state:`working`}):(0,Q.jsx)($,{name:t.kind===`updated`?`check`:`arrow-up`}),(0,Q.jsx)(`span`,{children:r})]}),(0,Q.jsx)(`div`,{ref:n,tabIndex:-1,className:`popover-body update-popover is-${t.kind}`,"aria-live":`polite`,children:(0,Q.jsx)(X0,{shown:t})})]})}function r2({onShow:e}){let t=F0().state?.current,[n,r]=(0,d.useState)(null),i=(0,d.useRef)(!0);(0,d.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=n?.kind===`checking`;return(0,Q.jsxs)(`div`,{className:`user-version`,children:[(0,Q.jsxs)(`div`,{className:`user-version-row`,children:[(0,Q.jsx)(`span`,{children:t?`Tricot ${t}`:`Tricot`}),(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,"aria-disabled":a||void 0,onClick:()=>{a||(r({kind:`checking`}),V0().then(e=>i.current&&r(e)))},children:[(0,Q.jsx)($,{name:`sync`}),` Check for updates`]})]}),(0,Q.jsxs)(`div`,{className:`user-version-said${n?` is-${n.kind}`:``}`,children:[(0,Q.jsx)(`p`,{role:`status`,children:n&&_0(n)}),n?.kind===`newer`&&(0,Q.jsx)(`button`,{type:`button`,className:`user-version-show`,onClick:()=>{e(),W0()},children:`See the update`})]})]})}function i2({name:e,onRename:t}){let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=IU(),u=(0,d.useCallback)(()=>r(!1),[]);return Zl(n,u,c),(0,Q.jsxs)(`div`,{className:`user-menu`,ref:c,children:[(0,Q.jsxs)(`button`,{className:`user-chip`,onClick:()=>r(!n),"aria-expanded":n,title:`You`,children:[(0,Q.jsx)(ix,{actor:{kind:`human`,name:e}}),(0,Q.jsx)($,{name:`chevron-down`,className:`user-chev`})]}),n&&(0,Q.jsxs)(`div`,{className:`menu-panel user-panel`,children:[(0,Q.jsxs)(`button`,{className:`menu-item`,onClick:()=>{r(!1),t()},children:[(0,Q.jsx)(`strong`,{children:`Change your name`}),(0,Q.jsx)(`span`,{children:`How people and agents see you on every board.`})]}),(0,Q.jsxs)(`button`,{className:`menu-item`,onClick:()=>{r(!1),s(!0)},children:[(0,Q.jsx)(`strong`,{children:`Your browsers and terminals`}),(0,Q.jsx)(`span`,{children:`The ones you let act for you, and removing one.`})]}),(0,Q.jsxs)(`div`,{className:`user-theme`,children:[(0,Q.jsx)(`span`,{children:`Theme`}),(0,Q.jsx)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Theme`,children:TU.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:l===e?`is-active`:``,"aria-pressed":l===e,onClick:()=>FU(e),children:[(0,Q.jsx)($,{name:e.base===`light`?`sun`:`moon`}),` `,e.label]},e.id))})]}),(0,Q.jsx)(r2,{onShow:u}),(0,Q.jsx)(fw,{onOpen:e=>{r(!1),a(e)}})]}),i&&(0,Q.jsx)(pw,{name:i,person:e,onClose:()=>a(null)}),o&&(0,Q.jsx)(rS,{name:e,onClose:()=>s(!1)})]})}function a2({home:e=!1,left:t,right:n,bar:r}){let{name:i,rename:a}=u0();return(0,Q.jsxs)(`header`,{className:`topbar`,ref:r,children:[e?(0,Q.jsx)(`div`,{className:`brand`,children:(0,Q.jsx)(cx,{})}):(0,Q.jsxs)(`div`,{className:`topbar-left`,children:[(0,Q.jsx)(`a`,{className:`brand`,href:dS.home(),title:`All boards`,children:(0,Q.jsx)(cx,{})}),t]}),(0,Q.jsxs)(`div`,{className:`topbar-right`,children:[n,(0,Q.jsx)(i2,{name:i,onRename:a})]})]})}function o2(e){let[t,n]=(0,d.useState)(null);return(0,d.useEffect)(()=>n(null),[e]),[t??e,n]}function s2({as:e,className:t,value:n,placeholder:r,label:i,required:a,maxLength:o,hint:s,onSave:c,onDone:l}){let[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),h=(0,d.useRef)(null),g=(0,d.useRef)(!1),_=(0,d.useRef)(!1);(0,d.useLayoutEffect)(()=>h.current?.select(),[]);let v=async e=>{let t=e.value.trim();if(g.current||t===n||a&&!t)return l(_.current);m(!0);try{await c(t),l(_.current)}catch(t){f(t.message),_.current=!1,e.focus()}finally{m(!1)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(e,{className:t,children:(0,Q.jsx)(`input`,{ref:h,autoFocus:!0,className:`inline-input`,defaultValue:n,placeholder:r,"aria-label":i,"aria-invalid":!!u,maxLength:o,readOnly:p,onFocus:e=>e.currentTarget.select(),onBlur:e=>!p&&void v(e.currentTarget),onKeyDown:e=>{e.key===`Enter`&&(_.current=!0,e.currentTarget.blur()),e.key===`Escape`&&(g.current=!0,_.current=!0,e.currentTarget.blur())}})}),u?(0,Q.jsx)(`p`,{className:`heading-note error`,role:`alert`,children:u}):s&&(0,Q.jsx)(`p`,{className:`heading-note`,children:s})]})}var c2=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),l2=c2?`⌘B`:`Ctrl B`;function u2(e,t){let n=dT(e);return n&&`now`in n?`${n.now.name} ${pT(n.now,t(n.now))} · ${ex(n.now.lastSeen)}`:n?`${n.last.name}, ${tx(n.last.at)}`:`no agent · ${ex(e.updatedAt)}`}var d2=e=>!!(e&&e.scrollWidth>e.clientWidth);function f2({boardId:e,name:t,title:n,children:r}){let[i,a]=(0,d.useState)(!1),{report:o,error:s}=P$(t,i),c=(0,d.useRef)(null),l=(0,d.useRef)(null),[u,f]=(0,d.useState)(!1),p=(0,d.useRef)(null),m=(0,d.useCallback)(e=>{p.current=e,a(!0)},[]),h=(0,d.useCallback)(e=>{a(!1);let t=p.current;e&&t instanceof HTMLElement&&t.isConnected&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))},[]);return(0,d.useEffect)(()=>{let e=e=>{if(e.key.toLowerCase()!==`b`||e.altKey||e.shiftKey||!(c2?e.metaKey:e.ctrlKey))return;let t=e.target instanceof Element&&!!e.target.closest(`.board-switch-panel`);(!Xl(e.target)||t)&&(e.preventDefault(),i?h(!0):m(document.activeElement))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,m,h]),(0,Q.jsxs)(`div`,{className:`board-switch`,children:[r??(0,Q.jsx)(`h1`,{children:(0,Q.jsxs)(`button`,{ref:c,type:`button`,className:`board-switch-button`,onClick:()=>i?h(!0):m(c.current),onMouseEnter:()=>f(d2(l.current)),"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":c2?`Meta+B`:`Control+B`,title:`${u?`${n}\n`:``}Switch board (${l2})`,children:[(0,Q.jsx)(`span`,{ref:l,className:`board-switch-current`,children:n}),(0,Q.jsx)($,{name:`chevron-down`,className:`board-switch-chevron`})]})}),i&&(0,Q.jsx)(p2,{boardId:e,report:o,error:s,button:c,onClose:h})]})}function p2({boardId:e,report:t,error:n,button:r,onClose:i}){let[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(null),[l]=(0,d.useState)(e0),u=(0,d.useRef)(null),f=(0,d.useId)(),p=fT(),m=e=>`${f}-${e}`,h=e=>dS.board(e),g=(0,d.useMemo)(()=>t?$1(Q1(t.projects,l),a):[],[t,l,a]),_=g.find(e=>e.id===s)??g.find(t=>t.id!==e)??g[0],v=_?g.indexOf(_):-1;Zl(!0,i,u,r),(0,d.useEffect)(()=>{v>=0&&document.getElementById(`${f}-${v}`)?.scrollIntoView({block:`nearest`})},[f,v]);let y=e=>{i(!1),location.hash=h(e)},b=e=>{e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),g.length&&c(g[(v+(e.key===`ArrowDown`?1:g.length-1))%g.length].id)):e.key===`Enter`&&_&&(e.preventDefault(),y(_.id))},x=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),y(t))},S=a.trim();return(0,Q.jsxs)(`div`,{className:`board-switch-panel`,ref:u,role:`dialog`,"aria-label":`Switch board`,onBlur:e=>{let t=e.relatedTarget;t&&!u.current?.contains(t)&&!r.current?.contains(t)&&i(!1)},children:[(0,Q.jsxs)(`div`,{className:`board-switch-field`,children:[(0,Q.jsx)($,{name:`search`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>{o(e.target.value),c(null)},onKeyDown:b,placeholder:`Switch board…`,"aria-label":`Find a board`,role:`combobox`,"aria-expanded":g.length>0,"aria-controls":f,"aria-activedescendant":v>=0?m(v):void 0,"aria-autocomplete":`list`,spellCheck:!1}),(0,Q.jsx)(`kbd`,{className:`board-switch-key`,"aria-hidden":!0,children:l2})]}),(0,Q.jsx)(`div`,{className:`board-switch-list`,id:f,role:`listbox`,"aria-label":S?`Matching boards`:`Recent boards`,children:t===null?(0,Q.jsx)(`p`,{className:`board-switch-empty${n?` error`:``}`,role:n?`alert`:`status`,children:n?`Couldn't load your boards: ${n}`:`Loading your boards…`}):g.length===0?(0,Q.jsx)(`p`,{className:`board-switch-empty`,children:S?`No board matches “${S}”.`:`No boards in use.`}):(0,Q.jsxs)(Q.Fragment,{children:[!S&&(0,Q.jsx)(`p`,{className:`board-switch-label`,"aria-hidden":!0,children:`Recent`}),g.map((t,n)=>{let r=t.id===e;return(0,Q.jsxs)(`a`,{id:m(n),role:`option`,"aria-selected":n===v,"aria-current":r?`page`:void 0,className:`board-switch-row${n===v?` is-active`:``}`,href:h(t.id),onMouseMove:()=>n!==v&&c(t.id),onClick:e=>x(e,t.id),title:t.goal,children:[(0,Q.jsxs)(`span`,{className:`board-switch-text`,children:[(0,Q.jsxs)(`span`,{className:`board-switch-title`,children:[(0,Q.jsx)(`span`,{className:`board-switch-name`,children:t.title}),(t.needs??0)>0&&(0,Q.jsxs)(`span`,{className:`tag tag-needs`,children:[t.needs,` `,t.needs===1?`needs`:`need`,` you`]})]}),(0,Q.jsx)(`span`,{className:`board-switch-agent`,children:u2(t,p)})]}),r&&(0,Q.jsx)($,{name:`check`,className:`board-switch-check`})]},t.id)})]})}),(0,Q.jsxs)(`footer`,{className:`board-switch-foot`,children:[(0,Q.jsxs)(`a`,{className:`board-switch-link`,href:dS.newBoard(),children:[(0,Q.jsx)($,{name:`plus`}),` New board`]}),(0,Q.jsx)(`a`,{className:`board-switch-link`,href:dS.home(),children:`All boards`})]})]})}function m2({board:e,name:t,editing:n,onDone:r,actions:i}){let[a,o]=o2(e.title),[s,c]=o2(e.goal??``);return(0,Q.jsxs)(`div`,{className:`board-heading`,children:[(0,Q.jsxs)(`div`,{className:`board-title-row`,children:[(0,Q.jsx)(f2,{boardId:e.id,name:t,title:a,children:n===`title`?(0,Q.jsx)(s2,{as:`h1`,value:a,label:`Rename the board`,required:!0,hint:`Enter to save · Esc to cancel · old links keep working`,onSave:n=>zQ(e.id,t,{title:n}).then(()=>o(n)),onDone:r}):null}),n!==`title`&&i]}),n===`goal`?(0,Q.jsx)(s2,{as:`p`,className:`board-goal`,value:s,placeholder:`Add a goal: what this work is for`,label:s?`Change the goal`:`Add a goal`,onSave:n=>zQ(e.id,t,{goal:n}).then(()=>c(n)),onDone:r}):n!==`title`&&s&&(0,Q.jsx)(`p`,{className:`board-goal`,title:s,children:s})]})}function h2({board:e,name:t,live:n,agents:r,controls:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null),u=vS().agentWork();return pu(l,s,`.board-menu > .menu-button`,()=>c(!1)),(0,Q.jsx)(a2,{bar:l,left:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`topbar-rule`,"aria-hidden":!0}),(0,Q.jsx)(m2,{board:e,name:t,editing:a,onDone:e=>{o(null),c(e)},actions:(0,Q.jsx)(g2,{board:e,name:t,onEdit:o})})]}),right:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(n2,{}),(0,Q.jsx)(jw,{live:n,agents:r,work:u&&(t=>u({board:e,agent:t}))}),i]})})}function g2({board:e,name:t,onEdit:n}){let{open:r,setOpen:i,close:a,root:o,button:s,menu:c,onKeyDown:l}=lu(),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(!1),_=n=>{f(!0),BQ(e.id,t,n).then(()=>{m(null),a(!0)},e=>m(e.message)).finally(()=>f(!1))},v=e=>()=>{a(!1),e()},y={rename:{label:`Rename…`,note:`Its link changes to match. Old links keep working.`,run:v(()=>n(`title`))},goal:{label:HQ(!!e.goal),note:`What this work is for, in a line under its name.`,run:v(()=>n(`goal`))},archive:{label:`Archive`,note:`Hides it from the boards list and makes it read-only, for people and agents. You can unarchive it any time.`,run:()=>_(!0),waits:!0},unarchive:{label:`Unarchive`,note:`Back on the boards list, and open to changes again.`,run:()=>_(!1),waits:!0},delete:{label:`Delete board…`,note:`Removes it and everything on it for good. You confirm by typing its name.`,run:v(()=>g(!0))}};return(0,Q.jsxs)(`div`,{className:`board-menu`,ref:o,children:[(0,Q.jsx)(`button`,{ref:s,className:`menu-button`,onClick:()=>i(!r),"aria-haspopup":`menu`,"aria-expanded":r,"aria-label":`Board actions`,title:`Board actions`,children:(0,Q.jsx)($,{name:`more`})}),r&&(0,Q.jsxs)(`div`,{className:`menu-panel`,role:`menu`,"aria-label":`Board actions`,ref:c,onKeyDown:l,children:[UQ(e).map(t=>t===`connectors`?(0,Q.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`menu-item`,href:dS.connectors(e.id),onClick:()=>a(!1),children:[(0,Q.jsx)(`strong`,{children:`Connectors`}),(0,Q.jsxs)(`span`,{children:[G(oa().map(e=>e.name)),` and other services, set up once for every board.`]})]},t):(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item`,disabled:y[t].waits&&u,onClick:y[t].run,children:[(0,Q.jsx)(`strong`,{children:y[t].label}),(0,Q.jsx)(`span`,{children:y[t].note})]},t)),p&&(0,Q.jsx)(`p`,{className:`menu-error error`,role:`alert`,children:p})]}),h&&(0,Q.jsx)(a0,{board:e,name:t,onClose:()=>g(!1),onDeleted:CS.home}),` `]})}function _2({board:e,name:t}){let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(null);if(!e.archived)return null;let{by:o,at:s}=e.archived;return(0,Q.jsxs)(`div`,{className:`archived-bar`,children:[(0,Q.jsx)($,{name:`archive`,className:`archived-icon`}),(0,Q.jsxs)(`p`,{className:`archived-text`,children:[(0,Q.jsx)(`strong`,{children:`Archived`}),` by `,o.name,` `,ex(s),`. Read-only for people and agents until it's unarchived.`]}),i&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:i}),(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:n,onClick:()=>{r(!0),BQ(e.id,t,!1).then(()=>a(null),e=>a(e.message)).finally(()=>r(!1))},children:`Unarchive`})]})}var v2=[`comment`,`block`],y2={comment:`Comments`,block:`Canvas`},b2={placeholder:`Search comments and canvases`,hint:`Find past comments and canvas notes.`},x2={query:``,filter:`all`,allBoards:!1,openOnly:!1},S2=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),C2=S2?`⌘K`:`Ctrl K`;function w2(e,t){let n=e;for(let{id:e}of t.kinds()){let t=n[`${e}Id`];if(typeof t==`string`&&t)return{kind:e,id:t}}}function T2(e,t){let{boardId:n,target:r}=e,i=w2(r,t);return i?t.byId(i.kind,n,i.id)?.href??dS.board(n):r.pageId?dS.page(n,r.pageId):dS.context(n)}function E2(e,t){let{target:n}=e;n.blockId&&_X(n.blockId),location.hash=T2(e,t),n.commentId&&!n.pinId&&JE([n.commentId])}function D2({text:e,ranges:t}){let n=[],r=0;for(let[i,a]of t)i<r||(i>r&&n.push(e.slice(r,i)),n.push({mark:e.slice(i,a)}),r=a);return r<e.length&&n.push(e.slice(r)),(0,Q.jsx)(Q.Fragment,{children:n.map((e,t)=>typeof e==`string`?e:(0,Q.jsx)(`mark`,{children:e.mark},t))})}function O2({boardId:e,onClose:t}){let n=mx(),r=vS(),i=r.search(),a=r.boardContext()?.name,o=(0,d.useMemo)(()=>[{key:`all`,label:`All`,kinds:i?[]:v2},...i?.filters??[],{key:`comments`,label:`Comments`,kinds:[`comment`]},{key:`canvas`,label:`Canvas`,kinds:[`block`]}],[i]),s=i??b2,[c,l]=(0,d.useState)(x2.query),[u,f]=(0,d.useState)(x2.filter),[p,m]=(0,d.useState)(x2.allBoards),[h,g]=(0,d.useState)(x2.openOnly),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(0),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=p||!e,E=c.trim(),D=E.length>=2;(0,d.useEffect)(()=>{x2={query:c,filter:u,allBoards:p,openOnly:h}},[c,u,p,h]),(0,d.useEffect)(()=>{w.current?.select()},[]),Zl(!0,t,C),(0,d.useEffect)(()=>{if(!D){v(null),b(null);return}let t=!1,n=o.find(e=>e.key===u)?.kinds,r=setTimeout(()=>{X.search(e,E,{kinds:n,all:T,open:h}).then(e=>{t||(v(e),b(null),S(0))},e=>!t&&b(e.message))},120);return()=>{t=!0,clearTimeout(r)}},[e,E,D,u,T,h,o]);let O=(0,d.useMemo)(()=>{let e=new Map;for(let t of _?.results??[])e.set(t.kind,[...e.get(t.kind)??[],t]);return[...e].map(([e,t])=>({kind:e,label:i?.groups[e]??y2[e]??e,results:t}))},[_,i]),k=O.flatMap(e=>e.results);(0,d.useEffect)(()=>{document.getElementById(`search-row-${x}`)?.scrollIntoView({block:`nearest`})},[x]);let A=e=>{t(),E2(e,n)},j=e=>{e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),k.length&&S(t=>(t+(e.key===`ArrowDown`?1:k.length-1))%k.length)):e.key===`Enter`&&k[x]&&(e.preventDefault(),A(k[x]))},M=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),A(t))},N=T?`all boards`:`this board`,P=D?_?`${_.results.length<_.total?`${_.results.length} of ${_.total}`:_.total} result${_.total===1?``:`s`} · ${N}`:`Searching ${N}…`:N,F=-1;return(0,Qx.createPortal)((0,Q.jsx)(`div`,{className:`search-scrim`,children:(0,Q.jsxs)(`div`,{className:`search-panel`,ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,children:[(0,Q.jsxs)(`div`,{className:`search-field`,children:[(0,Q.jsx)($,{name:`search`}),(0,Q.jsx)(`input`,{ref:w,autoFocus:!0,value:c,onChange:e=>l(e.target.value),onKeyDown:j,placeholder:s.placeholder,role:`combobox`,"aria-expanded":k.length>0,"aria-controls":`search-results`,"aria-activedescendant":k.length?`search-row-${x}`:void 0,"aria-autocomplete":`list`,spellCheck:!1}),(0,Q.jsx)(`span`,{className:`search-count`,"aria-live":`polite`,children:P})]}),(0,Q.jsxs)(`div`,{className:`search-filters`,children:[(0,Q.jsx)(`div`,{className:`search-chips`,role:`group`,"aria-label":`Show`,children:o.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`search-chip`,"aria-pressed":u===e.key,onClick:()=>f(e.key),children:e.label},e.key))}),(0,Q.jsxs)(`div`,{className:`search-chips`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`search-chip`,"aria-pressed":T,disabled:!e,title:e?`Search every board, archived ones included`:`Every board is searched from here`,onClick:()=>m(!p),children:[T&&(0,Q.jsx)($,{name:`check`}),` All boards`]}),i&&(0,Q.jsxs)(`button`,{type:`button`,className:`search-chip`,"aria-pressed":h,title:i.openOnly.title,onClick:()=>g(!h),children:[h&&(0,Q.jsx)($,{name:`check`}),` Open only`]})]})]}),(0,Q.jsx)(`div`,{className:`search-results`,id:`search-results`,role:`listbox`,"aria-label":`Results`,children:D?y?(0,Q.jsx)(`p`,{className:`search-empty error`,children:y}):_&&_.total===0?(0,Q.jsxs)(`div`,{className:`search-empty`,children:[(0,Q.jsxs)(`p`,{children:[`Nothing matches “`,E,`” on `,N,u===`all`?``:` in ${o.find(e=>e.key===u)?.label.toLowerCase()}`,h?` among open cards`:``,`.`]}),!T&&(0,Q.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>m(!0),children:`Search all boards`})]}):O.map(e=>(0,Q.jsxs)(`section`,{className:`search-group`,"aria-label":e.label,children:[(0,Q.jsxs)(`h3`,{className:`search-group-head`,children:[e.label,` `,(0,Q.jsx)(`span`,{className:`tab-count`,children:e.results.length})]}),e.results.map(e=>{F+=1;let t=F,r=e.target.canvas===`board`||e.target.canvas===`page`,o=i?.result(e),s=[r&&(e.target.pageId?e.ref:a),e.snippet?.where].filter(Boolean).join(` · `);return(0,Q.jsxs)(`a`,{id:`search-row-${t}`,role:`option`,"aria-selected":t===x,className:`search-row${t===x?` is-active`:``}`,href:T2(e,n),onMouseMove:()=>t!==x&&S(t),onClick:t=>M(t,e),title:o?.status?`${e.ref} · ${o.status}`:e.ref,children:[(0,Q.jsx)(`span`,{className:`search-ref ${o?.marker??``}`,children:r?(0,Q.jsx)($,{name:`canvas`}):e.ref}),(0,Q.jsxs)(`span`,{className:`search-text`,children:[(0,Q.jsx)(`span`,{className:`search-title`,children:(0,Q.jsx)(D2,{text:e.title,ranges:e.titleRanges})}),(e.snippet||s)&&(0,Q.jsxs)(`span`,{className:`search-snippet`,children:[s&&(0,Q.jsx)(`span`,{className:`search-where`,children:s}),e.snippet&&(0,Q.jsx)(D2,{text:e.snippet.text,ranges:e.snippet.ranges})]})]}),(0,Q.jsxs)(`span`,{className:`search-side`,children:[T&&(0,Q.jsxs)(`span`,{className:`search-board`,title:e.boardTitle,children:[e.boardTitle,e.boardArchived&&` · archived`]}),o?.tag]})]},`${e.kind}:${e.target.commentId??e.target.blockId??w2(e.target,n)?.id}:${t}`)})]},e.kind)):(0,Q.jsx)(`p`,{className:`search-empty`,children:E?`Type at least two characters.`:s.hint})}),(0,Q.jsxs)(`footer`,{className:`search-foot`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{children:`↑`}),(0,Q.jsx)(`kbd`,{children:`↓`}),` to move · `,(0,Q.jsx)(`kbd`,{children:`↵`}),` to open · `,(0,Q.jsx)(`kbd`,{children:`Esc`})]}),(0,Q.jsxs)(`span`,{className:`faint`,children:[C2,` from anywhere`]})]})]})}),document.body)}function k2({boardId:e}){let[t,n]=(0,d.useState)(!1),r=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=e=>{e.key.toLowerCase()!==`k`||e.altKey||e.shiftKey||!(S2?e.metaKey:e.ctrlKey)||(e.preventDefault(),n(e=>(e||(r.current=document.activeElement),!e)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let i=(0,d.useCallback)(()=>{n(!1);let e=r.current;e instanceof HTMLElement&&e.isConnected&&requestAnimationFrame(()=>e.focus({preventScroll:!0}))},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`search-button`,onClick:()=>{r.current=document.activeElement,n(!0)},"aria-haspopup":`dialog`,"aria-expanded":t,title:`Search (${C2})`,"aria-label":`Search`,children:(0,Q.jsx)($,{name:`search`})}),t&&(0,Q.jsx)(O2,{boardId:e,onClose:i})]})}function A2({board:e,name:t,steps:n,children:r}){let i=vS().refKinds();return(0,Q.jsx)(mu.Provider,{value:!!e.archived,children:(0,Q.jsx)(Nb,{board:e,kinds:i,children:(0,Q.jsx)(lT,{value:e.presence??[],children:(0,Q.jsx)(Hw,{value:n,children:(0,Q.jsx)(pE,{board:e,me:t,children:r})})})})})}function j2({board:e}){return(0,d.useEffect)(()=>{e&&i0(e)},[e]),(0,Q.jsx)(`div`,{className:`page`,children:(0,Q.jsxs)(`div`,{className:`board-deleted`,children:[(0,Q.jsx)(`h1`,{children:`This board was deleted`}),(0,Q.jsxs)(`p`,{children:[e?`“${e.title}” was deleted by a person, for good. `:``,`It is gone from Tricot, with everything on it.`]}),(0,Q.jsx)(`a`,{href:dS.home(),children:`Back to boards`})]})})}function M2({route:e,name:t}){let{boardId:n,pinId:r}=e,i=vS(),{board:a,error:o,live:s,deleted:c,steps:l}=H$(n);N1(n,!!(a&&B1(a))),jx(`page`,c?void 0:a?.title);let u=j$(a,t),f=lC(a,t),p=i.useSession({board:a,boardId:n,name:t,route:e,away:u}),{markSeen:m}=u,h=f.seen,[g,_]=(0,d.useState)(),v=i.cardPages().flatMap(t=>t.idAt(e)??[]).join(`
100
+ `);(0,d.useEffect)(()=>{for(let e of v?v.split(`
101
+ `):[])m(e),h(e,!1)},[v,m,h]),du(3e4),(0,d.useEffect)(()=>{a?.aliases?.includes(n)&&location.replace(fS(location.hash,a.id))},[a,n]),(0,d.useEffect)(()=>{if(!r||!a)return;vX(r);let e=is(a,r),t=e?.page&&jo(e.page)?e.canvas.blocks.find(t=>t.id===e.pin.blockId):void 0;t?.type===`code`?TS(dS.files(a.id,t.path,!0)):wS(e?.page?.id)},[r,!!a]);let y=a?.id;if((0,d.useEffect)(()=>{a&&y&&r0(y,a.aliases)},[y]),c)return(0,Q.jsx)(j2,{board:a});if(o&&!a)return(0,Q.jsx)(`div`,{className:`page`,children:(0,Q.jsxs)(`div`,{className:`empty empty-page`,children:[(0,Q.jsx)(`p`,{children:o}),(0,Q.jsx)(`a`,{href:dS.home(),children:`Back to boards`})]})});if(!a)return(0,Q.jsx)(`div`,{className:`page loading`,children:`Loading board…`});let b=i.viewAt(e.view),x=b?.id??``,S={board:a,name:t,route:e,shown:x,away:u,justMade:f,session:p,onFile:_},C=a.presence??[],w=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ox,{className:`connect-popover`,children:[(0,Q.jsx)(`summary`,{className:`search-button`,title:`Connect an agent`,"aria-label":`Connect an agent`,children:(0,Q.jsx)($,{name:`knitted-plug`})}),(0,Q.jsx)(`div`,{className:`popover-body`,children:(0,Q.jsx)(Ew,{boardId:a.id})})]}),(0,Q.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0}),(0,Q.jsx)(k2,{boardId:a.id}),i.controls(S),(0,Q.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0})]}),T=(0,Q.jsx)(h2,{board:a,name:t,live:s,agents:C,controls:w}),E=i.needsStrip(S),D=(0,Q.jsx)(_2,{board:a,name:t});for(let e of i.cardPages()){let n=e.render(S,{topbar:T,notice:D,needsYou:E});if(n)return(0,Q.jsx)(A2,{board:a,name:t,steps:l,children:n})}let O=i.feed(),k=!!O?.open(S);return(0,Q.jsx)(A2,{board:a,name:t,steps:l,children:(0,Q.jsxs)(`div`,{className:`page board-page`,children:[T,D,(0,Q.jsxs)(`div`,{className:`attention`,children:[i.doors().map(e=>(0,Q.jsx)(d.Fragment,{children:e.door?.(S)},e.id)),(0,Q.jsx)(`nav`,{className:`tabs`,"aria-label":`Board views`,children:i.tabs().map(e=>{let t=e.tab?.(S)??{changed:!1};return(0,Q.jsxs)(`a`,{href:e.link(a.id),className:x===e.id?`is-active`:``,children:[e.label,` `,t.count!==void 0&&(0,Q.jsx)(`span`,{className:`tab-count`,children:t.count}),t.more,t.changed&&(0,Q.jsx)(`span`,{className:`new-dot`,"aria-label":`Has changes`})]},e.id)})}),(0,Q.jsxs)(`div`,{className:`attention-end`,children:[E,b?.controls?.(S),O?.toggle(S)]})]}),(0,Q.jsxs)(`div`,{className:`board-layout${k?``:` board-layout-full`}${b?.layout?` board-layout-${b.layout}`:``}`,children:[b?.render(S),(0,Q.jsx)(hQ,{board:a,name:t,door:b?.chat(S)??`threads`,page:x===`scratch`&&e.pageId?a.pages?.find(t=>t.id===e.pageId):void 0,file:x===`files`?g:void 0,onSeeItem:m}),k&&O?.panel(S)]})]})})}function N2({page:e}){let t=No(e.agent);if(!t||!e.agent)return null;let n=e.agent.name;return(0,Q.jsx)(`p`,{className:`scratch-maker`,title:`${t}\nWhat you ask on this page, from the chat bar or about blocks you select, goes to ${n}, unless you @-mention another agent.`,children:(0,Q.jsxs)(`span`,{className:`scratch-maker-text`,children:[t,(0,Q.jsxs)(`span`,{className:`scratch-maker-to`,children:[` · `,n,` answers here`]})]})})}var P2=`application/x-tricot-page`;function F2(e){let{pages:t,current:n,changed:r,readOnly:i,renaming:a,autoFocus:o,onShow:s,onAdd:c,onStartRename:l,onRenamed:u,onDelete:f,onMove:p}=e,[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(null),v=(0,d.useRef)(null);if((0,d.useLayoutEffect)(()=>{let e=v.current;v.current=null,e&&document.querySelector(`.toolbar-pages [data-page="${CSS.escape(e)}"]`)?.focus()},[t]),a)return(0,Q.jsx)(I2,{page:n,onDone:(e,t)=>{h(t),u(e)}});let y=(e,n)=>{if(e.id===n)return;if(e.after)return p(n,e.id);let r=t.filter(e=>e.id!==n),i=r.findIndex(t=>t.id===e.id);p(n,i>0?r[i-1].id:null)},b=(e,n)=>{if(i||!e.altKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault(),e.stopPropagation();let r=e.key===`ArrowDown`?1:-1,a=t[t.indexOf(n)+r];a&&(v.current=n.id,y({id:a.id,after:r>0},n.id))},x=e=>i?{}:{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(P2,e.id),t.dataTransfer.effectAllowed=`move`,_({id:e.id})},onDragOver:t=>{if(!g||!t.dataTransfer.types.includes(P2))return;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`;let n=t.currentTarget.getBoundingClientRect(),r={id:e.id,after:t.clientY>n.top+n.height/2};(g.at?.id!==r.id||g.at.after!==r.after)&&_({...g,at:r})},onDrop:e=>{g&&(e.preventDefault(),e.stopPropagation(),g.at&&y(g.at,g.id),_(null))},onDragEnd:()=>_(null)},S=({open:e,close:a,enter:o})=>{let u={role:e?`menuitem`:void 0,tabIndex:-1,type:`button`},d=(e,t,n,r)=>(0,Q.jsx)(`button`,{...u,className:`menu-item is-line add-menu-item`,style:o(e),onClick:r,children:(0,Q.jsxs)(`span`,{className:`add-menu-row`,children:[(0,Q.jsx)($,{name:t,className:`add-menu-icon`}),n]})});return(0,Q.jsxs)(Q.Fragment,{children:[t.map((e,t)=>{let c=e.id===n.id,l=g?.at?.id===e.id&&g.id!==e.id?g.at:void 0,d=[`pages-menu-row`,g?.id===e.id&&`is-dragged`,l&&(l.after?`drop-after`:`drop-before`)].filter(Boolean);return(0,Q.jsx)(`div`,{role:`none`,className:d.join(` `),...x(e),children:(0,Q.jsx)(`button`,{...u,className:`menu-item is-line add-menu-item pages-menu-page`,"data-page":e.id,"data-menu-start":c?``:void 0,"aria-current":c?`page`:void 0,title:i?e.title:`${e.title}. Drag to move it.`,style:o(t),onClick:()=>{a(!0),c||s(e.id)},onKeyDown:t=>b(t,e),children:(0,Q.jsxs)(`span`,{className:`add-menu-row`,children:[(0,Q.jsx)(`span`,{className:`pages-menu-mark`,children:c&&(0,Q.jsx)($,{name:`check`})}),(0,Q.jsx)(`span`,{className:`pages-menu-title`,children:e.title}),!c&&r.has(e.id)&&(0,Q.jsx)(`span`,{className:`new-dot`,"aria-label":`Has changes`})]})})},e.id)}),!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`separator`,className:`menu-rule add-menu-rule`,style:o(t.length)}),d(t.length+1,`edit`,`Rename page`,()=>{a(!1),l()}),d(t.length+2,`trash`,`Delete page…`,()=>{a(!0),f(n)}),d(t.length+3,`plus`,`New page`,()=>{a(!1),c()})]})]})},C=t.some(e=>e.id!==n.id&&r.has(e.id));return(0,Q.jsx)(KY,{icon:`pages`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`toolbar-pages-title`,children:n.title}),C&&(0,Q.jsx)(`span`,{className:`new-dot`})]}),title:i?`The Sketchbook's pages`:`The Sketchbook's pages. F2 renames this one.`,name:`Pages: ${n.title}${C?`. Another page has changes.`:``}`,menuLabel:`Pages`,className:`toolbar-pages`,rows:t.length+(i?0:4),autoFocus:o||m,onButtonKeyDown:e=>{e.key!==`F2`||i||(e.preventDefault(),l())},children:S})}function I2({page:e,onDone:t}){let[n,r]=(0,d.useState)(e.title.length),i=(0,d.useRef)(!1),a=(e,n)=>{i.current||(i.current=!0,t(e,n))};return(0,Q.jsx)(`div`,{className:`toolbar-add toolbar-pages`,children:(0,Q.jsxs)(`div`,{className:`toolbar-add-field toolbar-pages-field`,children:[(0,Q.jsx)(`span`,{className:`toolbar-add-plus`,"aria-hidden":!0,children:(0,Q.jsx)($,{name:`pages`})}),(0,Q.jsx)(`input`,{className:`nodrag nopan`,"aria-label":`Page name`,autoFocus:!0,defaultValue:e.title,maxLength:120,size:Math.max(12,Math.min(40,n+2)),onFocus:e=>e.currentTarget.select(),onInput:e=>r(e.currentTarget.value.length),onBlur:e=>a(e.currentTarget.value,!1),onKeyDown:e=>{e.key!==`Tab`&&(e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),a(e.currentTarget.value,!0)):e.key===`Escape`&&(e.preventDefault(),a(null,!0)))}})]})})}var L2=`Untitled page`,R2=4e3;function z2(e){try{let t=localStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}}function B2(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function V2({board:e,name:t,pageId:n,newItems:r,changed:i,onSeeItem:a}){let o=hu(),s=`tricot:scratch-page:${nl(e)}`,[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),y=(0,d.useCallback)(e=>v(e instanceof Error?e.message:String(e)),[]);(0,d.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>v(null),R2);return()=>clearTimeout(e)},[_]),(0,d.useEffect)(()=>{c&&e.pages?.some(e=>e.id===c.id)&&l(null)},[c,e.pages]);let b=(0,d.useMemo)(()=>{let t=Oo(e),n=c&&!t.some(e=>e.id===c.id)?[...t,c]:t;if(!u||u.from!==e.pages)return n;let r=new Map(u.order.map((e,t)=>[e,t]));return[...n].sort((e,t)=>(r.get(e.id)??1/0)-(r.get(t.id)??1/0))},[e,c,u]),x=n?b.find(e=>e.id===n):void 0,S=z2(s),C=x??b.find(e=>e.id===S)??b[0],w=C?.id;(0,d.useEffect)(()=>{w?(w!==n&&TS(dS.page(e.id,w)),B2(s,w)):n&&n!==c?.id&&TS(dS.board(e.id,`scratch`))},[w,n,e.id,s,c]),(0,d.useEffect)(()=>{w&&a(w)},[w,a]),(0,d.useEffect)(()=>g(null),[w]);let T=t=>{g(t),CS.page(e.id,t)},E=async()=>{try{let n=await X.addPage(e.id,t,L2);l(n),m(n.id),CS.page(e.id,n.id)}catch(e){y(e)}},D=(e,n)=>{m(null);let r=n?.trim();r&&r!==e.title&&X.renamePage(e.id,t,r).catch(y)},O=(n,r)=>{let i=b.filter(e=>e.id!==n).map(e=>e.id),a=[...i];a.splice(r===null?0:i.indexOf(r)+1,0,n),a.every((e,t)=>e===b[t]?.id)||(f({from:e.pages,order:a}),X.movePage(n,t,r).catch(e=>{f(null),y(e)}))},k=async n=>{let r=n.canvas.blocks.length;if(await MB({title:`Delete “${n.title}”?`,detail:r?`Its ${r} block${r===1?``:`s`}, with their comments and versions, go with it, for good.`:`It has nothing on it. It goes for good.`,confirmLabel:`Delete page`,danger:!0}))try{let r=b.findIndex(e=>e.id===n.id);if(await X.deletePage(n.id,t),n.id!==w)return;let i=b[r+1]??b[r-1];i&&g(i.id),TS(i?dS.page(e.id,i.id):dS.board(e.id,`scratch`))}catch(e){y(e)}},A=_&&(0,Q.jsx)(`p`,{className:`scratch-error error`,role:`alert`,children:_});return C?(0,Q.jsxs)(`div`,{className:`scratch-pad`,children:[(0,Q.jsx)(vZ,{board:e,page:C,name:t,newItems:r,onSeeItem:a,lead:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F2,{pages:b,current:C,changed:i,readOnly:o,renaming:p===C.id&&!o,autoFocus:h===C.id,onShow:T,onAdd:E,onStartRename:()=>m(C.id),onRenamed:e=>D(C,e),onDelete:k,onMove:O}),(0,Q.jsx)(N2,{page:C})]})},C.id),A]}):(0,Q.jsxs)(`div`,{className:`scratch-pad`,children:[(0,Q.jsxs)(`div`,{className:`scratch-empty`,children:[(0,Q.jsx)($,{name:`canvas`}),(0,Q.jsx)(`h2`,{children:`The sketchbook is empty`}),(0,Q.jsx)(`p`,{children:`Start a page to sketch an idea out with agents.`}),!o&&(0,Q.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:E,children:[(0,Q.jsx)($,{name:`plus`}),` New page`]})]}),A]})}function H2(e){return e.add({id:`scratch`,label:`Sketchbook`,link:e=>dS.board(e,`scratch`),tab:({board:e,away:t})=>({count:Oo(e).length,changed:t.pagesChanged.size>0}),chat:()=>`threads`,render:({board:e,name:t,route:n,away:r})=>(0,Q.jsx)(`section`,{className:`board-canvas`,"aria-label":`Sketchbook`,children:(0,Q.jsx)(V2,{board:e,name:t,pageId:n.pageId,newItems:r.items,changed:r.pagesChanged,onSeeItem:r.markSeen})})}),e.add({id:`files`,link:e=>dS.files(e),door:({board:e,shown:t})=>(0,Q.jsx)(`a`,{className:`files-door${t===`files`?` is-active`:``}`,href:dS.files(e.id),"aria-label":`Project files`,"aria-current":t===`files`?`page`:void 0,"aria-keyshortcuts":B1(e)?`${C1} ${T1}`:void 0,title:B1(e)?`Project files · ${B1(e)} · ${S1} finds a file, ${w1} searches inside them`:`Project files · choose the project folder`,children:(0,Q.jsx)($,{name:`folder`})}),chat:()=>`threads`,render:({board:e,name:t,route:n,onFile:r})=>(0,Q.jsx)(H1,{board:e,name:t,file:n.file,pair:n.pair,line:n.line,onShown:r})}),e}function U2(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),i=(0,d.useCallback)(()=>{X.connectors().then(e=>{t(e),r(null)},e=>r(e.message))},[]);return(0,d.useEffect)(()=>{i(),window.addEventListener(`focus`,i);let e=AW(i);return()=>{window.removeEventListener(`focus`,i),e()}},[i]),{connectors:e,error:n,refresh:i,setConnectors:t}}var W2={connected:{label:`Connected`,tone:`connected`},ready:{label:`Not connected`,tone:`idle`},not_set_up:{label:`Not set up`,tone:`idle`},needs_sign_in:{label:`Sign in again`,tone:`attention`},error:{label:`Not working`,tone:`error`}};function G2({state:e}){let{label:t,tone:n}=W2[e];return(0,Q.jsx)(`span`,{className:`status connector-state is-${n}`,children:t})}function K2({id:e}){let t=yq(e)?.Mark;return t?(0,Q.jsx)(t,{}):(0,Q.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0})}function q2({from:e}){let{connectors:t,error:n,refresh:r,setConnectors:i}=U2();jx(`page`,`Connectors`);let[a,o]=(0,d.useState)();(0,d.useEffect)(()=>{e&&X.boards().then(t=>o(t.find(t=>t.id===e)?.title),()=>{})},[e]);let s=t?.some(e=>e.state===`not_set_up`);return(0,d.useEffect)(()=>{if(!s)return;let e=setInterval(()=>document.visibilityState===`visible`&&r(),5e3);return()=>clearInterval(e)},[s,r]),(0,Q.jsxs)(`div`,{className:`page`,children:[(0,Q.jsx)(a2,{}),(0,Q.jsxs)(`main`,{className:`connectors`,children:[(0,Q.jsxs)(`a`,{className:`connectors-back`,href:e?dS.board(e):dS.home(),children:[(0,Q.jsx)($,{name:`arrow-left`}),` `,e?a?`Back to ${a}`:`Back to the board`:`All boards`]}),(0,Q.jsxs)(`section`,{className:`connectors-intro`,children:[(0,Q.jsx)(`h1`,{children:`Connectors`}),(0,Q.jsx)(`p`,{className:`lede`,children:`Let Tricot read from the services you already use. You set each one up once on this computer, and every board uses it. Sign-ins stay on this computer.`})]}),n&&!t&&(0,Q.jsx)(`p`,{className:`error`,children:n}),t===null?!n&&(0,Q.jsx)(`p`,{className:`muted`,children:`Loading…`}):(0,Q.jsx)(`div`,{className:`connector-list`,children:t.map(e=>(0,Q.jsx)(Y2,{connector:e,onChange:e=>i(t=>t?.map(t=>t.id===e.id?e:t)??null),refresh:r},e.id))})]})]})}var J2=6e5;function Y2(e){let{connector:t,onChange:n,refresh:r}=e,[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(!1),h=(0,d.useRef)(t.account?.connectedAt);(0,d.useEffect)(()=>{if(!i)return;let e=AW(e=>{e.id===t.id&&(e.ok||(s(e.message??`The sign-in failed.`),a(null)))}),n=setInterval(()=>{Date.now()-i.since>J2?a(null):r()},2e3);return()=>{e(),clearInterval(n)}},[i,t.id,r]),(0,d.useEffect)(()=>{let e=t.account?.connectedAt;i&&t.state===`connected`&&e!==h.current&&(a(null),s(null)),h.current=e},[t,i]);let g=async e=>{let n=window.open(``,`_blank`);s(null),l(null),a({since:Date.now()});try{let{url:r}=await X.startConnector(t.id,e);n&&(n.location.href=r),a({url:r,since:Date.now(),blocked:!n})}catch(e){n?.close(),a(null),s(e.message)}},_=async()=>{m(!0);try{let{connector:e,revoked:r}=await X.disconnectConnector(t.id);n(e),f(!1),l(r?null:x?.removedNote??`Signed out here. ${t.name} couldn't be reached to remove Tricot's access too; ${x?.signOutHint??`you can remove it where you manage its access.`}`)}catch(e){s(e.message)}finally{m(!1)}},{state:v,account:y}=t,b=v===`connected`||v===`needs_sign_in`||v===`error`&&y,x=yq(t.id),S=x?.permission,C=!!(S&&t.access.find(e=>e.scope===S.scope)?.granted),w=o??(i?null:t.lastFailure),T=v===`not_set_up`&&t.clientFile;return(0,Q.jsxs)(`article`,{className:`connector-card is-${v}`,"aria-labelledby":`connector-${t.id}`,children:[(0,Q.jsxs)(`header`,{className:`connector-head`,children:[(0,Q.jsx)(K2,{id:t.id}),(0,Q.jsxs)(`div`,{className:`connector-name`,children:[(0,Q.jsx)(`h2`,{id:`connector-${t.id}`,children:t.name}),x?.serves&&(0,Q.jsx)(`p`,{className:`muted small`,children:x.serves})]}),(0,Q.jsx)(G2,{state:v})]}),y&&v!==`not_set_up`&&(0,Q.jsxs)(`p`,{className:`connector-account`,children:[v===`connected`?`Connected as`:`Was connected as`,` `,(0,Q.jsx)(`strong`,{children:y.email}),(0,Q.jsxs)(`span`,{className:`faint connector-since`,children:[` · `,ex(y.connectedAt)]})]}),v!==`not_set_up`&&t.clientSource&&(0,Q.jsx)(`p`,{className:`faint small connector-client`,children:t.clientSource===`built-in`?(0,Q.jsxs)(Q.Fragment,{children:[`Signs in with Tricot's own `,t.name,` client: nothing to set up.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Signs in with your own client, from `,(0,Q.jsx)(`code`,{children:t.clientFile}),`. A client file in the data folder always comes first.`]})}),(v===`needs_sign_in`||v===`error`||T)&&t.message&&(0,Q.jsx)(`p`,{className:`connector-note${v===`needs_sign_in`?` is-attention`:` is-error`}`,role:`status`,children:t.message}),(0,Q.jsxs)(`section`,{className:`connector-section`,children:[(0,Q.jsx)(`h3`,{children:v===`connected`?`What Tricot can use`:`What Tricot asks to use`}),(0,Q.jsx)(`ul`,{className:`connector-access`,children:t.access.map(e=>(0,Q.jsxs)(`li`,{className:e.granted===!1?`is-denied`:void 0,children:[(0,Q.jsx)($,{name:e.granted===!1?`x`:`check`,className:`connector-access-icon`}),(0,Q.jsxs)(`span`,{children:[e.label,e.granted===!1&&(0,Q.jsx)(`span`,{className:`faint`,children:` · not allowed; connect again to allow it`})]})]},e.scope))}),(0,Q.jsx)(`p`,{className:`faint small`,children:x?.accessNote(t)??`Read-only: it can't open what's in your files, or change anything.`}),t.notice&&v===`connected`&&(0,Q.jsx)(`p`,{className:`connector-note is-attention`,role:`status`,children:t.notice})]}),v===`connected`&&x?.Panel&&(0,Q.jsx)(x.Panel,{status:t}),x?.SignIn&&(v===`ready`||v===`needs_sign_in`)&&(0,Q.jsx)(x.SignIn,{status:t,onChange:n}),v===`not_set_up`&&t.setup&&(0,Q.jsxs)(`section`,{className:`connector-section`,children:[(0,Q.jsxs)(`h3`,{children:[`Set up `,t.name,` once`]}),(0,Q.jsx)(`p`,{className:`muted small`,children:x?.setup.intro}),(0,Q.jsx)(`ol`,{className:`connector-steps`,children:t.setup.steps.map((e,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(X2,{text:e,folder:t.setup.folder,files:x?.setup.files??[]})},n))}),(0,Q.jsx)(`p`,{className:`muted small`,children:`This page picks the file up on its own.`})]}),w&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:w}),c&&(0,Q.jsx)(`p`,{className:`muted small`,children:c}),(0,Q.jsx)(`footer`,{className:`connector-actions`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),i.blocked?`The browser didn't open a new tab. Open ${t.name} to sign in, then come back here.`:`Finish signing in on the ${t.name} tab…`]}),i.url&&(0,Q.jsxs)(`a`,{className:`btn btn-small${i.blocked?` btn-primary`:``}`,href:i.url,target:`_blank`,rel:`noreferrer`,children:[i.blocked?`Open ${t.name}`:`Open it again`,(0,Q.jsx)($,{name:`external`})]}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>a(null),children:`Cancel`})]}):u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`connector-confirm`,children:[`Disconnect `,t.name,`? Link cards go back to plain names, for every board.`]}),(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:p,onClick:_,children:`Disconnect`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:p,onClick:()=>f(!1),children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[v===`ready`&&!x?.SignIn&&(0,Q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>g(),children:[`Connect `,t.name]}),v===`needs_sign_in`&&!x?.SignIn&&(0,Q.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>g(),children:`Connect again`}),v===`connected`&&t.notice&&(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>g(),children:`Connect again`}),v===`connected`&&S&&!C&&(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:()=>g([S.name]),title:S.title,children:S.button}),(v===`not_set_up`||v===`error`&&!y)&&(0,Q.jsx)(`button`,{className:`btn btn-small`,onClick:r,children:`Check again`}),v===`ready`&&!x?.SignIn&&(0,Q.jsxs)(`span`,{className:`faint small`,children:[`Opens `,t.name,` in a new tab.`]}),b&&(0,Q.jsx)(`button`,{className:`btn ${v===`connected`?``:`btn-quiet `}btn-small`,onClick:()=>f(!0),children:`Disconnect`})]})})]})}function X2({text:e,folder:t,files:n}){let r=[t,...n],i=RegExp(`(${r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})`);return(0,Q.jsx)(Q.Fragment,{children:e.split(i).map((e,t)=>r.includes(e)?(0,Q.jsx)(`code`,{children:e},t):e)})}var Z2={connected:{text:`connected`,square:`decided`},ready:{text:`not connected`,square:`idle`},not_set_up:{text:`not set up`,square:`idle`},needs_sign_in:{text:`needs you to sign in again`,square:`open`},error:{text:`not working`,square:`blocking`}};function Q2(){let{connectors:e}=U2();return e?e.length===0?(0,Q.jsx)(`a`,{className:`home-link`,href:dS.connectors(),children:`Set up`}):(0,Q.jsx)(Q.Fragment,{children:e.map(e=>(0,Q.jsxs)(`a`,{className:`home-link home-status`,href:dS.connectors(),title:e.state===`connected`&&e.account?`Connected as ${e.account.email}`:`${W2[e.state].label}: open Connectors`,children:[(0,Q.jsx)(`span`,{className:`sq sq-${Z2[e.state].square}`,"aria-hidden":!0}),e.name,` `,Z2[e.state].text]},e.id))}):null}function $2({title:e,hasGoal:t,onEdit:n,onArchive:r}){let{open:i,setOpen:a,close:o,root:s,button:c,menu:l,onKeyDown:u}=lu(),d=e=>()=>{o(!1),e()};return(0,Q.jsxs)(`div`,{className:`project-menu`,ref:s,children:[(0,Q.jsx)(`button`,{ref:c,type:`button`,className:`menu-button project-menu-button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-label":`Actions for ${e}`,title:`Rename, edit the goal or archive`,onClick:()=>a(!i),children:(0,Q.jsx)($,{name:`more`})}),i&&(0,Q.jsxs)(`div`,{className:`menu-panel project-menu-panel`,role:`menu`,"aria-label":e,ref:l,onKeyDown:u,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,"aria-keyshortcuts":`R`,onClick:d(()=>n(`title`)),children:[`Rename…`,(0,Q.jsx)(`kbd`,{"aria-hidden":!0,children:`R`})]}),(0,Q.jsx)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,onClick:d(()=>n(`goal`)),children:HQ(t)}),(0,Q.jsx)(`div`,{role:`separator`,className:`menu-rule`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,"aria-keyshortcuts":`A`,onClick:d(r),children:[`Archive`,(0,Q.jsx)(`kbd`,{"aria-hidden":!0,children:`A`})]})]})]})}function e4({board:e,name:t,focus:n,onDone:r}){let[i,a]=(0,d.useState)(e.title),[o,s]=(0,d.useState)(e.goal??``),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null);return(0,Q.jsxs)(`form`,{className:`project-edit`,onSubmit:async n=>{if(n.preventDefault(),c)return;let a=VQ(e,{title:i,goal:o});if(!a)return r(null);if(`error`in a)f(a.error),n.currentTarget.querySelector(`input`)?.focus();else{l(!0);try{r(await zQ(e.id,t,a.patch))}catch(e){f(e.message),l(!1)}}},onKeyDown:e=>{e.key!==`Escape`||c||(e.preventDefault(),r(null))},children:[(0,Q.jsx)(`input`,{className:`project-edit-title`,value:i,onChange:e=>{a(e.target.value),f(null)},onFocus:e=>e.currentTarget.select(),"aria-label":`Board title`,"aria-invalid":!!u,maxLength:nc.boardTitle,readOnly:c,autoFocus:n===`title`}),(0,Q.jsx)(`input`,{className:`project-edit-goal`,value:o,onChange:e=>{s(e.target.value),f(null)},onFocus:e=>e.currentTarget.select(),placeholder:`Add a goal: what this work is for`,"aria-label":`Goal`,maxLength:nc.goal,readOnly:c,autoFocus:n===`goal`}),u&&(0,Q.jsx)(`p`,{className:`error project-edit-error`,role:`alert`,children:u}),(0,Q.jsxs)(`div`,{className:`project-edit-actions`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-small`,disabled:c,children:`Save`}),(0,Q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:c,onClick:()=>r(null),children:`Cancel`}),(0,Q.jsx)(`span`,{className:`project-edit-hint`,children:`Old links keep working.`})]})]})}function t4(e,t){let[n,r]=(0,d.useState)(()=>new Set),[i,a]=(0,d.useState)(null);(0,d.useEffect)(()=>{t&&r(e=>WQ(e,t.map(e=>e.id)))},[t]);let o=e=>r(t=>{let n=new Set(t);return n.delete(e),n}),s=(0,d.useCallback)(t=>{r(e=>new Set(e).add(t.id)),BQ(t.id,e,!0).then(e=>a({key:Date.now(),board:{id:e.id,title:e.title}}),e=>{o(t.id),a({key:Date.now(),note:`Couldn’t archive “${H(t.title,48)}”: ${e.message}`})})},[e]),c=i&&`board`in i?i.board:null,l=(0,d.useCallback)(()=>{c&&(a(null),o(c.id),BQ(c.id,e,!1).catch(e=>a({key:Date.now(),note:`Couldn’t bring “${H(c.title,48)}” back: ${e.message}`})))},[c,e]);return UX(!!c,l),{archive:s,held:n,toast:i&&(0,Q.jsx)(`div`,{className:`home-toast`,children:(0,Q.jsx)(WX,{text:`board`in i?`Archived “${H(i.board.title,48)}”. It’s under Archived.`:i.note,onUndo:`board`in i?l:void 0,onGone:()=>a(e=>e?.key===i.key?null:e)},i.key)})}}function n4(e){e?.contains(document.activeElement)&&(e.nextElementSibling??e.previousElementSibling)?.querySelector(`.project-link`)?.focus()}function r4({name:e}){let{boards:t,refresh:n}=U$(),[r,i]=(0,d.useState)(!1),{report:a,error:o}=P$(e),s=vS().home(),[c,l]=Yl(`tricot:show-archived`,()=>!1),{archive:u,held:f,toast:p}=t4(e,a?.projects),[m,h]=(0,d.useState)(null);du(3e4);let g=t?.filter(e=>e.archived)??[],_=a?.projects.filter(e=>!f.has(e.id))??[],v=e=>({focus:m===e,onFocus:h,onFocused:()=>h(null)}),y=$w(),b=fT(),x=t!==null&&!!s?.firstRun?.shows(t,r);return(0,Q.jsxs)(`div`,{className:`page`,children:[(0,Q.jsx)(a2,{home:!0,right:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(k2,{}),s?.controls({report:a,name:e}),(0,Q.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0})]})}),(0,Q.jsxs)(`main`,{className:x?`home is-first-run`:`home`,children:[(0,Q.jsx)(e2,{}),t===null||a===null?o?(0,Q.jsxs)(`p`,{className:`error`,role:`alert`,children:[`Couldn't load your projects: `,o]}):(0,Q.jsx)(`p`,{className:`home-loading`,role:`status`,children:`Loading your projects…`}):x?s?.firstRun?.render({name:e,agents:a.agents,onSending:i,onEveryWay:o4}):(0,Q.jsxs)(Q.Fragment,{children:[s?.headline?s.headline({report:a,name:e}):(0,Q.jsx)(i4,{}),s?.needs({report:a,name:e}),(0,Q.jsxs)(`section`,{className:`projects`,"aria-labelledby":`projects-title`,children:[(0,Q.jsxs)(`div`,{className:`projects-head`,children:[(0,Q.jsx)(`h2`,{id:`projects-title`,children:`Projects`}),(0,Q.jsxs)(`span`,{className:`projects-count`,children:[_.length,` active`]}),(0,Q.jsx)(s4,{name:e})]}),_.length===0?(0,Q.jsx)(`p`,{className:`sheet projects-none`,children:`No projects in use. Create one, or unarchive one to pick it up again.`}):(0,Q.jsx)(Qw,{value:y,children:(0,Q.jsx)(`ul`,{className:`sheet projects-list`,children:_.map(t=>(0,Q.jsx)(c4,{project:t,name:e,onArchive:u,...v(t.id)},t.id))})})]})]}),(0,Q.jsxs)(`footer`,{className:`home-foot`,children:[(0,Q.jsxs)(`div`,{className:`home-foot-group`,children:[(0,Q.jsx)(`span`,{className:`home-foot-label`,children:`Agents`}),a?.agents.map(e=>(0,Q.jsxs)(`span`,{className:`home-agent is-${e.state}`,title:h4(e,b,m4(e,b(e))),children:[(0,Q.jsx)(p4,{name:e.name}),e.name,` `,m4(e,b(e))]},e.name)),a&&a.agents.length===0&&(0,Q.jsx)(`span`,{className:`home-foot-none`,children:`No agent connected`}),(0,Q.jsxs)(ox,{className:`home-connect`,children:[(0,Q.jsx)(`summary`,{className:`home-link`,children:a?.agents.length?`Connect another`:`Connect an agent`}),(0,Q.jsx)(`div`,{className:`popover-body`,children:(0,Q.jsx)(Ew,{})})]})]}),(0,Q.jsxs)(`div`,{className:`home-foot-group`,children:[(0,Q.jsx)(`span`,{className:`home-foot-label`,children:`Connectors`}),(0,Q.jsx)(Q2,{})]}),g.length>0&&(0,Q.jsxs)(`button`,{className:`home-link home-archived-toggle`,"aria-expanded":c,onClick:()=>l(!c),children:[`Archived (`,g.length,`)`]}),(0,Q.jsx)(a4,{})]}),c&&g.length>0&&(0,Q.jsx)(`ul`,{className:`sheet projects-list projects-archived`,"aria-label":`Archived projects`,children:g.map(t=>(0,Q.jsx)(l4,{board:t,name:e,onDeleted:n,...v(t.id)},t.id))}),p]})]})}function i4(){let e=bt(Fx());return(0,Q.jsxs)(`section`,{className:`home-head`,children:[(0,Q.jsx)(`h1`,{children:`Your projects`}),e&&(0,Q.jsx)(`p`,{className:`home-sub`,children:e})]})}function a4(){let[e,t]=(0,d.useState)();return(0,d.useEffect)(()=>{let e=!0;return X.info().then(n=>e&&t(n),()=>{}),()=>{e=!1}},[]),!e?.version&&!e?.source?null:(0,Q.jsxs)(`div`,{className:`home-foot-group home-foot-about`,children:[e.version&&(0,Q.jsxs)(`span`,{children:[`Tricot `,e.version]}),e.source&&(0,Q.jsx)(`a`,{className:`home-link`,href:e.source,target:`_blank`,rel:`noreferrer`,children:`Source`})]})}function o4(){let e=document.querySelector(`details.home-connect`);e&&(e.open=!0,e.querySelector(`summary`)?.focus())}function s4({name:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(null),[s]=(0,d.useState)(()=>ES(uS.newBoard));return(0,d.useEffect)(()=>{s&&DS(uS.newBoard)},[s]),(0,Q.jsxs)(`form`,{className:`new-project`,onSubmit:async n=>{if(n.preventDefault(),t.trim()&&!r){i(!0);try{let n=await X.createBoard(e,t.trim(),``);CS.board(n.id)}catch(e){o(e.message),i(!1)}}},children:[(0,Q.jsx)(`input`,{value:t,onChange:e=>{n(e.target.value),o(null)},placeholder:`New project title`,"aria-label":`New project title`,maxLength:200,autoFocus:s}),(0,Q.jsxs)(`button`,{className:`btn btn-primary`,disabled:!t.trim()||r,children:[(0,Q.jsx)($,{name:`plus`}),`Create`]}),a&&(0,Q.jsx)(`p`,{className:`error new-project-error`,role:`alert`,children:a})]})}function c4({project:e,name:t,onArchive:n,focus:r,onFocus:i,onFocused:a}){let o=vS().home(),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=(0,d.useRef)(null);(0,d.useEffect)(()=>u(null),[e.title,e.goal]),pu(f,r,`.project-menu-button`,a);let{title:p,goal:m}=l??e;return(0,Q.jsxs)(`li`,{className:`project${o?.projectWork?``:` is-plain`}${s?` is-editing`:``}`,ref:f,children:[(0,Q.jsx)(`div`,{className:`project-name`,children:s?(0,Q.jsx)(e4,{board:{id:e.id,title:p,goal:m},name:t,focus:s,onDone:t=>{t&&u({title:t.title,goal:t.goal}),c(null),i(t?.id??e.id)}}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h3`,{className:`project-title`,children:[(0,Q.jsx)(`a`,{className:`project-link`,href:dS.board(e.id),children:p}),o?.projectTag?.({project:e})]}),m&&(0,Q.jsx)(`p`,{className:`project-goal`,title:m,children:m})]})}),o?.projectWork&&(0,Q.jsx)(`div`,{className:`project-work`,children:o.projectWork({project:e})}),(0,Q.jsx)(u4,{project:e}),(0,Q.jsx)(`time`,{className:`project-when`,dateTime:e.updatedAt,title:`Last change ${new Date(e.updatedAt).toLocaleString()}`,children:ex(e.updatedAt)}),s?(0,Q.jsx)(`span`,{"aria-hidden":!0}):(0,Q.jsx)($2,{title:p,hasGoal:!!m,onEdit:c,onArchive:()=>{n4(f.current),n({...e,title:p})}})]})}function l4({board:e,name:t,onDeleted:n,focus:r,onFocus:i,onFocused:a}){let[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),_=(0,d.useRef)(null);(0,d.useEffect)(()=>f(null),[e.title,e.goal]),pu(_,r,`.project-rename`,a);let{title:v,goal:y}=u??e;return(0,Q.jsxs)(`li`,{className:`project is-archived${c?` is-editing`:``}`,ref:_,children:[(0,Q.jsxs)(`div`,{className:`project-name`,children:[c?(0,Q.jsx)(e4,{board:{id:e.id,title:v,goal:y},name:t,focus:`title`,onDone:t=>{t&&f({title:t.title,goal:t.goal}),l(!1),i(t?.id??e.id)}}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h3`,{className:`project-title`,children:(0,Q.jsx)(`a`,{className:`project-link`,href:dS.board(e.id),children:v})}),y&&(0,Q.jsx)(`p`,{className:`project-goal`,children:y})]}),h&&(0,Q.jsx)(`p`,{className:`error project-row-error`,role:`alert`,children:h})]}),(0,Q.jsxs)(`div`,{className:`project-archived-side`,children:[(0,Q.jsxs)(`time`,{className:`project-when`,dateTime:e.updatedAt,children:[`archived `,ex(e.updatedAt)]}),!c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`btn btn-small`,disabled:p,onClick:()=>{m(!0),g(null),BQ(e.id,t,!1).then(()=>n4(_.current),e=>{g(e.message),m(!1)})},"aria-label":`Restore ${v}`,children:`Restore`}),(0,Q.jsx)(`button`,{className:`btn btn-small project-rename`,disabled:p,onClick:()=>l(!0),"aria-label":`Rename ${v}`,children:`Rename…`}),(0,Q.jsx)(`button`,{className:`btn btn-small btn-delete`,disabled:p,onClick:()=>s(!0),"aria-label":`Delete ${v}`,children:`Delete…`})]})]}),o&&(0,Q.jsx)(a0,{board:{...e,title:v},name:t,onClose:()=>s(!1),onDeleted:()=>{s(!1),n()}})]})}function u4({project:e}){let t=dT(e),n=d4(e),r=tT(rT(e.id),Date.now()),i=fT(),a=t&&`now`in t?t.others:0;if(n){let t=e=>`${qw(e)}${i(e)&&!e.narration?` on ${i(e)}`:``}`,o=e.agents.map(e=>{let n=r.get(e.name.toLowerCase());return n?`${e.name}: ${t(n)}`:h4(e,i)});return e.agents.some(e=>U(e.name,n.step.agent))||o.unshift(`${n.step.agent}: ${t(n.step)}`),(0,Q.jsxs)(f4,{className:`project-agent is-working has-step${n.phase===`dim`?` is-dim`:``}`,title:o.join(`
102
+ `),name:n.step.agent,busy:Kw(n.phase),after:a>0&&(0,Q.jsxs)(`span`,{className:`project-agent-more`,children:[`+`,a]}),children:[(0,Q.jsxs)(`span`,{className:`step-sr`,children:[n.step.agent,`: `]}),(0,Q.jsx)(Jw,{text:t(n.step),className:`project-agent-step`},n.step.at)]})}if(t&&`now`in t)return(0,Q.jsxs)(f4,{className:`project-agent is-${t.now.state}`,title:e.agents.map(e=>h4(e,i)).join(`
103
+ `),name:t.now.name,busy:t.now.state===`working`?`casting`:`resting`,children:[t.now.name,` `,pT(t.now,i(t.now)),a>0&&(0,Q.jsxs)(`span`,{className:`project-agent-more`,children:[` +`,a]})]});if(!t)return(0,Q.jsx)(`span`,{className:`project-agent is-none`,children:`No agent connected`});let{last:o}=t;return(0,Q.jsxs)(`span`,{className:`project-agent`,title:`${o.name} last worked on it ${new Date(o.at).toLocaleString()}`,children:[(0,Q.jsx)(p4,{name:o.name}),(0,Q.jsxs)(`span`,{className:`project-agent-text`,children:[o.name,`, `,tx(o.at)]})]})}function d4(e){let t=rT(e.id),n=nT(e.agents.map(e=>e.name),t,Date.now()),r=Yw(n),i=n&&Rw(n,r);return n&&i?{step:n,phase:i}:void 0}function f4({className:e,title:t,name:n,busy:r,after:i,children:a}){return(0,Q.jsxs)(`span`,{className:e,title:t,children:[(0,Q.jsx)(p4,{name:n}),(0,Q.jsx)(`span`,{className:`project-agent-text`,children:a}),(0,Q.jsx)(sT,{state:r}),i]})}function p4({name:e}){return(0,Q.jsx)(`span`,{className:`actor actor-agent`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`actor-mark`,children:e.charAt(0).toUpperCase()})})}function m4(e,t){return!e.board&&e.state===`working`?`connected`:pT(e,t)}function h4(e,t,n=pT(e,t(e))){let r=t(e),i=r&&e.onTitle?` (${r} ${e.onTitle})`:``;return`${e.name} ${n}${i}, last checked ${ex(e.lastSeen)}`}function g4({name:e}){let t=xS();return Ix(t.page!==`board`&&t.page!==`home`),t.page===`board`?(0,Q.jsx)(M2,{route:t,name:e}):t.page===`connectors`?(0,Q.jsx)(q2,{from:t.from}):(0,Q.jsx)(r4,{name:e})}function _4(){let e=H2(new mS);return e.withHeaderControls(e=>(0,Q.jsx)(DQ,{...e})),e}function v4(){let[e]=(0,d.useState)(()=>new ux),[t]=(0,d.useState)(_4);return(0,Q.jsx)(px,{kinds:e,children:(0,Q.jsx)(_S,{views:t,children:(0,Q.jsx)(d0,{children:e=>(0,Q.jsx)(g4,{name:e})})})})}(0,f.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(d.StrictMode,{children:(0,Q.jsx)(v4,{})}));export{oA as a,zk as c,ek as d,Fa as f,iA as i,gk as l,yA as n,vk as o,Ia as p,fA as r,Vk as s,GU as t,_k as u};