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.
- package/README.md +2 -2
- package/dist/canvas/assets/{abnfDiagram-WEYOIA3C-CkvKK8YW.js → abnfDiagram-WEYOIA3C-D_3EtYyY.js} +1 -1
- package/dist/canvas/assets/{architecture-WOLXFQ4H-DkTZhXsX.js → architecture-WOLXFQ4H-CNOO52kd.js} +1 -1
- package/dist/canvas/assets/{architectureDiagram-ZHVYKT53-D03vtDRz.js → architectureDiagram-ZHVYKT53-lBYqdNkj.js} +1 -1
- package/dist/canvas/assets/{blockDiagram-RJAE7QA3-ClhjJGi8.js → blockDiagram-RJAE7QA3-nyVHPSk9.js} +1 -1
- package/dist/canvas/assets/{c4Diagram-XDPPPE54-DtL6ydla.js → c4Diagram-XDPPPE54-cD9txCLb.js} +1 -1
- package/dist/canvas/assets/channel-I1sbw6a8.js +1 -0
- package/dist/canvas/assets/{chunk-2E7WHVMD-BjKI2q8S.js → chunk-2E7WHVMD-DSCYrP5D.js} +1 -1
- package/dist/canvas/assets/{chunk-55XCU76K-CvtY1-ZJ.js → chunk-55XCU76K-D4EXRr0U.js} +1 -1
- package/dist/canvas/assets/{chunk-7S6XSTFO-DDv33qEN.js → chunk-7S6XSTFO-CGWM3r9f.js} +1 -1
- package/dist/canvas/assets/{chunk-AQDTSKZB-DtlvoldN.js → chunk-AQDTSKZB-BorQNuc7.js} +1 -1
- package/dist/canvas/assets/{chunk-DSNLSHJZ-BFvSD6Sg.js → chunk-DSNLSHJZ-DJHGHKVr.js} +1 -1
- package/dist/canvas/assets/{chunk-HAGFOTED-nnwhNY8-.js → chunk-HAGFOTED-DrEGbLXf.js} +1 -1
- package/dist/canvas/assets/{chunk-HNE4Q36P-BnG_tdfU.js → chunk-HNE4Q36P-7U5SJLeY.js} +1 -1
- package/dist/canvas/assets/{chunk-NQOKRVIF-CCbkrWl0.js → chunk-NQOKRVIF-DTNZadno.js} +1 -1
- package/dist/canvas/assets/{chunk-UHW7PFBP-CA3tNzJ3.js → chunk-UHW7PFBP-CbE5Jzvg.js} +1 -1
- package/dist/canvas/assets/{chunk-VQ5W62QI-DjaHlbpW.js → chunk-VQ5W62QI-K3Kh3v_p.js} +1 -1
- package/dist/canvas/assets/{chunk-WQQL4CDK-D0hvZxqh.js → chunk-WQQL4CDK-COzd17uX.js} +1 -1
- package/dist/canvas/assets/chunk-XXDRQBXY-CaMdJWQP.js +1 -0
- package/dist/canvas/assets/{chunk-YZO67HFG-DHeiZehr.js → chunk-YZO67HFG-BxV8PpHv.js} +1 -1
- package/dist/canvas/assets/{chunk-ZAUX2LTX-AuFSGuK2.js → chunk-ZAUX2LTX-N0CHdlVz.js} +1 -1
- package/dist/canvas/assets/{chunk-ZCHMQSOR-Cl58-GNR.js → chunk-ZCHMQSOR-zeafUjpn.js} +1 -1
- package/dist/canvas/assets/{classDiagram-v2-4MYWR3UA-DZtVdg28.js → classDiagram-v2-4MYWR3UA-Hvvc0Z5z.js} +1 -1
- package/dist/canvas/assets/{cose-bilkent-JH36ORCC-DRZodgHH.js → cose-bilkent-JH36ORCC-BHH57wZb.js} +1 -1
- package/dist/canvas/assets/cynefin-EF2NZ3EQ-BLZeevha.js +1 -0
- package/dist/canvas/assets/{cynefinDiagram-WF24UDRP-tSV7rZTE.js → cynefinDiagram-WF24UDRP-DcBq_eWM.js} +1 -1
- package/dist/canvas/assets/{dagre-NK4GIZVX-BoUs8R6c.js → dagre-NK4GIZVX-Cijvcguq.js} +1 -1
- package/dist/canvas/assets/{diagram-CBK3MWTC-CShLnQiV.js → diagram-CBK3MWTC-B2A6XrPd.js} +1 -1
- package/dist/canvas/assets/{diagram-I5XIIV2D-BFFrtOXg.js → diagram-I5XIIV2D-bZURkpE7.js} +1 -1
- package/dist/canvas/assets/{diagram-ODIL2UCW-ChXvBoFb.js → diagram-ODIL2UCW-IP547iQ6.js} +1 -1
- package/dist/canvas/assets/{diagram-PFBEJUXE-Cz5EOU5J.js → diagram-PFBEJUXE-aS8DG6-4.js} +1 -1
- package/dist/canvas/assets/{diagram-RJA3I4VV-yvxfMgx3.js → diagram-RJA3I4VV-zY5MuDSR.js} +1 -1
- package/dist/canvas/assets/{diagram-TYUNFSNR-B6LIObJY.js → diagram-TYUNFSNR-B3nerWk2.js} +1 -1
- package/dist/canvas/assets/{ebnfDiagram-V4P3TTPT-BTkb18PM.js → ebnfDiagram-V4P3TTPT-DgRadxbh.js} +1 -1
- package/dist/canvas/assets/{erDiagram-KYQIGQAA-BIblBx4Z.js → erDiagram-KYQIGQAA-dvWUXrD4.js} +1 -1
- package/dist/canvas/assets/{eventmodeling-K75KTNOO-CvVJseOX.js → eventmodeling-K75KTNOO-jzFwuc9b.js} +1 -1
- package/dist/canvas/assets/flowDiagram-IUGLLWBU-Vs84qJLC.js +1 -0
- package/dist/canvas/assets/{ganttDiagram-R7GPNTJY-CfYCIMyT.js → ganttDiagram-R7GPNTJY-DP6wLffx.js} +1 -1
- package/dist/canvas/assets/gitGraph-VSP46ZUC-FvxVMqH9.js +1 -0
- package/dist/canvas/assets/{gitGraphDiagram-PDYL7XHY-D7ctyGM3.js → gitGraphDiagram-PDYL7XHY-BPBKv4UK.js} +1 -1
- package/dist/canvas/assets/index-MgC2fGp9.js +103 -0
- package/dist/canvas/assets/index-bltLAfdr.css +1 -0
- package/dist/canvas/assets/info-OHQRW6UA-CnTN2dPe.js +1 -0
- package/dist/canvas/assets/{infoDiagram-MVDRKAX5-nVR1Wuq1.js → infoDiagram-MVDRKAX5-CY5YF8CW.js} +1 -1
- package/dist/canvas/assets/{ishikawaDiagram-HPEHV2GE-CZ6cEozT.js → ishikawaDiagram-HPEHV2GE-BJJjIJn5.js} +1 -1
- package/dist/canvas/assets/{journeyDiagram-BOSHW7O7-D0ChNzur.js → journeyDiagram-BOSHW7O7-SsXzs88l.js} +1 -1
- package/dist/canvas/assets/{kanban-definition-FNSA4HC5-BQX5oSRG.js → kanban-definition-FNSA4HC5-cdeRNo2o.js} +1 -1
- package/dist/canvas/assets/{line-BpdAl23-.js → line-BR2n8Nk4.js} +1 -1
- package/dist/canvas/assets/{linear-DPDFY6tx.js → linear-fljUQPXC.js} +1 -1
- package/dist/canvas/assets/{mermaid-parser.core--Y0hpmIt.js → mermaid-parser.core-CyflrFl5.js} +3 -3
- package/dist/canvas/assets/{mermaid.core-CsGeJ437.js → mermaid.core-DBd9VEEZ.js} +4 -4
- package/dist/canvas/assets/{mindmap-definition-6OY57UG3-BkBpxEG9.js → mindmap-definition-6OY57UG3-D2cu_ZTc.js} +1 -1
- package/dist/canvas/assets/packet-JDAUHWVQ-yaYO4cp5.js +1 -0
- package/dist/canvas/assets/{pegDiagram-ECIUJNBX-DuMILqC7.js → pegDiagram-ECIUJNBX-BcjXQQD6.js} +1 -1
- package/dist/canvas/assets/pie-XZMESJXO-cztCBI0v.js +1 -0
- package/dist/canvas/assets/{pieDiagram-GNMPY74T-DlXwdptO.js → pieDiagram-GNMPY74T-CrqNQajy.js} +1 -1
- package/dist/canvas/assets/{quadrantDiagram-D57K4MC3-Cm0ItFD1.js → quadrantDiagram-D57K4MC3-AXTAhi9U.js} +1 -1
- package/dist/canvas/assets/radar-ABXABTNO-CbHQvfsD.js +1 -0
- package/dist/canvas/assets/railroad-I3PHUGI6-B0oHQTAZ.js +1 -0
- package/dist/canvas/assets/{railroad-abnf-LNEFI6M7-c41jTPZO.js → railroad-abnf-LNEFI6M7-BBGt3_q2.js} +1 -1
- package/dist/canvas/assets/{railroad-ebnf-DWYD2UWJ-DQP1QDSQ.js → railroad-ebnf-DWYD2UWJ-ixu4lUxo.js} +1 -1
- package/dist/canvas/assets/{railroad-peg-JR7BVNR7-C1IBSHmp.js → railroad-peg-JR7BVNR7-CIX3eq1Z.js} +1 -1
- package/dist/canvas/assets/{railroadDiagram-Y72NRBL7-B9uAMQDK.js → railroadDiagram-Y72NRBL7-DeCWgQz5.js} +1 -1
- package/dist/canvas/assets/{requirementDiagram-EQYSW5RA-CMHcUPPI.js → requirementDiagram-EQYSW5RA-C4gXUvln.js} +1 -1
- package/dist/canvas/assets/{sankeyDiagram-SY24JHO5-DufhzgOJ.js → sankeyDiagram-SY24JHO5-CbMzM3uf.js} +1 -1
- package/dist/canvas/assets/{sequenceDiagram-BLEHNHQU-MSVqrEvn.js → sequenceDiagram-BLEHNHQU-CzijdEGb.js} +1 -1
- package/dist/canvas/assets/{src-C3R7ySEG.js → src-B5Y2JrIY.js} +1 -1
- package/dist/canvas/assets/{stateDiagram-v2-A6IESKWZ-BDSMSpBW.js → stateDiagram-v2-A6IESKWZ-CfwZBSP7.js} +1 -1
- package/dist/canvas/assets/{swimlanes-B3ENRKFQ-AFjoAwpd.js → swimlanes-B3ENRKFQ-BSsYg9m-.js} +1 -1
- package/dist/canvas/assets/swimlanesDiagram-AYQRV4AK-DUXorK0t.js +8 -0
- package/dist/canvas/assets/{timeline-definition-JXYKGLGB-CfA9MTDy.js → timeline-definition-JXYKGLGB-DW4DRHsM.js} +1 -1
- package/dist/canvas/assets/treeView-D4JQ5SDB-C3JqYPrF.js +1 -0
- package/dist/canvas/assets/treemap-SAJKECNS-C-h8cYwi.js +1 -0
- package/dist/canvas/assets/{usecaseDiagram-WPOLBNNX-Cc6WisEf.js → usecaseDiagram-WPOLBNNX-DRrQYFd8.js} +1 -1
- package/dist/canvas/assets/{vennDiagram-Q3Y3IDCW-D3WngNEg.js → vennDiagram-Q3Y3IDCW-DlRzTf21.js} +1 -1
- package/dist/canvas/assets/{viewer-BaxYd8Fo.js → viewer-DfqWyEfI.js} +1 -1
- package/dist/canvas/assets/wardley-7MLQ67FV-Cy1YJVOj.js +1 -0
- package/dist/canvas/assets/{wardleyDiagram-IVAIDKWA-DKWBZz5i.js → wardleyDiagram-IVAIDKWA-B6ONQrQu.js} +1 -1
- package/dist/canvas/assets/{xychartDiagram-4URNHDU4-BhnzRhXc.js → xychartDiagram-4URNHDU4-kz3gj_5i.js} +1 -1
- package/dist/canvas/index.html +2 -2
- package/dist/cli/command.js +304 -300
- package/hooks/tricot-approve.mjs +53 -11
- package/package.json +2 -2
- package/dist/canvas/assets/channel-DRLcYYiR.js +0 -1
- package/dist/canvas/assets/chunk-XXDRQBXY-Bg2ExrhT.js +0 -1
- package/dist/canvas/assets/cynefin-EF2NZ3EQ-Clnz5u6l.js +0 -1
- package/dist/canvas/assets/flowDiagram-IUGLLWBU-DVpB4d93.js +0 -1
- package/dist/canvas/assets/gitGraph-VSP46ZUC-Cit8ODu4.js +0 -1
- package/dist/canvas/assets/index-354nVOc5.js +0 -105
- package/dist/canvas/assets/index-hW9r01Xp.css +0 -1
- package/dist/canvas/assets/info-OHQRW6UA-PyEgngMG.js +0 -1
- package/dist/canvas/assets/packet-JDAUHWVQ-Bz3vh45c.js +0 -1
- package/dist/canvas/assets/pie-XZMESJXO-f2NWqr47.js +0 -1
- package/dist/canvas/assets/radar-ABXABTNO-D4fqD9aS.js +0 -1
- package/dist/canvas/assets/railroad-I3PHUGI6-DDKXQRXI.js +0 -1
- package/dist/canvas/assets/swimlanesDiagram-AYQRV4AK-CYKKFazU.js +0 -8
- package/dist/canvas/assets/treeView-D4JQ5SDB-7QR5QkG0.js +0 -1
- package/dist/canvas/assets/treemap-SAJKECNS-C9vPlOOC.js +0 -1
- package/dist/canvas/assets/wardley-7MLQ67FV-djPzhq5M.js +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CsGeJ437.js","assets/chunk-DSNLSHJZ-BFvSD6Sg.js","assets/src-C3R7ySEG.js","assets/rolldown-runtime-XKyaHtl9.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-HNE4Q36P-BnG_tdfU.js","assets/chunk-ZAUX2LTX-AuFSGuK2.js","assets/chunk-HAGFOTED-nnwhNY8-.js","assets/chunk-UHW7PFBP-CA3tNzJ3.js","assets/chunk-AQDTSKZB-DtlvoldN.js","assets/chunk-YZO67HFG-DHeiZehr.js","assets/chunk-7S6XSTFO-DDv33qEN.js","assets/dist-Dce-2YbA.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-WQQL4CDK-D0hvZxqh.js","assets/line-BpdAl23-.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`),H=Symbol.for(`react.view_transition`),ne=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?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 H: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?oe(e.type)||`Memo`:t;case B:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=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,ce={pending:!1,data:null,method:null,action:null},le=[],ue=-1;function de(e){return{current:e}}function fe(e){0>ue||(e.current=le[ue],le[ue]=null,ue--)}function pe(e,t){ue++,le[ue]=e.current,e.current=t}var me=de(null),he=de(null),ge=de(null),_e=de(null);function ve(e,t){switch(pe(ge,t),pe(he,e),pe(me,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}}fe(me),pe(me,e)}function ye(){fe(me),fe(he),fe(ge)}function be(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,pe(_e,e)),t=me.current;var n=pp(t,e.type);t!==n&&(pe(he,e),pe(me,n))}function G(e){he.current===e&&(fe(me),fe(he)),_e.current===e&&(fe(_e),lh._currentValue=ce)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1<e.stack.indexOf(`
|
|
3
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
-
`+xe+e+Se}var we=!1;function Te(e,t){if(!e||we)return``;we=!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{we=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ce(n):``}function Ee(e,t){switch(e.tag){case 26:case 27:case 5:return Ce(e.type);case 16:return Ce(`Lazy`);case 13:return e.child!==t&&t!==null?Ce(`Suspense Fallback`):Ce(`Suspense`);case 19:return Ce(`SuspenseList`);case 0:case 15:return Te(e.type,!1);case 11:return Te(e.type.render,!1);case 1:return Te(e.type,!0);case 31:return Ce(`Activity`);case 30:return Ce(`ViewTransition`);default:return``}}function De(e){try{var t=``,n=null;do t+=Ee(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
-
Error generating stack: `+e.message+`
|
|
9
|
-
`+e.stack}}var Oe=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ae=t.unstable_cancelCallback,je=t.unstable_shouldYield,Me=t.unstable_requestPaint,Ne=t.unstable_now,Pe=t.unstable_getCurrentPriorityLevel,Fe=t.unstable_ImmediatePriority,Ie=t.unstable_UserBlockingPriority,Le=t.unstable_NormalPriority,Re=t.unstable_LowPriority,ze=t.unstable_IdlePriority,Be=t.log,Ve=t.unstable_setDisableYieldValue,He=null,Ue=null;function We(e){if(typeof Be==`function`&&Ve(e),Ue&&typeof Ue.setStrictMode==`function`)try{Ue.setStrictMode(He,e)}catch{}}var Ge=Math.clz32?Math.clz32:Je,Ke=Math.log,qe=Math.LN2;function Je(e){return e>>>=0,e===0?32:31-(Ke(e)/qe|0)|0}var Ye=256,Xe=262144,Ze=4194304;function Qe(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 $e(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=Qe(n))):i=Qe(o):i=Qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Qe(n))):i=Qe(o)):i=Qe(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 et(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tt(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-Ge(n),i=1<<r;t|=e[r],n&=~i}return t}function nt(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 rt(){var e=Ze;return Ze<<=1,!(Ze&62914560)&&(Ze=4194304),e}function it(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function at(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ot(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-Ge(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&&st(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function st(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ge(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ct(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ge(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function lt(e,t){var n=t&-t;return n=n&42?1:ut(n),(n&(e.suspendedLanes|t))===0?n:0}function ut(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 dt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ft(){var e=W.p;return e===0?(e=window.event,e===void 0?32:Th(e.type)):e}function pt(e,t){var n=W.p;try{return W.p=e,t()}finally{W.p=n}}var mt=Math.random().toString(36).slice(2),ht=`__reactFiber$`+mt,gt=`__reactProps$`+mt,_t=`__reactContainer$`+mt,vt=`__reactEvents$`+mt,yt=`__reactListeners$`+mt,bt=`__reactHandles$`+mt,xt=`__reactResources$`+mt,St=`__reactMarker$`+mt,Ct=`__reactLoad$`+mt;function wt(e){delete e[ht],delete e[gt],delete e[yt],delete e[bt]}function Tt(e){var t;if(t=e[ht])return t;for(var n=e.parentNode;n;){if(t=n[_t]||n[ht]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[ht])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function Et(e){if(e=e[ht]||e[_t]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Dt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(a(33))}function Ot(e){var t=e[xt];return t||=e[xt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function kt(e){e[St]=!0}function At(e){e[Ct]=void 0}var jt=new Set,Mt={};function Nt(e,t){Pt(e,t),Pt(e+`Capture`,t)}function Pt(e,t){for(Mt[e]=t,e=0;e<t.length;e++)jt.add(t[e])}var Ft=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]*$`),It={},K={};function Lt(e){return Oe.call(K,e)?!0:Oe.call(It,e)?!1:Ft.test(e)?K[e]=!0:(It[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(se(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=Et(e);if(t&&(e=t.stateNode)){var n=e[gt]||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[gt]||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[gt]||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(Dt(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(!Oe.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 qr(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 Jr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Yr={animationend:Jr(`Animation`,`AnimationEnd`),animationiteration:Jr(`Animation`,`AnimationIteration`),animationstart:Jr(`Animation`,`AnimationStart`),transitionrun:Jr(`Transition`,`TransitionRun`),transitionstart:Jr(`Transition`,`TransitionStart`),transitioncancel:Jr(`Transition`,`TransitionCancel`),transitionend:Jr(`Transition`,`TransitionEnd`)},Xr={},Zr={};bn&&(Zr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Yr.animationend.animation,delete Yr.animationiteration.animation,delete Yr.animationstart.animation),`TransitionEvent`in window||delete Yr.transitionend.transition);function Qr(e){if(Xr[e])return Xr[e];if(!Yr[e])return e;var t=Yr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Zr)return Xr[e]=t[n];return e}var $r=Qr(`animationend`),ei=Qr(`animationiteration`),ti=Qr(`animationstart`),ni=Qr(`transitionrun`),ri=Qr(`transitionstart`),ii=Qr(`transitioncancel`),ai=Qr(`transitionend`),oi=new Map,si=`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(` `);si.push(`scrollEnd`);function ci(e,t){oi.set(e,t),Nt(t,[e])}var li=0;function ui(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=yd.identifierPrefix;var n=li++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function di(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 fi(e,t){return e=di(e),t=di(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var pi=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)},mi=[],hi=0,gi=0;function _i(){for(var e=hi,t=gi=hi=0;t<e;){var n=mi[t];mi[t++]=null;var r=mi[t];mi[t++]=null;var i=mi[t];mi[t++]=null;var a=mi[t];if(mi[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&&xi(n,i,a)}}function vi(e,t,n,r){mi[hi++]=e,mi[hi++]=t,mi[hi++]=n,mi[hi++]=r,gi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function yi(e,t,n,r){return vi(e,t,n,r),Si(e)}function bi(e,t){return vi(e,null,null,t),Si(e)}function xi(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-Ge(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Si(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 Ci={};function wi(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 Ti(e,t,n,r){return new wi(e,t,n,r)}function Ei(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Di(e,t){var n=e.alternate;return n===null?(n=Ti(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 Oi(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 ki(e,t,n,r,i,o){var s=0;if(r=e,typeof r==`function`)Ei(r)&&(s=1);else if(typeof r==`string`)s=Ym(e,n,me.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ee:return e=Ti(31,n,t,i),e.elementType=ee,e.lanes=o,e;case j:return Ai(n.children,i,o,t);case M:s=8,i|=24;break;case N:return e=Ti(12,n,t,i|2),e.elementType=N,e.lanes=o,e;case L:return e=Ti(13,n,t,i),e.elementType=L,e.lanes=o,e;case R:return e=Ti(19,n,t,i),e.elementType=R,e.lanes=o,e;case V:case H:return e=i|32,e=Ti(30,n,t,e),e.elementType=H,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=Ti(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Ai(e,t,n,r){return e=Ti(7,e,r,t),e.lanes=n,e}function ji(e,t,n){return e=Ti(6,e,null,t),e.lanes=n,e}function Mi(e){var t=Ti(18,null,null,0);return t.stateNode=e,t}function Ni(e,t,n){return t=Ti(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Pi=new WeakMap;function Fi(e,t){if(typeof e==`object`&&e){var n=Pi.get(e);return n===void 0?(t={value:e,source:t,stack:De(t)},Pi.set(e,t),t):n}return{value:e,source:t,stack:De(t)}}var Ii=[],Li=0,Ri=null,zi=0,Bi=[],Vi=0,Hi=null,Ui=1,Wi=``;function Gi(e,t){Ii[Li++]=zi,Ii[Li++]=Ri,Ri=e,zi=t}function Ki(e,t,n){Bi[Vi++]=Ui,Bi[Vi++]=Wi,Bi[Vi++]=Hi,Hi=e;var r=Ui;e=Wi;var i=32-Ge(r)-1;r&=~(1<<i),n+=1;var a=32-Ge(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ui=1<<32-Ge(t)+i|n<<i|r,Wi=a+e}else Ui=1<<a|n<<i|r,Wi=e}function qi(e){e.return!==null&&(Gi(e,1),Ki(e,1,0))}function Ji(e){for(;e===Ri;)Ri=Ii[--Li],Ii[Li]=null,zi=Ii[--Li],Ii[Li]=null;for(;e===Hi;)Hi=Bi[--Vi],Bi[Vi]=null,Wi=Bi[--Vi],Bi[Vi]=null,Ui=Bi[--Vi],Bi[Vi]=null}function Yi(e,t){Bi[Vi++]=Ui,Bi[Vi++]=Wi,Bi[Vi++]=Hi,Ui=t.id,Wi=t.overflow,Hi=e}var Xi=null,Zi=null,Qi=!1,$i=null,ea=!1,ta=Error(a(519));function na(e){throw ca(Fi(Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ta}function ra(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ht]=e,t[gt]=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||na(e,!0)}function ia(e){for(Xi=e.return;Xi;)switch(Xi.tag){case 5:case 31:case 13:ea=!1;return;case 27:case 3:ea=!0;return;default:Xi=Xi.return}}function aa(e){if(e!==Xi)return!1;if(!Qi)return ia(e),Qi=!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&&Zi&&na(e),ia(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Zi=pm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Zi=pm(e)}else t===27?(t=Zi,wp(e.type)?(e=fm,fm=null,Zi=e):Zi=t):Zi=Xi?dm(e.stateNode.nextSibling):null;return!0}function oa(){Zi=Xi=null,Qi=!1}function sa(){var e=$i;return e!==null&&(dd===null?dd=e:dd.push.apply(dd,e),$i=null),e}function ca(e){$i===null?$i=[e]:$i.push(e)}var la=de(null),ua=null,da=null;function fa(e,t,n){pe(la,t._currentValue),t._currentValue=n}function pa(e){e._currentValue=la.current,fe(la)}function ma(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 ha(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),ma(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),ma(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),ma(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 ga(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===_e.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&&ha(t,e,n,r),t.flags|=262144,e!==null}function _a(e){for(e=e.firstContext;e!==null;){if(!Pr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function va(e){ua=e,da=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ya(e){return xa(ua,e)}function ba(e,t){return ua===null&&va(e),xa(e,t)}function xa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},da===null){if(e===null)throw Error(a(308));da=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else da=da.next=t;return n}var Sa=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()})}},Ca=t.unstable_scheduleCallback,wa=t.unstable_NormalPriority,Ta={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ea(){return{controller:new Sa,data:new Map,refCount:0}}function Da(e){e.refCount--,e.refCount===0&&Ca(wa,function(){e.controller.abort()})}function Oa(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 ka=null;function Aa(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var ja=null,Ma=0,Na=0,Pa=null;function Fa(e,t){if(ja===null){var n=ja=[];Ma=0,Na=Pf(),Pa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ma++,t.then(Ia,Ia),t}function Ia(){if(--Ma===0&&(ka=null,ja!==null)){Pa!==null&&(Pa.status=`fulfilled`);var e=ja;ja=null,Na=0,Pa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function La(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 Ra=U.S;U.S=function(e,t){if(md=Ne(),typeof t==`object`&&t&&typeof t.then==`function`&&Fa(e,t),ka!==null)for(var n=bf;n!==null;)Oa(n,ka),n=n.next;if(n=e.types,n!==null){for(var r=bf;r!==null;)Oa(r,n),r=r.next;if(Na!==0){r=ka,r===null&&(r=ka=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ra!==null&&Ra(e,t)};var za=de(null);function Ba(){var e=za.current;return e===null?Yu.pooledCache:e}function Va(e,t){t===null?pe(za,za.current):pe(za,t.pool)}function Ha(){var e=Ba();return e===null?null:{parent:Ta._currentValue,pool:e}}var Ua=Error(a(460)),Wa=Error(a(474)),Ga=Error(a(542)),Ka={then:function(){}};function qa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ja(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,Qa(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,Qa(e),e}throw Xa=t,Ua}}function Ya(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Xa=e,Ua):e}}var Xa=null;function Za(){if(Xa===null)throw Error(a(459));var e=Xa;return Xa=null,e}function Qa(e){if(e===Ua||e===Ga)throw Error(a(483))}var $a=null,eo=0;function to(e){var t=eo;return eo+=1,$a===null&&($a=[]),Ja($a,e,t)}function no(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ro(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 io(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=Di(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=ji(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),no(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===B&&Ya(a)===t.type)?(t=i(t,n.props),no(t,n),t.return=e,t):(t=ki(n.type,n.key,n.props,null,e.mode,r),no(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=Ni(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=Ai(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=ji(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=ki(t.type,t.key,t.props,null,e.mode,n),no(n,t),n.return=e,n;case A:return t=Ni(t,e.mode,n),t.return=e,t;case B:return t=Ya(t),f(e,t,n)}if(se(t)||ie(t))return t=Ai(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,to(t),n);if(t.$$typeof===F)return f(e,ba(e,t),n);ro(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=Ya(n),p(e,t,n,r)}if(se(n)||ie(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,to(n),r);if(n.$$typeof===F)return p(e,t,ba(e,n),r);ro(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=Ya(r),m(e,t,n,r,i)}if(se(r)||ie(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,to(r),i);if(r.$$typeof===F)return m(e,t,n,ba(t,r),i);ro(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),Qi&&Gi(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 Qi&&Gi(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)}),Qi&&Gi(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),Qi&&Gi(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 Qi&&Gi(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)}),Qi&&Gi(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),no(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===B&&Ya(l)===r.type){n(e,r.sibling),c=i(r,o.props),no(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=Ai(o.props.children,e.mode,c,o.key),no(c,o),c.return=e,e=c):(c=ki(o.type,o.key,o.props,null,e.mode,c),no(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=Ni(o,e.mode,c),c.return=e,e=c}return s(e);case B:return o=Ya(o),_(e,r,o,c)}if(se(o))return h(e,r,o,c);if(ie(o)){if(l=ie(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,to(o),c);if(o.$$typeof===F)return _(e,r,ba(e,o),c);ro(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=ji(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{eo=0;var i=_(e,t,n,r);return $a=null,i}catch(t){if(t===Ua||t===Ga)throw t;var a=Ti(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ao=io(!0),oo=io(!1),so=!1;function co(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lo(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 uo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function fo(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=Si(e),xi(e,null,n),t}return vi(e,r,t,n),Si(e)}function po(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,ct(e,n)}}function mo(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 ho=!1;function go(){if(ho){var e=Pa;if(e!==null)throw e}}function _o(e,t,n,r){ho=!1;var i=e.updateQueue;so=!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===Na&&(ho=!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:so=!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 vo(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function yo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)vo(n[e],t)}var bo=de(null),xo=de(0);function So(e,t){e=rd,pe(xo,e),pe(bo,t),rd=e|t.baseLanes}function Co(){pe(xo,rd),pe(bo,bo.current)}function wo(){rd=xo.current,fe(bo),fe(xo)}var To=de(null),Eo=null;function Do(e){var t=e.alternate;pe(Mo,Mo.current&1),pe(To,e),Eo===null&&(t===null||bo.current!==null||t.memoizedState!==null)&&(Eo=e)}function Oo(e){pe(Mo,Mo.current),pe(To,e),Eo===null&&(Eo=e)}function ko(e){e.tag===22?(pe(Mo,Mo.current),pe(To,e),Eo===null&&(Eo=e)):Ao()}function Ao(){pe(Mo,Mo.current),pe(To,To.current)}function jo(e){fe(To),Eo===e&&(Eo=null),fe(Mo)}var Mo=de(0);function No(e,t){pe(To,To.current),pe(Mo,t)}function Po(e){fe(Mo),fe(To),Eo===e&&(Eo=null)}function Fo(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 q=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 q=a,Io=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,U.H=e===null||e.memoizedState===null?lc:uc,Vo=!1,a=n(r,i),Vo=!1,Bo&&(a=Xo(t,n,r,i)),Yo(e),a}function Yo(e){U.H=cc;var t=Lo!==null&&Lo.next!==null;if(q=0,Ro=Lo=Io=null,zo=!1,Uo=0,Wo=null,t)throw Error(a(300));e===null||Dc||(e=e.dependencies,e!==null&&_a(e)&&(Dc=!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=dc,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}q=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=Ja(Wo,e,t),t=Io,(Ro===null?t.memoizedState:Ro.next)===null&&(t=t.alternate,U.H=t===null||t.memoizedState===null?lc:uc),e}function as(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return is(e);if(e.$$typeof===ne)return;if(e.$$typeof===F)return ya(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?(q&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===Na&&(d=!0);else if((q&p)===p){u=u.next,p===Na&&(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)&&(Dc=!0,d&&(n=Pa,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)||(Dc=!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=Qi;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,Dc=!0),i=i.queue,Ps(ms.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||s||Ro!==null&&!!(Ro.memoizedState.tag&1),ks(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||q&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=bi(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){We(!0);try{n()}finally{We(!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(ac(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),J(e,t,s)}catch(n){xs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),U.T=a}}else try{a=n(i,r),J(e,t,a)}catch(n){xs(e,t,n)}}function J(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Y(e,t,n)},function(n){return xs(e,t,n)}):Y(e,t,n)}function Y(e,t,n){t.status=`fulfilled`,t.value=n,Ss(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 xs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ss(t),t=t.next;while(t!==r)}e.action=null}function Ss(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Cs(e,t){return t}function ws(e,t){if(Qi){var n=Yu.formState;if(n!==null){a:{var r=Io;if(Qi){if(Zi){b:{for(var i=Zi,a=ea;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){Zi=dm(i.nextSibling),r=i.data===`F!`;break a}}na(r)}r=!1}r&&(t=n[0])}}return n=ts(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cs,lastRenderedState:t},n.queue=r,n=nc.bind(null,Io,r),r.dispatch=n,r=_s(!1),a=ic.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 Ts(e){return Es(ns(),Lo,e)}function Es(e,t,n){if(t=ls(e,t,Cs)[0],e=cs(ss)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=is(t)}catch(e){throw e===Ua?Ga:e}else r=t;t=ns();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Io.flags|=2048,ks(9,{destroy:void 0},Ds.bind(null,i,n),null)),[r,a,e]}function Ds(e,t){e.action=t}function Os(e){var t=ns(),n=Lo;if(n!==null)return Es(t,n,e);ns(),t=t.memoizedState,n=ns();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ks(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 As(){return ns().memoizedState}function js(e,t,n,r){var i=ts();Io.flags|=e,i.memoizedState=ks(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ms(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=ks(t,a,n,r):(Io.flags|=e,i.memoizedState=ks(1|t,a,n,r))}function Ns(e,t){js(8390656,8,e,t)}function Ps(e,t){Ms(2048,8,e,t)}function Fs(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 Is(e){var t=ns().memoizedState;return Fs({ref:t,nextImpl:e}),function(){if(Ju&2)throw Error(a(440));return t.impl.apply(void 0,arguments)}}function Ls(e,t){return Ms(4,2,e,t)}function Rs(e,t){return Ms(4,4,e,t)}function zs(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 Bs(e,t,n){n=n==null?null:n.concat([e]),Ms(4,4,zs.bind(null,t,e),n)}function Vs(){}function Hs(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 Us(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){We(!0);try{e()}finally{We(!1)}}return n.memoizedState=[r,t],r}function Ws(e,t,n){return n===void 0||q&1073741824&&!(Zu&261930)?e.memoizedState=t:(e.memoizedState=n,e=jd(),Io.lanes|=e,ad|=e,n)}function Gs(e,t,n,r){return Pr(n,t)?n:bo.current===null?!(q&106)||q&1073741824&&!(Zu&261930)?(Dc=!0,e.memoizedState=n):(e=jd(),Io.lanes|=e,ad|=e,t):(e=Ws(e,n,r),Pr(e,t)||(Dc=!0),e)}function Ks(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,ic(e,!1,t,n);try{var c=i(),l=U.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?rc(e,t,La(c,r),Ad(e)):rc(e,t,r,Ad(e))}catch(n){rc(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 qs(){}function Js(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=Ys(e).queue;Ks(e,i,t,ce,n===null?qs:function(){return Xs(e),n(r)})}function Ys(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:ce},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 Xs(e){var t=Ys(e);t.next===null&&(t=e.alternate.memoizedState),rc(e,t.next.queue,{},Ad())}function Zs(){return ya(lh)}function Qs(){return ns().memoizedState}function $s(){return ns().memoizedState}function ec(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ad();e=uo(n);var r=fo(t,e,n);r!==null&&(Nd(r,t,n),po(r,t,n)),t={cache:Ea()},e.payload=t;return}t=t.return}}function tc(e,t,n){var r=Ad();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ac(e)?oc(t,n):(n=yi(e,t,n,r),n!==null&&(Nd(n,e,r),sc(n,t,r)))}function nc(e,t,n){rc(e,t,n,Ad())}function rc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ac(e))oc(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 vi(e,t,i,0),Yu===null&&_i(),!1}catch{}if(n=yi(e,t,i,r),n!==null)return Nd(n,e,r),sc(n,t,r),!0}return!1}function ic(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ac(e)){if(t)throw Error(a(479))}else t=yi(e,n,r,2),t!==null&&Nd(t,e,2)}function ac(e){var t=e.alternate;return e===Io||t!==null&&t===Io}function oc(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 sc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}var cc={readContext:ya,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},lc={readContext:ya,use:as,useCallback:function(e,t){return ts().memoizedState=[e,t===void 0?null:t],e},useContext:ya,useEffect:Ns,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),js(4194308,4,zs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return js(4194308,4,e,t)},useInsertionEffect:function(e,t){js(4,2,e,t)},useMemo:function(e,t){var n=ts();t=t===void 0?null:t;var r=e();if(Vo){We(!0);try{e()}finally{We(!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){We(!0);try{n(t)}finally{We(!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=tc.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=nc.bind(null,Io,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Vs,useDeferredValue:function(e,t){return Ws(ts(),e,t)},useTransition:function(){var e=_s(!1);return e=Ks.bind(null,Io,e.queue,!0,!1),ts().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Io,i=ts();if(Qi){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,Ns(ms.bind(null,r,o,e),[e]),r.flags|=2048,ks(9,{destroy:void 0},ps.bind(null,r,o,n,t),null),n},useId:function(){var e=ts(),t=Yu.identifierPrefix;if(Qi){var n=Wi,r=Ui;n=(r&~(1<<32-Ge(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:Zs,useFormState:ws,useActionState:ws,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=ic.bind(null,Io,!0,n),n.dispatch=t,[e,t]},useMemoCache:os,useCacheRefresh:function(){return ts().memoizedState=ec.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)}}},uc={readContext:ya,use:as,useCallback:Hs,useContext:ya,useEffect:Ps,useImperativeHandle:Bs,useInsertionEffect:Ls,useLayoutEffect:Rs,useMemo:Us,useReducer:cs,useRef:As,useState:function(){return cs(ss)},useDebugValue:Vs,useDeferredValue:function(e,t){return Gs(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:Qs,useHostTransitionStatus:Zs,useFormState:Ts,useActionState:Ts,useOptimistic:function(e,t){return vs(ns(),Lo,e,t)},useMemoCache:os,useCacheRefresh:$s,useEffectEvent:Is},dc={readContext:ya,use:as,useCallback:Hs,useContext:ya,useEffect:Ps,useImperativeHandle:Bs,useInsertionEffect:Ls,useLayoutEffect:Rs,useMemo:Us,useReducer:us,useRef:As,useState:function(){return us(ss)},useDebugValue:Vs,useDeferredValue:function(e,t){var n=ns();return Lo===null?Ws(n,e,t):Gs(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:Qs,useHostTransitionStatus:Zs,useFormState:Os,useActionState:Os,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:$s,useEffectEvent:Is};function fc(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 pc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ad(),r=uo(n);r.tag=2,t!=null&&(r.callback=t),t=fo(e,r,n),t!==null&&(Nd(t,e,n),po(t,e,n))}};function mc(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 hc(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&&pc.enqueueReplaceState(t,t.state,null)}function gc(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 _c(e){pi(e)}function vc(e){console.error(e)}function yc(e){pi(e)}function bc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function xc(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 Sc(e,t,n){return n=uo(n),n.tag=3,n.payload={element:null},n.callback=function(){bc(e,t)},n}function Cc(e){return e=uo(e),e.tag=3,e}function wc(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(){xc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){xc(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 Tc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ga(t,n,i,!0),n=To.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Eo===null?Gd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===Ka?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===Ka?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(Qi)return t=To.current,t===null?(r!==ta&&(t=Error(a(423),{cause:r}),ca(Fi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Fi(r,n),i=Sc(e.stateNode,r,i),mo(e,i),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==ta&&(e=Error(a(422),{cause:r}),ca(Fi(e,n)))),!1;var o=Error(a(520),{cause:r});if(o=Fi(o,n),ud===null?ud=[o]:ud.push(o),id!==4&&(id=2),t===null)return!0;r=Fi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Sc(n.stateNode,r,e),mo(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=Cc(i),wc(i,e,n,r),mo(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Ec=Error(a(461)),Dc=!1;function X(e,t,n,r){t.child=e===null?oo(t,null,n,r):ao(t,e.child,n,r)}function Oc(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 va(t),r=Jo(e,t,n,o,a,i),s=Qo(),e!==null&&!Dc?($o(e,t,i),nl(e,t,i)):(Qi&&s&&qi(t),t.flags|=1,X(e,t,r,i),t.child)}function kc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ei(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Ac(e,t,a,r,i)):(e=ki(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!rl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Fr:n,n(o,r)&&e.ref===t.ref)return nl(e,t,i)}return t.flags|=1,e=Di(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Fr(a,r)&&e.ref===t.ref){if(Dc=!1,t.pendingProps=r=a,rl(e,i))e.flags&131072&&(Dc=!0);else return t.lanes=e.lanes,nl(e,t,i)}}return Rc(e,t,n,r,i)}function jc(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 Nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Va(t,a===null?null:a.cachePool),a===null?Co():So(t,a),ko(t);else return r=t.lanes=536870912,Nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Va(t,null),Co(),Ao()):(Va(t,a.cachePool),So(t,a),Ao(),t.memoizedState=null);return X(e,t,i,n),t.child}function Mc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Nc(e,t,n,r,i){var a=Ba();return a=a===null?null:{parent:Ta._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Va(t,null),Co(),ko(t),e!==null&&ga(e,t,r,!0),t.childLanes=i,null}function Pc(e,t){return t=qc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Fc(e,t,n){return ao(t,e.child,null,n),e=Pc(t,t.pendingProps),e.flags|=2,jo(t),t.memoizedState=null,e}function Ic(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if(Qi){if(r.mode===`hidden`)return e=Pc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Mc(null,e);if(Oo(t),(e=Zi)?(e=sm(e,ea),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Hi===null?null:{id:Ui,overflow:Wi},retryLane:536870912,hydrationErrors:null},n=Mi(e),n.return=t,t.child=n,Xi=t,Zi=null)):e=null,e===null)throw na(t);return t.lanes=536870912,null}return Pc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Oo(t),i){if(t.flags&256)t.flags&=-257,t=Fc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(a(558))}else if(Dc||ga(e,t,n,!1),i=(n&e.childLanes)!==0,Dc||i){if(bo.current===null){if(r=Yu,r!==null&&(s=lt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,bi(e,s),Nd(r,e,s),Ec;Gd()}t=Fc(e,t,n)}else e=o.treeContext,Zi=dm(s.nextSibling),Xi=t,Qi=!0,$i=null,ea=!1,e!==null&&Yi(t,e),t=Pc(t,r),t.flags|=134221824;return t}return e=Di(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Lc(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 Rc(e,t,n,r,i){return va(t),n=Jo(e,t,n,r,void 0,i),r=Qo(),e!==null&&!Dc?($o(e,t,i),nl(e,t,i)):(Qi&&r&&qi(t),t.flags|=1,X(e,t,n,i),t.child)}function zc(e,t,n,r,i,a){return va(t),t.updateQueue=null,n=Xo(t,r,n,i),Yo(e),r=Qo(),e!==null&&!Dc?($o(e,t,a),nl(e,t,a)):(Qi&&r&&qi(t),t.flags|=1,X(e,t,n,a),t.child)}function Bc(e,t,n,r,i){if(va(t),t.stateNode===null){var a=Ci,o=n.contextType;typeof o==`object`&&o&&(a=ya(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=pc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},co(t),o=n.contextType,a.context=typeof o==`object`&&o?ya(o):Ci,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(fc(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&&pc.enqueueReplaceState(a,a.state,null),_o(t,r,a,i),go(),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=gc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Ci,typeof u==`object`&&u&&(o=ya(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)&&hc(t,a,r,o),so=!1;var f=t.memoizedState;a.state=f,_o(t,r,a,i),go(),l=t.memoizedState,s||f!==l||so?(typeof d==`function`&&(fc(t,n,d,r),l=t.memoizedState),(c=so||mc(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,lo(e,t),o=t.memoizedProps,u=gc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Ci,typeof l==`object`&&l&&(c=ya(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)&&hc(t,a,r,c),so=!1,f=t.memoizedState,a.state=f,_o(t,r,a,i),go();var p=t.memoizedState;o!==d||f!==p||so||e!==null&&e.dependencies!==null&&_a(e.dependencies)?(typeof s==`function`&&(fc(t,n,s,r),p=t.memoizedState),(u=so||mc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&_a(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,Lc(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=ao(t,e.child,null,i),t.child=ao(t,null,n,i)):X(e,t,n,i),t.memoizedState=a.state,e=t.child):e=nl(e,t,i),e}function Vc(e,t,n,r){return oa(),t.flags|=256,X(e,t,n,r),t.child}var Hc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Uc(e){return{baseLanes:e,cachePool:Ha()}}function Wc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cd),e}function Gc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Mo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(Qi){if(i?Do(t):Ao(),(e=Zi)?(e=sm(e,ea),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Hi===null?null:{id:Ui,overflow:Wi},retryLane:536870912,hydrationErrors:null},n=Mi(e),n.return=t,t.child=n,Xi=t,Zi=null)):e=null,e===null)throw na(t);return t.lanes=lm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Ao(),i=t.mode,a=qc({mode:`hidden`,children:a},i),r=Ai(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Uc(n),r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(null,r)):(Do(t),Kc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Yc(e,t,a,o,r,c,s,n)}return i?(Ao(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Di(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Ai(i,a,n,null),i.flags|=2):i=Di(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Mc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Uc(n):(a=i.cachePool,a===null?a=Ha():(s=Ta._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(e.child,r)):(Do(t),n=e.child,e=n.sibling,n=Di(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 Kc(e,t){return t=qc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function qc(e,t){return e=Ti(22,e,null,t),e.lanes=0,e}function Jc(e,t,n){return ao(t,e.child,null,n),e=Kc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yc(e,t,n,r,i,o,s,c){if(n)return t.flags&256?(Do(t),t.flags&=-257,Jc(e,t,c)):t.memoizedState===null?(Ao(),o=i.fallback,s=t.mode,i=qc({mode:`visible`,children:i.children},s),o=Ai(o,s,c,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,ao(t,e.child,null,c),i=t.child,i.memoizedState=Uc(c),i.childLanes=Wc(e,r,c),t.memoizedState=Hc,Mc(null,i)):(Ao(),t.child=e.child,t.flags|=128,null);if(Do(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,ca({value:i,source:null,stack:null})),Jc(e,t,c)}if(Dc||ga(e,t,c,!1),r=(c&e.childLanes)!==0,Dc||r){if(bo.current!==null)return Jc(e,t,c);if(r=Yu,r!==null&&(i=lt(r,c),i!==0&&i!==s.retryLane))throw s.retryLane=i,bi(e,i),Nd(r,e,i),Ec;return cm(o)||Gd(),Jc(e,t,c)}return cm(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,Zi=dm(o.nextSibling),Xi=t,Qi=!0,$i=null,ea=!1,e!==null&&Yi(t,e),t=Kc(t,i.children),t.flags|=134221824,t)}function Xc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ma(e.return,t,n)}function Zc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Fo(n)===null&&(t=e),e=e.sibling}return t}function Qc(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 $c(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 el(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Mo.current;if(t.flags&128)return No(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,No(t,o),i===`backwards`&&e!==null?($c(e),X(e,t,r,n),$c(e)):X(e,t,r,n),r=Qi?zi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xc(e,n,t);else if(e.tag===19)Xc(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=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,$c(t)),Qc(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&&Fo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Qc(t,!0,n,null,a,r);break;case`together`:Qc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Qc(t,!1,i,n,a,r)}return t.child}function tl(e,t,n){var r=t.pendingProps;return fa(t,t.type,r.value),X(e,t,r.children,n),t.child}function nl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ad|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ga(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=Di(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Di(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&_a(e)))}function il(e,t,n){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),fa(t,Ta,e.memoizedState.cache),oa();break;case 27:case 5:be(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:fa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Oo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Do(t),t.flags|=128,null;r=ga(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Gc(e,t,n):(Do(t),e=nl(e,t,n),e===null?null:e.sibling)}Do(t);break;case 19:if(t.flags&128)return el(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(ga(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return el(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),No(t,Mo.current),r)break;return null;case 22:return t.lanes=0,jc(e,t,n,t.pendingProps);case 24:fa(t,Ta,e.memoizedState.cache)}return nl(e,t,n)}function al(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Dc=!0;else{if(!rl(e,n)&&!(t.flags&128))return Dc=!1,il(e,t,n);Dc=!!(e.flags&131072)}}else Dc=!1,Qi&&t.flags&1048576&&Ki(t,zi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ya(t.elementType),t.type=e,typeof e==`function`)Ei(e)?(r=gc(e,r),t.tag=1,t=Bc(null,t,e,r,n)):(t.tag=0,t=Rc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===I){t.tag=11,t=Oc(null,t,e,r,n);break a}if(i===z){t.tag=14,t=kc(null,t,e,r,n);break a}if(i===F){t.tag=10,t.type=e,t=tl(null,t,n);break a}}throw t=oe(e)||e,Error(a(306,t,``))}}return t;case 0:return Rc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=gc(r,t.pendingProps),Bc(e,t,r,i,n);case 3:a:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(a(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,lo(e,t),_o(t,r,null,n);var s=t.memoizedState;if(r=s.cache,fa(t,Ta,r),r!==o.cache&&ha(t,[Ta],n,!0),go(),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=Vc(e,t,r,n);break a}if(r!==i){i=Fi(Error(a(424)),t),ca(i),t=Vc(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(Zi=dm(e.firstChild),Xi=t,Qi=!0,$i=null,ea=!0,n=oo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(oa(),r===i){t=nl(e,t,n);break a}X(e,t,r,n)}t=t.child}return t;case 26:return Lc(e,t),e===null?(n=Fm(t.type,null,t.pendingProps,null))?t.memoizedState=n:Qi||(t.stateNode=mp(t.type,t.pendingProps,ge.current,t)):t.memoizedState=Fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return be(t),e===null&&Qi&&(r=t.stateNode=_m(t.type,t.pendingProps,ge.current),Xi=t,ea=!0,i=Zi,wp(t.type)?(fm=i,Zi=dm(r.firstChild)):Zi=i),X(e,t,t.pendingProps.children,n),Lc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Qi&&((i=r=Zi)&&(r=am(r,t.type,t.pendingProps,ea),r===null?i=!1:(t.stateNode=r,Xi=t,Zi=dm(r.firstChild),ea=!1,i=!0)),i||na(t)),be(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),Lc(e,t),X(e,t,r,n),t.child;case 6:return e===null&&Qi&&((e=n=Zi)&&(n=om(n,t.pendingProps,ea),n===null?e=!1:(t.stateNode=n,Xi=t,Zi=null,e=!0)),e||na(t)),null;case 13:return Gc(e,t,n);case 4:return ve(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ao(t,null,r,n):X(e,t,r,n),t.child;case 11:return Oc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Lc(e,t),X(e,t,r,n),t.child;case 8:return X(e,t,t.pendingProps.children,n),t.child;case 12:return X(e,t,t.pendingProps.children,n),t.child;case 10:return tl(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,va(t),i=ya(i),r=r(i),t.flags|=1,X(e,t,r,n),t.child;case 14:return kc(e,t,t.type,t.pendingProps,n);case 15:return Ac(e,t,t.type,t.pendingProps,n);case 19:return el(e,t,n);case 31:return Ic(e,t,n);case 22:return jc(e,t,n,t.pendingProps);case 24:return va(t),r=ya(Ta),e===null?(i=Ba(),i===null&&(i=Yu,o=Ea(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},co(t),fa(t,Ta,i)):((e.lanes&n)!==0&&(lo(e,t),_o(t,null,null,n),go()),i=e.memoizedState,o=t.memoizedState,i.parent===r?(r=o.cache,fa(t,Ta,r),r!==i.cache&&ha(t,[Ta],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),fa(t,Ta,r))),X(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:Qi&&qi(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Lc(e,t),X(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(a(156,t.tag))}function ol(e){e.flags|=4}function sl(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 Xa=Ka,Wa}}else e.flags&=-16777217}function cl(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 Xa=Ka,Wa}}function ll(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:rt(),e.lanes|=t,ld|=t)}function ul(e,t){if(!Qi)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 dl(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 fl(e,t,n){var r=t.pendingProps;switch(Ji(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dl(t),null;case 1:return dl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),pa(Ta),ye(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(aa(t)?ol(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,sa())),dl(t),null;case 26:var i=t.type,o=t.memoizedState;return e===null?(ol(t),o===null?(dl(t),sl(t,i,null,r,n)):(dl(t),cl(t,o))):o?o===e.memoizedState?(dl(t),t.flags&=-16777217):(ol(t),dl(t),cl(t,o)):(e=e.memoizedProps,e!==r&&ol(t),dl(t),sl(t,i,e,r,n)),null;case 27:if(G(t),n=ge.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return dl(t),t.subtreeFlags&=-33554433,null}e=me.current,aa(t)?ra(t,e):(e=_m(i,r,n),t.stateNode=e,ol(t))}return dl(t),t.subtreeFlags&=-33554433,null;case 5:if(G(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return dl(t),t.subtreeFlags&=-33554433,null}if(o=me.current,aa(t))ra(t,o);else{var s=dp(ge.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[ht]=t,o[gt]=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&&ol(t)}}return dl(t),t.subtreeFlags&=-33554433,sl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=ge.current,aa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Xi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[ht]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||tp(e.nodeValue,n)),e||na(t,!0)}else e=dp(e).createTextNode(r),e[ht]=t,t.stateNode=e}return dl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=aa(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[ht]=t}else oa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),e=!1}else n=sa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(jo(t),t):(jo(t),null);if(t.flags&128)throw Error(a(558))}return dl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=aa(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[ht]=t}else oa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),i=!1}else i=sa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(jo(t),t):(jo(t),null)}return jo(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),ll(t,t.updateQueue),dl(t),null);case 4:return ye(),e===null&&Gf(t.stateNode.containerInfo),t.flags|=67108864,dl(t),null;case 10:return pa(t.type),dl(t),null;case 19:if(Po(t),r=t.memoizedState,r===null)return dl(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)ul(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Fo(e),o!==null){for(t.flags|=128,ul(r,!1),e=o.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Oi(n,e),n=n.sibling;return No(t,Mo.current&1|2),Qi&&Gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ne()>hd&&(t.flags|=128,i=!0,ul(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Fo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),ul(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!Qi)return dl(t),null}else 2*Ne()-r.renderingStartTime>hd&&n!==536870912&&(t.flags|=128,i=!0,ul(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=Ne(),e.sibling=null,o=Mo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||Qi?No(t,o):(n=o,pe(To,t),pe(Mo,n),Eo===null&&(Eo=t)),Qi&&Gi(t,r.treeForkCount),e}return dl(t),null;case 22:case 23:return jo(t),wo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(dl(t),t.subtreeFlags&6&&(t.flags|=8192)):dl(t),n=t.updateQueue,n!==null&&ll(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&&fe(za),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),pa(Ta),dl(t),null;case 25:return null;case 30:return t.flags|=33554432,dl(t),null}throw Error(a(156,t.tag))}function pl(e,t){switch(Ji(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pa(Ta),ye(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return G(t),null;case 31:if(t.memoizedState!==null){if(jo(t),t.alternate===null)throw Error(a(340));oa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(jo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));oa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Po(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 ye(),null;case 10:return pa(t.type),null;case 22:case 23:return jo(t),wo(),e!==null&&fe(za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return pa(Ta),null;case 25:return null;default:return null}}function ml(e,t){switch(Ji(t),t.tag){case 3:pa(Ta),ye();break;case 26:case 27:case 5:G(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&jo(t);break;case 13:jo(t);break;case 19:Po(t);break;case 10:pa(t.type);break;case 22:case 23:jo(t),wo(),e!==null&&fe(za);break;case 24:pa(Ta)}}function hl(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 gl(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 _l(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{yo(t,n)}catch(t){pf(e,e.return,t)}}}function vl(e,t,n){n.props=gc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pf(e,t,n)}}function yl(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=ui(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 bl(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 xl(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 Sl(e){for(var t=e.return;t!==null&&(wl(t)&&nm(e.stateNode,t.stateNode),!Z(t));)t=t.return}function Cl(e){for(var t=e.return;t!==null&&(wl(t)&&rm(e.stateNode,t.stateNode),!Z(t));)t=t.return}function Z(e){return e.tag===5||e.tag===3||e.tag===27}function wl(e){return e&&e.tag===7&&e.stateNode!==null}function Tl(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 El(e,t,n){try{var r=e.stateNode;op(r,e.type,n,t),r[gt]=t}catch(t){pf(e,e.return,t)}}function Dl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wp(e.type)||e.tag===4}function Ol(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Dl(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 kl(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)),xl(e,r),Rt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(kl(e,t,n,r),e=e.sibling;e!==null;)kl(e,t,n,r),e=e.sibling}function Al(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),xl(e,r),Rt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Al(e,t,n,r),e=e.sibling;e!==null;)Al(e,t,n,r),e=e.sibling}function jl(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[ht]=e,t[gt]=n}catch(t){pf(e,e.return,t)}}var Ml=!1,Nl=null;function Pl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Ml=!0)}var Fl=null;function Il(){var e=Fl;return Fl=null,e}var Ll=0;function Rl(e,t,n,r,i){return Ll=0,zl(e.child,t,n,r,i)}function zl(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);Ml=!0,Dp(o,Ll===0?t:t+`_`+Ll,n),Ll++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||zl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Bl(e,t){for(;e!==null;)e.tag===5?Op(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Bl(e.child,t),e=e.sibling}function Vl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Vl(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=fi(t.default,t.share),t!==`none`&&(Rl(e,n,t,null,!1)||Bl(e.child,!1))}e=e.sibling}}function Hl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=ui(r,n),a=fi(r.default,n.paired?r.share:r.enter);a===`none`?Vl(e):Rl(e,i,a,null,!1)?(Vl(e),n.paired||t||Md(e,r.onEnter)):Bl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Hl(e,t),e=e.sibling;else Vl(e)}function Ul(e){if(Nl!==null&&Nl.size!==0){var t=Nl;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=fi(n.default,n.share);if(a!==`none`&&(Rl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Md(e,n.onShare)):Bl(e.child,!1)),t.delete(r),t.size===0)break}}}Ul(e)}e=e.sibling}}}function Wl(e){if(e.tag===30){var t=e.memoizedProps,n=ui(t,e.stateNode),r=Nl===null?void 0:Nl.get(n),i=fi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Rl(e,n,i,null,!1)?r===void 0?Md(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Nl.delete(n),Md(e,t.onShare)):Bl(e.child,!1)),Nl!==null&&Ul(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e),e=e.sibling;else Nl!==null&&Ul(e)}function Gl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=ui(t,e.stateNode);t=fi(t.default,t.update),e.flags&=-5,t!==`none`&&Rl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Gl(e);e=e.sibling}}function Kl(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,Bl(e.child,!1))}Kl(e)}e=e.sibling}}function ql(e){if(e.tag===30)e.stateNode.paired=null,Bl(e.child,!1),Kl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)ql(e),e=e.sibling;else Kl(e)}function Jl(e){for(e=e.child;e!==null;)e.tag===30?Bl(e.child,!1):e.subtreeFlags&33554432&&Jl(e),e=e.sibling}function Yl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Ll<a.length){var l=a[Ll],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,Ll===0?n:n+`_`+Ll,i),s&&e.flags&4||(Fl===null&&(Fl=[]),Fl.push(c,Ll===0?r:r+`_`+Ll,t.memoizedProps)),Ll++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Yl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Xl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=ui(n,r),a=fi(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;Ll=0,i=Yl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Md(e,n.onUpdate))}else e.subtreeFlags&33554432&&Xl(e,t);e=e.sibling}}var Zl=!1,Ql=!1,$l=!1,eu=!1,tu=typeof WeakSet==`function`?WeakSet:Set,nu=null,ru=!1,iu=!1,au=!1,ou=!1;function su(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,nu=t,t=n?9270:1024;nu!==null;){if(e=nu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Wl(r[a]);if(e.alternate===null&&e.flags&2)n&&Pl(e),cu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Wl(r),cu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Pl(e),cu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,nu=r):(n&&Gl(e),cu(n))}}Nl=null}function cu(e){for(;nu!==null;){var t=nu,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=gc(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=ui(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=fi(i.default,i.update),i!==`none`&&Rl(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,nu=r;break}nu=t.return}}function lu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ku(e,n),r&4&&hl(5,n);break;case 1:if(ku(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){pf(n,n.return,e)}else{var i=gc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pf(n,n.return,e)}}}r&64&&_l(n),r&512&&yl(n,n.return);break;case 3:if(ku(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{yo(e,t)}catch(e){pf(n,n.return,e)}}break;case 27:t===null&&r&4&&jl(n);case 26:case 5:ku(e,n),t===null&&r&4&&Tl(n),r&512&&yl(n,n.return);break;case 12:ku(e,n);break;case 31:ku(e,n),r&4&&vu(e,n);break;case 13:ku(e,n),r&4&&yu(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||Zl,!r){var a=t!==null&&t.memoizedState!==null||Ql;t=Zl,i=Ql,Zl=r,(Ql=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),ju(e,n,r)):ku(e,n),Zl=t,Ql=i}break;case 30:ku(e,n),r&512&&yl(n,n.return);break;case 7:r&512&&yl(n,n.return);default:ku(e,n)}}function uu(e,t){for(e=e.child;e!==null;)du(e,t),e=e.sibling}function du(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)}fu(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&&uu(e,t);break;default:uu(e,t)}}function fu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:du(n,r);break a;case 22:n.memoizedState===null&&fu(n,r);break a;default:fu(n,r)}}e=e.sibling}}function pu(e){var t=e.alternate;t!==null&&(e.alternate=null,pu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&wt(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 mu=null,hu=!1;function gu(e,t,n){for(n=n.child;n!==null;)_u(e,t,n),n=n.sibling}function _u(e,t,n){if(Ue&&typeof Ue.onCommitFiberUnmount==`function`)try{Ue.onCommitFiberUnmount(He,n)}catch{}switch(n.tag){case 26:Ql||bl(n,t),gu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Ql&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ql||bl(n,t),Cl(n);var r=mu,i=hu;wp(n.type)&&(mu=n.stateNode,hu=!1),gu(e,t,n),vm(n.stateNode,n.type,n.memoizedProps),mu=r,hu=i;break;case 5:Ql||bl(n,t),Cl(n);case 6:if(n.tag===6&&Cl(n),r=mu,i=hu,mu=null,gu(e,t,n),mu=r,hu=i,mu!==null){if(hu)try{(mu.nodeType===9?mu.body:mu.nodeName===`HTML`?mu.ownerDocument.body:mu).removeChild(n.stateNode),Rt=!0}catch(e){pf(n,t,e)}else try{mu.removeChild(n.stateNode),Rt=!0}catch(e){pf(n,t,e)}}break;case 18:mu!==null&&(hu?(e=mu,Tp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wh(e)):Tp(mu,n.stateNode));break;case 4:r=mu,i=hu,mu=n.stateNode.containerInfo,hu=!0,gu(e,t,n),mu=r,hu=i;break;case 0:case 11:case 14:case 15:gl(2,n,t),Ql||gl(4,n,t),gu(e,t,n);break;case 1:Ql||(bl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&vl(n,t,r)),gu(e,t,n);break;case 21:gu(e,t,n);break;case 22:Ql=(r=Ql)||n.memoizedState!==null,gu(e,t,n),Ql=r;break;case 30:bl(n,t),gu(e,t,n);break;case 7:Ql||bl(n,t),gu(e,t,n);break;default:gu(e,t,n)}}function vu(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 yu(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 bu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tu),t;default:throw Error(a(435,e.tag))}}function xu(e,t){var n=bu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=vf.bind(null,e,t);t.then(r,r)}})}function Su(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)){mu=l.stateNode,hu=!1;break a}break;case 5:mu=l.stateNode,hu=!1;break a;case 3:case 4:mu=l.stateNode.containerInfo,hu=!0;break a}l=l.return}if(mu===null)throw Error(a(160));_u(s,c,o),mu=null,hu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)wu(t,e,n),t=t.sibling}var Cu=null;function wu(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}Su(t,e,n),Tu(e),i&4&&(gl(3,e,e.return),hl(3,e),gl(5,e,e.return));break;case 1:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),i&64&&Zl&&(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=Cu,Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(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(Zl)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[St]||r[ht]||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[ht]=e,kt(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[ht]=e,kt(r),t=r}e.stateNode=t}}else Zl||Jm(o,e.type,e.stateNode)}else e.stateNode=Hm(o,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&El(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||Ql||t.parentNode.removeChild(t)):i.count--,n===null?Zl||Jm(o,e.type,e.stateNode):Hm(o,n,e.memoizedProps))}break;case 27:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),r!==null&&i&4&&El(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=$l,$l=!1,Su(t,e,n),$l=o,Tu(e),i&512&&(Ql||r===null||bl(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,El(e,t,r===null?t:r.memoizedProps)),i&1024&&(eu=!0);break;case 6:if(Su(t,e,n),Tu(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=Cu,Cu=Sm(t.containerInfo),Su(t,e,n),Cu=o,Tu(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Wh(t.containerInfo)}catch(t){pf(e,e.return,t)}eu&&(eu=!1,Eu(e)),Rt=!1;break;case 4:i=$l,$l=Zl,r=zt(),o=Cu,Cu=Sm(e.stateNode.containerInfo),Su(t,e,n),Tu(e),Cu=o,Rt&&iu&&(au=!0),Rt=r,$l=i;break;case 12:Su(t,e,n),Tu(e);break;case 31:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 13:Su(t,e,n),Tu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(pd=Ne()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Zl,l=Ql,u=$l;Zl=c||o,$l=u||o,Ql=l||s,Su(t,e,n),Ql=l,$l=u,Zl=c,Tu(e),i&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||Zl||Ql||(t=s||Ql,n=Zl,r=Ql,Zl=o||Zl,Ql=t,Au(e,2),Zl=n,Ql=r),!o&&$l||uu(e,o)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,xu(e,n))));break;case 19:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 30:i&512&&(Ql||r===null||bl(r,r.return)),i=zt(),o=iu,s=(n&335544064)===n,c=e.memoizedProps,iu=s&&fi(c.default,c.update)!==`none`,Su(t,e,n),Tu(e),s&&r!==null&&Rt&&(e.flags|=4),iu=o,Rt=i;break;case 21:break;case 7:i&512&&(Ql||r===null||bl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Su(t,e,n),Tu(e)}}function Tu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Dl(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(wl(i)){var o=i.stateNode;r===null?r=[o]:r.push(o)}if(Z(i))break;i=i.return}var s=r;if(n==null)throw Error(a(160));switch(n.tag){case 27:var c=n.stateNode;Al(e,Ol(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(nn(l,``),n.flags&=-33),Al(e,Ol(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;kl(e,Ol(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 Eu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Eu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,vh=!0,t.reset(),vh=!1),e=e.sibling}}function Du(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Ou(t,e),t=t.sibling;else Xl(t,!1)}function Ou(e,t){var n=e.alternate;if(n===null)Hl(e,!1);else switch(e.tag){case 3:if(ou=ru=!1,Il(),Du(t,e),!ru&&!au){if(e=Fl,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`})),ou=!0}Fl=null;break;case 5:Du(t,e);break;case 4:r=ru,ru=!1,Du(t,e),ru&&(au=!0),ru=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Du(t,e):Hl(e,!1));break;case 30:r=ru,i=Il(),ru=!1,Du(t,e),ru&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=ui(a,o),o=ui(n.memoizedProps,o);var s=fi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Ll=0,t=Yl(e,n,t,o,s,a,!0),Ll!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Md(e,e.memoizedProps.onUpdate),Fl=i):i!==null&&(i.push.apply(i,Fl),Fl=i),ru=e.flags&32?!0:r;break;default:Du(t,e)}}function ku(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)lu(e,t.alternate,t),t=t.sibling}function Au(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:gl(4,n,n.return),Au(n,r);break;case 1:bl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&vl(n,n.return,i),Au(n,r);break;case 27:r&2&&vm(n.stateNode,n.type,n.memoizedProps);case 5:bl(n,n.return),n.tag!==5&&n.tag!==27||Cl(n),Au(n,r);break;case 6:Cl(n);break;case 26:bl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Ql||i.parentNode.removeChild(i),Au(n,r);break;case 22:n.memoizedState===null&&Au(n,r);break;case 30:bl(n,n.return),Au(n,r);break;case 7:bl(n,n.return);default:Au(n,r)}e=e.sibling}}function ju(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:ju(i,a,n),hl(4,a);break;case 1:if(ju(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++)vo(l[i],c)}catch(e){pf(r,r.return,e)}}s&&o&64&&_l(a),yl(a,a.return);break;case 27:n&2&&jl(a);case 5:a.tag!==5&&a.tag!==27||Sl(a),ju(i,a,n),s&&r===null&&o&4&&Tl(a),yl(a,a.return);break;case 6:Sl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Zl||Jm(Sm(c.ownerDocument),a.type,c),ju(i,a,n),s&&r===null&&o&4&&Tl(a),yl(a,a.return);break;case 12:ju(i,a,n);break;case 31:ju(i,a,n),s&&o&4&&vu(i,a);break;case 13:ju(i,a,n),s&&o&4&&yu(i,a);break;case 22:a.memoizedState===null&&ju(i,a,n),yl(a,a.return);break;case 30:ju(i,a,n),yl(a,a.return);break;case 7:yl(a,a.return);default:ju(i,a,n)}t=t.sibling}}function Mu(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&&Da(n))}function Nu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Da(e))}function Pu(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&&Jl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&ql(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Pu(e,t,n,r),a&2048&&hl(9,t);break;case 1:Pu(e,t,n,r);break;case 3:Pu(e,t,n,r),i&&ou&&(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&&Da(a)));break;case 12:if(a&2048){Pu(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 Pu(e,t,n,r);break;case 31:Pu(e,t,n,r);break;case 13:Pu(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&&ql(t),o._visibility&2?Pu(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&ql(s),o._visibility&2?Pu(e,t,n,r):Lu(e,t)),a&2048&&Mu(s,t);break;case 24:Pu(e,t,n,r),a&2048&&Nu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Bl(a.child,!0),Bl(t.child,!0))),Pu(e,t,n,r);break;default:Pu(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),hl(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&&Mu(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Nu(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&&Mu(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Nu(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,Cu,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=Cu;Cu=Sm(e.stateNode.containerInfo),zu(e,t,n),Cu=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,Nl===null&&(Nl=new Map),Nl.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];nu=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&&gl(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];nu=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:gl(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(;nu!==null;){var n=nu;switch(n.tag){case 0:case 11:case 15:gl(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:Da(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nu=r;else a:for(n=e;nu!==null;){r=nu;var i=r.sibling,a=r.return;if(pu(r),r===n){nu=null;break a}if(i!==null){i.return=a,nu=i;break a}nu=a}}}var Ku={getCacheForType:function(e){var t=ya(Ta),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ya(Ta).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?ft():Pf()}function jd(){if(cd===0){if(!(Zu&536870912)||Qi){var e=Xe;Xe<<=1,!(Xe&3932160)&&(Xe=262144),cd=e}else cd=536870912}return e=To.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(ui(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)),at(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||et(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-Ne(),10<i)){if(Ld(r,t,cd,!ed),$e(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},Nl=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-Ne():(a&4194048)===a?md-Ne():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=tt(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-Ge(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&st(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,da=ua=null,es(e),$a=null,eo=0,e=Xu;for(;e!==null;)ml(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=Di(e.current,null),Zu=t,Qu=0,$u=null,ed=!1,td=et(e,t),nd=!1,ld=cd=sd=od=ad=id=0,dd=ud=null,fd=!1,rd=tt(e,t),_i(),n}function Vd(e,t){Io=null,U.H=cc,t===Ua||t===Ga?(t=Za(),Qu=3):t===Wa?(t=Za(),Qu=4):Qu=t===Ec?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,Xu===null&&(id=1,bc(e,Fi(t,e.current)))}function Hd(){var e=To.current;return e===null?!0:(Zu&4194048)===Zu?Eo===null:(Zu&62914560)===Zu||Zu&536870912?e===Eo:!1}function Ud(){var e=U.H;return U.H=cc,e===null?cc:e}function Wd(){var e=U.A;return U.A=Ku,e}function Gd(){id=4,ed||(Zu&4194048)!==Zu&&To.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:To.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++,da=ua=null,Ju=r,U.H=i,U.A=a,Xu===null&&(Yu=null,Zu=0,_i()),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=Ne()+500,Bd(e,t)):td=et(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(qa(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:qa(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 da=ua=null,U.H=r,U.A=i,Ju=n,Xu===null?(Yu=null,Zu=0,_i(),id):0}function Yd(){for(;Xu!==null&&!je();)Xd(Xu)}function Xd(e){var t=al(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=zc(n,t,t.pendingProps,t.type,void 0,Zu);break;case 11:t=zc(n,t,t.pendingProps,t.type.render,t.ref,Zu);break;case 5:es(t);var r=t;r===Xi&&(Qi?(ia(r),r.tag===5&&r.stateNode!=null&&(Zi=r.stateNode)):(ia(r),Qi=!0));default:ml(n,t),t=Xu=Oi(t,rd),t=al(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Qd(e,t,n,r){da=ua=null,es(t),$a=null,eo=0;var i=t.return;try{if(Tc(e,i,t,n,Zu)){id=1,bc(e,Fi(n,e.current)),Xu=null;return}}catch(t){if(i!==null)throw Xu=i,t;id=1,bc(e,Fi(n,e.current)),Xu=null;return}t.flags&32768?(Qi||r===1?e=!0:td||Zu&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=To.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=fl(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=pl(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|=gi,ot(e,n,s,r,i,a),Ed=null,(n&335544064)===n?(Dd=Aa(e),r=10262):(Dd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,yf(Le,function(){return df(),null})):(e.callbackNode=null,e.callbackPriority=0),Ml=!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{su(e,t,n)}finally{Ju=a,W.p=i,U.T=r}}vd=1,Ml?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,Ou(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{iu=au=!1,wu(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{lu(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,Me();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),dt(r),n=n.stateNode,Ue&&typeof Ue.onCommitFiberRoot==`function`)try{Ue.onCommitFiberRoot(He,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,Da(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=dt(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),Ue&&typeof Ue.onPostCommitFiberRoot==`function`)try{Ue.onPostCommitFiberRoot(He,o)}catch{}return!0}finally{W.p=i,U.T=r,lf(e,t)}}function ff(e,t,n){t=Fi(n,t),t=Sc(e.stateNode,t,2),e=fo(e,t,2),e!==null&&(at(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=Fi(n,e),n=Cc(2),r=fo(t,n,2),r!==null&&(wc(n,r,t,e),at(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>Ne()-pd?Ju&2?sd|=n:Bd(e,0):sd|=n,ld===Zu&&(ld=0)),Ef(e)}function gf(e,t){t===0&&(t=rt()),e=bi(e,t),e!==null&&(at(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 ke(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-Ge(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=$e(r,r===Yu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||et(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=Ne(),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-Ge(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=nt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yu,n=Zu,n=$e(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&&Ae(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||et(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ae(r),dt(n)){case 2:case 8:n=Ie;break;case 32:n=Le;break;case 268435456:n=ze;break;default:n=Le}return r=jf.bind(null,e),n=ke(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ae(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=$e(e,e===Yu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pd(e,r,t),Af(e,Ne()),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?ke(Fe,Of):kf()})}function Pf(){if(Tf===0){var e=Na;e===0&&(e=Ye,Ye<<=1,!(Ye&261888)&&(Ye=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[gt]||null).action),o=r.submitter;o&&(t=(t=o[gt]||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);Js(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Js(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Lf=0;Lf<si.length;Lf++){var Rf=si[Lf];ci(Rf.toLowerCase(),`on`+(Rf[0].toUpperCase()+Rf.slice(1)))}ci($r,`onAnimationEnd`),ci(ei,`onAnimationIteration`),ci(ti,`onAnimationStart`),ci(`dblclick`,`onDoubleClick`),ci(`focusin`,`onFocus`),ci(`focusout`,`onBlur`),ci(ni,`onTransitionRun`),ci(ri,`onTransitionStart`),ci(ii,`onTransitionCancel`),ci(ai,`onTransitionEnd`),Pt(`onMouseEnter`,[`mouseout`,`mouseover`]),Pt(`onMouseLeave`,[`mouseout`,`mouseover`]),Pt(`onPointerEnter`,[`pointerout`,`pointerover`]),Pt(`onPointerLeave`,[`pointerout`,`pointerover`]),Nt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Nt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Nt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Nt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Nt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Nt(`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){pi(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){pi(e)}i.currentTarget=null,a=c}}}}function Hf(e,t){var n=t[vt];n===void 0&&(n=t[vt]=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,jt.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=Tt(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=oi.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 $r:case ei:case ti:c=Hn;break;case ai: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)&&(Tt(u)||u[_t]))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?Tt(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:Dt(s),h=c==null?u:Dt(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Tt(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?Dt(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?Dt(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,qr(o,n,i);break;case`selectionchange`:if(Hr)break;case`keydown`:case`keyup`:qr(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(!Mt.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[gt]||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[ht]=r,n[gt]=t,ip(n,e,t),kt(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[St]||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=Tt(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),wt(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[St])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),wt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);wt(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=Et(e);t!==null&&t.tag===5&&t.type===`form`?Xs(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),kt(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[Ct]=!0,o.onload=o.onerror=function(){At(o)}),kt(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),kt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=Ot(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`);kt(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=Ot(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`),kt(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=Ot(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`),kt(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=ge.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=Ot(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=Ot(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=Ot(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[Ct]){r.loading=1;return}}else t=e.createElement(`link`),t[Ct]=!0,t.onload=t.onerror=At.bind(null,t),ip(t,`link`,n),kt(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,kt(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`),kt(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,kt(o),o;r=Rm(n),(i=bm.get(i))&&Wm(r,i),o=(e.ownerDocument||e).createElement(`link`),kt(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,kt(i),i):(r=n,(i=bm.get(o))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),kt(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[St]||a[ht]||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,kt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),kt(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:ce,_currentValue2:ce,_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=it(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=it(0),this.hiddenUpdates=it(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=Ti(3,null,null,t),e.current=a,a.stateNode=e,t=Ea(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},co(a),e}function fh(e){return e?(e=Ci,e):Ci}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=uo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=fo(e,r,t),n!==null&&(Nd(n,e,t),po(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=bi(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=ut(t);var n=bi(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=Et(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Qe(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ge(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ne()+500,Df(0,!1))}}break;case 31:case 13:s=bi(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=Tt(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(Pe()){case Fe:return 2;case Ie:return 8;case Le:case Re:return 32;case ze: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=Et(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=Tt(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,pt(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,pt(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=Et(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=Et(n);a!==null&&(e.splice(t,3),t-=3,Js(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[gt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[gt]||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[_t]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=ft();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{He=Xh.inject(Yh),Ue=Xh}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(a(299));var n=!1,r=``,i=_c,o=vc,c=yc;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[_t]=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();function p(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function m(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function h(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 _(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 v=/(?:[\w.@~+-]+\/)+[\w.@~+-]+/;function y(e){let t=v.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 b(e,t){return e.trim()===t}var x=[`bar`,`line`,`area`,`stacked-bar`,`pie`],S={bar:`Bar`,line:`Line`,area:`Area`,"stacked-bar":`Stacked bar`,pie:`Pie`},C=/^([+\-−]?)\s*([$€£¥₹]?)\s*(\d{1,3}(?:,\d{3})+|\d+)?(\.\d+)?\s*(%?)$/;function w(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=C.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 T=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();function E(e){let t=e.rows.map(e=>e[0]??``),n=e.columns.slice(1).map((t,n)=>({name:t,values:e.rows.map(e=>w(e[n+1]??``)??null)}));return{kind:e.kind,categories:t,series:n,unit:e.unit,highlight:e.highlight?t.indexOf(e.highlight):-1}}var D=`−`,O=/^[$€£¥₹]$/;function k(e){return e?O.test(e)?`prefix`:e===`%`||e===`‰`||e===`°`?`tight`:e.length<=3?`spaced`:`caption`:`none`}function A(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`?`${D}${r}`:r}function j(e,t,n){let r=k(t);return r===`none`||r===`caption`&&!n?e:r===`prefix`?e.startsWith(D)?`${D}${t}${e.slice(1)}`:`${t}${e}`:r===`tight`?`${e}${t}`:`${e} ${t}`}function M(e,t){return e===null?`no value`:j(A(e),t,!0)}function N(e,t){return j(A(e,!0),t,!1)}function P(e){let t=e*100;return`${t>0&&t<1?`<1`:A(Math.round(t*(t<10?10:1))/(t<10?10:1))}%`}function F(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 I(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 L=11,R=13,z=24,B=2,ee=4;function V(e,t=L){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 te(e,t,n=L){if(V(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(V(i,n)<=t)return i}return null}var H=e=>Math.round(e*10)/10;function ne(e,t,n,r,i){let a=Math.max(0,Math.min(ee,n/2,r));return a===0||r<=0?`M${H(e)} ${H(t)}h${H(n)}v${H(r)}h${H(-n)}Z`:i?`M${H(e)} ${H(t+r)}V${H(t+a)}A${H(a)} ${H(a)} 0 0 1 ${H(e+a)} ${H(t)}H${H(e+n-a)}A${H(a)} ${H(a)} 0 0 1 ${H(e+n)} ${H(t+a)}V${H(t+r)}Z`:`M${H(e)} ${H(t)}V${H(t+r-a)}A${H(a)} ${H(a)} 0 0 0 ${H(e+a)} ${H(t+r)}H${H(e+n-a)}A${H(a)} ${H(a)} 0 0 0 ${H(e+n)} ${H(t+r-a)}V${H(t)}Z`}function re(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 ie(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?re(n,r):e.kind===`pie`?le(e,n,r):oe(e,n,r)}function ae(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 oe(e,t,n){let{categories:r,series:i,unit:a,kind:o}=e,s=r.length,c=o===`line`||o===`area`,l=k(a),u=l===`caption`?30:16,d=Math.max(20,n-u-24),f=I(e),p=i.every(e=>e.values.every(e=>e===null||Number.isInteger(e))),m=F(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=>N(e,a)),v=Math.ceil(Math.max(16,..._.map(e=>V(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=N(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=>V(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,A=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:A(t)};let n=t===0?C.x:(A(t-1)+A(t))/2;return{category:t,x:n,w:(t===s-1?C.x+C.w:(A(t)+A(t+1))/2)-n,cx:A(t)}}),T.axis=se(r,A,c&&s>1?O:E,t),c?W(e,T,A,w,x?y:[]):U(e,T,E,w),T}function se(e,t,n,r){let i=e.length,a=Math.max(...e.map(e=>V(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=te(e[n],s);if(!i)continue;let a=V(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 U(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=B,m=Math.min(z,(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-B:u,h=Math.max(.5,p-d),g=f?c.y:d-B/2,_=l===0?u+2:u+B/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?ne(o,d,m,h,!0):`M${H(o)} ${H(d)}h${H(m)}v${H(h)}h${H(-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:ne(u,g,m,_,h),hit:y})})});let _=ae(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=N(y,o),C=Math.min(t.width-V(S)/2-2,Math.max(V(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 W(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`}${H(e.x)} ${H(e.y)}`).join(``)).join(``),d=s===`area`?o.filter(e=>e.length>1).map(e=>`${e.map((e,t)=>`${t?`L`:`M`}${H(e.x)} ${H(e.y)}`).join(``)}L${H(e.at(-1).x)} ${H(l)}L${H(e[0].x)} ${H(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+R);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-R);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=ae(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=N(h.value,o),_=V(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 ce(e,t,n,r,i,a){let o=a-i>=Math.PI*2-1e-6,s=(n,r)=>`${H(e+n*Math.cos(r))} ${H(t+n*Math.sin(r))}`;if(o){let e=i+Math.PI;return`M${s(n,i)}A${H(n)} ${H(n)} 0 1 1 ${s(n,e)}A${H(n)} ${H(n)} 0 1 1 ${s(n,i)}ZM${s(r,i)}A${H(r)} ${H(r)} 0 1 0 ${s(r,e)}A${H(r)} ${H(r)} 0 1 0 ${s(r,i)}Z`}let c=+(a-i>Math.PI);return`M${s(n,i)}A${H(n)} ${H(n)} 0 ${c} 1 ${s(n,a)}L${s(r,a)}A${H(r)} ${H(r)} 0 ${c} 0 ${s(r,i)}Z`}function le(e,t,n){let r=e.series[0]?.values??[],i=r.reduce((e,t)=>e+Math.max(0,t??0),0),a=re(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:ce(o,s,c,l,r,d),hit:ce(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:N(i,e.unit),caption:k(e.unit)===`caption`?`${e.unit} in all`:`in all`};let d=ae(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:P(f.share),anchor:r>.25?`start`:r<-.25?`end`:`middle`,strong:!0})}return a}function ue(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?P(i/r):`0%`}function de(e,t,n){let r=e.rows.findIndex(e=>e[0]===t);if(r===-1&&(r=e.rows.findIndex(e=>T(e[0]??``,t))),r===-1)return null;if(n===void 0)return{row:r,series:null};let i=fe(e,n);return i===null?null:{row:r,series:i}}function fe(e,t){let n=e.columns.findIndex((e,n)=>n>0&&e===t);return n===-1&&(n=e.columns.findIndex((e,n)=>n>0&&T(e,t))),n===-1?null:n-1}function pe(e,t){return`${p(e.columns[t+1]||`series ${t+1}`,40)} series`}function me(e,t,n){let r=p(e.rows[t]?.[0]||`row ${t+1}`,60),i=e.columns.length>2;if(n===null&&i)return r;let a=n??0,o=M(w(e.rows[t]?.[a+1]??``)??null,e.unit);return i?`${r} · ${p(e.columns[a+1],40)}: ${o}`:`${r}: ${o}`}var he={w:780,h:400};function ge(){return{blocks:[],groups:[],links:[],pins:[]}}function _e(e){let t=_i(e.type);return t.named?.(e)||(e.title?`${e.type} "${p(e.title,50)}"`:t.untitled?.(e)??`untitled ${e.type}`)}function ve(e){return`${_e(e)} is ${/^[aeiou]/.test(e.type)?`an`:`a`} ${e.type}`}function ye(e,t=50){return e.title?`"${p(e.title,t)}"`:_e(e)}function be(e,t){return{...e,title:t.title,type:t.type,..._i(t.type).fromSnapshot(t,e)}}var G={},xe={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:G.anchor,part:G.part,parts:{point:{lost:`no longer there`,drawn:!0,askedTo:`change the chart's data`,missing:e=>`Points are pinned in charts; ${ve(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:fe(e,r);return t===null?null:{kind:`point`,row:null,series:t}}let i=de(e,n,r);return i&&{kind:`point`,...i}}},...G},Se=2097152;function Ce(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 we(e,t){return`+${e.toLocaleString(`en-US`)} −${t.toLocaleString(`en-US`)}`}var Te=[/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|go\.sum)$/,/\.lock$/,/(^|\/)dist\//,/\.min\.(js|css)$/,/\.map$/,/(^|\/)__snapshots__\//,/\.snap$/];function Ee(e){return Te.some(t=>t.test(e))}function De(e){return e.hunks.reduce((e,t)=>e+t.lines.length,0)}function Oe(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&&!Ee(t.path)&&De(t)<=150&&n.add(t.path)}return n}function ke(e,t=[]){return t.length===0?e:[...t.flatMap(t=>e.filter(e=>e.path===t)),...e.filter(e=>!t.includes(e.path))]}function Ae(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 je(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 Me(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 Ne(e){return e.replace(/\s+/g,` `).trim().slice(0,1e3)}function Pe(e,t,n){for(let r of e.hunks)for(let e of je(r))if(e[t]===n)return e.text}function Fe(e,t){return e.find(e=>e.path===t)??e.find(e=>e.oldPath===t)}function Ie(e,t,n,r,i){let a=Fe(e,t);if(!a)return null;let o=null;for(let e of a.hunks)for(let t of je(e)){let e=t[n];e!==void 0&&Ne(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 Le=class extends Error{},Re=[{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 ze(e){let t=e.split(/[\\/]/).pop()??``,n=Re.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 Re.find(e=>e.extensions.includes(i))}function Be(e){let t=e.trim().toLowerCase().replace(/^\./,``);if(t)return Re.find(e=>e.name.toLowerCase()===t||e.aliases?.includes(t)||e.extensions.includes(t))}function Ve(e){return e.language?Be(e.language)??{name:e.language,extensions:[]}:ze(e.path)}function He(e){let t=e.split(`
|
|
11
|
-
`).map(e=>e.endsWith(`\r`)?e.slice(0,-1):e);return t.length>1&&t.at(-1)===``&&t.pop(),t}function Ue(e,t=He(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 We=e=>e.toLocaleString(`en-US`);function Ge([e,t]){return e===t?String(e):`${e}–${t}`}function Ke(e,t){let{first:n,last:r,total:i}=Ue(e,t);return n===1&&i===r?`${We(r)} line${r===1?``:`s`}`:`lines ${Ge([n,r])}${i?` of ${We(i)}`:``}`}function qe(e,t=60){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Je(e,t,n){let r=e.start??1,i=null;return He(e.text).forEach((e,a)=>{let o=r+a;Ne(e)===n&&(i===null||Math.abs(o-t)<Math.abs(i-t))&&(i=o)}),i}function Ye(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 Xe(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Ze(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 Qe(e,t=`The text`){if(!e.trim())throw new Le(`${t} is empty. A code block needs the file's text, or the lines that matter.`);let n=Ye(e);if(n>1048576)throw new Le(`${t} is ${Xe(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(Ze(e))throw new Le(`${t} looks like a binary file, not text. Code blocks hold source and other text files.`);return e}function $e(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 et=4;function tt(e,t={}){let{first:n,last:r}=Ue(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 $e(a)){let n=o.at(-1);n&&e-n[1]-1<et?n[1]=t:o.push([e,t])}o.length&&o[0][0]-n<et&&(o[0][0]=n),o.length&&r-o[o.length-1][1]<et&&(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 nt(e,t,n){let r=t.filter(e=>e.kind===`lines`),{first:i,last:a,total:o}=Ue(e,n);return r.length!==1||r[0].from===i&&r[0].to===a?Ke(e,n):`lines ${Ge([r[0].from,r[0].to])}${o?` of ${We(o)}`:``}`}var rt=19.2,it=40,at=24,ot=7.3;function st(e){let t=He(e.text),n=tt(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(it+i*rt+s*at+8),u=Math.round(c*ot+30+a*ot+24);return{w:Math.min(820,Math.max(460,u)),h:Math.min(560,Math.max(120,l))}}var ct=e=>e.last&&e.last>e.line?`${e.line}–${e.last}`:`${e.line}`;function lt({anchor:e,quote:t}){let n=ct(e);return`${e.file?`${e.file}:${n}`:`${n.includes(`–`)?`lines`:`line`} ${n}`}${e.side===`old`?` (old)`:``} · ${t?`“${t}”`:`a blank line`}`}var ut={name:({anchor:e})=>{let t=e.last&&e.last>e.line?`lines`:`line`;return`${e.side===`old`?`old `:``}${t} ${ct(e)}${e.file?` of ${e.file}`:``}`},quote:lt,detail:lt,lost:`no longer there`,answeredOn:`the line`,where:e=>e.quote?` ("${p(e.quote,80)}")`:` (a blank line)`},dt={type:`code`,label:`Code`,defaultSize:{w:640,h:420},titled:!1,named:e=>e.path?`code "${qe(e.path)}"`:`untitled code`,sizeFor:e=>st(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:G.anchor,part:G.part,parts:{line:{...ut,askedTo:`change the code`}},place(e,t){if(t.anchor.kind!==`line`)return;let n=Je(e,t.anchor.line,t.quote);if(n===null)return null;let{last:r}=t.anchor,i=(e.start??1)+He(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)}:{}}}},...G},ft={type:`comparison`,label:`Comparison`,defaultSize:{w:520,h:340},fromSnapshot:()=>({}),...G},pt=/^(?:flowchart|flowchart-elk|graph)\b(?:[ \t]+(?:TB|TD|BT|RL|LR))?[ \t]*;?/,mt=/^(?:classDef|class|style|linkStyle|click|direction)[ \t]|^(?:accTitle|accDescr)[ \t]*[:{]|^end\b/,ht=/^(?:[\p{L}\p{N}_$]|\.(?![-=])|-(?![-.>=]))+/u,gt=[[`(((`,[`)))`]],[`((`,[`))`]],[`([`,[`])`]],[`[[`,[`]]`]],[`[(`,[`)]`]],[`{{`,[`}}`]],[`[/`,[`/]`,`\\]`]],[`[\\`,[`\\]`,`/]`]],[`[`,[`]`]],[`(`,[`)`]],[`{`,[`}`]],[`>`,[`]`]]],_t=/^(?:[<ox]?(?:-{2,}[>ox]|-{3,}|={2,}[>ox]|={3,}|-\.+-[>ox]?)|~{3,})/,vt=/^[<ox]?(?:--|==|-\.)[ \t]*([^-=.>\s].*?)[ \t]*(?:-{2,}[>ox]|-{3,}|={2,}[>ox]|={3,}|\.-+[>ox]?)/,yt={quot:`"`,amp:`&`,lt:`<`,gt:`>`,nbsp:` `};function bt(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)=>yt[t]).replace(/\s+/g,` `).trim()}function xt(e){let t=e.replace(/^\s*---\n[\s\S]*?\n---[ \t]*\n/,``).split(`
|
|
12
|
-
`).filter(e=>!/^\s*%%/.test(e));for(;t.length&&!t[0].trim();)t.shift();let n=t[0]?.trim().match(pt);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(ht)?.[0];if(!i)return null;t+=i.length,r.has(i)||r.set(i,i);let a=gt.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,bt(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,bt(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(_t),i=r?null:n().match(vt),a=r??i;if(!a)return null;t+=a[0].length;let o=i?bt(i[1]):void 0,s=n().match(/^[ \t]*\|([^|]*)\|/);return s&&(o=bt(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||mt.test(n()))break;let r=n().match(/^subgraph\b[ \t]*/);if(r){let n=e.slice(t+r[0].length).match(ht)?.[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 St(e,t,n){return e?.nodes.find(e=>e.id===t)??(n?e?.nodes.find(e=>e.label===n):void 0)}function Ct(e,t){let n=t=>p(St(e,t)?.label??t,40);return`${n(t.from)} → ${n(t.to)}`}var wt=e=>`Only diagrams have nodes and arrows; ${ve(e)}.`,Tt={type:`diagram`,label:`Diagram`,defaultSize:{w:440,h:320},fromSnapshot:e=>({source:e.source}),pins:{anchor:G.anchor,part:G.part,parts:{node:{name:e=>`node "${p(e.quote,80)}"`,lost:`node removed`,drawn:!0,askedTo:`change the diagram's source`,where:e=>` (id ${e.anchor.nodeId})`,missing:wt},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:wt}},place(e,t){let{anchor:n}=t;if(n.kind===`node`){let t=St(xt(e.source),n.nodeId,n.label);return t?{kind:`node`,nodeId:t.id}:null}if(n.kind!==`arrow`)return;let r=xt(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}},...G},Et={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:G.anchor,parts:{line:{...ut,missing:e=>`Lines are pinned in diffs and code blocks; ${ve(e)}.`}},place(e,t){if(t.anchor.kind!==`line`)return;let n=Ie(e.files,t.anchor.file,t.anchor.side,t.anchor.line,t.quote);return n&&{kind:`line`,...n,side:t.anchor.side}}},...G},Dt={w:380,h:300},Ot={w:26,h:78},kt=1100;function At(e){return e.width>=1600?e.width/2:e.width}function jt(e,t){return{w:Math.round(t+Ot.w),h:Math.round(t*e.height/e.width+Ot.h)}}function Mt(e){return jt(e,At(e))}function Nt(e,t={}){if(!e||!(e.width>0)||!(e.height>0))return Dt;if(t.w!==void 0&&t.h===void 0)return jt(e,Math.max(1,t.w-Ot.w));if(t.h!==void 0&&t.w===void 0)return{w:jt(e,Math.max(1,t.h-Ot.h)*e.width/e.height).w,h:Math.round(t.h)};let n=Dt.w-Ot.w,r=Math.min(Math.max(At(e),n),kt-Ot.w),i=kt-Ot.h;return r*e.height/e.width>i&&(r=Math.max(n,i*e.width/e.height)),jt(e,r)}var Pt=e=>String(Math.round(e*1e3)/1e3),Ft={type:`image`,label:`Image`,defaultSize:Dt,untitled:e=>e.caption?`image "${p(e.caption,40)}"`:void 0,refText:e=>[e.caption],sizeFor:(e,t)=>e.naturalWidth&&e.naturalHeight?Nt({width:e.naturalWidth,height:e.naturalHeight},t):Dt,fromSnapshot:(e,t)=>({assetId:e.assetId,caption:e.caption,...t.type===`image`&&t.assetId===e.assetId?{}:{naturalWidth:void 0,naturalHeight:void 0}}),pins:{anchor:G.anchor,part:G.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 ${Pt(e.x)}, y ${Pt(e.y)}, w ${Pt(e.w)}, h ${Pt(e.h)})`,missing:e=>`Boxes are drawn on images; ${ve(e)}.`}},place:(e,t)=>t.anchor.kind===`box`?{...t.anchor}:void 0},...G},It=e=>({method:`GET`,path:e}),K=e=>({method:`POST`,path:e}),Lt=e=>({method:`DELETE`,path:e});function Rt(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 zt={token:K(`/api/connectors/figma/token`),file:It(`/api/connectors/figma/files/:fileId`),bringIn:K(`/api/connectors/figma/frames`),refresh:K(`/api/connectors/figma/images/:blockId/refresh`)},Bt=`file_content:read`,Vt=`file_comments:read`,Ht=`allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox`,Ut=`${Ht} allow-presentation`,Wt={file:`Figma file`,design:`Figma design`,proto:`Figma prototype`},Gt={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(Wt,t[0]??``)&&/^[A-Za-z0-9]+$/.test(t[1]??``)?Wt[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:Ht,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}},Kt=/^[A-Za-z0-9]{6,64}$/,qt=/^(\d{1,12})[-:](\d{1,12})$/;function Jt(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||!Kt.test(r))return null;let i=qt.exec(t.searchParams.get(`node-id`)??``);return i?{fileKey:r,nodeId:`${i[1]}:${i[2]}`}:{fileKey:r}}function Yt(e){return e.nodeId?`${e.fileKey}:${e.nodeId}`:e.fileKey}var Xt={w:400,h:260},Zt={id:`figma`,hosts:Gt.hosts,read(e,t){let n=Jt(e.href),r=n&&Gt.read(e,t);return r?{...r,fileId:Yt(n),card:Xt}:null}},Qt={id:`figma`,name:`Figma`,scopes:{[Bt]:{label:`See the Figma files your token can open, and their frames as pictures`,agent:`Figma frames`},[Vt]:{label:`Read the comments on those files`,agent:`Figma comments`}},identity:{scopes:[],email:[]},sources:[Zt],routes:zt,agent:G.agent},$t={device:It(`/api/connectors/github/device`),startDevice:K(`/api/connectors/github/device/start`),pollDevice:K(`/api/connectors/github/device/poll`),cancelDevice:K(`/api/connectors/github/device/cancel`),token:K(`/api/connectors/github/token`),repos:It(`/api/connectors/github/repos`),card:It(`/api/connectors/github/cards/:owner/:repo/:kind/:number`),showChanges:K(`/api/connectors/github/blocks/:blockId/diff`),bringInFile:K(`/api/connectors/github/blocks/:blockId/file`)},en=`github:contents`,tn=`github:pull_requests`,nn=`github:issues`,rn=`github:checks`,an=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`]),on={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)||an.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`}}},sn=/^#L(\d+)(?:C\d+)?(?:-L(\d+)(?:C\d+)?)?$/;function cn(e){try{return decodeURIComponent(e)}catch{return e}}function ln(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(!on.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=sn.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(cn),...a?{lines:a}:{}}}return null}var un=e=>`${e.owner}/${e.repo}/${e.kind}/${e.number}`,dn={w:400,h:100},fn={id:`github`,hosts:on.hosts,read(e,t){let n=on.read(e,t);if(!n)return null;let r=ln(e.href);return r?r.kind===`file`?{...n,name:r.refPath.slice(1).join(`/`)||n.name}:{...n,fileId:un(r),card:dn}:n}},pn={id:`github`,name:`GitHub`,scopes:{[en]:{label:`See the files in the repositories Tricot is installed on`,agent:`files`},[tn]:{label:`See pull requests and what they change`,agent:`pull requests`},[nn]:{label:`See issues`,agent:`issues`},[rn]:{label:`See check results and commit statuses`,agent:`checks`}},identity:{scopes:[],email:[]},sources:[fn],routes:$t,agent:G.agent};function mn(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 hn={file:It(`/api/connectors/google/files/:fileId`),picker:K(`/api/connectors/google/picker`),chosen:K(`/api/connectors/google/chosen`),doc:It(`/api/connectors/google/docs/:blockId`),docDraft:K(`/api/connectors/google/docs/:blockId/draft`),docDiscard:K(`/api/connectors/google/docs/:blockId/discard`),docSave:K(`/api/connectors/google/docs/:blockId/save`),docPins:K(`/api/connectors/google/docs/:blockId/pins`),docResolve:K(`/api/connectors/google/docs/:blockId/resolve`)},gn=`https://www.googleapis.com/auth/drive.file`,_n=`https://www.googleapis.com/auth/drive.metadata.readonly`,vn=`https://www.googleapis.com/auth/userinfo.email`,yn=`https://www.googleapis.com/auth/documents`,bn=`Google won't show this inside the board in this browser. Open it in Google, or publish it to view here read-only.`,xn={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`}},Sn={id:`google`,hosts:[`docs.google.com`],embeds:`Google Docs, Sheets and Slides`,read(e,t){let n=Object.hasOwn(xn,t[0]??``)?xn[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:Ht,referrer:`no-referrer`,size:n.size,blocked:bn}}}},Cn={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`},[vn]:{label:`See your email address`,agent:`email address`},[gn]:{label:`See and edit the Google Docs you choose, and only those`,agent:`Google Docs people choose`},[_n]:{label:`See the names of your Drive files and when they were last edited`,agent:`Drive file names and dates`},[yn]:{label:`See and edit your Google Docs`,agent:`Google Docs, read and write`}},identity:{scopes:[`openid`,`email`,vn],email:[`email`,vn]},sources:[Sn],routes:hn,pins:{kind:`doc`,place:mn,name:e=>`"${p(e.quote,80)}"`,quote:e=>`“${e.quote}”`,lost:`paragraph removed`,askedTo:`edit the draft`,anchor:G.pins?.anchor,where:G.pins?.where,label:G.pins?.label,missing:G.pins?.missing,seen:G.pins?.seen,ask:G.pins?.ask},agent:G.agent,link:G.link,store:G.store},wn={key:K(`/api/connectors/linear/key`),issue:It(`/api/connectors/linear/issues/:identifier`)},Tn=`read`,En=/^[A-Za-z][A-Za-z0-9]{0,9}-\d{1,9}$/;function Dn(e){let t=e.trim();return En.test(t)?t.toUpperCase():null}function On(e){return e[1]===`issue`?Dn(e[2]??``):null}var kn={w:400,h:100},An={id:`linear`,hosts:[`linear.app`],read(e,t){let n=On(t);return n?{kind:`Linear`,what:`issue`,ref:n,name:n,site:`Linear`,mark:`linear`,fileId:n,card:kn}:null}},jn={id:`linear`,name:`Linear`,scopes:{[Tn]:{label:`See the issues, projects and teams your Linear account can see`,agent:`issues`}},identity:{scopes:[],email:[]},sources:[An],routes:wn,agent:G.agent},Mn={thread:It(`/api/connectors/slack/threads/:channel/:ts`),shareDecision:K(`/api/connectors/slack/decisions/:decisionId/share`)},Nn=`channels:history`,Pn=`groups:history`,Fn=`users:read`,In=`chat:write`,Ln=[`*.slack.com`],Rn=/^[CGD][A-Z0-9]{7,14}$/,zn=/^\d{10}\.\d{6}$/,Bn=/^p(\d{10})(\d{6})$/,Vn=/^[a-z0-9][a-z0-9.-]*$/,Hn=new Set([`app`,`api`,`files`,`hooks`,`status`,`join`,`edgeapi`,`slackb`,`www`]);function Un(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(!Vn.test(r)||Hn.has(r))return null;let[i,a,o,...s]=t.pathname.split(`/`).filter(Boolean);return i!==`archives`||!a||!Rn.test(a)?null:{url:t,channel:a,message:o,more:s.length>0}}function Wn(e){let t=Un(e),n=Bn.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&&zn.test(i)&&i!==r?i:void 0;return{channel:t.channel,ts:r,...a?{threadTs:a}:{}}}var Gn=e=>`${e.channel}/${e.threadTs??e.ts}`;function Kn(e){let t=e.trim();return Rn.test(t)?t:Un(t)?.channel??null}var qn={w:400,h:170},Jn={id:`slack`,hosts:Ln,read(e){let t=Wn(e.href);return t?{kind:`Slack`,what:t.threadTs?`thread`:`message`,name:`Slack thread`,site:`Slack`,mark:`slack`,fileId:Gn(t),card:qn}:null}},Yn={id:`slack`,name:`Slack`,scopes:{[Nn]:{label:`Read the messages in the public channels whose threads you link`,agent:`threads in public channels`},[Pn]:{label:`Read the messages in the private channels whose threads you link`,agent:`threads in private channels`},[Fn]:{label:`See people's names, to say who wrote a message`,agent:`who wrote them`},[In]:{label:`Post a message as you, only when you share a decision`,agent:`posting by people only`}},identity:{scopes:[],email:[]},sources:[Jn],routes:Mn,agent:G.agent},Xn=()=>[Cn,Qt,pn,Yn,jn],Zn;function Qn(){return Zn??=Xn()}function $n(e){return Qn().find(t=>t.pins?.kind===e)}var er={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:Ut,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 tr(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 nr={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=tr(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:Ut,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.`}}}},rr=()=>[...Qn().flatMap(e=>(e.sources??[]).map(t=>({source:t,connector:e.id}))),...[Gt,nr,er,on].map(e=>({source:e}))],ir;function ar(){return ir??=rr()}function or(e,t){return e.some(e=>e.startsWith(`*.`)?t.endsWith(e.slice(1)):e===t)}function sr(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 ar()){if(!or(e.hosts,n))continue;let a=e.read(t,r);if(a)return i?{...a,connector:i}:a}return null}function cr(e){return e.what?`${e.kind} ${e.what}`:e.kind}var lr={w:300,h:90};function ur(e){let t=sr(e);return t?t.card?t.card:{w:t.editable?480:400,h:lr.h}:lr}function dr(e){let t;try{t=new URL(e.trim())}catch{return null}return t.protocol===`http:`||t.protocol===`https:`?t.href:null}function fr(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function pr(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 mr={type:`link`,label:`Link`,defaultSize:lr,untitled:e=>`link "${p(pr(e.url),50)}"`,sizeFor:e=>ur(e.url),fromSnapshot:e=>({url:e.url}),pins:{anchor:G.anchor,place:(e,t)=>$n(t.anchor.kind)?.pins?.place(e,t),whole:{word:`card`,quote:e=>pr(e.url)}},...G},hr=class extends Error{code;constructor(e,t=`invalid`){super(e),this.code=t}},gr=2e5,_r=5e3,vr=64,yr=256,br=32,xr=1e4,Sr=[`Scene`,`Group`,`Object3D`,`Mesh`,`InstancedMesh`,`SkinnedMesh`,`Bone`,`LOD`,`Line`,`LineLoop`,`LineSegments`,`Points`,`Sprite`,`AmbientLight`,`DirectionalLight`,`HemisphereLight`,`PointLight`,`SpotLight`,`RectAreaLight`,`LightProbe`,`PerspectiveCamera`,`OrthographicCamera`],Cr=new Set([`Mesh`,`InstancedMesh`,`SkinnedMesh`,`Line`,`LineLoop`,`LineSegments`,`Points`]),wr=[`BoxGeometry`,`CapsuleGeometry`,`CircleGeometry`,`ConeGeometry`,`CylinderGeometry`,`DodecahedronGeometry`,`EdgesGeometry`,`ExtrudeGeometry`,`IcosahedronGeometry`,`LatheGeometry`,`OctahedronGeometry`,`PlaneGeometry`,`PolyhedronGeometry`,`RingGeometry`,`ShapeGeometry`,`SphereGeometry`,`TetrahedronGeometry`,`TorusGeometry`,`TorusKnotGeometry`,`TubeGeometry`,`WireframeGeometry`,`BufferGeometry`],Tr=[`MeshStandardMaterial`,`MeshPhysicalMaterial`,`MeshBasicMaterial`,`MeshLambertMaterial`,`MeshPhongMaterial`,`MeshToonMaterial`,`MeshNormalMaterial`,`MeshMatcapMaterial`,`MeshDepthMaterial`,`MeshDistanceMaterial`,`LineBasicMaterial`,`LineDashedMaterial`,`PointsMaterial`,`SpriteMaterial`,`ShadowMaterial`],Er=new Set([`ShaderMaterial`,`RawShaderMaterial`]),Dr=[`color`,`emissive`,`specular`,`sheenColor`,`specularColor`,`attenuationColor`],Or=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,kr=/^data:image\/(?:png|jpeg|gif|webp|avif);base64,/i,Ar=/^(?:[a-z][a-z0-9+.-]*:\/\/|\/\/)/i,jr=`{"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]}]}}`,Mr=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Nr=e=>Array.isArray(e)?e:[],Pr=e=>`"${p(String(e),40)}"`,Fr=e=>`${e.slice(0,6).join(`, `)}${e.length>6?` …`:``}`,Ir=(e,t)=>typeof e.name==`string`&&e.name?`Object ${Pr(e.name)}`:`The ${String(e.type??`object`)} at ${t}`,Lr=(e,t,n)=>`${t} ${typeof e.uuid==`string`?Pr(e.uuid):n+1}`,Rr=new Map;function zr(e){let t=Rr.get(e);if(t)return t;if(!e.trim())throw new hr(`A scene needs its three.js JSON, as Object3D.toJSON() writes it.`);if(e.length>2e5)throw new hr(`A scene holds up to ${gr.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 hr(`The scene isn't valid JSON: ${e.message.replace(/\.$/,``)}.`)}let r=Mr(n);if(!r)throw new hr(`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=Br(r);Rr.size>=16&&Rr.delete(Rr.keys().next().value);let a={json:r,facts:i};return Rr.set(e,a),a}function Br(e){let t=Mr(e.metadata)?.type;if(t!==void 0&&t!==`Object`)throw new hr(`The scene's metadata says it is ${Pr(t)}; a scene is "Object", as Object3D.toJSON() writes it.`);Vr(e);let n=new Set;Nr(e.geometries).forEach((e,t)=>{let r=Mr(e);if(!r||typeof r.uuid!=`string`||!r.uuid)throw new hr(`Geometry ${t+1} needs a uuid: meshes name their geometry by it.`);if(!wr.includes(r.type))throw new hr(`${Lr(r,`Geometry`,t)} has type ${Pr(r.type)}: a geometry is one of ${Fr(wr)} or BufferGeometry.`);for(let[e,n]of Object.entries({...r,...Mr(r.options)})){let i=/detail/i.test(e)?br:/segments|steps/i.test(e)?yr:1/0;if(typeof n==`number`&&n>i)throw new hr(`${Lr(r,`Geometry`,t)} asks for ${n} ${e}; at most ${i} are drawn.`)}n.add(r.uuid)});let r=new Set;Nr(e.materials).forEach((e,t)=>{let n=Mr(e);if(!n||typeof n.uuid!=`string`||!n.uuid)throw new hr(`Material ${t+1} needs a uuid: meshes name their material by it.`);if(Er.has(n.type))throw new hr(`${Lr(n,`Material`,t)} is a ${n.type}: the board doesn't run shader code. Use MeshStandardMaterial or another built-in material.`);if(!Tr.includes(n.type))throw new hr(`${Lr(n,`Material`,t)} has type ${Pr(n.type)}: a material is one of ${Fr(Tr)}.`);for(let e of Dr){let r=n[e];if(!(r===void 0||Number.isInteger(r)&&r>=0&&r<=16777215||typeof r==`string`&&Or.test(r)))throw new hr(`${Lr(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 Nr(e.images)){let e=Mr(t);for(let t of[e?.url].flat())if(typeof t==`string`&&!kr.test(t))throw new hr(`The scene's picture ${Pr(t)} isn't embedded, and the board fetches nothing from elsewhere: give it as a data: URL (data:image/png;base64,…).`)}let i=Mr(e.object);if(!i)throw new hr(`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:Nr(e.textures).length,animations:Nr(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=Mr(e);if(!s)throw new hr(`${t} isn't an object: each child is { "type": …, … }.`);if(i>vr)throw new hr(`The scene nests objects more than ${vr} deep.`);if(++a.objects>_r)throw new hr(`A scene holds up to ${_r.toLocaleString(`en-US`)} objects.`);let c=s.type;if(!Sr.includes(c))throw new hr(`${Ir(s,t)} has type ${Pr(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 hr(`${Ir(s,t)} has ${e} ${p(JSON.stringify(n),40)}: it is [x, y, z].`)}if(c===`InstancedMesh`&&!(Number.isInteger(s.count)&&s.count>=0&&s.count<=xr))throw new hr(`${Ir(s,t)} has count ${p(JSON.stringify(s.count),20)}: an InstancedMesh draws from 0 to ${xr.toLocaleString(`en-US`)} copies.`);if(Cr.has(c)&&!n.has(s.geometry))throw new hr(`${Ir(s,t)} uses geometry ${Pr(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 hr(`${Ir(s,t)} uses material ${Pr(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 hr(`${Ir(s,t)} has children that aren't a list.`);let l=Nr(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 Vr(e){let t=[e];for(;t.length>0;){let e=t.pop();if(typeof e==`string`){if(Ar.test(e))throw new hr(`The scene names ${Pr(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 Hr(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 Ur=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function Wr(e){let t=[Ur(e.meshes,`mesh`,`meshes`),e.lights&&Ur(e.lights,`light`),e.cameras&&Ur(e.cameras,`camera`)],n=[Ur(e.geometries,`geometry`,`geometries`),Ur(e.materials,`material`),e.textures&&Ur(e.textures,`texture`),e.animations&&Ur(e.animations,`animation`)];return`${Ur(e.objects,`object`)}: ${t.filter(Boolean).join(`, `)}; ${n.filter(Boolean).join(`, `)}`}function Gr(e,t){return Math.max(0,...e.flatMap(e=>e.blockId===t&&e.anchor.kind===`spot`?[e.anchor.n]:[]))+1}var Kr=(e,t)=>`spot ${e}${t?` on "${p(t,60)}"`:``}`;function qr(e){if(e.includes(`
|
|
13
|
-
`))return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Jr(e){try{return zr(e).facts}catch{return}}var Yr={type:`scene`,label:`3D scene`,defaultSize:{w:460,h:400},untitled:e=>{let t=Jr(e.scene)?.named[0];return t?`scene "${p(t.name,40)}"`:void 0},fromSnapshot:e=>({scene:e.scene}),pins:{anchor:G.anchor,part:G.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; ${ve(e)}.`}},place(e,t){if(t.anchor.kind!==`spot`)return;if(t.anchor.name===void 0)return{...t.anchor};let n=Jr(e.scene);return n&&Hr(n,t.anchor.object,t.anchor.name)?{...t.anchor}:null}},...G},Xr={w:520,h:420};function Zr(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 Qr(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 $r(e){if(e.folder)return`folder ${e.folder}`;try{return`dev server ${new URL(e.url??``).host}`}catch{return`no source`}}function ei(e,t){return e.pages?.find(e=>e.path===t)?.title}var ti={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 ni(e){return ti[e.toLowerCase()]??`element`}function ri(e){return e.replace(/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069]/g,` `).replace(/["“”„‟«»〝〞"]/g,`'`).replace(/\s+/g,` `).trim()}function ii(e){return p(ri(e),160)}var ai=`(?:#[A-Za-z][\\w-]{0,99}|[a-z][a-z\\d-]{0,40}(?::nth-of-type\\([1-9]\\d{0,4}\\))?)`;RegExp(`^${ai}(?: > ${ai}){0,40}$`);function oi(e,t,n){let r=ii(t);return r?`${ni(e)} “${p(r,80)}”`:`${ni(e)} ${p(n,80)}`}function si(e,t){return e?t?`${e}, line ${t}`:e:``}var ci={type:`site`,label:`Website`,defaultSize:Xr,untitled:e=>`site "${p(Qr(e),50)}"`,fromSnapshot:e=>({...e.folder?{folder:e.folder}:{url:e.url},page:e.page}),pins:{anchor:G.anchor,part:G.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})=>` (${p(e.selector,100)}${e.file?`; ${si(p(e.file,120),e.line)}`:``})`,missing:e=>`Elements are pinned on websites; ${ve(e)}.`}},place:(e,t)=>t.anchor.kind===`site`?{kind:`site`,page:t.anchor.page,selector:t.anchor.selector}:void 0},...G},li={type:`note`,label:`Note`,defaultSize:{w:300,h:200},untitled:e=>e.text.trim()?`note "${p(e.text,40)}"`:void 0,refText:e=>[e.text],fromSnapshot:e=>({text:e.text}),pins:{anchor:G.anchor,part:G.part,parts:{text:{name:e=>`"${p(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; ${ve(e)}.`}},place(e,t){if(t.anchor.kind!==`text`)return;let n=wo(Co(e.text),t.quote,t.anchor);return n&&{kind:`text`,...n}}},...G};function ui(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 di(e,t){let n=null;if(t.columns){let r=t.columns[1]-t.columns[0]+1,i=ui(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=ui(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 fi={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:G.anchor,part:G.part,parts:{cells:{lost:`cells changed`,drawn:!0,askedTo:`change the table`,missing:e=>`Only tables have cells; ${ve(e)}.`}},place:(e,t)=>t.anchor.kind===`cells`?di(e,t.anchor):void 0},...G},pi=()=>[li,fi,Ft,Tt,ft,mr,Et,dt,xe,Yr,ci],mi;function hi(){return mi??=pi()}function gi(e){return hi().find(t=>t.type===e)}function _i(e){let t=gi(e);if(!t)throw Error(`Unknown block type "${e}".`);return t}var vi=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} "${p(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 ki({kind:this.kind.kind,id:this.id})}},yi=[],bi=()=>yi,xi=e=>yi.find(t=>t.kind===e),Si=(e,t)=>e[t.list]??[];function Ci(e,t){let n=xi(t);return n?Si(e,n).map(e=>new vi(n,e)):[]}function wi(e){return yi.flatMap(t=>Si(e,t).map(e=>new vi(t,e)))}function Ti(e,t,n){let r=xi(t),i=r&&Si(e,r).find(e=>e.id===n);return r&&i?new vi(r,i):void 0}function Ei(e,t){for(let n of yi){let r=Si(e,n).find(e=>e.id===t);if(r)return new vi(n,r)}}function Di(e,t){let n=t;for(let t of yi){let r=n[`${t.kind}Id`];if(typeof r==`string`&&r)return Ti(e,t.kind,r)}}function Oi(e){let t=e;return bi().flatMap(({kind:e})=>{let n=t[`${e}Id`];return typeof n==`string`&&n?[{kind:e,id:n}]:[]})}var ki=({kind:e,id:t})=>({[`${e}Id`]:t}),Ai=e=>Oi(e);function ji(e){let t=e;for(let e of yi){let n=t[e.kind];if(n)return new vi(e,n)}}function Mi(e,t){let n=e[`${t}Id`];return typeof n==`string`&&n?n:void 0}function Ni(e,t){let n=$n(e)?.pins;if(n)return n;let r=e;return(t&&_i(t.type).pins?.parts?.[r])??hi().find(e=>e.pins?.parts?.[r])?.pins?.parts?.[r]}var Pi=`TRICOT_TOKEN`,Fi=e=>e?`powershell`:`posix`,Ii=/^[\w@%+:,./-][\w@%+=:,./-]*$/,Li=/[$`\\"!]/,Ri=/^[\w+:./\\-][\w+=:./\\@-]*$/,zi=/['‘’‚‛]/g,Bi=e=>`'${e.replace(zi,e=>e+e)}'`;function Vi(e,t=`posix`){return t===`powershell`?Ri.test(e)?e:Bi(e):Ii.test(e)?e:Li.test(e)?`'${e.replaceAll(`'`,`'\\''`)}'`:`"${e}"`}function Hi(e,t=`posix`){let n=e.map(e=>Vi(e,t)).join(` `);return t===`powershell`&&n.startsWith(`'`)?`& ${n}`:n}function Ui(e,t,n=`posix`){return n===`powershell`?`$env:${e} = ${Bi(t)}`:`export ${e}=${Vi(t)}`}function Wi(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 Gi(e,t=`posix`){return Ui(Pi,e,t)}function Ki(e,{token:t,scope:n=`user`}={}){return[`claude`,`mcp`,`add`,`--scope`,n,`--transport`,`http`,`tricot`,e,...t?[`--header`,`Authorization: Bearer ${t}`]:[]]}function qi(e,t={}){return Hi(Ki(e,t),t.shell)}function Ji(e,t,n){return t?[Gi(t,n),Hi(e,n)]:[Hi(e,n)]}function Yi(e,t){let n=[`codex`,`mcp`,`add`,`tricot`,`--url`,e];return t?[...n,`--bearer-token-env-var`,Pi]:n}function Xi(e,t,n){return Ji(Yi(e,t),t,n)}function Zi(e,t){let n=[`pi`,`mcp`,`add`,`tricot`,`--url`,e];return t?[...n,`--bearer-token-env-var`,Pi]:n}function Qi(e,t,n){return Ji(Zi(e,t),t,n)}var $i=3e5;function ea(e,t){return{type:`http`,url:e,timeout:$i,...t?{headers:{Authorization:`Bearer \${${Pi}}`}}:{}}}var ta=`~/.omp/agent/mcp.json`;function na(e,t){let n=[`gemini`,`mcp`,`add`,`--scope`,`user`,`--transport`,`http`];return t?[...n,`--header`,`Authorization: Bearer \${${Pi}}`,`tricot`,e]:[...n,`tricot`,e]}function ra(e,t,n){return Ji(na(e,t),t,n)}function ia(e,t){let n=[`grok`,`mcp`,`add`,`--scope`,`user`,`--transport`,`http`];return t?[...n,`--header`,`Authorization: Bearer \${${Pi}}`,`tricot`,e]:[...n,`tricot`,e]}function aa(e,t,n){return Ji(ia(e,t),t,n)}var oa=`~/.copilot/mcp-config.json`;function sa(e,t){let n=[`copilot`,`mcp`,`add`,`--transport`,`http`,`--timeout`,String($i)];return t?[...n,`--header`,`Authorization: Bearer \${${Pi}}`,`tricot`,e]:[...n,`tricot`,e]}function ca(e,t,n){return Ji(sa(e,t),t,n)}function la(e,t){return{type:`remote`,url:e,timeout:$i,...t?{headers:{Authorization:`Bearer {env:${Pi}}`}}:{}}}var ua=`~/.config/opencode/opencode.json`,da=`~/.config/goose/config.yaml`,fa=`%APPDATA%\\Block\\goose\\config\\config.yaml`;function pa(e,t){return{name:`tricot`,type:`streamable_http`,uri:e,enabled:!0,timeout:$i/1e3,...t?{env_keys:[Pi],headers:{Authorization:`Bearer \${${Pi}}`}}:{}}}var ma=`~/.hermes/config.yaml`;function ha(e,t){return{url:e,timeout:$i/1e3,...t?{headers:{Authorization:`Bearer \${${Pi}}`}}:{}}}var ga=`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".`,_a={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`,ultra:`Ultra`,auto:`Auto`},va=(...e)=>e.map(e=>({id:e,label:_a[e]??e})),ya=/[\u0000-\u001f\u007f-\u009f]/;function ba(e){if(ya.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 xa=(e,t)=>(e.model??``)===(t.model??``)&&(e.effort??``)===(t.effort??``),Sa=(e,t)=>e.startsOn?.models.find(e=>e.id===t)?.label??t,Ca=(e,t)=>e.startsOn?.levels?.find(e=>e.id===t)?.label??t;function wa(e,t){if(!t.model&&!t.effort)return;let n=t.model?Sa(e,t.model):`Default`;return t.effort?`${n} · ${Ca(e,t.effort).toLowerCase()}`:n}function Ta(e,t,n){if(!t)return;let r=wa(e,t)??`its own settings`;return xa(t,n)?`Running on ${r}`:`On ${r} till it restarts`}var Ea={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)=>Ki(e,{token:t}),lines:(e,t,n)=>[qi(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:va(`low`,`medium`,`high`,`xhigh`,`max`)},perMessage:{via:`subagent`,models:[`opus`,`sonnet`,`haiku`,`fable`]},skills:`skills`,approvals:!0,...G},Da={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:Yi,lines:Xi,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:va(`low`,`medium`,`high`,`xhigh`,`max`,`ultra`)},skills:`prompts`,approvals:!0,...G},Oa={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:sa,lines:ca,settings:oa,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:va(`low`,`medium`,`high`,`xhigh`,`max`)},skills:`skills`,...G},ka=/^[A-Za-z][\w-]*$/,Aa=new Set([`true`,`false`,`null`,`yes`,`no`,`on`,`off`,`y`,`n`]),ja=e=>typeof e==`object`&&!!e;function Ma(e){if(typeof e==`string`)return ka.test(e)&&!Aa.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 Na=e=>ka.test(e)&&!Aa.has(e.toLowerCase())?e:JSON.stringify(e),Pa=e=>Array.isArray(e)?e.length===0:Object.values(e).every(e=>e===void 0);function Fa(e,t){let n=` `.repeat(t);return Array.isArray(e)?e.flatMap(e=>{if(!ja(e)||Pa(e))return[`${n}- ${Ia(e)}`];let[r,...i]=Fa(e,t+2);return[`${n}- ${r.slice(t+2)}`,...i]}):Object.entries(e).flatMap(([e,r])=>r===void 0?[]:!ja(r)||Pa(r)?[`${n}${Na(e)}: ${Ia(r)}`]:[`${n}${Na(e)}:`,...Fa(r,t+2)])}function Ia(e){return ja(e)?Array.isArray(e)?`[]`:`{}`:Ma(e)}function La(e){return ja(e)&&!Pa(e)?Fa(e,0).join(`
|
|
14
|
-
`):Ia(e)}function Ra(e,t){let n={[e.section]:{[e.name]:t}};return`${e.format===`json`?JSON.stringify(n,null,2):za(n).join(`
|
|
15
|
-
`)}\n`}var za=e=>La(e).split(`
|
|
16
|
-
`),Ba=`tricot`;function Va(e){let t={format:e.format,section:e.section,name:Ba};return{how:`file`,...e,entry:(n,r)=>Ra(t,e.value(n,r)).trimEnd()}}var Ha={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:Va({file:`~/.cursor/mcp.json`,format:`json`,section:`mcpServers`,value:(e,t)=>({url:e,...t?{headers:{Authorization:`Bearer \${env:${Pi}}`}}:{}})}),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,...G},Ua={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:na,lines:ra,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`,...G},Wa={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:Va({file:da,format:`yaml`,section:`extensions`,value:pa,agentWrites:!0}),panel:{intro:[`Goose has no command for this: `,{code:`goose configure`},` only asks questions. Add the entry under `,{code:`extensions`},` in `,{code:da},` (merge it in if the file exists; on Windows the file is `,{code:fa},`). 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`,...G},Ga={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:ia,lines:aa,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`,...G},Ka={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:Va({file:ma,format:`yaml`,section:`mcp_servers`,value:ha,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:ma},` (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`,...G},qa={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:Va({file:ta,format:`json`,section:`mcpServers`,value:ea}),panel:{intro:[`OMP has no command for this. Add the entry to `,{code:ta},` (merge it into `,{code:`mcpServers`},` if the file exists), or to `,{code:`.omp/mcp.json`},` for one project.`],note:[ga],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:va(`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`auto`)},skills:`skills`,...G},Ja={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:Va({file:ua,format:`json`,section:`mcp`,value:la}),panel:{intro:[`Add the entry to `,{code:ua},` (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`,...G},Ya={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:Zi,lines:Qi,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:va(`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`)},skills:`skills`,...G},Xa=()=>[Ea,Da,Ya,qa,Ua,Ja,Wa,Ka,Ga,Oa,Ha],Za;function Qa(){return Za??=Xa()}function $a(e){return Qa().find(t=>t.id===e)}var eo=()=>Qa()[0];function to(e){return(e.tool?$a(e.tool):void 0)??Qa().find(t=>m(t.boardName,e.name))}var no=e=>Qa().find(t=>t.usage.source===e),ro=`other`;function io(e,t){let n={[ro]:e};for(let{id:r,boardName:i,connect:a}of Qa()){let o=Wi(e,i);n[r]=a.how===`command`?a.lines(o,void 0,t).join(`
|
|
17
|
-
`):a.entry(o)}return n}function ao(e){return(e.pages??[]).filter(e=>!oo(e)).sort((e,t)=>e.rank-t.rank)}var oo=e=>e.files===!0,so=e=>e.pages?.find(oo);function co(e){if(!e)return;if(!e.asked)return`Made by ${e.name}`;let t=e.tool?$a(e.tool)?.name:void 0;return`${t?`Asked in ${t}`:`Asked of ${e.name}`}: “${e.asked}”`}function lo(e,t){let n=e?.agent?.name;return!n||t?.agent?t??null:{...t??{name:`General`},agent:n}}function uo(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 fo=32,po=new Set([`*`,`_`,"`",`~`]);function mo(e){let t=``,n=[],r=!0;for(let i=0;i<e.length;i++){let a=e[i];if(po.has(a))continue;let o=/\s/.test(a);o&&r||(r=o,t+=o?` `:a,n.push(i))}return{text:t,from:n}}function ho(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 go(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function _o(e){return e.replace(/\s+/g,` `).trim()}function vo(e,t,n={}){let r=mo(t).text.trim();if(!r)return null;let i=mo(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-fo),e),n=i.text.slice(e+r.length,e+r.length+fo),u=ho(t,a)+go(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 yo(e,t,n){let r=_o(e.slice(t,n));if(!mo(r).text.trim())return null;let i=mo(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-fo),a),suffix:i.text.slice(o+1,o+1+fo)}}var bo={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:` `,copy:`©`,reg:`®`,trade:`™`,hellip:`…`,mdash:`—`,ndash:`–`,larr:`←`,rarr:`→`};function xo(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)?bo[t]??e:n>0&&n<=1114111?String.fromCodePoint(n):e}function So(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,xo)}function Co(e){return So(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 wo(e,t,n={}){let r=vo(e,t,n);if(r)return r;let i=So(t);return i===t?null:vo(e,i,n)}function To(e,t){return t.anchor.kind===`block`?{kind:`block`}:_i(e.type).pins?.place?.(e,t)??null}function Eo(e){return e&&_i(e.type).pins?.whole?.word||`block`}function Do(e,t){return e.anchor.kind===`block`?`the whole ${Eo(t)}`:Ni(e.anchor.kind,t)?.name?.(e)??e.quote}function Oo(e,t){if(e.anchor.kind===`block`)return`${e.quote} · the whole ${Eo(t)}`;let n=Ni(e.anchor.kind,t)?.quote;if(n)return n(e);let r=t?t.title||_i(t.type).label:``,i=Do(e,t);return r?`${r} · ${i}`:i}function ko(e,t){return Ni(e.anchor.kind,t)?.lost??`text changed`}function Ao(e,t,n){if(e.kind!==t.kind)return!1;let r=Ni(e.kind,n)?.same;return r?r(e,t):JSON.stringify(e)===JSON.stringify(t)}function jo(e,t){if(t.discussion)return null;let n=Di(e,t);return n?{ref:n.label,status:n.statusWord??``,title:n.title,done:n.settled}:null}function Mo(e){return[{canvas:e.canvas},...wi(e).map(e=>({canvas:e.canvas,[e.kind.kind]:e.card})),...(e.pages??[]).map(e=>({canvas:e.canvas,page:e}))]}function No(e){return[{canvas:e.canvas},...(e.pages??[]).map(e=>({canvas:e.canvas,page:e}))]}function Po(e,t){if(t)for(let n of No(e)){let e=n.canvas.pins.find(e=>e.id===t);if(e)return{...n,pin:e}}}function Fo(e,t){if(!e.discussion)return[];let n=ji(t);return n?n.comments.filter(t=>t.pin?.id===e.id):e.discussion.thread??[]}var q={info:It(`/api/info`),chooseFolder:K(`/api/folders/choose`),instance:It(`/api/instance`),update:It(`/api/update`),startUpdate:K(`/api/update`),checkForUpdates:K(`/api/update/check`),stop:K(`/api/stop`),boards:It(`/api/boards`),needs:It(`/api/needs`),createBoard:K(`/api/boards`),board:It(`/api/boards/:boardId`),updateBoard:K(`/api/boards/:boardId`),archiveBoard:K(`/api/boards/:boardId/archive`),unarchiveBoard:K(`/api/boards/:boardId/unarchive`),deleteBoard:K(`/api/boards/:boardId/delete`),boardLive:It(`/api/boards/:boardId/live`),boardEvents:It(`/api/boards/:boardId/events`),boardStream:It(`/api/boards/:boardId/stream`),wakes:K(`/api/boards/:boardId/wakes`),listen:K(`/api/boards/:boardId/listen`),boardSearch:It(`/api/boards/:boardId/search`),projectFiles:It(`/api/boards/:boardId/files`),projectFile:It(`/api/boards/:boardId/files/read`),projectImage:It(`/api/boards/:boardId/files/image`),projectFileBlock:K(`/api/boards/:boardId/files/block`),projectFileWrite:K(`/api/boards/:boardId/files/write`),search:It(`/api/search`),requestSync:K(`/api/boards/:boardId/sync`),cancelSync:K(`/api/boards/:boardId/sync/cancel`),askAgents:K(`/api/boards/:boardId/requests`),cancelRequest:K(`/api/boards/:boardId/requests/:requestId/cancel`),boardThreads:It(`/api/boards/:boardId/threads`),startThread:K(`/api/boards/:boardId/threads`),askInGeneral:K(`/api/boards/:boardId/threads/general`),thread:It(`/api/threads/:threadId`),postToThread:K(`/api/threads/:threadId/messages`),setThreadLens:K(`/api/threads/:threadId/lens`),reactToThreadMessage:K(`/api/threads/:threadId/messages/:commentId/reactions`),reactToPinComment:K(`/api/canvas/pins/:pinId/comments/:commentId/reactions`),addPage:K(`/api/boards/:boardId/pages`),updatePage:K(`/api/pages/:pageId`),deletePage:K(`/api/pages/:pageId/delete`),askOnPage:K(`/api/pages/:pageId/requests`),addBlock:K(`/api/canvas/blocks`),updateBlock:K(`/api/canvas/blocks/:id`),deriveBlock:K(`/api/canvas/blocks/:id/chart`),blockVersions:It(`/api/canvas/blocks/:id/versions`),blockVersion:It(`/api/canvas/blocks/:id/versions/:rev`),deleteVersion:K(`/api/canvas/blocks/:id/versions/:rev/delete`),deleteEarlierVersions:K(`/api/canvas/blocks/:id/versions/delete`),restoreBlock:K(`/api/canvas/blocks/:id/restore`),pinComment:K(`/api/canvas/blocks/:id/pins/comment`),pinToCard:K(`/api/canvas/blocks/:id/pins`),commentOnPin:K(`/api/canvas/pins/:id/comments`),resolvePin:K(`/api/canvas/pins/:id/resolve`),moveItems:K(`/api/canvas/move`),pasteBlocks:K(`/api/canvas/paste`),addGroup:K(`/api/canvas/groups`),renameGroup:K(`/api/canvas/groups/:id`),addLink:K(`/api/canvas/links`),relabelLink:K(`/api/canvas/links/:id`),removeItem:K(`/api/canvas/items/:id/delete`),restoreItem:K(`/api/canvas/items/:id/restore`),uploadAsset:K(`/api/assets`),asset:It(`/api/assets/:id`),siteAddress:It(`/api/sites/:blockId`),startPairing:K(`/api/pairing`),pairingBeat:K(`/api/pairing/:id/beat`),endPairing:K(`/api/pairing/:id/end`),stepsStream:It(`/api/steps/stream`),recordStep:K(`/api/agents/:name/steps`),liveSteps:It(`/api/live-steps`),previewLiveSteps:K(`/api/live-steps/:agent/preview`),applyLiveSteps:K(`/api/live-steps/:agent/apply`),agents:It(`/api/agents`),recordUsage:K(`/api/agents/:name/usage`),agentUsage:It(`/api/agents/:name/usage`),toolCosts:It(`/api/tool-costs`),agentRules:It(`/api/agent-rules`),setAgentRule:K(`/api/agent-rules/:agent`),addSkill:K(`/api/skills`),editSkill:K(`/api/skills/:skillId`),deleteSkill:K(`/api/skills/:skillId/delete`),registerHost:K(`/api/approvals/hosts`),hostHeartbeat:K(`/api/approvals/hosts/heartbeat`),hostRelease:K(`/api/approvals/hosts/release`),requestApproval:K(`/api/agents/:name/approvals`),waitForApproval:K(`/api/approvals/:id/wait`),withdrawApproval:K(`/api/approvals/:id/withdraw`),approvals:It(`/api/approvals`),approvalsStream:It(`/api/approvals/stream`),answerApproval:K(`/api/approvals/:id/answer`),askToBeLetIn:K(`/api/seats/admissions`),admission:It(`/api/seats/admissions/:id`),admissions:It(`/api/seats/admissions`),answerAdmission:K(`/api/seats/admissions/:id/answer`),seats:It(`/api/seats`),seatTicket:K(`/api/seats/ticket`),seatBeat:K(`/api/seats/beat`),seatRelease:K(`/api/seats/release`),removeSeat:K(`/api/seats/:id/remove`),takeLease:K(`/api/leases`),beatLease:K(`/api/leases/:id`),releaseLease:Lt(`/api/leases/:id`),connectors:It(`/api/connectors`),startConnector:K(`/api/connectors/:id/start`),connectorCallback:It(`/api/connectors/:id/callback`),disconnectConnector:K(`/api/connectors/:id/disconnect`)},Io=`Tricot-Seat`,Lo=`Tricot-Time`,Ro=`Tricot-Signature`,zo=`ticket`;function Bo(e){return[`tricot-seat-1`,e.method.toUpperCase(),e.path,e.bodyHash,String(e.time),String(e.counter),e.seat].join(`
|
|
20
|
-
`)}function Vo(e,t){return`${e}.${t}`}var Ho=`tricot-seat`,Uo=`seat`,Wo=`this`,Go=1e3,Ko=()=>typeof crypto<`u`&&!!crypto.subtle&&typeof indexedDB<`u`,qo;function Jo(){return qo??=new Promise((e,t)=>{let n=indexedDB.open(Ho,1);n.onupgradeneeded=()=>n.result.createObjectStore(Uo),n.onsuccess=()=>e(n.result),n.onerror=()=>{qo=void 0,t(n.error??Error(`This browser couldn't open its store for Tricot.`))}}),qo}async function Yo(e){let t=await Jo();return new Promise((n,r)=>{let i=t.transaction(Uo,`readwrite`),a=i.objectStore(Uo),o,s=a.get(Wo);s.onsuccess=()=>{let t=e(s.result);o=t.result,t.keep&&a.put(t.keep,Wo)},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 Xo=()=>Yo(e=>({result:e}));async function Zo(){let e=await Xo();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 Yo(e=>e?{result:e}:{keep:r,result:r})}async function Qo(){if(Ko())try{return(await Xo())?.seat}catch{return}}var $o=new Set,es=()=>$o.forEach(e=>e()),ts=null;function ns(){return ts===null&&(ts=typeof window>`u`||typeof BroadcastChannel>`u`?void 0:new BroadcastChannel(`tricot-seat`),ts&&(ts.onmessage=es)),ts}async function rs(e){await Yo(t=>t?{keep:{...t,seat:e},result:void 0}:{result:void 0}),es(),ns()?.postMessage(`changed`)}var is=()=>rs(void 0);function as(e){return ns(),$o.add(e),()=>$o.delete(e)}var os=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function ss(e,t,n=``){if(!Ko())return;let r=await Yo(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=os(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n))),o=Date.now(),s=Bo({method:e,path:i.pathname+i.search,bodyHash:a,time:o,counter:r.counter,seat:r.seat}),c=os(await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},r.keys.privateKey,new TextEncoder().encode(s)));return{[Io]:r.seat,[Lo]:String(o),[Ro]:Vo(r.counter,c)}}var cs,ls=new Set,us=e=>{cs=e,ls.forEach(e=>e())},ds={get:()=>cs,subscribe(e){return ls.add(e),()=>ls.delete(e)},dismiss:()=>{ps=!0,us(void 0)}},fs,ps=!1,ms=async e=>await e.json().catch(()=>({}));function hs(){return fs??=(async()=>{ps=!1,us({state:`asking`});try{if(!Ko())return us({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 Zo(),t=await fetch(Rt(q.askToBeLetIn),{method:q.askToBeLetIn.method,headers:{"Content-Type":`application/json`},body:JSON.stringify({publicKey:e.publicKey})}),n=await ms(t);if(t.status===200&&n.state===`admitted`&&n.seat)return await rs(n.seat),us(void 0),!0;if(!t.ok||!n.id||!n.code)return us({state:`failed`,error:n.error??`Tricot couldn't ask (${t.status}).`}),!1;for(us({state:`waiting`,code:n.code,expiresAt:n.expiresAt??``,...n.first&&{first:!0}});;){if(await new Promise(e=>setTimeout(e,Go)),ps)return!1;let e;try{let t=await fetch(Rt(q.admission,{id:n.id}),{cache:`no-store`});if(t.status===404)return us({state:`expired`}),!1;e=await ms(t)}catch{continue}if(e.state===`admitted`&&e.seat)return await rs(e.seat),us(void 0),!0;if(e.state===`denied`)return us({state:`denied`,...e.by&&{by:e.by}}),!1;if(e.state===`expired`)return us({state:`expired`}),!1}}catch(e){return us({state:`failed`,error:e.message}),!1}finally{fs=void 0}})(),fs}async function gs(e){if(!await Qo())return e;let t=await ss(q.seatTicket.method,Rt(q.seatTicket),`{}`);if(!t)return e;try{let n=await fetch(Rt(q.seatTicket),{method:q.seatTicket.method,headers:{"Content-Type":`application/json`,...t},body:`{}`}),r=await n.json().catch(()=>({}));if(n.status===403&&r.code===`seat_gone`&&await is(),!n.ok||!r.ticket)return e;let i=new URL(e,location.origin);return i.searchParams.set(zo,r.ticket),i.pathname+i.search}catch{return e}}var _s=class{url;onopen=null;onerror=null;source;listeners=[];closed=!1;opening=0;stopListening;constructor(e){this.url=e,this.stopListening=as(()=>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;gs(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()})})}},vs=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 ys(e,t,n){let r=n?JSON.stringify(n):void 0,i=async n=>{let i=await fetch(t,{method:e,headers:{...r&&{"Content-Type":`application/json`},...n},body:r});return{response:i,data:await i.json().catch(()=>({}))}},{response:a,data:o}=await i();for(let n=0;a.status===403&&(o.code===`seat_needed`||o.code===`seat_gone`)&&n<2;n++){o.code===`seat_gone`&&await is();let n=await ss(e,t,r??``);if(!n&&await hs()&&(n=await ss(e,t,r??``)),!n)break;({response:a,data:o}=await i(n))}if(!a.ok){let e=Error(o.error??`Request failed (${a.status})`);throw e.status=a.status,typeof o.code==`string`&&(e.code=o.code),e}return o}var bs=e=>(...t)=>ys(`GET`,Rt(e,...t)),J=e=>(t,...n)=>ys(`POST`,Rt(e,...n),t),Y={info:()=>bs(q.info)(),update:()=>bs(q.update)(),startUpdate:e=>J(q.startUpdate)({version:e}),checkForUpdates:()=>J(q.checkForUpdates)(void 0),boards:()=>bs(q.boards)(),needs:(e,t)=>bs(q.needs)(void 0,{name:e,seen:JSON.stringify(t)}),agents:e=>bs(q.agents)(void 0,e?{board:e}:void 0),agentUsage:(e,t)=>bs(q.agentUsage)({name:e},{...t.board&&{board:t.board},day:String(t.day),week:String(t.week)}),agentRules:()=>bs(q.agentRules)(),setAgentRule:(e,t)=>J(q.setAgentRule)(t,{agent:e}),addSkill:(e,t)=>J(q.addSkill)({actor:e,...t}),editSkill:(e,t,n)=>J(q.editSkill)({actor:t,...n},{skillId:e}),deleteSkill:(e,t)=>J(q.deleteSkill)({actor:t},{skillId:e}),liveSteps:()=>bs(q.liveSteps)(),previewLiveSteps:(e,t,n)=>J(q.previewLiveSteps)({actor:t,...n},{agent:e}),applyLiveSteps:(e,t,n)=>J(q.applyLiveSteps)({actor:t,...n},{agent:e}),answerApproval:(e,t,n)=>J(q.answerApproval)({actor:t,...n},{id:e}),seats:()=>bs(q.seats)(),removeSeat:(e,t)=>J(q.removeSeat)({actor:t},{id:e}),admissions:()=>bs(q.admissions)(),answerAdmission:(e,t,n)=>J(q.answerAdmission)({actor:t,allow:n},{id:e}),board:e=>bs(q.board)({boardId:e}),live:e=>bs(q.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 bs(q.boardEvents)({boardId:e},r)},projectFiles:e=>bs(q.projectFiles)({boardId:e}),projectFile:(e,t,n)=>bs(q.projectFile)({boardId:e},{path:t,...n?{lines:n}:{}}),projectFileBlock:(e,t,n)=>J(q.projectFileBlock)({actor:t,path:n},{boardId:e}),writeProjectFile:(e,t,n,r,i)=>J(q.projectFileWrite)({actor:t,path:n,text:r,base:i},{boardId:e}),chooseFolder:()=>J(q.chooseFolder)({}),createBoard:(e,t,n,r)=>J(q.createBoard)({actor:e,title:t,goal:n,folder:r}),updateBoard:(e,t,n)=>J(q.updateBoard)({actor:t,...n},{boardId:e}),archiveBoard:(e,t,n)=>J(n?q.archiveBoard:q.unarchiveBoard)({actor:t},{boardId:e}),deleteBoard:(e,t,n)=>J(q.deleteBoard)({actor:t,confirm:n},{boardId:e}),requestSync:(e,t,n)=>J(q.requestSync)({actor:t,blockIds:n},{boardId:e}),cancelSync:(e,t)=>J(q.cancelSync)({actor:t},{boardId:e}),askAgents:(e,t,n)=>J(q.askAgents)({actor:t,text:n},{boardId:e}),cancelRequest:(e,t,n)=>J(q.cancelRequest)({actor:n},{boardId:e,requestId:t}),threads:e=>bs(q.boardThreads)({boardId:e}),thread:e=>bs(q.thread)({threadId:e}),startThread:(e,t,n,r,i,a,o,s,c)=>J(q.startThread)({actor:t,body:n,lens:r,door:i,messageLens:a,pageId:o,blockIds:s,file:c},{boardId:e}),postToThread:(e,t,n,r)=>J(q.postToThread)({actor:t,body:n,messageLens:r},{threadId:e}),setThreadLens:(e,t,n)=>J(q.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?bs(q.boardSearch)({boardId:e},r):bs(q.search)(void 0,r)},reactInThread:(e,t,n,r,i)=>J(q.reactToThreadMessage)({actor:n,emoji:r,...i?{remove:i}:{}},{threadId:e,commentId:t}),reactOnPin:(e,t,n,r,i)=>J(q.reactToPinComment)({actor:n,emoji:r,...i?{remove:i}:{}},{pinId:e,commentId:t}),addPage:(e,t,n)=>J(q.addPage)({actor:t,title:n},{boardId:e}),renamePage:(e,t,n)=>J(q.updatePage)({actor:t,title:n},{pageId:e}),movePage:(e,t,n)=>J(q.updatePage)({actor:t,after:n},{pageId:e}),deletePage:(e,t)=>J(q.deletePage)({actor:t},{pageId:e}),addBlock:(e,t,n)=>J(q.addBlock)({actor:t,...e,...n}),updateBlock:(e,t,n)=>J(q.updateBlock)({actor:t,...n},{id:e}),deriveBlock:(e,t)=>J(q.deriveBlock)({actor:t},{id:e}),blockVersions:e=>bs(q.blockVersions)({id:e}),blockVersion:(e,t)=>bs(q.blockVersion)({id:e,rev:t}),restoreBlock:(e,t,n,r)=>J(q.restoreBlock)({actor:t,rev:n,blockRev:r},{id:e}),deleteVersion:(e,t,n)=>J(q.deleteVersion)({actor:t},{id:e,rev:n}),deleteEarlierVersions:(e,t)=>J(q.deleteEarlierVersions)({actor:t},{id:e}),moveItems:(e,t,n)=>J(q.moveItems)({actor:t,...e,moves:n}),pasteBlocks:(e,t,n)=>J(q.pasteBlocks)({actor:t,...e,...n}),addGroup:(e,t,n)=>J(q.addGroup)({actor:t,...e,...n}),renameGroup:(e,t,n)=>J(q.renameGroup)({actor:t,title:n},{id:e}),addLink:(e,t,n)=>J(q.addLink)({actor:e,from:t,to:n}),relabelLink:(e,t,n)=>J(q.relabelLink)({actor:t,label:n},{id:e}),pinComment:(e,t,n)=>J(q.pinComment)({actor:t,...n},{id:e}),commentOnPin:(e,t,n)=>J(q.commentOnPin)({actor:t,body:n},{id:e}),resolvePin:(e,t,n)=>J(q.resolvePin)({actor:t,resolved:n},{id:e}),startPairing:(e,t)=>J(q.startPairing)({actor:e,...t}),pairingBeat:(e,t,n)=>J(q.pairingBeat)({actor:t,active:n},{id:e}),endPairing:(e,t)=>J(q.endPairing)({actor:t},{id:e}),leavePairing:(e,t)=>void fetch(Rt(q.endPairing,{id:e}),{method:`POST`,keepalive:!0,headers:{"Content-Type":`application/json`},body:JSON.stringify({actor:t})}).catch(()=>void 0),removeItem:(e,t)=>J(q.removeItem)({actor:t},{id:e}),restoreItem:(e,t)=>J(q.restoreItem)({actor:t},{id:e}),uploadImage:async e=>{let t=await fetch(Rt(q.uploadAsset),{method:q.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:()=>bs(q.connectors)(),startConnector:(e,t)=>J(q.startConnector)(t?{permissions:t}:{},{id:e}),disconnectConnector:e=>J(q.disconnectConnector)({},{id:e})},xs=`tricot:boards`;function Ss(e=xs){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 Cs,ws=()=>Cs??=Ss(),Ts=()=>ws().notify(),Es=e=>ws().listen(e);async function Ds(e,t,n){let r=await Y.updateBoard(e,t,n);return Ts(),r}async function Os(e,t,n){let r=await Y.archiveBoard(e,t,n);return Ts(),r}function ks(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 As=e=>e?`Edit the goal…`:`Add a goal…`;function js(e){return e.archived?[`rename`,`goal`,`connectors`,`unarchive`,`delete`]:[`rename`,`goal`,`connectors`,`archive`]}function Ms(e,t){let n=new Set(t),r=new Set([...e].filter(e=>n.has(e)));return r.size===e.size?e:r}var Ns=()=>({actors:[]}),Ps=(e,t)=>e.kind===t.kind&&m(e.name,t.name),Fs=[];function Is(e,t,n=Fs){let r=e.actors.findIndex(e=>Ps(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 Ls=[`task_reordered`,`comment_reacted`],Rs=e=>typeof e==`object`&&!!e&&!Array.isArray(e),zs={page:`pages`,thread:`threads`,request:`requests`,deletion:`deleted`},Bs=e=>Object.hasOwn(zs,e)?zs[e]:xi(e)?.list,Vs={block:`blocks`,group:`groups`,link:`links`,pin:`pins`},Hs=class{copied=new WeakSet;object(e,t){let n=e[t];if(Rs(n)&&this.copied.has(n))return n;let r=Rs(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]}},Us=(e,t)=>e.findIndex(e=>e.id===t);function Ws(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 Gs=e=>e===`page`?`pages`:xi(e)?.list;function Ks(e,t,n){if(n===`board`)return e.object(t,`canvas`);let[r,i]=n.split(/:(.*)/s),a=Gs(r);if(!a)return;let o=e.list(t,a),s=Us(o,i);return s<0?void 0:e.object(e.item(o,s),`canvas`)}function qs(e,t,n){if(!n.owner){let r=Bs(n.kind);return r?e.list(t,r):void 0}let r=Ks(e,t,n.owner),i=Vs[n.kind];return r&&i?e.list(r,i):void 0}function Js(e,t){return Gs(e.kind)?{...e.body,id:e.id,canvas:t?.canvas??ge()}:e.body}function Ys(e){let t=e??Ns(),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?[...r]:Rs(r)?{...r}:r;return n}function Xs(e,t){if(t.reload)return null;let n={...e},r=new Hs,i=(t.events??[]).filter(t=>t.seq>e.seq);if(i.length){let t=Ys(e.activity);for(let e of i)Is(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=qs(r,n,e),i=t?Us(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=qs(r,n,e);if(!t)return null;let i=Us(t,e.id);i>=0?t[i]=Js(e,t[i]):t.splice(Math.min(e.pos,t.length),0,Js(e,void 0))}for(let e of t.patch??[]){let t=qs(r,n,e),i=t?Us(t,e.id):-1,a=t&&i>=0?Ws(t[i],e):null;if(!t||!a)return null;t[i]=a}return n}function Zs(e){let t=[e.canvas,...wi(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(bi().map(({kind:t,list:n})=>[n,Ci(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 Qs=(e,t)=>Object.keys(e).every(n=>e[n]===t[n]);function $s(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&&(Ls.includes(e.type)||e.actor.kind===`human`&&m(e.actor.name,n)))}function ec(e){return e.aliases?.[0]??e.id}var tc=e=>Ai(e).at(-1),nc=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()}},rc=500,ic=1e3,ac=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>ic){let e=this.events.splice(0,this.events.length-ic);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)}},oc=new Map;function sc(e){let t=oc.get(e);return t||oc.set(e,t=new ac),t}async function cc(e,t,n){return sc(e).since(t,n)??lc(e,t)}async function lc(e,t){let n=[];for(;;){let r=await Y.events(e,{since:n.at(-1)?.seq??t,limit:rc});if(n.push(...r.events),!r.more)return n}}var uc=`tricot:seen:`,dc=e=>`${uc}${e}`;function fc(e){try{let t=localStorage.getItem(dc(e));return t===null?null:Number(t)}catch{return null}}function pc(){let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(!n?.startsWith(uc))continue;let r=Number(localStorage.getItem(n));Number.isInteger(r)&&r>=0&&(e[n.slice(12)]=r)}}catch{}return e}function mc(e){try{localStorage.removeItem(dc(e))}catch{}}function hc(e,t){try{localStorage.setItem(dc(e),String(t))}catch{}}var gc=18e5,_c=e=>`tricot:visit:${e}`;function vc(e){try{let t=JSON.parse(sessionStorage.getItem(_c(e))??`null`);return t&&Number.isInteger(t.seq)?t:null}catch{return null}}function yc(e,t){try{sessionStorage.setItem(_c(e),JSON.stringify(t))}catch{}}function bc(e,t){let n=vc(e),r=n&&(n.leftAt===void 0||Date.now()-n.leftAt<gc)?Math.min(n.seq,t):t;return yc(e,{seq:r}),r}function xc(e){let t=vc(e);t&&yc(e,{seq:t.seq,leftAt:Date.now()})}function Sc(e,t){let n=e?ec(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||ec(e)!==n||o!==null)return;let t=fc(n)??e.seq;a({boardId:n,seq:t}),c({boardId:n,seq:bc(n,t)})},[e,n,o]),(0,d.useEffect)(()=>{if(!n)return;let e=()=>{hc(n,r.current),xc(n)},t=()=>{if(document.visibilityState===`hidden`)return e();let t=fc(n)??r.current;a({boardId:n,seq:t}),c({boardId:n,seq:bc(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 cc(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&&$s(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=tc(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=Mi(e,`decision`);return t&&!Mi(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?uo(e,n.itemId):void 0;r&&t.add(r.id)}return t},[C,e]),D=C.some(t=>t.type===`canvas_changed`&&!Mi(t,`decision`)&&!(e&&t.itemId&&uo(e,t.itemId))),O=e?.createdAt,k=Cc(n,o,O),A=Cc(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&&(hc(n,r.current),a({boardId:n,seq:r.current}),f(new Set))},[n])}}function Cc(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 Y.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 wc=`tricot:needs-dismissed`;function Tc(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=()=>Y.needs(e,pc()).then(e=>{n||(r(e),a(null))},e=>!n&&a(e.message));i();let o=setInterval(i,5e3);window.addEventListener(`focus`,i),window.addEventListener(wc,i);let s=Es(i);return()=>{n=!0,clearInterval(o),window.removeEventListener(`focus`,i),window.removeEventListener(wc,i),s()}},[e,t]),{report:n,error:i}}function Ec(e){return/^v\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1)}var Dc=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})),X=n(((e,t)=>{t.exports=Dc()}))(),Oc=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()}},kc=c(),Ac=new nc,jc=(0,d.createContext)(Ac);function Mc({kinds:e,children:t}){return(0,X.jsx)(jc.Provider,{value:e,children:t})}function Nc(){return(0,d.useContext)(jc)}function Pc(e){let{href:t,className:n,title:r,onClick:i,children:a}=e;return t===void 0?(0,X.jsx)(`span`,{className:n,title:r,children:a}):(0,X.jsx)(`a`,{className:n,href:t,title:r,onClick:i,children:a})}function Fc(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Ic(e,t){return e.taken||e.interactive||!Fc(e)?!1:!t||t.moved<=4&&!t.selected}var Lc=[`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 Rc(e,t){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(Lc)!==null||t!==void 0&&zc(e,t.x,t.y)}function zc(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 Bc(){let e=typeof getSelection==`function`?getSelection():null;return e&&!e.isCollapsed?e.toString():``}function Vc(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 Hc(e){return e instanceof Element&&!!e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`)}function Uc(e,t,n,r,i=!1){(0,d.useEffect)(()=>{if(!e)return;i||Wc.add(n);let a=e=>{i||Kc.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||Kc.add(e),t(!0,e))};return document.addEventListener(`mousedown`,a,!0),document.addEventListener(`keydown`,o),()=>{Wc.delete(n),document.removeEventListener(`mousedown`,a,!0),document.removeEventListener(`keydown`,o)}},[e,t,n,r,i])}var Wc=new Set,Gc=[],Kc=new WeakSet,qc=new WeakSet;function Jc(e){for(let t of Wc)if(t!==e)return!0;return!1}function Yc(e){return Wc.size>0||Kc.has(e)||typeof document<`u`&&document.querySelector(`[aria-modal="true"]`)!==null}function Xc(e,t){(0,d.useEffect)(()=>{if(e)return Gc.push(t),()=>void Gc.splice(Gc.indexOf(t),1)},[e,t])}function Zc(e,t){return t.defaultPrevented||qc.has(t)||Yc(t)||Gc.at(-1)!==e?!1:(qc.add(t),!0)}function Qc(e,t){let n=e.target,r={button:e.button,metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,interactive:Rc(n,{x:e.clientX,y:e.clientY}),taken:Yc(e)||!!n.closest?.(`.popover[open]`)};if(!Ic(r))return null;let i=Bc();return $c(n=>{let a=n.type===`mouseup`?Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY):1/0,o=Bc();t(Ic(r,{moved:a,selected:o!==``&&o!==i}))})}function $c(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 el(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 tl(){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 Uc(e,a,n),(0,d.useEffect)(()=>{e&&nl(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=nl(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=el(e.key,t.indexOf(document.activeElement),t.length);r!==void 0&&(e.preventDefault(),t[r].focus())}}}function nl(e){return[...e?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]]}function rl(e){let[,t]=(0,d.useState)(0);(0,d.useEffect)(()=>{let n=setInterval(()=>t(e=>e+1),e);return()=>clearInterval(n)},[e])}function il(e,t,n,r){(0,d.useEffect)(()=>{if(!t)return;let i=e.current?.querySelector(n);i&&(i.focus(),r())})}var al=(0,d.createContext)(!1);function ol(){return(0,d.useContext)(al)}function sl(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var cl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ll=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ul={};function dl(e,t){return((t||ul).jsx?ll:cl).test(e)}var fl=/[ \t\n\f\r]/g;function pl(e){return typeof e==`object`?e.type===`text`&&ml(e.value):ml(e)}function ml(e){return e.replace(fl,``)===``}var hl=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};hl.prototype.normal={},hl.prototype.property={},hl.prototype.space=void 0;function gl(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new hl(n,r,t)}function _l(e){return e.toLowerCase()}var vl=class{constructor(e,t){this.attribute=t,this.property=e}};vl.prototype.attribute=``,vl.prototype.booleanish=!1,vl.prototype.boolean=!1,vl.prototype.commaOrSpaceSeparated=!1,vl.prototype.commaSeparated=!1,vl.prototype.defined=!1,vl.prototype.mustUseProperty=!1,vl.prototype.number=!1,vl.prototype.overloadedBoolean=!1,vl.prototype.property=``,vl.prototype.spaceSeparated=!1,vl.prototype.space=void 0;var yl=e({boolean:()=>xl,booleanish:()=>Sl,commaOrSpaceSeparated:()=>El,commaSeparated:()=>Tl,number:()=>Z,overloadedBoolean:()=>Cl,spaceSeparated:()=>wl}),bl=0,xl=Dl(),Sl=Dl(),Cl=Dl(),Z=Dl(),wl=Dl(),Tl=Dl(),El=Dl();function Dl(){return 2**++bl}var Ol=Object.keys(yl),kl=class extends vl{constructor(e,t,n,r){let i=-1;if(super(e,t),Al(this,`space`,r),typeof n==`number`)for(;++i<Ol.length;){let e=Ol[i];Al(this,Ol[i],(n&yl[e])===yl[e])}}};kl.prototype.defined=!0;function Al(e,t,n){n&&(e[t]=n)}function jl(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new kl(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[_l(r)]=r,n[_l(a.attribute)]=r}return new hl(t,n,e.space)}var Ml=jl({properties:{ariaActiveDescendant:null,ariaAtomic:Sl,ariaAutoComplete:null,ariaBusy:Sl,ariaChecked:Sl,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:wl,ariaCurrent:null,ariaDescribedBy:wl,ariaDetails:null,ariaDisabled:Sl,ariaDropEffect:wl,ariaErrorMessage:null,ariaExpanded:Sl,ariaFlowTo:wl,ariaGrabbed:Sl,ariaHasPopup:null,ariaHidden:Sl,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wl,ariaLevel:Z,ariaLive:null,ariaModal:Sl,ariaMultiLine:Sl,ariaMultiSelectable:Sl,ariaOrientation:null,ariaOwns:wl,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:Sl,ariaReadOnly:Sl,ariaRelevant:null,ariaRequired:Sl,ariaRoleDescription:wl,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:Sl,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 Nl(e,t){return t in e?e[t]:t}function Pl(e,t){return Nl(e,t.toLowerCase())}var Fl=jl({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Tl,acceptCharset:wl,accessKey:wl,action:null,allow:null,allowFullScreen:xl,allowPaymentRequest:xl,allowUserMedia:xl,alpha:xl,alt:null,as:null,async:xl,autoCapitalize:null,autoComplete:wl,autoFocus:xl,autoPlay:xl,blocking:wl,capture:null,charSet:null,checked:xl,cite:null,className:wl,closedBy:null,colorSpace:null,cols:Z,colSpan:Z,command:null,commandFor:null,content:null,contentEditable:Sl,controls:xl,controlsList:wl,coords:Z|Tl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xl,defer:xl,dir:null,dirName:null,disabled:xl,download:Cl,draggable:Sl,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xl,formTarget:null,headers:wl,height:Z,hidden:Cl,high:Z,href:null,hrefLang:null,htmlFor:wl,httpEquiv:wl,id:null,imageSizes:null,imageSrcSet:null,inert:xl,inputMode:null,integrity:null,is:null,isMap:xl,itemId:null,itemProp:wl,itemRef:wl,itemScope:xl,itemType:wl,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xl,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:xl,muted:xl,name:null,nonce:null,noModule:xl,noValidate:xl,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:xl,optimum:Z,pattern:null,ping:wl,placeholder:null,playsInline:xl,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xl,referrerPolicy:null,rel:wl,required:xl,reversed:xl,rows:Z,rowSpan:Z,sandbox:wl,scope:null,scoped:xl,seamless:xl,selected:xl,shadowRootClonable:xl,shadowRootCustomElementRegistry:xl,shadowRootDelegatesFocus:xl,shadowRootMode:null,shadowRootSerializable:xl,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:Sl,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:xl,useMap:null,value:Sl,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wl,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:xl,declare:xl,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:xl,noHref:xl,noShade:xl,noWrap:xl,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:Sl,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:xl,disablePictureInPicture:xl,disableRemotePlayback:xl,exportParts:Tl,part:wl,prefix:null,property:null,results:Z,security:null,unselectable:null},space:`html`,transform:Pl}),Il=jl({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:El,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:wl,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:xl,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:Tl,g2:Tl,glyphName:Tl,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:El,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:wl,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:El,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:El,rev:El,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:El,requiredFeatures:El,requiredFonts:El,requiredFormats:El,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:El,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:El,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:El,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:Nl}),Ll=jl({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()}}),Rl=jl({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Pl}),zl=jl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Bl={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`},Vl=/[A-Z]/g,Hl=/-[a-z]/g,Ul=/^data[-\w.:]+$/i;function Wl(e,t){let n=_l(t),r=t,i=vl;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ul.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Hl,Kl);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Hl.test(e)){let n=e.replace(Vl,Gl);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=kl}return new i(r,t)}function Gl(e){return`-`+e.toLowerCase()}function Kl(e){return e.charAt(1).toUpperCase()}var ql=gl([Ml,Fl,Ll,Rl,zl],`html`),Jl=gl([Ml,Il,Ll,Rl,zl],`svg`);function Yl(e){return e.join(` `).trim()}var Xl=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})),Zl=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(Xl());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}})),Ql=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))}})),$l=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Zl()),i=Ql();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})),eu=nu(`end`),tu=nu(`start`);function nu(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 ru(e){let t=tu(e),n=eu(e);if(t&&n)return{start:t,end:n}}function iu(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?ou(e.position):`start`in e||`end`in e?ou(e):`line`in e||`column`in e?au(e):``}function au(e){return su(e&&e.line)+`:`+su(e&&e.column)}function ou(e){return au(e&&e.start)+`-`+au(e&&e.end)}function su(e){return e&&typeof e==`number`?e:1}var cu=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=iu(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}};cu.prototype.file=``,cu.prototype.name=``,cu.prototype.reason=``,cu.prototype.message=``,cu.prototype.stack=``,cu.prototype.column=void 0,cu.prototype.line=void 0,cu.prototype.ancestors=void 0,cu.prototype.cause=void 0,cu.prototype.fatal=void 0,cu.prototype.place=void 0,cu.prototype.ruleId=void 0,cu.prototype.source=void 0;var lu=t($l(),1),uu={}.hasOwnProperty,du=new Map,fu=/[A-Z]/g,pu=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),mu=new Set([`td`,`th`]),hu=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function gu(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=Du(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=Eu(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`?Jl:ql,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_u(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _u(e,t,n){if(t.type===`element`)return vu(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return yu(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return xu(e,t,n);if(t.type===`mdxjsEsm`)return bu(e,t);if(t.type===`root`)return Su(e,t,n);if(t.type===`text`)return Cu(e,t)}function vu(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Jl,e.schema=i),e.ancestors.push(t);let a=Nu(e,t.tagName,!1),o=Ou(e,t),s=Au(e,t);return pu.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!pl(e)})),wu(e,o,a,t),Tu(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function yu(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)}Pu(e,t.position)}function bu(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Pu(e,t.position)}function xu(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Jl,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Nu(e,t.name,!0),o=ku(e,t),s=Au(e,t);return wu(e,o,a,t),Tu(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Su(e,t,n){let r={};return Tu(r,Au(e,t)),e.create(t,e.Fragment,r,n)}function Cu(e,t){return t.value}function wu(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Tu(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Eu(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 Du(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=tu(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 Ou(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&uu.call(t.properties,i)){let a=ju(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&mu.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 ku(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 Pu(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 Pu(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Au(e,t){let n=[],r=-1,i=e.passKeys?new Map:du;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=_u(e,a,o);s!==void 0&&n.push(s)}return n}function ju(e,t,n){let r=Wl(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sl(n):Yl(n)),r.property===`style`){let t=typeof n==`object`?n:Mu(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Fu(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Bl[r.property]||r.property:r.attribute,n]}}function Mu(e,t){try{return(0,lu.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new cu("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=hu+`#cannot-parse-style-attribute`,r}}function Nu(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=dl(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=dl(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return uu.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Pu(e)}function Pu(e,t){let n=new cu("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=hu+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Fu(e){let t={},n;for(n in e)uu.call(e,n)&&(t[Iu(n)]=e[n]);return t}function Iu(e){let t=e.replace(fu,Lu);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Lu(e){return`-`+e.toLowerCase()}var Ru={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`]},zu={};function Bu(e,t){let n=t||zu;return Vu(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function Vu(e,t,n){if(Uu(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 Hu(e.children,t,n)}return Array.isArray(e)?Hu(e,t,n):``}function Hu(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Vu(e[i],t,n);return r.join(``)}function Uu(e){return!!(e&&typeof e==`object`)}var Wu=document.createElement(`i`);function Gu(e){let t=`&`+e+`;`;Wu.innerHTML=t;let n=Wu.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function Ku(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 qu(e,t){return e.length>0?(Ku(e,e.length,0,t),e):t}var Ju={}.hasOwnProperty;function Yu(e){let t={},n=-1;for(;++n<e.length;)Xu(t,e[n]);return t}function Xu(e,t){let n;for(n in t){let r=(Ju.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Ju.call(r,a)||(r[a]=[]);let e=i[a];Zu(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Zu(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Ku(e,0,0,r)}function Qu(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 $u(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var ed=fd(/[A-Za-z]/),td=fd(/[\dA-Za-z]/),nd=fd(/[#-'*+\--9=?A-Z^-~]/);function rd(e){return e!==null&&(e<32||e===127)}var id=fd(/\d/),ad=fd(/[\dA-Fa-f]/),od=fd(/[!-/:-@[-`{-~]/);function sd(e){return e!==null&&e<-2}function cd(e){return e!==null&&(e<0||e===32)}function ld(e){return e===-2||e===-1||e===32}var ud=fd(/\p{P}|\p{S}/u),dd=fd(/\s/);function fd(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function pd(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&td(e.charCodeAt(n+1))&&td(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 md(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return ld(r)?(e.enter(n),s(r)):t(r)}function s(r){return ld(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function hd(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&ld(t)?(e.enter(r),c(t)):l(t)}function c(t){return ld(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var gd={tokenize:_d};function _d(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`),md(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 sd(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var vd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){yd(this,e,t,n,!1)}addBefore(e,t,n){yd(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 yd(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 bd={tokenize:Sd},xd={tokenize:Cd};function Sd(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 vd;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(xd,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(xd,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 sd(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 vd;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 Cd(e,t,n){return md(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function wd(e){if(e===null||cd(e)||dd(e))return 1;if(ud(e))return 2}function Td(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 Ed={name:`attention`,resolveAll:Dd,tokenize:Od};function Dd(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};kd(o,-a),kd(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=qu(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=qu(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=qu(r,Td(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=qu(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=qu(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),Ku(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 Od(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wd(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=wd(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 kd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ad={name:`autolink`,tokenize:jd};function jd(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 ed(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||td(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||td(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||rd(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):nd(t)?(e.consume(t),l):n(t)}function u(e){return td(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||td(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Md={partial:!0,tokenize:Nd};function Nd(e,t,n){return r;function r(t){return ld(t)?md(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||sd(e)?t(e):n(e)}}var Pd={continuation:{tokenize:Id},exit:Ld,name:`blockQuote`,tokenize:Fd};function Fd(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 ld(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Id(e,t,n){let r=this;return i;function i(t){return ld(t)?md(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Pd,t,n)(r)}}function Ld(e){e.exit(`blockQuote`)}var Rd={name:`characterEscape`,tokenize:zd};function zd(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 od(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Bd={name:`characterReference`,tokenize:Vd};function Vd(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=td,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=ad,u):(e.enter(`characterReferenceValue`),a=7,o=id,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===td&&!Gu(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 Hd={partial:!0,tokenize:Ud};function Ud(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 Wd={concrete:!0,name:`codeFenced`,tokenize:Gd};function Gd(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`),ld(t)?md(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||sd(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Hd,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||sd(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):ld(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),md(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||sd(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||sd(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&&ld(t)?md(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||sd(t)?e.check(Hd,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||sd(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`),ld(t)?md(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`),ld(t)?md(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||sd(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var Kd={name:`codeIndented`,tokenize:Jd},qd={partial:!0,tokenize:Yd};function Jd(e,t,n){return r;function r(t){return e.enter(`codeIndented`),hd(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):sd(t)?e.attempt(qd,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||sd(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function Yd(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):sd(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):hd(e,t,a,`linePrefix`,4,4)(o)}function a(e){return sd(e)?i(e):n(e)}}var Xd={name:`codeText`,previous:Qd,resolve:Zd,tokenize:$d};function Zd(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 Qd(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function $d(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)):sd(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||sd(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 ef=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&&tf(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),tf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),tf(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);tf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);tf(this.left,t.reverse())}}}};function tf(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 nf(e){let t={},n=-1,r,i,a,o,s,c,l,u=new ef(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,rf(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 Ku(e,0,1/0,u.slice(0)),!l}function rf(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 af={resolve:sf,tokenize:cf},of={partial:!0,tokenize:lf};function sf(e){return nf(e),e}function cf(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):sd(t)?e.check(of,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 lf(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),md(e,a,`linePrefix`)}function a(i){if(i===null||sd(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 uf(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||rd(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||sd(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||cd(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||rd(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 df(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):sd(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||sd(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!ld(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function ff(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):sd(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),md(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||sd(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 pf(e,t){let n;return r;function r(i){return sd(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):ld(i)?md(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var mf={name:`definition`,tokenize:gf},hf={partial:!0,tokenize:_f};function gf(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return df.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=$u(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 cd(t)?pf(e,l)(t):l(t)}function l(t){return uf(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(hf,d,d)(t)}function d(t){return ld(t)?md(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||sd(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function _f(e,t,n){return r;function r(t){return cd(t)?pf(e,i)(t):n(t)}function i(t){return ff(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return ld(t)?md(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||sd(e)?t(e):n(e)}}var vf={name:`hardBreakEscape`,tokenize:yf};function yf(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return sd(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var bf={name:`headingAtx`,resolve:xf,tokenize:Sf};function xf(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`};Ku(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Sf(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||cd(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||sd(n)?(e.exit(`atxHeading`),t(n)):ld(n)?md(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||cd(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Cf=`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(`.`),wf=[`pre`,`script`,`style`,`textarea`],Tf={concrete:!0,name:`htmlFlow`,resolveTo:Df,tokenize:Of},Ef={partial:!0,tokenize:kf};function Df(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 Of(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):ed(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):ed(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 ed(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||cd(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&wf.includes(l)?(i=1,r.interrupt?t(s):O(s)):Cf.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||td(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 ld(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||ed(t)?(e.consume(t),b):ld(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||td(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):ld(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):ld(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||sd(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||cd(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||ld(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||sd(t)?O(t):ld(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):sd(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Ef,R,k)(t)):t===null||sd(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Hd,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||sd(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 wf.includes(n)?(e.consume(t),L):O(t)}return ed(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||sd(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function kf(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Md,t,n)}}var Af={name:`htmlText`,tokenize:jf};function jf(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):ed(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):ed(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):sd(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):sd(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):sd(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):sd(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return ed(t)?(e.consume(t),S):n(t)}function S(t){return t===45||td(t)?(e.consume(t),S):C(t)}function C(t){return sd(t)?(o=C,N(t)):ld(t)?(e.consume(t),C):M(t)}function w(t){return t===45||td(t)?(e.consume(t),w):t===47||t===62||cd(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||ed(t)?(e.consume(t),E):sd(t)?(o=T,N(t)):ld(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||td(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):sd(t)?(o=D,N(t)):ld(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):sd(t)?(o=O,N(t)):ld(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):sd(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||cd(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||cd(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 ld(t)?md(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 Mf={name:`labelEnd`,resolveAll:If,resolveTo:Lf,tokenize:Rf},Nf={tokenize:zf},Pf={tokenize:Bf},Ff={tokenize:Vf};function If(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&&Ku(e,0,e.length,n),e}function Lf(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=qu(o,e.slice(i+1,i+r+3)),o=qu(o,[[`enter`,l,t]]),o=qu(o,Td(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=qu(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=qu(o,e.slice(a+1)),o=qu(o,[[`exit`,s,t]]),Ku(e,i,e.length,o),e}function Rf(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($u(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(Nf,u,o?u:d)(t):t===91?e.attempt(Pf,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Ff,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function zf(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 cd(t)?pf(e,a)(t):a(t)}function a(t){return t===41?u(t):uf(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return cd(t)?pf(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?ff(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return cd(t)?pf(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 Bf(e,t,n){let r=this;return i;function i(t){return df.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes($u(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Vf(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 Hf={name:`labelStartImage`,resolveAll:Mf.resolveAll,tokenize:Uf};function Uf(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 Wf={name:`labelStartLink`,resolveAll:Mf.resolveAll,tokenize:Gf};function Gf(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 Kf={name:`lineEnding`,tokenize:qf};function qf(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),md(e,t,`linePrefix`)}}var Jf={name:`thematicBreak`,tokenize:Yf};function Yf(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||sd(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),ld(t)?md(e,s,`whitespace`)(t):s(t))}}var Xf={continuation:{tokenize:ep},exit:np,name:`list`,tokenize:$f},Zf={partial:!0,tokenize:rp},Qf={partial:!0,tokenize:tp};function $f(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:id(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(Jf,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 id(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(Md,r.interrupt?n:u,e.attempt(Zf,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return ld(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 ep(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Md,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,md(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!ld(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(Qf,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,md(e,e.attempt(Xf,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function tp(e,t,n){let r=this;return md(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 np(e){e.exit(this.containerState.type)}function rp(e,t,n){let r=this;return md(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!ld(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var ip={name:`setextUnderline`,resolveTo:ap,tokenize:op};function ap(e,t){let n=new vd,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 op(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`),ld(t)?md(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||sd(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var sp={tokenize:cp};function cp(e){let t=this,n=e.attempt(Md,r,e.attempt(this.parser.constructs.flowInitial,i,md(e,e.attempt(this.parser.constructs.flow,i,e.attempt(af,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 lp={resolveAll:pp()},up=fp(`string`),dp=fp(`text`);function fp(e){return{resolveAll:pp(e===`text`?mp: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 pp(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 mp(e,t){let n=new vd,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 hp=e({attentionMarkers:()=>Cp,contentInitial:()=>_p,disable:()=>wp,document:()=>gp,flow:()=>yp,flowInitial:()=>vp,insideSpan:()=>Sp,string:()=>bp,text:()=>xp}),gp={42:Xf,43:Xf,45:Xf,48:Xf,49:Xf,50:Xf,51:Xf,52:Xf,53:Xf,54:Xf,55:Xf,56:Xf,57:Xf,62:Pd},_p={91:mf},vp={[-2]:Kd,[-1]:Kd,32:Kd},yp={35:bf,42:Jf,45:[ip,Jf],60:Tf,61:ip,95:Jf,96:Wd,126:Wd},bp={38:Bd,92:Rd},xp={[-5]:Kf,[-4]:Kf,[-3]:Kf,33:Hf,38:Bd,42:Ed,60:[Ad,Af],91:Wf,92:[vf,Rd],93:Mf,95:Ed,96:Xd},Sp={null:[Ed,lp]},Cp={null:[42,95]},wp={null:[]};function Tp(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=qu(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Td(a,l.events,l),l.events):[]}function f(e,t){return Dp(p(e),t)}function p(e){return Ep(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){sd(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&&Ku(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 Ep(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 Dp(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 Op(e){let t={constructs:Yu([hp,...(e||{}).extensions||[]]),content:n(gd),defined:[],document:n(bd),flow:n(sp),lazy:{},string:n(up),text:n(dp)};return t;function n(e){return n;function n(n){return Tp(t,e,n)}}}function kp(e){for(;!nf(e););return e}var Ap=/[\0\t\n\r]/g;function jp(){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;){Ap.lastIndex=c;let n=Ap.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 Mp=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Np(e){return e.replace(Mp,Pp)}function Pp(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return Qu(n.slice(t?2:1),t?16:10)}return Gu(n)||e}var Fp={}.hasOwnProperty;function Ip(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Lp(n)(kp(Op(n).document().write(jp()(e,t,!0))))}function Lp(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(de),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(W),blockQuote:o(ie),characterEscape:E,characterReference:E,codeFenced:o(ae),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(ae,s),codeText:o(oe,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(se),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(U),hardBreakEscape:o(ce),hardBreakTrailing:o(ce),htmlFlow:o(le,s),htmlFlowData:E,htmlText:o(le,s),htmlTextData:E,image:o(ue),label:s,link:o(de),listItem:o(pe),listItemValue:p,listOrdered:o(fe,f),listUnordered:o(fe),paragraph:o(me),reference:B,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(W),strong:o(he),thematicBreak:o(_e)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:re,autolinkProtocol:ne,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:te,characterReference:H,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()}};zp(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]),Fp.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]||Vp).call(o,void 0,e[0])}for(r.position={start:Rp(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Rp(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:Rp(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+"` ("+iu({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Vp).call(this,e,r[0])),n.position.end=Rp(e.end)}function d(){return Bu(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=$u(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=ge(),n.position={start:Rp(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=Rp(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=Rp(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=Np(t),n.identifier=$u(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=$u(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=Qu(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Gu(t);let i=this.stack[this.stack.length-1];i.value+=r}function H(e){let t=this.stack.pop();t.position.end=Rp(e.end)}function ne(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function re(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ie(){return{type:`blockquote`,children:[],position:void 0}}function ae(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function oe(){return{type:`inlineCode`,value:``,position:void 0}}function se(){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 ce(){return{type:`break`,position:void 0}}function le(){return{type:`html`,value:``,position:void 0}}function ue(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function de(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function fe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function me(){return{type:`paragraph`,children:[],position:void 0}}function he(){return{type:`strong`,children:[],position:void 0}}function ge(){return{type:`text`,value:``,position:void 0}}function _e(){return{type:`thematicBreak`,position:void 0}}}function Rp(e){return{line:e.line,column:e.column,offset:e.offset}}function zp(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?zp(e,r):Bp(e,r)}}function Bp(e,t){let n;for(n in t)if(Fp.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 Vp(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+iu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+iu({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+iu({start:t.start,end:t.end})+`) is still open`)}function Hp(e){let t=this;t.parser=n;function n(n){return Ip(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Up(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 Wp(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
24
|
-
`}]}function Gp(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 Kp(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qp(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Jp(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=pd(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 Yp(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 Xp(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Zp(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 Qp(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zp(e,t);let i={src:pd(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 $p(e,t){let n={src:pd(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 em(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 tm(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zp(e,t);let i={href:pd(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 nm(e,t){let n={href:pd(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 rm(e,t,n){let r=e.all(t),i=n?im(n):am(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 im(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=am(n[r])}return t}function am(e){return e.spread??e.children.length>1}function om(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 sm(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cm(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function lm(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function um(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=tu(t.children[1]),o=eu(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 dm(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 fm(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var pm=9,mm=32;function hm(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(gm(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(gm(t.slice(i),i>0,!1)),a.join(``)}function gm(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===pm||t===mm;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===pm||t===mm;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function _m(e,t){let n={type:`text`,value:hm(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function vm(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var ym={blockquote:Up,break:Wp,code:Gp,delete:Kp,emphasis:qp,footnoteReference:Jp,heading:Yp,html:Xp,imageReference:Qp,image:$p,inlineCode:em,linkReference:tm,link:nm,listItem:rm,list:om,paragraph:sm,root:cm,strong:lm,table:um,tableCell:fm,tableRow:dm,text:_m,thematicBreak:vm,toml:bm,yaml:bm,definition:bm,footnoteDefinition:bm};function bm(){}var{defineProperty:xm}=Object,Sm=typeof self==`object`?self:globalThis,Cm=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Sm[e](t)},wm=(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__`?xm(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 Sm[e]==`function`?Cm(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(Cm(a,o),i)};return r},Tm=e=>wm(new Map,e)(0),Em=``,{toString:Dm}={},{keys:Om,is:km}=Object,Am=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Dm.call(e).slice(8,-1);switch(n){case`Array`:return[1,Em];case`Object`:return[2,Em];case`Date`:return[3,Em];case`RegExp`:return[4,Em];case`Map`:return[5,Em];case`Set`:return[6,Em];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},jm=([e,t])=>e===0&&(t===`function`||t===`symbol`),Mm=(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]=Am(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&km(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 Om(o))(e||!jm(Am(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?Em: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||!(jm(Am(n))||jm(Am(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!jm(Am(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},Nm=(e,{json:t,lossy:n}={})=>{let r=[];return Mm(!(t||n),!!t,new Map,r)(e),r},Pm=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Tm(Nm(e,t)):structuredClone(e):(e,t)=>Tm(Nm(e,t));function Fm(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 Im(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function Lm(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||Fm,r=e.options.footnoteBackLabel||Im,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=pd(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:{...Pm(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 Rm=(function(e){if(e==null)return Um;if(typeof e==`function`)return Hm(e);if(typeof e==`object`)return Array.isArray(e)?zm(e):Bm(e);if(typeof e==`string`)return Vm(e);throw Error(`Expected function, string, or object as test`)});function zm(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Rm(e[n]);return Hm(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Bm(e){let t=e;return Hm(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Vm(e){return Hm(t);function t(t){return t&&t.type===e}}function Hm(e){return t;function t(t,n,r){return!!(Wm(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Um(){return!0}function Wm(e){return typeof e==`object`&&!!e&&`type`in e}function Gm(e){return e}var Km=[],qm=`skip`;function Jm(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=Rm(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 (`+Gm(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=Km;if(s&&r&&(o=Ym(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=Ym(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 Ym(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Km:[e]}function Xm(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`?Jm(e,i,Qm(a),o):Jm(e,i,Zm(a),o)}function Zm(e){return!e||typeof e!=`object`?e:{enter:typeof e.enter==`function`?Qm(e.enter):e.enter,exit:typeof e.exit==`function`?Qm(e.exit):e.exit}}function Qm(e){return t;function t(t,n,r){return e(t,r,n[n.length-1])}}var $m={}.hasOwnProperty,eh={};function th(e,t){let n=t||eh,r=new Map,i=new Map,a={all:s,applyData:rh,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ym,...n.handlers},one:o,options:n,patch:nh,wrap:ah};return Xm(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($m.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=Pm(n);return r.children=a.all(e),r}return Pm(e)}return(a.options.unknownHandler||ih)(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=oh(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=oh(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function nh(e,t){e.position&&(t.position=ru(e))}function rh(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,Pm(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function ih(e,t){let n=t.data||{},r=`value`in t&&!($m.call(n,`hProperties`)||$m.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 ah(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 oh(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function sh(e,t){let n=th(e,t),r=n.one(e,void 0),i=Lm(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 ch(e,t){return e&&`run`in e?async function(n,r){let i=sh(n,{file:r,...t});await e.run(i,r)}:function(n,r){return sh(n,{file:r,...e||t})}}function lh(e){if(e)throw e}var uh=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 dh(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 fh(){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?ph(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 ph(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 mh={basename:hh,dirname:gh,extname:_h,join:vh,sep:`/`};function hh(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);xh(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 gh(e){if(xh(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 _h(e){xh(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 vh(...e){let t=-1,n;for(;++t<e.length;)xh(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:yh(n)}function yh(e){xh(e);let t=e.codePointAt(0)===47,n=bh(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function bh(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 xh(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Sh={cwd:Ch};function Ch(){return`/`}function wh(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Th(e){if(typeof e==`string`)e=new URL(e);else if(!wh(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 Eh(e)}function Eh(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 Dh=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Oh=class{constructor(e){let t;t=e?wh(e)?{path:e}:typeof e==`string`||Mh(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Sh.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Dh.length;){let e=Dh[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)Dh.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?mh.basename(this.path):void 0}set basename(e){Ah(e,`basename`),kh(e,`basename`),this.path=mh.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?mh.dirname(this.path):void 0}set dirname(e){jh(this.basename,`dirname`),this.path=mh.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?mh.extname(this.path):void 0}set extname(e){if(kh(e,`extname`),jh(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=mh.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){wh(e)&&(e=Th(e)),Ah(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?mh.basename(this.path,this.extname):void 0}set stem(e){Ah(e,`stem`),kh(e,`stem`),this.path=mh.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 cu(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 kh(e,t){if(e&&e.includes(mh.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+mh.sep+"`")}function Ah(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function jh(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Mh(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Nh=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Ph=t(uh(),1),Fh={}.hasOwnProperty,Ih=new class e extends Nh{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=fh()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Ph.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(zh(`data`,this.frozen),this.namespace[e]=t,this):Fh.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zh(`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=Hh(e),n=this.parser||this.Parser;return Lh(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Lh(`process`,this.parser||this.Parser),Rh(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Hh(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);Wh(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(),Lh(`processSync`,this.parser||this.Parser),Rh(`processSync`,this.compiler||this.Compiler),this.process(e,r),Vh(`processSync`,`process`,t),n;function r(e,r){t=!0,lh(e),n=r}}run(e,t,n){Bh(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=Hh(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),Vh(`runSync`,`run`,n),r;function i(e,t){lh(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Hh(t),r=this.compiler||this.Compiler;return Rh(`stringify`,r),Bh(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zh(`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,Ph.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];dh(o)&&dh(r)&&(r=(0,Ph.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Lh(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Rh(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function zh(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 Bh(e){if(!dh(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Vh(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Hh(e){return Uh(e)?e:new Oh(e)}function Uh(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Wh(e){return typeof e==`string`||Gh(e)}function Gh(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Kh=[],qh={allowDangerousHtml:!0},Jh=/^(https?|ircs?|mailto|xmpp)$/i,Yh=[{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 Xh(e){let t=Zh(e),n=Qh(e);return $h(t.runSync(t.parse(n),n),e)}function Zh(e){let t=e.rehypePlugins||Kh,n=e.remarkPlugins||Kh,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qh}:qh;return Ih().use(Hp).use(n).use(ch,r).use(t)}function Qh(e){let t=e.children||``,n=new Oh;return typeof t==`string`?n.value=t:``+t,n}function $h(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||eg;for(let e of Yh)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return Xm(e,l),gu(e,{Fragment:X.Fragment,components:i,ignoreInvalidStyle:!0,jsx:X.jsx,jsxs:X.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 Ru)if(Object.hasOwn(Ru,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Ru[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 eg(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||Jh.test(e.slice(0,t))?e:``}function tg(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 ng(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function rg(e,t,n){let r=Rm((n||{}).ignore||[]),i=ig(t),a=-1;for(;++a<i.length;)Jm(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 qm}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 ig(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([ag(e[0]),og(e[1])])}return t}function ag(e){return typeof e==`string`?new RegExp(ng(e),`g`):e}function og(e){return typeof e==`function`?e:function(){return e}}var sg=`phrasing`,cg=[`autolink`,`link`,`image`,`label`];function lg(){return{transforms:[_g],enter:{literalAutolink:dg,literalAutolinkEmail:fg,literalAutolinkHttp:fg,literalAutolinkWww:fg},exit:{literalAutolink:gg,literalAutolinkEmail:hg,literalAutolinkHttp:pg,literalAutolinkWww:mg}}}function ug(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:sg,notInConstruct:cg},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:sg,notInConstruct:cg},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:sg,notInConstruct:cg}]}}function dg(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function fg(e){this.config.enter.autolinkProtocol.call(this,e)}function pg(e){this.config.exit.autolinkProtocol.call(this,e)}function mg(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 hg(e){this.config.exit.autolinkEmail.call(this,e)}function gg(e){this.exit(e)}function _g(e){rg(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,vg],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,yg]],{ignore:[`link`,`linkReference`]})}function vg(e,t,n,r,i){let a=``;if(!Sg(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!bg(n)))return!1;let o=xg(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 yg(e,t,n,r){return!Sg(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function bg(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 xg(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=tg(e,`(`),a=tg(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 Sg(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||dd(n)||ud(n))&&(!t||n!==47)}Mg.peek=jg;function Cg(){this.buffer()}function wg(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Tg(){this.buffer()}function Eg(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Dg(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$u(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Og(e){this.exit(e)}function kg(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$u(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ag(e){this.exit(e)}function jg(){return`[`}function Mg(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 Ng(){return{enter:{gfmFootnoteCallString:Cg,gfmFootnoteCall:wg,gfmFootnoteDefinitionLabelString:Tg,gfmFootnoteDefinition:Eg},exit:{gfmFootnoteCallString:Dg,gfmFootnoteCall:Og,gfmFootnoteDefinitionLabelString:kg,gfmFootnoteDefinition:Ag}}}function Pg(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Mg},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?Ig:Fg))),s(),o}}function Fg(e,t,n){return t===0?e:Ig(e,t,n)}function Ig(e,t,n){return(n?``:` `)+e}var Lg=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Hg.attention=Ug,Hg.peek=Wg;function Rg(){return{canContainEols:[`delete`],enter:{strikethrough:Bg},exit:{strikethrough:Vg}}}function zg(){return{handlers:{delete:Hg},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Lg}]}}function Bg(e){this.enter({type:`delete`,children:[],position:void 0},e)}function Vg(e){this.exit(e)}function Hg(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 Ug(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function Wg(){return`~`}function Gg(e){return e.length}function Kg(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Gg,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=qg(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]=Jg(r[d]);else{let e=Jg(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 qg(e){return e==null?``:String(e)}function Jg(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 Yg=Rm([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Xg(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()),Zg);return i(),o}function Zg(e,t,n){return`>`+(n?``:` `)+e}function Qg(e,t){return $g(e,t.inConstruct,!0)&&!$g(e,t.notInConstruct,!1)}function $g(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 e_(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&&Qg(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
37
|
-
`}function t_(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 n_(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 r_(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function i_(e,t,n,r){let i=r_(n),a=e.value||``;if(n_(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,a_);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(t_(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 a_(e,t,n){return(n?``:` `)+e}function o_(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function s_(e,t,n,r){let i=o_(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 c_(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function l_(e){let t=e.codePointAt(0);return t===void 0?``:String.fromCodePoint(t)}function u_(e){let t=e.codePointAt(e.length-2);return t!==void 0&&t>65535?e.slice(-2):e.slice(-1)}function d_(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function f_(e,t,n){let r=wd(e),i=wd(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 p_(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:ed(t)?4:void 0}if(t===63)return 3;let n=t===47,r=n?2:1,i=r,a=e.charCodeAt(i);if(!ed(a))return;for(;a===45||td(a);)a=e.charCodeAt(++i);let o=e.slice(r,i).toLowerCase();return!n&&a!==47&&wf.includes(o)?1:Cf.includes(o)?6:7}var m_=new Map([[`*`,!1],[`_`,!0]]);function h_(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 g_(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=m_.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=wd(u.charCodeAt(u.length-1)),f=wd((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(y_(r,i),o=-1;++o<e.length;){let t=i.get(e[o]);if(t)return{attention:h_(e,t,a),index:o}}}function __(e,t){let n=e[t?0:e.length-1];if(!n||n.attention)return;let r=t?l_(n.value):u_(n.value),i=d_(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 v_(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=C_(e,c,r,i),u=g_(l,r,i);if(!u||u.index>n.index)return{chosen:c,mistake:u,tokens:l}}}}function y_(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 b_(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(!od(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 x_(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?l_(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`&&p_(l.value)!==7&&(a[a.length-1]=d.replace(/(\r?\n|\r)$/,` `),s=` `,c=t.createTracker(n),c.move(w_(a,n.before,n.after)));let f=t.handle.handlers[l.type];if(f&&f.attention){let e=S_(l,f.attention,t,c);a.push(e),s=u_(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=u_(n)}}return r.pop(),a}function S_(e,t,n,r){let{construct:i,markers:a,sizes:o}=t(e,n),s=b_(e.type,a,o),c=s[0],l=n.enter(i);r.move(c);let u=x_(e,n,{...r.current(),before:c,after:c});return r.move(w_(u,c,c)),r.move(c),l(),{children:u,sequences:s}}function C_(e,t,n,r){let i=[],a,o=u_(n),s=-1;for(;++s<e.length;){let n=e[s];if(typeof n==`string`){let e={value:n,attention:void 0};a&&a===l_(n)&&__([e],!0),a=void 0,i.push(e),e.value&&(o=u_(e.value));continue}let c=t.get(n)||n.sequences[0],l=c.charAt(0),u=e[s+1],d=o,f=l_(u===void 0?r:typeof u==`string`?u:t.get(u)||u.sequences[0]),p=C_(n.children,t,c,c),m=p.length>0?p[0].value:``,h=f_(d.charCodeAt(d.length-1),m.charCodeAt(0),l);h.inside&&__(p,!0);let g=p.length>0?u_(p[p.length-1].value):``,_=f_(f.charCodeAt(0),g.charCodeAt(g.length-1),l);_.inside&&__(p,!1),h.outside&&d!==`
|
|
43
|
-
`&&d!==`\r`&&__(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 w_(e,t,n){let r=new Map,i=C_(e,r,t,n),a=i,o=g_(a,t,n);for(;o;){let s=v_(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}T_.attention=E_,T_.peek=D_;function T_(e,t,n,r){let i=n.enter(`phrasing`),a=w_([S_(e,E_,n,n.createTracker(r))],r.before,r.after);return i(),a}function E_(e,t){return{construct:`emphasis`,markers:c_(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function D_(e,t,n){return n.options.emphasis||`*`}function O_(e,t){let n=!1;return Xm(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)&&Bu(e)&&(t.options.setext||n))}function k_(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(O_(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=d_(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}A_.peek=j_;function A_(e){return e.value||``}function j_(){return`<`}M_.peek=N_;function M_(e,t,n,r){let i=o_(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 N_(){return`!`}P_.peek=F_;function P_(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 F_(){return`!`}I_.peek=L_;function I_(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 L_(){return"`"}function R_(e,t){let n=Bu(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))}z_.peek=B_;function z_(e,t,n,r){let i=o_(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(R_(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 B_(e,t,n){return R_(e,n)?`<`:`[`}V_.peek=H_;function V_(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 H_(){return`[`}function U_(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 W_(e){let t=U_(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 G_(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function K_(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 q_(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?G_(n):U_(n),s=e.ordered?o===`.`?`)`:`.`:W_(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),K_(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 J_(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 Y_(e,t,n,r){let i=J_(n),a=n.bulletCurrent||U_(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 X_(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function Z_(e,t,n,r){if(!e.children.some(function(e){return Yg(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function Q_(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}$_.attention=ev,$_.peek=tv;function $_(e,t,n,r){let i=n.enter(`phrasing`),a=w_([S_(e,ev,n,n.createTracker(r))],r.before,r.after);return i(),a}function ev(e,t){return{construct:`strong`,markers:Q_(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function tv(e,t,n){return n.options.strong||`*`}function nv(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 rv(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 iv(e,t,n){let r=(K_(n)+(n.options.ruleSpaces?` `:``)).repeat(rv(n));return n.options.ruleSpaces?r.slice(0,-1):r}var av={blockquote:Xg,break:e_,code:i_,definition:s_,emphasis:T_,hardBreak:e_,heading:k_,html:A_,image:M_,imageReference:P_,inlineCode:I_,link:z_,linkReference:V_,list:q_,listItem:Y_,paragraph:X_,root:Z_,strong:$_,text:nv,thematicBreak:iv};function ov(){return{enter:{table:sv,tableData:dv,tableHeader:dv,tableRow:lv},exit:{codeText:fv,table:cv,tableData:uv,tableHeader:uv,tableRow:uv}}}function sv(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 cv(e){this.exit(e),this.data.inTable=void 0}function lv(e){this.enter({type:`tableRow`,children:[]},e)}function uv(e){this.exit(e)}function dv(e){this.enter({type:`tableCell`,children:[]},e)}function fv(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pv));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pv(e,t){return t===`|`?t:e}function mv(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 Kg(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=av.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hv(){return{exit:{taskListCheckValueChecked:_v,taskListCheckValueUnchecked:_v,paragraph:vv}}}function gv(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yv}}}function _v(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vv(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 yv(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=av.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 bv(){return[lg(),Ng(),Rg(),ov(),hv()]}function xv(e){return{extensions:[ug(),Pg(e),zg(),mv(e),gv()]}}var Sv={tokenize:Iv,partial:!0},Cv={tokenize:Lv,partial:!0},wv={tokenize:Rv,partial:!0},Tv={tokenize:zv,partial:!0},Ev={tokenize:Bv,partial:!0},Dv={name:`wwwAutolink`,tokenize:Pv,previous:Vv},Ov={name:`protocolAutolink`,tokenize:Fv,previous:Hv},kv={name:`emailAutolink`,tokenize:Nv,previous:Uv},Av={};function jv(){return{text:Av}}for(var Mv=48;Mv<123;)Av[Mv]=kv,Mv++,Mv===58?Mv=65:Mv===91&&(Mv=97);Av[43]=kv,Av[45]=kv,Av[46]=kv,Av[95]=kv,Av[72]=[kv,Ov],Av[104]=[kv,Ov],Av[87]=[kv,Dv],Av[119]=[kv,Dv];function Nv(e,t,n){let r=this,i,a;return o;function o(t){return!Wv(t)||!Uv.call(r,r.previous)||Gv(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Wv(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ev,u,l)(t):t===45||t===95||td(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&&ed(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Pv(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Vv.call(r,r.previous)||Gv(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Sv,e.attempt(Cv,e.attempt(wv,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Fv(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Hv.call(r,r.previous)&&!Gv(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(ed(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||rd(t)||cd(t)||dd(t)||ud(t)?n(t):e.attempt(Cv,e.attempt(wv,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Iv(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 Lv(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Tv,c,s)(t):t===null||cd(t)||dd(t)||t!==45&&ud(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 Rv(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(Tv,t,a)(o):o===null||cd(o)||dd(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zv(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||cd(o)||dd(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||cd(e)||dd(e)?t(e):r(e)}function a(e){return ed(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):ed(t)?(e.consume(t),o):n(t)}}function Bv(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return td(e)?n(e):t(e)}}function Vv(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||cd(e)}function Hv(e){return!ed(e)}function Uv(e){return!(e===47||Wv(e))}function Wv(e){return e===43||e===45||e===46||e===95||td(e)}function Gv(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 Kv={tokenize:ey,partial:!0};function qv(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Zv,continuation:{tokenize:Qv},exit:$v}},text:{91:{name:`gfmFootnoteCall`,tokenize:Xv},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Jv,resolveTo:Yv}}}}function Jv(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=$u(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 Yv(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 Xv(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||cd(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes($u(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return cd(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 Zv(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||cd(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=$u(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return cd(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),md(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Qv(e,t,n){return e.check(Md,t,e.attempt(Kv,t,n))}function $v(e){e.exit(`gfmFootnoteDefinition`)}function ey(e,t,n){let r=this;return md(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 ty(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&&Ku(o,o.length,0,Td(s,e.slice(r+1,n),t)),Ku(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ku(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=wd(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=wd(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ny=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){ry(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 ry(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 iy(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 ay(){return{flow:{null:{name:`table`,tokenize:oy,resolveAll:sy}}}}function oy(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):sd(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):ld(t)?md(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||cd(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,ld(t)?md(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 ld(t)?md(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||sd(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 ld(t)?md(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||sd(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||sd(n)?(e.exit(`tableRow`),t(n)):ld(n)?md(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||cd(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 sy(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 ny;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ly(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=cy(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=cy(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=cy(f,t,o,i,n,d)):(o[0]=o[1],d=cy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ly(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=iy(t.events,n))}return e}function cy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uy(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uy(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=uy(t.events,n[2]),a=uy(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({},uy(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ly(e,t,n,r,i){let a=[],o=uy(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 uy(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var dy={name:`tasklistCheck`,tokenize:py};function fy(){return{text:{91:dy}}}function py(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 cd(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 sd(r)?t(r):ld(r)?e.check({tokenize:my},t,n)(r):n(r)}}function my(e,t,n){return md(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hy(e){return Yu([jv(),qv(),ty(e),ay(),fy()])}var gy={};function _y(e){let t=this,n=e||gy,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hy(n)),a.push(bv()),o.push(xv(n))}var vy=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),yy=e=>new RegExp(String.raw`(?<![\p{L}\p{N}_&#])(${e.map(vy).join(`|`)})([1-9]\d{0,5})(?![\p{L}\p{N}_…]|[.,]\p{N})`,`gu`),by=new Set([`code`,`pre`,`kbd`,`samp`,`a`]);function xy(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?yy(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`&&!by.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 Sy(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 Cy=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??=xy(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}`}},wy=class extends Cy{picker;pickWith(e){if(this.picker)throw Error(`There are two # lists.`);this.picker=e}list(){return this.picker}},Ty=(0,d.createContext)(null);function Ey(){return(0,d.useContext)(Ty)}var Dy=new wy;function Oy({board:e,kinds:t=Dy,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,X.jsx)(Ty.Provider,{value:r,children:n})}function ky(e){let{kind:t,number:n,inert:r,children:i}=e,a=Ey(),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,X.jsx)(`span`,{className:`ref-chip ref-deleted${r?` is-inert`:``}`,title:`Deleted by ${c}, for good`,children:s});if(!o)return(0,X.jsx)(X.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,X.jsx)(`span`,{...l,onClick:e,children:s})}return(0,X.jsx)(`a`,{...l,href:o.href,draggable:!1,onClick:e=>e.stopPropagation(),children:s})}var Ay=[`blockQuote`,`codeFenced`,`codeIndented`,`definition`,`gfmFootnoteDefinition`,`headingAtx`,`htmlFlow`,`list`,`setextUnderline`,`table`,`thematicBreak`];function jy(){let e=this.data();(e.micromarkExtensions??=[]).push({disable:{null:Ay}})}var My=[_y],Ny=[_y,jy];function Py(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 Fy=e=>e!==``&&!/^([a-z][a-z0-9+.-]*:|[#/?])/i.test(e);function Iy(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=Fy(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 Ly=e=>e.startsWith(Rt(q.asset,{id:``}))||/^data:/i.test(e),Ry={x:0,y:0},zy=e=>Ry={x:e.clientX,y:e.clientY},By=e=>e.detail>0&&Math.abs(e.clientX-Ry.x)+Math.abs(e.clientY-Ry.y)>4;function Vy(e,t){e.preventDefault(),By(e)||e.currentTarget.closest(`.md`)?.querySelector(`#${CSS.escape(t)}`)?.scrollIntoView({block:`nearest`})}function Hy({node:e,...t}){let n=Sy(t[`data-ref`]);if(n)return(0,X.jsx)(ky,{...n,children:t.children});let r=t.href??``;return t[`data-here`]?(0,X.jsx)(`a`,{...t,draggable:!1,onMouseDown:zy,onClick:e=>By(e)&&e.preventDefault()}):r.startsWith(`#`)?(0,X.jsx)(`a`,{...t,draggable:!1,onMouseDown:zy,onClick:e=>Vy(e,r.slice(1))}):(0,X.jsx)(`a`,{...t,draggable:!1,target:`_blank`,rel:`noreferrer`,onMouseDown:zy,onClick:e=>By(e)&&e.preventDefault()})}var Uy={p:({children:e})=>(0,X.jsx)(X.Fragment,{children:e})};function Wy(){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 Gy=(0,d.createContext)(void 0);function Ky({node:e,...t}){let n=(0,d.useContext)(Gy),r=Number(t[`data-task-line`]);if(!n||t.type!==`checkbox`||!r)return(0,X.jsx)(`input`,{...t});let i=!!t.checked;return(0,X.jsx)(`input`,{type:`checkbox`,className:`task-box nodrag`,checked:i,onChange:e=>n(r,e.currentTarget.checked),onDoubleClick:e=>e.stopPropagation()})}function qy({children:e,inline:t=!1,onTick:n,beside:r,rehypePlugins:i,components:a}){let o=Ey(),s=t?[Py]:[Wy,[Py,{shows:Ly}]];r&&s.unshift([Iy,r]),o?.scanner&&s.push([o.scanner.rehype,{known:o.known}]);let c=(0,X.jsx)(Xh,{remarkPlugins:t?Ny:My,rehypePlugins:[...s,...i??[]],components:{a:Hy,...t?Uy:{input:Ky},...a},children:e});return t?(0,X.jsx)(`span`,{className:`md-inline`,children:c}):(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(Gy.Provider,{value:n,children:c})})}function Jy(e){return(0,X.jsx)(qy,{...e,inline:!0})}function Yy(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 Xy(e){let t=(Date.now()-Date.parse(e))/36e5;return t>=24&&t<48?`yesterday`:Yy(e)}var Zy={"arrow-right":(0,X.jsx)(`path`,{d:`M3 8h10M9 4l4 4-4 4`}),"arrow-left":(0,X.jsx)(`path`,{d:`M13 8H3M7 4 3 8l4 4`}),"arrow-up":(0,X.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-up-left":(0,X.jsx)(`path`,{d:`M11.5 11.5 4.5 4.5M4.5 10V4.5H10`}),"chevron-down":(0,X.jsx)(`path`,{d:`m4.5 6.25 3.5 3.5 3.5-3.5`}),"chevron-left":(0,X.jsx)(`path`,{d:`M9.75 4.5 6.25 8l3.5 3.5`}),expand:(0,X.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,X.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,X.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,X.jsx)(`path`,{d:`M8 3v10M3 8h10`}),x:(0,X.jsx)(`path`,{d:`m4.5 4.5 7 7m0-7-7 7`}),edit:(0,X.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,X.jsx)(`path`,{d:`m3.5 8.5 3 3 6-7`}),sync:(0,X.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,X.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,X.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,X.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,X.jsxs)(X.Fragment,{children:[(0,X.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,X.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,X.jsxs)(X.Fragment,{children:[(0,X.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,X.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,X.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,X.jsx)(`path`,{d:`M3.5 8h.01M8 8h.01M12.5 8h.01`,strokeWidth:`2.2`}),details:(0,X.jsx)(`path`,{d:`M3 4.5h10M3 8h10M3 11.5h6`}),archive:(0,X.jsx)(`path`,{d:`M2.5 3.5h11v3h-11ZM3.5 6.5v6h9v-6M6.5 9h3`}),link:(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5`}),(0,X.jsx)(`path`,{d:`M8 3a5 5 0 0 1 0 10Z`,fill:`currentColor`,stroke:`none`})]}),star:(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`}),(0,X.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,X.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,X.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,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:`M10.9 5.6A5 5 0 1 0 12 9`}),(0,X.jsx)(`path`,{d:`M5 10.6a2.6 2.6 0 0 0 4 0`}),(0,X.jsx)(`path`,{d:`M5.3 7.6h.01M8.7 7.6h.01`,strokeWidth:`2`}),(0,X.jsx)(`path`,{d:`M13 1.75v3.5M11.25 3.5h3.5`})]}),globe:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,X.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,X.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,X.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,X.jsx)(`path`,{d:`M6 4v8M10 4v8`}),trash:(0,X.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,X.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,X.jsx)(`path`,{d:`M4 2.5h5.25L12 5.25v8.25H4ZM9 2.75V5.5h2.75M6 8.5h4M6 11h2.5`}),diagram:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`2.5`,width:`5`,height:`4`,rx:`1`}),(0,X.jsx)(`rect`,{x:`9`,y:`9.5`,width:`5`,height:`4`,rx:`1`}),(0,X.jsx)(`path`,{d:`M4.5 6.5v3.5a1.5 1.5 0 0 0 1.5 1.5h3`})]}),image:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,X.jsx)(`circle`,{cx:`5.75`,cy:`6.5`,r:`1.1`}),(0,X.jsx)(`path`,{d:`m2.5 12 3.5-3.5 2.5 2.5 2-2 3 3`})]}),table:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M2 6h12M2 9.75h12M6.5 6v7.5`})]}),chart:(0,X.jsx)(`path`,{d:`M2.5 13.5h11M4.5 13.5V9M8 13.5V4.5M11.5 13.5V7`}),scene:(0,X.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,X.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,X.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,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`1.75`,y:`2.25`,width:`12.5`,height:`11.5`,rx:`2`,strokeDasharray:`1.5 2.25`}),(0,X.jsx)(`rect`,{x:`4.5`,y:`5`,width:`3.25`,height:`3`,rx:`.75`}),(0,X.jsx)(`rect`,{x:`8.25`,y:`8`,width:`3.25`,height:`3`,rx:`.75`})]})};function Q({name:e,className:t}){return(0,X.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:Zy[e]})}function Qy(e){let t=0;for(let n of e)t=(t*31+n.charCodeAt(0))%360;return t}function $y({actor:e,showName:t=!0,title:n}){let r=e.kind===`human`?{"--hue":Qy(e.name)}:void 0;return(0,X.jsxs)(`span`,{className:`actor actor-${e.kind}`,title:n??`${e.name} (${e.kind})`,children:[(0,X.jsx)(`span`,{className:`actor-mark`,style:r,"aria-hidden":!0,children:e.name.charAt(0).toUpperCase()}),t&&(0,X.jsx)(`span`,{className:`actor-name`,children:e.name})]})}function eb({text:e,block:t}){let[n,r]=(0,d.useState)(!1);return(0,X.jsxs)(`div`,{className:t?`copyline is-block`:`copyline`,children:[(0,X.jsx)(`code`,{children:e}),(0,X.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 tb({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 Uc(r,a,n),(0,X.jsx)(`details`,{ref:n,className:e?`popover ${e}`:`popover`,onToggle:e=>i(e.currentTarget.open),children:typeof t==`function`?t(a):t})}function nb({size:e}){return(0,X.jsx)(`svg`,{className:`board-mark`,width:e,height:e,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsxs)(`g`,{transform:`rotate(45 8 8)`,children:[(0,X.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,X.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,X.jsx)(`rect`,{x:`6.75`,y:`6.75`,width:`2.5`,height:`2.5`,rx:`0.5`,fill:`var(--text)`})]})})}function rb({small:e=!1}){return(0,X.jsxs)(`span`,{className:`brand-lockup${e?` brand-lockup-small`:``}`,children:[(0,X.jsx)(nb,{size:e?22:30}),(0,X.jsx)(`span`,{className:`brand-text`,children:(0,X.jsx)(`span`,{className:`wordmark`,children:`Tricot`})})]})}var ib={scratch:`sketchbook`,files:`files`},ab=e=>encodeURIComponent(e),ob=e=>e?decodeURIComponent(e):void 0,sb=[{pattern:/^\/overview\/p\/([^/]+)/,read:e=>({pinId:ob(e[1])})},{pattern:/^\/sketchbook\/([^/?]+)/,read:e=>({view:`scratch`,pageId:ob(e[1])})},{pattern:/^\/sketchbook/,read:()=>({view:`scratch`})},{pattern:/^\/files(?![^/?])(?:\?path=([^&]*)(&pair)?)?/,read:e=>{let t=ob(e[1]);return{view:`files`,...t?{file:t}:{},...t&&e[2]?{pair:!0}:{}}}}],cb={connectors:{pattern:/^#\/connectors(?:\?from=([^&]+))?/,read:e=>({page:`connectors`,from:ob(e[1])}),link:e=>e?`#/connectors?from=${ab(e)}`:`#/connectors`},board:{pattern:/^#\/b\/([^/]+)/,read:(e,t)=>{let n=decodeURIComponent(e[1]),r=(e.input??``).slice(e[0].length);for(let e of[...sb,...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/${ab(e)}${t?`/${ib[t]}`:``}`,files:(e,t,n)=>`#/b/${ab(e)}/${ib.files}${t?`?path=${ab(t)}${n?`&pair`:``}`:``}`,pin:(e,t)=>`#/b/${ab(e)}/overview/p/${ab(t)}`,scratchPage:(e,t)=>`#/b/${ab(e)}/${ib.scratch}/${ab(t)}`},home:{pattern:/^/,read:()=>({page:`home`}),link:()=>`#/`}};function lb(e,t=[]){for(let n of Object.values(cb)){let r=e.match(n.pattern);if(r)return n.read(r,t)}return{page:`home`}}var ub={newBoard:/\?new$/,ask:/\?ask$/},db={home:cb.home.link,newBoard:()=>`${cb.home.link()}?new`,connectors:cb.connectors.link,board:cb.board.link,context:e=>`#/b/${ab(e)}/overview/context`,askAgents:e=>`${db.context(e)}?ask`,pin:cb.board.pin,page:cb.board.scratchPage,files:cb.board.files},fb=(e,t)=>e.replace(/^#\/b\/[^/]+/,cb.board.link(t)),pb={nameGate:`Your name is attached to what you add, so everyone can see who did what.`},mb=class{views=[];pages=[];landing;sessionHook;headerControls;strip;feedSlot;homeSlots;searchSlot;wordsSet;boardContextSlot;agentWorkSlot;refKindsSet;noRefKinds=new wy;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??pb}boardContext(){return this.boardContextSlot}agentWork(){return this.agentWorkSlot}refKinds(){return this.refKindsSet??this.noRefKinds}},hb=new mb,gb=(0,d.createContext)(hb);function _b({views:e,children:t}){return(0,X.jsx)(gb.Provider,{value:e,children:t})}function vb(){return(0,d.useContext)(gb)}var yb=`tricot:address-replaced`;function bb(e){return window.addEventListener(`hashchange`,e),window.addEventListener(yb,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(yb,e)}}function xb(){return lb((0,d.useSyncExternalStore)(bb,()=>location.hash),vb().pieces())}var Sb=e=>location.hash=e,Cb={home:()=>Sb(db.home()),board:e=>Sb(db.board(e)),scratch:e=>Sb(db.board(e,`scratch`)),page:(e,t)=>Sb(db.page(e,t)),files:(e,t)=>Sb(db.files(e,t)),pin:(e,t)=>Sb(db.pin(e,t))};function wb(e){let t=lb(location.hash);t.page===`board`&&t.pinId&&Tb(e?db.page(t.boardId,e):db.context(t.boardId))}function Tb(e){location.hash!==e&&(history.replaceState(history.state,``,`${location.pathname}${location.search}${e}`),window.dispatchEvent(new Event(yb)))}var Eb=e=>e.test(location.hash);function Db(e){e.test(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}${location.hash.replace(e,``)}`)}function Ob(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 kb=e=>`tricot steps on --agent ${e.id}`;function Ab(e){let t=eo();return{command:`${kb(t)} --name "${e}"`,others:Qa().flatMap(e=>e===t||e.liveSteps===!1?[]:[e.id])}}function jb(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&&m(t.sendsAs,e))??t.find(t=>m(t.agentName,e)||m(t.name,e)||m(t.id,e))??t.find(e=>r(e.agentName.toLowerCase())||r(e.name.toLowerCase()))}function Mb(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=!0;return Y.liveSteps().then(n=>e&&t(n),()=>e&&t(void 0)),()=>{e=!1}},[n]),{report:e,reload:(0,d.useCallback)(()=>r(e=>e+1),[])}}function Nb(e){return e.split("`").map((e,t)=>t%2?(0,X.jsx)(`code`,{children:e},t):e)}function Pb({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=jb(e,r.agents);if(!p){let{command:t,others:n}=Ab(e);return(0,X.jsxs)(`section`,{className:`live-steps`,"aria-labelledby":u,children:[(0,X.jsxs)(`div`,{className:`live-steps-text`,children:[(0,X.jsx)(`span`,{className:`live-steps-title`,id:u,children:`Live steps`}),(0,X.jsxs)(`span`,{className:`live-steps-state`,children:[`Tricot can't tell which tool `,e,` runs in, so there is no switch here.`]})]}),(0,X.jsxs)(`p`,{className:`live-steps-line`,children:[`From a terminal: `,(0,X.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,X.jsxs)(`section`,{className:`live-steps`,"aria-labelledby":u,children:[(0,X.jsxs)(`div`,{className:`live-steps-row`,children:[(0,X.jsxs)(`div`,{className:`live-steps-text`,children:[(0,X.jsx)(`span`,{className:`live-steps-title`,id:u,children:`Live steps`}),(0,X.jsx)(`span`,{className:`live-steps-state${m?` is-on`:``}`,id:f,children:Ob(p)})]}),(0,X.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,X.jsx)(`span`,{className:`live-switch-thumb`,"aria-hidden":!0})})]}),!r.canChange&&r.why&&(0,X.jsx)(`p`,{className:`live-steps-line`,children:r.why}),p.problem&&(0,X.jsx)(`p`,{className:`live-steps-line`,children:p.problem}),p.state===`partly`&&p.missing&&(0,X.jsxs)(`p`,{className:`live-steps-line`,children:[`Missing `,p.missing.join(`, `),`. Turning it on mends it.`]}),p.trust&&p.state!==`off`&&(0,X.jsxs)(`p`,{className:`live-steps-line is-needs-you`,children:[(0,X.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,X.jsx)(`p`,{className:`live-steps-line`,children:p.state===`off`?(0,X.jsxs)(`span`,{children:[`Also set up in `,(0,X.jsx)(`code`,{children:p.alsoInProject}),` from earlier, so steps show from that project.`]}):(0,X.jsxs)(`span`,{children:[`Also set up in `,(0,X.jsx)(`code`,{children:p.alsoInProject}),` from earlier; steps still show once.`,` `,!g&&(0,X.jsx)(`button`,{type:`button`,className:`live-steps-link`,onClick:()=>{c(null),o({action:`off`,scope:`project`})},children:`Tidy up`})]})}),s&&(0,X.jsx)(`p`,{className:`live-steps-done`,role:`status`,children:s.summary}),a&&(0,X.jsx)(zb,{agent:p,person:t,change:a,onCancel:()=>{o(null),l.current?.focus()},onDone:e=>{o(null),c(e),i(),l.current?.focus()}})]})}var Fb={write:`Adds`,add:`Adds`,replace:`Adds`,remove:`Removes`,delete:`Removes`};function Ib({file:e}){return(0,X.jsxs)(`li`,{className:`live-file`,children:[(0,X.jsxs)(`div`,{className:`live-file-head`,children:[(0,X.jsx)(`span`,{className:`live-file-does`,children:Fb[e.does]}),(0,X.jsx)(`code`,{className:`live-file-path`,children:e.path})]}),(0,X.jsxs)(`p`,{className:`live-file-what`,children:[e.what,e.same&&(0,X.jsx)(`span`,{className:`live-file-same`,children:` · there already, not written again`})]})]})}function Lb({files:e}){let t=e.filter(e=>e.lines&&!e.same);return t.length?(0,X.jsxs)(`details`,{className:`live-lines`,children:[(0,X.jsx)(`summary`,{children:`Show the exact lines`}),t.map(e=>(0,X.jsxs)(`div`,{className:`live-lines-file`,children:[(0,X.jsxs)(`p`,{children:[e.does===`remove`||e.does===`delete`?`Out of`:`In`,` `,(0,X.jsx)(`code`,{children:e.path})]}),(0,X.jsx)(`pre`,{className:`live-file-lines`,tabIndex:0,"aria-label":`The lines for ${e.path}`,children:e.lines})]},`${e.does}:${e.path}`))]}):null}var Rb=`button:not(:disabled), input:not(:disabled), summary, [tabindex]:not([tabindex="-1"])`;function zb({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),Y.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 Y.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(Rb)];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,X.jsx)(`div`,{className:`live-sheet-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!l&&r(),children:(0,X.jsxs)(`div`,{className:`live-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":h,ref:m,tabIndex:-1,onKeyDown:b,children:[(0,X.jsxs)(`div`,{className:`live-sheet-body`,children:[(0,X.jsx)(`h3`,{id:h,children:S}),(0,X.jsx)(`p`,{className:`live-sheet-lede`,children:C}),a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`live-sheet-meta`,children:[a.sendsAs&&(0,X.jsxs)(X.Fragment,{children:[`Its steps show as `,(0,X.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,X.jsx)(`ul`,{className:`live-files`,children:a.files.map(e=>(0,X.jsx)(Ib,{file:e},`${e.does}:${e.path}`))}),(0,X.jsx)(Lb,{files:a.files}),a.notes.map(e=>(0,X.jsx)(`p`,{className:`live-sheet-note`,children:Nb(e)},e))]}):!s&&(0,X.jsx)(`p`,{className:`live-sheet-meta`,children:`Reading what is there now…`}),s&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:s})]}),(0,X.jsxs)(`div`,{className:`live-sheet-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:r,disabled:l,children:`Cancel`}),(0,X.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 Bb({tool:e}){let{report:t}=Mb(),n=t?.agents.find(t=>t.id===e);return!n||!n.found||n.state===`on`||n.problem?null:(0,X.jsxs)(`p`,{className:`connect-hint`,children:[(0,X.jsx)(`span`,{className:`connect-hint-mark`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[n.state===`partly`?`${n.name}'s live steps are partly set up`:`No live steps for ${n.name} yet`,`: run `,(0,X.jsx)(`code`,{children:kb(n)}),`, or use the switch in its panel.`]})]})}var Vb=to,Hb=e=>!(!e?.startsOn||e.cantStart),Ub=(e,t)=>m(e.boardName,t)?t:e.name,Wb={one:264,two:336};function Gb(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=wa(t,r),f=Ub(t,n),p=(0,d.useCallback)((e=!1)=>{c(!1),e&&l.current?.focus()},[]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`span`,{className:`agent-rule-chip-label`,children:u??`Its own settings`}),(0,X.jsx)(`svg`,{className:`assignee-caret`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,X.jsx)(`path`,{d:`m4.5 6.5 3.5 3.5 3.5-3.5`})})]}),s&&(0,X.jsx)(Kb,{kind:t,owner:f,rule:r,runsOn:i,anchor:l,under:o,onSet:a,onClose:p})]})}function Kb(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?Wb.two:Wb.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]);Uc(!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=ba(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=el(e.key,r.indexOf(t),r.length);i!==void 0&&(e.preventDefault(),r[i].focus())},D=(e,t,n,r)=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,className:`assignee-option agent-rule-option${t?` is-chosen`:``}`,disabled:v,onClick:n,children:[(0,X.jsx)(`span`,{className:`agent-rule-option-label`,children:e}),t&&(0,X.jsx)(Q,{name:`check`,className:`agent-rule-check`})]},r),O=i&&(wa(t,i)??`its own settings`);return(0,kc.createPortal)((0,X.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,X.jsxs)(`div`,{className:`agent-rule-title`,children:[n,` starts on`]}),(0,X.jsxs)(`div`,{className:`agent-rule-columns${u.length?` is-two`:``}`,children:[(0,X.jsxs)(`div`,{className:`agent-rule-column`,role:`group`,"aria-label":`Model`,children:[(0,X.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,X.jsx)(`form`,{className:`agent-rule-own`,onSubmit:T,children:(0,X.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,X.jsxs)(`div`,{className:`agent-rule-column`,role:`group`,"aria-label":`Thinking`,children:[(0,X.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,X.jsx)(`p`,{className:`agent-rule-error`,role:`alert`,children:b}),(0,X.jsxs)(`p`,{className:`agent-rule-foot`,children:[O&&(0,X.jsxs)(X.Fragment,{children:[`Running now on `,(0,X.jsx)(`strong`,{children:O}),`.`,` `]}),`A change takes effect the next time `,n,` starts; Default passes nothing.`]})]}),document.body)}Qa().flatMap(e=>e.usage.source??[]);var qb=e=>e===void 0?void 0:$a(e)?.usage.shares,Jb=e=>no(e)?.id??e;function Yb(e,t){if(qb(e)===`none`)return $a(e)?.usage.notShared??`${t} keeps its usage to itself.`;if(qb(e)===`tokens`)return`${t} shares tokens and cost, not plan limits.`}var Xb=6e4,Zb=60*Xb,Qb=24*Zb;function $b(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 ex(e,t){let n=e-t;if(n<=0)return;if(n<Xb)return`under a minute`;if(n<Zb)return`${Math.ceil(n/Xb)}m`;if(n<Qb){let e=Math.floor(n/Zb),t=Math.floor(n%Zb/Xb);return t?`${e}h ${t}m`:`${e}h`}let r=Math.floor(n/Qb),i=Math.floor(n%Qb/Zb);return i?`${r}d ${i}h`:`${r}d`}var tx=e=>`${e>0&&e<1?`<1`:Math.round(e)}%`;function nx(e,t){let n=ex(e.resetsAt,t);return`${tx(e.usedPercent)} used${n?` · resets in ${n}`:``}`}var rx=(e,t)=>(e??[]).filter(e=>e.resetsAt>t),ix=e=>e>=95?`at`:e>=80?`near`:`ok`;function ax(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*Qb?`as of ${o} ${i}`:`as of ${a(e)}`}function ox(e){return e<1e3?String(Math.round(e)):e<1e6?`${sx((e/1e3).toFixed(+(e<1e4)))}k`:`${sx((e/1e6).toFixed(+(e<1e7)))}M`}var sx=e=>e.replace(/\.0$/,``),cx=e=>e>0&&e<.01?`under $0.01`:`$${e.toFixed(2)}`,lx=e=>`${e.charAt(0).toUpperCase()}${e.slice(1).replace(/_/g,` `)} plan`;function ux(e){if(e<=0)return`none`;if(e<Xb)return`under a minute`;let t=Math.floor(e/Zb),n=Math.round(e%Zb/Xb);return t?n?`${t}h ${n}m`:`${t}h`:`${n}m`}function dx(e){let t=[`${ox(e.input)} in`,`${ox(e.output)} out`];return e.cacheRead&&t.push(`${ox(e.cacheRead)} from cache`),e.reasoning&&t.push(`${ox(e.reasoning)} reasoning`),`${ox(e.total)} tokens · ${t.join(`, `)}`}function fx(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 px=3e4,mx=15e3;function hx(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}=fx(Date.now());Y.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,px);return()=>{n=!1,clearInterval(o)}},[e,t,i]),n?.key===i?n.value:null}function gx(){let[e,t]=(0,d.useState)(()=>Date.now());return(0,d.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),mx);return()=>clearInterval(e)},[]),e}function _x(e,t,n,r){let i=qb(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=Yb(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 $a(r)?.usage.quiet?.(a,!!n)}function vx({name:e,board:t,liveSteps:n}){let r=hx(e,t?.id),i=gx(),a=(0,d.useId)();if(r===null||n===null)return null;let o=r.usage,s=n?jb(e,n.agents):void 0,c=o?Jb(o.source):s?.id,l=rx(o?.windows,i),u=o&&ax(l.length?o.windowsAt??o.at:o.at,i),f=[o?.plan&&lx(o.plan),u].filter(Boolean).join(` · `),p=_x(e,s,o,c),m=o?yx(o):[];return(0,X.jsxs)(`section`,{className:`agent-usage`,"aria-labelledby":a,children:[(0,X.jsxs)(`div`,{className:`agent-usage-head`,children:[(0,X.jsx)(`span`,{className:`agent-usage-title`,id:a,children:`Usage`}),f&&(0,X.jsx)(`span`,{className:`agent-usage-meta`,children:f})]}),l.length>0&&(0,X.jsx)(`ul`,{className:`usage-windows`,children:l.map(e=>{let t=$b(e),n=ix(e.usedPercent);return(0,X.jsxs)(`li`,{className:`usage-window is-${n}`,children:[(0,X.jsxs)(`div`,{className:`usage-window-line`,children:[(0,X.jsx)(`span`,{className:`usage-window-name`,children:t}),(0,X.jsx)(`span`,{className:`usage-window-text`,children:nx(e,i)})]}),(0,X.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":nx(e,i),children:(0,X.jsx)(`span`,{className:`usage-bar-fill`,style:{width:`${Math.min(100,Math.max(0,e.usedPercent))}%`}})})]},e.id)})}),m.length>0&&(0,X.jsx)(`ul`,{className:`usage-extras`,children:m.map(e=>(0,X.jsx)(`li`,{children:e},e))}),p&&(0,X.jsx)(`p`,{className:`usage-quiet`,children:p}),r.activity&&(0,X.jsx)(xx,{activity:r.activity})]})}function yx(e){let t=[];return e.tokens&&t.push(`${dx(e.tokens)}, this session`),e.costUsd!==void 0&&t.push(no(e.source)?.usage.listPrices?`${cx(e.costUsd)} this session, at list prices`:`${cx(e.costUsd)} this session`),e.context&&t.push(`Context ${tx(e.context.usedPercent)} full, of ${ox(e.context.window)} tokens`),t}var bx=[[`comments`,`Comments and replies`],[`workingMs`,`Time working`]];function xx({activity:e}){let t=[...Nc().activityRows(),...bx],n=(e,t)=>t===`workingMs`?ux(e.workingMs):String(e[t]);return(0,X.jsxs)(`table`,{className:`usage-board`,children:[(0,X.jsxs)(`caption`,{children:[`On `,e.board.title]}),(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`td`,{}),(0,X.jsx)(`th`,{scope:`col`,children:`Today`}),(0,X.jsx)(`th`,{scope:`col`,children:`This week`})]})}),(0,X.jsx)(`tbody`,{children:t.map(([t,r])=>(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{scope:`row`,children:r}),(0,X.jsx)(`td`,{children:n(e.today,t)}),(0,X.jsx)(`td`,{children:n(e.week,t)})]},t))})]})}function Sx(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(0);return(0,d.useEffect)(()=>{let e=!0;return Y.agents().then(n=>e&&t(n),()=>e&&t(e=>e??[])),()=>{e=!1}},[n]),{agents:e,reload:(0,d.useCallback)(()=>r(e=>e+1),[])}}function Cx(){let[e,t]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let e=!0;return Y.agentRules().then(n=>e&&t(n.rules),()=>e&&t({})),()=>{e=!1}},[]),{rules:e,set:(0,d.useCallback)(async(e,n)=>{let r=await Y.setAgentRule(e,{model:n.model??null,effort:n.effort??null});t(r.rules)},[])}}function wx(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 ${Yy(e.lastSeen)}${n}`:`${e.state}${n}`}var Tx=e=>`${e.skills.length} skill${e.skills.length===1?``:`s`}`;function Ex({onOpen:e}){let{agents:t}=Sx();return t===null?null:(0,X.jsxs)(`div`,{className:`user-agents`,children:[(0,X.jsx)(`div`,{className:`user-agents-head`,children:`Agents`}),t.length===0?(0,X.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,X.jsxs)(`button`,{type:`button`,className:`user-agent`,onClick:()=>e(t.name),"aria-haspopup":`dialog`,children:[(0,X.jsx)($y,{actor:{kind:`agent`,name:t.name},showName:!1}),(0,X.jsxs)(`span`,{className:`user-agent-text`,children:[(0,X.jsx)(`span`,{className:`user-agent-name`,children:t.name}),(0,X.jsxs)(`span`,{className:`user-agent-state`,children:[(0,X.jsx)(`span`,{className:`user-agent-dot is-${t.state}`,"aria-hidden":!0}),wx(t)]})]}),(0,X.jsxs)(`span`,{className:`user-agent-count`,children:[Tx(t),` ›`]})]},t.name))]})}function Dx({name:e,person:t,onClose:n}){let{agents:r,reload:i}=Sx(),a=r?.find(t=>m(t.name,e)),[o,s]=(0,d.useState)(`skills`),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=Mb(),{rules:f,set:p}=Cx(),h=Nc().hasWork()?[`skills`,`work`,`activity`]:[`skills`,`activity`],g=Vb(a??{name:e}),_=Hb(g)&&f!==null?g:void 0,v=_&&f?.[_.id]||{},y=_&&Ta(_,a?.runsOn,v);(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 b=a?.reportedAt?`skills reported ${Yy(a.reportedAt)}`:`hasn't reported its skills`;return(0,kc.createPortal)((0,X.jsx)(`div`,{className:`agent-scrim`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,X.jsxs)(`aside`,{className:`agent-panel`,ref:c,role:`dialog`,"aria-modal":`true`,"aria-label":`${e}, an agent`,tabIndex:-1,children:[(0,X.jsxs)(`header`,{className:`agent-head`,ref:l,children:[(0,X.jsx)($y,{actor:{kind:`agent`,name:e},showName:!1}),(0,X.jsxs)(`div`,{className:`agent-head-text`,children:[(0,X.jsx)(`h2`,{children:a?.name??e}),(0,X.jsxs)(`p`,{children:[a&&(0,X.jsx)(`span`,{className:`user-agent-dot is-${a.state}`,"aria-hidden":!0}),a?wx(a,!0):`Loading…`,` · `,b]}),y&&(0,X.jsx)(`p`,{className:`agent-head-runs`,children:y})]}),_&&(0,X.jsx)(Gb,{kind:_,name:a?.name??e,rule:v,runsOn:a?.runsOn,onSet:e=>p(_.id,e),under:l}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small agent-close`,onClick:n,"aria-label":`Close`,children:(0,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(Pb,{name:a?.name??e,person:t,steps:u}),r!==null&&(0,X.jsx)(vx,{name:a?.name??e,board:a?.board,liveSteps:u.report}),(0,X.jsx)(`div`,{className:`agent-tabs`,role:`tablist`,"aria-label":`${e}`,children:h.map(e=>(0,X.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,X.jsx)(`div`,{className:`agent-body`,children:a?o===`skills`?(0,X.jsx)(kx,{agent:a,person:t,onChange:i}):o===`work`?(0,X.jsx)(Mx,{agent:a,onOpen:n}):(0,X.jsx)(Px,{agent:a,onOpen:n}):(0,X.jsx)(`p`,{className:`agent-empty`,children:r===null?`Loading…`:`${e} isn't known to Tricot.`})})]})}),document.body)}function Ox(e,t){return e.tricot?e.tricot.agent?`Tricot skill · just for ${t}`:`Tricot skill · works with every agent`:`its own`}function kx({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,X.jsxs)(X.Fragment,{children:[(0,X.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,X.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,X.jsxs)(`p`,{className:`agent-empty`,children:[`No skill matches “`,r.trim(),`”.`]}):(0,X.jsx)(`ul`,{className:`agent-skills`,children:c.map(n=>n.tricot&&a===n.tricot.id?(0,X.jsx)(`li`,{className:`agent-skill is-editing`,children:(0,X.jsx)(Ax,{agent:e.name,person:t,skill:n,onDone:l,onCancel:()=>o(null)})},`tricot:${n.tricot.id}`):(0,X.jsxs)(`li`,{className:`agent-skill`,children:[(0,X.jsxs)(`div`,{className:`agent-skill-line`,children:[(0,X.jsxs)(`code`,{children:[`/`,n.name,n.call&&` (Tricot)`]}),(0,X.jsx)(`span`,{className:`agent-skill-tag${n.tricot?` is-tricot`:``}`,children:Ox(n,e.name)}),n.tricot&&(0,X.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,X.jsx)(`p`,{className:`agent-skill-desc`,title:n.description,children:n.description}),n.call&&(0,X.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,X.jsx)(`div`,{className:`agent-add is-open`,children:(0,X.jsx)(Ax,{agent:e.name,person:t,onDone:l,onCancel:()=>o(null)})}):(0,X.jsxs)(`button`,{type:`button`,className:`agent-add`,onClick:()=>o(`new`),children:[(0,X.jsx)(Q,{name:`plus`}),` Add a skill`]})]})}function Ax({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,X.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?Y.editSkill(a.id,t,r):Y.addSkill(t,r))},children:[(0,X.jsx)(`div`,{className:`agent-form-head`,children:a?`Edit /${n.name}`:`Add a skill`}),(0,X.jsxs)(`label`,{className:`agent-field`,children:[(0,X.jsx)(`span`,{children:`Name`}),(0,X.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`One word, e.g. weekly-summary`,autoFocus:!0,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`agent-field`,children:[(0,X.jsx)(`span`,{children:`What it does, in one line`}),(0,X.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Write release notes from the last commits`})]}),(0,X.jsxs)(`label`,{className:`agent-field`,children:[(0,X.jsx)(`span`,{children:`Instructions the agent follows when you call it`}),(0,X.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,X.jsxs)(`div`,{className:`agent-field`,children:[(0,X.jsx)(`span`,{children:`Who it is for`}),(0,X.jsxs)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Who it is for`,children:[(0,X.jsx)(`button`,{type:`button`,className:p?``:`is-active`,"aria-pressed":!p,onClick:()=>m(!1),children:`Every agent`}),(0,X.jsxs)(`button`,{type:`button`,className:p?`is-active`:``,"aria-pressed":p,onClick:()=>m(!0),children:[`Just `,e]})]})]}),(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:y}),_?(0,X.jsxs)(`div`,{className:`agent-form-actions`,children:[(0,X.jsxs)(`span`,{className:`small`,children:[`Delete /`,n?.name,` for `,a?.agent?a.agent:`every agent`,`?`]}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:h,onClick:()=>v(!1),children:`Keep it`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small agent-delete`,disabled:h,onClick:()=>void S(()=>Y.deleteSkill(a.id,t)),children:`Delete`})]}):(0,X.jsxs)(`div`,{className:`agent-form-actions`,children:[a&&(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-small agent-delete`,onClick:()=>v(!0),children:[(0,X.jsx)(Q,{name:`trash`}),` Delete`]}),(0,X.jsx)(`span`,{className:`row-spacer`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:i,children:`Cancel`}),(0,X.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 jx(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 Mx({agent:e,onOpen:t}){let n=Nc(),{value:r,error:i}=jx(()=>n.work(e.name),e.name);return i?(0,X.jsx)(`p`,{className:`error agent-empty`,children:i}):r?r.length===0?(0,X.jsx)(`p`,{className:`agent-empty`,children:n.noWork(e.name)}):(0,X.jsx)(`ul`,{className:`agent-rows`,children:r.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:e.href,onClick:t,className:`agent-row`,children:[(0,X.jsxs)(`span`,{className:`agent-row-title`,children:[(0,X.jsx)(`span`,{className:`agent-row-ref`,children:e.ref}),` `,e.title]}),(0,X.jsx)(`span`,{className:`agent-row-meta`,children:e.meta})]})},e.id))}):(0,X.jsx)(`p`,{className:`agent-empty`,children:`Loading…`})}var Nx=30;function Px({agent:e,onOpen:t}){let n=Nc(),r=e.board,{value:i,error:a}=jx(()=>r?Y.events(r.id,{actor:e.name,limit:Nx}):Promise.resolve(null),`${e.name}:${r?.id??``}`);if(!r)return(0,X.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,X.jsx)(`p`,{className:`error agent-empty`,children:a});if(!i)return(0,X.jsx)(`p`,{className:`agent-empty`,children:`Loading…`});if(i.events.length===0)return(0,X.jsxs)(`p`,{className:`agent-empty`,children:[e.name,` hasn't done anything on `,r.title,` yet.`]});let o=e=>{let t=tc(e);return(t&&n.byId(t.kind,r.id,t.id)?.href)??db.board(r.id)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`agent-activity-head`,children:[`On `,r.title,`, newest first`,i.total>i.events.length?` (${i.events.length} of ${i.total})`:``]}),(0,X.jsx)(`ul`,{className:`agent-rows`,children:i.events.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:o(e),onClick:t,className:`agent-row`,children:[(0,X.jsx)(`span`,{className:`agent-row-title`,children:e.summary}),(0,X.jsx)(`span`,{className:`agent-row-meta`,children:Yy(e.at)})]})},e.seq))})]})}function Fx(e,t){return Hi([`tricot`,e,...t?[`--board`,t]:[]])}var Ix=Fi(typeof navigator<`u`&&/Win/.test(navigator.platform)),Lx=`tricot:connect-tool`,Rx=e=>e===`other`||Qa().some(t=>t.id===e);function zx({parts:e}){return(0,X.jsx)(X.Fragment,{children:e.map((e,t)=>typeof e==`string`?e:(0,X.jsx)(`code`,{children:e.code},t))})}function Bx({boardId:e}){let[t,n]=(0,d.useState)(),[r,i]=(0,d.useState)(()=>{try{let e=localStorage.getItem(Lx);return Rx(e)?e:eo().id}catch{return eo().id}});(0,d.useEffect)(()=>{Y.info().then(e=>n(e.mcpUrl),()=>{})},[]);let a=e=>{i(e);try{localStorage.setItem(Lx,e)}catch{}};if(!t)return null;let o=io(t,Ix),s=[...Qa().map(e=>({key:e.id,label:e.name})),{key:ro,label:`Other`}],c=$a(r);return(0,X.jsxs)(`div`,{className:`connect`,children:[(0,X.jsx)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Agent tool`,children:s.map(e=>(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:(0,X.jsx)(zx,{parts:c.panel.intro})}),(0,X.jsx)(eb,{block:c.connect.how===`file`,text:o[c.id]}),c.panel.note&&(0,X.jsx)(`p`,{className:`muted small`,children:(0,X.jsx)(zx,{parts:c.panel.note})}),!c.cantStart&&(0,X.jsx)(Vx,{agent:c.id,name:c.name,boardId:e})]}),r===`other`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:`Any MCP client (Streamable HTTP): point it at this address.`}),(0,X.jsx)(eb,{text:o.other}),(0,X.jsxs)(`p`,{className:`muted small`,children:[`Add `,(0,X.jsx)(`code`,{children:`?agent=Name`}),` to label the agent on the board.`]})]}),r!==`other`&&(0,X.jsx)(Bb,{tool:r}),e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:`Then tell your agent which board to work on:`}),(0,X.jsx)(eb,{text:e})]})]})}function Vx({agent:e,name:t,boardId:n}){return(0,X.jsxs)(`p`,{className:`muted small connect-session`,children:[`Or start `,t,` with the board for one session, its settings left alone: `,(0,X.jsx)(`code`,{children:Fx(e,n)})]})}function Hx(e,t){return e.author.kind===`agent`?t(e.mentions).filter(t=>!m(t,e.author.name)):[]}function Ux(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=Hx(e,t);if(n.length)for(let t of[e.author.name,...n])r.some(e=>m(e,t))||r.push(t)}return r}function Wx(e){return`${g(e)} have gone back and forth here; they'll wait for a person before tagging each other again.`}var Gx=/[\p{L}\p{N}_.\/+\-[\]]/u,Kx=/[\p{L}\p{N}_-]/u,qx=/^(?:$|[\s,;.!?)\]}"'”’…]|:(?:$|\s))/u,Jx=(e,t,n)=>{let r=t;for(;r<e.length&&n.test(e[r]);)r++;return r};function Yx(e,t){if(e[t]!==`:`)return;let n=Jx(e,t+1,Gx);for(;n>t+1&&e[n-1]===`.`;)n--;let r=e.slice(t+1,n),i=n,a=``;if(e[n]===`:`){let t=Jx(e,n+1,Kx);a=e.slice(n+1,t),a&&(i=t)}if((r||a)&&qx.test(e.slice(i)))return{tag:{...r&&{model:r},...a&&{effort:a}},end:i}}function Xx(e){return!e?.model&&!e?.effort?``:e.effort?`:${e.model??``}:${e.effort}`:`:${e.model}`}function Zx(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()))}var Qx=[{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.`}],$x=/^\s*\^([\p{L}\p{N}](?:[\p{L}\p{N}_-]*[\p{L}\p{N}])?)(?![\p{L}\p{N}_-])/u;function eS(e){if(typeof e!=`string`)return;let t=$x.exec(e);if(!t)return;let n=t[1],r=Qx.find(e=>e.name.toLowerCase()===n.toLowerCase());return r?{lens:r}:{unknown:n}}function tS(e,t){return e.deletedCards?.find(e=>e.id===t)}function nS(e,t){return so(e)?.canvas.blocks.find(e=>e.type===`code`&&e.path===t)}function rS(e,t,n){let r=so(e),i=nS(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=>m(t,e));if(t)return t}}}var iS=e=>!!(e&&oo(e));function aS(e,t){let n=t.pageId?e.pages?.find(e=>e.id===t.pageId):void 0,r=t.blockIds?.[0];if(!n||!r||!iS(n))return;let i=n.canvas.blocks.find(e=>e.id===r);return{page:n,blockId:r,...i?.type===`code`&&{path:i.path}}}var oS=(e,t=48)=>qe(e,t);function sS(e){return e.path?`Files · ${oS(e.path)}`:`Files`}var cS={canvas:{name:`Overview`,placeholder:`Ask agents for a view of the project…`,tab:!0},threads:{name:`Threads`,placeholder:`What do you want to work through?`}},lS={},uS=e=>lS[e]??cS[e],dS=e=>uS(e)?.name,fS=e=>uS(e)?.placeholder??``;function pS(e,t){return uS(e)?.question&&t===0?`question`:`thread`}var mS=e=>`${e} block${e===1?``:`s`}`;function hS(e,t){return e.threads?.findLast(e=>e.groupId===t)}var gS=(e,t)=>wi(e).filter(e=>e.fromThread?.id===t.id);function _S(e,t){let n=gS(e,t);return Object.fromEntries(bi().map(({kind:e})=>[`${e}Ids`,n.filter(t=>t.kind.kind===e).map(e=>e.id)]))}var vS=[`👍`,`👎`,`👀`],yS={"👍":`Thumbs up`,"👎":`Thumbs down`,"👀":`Eyes`},bS=[`👍`,`👎`],xS=e=>t=>t.by.kind===e.kind&&m(t.by.name,e.name);function SS(e,t,n){return!!e.reactions?.some(e=>e.emoji===t&&xS(n)(e))}function CS(e,t){return!!e.reactions?.some(e=>bS.includes(e.emoji)&&m(e.by.name,t))}function wS(e){return bS.includes(e)}function TS(e){return vS.flatMap(t=>{let n=(e??[]).filter(e=>e.emoji===t);return n.length?[{emoji:t,reactions:n}]:[]})}var ES={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},DS=ES.message;function OS(e,t=[],n=[]){let r=qS(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 kS(e){let t=e.messages[0];if(e.general||!t||!e.title.endsWith(`…`))return e.title;let n=OS(t.body,t.mentions??[]);return n.length>e.title.length&&n.startsWith(e.title.slice(0,-1))?n:e.title}var AS=ES.lensName,jS=ES.lensBrief;function MS(e){return Qx.find(t=>m(t.name,e.trim()))}function NS(e,t,n){let r=MS(e);return r?.name===`General`&&!n?null:{name:r?.name??e,...!r&&t?{brief:t}:{},...n?{agent:n}:{}}}function PS(e,t,n){let r=tC(e,n.mentions);return r.length||n.author.kind!==`human`||n.mentions?.length?r:t.lens?.agent?[t.lens.agent]:[]}function FS(e,t){let n={kind:`gone`,ref:t};if(t.kind===`comment`){let r=t.on?Ei(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 IS(e,t.id)??n;let r=Ti(e,t.kind,t.id);return r?{kind:r.kind.kind,card:r}:n}function IS(e,t){let n=e.canvas.blocks.find(e=>e.id===t);if(n)return{kind:`block`,block:n};for(let n of wi(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 LS(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 RS(e,t,n){let r=tS(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 zS(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=>m(t.author.name,e))||CS(r,e),o=PS(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`&&CS(r,e.by.name));if(!(nC(e,r.mentions).length||i.length||s))return{message:r,agents:[]}}function BS(e,t=[]){let n=[],r=e=>{let t=e.trim();t&&!n.some(e=>m(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 VS(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&&Ti(e,n.focus.kind,n.focus.id),i=r?.kind.workedBy?r:void 0,a=wi(e).find(e=>e.workedBy?.kind===`agent`&&m(e.workedBy.name,t)),o=i??a;return o?`working on ${o.label}`:`working`}function HS(e){return h(e).map(e=>e.name)}var US=/[\p{L}\p{N}_.@/-]/u,WS=/[\p{L}\p{N}_]/u;function GS(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&&US.test(e[t-1]))continue;let a=e.slice(t+1).toLowerCase(),o=r.find(n=>a.startsWith(n.toLowerCase())&&!WS.test(e[t+1+n.length]??``));if(!o)continue;let s=t+1+o.length,c=n.some(e=>m(e,o))?Yx(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 KS(e,t){let n=[];for(let{name:r}of GS(e,t))n.some(e=>m(e,r))||n.push(r);return n}function qS(e,t,n=[]){let r=e.trimStart();for(;;){let[e]=GS(r,t,n);if(!e||e.start!==0)break;r=r.slice(e.end).replace(/^[\s,:;-]+/,``)}return r.trim()?r:e}function JS(e,t,n=[]){let r=[],i=e.trimStart();for(;;){let[e]=GS(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 YS=/(?:^|[^\p{L}\p{N}_.@/-])@([\p{L}\p{N}_.\- ]{0,30})$/u,XS=/(?:^|\s)\/([\w.:-]{0,60})$/;function ZS(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n.startsWith(r)||n.split(/\s+/).some(e=>e.startsWith(r))}function QS(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 $S(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}=JS(a&&o?`${a} ${o}`:a+o,i),c=`@${n} /${r} `;return{text:c+s,caret:c.length}}function eC(e,t){let n=GS(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 tC(e,t){if(!t?.length)return[];let n=HS(e);return t.filter(e=>!n.some(t=>m(t,e)))}function nC(e,t){if(!t?.length)return[];let n=HS(e);return t.filter(e=>n.some(t=>m(t,e)))}function rC(e,t,n){let r=e=>e.author.kind===`human`&&m(e.author.name,n);return!n||r(e)||!e.mentions?.some(e=>m(e,n))||CS(e,n)?!1:!t.slice(t.indexOf(e)+1).some(r)}var iC=new Set([`code`,`pre`,`kbd`,`samp`,`a`]);function aC({names:e,agents:t=[]}){return n=>{if(e.length===0)return;let r=n=>{n.children=n.children.flatMap(n=>{if(n.type===`element`&&!iC.has(n.tagName)&&r(n),n.type!==`text`)return[n];let i=[],a=0;for(let r of GS(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 oC=36e5,sC=2e3,cC=[`listening`,`asleep`,`working`,`away`],lC=e=>cC.indexOf(e);function uC(e){let t=e,n=bi().find(e=>t[e.kind]);return n&&new vi(n,t[n.kind])}function dC(e,t,n){if(n.paired)return;if(n.author?.kind===`agent`){let t=Hx({author:n.author,mentions:n.mentions},t=>tC(e,t));return t.length&&!n.held?t:void 0}let r=tC(e,n.mentions);if(r.length)return r;if(nC(e,n.mentions).length)return;if(`thread`in t)return t.thread.lens?.agent?[t.thread.lens.agent]:[];let i=uC(t)?.followedBy;return i?[i]:[]}function fC({board:e,where:t,said:n,after:r,agents:i,steps:a}){let o=dC(e,t,n);if(!o)return;let s=r.filter(e=>e.author.kind===`agent`),c=e=>s.some(t=>m(t.author.name,e))||CS(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`&&wS(e.emoji))))return{state:`replied`};let u=Date.parse(n.at),d=uC(t),f=d&&{kind:d.kind.kind,id:d.id},p=`thread`in t?t.thread.id:void 0,h=e=>!!(f&&e&&e.kind===f.kind&&e.id===f.id),g=e=>p?e.thread===p:`boardContext`in t?!e.card&&!e.thread:h(e.card),_=(n.reactions??[]).filter(e=>e.by.kind===`agent`&&e.emoji===`👀`),v=(o.length?l:jC([...i.filter(e=>e.state!==`away`).map(e=>e.name),..._.map(e=>e.by.name),...a.filter(g).map(e=>e.agent)])).map(t=>{let n=i.find(e=>m(e.name,t)),r=AC(a.filter(e=>m(e.agent,t)&&g(e)&&!e.done&&Date.parse(e.at)>=u-sC));if(r)return{rank:6,delivery:{state:`working`,agent:r.agent,step:r}};if(n&&n.state!==`listening`&&n.state!==`asleep`&&h(n.focus)&&Date.parse(n.lastSeen)>=u-sC)return{rank:5,delivery:{state:`working`,agent:n.name}};let o=n?.focus&&!h(n.focus)?Ti(e,n.focus.kind,n.focus.id)?.label:void 0,s=_.find(e=>m(e.by.name,t));if(s){let e=Date.parse(s.at)-sC,r=a.some(n=>m(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)+sC,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}}}}),y=v.reduce((e,t)=>t.rank>e.rank?t:e,{rank:0}),b=e=>v.flatMap(t=>t.delivery?.state===`delivered`&&e(t.delivery)?t.delivery.agents:[]),x=b(e=>e.listening),S=b(e=>!!e.asleep?.length);if(y.delivery?.state===`delivered`&&x.length+S.length>0)return{state:`delivered`,agents:[...x,...S],listening:x.length>0,...S.length&&{asleep:S}};if(y.delivery)return y.delivery;let C=kC(e,i,o.length?l:void 0);return o.length?{state:`waiting`,agents:l,...C&&{last:C}}:i.length?{state:`waiting`,agents:[],...C&&{last:C}}:{state:`nobody`}}function pC(e,t){switch(e.state){case`replied`:return;case`working`:return e.step?`${e.agent} · ${CC(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 ${MC(r.at,t)}`:`not listening`}`:`Waiting for an agent${r?` · ${r.name} was last seen ${MC(r.at,t)}`:``}`}case`nobody`:return`No agent is listening on this board`}}var mC=`Start listening on Tricot`;function hC(e,t){if(e?.state===`waiting`)return e.agents[0]??e.last?.name??t[0];if(e?.state===`nobody`)return t[0]}function gC(e,t){if(t.length!==0)return`${e[0]??t[0]} isn't listening here`}function _C(e){if(e.length!==0)return e.length>2?`${e.length} agents`:e.join(` and `)}function vC(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 yC(e,t){let n=vC(e,t);return n?`Reply to ${n}…`:`Reply…`}function bC(e,t){return`${e} isn't listening${t.state===`nobody`?` yet`:``}.`}function xC(e,t){return t?`In ${t}, say:`:`Say to ${e}:`}function SC(e,t,n){return`${bC(e,n)} ${xC(e,t)} “${mC}”`}function CC(e){return e.narration?`“${e.text}”`:e.ended&&e.ms!==void 0&&e.ms>=1e3?`${e.text} (${_(e.ms)})`:e.text}function wC(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 TC(e,t){if(e===`casting`||e===`working`)return t??(e===`casting`?`cast`:`knit`)}function EC(e,t){return e!==void 0&&t?.state===`replied`}function DC(e,t,n){return`${e}\nAsked ${_(Math.max(0,n-Date.parse(t.at)))} ago`}function OC(e,t){return t-Date.parse(e.at)<oC}function kC(e,t,n){let r=e=>!n||n.some(t=>m(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 AC(e){return e.reduce((e,t)=>!e||Date.parse(t.at)>Date.parse(e.at)?t:e,void 0)}function jC(e){return e.filter((t,n)=>e.findIndex(e=>m(e,t))===n)}function MC(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`}var NC={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 ${Yy(e)}).`},away:{label:`not checking`,meaning:e=>`Last checked the board ${Yy(e)}; nudge it in its session if you're waiting on it.`}},PC=`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.`,FC=150;function IC({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),[]),Uc(r,(0,d.useCallback)(e=>{e&&a.current?.contains(document.activeElement)&&o.current?.focus(),i(!1)},[]),a),!e)return(0,X.jsx)(`div`,{className:`live`,title:`Reconnecting…`,children:(0,X.jsxs)(`span`,{className:`live-label`,children:[(0,X.jsx)(`span`,{className:`live-dot`}),` Offline`]})});let l=e=>{clearTimeout(c.current),c.current=setTimeout(()=>i(e),FC)},u=()=>a.current?.contains(document.activeElement)??!1,f=[...t].sort((e,t)=>lC(e.state)-lC(t.state)),p=f[0]?.state??`listening`,m=t.length===0?`No agents`:t.length===1?`${t[0].name} · ${NC[t[0].state].label}`:`${t.length} agents`;return(0,X.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,X.jsxs)(`button`,{ref:o,type:`button`,className:`live-label live-on live-${p}`,"aria-expanded":r,onClick:()=>i(!0),children:[(0,X.jsx)(`span`,{className:`live-dot`}),(0,X.jsx)(`span`,{className:`live-words`,children:m})]}),r&&(0,X.jsx)(`div`,{className:`live-card`,role:`group`,"aria-label":`Agents on this board`,children:t.length===0?(0,X.jsx)(`p`,{className:`live-card-empty`,children:`No agent has used this board in the last 5 minutes.`}):(0,X.jsx)(`ul`,{className:`live-agents`,children:f.map(e=>(0,X.jsxs)(`li`,{className:`live-agent`,children:[(0,X.jsxs)(`div`,{className:`live-agent-head`,children:[(0,X.jsx)($y,{actor:{kind:`agent`,name:e.name}}),(0,X.jsxs)(`span`,{className:`live-state live-${e.state}`,children:[(0,X.jsx)(`span`,{className:`live-dot`}),NC[e.state].label]})]}),(0,X.jsx)(`p`,{className:`live-agent-meaning`,children:e.stuck?PC:NC[e.state].meaning(e.lastSeen)}),n?.(e)]},e.name))})})]})}var LC=45e3,RC=12e4,zC=15e3,BC=6e5,VC=72e4;function HC(e){return e.done?[zC]:e.running?[BC,VC]:[LC,RC]}function UC(e,t){let n=Math.max(0,t-Date.parse(e.at)),[r,i]=HC(e);return i===void 0?n<r?`dim`:void 0:n<r?`live`:n<i?`dim`:void 0}function WC(e,t){let n=Math.max(0,t-Date.parse(e.at)),r=HC(e).find(e=>e>n);return r===void 0?1/0:r-n}var GC=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))},KC=(0,d.createContext)(null),qC=KC.Provider,JC=[],YC={get:()=>JC,subscribe:()=>()=>{}};function XC(){let e=(0,d.useContext)(KC)??YC;return(0,d.useSyncExternalStore)(e.subscribe,e.get)}var ZC=e=>e===`live`?`working`:`resting`,QC=e=>CC(e);function $C({text:e,className:t=``}){let n=y(e);return n?(0,X.jsxs)(`span`,{className:`${t} step-text`,children:[(0,X.jsx)(`span`,{className:`step-lead`,children:n.lead}),(0,X.jsx)(`span`,{className:`step-dirs`,children:n.dirs}),n.head&&(0,X.jsx)(`span`,{className:`step-head`,children:n.head}),(0,X.jsx)(`span`,{className:`step-tail`,children:n.tail}),n.after&&(0,X.jsx)(`span`,{className:`step-after`,children:n.after})]}):(0,X.jsx)(`span`,{className:t,children:e})}function ew(e){let[t,n]=(0,d.useState)(()=>Date.now()),r=Math.max(t,Date.now()),i=e?WC(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 tw=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)??JC;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))},nw=(0,d.createContext)(null),rw=nw.Provider;function iw(){let[e]=(0,d.useState)(()=>new tw);return(0,d.useEffect)(()=>{let t=new _s(Rt(q.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=>Oc.set(JSON.parse(e.data))),t.addEventListener(`admissions`,e=>vs.set(JSON.parse(e.data))),()=>t.close()},[e]),e}var aw={of:()=>JC,subscribe:()=>()=>{}};function ow(e,t){let n=new Map;for(let r of e){let e=r.agent.toLowerCase(),i=n.get(e);UC(r,t)&&(!i||Date.parse(r.at)>Date.parse(i.at))&&n.set(e,r)}return n}function sw(e,t,n){let r=ow(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 cw(e){let t=(0,d.useContext)(nw)??aw;return(0,d.useSyncExternalStore)(t.subscribe,()=>t.of(e))}var lw=`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`,uw=e=>(document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)),dw=()=>document.visibilityState===`hidden`;function fw({state:e,leaving:t=!1}){let n=(0,d.useSyncExternalStore)(uw,dw,()=>!1),[r,i]=(0,d.useState)(()=>TC(e,void 0)),a=TC(e,r);return a!==r&&i(a),e?(0,X.jsx)(`span`,{className:`stitch is-${a?`working`:e}${a===`cast`?` is-cast-on`:``}${t?` is-leaving`:``}${n?` is-paused`:``}`,"aria-hidden":!0,children:(0,X.jsx)(`svg`,{viewBox:`0 0 24 8.8`,children:(0,X.jsx)(`path`,{className:`stitch-yarn`,d:lw,pathLength:100})})}):null}var pw=(0,d.createContext)([]),mw=pw.Provider,hw=()=>(0,d.useContext)(pw);function gw(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 _w(){let e=Nc().hasWork();return t=>e?t.on:void 0}function vw(e,t){return e.state===`working`?t?`working on ${t}`:`working`:e.state===`listening`||e.state===`asleep`?e.state:`not checking`}var yw=5e4,bw=1e4,xw=3e3,Sw=300,Cw=2,ww=e=>e.status===404,Tw=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>yw&&this.reconnect()},bw),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===Cw&&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&&ww(e))return this.gone();this.session.onError(e.message),this.retry=setTimeout(()=>void this.reload(),xw)}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(Rt(q.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===Cw&&!this.stopped&&(this.retry=setTimeout(()=>this.reconnect(),xw),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=Xs(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&&Qs(e.tally,Zs(t))}async verify(){for(let e=0;e<2;e++){let t;try{t=await this.session.fetchLive()}catch(e){return ww(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,Sw))}this.reload()}};function Ew(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 GC);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 Tw({boardId:e,held:t,feed:e=>sc(ec(e)),fetchBoard:()=>Y.board(e),fetchLive:()=>Y.live(e),open:e=>new _s(e),onBoard:e=>{l.current=e,n(e)},onError:i,onLive:o,onDeleted:()=>c(!0),onSteps:e=>u.set(e),onApprovals:e=>Oc.set(e),onAdmissions:e=>vs.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 Dw(){let[e,t]=(0,d.useState)(null),n=(0,d.useCallback)(()=>{Y.boards().then(t,()=>{})},[]);return(0,d.useEffect)(()=>{n();let e=setInterval(n,5e3);window.addEventListener(`focus`,n);let t=Es(n);return()=>{clearInterval(e),window.removeEventListener(`focus`,n),t()}},[n]),{boards:e,refresh:n}}var Ow=/(?:^|\s)\^([\p{L}\p{N}_-]{0,30})$/u;function kw(e){let t=e.match(Ow);return t?{at:e.length-t[1].length-1,query:t[1]}:null}function Aw(e){let t=eS(e);return t&&(`lens`in t?t.lens.name:t.unknown)}var jw=e=>Aw(`^${e}`)?.length===e.length;function Mw(e,t){let n=t.toLowerCase(),r=e.filter(e=>ZS(e.name,t));return[...r.filter(e=>e.name.toLowerCase().startsWith(n)),...r.filter(e=>!e.name.toLowerCase().startsWith(n))]}function Nw(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=Aw(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 Pw(e,t){let n=``,r=0;for(let{start:i,end:a}of Nw(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 Fw(e,t){let n=Nw(e,t).at(-1)?.name;return{body:Pw(e,t).trim(),...n&&{lens:n}}}function Iw(e,t,n,r){let i=Pw(e.slice(0,t.at),r),a=Pw(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 Lw=RegExp(`^/(${`^[A-Za-z0-9][\\w.:-]*$`.slice(1,-1)})(?=\\s|$)`);function Rw(e,t,n){let r=t.map(e=>e.agent),{names:i,rest:a}=JS(e,[...n,...r],r),o=Lw.exec(a);if(!o)return;let s=i.filter(e=>t.some(t=>m(t.agent,e)));if(i.length>0&&s.length===0)return;let c=i.length>0?t.filter(e=>s.some(t=>m(e.agent,t))):t,l=e=>i.length>0||!e.tricot||e.tricot.agent!==void 0,u=e=>e.skills.find(e=>m(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]),h=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:h,end:h+o[0].length}}[...cC.map(e=>e===`away`?`idle`:e)];function zw({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 Bw(e){let t=MS(e?.name??`General`);return`lens-${t?t.name.toLowerCase():`own`}`}var Vw=`No lens: agents answer as they see fit.`,Hw=Qx.map(({name:e,brief:t})=>({name:e,brief:t??Vw,tone:Bw({name:e}),...e===`General`&&{current:!0}})),Uw=e=>!!(e?.perMessage&&e.startsOn);function Ww(e,t,n){let r=Zx(e,t),i=Kw(t,n),a=r.findIndex(e=>e===i);return a<0?[void 0,...r]:r.map((e,t)=>t===a?void 0:e)}function Gw(e,t,n,r,i){let a=Ww(e,t,n);return a[(Math.max(0,a.indexOf(r))+i+a.length)%a.length]}var Kw=(e,t)=>e===`model`?t.model:t.effort,qw=(e,t,n)=>t===`model`?Sa(e,n):Ca(e,n),Jw=(e,t,n)=>{let r=Kw(t,n);return r?qw(e,t,r):`Default`};function Yw(e,t,n,r){return r?{words:qw(e,t,r),set:!0}:{words:Jw(e,t,n),set:!1}}function Xw(e,t,n){return Ww(e,t,n).map(r=>r?{value:r,words:qw(e,t,r)}:Kw(t,n)?{value:r,words:Jw(e,t,n),note:`default`}:{value:r,words:`Default`})}var Zw=e=>e.startsOn?.levels?.length?[`model`,`level`]:[`model`],Qw=e=>e===`model`?`Model for this message`:`Thinking for this message`,$w=(e,t)=>`@${e}${Xx(t)}`;function eT(e,t,n,r){let i=t===`model`?`Model`:`Thinking`;if(r)return`${i} for this message: ${qw(e,t,r)}`;let a=Kw(t,n);return a?`${i}: ${qw(e,t,a)}, its rule`:`${i}: its own`}var tT=(0,d.createContext)({boardId:``,me:``,agents:[],people:[]});function nT(){return(0,d.useContext)(tT)}function rT({board:e,me:t,children:n}){let r=(0,d.useMemo)(()=>{let n=e.presence??[],r=BS(e,n.map(e=>e.name)).map(t=>{let r=n.find(e=>m(e.name,t));return{name:t,state:VS(e,t,r),present:!!r,rank:r?lC(r.state):cC.length}});r.sort((e,t)=>e.rank-t.rank);let i=HS(e).filter(e=>!m(e,t));return{boardId:e.id,me:t,agents:r.map(({rank:e,...t})=>t),people:i}},[e,t]);return(0,X.jsx)(tT.Provider,{value:r,children:n})}function iT({comment:e}){let{people:t,me:n}=nT(),r=e.mentions??[],i=r.filter(e=>!m(e,n)&&!t.some(t=>m(t,e))),a=[];return r.length&&a.push([aC,{names:r,agents:i}]),e.skill&&a.push([zw,{name:e.skill.name}]),(0,X.jsx)(qy,{rehypePlugins:a.length?a:void 0,children:e.body})}function aT({lens:e}){return e?(0,X.jsxs)(`span`,{className:`lens-chip ${Bw(e)}`,title:`Asked agents to answer this comment through the ${e.name} lens`,children:[`^`,e.name]}):null}function oT({via:e}){return e?(0,X.jsxs)(`span`,{className:`tag tag-via`,title:`Made by running /${e}, as a person asked`,children:[`via /`,e]}):null}function sT({comment:e,thread:t}){let{me:n}=nT();return rC(e,t,n)?(0,X.jsx)(`span`,{className:`tag tag-asked`,children:`asks you`}):null}var cT=[`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 lT(e,t){let n=getComputedStyle(e),r=document.createElement(`div`);for(let e of cT)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 uT=280,dT=380,fT=36,pT=400,mT=320,hT=380,gT=320,_T=460,vT=34,yT=(e,t)=>e.row===t?e:{row:t,cell:null};function bT(e){return e.present?e.state:`runs next time ${e.name} connects`}function xT(e,t,n,r){let i=nT(),a=Ey()?.picker,o=a?.read,s=(0,d.useRef)(null),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)([]),[p,h]=(0,d.useState)({}),[g,_]=(0,d.useState)({cell:null}),[v,y]=(0,d.useState)(0),b=(0,d.useRef)(null),[x,S]=(0,d.useState)(null),C=(0,d.useRef)(null),w=(0,d.useMemo)(()=>(r??[]).map(e=>e.name),[r]),T=w.length>0,E=(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(YS),a=!i&&o?o(r):null,c=!i&&!a&&n?r.match(XS):null,u=!i&&!a&&!c&&T?kw(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===b.current)return l(null);b.current=null,l(e=>e?.trigger===d.trigger&&e.at===d.at&&e.query===d.query?e:d)},[n,o,T]),D=c?.trigger===`/`,O=c?.trigger===`@`;(0,d.useEffect)(()=>{if(!D&&!O)return;let e=!0;return Y.agents(i.boardId||void 0).then(t=>e&&f(t),()=>{}),O&&Y.agentRules().then(t=>e&&h(t.rules),()=>{}),()=>{e=!1}},[D,O,i.boardId]);let k=c?.trigger===`#`,A=(0,d.useMemo)(()=>{if(!c)return[];if(c.trigger===`#`)return(a?.pick(c.query)??[]).map(e=>({kind:`card`,card:e}));if(c.trigger===`^`)return Mw(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=>to({name:e,tool:u.find(t=>m(t.name,e))?.tool});return[...i.agents.filter(t=>ZS(t.name,e)).map(e=>({kind:`agent`,name:e.name,state:e.state,agent:t(e.name)})),...i.people.filter(t=>ZS(t,e)).map(e=>({kind:`person`,name:e}))].slice(0,8)},[c,i,u,a,r]),j=!!c&&A.length>0,M=Math.min(v,Math.max(A.length-1,0));(0,d.useEffect)(()=>{y(0),_({cell:null})},[c?.trigger,c?.at,c?.query]);let N=j?A[M]:void 0,P=N?.kind===`agent`&&Uw(N.agent)?N:void 0,F=e=>p[e.id]??{},I=e=>g.row===e?{model:g.model,effort:g.effort}:{},L=P&&g.row===P.name?g.cell:null,R=L&&g.open?L:null,z=(e,t)=>{e!==M&&(y(e),_(e=>t?{cell:null}:{...e,cell:null,open:!1}))},B=e=>()=>{g.open||z(e,!1)},ee=c?.trigger===`^`,V=!D&&!k&&!ee&&A.some(e=>e.kind===`agent`),te=V&&A.some(e=>e.kind===`agent`&&Uw(e.agent)),H=D?pT:k?hT:ee?_T:V?dT:uT;(0,d.useLayoutEffect)(()=>{if(!j||!c||!s.current)return S(null);let e=s.current.getBoundingClientRect(),t=lT(s.current,c.at),n=Math.max(e.left,Math.min(t.left-6,e.right-H)),r=Math.max(8,Math.min(n,window.innerWidth-H-8)),i=e.bottom+4,a=D?mT:k?Math.min(gT,64+A.length*32):ee?40+A.length*34+vT:40+A.length*34+(te?fT:0);S(i+a<window.innerHeight?{left:r,top:i}:{left:r,bottom:window.innerHeight-e.top+4})},[j,c,A.length,D,k,ee,te,H]),(0,d.useLayoutEffect)(()=>{j&&C.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`})},[j,M,x]);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}=$S(e,c,n.agent,n.call,re));else if(n.kind===`lens`)({text:i,caret:a}=Iw(e,c,n.lens.name,w));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`&&Uw(n.agent)?Xx(I(n.name)):``;({text:i,caret:a}=QS(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(!P?.agent)return;let{name:n,agent:r}=P;_(i=>{let a=yT(i,n);return{...a,cell:e,[ae(e)]:Gw(r,e,F(r),a[ae(e)],t)}})},se=(e,t,n)=>{t!==M&&y(t),_(t=>t.open&&t.cell===n&&t.row===e.name?{...t,cell:null,open:!1}:{...yT(t,e.name),cell:n,open:!0})},U=(e,t,n)=>_(r=>({...yT(r,e),cell:null,open:!1,[ae(t)]:n})),W=()=>_(e=>({...e,cell:null,open:!1})),ce=e=>{if(!j||e.metaKey||e.ctrlKey||e.altKey)return!1;let t=P?.agent?Zw(P.agent):[],n=L?t.indexOf(L):-1;if(e.key===`ArrowRight`&&P&&t.length)_(e=>({...yT(e,P.name),cell:t[Math.min(n+1,t.length-1)],open:!1}));else if(e.key===`ArrowLeft`&&L)_(e=>({...e,cell:n>0?t[n-1]:null,open:!1}));else if((e.key===`ArrowDown`||e.key===`ArrowUp`)&&L)oe(L,e.key===`ArrowDown`?1:-1);else if(e.key===`ArrowDown`||e.key===`ArrowUp`)z((M+(e.key===`ArrowDown`?1:A.length-1))%A.length,!0);else if(e.key===`Enter`||e.key===`Tab`)ie(A[M]);else if(e.key===`Escape`&&R)W();else if(e.key===`Escape`&&L)_({cell:null});else if(e.key===`Escape`)b.current=c.at,l(null);else return!1;return e.preventDefault(),e.stopPropagation(),!0},le=(e,t)=>{let n=e.agent,r=F(n),i=I(e.name),a=t===M;return(0,X.jsx)(`span`,{className:`mention-tag-cells`,children:Zw(n).map(o=>{let s=i[ae(o)],{words:c,set:l}=Yw(n,o,r,s),u=a&&R===o;return(0,X.jsxs)(`button`,{type:`button`,tabIndex:-1,id:`mention-${t}-${o}`,className:`mention-tag-cell${l?` is-set`:``}${a&&L===o&&!u?` is-focus`:``}`,"aria-label":eT(n,o,r,s),"aria-haspopup":`listbox`,"aria-expanded":u,onClick:n=>{n.stopPropagation(),se(e,t,o)},children:[(0,X.jsx)(`span`,{className:`mention-tag-words`,children:c}),(0,X.jsx)(`svg`,{className:`assignee-caret`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,X.jsx)(`path`,{d:`m4.5 6.5 3.5 3.5 3.5-3.5`})})]},o)})})},ue=()=>{if(!R||!P?.agent)return null;let{name:e,agent:t}=P;return(0,X.jsx)(ST,{anchor:`mention-${M}-${R}`,name:Qw(R),choices:Xw(t,R,F(t)),value:I(e)[ae(R)],onPick:t=>U(e,R,t)})},de=(e,t)=>(0,X.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===M,className:`mention-option${t===M?` is-active`:``}${e.kind===`agent`&&V?` has-tag`:``}`,onMouseEnter:B(t),onClick:()=>ie(e),children:[(0,X.jsx)($y,{actor:{kind:e.kind===`agent`?`agent`:`human`,name:e.name},title:e.name}),e.state&&(0,X.jsx)(`span`,{className:`mention-state`,children:e.state}),e.kind===`agent`&&(Uw(e.agent)?le(e,t):(0,X.jsx)(`span`,{className:`mention-tag-note`,children:`its own model`}))]},`${e.kind}:${e.name}`),fe=()=>{if(!te)return null;if(!P?.agent)return(0,X.jsx)(`div`,{className:`mention-tag-foot`,"aria-live":`polite`,children:(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↵`}),`mention`]})});let e=!!(F(P.agent).model||F(P.agent).effort),t=I(P.name),n=!!(t.model||t.effort),r=!(!L||R);return(0,X.jsxs)(`div`,{className:`mention-tag-foot`,"aria-live":`polite`,children:[r&&(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↑`}),(0,X.jsx)(`kbd`,{children:`↓`}),`change`]}),r||n?(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↵`}),`writes `,(0,X.jsx)(`code`,{children:$w(P.name,t)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↵`}),`mention`,e?`, on its rule`:``]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`→`}),`model and thinking`]})]})]})},pe=(e,t)=>{let n=u.find(t=>t.name===e.agent),r=t===0||A[t-1].agent!==e.agent;return(0,X.jsxs)(`div`,{children:[r&&(0,X.jsxs)(`div`,{className:`mention-menu-head skill-head${n.present?``:` is-away`}`,children:[(0,X.jsx)(`span`,{className:`skill-agent`,children:e.agent}),(0,X.jsx)(`span`,{className:`skill-agent-note`,children:bT(n)})]}),(0,X.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===M,className:`mention-option skill-option${t===M?` is-active`:``}${e.present?``:` is-away`}`,onMouseEnter:()=>y(t),onClick:()=>ie(e),children:[(0,X.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,X.jsx)(`span`,{className:`skill-desc`,children:e.description}),e.tricot&&(0,X.jsx)(`span`,{className:`skill-tricot`,children:`Tricot skill`})]})]},`${e.agent}:${e.tricot?`tricot`:`own`}:${e.name}`)},me=(e,t)=>{let{card:n}=e,{label:r}=n;return(0,X.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===M,className:`mention-option hash-option${t===M?` is-active`:``}`,onMouseEnter:()=>y(t),onClick:()=>ie(e),title:`${r} · ${n.title} · ${n.status}`,children:[(0,X.jsx)(`span`,{className:`hash-option-ref ${n.marker}`,children:r}),(0,X.jsx)(`span`,{className:`hash-option-title`,children:n.title}),(0,X.jsx)(`span`,{className:`mention-state`,children:n.status})]},r)},he=(e,t)=>{let{lens:n}=e;return(0,X.jsxs)(`div`,{id:`mention-${t}`,role:`option`,"aria-selected":t===M,className:`mention-option lens-option${t===M?` is-active`:``}`,onMouseEnter:()=>y(t),onClick:()=>ie(e),title:`${n.name}: ${n.brief}${n.current?` (the thread's lens now)`:``}`,children:[(0,X.jsx)(`span`,{className:`lens-option-name ${n.tone}`,children:n.name}),(0,X.jsx)(`span`,{className:`lens-option-brief`,children:n.brief}),n.current&&(0,X.jsx)(`span`,{className:`lens-option-now`,"aria-label":`The thread's lens now`,children:(0,X.jsx)(Q,{name:`check`})})]},n.name)},ge=A.filter(e=>e.kind===`agent`||e.kind===`person`),_e=A.filter(e=>e.kind===`card`),ve=ge.filter(e=>e.kind===`agent`),ye=ge.filter(e=>e.kind===`person`),be=j&&x?(0,X.jsx)(`div`,{ref:C,className:`mention-menu${D?` skill-menu`:k?` hash-menu`:ee?` lens-menu-list`:``}`,role:`listbox`,"aria-label":D?`Call a skill`:k?a?.name??`Link a card`:ee?`Pick a lens for this message`:`Mention someone`,style:{left:x.left,top:x.top,bottom:x.bottom,width:H},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClickCapture:e=>{if(!g.open)return;let t=e.target.closest(`.mention-tag-cell`);t&&t.id.startsWith(`mention-${M}-`)||(e.stopPropagation(),W())},children:D?(0,X.jsxs)(X.Fragment,{children:[A.map((e,t)=>pe(e,t)),(0,X.jsx)(`div`,{className:`skill-foot`,children:`A message that starts with a skill asks that agent to run it.`})]}):ee?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mention-menu-head`,children:`Lens for this message`}),A.map((e,t)=>he(e,t)),(0,X.jsx)(`div`,{className:`lens-foot`,children:r===Hw?`Only this comment goes through it.`:`Only this message goes through it. The thread keeps its lens.`})]}):k?(0,X.jsx)(X.Fragment,{children:_e.map((e,t)=>(0,X.jsxs)(d.Fragment,{children:[e.card.group&&e.card.group!==_e[t-1]?.card.group&&(0,X.jsx)(`div`,{className:`mention-menu-head`,children:e.card.group}),me(e,t)]},e.card.label))}):(0,X.jsxs)(X.Fragment,{children:[ve.length>0&&(0,X.jsx)(`div`,{className:`mention-menu-head`,children:`Agents on this board`}),ve.map((e,t)=>de(e,t)),ye.length>0&&(0,X.jsx)(`div`,{className:`mention-menu-head`,children:`People`}),ye.map((e,t)=>de(e,ve.length+t)),fe()]})}):null,G=be?(0,kc.createPortal)((0,X.jsxs)(X.Fragment,{children:[be,ue()]}),document.body):null,xe=(0,d.useMemo)(()=>{let t=GS(e,re,ne).map(e=>[e.start,e.end]);for(let n of Nw(e,w))t.push([n.start,n.end,r?.find(e=>e.name===n.name)?.tone]);if(n&&u.length){let n=Rw(e,u.map(e=>({agent:e.name,skills:e.skills,reportedAt:e.reportedAt??``})),re);n&&t.push([n.start,n.end])}return j&&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,j,c,r,w]),Se=R&&P?.agent?Xw(P.agent,R,F(P.agent)).findIndex(e=>e.value===I(P.name)[ae(R)]):-1,Ce=Se>=0?`mention-${M}-${R}-${Se}`:`mention-${M}`;return{field:s,read:E,onKey:ce,menu:G,marks:xe,close:()=>l(null),aria:{"aria-autocomplete":`list`,"aria-expanded":j,"aria-activedescendant":j?Ce:void 0}}}function ST({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,X.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,X.jsx)(`div`,{className:`mention-menu-head`,"aria-hidden":!0,children:t}),n.map((t,n)=>{let a=t.value===r;return(0,X.jsxs)(`div`,{id:`${e}-${n}`,role:`option`,"aria-selected":a,className:`mention-tag-choice${a?` is-chosen`:``}`,onClick:()=>i(t.value),children:[(0,X.jsx)(`span`,{className:`mention-tag-choice-words`,children:t.words}),t.note&&(0,X.jsx)(`span`,{className:`mention-tag-choice-note`,children:t.note}),(0,X.jsx)(`span`,{className:`mention-tag-check`,children:a&&(0,X.jsx)(Q,{name:`check`})})]},t.value??``)})]})}var CT=[`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 wT({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 CT)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,X.jsx)(`mark`,{className:o?`lens-mark ${o}`:void 0,children:e.slice(n,r)},n)),a=r);return i.push(e.slice(a),``),(0,X.jsx)(`span`,{ref:r,className:`mention-backdrop`,"aria-hidden":!0,children:(0,X.jsx)(`span`,{children:i})})}var TT=e=>{let t=e.currentTarget.previousElementSibling;t&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)};function ET(e,t){return(0,d.useCallback)(n=>{e.current=n,typeof t==`function`?t(n):t&&(t.current=n)},[e,t])}function DT({value:e,onValue:t,onKeyDown:n,ref:r,rows:i,skills:a=!1,lenses:o,...s}){let c=xT(e,t,a,o),l=ET(c.field,r),u=c.marks.length>0;return(0,X.jsxs)(`span`,{className:`mention-field${u?` has-marks`:``}`,children:[u&&(0,X.jsx)(wT,{value:e,marks:c.marks,field:c.field}),(0,X.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:TT,onKeyDown:e=>c.onKey(e)||n?.(e)}),c.menu]})}function OT({value:e,onValue:t,onKeyDown:n,ref:r,skills:i=!1,lenses:a,...o}){let s=xT(e,t,i,a),c=ET(s.field,r),l=s.marks.length>0;return(0,X.jsxs)(`span`,{className:`mention-field mention-line${l?` has-marks`:``}`,children:[l&&(0,X.jsx)(wT,{value:e,marks:s.marks,field:s.field}),(0,X.jsx)(`input`,{...o,...s.aria,ref:c,value:e,onChange:e=>{t(e.target.value),s.read()},onSelect:s.read,onBlur:s.close,onScroll:TT,onKeyDown:e=>s.onKey(e)||n?.(e)}),s.menu]})}function kT(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=kT(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var AT={value:()=>{}};function jT(){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 MT(n)}function MT(e){this._=e}function NT(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}})}MT.prototype=jT.prototype={constructor:MT,on:function(e,t){var n=this._,r=NT(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=PT(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]=FT(n[i],e.name,t);else if(t==null)for(i in n)n[i]=FT(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 MT(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 PT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function FT(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=AT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var IT={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 LT(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),IT.hasOwnProperty(t)?{space:IT[t],local:e}:e}function RT(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 zT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function BT(e){var t=LT(e);return(t.local?zT:RT)(t)}function VT(){}function HT(e){return e==null?VT:function(){return this.querySelector(e)}}function UT(e){typeof e!=`function`&&(e=HT(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 jD(r,this._parents)}function WT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function GT(){return[]}function KT(e){return e==null?GT:function(){return this.querySelectorAll(e)}}function qT(e){return function(){return WT(e.apply(this,arguments))}}function JT(e){e=typeof e==`function`?qT(e):KT(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 jD(r,i)}function YT(e){return function(){return this.matches(e)}}function XT(e){return function(t){return t.matches(e)}}var ZT=Array.prototype.find;function QT(e){return function(){return ZT.call(this.children,e)}}function $T(){return this.firstElementChild}function eE(e){return this.select(e==null?$T:QT(typeof e==`function`?e:XT(e)))}var tE=Array.prototype.filter;function nE(){return Array.from(this.children)}function rE(e){return function(){return tE.call(this.children,e)}}function iE(e){return this.selectAll(e==null?nE:rE(typeof e==`function`?e:XT(e)))}function aE(e){typeof e!=`function`&&(e=YT(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 jD(r,this._parents)}function oE(e){return Array(e.length)}function sE(){return new jD(this._enter||this._groups.map(oE),this._parents)}function cE(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}cE.prototype={constructor:cE,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 lE(e){return function(){return e}}function uE(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 cE(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function dE(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 cE(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function fE(e){return e.__data__}function pE(e,t){if(!arguments.length)return Array.from(this,fE);var n=t?dE:uE,r=this._parents,i=this._groups;typeof e!=`function`&&(e=lE(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=mE(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 jD(o,r),o._enter=s,o._exit=c,o}function mE(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function hE(){return new jD(this._exit||this._groups.map(oE),this._parents)}function gE(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 _E(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 jD(s,this._parents)}function vE(){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 yE(e){e||=bE;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 jD(i,this._parents).order()}function bE(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function xE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function SE(){return Array.from(this)}function CE(){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 wE(){let e=0;for(let t of this)++e;return e}function TE(){return!this.node()}function EE(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 DE(e){return function(){this.removeAttribute(e)}}function OE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function kE(e,t){return function(){this.setAttribute(e,t)}}function AE(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function jE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ME(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 NE(e,t){var n=LT(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?OE:DE:typeof t==`function`?n.local?ME:jE:n.local?AE:kE)(n,t))}function PE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function FE(e){return function(){this.style.removeProperty(e)}}function IE(e,t,n){return function(){this.style.setProperty(e,t,n)}}function LE(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function RE(e,t,n){return arguments.length>1?this.each((t==null?FE:typeof t==`function`?LE:IE)(e,t,n??``)):zE(this.node(),e)}function zE(e,t){return e.style.getPropertyValue(t)||PE(e).getComputedStyle(e,null).getPropertyValue(t)}function BE(e){return function(){delete this[e]}}function VE(e,t){return function(){this[e]=t}}function HE(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function UE(e,t){return arguments.length>1?this.each((t==null?BE:typeof t==`function`?HE:VE)(e,t)):this.node()[e]}function WE(e){return e.trim().split(/^|\s+/)}function GE(e){return e.classList||new KE(e)}function KE(e){this._node=e,this._names=WE(e.getAttribute(`class`)||``)}KE.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 qE(e,t){for(var n=GE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function JE(e,t){for(var n=GE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function YE(e){return function(){qE(this,e)}}function XE(e){return function(){JE(this,e)}}function ZE(e,t){return function(){(t.apply(this,arguments)?qE:JE)(this,e)}}function QE(e,t){var n=WE(e+``);if(arguments.length<2){for(var r=GE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?ZE:t?YE:XE)(n,t))}function $E(){this.textContent=``}function eD(e){return function(){this.textContent=e}}function tD(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function nD(e){return arguments.length?this.each(e==null?$E:(typeof e==`function`?tD:eD)(e)):this.node().textContent}function rD(){this.innerHTML=``}function iD(e){return function(){this.innerHTML=e}}function aD(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function oD(e){return arguments.length?this.each(e==null?rD:(typeof e==`function`?aD:iD)(e)):this.node().innerHTML}function sD(){this.nextSibling&&this.parentNode.appendChild(this)}function cD(){return this.each(sD)}function lD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function uD(){return this.each(lD)}function dD(e){var t=typeof e==`function`?e:BT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fD(){return null}function pD(e,t){var n=typeof e==`function`?e:BT(e),r=t==null?fD:typeof t==`function`?t:HT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function mD(){var e=this.parentNode;e&&e.removeChild(this)}function hD(){return this.each(mD)}function gD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _D(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vD(e){return this.select(e?_D:gD)}function yD(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function bD(e){return function(t){e.call(this,t,this.__data__)}}function xD(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 SD(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 CD(e,t,n){return function(){var r=this.__on,i,a=bD(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 wD(e,t,n){var r=xD(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?CD:SD,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function TD(e,t,n){var r=PE(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 ED(e,t){return function(){return TD(this,e,t)}}function DD(e,t){return function(){return TD(this,e,t.apply(this,arguments))}}function OD(e,t){return this.each((typeof t==`function`?DD:ED)(e,t))}function*kD(){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 AD=[null];function jD(e,t){this._groups=e,this._parents=t}function MD(){return new jD([[document.documentElement]],AD)}function ND(){return this}jD.prototype=MD.prototype={constructor:jD,select:UT,selectAll:JT,selectChild:eE,selectChildren:iE,filter:aE,data:pE,enter:sE,exit:hE,join:gE,merge:_E,selection:ND,order:vE,sort:yE,call:xE,nodes:SE,node:CE,size:wE,empty:TE,each:EE,attr:NE,style:RE,property:UE,classed:QE,text:nD,html:oD,raise:cD,lower:uD,append:dD,insert:pD,remove:hD,clone:vD,datum:yD,on:wD,dispatch:OD,[Symbol.iterator]:kD};function PD(e){return typeof e==`string`?new jD([[document.querySelector(e)]],[document.documentElement]):new jD([[e]],AD)}function FD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ID(e,t){if(e=FD(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 LD={passive:!1},RD={capture:!0,passive:!1};function zD(e){e.stopImmediatePropagation()}function BD(e){e.preventDefault(),e.stopImmediatePropagation()}function VD(e){var t=e.document.documentElement,n=PD(e).on(`dragstart.drag`,BD,RD);`onselectstart`in t?n.on(`selectstart.drag`,BD,RD):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function HD(e,t){var n=e.document.documentElement,r=PD(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,BD,RD),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 UD=e=>()=>e;function WD(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}})}WD.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function GD(e){return!e.ctrlKey&&!e.button}function KD(){return this.parentNode}function qD(e,t){return t??{x:e.x,y:e.y}}function JD(){return navigator.maxTouchPoints||`ontouchstart`in this}function YD(){var e=GD,t=KD,n=qD,r=JD,i={},a=jT(`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`,_,LD).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&&(PD(n.view).on(`mousemove.drag`,m,RD).on(`mouseup.drag`,h,RD),VD(n.view),zD(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(BD(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){PD(e.view).on(`mousemove.drag mouseup.drag`,null),HD(e.view,l),BD(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]))&&(zD(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])&&(BD(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])&&(zD(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=ID(l||r,t),p,m,h;if((h=n.call(e,new WD(`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=ID(l||a,t),_=o}u.call(r,e,new WD(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:UD(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:UD(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:UD(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:UD(!!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 XD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ZD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function QD(){}var $D=.7,eO=1/$D,tO=`\\s*([+-]?\\d+)\\s*`,nO=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,rO=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,iO=/^#([0-9a-f]{3,8})$/,aO=RegExp(`^rgb\\(${tO},${tO},${tO}\\)$`),oO=RegExp(`^rgb\\(${rO},${rO},${rO}\\)$`),sO=RegExp(`^rgba\\(${tO},${tO},${tO},${nO}\\)$`),cO=RegExp(`^rgba\\(${rO},${rO},${rO},${nO}\\)$`),lO=RegExp(`^hsl\\(${nO},${rO},${rO}\\)$`),uO=RegExp(`^hsla\\(${nO},${rO},${rO},${nO}\\)$`),dO={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};XD(QD,gO,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fO,formatHex:fO,formatHex8:pO,formatHsl:mO,formatRgb:hO,toString:hO});function fO(){return this.rgb().formatHex()}function pO(){return this.rgb().formatHex8()}function mO(){return kO(this).formatHsl()}function hO(){return this.rgb().formatRgb()}function gO(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=iO.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?_O(t):n===3?new xO(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?vO(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?vO(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=aO.exec(e))?new xO(t[1],t[2],t[3],1):(t=oO.exec(e))?new xO(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=sO.exec(e))?vO(t[1],t[2],t[3],t[4]):(t=cO.exec(e))?vO(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lO.exec(e))?OO(t[1],t[2]/100,t[3]/100,1):(t=uO.exec(e))?OO(t[1],t[2]/100,t[3]/100,t[4]):dO.hasOwnProperty(e)?_O(dO[e]):e===`transparent`?new xO(NaN,NaN,NaN,0):null}function _O(e){return new xO(e>>16&255,e>>8&255,e&255,1)}function vO(e,t,n,r){return r<=0&&(e=t=n=NaN),new xO(e,t,n,r)}function yO(e){return e instanceof QD||(e=gO(e)),e?(e=e.rgb(),new xO(e.r,e.g,e.b,e.opacity)):new xO}function bO(e,t,n,r){return arguments.length===1?yO(e):new xO(e,t,n,r??1)}function xO(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}XD(xO,bO,ZD(QD,{brighter(e){return e=e==null?eO:eO**+e,new xO(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$D:$D**+e,new xO(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new xO(EO(this.r),EO(this.g),EO(this.b),TO(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:SO,formatHex:SO,formatHex8:CO,formatRgb:wO,toString:wO}));function SO(){return`#${DO(this.r)}${DO(this.g)}${DO(this.b)}`}function CO(){return`#${DO(this.r)}${DO(this.g)}${DO(this.b)}${DO((isNaN(this.opacity)?1:this.opacity)*255)}`}function wO(){let e=TO(this.opacity);return`${e===1?`rgb(`:`rgba(`}${EO(this.r)}, ${EO(this.g)}, ${EO(this.b)}${e===1?`)`:`, ${e})`}`}function TO(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function EO(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function DO(e){return e=EO(e),(e<16?`0`:``)+e.toString(16)}function OO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new jO(e,t,n,r)}function kO(e){if(e instanceof jO)return new jO(e.h,e.s,e.l,e.opacity);if(e instanceof QD||(e=gO(e)),!e)return new jO;if(e instanceof jO)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 jO(o,s,c,e.opacity)}function AO(e,t,n,r){return arguments.length===1?kO(e):new jO(e,t,n,r??1)}function jO(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}XD(jO,AO,ZD(QD,{brighter(e){return e=e==null?eO:eO**+e,new jO(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$D:$D**+e,new jO(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 xO(PO(e>=240?e-240:e+120,i,r),PO(e,i,r),PO(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new jO(MO(this.h),NO(this.s),NO(this.l),TO(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=TO(this.opacity);return`${e===1?`hsl(`:`hsla(`}${MO(this.h)}, ${NO(this.s)*100}%, ${NO(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function MO(e){return e=(e||0)%360,e<0?e+360:e}function NO(e){return Math.max(0,Math.min(1,e||0))}function PO(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 FO=e=>()=>e;function IO(e,t){return function(n){return e+n*t}}function LO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function RO(e,t){var n=t-e;return n?IO(e,n>180||n<-180?n-360*Math.round(n/360):n):FO(isNaN(e)?t:e)}function zO(e){return(e=+e)==1?BO:function(t,n){return n-t?LO(t,n,e):FO(isNaN(t)?n:t)}}function BO(e,t){var n=t-e;return n?IO(e,n):FO(isNaN(e)?t:e)}var VO=(function e(t){var n=zO(t);function r(e,t){var r=n((e=bO(e)).r,(t=bO(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=BO(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 HO(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 UO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function WO(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]=$O(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 GO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function KO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function qO(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]=$O(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var JO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,YO=new RegExp(JO.source,`g`);function XO(e){return function(){return e}}function ZO(e){return function(t){return e(t)+``}}function QO(e,t){var n=JO.lastIndex=YO.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=JO.exec(e))&&(i=YO.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:KO(r,i)})),n=YO.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?ZO(c[0].x):XO(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 $O(e,t){var n=typeof t,r;return t==null||n===`boolean`?FO(t):(n===`number`?KO:n===`string`?(r=gO(t))?(t=r,VO):QO:t instanceof gO?VO:t instanceof Date?GO:UO(t)?HO:Array.isArray(t)?WO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?qO:KO)(e,t)}var ek=180/Math.PI,tk={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function nk(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)*ek,skewX:Math.atan(c)*ek,scaleX:o,scaleY:s}}var rk;function ik(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?tk:nk(t.a,t.b,t.c,t.d,t.e,t.f)}function ak(e){return e==null||(rk||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),rk.setAttribute(`transform`,e),!(e=rk.transform.baseVal.consolidate()))?tk:(e=e.matrix,nk(e.a,e.b,e.c,e.d,e.e,e.f))}function ok(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:KO(e,i)},{i:c-2,x:KO(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:KO(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:KO(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:KO(e,n)},{i:s-2,x:KO(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 sk=ok(ik,`px, `,`px)`,`deg)`),ck=ok(ak,`, `,`)`,`)`),lk=1e-12;function uk(e){return((e=Math.exp(e))+1/e)/2}function dk(e){return((e=Math.exp(e))-1/e)/2}function fk(e){return((e=Math.exp(2*e))-1)/(e+1)}var pk=(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<lk)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=uk(y),c=s/(n*g)*(i*fk(t*r+y)-dk(y));return[a+c*d,o+c*f,s*i/uk(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),mk=0,hk=0,gk=0,_k=1e3,vk,yk,bk=0,xk=0,Sk=0,Ck=typeof performance==`object`&&performance.now?performance:Date,wk=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tk(){return xk||=(wk(Ek),Ck.now()+Sk)}function Ek(){xk=0}function Dk(){this._call=this._time=this._next=null}Dk.prototype=Ok.prototype={constructor:Dk,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Tk():+n)+(t==null?0:+t),!this._next&&yk!==this&&(yk?yk._next=this:vk=this,yk=this),this._call=e,this._time=n,Nk()},stop:function(){this._call&&(this._call=null,this._time=1/0,Nk())}};function Ok(e,t,n){var r=new Dk;return r.restart(e,t,n),r}function kk(){Tk(),++mk;for(var e=vk,t;e;)(t=xk-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mk}function Ak(){xk=(bk=Ck.now())+Sk,mk=hk=0;try{kk()}finally{mk=0,Mk(),xk=0}}function jk(){var e=Ck.now(),t=e-bk;t>_k&&(Sk-=t,bk=e)}function Mk(){for(var e,t=vk,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:vk=n);yk=e,Nk(r)}function Nk(e){mk||(hk&&=clearTimeout(hk),e-xk>24?(e<1/0&&(hk=setTimeout(Ak,e-Ck.now()-Sk)),gk&&=clearInterval(gk)):(gk||=(bk=Ck.now(),setInterval(jk,_k)),mk=1,wk(Ak)))}function Pk(e,t,n){var r=new Dk;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Fk=jT(`start`,`end`,`cancel`,`interrupt`),Ik=[];function Lk(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Vk(e,n,{name:t,index:r,group:i,on:Fk,tween:Ik,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Rk(e,t){var n=Bk(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function zk(e,t){var n=Bk(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Bk(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Vk(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ok(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 Pk(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(Pk(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 Hk(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 Uk(e){return this.each(function(){Hk(this,e)})}function Wk(e,t){var n,r;return function(){var i=zk(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 Gk(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=zk(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 Kk(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=Bk(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?Wk:Gk)(n,e,t))}function qk(e,t,n){var r=e._id;return e.each(function(){var e=zk(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return Bk(e,r).value[t]}}function Jk(e,t){var n;return(typeof t==`number`?KO:t instanceof gO?VO:(n=gO(t))?(t=n,VO):QO)(e,t)}function Yk(e){return function(){this.removeAttribute(e)}}function Xk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zk(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 Qk(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 $k(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 eA(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 tA(e,t){var n=LT(e),r=n===`transform`?ck:Jk;return this.attrTween(e,typeof t==`function`?(n.local?eA:$k)(n,r,qk(this,`attr.`+e,t)):t==null?(n.local?Xk:Yk)(n):(n.local?Qk:Zk)(n,r,t))}function nA(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function rA(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function iA(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&rA(e,i)),n}return i._value=t,i}function aA(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&nA(e,i)),n}return i._value=t,i}function oA(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=LT(e);return this.tween(n,(r.local?iA:aA)(r,t))}function sA(e,t){return function(){Rk(this,e).delay=+t.apply(this,arguments)}}function cA(e,t){return t=+t,function(){Rk(this,e).delay=t}}function lA(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?sA:cA)(t,e)):Bk(this.node(),t).delay}function uA(e,t){return function(){zk(this,e).duration=+t.apply(this,arguments)}}function dA(e,t){return t=+t,function(){zk(this,e).duration=t}}function fA(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?uA:dA)(t,e)):Bk(this.node(),t).duration}function pA(e,t){if(typeof t!=`function`)throw Error();return function(){zk(this,e).ease=t}}function mA(e){var t=this._id;return arguments.length?this.each(pA(t,e)):Bk(this.node(),t).ease}function hA(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();zk(this,e).ease=n}}function gA(e){if(typeof e!=`function`)throw Error();return this.each(hA(this._id,e))}function _A(e){typeof e!=`function`&&(e=YT(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 KA(r,this._parents,this._name,this._id)}function vA(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 KA(o,this._parents,this._name,this._id)}function yA(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 bA(e,t,n){var r,i,a=yA(t)?Rk:zk;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function xA(e,t){var n=this._id;return arguments.length<2?Bk(this.node(),n).on.on(e):this.each(bA(n,e,t))}function SA(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function CA(){return this.on(`end.remove`,SA(this._id))}function wA(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=HT(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,Lk(l[f],t,n,f,l,Bk(u,n)));return new KA(a,this._parents,t,n)}function TA(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=KT(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=Bk(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Lk(p,t,n,h,f,m);a.push(f),o.push(u)}return new KA(a,o,t,n)}var EA=MD.prototype.constructor;function DA(){return new EA(this._groups,this._parents)}function OA(e,t){var n,r,i;return function(){var a=zE(this,e),o=(this.style.removeProperty(e),zE(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function kA(e){return function(){this.style.removeProperty(e)}}function AA(e,t,n){var r,i=n+``,a;return function(){var o=zE(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function jA(e,t,n){var r,i,a;return function(){var o=zE(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),zE(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function MA(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=zk(this,e),l=c.on,u=c.value[a]==null?s||=kA(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function NA(e,t,n){var r=(e+=``)==`transform`?sk:Jk;return t==null?this.styleTween(e,OA(e,r)).on(`end.style.`+e,kA(e)):typeof t==`function`?this.styleTween(e,jA(e,r,qk(this,`style.`+e,t))).each(MA(this._id,e)):this.styleTween(e,AA(e,r,t),n).on(`end.style.`+e,null)}function PA(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function FA(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&PA(e,a,n)),r}return a._value=t,a}function IA(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,FA(e,t,n??``))}function LA(e){return function(){this.textContent=e}}function RA(e){return function(){var t=e(this);this.textContent=t??``}}function zA(e){return this.tween(`text`,typeof e==`function`?RA(qk(this,`text`,e)):LA(e==null?``:e+``))}function BA(e){return function(t){this.textContent=e.call(this,t)}}function VA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&BA(r)),t}return r._value=e,r}function HA(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,VA(e))}function UA(){for(var e=this._name,t=this._id,n=qA(),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=Bk(c,t);Lk(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new KA(r,this._parents,e,n)}function WA(){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=zk(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 GA=0;function KA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function qA(){return++GA}var JA=MD.prototype;KA.prototype={constructor:KA,select:wA,selectAll:TA,selectChild:JA.selectChild,selectChildren:JA.selectChildren,filter:_A,merge:vA,selection:DA,transition:UA,call:JA.call,nodes:JA.nodes,node:JA.node,size:JA.size,empty:JA.empty,each:JA.each,on:xA,attr:tA,attrTween:oA,style:NA,styleTween:IA,text:zA,textTween:HA,remove:CA,tween:Kk,delay:lA,duration:fA,ease:mA,easeVarying:gA,end:WA,[Symbol.iterator]:JA[Symbol.iterator]};function YA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var XA={time:null,delay:0,duration:250,ease:YA};function ZA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function QA(e){var t,n;e instanceof KA?(t=e._id,e=e._name):(t=qA(),(n=XA).time=Tk(),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])&&Lk(c,e,t,l,o,n||ZA(c,t));return new KA(r,this._parents,e,t)}MD.prototype.interrupt=Uk,MD.prototype.transition=QA;var $A=e=>()=>e;function ej(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 tj(e,t,n){this.k=e,this.x=t,this.y=n}tj.prototype={constructor:tj,scale:function(e){return e===1?this:new tj(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new tj(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 nj=new tj(1,0,0);rj.prototype=tj.prototype;function rj(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nj;return e.__zoom}function ij(e){e.stopImmediatePropagation()}function aj(e){e.preventDefault(),e.stopImmediatePropagation()}function oj(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function sj(){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 cj(){return this.__zoom||nj}function lj(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function uj(){return navigator.maxTouchPoints||`ontouchstart`in this}function dj(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 fj(){var e=oj,t=sj,n=dj,r=lj,i=uj,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=pk,l=jT(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,cj).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`,cj),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(nj.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 tj(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 tj(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 tj(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=PD(this.that).datum();l.call(e,this.that,new ej(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=ID(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)],Hk(this),s.start();aj(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=PD(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=ID(t,i),l=t.clientX,u=t.clientY;VD(t.view),ij(t),a.mouse=[c,this.__zoom.invert(c)],Hk(this),a.start();function d(e){if(aj(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]=ID(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),HD(e.view,a.moved),aj(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=ID(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);aj(r),s>0?PD(this).transition().duration(s).call(x,d,c,r):PD(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(ij(t),s=0;s<i;++s)c=r[s],l=ID(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)),Hk(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(aj(e),s=0;s<a;++s)c=i[s],l=ID(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(ij(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=ID(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=PD(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:$A(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:$A(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:$A(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:$A([[+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 pj={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.`},mj=[[-1/0,-1/0],[1/0,1/0]],hj=[`Enter`,` `,`Escape`],gj={"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`},_j;(function(e){e.Strict=`strict`,e.Loose=`loose`})(_j||={});var vj;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(vj||={});var yj;(function(e){e.Partial=`partial`,e.Full=`full`})(yj||={});var bj={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},xj;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(xj||={});var Sj;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Sj||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var Cj={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top},wj=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,Tj=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Ej=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Dj=(e,t=[0,0])=>{let{width:n,height:r}=sM(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Oj=(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):Ej(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Vj(e,Gj(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Uj(r):{x:0,y:0,width:0,height:0}},kj=(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=Vj(n,Gj(e)),r=!0)}),r?Uj(n):{x:0,y:0,width:0,height:0}},Aj=(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=qj(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},jj=(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 Mj(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}=sM(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 Nj({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=iM(kj(Mj(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 Pj({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`,pj.error005());else{let{width:e,height:t}=sM(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&oM(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=oM(d)?Lj(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,pj.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 Fj({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=jj(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 Ij=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Lj=(e={x:0,y:0},t,n)=>({x:Ij(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ij(e.y,t[0][1],t[1][1]-(n?.height??0))});function Rj(e,t,n){let{width:r,height:i}=sM(n),{x:a,y:o}=n.internals.positionAbsolute;return Lj(e,[[a,o],[a+r,o+i]],t)}var zj=(e,t,n)=>e<t?Ij(Math.abs(e-t),1,t)/t:e>n?-Ij(Math.abs(e-n),1,t)/t:0,Bj=(e,t,n=15,r=40)=>[zj(e.x,r,t.width-r)*n,zj(e.y,r,t.height-r)*n],Vj=(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)}),Hj=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Uj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Wj=(e,t=[0,0])=>{let{x:n,y:r}=Ej(e)?e.internals.positionAbsolute:Dj(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}},Gj=(e,t=[0,0])=>{let{x:n,y:r}=Ej(e)?e.internals.positionAbsolute:Dj(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)}},Kj=(e,t)=>Uj(Vj(Hj(e),Hj(t))),qj=(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)},Jj=(e,t)=>qj(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Yj=e=>Xj(e.width)&&Xj(e.height)&&Xj(e.x)&&Xj(e.y),Xj=e=>!isNaN(e)&&isFinite(e),Zj=(e,t)=>(e,t)=>{},Qj=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),$j=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Qj(s,o):s},eM=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function tM(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 nM(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=tM(e,n),i=tM(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=tM(e.top??e.y??0,n),i=tM(e.bottom??e.y??0,n),a=tM(e.left??e.x??0,t),o=tM(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 rM(e,t,n,r,i,a){let{x:o,y:s}=eM(e,[t,n,r]),{x:c,y:l}=eM({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 iM=(e,t,n,r,i,a)=>{let o=nM(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Ij(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=rM(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}},aM=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function oM(e){return e!=null&&e!==`parent`}function sM(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function cM(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function lM(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 uM(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function dM(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function fM(e){return{...gj,...e||{}}}function pM(e){return e===null?null:e?`valid`:`invalid`}function mM(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=bM(e),s=$j({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Qj(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var hM=e=>({width:e.offsetWidth,height:e.offsetHeight}),gM=e=>e?.getRootNode?.()||window?.document,_M=[`INPUT`,`SELECT`,`TEXTAREA`];function vM(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?_M.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var yM=e=>`clientX`in e,bM=(e,t)=>{let n=yM(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)}},xM=(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,...hM(t)}})};function SM({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 CM(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wM({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-CM(t-r,a),n];case $.Right:return[t+CM(r-t,a),n];case $.Top:return[t,n-CM(n-i,a)];case $.Bottom:return[t,n+CM(i-n,a)]}}function TM({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=wM({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=wM({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=SM({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 EM({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 DM({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 OM({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Vj(Gj(e),Gj(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Jj({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Uj(a))>0}var kM=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,AM=(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)),jM=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,pj.error006()),t;let r=n.getEdgeId||kM,i;return i=wj(e)?{...e}:{...e,id:r(e)},AM(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function MM({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=EM({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var NM={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},PM=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.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},FM=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function IM({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=NM[t],c=NM[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=PM({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]=EM({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 LM(e,t,n,r){let i=Math.min(FM(e,t)/2,FM(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 RM({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=IM({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+=LM(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 zM(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function BM(e){let{sourceNode:t,targetNode:n}=e;if(!zM(t)||!zM(n))return null;let r=t.internals.handleBounds||VM(t.handles),i=n.internals.handleBounds||VM(n.handles),a=UM(r?.source??[],e.sourceHandle),o=UM(e.connectionMode===_j.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,pj.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=HM(t,a,s),u=HM(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function VM(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 HM(e,t,n=$.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??sM(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function UM(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function WM(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function GM(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=WM(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 KM(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 $.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 $.Bottom:o[1]=(e.y+e.height)*t.zoom+t.y+r,s[1]=0;break;case $.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 qM=1e3,JM=10,YM={nodeOrigin:[0,0],nodeExtent:mj,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},XM={...YM,checkEquality:!0};function ZM(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function QM(e,t,n){let r=ZM(YM,n);for(let n of e.values())if(n.parentId)rN(n,e,t,r);else{let e=Lj(Dj(n,r.nodeOrigin),oM(n.extent)?n.extent:r.nodeExtent,sM(n));n.internals.positionAbsolute=e}}function $M(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 eN(e){return e===`manual`}function tN(e,t,n,r={}){let i=ZM(XM,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!eN(i.zIndexMode)?qM: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=Lj(Dj(u,i.nodeOrigin),oM(u.extent)?u.extent:i.nodeExtent,sM(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:$M(u,e),z:iN(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&&rN(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function nN(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 rN(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=ZM(YM,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}nN(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*JM),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=aN(e,u,o,s,a&&!eN(c)?qM: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 iN(e,t,n){let r=Xj(e.zIndex)?e.zIndex:0;return eN(n)?r:r+(e.selected?t:0)}function aN(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=sM(e),l=Dj(e,n),u=oM(e.extent)?Lj(l,e.extent,c):l,d=Lj({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Rj(d,c,t));let f=iN(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function oN(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=Kj(a.get(n.parentId)?.expandedRect??Wj(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=sM(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 sN(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=hM(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=oM(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Rj(h,s,n))}else m&&(h=Lj(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:xM(`source`,r.nodeElement,p,d,e.id),target:xM(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&rN(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:Wj(g,i)}))}}if(f.length>0){let e=oN(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function cN({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 lN(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 uN(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}`;lN(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),lN(`target`,s,c,e,i,o),t.set(r.id,r)}}function dN(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:dN(n,t):!1}function fN(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 pN(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!dN(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 mN({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 hN({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=Qj(a,t);return{x:o.x-a.x,y:o.y-a.y}}function gN({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=PD(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?Hj(kj(s)):null,x=v&&l?hN({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)}:Qj(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}=Pj({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]=mN({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]=Bj(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=mM(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=pN(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=mN({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=YD().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=mM(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=bM(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=mM(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=bM(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=bM(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]=mN({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||!fN(t,`.${g}`,v))&&(!_||fN(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function _N(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())Jj(i,Wj(e))>0&&r.push(e);return r}var vN=250;function yN(e,t,n,r){let i=[],a=1/0,o=_N(e,n,t+vN);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}=HM(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 bN(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,...HM(o,c,c.position,!0)}:c}function xN(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function SN(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var CN=()=>!0;function wN(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:_=CN,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=gM(e.target),E=0,D,{x:O,y:k}=bM(e),A=xN(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=bN(i,A,r,c,t);if(!N)return;let P=bM(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Bj(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:HM(ee,B,$.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:ee,to:P,toHandle:null,toPosition:Cj[B.position],toNode:null,pointer:P};function te(){M=!0,y(V),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function H(e){if(!M){let{x:t,y:n}=bM(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){ne(e);return}let a=b();P=bM(e,j),D=yN($j(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=TN(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=SN(!!D,s.isValid);let u=c.get(i),f=u?HM(u,B,$.Left,!0):V.from,p={...V,from:f,isValid:L,to:s.toHandle&&L?eM({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Cj[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),V=p}function ne(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`,H),T.removeEventListener(`mouseup`,ne),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,ne)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,ne),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,ne)}function TN(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=CN,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}=bM(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=xN(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===_j.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=bN(t,e,a,u,n,!0)}return _}var EN={onPointerDown:wN,isValid:TN};function DN({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=PD(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&&aM()?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=fj().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:ID}}var ON=e=>({x:e.x,y:e.y,zoom:e.k}),kN=({x:e,y:t,zoom:n})=>nj.translate(e,t).scale(n),AN=(e,t)=>e.target.closest(`.${t}`),jN=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),MN=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,NN=(e,t=0,n=MN,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},PN=e=>{let t=e.ctrlKey&&aM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function FN({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(AN(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=ID(u),t=d*2**PN(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===vj.Vertical?0:u.deltaX*f,m=i===vj.Horizontal?0:u.deltaY*f;!aM()&&u.shiftKey&&i!==vj.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=ON(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 IN({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=AN(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function LN({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=ON(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 RN({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&jN(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,ON(a.transform))}}function zN({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&jN(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=ON(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function BN({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`&&(AN(f,`${u}-flow__node`)||AN(f,`${u}-flow__edge`)||AN(f,`${u}-flow__selection`)||AN(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||AN(f,c)&&h||AN(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 VN({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=fj().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=PD(e).call(f);y({x:i.x,y:i.y,zoom:Ij(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(PN);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?$O:pk).transform(NN(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:!Xj(D)||D<0?0:D);let A=k?FN({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):IN({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=LN({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=RN({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=zN({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=BN({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=kN(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=kN(e);return await g(n,t),n}function x(e){if(p){let t=kN(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?rj(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`?$O:pk).scaleTo(NN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?$O:pk).scaleBy(NN(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=!Xj(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 HN;(function(e){e.Line=`line`,e.Handle=`handle`})(HN||={});var UN=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],WN=[`top`,`right`,`bottom`,`left`];function GN({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 KN(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 qN(e,t){return Math.max(0,t-e)}function JN(e,t){return Math.max(0,e-t)}function YN(e,t,n){return Math.max(0,t-e,e-n)}function XN(e,t){return e?!t:t}function ZN(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=YN(E,h,g),j=YN(D,_,v);if(o){let e=0,t=0;c&&w<0?e=qN(y+w+O,o[0][0]):!c&&w>0&&(e=JN(y+E+O,o[1][0])),l&&T<0?t=qN(b+T+k,o[0][1]):!l&&T>0&&(t=JN(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=JN(y+w,s[0][0]):!c&&w<0&&(e=qN(y+E,s[1][0])),l&&T>0?t=JN(b+T,s[0][1]):!l&&T<0&&(t=qN(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=YN(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?JN(b+k+E/C,o[1][1])*C:qN(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?qN(b+E/C,s[1][1])*C:JN(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=YN(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?JN(y+D*C+O,o[1][0])/C:qN(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?qN(y+D*C,s[1][0])/C:JN(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=(XN(c,l)?-w:w)/C:w=(XN(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 QN={width:0,height:0,x:0,y:0},$N={...QN,pointerX:0,pointerY:0,aspectRatio:1};function eP(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 tP({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=PD(e),o={controlDirection:KN(`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={...QN},h={...$N};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:KN(e)};let g,_=null,v=[],y,b,x,S=YD().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}=mM(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=oM(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=eP(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=mM(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}=ZN(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=GN({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 nP=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})),rP=n(((e,t)=>{t.exports=nP()})),iP=n((e=>{var t=i(),n=rP();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}})),aP=t(n(((e,t)=>{t.exports=iP()}))(),1),oP=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},sP=e=>e?oP(e):oP,{useDebugValue:cP}=d.default,{useSyncExternalStoreWithSelector:lP}=aP.default,uP=e=>e;function dP(e,t=uP,n){let r=lP(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return cP(r),r}var fP=(e,t)=>{let n=sP(e),r=(e,r=t)=>dP(n,e,r);return Object.assign(r,n),r},pP=(e,t)=>e?fP(e,t):fP;function mP(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 hP=(0,d.createContext)(null),gP=hP.Provider,_P=pj.error001(`react`);function vP(e,t){let n=(0,d.useContext)(hP);if(n===null)throw Error(_P);return dP(n,e,t)}function yP(){let e=(0,d.useContext)(hP);if(e===null)throw Error(_P);return(0,d.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var bP={display:`none`},xP={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},SP=`react-flow__node-desc`,CP=`react-flow__edge-desc`,wP=`react-flow__aria-live`,TP=e=>e.ariaLiveMessage,EP=e=>e.ariaLabelConfig;function DP({rfId:e}){let t=vP(TP);return(0,X.jsx)(`div`,{id:`${wP}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:xP,children:t})}function OP({rfId:e,disableKeyboardA11y:t}){let n=vP(EP);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{id:`${SP}-${e}`,style:bP,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,X.jsx)(`div`,{id:`${CP}-${e}`,style:bP,children:n[`edge.a11yDescription.default`]}),!t&&(0,X.jsx)(DP,{rfId:e})]})}var kP=(0,d.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,X.jsx)(`div`,{className:kT([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});kP.displayName=`Panel`;var AP=`https://reactflow.dev?utm_source=attribution`;function jP({proOptions:e,position:t=`bottom-right`}){return(0,d.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,X.jsx)(kP,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${AP}`,children:(0,X.jsx)(`a`,{href:AP,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var MP=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}},NP=e=>e.id;function PP(e,t){return mP(e.selectedNodes.map(NP),t.selectedNodes.map(NP))&&mP(e.selectedEdges.map(NP),t.selectedEdges.map(NP))}function FP({onSelectionChange:e}){let t=yP(),{selectedNodes:n,selectedEdges:r}=vP(MP,PP);return(0,d.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var IP=e=>!!e.onSelectionChangeHandlers;function LP({onSelectionChange:e}){let t=vP(IP);return e||t?(0,X.jsx)(FP,{onSelectionChange:e}):null}var RP=[0,0],zP={x:0,y:0,zoom:1},BP=[...`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`],VP=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}),HP={translateExtent:mj,nodeOrigin:RP,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function UP(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=vP(VP,mP),l=yP();(0,d.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=HP,s()}),[]);let u=(0,d.useRef)(HP);return(0,d.useEffect)(()=>{for(let s of BP){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:fM(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},BP.map(t=>e[t])),null}function WP(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function GP(e){let[t,n]=(0,d.useState)(e===`system`?null:e);return(0,d.useEffect)(()=>{if(e!==`system`){n(e);return}let t=WP(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?WP()?.matches?`dark`:`light`:t}var KP=typeof document<`u`?document:null;function qP(e=null,t={target:KP,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,`
|
|
52
|
-
`).replace(`
|
|
53
|
-
|
|
54
|
-
`,`
|
|
55
|
-
+`).split(`
|
|
56
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,d.useEffect)(()=>{let n=t?.target??KP,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)&&vM(e))return!1;let n=YP(e.code,s);if(a.current.add(e[n]),JP(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=YP(e.code,s);JP(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 JP(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function YP(e,t){return t.includes(e)?`code`:`key`}var XP=()=>{let e=yP();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=iM(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 $j(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=eM(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function ZP(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)QP(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 QP(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 $P(e,t){return ZP(e,t)}function eF(e,t){return ZP(e,t)}function tF(e,t){return{id:e,type:`select`,selected:t}}function nF(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(tF(a.id,e)))}return r}function rF({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 iF(e){return{id:e.id,type:`remove`}}var aF=Zj(`React Flow`,`https://reactflow.dev/`);function oF(e,t,n={}){return jM(e,t,{...n,onError:n.onError??aF})}var sF=e=>Tj(e),cF=e=>wj(e);function lF(e){return(0,d.forwardRef)(e)}var uF=typeof window<`u`?d.useLayoutEffect:d.useEffect;function dF(e){let[t,n]=(0,d.useState)(BigInt(0)),[r]=(0,d.useState)(()=>fF(()=>n(e=>e+BigInt(1))));return uF(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function fF(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var pF=(0,d.createContext)(null);function mF({children:e}){let t=yP(),n=dF((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=rF({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=dF((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(rF({items:s,lookup:o}))},[])),i=(0,d.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,X.jsx)(pF.Provider,{value:i,children:e})}function hF(){let e=(0,d.useContext)(pF);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var gF=e=>!!e.panZoom;function _F(){let e=XP(),t=yP(),n=hF(),r=vP(gF),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=sF(e)?e:n.get(e.id),a=i.parentId?lM(i.position,i.measured,i.parentId,n,r):i.position;return Wj({...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&&sF(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&&cF(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 Fj({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(iF);o?.(f),c(e)}if(m){let e=d.map(iF);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Yj(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=Wj(s?r:a),l=Jj(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Yj(e)?e:a(e);if(!r)return!1;let i=Jj(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 Oj(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??dM();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 vF=e=>e.selected,yF=typeof window<`u`?window:void 0;function bF({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=yP(),{deleteElements:r}=_F(),i=qP(e,{actInsideInputWithModifier:!1}),a=qP(t,{target:yF});(0,d.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(vF),edges:e.filter(vF)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,d.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function xF(e){let t=yP();(0,d.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=hM(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,pj.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 SF={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},CF=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function wF({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=vj.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=yP(),w=(0,d.useRef)(null),{userSelectionActive:T,lib:E,connectionInProgress:D}=vP(CF,mP),O=qP(m),k=(0,d.useRef)();xF(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=VN({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,X.jsx)(`div`,{className:`react-flow__renderer`,ref:w,style:SF,children:g})}var TF=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function EF(){let{userSelectionActive:e,userSelectionRect:t}=vP(TF,mP);return e&&t?(0,X.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 DF=(e,t)=>n=>{n.target===t.current&&e?.(n)},OF=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function kF({isSelecting:e,selectionKeyPressed:t,selectionMode:n=yj.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=yP(),{userSelectionActive:y,elementsSelectable:b,dragging:x,panBy:S,autoPanSpeed:C}=vP(OF,mP),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}=bM(n.nativeEvent,E.current),u=$j({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}=eM(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(Aj(a,m,i,n===yj.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)}}uM(h,D.current)||c(nF(a,D.current,!0)),uM(g,O.current)||l(nF(o,O.current)),v.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!i||!E.current)return;let[e,t]=Bj(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}=bM(e.nativeEvent,E.current);j.current={x:o,y:c};let l=eM({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()},H=r===!0||Array.isArray(r)&&r.includes(0);return(0,X.jsxs)(`div`,{className:kT([`react-flow__pane`,{draggable:H,dragging:x,selection:e}]),onClick:w?void 0:DF(N,T),onContextMenu:DF(P,T),onWheel:DF(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:SF,children:[g,(0,X.jsx)(EF,{})]})}function AF({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`,pj.error012(e))}function jF({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=yP(),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)();return(0,d.useEffect)(()=>{if(!t)return u.current=gN({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{AF({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 MF=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function NF(){let e=yP();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=MF(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=Qj(t,i));let{position:a,positionAbsolute:s}=Pj({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 PF=(0,d.createContext)(null),FF=PF.Provider;PF.Consumer;var IF=()=>(0,d.useContext)(PF),LF=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),RF=(0,d.createContext)(null);function zF({children:e}){let t=vP(LF,mP);return(0,X.jsx)(RF.Provider,{value:t,children:e})}function BF(){let e=(0,d.useContext)(RF);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var VF={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},HF=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return VF;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===_j.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function UF({type:e=`source`,position:t=$.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=yP(),_=IF(),{connectOnClick:v,noPanClassName:y,rfId:b}=BF(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=vP(HF(_,m,e),mP);_||g.getState().onError?.(`010`,pj.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(oF(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=yM(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();EN.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,X.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:kT([`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=gM(t.target),h=n||c,{connection:v,isValid:y}=EN.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 WF=(0,d.memo)(lF(UF));function GF({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,X.jsxs)(X.Fragment,{children:[e?.label,(0,X.jsx)(WF,{type:`source`,position:n,isConnectable:t})]})}function KF({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(WF,{type:`target`,position:n,isConnectable:t}),e?.label,(0,X.jsx)(WF,{type:`source`,position:r,isConnectable:t})]})}function qF(){return null}function JF({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(WF,{type:`target`,position:n,isConnectable:t}),e?.label]})}var YF={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},XF={input:GF,default:KF,output:JF,group:qF};function ZF(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 QF=e=>{let{width:t,height:n,x:r,y:i}=kj(e.nodeLookup,{filter:e=>!!e.selected});return{width:Xj(t)?t:null,height:Xj(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 $F({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=yP(),{width:i,height:a,transformString:o,userSelectionActive:s}=vP(QF,mP),c=NF(),l=(0,d.useRef)(null);(0,d.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(jF({nodeRef:l,disabled:!u}),!u)return null;let f=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,X.jsx)(`div`,{className:kT([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,X.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(YF,e.key)&&(e.preventDefault(),c({direction:YF[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var eI=typeof window<`u`?window:void 0,tI=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function nI({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}=vP(tI,mP),z=qP(l,{target:eI}),B=qP(h,{target:eI}),ee=B||w,V=B||b,te=u&&ee!==!0,H=z||R||te;return bF({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,X.jsx)(wF,{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,X.jsxs)(kF,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:ee,autoPanOnSelection:T,isSelecting:!!H,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:te,children:[e,L&&(0,X.jsx)($F,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}nI.displayName=`FlowRenderer`;var rI=(0,d.memo)(nI),iI=e=>t=>e?Aj(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 aI(e){return vP((0,d.useCallback)(iI(e),[e]),mP)}var oI=e=>e.updateNodeInternals;function sI(){let e=vP(oI),[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 cI({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=yP(),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 lI({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}=vP(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},mP),S=y.type||`default`,C=g?.[S]||XF[S];C===void 0&&(v?.(`003`,pj.error003(S)),S=`default`,C=g?.default||XF.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=yP(),k=cM(y),A=cI({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=jF({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=NF();if(y.hidden)return null;let N=sM(y),P=ZF(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)&&AF({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},V=t=>{if(!(vM(t.nativeEvent)||m)){if(hj.includes(t.key)&&T){let n=t.key===`Escape`;AF({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(YF,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:YF[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&&(Aj(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,X.jsx)(`div`,{className:kT([`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:`${SP}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,X.jsx)(FF,{value:e,children:(0,X.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 uI=(0,d.memo)(lI),dI=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function fI(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=vP(dI,mP),a=aI(e.onlyRenderVisibleElements),o=sI();return(0,X.jsx)(`div`,{className:`react-flow__nodes`,style:SF,children:a.map(a=>(0,X.jsx)(uI,{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))})}fI.displayName=`NodeRenderer`;var pI=(0,d.memo)(fI);function mI(e){return vP((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&&OM({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),mP)}var hI=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,X.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},gI=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,X.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},_I={[Sj.Arrow]:hI,[Sj.ArrowClosed]:gI};function vI(e){let t=yP();return(0,d.useMemo)(()=>Object.prototype.hasOwnProperty.call(_I,e)?_I[e]:(t.getState().onError?.(`009`,pj.error009(e)),null),[e])}var yI=({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=vI(t);return c?(0,X.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,X.jsx)(c,{color:n,strokeWidth:o})}):null},bI=({defaultColor:e,rfId:t})=>{let n=vP(e=>e.edges),r=vP(e=>e.defaultEdgeOptions),i=(0,d.useMemo)(()=>GM(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,X.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,X.jsx)(`defs`,{children:i.map(e=>(0,X.jsx)(yI,{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};bI.displayName=`MarkerDefinitions`;var xI=(0,d.memo)(bI);function SI({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=kT([`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,X.jsxs)(`g`,{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?`visible`:`hidden`,...u,children:[i&&(0,X.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,X.jsx)(`text`,{className:`react-flow__edge-text`,y:f.height/2,dy:`0.3em`,ref:h,style:r,children:n}),c]}):null}SI.displayName=`EdgeText`;var CI=(0,d.memo)(SI);function wI({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{...u,d:e,fill:`none`,className:kT([`react-flow__edge-path`,u.className])}),l?(0,X.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Xj(t)&&Xj(n)?(0,X.jsx)(CI,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function TI({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function EI({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=TI({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=TI({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=SM({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 DI(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]=EI({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,X.jsx)(wI,{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 OI=DI({isInternal:!1}),kI=DI({isInternal:!0});OI.displayName=`SimpleBezierEdge`,kI.displayName=`SimpleBezierEdgeInternal`;function AI(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=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=RM({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,X.jsx)(wI,{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 jI=AI({isInternal:!1}),MI=AI({isInternal:!0});jI.displayName=`SmoothStepEdge`,MI.displayName=`SmoothStepEdgeInternal`;function NI(e){return(0,d.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,X.jsx)(jI,{...n,id:r,pathOptions:(0,d.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var PI=NI({isInternal:!1}),FI=NI({isInternal:!0});PI.displayName=`StepEdge`,FI.displayName=`StepEdgeInternal`;function II(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]=MM({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,X.jsx)(wI,{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 LI=II({isInternal:!1}),RI=II({isInternal:!0});LI.displayName=`StraightEdge`,RI.displayName=`StraightEdgeInternal`;function zI(e){return(0,d.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.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]=TM({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,X.jsx)(wI,{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 BI=zI({isInternal:!1}),VI=zI({isInternal:!0});BI.displayName=`BezierEdge`,VI.displayName=`BezierEdgeInternal`;var HI={default:VI,straight:RI,step:FI,smoothstep:MI,simplebezier:kI},UI={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},WI=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,GI=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,KI=`react-flow__edgeupdater`;function qI({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,X.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:kT([KI,`${KI}-${s}`]),cx:WI(t,r,e),cy:GI(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function JI({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=yP(),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`;EN.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,X.jsxs)(X.Fragment,{children:[(e===!0||e===`source`)&&(0,X.jsx)(qI,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,X.jsx)(qI,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function YI({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=vP(t=>t.edgeLookup.get(e)),x=vP(e=>e.defaultEdgeOptions);b=x?{...x,...b}:b;let S=b.type||`default`,C=g?.[S]||HI[S];C===void 0&&(v?.(`011`,pj.error011(S)),S=`default`,C=g?.default||HI.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=yP(),{zIndex:N=b.zIndex,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z}=vP((0,d.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return UI;let i=BM({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:v}),a=DM({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||UI,zIndex:a}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex,v]),mP),B=(0,d.useMemo)(()=>b.markerStart?`url('#${WM(b.markerStart,h)}')`:void 0,[b.markerStart,h]),ee=(0,d.useMemo)(()=>b.markerEnd?`url('#${WM(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,H=o?e=>{o(e,{...b})}:void 0,ne=s?e=>{s(e,{...b})}:void 0,re=c?e=>{c(e,{...b})}:void 0,ie=l?e=>{l(e,{...b})}:void 0;return(0,X.jsx)(`svg`,{style:{zIndex:N},children:(0,X.jsxs)(`g`,{className:kT([`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:H,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:w?t=>{if(!y&&hj.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?`${CP}-${h}`:void 0,ref:D,...b.domAttributes,children:[!A&&(0,X.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,X.jsx)(JI,{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 XI=(0,d.memo)(YI),ZI=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function QI({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}=vP(ZI,mP),b=mI(t);return(0,X.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,X.jsx)(xI,{defaultColor:e,rfId:n}),b.map(e=>(0,X.jsx)(XI,{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))]})}QI.displayName=`EdgeRenderer`;var $I=(0,d.memo)(QI),eL=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function tL({children:e}){let t=yP(),n=(0,d.useRef)(null),[r]=(0,d.useState)(()=>t.getState().transform);return uF(()=>{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=eL(r)))};return r(),t.subscribe(r)},[t]),(0,X.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:eL(r)},children:e})}function nL(e){let t=_F(),n=(0,d.useRef)(!1);(0,d.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var rL=e=>e.panZoom?.syncViewport;function iL(e){let t=vP(rL),n=yP();return(0,d.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function aL(e){return e.connection.inProgress?{...e.connection,to:$j(e.connection.to,e.transform)}:{...e.connection}}function oL(e){return e?t=>e(aL(t)):aL}function sL(e){return vP(oL(e),mP)}var cL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lL({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=vP(cL,mP);return a&&i&&c?(0,X.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,X.jsx)(`g`,{className:kT([`react-flow__connection`,pM(s)]),children:(0,X.jsx)(uL,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var uL=({style:e,type:t=xj.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}=sL();if(!i)return;if(n)return(0,X.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:pM(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 xj.Bezier:[m]=TM(h);break;case xj.SimpleBezier:[m]=EI(h);break;case xj.Step:[m]=RM({...h,borderRadius:0});break;case xj.SmoothStep:[m]=RM(h);break;default:[m]=MM(h)}return(0,X.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};uL.displayName=`ConnectionLine`;var dL={};function fL(e=dL){(0,d.useRef)(e),yP(),(0,d.useEffect)(()=>{},[e])}function pL(){yP(),(0,d.useRef)(!1),(0,d.useEffect)(()=>{},[])}function mL({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:H,onPaneScroll:ne,onPaneContextMenu:re,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:U,onEdgeMouseLeave:W,reconnectRadius:ce,onReconnect:le,onReconnectStart:ue,onReconnectEnd:de,noDragClassName:fe,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:he,nodeExtent:ge,rfId:_e,viewport:ve,onViewportChange:ye,nodesDraggable:be}){return fL(e),fL(t),pL(),nL(n),iL(ve),(0,X.jsx)(rI,{onPaneClick:ee,onPaneMouseEnter:V,onPaneMouseMove:te,onPaneMouseLeave:H,onPaneContextMenu:re,onPaneScroll:ne,paneClickDistance:ie,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:fe,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:he,onViewportChange:ye,isControlledViewport:!!ve,children:(0,X.jsxs)(tL,{children:[(0,X.jsx)($I,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:le,onReconnectStart:ue,onReconnectEnd:de,onlyRenderVisibleElements:T,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:U,onEdgeMouseLeave:W,reconnectRadius:ce,defaultMarkerColor:M,noPanClassName:me,disableKeyboardA11y:he,rfId:_e}),(0,X.jsx)(lL,{style:h,type:m,component:g,containerStyle:_}),(0,X.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,X.jsx)(pI,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ae,onlyRenderVisibleElements:T,noPanClassName:me,noDragClassName:fe,disableKeyboardA11y:he,nodeExtent:ge,rfId:_e,nodesDraggable:be}),(0,X.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}mL.displayName=`GraphView`;var hL=(0,d.memo)(mL),gL=Zj(`React Flow`,`https://reactflow.dev/`),_L=({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??mj;uN(h,g,_);let{nodesInitialized:x}=tN(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=iM(kj(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:mj,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:_j.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:{...bj},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:gL,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:gj,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}},vL=({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})=>pP((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 Nj({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{..._L({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}=tN(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();uN(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}=sN(e,n,r,i,a,o,l);d&&(QM(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=HM(e,o.fromHandle,$.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=oN(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($P(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(eF(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=>tF(e,!0))):(i(nF(r,new Set([...e]),!0)),a(nF(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?a(e.map(e=>tF(e,!0))):(a(nF(n,new Set([...e]))),i(nF(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(tF(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(tF(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,tF(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,tF(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])&&(tN(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 cN({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:{...bj}})},updateConnection:e=>{p({connection:e})},reset:()=>p({..._L()})}},Object.is);function yL({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)(()=>vL({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,X.jsx)(gP,{value:h,children:(0,X.jsx)(mF,{children:(0,X.jsx)(zF,{children:m})})})}function bL({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)(hP)?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(yL,{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 xL={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function SL({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=xj.Bezier,connectionLineStyle:B,connectionLineComponent:ee,connectionLineContainerStyle:V,deleteKeyCode:te=`Backspace`,selectionKeyCode:H=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=yj.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=aM()?`Meta`:`Control`,zoomActivationKeyCode:oe=aM()?`Meta`:`Control`,snapToGrid:se,snapGrid:U,onlyRenderVisibleElements:W=!1,selectNodesOnDrag:ce,nodesDraggable:le,autoPanOnNodeFocus:ue,nodesConnectable:de,nodesFocusable:fe,nodeOrigin:pe=RP,edgesFocusable:me,edgesReconnectable:he,elementsSelectable:ge=!0,defaultViewport:_e=zP,minZoom:ve=.5,maxZoom:ye=2,translateExtent:be=mj,preventScrolling:G=!0,nodeExtent:xe,defaultMarkerColor:Se=`#b1b1b7`,zoomOnScroll:Ce=!0,zoomOnPinch:we=!0,panOnScroll:Te=!1,panOnScrollSpeed:Ee=.5,panOnScrollMode:De=vj.Free,zoomOnDoubleClick:Oe=!0,panOnDrag:ke=!0,onPaneClick:Ae,onPaneMouseEnter:je,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:Pe,onPaneContextMenu:Fe,paneClickDistance:Ie=1,nodeClickDistance:Le=0,children:Re,onReconnect:ze,onReconnectStart:Be,onReconnectEnd:Ve,onEdgeContextMenu:He,onEdgeDoubleClick:Ue,onEdgeMouseEnter:We,onEdgeMouseMove:Ge,onEdgeMouseLeave:Ke,reconnectRadius:qe=10,onNodesChange:Je,onEdgesChange:Ye,noDragClassName:Xe=`nodrag`,noWheelClassName:Ze=`nowheel`,noPanClassName:Qe=`nopan`,fitView:$e,fitViewOptions:et,connectOnClick:tt,attributionPosition:nt,proOptions:rt,defaultEdgeOptions:it,elevateNodesOnSelect:at=!0,elevateEdgesOnSelect:ot=!1,disableKeyboardA11y:st=!1,autoPanOnConnect:ct,autoPanOnNodeDrag:lt,autoPanOnSelection:ut=!0,autoPanSpeed:dt,connectionRadius:ft,isValidConnection:pt,onError:mt,style:ht,id:gt,nodeDragThreshold:_t,connectionDragThreshold:vt,viewport:yt,onViewportChange:bt,width:xt,height:St,colorMode:Ct=`light`,debug:wt,onScroll:Tt,ariaLabelConfig:Et,zIndexMode:Dt=`basic`,...Ot},kt){let At=gt||`1`,jt=GP(Ct),Mt=(0,d.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Tt?.(e)},[Tt]);return(0,X.jsx)(`div`,{"data-testid":`rf__wrapper`,...Ot,onScroll:Mt,style:{...ht,...xL},ref:kt,className:kT([`react-flow`,i,jt]),id:gt,role:`application`,children:(0,X.jsxs)(bL,{nodes:e,edges:t,width:xt,height:St,fitView:$e,fitViewOptions:et,minZoom:ve,maxZoom:ye,nodeOrigin:pe,nodeExtent:xe,zIndexMode:Dt,children:[(0,X.jsx)(UP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:h,onConnectEnd:g,onClickConnectStart:_,onClickConnectEnd:v,nodesDraggable:le,autoPanOnNodeFocus:ue,nodesConnectable:de,nodesFocusable:fe,edgesFocusable:me,edgesReconnectable:he,elementsSelectable:ge,elevateNodesOnSelect:at,elevateEdgesOnSelect:ot,minZoom:ve,maxZoom:ye,nodeExtent:xe,onNodesChange:Je,onEdgesChange:Ye,snapToGrid:se,snapGrid:U,connectionMode:R,translateExtent:be,connectOnClick:tt,defaultEdgeOptions:it,fitView:$e,fitViewOptions:et,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:Qe,nodeOrigin:pe,rfId:At,autoPanOnConnect:ct,autoPanOnNodeDrag:lt,autoPanSpeed:dt,onError:mt,connectionRadius:ft,isValidConnection:pt,selectNodesOnDrag:ce,nodeDragThreshold:_t,connectionDragThreshold:vt,onBeforeDelete:L,debug:wt,ariaLabelConfig:Et,zIndexMode:Dt}),(0,X.jsx)(hL,{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:H,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:te,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:W,defaultViewport:_e,translateExtent:be,minZoom:ve,maxZoom:ye,preventScrolling:G,zoomOnScroll:Ce,zoomOnPinch:we,zoomOnDoubleClick:Oe,panOnScroll:Te,panOnScrollSpeed:Ee,panOnScrollMode:De,panOnDrag:ke,autoPanOnSelection:ut,onPaneClick:Ae,onPaneMouseEnter:je,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:Pe,onPaneContextMenu:Fe,paneClickDistance:Ie,nodeClickDistance:Le,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onReconnect:ze,onReconnectStart:Be,onReconnectEnd:Ve,onEdgeContextMenu:He,onEdgeDoubleClick:Ue,onEdgeMouseEnter:We,onEdgeMouseMove:Ge,onEdgeMouseLeave:Ke,reconnectRadius:qe,defaultMarkerColor:Se,noDragClassName:Xe,noWheelClassName:Ze,noPanClassName:Qe,rfId:At,disableKeyboardA11y:st,nodeExtent:xe,viewport:yt,onViewportChange:bt,nodesDraggable:le}),(0,X.jsx)(LP,{onSelectionChange:A}),Re,(0,X.jsx)(jP,{proOptions:rt,position:nt}),(0,X.jsx)(OP,{rfId:At,disableKeyboardA11y:st})]})})}var CL=lF(SL),wL=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function TL({children:e}){let t=vP(wL);return t?(0,kc.createPortal)(e,t):null}pj.error014();function EL(e){return vP((0,d.useCallback)(t=>t.nodeLookup.get(e),[e]),mP)}function DL({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,X.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:kT([`react-flow__background-pattern`,n,r])})}function OL({radius:e,className:t}){return(0,X.jsx)(`circle`,{cx:e,cy:e,r:e,className:kT([`react-flow__background-pattern`,`dots`,t])})}var kL;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(kL||={});var AL={[kL.Dots]:1,[kL.Lines]:1,[kL.Cross]:6},jL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ML({id:e,variant:t=kL.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}=vP(jL,mP),h=r||AL[t],g=t===kL.Dots,_=t===kL.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,X.jsxs)(`svg`,{className:kT([`react-flow__background`,l]),style:{...c,...SF,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:f,"data-testid":`rf__background`,children:[(0,X.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,X.jsx)(OL,{radius:b/2,className:u}):(0,X.jsx)(DL,{dimensions:S,lineWidth:i,variant:t,className:u})}),(0,X.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}ML.displayName=`Background`;var NL=(0,d.memo)(ML);function PL(){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,X.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function FL(){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,X.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function IL(){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,X.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 LL(){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,X.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 RL(){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,X.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 zL({children:e,className:t,...n}){return(0,X.jsx)(`button`,{type:`button`,className:kT([`react-flow__controls-button`,t]),...n,children:e})}var BL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function VL({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=yP(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=vP(BL,mP),{zoomIn:y,zoomOut:b,fitView:x}=_F();return(0,X.jsxs)(kP,{className:kT([`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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zL,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,X.jsx)(PL,{})}),(0,X.jsx)(zL,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,X.jsx)(FL,{})})]}),n&&(0,X.jsx)(zL,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,X.jsx)(IL,{})}),r&&(0,X.jsx)(zL,{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,X.jsx)(RL,{}):(0,X.jsx)(LL,{})}),u]})}VL.displayName=`Controls`;var HL=(0,d.memo)(VL);function UL({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,X.jsx)(`rect`,{className:kT([`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 WL=(0,d.memo)(UL),GL=e=>e.nodes.map(e=>e.id),KL=e=>e instanceof Function?e:()=>e;function qL({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=WL,onClick:o}){let s=vP(GL,mP),c=KL(t),l=KL(e),u=KL(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,X.jsx)(X.Fragment,{children:s.map(e=>(0,X.jsx)(YL,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function JL({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}=vP(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}=sM(r);return{node:r,x:i,y:a,width:o,height:s}},mP);return!l||l.hidden||!cM(l)?null:(0,X.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 YL=(0,d.memo)(JL),XL=(0,d.memo)(qL),ZL=200,QL=150,$L=e=>!e.hidden,eR=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?Kj(kj(e.nodeLookup,{filter:$L}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},tR=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,nR=(e,t)=>tR(e.viewBB,t.viewBB)&&tR(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,rR=`react-flow__minimap-desc`;function iR({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=yP(),C=(0,d.useRef)(null),{boundingRect:w,panZoom:T,viewBB:E,rfId:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=vP(eR,nR),M=e?.width??ZL,N=e?.height??QL,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,H=`${rR}-${D}`,ne=(0,d.useRef)(0),re=(0,d.useRef)();ne.current=I,(0,d.useEffect)(()=>{let e=S.getState().panZoom;if(C.current&&e)return re.current=DN({domNode:C.current,panZoom:e,getTransform:()=>S.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[T]),(0,d.useEffect)(()=>{re.current?.update({translateExtent:O,width:k,height:A,inversePan:y,pannable:g,zoomStep:b,zoomable:_})},[g,_,y,b,O,k,A]);let ie=m?e=>{let[t,n]=re.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,ae=(0,d.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;h?.(e,n)},[h]),oe=h?ae:void 0,se=v??j[`minimap.ariaLabel`];return(0,X.jsx)(kP,{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:kT([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,X.jsxs)(`svg`,{width:M,height:N,viewBox:`${B} ${ee} ${V} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":H,ref:C,onClick:ie,children:[se&&(0,X.jsx)(`title`,{id:H,children:se}),(0,X.jsx)(XL,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,X.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
|
|
57
|
-
M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}iR.displayName=`MiniMap`,(0,d.memo)(iR);var aR=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,oR={[HN.Line]:`right`,[HN.Handle]:`bottom-right`};function sR({nodeId:e,position:t,variant:n=HN.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=IF(),b=typeof e==`string`?e:y,x=yP(),S=(0,d.useRef)(null),C=n===HN.Handle,w=vP((0,d.useCallback)(aR(C&&m),[C,m]),mP),T=(0,d.useRef)(null),E=t??oR[n];(0,d.useEffect)(()=>{if(S.current&&b)return T.current||=tP({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=oN([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...lM({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,X.jsx)(`div`,{className:kT([`react-flow__resize-control`,`nodrag`,...D,n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}var cR=(0,d.memo)(sR);function lR({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,X.jsxs)(X.Fragment,{children:[WN.map(t=>(0,X.jsx)(cR,{className:i,style:a,nodeId:e,position:t,variant:HN.Line,color:o,minWidth:s,minHeight:c,maxWidth:l,maxHeight:u,onResizeStart:m,keepAspectRatio:d,autoScale:f,shouldResize:p,onResize:h,onResizeEnd:g},t)),UN.map(t=>(0,X.jsx)(cR,{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 uR=e=>e.domNode?.querySelector(`.react-flow__renderer`);function dR({children:e}){let t=vP(uR);return t?(0,kc.createPortal)(e,t):null}var fR=(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,pR=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e)if(fR(r,t.get(n)))return!1;return!0},mR=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2],selectedNodesCount:e.nodes.filter(e=>e.selected).length});function hR({nodeId:e,children:t,className:n,style:r,isVisible:i,position:a=$.Top,offset:o=10,align:s=`center`,...c}){let l=IF(),u=vP((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]),pR),{x:f,y:p,zoom:m,selectedNodesCount:h}=vP(mR,mP);if(!(typeof i==`boolean`?i:u.size===1&&u.values().next().value?.selected&&h===1)||!u.size)return null;let g=kj(u),_=Array.from(u.values()),v=Math.max(..._.map(e=>e.internals.z+1)),y={position:`absolute`,transform:KM(g,{x:f,y:p,zoom:m},a,o,s),zIndex:v,...r};return(0,X.jsx)(dR,{children:(0,X.jsx)(`div`,{style:y,className:kT([`react-flow__node-toolbar`,n]),...c,"data-id":_.reduce((e,t)=>`${e}${t.id} `,``).trim(),children:t})})}var gR=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`#`)),_R=e=>e.replace(/^(?:[ \t]*\r?\n)+/,``).trimEnd();function vR(e){return{links:gR(e.getData(`text/uri-list`)),text:_R(e.getData(`text/plain`))}}function yR(e,t){let n=e.filter(e=>e.clips?.accepts(t));return n.find(e=>!e.clips.fallback)??n[0]}function bR(e){let t=e,n=t&&(t.nodeType===1?t:t.parentElement);return!!n?.closest(`input, textarea, select`)||!!n?.isContentEditable}var xR=e=>[...e.dataTransfer?.types??[]],SR=e=>e.includes(`text/uri-list`)&&!e.includes(`Files`),CR=e=>e.includes(`text/plain`)&&!e.includes(`text/uri-list`)&&!e.includes(`Files`),wR=`application/x-tricot-blocks`,TR=`tricot-blocks`;function ER(e){return JSON.stringify({tricot:TR,ids:e})}function DR(e){let t;try{t=JSON.parse(e.getData(wR))}catch{return null}let{tricot:n,ids:r}=t??{};return n!==TR||!Array.isArray(r)||r.length===0||!r.every(e=>typeof e==`string`)?null:{ids:r}}var OR=(e,t)=>[e,...t].map(e=>e.join(` `)).join(`
|
|
58
|
-
`);function kR(e,t){return t.map(t=>[t.title,e.find(e=>e.type===t.type)?.copyText?.(t)].filter(Boolean).join(`
|
|
59
|
-
`)).filter(Boolean).join(`
|
|
60
|
-
|
|
61
|
-
`)}function AR(e){return e.owner?{[e.owner.kind]:e.owner.card}:{}}var jR=(0,d.createContext)(null);function MR(){let e=(0,d.useContext)(jR);if(!e)throw Error(`useCanvas outside a canvas`);return e}function NR(e){let{value:t,placeholder:n,onCommit:r,className:i=``,display:a}=e,{readOnly:o}=MR(),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(!1);if(o)return(0,X.jsx)(`span`,{className:`editable ${i}`,children:a??t});if(!s)return(0,X.jsx)(`span`,{className:`editable ${i}`,onDoubleClick:e=>{e.stopPropagation(),l.current=!1,c(!0)},title:`Double-click to edit`,children:t?a??t:(0,X.jsx)(`span`,{className:`placeholder`,children:n})});let u=e=>{c(!1),!l.current&&e.value!==t&&r(e.value)};return(0,X.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 PR=/[.!?…]+["'”’)\]]*(?=\s|$)|\n/g;function FR(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(PR)){let e=t[0]===`
|
|
62
|
-
`?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 IR(e,t){let[n,r]=e<=t?[e,t]:[t,e];return r>n?{line:n,last:r}:{line:n}}var LR=e=>Math.min(1,Math.max(0,e)),RR=e=>Math.round(e*1e4)/1e4;function zR(e,t){let[n,r]=[LR(Math.min(e.x,t.x)),LR(Math.max(e.x,t.x))],[i,a]=[LR(Math.min(e.y,t.y)),LR(Math.max(e.y,t.y))];return{x:RR(n),y:RR(i),w:RR(r-n),h:RR(a-i)}}function BR(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,LR(e.x)-i/2)),s=Math.min(1-a,Math.max(0,LR(e.y)-a/2));return{x:RR(o),y:RR(s),w:RR(i),h:RR(a)}}function VR(e,t,n=8){return e.w*t.width<n||e.h*t.height<n}function HR(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 UR(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 WR(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 GR(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 KR(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 qR={type:`chart`,kind:`bar`,columns:[`Team`,`Tasks done`],rows:[[`Design`,`8`],[`Web`,`13`],[`Server`,`11`],[`Docs`,`5`]]},JR=e=>`var(--series-${e%8+1})`,YR=new Map,XR=new Set;function ZR(e){YR.set(e,`data`);for(let e of XR)e()}function QR(e){return[(0,d.useSyncExternalStore)(e=>(XR.add(e),()=>XR.delete(e)),()=>YR.get(e)??`chart`),t=>{YR.set(e,t);for(let e of XR)e()}]}function $R({block:e,frozen:t}){let n=MR(),[r,i]=QR(e.id),a=`${S[e.kind]} chart`;return(0,X.jsxs)(X.Fragment,{children:[n.readOnly||t?(0,X.jsx)(`span`,{className:`chart-kind`,children:a}):(0,X.jsxs)(`span`,{className:`chart-kind is-menu nodrag`,onDoubleClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`select`,{value:e.kind,onChange:t=>n.updateBlock(e,{kind:t.target.value}),"aria-label":`Kind of chart`,title:`Kind of chart`,children:x.map(e=>(0,X.jsxs)(`option`,{value:e,children:[S[e],` chart`]},e))}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:a}),(0,X.jsx)(`svg`,{className:`chart-kind-caret`,viewBox:`0 0 8 8`,"aria-hidden":!0,children:(0,X.jsx)(`path`,{d:`M1.5 3 4 5.5 6.5 3`})})]}),(0,X.jsx)(`span`,{className:`chart-switch nodrag`,role:`radiogroup`,"aria-label":`Show`,onDoubleClick:e=>e.stopPropagation(),children:[`chart`,`data`].map(e=>(0,X.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 ez({block:e,selected:t,placed:n}){let[r]=QR(e.id);return r===`data`?(0,X.jsx)(lz,{block:e,selected:t}):(0,X.jsx)(az,{block:e,placed:n})}function tz(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 nz(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 rz(e,t,n,r){if(t.category===void 0){let i=t.series===void 0?null:fe(e,t.series);return i===null?null:{id:n,category:null,series:i,draft:r}}let i=de(e,t.category,t.series);return i&&{id:n,category:i.row,series:i.series,draft:r}}function iz(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:pe(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:me(e,t,r)}}function az({block:e,placed:t}){let n=MR(),r=n.draft?.blockId===e.id&&n.draft.part.kind===`point`?n.draft.part:null,i=r&&rz(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,X.jsx)(oz,{block:e,marks:a,pinnable:!n.readOnly,onPick:(t,r)=>{let i=iz(e,t,r);i&&n.startPin(i)}})}function oz(e){let{block:t,marks:n,pinnable:r,onPick:i,full:a=!1,onOpen:o}=e,s=(0,d.useMemo)(()=>E(t),[t]),c=(0,d.useRef)(null),l=tz(c),u=(0,d.useMemo)(()=>ie(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=>KR(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&&KR(n,e,t));s&&(a.stopPropagation(),o(s.id))},x=(e,t)=>()=>p({category:e,series:t}),C=()=>p(null),w=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:T}=u,D=`${S[s.kind]} chart of ${s.series.map(e=>e.name).join(`, `)}${t.columns[0]?` by ${t.columns[0]}`:``}`,O=e=>h?[e,null]:[null,e];return(0,X.jsxs)(`div`,{className:`chart is-${s.kind}`,children:[(0,X.jsx)(sz,{block:t,model:s,...a&&{marked:e=>y(...O(e),h?`none`:`series`),pick:e=>b(...O(e)),pinnable:r}}),(0,X.jsxs)(`div`,{ref:c,className:`chart-frame nopan`,tabIndex:0,"aria-label":`${D}. Arrow keys read the values; the Data tab shows them all.`,onKeyDown:w,onBlur:C,onPointerLeave:C,children:[u.width>0&&(0,X.jsxs)(`svg`,{className:`chart-svg`,width:u.width,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,role:`img`,"aria-label":D,children:[!h&&(0,X.jsxs)(`g`,{"aria-hidden":!0,children:[u.ticks.map(e=>(0,X.jsx)(`line`,{className:`chart-grid`,x1:T.x,x2:T.x+T.w,y1:e.y,y2:e.y},e.value)),u.ticks.length>0&&(0,X.jsx)(`line`,{className:`chart-baseline`,x1:T.x,x2:T.x+T.w,y1:u.zero,y2:u.zero}),u.ticks.map(e=>(0,X.jsx)(`text`,{className:`chart-tick`,x:T.x-8,y:e.y+3.5,textAnchor:`end`,children:e.label},e.value)),u.caption&&(0,X.jsx)(`text`,{className:`chart-tick`,x:u.caption.x,y:u.caption.y,children:u.caption.text}),u.axis.map(e=>(0,X.jsx)(`text`,{className:`chart-axis`,x:e.x,y:T.y+T.h+16,textAnchor:e.anchor,children:e.text},e.category)),f&&!g&&u.bands[f.category]&&(0,X.jsx)(`rect`,{className:`chart-band`,x:u.bands[f.category].x,y:T.y,width:u.bands[f.category].w,height:T.h})]}),u.lines.map(e=>{let{className:t,...n}=y(null,e.series,`none`);return(0,X.jsxs)(`g`,{children:[e.area&&(0,X.jsx)(`path`,{className:`chart-area`,d:e.area,style:{fill:JR(e.series)}}),(0,X.jsx)(`path`,{className:`chart-line${t}`,d:e.path,style:{stroke:JR(e.series)},...n}),e.lone.map(t=>(0,X.jsx)(`circle`,{className:`chart-dot`,cx:t.x,cy:t.y,r:3,style:{fill:JR(e.series)}},t.category))]},e.series)}),u.bars.map(e=>{let{className:t,...n}=y(e.category,e.series);return(0,X.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:JR(e.series)},...n},`${e.category}-${e.series}`)}),u.slices.map(e=>{let{className:t,...n}=y(e.category,null);return(0,X.jsx)(`path`,{className:`chart-slice${_(e.category)?` is-faded`:``}${f?.category===e.category?` is-hover`:``}${t}`,d:e.path,style:{fill:JR(e.category)},...n},e.category)}),u.ring&&(0,X.jsxs)(`g`,{"aria-hidden":!0,children:[(0,X.jsx)(`text`,{className:`chart-total`,x:u.ring.cx,y:u.ring.cy+2,textAnchor:`middle`,children:u.ring.total}),(0,X.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,X.jsxs)(`g`,{"aria-hidden":!0,children:[(0,X.jsx)(`line`,{className:`chart-crosshair`,x1:u.bands[f.category].cx,x2:u.bands[f.category].cx,y1:T.y,y2:T.y+T.h}),u.lines.flatMap(e=>e.points.filter(e=>e.category===f.category).map(t=>(0,X.jsx)(`circle`,{className:`chart-marker`,cx:t.x,cy:t.y,r:4,style:{fill:JR(e.series)}},e.series)))]}),u.markers.map(e=>(0,X.jsx)(`circle`,{className:`chart-marker`,cx:e.x,cy:e.y,r:4,style:{fill:JR(e.series)}},`${e.series}-${e.x}`)),(0,X.jsx)(`g`,{"aria-hidden":!0,children:u.labels.map((e,t)=>(0,X.jsxs)(`g`,{children:[e.leader&&(0,X.jsx)(`line`,{className:`chart-leader`,x1:e.leader.x1,y1:e.leader.y1,x2:e.leader.x2,y2:e.leader.y2}),(0,X.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=nz(u,e.category,e.series);return t?(0,X.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,X.jsxs)(`g`,{className:r?`chart-hits is-pinnable`:`chart-hits`,children:[u.bars.map(e=>(0,X.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,X.jsx)(`path`,{d:e.hit,onPointerEnter:x(e.category,null),onClick:b(e.category,null)},e.category)),g&&u.bands.map(e=>(0,X.jsx)(`rect`,{x:e.x,y:T.y,width:e.w,height:T.h,onPointerEnter:x(e.category,null),onClick:b(e.category,null)},e.category)),g&&m&&u.lines.flatMap(e=>e.points.map(t=>(0,X.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,X.jsx)(cz,{model:s,layout:u,hover:f})]})]})}function sz(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:ue(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,X.jsxs)(`div`,{className:`chart-top${c.length?``:` is-subtitle-only`}`,children:[c.length>0&&(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`i`,{className:`chart-key ${s}`,style:{background:JR(e.i)},"aria-hidden":!0}),e.name,e.note&&(0,X.jsx)(`span`,{className:`chart-legend-note`,children:e.note})]});return(0,X.jsx)(`li`,{className:`${t}${c}`.trim()||void 0,...l,children:i?(0,X.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,X.jsx)(`p`,{className:`chart-subtitle`,children:t.subtitle})]})}function cz({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:M(o(0),e.unit),name:ue(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:M(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:M(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:M(t,e.unit),name:`in all`})}let c=nz(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,X.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,X.jsx)(`p`,{className:`chart-tip-head`,children:e.categories[r]||`Row ${r+1}`}),s.map(e=>(0,X.jsxs)(`p`,{className:e.strong?`chart-tip-row is-on`:`chart-tip-row`,children:[e.key>=0&&(0,X.jsx)(`i`,{className:`chart-key is-line`,style:{background:JR(e.key)},"aria-hidden":!0}),(0,X.jsx)(`b`,{children:e.value}),e.name&&(0,X.jsx)(`span`,{children:e.name})]},e.key))]})}function lz({block:e,selected:t}){let n=MR(),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,X.jsxs)(`div`,{className:`block-table-wrap chart-data`,children:[(0,X.jsxs)(`table`,{className:`block-table nopan`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[e.columns.map((t,n)=>(0,X.jsxs)(`th`,{className:n?`is-number`:void 0,children:[(0,X.jsx)(NR,{value:t,placeholder:n?`Series`:`Category`,onCommit:e=>a(-1,n,e)}),r&&n>0&&e.columns.length>2&&(0,X.jsx)(`button`,{className:`cell-remove nodrag`,onClick:()=>s(n),title:`Remove series`,"aria-label":`Remove series`,children:(0,X.jsx)(Q,{name:`x`})})]},n)),r&&e.columns.length<9&&(0,X.jsx)(`th`,{className:`table-add-col`,children:(0,X.jsx)(`button`,{className:`nodrag`,onClick:o,title:`Add a series`,"aria-label":`Add a series`,children:(0,X.jsx)(Q,{name:`plus`})})})]})}),(0,X.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,X.jsxs)(`tr`,{children:[t.map((e,t)=>(0,X.jsx)(`td`,{className:t?`is-number`:void 0,children:(0,X.jsx)(NR,{value:e,placeholder:``,onCommit:e=>a(n,t,e)})},t)),r&&e.rows.length>1&&(0,X.jsx)(`td`,{className:`table-row-remove`,children:(0,X.jsx)(`button`,{className:`nodrag`,onClick:()=>i(e.columns,e.rows.filter((e,t)=>t!==n)),title:`Remove row`,"aria-label":`Remove row`,children:(0,X.jsx)(Q,{name:`x`})})})]},n))})]}),r&&(0,X.jsxs)(`button`,{className:`block-add nodrag`,onClick:()=>i(e.columns,[...e.rows,e.columns.map(()=>``)]),children:[(0,X.jsx)(Q,{name:`plus`}),` Row`]}),e.unit&&(0,X.jsxs)(`p`,{className:`chart-data-unit`,children:[`Numbers in `,e.unit]})]})}var uz=null;function dz(e){uz?.(!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=>{uz===a&&(uz=null,r.unmount(),n.remove(),!e&&t?.isConnected&&t.focus(),i(e))};uz=a,(0,kc.flushSync)(()=>r.render((0,X.jsx)(fz,{...e,onAnswer:a})))})}function fz({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,X.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&a(!1),children:(0,X.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,X.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),t&&(0,X.jsx)(`p`,{id:`confirm-dialog-detail`,children:t}),(0,X.jsxs)(`div`,{className:`delete-actions`,children:[(0,X.jsx)(`button`,{ref:s,type:`button`,className:`btn`,onClick:()=>a(!1),children:r}),(0,X.jsx)(`button`,{ref:c,type:`button`,className:i?`btn btn-danger`:`btn btn-primary`,onClick:()=>a(!0),children:n})]})]})})}function pz(e,t){let n=`${t} comment${t===1?``:`s`}`;return dz({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 mz=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,hz=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function gz(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,X.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,X.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,X.jsx)(`p`,{className:`pin-prompt-quote`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:p,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(DT,{skills:!0,lenses:Hw,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,X.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,X.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:h||a,onClick:()=>f(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:h||a,onClick:()=>f(!1),children:`Add a note`}),(0,X.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${mz}+Enter asks ${s??`an agent`}`,children:mz===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,X.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 _z(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=MR(),s=Fo(t,AR(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,X.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,X.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} ${t.quote}: ${hz(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,X.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,X.jsx)(Q,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,X.jsx)(Q,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,X.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,X.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await pz(`this part`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin ${t.quote}`,title:`Unpin. Its thread goes with it.`,children:(0,X.jsx)(Q,{name:`x`})})]})}var vz=e=>t=>tC(e,t);function yz({board:e,said:t,className:n}){let r=Hx(t,vz(e));if(r.length===0)return null;let i=g(r);return(0,X.jsxs)(`span`,{className:n?`said-to ${n}`:`said-to`,title:`${t.author.name} to ${i}`,children:[(0,X.jsx)(Q,{name:`arrow-right`,className:`said-to-arrow`}),(0,X.jsx)(`span`,{className:`said-to-sr`,children:`to `}),(0,X.jsx)(`span`,{className:`said-to-name`,children:i})]})}function bz(e,t){let n=t.findLastIndex(t=>Hx(t,vz(e)).length>0);return n>=0&&!t[n].held?n:-1}function xz({board:e,items:t,className:n=`loop-line`}){let r=Ux(t,vz(e));return r?(0,X.jsx)(`p`,{className:n,children:Wx(r)}):null}var Sz=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 Cz(e){let t=(0,d.useSyncExternalStore)(Sz.subscribe,Sz.get);return(0,d.useMemo)(()=>t.filter(t=>t.place===e),[t,e])}function wz(e,t,n,r,i=Sz.keyOf){let a=new Map,o=[];for(let r of t){let t=e=>!a.has(e.id)&&e.author.kind===`human`&&m(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 Tz(e){let t=e.outgoing;if(t&&e.item.id===t.key&&t.state!==`sent`)return t.state}function Ez(e){return e.flatMap(e=>e.outgoing&&e.item.id!==e.outgoing.key&&e.outgoing.state!==`sending`?[e.outgoing.key]:[])}function Dz(e,t,n,r){let i=e.filter(e=>e.author.kind===`human`&&m(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 Oz,kz;function Az(){return Oz??=Y.liveSteps().then(e=>kz=e.installedAgents??e.agents,()=>kz=null),Oz}function jz(){let[e,t]=(0,d.useState)(kz);return(0,d.useEffect)(()=>{let e=!0;return Az().then(n=>e&&t(n)),()=>{e=!1}},[]),e}var Mz=new Set,Nz,Pz,Fz=1e4;function Iz(){Y.agents().then(e=>{let t=e.filter(e=>e.state!==`absent`).map(e=>e.name);if(!(Nz&&t.join(`
|
|
63
|
-
`)===Nz.join(`
|
|
64
|
-
`))){Nz=t;for(let e of Mz)e()}},()=>{})}function Lz(e){return Mz.add(e),Mz.size===1&&(Iz(),Pz=setInterval(Iz,Fz)),()=>{Mz.delete(e),Mz.size===0&&clearInterval(Pz)}}function Rz(){return(0,d.useSyncExternalStore)(Lz,()=>Nz)}function zz(e,t){return t?jb(e,t)?.name:void 0}function Bz({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(mC).then(()=>i(!0),()=>{});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{"aria-hidden":n||void 0,children:[xC(e,t),` `,(0,X.jsx)(`q`,{className:`say-phrase`,children:mC})]}),` `,(0,X.jsx)(`button`,{type:`button`,className:`delivery-action say-copy`,onClick:()=>void a(),title:`Copy “${mC}”`,children:r?`Copied`:`Copy`})]})}var Vz=5e3;function Hz({board:e,where:t,said:n,after:r,onItsWay:i,outgoing:a,onEdit:o,onConnect:s,children:c}){let l=ol(),u=hw(),f=XC(),[p,m]=(0,d.useState)(()=>Date.now()),h=Math.max(p,Date.now()),g=f.filter(e=>UC(e,h)||e.done),_=i||l||!OC(n,h)?void 0:fC({board:e,where:t,said:n,after:r,agents:u,steps:g}),v=_&&pC(_,h),y=!!v;(0,d.useEffect)(()=>{if(!y)return;let e=setInterval(()=>m(Date.now()),Vz);return()=>clearInterval(e)},[y]);let b=_&&v?{delivery:_,words:v,title:DC(v,n,h),busy:wC(_,e=>UC(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||!EC(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,X.jsxs)(`p`,{className:`delivery is-failed`,role:`alert`,title:a.error,children:[(0,X.jsxs)(`span`,{className:`delivery-text`,children:[`Not sent`,a.error?`: ${a.error}`:``]}),(0,X.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>Sz.retry(a.key),children:`Retry`}),o&&(0,X.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>{Sz.remove(a.key),o(a.body,a.lens)},children:`Edit`})]});else if(i===`sending`)T=(0,X.jsxs)(`p`,{className:`delivery is-sending`,children:[(0,X.jsx)(`span`,{className:`delivery-text`,children:`Sending…`}),(0,X.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,X.jsx)(Wz,{shown:b,said:n,at:h,onHover:e,onConnect:s}):(0,X.jsx)(Uz,{shown:b,onHover:e,onConnect:s})}else S&&w&&(T=(0,X.jsx)(Uz,{shown:S,leaving:!0}));return T?(0,X.jsxs)(`div`,{className:`said-foot`,children:[c,T]}):(0,X.jsx)(X.Fragment,{children:c})}function Uz({shown:{delivery:e,words:t,title:n,busy:r},leaving:i=!1,onHover:a,onConnect:o}){let s=e.state===`working`;return(0,X.jsxs)(`p`,{className:`delivery is-${e.state}${i?` is-leaving`:``}`,title:n,onPointerEnter:a,children:[(0,X.jsx)(`span`,{className:`delivery-text`,"aria-hidden":!0,children:(0,X.jsx)($C,{text:t})},t),(0,X.jsx)(fw,{state:r,leaving:i}),e.state===`nobody`&&(0,X.jsx)(`button`,{type:`button`,className:`delivery-action`,onClick:()=>{o?.(),Gz()},children:`Connect one`}),(0,X.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:s?`${e.agent} is working on it`:t})]})}function Wz({shown:e,said:t,at:n,onHover:r,onConnect:i}){let a=Rz(),o=jz();if(a===void 0||o===void 0)return null;let s=hC(e.delivery,a);if(!s)return(0,X.jsx)(Uz,{shown:e,onHover:r,onConnect:i});let c=zz(s,o),l=SC(s,c,e.delivery);return(0,X.jsxs)(`p`,{className:`delivery is-unheard`,title:DC(l,t,n),onPointerEnter:r,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:bC(s,e.delivery)}),` `,(0,X.jsx)(Bz,{agent:s,tool:c,quiet:!0}),(0,X.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:l})]})}function Gz(){let e=document.querySelector(`details.connect-popover`);e&&(e.open=!0,e.querySelector(`summary`)?.focus())}var Kz=2;function qz(e,t){return`threadId`in e?(t,n,r,i)=>Y.reactInThread(e.threadId,t,n,r,i):`pinId`in e?(t,n,r,i)=>Y.reactOnPin(e.pinId,t,n,r,i):t.reaction(e)}function Jz({item:e,place:t,name:n}){let r=ol(),i=Nc(),a={kind:`human`,name:n},o=e.author.kind===`human`&&m(e.author.name,n),s=qz(t,i),c=!r&&!o&&!!n&&!!s,[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(null),h=TS(e.reactions),g=async t=>{if(!l&&c&&s){u(!0),p(null);try{await s(e.id,n,t,SS(e,t,a))}catch(e){p(e.message)}finally{u(!1)}}};return h.length===0&&!c?null:(0,X.jsxs)(`div`,{className:`reactions`,children:[h.map(({emoji:t,reactions:n})=>{let r=SS(e,t,a),i=`${yS[t]} from ${Yz(n,n.length)}${r&&c?`. Yours: press to take it back`:``}`,o=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`reaction-emoji`,"aria-hidden":!0,children:t}),(0,X.jsx)(`span`,{className:`reaction-names`,children:Yz(n,Kz)})]});return c?(0,X.jsx)(`button`,{type:`button`,className:`reaction${r?` is-mine`:``}`,"aria-pressed":r,"aria-label":i,title:Xz(t,n),disabled:l,onClick:()=>void g(t),children:o},t):(0,X.jsx)(`span`,{className:`reaction${r?` is-mine`:``}`,role:`img`,"aria-label":i,title:Xz(t,n),children:o},t)}),c&&(0,X.jsx)(Zz,{item:e,me:a,busy:l,onPick:e=>void g(e)}),f&&(0,X.jsx)(`span`,{className:`reactions-error`,role:`alert`,children:f})]})}function Yz(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 Xz(e,t){return[`${e} ${yS[e]}`,...t.map(e=>`${e.by.name}, ${Yy(e.at)}`)].join(`
|
|
65
|
-
`)}function Zz({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 Uc(i,l,o),(0,d.useEffect)(()=>{i&&c.current?.querySelector(`button`)?.focus()},[i]),(0,X.jsxs)(`span`,{className:`reaction-adder`,ref:o,children:[(0,X.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,X.jsx)(Q,{name:`react`})}),i&&(0,X.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=el(e.key,t.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),t[n]?.focus())},children:vS.map(i=>{let a=SS(e,i,t);return(0,X.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":a,"aria-label":yS[i],title:a?`${yS[i]}: take yours back`:yS[i],tabIndex:-1,disabled:n,onClick:()=>{r(i),l(!0)},children:i},i)})})]})}typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent);function Qz(e){let t=nT();return[...t.agents.map(e=>e.name),...t.people,e]}var $z=`tricot:focus-pin`,eB=e=>`comment-${e}`;function tB(e,t=12){let n=e.flatMap(e=>document.getElementById(eB(e))??[]);if(n.length===0)t>0&&setTimeout(()=>tB(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`)}}var nB=`draft`;function rB(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 iB(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 aB=new Set([`p`,`li`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`blockquote`,`pre`,`td`,`th`]);function oB({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,aB.has(n.tagName)?n:t)};s(i,i);let c=e.flatMap(e=>{let t=wo(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=rB(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===nB);return{type:`element`,tagName:`mark`,properties:{className:iB(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 sB({node:e,children:t,...n}){let{pins:r}=MR(),i=n,a=i[`data-chip`];if(a){let e=[...r.values()].flat().find(e=>e.id===a);return e?(0,X.jsx)(lB,{pin:e}):null}return(0,X.jsx)(`mark`,{className:n.className,"data-pin-draft":i[`data-pin-draft`]?``:void 0,children:t})}function cB({text:e,marks:t,focus:n}){return t.length===0?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(X.Fragment,{children:rB(e.length,t).map(t=>{let r=e.slice(t.start,t.end);if(t.covering.length===0)return(0,X.jsx)(`span`,{children:r},t.start);let i=t.covering.some(e=>e.id===nB);return(0,X.jsx)(`mark`,{className:iB(t.covering,n),"data-pin-draft":i?``:void 0,children:r},t.start)})})}function lB({pin:e,part:t,lost:n}){let{board:r,readOnly:i,removeItem:a,focusPin:o}=MR(),s=Nc(),c=jo(r,e);if(e.discussion)return(0,X.jsx)(dB,{pin:e,part:t,lost:n});if(!c)return null;let[l]=Oi(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 ${Ni(e.anchor.kind)?.words?`words`:`part`} changed since)`:``}`,p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-dot`,"aria-hidden":!0}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-part`,children:t}),n&&(0,X.jsx)(`span`,{className:`pin-chip-lost`,children:n}),(0,X.jsx)(Q,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,X.jsx)(`span`,{className:`pin-chip-ref`,children:c.ref}),(0,X.jsx)(`span`,{className:`pin-chip-status`,children:c.status})]});return(0,X.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,X.jsx)(`button`,{type:`button`,className:`pin-chip-open`,onClick:()=>u.open(),title:f,children:p}):(0,X.jsx)(`span`,{className:`pin-chip-open`,title:f,children:p}),!i&&(0,X.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,X.jsx)(Q,{name:`x`})})]})}var uB=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function dB({pin:e,part:t,lost:n}){let r=MR(),{readOnly:i,removeItem:a,focusPin:o,newItems:s,thread:c}=r,l=Fo(e,AR(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?`${uB(l.length,`comment`)} on this part${d?`, resolved by ${d.by.name}`:``}`:`${uB(l.length,`comment`)} on this part in the discussion`;return(0,X.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,X.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:()=>u?r.openThread(e.id):tB(l.map(e=>e.id)),title:u?h:`${h}. Show ${l.length===1?`it`:`them`}.`,"aria-expanded":u?f:void 0,children:[t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-part`,children:t}),n&&(0,X.jsx)(`span`,{className:`pin-chip-lost`,children:n}),(0,X.jsx)(Q,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,X.jsx)(Q,{name:d?`check`:`comment`,className:`pin-chip-icon`}),(0,X.jsx)(`span`,{className:`pin-chip-ref`,children:l.length}),d&&(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}),p&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!i&&(0,X.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{u&&l.length&&!await pz(`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,X.jsx)(Q,{name:`x`})})]})}function fB({block:e,placed:t}){let n=t.filter(({pin:t,place:n})=>!n||Ni(t.anchor.kind,e)?.drawn||t.anchor.kind===`block`&&!_i(e.type).pins?.whole);return n.length===0?null:(0,X.jsx)(`div`,{className:`pin-strip`,"data-pin-skip":``,children:n.map(({pin:t,place:n})=>(0,X.jsx)(lB,{pin:t,part:Do(t,e),lost:n?void 0:ko(t,e)},t.id))})}function pB(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 mB(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 hB(e,t){let n=pB(e),r=n.map(e=>e.data).join(``),i=mB(n,t.startContainer,t.startOffset),a=mB(n,t.endContainer,t.endOffset),o=a>i?yo(r,i,a):null;return o&&{kind:`text`,...o}}function gB(e){return e.shiftKey||e.metaKey||e.ctrlKey?null:e.target?.closest?.(`[data-pin-text][data-block-id]`)??null}function _B(e,t){if(!e?.isConnected||!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);return n.intersectsNode(e)?hB(e,n):null}function vB(e){let t=pB(e);return{text:t.map(e=>e.data).join(``),at:(e,n)=>mB(t,e,n)}}function yB(){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 bB({part:e,block:t}){return(0,X.jsx)(X.Fragment,{children:Oo(e,t)})}var xB=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,SB={id:`comment`,label:`Comment`,does:`comments`},CB={placeholder:`A comment on this part`,label:`Comment`,hint:``,line:`Click a line to comment on it`,becomes:`a comment`};function wB(){let e=Nc().pinWords(null)??CB;return{line:e.line??CB.line,becomes:e.becomes??CB.becomes}}function TB(e,t){let n=e.pinActions({card:t});return{offered:n,acts:[...n.filter(e=>!e.afterComment),SB,...n.filter(e=>e.afterComment)]}}function EB(e){let{draft:t,block:n,name:r,style:i,above:a,onChange:o,onClose:s,onCommented:c}=e,l=MR(),u=Nc(),f=ji(AR(l))?.kind.kind??null,{offered:p,acts:m}=TB(u,f),h=u.pinWords(f)??CB,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?pY(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 Y.pinComment(t.blockId,r,{part:t.part,body:y});c(e,n)}s()}catch(e){E(e.message),w(!1)}}};return(0,X.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,X.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,X.jsx)(`p`,{className:`pin-prompt-quote`,children:(0,X.jsx)(bB,{part:{anchor:t.part,quote:t.quote},block:n})}),(0,X.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:s,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),n&&O&&(0,X.jsx)(O,{draft:t,block:n,onChange:o}),(0,X.jsx)(DT,{skills:!0,lenses:Hw,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,X.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:T}),(0,X.jsxs)(`div`,{className:`pin-prompt-actions${m.length>2?` is-three`:``}`,children:[m.map(e=>(0,X.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,X.jsxs)(`label`,{className:`pin-ready`,title:h.ready?.title,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),h.ready?.label??`Ready now`]}),(0,X.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${xB}+Enter ${g.does}`,children:xB===`⌘`?`⌘↵`:`Ctrl ↵`})]}),h.hint&&(0,X.jsx)(`p`,{className:`pin-prompt-hint`,children:h.hint})]})}function DB(e){let{pin:t,block:n,name:r,style:i,above:a,inline:o,onClose:s,onHeight:c,live:l,address:u}=e,f=MR(),{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=Fo(t,AR(f)),w=!!t.discussion?.thread,T=t.discussion?.resolved,E=(m.get(t.blockId)??[]).filter(e=>e!==t&&!e.discussion&&Ao(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(()=>Y.commentOnPin(t.id,r,u?u(_):_),()=>v(``));return(0,X.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,X.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,X.jsx)(`p`,{className:`pin-prompt-quote`,children:(0,X.jsx)(bB,{part:t,block:n})}),(0,X.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:s,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(`ol`,{className:`pin-thread-comments`,ref:g,children:C.map(e=>(0,X.jsxs)(`li`,{className:`pin-thread-comment comment-${e.author.kind}`,children:[(0,X.jsxs)(`div`,{className:`comment-head`,children:[(0,X.jsx)($y,{actor:e.author}),` `,(0,X.jsx)(`span`,{className:`faint small`,children:Yy(e.createdAt)}),e.ask&&(0,X.jsx)(`span`,{className:`pin-thread-ask`,children:`Asked agents`}),(0,X.jsx)(aT,{lens:e.lens}),(0,X.jsx)(oT,{via:e.via}),(0,X.jsx)(sT,{comment:e,thread:C})]}),(0,X.jsx)(iT,{comment:e}),(0,X.jsx)(Jz,{item:e,place:{pinId:t.id},name:r})]},e.id))}),(()=>{let e=D&&(0,X.jsx)(`p`,{className:`pin-thread-note`,children:O?`Agents see this request in their updates, ${Ni(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,X.jsxs)(`div`,{className:`pin-thread-also`,children:[(0,X.jsx)(`span`,{children:`Pinned here too`}),E.map(e=>(0,X.jsx)(lB,{pin:e},e.id))]}),T&&(0,X.jsxs)(`p`,{className:`pin-thread-resolved`,children:[(0,X.jsx)(Q,{name:`check`}),` Resolved by `,T.by.name,` `,Yy(T.at)]}),!p&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(DT,{skills:!0,lenses:Hw,rows:2,value:_,placeholder:T?`Reply to reopen it`:`Reply (${xB===`⌘`?`⌘↵`:`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,X.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:x}),(0,X.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,disabled:!_.trim()||y,onClick:j,children:`Reply`}),w&&(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:y,onClick:()=>void A(()=>Y.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 OB=e=>`of`in e;function kB(e,t,n,r){let i=MR(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),f=a&&n&&OB(n)?n:null,p=(0,d.useCallback)(()=>{n&&r&&(u(null),o(t=>t??{base:e,text:OB(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(!OB(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 Y.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&&OB(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=OB(n)?(0,X.jsx)(jB,{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&&!OB(n)),text:a?.text??``,saving:s,error:l,theirs:_,start:p,stop:g,discard:m,keepMine:v,takeTheirs:y,setText:b,editor:x}}var AB=250;function jB({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),AB);return()=>clearTimeout(e)},[n]);let s=e.single?(0,X.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,X.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,X.jsxs)(`div`,{className:`piece-edit${e.preview?` has-preview`:``}${e.single?` is-single`:``}`,children:[(0,X.jsxs)(`div`,{className:`piece-edit-field`,children:[(0,X.jsx)(`span`,{className:`piece-edit-label`,children:e.label}),s]}),e.preview&&(0,X.jsxs)(`div`,{className:`piece-edit-preview`,"aria-label":`Preview`,children:[(0,X.jsx)(`span`,{className:`piece-edit-label`,children:`Preview`}),(0,X.jsx)(`div`,{className:`piece-edit-shown`,children:e.preview(a,t)})]})]})}var MB=6e4,NB=2e3;function PB(e,t,n){return GS(e,[...n,t]).length>0?e:`@${t} ${e.trimStart()}`}function FB(e,t){return!!e.mentions?.some(e=>m(e,t))||/\?["”’)\]]*\s*$/.test(e.body.trim())}function IB(e,t,n){let r=Date.parse(n.startedAt)-NB,i=[];for(let a of e){if(a.blockId!==n.blockId||!a.discussion)continue;let e=Fo(a,t),o=e.filter(e=>e.author.kind===`human`&&m(e.author.name,n.person)&&Date.parse(e.createdAt)>=r&&e.mentions?.some(e=>m(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=>m(e.author.name,n.agent))??l.at(-1),d=u&&!c.slice(c.indexOf(u)+1).some(e=>e.author.kind===`human`),f=d?FB(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 LB=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function RB(e){if(e.length===0)return`no requests`;let t=e.filter(e=>e.state===`done`).length;return`${LB(e.length,`request`)}, ${t} done, ${e.length-t} open`}function zB(e,t){return e.state===`working`&&e.step?`${e.agent} is on it · ${CC(e.step)}`:pC(e,t)}function BB(e){return p(qS(e.asked.body,e.asked.mentions??[]),120)}var VB=5e3;function HB(e){let t=MR(),n=hw(),r=XC(),[i,a]=(0,d.useState)(()=>Date.now()),o=Fo(e,AR(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=>UC(e,s)||e.done),p=l&&!t.readOnly&&OC({at:l.createdAt},s)?fC({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&&zB(p,s);if((0,d.useEffect)(()=>{if(!m)return;let e=setInterval(()=>a(Date.now()),VB);return()=>clearInterval(e)},[!!m]),p&&m&&l)return{delivery:p,words:m,said:l,busy:wC(p,e=>UC(e,s)===`live`)}}function UB({pin:e,fallback:t=null}){let n=HB(e);if(!n)return(0,X.jsx)(X.Fragment,{children:t});let{delivery:r,words:i,busy:a,said:o}=n,s=r.state===`working`;return(0,X.jsxs)(`p`,{className:`delivery pin-live is-${r.state}`,title:DC(i,{at:o.createdAt},Date.now()),children:[(0,X.jsx)(`span`,{className:`delivery-text`,"aria-hidden":!0,children:(0,X.jsx)($C,{text:i})},i),(0,X.jsx)(fw,{state:a}),(0,X.jsx)(`span`,{className:`delivery-sr`,role:`status`,children:s?`${r.agent} is working on it`:i})]})}function WB(e){if(e.status!==`backlog`)return e.assignee?e.assignee:e.claimedBy?.kind===`agent`&&e.status!==`todo`?e.claimedBy.name:void 0}function GB(e,t){let n=[],r=e=>{e&&!n.some(t=>m(t,e))&&n.push(e)};t.task&&r(WB(t.task));let i=e.author.kind===`agent`?e.author.name:void 0;for(let n of t.threads??[])LS(n,{kind:`block`,id:e.id})&&r(n.lens?.agent??i);return n}function KB({agents:e,picked:t,named:n=[],last:r}){let i=t=>t?e.find(e=>m(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&&m(e.name,r))??n[0]).name}return e[0]?.name??null}var qB=`tricot:pair-agent`;function JB(){try{return localStorage.getItem(qB)}catch{return null}}function YB(e){try{localStorage.setItem(qB,e)}catch{}}function XB(e,t,n,r={}){let i=MR(),{board:a,owner:o}=i,s=i.readOnly||!!r.readOnly,c=hw(),[l,u]=(0,d.useState)(`browse`),[f,p]=(0,d.useState)(null),[h]=(0,d.useState)(JB),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(null),b=(0,d.useRef)(null);b.current=g;let x=(0,d.useRef)(!1),[S,C]=(0,d.useState)(!1),w=(0,d.useRef)(`browse`),T=(0,d.useRef)(!1),E=(0,d.useMemo)(()=>BS(a,c.map(e=>e.name)).map(e=>{let t=c.find(t=>m(t.name,e));return t?{name:t.name,state:t.state,lastSeen:t.lastSeen}:{name:e,state:`unseen`}}),[a,c]),D=a.threads,O=KB({agents:E,picked:f,named:(0,d.useMemo)(()=>GB(e,{task:o?.card,threads:D}),[e,o,D]),last:h}),k=(0,d.useCallback)(async e=>{let n=b.current;if(n){b.current=null,_(null);try{let{summary:r}=await Y.endPairing(n.id,t);y(e(r))}catch{y(e())}}},[t]),A=(0,d.useCallback)(async r=>{try{let i=await Y.startPairing(t,{blockId:e.id,part:n,agent:r});if(w.current!==`pair`)return void Y.endPairing(i.id,t).catch(()=>void 0);b.current=i,_(i),p(i.agent),YB(i.agent)}catch(e){y(`Couldn't start pairing with ${r}: ${e.message}`)}},[t,e.id,n]),j=(0,d.useCallback)(e=>{if(s)return;let t=e??O;if(e&&(p(e),YB(e)),u(`pair`),w.current=`pair`,y(null),!t||x.current)return;let n=b.current;n&&m(n.agent,t)||(x.current=!0,C(!0),(async()=>{n&&await k(e=>e??null),await A(t),x.current=!1,C(!1)})())},[s,O,k,A]),M=(0,d.useCallback)(()=>{u(`browse`),w.current=`browse`,k(e=>e??null)},[k]);(0,d.useEffect)(()=>{if(!g)return;let e=()=>T.current=!0;document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0);let n=setInterval(()=>{let e=T.current;T.current=!1,Y.pairingBeat(g.id,t,e).catch(e=>{e.status===404&&b.current?.id===g.id&&(b.current=null,_(null),u(`browse`),w.current=`browse`,y(`Pairing with ${g.agent} ended: nothing was asked for a while, or it moved to another tab.`))})},MB),r=()=>b.current&&Y.leavePairing(b.current.id,t);return window.addEventListener(`pagehide`,r),()=>{clearInterval(n),document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pagehide`,r)}},[g,t]),(0,d.useEffect)(()=>()=>{w.current=`browse`,b.current&&Y.leavePairing(b.current.id,t),b.current=null},[t]);let N=i.pins.get(e.id),P=(0,d.useMemo)(()=>g?IB(N??[],AR({owner:o}),g):[],[g,N,o]),F=(0,d.useMemo)(()=>E.map(e=>e.name),[E]);return{mode:l,agent:O,agents:E,session:g,requests:P,note:v,readOnly:s,busy:S,pair:j,browse:M,dismissNote:()=>y(null),address:(0,d.useCallback)(e=>l===`pair`&&O?PB(e,O,F):e,[l,O,F])}}function ZB({pairing:e,open:t,onOpen:n}){let{requests:r,agent:i,session:a}=e,o=i??`an agent`;return(0,X.jsxs)(`aside`,{className:`pair-list`,"aria-label":`Asked while pairing`,children:[(0,X.jsxs)(`div`,{className:`pair-list-head`,children:[(0,X.jsx)(`h3`,{children:`This session`}),r.length>0&&(0,X.jsx)(`span`,{className:`faint small`,children:RB(r)})]}),r.length===0?(0,X.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,X.jsx)(`ol`,{className:`pair-requests`,children:r.map((e,r)=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`pair-request is-${e.state}${e.pin.id===t?` is-open`:``}`,onClick:()=>n(e.pin),children:[(0,X.jsx)(`span`,{className:`pair-request-n`,children:r+1}),(0,X.jsxs)(`span`,{className:`pair-request-main`,children:[(0,X.jsx)(`span`,{className:`pair-request-text`,children:BB(e)}),(0,X.jsx)(`span`,{className:`pair-request-part`,children:p(e.pin.quote,60)}),(0,X.jsx)(QB,{request:e,agent:o})]})]})},e.pin.id))})]})}function QB({request:e,agent:t}){return e.state===`done`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`pair-request-state is-done`,children:[(0,X.jsx)(Q,{name:`check`}),` Done`]}),e.reply&&(0,X.jsx)(`span`,{className:`pair-request-reply`,children:p(e.reply.body,90)})]}):e.state===`waiting`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pair-request-state is-waiting`,children:(0,X.jsx)(`span`,{className:`tag tag-waiting`,children:`Waiting on you`})}),e.reply&&(0,X.jsx)(`span`,{className:`pair-request-reply`,children:p(e.reply.body,90)})]}):(0,X.jsx)($B,{request:e,agent:t})}function $B({request:e,agent:t}){let n=HB(e.pin);return(0,X.jsxs)(`span`,{className:`pair-request-state is-working`,children:[(0,X.jsx)(fw,{state:n?.busy}),(0,X.jsx)($C,{text:n?.words??`Sent to ${t}`})]})}var eV={current:null},tV=()=>Jc(eV),nV={listening:`listening`,asleep:`asleep`,working:`working`,away:`not checking`,unseen:`not on the board now`};function rV(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 iV(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`||Hc(e.target)||e.stopPropagation()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,X.jsxs)(`div`,{className:`pair-shell nowheel nodrag nopan${b?` is-pairing`:``}${_?` ${_}`:``}`,role:`dialog`,"aria-modal":`true`,"aria-label":r,children:[(0,X.jsxs)(`header`,{className:`pair-bar`,children:[(0,X.jsx)(`span`,{className:`pair-icon`,"aria-hidden":!0,children:i}),(0,X.jsxs)(`div`,{className:`pair-title`,children:[(0,X.jsx)(`h2`,{children:a}),(0,X.jsx)(`p`,{className:`muted small`,title:s,children:o})]}),!t.readOnly&&(0,X.jsx)(aV,{pairing:t,edit:n,browse:c,pairHint:l}),p&&(0,X.jsx)(`div`,{className:`pair-controls`,children:p}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet pair-close`,onClick:g,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),b&&(0,X.jsx)(`div`,{className:`pair-band`,role:`status`,children:u}),t.note&&(0,X.jsxs)(`div`,{className:`pair-band is-note`,role:`status`,children:[(0,X.jsx)(`span`,{children:t.note}),(0,X.jsx)(`button`,{type:`button`,className:`pair-band-close`,onClick:t.dismissNote,"aria-label":`Dismiss`,children:(0,X.jsx)(Q,{name:`x`})})]}),f,(0,X.jsxs)(`div`,{className:`pair-main`,children:[(0,X.jsx)(`div`,{className:`pair-body`,children:y}),b&&(0,X.jsx)(ZB,{pairing:t,open:m,onOpen:h})]}),v]})}function aV({pairing:e,edit:t,browse:n,pairHint:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useRef)(null);Uc(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,X.jsxs)(`div`,{className:`pair-modes`,role:`group`,"aria-label":`Mode`,ref:o,children:[(0,X.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,X.jsx)(`button`,{type:`button`,className:`pair-mode${c?` is-on`:``}`,"aria-pressed":c,onClick:()=>!c&&t.start(),title:t.hint,children:`Edit`}),(0,X.jsxs)(`span`,{className:`pair-mode pair-mode-pair${s?` is-on`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`pair-mode-main`,"aria-pressed":s,disabled:e.busy,onClick:()=>p(),title:u?`${r} ${rV(f,u)}`:r,children:[u&&(0,X.jsx)(`span`,{className:`live-dot pair-dot live-${f?.state??`away`}`,"aria-hidden":!0}),u?`Pair with ${u}`:`Pair`]}),(0,X.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,X.jsx)(Q,{name:`chevron-down`})})]}),i&&(0,X.jsx)(oV,{pairing:e,onPick:e=>{a(!1),p(e)}})]})}function oV({pairing:e,onPick:t}){let{agents:n,agent:r}=e;return(0,X.jsxs)(`div`,{className:`pair-picker`,role:`menu`,"aria-label":`Pair with`,children:[n.length===0?(0,X.jsx)(`p`,{className:`pair-picker-empty`,children:`No agent has been on this board yet. Connect one, and it shows here.`}):(0,X.jsx)(`ul`,{children:n.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.name===r,className:`pair-picker-agent`,onClick:()=>t(e.name),children:[(0,X.jsx)($y,{actor:{kind:`agent`,name:e.name}}),(0,X.jsxs)(`span`,{className:`live-state live-${e.state===`unseen`?`away`:e.state}`,children:[(0,X.jsx)(`span`,{className:`live-dot`}),nV[e.state],e.state===`away`&&e.lastSeen?` · ${Yy(e.lastSeen)}`:``]}),(0,X.jsx)(`span`,{className:`pair-picker-check`,"aria-hidden":!0,children:e.name===r&&(0,X.jsx)(Q,{name:`check`})})]})},e.name))}),(0,X.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 sV=340,cV=230,lV=300,uV=3200,dV=`draft`;function fV(e,t){let n=e.querySelectorAll(`[data-pair-anchor~="${CSS.escape(t)}"]`);if(n.length===0)return null;let r=e.getBoundingClientRect();return UR([...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 pV(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=fV(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 mV(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=MR(),{seeItem:C}=S,w=(0,d.useMemo)(()=>r?be(t,r):t,[t,r]),T=XB(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)(lV),V=kB(t,n,b,!!b&&!T.readOnly),te=(0,d.useRef)(V.on);te.current=V.on;let H=(0,d.useCallback)(()=>{T.mode===`pair`&&T.browse(),k(null),L(null),V.start()},[T,V]),ne=(0,d.useCallback)(()=>{V.stop().then(e=>e&&x())},[V,x]),re=S.pins.get(t.id),ie=(0,d.useMemo)(()=>{if(r)return[];let e=(re??[]).filter(e=>e.discussion&&e.anchor.kind!==`block`);return R&&!e.some(e=>e.id===R.id)?[...e,R]:e},[re,R,r]);(0,d.useEffect)(()=>{R&&re?.some(e=>e.id===R.id)&&z(null)},[re,R]);let ae=(0,d.useMemo)(()=>ie.map(e=>({pin:e,place:To(w,e)})),[ie,w]),oe=(0,d.useMemo)(()=>ae.filter(({pin:e,place:t})=>t&&(!e.discussion?.resolved||e.id===I)),[ae,I]),se=(0,d.useMemo)(()=>ae.filter(({pin:e,place:t})=>!t&&(!e.discussion?.resolved||e.id===I)).map(({pin:e})=>e),[ae,I]);(0,d.useEffect)(()=>{E||(k(null),j(``))},[E]);let[U,W]=(0,d.useState)(null),ce=(0,d.useRef)(t.rev);(0,d.useEffect)(()=>{if(t.rev===ce.current)return;ce.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),uV);return()=>clearTimeout(e)},[U]);let le=(0,d.useCallback)(()=>{k(null),j(``)},[]),ue=(0,d.useCallback)(e=>{k(e),F(null),L(null)},[]),de=(0,d.useCallback)(e=>{L(t=>t===e?null:e),k(null),C(e)},[C]),fe=(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),fe(i))},[i,fe]);let pe=e=>{L(e.id),k(null),C(e.id),fe(e.id)};(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||tV()||(V.on?V.live&&Hc(e.target)||V.stop():O?le():I?L(null):x())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,I,x,le,V]);let me=async e=>{if(O&&A.trim()&&!M){N(!0),F(null);try{let r=e?T.address(A):A,{pin:i}=await Y.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)}}},he=ie.find(e=>e.id===I),ge=he&&oe.some(({pin:e})=>e.id===he.id)?he:void 0,_e=he&&se.includes(he)?he:void 0,ve=pV(D,O?dV:null),ye=pV(D,ge?ge.id:null),G=O&&ve.rect&&HR(ve.rect,ve.size,{width:sV,height:cV}),xe=ge&&ye.rect&&HR(ye.rect,ye.size,{width:sV,height:B}),Se=e=>t=>(0,X.jsx)(UB,{pin:e,fallback:t}),Ce=T.agent,we=T.agents.find(e=>e.name===Ce),Te=!!b&&!T.readOnly;return(0,X.jsxs)(iV,{pairing:T,edit:Te&&b?{on:V.on,hint:b.hint,start:H,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,X.jsxs)(X.Fragment,{children:[Ce?`Pairing with ${Ce}: ${m} to ask ${Ce} 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.`,Ce?` ${rV(we,Ce)}`:``]}),band:V.on?(0,X.jsx)(hV,{hand:V,it:p,back:f.label}):U&&(0,X.jsx)(`div`,{className:`pair-band is-changed`,role:`status`,children:U}),controls:V.on?void 0:_,open:I,onOpenRequest:pe,onClose:ne,children:[(0,X.jsxs)(`div`,{className:`piece-stage${E?` is-pointing`:``}${V.on?` is-editing`:``}`,ref:D,onDoubleClick:e=>{!Te||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(),H())},children:[V.on?V.editor:y({block:w,placed:r?[]:oe,pointing:E,chosen:O,open:I,pick:ue,openPin:de}),(0,X.jsxs)(`div`,{className:`piece-layer`,hidden:V.on,children:[ge&&xe&&(0,X.jsx)(DB,{pin:ge,block:w,name:n,above:xe.above,style:{left:xe.left,top:xe.top,width:sV},onClose:()=>L(null),onHeight:ee,live:Se(ge),address:T.address},ge.id),O&&G&&(0,X.jsx)(gz,{quote:Oo({anchor:O.part,quote:O.quote},w),style:{left:G.left,top:G.top,width:sV},above:G.above,text:A,busy:M,error:P,agent:T.agent,does:h,example:g,onText:e=>{j(e),F(null)},onSubmit:e=>void me(e),onClose:le},JSON.stringify(O.part))]})]}),se.length>0&&!V.on&&(0,X.jsxs)(`footer`,{className:`piece-apart`,children:[(0,X.jsxs)(`div`,{className:`piece-apart-chips`,children:[(0,X.jsx)(`span`,{className:`faint small`,children:`No longer where they were`}),se.map(e=>(0,X.jsx)(_z,{pin:e,open:e.id===I,part:Do(e,w),lost:ko(e,w),onToggle:()=>de(e.id)},e.id))]}),_e&&(0,X.jsx)(DB,{inline:!0,pin:_e,block:w,name:n,onClose:()=>L(null),live:Se(_e),address:T.address},_e.id)]})]})}function hV({hand:e,it:t,back:n}){return e.theirs?(0,X.jsxs)(`div`,{className:`pair-band is-conflict`,role:`alert`,children:[(0,X.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,X.jsxs)(`span`,{className:`pair-band-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:e.takeTheirs,children:`Take theirs`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,onClick:e.keepMine,children:`Keep yours`})]})]}):(0,X.jsxs)(`div`,{className:`pair-band is-editing${e.error?` is-error`:``}`,role:`status`,children:[(0,X.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,X.jsx)(`span`,{className:`pair-band-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small btn-quiet`,onClick:e.discard,disabled:e.saving,children:`Discard changes`})})]})}var gV=(e,t,n=`${t}s`)=>`${e.toLocaleString(`en-US`)} ${e===1?t:n}`;function _V({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=r?.part.kind===`point`?rz(e,r.part,dV,!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,X.jsxs)(`div`,{className:`chart-full-wrap`,children:[(0,X.jsx)(`div`,{className:`piece-sheet chart-full${n?` is-pointing`:``}`,children:(0,X.jsx)(oz,{block:e,marks:c,pinnable:n,full:!0,onPick:(t,n)=>{let r=iz(e,t,n);r&&a(r)},onOpen:o})}),t.length>0&&(0,X.jsx)(`div`,{className:`chart-full-chips`,children:t.map(({pin:t})=>(0,X.jsx)(_z,{pin:t,open:t.id===i,part:Do(t,e),onToggle:()=>o(t.id)},t.id))})]})}function vV(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 yV({block:e,save:t}){return(0,X.jsxs)(`div`,{className:`piece-edit has-preview chart-edit`,children:[(0,X.jsxs)(`div`,{className:`piece-edit-field`,children:[(0,X.jsxs)(`label`,{className:`piece-edit-label chart-edit-kind`,children:[`Kind`,(0,X.jsx)(`select`,{value:e.kind,onChange:e=>t({kind:e.target.value}),children:x.map(e=>(0,X.jsxs)(`option`,{value:e,children:[S[e],` chart`]},e))})]}),(0,X.jsx)(`div`,{className:`piece-edit-shown chart-edit-data`,children:(0,X.jsx)(lz,{block:e,selected:!0})})]}),(0,X.jsxs)(`div`,{className:`piece-edit-preview`,children:[(0,X.jsx)(`span`,{className:`piece-edit-label`,children:`Preview`}),(0,X.jsx)(`div`,{className:`piece-edit-shown chart-edit-plot`,children:(0,X.jsx)(oz,{block:e,marks:[],pinnable:!1,full:!0,onPick:()=>{}})})]})]})}function bV({block:e,name:t,version:n,pinId:r,onClose:i}){let a=e.columns.length-1,o=[`${S[e.kind]} chart`,`${gV(e.rows.length,`category`,`categories`)}${a>1?`, ${gV(a,`series`,`series`)}`:``}`,e.unit&&`in ${e.unit}`].filter(Boolean).join(` · `);return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`chart`,className:`chart-full-view`,label:`Chart ${e.title??``}`.trim(),icon:(0,X.jsx)(Q,{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:vV(e),does:`changes the chart's data`,example:`make it 12, say`,body:e=>(0,X.jsx)(_V,{...e}),edit:{hint:`Edit its kind and its numbers by hand (or double-click it while viewing)`,live:({block:e,save:t})=>(0,X.jsx)(yV,{block:e,save:t})},onClose:i})}function xV({block:e,viewing:t}){let n=MR();return(0,X.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 SV={type:`chart`,copyText:e=>OR(e.columns,e.rows),Body:ez,Head:({block:e,frozen:t})=>(0,X.jsx)($R,{block:e,frozen:t}),Tools:xV,overlay:{Component:bV,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Chart`,icon:`chart`,add:()=>({content:qR,title:`New chart`})},added:e=>ZR(e.id)};function CV({what:e,as:t,about:n}){return(0,X.jsx)(`div`,{className:`canvas-drop`,"aria-hidden":!0,children:(0,X.jsxs)(`div`,{className:`canvas-drop-card`,children:[(0,X.jsxs)(`p`,{className:`canvas-drop-what`,children:[`Drop to add `,e,` as `,t]}),n&&(0,X.jsx)(`p`,{className:`canvas-drop-about`,children:n})]})})}function wV(e,t){let[n,r]=(0,d.useState)(!1);return{onDragEnter:n=>r(e&&t.matches(xR(n))&&!bR(n.target)),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},clear:()=>r(!1),overlay:n&&(0,X.jsx)(CV,{what:t.what,as:t.as})}}var TV=e=>new Set(e.split(/\s+/).filter(Boolean)),EV={lineComments:[`//`],blockComment:[`/*`,`*/`],numbers:!0},DV={js:{...EV,quotes:`'"\``,keywords:TV(`
|
|
66
|
-
abstract as async await break case catch class const continue debugger declare default delete do else enum export
|
|
67
|
-
extends false finally for from function get if implements import in instanceof interface keyof let namespace new null
|
|
68
|
-
of private protected public readonly return satisfies set static super switch this throw true try type typeof
|
|
69
|
-
undefined var void while yield string number boolean unknown never any bigint symbol object`)},json:{...EV,quotes:`"`,keywords:TV(`true false null`)},css:{blockComment:[`/*`,`*/`],lineComments:[],quotes:`'"`,units:!0,numbers:!0,keywords:TV(`important inherit initial unset none auto`)},scss:{blockComment:[`/*`,`*/`],lineComments:[`//`],quotes:`'"`,units:!0,numbers:!0,keywords:TV(`important inherit initial unset none auto`)},html:{blockComment:[`<!--`,`-->`],lineComments:[],quotes:`'"`,tags:!0,keywords:TV(``)},python:{lineComments:[`#`],quotes:`'"`,numbers:!0,keywords:TV(`
|
|
70
|
-
and as assert async await break class continue def del elif else except False finally for from global if import in
|
|
71
|
-
is lambda None nonlocal not or pass raise return self True try while with yield match case`)},go:{...EV,quotes:`"'\``,keywords:TV(`
|
|
72
|
-
break case chan const continue default defer else fallthrough false for func go goto if import interface iota map nil
|
|
73
|
-
package range return select struct switch true type var string int int64 int32 uint byte rune bool error float64 any`)},rust:{...EV,quotes:`"`,charLiterals:!0,keywords:TV(`
|
|
74
|
-
as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub
|
|
75
|
-
ref return self Self static struct super trait true type unsafe use where while Some None Ok Err Option Result String
|
|
76
|
-
Vec i32 i64 u8 u32 u64 usize isize f32 f64 bool str char`)},shell:{lineComments:[`#`],hashAtWordStart:!0,quotes:`'"`,numbers:!0,keywords:TV(`
|
|
77
|
-
if then else elif fi for while until do done case esac in function return export local readonly set unset shift exit
|
|
78
|
-
source alias echo cd`)}};function OV(e){return kV(ze(e))}function kV(e){return e?.colour&&DV[e.colour]||null}var AV=/0[xX][\da-fA-F_]+n?|0[oO][0-7_]+n?|0[bB][01_]+n?|\d[\d_]*(?:\.\d+)?(?:[eE][+-]?\d+)?n?/y,jV=/#[\da-fA-F]{3,8}\b|\d*\.?\d+(?:%|[a-zA-Z]+)?/y,MV=/[A-Za-z_$][\w$]*/y,NV=/@[\w-]+/y,PV=/<\/?[A-Za-z][\w:-]*/y,FV=/'(?:\\.|[^\\'])'/y;function IV(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}var LV=(e,t)=>t===0||!/[\w$]/.test(e[t-1]);function RV(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=IV(FV,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=IV(PV,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))&&LV(e,o)){let t=IV(n===`@`?NV:jV,e,o);if(t){a(t,n===`@`?`kw`:`num`),o+=t.length;continue}}if(t.numbers&&!t.units&&/\d/.test(n)&&LV(e,o)){let t=IV(AV,e,o);a(t,`num`),o+=t.length}else if(/[A-Za-z_$]/.test(n)&&LV(e,o)){let n=IV(MV,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 zV=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function BV({tokens:e,note:t}){return(0,X.jsx)(`span`,{className:t?`diff-text is-note`:`diff-text`,children:e.map((e,t)=>e.kind?(0,X.jsx)(`span`,{className:`tok-${e.kind}`,children:e.text},t):e.text)})}function VV(e){let t=MR(),n=yB(),r=wB(),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 HV({pins:e,numbers:t,where:n}){let r=MR();return(0,X.jsx)(`div`,{className:`diff-thread nodrag nopan`,"data-pin-skip":``,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,X.jsxs)(`div`,{className:`diff-thread-card`,children:[e.map(e=>{if(!e.discussion)return null;let i=Fo(e,AR(r));if(i.length===0)return null;let[a,...o]=i,s=o.length>3?o.length-2:0;return(0,X.jsxs)(`div`,{className:`diff-comments`,children:[(0,X.jsxs)(`p`,{className:`diff-comment-head`,children:[(0,X.jsx)(`span`,{className:`diff-pin-n`,children:t.get(e.id)??`•`}),(0,X.jsx)(`b`,{children:a.author.name}),` `,(0,X.jsxs)(`span`,{className:`diff-comment-where`,children:[`· on `,n]})]}),(0,X.jsx)(`p`,{className:`diff-comment-body`,children:p(Co(a.body),600)}),s>0&&(0,X.jsx)(`p`,{className:`diff-comment-more`,children:zV(s,`more reply`)}),o.slice(s).map(e=>(0,X.jsxs)(`p`,{className:`diff-comment-reply`,children:[(0,X.jsx)(`b`,{children:e.author.name}),` · `,p(Co(e.body),300)]},e.id))]},e.id)}),(0,X.jsx)(`div`,{className:`diff-thread-chips`,children:e.map(e=>(0,X.jsx)(lB,{pin:e},e.id))})]})})}var UV=e=>e.toLocaleString(`en-US`),WV=(e,t)=>`${UV(e)} ${t}${e===1?``:`s`}`,GV={all:!1,opened:[]},KV=new Map,qV=new Set;function JV(e){return[(0,d.useSyncExternalStore)(e=>(qV.add(e),()=>qV.delete(e)),()=>KV.get(e)??GV),t=>{KV.set(e,t);for(let e of qV)e()}]}function YV(e,t){let n=(0,d.useMemo)(()=>He(e.text),[e.text]),[r,i]=JV(e.id),a=t.flatMap(({place:e})=>e?.kind===`line`?[e.line]:[]).join(`,`);return{lines:n,segments:(0,d.useMemo)(()=>tt(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 XV=e=>/^[0-9a-f]{12,}$/i.test(e)?e.slice(0,7):e;function ZV({block:e,placed:t,frozen:n}){let{lines:r,segments:i,state:a,setState:o}=YV(e,t),s=Ve(e),c=i.some(e=>e.kind===`fold`),l=[s?.name,nt(e,i,r.length),e.commit&&`at ${XV(e.commit)}`].filter(Boolean).join(` · `);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(QV,{block:e,frozen:n}),(0,X.jsx)(`span`,{className:`code-meta`,title:e.commit?`${l.replace(XV(e.commit),e.commit)}`:l,children:l}),(0,X.jsxs)(`span`,{className:`code-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:[(0,X.jsx)($V,{text:e.text}),c&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>o({all:!0,opened:[]}),title:`Show all ${WV(r.length,`line`)}`,children:`Show all`}),a.all&&r.length>60&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(GV),title:`Fold it back to the lines that matter`,children:`Fold`})]})]})}function QV({block:e,frozen:t}){let n=MR(),[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(!1),o=e.path||(0,X.jsx)(`span`,{className:`placeholder`,children:`Untitled`});if(t||n.readOnly)return(0,X.jsx)(`span`,{className:`code-path`,title:e.path,children:o});if(!r)return(0,X.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,X.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 $V({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,X.jsx)(`button`,{type:`button`,onClick:()=>void r(),title:`Copy the text`,children:t?`Copied`:`Copy`})}function eH(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 tH({block:e,placed:t}){let n=MR(),r=(0,d.useRef)(null),{lines:i,segments:a,setState:o,state:s}=YV(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)(()=>kV(Ve(e)),[e]),p=(0,d.useMemo)(()=>{let e={inComment:!1};return i.slice(0,u-c+1).map(t=>RV(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}=VV(t=>{let n=Number(t.dataset.line);return{blockId:e.id,part:{kind:`line`,file:e.path,line:n,side:`new`},quote:Ne(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,X.jsxs)(d.Fragment,{children:[(0,X.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,X.jsx)(`span`,{className:`diff-num`,children:o}),(0,X.jsx)(BV,{tokens:p[o-c]??[{text:i[o-c]}]})]}),s.length>0&&(0,X.jsx)(HV,{pins:s,numbers:h,where:eH(o,s,t)})]},o)});return(0,X.jsxs)(`div`,{className:`diff code-view`,ref:r,children:[(0,X.jsx)(fB,{block:e,placed:t}),(0,X.jsx)(`div`,{className:`diff-code nodrag${v?` is-pinnable`:``}`,...y,children:(0,X.jsxs)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${String(Math.max(l,e.total??0)).length}ch`},children:[c>1&&(0,X.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,WV(c-1,`line`),` above, not in this block`]}),a.map(e=>e.kind===`lines`?(0,X.jsx)(d.Fragment,{children:w(e.from,e.to)},`l${e.from}`):(0,X.jsxs)(`p`,{className:`code-fold`,"data-pin-skip":``,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>S(e),title:`Show lines ${UV(e.from)}–${UV(e.to)}`,children:[`⋯ `,WV(e.to-e.from+1,`line`),e.from===c?` above`:e.to===l?` below`:``]}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsx)(`button`,{type:`button`,onClick:C,children:`Show all`})]},`f${e.from}`)),e.total!==void 0&&e.total>l&&(0,X.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,WV(e.total-l,`line`),` below, not in this block`]})]})})]})}function nH(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);Uc(!i.trim()&&!o.trim(),r,u,t);let f=o.trim()?ze(o.trim()):void 0,p=i?He(i).length:0,m=[f?.name??(o.trim()&&`No colours for this kind of file`),p>0&&WV(p,`line`)].filter(Boolean).join(` · `),h=e=>{e?.preventDefault();try{Qe(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,X.jsxs)(`form`,{ref:u,className:`add-link add-code nodrag nopan nowheel`,onSubmit:h,onKeyDown:e=>e.key===`Escape`&&r(),children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{className:`field-label`,children:`Code`}),(0,X.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,X.jsxs)(`label`,{children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`File name `,(0,X.jsx)(`span`,{className:`faint`,children:`(optional, for its colours)`})]}),(0,X.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`e.g. src/core/store.ts`})]}),m&&(0,X.jsx)(`p`,{className:`add-code-about`,children:m}),c&&(0,X.jsx)(`p`,{className:`error`,children:c}),(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!i.trim(),children:`Add code`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:r,children:`Cancel`})]})]})}var rH=e=>e.startsWith(`image/`);async function iH(e){if(e.size>1048576)throw Error(`${e.name} is ${Xe(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(Ze(r))throw t;if(!r.trim())throw Error(`${e.name} is empty.`);return r}async function aH(e){let t=ze(e.name)?.name;try{return[t,WV(He(await iH(e)).length,`line`)].filter(Boolean).join(` · `)}catch(t){return t.message.replace(`${e.name} `,`It `).replace(/ Drop source code or other text\.$/,``)}}function oH(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`&&!rH(e.type)),a=[...t.dataTransfer.files].filter(e=>!rH(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=aH(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 sH({drop:e}){let t=e.name?(0,X.jsx)(`b`,{children:e.name}):e.count===1?`the file`:`${e.count} files`;return(0,X.jsx)(CV,{what:t,as:e.count===1?`a Code block`:`Code blocks`,about:e.about})}var cH=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,lH=e=>/^[0-9a-f]{12,}$/i.test(e)?e.slice(0,7):e;function uH({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=(0,d.useMemo)(()=>He(e.text),[e.text]),c=e.start??1,l=c+s.length-1,u=(0,d.useMemo)(()=>kV(Ve(e)),[e]),f=(0,d.useMemo)(()=>{let e={inComment:!1};return s.map(t=>RV(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&&IR(_.current.from,_.current.to);if(g(null),!t)return;let n=Ne(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?IR(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,X.jsx)(`div`,{className:`piece-scroll code-full-scroll`,children:(0,X.jsx)(`div`,{className:`piece-sheet code-full-sheet`,children:(0,X.jsx)(`div`,{className:`diff code-view code-full${n?` is-pointing`:``}`,children:(0,X.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,X.jsxs)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${String(Math.max(l,e.total??0)).length}ch`},children:[c>1&&(0,X.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,cH(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?[dV]:[]].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,X.jsx)(d.Fragment,{children:(0,X.jsxs)(`div`,{className:u.filter(Boolean).join(` `),"data-line":n,"data-pair-anchor":l||void 0,children:[(0,X.jsx)(`span`,{className:`diff-num`,children:n}),(0,X.jsx)(BV,{tokens:f[t]??[{text:s[t]}]}),h.length>0&&(0,X.jsx)(`span`,{className:`code-full-chips`,children:h.map(e=>(0,X.jsx)(_z,{pin:e,open:e.id===i,onToggle:()=>o(e.id)},e.id))})]})},n)}),e.total!==void 0&&e.total>l&&(0,X.jsxs)(`p`,{className:`code-edge`,children:[`⋯ `,cH(e.total-l,`line`),` below, not in this block`]})]})})})})})}function dH({block:e,name:t,version:n,pinId:r,onClose:i}){let a=Ve(e),o=He(e.text).length,s=[a?.name??`Code`,e.start&&e.start>1?Ke(e,o):cH(o,`line`),e.commit&&`at ${lH(e.commit)}`].filter(Boolean).join(` · `),c=e.path?qe(e.path,48):``;return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`code`,className:`code-full-view`,label:`Code ${e.path||`block`}`,icon:(0,X.jsx)(Q,{name:`code`}),title:e.path||`Untitled code`,from:s,fromTitle:e.commit?`${s.replace(lH(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,X.jsx)(uH,{...e}),onClose:i})}function fH(e,t,n){let r=st(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 pH(e,t,n){for(let[r,i]of e.entries())try{let e=await iH(i);await fH({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 mH({toggle:e,context:t,close:n}){return(0,X.jsx)(nH,{toggle:e,onAdd:e=>{n(),fH(e,t)},onCancel:n})}function hH(e){let{drop:t,onDragEnter:n,onDragLeave:r,clear:i}=oH(e);return{onDragEnter:n,onDragLeave:r,clear:i,overlay:t&&(0,X.jsx)(sH,{drop:t})}}function gH({block:e,viewing:t}){let n=MR();return(0,X.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 _H={type:`code`,copyText:e=>e.text,Body:({block:e,placed:t})=>(0,X.jsx)(tH,{block:e,placed:t}),Title:({block:e,placed:t,frozen:n})=>(0,X.jsx)(ZV,{block:e,placed:t,frozen:n}),ownPins:!0,Tools:gH,overlay:{Component:dH,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Code`,icon:`code`,Form:mH,toggles:!0},files:{accepts:e=>!rH(e.type),add:pH,useDrop:hH}};function vH(e){let t=MR(),[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 yH={mark:sB};function bH(e,t){return Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4}function xH(e){return e.shiftKey||e.metaKey||e.ctrlKey}function SH(e,t,n){return e?.blockId===t&&e.part.kind===n?e.part:null}function CH(e,t,n){return Math.min((e.width-n.pad*2)/t.width,(e.height-n.pad*2)/t.height,n.fitMax)}var wH=(e,t,n)=>Math.min(CH(e,t,n),n.actual);function TH(e){let t=typeof window<`u`&&window.devicePixelRatio||1;return Math.round(e*t)/t}var EH=.4;function DH(e,t,n,r,i=!1){let a=Math.min(r.maxScale,Math.max(wH(t,n,r),e.scale)),o=(e,t,n)=>{if(i&&t<=n)return(n-t)/2;let r=n*EH;return Math.min(Math.max(0,n-t)+r,Math.max(Math.min(0,n-t)-r,e))};return{...e,scale:a,x:TH(o(e.x,n.width*a,t.width)),y:TH(o(e.y,n.height*a,t.height))}}var OH=1.25,kH=80,AH=4e3,jH=4;function MH(e){try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}var NH=`Arrow keys move it, plus and minus zoom, 0 fits it.`;function PH(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?DH({scale:CH(i,e,t),x:0,y:0,fitted:!0},i,e,t,!0):DH(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(wH(r,i,a),e));s(e=>{let t=(o.x-e.x)/e.scale,s=(o.y-e.y)/e.scale;return DH({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=>DH({...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(DH({scale:CH(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(Hc(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let{stage:t}=u.current,n=e.shiftKey&&t?Math.max(kH,Math.min(t.width,t.height)*.8):kH,r={ArrowLeft:()=>h(n,0),ArrowRight:()=>h(-n,0),ArrowUp:()=>h(0,n),ArrowDown:()=>h(0,-n),"+":()=>m(u.current.view.scale*OH),"=":()=>m(u.current.view.scale*OH),"-":()=>m(u.current.view.scale/OH),_:()=>m(u.current.view.scale/OH),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),AH);return()=>clearTimeout(e)},[]);let{actual:_}=t,v=i&&e?CH(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 FH(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,MH(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)<jH)return;u.current=!0,MH(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 IH({zoom:e,labels:t}){let{active:n,percent:r,show:i}=e;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`zoom-percent`,title:`Zoom`,children:r}),(0,X.jsx)(`div`,{className:`pair-segments`,role:`radiogroup`,"aria-label":`Zoom`,children:[`fit`,`actual`,`double`].map(e=>(0,X.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 LH({zoom:e,children:t}){return(0,X.jsx)(`p`,{className:`zoom-hint${e.hint?``:` is-gone`}`,"aria-hidden":!0,children:t})}function RH(e){return e.id.match(/flowchart-(.+)-\d+$/)?.[1]}function zH(e,t){if(`nodeId`in t)return[...e.querySelectorAll(`g.node`)].filter(e=>RH(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 BH(e,t,n){let r=n.closest(`g.node`);if(r){let n=e.nodes.find(e=>e.id===RH(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:Ct(e,a)}:null}function VH(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 HH=[{id:`light`,label:`Light`,base:`light`},{id:`dark`,label:`Dark`,base:`dark`}];function UH(e){return HH.find(t=>t.id===e)}function WH(e){return UH(e?`dark`:`light`)}var GH=`tricot:theme`,KH=window.matchMedia(`(prefers-color-scheme: dark)`),qH=new Set;function JH(){return WH(KH.matches)}var YH=(()=>{try{return UH(localStorage.getItem(GH))??null}catch{return null}})(),XH=YH??JH();function ZH(e){XH=e,document.documentElement.dataset.theme=e.id;for(let e of qH)e()}ZH(XH),KH.addEventListener(`change`,()=>{YH||ZH(JH())});function QH(e){YH=e===JH()?null:e;try{YH?localStorage.setItem(GH,YH.id):localStorage.removeItem(GH)}catch{}ZH(e)}function $H(){return(0,d.useSyncExternalStore)(e=>(qH.add(e),()=>qH.delete(e)),()=>XH)}var eU={FORBID_TAGS:[`style`,`img`,`image`,`picture`,`source`,`video`,`audio`,`track`,`input`]},tU=[`secure`,`securityLevel`,`startOnLoad`,`maxTextSize`,`suppressErrorRendering`,`maxEdges`,`dompurifyConfig`];function nU(e,t){return{startOnLoad:!1,securityLevel:`strict`,secure:tU,dompurifyConfig:eU,theme:e===`dark`?`dark`:`neutral`,fontFamily:t}}var rU=`modulepreload`,iU=function(e){return`/`+e},aU={},oU=function(e){return e.pathname.endsWith(`.css`)},sU=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},cU=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=iU(t,n);let r=s(t),i=oU(r);return sU(aU,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`:rU,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)})},lU=null,uU=null,dU=Promise.resolve(),fU=0;function pU(){return lU??=cU(async()=>{let{default:e}=await import(`./mermaid.core-CsGeJ437.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),lU}function mU(e,t){let n=dU.then(async()=>{let n=await pU();if(uU!==t){let e=getComputedStyle(document.documentElement).getPropertyValue(`--font`).trim();n.initialize(nU(t,e)),uU=t}await n.parse(e);let{svg:r}=await n.render(`mermaid-${++fU}`,e);return r});return dU=n.catch(()=>{}),n}function hU({source:e,onRender:t}){let[n,r]=(0,d.useState)(),[i,a]=(0,d.useState)(),o=$H().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 mU(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(`
|
|
79
|
-
`).slice(0,4).join(`
|
|
80
|
-
`))}),()=>{t=!0}},[e,o]),i?(0,X.jsx)(`pre`,{className:`mermaid-error`,children:i}):n?(0,X.jsx)(`div`,{ref:s,className:`mermaid`,dangerouslySetInnerHTML:{__html:n}}):(0,X.jsx)(`p`,{className:`placeholder`,children:`Rendering diagram…`})}var gU={actual:1,fitMax:1.8,maxScale:8,pad:28},_U={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 vU({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o,sizing:s}){let{zoom:c,setNatural:l}=s,u=FH(c),f=(0,d.useMemo)(()=>xt(e.source),[e.source]),[p,m]=(0,d.useState)(null);VH(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(zH(p,n),`linked`,e.id,e.id===i);let o=r?.blockId===e.id?r.part:null;if(o?.kind===`node`&&a(zH(p,o),`draft`,dV),o?.kind===`arrow`){let e=f.arrows.find(e=>e.from===o.from&&e.to===o.to&&e.n===(o.n??0));e&&a(zH(p,{arrowId:e.id}),`draft`,dV)}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=BH(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,X.jsxs)(`div`,{className:`diagram-full-wrap`,children:[(0,X.jsxs)(`div`,{ref:c.stageRef,className:`zoom-stage diagram-full-stage${_}`,tabIndex:0,"aria-label":`${v} at ${c.percent}. ${NH}`,...u.handlers,children:[(0,X.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,X.jsx)(hU,{source:e.source,onRender:h})}),c.sheet&&(0,X.jsx)(LH,{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,X.jsx)(`div`,{className:`diagram-full-chips`,children:t.map(({pin:t})=>(0,X.jsx)(_z,{pin:t,open:t.id===i,part:Do(t,e),onToggle:()=>o(t.id)},t.id))})]})}function yU({block:e,name:t,version:n,pinId:r,onClose:i}){let a=xt(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=PH(c,gU),p={zoom:f,setNatural:u};return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`diagram`,className:`diagram-full-view`,label:`Diagram ${e.title??``}`.trim(),icon:(0,X.jsx)(Q,{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,X.jsx)(IH,{zoom:f,labels:_U}):void 0,body:e=>(0,X.jsx)(vU,{...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,X.jsx)(hU,{source:e}):(0,X.jsx)(`p`,{className:`placeholder`,children:`Nothing to draw yet.`})},onClose:i})}function bU({block:e,placed:t}){let n=MR(),r=vH(e.id),i=(0,d.useMemo)(()=>xt(e.source),[e.source]),[a,o]=(0,d.useState)(null),s=yB(),c=(0,d.useRef)({x:0,y:0}),l=!!i&&!n.readOnly,u=n.draft?.blockId===e.id?n.draft.part:null;return VH(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(zH(a,e),`linked`);if(u?.kind===`node`&&n(zH(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(zH(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,X.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,X.jsx)(`div`,{className:`block-diagram${l?` is-pinnable`:``}`,onMouseDown:e=>c.current={x:e.clientX,y:e.clientY},onClick:t=>{if(!l||!i||xH(t))return;let r=BH(i,e.id,t.target);r&&(t.stopPropagation(),t.detail!==1||bH(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,X.jsx)(hU,{source:e.source,onRender:o})})}function xU({block:e,viewing:t}){let n=MR();return(0,X.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 SU={type:`diagram`,copyText:e=>e.source,Body:bU,Tools:xU,overlay:{Component:yU,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Diagram`,icon:`diagram`,add:()=>({content:{type:`diagram`,source:`flowchart LR
|
|
81
|
-
A[Start] --> B[Next]`}})},added:(e,t)=>t.edit(e.id)},CU=400,wU=`tricot:diff-view`,TU=new Set,EU=(()=>{try{return localStorage.getItem(wU)===`split`?`split`:`unified`}catch{return`unified`}})();function DU(){return[(0,d.useSyncExternalStore)(e=>(TU.add(e),()=>TU.delete(e)),()=>EU),e=>{EU=e;try{localStorage.setItem(wU,e)}catch{}for(let e of TU)e()}]}var OU=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function kU({block:e}){let[t,n]=DU(),r=(0,d.useMemo)(()=>Ce(e.files),[e.files]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`diff-stat`,title:`${we(r.additions,r.deletions)} in ${OU(r.files,`file`)}`,children:[(0,X.jsxs)(`span`,{className:`diff-plus`,children:[`+`,r.additions.toLocaleString(`en-US`)]}),` `,(0,X.jsxs)(`span`,{className:`diff-minus`,children:[`−`,r.deletions.toLocaleString(`en-US`)]}),(0,X.jsxs)(`span`,{className:`diff-stat-files`,children:[` · `,OU(r.files,`file`)]})]}),(0,X.jsx)(`span`,{className:`diff-switch nodrag`,role:`radiogroup`,"aria-label":`Show the diff`,onDoubleClick:e=>e.stopPropagation(),children:[`unified`,`split`].map(e=>(0,X.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 AU=(e,t,n)=>`${e}\n${t}\n${n}`;function jU({block:e,placed:t}){let n=(0,d.useMemo)(()=>e.files.map(e=>e.path).join(`
|
|
82
|
-
`),[e.files]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fB,{block:e,placed:t}),(0,X.jsx)(MU,{block:e,placed:t},n)]})}function MU({block:e,placed:t}){let n=MR(),[r]=DU(),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([...Oe(e.files,e.focus),...o])),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(()=>new Set),m=(0,d.useMemo)(()=>ke(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=AU(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 je(r))for(let r of[AU(n.path,`old`,i.old),AU(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:Ae(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,X.jsxs)(`div`,{className:`diff is-${r}`,ref:i,children:[x>0&&(0,X.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,X.jsx)(FU,{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,X.jsxs)(`button`,{type:`button`,className:`diff-more nodrag`,onClick:()=>u(!0),children:[OU(e.files.length-y.length,`more file`),` · Show all`]})]})}function NU({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,X.jsx)(`span`,{className:`diff-bar`,"aria-hidden":!0,children:Array.from({length:5},(e,t)=>(0,X.jsx)(`i`,{className:t<i?`is-add`:t<r?`is-del`:void 0},t))})}var PU={added:`new`,deleted:`deleted`,renamed:`renamed`,binary:`binary`,modified:null};function FU(e){let{file:t,open:n,onToggle:r,biggest:i}=e,a=Ee(t.path),o=[PU[t.status],a&&`generated`,t.omitted&&`too big to show`].filter(Boolean),s=t.oldPath?`${t.oldPath} → ${t.path}`:t.path;return(0,X.jsxs)(`section`,{className:`diff-file${n?` is-open`:``}`,children:[(0,X.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,X.jsx)(`span`,{className:`diff-chevron`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(`span`,{className:`diff-path`,children:s}),o.map(e=>(0,X.jsx)(`span`,{className:`diff-tag is-${e.split(` `)[0]}`,children:e},e)),(0,X.jsx)(`span`,{className:`diff-file-count`,children:t.status===`binary`?``:(0,X.jsxs)(X.Fragment,{children:[t.additions>0&&(0,X.jsxs)(`span`,{className:`diff-plus`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),t.deletions>0&&(0,X.jsxs)(`span`,{className:`diff-minus`,children:[` −`,t.deletions.toLocaleString(`en-US`)]})]})}),(0,X.jsx)(NU,{file:t,biggest:i})]}),n&&(0,X.jsx)(LU,{...e})]})}function IU(e){return e.omitted?`Its changes were left out to keep this diff under ${Math.round(Se/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 LU(e){let{block:t,file:n,view:r,whole:i,onWhole:a,bySpot:o,numbers:s}=e,c=MR(),{pinnable:l,handlers:u}=VV(e=>{let r=e.dataset.side,i=Number(e.dataset.line),a=Pe(n,r,i)??``;return{blockId:t.id,part:{kind:`line`,file:n.path,line:i,side:r},quote:Ne(a)}}),f=De(n),p=(0,d.useMemo)(()=>{let e=OV(n.path),t=i?1/0:CU,r=[];for(let i of n.hunks){if(t<=0)break;let n={inComment:!1},a=je(i).slice(0,t).map(t=>({row:t,tokens:t.kind===`note`?[{text:t.text}]:RV(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:Me(a.map(e=>e.row)),tokensOfRow:o})}return r},[n,i]);if(n.hunks.length===0)return(0,X.jsx)(`p`,{className:`diff-empty`,children:IU(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(AU(n.path,e,t))??[],v=(e,t,n)=>e.length>0&&(0,X.jsx)(HV,{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,X.jsxs)(`div`,{className:`diff-code nodrag${l?` is-pinnable`:``}`,...u,children:[(0,X.jsx)(`div`,{className:`diff-rows`,style:{"--diff-digits":`${m}ch`},children:p.map(({hunk:e,rows:t,pairs:n,tokensOfRow:i},a)=>(0,X.jsxs)(d.Fragment,{children:[(0,X.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,X.jsxs)(d.Fragment,{children:[(0,X.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,X.jsx)(`span`,{className:`diff-num`,children:e.old}),(0,X.jsx)(`span`,{className:`diff-num`,children:e.new}),(0,X.jsx)(`span`,{className:`diff-mark`,children:RU[e.kind]}),(0,X.jsx)(BV,{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,X.jsxs)(d.Fragment,{children:[(0,X.jsxs)(`div`,{className:l.filter(Boolean).join(` `),"data-pin-ids":s.length?s.map(e=>e.id).join(` `):void 0,children:[(0,X.jsx)(zU,{row:e,side:`old`,tokens:r(e),draft:g(`old`,e?.old)}),(0,X.jsx)(zU,{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,X.jsxs)(`button`,{type:`button`,className:`diff-more`,onClick:a,children:[`Show all `,f.toLocaleString(`en-US`),` lines`]})]})}var RU={add:`+`,del:`−`,context:``,note:``};function zU({row:e,side:t,tokens:n,draft:r}){if(!e)return(0,X.jsx)(`span`,{className:`diff-half is-blank`});let i=e.kind===`note`?void 0:e[t];return(0,X.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,X.jsx)(`span`,{className:`diff-num`,children:i}),(0,X.jsx)(`span`,{className:`diff-mark`,children:RU[e.kind]}),(0,X.jsx)(BV,{tokens:n,note:e.kind===`note`})]})}var BU={type:`diff`,copyText:e=>e.patch,Body:({block:e,placed:t})=>(0,X.jsx)(jU,{block:e,placed:t}),Head:({block:e})=>(0,X.jsx)(kU,{block:e}),ownPins:!0};function VU(e,t){return Math.max(0,...e.flatMap(e=>e.blockId===t&&e.anchor.kind===`box`?[e.anchor.n]:[]))+1}var HU={id:`figma`,marks:{figma:{tile:`#1e1e1e`,dark:!0,glyph:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:`M16 7h-3a3 3 0 0 0 0 6h3Z`,fill:`#f24e1e`}),(0,X.jsx)(`path`,{d:`M16 7h3a3 3 0 0 1 0 6h-3Z`,fill:`#ff7262`}),(0,X.jsx)(`path`,{d:`M16 13h-3a3 3 0 0 0 0 6h3Z`,fill:`#a259ff`}),(0,X.jsx)(`circle`,{cx:`19`,cy:`16`,r:`3`,fill:`#1abcfe`}),(0,X.jsx)(`path`,{d:`M13 19h3v3a3 3 0 1 1-3-3Z`,fill:`#0acf83`})]})}}},UU=`tricot:connectors`,WU=new Set,GU=!1;function KU(e){return!!(e&&typeof e==`object`&&e.type===`tricot:connector`)}function qU(e){if(!GU){GU=!0;let e=e=>{if(KU(e)){XU.clear(),eW();for(let t of WU)t(e)}};try{new BroadcastChannel(UU).onmessage=t=>e(t.data)}catch{}window.addEventListener(`message`,t=>t.origin===location.origin&&e(t.data))}return WU.add(e),()=>WU.delete(e)}var JU=12e4,YU=6e4,XU=new Map,ZU=new Set,QU=new Set;function $U(){XU.clear(),eW()}function eW(){for(let e of QU)e()}function tW(e,t){let n=XU.get(e);ZU.has(e)||n&&Date.now()-n.at<(n.file?JU:YU)||(ZU.add(e),t().then(t=>XU.set(e,{at:Date.now(),file:t}),()=>XU.set(e,{at:Date.now(),file:n?.file??null})).finally(()=>{ZU.delete(e),eW()}))}function nW(e){QU.add(e);let t=qU(()=>{});return()=>{QU.delete(e),t()}}function rW(e){let t=e?.fileId,n=e?.connector?KK(e.connector)?.fileInfo:void 0,r=t&&n&&e?.connector?`${e.connector}:${t}`:void 0,i=(0,d.useSyncExternalStore)(nW,()=>r?XU.get(r)?.file??null:null);return(0,d.useEffect)(()=>{if(!r||!t||!n)return;let e=()=>tW(r,()=>n(t));return e(),window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[r,t,i]),i}function iW(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;if(Date.now()-t.getTime()<6048e5)return`edited ${Yy(e)}`;let n=t.getFullYear()===new Date().getFullYear();return`edited ${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:n?void 0:`numeric`})}`}var aW=2e4,oW=new Map,sW=new Set;function cW(){oW.clear(),$U();for(let e of sW)e()}var lW={card(e){let t=oW.get(e);if(t&&Date.now()-t.at<aW)return t.answer;let n=bs(zt.file)({fileId:e});return oW.set(e,{at:Date.now(),answer:n}),n.catch(()=>oW.delete(e)),n},connect:e=>J(zt.token)({token:e}),bringIn:(e,t)=>J(zt.bringIn)({actor:t,blockId:e}),refresh:(e,t)=>J(zt.refresh)({actor:t},{blockId:e})};function uW(e){let[t,n]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!e)return;let t=!0,r=()=>{lW.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(),sW.add(r),window.addEventListener(`focus`,r),()=>{t=!1,sW.delete(r),window.removeEventListener(`focus`,r)}},[e]),t&&t.fileId===e?t.answer:null}function dW(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 fW({block:e,source:t}){let n=MR(),r=uW(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,X.jsxs)(`div`,{className:`figma-card nodrag`,children:[(0,X.jsx)(`div`,{className:`figma-card-preview`,children:o?.thumbnail?(0,X.jsx)(`img`,{src:Rt(q.asset,{id:o.thumbnail}),alt:`Preview of ${o.name}`,draggable:!1}):r?(0,X.jsx)(`p`,{className:`faint small`,children:dW(r.problem?.code,s,r.problem?.message)}):(0,X.jsx)(`p`,{className:`faint small`,children:`Loading the preview…`})}),(0,X.jsxs)(`div`,{className:`figma-card-actions`,children:[o&&s&&(0,X.jsxs)(`span`,{className:`faint small figma-card-file`,children:[`In `,o.fileName]}),c&&(0,X.jsx)(`a`,{className:`btn btn-small btn-primary`,href:db.connectors(n.board.id),children:`Connect Figma`}),o&&s&&!n.readOnly&&(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:i,onClick:()=>n.perform(async t=>{a(!0);try{await lW.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 pW({block:e,viewing:t}){let n=MR(),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1);return n.readOnly?null:(0,X.jsx)(`button`,{onClick:()=>n.perform(async t=>{i(!0),o(!1);try{let{changed:n}=await lW.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 mW({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 lW.connect(n);r(``),t(e),cW()}catch(e){s(e.message)}finally{a(!1)}};return(0,X.jsxs)(`section`,{className:`connector-section`,children:[(0,X.jsx)(`h3`,{children:e.state===`needs_sign_in`?`Paste a new Figma token`:`Paste your Figma token`}),(0,X.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,X.jsxs)(`form`,{className:`figma-token`,onSubmit:e=>void c(e),children:[(0,X.jsx)(`input`,{type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`figd_…`,"aria-label":`Figma token`,value:n,onChange:e=>r(e.target.value)}),(0,X.jsx)(`button`,{className:`btn btn-primary`,disabled:i||!n.trim(),children:i?`Checking…`:`Connect Figma`})]}),(0,X.jsx)(`p`,{className:`faint small`,children:`The token stays on this computer and is sent only to Figma.`}),o&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:o})]})}function hW(){let{tile:e,glyph:t}=HU.marks.figma;return(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var gW={id:`figma`,Mark:hW,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:mW,fileInfo:async e=>{let{file:t}=await lW.card(e);return t&&{name:t.name,modifiedTime:t.modifiedTime}},LinkCard:fW,ImageTools:pW},_W={stroke:`#fff`,strokeWidth:1.75,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`},vW=`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`,yW={id:`github`,marks:{github:{tile:`#1f2328`,dark:!0,glyph:(0,X.jsxs)(`g`,{..._W,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`10`,r:`2`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`22`,r:`2`}),(0,X.jsx)(`circle`,{cx:`21`,cy:`14`,r:`2`}),(0,X.jsx)(`path`,{d:`M12 12v8M21 16c0 3-4 3-9 4`})]})},"github-pull":{tile:`#1f2328`,dark:!0,glyph:(0,X.jsxs)(`g`,{..._W,children:[(0,X.jsx)(`circle`,{cx:`11`,cy:`10`,r:`2`}),(0,X.jsx)(`circle`,{cx:`11`,cy:`22`,r:`2`}),(0,X.jsx)(`circle`,{cx:`21`,cy:`22`,r:`2`}),(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`circle`,{cx:`16`,cy:`16`,r:`6.5`,..._W}),(0,X.jsx)(`circle`,{cx:`16`,cy:`16`,r:`1.6`,fill:`#fff`})]})},"github-repo":{tile:`#1f2328`,dark:!0,glyph:(0,X.jsx)(`path`,{d:vW,..._W})}}},bW={open:`Open`,closed:`Closed`,merged:`Merged`,draft:`Draft`};function xW(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 SW={device:()=>bs($t.device)(),startDevice:()=>J($t.startDevice)({}),pollDevice:()=>J($t.pollDevice)({}),cancelDevice:()=>J($t.cancelDevice)({}),useToken:e=>J($t.token)({token:e}),repos:(e=!1)=>bs($t.repos)(void 0,e?{fresh:`1`}:void 0),card:(e,t=!1)=>{let[n,r,i,a]=e.split(`/`);return bs($t.card)({owner:n,repo:r,kind:i,number:a},t?{fresh:`1`}:void 0)},showChanges:(e,t)=>J($t.showChanges)({actor:t},{blockId:e}),bringInFile:(e,t)=>J($t.bringInFile)({actor:t},{blockId:e})},CW=6e4,wW=new Map,TW=new Map,EW=new Set,DW=()=>EW.forEach(e=>e());function OW(e,t=!1){let n=wW.get(e),r=TW.get(e);if(r)return r;if(!t&&n&&Date.now()-n.at<CW)return Promise.resolve(n.answer);let i=SW.card(e,t).then(t=>(wW.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return TW.set(e,i),DW(),i.finally(()=>{TW.delete(e),DW()}),i}function kW(){wW.clear(),DW()}var AW=e=>(EW.add(e),()=>void EW.delete(e));function jW(e){let t=(0,d.useSyncExternalStore)(AW,()=>e?wW.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(AW,()=>e?TW.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;OW(e);let t=()=>void OW(e);return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[e]);let r=(0,d.useCallback)(()=>e?OW(e,!0):Promise.resolve(null),[e]);return{card:t?.card,problem:t?.problem,busy:n,refresh:r}}function MW({block:e}){let t=(0,d.useMemo)(()=>ln(e.url),[e.url]);return t?t.kind===`file`?(0,X.jsx)(zW,{block:e,target:t}):(0,X.jsx)(RW,{block:e,target:t}):null}function NW({passing:e,failing:t,pending:n}){return e+t+n===0?`No checks`:t?`${t} failing`:n?`${n} pending`:`${e} passing`}function PW({checks:e}){let t=e.passing+e.failing+e.pending,n=e.failing?`failing`:e.pending?`pending`:t?`passing`:`none`;return(0,X.jsxs)(`span`,{className:`gh-checks is-${n}`,title:`Checks on the latest commit: ${xW(e)}`,children:[(0,X.jsx)(`span`,{className:`gh-dot`,"aria-hidden":!0}),NW(e)]})}function FW({card:e}){return(0,X.jsx)(`span`,{className:`gh-state is-${e.state}`,children:bW[e.state]})}function IW(e){let t=MR(),[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 LW={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 RW({block:e,target:t}){let{card:n,problem:r,busy:i,refresh:a}=jW(un(t)),o=IW(t=>SW.showChanges(e.id,t));if(!n&&!r)return i?(0,X.jsx)(`p`,{className:`gh-details faint`,children:`Looking it up on GitHub…`}):null;if(r){if(r.code===`not_connected`)return null;let e=LW[r.code]??r.message;return(0,X.jsxs)(`p`,{className:`gh-details gh-problem is-${r.code}`,role:`status`,children:[(0,X.jsx)(`span`,{className:`gh-problem-text`,title:r.message,children:e}),r.code===`not_installed`&&r.installUrl&&(0,X.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,X.jsx)(Q,{name:`external`})]}),r.code===`needs_sign_in`&&(0,X.jsx)(`a`,{className:`btn btn-small nodrag`,href:db.connectors(),children:`Sign in again`})]})}return n?(0,X.jsxs)(`div`,{className:`gh-details nodrag`,children:[(0,X.jsx)(FW,{card:n}),(0,X.jsx)(`span`,{className:`gh-by`,title:`${n.repo} #${n.number}, by ${n.author}`,children:n.author}),n.checks&&(0,X.jsx)(PW,{checks:n.checks}),(0,X.jsx)(`span`,{className:`gh-spacer`}),n.kind===`pull`&&o.canAdd&&(0,X.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,X.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,X.jsx)(Q,{name:`sync`})})]}):null}function zW({block:e,target:t}){let n=IW(t=>SW.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,X.jsxs)(`div`,{className:`gh-details nodrag`,children:[(0,X.jsx)(`span`,{className:`gh-by`,children:r?`Highlights ${r}`:`A file on GitHub`}),(0,X.jsx)(`span`,{className:`gh-spacer`}),(0,X.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 BW=30;function VW(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),SW.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,X.jsxs)(`section`,{className:`connector-section`,children:[(0,X.jsx)(`h3`,{children:c?`Repositories Tricot is installed on`:`Repositories this token covers`}),r&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:r}),t&&t.repos.length===0&&!r&&(0,X.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,X.jsxs)(`ul`,{className:`gh-repos`,children:[t.repos.slice(0,BW).map(e=>(0,X.jsxs)(`li`,{title:e.private?`Private`:`Public`,children:[e.fullName,e.private&&(0,X.jsx)(`span`,{className:`gh-private`,children:` · private`})]},e.fullName)),t.repos.length>BW&&(0,X.jsxs)(`li`,{className:`faint`,children:[`and `,t.repos.length-BW,` more`]}),t.truncated&&(0,X.jsx)(`li`,{className:`faint`,children:`and more not listed`})]}),(0,X.jsxs)(`div`,{className:`row`,children:[c&&(t?.installUrl?(0,X.jsxs)(`a`,{className:`btn btn-small`,href:t.installUrl,target:`_blank`,rel:`noreferrer`,children:[`Install on your repos`,(0,X.jsx)(Q,{name:`external`})]}):(0,X.jsxs)(`a`,{className:`btn btn-small`,href:t?.manageUrl??`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:[`Manage installations on GitHub`,(0,X.jsx)(Q,{name:`external`})]})),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:a,onClick:()=>s(!0),children:`Refresh the list`})]})]})}var HW=`https://github.com/settings/personal-access-tokens/new`;function UW({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)(()=>{SW.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 SW.pollDevice();if(e)return;if(t.state===`pending`)return a(t.interval);n(null),t.state===`connected`?(kW(),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 SW.startDevice()).device)}catch(e){i(e.message)}finally{o(!1)}},f=()=>{n(null),SW.cancelDevice().catch(()=>{})},p=async()=>{o(!0),i(null);try{let{connector:t}=await SW.useToken(s);c(``),kW(),e(t)}catch(e){i(e.message)}finally{o(!1)}};return(0,X.jsxs)(`section`,{className:`connector-section gh-signin`,children:[t?(0,X.jsxs)(`div`,{className:`gh-code`,role:`status`,children:[(0,X.jsx)(`p`,{className:`muted small`,children:`Type this code on GitHub to let Tricot in:`}),(0,X.jsx)(`p`,{className:`gh-code-digits`,"aria-label":`Your code is ${t.userCode.split(``).join(` `)}`,children:t.userCode}),(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsxs)(`a`,{className:`btn btn-primary btn-small`,href:t.verificationUri,target:`_blank`,rel:`noreferrer`,children:[`Open `,t.verificationUri.replace(/^https?:\/\//,``),(0,X.jsx)(Q,{name:`external`})]}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:f,children:`Cancel`})]}),(0,X.jsxs)(`span`,{className:`connector-waiting`,children:[(0,X.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Waiting for you to allow it on GitHub…`]})]}):(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsx)(`button`,{className:`btn btn-primary`,disabled:a,onClick:()=>void u(),children:`Connect GitHub`}),(0,X.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,X.jsxs)(`details`,{className:`gh-token`,children:[(0,X.jsx)(`summary`,{children:`Use a personal token instead`}),(0,X.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,X.jsx)(`a`,{href:HW,target:`_blank`,rel:`noreferrer`,children:`Make a token`})]}),(0,X.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,X.jsx)(`div`,{className:`row`,children:(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:a||!s.trim(),onClick:()=>void p(),children:`Use this token`})})]}),r&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}function WW(){let{tile:e,glyph:t}=yW.marks.github;return(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var GW={id:`github`,Mark:WW,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:UW,Panel:VW,LinkCard:MW,fileInfo:async e=>{let t=await OW(e);return t?.card?{name:t.card.title,modifiedTime:t.card.updatedAt}:null}},KW={driveFile:e=>bs(hn.file)({fileId:e}),pickerConfig:()=>J(hn.picker)({}),chosen:e=>J(hn.chosen)({fileIds:e}),googleDoc:(e,t)=>bs(hn.doc)({blockId:e},{actor:t}),editDocDraft:(e,t,n,r)=>J(hn.docDraft)({actor:t,revision:n,changes:r},{blockId:e}),discardDocDraft:(e,t)=>J(hn.docDiscard)({actor:t},{blockId:e}),saveDocDraft:(e,t)=>J(hn.docSave)({actor:t},{blockId:e}),resolveDocConflict:(e,t,n,r)=>J(hn.docResolve)({actor:t,conflict:n,keep:r},{blockId:e}),pinDocWords:(e,t,n)=>J(hn.docPins)({actor:t,...n},{blockId:e})},qW=`https://apis.google.com/js/api.js`,JW=`application/vnd.google-apps.document`,YW;function XW(){return YW??=new Promise((e,t)=>{let n=window,r=()=>{YW=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=qW,a.async=!0,a.onload=i,a.onerror=r,document.head.append(a)}),YW}var ZW=()=>({loadApi:XW,origin:`${location.protocol}//${location.host}`});async function QW(e,t={},n=ZW()){let r=await n.loadApi(),i=new r.DocsView(r.ViewId.DOCUMENTS).setMimeTypes(JW).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 $W(e={}){let t=await QW(await KW.pickerConfig(),e);return t.length&&(await KW.chosen(t.map(e=>e.id)),$U()),t}function eG({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 $W({multiple:!0});e.length&&i(e)}catch(e){o(e.message)}finally{n(!1)}};return(0,X.jsxs)(`section`,{className:`connector-section`,children:[(0,X.jsx)(`h3`,{children:`Google Docs Tricot may use`}),(0,X.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,X.jsx)(`div`,{className:`row`,children:(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:t,onClick:()=>void s(),children:t?`Choosing…`:`Choose Google Docs`})}),r.length>0&&(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:a})]})}var tG={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 nG(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 rG(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 iG(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 aG={id:`loom`,marks:{loom:{tile:`#625df5`,glyph:(0,X.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`,..._W,strokeWidth:2.25})}}},oG={id:`youtube`,marks:{youtube:{tile:`#ff0000`,glyph:(0,X.jsx)(`path`,{d:`M13 10.75v10.5L22 16Z`,fill:`#fff`,stroke:`#fff`,strokeWidth:1,strokeLinejoin:`round`})}}},sG=()=>[HU,oG,aG,yW],cG,lG={tile:`#5d5866`,glyph:null};function uG(e){return cG??=Object.assign({},...GK().map(e=>e.marks??{}),...sG().map(e=>e.marks)),cG[e]??lG}function dG({mark:e}){let{tile:t,dark:n,glyph:r}=e;return(0,X.jsx)(`span`,{className:n?`source-mark is-dark`:`source-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:t}),r]})})}function fG({mark:e}){return(0,X.jsx)(dG,{mark:uG(e)})}var pG=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,mG=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function hG(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,X.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,X.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,X.jsxs)(`p`,{className:`pin-prompt-quote`,children:[`“`,t.quote,`”`]}),(0,X.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:u,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(DT,{skills:!0,lenses:Hw,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,X.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,X.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:p||a,onClick:()=>l(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:p||a,onClick:()=>l(!1),children:`Comment`}),(0,X.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${pG}+Enter asks ${s??`an agent`}`,children:pG===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,X.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 gG(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=MR(),s=Fo(t,AR(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,X.jsxs)(`span`,{className:f.filter(Boolean).join(` `),"data-doc-chip":t.id,children:[(0,X.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} “${t.quote}”: ${mG(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,X.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,X.jsx)(Q,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,X.jsx)(Q,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,X.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,X.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await pz(`these words`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin “${t.quote}”`,title:`Unpin. Its thread goes with it.`,children:(0,X.jsx)(Q,{name:`x`})})]})}function _G({block:e}){let t=MR(),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=>Fo(e,AR(t)).some(e=>e.ask)).length,a=[i&&`${mG(i,`request`)} to agents`,n.length-i&&mG(n.length-i,`comment thread`)].filter(Boolean).join(` and `);return(0,X.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,X.jsx)(Q,{name:i?`edit`:`comment`}),n.length,r.length>0&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]})}var vG=`tricot:docs-save-noted`,yG=700,bG=240;function xG(){try{return localStorage.getItem(vG)===`1`}catch{return!1}}function SG(e,t){return`${e} ${t}${e===1?``:`s`}`}function CG(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,X.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 wG({actor:e,me:t}){return e.kind!==`human`||e.name.trim().toLowerCase()!==t.trim().toLowerCase()?(0,X.jsx)($y,{actor:e}):(0,X.jsxs)(`span`,{className:`actor actor-human`,title:`${e.name} (you)`,children:[(0,X.jsx)($y,{actor:e,showName:!1,title:`${e.name} (you)`}),(0,X.jsx)(`span`,{className:`actor-name`,children:`You`})]})}function TG({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)(xG),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=MR(),{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),[H,ne]=(0,d.useState)(n??null),[re,ie]=(0,d.useState)(null),ae=(0,d.useRef)(null),oe=(0,d.useRef)(null),se=XB(e,t,`doc`),U=se.mode===`pair`?se.agent:null,W=rW((0,d.useMemo)(()=>sr(e.url),[e.url])),ce=e.title||i?.doc.title||W?.name||`Google Doc`,le=u&&u.from===e.docDraft?u.draft:e.docDraft,ue=(0,d.useCallback)(async()=>{try{let n=await KW.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)(()=>{ue()},[ue]);let de=e.docDraft?.revision;(0,d.useEffect)(()=>{i&&de&&de!==i.doc.revision&&ue()},[de,i,ue]),(0,d.useEffect)(()=>{if(!c)return;let e=qU(e=>{e.id===`google`&&(e.ok?ue().then(e=>e&&l(null)):(l(null),v(e.message??`The sign-in failed.`)))}),t=setInterval(()=>void ue().then(e=>e&&l(null)),2500);return()=>{e(),clearInterval(t)}},[c,ue]),(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||tV()||(P?F(null):H?ne(null):C||r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,C,P,H]),(0,d.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>v(null),6e3);return()=>clearTimeout(e)},[_]);let fe=(0,d.useMemo)(()=>i?nG(i.doc.paragraphs,le):[],[i,le]),pe=(0,d.useMemo)(()=>iG(fe),[fe]),me=M.pins.get(e.id),he=(0,d.useMemo)(()=>{let e=(me??[]).filter(e=>e.anchor.kind===`doc`&&e.discussion);return re&&!e.some(e=>e.id===re.id)?[...e,re]:e},[me,re]);(0,d.useEffect)(()=>{re&&me?.some(e=>e.id===re.id)&&ie(null)},[me,re]);let{byRow:ge,gone:_e}=(0,d.useMemo)(()=>{let e=new Map,t=[];if(!i)return{byRow:e,gone:t};let n=new Set(fe.map(e=>e.id));for(let r of he){let a=r.anchor;a.gone||a.revision===i.doc.revision&&!n.has(a.paragraph)?r.discussion?.resolved&&r.id!==H||t.push(r):a.revision===i.doc.revision&&e.set(a.paragraph,[...e.get(a.paragraph)??[],r])}return{byRow:e,gone:t}},[he,fe,i,H]),ve=e=>{ne(t=>t===e?null:e),N(e)},ye=e=>{ne(e.id),N(e.id),requestAnimationFrame(()=>{let t=ae.current?.querySelector(`[data-doc-chip="${CSS.escape(e.id)}"]`);(t?.closest(`.doc-row, .doc-gone`)??t)?.scrollIntoView({block:`center`,behavior:`smooth`})})},be=e=>t=>(0,X.jsx)(UB,{pin:e,fallback:t}),G=(0,d.useRef)(!1);(0,d.useEffect)(()=>{n&&(ne(n),G.current=!1)},[n]),(0,d.useEffect)(()=>{if(!n||G.current||!i)return;let e=ae.current?.querySelector(`[data-doc-chip="${CSS.escape(n)}"]`);e&&(G.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=oe.current;oe.current=null,t&&e.button===0&&setTimeout(()=>{let e=t.dataset.paragraph,{selectionStart:n,selectionEnd:r,value:a}=t,o=e&&r>n?yo(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=ae.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+bG>n.height&&t[0].top-n.top>bG;te({left:i,width:r,above:o,top:o?t[0].top-n.top-8:a})},[P,fe,p]),(0,d.useEffect)(()=>{V&&ae.current?.querySelector(`.doc-ask`)?.scrollIntoView({block:`nearest`})},[V]);let xe=(0,d.useCallback)(()=>F(null),[]),Se=(e,t)=>{let n=[];for(let r of ge.get(e.id)??[]){if(r.discussion?.resolved&&r.id!==H)continue;let e=vo(t,r.quote,r.anchor);e&&n.push({id:r.id,...e})}let r=P?.paragraph===e.id?vo(t,P.quote,P):null;return r&&n.push({id:nB,...r}),n},Ce=(0,d.useMemo)(()=>rG(le),[le]),we=le?.edits.length??0,Te=le?.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 Ee=(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 KW.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&&ue();return}});return A.current=r,r},[i,e.id,e.docDraft,t,ue]),De=(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():Ee([{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})})},[Ee]),Oe=()=>Promise.all([...j.current.keys()].map(e=>De(e))),ke=(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 De(e),yG))};(0,d.useEffect)(()=>()=>k.current.forEach(e=>clearTimeout(e)),[]);let Ae=(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}),Ee(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=fe.slice(0,t).findLast(e=>e.state!==`removed`&&!e.locked);r&&(O.current={id:r.id,at:`end`}),Ee([{kind:`delete`,id:e.id}])}},je=async()=>{let e=window.open(``,`_blank`);v(null),l({});try{let{url:t}=await Y.startConnector(`google`);e&&(e.location.href=t),l({url:t,blocked:!e})}catch(t){e?.close(),l(null),v(t.message)}},Me=async()=>{let t=sr(e.url)?.fileId;v(null),b(!0);try{let e=await $W({fileIds:t?[t]:void 0,title:`Choose "${ce}"`});e.length&&t&&!e.some(e=>e.id===t)?v(`That's another doc. Choose "${ce}" to open it here.`):e.length&&await ue()}catch(e){v(e.message)}finally{b(!1)}},Ne=async()=>{g(`save`),v(null);try{await Oe(),await A.current;let n=await KW.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(vG,`1`)}catch{}E(!0),await ue()}else f({draft:n.draft,from:e.docDraft}),await ue()}catch(e){v(e.message)}finally{g(null)}},Pe=async()=>{g(`discard`);try{await KW.discardDocDraft(e.id,t),f({draft:void 0,from:e.docDraft}),m(new Map),w(!1),await ue()}catch(e){v(e.message)}finally{g(null)}},Fe=async n=>{if(P&&I.trim()&&!R){z(!0),ee(null);try{await De(P.paragraph),await A.current;let{pin:r}=await KW.pinDocWords(e.id,t,{...P,body:n?se.address(I):I,ask:n});ie(r),ne(r.id),F(null),L(``)}catch(e){ee(e.message)}finally{z(!1)}}},Ie=async(n,r)=>{try{let{draft:i}=await KW.resolveDocConflict(e.id,t,n.id,r);f({draft:i??void 0,from:e.docDraft})}catch(e){v(e.message)}},Le=(0,X.jsxs)(`a`,{className:`btn btn-small`,href:e.url,target:`_blank`,rel:`noreferrer`,children:[`Open in Google`,(0,X.jsx)(Q,{name:`external`})]}),Re;Re=o&&!i?(0,X.jsx)(AG,{problem:o,title:ce,waiting:c,choosing:y,error:_,onAllow:je,onChoose:()=>void Me(),onCancelWait:()=>l(null),onRetry:ue,openInGoogle:Le}):i?Te.length?(0,X.jsx)(kG,{conflicts:Te,draft:le,me:t,onResolve:Ie}):(0,X.jsxs)(`div`,{className:`doc-page`,ref:ae,children:[fe.map((n,r)=>{let i=p.get(n.id)??n.text,a=ge.get(n.id)??[],o=a.find(e=>e.id===H);return(0,X.jsx)(OG,{row:n,number:pe.get(n.id),me:t,text:i,marks:Se(n,i),focus:H,chips:a.map(e=>(0,X.jsx)(gG,{pin:e,open:e.id===H,lost:n.state===`removed`?`paragraph removed`:void 0,onToggle:()=>ve(e.id)},e.id)),after:o&&(0,X.jsx)(DB,{inline:!0,pin:o,block:e,name:t,onClose:()=>ne(null),live:be(o),address:se.address},o.id),onPress:e=>{e.button===0&&(oe.current=e.currentTarget)},onType:e=>ke(n.id,e),onBlur:()=>void De(n.id),onKeyDown:Ae(n,r),inputRef:e=>e?D.current.set(n.id,e):D.current.delete(n.id),onRemove:()=>void Ee([{kind:`delete`,id:n.id}]),onRestore:()=>{m(e=>{let t=new Map(e);return t.delete(n.id),t}),Ee([{kind:`restore`,id:n.id}])},onFormat:(e,t)=>void Ee([{kind:`format`,id:n.id,style:e,list:t}])},n.id)}),_e.length>0&&(0,X.jsxs)(`div`,{className:`doc-gone`,children:[(0,X.jsxs)(`div`,{className:`doc-gone-chips`,children:[(0,X.jsx)(`span`,{className:`faint small`,children:`No longer in the doc`}),_e.map(e=>(0,X.jsx)(gG,{pin:e,open:e.id===H,part:`“${e.quote.length>40?`${e.quote.slice(0,39)}…`:e.quote}”`,lost:`paragraph removed`,onToggle:()=>ve(e.id)},e.id))]}),_e.some(e=>e.id===H)&&(0,X.jsx)(DB,{inline:!0,pin:_e.find(e=>e.id===H),block:e,name:t,onClose:()=>ne(null),live:be(_e.find(e=>e.id===H)),address:se.address},H)]}),(0,X.jsxs)(`button`,{className:`doc-add`,onClick:()=>{let e=fe.findLast(e=>e.state!==`removed`);Ee([{kind:`add`,after:e?.id??``,text:``}]).then(e=>{e?.added[0]&&(O.current={id:e.added[0],at:`start`})})},children:[(0,X.jsx)(Q,{name:`plus`}),` Add a paragraph`]}),P&&V&&(0,X.jsx)(hG,{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 Fe(e),onClose:xe},`${P.paragraph}:${P.quote}`)]}):(0,X.jsxs)(`div`,{className:`doc-editor-state`,role:`status`,children:[(0,X.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Opening from Google…`]});let ze=se.agents.find(e=>e.name===se.agent);return(0,X.jsx)(iV,{pairing:se,className:`doc-editor`,label:`Edit ${ce}`,icon:(0,X.jsx)(fG,{mark:`google-docs`}),title:ce,from:`Google Doc · ${i?le?`draft in Tricot, from the version of ${Yy(i.doc.pulledAt)}`:`as Google has it, ${Yy(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:se.agent?`Pairing with ${se.agent}: select words to ask ${se.agent} to change them; ${se.agent} edits the draft and replies on the pin. ${rV(ze,se.agent)}`:`Select words to ask an agent to change them, or to comment.`,controls:Le,open:H,onOpenRequest:ye,onClose:r,foot:(0,X.jsxs)(X.Fragment,{children:[i&&!Te.length&&(0,X.jsxs)(`footer`,{className:`doc-editor-foot`,children:[we>0&&!T&&(0,X.jsxs)(`p`,{className:`doc-note`,children:[(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:_}),(0,X.jsx)(`div`,{className:`doc-editor-actions`,children:C?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`small`,children:[`Discard `,SG(we,`change`),`? Google's doc stays as it is.`]}),(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:h!==null,onClick:Pe,children:`Discard`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>w(!1),children:`Keep editing`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`faint small doc-editor-hint`,children:`Enter adds a paragraph · Shift+Enter breaks a line`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:!we||h!==null,onClick:()=>w(!0),children:`Discard draft`}),(0,X.jsx)(`button`,{className:`btn btn-primary`,disabled:!we||h!==null,onClick:Ne,children:h===`save`?`Saving to Google…`:we?`Save to Google · ${SG(we,`paragraph`)} changed`:`Nothing to save yet`})]})})]}),i&&Te.length>0&&_&&(0,X.jsx)(`footer`,{className:`doc-editor-foot`,children:(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:_})})]}),band:i&&(Ce.length>0||x||le?.rebased)&&(0,X.jsx)(`div`,{className:`doc-editor-band`,children:x&&!we?(0,X.jsxs)(`span`,{className:`doc-saved`,role:`status`,children:[(0,X.jsx)(Q,{name:`check`}),` Saved `,SG(x.paragraphs,`paragraph`),` to Google · `,Yy(x.at),`. The rest of the doc is as it was.`]}):(0,X.jsxs)(X.Fragment,{children:[Ce.length>0&&(0,X.jsxs)(`span`,{className:`doc-authors`,children:[(0,X.jsx)(`span`,{className:`faint`,children:`Changes in this draft`}),Ce.map(e=>(0,X.jsxs)(`span`,{className:`doc-author`,children:[(0,X.jsx)(wG,{actor:e.by,me:t}),(0,X.jsx)(`span`,{className:`doc-author-count`,children:e.count})]},`${e.by.kind}:${e.by.name}`))]}),le?.rebased&&!Te.length&&(0,X.jsxs)(`span`,{className:`doc-rebased`,children:[`Moved onto the latest version from Google`,le.rebased.theirs?` (${SG(le.rebased.theirs,`paragraph`)} changed there)`:``,`. Check it, then save again.`]})]})}),children:(0,X.jsx)(`div`,{className:`doc-editor-body`,children:Re})})}var EG={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`},DG=[{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 OG(e){let{row:t,number:n,me:r,text:i,marks:a,chips:o}=e,s=EG[t.style]??``;if(t.locked)return(0,X.jsx)(`div`,{className:`doc-row is-locked`,children:(0,X.jsxs)(`div`,{className:`doc-locked`,children:[(0,X.jsxs)(`span`,{className:`doc-locked-label`,children:[t.locked,`: edit in Google`]}),(t.detail||t.text)&&(0,X.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=DG.find(e=>e.style===t.style&&(e.list??void 0)===(t.list?t.list.ordered?`numbered`:`bullet`:void 0));return(0,X.jsxs)(`div`,{className:`doc-row is-${d}`,"data-row":t.id,children:[(0,X.jsxs)(`div`,{className:`doc-text`,style:{paddingLeft:t.list?22+l*22:0},children:[c&&(0,X.jsx)(`span`,{className:`doc-list-mark`,style:{left:l*22},children:c}),t.state===`removed`?(0,X.jsx)(`p`,{className:`doc-removed ${s}`,children:t.was||` `}):(0,X.jsxs)(`div`,{className:`doc-field`,children:[a.length>0&&(0,X.jsx)(`div`,{className:`doc-input doc-marks ${s}`,"aria-hidden":!0,children:(0,X.jsx)(cB,{text:i,marks:a,focus:e.focus})}),(0,X.jsx)(CG,{className:`doc-input ${s}`,value:i,paragraph:t.id,label:`${tG[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,X.jsxs)(`p`,{className:`doc-was`,title:`As the doc has it in Google`,children:[(0,X.jsx)(`span`,{className:`doc-was-label`,children:`In Google:`}),` `,t.was||`(empty)`]})]}),(0,X.jsxs)(`div`,{className:`doc-meta`,children:[o,d!==`same`&&(0,X.jsx)(`span`,{className:`doc-state is-${d}`,children:d===`changed`?`Edited`:d===`added`?`New`:`Removed`}),t.by&&(0,X.jsx)(wG,{actor:t.by,me:r}),t.state===`added`&&(0,X.jsx)(`select`,{className:`doc-style`,value:f?.value??`text`,onChange:t=>{let n=DG.find(e=>e.value===t.target.value);e.onFormat(n.style,n.list)},"aria-label":`Paragraph style`,children:DG.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,X.jsxs)(`span`,{className:`doc-actions`,children:[(t.state===`changed`||t.state===`removed`)&&(0,X.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,X.jsx)(`button`,{className:`btn btn-small btn-quiet doc-remove`,onClick:e.onRemove,title:`Remove this paragraph`,"aria-label":`Remove this paragraph`,children:(0,X.jsx)(Q,{name:`x`})})]})]}),e.after&&(0,X.jsx)(`div`,{className:`doc-row-after`,children:e.after})]})}function kG(e){let{conflicts:t,draft:n,me:r,onResolve:i}=e,a=n.edits.length;return(0,X.jsxs)(`div`,{className:`doc-conflicts`,children:[(0,X.jsxs)(`div`,{className:`doc-conflict-intro`,role:`status`,children:[(0,X.jsx)(`h3`,{children:`Someone edited this doc in Google since the draft began`}),(0,X.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 ${SG(a,`other change`)} carried over onto the latest version.`]})]}),t.map(e=>(0,X.jsxs)(`article`,{className:`doc-conflict`,children:[(0,X.jsxs)(`p`,{className:`faint small doc-conflict-was`,children:[`Was: `,(0,X.jsx)(`span`,{children:e.was||`(empty)`})]}),(0,X.jsxs)(`div`,{className:`doc-conflict-sides`,children:[(0,X.jsxs)(`div`,{className:`doc-side is-theirs`,children:[(0,X.jsx)(`span`,{className:`doc-side-label`,children:`In Google now`}),(0,X.jsx)(`p`,{className:e.theirs===void 0?`is-gone`:void 0,children:e.theirs??`Removed in Google`}),(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i(e,`theirs`),children:`Take theirs`})]}),(0,X.jsxs)(`div`,{className:`doc-side is-mine`,children:[(0,X.jsxs)(`span`,{className:`doc-side-label`,children:[`Your draft · `,(0,X.jsx)(wG,{actor:e.by,me:r})]}),(0,X.jsx)(`p`,{className:e.mine===void 0?`is-gone`:void 0,children:e.mine??`Removed in the draft`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-primary`,onClick:()=>i(e,`mine`),children:`Keep mine`})]})]})]},e.id))]})}function AG(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,X.jsxs)(`div`,{className:`doc-access`,children:[(0,X.jsx)(`span`,{className:`doc-access-mark`,"aria-hidden":!0,children:(0,X.jsx)(Q,{name:d||f?`edit`:`x`})}),(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{children:[`Choose `,(0,X.jsx)(`strong`,{children:n}),` in Google once to let Tricot open it.`]}),(0,X.jsxs)(`ul`,{className:`doc-access-points`,children:[(0,X.jsx)(`li`,{children:`Tricot can open only the Google Docs you choose, never the rest of your Drive.`}),(0,X.jsx)(`li`,{children:`Tricot changes a doc only when someone presses Save, and only the paragraphs edited here.`}),(0,X.jsx)(`li`,{children:`Agents can read a doc and suggest edits in the draft. They can't save.`})]})]}):(0,X.jsx)(`p`,{children:t.message}),r?(0,X.jsxs)(`div`,{className:`row doc-access-actions`,children:[(0,X.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,X.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,X.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,X.jsx)(Q,{name:`external`})]}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:c,children:`Cancel`})]}):(0,X.jsxs)(`div`,{className:`row doc-access-actions`,children:[f&&(0,X.jsx)(`button`,{className:`btn btn-primary`,disabled:i,onClick:s,children:i?`Choosing…`:`Choose in Google`}),d&&(0,X.jsx)(`button`,{className:`btn btn-primary`,onClick:o,children:d.action}),t.code===`not_set_up`&&(0,X.jsx)(`a`,{className:`btn btn-primary`,href:db.connectors(),children:`Go to Connectors`}),!d&&!f&&t.code!==`not_set_up`&&(0,X.jsx)(`button`,{className:`btn`,onClick:l,children:`Try again`}),!d&&!f&&u]}),a&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:a})]})}var jG=[[`#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`]],MG={"google-docs":{tile:`#1a73e8`,glyph:(0,X.jsx)(`path`,{d:`M10.5 11h11M10.5 15h11M10.5 19h11M10.5 23h6.5`,..._W,strokeWidth:2})},"google-sheets":{tile:`#188038`,glyph:(0,X.jsx)(`path`,{d:`M9.5 9.5h13v13h-13ZM9.5 14h13M9.5 18.25h13M14.25 9.5v13`,..._W})},"google-slides":{tile:`#f4b400`,glyph:(0,X.jsx)(`rect`,{x:`9`,y:`11`,width:`14`,height:`10`,rx:`1.5`,fill:`#fff`})},"google-forms":{tile:`#7248b9`,glyph:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:`M14.5 11h7.5M14.5 16h7.5M14.5 21h7.5`,..._W,strokeWidth:2}),(0,X.jsx)(`circle`,{cx:`10.5`,cy:`11`,r:`1.5`,fill:`#fff`}),(0,X.jsx)(`circle`,{cx:`10.5`,cy:`16`,r:`1.5`,fill:`#fff`}),(0,X.jsx)(`circle`,{cx:`10.5`,cy:`21`,r:`1.5`,fill:`#fff`})]})},"google-drive":{tile:`var(--mark-tile)`,glyph:(0,X.jsx)(`g`,{transform:`translate(7 7) scale(0.75)`,children:jG.map(([e,t])=>(0,X.jsx)(`path`,{d:t,fill:e},e))})},google:{tile:`var(--mark-tile)`,glyph:(0,X.jsxs)(`g`,{fill:`none`,strokeWidth:`3`,children:[(0,X.jsx)(`path`,{d:`M23 16a7 7 0 0 1-2.5 5.36`,stroke:`#4285f4`}),(0,X.jsx)(`path`,{d:`M16.5 16H23`,stroke:`#4285f4`}),(0,X.jsx)(`path`,{d:`M20.5 21.36A7 7 0 0 1 10.64 20.5`,stroke:`#34a853`}),(0,X.jsx)(`path`,{d:`M10.64 20.5a7 7 0 0 1 0-9`,stroke:`#fbbc05`}),(0,X.jsx)(`path`,{d:`M10.64 11.5a7 7 0 0 1 10.72 0`,stroke:`#ea4335`})]})}};function NG(){let{tile:e,glyph:t}=MG.google;return(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var PG={id:`google`,Mark:NG,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:eG,chooser:{label:`Choose a Google Doc`,async choose(){let[e]=await $W({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 KW.driveFile(e)).file,marks:MG,editor:{title:`Edit this doc's text here, then save the changes to Google`,Editor:TG,Threads:_G,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 FG(e,t,n){let r=(32-n)/2;return(0,X.jsx)(`path`,{d:e,fill:t,transform:`translate(${r} ${r}) scale(${n/24})`})}var IG=`var(--mark-tile)`,LG={tile:IG,glyph:FG(`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)},RG={tile:IG,glyph:FG(`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)},zG={tile:`#5e6ad2`,glyph:FG(`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)},BG={tile:`#4a154b`,dark:!0,glyph:(0,X.jsx)(`path`,{d:`M13.5 9v14M18.5 9v14M9 13.5h14M9 18.5h14`,..._W,strokeWidth:2.25})},VG={tile:`#0052cc`,glyph:FG(`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)},HG={tile:`#172b4d`,dark:!0,glyph:FG(`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)},UG={tile:`#000`,dark:!0,glyph:FG(`m12 1.608 12 20.784H0Z`,`#fff`,15)},WG={tile:`#cb3837`,glyph:FG(`M5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z`,`#fff`,28)},GG={tile:IG,glyph:FG(`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)},KG={tile:`#000`,dark:!0,glyph:FG(`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)},qG={tile:IG,glyph:FG(`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)},JG={gitlab:LG,notion:RG,linear:zG,slack:BG,jira:VG,confluence:HG,vercel:UG,npm:WG,stackOverflow:GG,mdn:KG,wikipedia:qG},YG={document:MG[`google-docs`],spreadsheets:MG[`google-sheets`],presentation:MG[`google-slides`],forms:MG[`google-forms`],file:MG[`google-drive`]},XG={"github.com":yW.marks.github,"githubusercontent.com":yW.marks.github,"gitlab.com":LG,"figma.com":HU.marks.figma,"google.com":MG.google,"docs.google.com":e=>{let t=e.pathname.split(`/`)[1]??``;return Object.hasOwn(YG,t)?YG[t]:MG.google},"drive.google.com":MG[`google-drive`],"sheets.google.com":MG[`google-sheets`],"slides.google.com":MG[`google-slides`],"forms.google.com":MG[`google-forms`],"forms.gle":MG[`google-forms`],"youtube.com":oG.marks.youtube,"youtu.be":oG.marks.youtube,"youtube-nocookie.com":oG.marks.youtube,"loom.com":aG.marks.loom,"notion.so":RG,"notion.com":RG,"notion.site":RG,"linear.app":zG,"slack.com":BG,"atlassian.net":e=>/^\/wiki(\/|$)/i.test(e.pathname)?HG:VG,"vercel.com":UG,"npmjs.com":WG,"npmjs.org":WG,"stackoverflow.com":GG,"developer.mozilla.org":KG,"wikipedia.org":qG};function ZG(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(XG,r))continue;let i=XG[r];return typeof i==`function`?i(t):i}return null}var QG={useKey:e=>J(wn.key)({key:e}),card:(e,t=!1)=>bs(wn.issue)({identifier:e},t?{fresh:`1`}:void 0)},$G=6e4,eK=new Map,tK=new Map,nK=new Set,rK=!1,iK=()=>nK.forEach(e=>e());function aK(){eK.clear(),iK()}function oK(e,t=!1){rK||(rK=!0,qU(aK));let n=eK.get(e),r=tK.get(e);if(r)return r;if(!t&&n&&Date.now()-n.at<$G)return Promise.resolve(n.answer);let i=QG.card(e,t).then(t=>(eK.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return tK.set(e,i),iK(),i.finally(()=>{tK.delete(e),iK()}),i}var sK=e=>(nK.add(e),()=>void nK.delete(e));function cK(e){let t=(0,d.useSyncExternalStore)(sK,()=>e?eK.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(sK,()=>e?tK.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;oK(e);let t=()=>void oK(e);return window.addEventListener(`focus`,t),()=>window.removeEventListener(`focus`,t)},[e]);let r=(0,d.useCallback)(()=>e?oK(e,!0):Promise.resolve(null),[e]);return{card:t?.card,problem:t?.problem,busy:n,refresh:r}}var lK={needs_sign_in:`Linear needs you to sign in again`,not_found:`Linear can't find this issue`};function uK({card:e}){return(0,X.jsx)(`span`,{className:`lin-state is-${e.status.kind||`unstarted`}`,children:e.status.name})}function dK({source:e}){let{card:t,problem:n,busy:r,refresh:i}=cK(e.fileId);return!t&&!n?r?(0,X.jsx)(`p`,{className:`lin-details faint`,children:`Looking it up on Linear…`}):null:n?n.code===`not_connected`?null:(0,X.jsxs)(`p`,{className:`lin-details lin-problem is-${n.code}`,role:`status`,children:[(0,X.jsx)(`span`,{className:`lin-problem-text`,title:n.message,children:lK[n.code]??n.message}),n.code===`needs_sign_in`&&(0,X.jsx)(`a`,{className:`btn btn-small nodrag`,href:db.connectors(),children:`Sign in again`})]}):t?(0,X.jsxs)(`div`,{className:`lin-details nodrag`,children:[(0,X.jsx)(uK,{card:t}),(0,X.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,X.jsx)(`span`,{className:`lin-priority`,children:t.priority}),(0,X.jsx)(`span`,{className:`lin-spacer`}),(0,X.jsx)(`span`,{className:`lin-id`,children:t.identifier}),(0,X.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,X.jsx)(Q,{name:`sync`})})]}):null}var fK=`https://linear.app/settings/account/security`;function pK({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 QG.useKey(n);r(``),aK(),e(t)}catch(e){s(e.message)}finally{a(!1)}};return(0,X.jsxs)(`form`,{className:`lin-key`,onSubmit:e=>void c(e),children:[(0,X.jsxs)(`p`,{className:`muted small`,children:[t,` `,(0,X.jsx)(`a`,{href:fK,target:`_blank`,rel:`noreferrer`,children:`Make a key`})]}),(0,X.jsxs)(`div`,{className:`lin-key-row`,children:[(0,X.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,X.jsx)(`button`,{className:`btn btn-primary`,disabled:i||!n.trim(),children:i?`Checking…`:`Use this key`})]}),(0,X.jsx)(`p`,{className:`faint small`,children:`The key stays on this computer and is sent only to Linear.`}),o&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:o})]})}function mK({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 qU(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 Y.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,X.jsxs)(`section`,{className:`connector-section lin-signin`,children:[n&&(0,X.jsx)(`div`,{className:`lin-connect`,children:r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,X.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,X.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,X.jsx)(Q,{name:`external`})]}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>i(null),children:`Cancel`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>void s(),children:c?`Connect again`:`Connect Linear`}),(0,X.jsx)(`span`,{className:`faint small`,children:`Opens Linear in a new tab. Nothing is saved until you allow it there.`})]})}),a&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:a}),n?(0,X.jsxs)(`details`,{className:`lin-details-key`,children:[(0,X.jsx)(`summary`,{children:`Use a personal API key instead`}),(0,X.jsx)(pK,{onChange:t,lead:`Make a key in Linear, under Settings → Security & access → Personal API keys, with read-only access, and paste it here.`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{children:c?`Paste a new Linear API key`:`Paste your Linear API key`}),(0,X.jsx)(pK,{onChange:t,lead:`In Linear, open Settings → Security & access → Personal API keys and make a key with read-only access.`})]})]})}var hK=JG.linear;function gK(){return(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:hK.tile}),hK.glyph]})})}var _K={id:`linear`,Mark:gK,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:mK,LinkCard:dK,marks:{linear:hK},fileInfo:async e=>{let t=await oK(e);return t?.card?{name:t.card.title,modifiedTime:t.card.updatedAt}:null}},vK=e=>e===0?`No replies`:e===1?`1 reply`:`${e} replies`,yK={thread:(e,t=!1)=>{let[n,r]=e.split(`/`);return bs(Mn.thread)({channel:n,ts:r},t?{fresh:`1`}:void 0)},shareDecision:(e,t)=>J(Mn.shareDecision)({channel:t},{decisionId:e})},bK=6e4,xK=new Map,SK=new Map,CK=new Set,wK=()=>CK.forEach(e=>e());function TK(e,t=!1){let n=xK.get(e),r=SK.get(e);if(r)return r;if(!t&&n?.answer.thread&&Date.now()-n.at<bK)return Promise.resolve(n.answer);let i=yK.thread(e,t).then(t=>(xK.set(e,{at:Date.now(),answer:t}),t),()=>n?.answer??null);return SK.set(e,i),wK(),i.finally(()=>{SK.delete(e),wK()}),i}function EK(){xK.clear(),wK()}var DK=e=>(CK.add(e),()=>void CK.delete(e));function OK(e){let t=(0,d.useSyncExternalStore)(DK,()=>e?xK.get(e)?.answer:void 0),n=(0,d.useSyncExternalStore)(DK,()=>e?SK.has(e):!1);(0,d.useEffect)(()=>{if(!e)return;TK(e);let t=()=>void TK(e);window.addEventListener(`focus`,t);let n=qU(t=>{t.id===`slack`&&(EK(),TK(e))});return()=>{window.removeEventListener(`focus`,t),n()}},[e]);let r=(0,d.useCallback)(()=>e?TK(e,!0):Promise.resolve(null),[e]);return{thread:t?.thread,problem:t?.problem,busy:n,refresh:r}}var kK={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 AK({source:e}){let t=MR(),{thread:n,problem:r,busy:i,refresh:a}=OK(e.fileId);if(!e.fileId)return null;if(!n&&!r)return(0,X.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,X.jsxs)(`p`,{className:`slack-card slack-problem nodrag`,role:`status`,title:r.message,children:[(0,X.jsx)(`span`,{className:`slack-problem-text`,children:kK[r.code]??r.message}),e&&(0,X.jsx)(`a`,{className:`btn btn-small btn-primary`,href:db.connectors(t.board.id),children:r.code===`not_connected`?`Connect Slack`:`Sign in again`})]})}return n?(0,X.jsxs)(`div`,{className:`slack-card nodrag`,children:[(0,X.jsxs)(`p`,{className:`slack-head`,children:[(0,X.jsx)(`strong`,{className:`slack-author`,title:n.author,children:n.author}),(0,X.jsx)(`span`,{className:`faint`,title:new Date(n.postedAt).toLocaleString(),children:Yy(n.postedAt)})]}),(0,X.jsx)(`p`,{className:`slack-text`,children:n.text||`A message with no text.`}),(0,X.jsxs)(`p`,{className:`slack-foot`,children:[(0,X.jsx)(`span`,{className:`slack-replies${n.replies?` has-replies`:``}`,children:vK(n.replies)}),n.latestReplyAt&&n.replies>0&&(0,X.jsxs)(`span`,{className:`faint`,children:[`last reply `,Yy(n.latestReplyAt)]}),(0,X.jsx)(`span`,{className:`slack-spacer`}),(0,X.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,X.jsx)(Q,{name:`sync`})})]})]}):null}var jK=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),MK=140,NK=300;function PK(e,t){let n=e.options.filter(e=>!e.outdated),r=[`*Decision #${e.number}: ${jK(p(e.question,NK))}*`,``];return n.forEach((t,n)=>{let i=t.id.length===1?t.id.toUpperCase():String.fromCharCode(65+n),a=t.description?`: ${jK(p(t.description,MK))}`:``,o=e.recommendation?.optionId===t.id?` _(recommended)_`:``;r.push(`• *${i}.* ${jK(p(t.label,MK))}${a}${o}`)}),r.push(``,`<${t}|Open the decision on the Tricot board>`),r.join(`
|
|
83
|
-
`)}var FK=`tricot:slack-channel`,IK=()=>{try{return localStorage.getItem(FK)??``}catch{return``}},LK=/\*([^*\n]+)\*|_([^_\n]+)_|<([^|>\n]+)\|([^>\n]+)>/g,RK=e=>e.replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`);function zK({text:e}){return(0,X.jsx)(X.Fragment,{children:e.split(`
|
|
84
|
-
`).map((e,t)=>{let n=[],r=0;for(let t of e.matchAll(LK))n.push(RK(e.slice(r,t.index))),t[1]===void 0?t[2]===void 0?n.push((0,X.jsx)(`span`,{className:`slack-share-link`,children:RK(t[4])},n.length)):n.push((0,X.jsx)(`em`,{children:RK(t[2])},n.length)):n.push((0,X.jsx)(`strong`,{children:RK(t[1])},n.length)),r=t.index+t[0].length;return n.push(RK(e.slice(r))),(0,X.jsx)(`p`,{className:`slack-share-line`,children:n},t)})})}function BK({board:e,decision:t,onClose:n}){let[r,i]=(0,d.useState)(IK),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(!1),m=Nc().byId(`decision`,e.id,t.id),h=m&&`${location.origin}/${m.href}`,g=Kn(r)!==null;return(0,d.useEffect)(()=>{Y.connectors().then(e=>o(e.find(e=>e.id===`slack`)?.account?.email??null),()=>{})},[]),(0,d.useEffect)(()=>{let e=e=>e.key===`Escape`&&!s&&n();return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,s]),h===void 0?null:(0,kc.createPortal)((0,X.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!s&&n(),children:(0,X.jsxs)(`form`,{className:`delete-dialog slack-share`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`slack-share-title`,onSubmit:async e=>{if(e.preventDefault(),g&&!s){c(!0),u(null);try{await yK.shareDecision(t.id,r.trim());try{localStorage.setItem(FK,r.trim())}catch{}p(!0)}catch(e){u(e.message)}finally{c(!1)}}},children:[(0,X.jsx)(`h2`,{id:`slack-share-title`,children:`Share to Slack`}),f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,children:[`Shared to Slack`,a?`, as ${a}`:``,`.`]}),(0,X.jsx)(`div`,{className:`delete-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:n,autoFocus:!0,children:`Done`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{children:[`Posts this decision to a channel`,a?(0,X.jsxs)(X.Fragment,{children:[`, as `,(0,X.jsx)(`strong`,{children:a})]}):``,`. It comes from your own Slack account, only when you press the button.`]}),(0,X.jsx)(`label`,{className:`delete-label`,htmlFor:`slack-share-channel`,children:`Channel`}),(0,X.jsx)(`input`,{id:`slack-share-channel`,value:r,onChange:e=>i(e.target.value),placeholder:`A link to the channel, or to a message in it`,autoComplete:`off`,spellCheck:!1,autoFocus:!0}),(0,X.jsx)(`p`,{className:`faint small`,children:`In Slack, right-click the channel or a message in it, then Copy link. A channel ID (C…) works too.`}),(0,X.jsx)(`label`,{className:`delete-label`,htmlFor:`slack-share-preview`,children:`What will be posted`}),(0,X.jsx)(`div`,{id:`slack-share-preview`,className:`slack-share-preview`,role:`group`,"aria-label":`What will be posted`,children:(0,X.jsx)(zK,{text:PK(t,h)})}),l&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:l}),(0,X.jsxs)(`div`,{className:`delete-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,disabled:s,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:!g||s,children:s?`Sharing…`:`Share to Slack`})]})]})]})}),document.body)}function VK(){let{tile:e,glyph:t}=JG.slack;return(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 32 32`,width:`32`,height:`32`,children:[(0,X.jsx)(`rect`,{width:`32`,height:`32`,rx:`6`,fill:e}),t]})})}var HK={id:`slack`,Mark:VK,serves:`Threads you link, and decisions you share`,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. It reads the threads you link, and posts only when you choose Share to Slack on a decision. Agents can read a linked thread; they can't post to Slack.`,LinkCard:AK,marks:{slack:JG.slack},share:{label:`Share to Slack…`,note:`Post the question, the options and a link back to a channel, as you.`,Dialog:BK},fileInfo:async e=>{let t=await TK(e);return t?.thread?{name:`Thread by ${t.thread.author}`}:null}},UK=()=>[PG,gW,GW,HK,_K],WK;function GK(){return WK??=UK()}function KK(e){return GK().find(t=>t.id===e)}function qK(e){return e?.connector?KK(e.connector):void 0}var JK={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)`}},YK=()=>({actual:1/(window.devicePixelRatio||1),fitMax:1,maxScale:8,pad:24});function XK(e){let t=Rt(q.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:PH(r?.src===t?r.size:n,(0,d.useMemo)(YK,[]))}}function ZK({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o,picturing:s}){let c=MR(),{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=FH(f),[w,T]=(0,d.useState)(null),E=(0,d.useRef)(null),D=(0,d.useRef)(null),O=VU(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(zR(D.current,D.current)),x(!1)):C.handlers.onPointerDown(e))},M=e=>{if(D.current)return T(zR(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=zR(n,A(t)),o=VR(i,r)?BR(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:dV,box:P,n:O,pin:void 0}]:[]],I=n?` is-pointing`:C.dragging?` is-dragging`:y?` is-pannable`:` is-fitted`;return(0,X.jsxs)(`div`,{className:`image-full`,children:[(0,X.jsxs)(`div`,{ref:f.stageRef,className:`zoom-stage image-viewer-stage${I}`,tabIndex:0,"aria-label":`${k} at ${b}. ${NH}`,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,X.jsxs)(`div`,{ref:E,className:`zoom-sheet image-viewer-sheet`,style:h??{visibility:`hidden`},children:[(0,X.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,X.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`?dV:void 0,style:{left:`${t.x*100}%`,top:`${t.y*100}%`,width:`${t.w*100}%`,height:`${t.h*100}%`},children:r?(0,X.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,X.jsx)(`span`,{className:`pin-box-n`,children:n})},e))]}),(0,X.jsx)(LH,{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,X.jsx)(`div`,{className:`image-full-chips`,children:t.map(({pin:e})=>(0,X.jsx)(_z,{pin:e,open:e.id===i,part:e.quote,onToggle:()=>o(e.id)},e.id))})]})}function QK({block:e,name:t,version:n,pinId:r,onClose:i}){let a=XK(n?be(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,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`image`,className:`image-full-view`,label:`${c}, full size`,icon:(0,X.jsx)(Q,{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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(IH,{zoom:o,labels:JK}),(0,X.jsxs)(`a`,{className:`btn btn-small`,href:s,target:`_blank`,rel:`noreferrer`,children:[`Open in a tab`,(0,X.jsx)(Q,{name:`external`})]})]}),body:e=>(0,X.jsx)(ZK,{...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,X.jsxs)(`figure`,{className:`image-edit-figure`,children:[(0,X.jsx)(`img`,{src:s,alt:e||t.title||``,draggable:!1}),e.trim()&&(0,X.jsx)(`figcaption`,{children:(0,X.jsx)(Jy,{children:e})})]})},onClose:i})}var $K=8;function eq(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=Rt(q.asset,{id:t}),()=>{e.onload=null}},[t,n,r]),i??(a?.assetId===t?a.size:null)}function tq(e){let{block:t,shown:n,viewing:r}=e,i=MR(),a=eq(n),o=a&&Mt(a),s=o!==null&&Math.abs(o.w-t.w)<=1&&Math.abs(o.h-t.h)<=1,c=t.origin&&KK(t.origin.connector)?.ImageTools;return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.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${At(a)<a.width?`, shown at half: a 2x screenshot`:``})`:`Reading the picture…`,children:`Natural size`}),c&&(0,X.jsx)(c,{block:t,viewing:r})]})}function nq({block:e,placed:t}){let n=MR(),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=SH(n.draft,e.id,`box`),f=VU(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:nB,box:u,n:f,draft:!0}]:[]];return(0,X.jsxs)(`figure`,{className:`block-image`,children:[(0,X.jsxs)(`div`,{className:`block-image-stage`,onDoubleClick:()=>n.openOverlay(e.id),children:[(0,X.jsx)(`img`,{ref:r,src:Rt(q.asset,{id:e.assetId}),alt:e.caption??e.title??``,draggable:!1}),i&&(0,X.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<$K||r.h*i.height<$K||n.startPin({blockId:e.id,part:{kind:`box`,...r},quote:`box ${f}`})},onPointerCancel:()=>{c.current=null,s(null)},onClick:e=>!xH(e)&&bH(e,l.current)&&e.stopPropagation(),children:h.map(({key:e,box:t,n:r,draft:i})=>(0,X.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,X.jsx)(`span`,{className:`pin-box-n`,children:r})},e))})]}),(0,X.jsx)(`figcaption`,{children:(0,X.jsx)(NR,{value:e.caption??``,placeholder:`Add a caption`,display:(0,X.jsx)(Jy,{children:e.caption??``}),onCommit:t=>n.updateBlock(e,{caption:t})})})]})}async function rq(e,t){if(t)return Nt(t);try{let t=await createImageBitmap(e),n=Nt({width:t.width,height:t.height});return t.close(),n}catch{return Nt(null)}}async function iq(e,t,n){for(let[r,i]of e.entries())try{let{assetId:e,size:a}=await Y.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 rq(i,a)})}catch(e){t.report(e)}}var aq={type:`image`,copyText:e=>e.caption,Body:nq,Tools:tq,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:iq},activate:(e,t)=>t.openOverlay(e.id),overlay:{Component:QK,refocus:!0}};function oq(){let[e,t]=(0,d.useState)(new Set);return(0,d.useEffect)(()=>{let e=()=>Y.connectors().then(e=>t(new Set(e.filter(e=>e.state===`connected`).map(e=>e.id))),()=>{});return e(),qU(()=>void e())},[]),e}function sq({onPick:e,onBusy:t}){let n=oq(),[r,i]=(0,d.useState)(null),a=GK().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,X.jsxs)(`div`,{className:`add-link-choose`,children:[a.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>void o(e),children:e.label},e.label)),(0,X.jsx)(`span`,{className:`faint small`,children:`or paste an address`}),r&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}var cq=12e3;function lq(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),cq))});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[t.url,s]);let u=(0,X.jsxs)(`a`,{className:`btn btn-small`,href:n,target:`_blank`,rel:`noreferrer`,children:[`Open in `,r,(0,X.jsx)(Q,{name:`external`})]});return(0,X.jsxs)(`div`,{className:`link-frame nodrag nowheel`,children:[(0,X.jsxs)(`div`,{className:`link-frame-stage is-${a}`,ref:l,children:[a===`loading`&&(0,X.jsxs)(`span`,{className:`link-frame-wait`,children:[`Loading from `,r,`…`]}),(0,X.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,X.jsx)(`div`,{className:`link-frame-note`,role:`status`,children:(0,X.jsxs)(`div`,{className:`link-frame-banner`,children:[(0,X.jsx)(`p`,{children:t.blocked}),(0,X.jsxs)(`div`,{className:`row`,children:[u,(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>c(e=>e+1),children:`Try again`})]})]})})]}),(0,X.jsxs)(`p`,{className:`link-frame-help`,children:[`Doesn't load?`,` `,(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,children:[`Open in `,r]})]})]})}function uq(e){let t=e.trim();return dr(/^[a-z][a-z\d+.-]*:(?!\d)/i.test(t)?t:`https://${t}`)}function dq({url:e}){let t=ZG(e);return t?(0,X.jsx)(dG,{mark:t}):(0,X.jsx)(`span`,{className:`site-icon`,"aria-hidden":!0,children:(0,X.jsx)(Q,{name:`link`})})}function fq(e){let{block:t,editing:n,setEditing:r,badges:i}=e,a=MR(),o=(0,d.useMemo)(()=>sr(t.url),[t.url]),s=rW(o),c=qK(o),l=c?.editor;if(n&&!a.readOnly)return(0,X.jsx)(pq,{block:t,onDone:()=>r(!1)});let u=o?.embed,f=!!(t.open&&u),p=t.title||s?.name||o?.name||pr(t.url),m=s?.modifiedTime?iW(s.modifiedTime):``,[h,g]=o?o.ref&&t.title?[o.ref,o.what]:[cr(o),m||fr(t.url)]:[fr(t.url)],_=!!(l&&o?.editable)&&!a.readOnly,v=l?.draft(t)??null,y=_&&l&&(0,X.jsx)(l.Threads,{block:t}),b=_&&l&&(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a.openOverlay(t.id),title:l.title,children:`Edit in Tricot`});return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(fG,{mark:o.mark}):(0,X.jsx)(dq,{url:t.url}),(0,X.jsxs)(`div`,{className:`block-link-text`,children:[(0,X.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,X.jsxs)(`span`,{className:`block-link-host`,children:[y,v?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`block-link-lead block-link-draft`,children:v[0].toUpperCase()+v.slice(1)}),(0,X.jsxs)(`span`,{className:`block-link-rest`,children:[` · `,h]})]}):g?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`block-link-lead`,children:h}),(0,X.jsxs)(`span`,{className:`block-link-rest`,children:[` · `,g]})]}):h]})]}),u&&!a.readOnly&&(0,X.jsx)(`div`,{className:`block-link-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>a.openLink(t,!1),children:`Collapse`}),b||(0,X.jsxs)(`a`,{className:`btn btn-small`,href:t.url,target:`_blank`,rel:`noreferrer`,children:[`Open in `,o.site,(0,X.jsx)(Q,{name:`external`})]})]}):(0,X.jsxs)(X.Fragment,{children:[b,(0,X.jsx)(`button`,{className:`btn btn-small${_?` btn-quiet`:``}`,onClick:()=>a.openLink(t,!0),children:`Open here`})]})}),i]}),!f&&o&&c?.LinkCard&&(0,X.jsx)(c.LinkCard,{block:t,source:o}),f&&u&&(0,X.jsx)(lq,{embed:u,url:t.url,site:o.site,title:p},u.url)]})}function pq({block:e,onDone:t}){let n=MR(),[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=uq(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,X.jsxs)(`div`,{className:`block-link-editor nodrag`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(uq(r)!==null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u(!0)),e.key===`Escape`&&u(!1)},children:[(0,X.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,X.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Title (optional)`,"aria-label":`Title`})]})}function mq({block:e,editing:t,setEditing:n}){let r=MR(),{becomes:i}=wB();return t?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>r.startPin({blockId:e.id,part:{kind:`block`},quote:e.title||pr(e.url)}),title:`Pin this card to ${i}`,children:`Pin`}),(0,X.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 Uc(!i.trim()&&!o.trim()&&!u,r,p,t),(0,X.jsxs)(`form`,{ref:p,className:`add-link nodrag nopan nowheel`,onSubmit:e=>{e.preventDefault();let t=uq(i);t?n(t,o.trim()):l(!0)},onKeyDown:e=>e.key===`Escape`&&r(),children:[(0,X.jsx)(sq,{onBusy:f,onPick:e=>n(e,``)}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{className:`field-label`,children:`Address`}),(0,X.jsx)(`input`,{autoFocus:!e.address,value:i,onChange:e=>{a(e.target.value),l(!1)},placeholder:`https://…`,"aria-invalid":c})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`Title `,(0,X.jsx)(`span`,{className:`faint`,children:`(optional)`})]}),(0,X.jsx)(`input`,{autoFocus:!!e.address,value:o,onChange:e=>s(e.target.value),placeholder:`e.g. Design file`})]}),c&&(0,X.jsx)(`p`,{className:`error`,children:`Enter an http:// or https:// address.`}),(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!i.trim(),children:`Add link`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:r,children:`Cancel`})]})]})}function gq({initial:e,toggle:t,context:n,close:r}){return(0,X.jsx)(hq,{address:e??``,toggle:t,onAdd:(e,t)=>{r(),n.add({type:`link`,url:e},{title:t})},onCancel:r})}var _q=e=>[...new Set(e.links.flatMap(e=>dr(e)??[]))];async function vq(e,t,n){for(let[r,i]of _q(e).entries())await t.add({type:`link`,url:i},{at:n&&{x:n.x+r*40,y:n.y+r*40}})}function yq({block:e,name:t,pinId:n,onClose:r}){let i=qK(sr(e.url))?.editor;return i?(0,X.jsx)(i.Editor,{block:e,name:t,pinId:n,onClose:r}):null}var bq={type:`link`,copyText:e=>e.url,Body:()=>null,Card:({block:e,editing:t,setEditing:n,badges:r})=>(0,X.jsx)(fq,{block:e,editing:t,setEditing:n,badges:r}),Tools:mq,overlay:{Component:yq,changes:!0},opensOnPin:(e,t)=>!!qK(sr(e.url))?.editor?.opensPin(t),menu:{label:`Link`,icon:`link`,Form:gq,paste:e=>/^https?:\/\/\S+$/i.test(e)?dr(e):null},clips:{accepts:e=>_q(e).length>0,add:vq,useDrop:e=>wV(e,{matches:SR,what:`the link`,as:`a Link card`})}},xq;function Sq(){return xq??=cU(()=>import(`./viewer-BaxYd8Fo.js`),[]).catch(e=>{throw xq=void 0,e}),xq}var Cq=new Map,wq=new Map,Tq=e=>wq.get(e)?.();function Eq(e){try{return zr(e).facts}catch{return null}}function Dq(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 Oq=Math.PI/12;function kq({block:e,selected:t,placed:n}){let r=MR(),i=vH(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=yB(),[f,p]=(0,d.useState)(0),[m,h]=(0,d.useState)(`waiting`),g=Dq(a,!i.editing),_=vP(e=>e.transform[2]),v=Eq(e.scene),y=e.id;(0,d.useEffect)(()=>(wq.set(e.id,i.start),()=>void wq.delete(e.id)),[e.id,i.start]);let b=SH(r.draft,e.id,`spot`),x=Gr(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:nB,point:[b.x,b.y,b.z],object:b.object,name:Aq(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(),Cq.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`),Sq().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,Cq.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?Hr(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:Kr(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(-Oq,0),ArrowRight:()=>t.turn(Oq,0),ArrowUp:()=>t.turn(0,-Oq),ArrowDown:()=>t.turn(0,Oq),"+":()=>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,X.jsx)(Pq,{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,X.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 ${Wr(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(bH(e,l.current))return e.stopPropagation();if(!A||r.readOnly||xH(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,X.jsx)(`div`,{ref:o,className:`scene-view`}),A&&(0,X.jsx)(`div`,{className:`scene-spots`,children:S.map(e=>(0,X.jsx)(Mq,{spot:e,style:jq(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,X.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,X.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,X.jsx)(`path`,{d:`M3.5 6.5A4.75 4.75 0 1 1 3.4 9.6M3.25 3.5v3h3`})})}),!A&&(0,X.jsx)(Nq,{facts:v,shown:m})]})}function Aq(e,t){return t!==void 0&&e?Hr(e,t,t)?.name:void 0}function jq(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 Mq(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,X.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,X.jsx)(`span`,{className:`scene-spot-n`,children:t.n})})}function Nq({facts:e,shown:t}){let n=e?`three.js scene of ${Wr(e)}`:`three.js scene`;return t===`no-webgl`?(0,X.jsxs)(`div`,{className:`scene-standing`,role:`note`,children:[(0,X.jsx)(`p`,{children:`This browser can't draw 3D scenes: WebGL is off or unavailable.`}),(0,X.jsx)(`p`,{className:`scene-standing-about`,children:n})]}):typeof t==`object`?(0,X.jsxs)(`div`,{className:`scene-standing`,role:`alert`,children:[(0,X.jsxs)(`p`,{className:`scene-error`,children:[`The scene couldn't be drawn: `,t.error]}),(0,X.jsx)(`p`,{className:`scene-standing-about`,children:`Double-click to edit its JSON.`})]}):(0,X.jsx)(`div`,{className:`scene-standing`,"aria-busy":t===`loading`,children:(0,X.jsx)(`p`,{className:`scene-standing-about`,children:t===`loading`?`Drawing the scene…`:n})})}function Pq({block:e,edit:t}){let n=MR(),[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1),o=qr(e.scene);return(0,X.jsxs)(`div`,{className:`scene-source`,children:[(0,X.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{zr(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,X.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 Fq=3600;function Iq(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 Lq=(e,t)=>t!==void 0&&e?Hr(e,t,t)?.name:void 0;function Rq({block:e,placed:t,pointing:n,chosen:r,open:i,pick:a,openPin:o}){let s=MR(),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=Eq(e.scene),x=Gr(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:dV,point:[S.x,S.y,S.z],object:S.object,name:Lq(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;Sq().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),Fq);return()=>clearTimeout(e)},[v]);let k=t=>{let r=l.current;if(!n||!r?.shown||!c.current||bH(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?Hr(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:Kr(x,s.name)})},A=g===`shown`;return(0,X.jsxs)(`div`,{className:`scene-full-wrap`,children:[(0,X.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,X.jsx)(`div`,{ref:c,className:`scene-view`}),A&&(0,X.jsx)(`div`,{className:`scene-spots`,children:C.map(e=>(0,X.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:Iq(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,X.jsx)(`span`,{className:`scene-spot-n`,children:e.n})},e.key))}),A&&(0,X.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,X.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,X.jsx)(`path`,{d:`M3.5 6.5A4.75 4.75 0 1 1 3.4 9.6M3.25 3.5v3h3`})})}),!A&&(0,X.jsxs)(`div`,{className:`scene-standing`,role:typeof g==`object`?`alert`:void 0,"aria-busy":g===`loading`,children:[g===`no-webgl`?(0,X.jsx)(`p`,{children:`This browser can't draw 3D scenes: WebGL is off or unavailable.`}):typeof g==`object`?(0,X.jsxs)(`p`,{className:`scene-error`,children:[`The scene couldn't be drawn: `,g.error]}):(0,X.jsx)(`p`,{className:`scene-standing-about`,children:`Drawing the scene…`}),b&&(0,X.jsxs)(`p`,{className:`scene-standing-about`,children:[`three.js scene of `,Wr(b)]})]}),v&&(0,X.jsx)(`p`,{className:`scene-full-note`,role:`status`,children:v})]}),t.length>0&&(0,X.jsx)(`div`,{className:`scene-full-chips`,children:t.map(({pin:t})=>(0,X.jsx)(_z,{pin:t,open:t.id===i,part:Do(t,e),onToggle:()=>o(t.id)},t.id))})]})}function zq(e){if(!e.trim())return`A scene needs its JSON: write some, or discard your changes.`;try{return zr(e),null}catch(e){return`${e.message} Put it right, or discard your changes.`}}function Bq({block:e,name:t,version:n,pinId:r,onClose:i}){let a=Eq(e.scene),o=a?.named.length??0,s=a?`3D scene · ${o===1?`1 named object`:`${o.toLocaleString(`en-US`)} named objects`} · ${Wr(a)}`:`3D scene`;return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`scene`,className:`scene-full-view`,label:`3D scene ${e.title??``}`.trim(),icon:(0,X.jsx)(Q,{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,X.jsx)(Rq,{...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=>qr(e.scene),patch:e=>({scene:e}),check:zq},onClose:i})}function Vq({block:e,viewing:t}){let n=MR();return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`button`,{onClick:()=>Tq(e.id),title:`Edit the scene's three.js JSON (or double-click it)`,children:`Edit JSON`})]})}var Hq={type:`scene`,Body:kq,Tools:Vq,still:!0,overlay:{Component:Bq,refocus:!0},activate:(e,t)=>t.openOverlay(e.id),menu:{label:`3D scene`,icon:`scene`,add:()=>({content:{type:`scene`,scene:qr(jr)},title:`New scene`})}},Uq=e=>{let t=e;return!!t&&[t.x,t.y,t.w,t.h].every(e=>typeof e==`number`&&Number.isFinite(e))},Wq=(e,t=2e3)=>typeof e==`string`&&e.length<=t,Gq=e=>typeof e==`string`&&Zr(e)===e,Kq=e=>Array.isArray(e)&&e.length<=500&&e.every(e=>Wq(e,40));function qq(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 Gq(r.page)&&Wq(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||Uq(e))&&(r.chosen===null||Uq(r.chosen))&&typeof r.scrollY==`number`?r:null}case`found`:return Gq(r.page)&&Kq(r.found)&&Kq(r.lost)?r:null;case`select`:{let e=r.element,t=e&&Wq(e.selector,500)&&Wq(e.tag,40)&&Wq(e.text)&&Uq(e.rect),n=e&&(e.file===void 0||Wq(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 Jq=`allow-scripts allow-same-origin allow-forms allow-popups`;async function Yq(e){try{return{address:await bs(q.siteAddress)({blockId:e})}}catch(e){return{error:e.message}}}function Xq(e){let[t,n]=(0,d.useState)({}),[r,i]=(0,d.useState)(!1);(0,d.useEffect)(()=>{let t=!0;return Yq(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 Zq=`tricot:site-changed`,Qq=e=>window.dispatchEvent(new CustomEvent(Zq,{detail:e})),$q=(e,t)=>`${e.origin}${t.startsWith(`/`)?t:`/${t}`}`;function eJ(e,t,n){let r=(0,d.useRef)(n);r.current=n,(0,d.useEffect)(()=>{if(!t)return;let n=n=>{let i=qq(n,e.current?.contentWindow,t);i&&r.current(i)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)},[e,t])}function tJ(e,t,n){t&&e?.contentWindow?.postMessage({...n,tricot:`site`},t)}function nJ(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 rJ=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,X.jsxs)(`div`,{className:`site-failed nodrag${e?` is-full`:``}`,role:`alert`,children:[(0,X.jsx)(`p`,{children:`This website couldn't be shown here.`}),(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>this.setState({failed:!1}),children:`Try again`}),e&&(0,X.jsxs)(`button`,{className:`btn btn-small btn-quiet`,onClick:e,children:[(0,X.jsx)(Q,{name:`x`}),` Close`]})]})]})}},iJ=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`,aJ=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function oJ(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,X.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,X.jsxs)(`div`,{className:`pin-prompt-head`,children:[(0,X.jsx)(`p`,{className:`pin-prompt-quote`,children:oi(t.tag,t.text,t.selector)}),(0,X.jsx)(`button`,{type:`button`,className:`pin-prompt-close`,onClick:u,"aria-label":`Close`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(DT,{skills:!0,lenses:Hw,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,X.jsx)(`p`,{className:`pin-prompt-error`,role:`alert`,children:o}),(0,X.jsxs)(`div`,{className:`pin-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small btn-primary`,disabled:p||a,onClick:()=>l(!0),children:s?`Ask ${s}`:`Ask an agent`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:p||a,onClick:()=>l(!1),children:`Add a note`}),(0,X.jsx)(`kbd`,{className:`pin-prompt-keys`,title:`${iJ}+Enter asks ${s??`an agent`}`,children:iJ===`⌘`?`⌘↵`:`Ctrl ↵`})]}),(0,X.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 sJ(e){let{pin:t,open:n,part:r,lost:i,onToggle:a}=e,o=MR(),s=Fo(t,AR(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,X.jsxs)(`span`,{className:f.filter(Boolean).join(` `),"data-chip-pin":t.id,children:[(0,X.jsxs)(`button`,{type:`button`,className:`pin-chip-open`,onClick:a,"aria-expanded":n,title:`${p} the ${t.quote}: ${aJ(s.length,`comment`)}${m}${i?` (${i})`:``}`,children:[r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`pin-chip-part`,children:r}),i&&(0,X.jsx)(`span`,{className:`pin-chip-lost`,children:i}),(0,X.jsx)(Q,{name:`arrow-right`,className:`pin-chip-arrow`})]}),(0,X.jsx)(Q,{name:c?`check`:l?`edit`:`comment`,className:`pin-chip-icon`}),(0,X.jsx)(`span`,{className:`pin-chip-ref`,children:s.length}),c?(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`resolved`}):l&&u&&(0,X.jsx)(`span`,{className:`pin-chip-status`,children:`asked`}),d&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),!o.readOnly&&(0,X.jsx)(`button`,{type:`button`,className:`pin-chip-unpin`,onClick:async()=>{(!s.length||await pz(`this element`,s.length))&&o.removeItem(t.id)},"aria-label":`Unpin the ${t.quote}`,title:`Unpin. Its thread goes with it.`,children:(0,X.jsx)(Q,{name:`x`})})]})}function cJ({blockId:e}){let t=MR(),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=>Fo(e,AR(t)).some(e=>e.ask)).length,a=[i&&`${aJ(i,`request`)} to agents`,n.length-i&&aJ(n.length-i,`note`)].filter(Boolean).join(` and `);return(0,X.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,X.jsx)(Q,{name:i?`edit`:`comment`}),n.length,r.length>0&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]})}function lJ(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 uJ=96,dJ=14,fJ=e=>`pin`in e,pJ=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function mJ({groups:e,open:t}){let n=MR(),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(fJ).length,l=n.readOnly?0:dJ,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=lJ(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:uJ});o(e=>e.shown===c.shown&&e.squeeze===c.squeeze?e:c)};let f=s.map(e=>fJ(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(fJ),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)=>fJ(e)?(0,X.jsx)(sJ,{pin:e.pin,open:e.pin.id===t,part:e.part,lost:e.lost,onToggle:()=>(n??(e=>e.onToggle()))(e)},e.pin.id):(0,X.jsx)(`span`,{className:`faint small site-view-apart-heading`,children:e.heading},`#${e.heading}`);return(0,X.jsxs)(`div`,{className:`site-view-apart-row`,ref:r,children:[(0,X.jsx)(`div`,{className:`site-view-apart-chips${a.squeeze?` is-squeezed`:``}`,children:p.map(e=>v(e))}),m.length>0&&(0,X.jsx)(tb,{className:`site-view-apart-more`,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`summary`,{className:`site-view-apart-more-button${g?` is-open`:``}`,title:`${pJ(m.length,`more pinned element`)}${_?`, with new replies`:``}`,children:[m.length,` more`,_&&(0,X.jsx)(`span`,{className:`pin-chip-new`,"aria-label":`new replies`})]}),(0,X.jsx)(`div`,{className:`popover-body site-view-apart-list`,children:h.map(t=>(0,X.jsxs)(`section`,{"aria-label":t.label,children:[(0,X.jsx)(`h3`,{className:`faint small site-view-apart-heading`,children:t.label}),(0,X.jsx)(`ul`,{children:t.pins.map(t=>(0,X.jsx)(`li`,{children:v(t,t=>{e(),t.onToggle()})},t.pin.id))})]},t.label))})]})}),(0,X.jsx)(`div`,{className:`site-view-apart-copy`,"aria-hidden":!0,inert:!0,children:(0,X.jsxs)(`div`,{className:`site-view-apart-copy-line`,ref:i,children:[(0,X.jsxs)(`span`,{className:`site-view-apart-more-button`,children:[c,` more`,(0,X.jsx)(`span`,{className:`pin-chip-new`})]}),s.map(e=>v(e))]})})]})}var hJ=390,gJ=340,_J=230,vJ={count:12,ms:5e3},yJ=1500,bJ=1500,xJ=3e3,SJ=e=>e===`/`?`Home page`:e;function CJ(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-gJ-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 wJ({block:e,name:t,pinId:n,pinAsked:r,onClose:i}){let a=MR(),{seeItem:o,readOnly:s}=a,{address:c,error:l,blocked:u}=Xq(e.id),f=c?.origin,p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=XB(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,H]=(0,d.useState)({w:0,h:0}),[ne,re]=(0,d.useState)(null),ie=(0,d.useRef)(!1),ae=(0,d.useRef)({restored:!1}),oe=(0,d.useRef)([]),se=(0,d.useRef)(0),U=(0,d.useRef)(void 0);(0,d.useEffect)(()=>()=>clearTimeout(U.current),[]),(0,d.useEffect)(()=>{ie.current=!1,ae.current={restored:!1}},[C]);let W=a.pins.get(e.id),ce=(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 le=(0,d.useMemo)(()=>ce.filter(e=>e.anchor.kind===`site`&&e.anchor.page===y),[ce,y]),ue=(0,d.useMemo)(()=>ce.filter(e=>e.anchor.kind===`site`&&e.anchor.page!==y&&(!e.discussion?.resolved||e.id===z)),[ce,y,z]),de=(0,d.useMemo)(()=>nJ(le,y),[le,y]),fe=JSON.stringify(de);(0,d.useEffect)(()=>{let e=m.current;if(!e)return;let t=new ResizeObserver(()=>H({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[c]);let pe=(0,d.useRef)(null),me=e=>{pe.current={id:e,until:Date.now()+xJ},tJ(p.current,f,{type:`reveal`,id:e})},he=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!n)return;B(n);let e=ce.find(e=>e.id===n),t=e?.anchor.kind===`site`?e.anchor.page:y;t===y?ie.current?me(n):he.current=n:(he.current=n,ie.current=!1,w(e=>({page:t,n:e.n+1,scrollY:0})))},[n,r]);let ge=(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)&&Y.updateBlock(e.id,t,{page:n,pageTitle:r}).catch(()=>void 0)},yJ))};eJ(p,c?.origin,t=>{switch(t.type){case`ready`:{let e=Date.now();if(oe.current=[...oe.current.filter(t=>e-t<vJ.ms),e],oe.current.length>vJ.count)break;let n=t.page!==y;ie.current=!0,b(t.page),S(t.title),n&&(A(null),E({}),O([])),tJ(p.current,f,{type:`mode`,edit:g}),tJ(p.current,f,{type:`pins`,pins:nJ(ce,t.page)}),tJ(p.current,f,{type:`watch`}),ae.current.restored||(ae.current.restored=!0,C.scrollY&&tJ(p.current,f,{type:`scrollTo`,y:C.scrollY})),ge(t.page,t.title);break}case`rects`:{E(t.pins),M(t.chosen);let e=pe.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?pe.current=null:tJ(p.current,f,{type:`reveal`,id:e.id});break}case`found`:O(t.lost),he.current&&t.found.includes(he.current)&&(me(he.current),he.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-se.current<bJ)break;se.current=n,re(n),Qq(e.id),w(e=>({page:y,n:e.n+1,scrollY:t.scrollY}));break}}}),(0,d.useEffect)(()=>{ie.current&&tJ(p.current,f,{type:`mode`,edit:g}),g||(A(null),P(``),tJ(p.current,f,{type:`choose`,selector:null}))},[g]),(0,d.useEffect)(()=>{ie.current&&tJ(p.current,f,{type:`pins`,pins:JSON.parse(fe)})},[fe]),(0,d.useEffect)(()=>{if(!ne)return;let e=setTimeout(()=>re(null),2400);return()=>clearTimeout(e)},[ne]);let _e=(0,d.useCallback)(()=>{A(null),P(``),tJ(p.current,f,{type:`choose`,selector:null})},[f]);(0,d.useEffect)(()=>{let e=e=>{e.key!==`Escape`||tV()||(k?_e():z?B(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[k,z,i,_e]);let ve=()=>{ie.current=!1,w(e=>({page:y,n:e.n+1,scrollY:0}))},ye=e=>{e.anchor.kind===`site`&&(B(e.id),o(e.id),he.current=e.id,ie.current=!1,w(t=>({page:e.anchor.page,n:t.n+1,scrollY:0})))},be=e=>{B(t=>t===e?null:e),A(null),o(e)},G=e=>{if(e.anchor.kind===`site`){if(e.anchor.page!==y)return ye(e);B(e.id),A(null),o(e.id),me(e.id)}},xe=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 Y.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(``),tJ(p.current,f,{type:`choose`,selector:null})}catch(e){R(e.message)}finally{I(!1)}}},Se=e.title||x||Qr(e),Ce=ce.find(e=>e.id===z),we=Ce&&Ce.anchor.kind===`site`&&Ce.anchor.page===y?T[Ce.id]:null,Te=le.filter(e=>(D.includes(e.id)||e.anchor.gone)&&(!e.discussion?.resolved||e.id===z)),Ee=k&&j&&CJ(j,te,_,_J),De=Ce&&we?CJ(we,te,_,260):null,Oe=c&&$q(c,C.page),ke=e=>t=>(0,X.jsx)(UB,{pin:e,fallback:t}),Ae;Ae=l?(0,X.jsx)(`div`,{className:`site-view-state`,role:`status`,children:(0,X.jsx)(`p`,{children:l})}):u?(0,X.jsxs)(`div`,{className:`site-view-state`,role:`status`,children:[(0,X.jsx)(`p`,{children:`Tricot started showing websites after this page opened. Load the page again to show this one.`}),(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>location.reload(),children:`Load again`})]}):!c||!Oe?(0,X.jsxs)(`div`,{className:`site-view-state`,role:`status`,children:[(0,X.jsx)(`span`,{className:`connector-spinner`,"aria-hidden":!0}),`Opening the website…`]}):(0,X.jsx)(`div`,{className:`site-view-stage${_?` is-phone`:``}`,children:(0,X.jsxs)(`div`,{className:`site-view-screen`,ref:m,style:_?{width:hJ}:void 0,children:[(0,X.jsx)(`iframe`,{ref:p,name:`tricot-site`,src:Oe,title:Se,sandbox:Jq,referrerPolicy:`strict-origin-when-cross-origin`,onLoad:()=>{ie.current||E({})}},`${C.page}:${C.n}`),(0,X.jsxs)(`div`,{className:`site-view-marks`,"aria-hidden":!1,children:[le.map(e=>{let t=T[e.id];if(!t||e.discussion?.resolved&&e.id!==z)return null;let n=e.id===z;return(0,X.jsxs)(`div`,{children:[(0,X.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,X.jsx)(`span`,{className:`site-pin`,style:{left:Math.min(t.x+t.w,te.w-8),top:Math.max(t.y,12)},children:(0,X.jsx)(sJ,{pin:e,open:n,onToggle:()=>be(e.id)})})]},e.id)}),Ce&&De&&(0,X.jsx)(DB,{pin:Ce,block:e,name:t,above:De.above,style:{left:De.left,top:De.top,width:gJ},onClose:()=>B(null),live:ke(Ce),address:h.address},Ce.id),k&&Ee&&(0,X.jsx)(oJ,{element:k,style:{left:Ee.left,top:Ee.top,width:gJ},above:Ee.above,text:N,busy:F,error:L,agent:h.agent,onText:e=>{P(e),R(null)},onSubmit:e=>void xe(e),onClose:_e},k.selector)]})]})});let je=[...Te,...ue],Me=Ce&&je.includes(Ce)?Ce:void 0,Ne=h.agent,Pe=h.agents.find(e=>e.name===Ne);return(0,X.jsxs)(iV,{pairing:h,className:`site-view`,label:`Website ${Se}`,icon:(0,X.jsx)(Q,{name:`globe`}),title:Se,from:`${SJ(y)} · ${e.folder?`folder ${Qr({...e,title:void 0})}`:$r(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,X.jsxs)(X.Fragment,{children:[Ne?`Pairing with ${Ne}: click any part of the page to ask ${Ne} 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.`,Ne?` ${rV(Pe,Ne)}`:``]}),band:ne&&(0,X.jsx)(`div`,{className:`pair-band is-changed`,role:`status`,children:`The site's files changed: reloaded where you were.`}),controls:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`pair-segments`,role:`group`,"aria-label":`Width`,children:[(0,X.jsx)(`button`,{className:_?``:`is-on`,"aria-pressed":!_,onClick:()=>v(!1),"aria-label":`Desktop width`,title:`Desktop width`,children:(0,X.jsx)(Q,{name:`desktop`})}),(0,X.jsx)(`button`,{className:_?`is-on`:``,"aria-pressed":_,onClick:()=>v(!0),"aria-label":`Phone width`,title:`Phone width (${hJ}px)`,children:(0,X.jsx)(Q,{name:`phone`})})]}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:ve,"aria-label":`Reload`,title:`Reload the page`,children:(0,X.jsx)(Q,{name:`sync`})}),c&&(0,X.jsxs)(`a`,{className:`btn btn-small`,href:$q(c,y),target:`_blank`,rel:`noreferrer`,children:[`Open in a tab`,(0,X.jsx)(Q,{name:`external`})]})]}),open:z,onOpenRequest:G,onClose:i,children:[(0,X.jsx)(`div`,{className:`site-view-body`,children:Ae}),je.length>0&&(0,X.jsxs)(`footer`,{className:`site-view-apart`,children:[(0,X.jsx)(mJ,{open:z,groups:[{label:`No longer on this page`,pins:Te.map(e=>({pin:e,part:e.quote,lost:`not found`,onToggle:()=>be(e.id)}))},{label:`On other pages`,pins:ue.map(e=>({pin:e,part:`${SJ(e.anchor.page)} · ${e.quote}`,onToggle:()=>ye(e)}))}].filter(e=>e.pins.length>0)}),Me&&(0,X.jsx)(`div`,{className:`site-view-apart-thread`,children:(0,X.jsx)(DB,{inline:!0,pin:Me,block:e,name:t,onClose:()=>B(null),live:ke(Me),address:h.address},Me.id)})]})]})}var TJ=1280;function EJ({block:e,onTitle:t,onOpen:n}){let{address:r,error:i,blocked:a}=Xq(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(Zq,t),()=>window.removeEventListener(Zq,t)},[e.id]),eJ(s,r?.origin,e=>{e.type===`ready`&&t(e.title)});let p=c.w?c.w/TJ:0;return(0,X.jsx)(`div`,{className:`site-preview`,ref:o,onDoubleClick:n,title:`Double-click to open it`,children:i||a?(0,X.jsx)(`p`,{className:`site-preview-note`,children:i??`Load the page again to show this website.`}):r&&p>0?(0,X.jsx)(`iframe`,{ref:s,name:`tricot-site-preview`,src:$q(r,e.page),title:`${Qr(e)}, scaled down`,sandbox:Jq,tabIndex:-1,loading:`lazy`,referrerPolicy:`strict-origin-when-cross-origin`,style:{width:TJ,height:c.h/p,transform:`scale(${p})`}},`${e.page}:${u}`):(0,X.jsx)(`span`,{className:`site-preview-note`,children:`Opening the website…`})})}function DJ({block:e,badges:t}){let n=MR(),[r,i]=(0,d.useState)(``),a=()=>n.openOverlay(e.id),o=e.folder?`Folder`:`Dev server`,s=e.folder?Qr({...e,title:void 0}):e.url?new URL(e.url).host:``,c=r||ei(e,e.page)||Qr(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`block-head block-link block-site`,children:[(0,X.jsx)(`span`,{className:`site-icon`,"aria-hidden":!0,children:(0,X.jsx)(Q,{name:`globe`})}),(0,X.jsxs)(`div`,{className:`block-link-text`,children:[(0,X.jsx)(NR,{className:`block-link-title`,value:e.title||c,placeholder:`Untitled`,onCommit:t=>n.updateBlock(e,{title:t})}),(0,X.jsxs)(`span`,{className:`block-link-host`,children:[(0,X.jsx)(cJ,{blockId:e.id}),(0,X.jsx)(`span`,{className:`block-link-lead`,children:o}),(0,X.jsxs)(`span`,{className:`block-link-rest`,children:[` `,`· `,s,` · `,e.page===`/`?`home page`:e.page]})]})]}),(0,X.jsx)(`div`,{className:`block-link-actions nodrag`,onDoubleClick:e=>e.stopPropagation(),children:(0,X.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,X.jsx)(EJ,{block:e,onTitle:i,onOpen:a})]})}function OJ({block:e,viewing:t}){let n=MR(),{becomes:r}=wB();return t?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>n.openOverlay(e.id),children:`Open`}),(0,X.jsx)(`button`,{onClick:()=>n.startPin({blockId:e.id,part:{kind:`block`},quote:e.title||Qr(e)}),title:`Pin this website to ${r}`,children:`Pin`})]})}function kJ(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 AJ({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 Uc(!r.trim()&&!a.trim(),n,l,e),(0,X.jsxs)(`form`,{ref:l,className:`add-link add-site nodrag nopan nowheel`,onSubmit:e=>{e.preventDefault();let i=kJ(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,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{className:`field-label`,children:`Folder or local address`}),(0,X.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>{i(e.target.value),c(!1)},placeholder:`~/my-site or localhost:3000`,"aria-invalid":s})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`Title `,(0,X.jsx)(`span`,{className:`faint`,children:`(optional)`})]}),(0,X.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Marketing site`})]}),s&&(0,X.jsx)(`p`,{className:`error`,children:`Give a folder on this computer, or a dev server's address such as localhost:3000.`}),(0,X.jsx)(`p`,{className:`faint small`,children:`Shown live, from an address of its own: its scripts can't reach the board.`}),(0,X.jsxs)(`div`,{className:`row`,children:[(0,X.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:!r.trim(),children:`Add website`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:n,children:`Cancel`})]})]})}function jJ(e){let{block:t}=e;return(0,d.useEffect)(()=>()=>{Qq(t.id)},[t.id]),(0,X.jsx)(rJ,{onClose:e.onClose,children:(0,X.jsx)(wJ,{...e})})}var MJ={type:`site`,copyText:e=>e.url??e.folder,Body:()=>null,Card:e=>(0,X.jsx)(rJ,{children:(0,X.jsx)(DJ,{...e})}),Tools:OJ,overlay:{Component:jJ},opensOnPin:(e,t)=>t.anchor.kind===`site`,activate:(e,t)=>t.openOverlay(e.id),menu:{label:`Website`,icon:`globe`,Form:AJ}},NJ=/^((?:[ \t]*>[ \t]?)*[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]{1,4})+)\[([ \txX])\](?=[ \t]|$)/,PJ=/^(?:[ \t]*>[ \t]?)*[ \t]*(`{3,}|~{3,})(.*)$/,FJ=e=>e.endsWith(`\r`)?e.slice(0,-1):e;function IJ(e,t){let n=FJ(e),r=NJ.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 LJ(e){let t=e.split(`
|
|
85
|
-
`),n=[],r=null;return t.forEach((e,i)=>{let a=PJ.exec(FJ(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=IJ(e,i===t.length-1);o&&n.push({line:i+1,...o})}),n}function RJ(e){let t=LJ(e);return{done:t.filter(e=>e.done).length,total:t.length}}function zJ(e,t,n){let r=e.split(`
|
|
86
|
-
`),i=t-1;if(!Number.isInteger(i)||i<0||i>=r.length)return null;let a=IJ(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(`
|
|
87
|
-
`)}function BJ(e,t,n){let r=LJ(e).filter(e=>e.text===t.text);return r.length===0?null:zJ(e,r.reduce((e,n)=>Math.abs(n.line-t.line)<Math.abs(e.line-t.line)?n:e).line,n)}function VJ(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 HJ({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:nB,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,X.jsx)(_z,{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,X.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,X.jsx)(`div`,{className:`piece-scroll note-full-scroll`,children:(0,X.jsx)(`div`,{className:`piece-sheet note-full-sheet`,children:e.text.trim()?(0,X.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=hB(r,t);if(!n)return;i.removeAllRanges(),a({blockId:e.id,part:n,quote:n.quote});return}let o=VJ(t.clientX,t.clientY);if(!o||!r.contains(o.node)||(o.node.parentElement?.closest(`[data-pin-skip]`)??null))return;let{text:c,at:l}=vB(r),u=FR(c,l(o.node,o.offset)),d=u&&yo(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,X.jsx)(qy,{rehypePlugins:[[oB,{marks:l,ids:!0}]],components:u,children:e.text})}):(0,X.jsx)(`p`,{className:`note-full-empty placeholder`,children:`This note is empty.`})})})}function UJ({block:e,name:t,version:n,pinId:r,onClose:i}){let{done:a,total:o}=RJ(e.text),s=e.title||p(Co(e.text.split(`
|
|
88
|
-
`).find(e=>e.trim())??``).trim(),60)||`Note`,c=[o?`Note · ${a} of ${o} done`:`Note`,`changed by ${e.updatedBy.name} ${Yy(e.updatedAt)}`].join(` · `);return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`note`,className:`note-full-view`,label:`Note ${s}`,icon:(0,X.jsx)(Q,{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,X.jsx)(HJ,{...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,X.jsx)(qy,{children:e}):(0,X.jsx)(`p`,{className:`placeholder`,children:`Nothing written yet.`})},onClose:i})}function WJ({block:e,placed:t}){let n=MR(),r=vH(e.id),i=SH(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:nB,quote:i.quote,prefix:i.prefix,suffix:i.suffix}]:[]];return r.editing?(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.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=>!xH(e)&&bH(e,a.current)&&e.stopPropagation(),children:(0,X.jsx)(qy,{rehypePlugins:[[oB,{marks:o,focus:n.focusPin}]],components:yH,onTick:n.readOnly?void 0:(t,r)=>{let i=zJ(e.text,t,r);if(i===null||i===e.text)return;let a=LJ(e.text).find(e=>e.line===t);n.updateBlock(e,{text:i},a&&(e=>{let t=e.type===`note`?BJ(e.text,a,r):null;return t===null||e.type!==`note`||t===e.text?null:{text:t}}))},children:e.text})}),(0,X.jsx)(fB,{block:e,placed:t})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`block-note`,onDoubleClick:r.start,children:(0,X.jsx)(`p`,{className:`placeholder`,children:`Double-click to write`})}),(0,X.jsx)(fB,{block:e,placed:t})]})}function GJ({block:e}){let{done:t,total:n}=RJ(e.text);return n===0?null:(0,X.jsxs)(`span`,{className:`note-progress`,title:`${t} of ${n} tasks done`,children:[t,` of `,n,` done`]})}function KJ({block:e,viewing:t}){let n=MR();return(0,X.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 qJ={type:`note`,copyText:e=>e.text,Body:WJ,Head:GJ,ownPins:!0,Tools:KJ,overlay:{Component:UJ,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=>wV(e,{matches:CR,what:`the text`,as:`a Note`})},added:(e,t)=>!e.text&&t.edit(e.id)};function JJ(e,t,n){let r=t=>p(e.rows[t]?.[0]||`row ${t+1}`,40),i=t=>p(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])}: ${p(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 YJ(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 XJ(e){let t=MR(),n=yB(),[r,i]=(0,d.useState)(null),a=(0,d.useRef)(r);a.current=r;let o=t=>{let{rows:n,columns:r}=ZJ(t);return n?{blockId:e.id,part:{kind:`cells`,rows:n,columns:r},quote:JJ(e,n,r),cells:{rows:n,columns:r}}:{blockId:e.id,part:{kind:`cells`,columns:r},quote:JJ(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||xH(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 ZJ({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 QJ(e){let{block:t,selected:n,placed:r,pinnable:i=!0}=e,a=MR(),o=n&&!a.readOnly,s=XJ(t),c=SH(a.draft,t.id,`cells`),l=r.flatMap(({place:e})=>e?.kind===`cells`?[e]:[]),u=e=>{if(!i)return{};let t=s.drag?YJ(ZJ(s.drag),e):!!(c&&YJ(c,e)),n=l.some(t=>YJ(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&&!xH(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,X.jsxs)(`div`,{className:`block-table-wrap`,children:[(0,X.jsxs)(`table`,{className:`block-table nopan`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[t.columns.map((e,n)=>(0,X.jsxs)(`th`,{...u([-1,n]),children:[(0,X.jsx)(NR,{value:e,placeholder:`Column`,display:(0,X.jsx)(Jy,{children:e}),onCommit:e=>f(-1,n,e)}),o&&t.columns.length>1&&(0,X.jsx)(`button`,{className:`cell-remove nodrag`,onClick:()=>m(n),title:`Remove column`,"aria-label":`Remove column`,children:(0,X.jsx)(Q,{name:`x`})})]},n)),o&&(0,X.jsx)(`th`,{className:`table-add-col`,children:(0,X.jsx)(`button`,{className:`nodrag`,onClick:p,title:`Add column`,"aria-label":`Add column`,children:(0,X.jsx)(Q,{name:`plus`})})})]})}),(0,X.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,X.jsxs)(`tr`,{children:[e.map((e,t)=>(0,X.jsx)(`td`,{...u([n,t]),children:(0,X.jsx)(NR,{value:e,placeholder:``,display:(0,X.jsx)(Jy,{children:e}),onCommit:e=>f(n,t,e)})},t)),o&&(0,X.jsx)(`td`,{className:`table-row-remove`,children:(0,X.jsx)(`button`,{className:`nodrag`,onClick:()=>d(t.columns,t.rows.filter((e,t)=>t!==n)),title:`Remove row`,"aria-label":`Remove row`,children:(0,X.jsx)(Q,{name:`x`})})})]},n))})]}),(o||t.rows.length===0&&!a.readOnly)&&(0,X.jsxs)(`button`,{className:`block-add nodrag`,onClick:()=>d(t.columns,[...t.rows,t.columns.map(()=>``)]),children:[(0,X.jsx)(Q,{name:`plus`}),` Row`]})]})}var $J=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`;function eY(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 tY({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?WR(c.from,c.to):r?.part.kind===`cells`?r.part:null,p=t=>({blockId:e.id,part:{kind:`cells`,...t},quote:JJ(e,t.rows,t.columns)});(0,d.useEffect)(()=>{if(!c)return;let e=()=>{let e=u.current;l(null),e&&a(p(WR(e.from,e.to)))};return document.addEventListener(`mouseup`,e),()=>document.removeEventListener(`mouseup`,e)},[!!c]);let m=(e,t)=>{let n=s.filter(({range:t})=>GR(t,e)).map(({id:e})=>e),r=!!(f&&GR(f,e)),a=[...n,...r?[dV]:[]].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=eY(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&&eY(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=eY(e),r=t&&s.find(({range:e})=>GR(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,X.jsxs)(`div`,{className:`piece-scroll table-full-scroll`,children:[(0,X.jsx)(`div`,{className:`piece-sheet table-full-sheet`,children:e.columns.length===0?(0,X.jsx)(`p`,{className:`table-full-empty placeholder`,children:`This table is empty.`}):(0,X.jsxs)(`table`,{className:`block-table table-full${n?` is-pointing`:``}`,onMouseDown:h,onMouseOver:g,onClick:_,title:v,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`table-full-corner`,"aria-hidden":!0}),e.columns.map((e,t)=>(0,X.jsx)(`th`,{scope:`col`,...m([-1,t]),children:(0,X.jsx)(Jy,{children:e})},t))]})}),(0,X.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{scope:`row`,...m([t,-1],`table-full-num`),children:t+1}),e.map((e,n)=>(0,X.jsx)(`td`,{...m([t,n]),children:(0,X.jsx)(Jy,{children:e})},n))]},t))})]})}),t.length>0&&(0,X.jsx)(`div`,{className:`table-full-chips`,children:t.map(({pin:t})=>(0,X.jsx)(_z,{pin:t,open:t.id===i,part:Do(t,e),onToggle:()=>o(t.id)},t.id))})]})}function nY({block:e,name:t,version:n,pinId:r,onClose:i}){let a=`Table · ${$J(e.rows.length,`row`)}, ${$J(e.columns.length,`column`)}`;return(0,X.jsx)(mV,{block:e,name:t,version:n,pinId:r,part:`table`,className:`table-full-view`,label:`Table ${e.title??``}`.trim(),icon:(0,X.jsx)(Q,{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,X.jsx)(tY,{...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,X.jsx)(`div`,{className:`piece-scroll`,children:(0,X.jsx)(`div`,{className:`piece-sheet piece-edit-sheet table-edit-sheet`,children:(0,X.jsx)(QJ,{block:e,selected:!0,placed:[],pinnable:!1})})})},onClose:i})}function rY({block:e,viewing:t}){let n=MR();return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`button`,{onClick:()=>n.perform(t=>Y.deriveBlock(e.id,t)),title:`Make a bar chart of this table's numbers, next to it`,children:`Make a chart`})]})}function iY(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:JJ(t,a.rows,a.columns)}}function aY(e){return e.kind===`cells`?e.rows&&e.columns?`cells`:e.rows?`rows`:`columns`:`cells`}function oY({draft:e,block:t,onChange:n}){if(!e.cells)return null;let r=aY(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,X.jsx)(`div`,{className:`pin-scope`,role:`radiogroup`,"aria-label":`Pin`,children:a.map(i=>(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===i.value,className:r===i.value?`is-on`:void 0,onClick:()=>n(iY(e,t,i.value)),children:i.label},i.value))})}var sY={type:`table`,copyText:e=>OR(e.columns,e.rows),Body:QJ,Tools:rY,PinScope:oY,overlay:{Component:nY,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 cY(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 lY=()=>[qJ,sY,aq,SU,bq,BU,_H,SV,Hq,MJ],uY,dY=[];function fY(){return uY??=[...lY(),...dY]}function pY(e){let t=fY().find(t=>t.type===e);if(!t)throw Error(`No web half for block type "${e}".`);return t}var mY=[`note`,`table`,`diagram`,`code`,`chart`,`image`,`link`,`comparison`];function hY(){return cY(fY().filter(e=>e.menu),mY,e=>e.type)}var gY=140,_Y=16,vY=120;function yY({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}=tl(),y=bY(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(_Y,vY/Math.max(1,o-1));return(0,X.jsxs)(`div`,{className:a?`toolbar-add ${a}`:`toolbar-add`,ref:h,children:[(0,X.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,X.jsx)(`span`,{className:`toolbar-add-plus`,"aria-hidden":!0,children:(0,X.jsx)(Q,{name:e})}),(0,X.jsx)(`span`,{className:`toolbar-add-label`,children:t}),(0,X.jsx)(Q,{name:`chevron-down`,className:`toolbar-add-chevron`})]}),(f||y)&&(0,X.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,X.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 bY(e){let[t,n]=(0,d.useState)(e),[r,i]=(0,d.useState)(!1);return e!==t&&(n(e),i(!e&&!xY())),(0,d.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),gY);return()=>clearTimeout(e)},[r]),r}var xY=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function SY({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,X.jsx)(yY,{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,X.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,X.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,X.jsxs)(`span`,{className:`add-menu-row`,children:[(0,X.jsx)(Q,{name:r,className:`add-menu-icon`}),i]})},n);return(0,X.jsxs)(X.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,X.jsx)(`div`,{role:`separator`,className:`menu-rule add-menu-rule`,style:c(o.length)}),u(o.length+1,`group`,`group`,`Group`,l(()=>void i()))]})}})}ES.request;var CY=48,wY=[{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`}],TY=[/^(?: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],EY=/^(?: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,DY=/^(?:a|an|the|some)\b\s+/i,OY=/\s+(?:of|for|on|about|in) (?:the|this|our) (?:project|board|app|codebase|repo|work)(?=$|[\s,.;:!?])/gi,kY=/(?:[\s,.;:!?]+|\s+(?:please|for (?:me|us)|thanks|thank you))+$/i;function AY(e,t=[]){let n=qS(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 TY)i=i.replace(e,``)}if(i=i.replace(EY,``).replace(DY,``).replace(OY,``).replace(kY,``).trim(),i||=r.replace(/[\s.?!]+$/,``)||n,i=i.charAt(0).toUpperCase()+i.slice(1),i.length<=CY)return i;let a=i.slice(0,47),o=a.lastIndexOf(` `);return`${(o>CY/2?a.slice(0,o):a).replace(/[\s,.;:-]+$/,``)}…`}function jY(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 MY(e,t){return jY(e,t)?.canvas.groups.find(e=>e.id===t.groupId)}function NY(e){return e.status===`open`||e.status===`working`}function PY(e,t){return e.requests?.findLast(e=>e.groupId===t)}var FY=`tricot:open-thread`;function IY(e,t){window.dispatchEvent(new CustomEvent(FY,{detail:{id:e,thread:t}}))}function LY({board:e,name:t}){let n=_F(),[r,i,a]=vP(e=>e.transform),o=vP(e=>e.width),s=vP(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=>NY(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,X.jsxs)(`div`,{className:`ask-pending`,role:`status`,children:[u>0&&(0,X.jsxs)(`span`,{className:`ask-pending-more`,children:[u,` more waiting`]}),l.slice(-3).map(({request:n,show:r})=>(0,X.jsx)(RY,{board:e,request:n,name:t,onShow:r},n.id))]})}function RY(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=MY(t,n),p=e.title??(0,X.jsx)(`span`,{className:`request-title`,children:f?.title??AY(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`,_=[`${n.by.name} asked ${Yy(n.at)}: “${n.text}”`,n.status===`done`&&`${m.name} finished it ${Yy(n.doneAt)}${n.note?`: “${n.note}”`:``}`,n.status===`cancelled`&&`Cancelled ${Yy(n.doneAt)}`].filter(Boolean).join(`
|
|
89
|
-
`);return(0,X.jsxs)(`span`,{className:`request-chip is-${n.status}`,children:[(0,X.jsxs)(`span`,{className:`request-pill`,title:_,children:[n.status===`open`&&(0,X.jsx)(`span`,{className:`request-dot`,"aria-hidden":!0}),n.status===`working`&&(0,X.jsx)(`span`,{className:`looking-mark`,"aria-hidden":!0,children:m.name.charAt(0).toUpperCase()}),n.status===`done`&&(0,X.jsx)($y,{actor:m,showName:!1,title:_}),(0,X.jsxs)(`span`,{className:`request-text`,children:[p,` · asked by ${n.by.name} · ${h}`]}),n.status===`working`&&(0,X.jsx)(fw,{state:`casting`})]}),o&&(0,X.jsx)(`button`,{type:`button`,className:`request-action nodrag`,onClick:o,children:`Show`}),NY(n)&&!a&&(0,X.jsx)(`button`,{type:`button`,className:`request-action nodrag`,disabled:s,onClick:()=>{c(!0),Y.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,X.jsx)(`span`,{className:`request-error`,role:`alert`,children:l}),n.status===`working`&&i&&(0,X.jsxs)(`span`,{className:`request-ghost`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]})]})}function zY({thread:e,title:t}){let n=`Started by ${e.startedBy.name} ${Yy(e.startedAt)}: “${e.title}”`;return(0,X.jsxs)(`span`,{className:`request-chip is-done is-thread`,children:[(0,X.jsxs)(`span`,{className:`request-pill`,title:n,children:[(0,X.jsx)(Q,{name:`thread`}),(0,X.jsxs)(`span`,{className:`request-text`,children:[t,` · from a thread`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`request-action nodrag`,onClick:()=>IY(e.id,e),title:`Open the thread these came from`,children:`Open thread`})]})}function BY(e){return(0,X.jsx)(X.Fragment,{children:Nc().requestCards(e)})}var VY=`tricot:focus-block`,HY=null;function UY(e,t){HY={kind:e,id:t,at:Date.now()},window.dispatchEvent(new Event(VY))}var WY=e=>UY(`block`,e),GY=e=>UY(`pin`,e);function KY(e,t,n){let[r,i]=(0,d.useState)(0);(0,d.useEffect)(()=>{let e=()=>i(e=>e+1);return window.addEventListener(VY,e),()=>window.removeEventListener(VY,e)},[]),(0,d.useEffect)(()=>{HY&&Date.now()-HY.at>1e4&&(HY=null);let r=HY;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(()=>{HY===r&&(i()||e===0?HY=null:o(e-1))},100)};return o(30),()=>clearTimeout(a)},[r,e,t,n])}function qY(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 JY(e,t,n){(0,d.useEffect)(()=>{if(!n)return;let r=n=>{if(!n.clipboardData||bR(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(wR,ER([...i,...a].map(e=>e.id))),n.clipboardData.setData(`text/plain`,kR(fY(),a)))};return document.addEventListener(`copy`,r),()=>document.removeEventListener(`copy`,r)},[e,t,n])}function YY(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 XY({wrapper:e,flow:t,context:n,readOnly:r,clips:i,openForm:a,pasteBlocks:o}){let s=YY(e),c=fY().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||bR(e.target))return;let t=e.clipboardData,s=t&&DR(t);if(s){if(!i)return;e.preventDefault();let r=vR(t),a=yR(fY(),r);o(s).then(e=>{!e&&a&&a.clips.add(r,n)});return}let c=[...t?.files??[]],l=fY().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=vR(t),f=yR(fY(),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&&!bR(e.target);return{dropProps:{onDragOver:e=>{if(r||s.current)return;let t=xR(e);(t.includes(`Files`)||l(e)&&(SR(t)||CR(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 fY()){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=vR(e.dataTransfer),u=yR(fY(),o);u&&(e.preventDefault(),u.clips.add(o,n,i))}},overlays:c.map((e,t)=>(0,X.jsx)(d.Fragment,{children:e.overlay},t))}}function ZY(){let e=vP(e=>e.userSelectionActive);return(0,X.jsx)(kP,{position:`bottom-left`,className:e?`canvas-hint is-lit`:`canvas-hint`,children:`Hold Space to move`})}function QY(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);Uc(a,(0,d.useCallback)(()=>o(!1),[]),m),(0,d.useEffect)(()=>{if(!a)return;let e=!0;return Y.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 Y.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)):Y.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,X.jsxs)(`span`,{className:`block-version-wrap nodrag nopan`,ref:m,onDoubleClick:e=>e.stopPropagation(),children:[(0,X.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,X.jsxs)(`div`,{className:`menu-panel version-menu nowheel`,role:`menu`,"aria-label":`Earlier versions of this block`,ref:h,children:[(0,X.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,X.jsxs)(`div`,{className:`version-row`,role:`none`,children:[(0,X.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,X.jsxs)(`strong`,{children:[`v`,e.rev,` · `,r?`now`:Yy(e.at)]}),(0,X.jsx)(`span`,{children:e.by.name})]}),i&&!r&&(0,X.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,X.jsx)(Q,{name:`x`})})]},e.rev)}),i&&v>0&&(0,X.jsxs)(`div`,{className:`version-menu-foot`,role:`none`,children:[(0,X.jsxs)(`span`,{children:[v,` earlier`]}),(0,X.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,X.jsxs)(`p`,{className:`version-menu-note`,children:[s||l?`Click one to view it; Restore makes it current.`:`Loading…`,i&&v>0&&(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[` `,(0,X.jsx)(Q,{name:`x`}),` deletes it.`]})]}),l&&(0,X.jsx)(`p`,{className:`menu-error error`,role:`alert`,children:l})]})]}):null}function $Y(e){let{block:t,version:n,onDone:r}=e,i=MR(),[a,o]=(0,d.useState)(!1);return(0,X.jsxs)(`div`,{className:`version-band nodrag`,role:`status`,children:[(0,X.jsxs)(`span`,{title:`Made ${Yy(n.at)} by ${n.by.name}. Read-only.`,children:[`Viewing v`,n.rev]}),(0,X.jsxs)(`span`,{className:`version-band-actions`,children:[!i.readOnly&&(0,X.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,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:r,children:`Back to latest`})]})]})}var eX=[];function tX({id:e,data:t,selected:n}){let{block:r}=t,i=MR(),a=i.boardContext,o=sL(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=pY(r.type),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(null),v=(0,d.useMemo)(()=>g?be(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)??eX,S=(0,d.useMemo)(()=>x.map(e=>({pin:e,place:To(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=vP(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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(QY,{block:r,viewing:g?.rev??null,onView:_,onDelete:i.readOnly?void 0:e=>i.deleteVersions(r,e)}),l&&(0,X.jsx)(`span`,{className:`block-new`,title:`Changed by ${r.updatedBy.name} since you last looked`,children:`new`}),s&&(0,X.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,X.jsx)($y,{actor:r.updatedBy,showName:!1})]});return(0,X.jsxs)(`div`,{className:k.filter(Boolean).join(` `),"data-pin-draft":w?``:void 0,children:[(0,X.jsx)(lR,{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,X.jsxs)(hR,{isVisible:n&&!i.readOnly,position:$.Top,align:`end`,className:`node-toolbar`,children:[i.evidence.length>0&&(0,X.jsxs)(`select`,{value:r.optionId??``,onChange:e=>i.updateBlock(r,{optionId:e.target.value||null}),title:`Pin as evidence for an option`,children:[(0,X.jsx)(`option`,{value:``,children:`Not pinned to an option`}),i.evidence.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[`Evidence for `,e.id,`) `,e.label,e.outdated?` (outdated)`:``]},e.id))]}),p.Tools&&(0,X.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,X.jsx)(`button`,{onClick:()=>i.keep.run(D),title:i.keep.words.blockTitle(D.length),children:i.keep.words.label}),(0,X.jsx)(`button`,{onClick:()=>i.removeItem(e),children:`Delete`})]}),p.Card?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jR.Provider,{value:g?y:i,children:(0,X.jsx)(p.Card,{block:v,editing:u&&!g,setEditing:f,badges:(0,X.jsxs)(X.Fragment,{children:[!g&&C.map(e=>(0,X.jsx)(lB,{pin:e},e.id)),A]})})}),g&&(0,X.jsx)($Y,{block:r,version:g,onDone:()=>_(null)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`block-head`,children:[(0,X.jsx)(`span`,{className:`block-kind`,children:_i(r.type).label}),p.Title?(0,X.jsx)(p.Title,{block:v,placed:g?[]:S,frozen:!!g}):g?(0,X.jsx)(`span`,{className:`editable block-title`,children:v.title||(0,X.jsx)(`span`,{className:`placeholder`,children:`Untitled`})}):(0,X.jsx)(NR,{className:`block-title`,value:r.title??``,placeholder:`Untitled`,onCommit:e=>i.updateBlock(r,{title:e})}),p.Head&&(0,X.jsx)(p.Head,{block:v,placed:g?[]:S,frozen:!!g}),A]}),g&&(0,X.jsx)($Y,{block:r,version:g,onDone:()=>_(null)}),g?(0,X.jsx)(jR.Provider,{value:y,children:(0,X.jsx)(`div`,{className:`block-body${O}`,children:(0,X.jsx)(p.Body,{block:v,selected:!1,placed:[]},`v${g.rev}`)})}):(0,X.jsxs)(`div`,{className:`block-body${O}`,children:[(0,X.jsx)(p.Body,{block:r,selected:n,placed:S}),!p.ownPins&&(0,X.jsx)(fB,{block:r,placed:S})]})]}),(0,X.jsx)(WF,{type:`source`,position:$.Right,className:`block-handle`,title:`Drag to link`}),(0,X.jsx)(WF,{type:`target`,position:$.Left,isConnectableStart:!1,className:`block-target${o?` is-active`:``}`})]})}var nX=e=>bi().reduce((t,{kind:n})=>t+(e[`${n}Ids`]?.length??0),0);function rX({id:e,data:t,selected:n}){let r=MR(),i=r.boardContext,a=r.owner?void 0:PY(r.board,e),o=r.owner||a?void 0:hS(r.board,e),s=a??(o?_S(r.board,o):void 0),c=s?nX(s):0,l=(0,X.jsx)(NR,{className:`frame-title`,value:t.group.title,placeholder:`Group name`,onCommit:t=>t.trim()&&r.renameGroup(e,t)});return(0,X.jsxs)(`div`,{className:`frame${n?` is-selected`:``}${a?` is-request is-${a.status}`:``}${o?` is-thread`:``}`,children:[(0,X.jsx)(lR,{isVisible:n&&!r.readOnly,minWidth:240,minHeight:140,lineClassName:`resize-line`,handleClassName:`resize-handle`,onResizeEnd:(t,n)=>r.resize(e,n)}),(0,X.jsxs)(hR,{isVisible:n&&!r.readOnly,position:$.Top,align:`end`,className:`node-toolbar`,children:[r.keep&&t.members>0&&(0,X.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,X.jsx)(`button`,{onClick:()=>r.removeItem(e),title:`Blocks inside stay on the canvas`,children:`Ungroup`})]}),(0,X.jsxs)(`header`,{className:`frame-head`,children:[a?(0,X.jsx)(RY,{board:r.board,request:a,name:r.viewer,title:l,empty:t.members===0&&c===0,readOnly:r.readOnly}):o?(0,X.jsx)(zY,{thread:o,title:l}):l,(t.members>0||c===0)&&(0,X.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,X.jsx)(BY,{board:r.board,request:s})]})}function iX(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 aX(e){return{x:e.internals.positionAbsolute.x+(e.measured.width??0)/2,y:e.internals.positionAbsolute.y+(e.measured.height??0)/2}}function oX({id:e,source:t,target:n,markerEnd:r,data:i,selected:a}){let o=MR(),s=EL(t),c=EL(n),[l,u]=(0,d.useState)(!1),f=(0,d.useRef)(!1);if(!s||!c)return null;let p=iX(s,aX(c)),m=iX(c,aX(s)),[h,g,_]=MM({sourceX:p.x,sourceY:p.y,targetX:m.x,targetY:m.y}),v=i?.link.label??``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(wI,{id:e,path:h,markerEnd:r,className:a?`link-path is-selected`:`link-path`}),(v||a&&!o.readOnly||l)&&(0,X.jsx)(TL,{children:(0,X.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,X.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,X.jsx)(`span`,{className:`placeholder`,children:`Double-click to label`})})})]})}var sX=null,cX=new Set;function lX(e){let t=sX&&e&&sX.pageId===e.pageId&&sX.blockIds.join(`,`)===e.blockIds.join(`,`)&&sX.names.join(`
|
|
90
|
-
`)===e.names.join(`
|
|
91
|
-
`);if(t||!sX&&!e)t&&(sX=e);else{sX=e;for(let e of cX)e()}}var uX=e=>(cX.add(e),()=>void cX.delete(e));function dX(e){let t=(0,d.useSyncExternalStore)(uX,()=>sX);return e&&t?.pageId===e&&t.blockIds.length?t:null}var fX=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),pX=fX?`⌘Z`:`Ctrl Z`;function mX(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 Y.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 Y.restoreItem(r.id,e);t.length&&n.push(`${Ec(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]);gX(!!s,c);let l=e=>r(t=>t?.key===e?null:t);return{remove:o,removed:a,toast:n&&(0,X.jsx)(_X,{text:`deleted`in n?mX(n.deleted):n.note,onUndo:`deleted`in n?()=>void c():void 0,onGone:()=>l(n.key)},n.key)}}function gX(e,t){(0,d.useEffect)(()=>{if(!e)return;let n=e=>{e.key.toLowerCase()!==`z`||e.altKey||e.shiftKey||!(fX?e.metaKey:e.ctrlKey)||Hc(e.target)||(e.preventDefault(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function _X({text:e,onUndo:t,onGone:n}){let r=(0,d.useRef)(null);return xX(r,n),(0,X.jsxs)(`div`,{ref:r,className:`undo-toast${t?``:` is-note`}`,role:`status`,children:[(0,X.jsx)(`span`,{className:`undo-toast-text`,children:e}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`undo-toast-undo`,onClick:t,children:`Undo`}),(0,X.jsx)(`kbd`,{className:`undo-toast-key`,"aria-label":`or press ${pX}`,children:pX})]}),(0,X.jsx)(`button`,{type:`button`,className:`undo-toast-close`,onClick:n,"aria-label":`Dismiss`,title:`Dismiss (Esc)`,children:(0,X.jsx)(Q,{name:`x`})}),(0,X.jsx)(`span`,{className:`undo-toast-bar`,"aria-hidden":`true`,children:(0,X.jsx)(`i`,{onAnimationEnd:n})})]})}var vX=`[role="dialog"], [role="alertdialog"]`,yX=e=>Yc(e)||document.querySelector(vX)!==null,bX=[];function xX(e,t){let n=(0,d.useRef)(t);n.current=t,(0,d.useEffect)(()=>{bX.push(e);let t=new WeakSet,r=e=>{e.key===`Escape`&&yX(e)&&t.add(e)},i=r=>{r.key!==`Escape`||r.defaultPrevented||t.has(r)||Hc(r.target)||bX.at(-1)!==e||(r.preventDefault(),n.current())},a=document.documentElement;return window.addEventListener(`keydown`,r,!0),a.addEventListener(`keydown`,i),()=>{bX.splice(bX.indexOf(e),1),window.removeEventListener(`keydown`,r,!0),a.removeEventListener(`keydown`,i)}},[e])}var SX={block:tX,frame:rX},CX={link:oX},wX={hideAttribution:!0},TX=4e3;function EX(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 DX(e){return e.links.map(e=>({id:e.id,source:e.from,target:e.to,type:`link`,data:{link:e},markerEnd:{type:Sj.ArrowClosed,width:16,height:16,color:`var(--muted)`}}))}var OX=new Set,kX=[],AX={maxZoom:1,padding:.15},jX={maxZoom:1,padding:{x:.15,top:.15,bottom:`120px`}},MX=[`Meta`,`Control`,`Shift`],NX=[1,2],PX=`Space`,FX=()=>{},IX=380,LX=230,RX=320,zX=2400;function BX(e,t,n,r=IX,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 VX={width:420,height:40},HX=96;function UX(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 BX(e,r.length?r:[n],LX)}function WX(e,t,n){let r=e.querySelector(`[data-chip-pin="${CSS.escape(t)}"]`);return r?BX(e,[r],n):null}function GX(e){return(0,X.jsx)(yL,{children:(0,X.jsx)(KX,{...e})})}function KX(e){let{board:t,page:n,name:r,emptyNote:i,evidence:a=kX,highlightOption:o=null,newItems:s=OX,onSeeItem:c=FX,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=ol(),C=_F(),w=(0,d.useRef)(null),T=(0,d.useRef)(new Map),[E,D]=(0,d.useState)(()=>EX(_)),[O,k]=(0,d.useState)(()=>DX(_)),[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)(RX),[H,ne]=(0,d.useState)(null),[re,ie]=(0,d.useState)(null),ae=vP(e=>e.transform),[oe,se]=(0,d.useState)(null),U=$H(),W=(0,d.useRef)(new Map),ce=(0,d.useCallback)(e=>se(e instanceof Error?e.message:String(e)),[]),{remove:le,removed:ue,toast:de}=hX(r,ce),fe=(0,d.useCallback)(async(e,n,i)=>{try{await Y.updateBlock(e.id,r,{...n,rev:e.rev})}catch(n){if(!i||n.status!==409)throw n;let a=Mo(await Y.board(t.id)).flatMap(({canvas:e})=>e.blocks).find(t=>t.id===e.id),o=a&&i(a);o&&await Y.updateBlock(e.id,r,{...o,rev:a.rev})}},[t.id,r]);(0,d.useEffect)(()=>{if(!oe)return;let e=setTimeout(()=>se(null),4e3);return()=>clearTimeout(e)},[oe]);let pe=e=>{let t=Date.now()+TX;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 EX(_).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 DX(_).map(e=>t.has(e.id)?{...e,selected:!0}:e)})},[_]);let me=(0,d.useCallback)(e=>D(t=>$P(e,t)),[]),ge=(0,d.useCallback)(e=>k(t=>eF(e,t)),[]),_e=vb().boardContext(),ve=!g&&!n,be=ve&&!S,G=(0,d.useMemo)(()=>E.filter(e=>e.selected&&e.type===`block`).map(e=>e.id),[E]),xe=(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)}))},[]),Se=(0,d.useCallback)(()=>xe([]),[xe]),Ce=(0,d.useMemo)(()=>({board:t,name:r,select:xe,report:ce}),[t,r,xe,ce]),we=!!n&&!S,Te=(0,d.useMemo)(()=>{if(!we)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(`,`)},[we,E,_]),Ee=(0,d.useMemo)(()=>Te?Te.split(`,`):[],[Te]),De=(0,d.useMemo)(()=>{let e=new Set(Ee);return _.blocks.filter(t=>e.has(t.id)).map(e=>ye(e,60)).join(`
|
|
92
|
-
`)},[Ee,_]),Oe=n?.id;(0,d.useEffect)(()=>{if(Oe)return lX(Ee.length?{pageId:Oe,blockIds:Ee,names:De.split(`
|
|
93
|
-
`),clear:Se}:null),()=>lX(null)},[Oe,Ee,De,Se]);let[ke,Ae]=(0,d.useState)(null),[je,Me]=(0,d.useState)(null),Ne=(0,d.useRef)(!1);(0,d.useEffect)(()=>{ke&&ke.blockIds.join(`,`)!==Te&&Ae(null)},[ke,Te]);let Pe=_e?.keep,Fe=(0,d.useCallback)(e=>{let t=new Set(e),r=_.blocks.filter(e=>t.has(e.id)).map(e=>e.id);n&&Pe&&!Ne.current&&r.length!==0&&(Ne.current=!0,Pe.run({...Ce,page:n,blockIds:r}).then(e=>{Ae(e),xe(e.blockIds)},ce).finally(()=>{Ne.current=!1}))},[n,Pe,_,Ce,ce,xe]),Ie=(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]),Le=(0,d.useCallback)(e=>{for(let t of C.getNodes()){if(t.type!==`frame`)continue;let n=Ie(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,Ie]),Re=(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=Ie(e.id),n=Le({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}}})),pe(i.map(e=>e.id)),Y.moveItems(x,r,i).catch(ce)},[Ie,Le,x,r,ce]),ze=(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});pe(n.map(e=>e.id)),Y.moveItems(x,r,n).catch(ce)},[C,x,r,ce]),Be=(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)),ze(e,{x:n.position.x,y:n.position.y,width:t.w,height:t.h}))},[C,ze]),[Ve,He]=(0,d.useState)(null),Ue=(0,d.useRef)(0),We=(0,d.useCallback)((e,t={})=>{let n=_.blocks.find(t=>t.id===e),r=n&&pY(n.type).overlay;r&&!(S&&r.changes)&&He({blockId:e,...t,...t.pinId?{pinAsked:++Ue.current}:{}})},[_,S]),Ge=(0,d.useCallback)(()=>{let e=Ve?.blockId,t=e&&_.blocks.find(t=>t.id===e);He(null),e&&e===f&&p?.(),e&&t&&pY(t.type).overlay?.refocus&&(w.current?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`))?.focus({preventScroll:!0})},[Ve,_,f,p]),Ke=(0,d.useRef)(void 0);(0,d.useEffect)(()=>{f&&Ke.current!==f&&_.blocks.some(e=>e.id===f)&&(Ke.current=f,Ve||We(f))},[f,_,Ve,We]),(0,d.useEffect)(()=>{Ve&&!_.blocks.some(e=>e.id===Ve.blockId)&&He(null)},[Ve,_]);let qe=(0,d.useRef)(!1),Je=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&&pY(n.type).activate;n&&r&&(e.preventDefault(),(e.key===`Enter`||e.type===`keyup`&&!qe.current)&&r(n,ht))},Ye=e=>{e.key===` `&&(qe.current=e.repeat),(e.key===`Enter`||e.key===` `)&&Je(e)},Xe=e=>{e.key===` `&&Je(e)},Ze=()=>{qe.current=!0},Qe=qY(E),$e=qP(l?null:PX),et=(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 le([...n,...r.map(e=>e.id)]),!1},[le]),tt=(0,d.useCallback)(({source:e,target:t})=>{e&&t&&e!==t&&Y.addLink(r,e,t).catch(ce)},[r,ce]),nt=()=>{let e=w.current.getBoundingClientRect();return C.screenToFlowPosition({x:e.left+e.width/2,y:e.top+e.height/2})},rt=(e,t)=>{let n=e.x-t.w/2,r=e.y-t.h/2,i=(e,t)=>C.getNodes().some(n=>{let r=Ie(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=Le(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)}},it={add:async(e,t={})=>{let{at:n,title:i}=t,a=_i(e.type),o=t.size??a.sizeFor?.(e,{})??a.defaultSize;try{let t=rt(n??nt(),o),a=await Y.addBlock(x,r,{content:e,title:i,...t,w:o.w,h:o.h});pY(e.type).added?.(a,{edit:j})}catch(e){ce(e)}},report:ce},at=e=>{let t=T.current.get(e);return t||T.current.set(e,t=(0,d.createRef)()),t},ot=async()=>{try{let{x:e,y:t}=rt(nt(),he);await Y.addGroup(x,r,{title:`New group`,x:e,y:t,w:he.w,h:he.h})}catch(e){ce(e)}},{dropProps:st,overlays:ct}=XY({wrapper:w,flow:C,context:it,readOnly:S||l,clips:!Ve,openForm:(e,t)=>N({type:e,initial:t}),pasteBlocks:async({ids:e})=>{try{return await Y.pasteBlocks(x,r,{ids:e,at:nt()}),!0}catch(e){return ce(e),e.status!==404}}});JY(_,(0,d.useMemo)(()=>E.filter(e=>e.selected).map(e=>e.id),[E]),!Ve&&!l),(0,d.useEffect)(()=>{let e=null,t=!1,n=n=>{let r=n.target,i=!!(r&&w.current?.contains(r));e=i?gB(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=_B(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?UX(w.current,P.blockId):null)},[P,ae,_]),(0,d.useEffect)(()=>{P&&!_.blocks.some(e=>e.id===P.blockId)&&F(null)},[P,_]);let lt=(0,d.useCallback)(()=>F(null),[]);(0,d.useLayoutEffect)(()=>{ee(R&&w.current?WX(w.current,R,V):null)},[R,ae,_,V]),(0,d.useEffect)(()=>{R&&!_.pins.some(e=>e.id===R)&&z(null),H&&_.pins.some(e=>e.id===H)&&(z(H),ne(null))},[R,H,_]);let ut=(0,d.useCallback)(()=>z(null),[]),dt=!!ke&&!P&&!R&&!Ve&&!E.some(e=>e.dragging);(0,d.useLayoutEffect)(()=>{let e=w.current;if(!dt||!ke||!e)return Me(null);let t=ke.blockIds.flatMap(t=>e.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`)??[]);Me(t.length?BX(e,t,VX.height,VX.width,HX,!0):null)},[dt,ke,ae,E]);let ft=(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&&pY(n.type).opensOnPin?.(n,t)&&We(n.id,{pinId:t.id}),C.fitView({nodes:[{id:t.blockId}],duration:400,maxZoom:1,padding:.3}),ie(null),requestAnimationFrame(()=>ie(t.id))};return window.addEventListener($z,e),()=>window.removeEventListener($z,e)},[_,C,We]),(0,d.useEffect)(()=>{if(!re)return;let e=setTimeout(()=>ie(null),zX);return()=>clearTimeout(e)},[re]),KY(_,(0,d.useCallback)(e=>C.getInternalNode(e)?.measured.width?(C.fitView({nodes:[{id:e}],duration:400,maxZoom:1,padding:.3}),xe([e]),!0):!1,[C,xe]),(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 pY(t.type).opensOnPin?.(t,e)||Ve?.blockId===t.id&&!Ve.version?(n&&r(),c(e.id),We(t.id,{pinId:e.id}),!0):n?(r(),c(e.id),He(null),ie(null),requestAnimationFrame(()=>ie(e.id)),e.discussion&&(F(null),z(e.id)),!0):!1},[_,C,c,We,Ve]));let pt=(0,d.useCallback)((e,t)=>{e.discussion?.thread?ne(e.id):tB([t.id])},[]),mt=(0,d.useMemo)(()=>{let e=new Map;for(let t of _.pins)e.set(t.blockId,[...e.get(t.blockId)??[],t]);return e},[_]),ht=(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 fe(e,t,n).catch(ce),restoreBlock:(e,t)=>Y.restoreBlock(e.id,r,t,e.rev).then(()=>!0,e=>(ce(e),!1)),deleteVersions:(e,t)=>(t===void 0?Y.deleteEarlierVersions(e.id,r):Y.deleteVersion(e.id,r,t)).then(({deleted:e})=>(ue([e]),!0),e=>(ce(e),!1)),openLink:(e,t)=>void Y.updateBlock(e.id,r,{open:t}).catch(ce),openOverlay:We,newItems:s,seeItem:c,resize:ze,setSize:Be,renameGroup:(e,t)=>void Y.renameGroup(e,r,t).catch(ce),relabelLink:(e,t)=>void Y.relabelLink(e,r,t).catch(ce),removeItem:e=>le([e]),perform:e=>void e(r).catch(ce),pins:mt,draft:P,startPin:e=>{S||(z(null),F(e))},focusPin:re,thread:R,openThread:ft,boardContext:_e&&ve?{slot:_e,tools:Ce}:void 0,keep:we&&Pe?{words:Pe,run:Fe}:void 0}),[t,g,a,n,S,o,A,r,ce,ze,s,c,mt,P,re,R,ft,_e,ve,Ce,we,Pe,Fe,le,ue,Be,We,fe]),gt=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(SY,{owner:m,context:it,toggleOf:at,setForm:N,addGroup:ot}),M&&(()=>{let e=pY(M.type).menu;return!e||!(`Form`in e)?null:(0,X.jsx)(e.Form,{initial:M.initial,toggle:at(M.type),context:it,close:()=>N(null)},M.initial??``)})()]}),_t=!S,vt=_.blocks.length===0&&_.groups.length===0,yt=i??(n?`A canvas for “${n.title}”, to think it through with agents.`:void 0),bt=R?_.pins.find(e=>e.id===R):void 0,xt=Ve?_.blocks.find(e=>e.id===Ve.blockId):void 0,St=xt&&pY(xt.type).overlay;return(0,X.jsx)(jR.Provider,{value:ht,children:(0,X.jsxs)(`div`,{ref:w,className:S?`canvas is-read-only`:`canvas`,...st,onKeyDown:Ye,onKeyUp:Xe,onPointerDownCapture:e=>{Ze(),Qe.onPointerDownCapture(e)},onPointerUpCapture:Qe.onPointerUpCapture,onPointerCancelCapture:Qe.onPointerCancelCapture,onWheelCapture:Ze,children:[(0,X.jsxs)(CL,{nodes:Qe.nodes,edges:O,nodeTypes:SX,edgeTypes:CX,onNodesChange:me,onEdgesChange:ge,onNodeDragStop:Re,onBeforeDelete:et,onConnect:tt,isValidConnection:e=>e.source!==e.target,colorMode:U.base,fitView:!0,fitViewOptions:v?jX:AX,minZoom:.15,maxZoom:4,panOnScroll:!0,panOnDrag:NX,panActivationKeyCode:l?null:PX,selectionOnDrag:!0,selectionMode:yj.Partial,zoomOnDoubleClick:!1,multiSelectionKeyCode:MX,nodesDraggable:!S&&!$e,nodesConnectable:!S,deleteKeyCode:S||l?null:[`Backspace`,`Delete`],proOptions:wX,children:[(0,X.jsx)(NL,{variant:kL.Dots,gap:22,size:1.2}),(0,X.jsx)(HL,{showInteractive:!1,fitViewOptions:v?jX:AX}),(0,X.jsx)(ZY,{}),(u!==void 0||_t)&&(0,X.jsxs)(kP,{position:`top-left`,className:`canvas-toolbar is-add`,children:[u,_t&&(u===void 0?gt:(0,X.jsx)(`div`,{className:`canvas-toolbar-add`,children:gt}))]}),(oe||be||de)&&(0,X.jsxs)(kP,{position:`bottom-center`,className:`canvas-bottom`,children:[oe&&(0,X.jsx)(`div`,{className:`canvas-error`,role:`alert`,children:oe}),de,_e&&be&&G.length>1&&_e.selection({...Ce,blockIds:G}),be&&(0,X.jsx)(LY,{board:t,name:r})]})]}),P&&I&&(0,X.jsx)(EB,{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:lt,onCommented:pt}),bt&&B&&(0,X.jsx)(DB,{pin:bt,block:_.blocks.find(e=>e.id===bt.blockId),name:r,style:{left:B.left,top:B.top,width:B.width},above:B.above,onClose:ut,onHeight:te},bt.id),dt&&ke&&je&&ke.notice({style:{left:je.left,top:je.top,maxWidth:je.width},above:je.above}),Ve&&xt&&St&&!(S&&St.changes)&&(0,X.jsx)(St.Component,{block:xt,name:r,version:Ve.version,pinId:Ve.pinId,pinAsked:Ve.pinAsked,onClose:Ge},xt.id),ct,vt&&(0,X.jsxs)(`div`,{className:`canvas-empty`,children:[yt&&(0,X.jsx)(`p`,{children:yt}),!S&&(0,X.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,X.jsx)(`code`,{children:`add_block`}),`.`]})]})]})})}var qX={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`},JX=e=>{let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``},YX=e=>qX[JX(e)];function XX(e){let t=JX(e);if(t===`md`||t===`markdown`)return`markdown`;if(t===`mmd`||t===`mermaid`)return`mermaid`;if(t===`csv`||t===`tsv`)return`table`;if(qX[t])return`image`}var ZX=e=>XX(e)!==`image`||JX(e)===`svg`;function QX(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===`
|
|
94
|
-
`||s===`\r`?(s===`\r`&&e[o+1]===`
|
|
95
|
-
`&&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 Y.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,kc.createPortal)((0,X.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!s&&n(),children:(0,X.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 Ds(e.id,t,{folder:a.trim()||null}),n()}catch(e){u(e.message),c(!1),i.current?.querySelector(`input`)?.focus()}}},children:[(0,X.jsx)(`h2`,{id:`${r}-title`,children:`Project folder`}),(0,X.jsx)(`p`,{children:`The folder this board is about, on this computer.`}),(0,X.jsx)(`label`,{className:`delete-label`,htmlFor:`${r}-folder`,children:`Folder`}),(0,X.jsxs)(`div`,{className:`folder-field`,children:[(0,X.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,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void m(),disabled:s||f,title:`Open this computer's folder dialog`,children:f?`Choosing…`:`Choose…`})]}),(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:l}),(0,X.jsxs)(`div`,{className:`delete-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,disabled:s,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:s,children:`Save`})]})]})}),document.body)}var eZ=e=>e.slice(e.lastIndexOf(`/`)+1);function tZ(e,t){let n=0;for(let r of t){if(n=e.indexOf(r,n),n<0)return!1;n++}return!0}function nZ(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.toLowerCase(),i=eZ(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(`/`)&&tZ(i,n))return 30;if(tZ(r,n))return 10}var rZ=50;function iZ(e,t){let n=e.flatMap(e=>{let n=nZ(e.path,t);return n===void 0?[]:[{file:e,score:n}]});return n.some(e=>e.score>=rZ)?n.filter(e=>e.score>=rZ):n}function aZ(e,t,n,r){let i=e.filter(e=>(n!==`week`||e.week)&&(n!==`board`||r.has(e.path)));return t.trim()?iZ(i,t).map(e=>e.file):i}function oZ(e,t,n){return iZ(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 sZ(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)=>eZ(e.path)<eZ(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 cZ(e){let t=e.split(`/`).slice(0,-1);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function lZ(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:uZ(n),on:t});else if(n.type===`diff`)for(let e of n.files)r(e.path,{kind:`diff`,blockId:n.id,title:uZ(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[...bi()].reverse())for(let n of Ci(e,t))i(n.canvas,{[`${t}Id`]:n.id,number:n.number,title:n.title});return n}var uZ=e=>e.title||(e.type===`code`?e.path:`Diff`);function dZ(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 fZ=2e3;function pZ({board:e,file:t,kind:n,text:r}){return n===`markdown`?(0,X.jsx)(mZ,{board:e,file:t,text:r}):n===`mermaid`?(0,X.jsx)(`div`,{className:`files-diagram`,children:(0,X.jsx)(hU,{source:r})}):(0,X.jsx)(gZ,{file:t,text:r})}function mZ({board:e,file:t,text:n}){let r=(0,d.useMemo)(()=>({picture:n=>{let r=dZ(t,n);return r&&YX(r)?Rt(q.projectImage,{boardId:e.id},{path:r}):void 0},link:n=>{let r=dZ(t,n);return r?db.files(e.id,r):void 0}}),[e.id,t]);return(0,X.jsx)(`article`,{className:`files-doc`,children:(0,X.jsx)(qy,{beside:r,children:n})})}var hZ=/^[-+]?[\d.,]+%?$|^[-+]?[$£€]\s?[\d.,]+$/;function gZ({file:e,text:t}){let n=(0,d.useMemo)(()=>QX(t,e.toLowerCase().endsWith(`.tsv`)?` `:`,`),[t,e]);if(!n.length)return(0,X.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]||hZ.test(e[t].trim()))&&i.some(e=>e[t]));return(0,X.jsxs)(`div`,{className:`files-table`,children:[(0,X.jsxs)(`table`,{className:`block-table`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:o(r).map((e,t)=>(0,X.jsx)(`th`,{className:s[t]?`is-number`:void 0,children:e},t))})}),(0,X.jsx)(`tbody`,{children:i.slice(0,fZ).map((e,t)=>(0,X.jsx)(`tr`,{children:o(e).map((e,t)=>(0,X.jsx)(`td`,{className:s[t]?`is-number`:void 0,children:e},t))},t))})]}),(0,X.jsxs)(`p`,{className:`files-table-count`,children:[i.length.toLocaleString(`en-US`),` `,i.length===1?`row`:`rows`,` · `,a,` `,a===1?`column`:`columns`,i.length>fZ&&`, the first ${fZ.toLocaleString(`en-US`)} shown`]})]})}function _Z({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=Rt(q.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,X.jsx)(`p`,{className:`files-note is-error`,children:s}):(0,X.jsxs)(`figure`,{className:`files-picture${a?` is-actual`:``}`,children:[(0,X.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,X.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,X.jsxs)(`figcaption`,{children:[r.width,` × `,r.height,a?` · actual size`:``]})]})}var vZ=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),yZ=vZ?`⌘P`:`Ctrl P`,bZ=vZ?`Meta+P`:`Control+P`,xZ=`tricot:find-file`,SZ=vZ?`⌘\\`:`Ctrl \\`,CZ=vZ?`Meta+\\`:`Control+\\`,wZ=e=>e.key===`\\`&&!e.altKey&&!e.shiftKey&&(vZ?e.metaKey:e.ctrlKey),TZ=!1;function EZ(){let e=TZ;return TZ=!1,e}function DZ(e,t){(0,d.useEffect)(()=>{if(!t)return;let n=t=>{t.key.toLowerCase()!==`p`||t.altKey||t.shiftKey||!(vZ?t.metaKey:t.ctrlKey)||(t.preventDefault(),TZ=!0,window.dispatchEvent(new Event(xZ)),Cb.files(e))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function OZ(e){(0,d.useEffect)(()=>{EZ()&&e();let t=()=>{EZ(),e()};return window.addEventListener(xZ,t),()=>window.removeEventListener(xZ,t)},[e])}var kZ=1500,AZ=4e3,jZ=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,MZ=e=>e.slice(e.lastIndexOf(`/`)+1),NZ=e=>e.folder,PZ={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 FZ({board:e,name:t,file:n,pair:r,onShown:i}){let a=NZ(e),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(`all`),[_,v]=(0,d.useState)(new Set),y=ol(),[b,x]=(0,d.useState)(!1),S=(0,d.useRef)(null),C=(0,d.useRef)(null),w=(0,d.useRef)(null),[T,E]=Vc(`tricot:files-tree`,()=>!0),[D,O]=Vc(`tricot:files-side`,()=>!0),[k,A]=(0,d.useState)(!1),j=T||k;OZ((0,d.useCallback)(()=>{A(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>w.current?.select()))},[])),(0,d.useEffect)(()=>{let e=e=>{if(!wZ(e))return;e.preventDefault();let t=!(T||D);E(t),O(t),A(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[T,D,E,O]);let M=(0,d.useCallback)(()=>{f(!0),l(null),Y.projectFiles(e.id).then(s,e=>l(e.message)).finally(()=>f(!1))},[e.id]);(0,d.useEffect)(()=>{a?M():s(null)},[a,M]);let N=(0,d.useRef)(a);(0,d.useEffect)(()=>{N.current!==a&&(N.current=a,s(null),m(``),g(`all`),v(new Set),n&&Cb.files(e.id))},[a,n,e.id]);let P=o?.git?.prefix??``,F=n&&P&&n.startsWith(P)&&!o?.files.some(e=>e.path===n)?n.slice(P.length):n,I=(0,d.useMemo)(()=>lZ(e,o?.git?.prefix??``),[e,o]);(0,d.useEffect)(()=>{F&&A(!1)},[F]),(0,d.useEffect)(()=>{C.current?.querySelector(`.is-picked`)?.scrollIntoView({block:`nearest`})},[F,o]);let L=o?.files??[],R=(0,d.useMemo)(()=>aZ(L,p,h,I),[L,p,h,I]),z=(0,d.useMemo)(()=>sZ(R),[R]),B=(0,d.useMemo)(()=>({all:L.length,week:L.filter(e=>e.week).length,board:L.filter(e=>I.has(e.path)).length}),[L,I]),ee=p.trim()!==``||h!==`all`,V=e=>ee||_.has(e)||F!==void 0&&cZ(F).includes(e),te=t=>v(n=>{let r=new Set(n);return V(t)&&!ee?(r.delete(t),F&&cZ(F).includes(t)&&Cb.files(e.id)):r.add(t),r}),H=b&&(0,X.jsx)($X,{board:e,name:t,onClose:()=>{x(!1),S.current?.focus()}});if(!a)return(0,X.jsxs)(`section`,{className:`files`,"aria-label":`Project files`,children:[(0,X.jsxs)(`div`,{className:`files-empty`,children:[(0,X.jsx)(Q,{name:`folder`}),(0,X.jsx)(`h2`,{children:`This board has no project folder yet`}),y?(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`button`,{className:`btn btn-primary`,ref:S,onClick:()=>x(!0),children:`Choose project folder…`})]})]}),H]});let ne=F?L.find(e=>e.path===F):void 0;return(0,X.jsxs)(`section`,{className:`files`,"aria-label":`Project files`,children:[(0,X.jsxs)(`header`,{className:`files-title`,children:[(0,X.jsx)(`h2`,{children:`Files`}),(0,X.jsxs)(`span`,{className:`files-where`,title:o?.folder??a,children:[o?.folder??a,o?.git?.branch&&(0,X.jsxs)(X.Fragment,{children:[` · `,o.git.branch]}),o?.git&&(0,X.jsxs)(X.Fragment,{children:[` · `,o.git.clean?`clean`:`changes not committed`]}),o&&(0,X.jsxs)(X.Fragment,{children:[` · `,jZ(o.files.length,`file`),o.truncated?` (the first ones)`:``]})]}),(0,X.jsxs)(`button`,{className:`btn btn-quiet btn-small files-reload`,onClick:M,disabled:u,title:`Read the folder again`,children:[(0,X.jsx)(Q,{name:`sync`}),u?`Reading…`:`Reload`]}),!y&&(0,X.jsxs)(`button`,{className:`btn btn-quiet btn-small files-change`,ref:S,onClick:()=>x(!0),title:`Choose another project folder for this board, or remove it`,children:[(0,X.jsx)(Q,{name:`folder`}),`Change folder…`]}),(0,X.jsxs)(`span`,{className:`files-panels`,role:`group`,"aria-label":`Panels`,children:[(0,X.jsx)(`button`,{type:`button`,className:`icon-button${j?` is-on`:``}`,"aria-pressed":j,"aria-keyshortcuts":CZ,onClick:()=>{E(!j),A(!1)},title:`${j?`Hide`:`Show`} the files (${SZ} for both panels)`,"aria-label":j?`Hide the files`:`Show the files`,children:(0,X.jsx)(Q,{name:`panel-left`})}),(0,X.jsx)(`button`,{type:`button`,className:`icon-button${D?` is-on`:``}`,"aria-pressed":D,"aria-keyshortcuts":CZ,onClick:()=>O(!D),title:`${D?`Hide`:`Show`} On the board (${SZ} for both panels)`,"aria-label":D?`Hide On the board`:`Show On the board`,children:(0,X.jsx)(Q,{name:`panel-right`})})]})]}),(0,X.jsxs)(`div`,{className:`files-body${ne||F?` has-file`:``}${j?``:` no-tree`}${D?``:` no-side`}`,children:[(0,X.jsxs)(`aside`,{className:`files-list`,"aria-label":`The project's files`,children:[(0,X.jsxs)(`label`,{className:`files-find`,children:[(0,X.jsx)(Q,{name:`search`}),(0,X.jsx)(`input`,{type:`search`,value:p,placeholder:`Find a file…`,"aria-label":`Find a file`,"data-files-find":!0,ref:w,onChange:e=>m(e.target.value),onKeyDown:t=>{t.key===`Escape`&&p?(t.preventDefault(),m(``)):t.key===`Enter`&&R.length&&Cb.files(e.id,(p.trim()?oZ(R,p,1)[0]:R[0]).path)}})]}),(0,X.jsx)(`div`,{className:`files-filters`,role:`group`,"aria-label":`Show`,children:[[`all`,`All`,B.all],[`week`,`This week`,B.week],[`board`,`On the board`,B.board]].map(([e,t,n])=>(0,X.jsxs)(`button`,{className:`files-filter${h===e?` is-on`:``}`,"aria-pressed":h===e,onClick:()=>g(e),children:[t,` `,(0,X.jsx)(`b`,{children:n.toLocaleString(`en-US`)})]},e))}),ee&&o&&(0,X.jsx)(`p`,{className:`files-count`,children:R.length?`${jZ(R.length,`file`)} ${p.trim()?`match “${p.trim()}”`:`shown`}`:`No file matches`}),(0,X.jsx)(`div`,{className:`files-rows`,role:`tree`,"aria-label":`Folders and files`,ref:C,children:c?(0,X.jsxs)(`div`,{className:`files-note is-error`,children:[(0,X.jsx)(`p`,{children:c}),(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:M,children:`Try again`})]}):o?(0,X.jsx)(IZ,{folder:z,depth:0,board:e,picked:F,places:I,isOpen:V,toggle:te,budget:{left:kZ}}):(0,X.jsxs)(`p`,{className:`files-note`,children:[`Reading `,a,`…`]})})]}),F?(0,X.jsx)(RZ,{board:e,name:t,file:F,listed:ne,places:I.get(F)??[],onSaved:M,pairNow:!!r,onShown:i},F):(0,X.jsx)(LZ,{board:e,files:L,listed:!!o})]}),H]})}function IZ(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,X.jsxs)(`div`,{role:`treeitem`,"aria-expanded":t,children:[(0,X.jsxs)(`button`,{className:`files-row is-folder`,style:l,onClick:()=>s(r.path),children:[(0,X.jsx)(Q,{name:`chevron-down`,className:t?`files-twist is-open`:`files-twist`}),(0,X.jsx)(Q,{name:`folder`,className:`files-folder`}),(0,X.jsx)(`span`,{className:`files-name`,children:r.name}),(0,X.jsx)(`span`,{className:`files-n`,children:r.count.toLocaleString(`en-US`)})]}),t&&(0,X.jsx)(`div`,{role:`group`,children:(0,X.jsx)(IZ,{...e,folder:r,depth:n+1})})]},`d:${r.path}`))}for(let e of t.files){if(c.left--<=0)break;let t=e.status&&PZ[e.status];u.push((0,X.jsxs)(`a`,{role:`treeitem`,"aria-selected":e.path===i,className:`files-row${e.path===i?` is-picked`:``}`,style:{paddingLeft:10+n*16+15},href:db.files(r.id,e.path),children:[(0,X.jsx)(Q,{name:`note`,className:`files-file`}),(0,X.jsx)(`span`,{className:`files-name`,children:MZ(e.path)}),(0,X.jsxs)(`span`,{className:`files-marks`,children:[t&&(0,X.jsx)(`span`,{className:`files-status is-${e.status}`,title:t.words,children:t.mark}),a.has(e.path)&&(0,X.jsx)(`span`,{className:`files-onboard`,title:`On the board`})]})]},`f:${e.path}`))}return n===0&&c.left<=0&&u.push((0,X.jsx)(`p`,{className:`files-note`,children:`More files than fit here: find one by name.`},`more`)),(0,X.jsx)(X.Fragment,{children:u})}function LZ({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,X.jsxs)(`div`,{className:`files-lately`,children:[(0,X.jsx)(`h3`,{children:n?`Changed lately`:` `}),n&&!r.length&&(0,X.jsx)(`p`,{className:`files-note`,children:`Nothing changed this week. Pick a file at the left to read it here.`}),(0,X.jsx)(`ul`,{children:r.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:db.files(e.id,t.path),children:[(0,X.jsx)(`span`,{className:`files-name`,children:MZ(t.path)}),(0,X.jsx)(`span`,{className:`files-dir`,children:t.path.slice(0,-MZ(t.path).length)||`./`}),(0,X.jsx)(`span`,{className:`files-when`,children:t.status?PZ[t.status].words:t.last?`${t.last.by} · ${Yy(t.last.at)}`:``})]})},t.path))}),n&&(0,X.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 RZ({board:e,name:t,file:n,listed:r,places:i,onSaved:a,pairNow:o,onShown:s}){let c=Nc(),l=vb().boardContext()?.name.toLowerCase()??`board`,[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(`read`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(null),[T,E]=(0,d.useState)(!1),D=XX(n),O=ZX(n),[k,A]=(0,d.useState)(D?`preview`:`source`),j=(0,d.useCallback)(()=>(O?Y.projectFile(e.id,n):Promise.resolve(null)).then(e=>(f(e),m(null),e),e=>(m(e.message),null)),[e.id,n,O]);(0,d.useEffect)(()=>{j()},[j]);let M=u?.named;(0,d.useEffect)(()=>{if(M)return s?.({path:n,named:M}),()=>s?.(void 0)},[n,M,s]);let N=(0,d.useMemo)(()=>u?He(u.text):[],[u]),P=(0,d.useMemo)(()=>{let e=kV(Ve({path:n})),t={inComment:!1};return N.slice(0,AZ).map(n=>RV(n,e,t))},[N,n]),F=XC(),I=Date.now(),L=F.filter(e=>e.text.includes(MZ(n))&&UC(e,I)),R=h===`edit`,z=R&&u!==null&&y!==u.text,B=()=>{u&&(b(u.text),w(null),g(`edit`))},ee=async()=>z&&!await dz({title:`Drop your changes to ${MZ(n)}?`,detail:`They aren't saved to the file.`,confirmLabel:`Drop them`,cancelLabel:`Keep editing`,danger:!0})?!1:(g(`read`),w(null),!0),V=async e=>{(!R||await ee())&&A(e)},te=e=>h===`read`&&k===e,H=async()=>{if(u&&!x&&z){S(!0),w(null);try{let{file:r}=await Y.writeProjectFile(e.id,t,n,y,u.hash);f(r),g(`read`),E(!0),window.setTimeout(()=>E(!1),2500),a()}catch(e){e.status===409?w(e.message):m(e.message)}finally{S(!1)}}},ne=(0,d.useCallback)(async()=>{S(!0),m(null);try{let{block:r,pageId:i}=await Y.projectFileBlock(e.id,t,n);v({pageId:i,blockId:r.id}),g(`pair`)}catch(e){m(e.message)}finally{S(!1)}},[e.id,t,n]),re=(0,d.useCallback)(()=>{g(`read`),v(null),j()},[j]),ie=(0,d.useRef)(o);(0,d.useEffect)(()=>{ie.current&&u&&(ie.current=!1,ne())},[u,ne]),(0,d.useEffect)(()=>{if(h!==`pair`)return;let r=window.setInterval(()=>void Y.projectFileBlock(e.id,t,n).catch(()=>void 0),4e3);return()=>window.clearInterval(r)},[h,e.id,t,n]);let ae=_?e.pages?.find(e=>e.id===_.pageId):void 0,oe=async e=>{e&&await navigator.clipboard?.writeText(y).catch(()=>void 0);let t=await j();t&&b(t.text),w(null)},se=n.split(`/`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`files-preview`,children:[h!==`pair`&&(0,X.jsxs)(`div`,{className:`files-head`,children:[(0,X.jsxs)(`span`,{className:`files-crumbs`,title:n,children:[se.slice(0,-1).map((e,t)=>(0,X.jsxs)(`span`,{children:[e,` / `]},t)),(0,X.jsx)(`b`,{children:se[se.length-1]})]}),T&&(0,X.jsx)(`span`,{className:`files-saved`,children:`Saved`}),R&&(0,X.jsxs)(`span`,{className:`files-actions`,children:[(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void ee(),disabled:x,children:`Cancel`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-primary`,onClick:()=>void H(),disabled:x||!z,title:`Save it over the file (⌘S)`,children:x?`Saving…`:`Save`})]}),O&&(0,X.jsxs)(`div`,{className:`pair-modes files-modes`,role:`group`,"aria-label":`Mode`,children:[D?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`pair-mode${te(`preview`)?` is-on`:``}`,"aria-pressed":te(`preview`),onClick:()=>void V(`preview`),title:BZ[D],children:`Preview`}),(0,X.jsx)(`button`,{type:`button`,className:`pair-mode${te(`source`)?` is-on`:``}`,"aria-pressed":te(`source`),onClick:()=>void V(`source`),title:`Its text, line by line`,children:`Source`})]}):(0,X.jsx)(`button`,{type:`button`,className:`pair-mode${h===`read`?` is-on`:``}`,"aria-pressed":h===`read`,onClick:()=>R&&void ee(),title:`Read the file`,children:`Read`}),(0,X.jsx)(`button`,{type:`button`,className:`pair-mode${R?` is-on`:``}`,"aria-pressed":R,onClick:()=>!R&&B(),disabled:!u,title:`Edit the file itself, and save it over it`,children:`Edit`}),(0,X.jsx)(`button`,{type:`button`,className:`pair-mode`,"aria-pressed":!1,onClick:()=>void ne(),disabled:!u||x||R,title:`Pair with an agent on it: point at lines and ask; the agent changes the file`,children:`Pair`})]})]}),C&&(0,X.jsxs)(`div`,{className:`files-band is-conflict`,role:`alert`,children:[(0,X.jsx)(`span`,{children:C}),(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void oe(!0),children:`Copy my edit, then reload`}),(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>void oe(!1),children:`Reload`})]}),h===`pair`?(0,X.jsx)(`div`,{className:`files-pair`,children:_&&ae?(0,X.jsx)(GX,{board:e,page:ae,name:t,opens:_.blockId,onClosed:re}):(0,X.jsxs)(`p`,{className:`files-note`,children:[`Opening `,MZ(n),` to pair on…`]})}):R?(0,X.jsx)(zZ,{value:y,onChange:b,onSave:()=>void H(),label:`Edit ${n}`}):(0,X.jsx)(`div`,{className:`files-code${D&&k===`preview`?` is-preview is-${D}`:``}`,tabIndex:0,"aria-label":D&&k===`preview`?`${n}, drawn`:`The text of ${n}`,children:p?(0,X.jsx)(`p`,{className:`files-note is-error`,children:p}):D===`image`&&k===`preview`?(0,X.jsx)(_Z,{board:e,file:n,stamp:`${r?.size??``}-${u?.hash.slice(0,8)??``}`}):u?D&&D!==`image`&&k===`preview`?(0,X.jsx)(pZ,{board:e,file:n,kind:D,text:u.text}):(0,X.jsxs)(`pre`,{children:[P.map((e,t)=>(0,X.jsxs)(`span`,{className:`files-line`,children:[(0,X.jsx)(`i`,{children:u.start+t}),(0,X.jsx)(BV,{tokens:e.length?e:[{text:N[t]}]}),`
|
|
96
|
-
`]},t)),N.length>AZ&&(0,X.jsxs)(`span`,{className:`files-line is-more`,children:[jZ(N.length-AZ,`more line`),` after these.`]})]}):(0,X.jsxs)(`p`,{className:`files-note`,children:[`Reading `,MZ(n),`…`]})})]}),(0,X.jsxs)(`aside`,{className:`files-side`,"aria-label":`${MZ(n)} on the board`,children:[(0,X.jsx)(`h4`,{children:`On the board`}),i.length?i.map(t=>(0,X.jsxs)(Pc,{className:`files-place`,href:VZ(c,e,t,n),children:[(0,X.jsx)(Q,{name:t.kind===`code`?`code`:`details`}),(0,X.jsxs)(`span`,{children:[t.title,(0,X.jsx)(`small`,{children:HZ(t,l)})]})]},t.blockId)):(0,X.jsx)(`p`,{className:`files-note`,children:`Not on the board yet.`}),L.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h4`,{children:`Now`}),L.map(e=>(0,X.jsxs)(`p`,{className:`files-now`,children:[(0,X.jsx)(`span`,{className:`files-agent`,children:e.agent[0]}),(0,X.jsxs)(`span`,{children:[e.agent,` · `,QC(e)]}),(0,X.jsx)(fw,{state:ZC(UC(e,I)??`dim`)})]},e.agent))]}),(0,X.jsx)(`h4`,{children:`Lately`}),r?.status&&(0,X.jsxs)(`p`,{className:`files-note`,children:[PZ[r.status].words,`.`]}),r?.last?(0,X.jsxs)(`p`,{className:`files-note`,children:[(0,X.jsx)(`b`,{children:r.last.subject}),(0,X.jsx)(`br`,{}),r.last.by,` · `,Yy(r.last.at),` · `,r.last.commit]}):!r?.status&&(0,X.jsx)(`p`,{className:`files-note`,children:`No recent commit changed it.`}),u?.total||N.length?(0,X.jsx)(`p`,{className:`files-note`,children:jZ(u?.total??N.length,`line`)}):null]})]})}function zZ({value:e,onChange:t,onSave:n,label:r}){let i=(0,d.useRef)(null),a=(0,d.useMemo)(()=>e.split(`
|
|
97
|
-
`).length,[e]),o=(0,d.useMemo)(()=>Array.from({length:a},(e,t)=>t+1).join(`
|
|
98
|
-
`),[a]);return(0,X.jsxs)(`div`,{className:`files-editor`,children:[(0,X.jsx)(`pre`,{className:`files-gutter`,ref:i,"aria-hidden":!0,children:o}),(0,X.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 BZ={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 VZ(e,t,n,r){let i=n.on;return`files`in i?db.files(t.id,r,!0):`pageId`in i?db.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:db.context(t.id)}function HZ(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 UZ=`tricot:recent-boards`;function WZ(e,t,n=[]){let r=new Set([t,...n]);return[t,...e.filter(e=>!r.has(e))].slice(0,50)}function GZ(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 KZ(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 qZ(){try{let e=JSON.parse(localStorage.getItem(UZ)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function JZ(e,t){return e.filter(e=>!t.includes(e))}function YZ(e){try{localStorage.setItem(UZ,JSON.stringify(JZ(qZ(),e)))}catch{}}function XZ(e,t){try{localStorage.setItem(UZ,JSON.stringify(WZ(qZ(),e,t)))}catch{}}function ZZ(e){mc(e.aliases?.[0]??e.id),YZ([e.id,...e.aliases??[]])}function QZ({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=b(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,kc.createPortal)((0,X.jsx)(`div`,{className:`delete-scrim`,onMouseDown:e=>e.target===e.currentTarget&&!o&&n(),children:(0,X.jsxs)(`form`,{className:`delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-title`,onSubmit:n=>{n.preventDefault(),u&&!o&&(s(!0),Y.deleteBoard(e.id,t,i).then(()=>{ZZ(e),Ts(),r()},e=>{l(e.message),s(!1)}))},children:[(0,X.jsxs)(`h2`,{id:`delete-title`,children:[`Delete “`,e.title,`”?`]}),(0,X.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,X.jsx)(`label`,{className:`delete-label`,htmlFor:`delete-confirm`,children:`Type the board’s name to confirm`}),(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:c}),(0,X.jsxs)(`div`,{className:`delete-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,disabled:o,children:`Keep it archived`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-danger`,disabled:!u||o,children:`Delete board`})]})]})}),document.body)}function $Z(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}var eQ=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:{},tQ=e=>typeof e==`string`&&e!==``?e:void 0;function nQ(e,t){let n=tQ(e.file_path)??tQ(e.notebook_path)??tQ(e.path);if(!n)return;let r=t?.replace(/[\\/]+$/,``);return r&&n.startsWith(`${r}/`)?n.slice(r.length+1):n}var rQ=new Set([`Bash`,`shell`,`exec_command`,`local_shell`,`unified_exec`]);function iQ(e,t){if(!rQ.has(e))return;let n=t.command??t.cmd;return Array.isArray(n)&&n.every(e=>typeof e==`string`)?n.join(` `):tQ(n)}function aQ(e){if(e.sealed)return`Let this browser act for you to see what it asks`;let t=eQ(e.input),n=nQ(t,e.cwd),r=e.cwd?` in ${$Z(e.cwd)}`:``,i=/^mcp__(.+?)__(.+)$/.exec(e.tool);if(i)return`Use ${i[1]}: ${i[2].replace(/_/g,` `)}`;if(iQ(e.tool,t)!==void 0||rQ.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 oQ(e){if(e.sealed)return{text:``,more:[]};let t=eQ(e.input),n=iQ(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=tQ(t.command)??tQ(t.patch)??tQ(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 sQ=e=>`${e.agent}${e.role?` (${e.role} subagent)`:``} is waiting for your OK`;function cQ(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`}function lQ(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 uQ(e){return e.sealed?{title:`${e.agent} needs your OK`,body:`Let this browser act for you to see what it asks, and answer.`}:{title:`${e.agent} needs your OK`,body:p(`${aQ(e)}: ${oQ(e).text}`,180)}}var dQ=`tricot:notify`,fQ=typeof window<`u`&&`Notification`in window,pQ=null;function mQ(){pQ??=new AudioContext,pQ.resume()}function hQ(){if(!pQ)return;let e=pQ.currentTime;[659.25,880].forEach((t,n)=>{let r=pQ.createOscillator(),i=pQ.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(pQ.destination),r.start(a),r.stop(a+.4)})}function gQ(){try{return localStorage.getItem(dQ)===`1`}catch{return!1}}function _Q(e){try{localStorage.setItem(dQ,e?`1`:`0`)}catch{}}var vQ=()=>fQ&&gQ()&&Notification.permission===`granted`;async function yQ(){if(!fQ)return!1;mQ();let e=(Notification.permission==="default"?await Notification.requestPermission():Notification.permission)===`granted`;return _Q(e),e&&hQ(),e}var bQ=()=>hQ(),xQ=fQ,SQ=`Tricot`;function CQ({page:e,replies:t,needsYou:n,hidden:r}){let i=p(e??``,60),a=i?`${i} · ${SQ}`:SQ;if(!r)return a;let o=n?i?`${n} · ${i}`:n:a;return t>0?`(${t}) ${o}`:o}var wQ={page:void 0,replies:0,needsYou:``},TQ=new class{parts={...wQ,hidden:!1};listeners=new Set;set(e){this.parts={...this.parts,...e};for(let e of this.listeners)e()}title=()=>CQ(this.parts);subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))};function EQ(e,t){(0,d.useEffect)(()=>{let n={};return n[e]=t,TQ.set(n),()=>{let t={};t[e]=wQ[e],TQ.set(t)}},[e,t])}function DQ(){return(0,d.useSyncExternalStore)(Oc.subscribe,Oc.get)}function OQ(e){(0,d.useEffect)(()=>{if(!e)return;let t=new _s(Rt(q.approvalsStream));return t.addEventListener(`approvals`,e=>Oc.set(JSON.parse(e.data))),t.addEventListener(`admissions`,e=>vs.set(JSON.parse(e.data))),()=>t.close()},[e])}var kQ=new Map,AQ=new Set,jQ=0,MQ=e=>(AQ.add(e),()=>AQ.delete(e));function NQ(){return(0,d.useSyncExternalStore)(MQ,()=>jQ),new Set(kQ.keys())}function PQ(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 FQ({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,X.jsx)(`span`,{className:`approval-time`,title:`Asked at ${new Date(e).toLocaleTimeString()}`,children:PQ(e,t)})}function IQ({approval:e,name:t,toast:n=!1}){let r=Nc(),[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}=oQ(e),g=!!e.forSession?.length;(0,d.useEffect)(()=>{i&&p.current?.focus()},[i]);let _=async n=>{l(!0),f(null);try{await Y.answerApproval(e.id,t,n),Oc.drop(e.id)}catch(t){let n=t.status;f(t.message),l(!1),n===404&&setTimeout(()=>Oc.drop(e.id),2500)}},v=e=>{e.preventDefault(),_({behavior:`deny`,...o.trim()&&{reason:o.trim()}})},y=e.on,b=y?.card&&e.card?r.byId(e.card.kind,y.board,e.card.id)?.href:void 0;return e.sealed?(0,X.jsx)(LQ,{approval:e,toast:n,cardLink:b}):(0,X.jsxs)(`section`,{className:`approval${n?` is-toast`:``}`,"data-approval":e.id,"aria-label":sQ(e),children:[(0,X.jsxs)(`header`,{className:`approval-head`,children:[(0,X.jsx)(Q,{name:`pause`,className:`approval-mark`}),(0,X.jsx)(`span`,{className:`approval-who`,children:sQ(e)}),(0,X.jsx)(FQ,{since:e.at})]}),(0,X.jsx)(`p`,{className:`approval-what`,children:aQ(e)}),(0,X.jsx)(`pre`,{className:`approval-input`,tabIndex:0,"aria-label":`What it asks to run, as sent`,children:m}),h.length>0&&(0,X.jsx)(`ul`,{className:`approval-more`,"aria-label":`Sent with it`,children:h.map(e=>(0,X.jsx)(`li`,{children:e},e))}),e.description&&(0,X.jsxs)(`p`,{className:`approval-why`,children:[`“`,e.description,`”`]}),n&&y&&(0,X.jsx)(`p`,{className:`approval-where`,children:b?(0,X.jsxs)(`a`,{href:b,title:y.cardTitle,children:[y.card,` on `,y.title]}):(0,X.jsxs)(X.Fragment,{children:[`On `,y.title]})}),i?(0,X.jsxs)(`form`,{className:`approval-deny`,onSubmit:v,children:[(0,X.jsxs)(`label`,{className:`approval-deny-label`,htmlFor:`deny-${e.id}`,children:[`Tell `,e.agent,` why `,(0,X.jsx)(`span`,{className:`faint`,children:`(optional; it reads this)`})]}),(0,X.jsxs)(`div`,{className:`approval-deny-row`,children:[(0,X.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:`Use npm run build instead`,disabled:c}),(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-small approval-deny-button`,disabled:c,children:`Deny`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>a(!1),disabled:c,children:`Back`})]})]}):(0,X.jsxs)(`div`,{className:`approval-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,onClick:()=>void _({behavior:`allow`}),disabled:c,children:`Allow`}),g&&(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>void _({behavior:`allow`,session:!0}),disabled:c,children:`Allow for this session`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>a(!0),disabled:c,children:`Deny…`})]}),g&&!i&&(0,X.jsxs)(`p`,{className:`approval-session`,children:[`For this session also allows `,(0,X.jsx)(`span`,{className:`approval-rules`,children:e.forSession.join(`, `)}),`, until `,e.agent,` ends it.`]}),u&&(0,X.jsx)(`p`,{className:`error approval-error`,role:`alert`,children:u})]})}function LQ({approval:e,toast:t,cardLink:n}){let[r,i]=(0,d.useState)(!1),a=e.on;return(0,X.jsxs)(`section`,{className:`approval is-sealed${t?` is-toast`:``}`,"data-approval":e.id,"aria-label":sQ(e),children:[(0,X.jsxs)(`header`,{className:`approval-head`,children:[(0,X.jsx)(Q,{name:`pause`,className:`approval-mark`}),(0,X.jsx)(`span`,{className:`approval-who`,children:sQ(e)}),(0,X.jsx)(FQ,{since:e.at})]}),(0,X.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,X.jsx)(`p`,{className:`approval-where`,children:n?(0,X.jsxs)(`a`,{href:n,title:a.cardTitle,children:[a.card,` on `,a.title]}):(0,X.jsxs)(X.Fragment,{children:[`On `,a.title]})}),(0,X.jsx)(`div`,{className:`approval-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,disabled:r,onClick:()=>{i(!0),hs().finally(()=>i(!1))},children:`Let this browser in`})})]})}function RQ(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 zQ({name:e}){let t=DQ(),n=NQ(),r=t.filter(e=>!n.has(e.id));return r.length===0?null:(0,X.jsxs)(`div`,{className:`approval-toasts`,role:`region`,"aria-label":`Agents waiting for your OK`,children:[r.map(t=>(0,X.jsx)(IQ,{approval:t,name:e,toast:!0},t.id)),(0,X.jsx)(BQ,{})]})}function BQ(){let[e,t]=(0,d.useState)(vQ);return e||!xQ||Notification.permission===`denied`?null:(0,X.jsxs)(`button`,{type:`button`,className:`link-button approval-notify`,onClick:()=>void yQ().then(t),title:`A system notification when an agent waits for your OK while Tricot is in the background`,children:[(0,X.jsx)(Q,{name:`bell`}),` Notify me when an agent needs me`]})}function VQ(){let e=DQ();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,X.jsxs)(`button`,{type:`button`,className:`chat-approval`,onClick:()=>RQ(e[0].id),title:e.map(e=>`${sQ(e)}: ${aQ(e)}`).join(`
|
|
99
|
-
`),children:[(0,X.jsx)(Q,{name:`pause`}),(0,X.jsx)(`span`,{className:`chat-approval-text`,children:n})]})}function HQ(){let e=Nc(),t=DQ(),[n,r]=(0,d.useState)(()=>document.visibilityState===`hidden`),i=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=()=>r(document.visibilityState===`hidden`);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),EQ(`needsYou`,cQ(t.map(e=>e.agent))),(0,d.useEffect)(()=>{let r=new Set(t.map(e=>e.id)),a=i.current;if(i.current=r,!a||!n||!vQ())return;let o=t.filter(e=>!a.has(e.id));for(let t of o.slice(-3)){let n=uQ(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&&bQ()},[t,n,e])}function UQ(){let e=(0,d.useSyncExternalStore)(ds.subscribe,ds.get);if((0,d.useEffect)(()=>{if(!e)return;let t=e=>e.key===`Escape`&&ds.dismiss();return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),!e)return null;let t=(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>ds.dismiss(),autoFocus:!0,children:`Close`});return(0,kc.createPortal)((0,X.jsx)(`div`,{className:`seat-scrim`,children:(0,X.jsxs)(`section`,{className:`seat-dialog seat-prompt`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`seat-title`,"aria-describedby":`seat-lead`,children:[(0,X.jsx)(`h2`,{id:`seat-title`,children:`Let this browser act for you`}),e.state===`asking`&&(0,X.jsx)(`p`,{id:`seat-lead`,className:`seat-lead`,children:`Asking Tricot…`}),e.state===`waiting`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{id:`seat-lead`,className:`seat-lead`,children:[`Press `,(0,X.jsx)(`kbd`,{children:`y`}),` in the terminal where Tricot runs, or run `,(0,X.jsx)(`code`,{children:`tricot access`}),`. It shows this code:`]}),(0,X.jsx)(`p`,{className:`seat-code`,"aria-label":`Code ${e.code.split(``).join(` `)}`,children:e.code}),(0,X.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,X.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,X.jsxs)(`div`,{className:`seat-actions`,children:[(0,X.jsxs)(`span`,{className:`seat-waiting`,role:`status`,children:[(0,X.jsx)(`span`,{className:`seat-dot`,"aria-hidden":`true`}),` Waiting for you there`]}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>ds.dismiss(),children:`Not now`})]})]}),e.state===`denied`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{id:`seat-lead`,className:`seat-lead`,children:[`It was denied`,e.by?` ${e.by}`:``,`, so nothing was done.`]}),(0,X.jsx)(`div`,{className:`seat-actions`,children:t})]}),e.state===`expired`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`div`,{className:`seat-actions`,children:t})]}),e.state===`failed`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{id:`seat-lead`,className:`seat-lead error`,role:`alert`,children:e.error}),(0,X.jsx)(`div`,{className:`seat-actions`,children:t})]})]})}),document.body)}function WQ(){return(0,d.useSyncExternalStore)(vs.subscribe,vs.get)}function GQ({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 Y.answerAdmission(e.id,t,n),vs.drop(e.id)}catch(e){a(e.message),r(!1)}};return(0,X.jsxs)(`section`,{className:`admission`,"aria-label":o?`A terminal asks to answer for you`:`A browser asks to act for you`,children:[(0,X.jsxs)(`header`,{className:`admission-head`,children:[(0,X.jsx)(Q,{name:`desktop`,className:`admission-mark`}),(0,X.jsx)(`span`,{children:o?`Let this terminal answer for you?`:`A browser wants to act for you`})]}),(0,X.jsxs)(`p`,{children:[e.label,`, code `,(0,X.jsx)(`strong`,{className:`admission-code`,children:e.code}),`. Allow it only if the `,o?`terminal`:`browser`,` you’re using shows this code.`]}),(0,X.jsxs)(`div`,{className:`admission-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-small`,onClick:()=>void s(!0),disabled:n,children:`Allow`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,onClick:()=>void s(!1),disabled:n,children:`Deny`})]}),i&&(0,X.jsx)(`p`,{className:`error admission-error`,role:`alert`,children:i})]})}function KQ({name:e}){let t=WQ();return t.length?(0,X.jsx)(`div`,{className:`admission-banners`,role:`region`,"aria-label":`Asking to act for you`,children:t.map(t=>(0,X.jsx)(GQ,{admission:t,name:e},t.id))}):null}function qQ({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 Y.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 Y.removeSeat(t.id,e))}catch(e){a(e.message)}finally{s(null)}};return!n&&!i?null:(0,kc.createPortal)((0,X.jsx)(`div`,{className:`seat-scrim`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,X.jsxs)(`section`,{className:`seat-dialog seats-panel`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`seats-title`,children:[(0,X.jsx)(`h2`,{id:`seats-title`,children:`Your browsers and terminals`}),(0,X.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,X.jsx)(`ul`,{className:`seats-list`,children:n.map(e=>(0,X.jsxs)(`li`,{className:`seats-row`,children:[(0,X.jsx)(Q,{name:e.kind===`terminal`?`code`:`desktop`,className:`seats-mark`}),(0,X.jsxs)(`div`,{className:`seats-main`,children:[(0,X.jsxs)(`p`,{className:`seats-label`,children:[e.label,e.you&&(0,X.jsx)(`span`,{className:`seats-you`,children:`This browser`})]}),(0,X.jsxs)(`p`,{className:`seats-meta`,children:[`Let in `,Yy(e.admittedAt),` `,e.admittedBy,e.lastUsedAt?` · last used ${Yy(e.lastUsedAt)}`:` · not used yet`]})]}),(0,X.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,X.jsx)(`p`,{className:`error`,role:`alert`,children:i}),(0,X.jsx)(`div`,{className:`seat-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:t,children:`Done`})})]})}),document.body)}var JQ=`tricot:name`;function YQ(){let[e,t]=(0,d.useState)(()=>{try{return localStorage.getItem(JQ)??``}catch{return``}});return[e,(0,d.useCallback)(e=>{t(e);try{e?localStorage.setItem(JQ,e):localStorage.removeItem(JQ)}catch{}},[])]}function XQ({onSubmit:e}){let[t,n]=(0,d.useState)(``),{nameGate:r}=vb().words();return(0,X.jsx)(`div`,{className:`gate`,children:(0,X.jsxs)(`form`,{className:`gate-card`,onSubmit:n=>{n.preventDefault(),t.trim()&&e(t.trim())},children:[(0,X.jsx)(rb,{}),(0,X.jsx)(`h1`,{children:`What should agents call you?`}),(0,X.jsx)(`p`,{className:`muted`,children:r}),(0,X.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`Your name`,maxLength:60}),(0,X.jsx)(`button`,{className:`btn btn-primary`,disabled:!t.trim(),children:`Continue`})]})})}var ZQ=(0,d.createContext)({name:``,rename:()=>{}});function QQ(){return(0,d.useContext)(ZQ)}function $Q({children:e}){let[t,n]=YQ(),r=(0,d.useCallback)(()=>n(``),[n]),i=(0,d.useMemo)(()=>({name:t,rename:r}),[t,r]);return t?(0,X.jsxs)(ZQ.Provider,{value:i,children:[e(t),(0,X.jsx)(zQ,{name:t}),(0,X.jsx)(KQ,{name:t}),(0,X.jsx)(UQ,{}),(0,X.jsx)(e$,{})]}):(0,X.jsx)(XQ,{onSubmit:n})}function e$(){return HQ(),t$(),null}function t$(){(0,d.useEffect)(()=>{let e=()=>{let e=TQ.title();document.title!==e&&(document.title=e)},t=()=>TQ.set({hidden:document.visibilityState===`hidden`}),n=TQ.subscribe(e);return t(),document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t),n()}},[])}var n$=`If the new version changes how boards are stored, it keeps a copy of them first.`;function r$(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 i$(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 a$(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 o$=`tricot:update-skipped`,s$=`tricot:update-failure-seen`,c$=`tricot:updating`,l$=`tricot:updated`,u$=6e5,d$=1e3,f$=48e4,p$={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{}}},m$=()=>typeof localStorage>`u`?void 0:localStorage,h$=()=>typeof sessionStorage>`u`?void 0:sessionStorage;function g$(e){try{return e?JSON.parse(e):void 0}catch{return}}var _$={state:null,skipped:p$.get(m$(),o$),failureSeen:p$.get(m$(),s$),justUpdated:g$(p$.get(h$(),l$)),waiting:g$(p$.get(h$(),c$))},v$=new Set,y$;function b$(e){_$={..._$,...e};for(let e of v$)e()}function x$(){Y.update().then(e=>{b$({state:e,loadedAs:_$.loadedAs??e.current}),e.updating&&!_$.waiting&&b$({waiting:{release:e.available??{version:e.updating},from:e.current,since:Date.now()}}),_$.waiting&&D$()},()=>{})}function S$(e){return v$.add(e),v$.size===1&&(x$(),y$=setInterval(x$,u$),window.addEventListener(`focus`,x$)),()=>{v$.delete(e),v$.size===0&&(clearInterval(y$),window.removeEventListener(`focus`,x$))}}function C$(){return(0,d.useSyncExternalStore)(S$,()=>_$)}var w$=!1;async function T$(e){let t=_$.state?.current??``;b$({error:void 0});try{let n=await Y.startUpdate(e.version),r={release:e,from:t,since:Date.now()};p$.set(h$(),c$,JSON.stringify(r)),b$({state:n,waiting:r}),D$()}catch(e){b$({error:e.message}),x$()}}async function E$(){try{let e=await fetch(Rt(q.update),{cache:`no-store`,signal:AbortSignal.timeout(3e3)});return e.ok?await e.json():void 0}catch{return}}async function D$(){if(!w$){w$=!0;try{for(;;){let e=_$.waiting;if(!e)return;Date.now()-e.since>f$&&b$({waiting:{...e,slow:!0}}),await new Promise(e=>setTimeout(e,d$));let t=await E$();if(t){if(t.current===e.release.version){p$.set(h$(),c$,void 0),p$.set(h$(),l$,JSON.stringify(e.release)),location.reload();return}if(t.failed?.version===e.release.version){p$.set(h$(),c$,void 0),b$({state:t,waiting:void 0});return}b$({state:t})}}}finally{w$=!1}}}function O$(e){p$.set(m$(),o$,e),b$({skipped:e})}async function k$(){try{let{checked:e,...t}=await Y.checkForUpdates();return b$({state:t,loadedAs:_$.loadedAs??t.current}),`newer`in e&&_$.skipped===e.newer.version&&(p$.set(m$(),o$,void 0),b$({skipped:void 0})),r$({checked:e})}catch(e){return i$(e)}}var A$=3e3,j$=0;function M$(){b$({reveal:Date.now()}),j$===0&&Cb.home()}function N$(e,t){(0,d.useEffect)(()=>(j$++,()=>{j$--}),[]),(0,d.useEffect)(()=>{e===void 0||Date.now()-e>A$||t()&&b$({reveal:void 0})})}function P$(e){p$.set(m$(),s$,e.at),b$({failureSeen:e.at})}function F$(){p$.set(h$(),l$,void 0),b$({justUpdated:void 0})}function I$(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 L$={npm:`npm is installing it`,brew:`Homebrew is upgrading it`,npx:`npx is fetching it`};function R$({shown:e}){switch(e.kind){case`updating`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`update-text`,children:[(0,X.jsx)(`p`,{className:`update-title`,children:(0,X.jsxs)(`strong`,{children:[`Updating to Tricot `,e.version,`…`]})}),(0,X.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?`${L$[e.how.via]}, then `:``}Tricot restarts on the same address. This page reconnects by itself.`})]}),(0,X.jsx)(`span`,{className:`update-busy`,"aria-hidden":!0,children:(0,X.jsx)(fw,{state:`working`})})]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`update-text`,children:[(0,X.jsxs)(`p`,{className:`update-title`,children:[(0,X.jsxs)(`strong`,{children:[`The update to Tricot `,e.failure.version,` didn't finish.`]}),` You're on `,e.current,`.`]}),(0,X.jsx)(`p`,{className:`update-fine`,children:e.failure.message}),(0,X.jsxs)(`p`,{className:`update-fine`,children:[`What happened is in `,(0,X.jsx)(`code`,{children:e.failure.log}),`.`]})]}),(0,X.jsx)(`div`,{className:`update-actions`,children:(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>P$(e.failure),children:`OK`})})]});case`updated`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`update-text`,children:[(0,X.jsx)(`p`,{className:`update-title`,children:(0,X.jsxs)(`strong`,{children:[`You're on Tricot `,e.release.version,` now.`]})}),e.release.notes&&(0,X.jsx)(`p`,{className:`update-notes`,children:e.release.notes}),(0,X.jsx)(z$,{release:e.release})]}),(0,X.jsx)(`div`,{className:`update-actions`,children:(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:F$,children:`OK`})})]});case`moved`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`update-text`,children:(0,X.jsxs)(`p`,{className:`update-title`,children:[(0,X.jsxs)(`strong`,{children:[`Tricot is now `,e.version,`.`]}),` Reload to use it.`]})}),(0,X.jsx)(`div`,{className:`update-actions`,children:(0,X.jsx)(`button`,{className:`btn btn-primary btn-small`,onClick:()=>location.reload(),children:`Reload`})})]});case`available`:return(0,X.jsx)(B$,{shown:e})}}function z$({release:e}){return e.link?(0,X.jsxs)(`a`,{className:`update-link`,href:e.link,target:`_blank`,rel:`noreferrer`,children:[`What's new in `,e.version,(0,X.jsx)(Q,{name:`external`})]}):null}function B$({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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`update-text`,children:[(0,X.jsxs)(`p`,{className:`update-title`,children:[(0,X.jsxs)(`strong`,{children:[`Tricot `,t.version,` is out.`]}),` You have `,n,`.`]}),t.notes&&(0,X.jsx)(`p`,{className:`update-notes`,children:t.notes}),(0,X.jsx)(z$,{release:t}),s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`update-fine`,children:s.why}),(0,X.jsx)(`code`,{className:`update-command`,children:s.command}),s.restart&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`update-fine`,children:`Then restart Tricot on it:`}),(0,X.jsx)(`code`,{className:`update-command`,children:s.restart})]}),(0,X.jsx)(`p`,{className:`update-fine`,children:n$})]}):(0,X.jsxs)(`p`,{className:`update-fine`,children:[`Update installs it, and Tricot restarts on the same address; this page reconnects by itself. `,n$]}),i&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:i})]}),(0,X.jsxs)(`div`,{className:`update-actions`,children:[s?(0,X.jsx)(V$,{text:s.command}):(0,X.jsx)(`button`,{className:`btn btn-primary btn-small`,disabled:a,onClick:()=>{o(!0),T$(t).finally(()=>o(!1))},children:`Update`}),(0,X.jsx)(`button`,{className:`btn btn-quiet btn-small`,onClick:()=>O$(t.version),title:`Hides it until a newer version is out`,children:`Skip this version`})]})]})}function V$({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,X.jsx)(`button`,{className:`btn btn-primary btn-small`,onClick:()=>void r(),children:t?`Copied`:`Copy the update command`})}function H$(){let e=C$(),t=I$(e),n=(0,d.useRef)(null);return N$(e.reveal,()=>n.current?(n.current.scrollIntoView({block:`nearest`}),n.current.focus(),!0):!1),t?(0,X.jsxs)(`section`,{ref:n,tabIndex:-1,className:`update-notice is-${t.kind}`,"aria-label":`Tricot update`,"aria-live":`polite`,children:[(0,X.jsx)(Q,{name:t.kind===`updated`?`check`:`arrow-up`,className:`update-icon`}),(0,X.jsx)(R$,{shown:t})]}):null}function U$(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 W$(){let e=C$(),t=I$(e),n=(0,d.useRef)(null);if(N$(e.reveal,()=>{let e=n.current?.closest(`details`);return e?(e.open=!0,n.current.focus(),!0):!1}),!t)return null;let r=U$(t);return(0,X.jsxs)(tb,{className:`update-chip`,children:[(0,X.jsxs)(`summary`,{className:`update-chip-button is-${t.kind}`,title:r,children:[t.kind===`updating`?(0,X.jsx)(fw,{state:`working`}):(0,X.jsx)(Q,{name:t.kind===`updated`?`check`:`arrow-up`}),(0,X.jsx)(`span`,{children:r})]}),(0,X.jsx)(`div`,{ref:n,tabIndex:-1,className:`popover-body update-popover is-${t.kind}`,"aria-live":`polite`,children:(0,X.jsx)(R$,{shown:t})})]})}function G$({onShow:e}){let t=C$().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,X.jsxs)(`div`,{className:`user-version`,children:[(0,X.jsxs)(`div`,{className:`user-version-row`,children:[(0,X.jsx)(`span`,{children:t?`Tricot ${t}`:`Tricot`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-quiet btn-small`,"aria-disabled":a||void 0,onClick:()=>{a||(r({kind:`checking`}),k$().then(e=>i.current&&r(e)))},children:[(0,X.jsx)(Q,{name:`sync`}),` Check for updates`]})]}),(0,X.jsxs)(`div`,{className:`user-version-said${n?` is-${n.kind}`:``}`,children:[(0,X.jsx)(`p`,{role:`status`,children:n&&a$(n)}),n?.kind===`newer`&&(0,X.jsx)(`button`,{type:`button`,className:`user-version-show`,onClick:()=>{e(),M$()},children:`See the update`})]})]})}function K$({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=$H(),u=(0,d.useCallback)(()=>r(!1),[]);return Uc(n,u,c),(0,X.jsxs)(`div`,{className:`user-menu`,ref:c,children:[(0,X.jsxs)(`button`,{className:`user-chip`,onClick:()=>r(!n),"aria-expanded":n,title:`You`,children:[(0,X.jsx)($y,{actor:{kind:`human`,name:e}}),(0,X.jsx)(Q,{name:`chevron-down`,className:`user-chev`})]}),n&&(0,X.jsxs)(`div`,{className:`menu-panel user-panel`,children:[(0,X.jsxs)(`button`,{className:`menu-item`,onClick:()=>{r(!1),t()},children:[(0,X.jsx)(`strong`,{children:`Change your name`}),(0,X.jsx)(`span`,{children:`How people and agents see you on every board.`})]}),(0,X.jsxs)(`button`,{className:`menu-item`,onClick:()=>{r(!1),s(!0)},children:[(0,X.jsx)(`strong`,{children:`Your browsers and terminals`}),(0,X.jsx)(`span`,{children:`The ones you let act for you, and removing one.`})]}),(0,X.jsxs)(`div`,{className:`user-theme`,children:[(0,X.jsx)(`span`,{children:`Theme`}),(0,X.jsx)(`div`,{className:`connect-tabs`,role:`group`,"aria-label":`Theme`,children:HH.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:l===e?`is-active`:``,"aria-pressed":l===e,onClick:()=>QH(e),children:[(0,X.jsx)(Q,{name:e.base===`light`?`sun`:`moon`}),` `,e.label]},e.id))})]}),(0,X.jsx)(G$,{onShow:u}),(0,X.jsx)(Ex,{onOpen:e=>{r(!1),a(e)}})]}),i&&(0,X.jsx)(Dx,{name:i,person:e,onClose:()=>a(null)}),o&&(0,X.jsx)(qQ,{name:e,onClose:()=>s(!1)})]})}function q$({home:e=!1,left:t,right:n,bar:r}){let{name:i,rename:a}=QQ();return(0,X.jsxs)(`header`,{className:`topbar`,ref:r,children:[e?(0,X.jsx)(`div`,{className:`brand`,children:(0,X.jsx)(rb,{})}):(0,X.jsxs)(`div`,{className:`topbar-left`,children:[(0,X.jsx)(`a`,{className:`brand`,href:db.home(),title:`All boards`,children:(0,X.jsx)(rb,{})}),t]}),(0,X.jsxs)(`div`,{className:`topbar-right`,children:[n,(0,X.jsx)(K$,{name:i,onRename:a})]})]})}function J$(e){let[t,n]=(0,d.useState)(null);return(0,d.useEffect)(()=>n(null),[e]),[t??e,n]}function Y$({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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e,{className:t,children:(0,X.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,X.jsx)(`p`,{className:`heading-note error`,role:`alert`,children:u}):s&&(0,X.jsx)(`p`,{className:`heading-note`,children:s})]})}var X$=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),Z$=X$?`⌘B`:`Ctrl B`;function Q$(e,t){let n=gw(e);return n&&`now`in n?`${n.now.name} ${vw(n.now,t(n.now))} · ${Yy(n.now.lastSeen)}`:n?`${n.last.name}, ${Xy(n.last.at)}`:`no agent · ${Yy(e.updatedAt)}`}var $$=e=>!!(e&&e.scrollWidth>e.clientWidth);function e1({boardId:e,name:t,title:n,children:r}){let[i,a]=(0,d.useState)(!1),{report:o,error:s}=Tc(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||!(X$?e.metaKey:e.ctrlKey))return;let t=e.target instanceof Element&&!!e.target.closest(`.board-switch-panel`);(!Hc(e.target)||t)&&(e.preventDefault(),i?h(!0):m(document.activeElement))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,m,h]),(0,X.jsxs)(`div`,{className:`board-switch`,children:[r??(0,X.jsx)(`h1`,{children:(0,X.jsxs)(`button`,{ref:c,type:`button`,className:`board-switch-button`,onClick:()=>i?h(!0):m(c.current),onMouseEnter:()=>f($$(l.current)),"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":X$?`Meta+B`:`Control+B`,title:`${u?`${n}\n`:``}Switch board (${Z$})`,children:[(0,X.jsx)(`span`,{ref:l,className:`board-switch-current`,children:n}),(0,X.jsx)(Q,{name:`chevron-down`,className:`board-switch-chevron`})]})}),i&&(0,X.jsx)(t1,{boardId:e,report:o,error:s,button:c,onClose:h})]})}function t1({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)(qZ),u=(0,d.useRef)(null),f=(0,d.useId)(),p=_w(),m=e=>`${f}-${e}`,h=e=>db.board(e),g=(0,d.useMemo)(()=>t?KZ(GZ(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;Uc(!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,X.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,X.jsxs)(`div`,{className:`board-switch-field`,children:[(0,X.jsx)(Q,{name:`search`}),(0,X.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,X.jsx)(`kbd`,{className:`board-switch-key`,"aria-hidden":!0,children:Z$})]}),(0,X.jsx)(`div`,{className:`board-switch-list`,id:f,role:`listbox`,"aria-label":S?`Matching boards`:`Recent boards`,children:t===null?(0,X.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,X.jsx)(`p`,{className:`board-switch-empty`,children:S?`No board matches “${S}”.`:`No boards in use.`}):(0,X.jsxs)(X.Fragment,{children:[!S&&(0,X.jsx)(`p`,{className:`board-switch-label`,"aria-hidden":!0,children:`Recent`}),g.map((t,n)=>{let r=t.id===e;return(0,X.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,X.jsxs)(`span`,{className:`board-switch-text`,children:[(0,X.jsxs)(`span`,{className:`board-switch-title`,children:[(0,X.jsx)(`span`,{className:`board-switch-name`,children:t.title}),(t.needs??0)>0&&(0,X.jsxs)(`span`,{className:`tag tag-needs`,children:[t.needs,` `,t.needs===1?`needs`:`need`,` you`]})]}),(0,X.jsx)(`span`,{className:`board-switch-agent`,children:Q$(t,p)})]}),r&&(0,X.jsx)(Q,{name:`check`,className:`board-switch-check`})]},t.id)})]})}),(0,X.jsxs)(`footer`,{className:`board-switch-foot`,children:[(0,X.jsxs)(`a`,{className:`board-switch-link`,href:db.newBoard(),children:[(0,X.jsx)(Q,{name:`plus`}),` New board`]}),(0,X.jsx)(`a`,{className:`board-switch-link`,href:db.home(),children:`All boards`})]})]})}function n1({board:e,name:t,editing:n,onDone:r,actions:i}){let[a,o]=J$(e.title),[s,c]=J$(e.goal??``);return(0,X.jsxs)(`div`,{className:`board-heading`,children:[(0,X.jsxs)(`div`,{className:`board-title-row`,children:[(0,X.jsx)(e1,{boardId:e.id,name:t,title:a,children:n===`title`?(0,X.jsx)(Y$,{as:`h1`,value:a,label:`Rename the board`,required:!0,hint:`Enter to save · Esc to cancel · old links keep working`,onSave:n=>Ds(e.id,t,{title:n}).then(()=>o(n)),onDone:r}):null}),n!==`title`&&i]}),n===`goal`?(0,X.jsx)(Y$,{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=>Ds(e.id,t,{goal:n}).then(()=>c(n)),onDone:r}):n!==`title`&&s&&(0,X.jsx)(`p`,{className:`board-goal`,title:s,children:s})]})}function r1({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=vb().agentWork();return il(l,s,`.board-menu > .menu-button`,()=>c(!1)),(0,X.jsx)(q$,{bar:l,left:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`topbar-rule`,"aria-hidden":!0}),(0,X.jsx)(n1,{board:e,name:t,editing:a,onDone:e=>{o(null),c(e)},actions:(0,X.jsx)(i1,{board:e,name:t,onEdit:o})})]}),right:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W$,{}),(0,X.jsx)(IC,{live:n,agents:r,work:u&&(t=>u({board:e,agent:t}))}),i]})})}function i1({board:e,name:t,onEdit:n}){let{open:r,setOpen:i,close:a,root:o,button:s,menu:c,onKeyDown:l}=tl(),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,_]=(0,d.useState)(!1),v=n=>{f(!0),Os(e.id,t,n).then(()=>{m(null),a(!0)},e=>m(e.message)).finally(()=>f(!1))},y=e=>()=>{a(!1),e()},b={rename:{label:`Rename…`,note:`Its link changes to match. Old links keep working.`,run:y(()=>n(`title`))},goal:{label:As(!!e.goal),note:`What this work is for, in a line under its name.`,run:y(()=>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:()=>v(!0),waits:!0},unarchive:{label:`Unarchive`,note:`Back on the boards list, and open to changes again.`,run:()=>v(!1),waits:!0},delete:{label:`Delete board…`,note:`Removes it and everything on it for good. You confirm by typing its name.`,run:y(()=>_(!0))}};return(0,X.jsxs)(`div`,{className:`board-menu`,ref:o,children:[(0,X.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,X.jsx)(Q,{name:`more`})}),r&&(0,X.jsxs)(`div`,{className:`menu-panel`,role:`menu`,"aria-label":`Board actions`,ref:c,onKeyDown:l,children:[js(e).map(t=>t===`connectors`?(0,X.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`menu-item`,href:db.connectors(e.id),onClick:()=>a(!1),children:[(0,X.jsx)(`strong`,{children:`Connectors`}),(0,X.jsxs)(`span`,{children:[g(Qn().map(e=>e.name)),` and other services, set up once for every board.`]})]},t):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item`,disabled:b[t].waits&&u,onClick:b[t].run,children:[(0,X.jsx)(`strong`,{children:b[t].label}),(0,X.jsx)(`span`,{children:b[t].note})]},t)),p&&(0,X.jsx)(`p`,{className:`menu-error error`,role:`alert`,children:p})]}),h&&(0,X.jsx)(QZ,{board:e,name:t,onClose:()=>_(!1),onDeleted:Cb.home}),` `]})}function a1({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,X.jsxs)(`div`,{className:`archived-bar`,children:[(0,X.jsx)(Q,{name:`archive`,className:`archived-icon`}),(0,X.jsxs)(`p`,{className:`archived-text`,children:[(0,X.jsx)(`strong`,{children:`Archived`}),` by `,o.name,` `,Yy(s),`. Read-only for people and agents until it's unarchived.`]}),i&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:i}),(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:n,onClick:()=>{r(!0),Os(e.id,t,!1).then(()=>a(null),e=>a(e.message)).finally(()=>r(!1))},children:`Unarchive`})]})}var o1=[`comment`,`block`],s1={comment:`Comments`,block:`Canvas`},c1={placeholder:`Search comments and canvases`,hint:`Find past comments and canvas notes.`},l1={query:``,filter:`all`,allBoards:!1,openOnly:!1},u1=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),d1=u1?`⌘K`:`Ctrl K`;function f1(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 p1(e,t){let{boardId:n,target:r}=e,i=f1(r,t);return i?t.byId(i.kind,n,i.id)?.href??db.board(n):r.pageId?db.page(n,r.pageId):db.context(n)}function m1(e,t){let{target:n}=e;n.blockId&&WY(n.blockId),location.hash=p1(e,t),n.commentId&&!n.pinId&&tB([n.commentId])}function h1({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,X.jsx)(X.Fragment,{children:n.map((e,t)=>typeof e==`string`?e:(0,X.jsx)(`mark`,{children:e.mark},t))})}function g1({boardId:e,onClose:t}){let n=Nc(),r=vb(),i=r.search(),a=r.boardContext()?.name,o=(0,d.useMemo)(()=>[{key:`all`,label:`All`,kinds:i?[]:o1},...i?.filters??[],{key:`comments`,label:`Comments`,kinds:[`comment`]},{key:`canvas`,label:`Canvas`,kinds:[`block`]}],[i]),s=i??c1,[c,l]=(0,d.useState)(l1.query),[u,f]=(0,d.useState)(l1.filter),[p,m]=(0,d.useState)(l1.allBoards),[h,g]=(0,d.useState)(l1.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)(()=>{l1={query:c,filter:u,allBoards:p,openOnly:h}},[c,u,p,h]),(0,d.useEffect)(()=>{w.current?.select()},[]),Uc(!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(()=>{Y.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]??s1[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(),m1(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,kc.createPortal)((0,X.jsx)(`div`,{className:`search-scrim`,children:(0,X.jsxs)(`div`,{className:`search-panel`,ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,children:[(0,X.jsxs)(`div`,{className:`search-field`,children:[(0,X.jsx)(Q,{name:`search`}),(0,X.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,X.jsx)(`span`,{className:`search-count`,"aria-live":`polite`,children:P})]}),(0,X.jsxs)(`div`,{className:`search-filters`,children:[(0,X.jsx)(`div`,{className:`search-chips`,role:`group`,"aria-label":`Show`,children:o.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`search-chip`,"aria-pressed":u===e.key,onClick:()=>f(e.key),children:e.label},e.key))}),(0,X.jsxs)(`div`,{className:`search-chips`,children:[(0,X.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,X.jsx)(Q,{name:`check`}),` All boards`]}),i&&(0,X.jsxs)(`button`,{type:`button`,className:`search-chip`,"aria-pressed":h,title:i.openOnly.title,onClick:()=>g(!h),children:[h&&(0,X.jsx)(Q,{name:`check`}),` Open only`]})]})]}),(0,X.jsx)(`div`,{className:`search-results`,id:`search-results`,role:`listbox`,"aria-label":`Results`,children:D?y?(0,X.jsx)(`p`,{className:`search-empty error`,children:y}):_&&_.total===0?(0,X.jsxs)(`div`,{className:`search-empty`,children:[(0,X.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,X.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>m(!0),children:`Search all boards`})]}):O.map(e=>(0,X.jsxs)(`section`,{className:`search-group`,"aria-label":e.label,children:[(0,X.jsxs)(`h3`,{className:`search-group-head`,children:[e.label,` `,(0,X.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,X.jsxs)(`a`,{id:`search-row-${t}`,role:`option`,"aria-selected":t===x,className:`search-row${t===x?` is-active`:``}`,href:p1(e,n),onMouseMove:()=>t!==x&&S(t),onClick:t=>M(t,e),title:o?.status?`${e.ref} · ${o.status}`:e.ref,children:[(0,X.jsx)(`span`,{className:`search-ref ${o?.marker??``}`,children:r?(0,X.jsx)(Q,{name:`canvas`}):e.ref}),(0,X.jsxs)(`span`,{className:`search-text`,children:[(0,X.jsx)(`span`,{className:`search-title`,children:(0,X.jsx)(h1,{text:e.title,ranges:e.titleRanges})}),(e.snippet||s)&&(0,X.jsxs)(`span`,{className:`search-snippet`,children:[s&&(0,X.jsx)(`span`,{className:`search-where`,children:s}),e.snippet&&(0,X.jsx)(h1,{text:e.snippet.text,ranges:e.snippet.ranges})]})]}),(0,X.jsxs)(`span`,{className:`search-side`,children:[T&&(0,X.jsxs)(`span`,{className:`search-board`,title:e.boardTitle,children:[e.boardTitle,e.boardArchived&&` · archived`]}),o?.tag]})]},`${e.kind}:${e.target.commentId??e.target.blockId??f1(e.target,n)?.id}:${t}`)})]},e.kind)):(0,X.jsx)(`p`,{className:`search-empty`,children:E?`Type at least two characters.`:s.hint})}),(0,X.jsxs)(`footer`,{className:`search-foot`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↑`}),(0,X.jsx)(`kbd`,{children:`↓`}),` to move · `,(0,X.jsx)(`kbd`,{children:`↵`}),` to open · `,(0,X.jsx)(`kbd`,{children:`Esc`})]}),(0,X.jsxs)(`span`,{className:`faint`,children:[d1,` from anywhere`]})]})]})}),document.body)}function _1({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||!(u1?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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`search-button`,onClick:()=>{r.current=document.activeElement,n(!0)},"aria-haspopup":`dialog`,"aria-expanded":t,title:`Search (${d1})`,"aria-label":`Search`,children:(0,X.jsx)(Q,{name:`search`})}),t&&(0,X.jsx)(g1,{boardId:e,onClose:i})]})}function v1(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 y1(e,t){let n=t??`agents`;return{placeholder:`Ask ${n} about ${oS(e)}…`,label:`Ask ${n} about ${e} in Files`}}var b1=36e5,x1=24*b1,S1=168*b1,C1=(e,t)=>e.author.kind===`human`&&m(e.author.name,t);function w1(e,t){return e.messages.slice(e.messages.findIndex(e=>e.id===t)+1)}function T1(e,t,n,r){let i=t.messages.at(-1);if(!i||i.author.kind!==`agent`||!w1(t,r).includes(i))return!1;let a=nC(e,i.mentions);if(a.length)return a.some(e=>m(e,n));let o=t.messages.filter(e=>e.author.kind===`human`);return o.length===0||o.some(e=>C1(e,n))}function E1(e,t,n){return w1(e,n).some(e=>!C1(e,t))}function D1(e,t){return k1(e,t,[...t.messages.flatMap(e=>e.refs??[]),...t.pending??[]]).labels}function O1(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 k1(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`){FS(e,s).kind===`block`&&(o+=1);continue}let c=Ti(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 A1(e,t){if(e.general)return dS(`canvas`);let n=t&&aS(t,e);return n?sS(n):e.pageId?e.blockIds?.length?`Sketchbook · ${mS(e.blockIds.length)}`:`Sketchbook`:e.door&&e.door!==`threads`?dS(e.door):void 0}function j1(e,t,n){return!zS(e,t)&&n-Date.parse(t.updatedAt)>=(D1(e,t).length?x1:S1)}var M1=(e,t)=>t.thread.updatedAt.localeCompare(e.thread.updatedAt);function N1(e,t,n,r){let i={waiting:[],recent:[],earlier:[]};for(let a of e.threads??[]){let o=n?.[a.id],s=!!n&&T1(e,a,t,o),c={thread:a,waiting:s,unread:!!n&&E1(a,t,o),tag:A1(a,e),made:D1(e,a)};s?i.waiting.push(c):j1(e,a,r)?i.earlier.push(c):i.recent.push(c)}return i.waiting.sort(M1),i.recent.sort(M1),i.earlier.sort(M1),i}function P1(e,t,n){return n?(e.threads??[]).filter(r=>T1(e,r,t,n[r.id])).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)):[]}function F1(e,t){let n=new Set((e.threads??[]).filter(e=>e.startedBy.kind===`human`&&m(e.startedBy.name,t)||e.messages.some(e=>C1(e,t))).map(e=>e.id));return wi(e).filter(e=>e.createdBy?.kind===`agent`&&e.fromThread&&n.has(e.fromThread.id)).map(e=>e.id)}var I1=`tricot:look-at-board`,L1=!1,R1=e=>e instanceof Element&&!!e.closest(`.board-layout > :first-child`);function z1(){if(L1)return;L1=!0;let e=e=>{R1(e.target)&&window.dispatchEvent(new Event(I1))};for(let t of[`pointermove`,`wheel`,`scroll`,`keydown`])document.addEventListener(t,e,{capture:!0,passive:!0})}function B1(){window.dispatchEvent(new Event(I1))}var V1=1800;function H1(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!==ec(e)&&(n.current={board:ec(e),ids:new Set(wi(e).map(e=>e.id))});let c=(e?F1(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)(()=>z1(),[]),(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})},V1)))},[])}}function U1(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?Fw(n,u.map(e=>e.name)).body:n.trim())&&!c;return(0,X.jsxs)(`form`,{className:`chat-bar${t?` is-docked`:``}`,onSubmit:e=>{e.preventDefault(),m&&i()},"aria-label":`Talk to agents`,children:[d&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(Q,{name:`thread`}),d.count>0&&(0,X.jsx)(`span`,{className:`chat-count`,"aria-hidden":!0,children:d.count})]}),(0,X.jsx)(`span`,{className:`chat-sep`,"aria-hidden":!0})]}),f&&(0,X.jsxs)(`span`,{className:`chat-context`,title:f.title,children:[(0,X.jsx)(Q,{name:`group`}),(0,X.jsx)(`span`,{className:`chat-context-label`,children:f.label}),(0,X.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,X.jsx)(Q,{name:`x`})})]}),(0,X.jsx)(OT,{skills:!0,lenses:u,ref:l,className:`chat-input`,value:n,onValue:r,onKeyDown:e=>{e.key===`Escape`&&!t&&l.current?.blur()},maxLength:DS,placeholder:a,"aria-label":o}),(0,X.jsx)(VQ,{}),(0,X.jsx)(W1,{quiet:t}),(0,X.jsx)(`button`,{type:`submit`,className:`chat-send${m?` is-ready`:``}`,disabled:!m,"aria-label":s,title:`${s} (Enter)`,children:(0,X.jsx)(Q,{name:`arrow-up`})}),p&&(0,X.jsx)(`p`,{className:`error chat-error`,role:`alert`,children:p})]})}function W1({quiet:e}){let t=hw(),n=t.filter(e=>e.state!==`away`),r=n.map(e=>e.name);if(r.length===0)return(0,X.jsx)(G1,{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(`
|
|
100
|
-
`);return(0,X.jsxs)(`span`,{className:`chat-who`,title:i,children:[(0,X.jsx)(`span`,{className:`chat-who-dot`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chat-who-text`,children:_C(r)})]})}function G1({onBoard:e}){let t=hw(),n=Rz(),r=jz(),i=Nc().question()?.note;if(n===void 0||r===void 0)return null;let a=gC(e,n);if(a){let t=e[0]??n[0],i=`${xC(t,zz(t,r))} “${mC}”.`;return(0,X.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,X.jsx)(`span`,{className:`chat-who-text`,children:a})})}let o=t.length?`${g(t.map(e=>e.name))} last checked the board ${Yy(t[0].lastSeen)}. `:`No agent is on this board right now. `;return(0,X.jsxs)(`span`,{className:`chat-who is-none`,title:`${o}What you send waits in a thread until one connects${i?`; ${i}`:``}.`,children:[(0,X.jsx)(`span`,{className:`chat-who-text`,children:`No agent listening`}),(0,X.jsx)(`button`,{type:`button`,className:`chat-connect`,onClick:Gz,children:`Connect one`})]})}var K1=90,q1=420,J1=`::view-transition-image-pair(chat-bar)`,Y1=0;function X1(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Z1(){let e=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--dock-pace`));return e>0?e:1}function Q1(e,t,n){let r=document.documentElement,i=++Y1,a=()=>i===Y1,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,kc.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,q1*Z1());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===J1);e?e.finished.then(o,o):o()},o),t.finished.finally(()=>{o(),setTimeout(s,40)}).catch(()=>{})};e===`close`&&!X1()?(r.dataset.dockLeaving=``,setTimeout(l,K1*Z1())):l()}var $1={open:!1,page:`thread`,selected:null,newLens:null,drafts:{}},e0=`stays`;function t0(e,t,n,r,i=e0){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 n0=`No lens: agents answer as they see fit.`;function r0(e){let t=e?.name??`General`,n=e&&!MS(e.name)&&jw(e.name)?[{name:e.name,brief:e.brief}]:[];return[...Qx,...n].map(({name:e,brief:n})=>({name:e,brief:n??n0,tone:Bw({name:e}),...m(e,t)&&{current:!0}}))}function i0(e,t){let n=MS(e);return n?{name:n.name}:t?.brief&&m(t.name,e)?{name:t.name,brief:t.brief}:void 0}var a0=8,o0=6;function s0(e,t,n){let r=Math.max(0,Math.min(t.width,n.width-16)),i=Math.max(8,Math.min(e.left-o0,n.width-8-r)),a=Math.max(8,e.bottom+a0),o=Math.max(0,n.height-8-a),s=Math.max(8,n.height-e.top+a0),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 c0=`Agents answer as they see fit.`;function l0({lens:e,children:t}){return(0,X.jsx)(`span`,{className:`lens-chip ${Bw(e)}`,children:t??e?.name??`General`})}function u0(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,X.jsx)(l0,{lens:t,children:i??h}),_=(0,d.useCallback)((e=!0)=>{s(!1),e&&f.current?.focus()},[]);Uc(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(s0(e,{width:380,height:d0(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,X.jsxs)(`span`,{className:`lens-anchor`,ref:u,onKeyDown:e=>{o&&e.key===`Escape`&&(e.stopPropagation(),_())},children:[(0,X.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,X.jsx)(h0,{id:m,root:p,lens:t,generalLine:a,place:c,onPick:e=>{_(),r(e)}})]})}function d0(e){return e?e.scrollHeight+e.offsetHeight-e.clientHeight:0}function f0(e){let{lens:t,onPick:n}=e;return(0,X.jsxs)(`div`,{className:`lens-line`,children:[(0,X.jsx)(u0,{lens:t,label:`${t?.name??`General`} lens`,onPick:n}),(0,X.jsx)(p0,{lens:t})]})}function p0({lens:e,className:t}){return e?.agent?(0,X.jsxs)(`span`,{className:t,title:`Messages that @-mention nobody go to ${e.agent}`,children:[e.agent,` answers`]}):null}var m0=`Name it, and say how agents should answer.`;function h0(e){let{id:t,root:n,lens:r,generalLine:i,place:a,onPick:o}=e,{agents:s}=nT(),c=r?.name??`General`,l=!MS(c),[u,f]=(0,d.useState)(l),[p,h]=(0,d.useState)(l?c:``),[g,_]=(0,d.useState)(l?r?.brief??``:``),[v,y]=(0,d.useState)(r?.agent??``),[b,x]=(0,d.useState)(null),S=!!(p.trim()&&g.trim())&&!MS(p),C=[...s.map(e=>e.name),...r?.agent&&!s.some(e=>m(e.name,r.agent))?[r.agent]:[]],w=u?``:c,T=b??w,E=T===``?m0:MS(T)?.brief??i??c0;(0,d.useEffect)(()=>{l||n.current?.querySelector(`[aria-checked="true"]`)?.focus()},[l]);let D=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()},O=e=>({onMouseEnter:()=>x(e),onMouseLeave:()=>x(null),onFocus:()=>x(e),onBlur:()=>x(null)});return(0,X.jsxs)(`div`,{id:t,ref:n,className:`lens-menu`,tabIndex:-1,style:a,children:[(0,X.jsxs)(`div`,{className:`lens-pills`,role:`radiogroup`,"aria-label":`Lens`,onKeyDown:D,children:[Qx.map(e=>{let t=w===e.name;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,tabIndex:t?0:-1,className:`lens-pill`,onClick:()=>o(NS(e.name,void 0,v||void 0)),...O(e.name),children:(0,X.jsxs)(l0,{lens:e,children:[e.name,t&&(0,X.jsx)(Q,{name:`check`,className:`lens-check`})]})},e.name)}),(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":u,tabIndex:u?0:-1,className:`lens-pill`,onClick:()=>f(!0),...O(``),children:(0,X.jsxs)(l0,{lens:{name:``},children:[`Your own`,u&&(0,X.jsx)(Q,{name:`check`,className:`lens-check`})]})})]}),(0,X.jsx)(`p`,{className:`lens-menu-brief`,"aria-live":`polite`,children:E}),u&&(0,X.jsxs)(`form`,{className:`lens-form`,onSubmit:e=>{e.preventDefault(),S&&o(NS(p.trim(),g.trim(),v||void 0))},children:[(0,X.jsx)(`input`,{value:p,maxLength:AS,onChange:e=>h(e.target.value),placeholder:`Name, e.g. Pricing`,"aria-label":`Lens name`,autoFocus:!0}),(0,X.jsx)(`textarea`,{rows:2,value:g,maxLength:jS,onChange:e=>_(e.target.value),placeholder:`How agents should answer, in a sentence or two`,"aria-label":`Lens brief`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-small`,disabled:!S,children:`Use this lens`})]}),(0,X.jsxs)(`label`,{className:`lens-agent`,children:[(0,X.jsx)(`span`,{children:`Who answers`}),(0,X.jsxs)(`select`,{value:v,onChange:e=>{y(e.target.value),u||o(NS(c,void 0,e.target.value||void 0))},children:[(0,X.jsx)(`option`,{value:``,children:`Any agent, the first to reply`}),C.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]})]})]})}var g0=5;function _0(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);Uc(!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,g0),x=(e,t=!1)=>(0,X.jsx)(v0,{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,X.jsxs)(`div`,{className:`threads-pop${a?` is-docked`:``}`,ref:f,role:`dialog`,"aria-label":`Threads`,onKeyDown:h,children:[(0,X.jsxs)(`header`,{className:`tl-head`,children:[(0,X.jsx)(`h2`,{className:`tl-heading`,children:`Threads`}),!i&&(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-small tl-new`,onClick:s,children:[(0,X.jsx)(Q,{name:`plus`}),` New thread`]})]}),(0,X.jsxs)(`div`,{className:`tl-body`,children:[y&&(0,X.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,X.jsxs)(`section`,{className:`tl-group is-waiting`,"aria-label":`Waiting on you`,children:[(0,X.jsx)(`h3`,{className:`tl-group-head`,children:`Waiting on you`}),(0,X.jsx)(`ol`,{className:`tl-rows`,children:g.map(e=>x(e))})]}),_.length>0&&(0,X.jsxs)(`section`,{className:`tl-group`,"aria-label":`Recent`,children:[(g.length>0||v.length>0)&&(0,X.jsx)(`h3`,{className:`tl-group-head`,children:`Recent`}),(0,X.jsx)(`ol`,{className:`tl-rows`,children:_.map(e=>x(e))})]}),v.length>0&&(0,X.jsxs)(`section`,{className:`tl-group is-earlier`,"aria-label":`Earlier`,children:[(0,X.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,X.jsx)(`ol`,{className:`tl-rows`,children:b.map(e=>x(e,!0))}),v.length>b.length&&(0,X.jsxs)(`button`,{type:`button`,className:`link-button tl-more`,onClick:()=>m(!0),children:[`Show `,v.length-b.length,` more`]})]})]})]})}function v0(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=kS(c),f=c.messages.at(-1),p=O1(t.made),{people:h,me:g}=nT(),_=p&&(0,X.jsx)(`span`,{className:`tl-made`,children:p});return(0,X.jsxs)(`li`,{className:`tl-row${r?` is-compact`:``}${l?` is-waiting`:``}${i?` is-current`:``}`,"data-thread":c.id,children:[(0,X.jsx)($y,{actor:c.startedBy,showName:!1}),(0,X.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,X.jsx)(`span`,{className:`tl-title`,children:d}),r?_:(0,X.jsxs)(`span`,{className:`tl-meta`,children:[f&&(0,X.jsx)(`span`,{className:`tl-last`,children:y0(f,n,e=>!m(e,g)&&!h.some(t=>m(t,e)))}),_]})]}),(0,X.jsxs)(`span`,{className:`tl-end`,children:[l?(0,X.jsx)(`span`,{className:`tl-turn`,"aria-hidden":!0}):u&&(0,X.jsx)(`span`,{className:`new-dot`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`tl-time`,title:new Date(c.updatedAt).toLocaleString(),children:r?x0(c.updatedAt):b0(c.updatedAt)})]}),!a&&(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-small tl-delete`,onClick:s,"aria-label":`Delete thread: ${d}`,children:[(0,X.jsx)(Q,{name:`trash`}),` Delete`]})]})}function y0(e,t,n){let r=e.author.kind===`human`&&m(e.author.name,t)?`You`:e.author.name,i=e.mentions??[];return`${r}: ${p(qS(e.body,i,i.filter(n)),140)}`}function b0(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`:x0(e)}function x0(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var S0=`tricot:threads-seen:`,C0=new Map,w0=new Set;function T0(e){if(C0.has(e))return C0.get(e);let t=null;try{let n=localStorage.getItem(S0+e);t=n===null?null:JSON.parse(n)}catch{t=null}return C0.set(e,t),t}function E0(e,t){C0.set(e,t);try{localStorage.setItem(S0+e,JSON.stringify(t))}catch{}for(let e of w0)e()}function D0(e){w0.add(e);let t=t=>{t.key?.startsWith(S0)&&(C0.delete(t.key.slice(20)),e())};return window.addEventListener(`storage`,t),()=>{w0.delete(e),window.removeEventListener(`storage`,t)}}function O0(e){let t=e?ec(e):``,n=(0,d.useSyncExternalStore)(D0,()=>t?T0(t):null),r=e?.threads;return(0,d.useEffect)(()=>{t&&!T0(t)&&E0(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&&T0(t)||{};t&&n&&r[e.id]!==n&&E0(t,{...r,[e.id]:n})},[t])}}var k0=`local-`,A0=e=>!!e?.id.startsWith(k0);function j0(e,t,n){let r=KS(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 M0=[],N0=null;function P0(e,t,n){!n||M0.includes(n.boardId)?IY(e,t):(N0={id:e,thread:t},location.hash=n.href)}var F0=wY.find(e=>e.label===`Risks and open questions`)?.text??``,I0=new Map,L0=null;function R0({board:e,name:t,door:n,page:r,file:i,onSeeItem:a}){let o=ol(),s=e.threads??[],{seen:c,markSeen:l}=O0(e),u=(0,d.useMemo)(()=>N1(e,t,c,Date.now()),[e,t,c]),f=hw(),p=Nc().question(),h=f.filter(e=>e.state!==`away`).map(e=>e.name),g=Qz(t),[_]=(0,d.useState)(()=>n===`canvas`&&Eb(ub.ask)),[v]=(0,d.useState)(()=>t0(I0.get(e.id)??$1,e.id,L0,e=>s.some(t=>t.id===e))),[y,b]=(0,d.useState)(()=>{let e=v.state;return _?{...e,open:!1,drafts:{...e.drafts,bar:F0}}:e});(0,d.useEffect)(()=>{I0.set(e.id,y)},[e.id,y]);let x=(0,d.useCallback)(e=>{b(t=>({...t,...typeof e==`function`?e(t):e}))},[]),{open:S,page:C,selected:w,newLens:T,drafts:E}=y,[D,O]=(0,d.useState)(null),[k,A]=(0,d.useState)(!1),[j,M]=(0,d.useState)(null),N=(0,d.useCallback)(e=>M(e instanceof Error?e.message:String(e)),[]),{remove:P,toast:F}=hX(t,N),I=(0,d.useRef)(null),[L,R]=(0,d.useState)(()=>v.list&&!_),z=(0,d.useRef)(null),B=(0,d.useRef)(!1),ee=(0,d.useRef)(`bar`),V=(0,d.useRef)(new Map),te=(0,d.useCallback)(()=>{let e=I.current;return e&&document.activeElement===e?[e.selectionStart??e.value.length,e.selectionEnd??e.value.length]:null},[]),H=(0,d.useCallback)(()=>{let e=te();e&&V.current.set(ee.current,e)},[te]),ne=(0,d.useCallback)((e=!1,t=!0)=>{let n=I.current;if(!n)return;if(t&&n.focus({preventScroll:!0}),e)return n.select();let r=n.value.length,[i,a]=V.current.get(ee.current)??[r,r];V.current.delete(ee.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),H(),e===B.current?(t(),n&&re()):Q1(e?`open`:`close`,t,()=>ne(!1,n))},[H,ne,re]);(0,d.useEffect)(()=>{_&&(Db(ub.ask),ne(!0),re(!0))},[_,re,ne]);let se=(0,d.useCallback)((e,t)=>oe(!0,()=>{t&&O(t),M(null),R(!1),x({open:!0,page:`thread`,selected:e})}),[x,oe]);(0,d.useEffect)(()=>{let t=e.id;M0.push(t),N0&&=(se(N0.id,N0.thread),null);let n=e=>{let{id:t,thread:n}=e.detail;se(t,n)};return window.addEventListener(FY,n),()=>{M0.splice(M0.indexOf(t),1),window.removeEventListener(FY,n)}},[se,e.id]);let U=C===`thread`?s.find(e=>e.id===w)??(D?.id===w?D:void 0):void 0,W=S&&(C===`new`||!!U);B.current=W,(0,d.useEffect)(()=>{W||B1()},[W]);let ce=(0,d.useCallback)(()=>oe(!1,()=>x({open:!1})),[x,oe]),le=(0,d.useRef)(null),ue=(0,d.useCallback)((e,t)=>{if(e){Zc(le,t)&&ce();return}let n=te(),r=Qc(t,e=>{ie.current=null,e&&B.current?(n&&V.current.set(ee.current,n),oe(!1,()=>x({open:!1}),!1)):ae.current=!1});r&&(ae.current=!0,ie.current?.(),ie.current=r)},[ce,te,oe,x]);Xc(W,le),Uc(W&&!L,ue,le,void 0,!0),W||(ae.current=!1),(0,d.useEffect)(()=>()=>{ie.current?.();let t=I0.get(e.id);ae.current&&t&&I0.set(e.id,{...t,open:!1}),L0={board:e.id,open:B.current&&!ae.current}},[e.id]);let de=U?.messages.at(-1)?.id;(0,d.useEffect)(()=>{W&&U&&!A0(U)&&(l(U),a?.(U.id))},[W,U?.id,de,l,a]);let fe=()=>{M(null),R(e=>!e)},pe=(0,d.useCallback)(e=>{R(!1),e&&z.current?.focus()},[]),me=()=>oe(!0,()=>{M(null),R(!1),x({open:!0,page:`new`})}),he=e=>se(e),ge=e=>{M(null),e.id===w&&C===`thread`&&W&&oe(!1,()=>x({open:!1})),P([e.id])},_e=(e,n)=>{M(null),Y.setThreadLens(e.id,t,n).catch(N)},ve=W&&C===`thread`?void 0:W&&C===`new`?`threads`:n,ye=ve===void 0?U.id:ve===`threads`?`new`:`bar`,be=!W&&n===`threads`?r:void 0,G=dX(be?.id),xe=be&&v1(be,G?.blockIds.length),Se=!W&&n===`threads`&&!r?i:void 0,Ce=(0,d.useMemo)(()=>Se&&rS(e,Se.named,BS(e,f.map(e=>e.name))),[e,Se,f]),we=Se&&y1(Se.path,Ce);ee.current=ye;let Te=E[ye]??``,Ee=(e,t)=>x(n=>({drafts:{...n.drafts,[e]:t}})),De=ve?pS(ve,h.length):`reply`,Oe=De===`question`&&!p?`thread`:De,ke=(n,r,i,a,o,s,c)=>{let u=new Date().toISOString(),d={kind:`human`,name:t},f=o?lo(o,i):c&&Ce?lo({agent:{name:Ce}},i):i,p={id:`${k0}${Date.now().toString(36)}`,title:OS(n,KS(n,g)),door:r,...o&&{pageId:o.id},...o&&s?.length&&{blockIds:s},startedBy:d,startedAt:u,updatedAt:u,messages:[],...f&&{lens:f}},m=null;Sz.send(`thread:${p.id}`,n,[],async u=>{let d=await Y.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,Sz.arrived(u,f),l(d),O(e=>e?.id===p.id?d:e),x(e=>e.selected===p.id?{selected:d.id}:{}),f},a),V.current.delete(r===`threads`?`new`:`bar`),oe(!0,()=>{let e=m??p;O(e),x(t=>({open:!0,page:`thread`,selected:e.id,drafts:{...t.drafts,[r===`threads`?`new`:`bar`]:``},...r===`threads`&&{newLens:null}}))})},Ae=async(n,r)=>{let{question:i,comment:a}=eC(r,g.filter(e=>!m(e,t)));if(i){A(!0);try{let r=await n.post(e.id,t,{question:i,comment:a},()=>Ee(`bar`,``));r&&M(r)}catch(e){N(e)}finally{A(!1)}}},je=W&&C===`thread`?U?.lens:W&&C===`new`?T??void 0:void 0,Me=(0,d.useMemo)(()=>Oe===`question`?void 0:r0(je),[Oe,je]),Ne=()=>{let e=Te.trim(),{body:n,lens:r}=Me?Fw(e,Me.map(e=>e.name)):{body:e,lens:void 0},i=r?i0(r,je):void 0;if(!n||k)return;if(M(null),!ve){if(!U||A0(U))return;let e=U.messages.map(e=>e.id);Sz.send(`thread:${U.id}`,n,e,async()=>Dz((await Y.postToThread(U.id,t,n,i)).messages,e,t,n),i),Ee(U.id,``);return}if(Oe===`question`&&p)return void Ae(p,n);let a=ve===`threads`&&be&&G?G:void 0;ke(n,ve,ve===`threads`?T:null,i,be,a?.blockIds,ve===`threads`?Se?.path:void 0),a?.clear()},Pe=(e,t)=>{let r=t?`^${t.name} ${e}`:e;if(A0(U)){let e=U?.door??n,t=e=>()=>{O(null),x(e)};e===`threads`?oe(!0,t(e=>({page:`new`,newLens:U?.lens??null,drafts:{...e.drafts,new:r}}))):oe(!1,t(e=>({open:!1,drafts:{...e.drafts,bar:r}})))}else U&&(Ee(U.id,r),re())},Fe=u.waiting.length,Ie=u.waiting.filter(e=>e.thread.id!==U?.id).length,Le=xe??we,Re=ve?Le?Le.placeholder:ve===`threads`&&T?`What do you want to work through in ${T.name}?`:fS(ve):yC(U,h),ze=o?null:(0,X.jsx)(U1,{docked:W,value:Te,onValue:e=>Ee(ye,e),onSend:Ne,placeholder:Re,label:ve?Le?Le.label:ve===`threads`?`Start a new thread`:`Talk to agents from ${dS(ve)??ve}`:`Reply in ${U.title}`,sendLabel:Oe===`reply`?`Send`:Oe===`question`?`Post as a question`:G?`Start a thread about these blocks`:we?`Start a thread about this file`:`Start a thread`,busy:k||A0(U),field:I,lenses:Me,threads:W?void 0:{count:Fe,open:L,onOpen:fe,button:z},context:G?{label:`${G.blockIds.length} block${G.blockIds.length===1?``:`s`}`,title:`What the thread you start is about:\n${G.names.join(`
|
|
101
|
-
`)}`,onRemove:()=>{G.clear(),re()}}:void 0,error:W?null:j}),Be=L&&(0,X.jsx)(_0,{groups:u,name:t,current:W?U?.id:void 0,readOnly:o,docked:W,onOpen:he,onNew:me,onDelete:ge,onClose:pe,toggle:z});if(!W)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`chat-float`,children:[Be,ze??(0,X.jsxs)(`button`,{type:`button`,className:`chat-threads-only`,ref:z,onClick:fe,"aria-expanded":L,"aria-haspopup":`dialog`,children:[(0,X.jsx)(Q,{name:`thread`}),` Threads`]})]}),F&&(0,X.jsx)(`div`,{className:`threads-toast`,children:F})]});let Ve=(0,X.jsx)(`button`,{type:`button`,className:`dock-close`,onClick:ce,"aria-label":`Close the conversation`,title:`Close (Esc)`,children:(0,X.jsx)(Q,{name:`x`})});return(0,X.jsxs)(`aside`,{className:`thread-dock`,ref:le,"aria-label":`Threads`,children:[(0,X.jsxs)(`header`,{className:`dock-head`,children:[(0,X.jsxs)(`button`,{type:`button`,ref:z,className:`dock-back`,onClick:fe,"aria-expanded":L,"aria-haspopup":`dialog`,"aria-label":`All threads${Ie?`, ${Ie} waiting on you`:``}`,children:[(0,X.jsx)(Q,{name:`arrow-left`}),` Threads`,Ie>0&&(0,X.jsx)(`span`,{className:`dock-count`,"aria-hidden":!0,children:Ie})]}),Ve]}),Be,j&&(0,X.jsx)(`p`,{className:`error threads-error`,role:`alert`,children:j}),C===`thread`&&U&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B0,{board:e,thread:U,readOnly:o||A0(U),onPick:e=>_e(U,e)}),(0,X.jsx)(V0,{board:e,thread:U,name:t,onOpen:z0,onEdit:Pe})]}),C===`new`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dock-title`,children:(0,X.jsx)(`h2`,{className:`dock-heading`,children:`New thread`})}),!o&&(0,X.jsx)(f0,{lens:T??void 0,onPick:e=>x({newLens:e})}),(0,X.jsx)(V0,{board:e,thread:void 0,name:t,onOpen:z0,onEdit:Pe})]}),ze&&(0,X.jsx)(`div`,{className:`dock-foot`,children:ze}),F&&(0,X.jsx)(`div`,{className:`threads-toast`,children:F})]})}var z0=()=>{};function B0(e){let{board:t,thread:n,readOnly:r,onPick:i}=e,a=D1(t,n),o=A1(n,t),s=vb().boardContext()?.generalThread;return(0,X.jsxs)(`div`,{className:`dock-title`,children:[(0,X.jsx)(`h2`,{className:`dock-heading`,title:kS(n),children:kS(n)}),(0,X.jsxs)(`div`,{className:`dock-meta`,children:[o&&(0,X.jsx)(`span`,{className:`dock-door`,children:o}),a.map(e=>(0,X.jsxs)(`span`,{className:`dock-made`,children:[`→ `,e]},e)),(0,X.jsxs)(`span`,{className:`dock-when`,title:new Date(n.startedAt).toLocaleString(),children:[`started `,Yy(n.startedAt)]}),(0,X.jsx)(u0,{lens:n.lens,readOnly:r,onPick:i,label:`${n.lens?.name??`General`} lens`,note:n.general?s:void 0})]})]})}function V0(e){let{board:t,thread:n,name:r,onOpen:i,onEdit:a}=e,o=ol(),s=(0,d.useRef)(null),c=Qz(r),l=wz(n?.messages??[],Cz(`thread:${n?.id??``}`),r,e=>j0(e,r,c)),u=Ez(l).join();(0,d.useEffect)(()=>{for(let e of u?u.split(`,`):[])Sz.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`&&m(e.author.name,r),h=l.findLastIndex(e=>e.item.author.kind===`human`),g=h>=0&&p(l[h].item)?h:-1,_=n?bz(t,n.messages):-1,v=_>=0?n.messages[_].id:void 0,y=g>=0?l[g]:void 0,b=!!(y&&n&&(Tz(y)||OC(y.item,Date.now())&&(y.outgoing||zS(t,n)?.message.id===y.item.id))),x=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,x]);let S=new Map;for(let{by:e,...t}of n?.pending??[]){let n=S.get(e.name)??{by:e,refs:[]};n.refs.push(t),S.set(e.name,n)}return(0,X.jsxs)(`div`,{className:`threads-conversation`,ref:s,"aria-label":n?`Thread: ${kS(n)}`:`New thread`,role:`region`,children:[n?(0,X.jsxs)(`ol`,{className:`thread-messages`,children:[l.map((e,o)=>{let s=e.item,c=Tz(e),u=s.id===e.outgoing?.key,d=u||A0(n)?null:(0,X.jsx)(Jz,{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,X.jsxs)(`li`,{id:u?void 0:eB(s.id),className:`thread-message${p?` is-arriving`:``}${m}`,onAnimationEnd:e=>e.currentTarget.classList.remove(`is-flash`),children:[(0,X.jsx)($y,{actor:s.author,showName:!1}),(0,X.jsxs)(`div`,{className:`thread-message-main`,children:[(0,X.jsxs)(`div`,{className:`thread-message-head`,children:[(0,X.jsx)(`strong`,{children:s.author.name}),(0,X.jsx)(yz,{board:t,said:s}),s.lens&&(0,X.jsx)(H0,{lens:s.lens,thread:n}),(0,X.jsx)(`span`,{className:`thread-message-time`,title:new Date(s.at).toLocaleString(),children:Yy(s.at)}),(0,X.jsx)(oT,{via:s.via})]}),(0,X.jsx)(iT,{comment:s}),s.refs?.length?(0,X.jsx)(W0,{board:t,refs:s.refs,onOpen:i}):null,c||o===g||s.id===v?(0,X.jsx)(Hz,{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)}),[...S.values()].map(({by:e,refs:n})=>(0,X.jsxs)(`li`,{className:`thread-message`,children:[(0,X.jsx)($y,{actor:e,showName:!1}),(0,X.jsxs)(`div`,{className:`thread-message-main`,children:[(0,X.jsxs)(`div`,{className:`thread-message-head`,children:[(0,X.jsx)(`strong`,{children:e.name}),(0,X.jsx)(`span`,{className:`thread-message-time`,children:`made, ahead of a reply`})]}),(0,X.jsx)(W0,{board:t,refs:n,onOpen:i})]})]},`ahead:${e.name}`))]}):o?(0,X.jsx)(`p`,{className:`threads-intro`,children:`No threads.`}):(0,X.jsx)(`p`,{className:`threads-intro`,children:`Start a thread to work something through with agents. @ an agent to ask that one.`}),n&&(0,X.jsx)(xz,{board:t,items:n.messages,className:`threads-quiet`}),!o&&!b&&(0,X.jsx)(U0,{board:t,thread:n})]})}function H0({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,X.jsx)(`span`,{className:`thread-message-lens`,title:`${r}, for this message alone${n}.`,children:(0,X.jsxs)(l0,{lens:e,children:[`^`,e.name]})})}function U0({board:e,thread:t}){let n=hw().filter(e=>e.state!==`away`),r=t?zS(e,t):void 0;if(n.length===0)return(0,X.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=>m(t.name,e)))?(0,X.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,X.jsxs)(`p`,{className:`threads-quiet`,children:[`Waiting for `,i.length?g(i):`an agent`,` to reply.`]})}function W0({board:e,refs:t,onOpen:n}){return(0,X.jsx)(`ul`,{className:`work-cards`,"aria-label":`What it led to`,children:t.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsx)(G0,{board:e,item:t,onOpen:n})},`${t.kind}:${t.id}`))})}function G0({board:e,item:t,onOpen:n}){let r=Nc(),i=Ey(),a=vb().boardContext()?.name??`board`,o=FS(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??_e(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?db.page(e.id,s.id):db.context(e.id);return(0,X.jsxs)(Pc,{className:`work-card is-row`,href:u,title:`${c}, on the ${l}`,onClick:()=>{WY(t.id),n()},children:[(0,X.jsxs)(`span`,{className:`work-meta`,children:[(0,X.jsx)(Q,{name:`canvas`}),t.type.charAt(0).toUpperCase()+t.type.slice(1)]}),(0,X.jsx)(`span`,{className:`work-title`,children:c}),(0,X.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,X.jsxs)(Pc,{className:`work-card`,href:a,onClick:()=>{tB([t.id]),n()},children:[(0,X.jsxs)(`span`,{className:`work-meta`,children:[(0,X.jsx)(Q,{name:`comment`}),`Comment on `,i.label]}),(0,X.jsx)(`span`,{className:`work-quote`,children:p(t.body.replace(/\s+/g,` `),160)})]})}case`gone`:return(0,X.jsx)(`span`,{className:`work-card is-gone`,children:K0(RS(e,t,(e,t)=>i?.label(e,t)))})}}var K0=e=>e.charAt(0).toUpperCase()+e.slice(1);function q0({board:e,name:t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useRef)(null),{seen:a}=O0(e),o=(0,d.useMemo)(()=>P1(e,t,a),[e,t,a]),s=(0,d.useCallback)(()=>r(!1),[]);Uc(n,s,i);let c=o.length===0?`Threads: none waiting on you`:`Threads: ${o.length} waiting on you`;return(0,X.jsxs)(`div`,{className:`inbox threads-badge`,ref:i,children:[(0,X.jsxs)(`button`,{className:`inbox-button${o.length?` has-new`:``}`,onClick:()=>r(!n),"aria-expanded":n,"aria-haspopup":`dialog`,"aria-label":c,title:c,children:[(0,X.jsx)(Q,{name:`thread`}),o.length>0&&(0,X.jsx)(`span`,{className:`inbox-count`,children:o.length})]}),n&&(0,X.jsx)(`div`,{className:`inbox-panel`,role:`dialog`,"aria-label":`Threads waiting on you`,children:o.length===0?(0,X.jsx)(`p`,{className:`inbox-empty`,children:`No thread is waiting on you.`}):(0,X.jsx)(`ol`,{className:`inbox-list`,children:o.map(e=>{let t=e.messages.at(-1);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{className:`inbox-item is-for-you`,onClick:()=>{s(),P0(e.id,e)},children:[(0,X.jsx)($y,{actor:t.author,showName:!1}),(0,X.jsxs)(`span`,{className:`inbox-text`,children:[(0,X.jsx)(`span`,{className:`inbox-subject`,children:e.title}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:t.author.name}),` `,p(t.body,140)]}),(0,X.jsx)(`span`,{className:`inbox-meta`,children:(0,X.jsx)(`span`,{children:Yy(t.at)})})]})]})},e.id)})})})]})}function J0({board:e,name:t,steps:n,children:r}){let i=vb().refKinds();return(0,X.jsx)(al.Provider,{value:!!e.archived,children:(0,X.jsx)(Oy,{board:e,kinds:i,children:(0,X.jsx)(mw,{value:e.presence??[],children:(0,X.jsx)(qC,{value:n,children:(0,X.jsx)(rT,{board:e,me:t,children:r})})})})})}function Y0({board:e}){return(0,d.useEffect)(()=>{e&&ZZ(e)},[e]),(0,X.jsx)(`div`,{className:`page`,children:(0,X.jsxs)(`div`,{className:`board-deleted`,children:[(0,X.jsx)(`h1`,{children:`This board was deleted`}),(0,X.jsxs)(`p`,{children:[e?`“${e.title}” was deleted by a person, for good. `:``,`It is gone from Tricot, with everything on it.`]}),(0,X.jsx)(`a`,{href:db.home(),children:`Back to boards`})]})})}function X0({route:e,name:t}){let{boardId:n,pinId:r}=e,i=vb(),{board:a,error:o,live:s,deleted:c,steps:l}=Ew(n);DZ(n,!!(a&&NZ(a))),EQ(`page`,c?void 0:a?.title);let u=Sc(a,t),f=H1(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(`
|
|
102
|
-
`);(0,d.useEffect)(()=>{for(let e of v?v.split(`
|
|
103
|
-
`):[])m(e),h(e,!1)},[v,m,h]),rl(3e4),(0,d.useEffect)(()=>{a?.aliases?.includes(n)&&location.replace(fb(location.hash,a.id))},[a,n]),(0,d.useEffect)(()=>{if(!r||!a)return;GY(r);let e=Po(a,r),t=e?.page&&oo(e.page)?e.canvas.blocks.find(t=>t.id===e.pin.blockId):void 0;t?.type===`code`?Tb(db.files(a.id,t.path,!0)):wb(e?.page?.id)},[r,!!a]);let y=a?.id;if((0,d.useEffect)(()=>{a&&y&&XZ(y,a.aliases)},[y]),c)return(0,X.jsx)(Y0,{board:a});if(o&&!a)return(0,X.jsx)(`div`,{className:`page`,children:(0,X.jsxs)(`div`,{className:`empty empty-page`,children:[(0,X.jsx)(`p`,{children:o}),(0,X.jsx)(`a`,{href:db.home(),children:`Back to boards`})]})});if(!a)return(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(tb,{className:`connect-popover`,children:[(0,X.jsx)(`summary`,{className:`search-button`,title:`Connect an agent`,"aria-label":`Connect an agent`,children:(0,X.jsx)(Q,{name:`knitted-plug`})}),(0,X.jsx)(`div`,{className:`popover-body`,children:(0,X.jsx)(Bx,{boardId:a.id})})]}),(0,X.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0}),(0,X.jsx)(_1,{boardId:a.id}),i.controls(S),(0,X.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0})]}),T=(0,X.jsx)(r1,{board:a,name:t,live:s,agents:C,controls:w}),E=i.needsStrip(S),D=(0,X.jsx)(a1,{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,X.jsx)(J0,{board:a,name:t,steps:l,children:n})}let O=i.feed(),k=!!O?.open(S);return(0,X.jsx)(J0,{board:a,name:t,steps:l,children:(0,X.jsxs)(`div`,{className:`page board-page`,children:[T,D,(0,X.jsxs)(`div`,{className:`attention`,children:[i.doors().map(e=>(0,X.jsx)(d.Fragment,{children:e.door?.(S)},e.id)),(0,X.jsx)(`nav`,{className:`tabs`,"aria-label":`Board views`,children:i.tabs().map(e=>{let t=e.tab?.(S)??{changed:!1};return(0,X.jsxs)(`a`,{href:e.link(a.id),className:x===e.id?`is-active`:``,children:[e.label,` `,t.count!==void 0&&(0,X.jsx)(`span`,{className:`tab-count`,children:t.count}),t.more,t.changed&&(0,X.jsx)(`span`,{className:`new-dot`,"aria-label":`Has changes`})]},e.id)})}),(0,X.jsxs)(`div`,{className:`attention-end`,children:[E,b?.controls?.(S),O?.toggle(S)]})]}),(0,X.jsxs)(`div`,{className:`board-layout${k?``:` board-layout-full`}${b?.layout?` board-layout-${b.layout}`:``}`,children:[b?.render(S),(0,X.jsx)(R0,{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 Z0({page:e}){let t=co(e.agent);if(!t||!e.agent)return null;let n=e.agent.name;return(0,X.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,X.jsxs)(`span`,{className:`scratch-maker-text`,children:[t,(0,X.jsxs)(`span`,{className:`scratch-maker-to`,children:[` · `,n,` answers here`]})]})})}var Q0=`application/x-tricot-page`;function $0(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,X.jsx)(e2,{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(Q0,e.id),t.dataTransfer.effectAllowed=`move`,_({id:e.id})},onDragOver:t=>{if(!g||!t.dataTransfer.types.includes(Q0))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,X.jsx)(`button`,{...u,className:`menu-item is-line add-menu-item`,style:o(e),onClick:r,children:(0,X.jsxs)(`span`,{className:`add-menu-row`,children:[(0,X.jsx)(Q,{name:t,className:`add-menu-icon`}),n]})});return(0,X.jsxs)(X.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,X.jsx)(`div`,{role:`none`,className:d.join(` `),...x(e),children:(0,X.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,X.jsxs)(`span`,{className:`add-menu-row`,children:[(0,X.jsx)(`span`,{className:`pages-menu-mark`,children:c&&(0,X.jsx)(Q,{name:`check`})}),(0,X.jsx)(`span`,{className:`pages-menu-title`,children:e.title}),!c&&r.has(e.id)&&(0,X.jsx)(`span`,{className:`new-dot`,"aria-label":`Has changes`})]})})},e.id)}),!i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(yY,{icon:`pages`,label:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolbar-pages-title`,children:n.title}),C&&(0,X.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 e2({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,X.jsx)(`div`,{className:`toolbar-add toolbar-pages`,children:(0,X.jsxs)(`div`,{className:`toolbar-add-field toolbar-pages-field`,children:[(0,X.jsx)(`span`,{className:`toolbar-add-plus`,"aria-hidden":!0,children:(0,X.jsx)(Q,{name:`pages`})}),(0,X.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 t2=`Untitled page`,n2=4e3;function r2(e){try{let t=localStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}}function i2(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function a2({board:e,name:t,pageId:n,newItems:r,changed:i,onSeeItem:a}){let o=ol(),s=`tricot:scratch-page:${ec(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),n2);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=ao(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=r2(s),C=x??b.find(e=>e.id===S)??b[0],w=C?.id;(0,d.useEffect)(()=>{w?(w!==n&&Tb(db.page(e.id,w)),i2(s,w)):n&&n!==c?.id&&Tb(db.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),Cb.page(e.id,t)},E=async()=>{try{let n=await Y.addPage(e.id,t,t2);l(n),m(n.id),Cb.page(e.id,n.id)}catch(e){y(e)}},D=(e,n)=>{m(null);let r=n?.trim();r&&r!==e.title&&Y.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}),Y.movePage(n,t,r).catch(e=>{f(null),y(e)}))},k=async n=>{let r=n.canvas.blocks.length;if(await dz({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 Y.deletePage(n.id,t),n.id!==w)return;let i=b[r+1]??b[r-1];i&&g(i.id),Tb(i?db.page(e.id,i.id):db.board(e.id,`scratch`))}catch(e){y(e)}},A=_&&(0,X.jsx)(`p`,{className:`scratch-error error`,role:`alert`,children:_});return C?(0,X.jsxs)(`div`,{className:`scratch-pad`,children:[(0,X.jsx)(GX,{board:e,page:C,name:t,newItems:r,onSeeItem:a,lead:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($0,{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,X.jsx)(Z0,{page:C})]})},C.id),A]}):(0,X.jsxs)(`div`,{className:`scratch-pad`,children:[(0,X.jsxs)(`div`,{className:`scratch-empty`,children:[(0,X.jsx)(Q,{name:`canvas`}),(0,X.jsx)(`h2`,{children:`The sketchbook is empty`}),(0,X.jsx)(`p`,{children:`Start a page to sketch an idea out with agents.`}),!o&&(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:E,children:[(0,X.jsx)(Q,{name:`plus`}),` New page`]})]}),A]})}function o2(e){return e.add({id:`scratch`,label:`Sketchbook`,link:e=>db.board(e,`scratch`),tab:({board:e,away:t})=>({count:ao(e).length,changed:t.pagesChanged.size>0}),chat:()=>`threads`,render:({board:e,name:t,route:n,away:r})=>(0,X.jsx)(`section`,{className:`board-canvas`,"aria-label":`Sketchbook`,children:(0,X.jsx)(a2,{board:e,name:t,pageId:n.pageId,newItems:r.items,changed:r.pagesChanged,onSeeItem:r.markSeen})})}),e.add({id:`files`,link:e=>db.files(e),door:({board:e,shown:t})=>(0,X.jsx)(`a`,{className:`files-door${t===`files`?` is-active`:``}`,href:db.files(e.id),"aria-label":`Project files`,"aria-current":t===`files`?`page`:void 0,"aria-keyshortcuts":NZ(e)?bZ:void 0,title:NZ(e)?`Project files · ${NZ(e)} · ${yZ}`:`Project files · choose the project folder`,children:(0,X.jsx)(Q,{name:`folder`})}),chat:()=>`threads`,render:({board:e,name:t,route:n,onFile:r})=>(0,X.jsx)(FZ,{board:e,name:t,file:n.file,pair:n.pair,onShown:r})}),e}function s2(){let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),i=(0,d.useCallback)(()=>{Y.connectors().then(e=>{t(e),r(null)},e=>r(e.message))},[]);return(0,d.useEffect)(()=>{i(),window.addEventListener(`focus`,i);let e=qU(i);return()=>{window.removeEventListener(`focus`,i),e()}},[i]),{connectors:e,error:n,refresh:i,setConnectors:t}}var c2={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 l2({state:e}){let{label:t,tone:n}=c2[e];return(0,X.jsx)(`span`,{className:`status connector-state is-${n}`,children:t})}function u2({id:e}){let t=KK(e)?.Mark;return t?(0,X.jsx)(t,{}):(0,X.jsx)(`span`,{className:`connector-mark`,"aria-hidden":!0})}function d2({from:e}){let{connectors:t,error:n,refresh:r,setConnectors:i}=s2();EQ(`page`,`Connectors`);let[a,o]=(0,d.useState)();(0,d.useEffect)(()=>{e&&Y.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,X.jsxs)(`div`,{className:`page`,children:[(0,X.jsx)(q$,{}),(0,X.jsxs)(`main`,{className:`connectors`,children:[(0,X.jsxs)(`a`,{className:`connectors-back`,href:e?db.board(e):db.home(),children:[(0,X.jsx)(Q,{name:`arrow-left`}),` `,e?a?`Back to ${a}`:`Back to the board`:`All boards`]}),(0,X.jsxs)(`section`,{className:`connectors-intro`,children:[(0,X.jsx)(`h1`,{children:`Connectors`}),(0,X.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,X.jsx)(`p`,{className:`error`,children:n}),t===null?!n&&(0,X.jsx)(`p`,{className:`muted`,children:`Loading…`}):(0,X.jsx)(`div`,{className:`connector-list`,children:t.map(e=>(0,X.jsx)(p2,{connector:e,onChange:e=>i(t=>t?.map(t=>t.id===e.id?e:t)??null),refresh:r},e.id))})]})]})}var f2=6e5;function p2(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=qU(e=>{e.id===t.id&&(e.ok||(s(e.message??`The sign-in failed.`),a(null)))}),n=setInterval(()=>{Date.now()-i.since>f2?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 Y.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 Y.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=KK(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,X.jsxs)(`article`,{className:`connector-card is-${v}`,"aria-labelledby":`connector-${t.id}`,children:[(0,X.jsxs)(`header`,{className:`connector-head`,children:[(0,X.jsx)(u2,{id:t.id}),(0,X.jsxs)(`div`,{className:`connector-name`,children:[(0,X.jsx)(`h2`,{id:`connector-${t.id}`,children:t.name}),x?.serves&&(0,X.jsx)(`p`,{className:`muted small`,children:x.serves})]}),(0,X.jsx)(l2,{state:v})]}),y&&v!==`not_set_up`&&(0,X.jsxs)(`p`,{className:`connector-account`,children:[v===`connected`?`Connected as`:`Was connected as`,` `,(0,X.jsx)(`strong`,{children:y.email}),(0,X.jsxs)(`span`,{className:`faint connector-since`,children:[` · `,Yy(y.connectedAt)]})]}),v!==`not_set_up`&&t.clientSource&&(0,X.jsx)(`p`,{className:`faint small connector-client`,children:t.clientSource===`built-in`?(0,X.jsxs)(X.Fragment,{children:[`Signs in with Tricot's own `,t.name,` client: nothing to set up.`]}):(0,X.jsxs)(X.Fragment,{children:[`Signs in with your own client, from `,(0,X.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,X.jsx)(`p`,{className:`connector-note${v===`needs_sign_in`?` is-attention`:` is-error`}`,role:`status`,children:t.message}),(0,X.jsxs)(`section`,{className:`connector-section`,children:[(0,X.jsx)(`h3`,{children:v===`connected`?`What Tricot can use`:`What Tricot asks to use`}),(0,X.jsx)(`ul`,{className:`connector-access`,children:t.access.map(e=>(0,X.jsxs)(`li`,{className:e.granted===!1?`is-denied`:void 0,children:[(0,X.jsx)(Q,{name:e.granted===!1?`x`:`check`,className:`connector-access-icon`}),(0,X.jsxs)(`span`,{children:[e.label,e.granted===!1&&(0,X.jsx)(`span`,{className:`faint`,children:` · not allowed; connect again to allow it`})]})]},e.scope))}),(0,X.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,X.jsx)(`p`,{className:`connector-note is-attention`,role:`status`,children:t.notice})]}),v===`connected`&&x?.Panel&&(0,X.jsx)(x.Panel,{status:t}),x?.SignIn&&(v===`ready`||v===`needs_sign_in`)&&(0,X.jsx)(x.SignIn,{status:t,onChange:n}),v===`not_set_up`&&t.setup&&(0,X.jsxs)(`section`,{className:`connector-section`,children:[(0,X.jsxs)(`h3`,{children:[`Set up `,t.name,` once`]}),(0,X.jsx)(`p`,{className:`muted small`,children:x?.setup.intro}),(0,X.jsx)(`ol`,{className:`connector-steps`,children:t.setup.steps.map((e,n)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(m2,{text:e,folder:t.setup.folder,files:x?.setup.files??[]})},n))}),(0,X.jsx)(`p`,{className:`muted small`,children:`This page picks the file up on its own.`})]}),w&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:w}),c&&(0,X.jsx)(`p`,{className:`muted small`,children:c}),(0,X.jsx)(`footer`,{className:`connector-actions`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`connector-waiting`,role:`status`,children:[(0,X.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,X.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,X.jsx)(Q,{name:`external`})]}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,onClick:()=>a(null),children:`Cancel`})]}):u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`connector-confirm`,children:[`Disconnect `,t.name,`? Link cards go back to plain names, for every board.`]}),(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:p,onClick:_,children:`Disconnect`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-quiet`,disabled:p,onClick:()=>f(!1),children:`Cancel`})]}):(0,X.jsxs)(X.Fragment,{children:[v===`ready`&&!x?.SignIn&&(0,X.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>g(),children:[`Connect `,t.name]}),v===`needs_sign_in`&&!x?.SignIn&&(0,X.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>g(),children:`Connect again`}),v===`connected`&&t.notice&&(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>g(),children:`Connect again`}),v===`connected`&&S&&!C&&(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:()=>g([S.name]),title:S.title,children:S.button}),(v===`not_set_up`||v===`error`&&!y)&&(0,X.jsx)(`button`,{className:`btn btn-small`,onClick:r,children:`Check again`}),v===`ready`&&!x?.SignIn&&(0,X.jsxs)(`span`,{className:`faint small`,children:[`Opens `,t.name,` in a new tab.`]}),b&&(0,X.jsx)(`button`,{className:`btn ${v===`connected`?``:`btn-quiet `}btn-small`,onClick:()=>f(!0),children:`Disconnect`})]})})]})}function m2({text:e,folder:t,files:n}){let r=[t,...n],i=RegExp(`(${r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})`);return(0,X.jsx)(X.Fragment,{children:e.split(i).map((e,t)=>r.includes(e)?(0,X.jsx)(`code`,{children:e},t):e)})}var h2={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 g2(){let{connectors:e}=s2();return e?e.length===0?(0,X.jsx)(`a`,{className:`home-link`,href:db.connectors(),children:`Set up`}):(0,X.jsx)(X.Fragment,{children:e.map(e=>(0,X.jsxs)(`a`,{className:`home-link home-status`,href:db.connectors(),title:e.state===`connected`&&e.account?`Connected as ${e.account.email}`:`${c2[e.state].label}: open Connectors`,children:[(0,X.jsx)(`span`,{className:`sq sq-${h2[e.state].square}`,"aria-hidden":!0}),e.name,` `,h2[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}=tl(),d=e=>()=>{o(!1),e()};return(0,X.jsxs)(`div`,{className:`project-menu`,ref:s,children:[(0,X.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,X.jsx)(Q,{name:`more`})}),i&&(0,X.jsxs)(`div`,{className:`menu-panel project-menu-panel`,role:`menu`,"aria-label":e,ref:l,onKeyDown:u,children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,"aria-keyshortcuts":`R`,onClick:d(()=>n(`title`)),children:[`Rename…`,(0,X.jsx)(`kbd`,{"aria-hidden":!0,children:`R`})]}),(0,X.jsx)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,onClick:d(()=>n(`goal`)),children:As(t)}),(0,X.jsx)(`div`,{role:`separator`,className:`menu-rule`}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`menu-item is-line`,"aria-keyshortcuts":`A`,onClick:d(r),children:[`Archive`,(0,X.jsx)(`kbd`,{"aria-hidden":!0,children:`A`})]})]})]})}function v2({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,X.jsxs)(`form`,{className:`project-edit`,onSubmit:async n=>{if(n.preventDefault(),c)return;let a=ks(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 Ds(e.id,t,a.patch))}catch(e){f(e.message),l(!1)}}},onKeyDown:e=>{e.key!==`Escape`||c||(e.preventDefault(),r(null))},children:[(0,X.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:ES.boardTitle,readOnly:c,autoFocus:n===`title`}),(0,X.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:ES.goal,readOnly:c,autoFocus:n===`goal`}),u&&(0,X.jsx)(`p`,{className:`error project-edit-error`,role:`alert`,children:u}),(0,X.jsxs)(`div`,{className:`project-edit-actions`,children:[(0,X.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-small`,disabled:c,children:`Save`}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:c,onClick:()=>r(null),children:`Cancel`}),(0,X.jsx)(`span`,{className:`project-edit-hint`,children:`Old links keep working.`})]})]})}function y2(e,t){let[n,r]=(0,d.useState)(()=>new Set),[i,a]=(0,d.useState)(null);(0,d.useEffect)(()=>{t&&r(e=>Ms(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)),Os(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 “${p(t.title,48)}”: ${e.message}`})})},[e]),c=i&&`board`in i?i.board:null,l=(0,d.useCallback)(()=>{c&&(a(null),o(c.id),Os(c.id,e,!1).catch(e=>a({key:Date.now(),note:`Couldn’t bring “${p(c.title,48)}” back: ${e.message}`})))},[c,e]);return gX(!!c,l),{archive:s,held:n,toast:i&&(0,X.jsx)(`div`,{className:`home-toast`,children:(0,X.jsx)(_X,{text:`board`in i?`Archived “${p(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 b2(e){e?.contains(document.activeElement)&&(e.nextElementSibling??e.previousElementSibling)?.querySelector(`.project-link`)?.focus()}function x2({name:e}){let{boards:t,refresh:n}=Dw(),[r,i]=(0,d.useState)(!1),{report:a,error:o}=Tc(e),s=vb().home(),[c,l]=Vc(`tricot:show-archived`,()=>!1),{archive:u,held:f,toast:p}=y2(e,a?.projects),[m,h]=(0,d.useState)(null);rl(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=iw(),b=_w(),x=t!==null&&!!s?.firstRun?.shows(t,r);return(0,X.jsxs)(`div`,{className:`page`,children:[(0,X.jsx)(q$,{home:!0,right:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_1,{}),s?.controls({report:a,name:e}),(0,X.jsx)(`span`,{className:`topbar-sep`,"aria-hidden":!0})]})}),(0,X.jsxs)(`main`,{className:x?`home is-first-run`:`home`,children:[(0,X.jsx)(H$,{}),t===null||a===null?o?(0,X.jsxs)(`p`,{className:`error`,role:`alert`,children:[`Couldn't load your projects: `,o]}):(0,X.jsx)(`p`,{className:`home-loading`,role:`status`,children:`Loading your projects…`}):x?s?.firstRun?.render({name:e,agents:a.agents,onSending:i,onEveryWay:w2}):(0,X.jsxs)(X.Fragment,{children:[s?.headline?s.headline({report:a,name:e}):(0,X.jsx)(S2,{}),s?.needs({report:a,name:e}),(0,X.jsxs)(`section`,{className:`projects`,"aria-labelledby":`projects-title`,children:[(0,X.jsxs)(`div`,{className:`projects-head`,children:[(0,X.jsx)(`h2`,{id:`projects-title`,children:`Projects`}),(0,X.jsxs)(`span`,{className:`projects-count`,children:[_.length,` active`]}),(0,X.jsx)(T2,{name:e})]}),_.length===0?(0,X.jsx)(`p`,{className:`sheet projects-none`,children:`No projects in use. Create one, or unarchive one to pick it up again.`}):(0,X.jsx)(rw,{value:y,children:(0,X.jsx)(`ul`,{className:`sheet projects-list`,children:_.map(t=>(0,X.jsx)(E2,{project:t,name:e,onArchive:u,...v(t.id)},t.id))})})]})]}),(0,X.jsxs)(`footer`,{className:`home-foot`,children:[(0,X.jsxs)(`div`,{className:`home-foot-group`,children:[(0,X.jsx)(`span`,{className:`home-foot-label`,children:`Agents`}),a?.agents.map(e=>(0,X.jsxs)(`span`,{className:`home-agent is-${e.state}`,title:N2(e,b,M2(e,b(e))),children:[(0,X.jsx)(j2,{name:e.name}),e.name,` `,M2(e,b(e))]},e.name)),a&&a.agents.length===0&&(0,X.jsx)(`span`,{className:`home-foot-none`,children:`No agent connected`}),(0,X.jsxs)(tb,{className:`home-connect`,children:[(0,X.jsx)(`summary`,{className:`home-link`,children:a?.agents.length?`Connect another`:`Connect an agent`}),(0,X.jsx)(`div`,{className:`popover-body`,children:(0,X.jsx)(Bx,{})})]})]}),(0,X.jsxs)(`div`,{className:`home-foot-group`,children:[(0,X.jsx)(`span`,{className:`home-foot-label`,children:`Connectors`}),(0,X.jsx)(g2,{})]}),g.length>0&&(0,X.jsxs)(`button`,{className:`home-link home-archived-toggle`,"aria-expanded":c,onClick:()=>l(!c),children:[`Archived (`,g.length,`)`]}),(0,X.jsx)(C2,{})]}),c&&g.length>0&&(0,X.jsx)(`ul`,{className:`sheet projects-list projects-archived`,"aria-label":`Archived projects`,children:g.map(t=>(0,X.jsx)(D2,{board:t,name:e,onDeleted:n,...v(t.id)},t.id))}),p]})]})}function S2(){let e=lQ(DQ());return(0,X.jsxs)(`section`,{className:`home-head`,children:[(0,X.jsx)(`h1`,{children:`Your projects`}),e&&(0,X.jsx)(`p`,{className:`home-sub`,children:e})]})}function C2(){let[e,t]=(0,d.useState)();return(0,d.useEffect)(()=>{let e=!0;return Y.info().then(n=>e&&t(n),()=>{}),()=>{e=!1}},[]),!e?.version&&!e?.source?null:(0,X.jsxs)(`div`,{className:`home-foot-group home-foot-about`,children:[e.version&&(0,X.jsxs)(`span`,{children:[`Tricot `,e.version]}),e.source&&(0,X.jsx)(`a`,{className:`home-link`,href:e.source,target:`_blank`,rel:`noreferrer`,children:`Source`})]})}function w2(){let e=document.querySelector(`details.home-connect`);e&&(e.open=!0,e.querySelector(`summary`)?.focus())}function T2({name:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(null),[s]=(0,d.useState)(()=>Eb(ub.newBoard));return(0,d.useEffect)(()=>{s&&Db(ub.newBoard)},[s]),(0,X.jsxs)(`form`,{className:`new-project`,onSubmit:async n=>{if(n.preventDefault(),t.trim()&&!r){i(!0);try{let n=await Y.createBoard(e,t.trim(),``);Cb.board(n.id)}catch(e){o(e.message),i(!1)}}},children:[(0,X.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,X.jsxs)(`button`,{className:`btn btn-primary`,disabled:!t.trim()||r,children:[(0,X.jsx)(Q,{name:`plus`}),`Create`]}),a&&(0,X.jsx)(`p`,{className:`error new-project-error`,role:`alert`,children:a})]})}function E2({project:e,name:t,onArchive:n,focus:r,onFocus:i,onFocused:a}){let o=vb().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]),il(f,r,`.project-menu-button`,a);let{title:p,goal:m}=l??e;return(0,X.jsxs)(`li`,{className:`project${o?.projectWork?``:` is-plain`}${s?` is-editing`:``}`,ref:f,children:[(0,X.jsx)(`div`,{className:`project-name`,children:s?(0,X.jsx)(v2,{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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`h3`,{className:`project-title`,children:[(0,X.jsx)(`a`,{className:`project-link`,href:db.board(e.id),children:p}),o?.projectTag?.({project:e})]}),m&&(0,X.jsx)(`p`,{className:`project-goal`,title:m,children:m})]})}),o?.projectWork&&(0,X.jsx)(`div`,{className:`project-work`,children:o.projectWork({project:e})}),(0,X.jsx)(O2,{project:e}),(0,X.jsx)(`time`,{className:`project-when`,dateTime:e.updatedAt,title:`Last change ${new Date(e.updatedAt).toLocaleString()}`,children:Yy(e.updatedAt)}),s?(0,X.jsx)(`span`,{"aria-hidden":!0}):(0,X.jsx)(_2,{title:p,hasGoal:!!m,onEdit:c,onArchive:()=>{b2(f.current),n({...e,title:p})}})]})}function D2({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]),il(_,r,`.project-rename`,a);let{title:v,goal:y}=u??e;return(0,X.jsxs)(`li`,{className:`project is-archived${c?` is-editing`:``}`,ref:_,children:[(0,X.jsxs)(`div`,{className:`project-name`,children:[c?(0,X.jsx)(v2,{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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`project-title`,children:(0,X.jsx)(`a`,{className:`project-link`,href:db.board(e.id),children:v})}),y&&(0,X.jsx)(`p`,{className:`project-goal`,children:y})]}),h&&(0,X.jsx)(`p`,{className:`error project-row-error`,role:`alert`,children:h})]}),(0,X.jsxs)(`div`,{className:`project-archived-side`,children:[(0,X.jsxs)(`time`,{className:`project-when`,dateTime:e.updatedAt,children:[`archived `,Yy(e.updatedAt)]}),!c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`btn btn-small`,disabled:p,onClick:()=>{m(!0),g(null),Os(e.id,t,!1).then(()=>b2(_.current),e=>{g(e.message),m(!1)})},"aria-label":`Restore ${v}`,children:`Restore`}),(0,X.jsx)(`button`,{className:`btn btn-small project-rename`,disabled:p,onClick:()=>l(!0),"aria-label":`Rename ${v}`,children:`Rename…`}),(0,X.jsx)(`button`,{className:`btn btn-small btn-delete`,disabled:p,onClick:()=>s(!0),"aria-label":`Delete ${v}`,children:`Delete…`})]})]}),o&&(0,X.jsx)(QZ,{board:{...e,title:v},name:t,onClose:()=>s(!1),onDeleted:()=>{s(!1),n()}})]})}function O2({project:e}){let t=gw(e),n=k2(e),r=ow(cw(e.id),Date.now()),i=_w(),a=t&&`now`in t?t.others:0;if(n){let t=e=>`${QC(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)}`:N2(e,i)});return e.agents.some(e=>m(e.name,n.step.agent))||o.unshift(`${n.step.agent}: ${t(n.step)}`),(0,X.jsxs)(A2,{className:`project-agent is-working has-step${n.phase===`dim`?` is-dim`:``}`,title:o.join(`
|
|
104
|
-
`),name:n.step.agent,busy:ZC(n.phase),after:a>0&&(0,X.jsxs)(`span`,{className:`project-agent-more`,children:[`+`,a]}),children:[(0,X.jsxs)(`span`,{className:`step-sr`,children:[n.step.agent,`: `]}),(0,X.jsx)($C,{text:t(n.step),className:`project-agent-step`},n.step.at)]})}if(t&&`now`in t)return(0,X.jsxs)(A2,{className:`project-agent is-${t.now.state}`,title:e.agents.map(e=>N2(e,i)).join(`
|
|
105
|
-
`),name:t.now.name,busy:t.now.state===`working`?`casting`:`resting`,children:[t.now.name,` `,vw(t.now,i(t.now)),a>0&&(0,X.jsxs)(`span`,{className:`project-agent-more`,children:[` +`,a]})]});if(!t)return(0,X.jsx)(`span`,{className:`project-agent is-none`,children:`No agent connected`});let{last:o}=t;return(0,X.jsxs)(`span`,{className:`project-agent`,title:`${o.name} last worked on it ${new Date(o.at).toLocaleString()}`,children:[(0,X.jsx)(j2,{name:o.name}),(0,X.jsxs)(`span`,{className:`project-agent-text`,children:[o.name,`, `,Xy(o.at)]})]})}function k2(e){let t=cw(e.id),n=sw(e.agents.map(e=>e.name),t,Date.now()),r=ew(n),i=n&&UC(n,r);return n&&i?{step:n,phase:i}:void 0}function A2({className:e,title:t,name:n,busy:r,after:i,children:a}){return(0,X.jsxs)(`span`,{className:e,title:t,children:[(0,X.jsx)(j2,{name:n}),(0,X.jsx)(`span`,{className:`project-agent-text`,children:a}),(0,X.jsx)(fw,{state:r}),i]})}function j2({name:e}){return(0,X.jsx)(`span`,{className:`actor actor-agent`,"aria-hidden":!0,children:(0,X.jsx)(`span`,{className:`actor-mark`,children:e.charAt(0).toUpperCase()})})}function M2(e,t){return!e.board&&e.state===`working`?`connected`:vw(e,t)}function N2(e,t,n=vw(e,t(e))){let r=t(e),i=r&&e.onTitle?` (${r} ${e.onTitle})`:``;return`${e.name} ${n}${i}, last checked ${Yy(e.lastSeen)}`}function P2({name:e}){let t=xb();return OQ(t.page!==`board`&&t.page!==`home`),t.page===`board`?(0,X.jsx)(X0,{route:t,name:e}):t.page===`connectors`?(0,X.jsx)(d2,{from:t.from}):(0,X.jsx)(x2,{name:e})}function F2(){let e=o2(new mb);return e.withHeaderControls(({board:e,name:t})=>(0,X.jsx)(q0,{board:e,name:t})),e}function I2(){let[e]=(0,d.useState)(()=>new nc),[t]=(0,d.useState)(F2);return(0,X.jsx)(Mc,{kinds:e,children:(0,X.jsx)(_b,{views:t,children:(0,X.jsx)($Q,{children:e=>(0,X.jsx)(P2,{name:e})})})})}(0,f.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(d.StrictMode,{children:(0,X.jsx)(I2,{})}));export{BO as a,yO as c,PD as d,Dr as f,RO as i,XD as l,$O as n,QD as o,Or as p,KO as r,xO as s,cU as t,ZD as u};
|